@arcgis/map-components
Version:
ArcGIS Map Components
561 lines (560 loc) • 36 kB
JavaScript
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
import { c as he } from "../../chunks/runtime.js";
import { watch as ge, when as ue, whenOnce as pe } from "@arcgis/core/core/reactiveUtils.js";
import * as me from "@arcgis/core/intl.js";
import fe from "@arcgis/core/views/3d/environment/SunLighting.js";
import _e from "@arcgis/core/views/3d/environment/VirtualLighting.js";
import { LitElement as be, createEvent as B, safeStyleMap as V, nothing as R } from "@arcgis/lumina";
import { css as ve, html as m } from "lit";
import { createRef as q, ref as G } from "lit/directives/ref.js";
import { u as we } from "../../chunks/useT9n.js";
import { u as ye } from "../../chunks/useView.js";
import { t as Y } from "../../chunks/earth-utils.js";
import { m as N } from "../../chunks/handle.js";
import { o as C, i as p, l as Z, b as D, d as W, g as xe } from "../../chunks/time-utils.js";
import { r as Se, b as De, d as Te } from "../../chunks/async-utils.js";
import { createTrackingTarget as ke, runTracked as K, signal as Pe } from "@arcgis/core/applications/Components/reactiveUtils.js";
import { C as Q } from "../../chunks/component-wrapper.js";
import { V as T } from "../../chunks/visible-element.js";
function ne(r, e) {
return (r % e + e) % e;
}
class Ce {
#e;
#i;
#r = ke(() => {
this.#t();
});
constructor(e) {
this.#i = e;
let t;
K(this.#r, () => {
t = e();
}), this.#e = Pe(t);
}
#t() {
const e = this.#e.value;
K(this.#r, () => {
this.#e.value = this.#i(e);
});
}
mutate(e) {
this.#e.value = e;
}
get value() {
return this.#e.value;
}
}
function A(r) {
return new Ce(r);
}
var L = Math.PI, u = Math.sin, k = Math.cos, $e = Math.asin, ze = Math.acos, y = L / 180, ae = 1e3 * 60 * 60 * 24, oe = 2440588, le = 2451545;
function Oe(r) {
return r.valueOf() / ae - 0.5 + oe;
}
function O(r) {
return new Date((r + 0.5 - oe) * ae);
}
function Ue(r) {
return Oe(r) - le;
}
var X = y * 23.4397;
function Me(r, e) {
return $e(u(e) * k(X) + k(e) * u(X) * u(r));
}
function Le(r) {
return y * (357.5291 + 0.98560028 * r);
}
function Ee(r) {
return y * (1.9148 * u(r) + 0.02 * u(2 * r) + 3e-4 * u(3 * r));
}
function He(r, e) {
var t = y * 102.9372;
return r + e + t + L;
}
var S = {};
S.PolarException = {
NORMAL: 0,
MIDNIGHT_SUN: 1,
POLAR_NIGHT: 2
};
var I = [
[-0.83, "sunrise", "sunset"]
// none of the below are currently used -> disabled to avoid unnecessary calculations,
// as all elements of 'times' are evaluated on every sunCalc.getTimes call.
/*,
[ -0.3, "sunriseEnd", "sunsetStart" ],
[ -6, "dawn", "dusk" ],
[ -12, "nauticalDawn", "nauticalDusk"],
[ -18, "nightEnd", "night" ],
[ 6, "goldenHourEnd", "goldenHour" ]
*/
], ce = 9e-4;
function Ae(r, e) {
return Math.round(r - ce - e / (2 * L));
}
function ee(r, e, t) {
return ce + (r + e) / (2 * L) + t;
}
function te(r, e, t) {
return le + r + 53e-4 * u(e) - 69e-4 * u(2 * t);
}
function Ie(r, e, t) {
return ze((u(r) - u(e) * u(t)) / (k(e) * k(t)));
}
S.getTimes = function(r, e, t) {
var i = y * -t, s = y * e, n = Ue(r), a = Ae(n, i), o = ee(0, i, a), c = Le(o), d = Ee(c), l = He(c, d), h = Me(l, 0), g = te(o, c, l);
function w(H) {
var z = Ie(H, s, h), de = ee(z, i, a);
return te(de, c, l);
}
function x(H) {
var z = (u(H) - u(s) * u(h)) / (k(s) * k(h));
return z < -1 ? S.PolarException.MIDNIGHT_SUN : z > 1 ? S.PolarException.POLAR_NIGHT : S.PolarException.NORMAL;
}
var _ = {
solarNoon: O(g),
nadir: O(g - 0.5),
polarException: S.PolarException.NORMAL
}, b, f, $, E, j;
for (b = 0, f = I.length; b < f; b += 1)
$ = I[b], E = w($[0] * y), j = g - (E - g), _[$[1]] = O(j), _[$[2]] = O(E);
return _.polarException = x(I[0][0] * y), _;
};
const Ne = {
spring: { dayOfMonth: 20, month: 2 },
// Northern Spring equinox in 2014 - March 20
summer: { dayOfMonth: 21, month: 5 },
// Northern Summer solstice in 2014 - June 21
fall: { dayOfMonth: 23, month: 8 },
// Northern Fall equinox in 2014 - September 23
winter: { dayOfMonth: 21, month: 11 }
// Northern Winter solstice in 2014 - December 21
}, J = ["spring", "summer", "fall", "winter"];
function P(r, e, t) {
const i = F(e, t), { dayOfMonth: s, month: n } = Ne[i], a = new Date(r.getTime());
return a.setMonth(n, s), a;
}
function Je(r, e) {
const t = Re(r);
return F(t, e);
}
function Re(r) {
const e = r.getTime(), t = P(r, "spring", "northern").getTime(), i = P(r, "summer", "northern").getTime(), s = P(r, "fall", "northern").getTime(), n = P(r, "winter", "northern").getTime();
return e >= t && e < i ? "spring" : e >= i && e < s ? "summer" : e >= s && e < n ? "fall" : "winter";
}
function F(r, e) {
return e === "northern" ? r : Fe(r);
}
function ie(r) {
return r >= 0 ? "northern" : "southern";
}
function Fe(r) {
const e = J.indexOf(r);
return J[(e + 2) % 4];
}
const je = 1440, Be = 864e5;
function Ve(r, e, t, i) {
const s = S.getTimes(r, e, t), n = s.sunrise, a = s.sunset, o = C(r, i), c = C(n, i), d = C(a, i);
if (o.getUTCDate() !== c.getUTCDate() || o.getUTCDate() !== d.getUTCDate()) {
const l = o.getTime() - c.getTime() > 0 ? 1 : -1;
n.setUTCDate(n.getUTCDate() + l), a.setUTCDate(a.getUTCDate() + l);
}
return {
sunrise: n,
sunset: a
};
}
const qe = 100, Ge = 1e3, v = 12e5, U = 72e5;
function re(r, e) {
return ne(r + e, 24);
}
function Ye({
mode: r,
lighting: e,
getPlaySpeed: t,
onProgress: i,
beforeProgress: s
}) {
let n = -1;
function a(o = Date.now()) {
const c = e.date, d = Date.now() - (o ?? 0);
if (r === "day") {
o = Date.now();
const h = t() / qe * d;
if (h > 0) {
let g = new Date(c.getTime() + h);
const w = e.displayUTCOffset ?? 0, x = re(g.getUTCHours(), w), _ = re(c.getUTCHours(), w);
x < _ && (g = new Date(c.getTime() + h - Be));
const b = e.clone();
s?.(), e.date = g, i?.(b, e);
}
} else if (d > Ge) {
o = Date.now();
const l = (c.getUTCMonth() + 1) % 12, h = new Date(c.getTime());
h.setUTCMonth(l);
const g = e.clone();
s?.(), e.date = h, i?.(g, e);
}
n = requestAnimationFrame(() => a(o));
}
return a(), N(() => cancelAnimationFrame(n));
}
const M = v / 4;
function Ze(r, e, t, i) {
const {
day: s,
night: n = s,
twilight: a = s
} = i, o = s * M, c = n * M, d = a * M;
if (r == null || e == null || Number.isNaN(r.getTime()) && Number.isNaN(e.getTime()))
return o;
const l = t.getTime(), h = r.getTime(), g = e.getTime(), w = h - U / 2, x = h + U / 2, _ = g - U / 3 * 2, b = g + U / 3;
let f = o;
return l >= w && l <= x ? l - w <= v ? f = c - (l - w) / v * (c - d) : x - l <= v / 2 ? f = o - (x - l) / v * 2 * (o - d) : f = d : l >= _ && l <= b ? l - _ <= v / 2 ? f = o - (l - _) / v * 2 * (o - d) : b - l <= v ? f = c - (b - l) / v * (c - d) : f = d : (l < h || l > g) && (f = c), f;
}
const We = ve`.esri-widget__heading{color:var(--calcite-color-text-2);margin:0 0 .5rem;font-weight:var(--calcite-font-weight-semibold)}h1.esri-widget__heading{font-size:var(--calcite-font-size-xl)}h2.esri-widget__heading{font-size:var(--calcite-font-size-md)}h3.esri-widget__heading,h4.esri-widget__heading,h5.esri-widget__heading,h6.esri-widget__heading{font-size:var(--calcite-font-size)}.esri-widget{box-sizing:border-box;color:var(--calcite-color-text-2);background-color:var(--calcite-color-foreground-1);font-size:var(--calcite-font-size);line-height:var(--calcite-font-line-height-relative-tight)}.esri-widget *,.esri-widget :before,.esri-widget :after{box-sizing:inherit}.esri-widget.esri-widget--disabled>*{opacity:.4;pointer-events:none}.esri-widget.esri-widget--compact{--esri-widget-padding-y: 0;--esri-widget-padding-x: 0}.esri-widget__anchor{color:var(--calcite-color-text-2)}.esri-widget__anchor:hover{color:var(--calcite-color-text-3)}.esri-widget__anchor:hover,.esri-widget__anchor:focus{text-decoration:underline}.esri-widget__anchor--disabled{opacity:.4;pointer-events:none}.esri-widget__header{background-color:var(--calcite-color-foreground-1);flex:1 0 100%;justify-content:space-between;align-items:center;width:100%;min-height:48px;padding:12px 0 12px 15px;display:flex}.esri-widget__heading{word-break:break-word}.esri-widget__header .esri-widget__heading{width:calc(100% - 48px);text-align:initial;color:var(--calcite-color-text-1);align-items:center;margin:0;padding:0;display:flex}.esri-widget__header-button{appearance:none;cursor:pointer;color:var(--calcite-color-text-2);background-color:var(--calcite-color-foreground-1);border:none;flex:0 0 48px;justify-content:center;align-self:stretch;align-items:center;width:48px;padding:0;display:flex}.esri-widget__footer{background-color:var(--calcite-color-foreground-1);justify-content:center;align-items:center;width:100%;min-height:48px;display:flex}.esri-widget__footer-pagination{color:var(--calcite-color-text-2);justify-content:space-between;align-items:center;display:flex}.esri-widget__footer-pagination-previous-button,.esri-widget__footer-pagination-next-button{cursor:pointer;background-color:var(--calcite-color-foreground-1);border:0;margin:0 7px;padding:12px 15px;transition:background-color .125s ease-in-out}.esri-widget__footer-pagination-previous-button:hover,.esri-widget__footer-pagination-previous-button:focus,.esri-widget__footer-pagination-next-button:hover,.esri-widget__footer-pagination-next-button:focus{color:var(--calcite-color-text-1);background-color:var(--calcite-color-foreground-1)}.esri-menu{visibility:hidden;z-index:1;background-clip:padding;background-color:var(--calcite-color-foreground-1);background-clip:padding-box;width:100%;max-height:0;margin:2px 0 0;padding:0;font-size:var(--calcite-font-size);line-height:var(--calcite-spacing-xl);position:absolute;top:100%;left:0;overflow:hidden;box-shadow:0 1px 2px #0000004d}.esri-menu .esri-menu__header{color:var(--calcite-color-text-inverse);background-color:var(--calcite-color-inverse);padding:6px 12px}.esri-menu__list{margin:0;padding:0;list-style:none}.esri-menu__list-item{cursor:pointer;border-top:1px solid #adadad4d;border-left:3px solid #0000;padding:.8em 1em}.esri-menu__list-item [class^=esri-icon-],.esri-menu__list-item [class*=" esri-icon-"]{padding-right:2.8px}.esri-menu__list-item:first-child{border-top:none}.esri-menu__list-item--focus,.esri-menu__list-item:hover,.esri-menu__list-item:focus{background-color:var(--calcite-color-foreground-1)}.esri-menu__list-item:active{background-color:var(--calcite-color-foreground-current)}.esri-menu__list-item--active,.esri-menu__list-item--active:hover,.esri-menu__list-item--active:focus{background-color:var(--calcite-color-foreground-1);border-left-color:var(--calcite-color-brand)}.esri-widget__table{border-collapse:collapse;color:var(--calcite-color-text-1);border:none;width:100%;line-height:var(--calcite-font-line-height-relative-tight)}.esri-widget__table tr:nth-child(odd){background-color:var(--calcite-color-transparent)}.esri-widget__table tr:nth-child(2n){background-color:var(--calcite-color-transparent-press)}.esri-widget__table tr a{color:var(--calcite-color-text-2)}.esri-widget__table tr a:hover,.esri-widget__table tr a:focus{color:var(--calcite-color-text-1)}.esri-widget__table tr td,.esri-widget__table tr th{vertical-align:top;word-break:break-word;padding:.5em .7em;font-size:var(--calcite-font-size-sm);font-weight:var(--calcite-font-weight-regular)}.esri-widget__table tr th{text-align:left;border-right:3px solid #0000000d;width:50%}.esri-widget__table tr td{width:50%}.esri-input{color:var(--calcite-color-text-1);background-color:var(--calcite-color-foreground-1);border:1px solid #959595;font-size:var(--calcite-font-size)}.esri-input::-ms-clear{display:none}.esri-input::placeholder{opacity:1;color:var(--calcite-color-text-2)}.esri-input:placeholder-shown{text-overflow:ellipsis}.esri-input[type=text],.esri-input[type=password],.esri-input[type=number]{height:32px;padding:0 .5em}calcite-combobox.esri-input{border:none}.esri-widget__content--empty{text-align:center;color:var(--calcite-color-border-input);flex-flow:column wrap;align-items:center;padding:18px 22px;display:flex}.esri-widget__content--empty h1.esri-widget__heading,.esri-widget__content--empty h2.esri-widget__heading,.esri-widget__content--empty h3.esri-widget__heading,.esri-widget__content--empty h4.esri-widget__heading,.esri-widget__content--empty h5.esri-widget__heading{font-weight:var(--calcite-font-weight-regular)}.esri-widget__content-illustration--empty{width:128px;padding:1rem 0}.esri-widget__content-icon--empty{width:32px;padding:.5rem 0}.esri-select{appearance:none;cursor:pointer;color:var(--calcite-color-text-2);background:var(--calcite-color-foreground-1) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='-8 -8 32 32' width='32' height='32'%3E%3Cpath d='M8 11.207l-4-4V5.793l4 4 4-4v1.414z' fill='%23adadad' fillrule='nonzero'/%3E%3C/svg%3E") 100% no-repeat;border:1px solid #959595;border-radius:0;width:100%;height:32px;margin:0;padding:0 .5em;font-family:inherit;font-size:.85em;display:block}.esri-select[disabled]{cursor:auto}.esri-select::-ms-expand{display:none}.esri-disabled a,.esri-disabled [role=menu],.esri-disabled [role=checkbox],.esri-disabled [class^=esri-icon-],.esri-disabled [class*=" esri-icon-"]{color:var(--calcite-color-text-3)}.keynav-mode .esri-widget:focus,.keynav-mode .esri-widget :focus{z-index:1;outline-offset:2px;outline:2px solid #adadad}.esri-widget__loader-animation{border:.15em solid #adadad4d;border-top-color:var(--calcite-color-border-input);border-radius:100%;width:1em;height:1em;font-size:var(--calcite-font-size-md);animation:1.25s linear infinite esri-rotate;display:block;transform:translateZ(0)}:dir(rtl) .esri-widget__table th{text-align:right;border-left:3px solid #0000000d;border-right:none}:dir(rtl) .esri-select{background-position:0}:dir(rtl) .esri-menu__list-item{border-left:none;border-right:3px solid #0000}:dir(rtl) .esri-menu__list-item [class^=esri-icon-],:dir(rtl) .esri-menu__list-item [class*=" esri-icon-"]{padding-left:2px;padding-right:0}:dir(rtl) .esri-menu__list-item--active{border-right-color:var(--calcite-color-brand)}.esri-icon-font-fallback-text{clip:rect(0 0 0 0);width:1px;height:1px;position:absolute;overflow:hidden}.esri-rotating{animation:1.25s linear infinite esri-rotate;transform:translateZ(0)}.esri-clearfix:before,.esri-clearfix:after{content:" ";display:table}.esri-clearfix:after{clear:both}.esri-interactive{cursor:pointer}.esri-hidden{display:none!important}.esri-invisible{visibility:hidden!important}.esri-offscreen{position:absolute;top:-999em;left:-999em}.esri-match-height{flex-direction:column;flex:auto;display:flex;overflow:hidden} (-ms-ime-align: auto){.esri-slider__anchor:focus{outline:1px dotted var(--calcite-color-foreground-current)}}.esri-slider{-webkit-user-select:none;user-select:none;direction:ltr;width:100%;height:100%;display:flex}.esri-disabled{pointer-events:none}.esri-disabled .esri-slider__content,.esri-disabled .esri-slider__min,.esri-disabled .esri-slider__max{opacity:var(--calcite-opacity-light)}.esri-slider--reversed.esri-slider--horizontal{flex-direction:row-reverse}.esri-slider--reversed.esri-slider--vertical{flex-direction:column}.esri-slider--horizontal{flex-direction:row}.esri-slider--horizontal .esri-slider__content{height:auto}.esri-slider--horizontal .esri-slider__track{width:100%;height:2px}.esri-slider--horizontal .esri-slider__segment--interactive:hover{cursor:ew-resize}.esri-slider--horizontal .esri-slider__anchor{width:1px;height:100%}.esri-slider--horizontal .esri-slider__label{text-align:center;margin:0 11px;top:-30px;left:-50px}.esri-slider--horizontal .esri-slider__label-input{text-align:center}.esri-slider--horizontal .esri-slider__max,.esri-slider--horizontal .esri-slider__min{flex:none;width:50px;height:auto;margin:auto}.esri-slider--horizontal .esri-slider__ticks{width:100%;margin:9px 0 0;top:100%;left:0}.esri-slider--horizontal .esri-slider__tick{width:1px;height:5px}.esri-slider--horizontal .esri-slider__tick-label{margin-top:18px}.esri-slider--vertical{flex-direction:column-reverse}.esri-slider--vertical .esri-slider__content{flex-direction:column;width:auto}.esri-slider--vertical .esri-slider__track{flex-direction:column;flex:1 0 0;width:2px;height:100%}.esri-slider--vertical .esri-slider__segment--interactive:hover{cursor:ns-resize}.esri-slider--vertical .esri-slider__anchor{width:100%;height:1px}.esri-slider--vertical .esri-slider__label{text-align:left;top:-10px;left:20px}.esri-slider--vertical .esri-slider__max,.esri-slider--vertical .esri-slider__min{flex:0 0 22px;width:100%;margin:auto}.esri-slider--vertical .esri-slider__ticks{margin:0 0 0 11px;top:0;left:100%}.esri-slider--vertical .esri-slider__tick{width:5px;height:1px}.esri-slider--vertical .esri-slider__tick-label{margin-left:30px}.esri-slider__content{z-index:0;flex:1 0 auto;justify-content:center;align-items:center;margin:auto;line-height:0;display:flex;position:relative}.esri-slider__track{touch-action:none;background-color:var(--calcite-color-border-ghost);display:inline-block;position:relative}.esri-slider__segment{transform-origin:0 0;will-change:transform;touch-action:none;width:100%;height:100%;position:absolute;top:0;left:0}.esri-slider__segment:hover{cursor:pointer}.esri-slider__anchor{touch-action:none;-webkit-user-select:none;user-select:none;background-color:var(--calcite-color-brand);position:absolute}.esri-slider__anchor:focus .esri-slider__thumb,.esri-slider__anchor:focus .esri-slider__label{outline:inherit}.esri-slider__anchor--moving:focus .esri-slider__thumb{cursor:grabbing;border:3px solid var(--calcite-color-brand-press)}.esri-slider__anchor--moving .esri-slider__label:hover,.esri-slider__anchor--moving .esri-slider__label--interactive:hover{cursor:grabbing}.esri-slider__thumb{box-sizing:border-box;z-index:1;touch-action:none;background-color:var(--calcite-color-foreground-2);border:2px solid var(--calcite-color-brand);border-radius:16px;width:16px;height:16px;transition:all .125s ease-in-out;position:absolute;top:-7px;left:-7px}.esri-slider__thumb:hover{cursor:grab;border-width:3px;border-color:var(--calcite-color-brand-press);width:19.2px;height:19.2px;top:-8.6px;left:-8.6px}.esri-slider__label{min-width:80px;line-height:var(--calcite-font-line-height-fixed-xl);position:absolute}.esri-slider__label:hover{cursor:grab}.esri-slider__label--interactive:hover,.esri-slider__max--interactive:hover,.esri-slider__min--interactive:hover{cursor:pointer;text-decoration:underline}.esri-slider__label-input{z-index:1;width:100%;position:relative}.esri-slider__extra-content{display:inline-block}.esri-slider__max,.esri-slider__min{text-align:center;justify-content:center;align-items:center;height:22px;line-height:var(--calcite-font-line-height-fixed-xl);display:flex}.esri-slider__max--interactive:hover,.esri-slider__min--interactive:hover{background-color:var(--calcite-color-foreground-2)}.esri-slider__range-input{text-align:center;width:100%;padding:1px 0}.esri-slider__ticks{z-index:0;height:100%;display:inline-block;position:absolute}.esri-slider__tick{background:var(--calcite-color-foreground-1);position:absolute}.esri-slider__tick-label{width:max-content;position:absolute}:dir(rtl) .esri-slider__label,:dir(rtl) .esri-slider__max,:dir(rtl) .esri-slider__min,:dir(rtl) .esri-slider__tick-label{direction:rtl;unicode-bidi:plaintext}:dir(rtl) .esri-slider__range-input,:dir(rtl) .esri-slider__label-input{unicode-bidi:plaintext}:host{width:350px}.root{display:flex;flex-direction:column;overflow:visible;gap:var(--calcite-spacing-md);justify-content:space-between;padding:var(--arcgis-internal-padding);position:relative;calcite-label{--calcite-label-margin-bottom: 0}&.loading>*:not(calcite-scrim){opacity:0}}.unsupported{padding:0 var(--calcite-spacing-lg);animation:esri-fade-in .25s ease-in-out}.slider{margin-block-start:0rem}.time-configuration{--date-play-button-offset: 11px;--slider-play-button-offset: var(--calcite-spacing-md);display:grid;gap:var(--calcite-spacing-md);grid-template-columns:1fr min-content;.slider-container{grid-column:1;+calcite-button{grid-column:2;transform:translateY(var(--slider-play-button-offset))}}.timezone-input-container{grid-column:1;min-width:0;+span{grid-column:2}}.date-picker-container{grid-column:1;+calcite-button{grid-column:2;transform:translateY(var(--date-play-button-offset))}}calcite-button{place-self:center}}`, Ke = {
day: 1,
night: 6,
twilight: 2 / 3
};
class Qe extends be {
constructor() {
super(...arguments), this.messages = we({ blocking: !0 }), this.#i = "none", this.#r = null, this.#l = q(), this.#g = q(), this.#u = 200, this.#p = 200, this.#c = !1, this.#a = {}, this._offset = A((e) => {
const t = this._lighting, i = p(t) ? t.displayUTCOffset : void 0;
return this.#t ? e : i ?? e;
}), this._timesliderPosition = A((e) => {
const t = this._lighting;
if (!p(t))
return e;
const i = t.displayUTCOffset ?? this.utcOffset ?? 0, s = t.date;
if (this.#t)
return e;
if (W(s)) {
const { minutesSinceMidnight: n } = D(s, i);
return n;
}
return e;
}), this._localDate = A((e) => {
const t = xe(this._view, this.utcOffset);
return this.#t ? e : t ?? e;
}), this.view = ye(this), this.autoDestroyDisabled = !1, this.dateOrSeason = "date", this.headingLevel = 2, this.hideDatePicker = !1, this.hideHeader = !1, this.hidePlayButtons = !1, this.hideShadowsToggle = !1, this.hideSunLightingToggle = !1, this.hideTimezone = !1, this.icon = "brightness", this.playSpeedMultiplier = 1, this.timeSliderSteps = 5, this.arcgisReady = B(), this.arcgisUserDateTimeChange = B(), this.#o = !1;
}
static {
this.properties = { localDateAsString: 32, view: 0, _playingState: 16, _sunlightingDisabled: 16, autoDestroyDisabled: 5, currentSeason: 1, dateOrSeason: 3, dayPlaying: 5, _directShadowsDisabled: 16, headingLevel: 9, hideDatePicker: 5, hideHeader: 5, hidePlayButtons: 5, hideShadowsToggle: 5, hideSunLightingToggle: 5, hideTimezone: 5, icon: 3, label: 1, playSpeedMultiplier: 9, referenceElement: 1, timeSliderSteps: 9, utcOffset: 9, timeSliderPosition: 9, localDate: 1, yearPlaying: 5 };
}
static {
this.styles = We;
}
get _view() {
return this.view?.type === "3d" ? this.view : void 0;
}
#e;
#i;
#r;
#t;
#l;
#g;
#u;
#p;
#c;
#s(e, t) {
return this.#o || this.#c ? !1 : (this.#a[e] = t, !0);
}
#m() {
const { utcOffset: e, timeSliderPosition: t, localDate: i, directShadowsDisabled: s, sunlightingDisabled: n } = this.#a;
if (this.#c = !0, e != null)
if (t == null && i == null) {
const a = this._lighting;
p(a) ? (a.displayUTCOffset = e, this.#h(e, a)) : this._offset.mutate(e);
} else
this.utcOffset = e;
t != null && (this.timeSliderPosition = t), i && (this.localDate = i), s != null && (this._directShadowsDisabled = s), n != null && (this._sunlightingDisabled = n), this.#a = {}, this.#c = !1;
}
#d() {
if (this.requestUpdate(), this.#t)
return;
const e = Se(() => {
if (p(this._lighting)) {
const t = this.utcOffset ?? 0, i = this.timeSliderPosition ?? 0, s = this.localDate;
this._lighting.date = Z(s, i, t), this._lighting.displayUTCOffset = t;
}
this.#t?.remove();
}, { timeout: this.#u });
this.#t = N(() => {
Te(e), this.#t = void 0;
});
}
#f(e) {
const t = this.utcOffset ?? e.displayUTCOffset ?? 0, { minutesSinceMidnight: i, localDate: s } = D(e.date, t), n = this.timeSliderPosition ?? i, a = this.localDateAsString ?? s;
this.#t?.remove(), e.date = Z(a, n, t), e.displayUTCOffset = t;
}
#_({ scale: e, disabled: t }) {
const { messages: i } = this;
return m`<calcite-label .scale=${e} class="date-picker-container">${i.date}${Xe({ disabled: t, scale: e, date: this.localDateAsString, onDateChange: (s) => {
const n = s.currentTarget.value, a = Array.isArray(n) ? n[0] : n;
this._stopPlaying(), this.localDate = a, this._emitUserDateTimeChangeEvent();
} })}</calcite-label>${T({ hidden: this.hidePlayButtons, children: se({ playing: this.yearPlaying, disabled: t, label: i.playYear, onClick: () => {
this._playingState === "year" ? this._playingState = "none" : this._playingState = "year";
}, scale: e }) })}`;
}
#b({ scale: e, disabled: t }) {
const { messages: i } = this;
return m`<calcite-label .scale=${e} class="date-picker-container">${i.season}${et({ scale: e, selectedSeason: this.currentSeason, disabled: t, messages: i, onSeasonChange: (s) => {
this._stopPlaying(), this.currentSeason = s.currentTarget.value;
} })}</calcite-label>`;
}
#a;
get #v() {
return this.#g?.value?.startTime;
}
get localDateAsString() {
return this._localDate.value ?? void 0;
}
get _playingState() {
return this.#i;
}
set _playingState(e) {
this.#i = e, this.#n?.remove(), e === "none" ? this.#e?.remove() : (this._play(e), this._emitUserDateTimeChangeEvent());
}
get _lighting() {
return this._view?.environment?.lighting;
}
get _sunlightingDisabled() {
return !p(this._lighting);
}
set _sunlightingDisabled(e) {
this.#s("sunlightingDisabled", e);
const t = this._view?.environment;
if (t == null)
return;
const i = t.lighting, s = this.#r;
this.#r = i;
const n = {
directShadowsEnabled: i.directShadowsEnabled,
glow: i.glow
};
p(i) && (n.cameraTrackingEnabled = i.cameraTrackingEnabled);
const a = e ? "virtual" : "sun";
let o;
s?.type === a ? o = s : o = e ? new _e() : new fe({
date: C(
C(this.localDate, this.timeSliderPosition ?? 0, "minutes"),
// this.localDate already includes the UTC offset, so we need to remove the offset to get the correct UTC date for the SunLighting configuration
this.utcOffset ?? 0
),
displayUTCOffset: this.utcOffset
}), o.set(n), t.lighting = o, e || (this._stopPlaying(), this.#l.value && (this.#l.value.open = !1));
}
get currentSeason() {
const e = this._view?.camera?.position?.latitude ?? 0, t = ie(e);
return Je(this.localDate, t);
}
set currentSeason(e) {
this._stopPlaying();
const t = this._view?.camera?.position?.latitude ?? 0, i = ie(t), s = F(e, i);
this.localDate = P(this.localDate, s, "northern"), this._emitUserDateTimeChangeEvent();
}
get dayPlaying() {
return this._playingState === "day";
}
set dayPlaying(e) {
this._playingState = e ? "day" : "none";
}
get _directShadowsDisabled() {
return !this._lighting?.directShadowsEnabled;
}
set _directShadowsDisabled(e) {
this.#s("directShadowsDisabled", e), this._lighting && (this._lighting.directShadowsEnabled = !e);
}
get utcOffset() {
return this._offset.value;
}
set utcOffset(e) {
this._offset.mutate(e), !this.#s("utcOffset", e) && this.#d();
}
get timeSliderPosition() {
return this._timesliderPosition.value;
}
set timeSliderPosition(e) {
this._timesliderPosition.mutate(ne(e ?? 0, je)), !this.#s("timeSliderPosition", e) && this.#d();
}
get localDate() {
return this._localDate.value != null ? new Date(this._localDate.value) : /* @__PURE__ */ new Date();
}
set localDate(e) {
if (typeof e == "string" && /^\d{4}-\d{2}-\d{2}$/u.test(e)) {
if (this._localDate.mutate(e), this.#s("localDate", e))
return;
this.#d();
return;
}
const t = new Date(e);
if (W(t)) {
t.setUTCFullYear(t.getFullYear(), t.getMonth(), t.getDate());
const i = t.toISOString().slice(0, 10);
if (this._localDate.mutate(i), this.#s("localDate", i))
return;
this.#d();
}
}
get yearPlaying() {
return this._playingState === "year";
}
set yearPlaying(e) {
this._playingState = e ? "year" : "none";
}
async destroy() {
await this.manager.destroy();
}
async load() {
this.manager.onLifecycle(() => [
// When camera tracking is enabled, update the displayed timezone whenever the camera crosses into a new rounded
// UTC offset.
ge(() => {
const e = this._view?.camera?.position;
return e ? Y(e) : void 0;
}, (e, t) => {
this.#w(e, t);
}, { sync: !0, initial: !0 }),
ue(() => !p(this._lighting), () => {
this._stopPlaying();
}),
me.onLocaleChange(() => {
this.requestUpdate();
})
]), this.manager.onDisconnected(() => {
this.#e?.remove(), this.#t?.remove(), this.#n?.remove();
});
}
willUpdate(e) {
if (super.willUpdate(e), !!this.#o && p(this._lighting) && e.has("utcOffset") && !e.has("localDate") && !e.has("timeSliderPosition")) {
const t = this.utcOffset ?? 0, { minutesSinceMidnight: i, localDate: s } = D(this._lighting.date, t);
this._timesliderPosition.mutate(i), this._localDate.mutate(s);
}
}
#o;
async loaded() {
const e = new AbortController();
this.manager.onDisconnected(() => ({
remove: () => {
e.abort();
}
})), await De(pe(() => this._view?.ready, { signal: e.signal }).then(() => {
const t = this._lighting, i = this._view?.camera?.position;
if (this.#a.utcOffset == null && p(t) && t.displayUTCOffset == null && i) {
const n = Y(i);
this.#h(n, t);
}
this.#o = !0, this.#m();
const s = this._playingState;
s !== "none" && this.#e == null && this._play(s);
}));
}
#w(e, t) {
const i = this._lighting;
if (!(!this.#o || !p(i) || !i.cameraTrackingEnabled || e == null)) {
if (t == null && i.displayUTCOffset == null) {
this.#h(e, i);
return;
}
i.displayUTCOffset != null && (i.displayUTCOffset = e), this.#h(e, i);
}
}
#h(e, t) {
t.displayUTCOffset = e, this._offset.mutate(e);
const { minutesSinceMidnight: i, localDate: s } = D(t.date, e);
this._timesliderPosition.mutate(i), this._localDate.mutate(s), this.requestUpdate();
}
_emitUserDateTimeChangeEvent() {
this.isConnected && this.arcgisUserDateTimeChange.emit();
}
_stopPlaying() {
this._playingState = "none";
}
#n;
#y(e) {
if (this.#n)
return;
const t = setTimeout(() => {
const i = e.displayUTCOffset ?? 0, s = e.date, { minutesSinceMidnight: n } = D(s, i);
this._timesliderPosition.mutate(n), this.#n?.remove();
}, this.#p);
this.#n = N(() => {
clearTimeout(t), this.#n = void 0;
const i = this._lighting;
if (p(i)) {
const s = i.displayUTCOffset ?? 0, n = i.date, { minutesSinceMidnight: a } = D(n, s);
this._timesliderPosition.mutate(a);
}
});
}
_play(e) {
this.#e?.remove();
const t = this._view;
if (t == null || this._sunlightingDisabled)
return;
const i = t.environment.lighting;
if (!p(i))
return;
this.#f(i);
let s = 0;
this.#e = Ye({
mode: e,
lighting: i,
beforeProgress: () => {
s = this.#v ?? 0;
},
onProgress: (n, a) => {
this._timesliderPosition.mutate(s), this.#y(a);
},
getPlaySpeed: () => {
const n = this._view, a = this._view?.environment.lighting;
if (n != null && p(a)) {
const o = n.camera.position.latitude ?? 0, c = n.camera.position.longitude ?? 0, { sunrise: d, sunset: l } = Ve(a.date, o, c, a.displayUTCOffset ?? 0);
return Ze(d, l, a.date, Ke) * this.playSpeedMultiplier;
} else
return M * this.playSpeedMultiplier;
}
});
}
render() {
const { messages: e, dateOrSeason: t } = this, i = this._sunlightingDisabled, s = "m";
if (!(this._view?.type === "3d"))
return Q({ class: "root", label: e.componentLabel, title: e.title, hideHeader: this.hideHeader, headingLevel: this.headingLevel, children: m`<div class="unsupported"><p>${e.unsupported}</p></div>` });
const a = (this.utcOffset ?? 0) * 60, o = this.view?.ready === !0, c = Array.isArray(this.timeSliderSteps) ? this.timeSliderSteps.at(0) : this.timeSliderSteps;
return Q({ class: { root: !0, loading: !o }, label: e.componentLabel, title: e.title, hideHeader: this.hideHeader, headingLevel: this.headingLevel, children: m`${o ? void 0 : m`<calcite-scrim loading></calcite-scrim>`}<div class="time-configuration" style=${V({ columnGap: this.hidePlayButtons ? "0" : void 0 })}><calcite-label class="slider-container" .scale=${s}>${e.timeSliderLabel}<arcgis-time-of-day-slider class="slider" .disabled=${this._sunlightingDisabled} mode=single .startTime=${this.timeSliderPosition ?? 0} .steps=${c} style=${V({ gridArea: "slider" })} =${({ currentTarget: d }) => {
this._stopPlaying(), this._emitUserDateTimeChangeEvent(), this.timeSliderPosition = d.startTime;
}} ${G(this.#g)}></arcgis-time-of-day-slider></calcite-label>${T({ hidden: this.hidePlayButtons, children: se({ disabled: this._sunlightingDisabled, playing: this.dayPlaying, label: e.playDay, onClick: () => {
this._playingState === "day" ? this._stopPlaying() : this._playingState = "day";
}, scale: s }) })}${T({ hidden: this.hideTimezone, children: m`<calcite-label .scale=${s} class="timezone-input-container">${e.timezone}<calcite-input-time-zone mode=offset overlay-positioning=fixed .scale=${s} .disabled=${this._sunlightingDisabled} .value=${`${a}`} .referenceDate=${this.localDateAsString} =${(d) => {
const l = +d.target.value;
this.utcOffset = l / 60, this._stopPlaying();
}} ${G(this.#l)}></calcite-input-time-zone></calcite-label><span></span>` })}${T({ hidden: this.hideDatePicker, children: t === "date" ? this.#_({ scale: s, disabled: i }) : this.#b({ scale: s, disabled: i }) })}</div>${T({ hidden: this.hideSunLightingToggle, children: tt({ scale: s, messages: e.sunLightingToggle, sunlightingEnabled: !this._sunlightingDisabled, onSunLightingToggle: (d) => {
this._sunlightingDisabled = !d;
} }) })}${T({ hidden: this.hideShadowsToggle, children: it({ scale: s, messages: e.shadowsToggle, onShadowCheckboxChange: (d) => {
this._directShadowsDisabled = !d;
}, shadowEnabled: !this._directShadowsDisabled }) })}` });
}
}
function se({ disabled: r, playing: e, onClick: t, label: i, scale: s = "m" }) {
return m`<calcite-button appearance=solid .scale=${s} .disabled=${r} .iconStart=${e ? "pause-f" : "play-f"} .label=${i} =${t} round title=${i ?? R} type=button></calcite-button>`;
}
function Xe({ disabled: r, date: e, onDateChange: t, scale: i }) {
return m`<calcite-input-date-picker data-testid=daylight-date-picker .disabled=${r} overlay-positioning=fixed placement=bottom .value=${e} .scale=${i} =${t}></calcite-input-date-picker>`;
}
function et({ messages: r, disabled: e, scale: t, selectedSeason: i, onSeasonChange: s }) {
return m`<calcite-select .disabled=${e} .label=${r.season} .scale=${t} .value=${i} =${(n) => {
s(n);
}}>${J.map((n) => m`<calcite-option .selected=${i === n} .value=${n}>${r[n]}</calcite-option>`)}</calcite-select>`;
}
function tt({ messages: r, sunlightingEnabled: e, onSunLightingToggle: t, scale: i }) {
return m`<calcite-label layout=inline .scale=${i} title=${r?.tooltip ?? R}><calcite-checkbox .scale=${i} .checked=${e} =${(s) => t(s.target.checked)}></calcite-checkbox>${r?.label}</calcite-label>`;
}
function it({ messages: r, shadowEnabled: e, onShadowCheckboxChange: t, scale: i }) {
return m`<calcite-label layout=inline .scale=${i} title=${r?.tooltip ?? R}><calcite-checkbox .checked=${e} =${(s) => t(s.target.checked)}></calcite-checkbox>${r.label}</calcite-label>`;
}
he("arcgis-daylight", Qe);
export {
Qe as ArcgisDaylight
};