world-clock-strip 0.2.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.
- package/README.md +204 -0
- package/assets/weather/Cloudy.webp +0 -0
- package/assets/weather/Foggy.webp +0 -0
- package/assets/weather/Partly_Cloudy.webp +0 -0
- package/assets/weather/Partly_Cloudy_Day.webp +0 -0
- package/assets/weather/Rainy.webp +0 -0
- package/assets/weather/Snow.webp +0 -0
- package/assets/weather/Sunny.webp +0 -0
- package/assets/weather/starry-night.webp +0 -0
- package/assets/weather/storm.webp +0 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1456 -0
- package/dist/index.js.map +1 -0
- package/dist/world-clock.d.ts +164 -0
- package/package.json +61 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,1456 @@
|
|
|
1
|
+
const x = ':host{--world-clock-radius: 18px;display:block;width:100%;color-scheme:dark;font-family:IBM Plex Sans,Avenir Next,Segoe UI,sans-serif;overflow:visible}*,*:before,*:after{box-sizing:border-box}.clock-strip{position:relative;width:100%;min-height:114px;padding-bottom:8px}.clock-strip--config-open{padding-bottom:344px}.clock-strip--preset-minimal .clock-strip__band{box-shadow:0 10px 22px #0000002e}.clock-strip--preset-cinematic .clock-strip__band{box-shadow:0 18px 42px #0000005c}.clock-strip--preset-wallboard .clock-strip__band{min-height:124px;border-radius:22px}.clock-strip__band{position:relative;min-height:114px;width:100%;overflow:hidden;border-radius:var(--world-clock-radius);border:none;background:#0b1522;box-shadow:0 14px 34px #00000047}.clock-strip__hover-zone{position:absolute;left:0;right:0;bottom:0;height:14px;display:grid;place-items:end center;z-index:3}.clock-strip__config-trigger{appearance:none;border:0;border-radius:999px;padding:7px 16px 8px;background:linear-gradient(180deg,#0b1522eb,#080f19fa);color:#dbe7f5e0;font:inherit;font-size:.78rem;font-weight:600;letter-spacing:.04em;box-shadow:0 8px 18px #00000047,inset 0 0 0 1px #8eaed02e;cursor:pointer;opacity:0;transform:translateY(10px);transition:opacity .15s ease,transform .15s ease,color .15s ease,box-shadow .15s ease}.clock-strip__hover-zone:hover .clock-strip__config-trigger,.clock-strip:focus-within .clock-strip__config-trigger,.clock-strip--config-open .clock-strip__config-trigger{opacity:1;transform:translateY(0)}.clock-strip__config-trigger:hover,.clock-strip__config-trigger:focus-visible{color:#f5f9fff5;box-shadow:0 12px 24px #00000057,inset 0 0 0 1px #aac8ea47;outline:none}.clock-config-drawer{position:absolute;left:0;right:0;bottom:0;z-index:2;opacity:0;transform:translateY(14px);pointer-events:none;transition:opacity .18s ease,transform .18s ease}.clock-config-drawer--open{opacity:1;transform:translateY(0);pointer-events:auto}.clock-config-drawer__form{display:grid;gap:12px;padding:12px 14px 16px;border-radius:20px;background:linear-gradient(180deg,#4a4f57b3,#363b42c2);box-shadow:0 18px 36px #0003,inset 0 0 0 1px #e0e5ec29;backdrop-filter:blur(16px) saturate(.82);-webkit-backdrop-filter:blur(16px) saturate(.82)}.clock-config-drawer__section-head{display:flex;align-items:center;justify-content:space-between;gap:12px}.clock-config-drawer__section-copy{margin-top:0;font-size:.78rem;color:#ecf0f5c7}.clock-config-drawer__head-actions{display:flex;align-items:center;gap:8px;flex:0 0 auto}.clock-config-drawer__list-title{font-size:.72rem;font-weight:700;letter-spacing:.08em;text-transform:uppercase;color:#eff3f7ad}.clock-config-drawer__section-copy code{font-family:IBM Plex Mono,SFMono-Regular,monospace;color:#f8fafcf5}.clock-config-status{font-size:.78rem;color:#f6f8faeb}.clock-config-drawer__ghost,.clock-config-drawer__primary,.clock-config-location__remove{appearance:none;border-radius:999px;padding:8px 14px;font:inherit;font-size:.8rem;font-weight:600;cursor:pointer;transition:background-color .15s ease,color .15s ease,box-shadow .15s ease,border-color .15s ease}.clock-config-drawer__ghost,.clock-config-location__remove{border:1px solid rgba(233,237,242,.18);background:#585d6694;color:#f7f9fbe6}.clock-config-drawer__primary{border:1px solid rgba(244,247,250,.2);background:linear-gradient(180deg,#7c818af5,#5a5f68fa);color:#f8fbfffa}.clock-config-drawer__ghost:hover,.clock-config-drawer__ghost:focus-visible,.clock-config-location__remove:hover,.clock-config-location__remove:focus-visible,.clock-config-drawer__primary:hover,.clock-config-drawer__primary:focus-visible{outline:none;box-shadow:0 10px 20px #0000002e}.clock-config-add-panel,.clock-config-drawer__list,.clock-config-advanced__custom{display:grid;gap:10px;padding:10px 12px;border-radius:14px;background:#ebeff31f;box-shadow:inset 0 0 0 1px #ffffff1f}.clock-config-search-results{display:grid;gap:8px;grid-template-columns:repeat(4,minmax(0,1fr))}.clock-config-search-result{appearance:none;display:grid;gap:2px;width:100%;text-align:left;border:1px solid rgba(255,255,255,.12);border-radius:12px;background:#f8fafc1f;color:#fafbfcf5;padding:10px 12px;cursor:pointer}.clock-config-search-result span:last-child{font-size:.76rem;color:#eaeff4b8}.clock-config-search-result--selected,.clock-config-search-result:hover,.clock-config-search-result:focus-visible{outline:none;border-color:#ffffff38;background:#ffffff2e}.clock-config-search-empty,.clock-config-add-confirm__city{font-size:.82rem;color:#f3f6f9d1}.clock-config-add-confirm{display:grid;gap:10px}.clock-config-add-confirm__actions,.clock-config-location-list__actions{display:flex;gap:8px;flex-wrap:wrap}.clock-config-preset-save,.clock-config-preset{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:8px;align-items:center}.clock-config-presets{display:grid;gap:8px}.clock-config-field{display:grid;gap:7px}.clock-config-field--wide{min-width:0}.clock-config-field--time-zone{grid-column:1 / span 2}.clock-config-field__label{font-size:.74rem;font-weight:700;letter-spacing:.08em;text-transform:uppercase;color:#95b3d4ad}.clock-config-field input,.clock-config-field select,.clock-config-textarea,.clock-config-preset-save input{width:100%;min-width:0;border:1px solid rgba(120,152,188,.18);border-radius:12px;background:#0d17228f;color:#f1f7fdf2;font:inherit;padding:10px 12px;backdrop-filter:blur(8px);-webkit-backdrop-filter:blur(8px)}.clock-config-field input::placeholder,.clock-config-textarea::placeholder,.clock-config-preset-save input::placeholder{color:#a5b6cb70}.clock-config-field input:focus,.clock-config-field select:focus,.clock-config-textarea:focus,.clock-config-preset-save input:focus{outline:none;border-color:#8bb5df80;box-shadow:0 0 0 3px #4a7fbb2e}.clock-config-textarea{min-height:120px;resize:vertical}.clock-config-field--toggle{align-content:start}.clock-config-field__toggle-row{display:flex;align-items:center;gap:10px;min-height:42px;padding:0 2px;color:#e4edf7e6}.clock-config-field__toggle-row input{width:16px;height:16px}.clock-config-drawer__locations{display:grid;gap:12px;max-height:200px;overflow:auto;padding-right:2px}.clock-config-location,.clock-config-location-list__item{display:grid;grid-template-columns:minmax(140px,.9fr) minmax(180px,1.1fr) auto;gap:12px;align-items:end;padding:10px 12px;border-radius:14px;background:#0c151f5c;box-shadow:inset 0 0 0 1px #5e79981f;backdrop-filter:blur(8px);-webkit-backdrop-filter:blur(8px)}.clock-config-location__remove{align-self:stretch;min-width:74px}.clock-config-location-list{list-style:none;margin:0;padding:0;display:grid;gap:8px}.clock-config-location-list__item{grid-template-columns:auto auto auto;align-items:center;padding:9px 12px;justify-content:space-between;width:20%;min-width:240px;max-width:320px}.clock-config-location-list__item--confirm{align-items:start;width:20%;min-width:240px;max-width:320px}.clock-config-location-list__item--selected{grid-template-columns:auto minmax(0,1fr) auto;align-items:start}.clock-config-location-list__bullet{font-size:1rem;font-weight:700;color:#d0dcebe0}.clock-config-location-list__body{min-width:0;max-width:none}.clock-config-location-list__body--button{appearance:none;border:0;background:transparent;color:inherit;text-align:left;padding:0;cursor:pointer}.clock-config-location-list__body--edit{display:grid;gap:8px}.clock-config-location-list__title,.clock-config-location-list__confirm{font-size:.9rem;font-weight:600;color:#f1f7fcf2}.clock-config-location-list__meta{margin-top:2px;font-size:.76rem;color:#b3c2d3c7;word-break:break-word}@media(max-width:1200px){.clock-config-search-results{grid-template-columns:repeat(3,minmax(0,1fr))}}.clock-config-advanced{display:none}.clock-config-advanced--open{display:block}.clock-config-advanced__grid{display:grid;grid-template-columns:150px minmax(240px,1fr);gap:12px;padding:10px 12px;border-radius:14px;background:#0a121c47;box-shadow:inset 0 0 0 1px #6683a51a}@media(max-width:900px){.clock-strip--config-open{padding-bottom:520px}.clock-config-drawer__section-head{flex-direction:column;align-items:stretch}.clock-config-search-results{grid-template-columns:repeat(2,minmax(0,1fr))}.clock-config-advanced__grid,.clock-config-location{grid-template-columns:1fr}.clock-config-field--time-zone{grid-column:auto}.clock-config-location__remove{justify-self:start}.clock-config-location-list__item,.clock-config-location-list__item--confirm{width:100%;min-width:0;max-width:none}}@media(max-width:560px){.clock-config-search-results{grid-template-columns:1fr}}.clock-strip__band:before{content:"";position:absolute;inset:0;background:var(--clock-strip-background)}.clock-strip__band:after{content:"";position:absolute;inset:0;background:linear-gradient(180deg,rgba(255,255,255,.08) 0%,rgba(255,255,255,.022) 10%,transparent 24%),linear-gradient(180deg,transparent 0%,rgba(2,6,14,.02) 58%,rgba(2,6,14,.12) 100%);pointer-events:none}.clock-strip__markers{position:absolute;inset:0}.clock-marker{position:absolute;z-index:1;display:grid;gap:4px;top:50%;min-width:156px;justify-items:center;text-align:center;transform:translate(-50%,-50%);overflow:visible;isolation:isolate;padding:0}.clock-marker--edge-left{justify-items:start;text-align:left;transform:translateY(-50%)}.clock-marker--edge-right{justify-items:end;text-align:right;transform:translateY(-50%)}.clock-marker__text{position:relative;z-index:1;min-width:0;max-width:100%;font-size:clamp(1.12rem,1.14vw,1.6rem);line-height:1.02;font-weight:700;letter-spacing:.02em;color:#fcfdfffa;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;text-shadow:none}.clock-marker__text--time{font-size:clamp(1.12rem,1.14vw,1.6rem);font-weight:700;font-variant-numeric:tabular-nums}.clock-marker__meta{position:relative;z-index:1;display:block;max-width:100%;margin-top:1px;font-size:.9rem;font-weight:700;letter-spacing:.03em;color:#eef6ffd6;text-shadow:none;white-space:nowrap}.clock-marker__temp{position:relative;z-index:1;display:block;max-width:100%;margin-top:-1px;font-size:.84rem;font-weight:800;letter-spacing:.08em;color:#fff5e0e6;text-shadow:none;white-space:nowrap}.clock-weather{position:absolute;z-index:0;left:50%;top:6px;width:164px;height:90px;overflow:visible;transform:translate(-50%);pointer-events:none;opacity:.92;background-image:var(--clock-weather-image);background-repeat:no-repeat;background-position:center center;background-size:contain;filter:saturate(1.03) contrast(1.02) brightness(1.01);mix-blend-mode:normal;-webkit-mask-image:radial-gradient(ellipse at center,rgba(0,0,0,1) 0%,rgba(0,0,0,.98) 58%,rgba(0,0,0,.78) 80%,transparent 100%);mask-image:radial-gradient(ellipse at center,rgba(0,0,0,1) 0%,rgba(0,0,0,.98) 58%,rgba(0,0,0,.78) 80%,transparent 100%)}.clock-marker--edge-left .clock-weather,.clock-marker--edge-right .clock-weather{left:50%;-webkit-mask-image:radial-gradient(ellipse at center,rgba(0,0,0,1) 0%,rgba(0,0,0,.98) 58%,rgba(0,0,0,.82) 82%,transparent 100%);mask-image:radial-gradient(ellipse at center,rgba(0,0,0,1) 0%,rgba(0,0,0,.98) 58%,rgba(0,0,0,.82) 82%,transparent 100%)}.clock-weather:after{content:none}.clock-weather--image{box-shadow:none}.clock-weather--clear-day,.clock-weather--clear-night{top:0;width:126px;height:126px;background-size:contain;opacity:.9}.clock-weather--clear-day{background-position:center center}.clock-weather--clear-night{top:-42px;width:430px;height:156px;background-size:cover;background-position:center 26%;opacity:.8;-webkit-mask-image:linear-gradient(90deg,transparent 0%,rgba(0,0,0,.42) 10%,rgba(0,0,0,.9) 22%,rgba(0,0,0,.98) 36%,rgba(0,0,0,.9) 66%,rgba(0,0,0,.48) 84%,transparent 100%),radial-gradient(ellipse at center,rgba(0,0,0,.98) 0%,rgba(0,0,0,.92) 50%,rgba(0,0,0,.58) 72%,transparent 100%);mask-image:linear-gradient(90deg,transparent 0%,rgba(0,0,0,.42) 10%,rgba(0,0,0,.9) 22%,rgba(0,0,0,.98) 36%,rgba(0,0,0,.9) 66%,rgba(0,0,0,.48) 84%,transparent 100%),radial-gradient(ellipse at center,rgba(0,0,0,.98) 0%,rgba(0,0,0,.92) 50%,rgba(0,0,0,.58) 72%,transparent 100%);-webkit-mask-composite:source-in;mask-composite:intersect}.clock-weather--partly-cloudy{top:52px;width:104px;height:58px;background-size:contain;background-position:center center}.clock-weather--cloudy{top:22px;width:170px;height:92px;background-size:contain;background-position:center center}.clock-weather--rain,.clock-weather--storm,.clock-weather--snow,.clock-weather--fog{width:160px;height:86px;background-size:contain;background-position:center center}.clock-weather--storm{width:255px;height:146px;top:-30px;opacity:.96}.clock-weather--fog{width:196px;height:98px;background-size:contain;background-position:center center}.clock-weather__sun,.clock-weather__stars,.clock-weather__rain,.clock-weather__snow,.clock-weather__mist,.clock-weather__cloud{position:absolute}.clock-weather__stars{inset:0;background:radial-gradient(circle at 20% 26%,rgba(255,255,255,1) 0 1.2px,transparent 1.8px),radial-gradient(circle at 62% 18%,rgba(255,255,255,.92) 0 1.2px,transparent 1.8px),radial-gradient(circle at 78% 34%,rgba(255,255,255,.8) 0 1.1px,transparent 1.7px),radial-gradient(circle at 36% 42%,rgba(255,255,255,.86) 0 1.2px,transparent 1.8px),radial-gradient(circle at 53% 58%,rgba(255,255,255,.78) 0 1.1px,transparent 1.7px);opacity:1}.clock-weather__cloud{border-radius:999px;background:radial-gradient(circle at 32% 36%,rgba(255,255,255,.95) 0%,rgba(244,249,255,.78) 30%,rgba(222,235,250,.42) 58%,rgba(222,235,250,.08) 78%,transparent 100%);filter:blur(4px);animation:clock-cloud-drift 18s linear infinite;box-shadow:0 0 22px #c9dff72e,inset 0 1px #ffffff38;mix-blend-mode:normal}.clock-weather__cloud--a{left:0;top:12px;width:108px;height:36px}.clock-weather__cloud--b{right:28px;top:4px;width:92px;height:30px;animation-duration:22s}.clock-weather__cloud--c{left:68px;bottom:10px;width:122px;height:34px;animation-duration:26s}.clock-weather__sun{right:24px;top:2px;width:46px;height:46px;border-radius:999px;background:radial-gradient(circle,rgba(255,247,192,1) 0%,rgba(255,218,104,.92) 36%,rgba(255,196,75,.44) 62%,rgba(255,196,75,.08) 82%,transparent 100%);box-shadow:0 0 22px #ffd05c57,0 0 38px #ffd05c2e;filter:none;mix-blend-mode:normal}.clock-weather__rain{inset:10px 0 0;background:linear-gradient(105deg,transparent 0 38%,rgba(183,219,255,.9) 39% 40.6%,transparent 41.2% 100%) 0 0 / 50px 100% repeat-x,linear-gradient(105deg,transparent 0 54%,rgba(183,219,255,.82) 55% 56.4%,transparent 57% 100%) 18px 0 / 66px 100% repeat-x;opacity:1;transform:translateY(-2px);filter:none;text-shadow:0 0 10px rgba(183,219,255,.25);animation:clock-rain-fall .9s linear infinite;mix-blend-mode:normal}.clock-weather__snow{inset:0;background:radial-gradient(circle at 15% 24%,rgba(255,255,255,1) 0 2px,transparent 2.3px),radial-gradient(circle at 34% 16%,rgba(255,255,255,.94) 0 1.7px,transparent 2px),radial-gradient(circle at 58% 22%,rgba(255,255,255,1) 0 2px,transparent 2.3px),radial-gradient(circle at 76% 28%,rgba(255,255,255,.92) 0 1.7px,transparent 2px),radial-gradient(circle at 26% 56%,rgba(255,255,255,.92) 0 1.7px,transparent 2px),radial-gradient(circle at 66% 58%,rgba(255,255,255,1) 0 2px,transparent 2.3px);animation:clock-snow-fall 4.8s linear infinite;mix-blend-mode:normal}.clock-weather__mist{left:0;right:0;height:16px;border-radius:999px;background:linear-gradient(90deg,transparent 0%,rgba(237,244,255,.54) 18%,rgba(237,244,255,.82) 50%,rgba(237,244,255,.54) 82%,transparent 100%);filter:blur(8px);animation:clock-mist-shift 8s ease-in-out infinite alternate;mix-blend-mode:normal}.clock-weather__mist--a{top:18px}.clock-weather__mist--b{top:40px;animation-duration:10s}.clock-weather--storm .clock-weather__cloud{background:radial-gradient(circle at 35% 35%,rgba(223,230,240,.82) 0%,rgba(187,201,221,.62) 42%,rgba(176,191,212,.16) 72%,transparent 100%)}@keyframes clock-cloud-drift{0%{transform:translate(-4px)}50%{transform:translate(4px)}to{transform:translate(-4px)}}@keyframes clock-rain-fall{0%{transform:translateY(-6px)}to{transform:translateY(10px)}}@keyframes clock-snow-fall{0%{transform:translateY(-8px)}to{transform:translateY(12px)}}@keyframes clock-mist-shift{0%{transform:translate(-6px)}to{transform:translate(6px)}}@media(max-width:720px){.clock-strip,.clock-strip__band{min-height:0}.clock-strip__markers{position:relative;display:grid;gap:12px;padding:14px;grid-template-columns:repeat(auto-fit,minmax(144px,1fr))}.clock-marker{position:relative;top:auto;left:auto!important;right:auto!important;transform:none;min-height:84px;min-width:0;padding:16px 12px;border-radius:16px;border:1px solid rgba(197,219,246,.1);background:#060c162e;backdrop-filter:blur(4px)}.clock-marker--edge-left,.clock-marker--edge-right{justify-items:center;text-align:center;transform:none}.clock-weather{width:auto;height:auto;inset:0;transform:none}.clock-marker__text,.clock-marker__meta,.clock-marker__temp{white-space:normal}}';
|
|
2
|
+
const I = "world-clock-strip", _ = "world-clock-time-zone-options", f = "worldClock", S = "world-clock-strip:presets", v = /* @__PURE__ */ new Map(), C = /* @__PURE__ */ new Map(), Q = /* @__PURE__ */ new Set([
|
|
3
|
+
"America/Adak",
|
|
4
|
+
"America/Anchorage",
|
|
5
|
+
"America/Boise",
|
|
6
|
+
"America/Chicago",
|
|
7
|
+
"America/Denver",
|
|
8
|
+
"America/Detroit",
|
|
9
|
+
"America/Indiana/Indianapolis",
|
|
10
|
+
"America/Indiana/Knox",
|
|
11
|
+
"America/Indiana/Marengo",
|
|
12
|
+
"America/Indiana/Petersburg",
|
|
13
|
+
"America/Indiana/Tell_City",
|
|
14
|
+
"America/Indiana/Vevay",
|
|
15
|
+
"America/Indiana/Vincennes",
|
|
16
|
+
"America/Indiana/Winamac",
|
|
17
|
+
"America/Juneau",
|
|
18
|
+
"America/Kentucky/Louisville",
|
|
19
|
+
"America/Kentucky/Monticello",
|
|
20
|
+
"America/Los_Angeles",
|
|
21
|
+
"America/Menominee",
|
|
22
|
+
"America/Metlakatla",
|
|
23
|
+
"America/New_York",
|
|
24
|
+
"America/Nome",
|
|
25
|
+
"America/North_Dakota/Beulah",
|
|
26
|
+
"America/North_Dakota/Center",
|
|
27
|
+
"America/North_Dakota/New_Salem",
|
|
28
|
+
"America/Phoenix",
|
|
29
|
+
"America/Puerto_Rico",
|
|
30
|
+
"America/Sitka",
|
|
31
|
+
"America/Yakutat",
|
|
32
|
+
"Pacific/Guam",
|
|
33
|
+
"Pacific/Honolulu",
|
|
34
|
+
"Pacific/Pago_Pago",
|
|
35
|
+
"Pacific/Saipan"
|
|
36
|
+
]), A = {
|
|
37
|
+
"clear-day": d("Sunny.webp"),
|
|
38
|
+
"clear-night": d("starry-night.webp"),
|
|
39
|
+
cloudy: d("Cloudy.webp"),
|
|
40
|
+
rain: d("Rainy.webp"),
|
|
41
|
+
storm: d("storm.webp"),
|
|
42
|
+
snow: d("Snow.webp"),
|
|
43
|
+
fog: d("Foggy.webp")
|
|
44
|
+
}, w = [
|
|
45
|
+
{ label: "Las Vegas", timeZone: "America/Los_Angeles", weatherQuery: "Las Vegas, Nevada" },
|
|
46
|
+
{ label: "Israel", timeZone: "Asia/Jerusalem", weatherQuery: "Jerusalem, Israel" },
|
|
47
|
+
{ label: "New Delhi", timeZone: "Asia/Kolkata", weatherQuery: "New Delhi, India" },
|
|
48
|
+
{ label: "Macau", timeZone: "Asia/Macau", weatherQuery: "Macau" },
|
|
49
|
+
{ label: "Sydney", timeZone: "Australia/Sydney", weatherQuery: "Sydney, Australia" }
|
|
50
|
+
], E = [
|
|
51
|
+
"America/Los_Angeles",
|
|
52
|
+
"America/Denver",
|
|
53
|
+
"America/Chicago",
|
|
54
|
+
"America/New_York",
|
|
55
|
+
"Europe/London",
|
|
56
|
+
"Europe/Paris",
|
|
57
|
+
"Asia/Jerusalem",
|
|
58
|
+
"Asia/Dubai",
|
|
59
|
+
"Asia/Kolkata",
|
|
60
|
+
"Asia/Singapore",
|
|
61
|
+
"Asia/Tokyo",
|
|
62
|
+
"Australia/Sydney"
|
|
63
|
+
], g = [
|
|
64
|
+
{ label: "Los Angeles", timeZone: "America/Los_Angeles", weatherQuery: "Los Angeles, California", country: "United States" },
|
|
65
|
+
{ label: "Las Vegas", timeZone: "America/Los_Angeles", weatherQuery: "Las Vegas, Nevada", country: "United States" },
|
|
66
|
+
{ label: "Denver", timeZone: "America/Denver", weatherQuery: "Denver, Colorado", country: "United States" },
|
|
67
|
+
{ label: "Chicago", timeZone: "America/Chicago", weatherQuery: "Chicago, Illinois", country: "United States" },
|
|
68
|
+
{ label: "New York", timeZone: "America/New_York", weatherQuery: "New York, New York", country: "United States" },
|
|
69
|
+
{ label: "Honolulu", timeZone: "Pacific/Honolulu", weatherQuery: "Honolulu, Hawaii", country: "United States" },
|
|
70
|
+
{ label: "London", timeZone: "Europe/London", weatherQuery: "London, United Kingdom", country: "United Kingdom" },
|
|
71
|
+
{ label: "Paris", timeZone: "Europe/Paris", weatherQuery: "Paris, France", country: "France" },
|
|
72
|
+
{ label: "Berlin", timeZone: "Europe/Berlin", weatherQuery: "Berlin, Germany", country: "Germany" },
|
|
73
|
+
{ label: "Jerusalem", timeZone: "Asia/Jerusalem", weatherQuery: "Jerusalem, Israel", country: "Israel" },
|
|
74
|
+
{ label: "Dubai", timeZone: "Asia/Dubai", weatherQuery: "Dubai, United Arab Emirates", country: "United Arab Emirates" },
|
|
75
|
+
{ label: "New Delhi", timeZone: "Asia/Kolkata", weatherQuery: "New Delhi, India", country: "India" },
|
|
76
|
+
{ label: "Singapore", timeZone: "Asia/Singapore", weatherQuery: "Singapore", country: "Singapore" },
|
|
77
|
+
{ label: "Hong Kong", timeZone: "Asia/Hong_Kong", weatherQuery: "Hong Kong", country: "Hong Kong" },
|
|
78
|
+
{ label: "Macau", timeZone: "Asia/Macau", weatherQuery: "Macau", country: "Macau" },
|
|
79
|
+
{ label: "Tokyo", timeZone: "Asia/Tokyo", weatherQuery: "Tokyo, Japan", country: "Japan" },
|
|
80
|
+
{ label: "Seoul", timeZone: "Asia/Seoul", weatherQuery: "Seoul, South Korea", country: "South Korea" },
|
|
81
|
+
{ label: "Sydney", timeZone: "Australia/Sydney", weatherQuery: "Sydney, Australia", country: "Australia" },
|
|
82
|
+
{ label: "Auckland", timeZone: "Pacific/Auckland", weatherQuery: "Auckland, New Zealand", country: "New Zealand" },
|
|
83
|
+
{ label: "Sao Paulo", timeZone: "America/Sao_Paulo", weatherQuery: "Sao Paulo, Brazil", country: "Brazil" }
|
|
84
|
+
];
|
|
85
|
+
class L extends HTMLElement {
|
|
86
|
+
static get observedAttributes() {
|
|
87
|
+
return [
|
|
88
|
+
"locations",
|
|
89
|
+
"weather-enabled",
|
|
90
|
+
"weather-endpoint",
|
|
91
|
+
"visual-preset",
|
|
92
|
+
"read-only",
|
|
93
|
+
"persist-key",
|
|
94
|
+
"enable-url-state",
|
|
95
|
+
"share-query-param"
|
|
96
|
+
];
|
|
97
|
+
}
|
|
98
|
+
root;
|
|
99
|
+
locationsState = u(w);
|
|
100
|
+
weatherEnabledState = !0;
|
|
101
|
+
weatherEndpointState = "";
|
|
102
|
+
visualPresetState = "default";
|
|
103
|
+
readOnlyState = !1;
|
|
104
|
+
persistKeyState = "";
|
|
105
|
+
enableUrlState = !1;
|
|
106
|
+
shareQueryParamState = f;
|
|
107
|
+
cityCatalogState = g;
|
|
108
|
+
weatherOverridesState = {};
|
|
109
|
+
weatherByKey = /* @__PURE__ */ new Map();
|
|
110
|
+
weatherFetchedAt = 0;
|
|
111
|
+
weatherRequestKey = "";
|
|
112
|
+
clockTimer = null;
|
|
113
|
+
weatherTimer = null;
|
|
114
|
+
inFlightWeatherRequest = null;
|
|
115
|
+
configDrawerOpen = !1;
|
|
116
|
+
advancedSettingsOpen = !1;
|
|
117
|
+
configDraftState = this.createConfigDraft();
|
|
118
|
+
addLocationOpen = !1;
|
|
119
|
+
addLocationQuery = "";
|
|
120
|
+
addLocationPreferredName = "";
|
|
121
|
+
selectedCommonCityKey = "";
|
|
122
|
+
pendingDeleteIndex = null;
|
|
123
|
+
selectedLocationIndex = null;
|
|
124
|
+
customLocationDraft = { label: "", timeZone: "", weatherQuery: "" };
|
|
125
|
+
presetNameDraft = "";
|
|
126
|
+
importExportDraft = "";
|
|
127
|
+
importExportOpen = !1;
|
|
128
|
+
statusMessage = "";
|
|
129
|
+
constructor() {
|
|
130
|
+
super(), this.root = this.attachShadow({ mode: "open" }), this.readAttributes(), this.configDraftState = this.createConfigDraft(), this.root.addEventListener("click", this.handleRootClick.bind(this)), this.root.addEventListener("input", this.handleRootInput.bind(this)), this.root.addEventListener("change", this.handleRootChange.bind(this)), this.root.addEventListener("focusout", this.handleRootFocusOut.bind(this));
|
|
131
|
+
}
|
|
132
|
+
connectedCallback() {
|
|
133
|
+
this.initializeSharedState(), this.render(), this.startClockRefresh(), this.startWeatherRefresh(!0);
|
|
134
|
+
}
|
|
135
|
+
disconnectedCallback() {
|
|
136
|
+
this.stopClockRefresh(), this.stopWeatherRefresh(), this.inFlightWeatherRequest?.abort(), this.inFlightWeatherRequest = null;
|
|
137
|
+
}
|
|
138
|
+
attributeChangedCallback(e, t, r) {
|
|
139
|
+
if (e === "locations") {
|
|
140
|
+
this.locationsState = P(r, this.locationsState), this.handleConfigurationChange(!0);
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
if (e === "weather-enabled") {
|
|
144
|
+
this.weatherEnabledState = r == null ? !0 : r !== "false", this.handleConfigurationChange(!0);
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
if (e === "weather-endpoint") {
|
|
148
|
+
this.weatherEndpointState = String(r || "").trim(), this.handleConfigurationChange(!0, "attribute");
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
if (e === "visual-preset") {
|
|
152
|
+
this.visualPresetState = h(r), this.handleConfigurationChange(!1, "attribute");
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
if (e === "read-only") {
|
|
156
|
+
this.readOnlyState = r != null && r !== "false", this.render();
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
if (e === "persist-key") {
|
|
160
|
+
this.persistKeyState = String(r || "").trim();
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
if (e === "enable-url-state") {
|
|
164
|
+
this.enableUrlState = r != null && r !== "false";
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
e === "share-query-param" && (this.shareQueryParamState = String(r || f).trim() || f);
|
|
168
|
+
}
|
|
169
|
+
get locations() {
|
|
170
|
+
return this.locationsState.map((e) => ({ ...e }));
|
|
171
|
+
}
|
|
172
|
+
set locations(e) {
|
|
173
|
+
this.locationsState = u(e), this.handleConfigurationChange(!0, "api");
|
|
174
|
+
}
|
|
175
|
+
get weatherEnabled() {
|
|
176
|
+
return this.weatherEnabledState;
|
|
177
|
+
}
|
|
178
|
+
set weatherEnabled(e) {
|
|
179
|
+
this.weatherEnabledState = !!e, this.handleConfigurationChange(!0, "api");
|
|
180
|
+
}
|
|
181
|
+
get weatherEndpoint() {
|
|
182
|
+
return this.weatherEndpointState;
|
|
183
|
+
}
|
|
184
|
+
set weatherEndpoint(e) {
|
|
185
|
+
this.weatherEndpointState = String(e || "").trim(), this.handleConfigurationChange(!0, "api");
|
|
186
|
+
}
|
|
187
|
+
get visualPreset() {
|
|
188
|
+
return this.visualPresetState;
|
|
189
|
+
}
|
|
190
|
+
set visualPreset(e) {
|
|
191
|
+
this.visualPresetState = h(e), this.handleConfigurationChange(!1, "api");
|
|
192
|
+
}
|
|
193
|
+
get readOnly() {
|
|
194
|
+
return this.readOnlyState;
|
|
195
|
+
}
|
|
196
|
+
set readOnly(e) {
|
|
197
|
+
this.readOnlyState = !!e, this.render();
|
|
198
|
+
}
|
|
199
|
+
get persistKey() {
|
|
200
|
+
return this.persistKeyState;
|
|
201
|
+
}
|
|
202
|
+
set persistKey(e) {
|
|
203
|
+
this.persistKeyState = String(e || "").trim();
|
|
204
|
+
}
|
|
205
|
+
get shareQueryParam() {
|
|
206
|
+
return this.shareQueryParamState;
|
|
207
|
+
}
|
|
208
|
+
set shareQueryParam(e) {
|
|
209
|
+
this.shareQueryParamState = String(e || f).trim() || f;
|
|
210
|
+
}
|
|
211
|
+
get cityCatalog() {
|
|
212
|
+
return this.cityCatalogState.map((e) => ({ ...e }));
|
|
213
|
+
}
|
|
214
|
+
set cityCatalog(e) {
|
|
215
|
+
this.cityCatalogState = Z(e), this.render();
|
|
216
|
+
}
|
|
217
|
+
get weatherOverrides() {
|
|
218
|
+
return { ...this.weatherOverridesState };
|
|
219
|
+
}
|
|
220
|
+
set weatherOverrides(e) {
|
|
221
|
+
this.weatherOverridesState = e && typeof e == "object" ? { ...e } : {}, this.handleConfigurationChange(!1);
|
|
222
|
+
}
|
|
223
|
+
get config() {
|
|
224
|
+
return {
|
|
225
|
+
locations: this.locations,
|
|
226
|
+
weatherEnabled: this.weatherEnabledState,
|
|
227
|
+
weatherEndpoint: this.weatherEndpointState,
|
|
228
|
+
visualPreset: this.visualPresetState
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
set config(e) {
|
|
232
|
+
this.applyConfigValue(e, "api");
|
|
233
|
+
}
|
|
234
|
+
readAttributes() {
|
|
235
|
+
this.hasAttribute("locations") && (this.locationsState = P(this.getAttribute("locations"), this.locationsState)), this.hasAttribute("weather-enabled") && (this.weatherEnabledState = this.getAttribute("weather-enabled") !== "false"), this.hasAttribute("weather-endpoint") && (this.weatherEndpointState = String(this.getAttribute("weather-endpoint") || "").trim()), this.hasAttribute("visual-preset") && (this.visualPresetState = h(this.getAttribute("visual-preset"))), this.hasAttribute("read-only") && (this.readOnlyState = this.getAttribute("read-only") !== "false"), this.hasAttribute("persist-key") && (this.persistKeyState = String(this.getAttribute("persist-key") || "").trim()), this.hasAttribute("enable-url-state") && (this.enableUrlState = this.getAttribute("enable-url-state") !== "false"), this.hasAttribute("share-query-param") && (this.shareQueryParamState = String(this.getAttribute("share-query-param") || f).trim() || f);
|
|
236
|
+
}
|
|
237
|
+
initializeSharedState() {
|
|
238
|
+
if (this.persistKeyState) {
|
|
239
|
+
const e = le(this.persistKeyState);
|
|
240
|
+
e && this.applyConfigValue(e, "storage");
|
|
241
|
+
}
|
|
242
|
+
if (this.enableUrlState) {
|
|
243
|
+
const e = ce(this.shareQueryParamState);
|
|
244
|
+
e && this.applyConfigValue(e, "url");
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
handleConfigurationChange(e, t = "api") {
|
|
248
|
+
this.weatherEnabledState || (this.weatherByKey = /* @__PURE__ */ new Map(), this.weatherFetchedAt = 0, this.weatherRequestKey = "", this.inFlightWeatherRequest?.abort(), this.inFlightWeatherRequest = null), this.persistCurrentConfig(), this.dispatchConfigChange(t), this.render(), this.isConnected && (e ? this.startWeatherRefresh(!0) : this.render());
|
|
249
|
+
}
|
|
250
|
+
applyConfigValue(e, t) {
|
|
251
|
+
e.locations && (this.locationsState = u(e.locations)), typeof e.weatherEnabled == "boolean" && (this.weatherEnabledState = e.weatherEnabled), typeof e.weatherEndpoint == "string" && (this.weatherEndpointState = e.weatherEndpoint.trim()), e.visualPreset && (this.visualPresetState = h(e.visualPreset)), this.syncConfigDraftFromState(), this.handleConfigurationChange(!0, t);
|
|
252
|
+
}
|
|
253
|
+
persistCurrentConfig() {
|
|
254
|
+
this.persistKeyState && de(this.persistKeyState, this.config);
|
|
255
|
+
}
|
|
256
|
+
dispatchConfigChange(e) {
|
|
257
|
+
this.dispatchEvent(
|
|
258
|
+
new CustomEvent("configchange", {
|
|
259
|
+
detail: {
|
|
260
|
+
config: this.config,
|
|
261
|
+
source: e
|
|
262
|
+
}
|
|
263
|
+
})
|
|
264
|
+
);
|
|
265
|
+
}
|
|
266
|
+
startClockRefresh() {
|
|
267
|
+
this.stopClockRefresh();
|
|
268
|
+
const e = () => {
|
|
269
|
+
this.render();
|
|
270
|
+
const t = 6e4 - Date.now() % 6e4 + 50;
|
|
271
|
+
this.clockTimer = window.setTimeout(e, t);
|
|
272
|
+
};
|
|
273
|
+
e();
|
|
274
|
+
}
|
|
275
|
+
stopClockRefresh() {
|
|
276
|
+
this.clockTimer != null && (window.clearTimeout(this.clockTimer), this.clockTimer = null);
|
|
277
|
+
}
|
|
278
|
+
startWeatherRefresh(e) {
|
|
279
|
+
if (this.stopWeatherRefresh(), !this.weatherEnabledState || !this.locationsState.length) {
|
|
280
|
+
this.render();
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
this.refreshWeather(e), this.weatherTimer = window.setInterval(() => {
|
|
284
|
+
this.refreshWeather(!1);
|
|
285
|
+
}, 9e5);
|
|
286
|
+
}
|
|
287
|
+
stopWeatherRefresh() {
|
|
288
|
+
this.weatherTimer != null && (window.clearInterval(this.weatherTimer), this.weatherTimer = null);
|
|
289
|
+
}
|
|
290
|
+
async refreshWeather(e) {
|
|
291
|
+
const t = this.buildWeatherRequestKey(), r = this.weatherFetchedAt > 0 && Date.now() - this.weatherFetchedAt < 9e5;
|
|
292
|
+
if (!e && r && t === this.weatherRequestKey)
|
|
293
|
+
return;
|
|
294
|
+
this.inFlightWeatherRequest?.abort();
|
|
295
|
+
const i = new AbortController();
|
|
296
|
+
this.inFlightWeatherRequest = i;
|
|
297
|
+
try {
|
|
298
|
+
const n = await be(this.locationsState, this.weatherEndpointState, i.signal);
|
|
299
|
+
if (i.signal.aborted || t !== this.buildWeatherRequestKey())
|
|
300
|
+
return;
|
|
301
|
+
const o = /* @__PURE__ */ new Map();
|
|
302
|
+
for (const s of n.locations)
|
|
303
|
+
o.set(m(s), s.weather ?? null);
|
|
304
|
+
this.weatherByKey = o, this.weatherFetchedAt = Date.now(), this.weatherRequestKey = t;
|
|
305
|
+
} catch (n) {
|
|
306
|
+
if (i.signal.aborted)
|
|
307
|
+
return;
|
|
308
|
+
console.error("World clock weather refresh failed", n), this.weatherFetchedAt = Date.now(), this.weatherRequestKey = t;
|
|
309
|
+
} finally {
|
|
310
|
+
this.inFlightWeatherRequest === i && (this.inFlightWeatherRequest = null), this.render();
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
buildWeatherRequestKey() {
|
|
314
|
+
return JSON.stringify({
|
|
315
|
+
endpoint: this.weatherEndpointState,
|
|
316
|
+
locations: this.locationsState.map((e) => ({
|
|
317
|
+
key: m(e),
|
|
318
|
+
weatherQuery: e.weatherQuery || e.label
|
|
319
|
+
}))
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
createConfigDraft() {
|
|
323
|
+
return {
|
|
324
|
+
locations: this.locationsState.map((e) => ({
|
|
325
|
+
label: e.label,
|
|
326
|
+
timeZone: e.timeZone,
|
|
327
|
+
weatherQuery: e.weatherQuery || e.label
|
|
328
|
+
})),
|
|
329
|
+
weatherEnabled: this.weatherEnabledState,
|
|
330
|
+
weatherEndpoint: this.weatherEndpointState,
|
|
331
|
+
visualPreset: this.visualPresetState
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
syncConfigDraftFromState() {
|
|
335
|
+
this.configDraftState = this.createConfigDraft();
|
|
336
|
+
}
|
|
337
|
+
handleRootClick(e) {
|
|
338
|
+
const t = e.target;
|
|
339
|
+
if (!(t instanceof Element))
|
|
340
|
+
return;
|
|
341
|
+
const r = t.closest("[data-action]");
|
|
342
|
+
if (!r)
|
|
343
|
+
return;
|
|
344
|
+
const i = r.dataset.action || "";
|
|
345
|
+
if (i === "toggle-config") {
|
|
346
|
+
this.configDrawerOpen = !this.configDrawerOpen, this.syncConfigDraftFromState(), this.resetTransientConfigUi(), this.render();
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
349
|
+
if (i === "toggle-advanced") {
|
|
350
|
+
this.advancedSettingsOpen = !this.advancedSettingsOpen, this.render();
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
if (i === "copy-share-link") {
|
|
354
|
+
this.copyShareLink();
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
357
|
+
if (i === "copy-config-json") {
|
|
358
|
+
this.copyConfigJson();
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
361
|
+
if (i === "toggle-import-export") {
|
|
362
|
+
this.importExportOpen = !this.importExportOpen, this.importExportDraft = this.importExportOpen ? JSON.stringify(this.config, null, 2) : "", this.render();
|
|
363
|
+
return;
|
|
364
|
+
}
|
|
365
|
+
if (i === "import-config-json") {
|
|
366
|
+
this.importConfigJson();
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
if (i === "save-preset") {
|
|
370
|
+
this.saveCurrentPreset();
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
if (i === "load-preset") {
|
|
374
|
+
const n = String(r.dataset.presetName || "");
|
|
375
|
+
this.loadSavedPreset(n);
|
|
376
|
+
return;
|
|
377
|
+
}
|
|
378
|
+
if (i === "delete-preset") {
|
|
379
|
+
const n = String(r.dataset.presetName || "");
|
|
380
|
+
this.deleteSavedPreset(n);
|
|
381
|
+
return;
|
|
382
|
+
}
|
|
383
|
+
if (i === "toggle-add-location") {
|
|
384
|
+
this.addLocationOpen = !this.addLocationOpen, this.addLocationOpen || this.resetAddLocationUi(), this.render();
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
387
|
+
if (i === "select-common-city") {
|
|
388
|
+
const n = String(r.dataset.cityKey || ""), o = g.find((s) => k(s) === n);
|
|
389
|
+
if (!o)
|
|
390
|
+
return;
|
|
391
|
+
this.selectedCommonCityKey = n, this.addLocationPreferredName = o.label, this.render();
|
|
392
|
+
return;
|
|
393
|
+
}
|
|
394
|
+
if (i === "confirm-add-location") {
|
|
395
|
+
const n = this.getSelectedCommonCity();
|
|
396
|
+
if (!n)
|
|
397
|
+
return;
|
|
398
|
+
this.configDraftState.locations.push({
|
|
399
|
+
label: (this.addLocationPreferredName || n.label).trim(),
|
|
400
|
+
timeZone: n.timeZone,
|
|
401
|
+
weatherQuery: n.weatherQuery
|
|
402
|
+
}), this.applyConfigDraft(!0), this.resetAddLocationUi(), this.render();
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
405
|
+
if (i === "cancel-add-location") {
|
|
406
|
+
this.resetAddLocationUi(), this.addLocationOpen = !1, this.render();
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
409
|
+
if (i === "request-remove-location") {
|
|
410
|
+
const n = Number.parseInt(r.dataset.index || "-1", 10);
|
|
411
|
+
Number.isInteger(n) && n >= 0 && (this.pendingDeleteIndex = n, this.selectedLocationIndex = null, this.render());
|
|
412
|
+
return;
|
|
413
|
+
}
|
|
414
|
+
if (i === "cancel-remove-location") {
|
|
415
|
+
this.pendingDeleteIndex = null, this.render();
|
|
416
|
+
return;
|
|
417
|
+
}
|
|
418
|
+
if (i === "confirm-remove-location") {
|
|
419
|
+
const n = Number.parseInt(r.dataset.index || "-1", 10);
|
|
420
|
+
Number.isInteger(n) && n >= 0 && (this.configDraftState.locations.splice(n, 1), this.pendingDeleteIndex = null, this.selectedLocationIndex = null, this.applyConfigDraft(!0), this.render());
|
|
421
|
+
return;
|
|
422
|
+
}
|
|
423
|
+
if (i === "select-location") {
|
|
424
|
+
const n = Number.parseInt(r.dataset.index || "-1", 10);
|
|
425
|
+
Number.isInteger(n) && n >= 0 && (this.pendingDeleteIndex = null, this.selectedLocationIndex = this.selectedLocationIndex === n ? null : n, this.render());
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
428
|
+
if (i === "add-custom-location") {
|
|
429
|
+
const n = {
|
|
430
|
+
label: this.customLocationDraft.label.trim(),
|
|
431
|
+
timeZone: this.customLocationDraft.timeZone.trim(),
|
|
432
|
+
weatherQuery: this.customLocationDraft.weatherQuery.trim()
|
|
433
|
+
};
|
|
434
|
+
if (!n.label || !n.timeZone || !n.weatherQuery)
|
|
435
|
+
return;
|
|
436
|
+
this.configDraftState.locations.push(n), this.customLocationDraft = { label: "", timeZone: "", weatherQuery: "" }, this.applyConfigDraft(!0), this.render();
|
|
437
|
+
return;
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
handleRootInput(e) {
|
|
441
|
+
const t = e.target;
|
|
442
|
+
if (!(t instanceof HTMLInputElement || t instanceof HTMLTextAreaElement))
|
|
443
|
+
return;
|
|
444
|
+
const r = t.dataset.setting || "";
|
|
445
|
+
if (r === "addLocationQuery") {
|
|
446
|
+
this.addLocationQuery = t.value, this.selectedCommonCityKey = "", this.addLocationPreferredName = "", this.render();
|
|
447
|
+
return;
|
|
448
|
+
}
|
|
449
|
+
if (r === "addLocationPreferredName") {
|
|
450
|
+
this.addLocationPreferredName = t.value;
|
|
451
|
+
return;
|
|
452
|
+
}
|
|
453
|
+
if (r === "customLabel") {
|
|
454
|
+
this.customLocationDraft.label = t.value;
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
if (r === "customTimeZone") {
|
|
458
|
+
this.customLocationDraft.timeZone = t.value;
|
|
459
|
+
return;
|
|
460
|
+
}
|
|
461
|
+
if (r === "customWeatherQuery") {
|
|
462
|
+
this.customLocationDraft.weatherQuery = t.value;
|
|
463
|
+
return;
|
|
464
|
+
}
|
|
465
|
+
if (r === "presetName") {
|
|
466
|
+
this.presetNameDraft = t.value;
|
|
467
|
+
return;
|
|
468
|
+
}
|
|
469
|
+
if (r === "importExportDraft") {
|
|
470
|
+
this.importExportDraft = t.value;
|
|
471
|
+
return;
|
|
472
|
+
}
|
|
473
|
+
const i = t.dataset.field || "", n = Number.parseInt(t.dataset.index || "-1", 10);
|
|
474
|
+
if (!Number.isInteger(n) || n < 0 || n >= this.configDraftState.locations.length)
|
|
475
|
+
return;
|
|
476
|
+
const o = this.configDraftState.locations[n];
|
|
477
|
+
if (i === "label") {
|
|
478
|
+
o.label = t.value;
|
|
479
|
+
return;
|
|
480
|
+
}
|
|
481
|
+
if (i === "timeZone") {
|
|
482
|
+
o.timeZone = t.value;
|
|
483
|
+
return;
|
|
484
|
+
}
|
|
485
|
+
i === "weatherQuery" && (o.weatherQuery = t.value);
|
|
486
|
+
}
|
|
487
|
+
handleRootChange(e) {
|
|
488
|
+
const t = e.target;
|
|
489
|
+
if (!(t instanceof HTMLInputElement || t instanceof HTMLSelectElement))
|
|
490
|
+
return;
|
|
491
|
+
const r = t.dataset.setting || "";
|
|
492
|
+
if (r === "weatherEnabled" && t instanceof HTMLInputElement) {
|
|
493
|
+
this.configDraftState.weatherEnabled = t.checked, this.applyConfigDraft(!0);
|
|
494
|
+
return;
|
|
495
|
+
}
|
|
496
|
+
if (r === "weatherEndpoint" && t instanceof HTMLInputElement) {
|
|
497
|
+
this.configDraftState.weatherEndpoint = t.value;
|
|
498
|
+
return;
|
|
499
|
+
}
|
|
500
|
+
if (r === "visualPreset" && t instanceof HTMLSelectElement) {
|
|
501
|
+
this.configDraftState.visualPreset = h(t.value), this.applyConfigDraft(!0);
|
|
502
|
+
return;
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
handleRootFocusOut(e) {
|
|
506
|
+
const t = e.target;
|
|
507
|
+
(t instanceof HTMLInputElement || t instanceof HTMLSelectElement || t instanceof HTMLTextAreaElement) && t.closest(".clock-config-drawer") && window.setTimeout(() => {
|
|
508
|
+
this.configDrawerOpen && this.applyConfigDraft(!0);
|
|
509
|
+
}, 0);
|
|
510
|
+
}
|
|
511
|
+
applyConfigDraft(e = !1) {
|
|
512
|
+
const t = u(
|
|
513
|
+
this.configDraftState.locations.map((r) => ({
|
|
514
|
+
label: r.label.trim(),
|
|
515
|
+
timeZone: r.timeZone.trim(),
|
|
516
|
+
weatherQuery: (r.weatherQuery || r.label).trim()
|
|
517
|
+
}))
|
|
518
|
+
);
|
|
519
|
+
this.locationsState = t.length ? t : u(w), this.weatherEnabledState = this.configDraftState.weatherEnabled, this.weatherEndpointState = this.configDraftState.weatherEndpoint.trim(), this.visualPresetState = this.configDraftState.visualPreset, this.configDrawerOpen = e ? this.configDrawerOpen : !1, this.syncConfigDraftFromState(), this.handleConfigurationChange(!0, "drawer");
|
|
520
|
+
}
|
|
521
|
+
render() {
|
|
522
|
+
const e = this.captureRenderFocus();
|
|
523
|
+
if (!this.locationsState.length) {
|
|
524
|
+
this.root.innerHTML = `<style>${x}</style>`, this.restoreRenderFocus(e);
|
|
525
|
+
return;
|
|
526
|
+
}
|
|
527
|
+
const t = /* @__PURE__ */ new Date(), r = this.locationsState.map((o, s) => {
|
|
528
|
+
const l = F(o.timeZone, t);
|
|
529
|
+
return {
|
|
530
|
+
label: o.label,
|
|
531
|
+
timeZone: o.timeZone,
|
|
532
|
+
weatherQuery: o.weatherQuery || o.label,
|
|
533
|
+
timeParts: l,
|
|
534
|
+
weather: Y(o, this.weatherByKey, this.weatherOverridesState),
|
|
535
|
+
positionPercent: X(s, this.locationsState.length)
|
|
536
|
+
};
|
|
537
|
+
}), i = W(r), n = i.reduce((o, s) => Math.max(o, s.lane + 1), 1);
|
|
538
|
+
this.root.innerHTML = `
|
|
539
|
+
<style>${x}</style>
|
|
540
|
+
<section class="clock-strip clock-strip--preset-${this.visualPresetState} ${this.configDrawerOpen && !this.readOnlyState ? "clock-strip--config-open" : ""}" part="base">
|
|
541
|
+
<section
|
|
542
|
+
class="clock-strip__band"
|
|
543
|
+
part="band"
|
|
544
|
+
style="--clock-lane-count:${n};--clock-strip-background:${V(i)};"
|
|
545
|
+
aria-label="World clock strip"
|
|
546
|
+
>
|
|
547
|
+
<div class="clock-strip__markers" part="markers">
|
|
548
|
+
${i.map((o) => this.renderClockMarker(o)).join("")}
|
|
549
|
+
</div>
|
|
550
|
+
</section>
|
|
551
|
+
${this.readOnlyState ? "" : `
|
|
552
|
+
<div class="clock-strip__hover-zone" part="config-hover-zone" aria-hidden="true">
|
|
553
|
+
<button
|
|
554
|
+
class="clock-strip__config-trigger"
|
|
555
|
+
type="button"
|
|
556
|
+
part="config-trigger"
|
|
557
|
+
data-action="toggle-config"
|
|
558
|
+
aria-label="${this.configDrawerOpen ? "Close world time settings" : "Open world time settings"}"
|
|
559
|
+
aria-expanded="${this.configDrawerOpen ? "true" : "false"}"
|
|
560
|
+
>
|
|
561
|
+
${this.configDrawerOpen ? "Close" : "World Time Settings"}
|
|
562
|
+
</button>
|
|
563
|
+
</div>
|
|
564
|
+
${this.renderConfigDrawer()}
|
|
565
|
+
`}
|
|
566
|
+
</section>
|
|
567
|
+
`, this.restoreRenderFocus(e);
|
|
568
|
+
}
|
|
569
|
+
renderConfigDrawer() {
|
|
570
|
+
const e = this.configDrawerOpen ? this.configDraftState : this.createConfigDraft(), t = this.getFilteredCommonCities(), r = this.getSelectedCommonCity(), i = this.getSavedPresets();
|
|
571
|
+
return `
|
|
572
|
+
<section
|
|
573
|
+
class="clock-config-drawer ${this.configDrawerOpen ? "clock-config-drawer--open" : ""}"
|
|
574
|
+
part="config-drawer"
|
|
575
|
+
aria-hidden="${this.configDrawerOpen ? "false" : "true"}"
|
|
576
|
+
>
|
|
577
|
+
<div class="clock-config-drawer__form">
|
|
578
|
+
<div class="clock-config-drawer__section-head">
|
|
579
|
+
<div class="clock-config-drawer__section-copy">Add from the common city list. Use <code>Advanced</code> for custom entries.</div>
|
|
580
|
+
<div class="clock-config-drawer__head-actions">
|
|
581
|
+
<button type="button" class="clock-config-drawer__ghost" data-action="copy-share-link">Share</button>
|
|
582
|
+
<button type="button" class="clock-config-drawer__ghost" data-action="toggle-import-export" aria-expanded="${this.importExportOpen ? "true" : "false"}">JSON</button>
|
|
583
|
+
<button type="button" class="clock-config-drawer__ghost" data-action="toggle-advanced" aria-expanded="${this.advancedSettingsOpen ? "true" : "false"}">Advanced</button>
|
|
584
|
+
<button type="button" class="clock-config-drawer__ghost" data-action="toggle-add-location" aria-expanded="${this.addLocationOpen ? "true" : "false"}">+</button>
|
|
585
|
+
</div>
|
|
586
|
+
</div>
|
|
587
|
+
${this.statusMessage ? `<div class="clock-config-status">${c(this.statusMessage)}</div>` : ""}
|
|
588
|
+
${this.renderAddLocationPanel(t, r)}
|
|
589
|
+
${this.renderPresetPanel(i)}
|
|
590
|
+
${this.renderImportExportPanel()}
|
|
591
|
+
<div class="clock-config-drawer__list">
|
|
592
|
+
<div class="clock-config-drawer__list-title">Current locations</div>
|
|
593
|
+
<ul class="clock-config-location-list">
|
|
594
|
+
${e.locations.map((n, o) => this.renderConfigLocationListItem(n, o)).join("")}
|
|
595
|
+
</ul>
|
|
596
|
+
</div>
|
|
597
|
+
${this.renderAdvancedSettings(e)}
|
|
598
|
+
<datalist id="${_}">
|
|
599
|
+
${oe().map((n) => `<option value="${c(n)}"></option>`).join("")}
|
|
600
|
+
</datalist>
|
|
601
|
+
</div>
|
|
602
|
+
</section>
|
|
603
|
+
`;
|
|
604
|
+
}
|
|
605
|
+
renderPresetPanel(e) {
|
|
606
|
+
return `
|
|
607
|
+
<section class="clock-config-drawer__list">
|
|
608
|
+
<div class="clock-config-drawer__list-title">Saved presets</div>
|
|
609
|
+
<div class="clock-config-preset-save">
|
|
610
|
+
<input
|
|
611
|
+
type="text"
|
|
612
|
+
value="${c(this.presetNameDraft)}"
|
|
613
|
+
data-setting="presetName"
|
|
614
|
+
placeholder="Preset name"
|
|
615
|
+
/>
|
|
616
|
+
<button type="button" class="clock-config-drawer__ghost" data-action="save-preset">Save current</button>
|
|
617
|
+
</div>
|
|
618
|
+
<div class="clock-config-presets">
|
|
619
|
+
${e.length ? e.map((t) => `
|
|
620
|
+
<div class="clock-config-preset">
|
|
621
|
+
<button type="button" class="clock-config-search-result" data-action="load-preset" data-preset-name="${c(t.name)}">${c(t.name)}</button>
|
|
622
|
+
<button type="button" class="clock-config-location__remove" data-action="delete-preset" data-preset-name="${c(t.name)}">Delete</button>
|
|
623
|
+
</div>
|
|
624
|
+
`).join("") : '<div class="clock-config-search-empty">No saved presets yet.</div>'}
|
|
625
|
+
</div>
|
|
626
|
+
</section>
|
|
627
|
+
`;
|
|
628
|
+
}
|
|
629
|
+
renderImportExportPanel() {
|
|
630
|
+
return this.importExportOpen ? `
|
|
631
|
+
<section class="clock-config-drawer__list">
|
|
632
|
+
<div class="clock-config-drawer__list-title">Import / export JSON</div>
|
|
633
|
+
<label class="clock-config-field">
|
|
634
|
+
<textarea
|
|
635
|
+
class="clock-config-textarea"
|
|
636
|
+
data-setting="importExportDraft"
|
|
637
|
+
placeholder="Paste config JSON"
|
|
638
|
+
>${c(this.importExportDraft)}</textarea>
|
|
639
|
+
</label>
|
|
640
|
+
<div class="clock-config-add-confirm__actions">
|
|
641
|
+
<button type="button" class="clock-config-drawer__ghost" data-action="copy-config-json">Copy current</button>
|
|
642
|
+
<button type="button" class="clock-config-drawer__primary" data-action="import-config-json">Import</button>
|
|
643
|
+
</div>
|
|
644
|
+
</section>
|
|
645
|
+
` : "";
|
|
646
|
+
}
|
|
647
|
+
renderAddLocationPanel(e, t) {
|
|
648
|
+
return this.addLocationOpen ? `
|
|
649
|
+
<section class="clock-config-add-panel">
|
|
650
|
+
<label class="clock-config-field">
|
|
651
|
+
<span class="clock-config-field__label">Search city</span>
|
|
652
|
+
<input
|
|
653
|
+
type="search"
|
|
654
|
+
value="${c(this.addLocationQuery)}"
|
|
655
|
+
data-setting="addLocationQuery"
|
|
656
|
+
placeholder="Start typing a city"
|
|
657
|
+
spellcheck="false"
|
|
658
|
+
autocapitalize="words"
|
|
659
|
+
autocomplete="off"
|
|
660
|
+
/>
|
|
661
|
+
</label>
|
|
662
|
+
<div class="clock-config-search-results">
|
|
663
|
+
${e.length ? e.map((r) => `
|
|
664
|
+
<button
|
|
665
|
+
type="button"
|
|
666
|
+
class="clock-config-search-result ${this.selectedCommonCityKey === k(r) ? "clock-config-search-result--selected" : ""}"
|
|
667
|
+
data-action="select-common-city"
|
|
668
|
+
data-city-key="${c(k(r))}"
|
|
669
|
+
>
|
|
670
|
+
<span>${c(r.label)}</span>
|
|
671
|
+
<span>${c(r.country)} · ${c(r.timeZone)}</span>
|
|
672
|
+
</button>
|
|
673
|
+
`).join("") : '<div class="clock-config-search-empty">No common city match. Use <strong>Advanced</strong> to add a custom city.</div>'}
|
|
674
|
+
</div>
|
|
675
|
+
${t ? `
|
|
676
|
+
<div class="clock-config-add-confirm">
|
|
677
|
+
<div class="clock-config-add-confirm__city">
|
|
678
|
+
Weather will use ${c(t.weatherQuery)}.
|
|
679
|
+
</div>
|
|
680
|
+
<label class="clock-config-field">
|
|
681
|
+
<span class="clock-config-field__label">Preferred name</span>
|
|
682
|
+
<input
|
|
683
|
+
type="text"
|
|
684
|
+
value="${c(this.addLocationPreferredName)}"
|
|
685
|
+
data-setting="addLocationPreferredName"
|
|
686
|
+
placeholder="${c(t.label)}"
|
|
687
|
+
/>
|
|
688
|
+
</label>
|
|
689
|
+
<div class="clock-config-add-confirm__actions">
|
|
690
|
+
<button type="button" class="clock-config-drawer__ghost" data-action="cancel-add-location">Cancel</button>
|
|
691
|
+
<button type="button" class="clock-config-drawer__primary" data-action="confirm-add-location">Add city</button>
|
|
692
|
+
</div>
|
|
693
|
+
</div>
|
|
694
|
+
` : ""}
|
|
695
|
+
</section>
|
|
696
|
+
` : "";
|
|
697
|
+
}
|
|
698
|
+
renderAdvancedSettings(e) {
|
|
699
|
+
return `
|
|
700
|
+
<section class="clock-config-advanced ${this.advancedSettingsOpen ? "clock-config-advanced--open" : ""}">
|
|
701
|
+
<div class="clock-config-advanced__grid">
|
|
702
|
+
<label class="clock-config-field clock-config-field--toggle">
|
|
703
|
+
<span class="clock-config-field__label">Weather</span>
|
|
704
|
+
<span class="clock-config-field__toggle-row">
|
|
705
|
+
<input
|
|
706
|
+
type="checkbox"
|
|
707
|
+
data-setting="weatherEnabled"
|
|
708
|
+
${e.weatherEnabled ? "checked" : ""}
|
|
709
|
+
/>
|
|
710
|
+
<span>${e.weatherEnabled ? "Enabled" : "Disabled"}</span>
|
|
711
|
+
</span>
|
|
712
|
+
</label>
|
|
713
|
+
<label class="clock-config-field clock-config-field--wide">
|
|
714
|
+
<span class="clock-config-field__label">Weather endpoint</span>
|
|
715
|
+
<input
|
|
716
|
+
type="text"
|
|
717
|
+
value="${c(e.weatherEndpoint)}"
|
|
718
|
+
placeholder="/api/weather/clocks"
|
|
719
|
+
data-setting="weatherEndpoint"
|
|
720
|
+
/>
|
|
721
|
+
</label>
|
|
722
|
+
<label class="clock-config-field clock-config-field--wide">
|
|
723
|
+
<span class="clock-config-field__label">Visual preset</span>
|
|
724
|
+
<select data-setting="visualPreset">
|
|
725
|
+
${["default", "minimal", "cinematic", "wallboard"].map((t) => `<option value="${t}" ${e.visualPreset === t ? "selected" : ""}>${t}</option>`).join("")}
|
|
726
|
+
</select>
|
|
727
|
+
</label>
|
|
728
|
+
</div>
|
|
729
|
+
<div class="clock-config-advanced__custom">
|
|
730
|
+
<div class="clock-config-drawer__list-title">Custom city</div>
|
|
731
|
+
<div class="clock-config-location">
|
|
732
|
+
<label class="clock-config-field">
|
|
733
|
+
<span class="clock-config-field__label">Preferred name</span>
|
|
734
|
+
<input type="text" value="${c(this.customLocationDraft.label)}" data-setting="customLabel" placeholder="Reykjavik" />
|
|
735
|
+
</label>
|
|
736
|
+
<label class="clock-config-field">
|
|
737
|
+
<span class="clock-config-field__label">Weather city</span>
|
|
738
|
+
<input type="text" value="${c(this.customLocationDraft.weatherQuery)}" data-setting="customWeatherQuery" placeholder="Reykjavik, Iceland" />
|
|
739
|
+
</label>
|
|
740
|
+
<label class="clock-config-field clock-config-field--time-zone">
|
|
741
|
+
<span class="clock-config-field__label">Time zone</span>
|
|
742
|
+
<input
|
|
743
|
+
type="search"
|
|
744
|
+
list="${_}"
|
|
745
|
+
value="${c(this.customLocationDraft.timeZone)}"
|
|
746
|
+
data-setting="customTimeZone"
|
|
747
|
+
placeholder="Search IANA time zone"
|
|
748
|
+
spellcheck="false"
|
|
749
|
+
autocapitalize="off"
|
|
750
|
+
autocomplete="off"
|
|
751
|
+
/>
|
|
752
|
+
</label>
|
|
753
|
+
<button type="button" class="clock-config-location__remove" data-action="add-custom-location">Add</button>
|
|
754
|
+
</div>
|
|
755
|
+
</div>
|
|
756
|
+
</section>
|
|
757
|
+
`;
|
|
758
|
+
}
|
|
759
|
+
renderConfigLocationListItem(e, t) {
|
|
760
|
+
return this.pendingDeleteIndex === t ? `
|
|
761
|
+
<li class="clock-config-location-list__item clock-config-location-list__item--confirm">
|
|
762
|
+
<span class="clock-config-location-list__bullet">-</span>
|
|
763
|
+
<div class="clock-config-location-list__body">
|
|
764
|
+
<div class="clock-config-location-list__confirm">Remove ${c(e.label)}?</div>
|
|
765
|
+
<div class="clock-config-location-list__actions">
|
|
766
|
+
<button type="button" class="clock-config-drawer__ghost" data-action="cancel-remove-location">No</button>
|
|
767
|
+
<button type="button" class="clock-config-location__remove" data-action="confirm-remove-location" data-index="${t}">Remove</button>
|
|
768
|
+
</div>
|
|
769
|
+
</div>
|
|
770
|
+
</li>
|
|
771
|
+
` : this.selectedLocationIndex === t ? `
|
|
772
|
+
<li class="clock-config-location-list__item clock-config-location-list__item--selected" part="config-location">
|
|
773
|
+
<span class="clock-config-location-list__bullet">-</span>
|
|
774
|
+
<div class="clock-config-location-list__body clock-config-location-list__body--edit">
|
|
775
|
+
<label class="clock-config-field">
|
|
776
|
+
<span class="clock-config-field__label">Screen name</span>
|
|
777
|
+
<input
|
|
778
|
+
type="text"
|
|
779
|
+
value="${c(e.label)}"
|
|
780
|
+
data-index="${t}"
|
|
781
|
+
data-field="label"
|
|
782
|
+
placeholder="Macau"
|
|
783
|
+
/>
|
|
784
|
+
</label>
|
|
785
|
+
<label class="clock-config-field">
|
|
786
|
+
<span class="clock-config-field__label">Weather city</span>
|
|
787
|
+
<input
|
|
788
|
+
type="text"
|
|
789
|
+
value="${c(e.weatherQuery)}"
|
|
790
|
+
data-index="${t}"
|
|
791
|
+
data-field="weatherQuery"
|
|
792
|
+
placeholder="Macau"
|
|
793
|
+
/>
|
|
794
|
+
</label>
|
|
795
|
+
<div class="clock-config-location-list__meta">${c(e.timeZone)}</div>
|
|
796
|
+
</div>
|
|
797
|
+
<button type="button" class="clock-config-location__remove" data-action="request-remove-location" data-index="${t}">Remove</button>
|
|
798
|
+
</li>
|
|
799
|
+
` : `
|
|
800
|
+
<li class="clock-config-location-list__item" part="config-location">
|
|
801
|
+
<span class="clock-config-location-list__bullet">-</span>
|
|
802
|
+
<button type="button" class="clock-config-location-list__body clock-config-location-list__body--button" data-action="select-location" data-index="${t}">
|
|
803
|
+
<div class="clock-config-location-list__title">${c(e.label)}</div>
|
|
804
|
+
<div class="clock-config-location-list__meta">${c(e.timeZone)}</div>
|
|
805
|
+
</button>
|
|
806
|
+
<button type="button" class="clock-config-location__remove" data-action="request-remove-location" data-index="${t}">Remove</button>
|
|
807
|
+
</li>
|
|
808
|
+
`;
|
|
809
|
+
}
|
|
810
|
+
getFilteredCommonCities() {
|
|
811
|
+
const e = new Set(
|
|
812
|
+
this.configDraftState.locations.map((r) => m(r))
|
|
813
|
+
), t = this.addLocationQuery.trim().toLowerCase();
|
|
814
|
+
return g.filter((r) => !e.has(m(r))).filter((r) => t ? `${r.label} ${r.country} ${r.timeZone} ${r.weatherQuery}`.toLowerCase().includes(t) : !0).slice(0, 8);
|
|
815
|
+
}
|
|
816
|
+
getSelectedCommonCity() {
|
|
817
|
+
return g.find((e) => k(e) === this.selectedCommonCityKey) ?? null;
|
|
818
|
+
}
|
|
819
|
+
resetAddLocationUi() {
|
|
820
|
+
this.addLocationQuery = "", this.addLocationPreferredName = "", this.selectedCommonCityKey = "";
|
|
821
|
+
}
|
|
822
|
+
resetTransientConfigUi() {
|
|
823
|
+
this.pendingDeleteIndex = null, this.selectedLocationIndex = null, this.advancedSettingsOpen = !1, this.addLocationOpen = !1, this.resetAddLocationUi(), this.customLocationDraft = { label: "", timeZone: "", weatherQuery: "" };
|
|
824
|
+
}
|
|
825
|
+
async copyShareLink() {
|
|
826
|
+
const e = se(this.config, this.shareQueryParamState);
|
|
827
|
+
await N(e), this.setStatusMessage("Share link copied");
|
|
828
|
+
}
|
|
829
|
+
async copyConfigJson() {
|
|
830
|
+
const e = JSON.stringify(this.config, null, 2);
|
|
831
|
+
await N(e), this.importExportDraft = e, this.setStatusMessage("Config JSON copied"), this.render();
|
|
832
|
+
}
|
|
833
|
+
importConfigJson() {
|
|
834
|
+
try {
|
|
835
|
+
const e = JSON.parse(this.importExportDraft), t = b(e);
|
|
836
|
+
this.applyConfigValue(t, "api"), this.setStatusMessage("Config imported"), this.render();
|
|
837
|
+
} catch (e) {
|
|
838
|
+
this.setStatusMessage(e instanceof Error ? e.message : "Invalid config JSON"), this.render();
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
getSavedPresets() {
|
|
842
|
+
try {
|
|
843
|
+
const e = window.localStorage.getItem(S);
|
|
844
|
+
if (!e)
|
|
845
|
+
return [];
|
|
846
|
+
const t = JSON.parse(e);
|
|
847
|
+
return Array.isArray(t) ? t.filter((r) => r && typeof r.name == "string" && r.config).map((r) => ({ name: r.name, config: b(r.config) })) : [];
|
|
848
|
+
} catch {
|
|
849
|
+
return [];
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
writeSavedPresets(e) {
|
|
853
|
+
window.localStorage.setItem(S, JSON.stringify(e));
|
|
854
|
+
}
|
|
855
|
+
saveCurrentPreset() {
|
|
856
|
+
const e = this.presetNameDraft.trim();
|
|
857
|
+
if (!e) {
|
|
858
|
+
this.setStatusMessage("Enter a preset name"), this.render();
|
|
859
|
+
return;
|
|
860
|
+
}
|
|
861
|
+
const t = this.getSavedPresets().filter((r) => r.name !== e);
|
|
862
|
+
t.unshift({ name: e, config: this.config }), this.writeSavedPresets(t), this.presetNameDraft = "", this.setStatusMessage("Preset saved"), this.render();
|
|
863
|
+
}
|
|
864
|
+
loadSavedPreset(e) {
|
|
865
|
+
const t = this.getSavedPresets().find((r) => r.name === e);
|
|
866
|
+
t && (this.applyConfigValue(t.config, "preset"), this.setStatusMessage(`Loaded preset: ${e}`), this.render());
|
|
867
|
+
}
|
|
868
|
+
deleteSavedPreset(e) {
|
|
869
|
+
const t = this.getSavedPresets().filter((r) => r.name !== e);
|
|
870
|
+
this.writeSavedPresets(t), this.setStatusMessage(`Deleted preset: ${e}`), this.render();
|
|
871
|
+
}
|
|
872
|
+
setStatusMessage(e) {
|
|
873
|
+
this.statusMessage = e, window.setTimeout(() => {
|
|
874
|
+
this.statusMessage === e && (this.statusMessage = "", this.render());
|
|
875
|
+
}, 2200);
|
|
876
|
+
}
|
|
877
|
+
captureRenderFocus() {
|
|
878
|
+
const e = this.root.activeElement;
|
|
879
|
+
if (!(e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement))
|
|
880
|
+
return null;
|
|
881
|
+
const t = e.dataset.setting;
|
|
882
|
+
if (t)
|
|
883
|
+
return {
|
|
884
|
+
selector: `[data-setting="${t}"]`,
|
|
885
|
+
start: e.selectionStart,
|
|
886
|
+
end: e.selectionEnd
|
|
887
|
+
};
|
|
888
|
+
const r = e.dataset.field, i = e.dataset.index;
|
|
889
|
+
return r && i != null ? {
|
|
890
|
+
selector: `[data-field="${r}"][data-index="${i}"]`,
|
|
891
|
+
start: e.selectionStart,
|
|
892
|
+
end: e.selectionEnd
|
|
893
|
+
} : null;
|
|
894
|
+
}
|
|
895
|
+
restoreRenderFocus(e) {
|
|
896
|
+
if (!e)
|
|
897
|
+
return;
|
|
898
|
+
const t = this.root.querySelector(e.selector);
|
|
899
|
+
if (t && (t.focus(), e.start != null && e.end != null))
|
|
900
|
+
try {
|
|
901
|
+
t.setSelectionRange(e.start, e.end);
|
|
902
|
+
} catch {
|
|
903
|
+
return;
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
renderClockMarker(e) {
|
|
907
|
+
const t = e.label, r = e.timeParts.timeText, i = e.timeParts.dayText, n = j(
|
|
908
|
+
e.weather,
|
|
909
|
+
q()
|
|
910
|
+
), o = z(e.positionPercent), s = o === "clock-marker--edge-left" ? `left:${e.edgeInsetPx != null ? e.edgeInsetPx : Math.max(10, e.labelOffsetPx || 0)}px;` : o === "clock-marker--edge-right" ? `right:${e.edgeInsetPx != null ? e.edgeInsetPx : Math.max(10, -(e.labelOffsetPx || 0))}px;left:auto;` : `left:calc(${e.positionPercent}% ${K(e.labelOffsetPx || 0)});`, l = [t, r, i, n].filter(Boolean).join(" · ");
|
|
911
|
+
return `
|
|
912
|
+
<article
|
|
913
|
+
class="clock-marker ${o}"
|
|
914
|
+
part="marker"
|
|
915
|
+
title="${c(l)}"
|
|
916
|
+
style="${s}--clock-lane:${e.lane};"
|
|
917
|
+
>
|
|
918
|
+
${this.renderClockWeatherBackdrop(e)}
|
|
919
|
+
<div class="clock-marker__text" part="label">${c(t)}</div>
|
|
920
|
+
<div class="clock-marker__text clock-marker__text--time" part="time">${c(r)}</div>
|
|
921
|
+
<div class="clock-marker__meta" part="meta">${c(i)}</div>
|
|
922
|
+
${n ? `<div class="clock-marker__temp" part="temperature">${c(n)}</div>` : ""}
|
|
923
|
+
</article>
|
|
924
|
+
`;
|
|
925
|
+
}
|
|
926
|
+
renderClockWeatherBackdrop(e) {
|
|
927
|
+
if (!this.weatherEnabledState)
|
|
928
|
+
return "";
|
|
929
|
+
const t = e.weather, r = t && t.state === "pass" ? String(t.condition || "cloudy") : G(e.timeParts.hour24), i = ge(r, t, e.timeParts.hour24);
|
|
930
|
+
return `
|
|
931
|
+
<div
|
|
932
|
+
class="clock-weather clock-weather--image clock-weather--${c(r)}"
|
|
933
|
+
aria-hidden="true"
|
|
934
|
+
style="--clock-weather-image:url('${i}')"
|
|
935
|
+
></div>
|
|
936
|
+
`;
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
function R(a = I) {
|
|
940
|
+
const e = customElements.get(a);
|
|
941
|
+
return e || (customElements.define(a, L), L);
|
|
942
|
+
}
|
|
943
|
+
function Ee(a = {}) {
|
|
944
|
+
R();
|
|
945
|
+
const e = document.createElement(I);
|
|
946
|
+
return a.locations && (e.locations = a.locations), a.weatherEnabled != null && (e.weatherEnabled = a.weatherEnabled), a.weatherEndpoint && (e.weatherEndpoint = a.weatherEndpoint), a.visualPreset && (e.visualPreset = a.visualPreset), a.readOnly != null && (e.readOnly = a.readOnly), a.persistKey && (e.persistKey = a.persistKey), a.enableUrlState != null && e.setAttribute("enable-url-state", String(a.enableUrlState)), a.shareQueryParam && (e.shareQueryParam = a.shareQueryParam), a.cityCatalog && (e.cityCatalog = a.cityCatalog), a.weatherOverrides && (e.weatherOverrides = a.weatherOverrides), e;
|
|
947
|
+
}
|
|
948
|
+
function u(a) {
|
|
949
|
+
const e = (Array.isArray(a) ? a : w).map((i) => ({
|
|
950
|
+
label: String(i?.label || "").trim(),
|
|
951
|
+
timeZone: String(i?.timeZone || "").trim(),
|
|
952
|
+
weatherQuery: String(i?.weatherQuery || i?.label || "").trim()
|
|
953
|
+
})).filter((i) => i.label && i.timeZone), t = [];
|
|
954
|
+
let r = !1;
|
|
955
|
+
for (const i of e) {
|
|
956
|
+
if (Ce(i))
|
|
957
|
+
continue;
|
|
958
|
+
if (ve(i)) {
|
|
959
|
+
r || (t.push({ label: "Macau", timeZone: "Asia/Macau", weatherQuery: "Macau" }), r = !0);
|
|
960
|
+
continue;
|
|
961
|
+
}
|
|
962
|
+
t.some(
|
|
963
|
+
(o) => o.label.toLowerCase() === i.label.toLowerCase() && o.timeZone.toLowerCase() === i.timeZone.toLowerCase()
|
|
964
|
+
) || t.push(i);
|
|
965
|
+
}
|
|
966
|
+
return t.sort(Ae);
|
|
967
|
+
}
|
|
968
|
+
function b(a) {
|
|
969
|
+
return {
|
|
970
|
+
locations: u(a.locations),
|
|
971
|
+
weatherEnabled: a.weatherEnabled !== !1,
|
|
972
|
+
weatherEndpoint: String(a.weatherEndpoint || "").trim(),
|
|
973
|
+
visualPreset: h(a.visualPreset)
|
|
974
|
+
};
|
|
975
|
+
}
|
|
976
|
+
function h(a) {
|
|
977
|
+
return a === "minimal" || a === "cinematic" || a === "wallboard" ? a : "default";
|
|
978
|
+
}
|
|
979
|
+
function Z(a) {
|
|
980
|
+
return (Array.isArray(a) ? a : g).map((t) => ({
|
|
981
|
+
label: String(t?.label || "").trim(),
|
|
982
|
+
timeZone: String(t?.timeZone || "").trim(),
|
|
983
|
+
weatherQuery: String(t?.weatherQuery || t?.label || "").trim(),
|
|
984
|
+
country: String(t?.country || "").trim()
|
|
985
|
+
})).filter((t) => t.label && t.timeZone && t.weatherQuery);
|
|
986
|
+
}
|
|
987
|
+
function P(a, e) {
|
|
988
|
+
if (!a)
|
|
989
|
+
return u(e);
|
|
990
|
+
try {
|
|
991
|
+
const t = JSON.parse(a);
|
|
992
|
+
return u(t);
|
|
993
|
+
} catch (t) {
|
|
994
|
+
return console.error("Invalid world clock locations attribute", t), u(e);
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
function D(a) {
|
|
998
|
+
return `linear-gradient(90deg, ${a.map((e) => `${e.color} ${e.percent}%`).join(", ")})`;
|
|
999
|
+
}
|
|
1000
|
+
function W(a) {
|
|
1001
|
+
return a.map((e) => ({
|
|
1002
|
+
...e,
|
|
1003
|
+
lane: 0,
|
|
1004
|
+
labelOffsetPx: 0
|
|
1005
|
+
}));
|
|
1006
|
+
}
|
|
1007
|
+
function K(a) {
|
|
1008
|
+
const e = Number(a || 0);
|
|
1009
|
+
return e < 0 ? `- ${Math.abs(e)}px` : `+ ${e}px`;
|
|
1010
|
+
}
|
|
1011
|
+
function z(a) {
|
|
1012
|
+
return a <= 8 ? "clock-marker--edge-left" : a >= 92 ? "clock-marker--edge-right" : "";
|
|
1013
|
+
}
|
|
1014
|
+
function F(a, e) {
|
|
1015
|
+
try {
|
|
1016
|
+
const r = new Intl.DateTimeFormat("en-US", {
|
|
1017
|
+
timeZone: a,
|
|
1018
|
+
weekday: "long",
|
|
1019
|
+
hour: "numeric",
|
|
1020
|
+
minute: "2-digit",
|
|
1021
|
+
hour12: !0,
|
|
1022
|
+
timeZoneName: "short"
|
|
1023
|
+
}).formatToParts(e), i = Object.fromEntries(r.map((l) => [l.type, l.value])), n = Number(i.hour || "0"), o = String(i.dayPeriod || "").toUpperCase();
|
|
1024
|
+
return {
|
|
1025
|
+
hour24: o === "PM" && n < 12 ? n + 12 : o === "AM" && n === 12 ? 0 : n,
|
|
1026
|
+
minute24: Number(i.minute || "0"),
|
|
1027
|
+
timeText: `${i.hour || ""}:${i.minute || ""} ${i.dayPeriod || ""}`.trim(),
|
|
1028
|
+
dayText: O(a, e, String(i.weekday || "")),
|
|
1029
|
+
zoneText: String(i.timeZoneName || a)
|
|
1030
|
+
};
|
|
1031
|
+
} catch {
|
|
1032
|
+
return {
|
|
1033
|
+
hour24: e.getHours(),
|
|
1034
|
+
minute24: e.getMinutes(),
|
|
1035
|
+
timeText: e.toLocaleTimeString("en-US", { hour: "numeric", minute: "2-digit" }),
|
|
1036
|
+
dayText: O(a, e, e.toLocaleDateString("en-US", { weekday: "long" })),
|
|
1037
|
+
zoneText: a
|
|
1038
|
+
};
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
function O(a, e, t) {
|
|
1042
|
+
const r = U(a, e);
|
|
1043
|
+
return r ? `${t} ${r}${H(r)}` : t;
|
|
1044
|
+
}
|
|
1045
|
+
function U(a, e) {
|
|
1046
|
+
try {
|
|
1047
|
+
const i = new Intl.DateTimeFormat("en-US", {
|
|
1048
|
+
timeZone: a,
|
|
1049
|
+
day: "numeric"
|
|
1050
|
+
}).formatToParts(e).find((o) => o.type === "day"), n = Number(i?.value || "");
|
|
1051
|
+
return Number.isFinite(n) ? n : null;
|
|
1052
|
+
} catch {
|
|
1053
|
+
const t = e.getDate();
|
|
1054
|
+
return Number.isFinite(t) ? t : null;
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
function H(a) {
|
|
1058
|
+
const e = a % 100;
|
|
1059
|
+
if (e >= 11 && e <= 13)
|
|
1060
|
+
return "th";
|
|
1061
|
+
const t = a % 10;
|
|
1062
|
+
return t === 1 ? "st" : t === 2 ? "nd" : t === 3 ? "rd" : "th";
|
|
1063
|
+
}
|
|
1064
|
+
function j(a, e) {
|
|
1065
|
+
const t = a?.state === "pass" ? Number(a.temperature) : Number.NaN;
|
|
1066
|
+
if (!Number.isFinite(t))
|
|
1067
|
+
return "";
|
|
1068
|
+
const r = J(e), i = r === "F" ? B(t) : t;
|
|
1069
|
+
return `${Math.round(i)}°${r}`;
|
|
1070
|
+
}
|
|
1071
|
+
function J(a) {
|
|
1072
|
+
return Q.has(a) ? "F" : "C";
|
|
1073
|
+
}
|
|
1074
|
+
function q() {
|
|
1075
|
+
try {
|
|
1076
|
+
return String(Intl.DateTimeFormat().resolvedOptions().timeZone || "").trim();
|
|
1077
|
+
} catch {
|
|
1078
|
+
return "";
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1081
|
+
function B(a) {
|
|
1082
|
+
return a * 9 / 5 + 32;
|
|
1083
|
+
}
|
|
1084
|
+
function Y(a, e, t) {
|
|
1085
|
+
const r = m(a);
|
|
1086
|
+
return Object.prototype.hasOwnProperty.call(t, r) ? t[r] : e.get(r) ?? null;
|
|
1087
|
+
}
|
|
1088
|
+
function G(a) {
|
|
1089
|
+
return a >= 6 && a < 18 ? "clear-day" : "clear-night";
|
|
1090
|
+
}
|
|
1091
|
+
function V(a) {
|
|
1092
|
+
if (!a.length)
|
|
1093
|
+
return D(M());
|
|
1094
|
+
const e = a.map((o) => ({
|
|
1095
|
+
x: o.positionPercent,
|
|
1096
|
+
time: ee(o.timeParts)
|
|
1097
|
+
})), t = te(e), r = [
|
|
1098
|
+
...t.map((o) => ({ x: o.x - 100, time: o.time - 100 })),
|
|
1099
|
+
...t,
|
|
1100
|
+
...t.map((o) => ({ x: o.x + 100, time: o.time + 100 }))
|
|
1101
|
+
].sort((o, s) => o.x - s.x), i = 72, n = [];
|
|
1102
|
+
for (let o = 0; o <= i; o += 1) {
|
|
1103
|
+
const s = Number((o / i * 100).toFixed(2)), l = ae(s, r);
|
|
1104
|
+
n.push({
|
|
1105
|
+
color: re(l),
|
|
1106
|
+
percent: s
|
|
1107
|
+
});
|
|
1108
|
+
}
|
|
1109
|
+
return D(n);
|
|
1110
|
+
}
|
|
1111
|
+
function X(a, e) {
|
|
1112
|
+
if (e <= 1)
|
|
1113
|
+
return 50;
|
|
1114
|
+
const t = 12, r = 100 - t * 2;
|
|
1115
|
+
return Number((t + r * a / (e - 1)).toFixed(2));
|
|
1116
|
+
}
|
|
1117
|
+
function M() {
|
|
1118
|
+
return [
|
|
1119
|
+
{ color: "#08111b", percent: 0 },
|
|
1120
|
+
{ color: "#0d1c30", percent: 18 },
|
|
1121
|
+
{ color: "#1f3048", percent: 20.83 },
|
|
1122
|
+
{ color: "#5f5163", percent: 24 },
|
|
1123
|
+
{ color: "#d18b59", percent: 29.17 },
|
|
1124
|
+
{ color: "#5e8bb9", percent: 36 },
|
|
1125
|
+
{ color: "#8cc4e7", percent: 45.83 },
|
|
1126
|
+
{ color: "#dceff8", percent: 58 },
|
|
1127
|
+
{ color: "#7ab6df", percent: 70.83 },
|
|
1128
|
+
{ color: "#5e7692", percent: 74.5 },
|
|
1129
|
+
{ color: "#9c6149", percent: 76.5 },
|
|
1130
|
+
{ color: "#d98d55", percent: 77.8 },
|
|
1131
|
+
{ color: "#402e43", percent: 79.17 },
|
|
1132
|
+
{ color: "#111d31", percent: 81.25 },
|
|
1133
|
+
{ color: "#08111b", percent: 86 },
|
|
1134
|
+
{ color: "#08111b", percent: 100 }
|
|
1135
|
+
];
|
|
1136
|
+
}
|
|
1137
|
+
function ee(a) {
|
|
1138
|
+
return (Number(a.hour24 || 0) * 60 + Number(a.minute24 || 0)) % 1440 / 1440 * 100;
|
|
1139
|
+
}
|
|
1140
|
+
function te(a) {
|
|
1141
|
+
if (!a.length)
|
|
1142
|
+
return [];
|
|
1143
|
+
const e = [{ ...a[0] }];
|
|
1144
|
+
let t = a[0].time;
|
|
1145
|
+
for (let r = 1; r < a.length; r += 1) {
|
|
1146
|
+
let i = a[r].time;
|
|
1147
|
+
for (; i < t; )
|
|
1148
|
+
i += 100;
|
|
1149
|
+
e.push({
|
|
1150
|
+
x: a[r].x,
|
|
1151
|
+
time: i
|
|
1152
|
+
}), t = i;
|
|
1153
|
+
}
|
|
1154
|
+
return e;
|
|
1155
|
+
}
|
|
1156
|
+
function ae(a, e) {
|
|
1157
|
+
if (!e.length)
|
|
1158
|
+
return 0;
|
|
1159
|
+
for (let t = 0; t < e.length - 1; t += 1) {
|
|
1160
|
+
const r = e[t], i = e[t + 1];
|
|
1161
|
+
if (a < r.x || a > i.x)
|
|
1162
|
+
continue;
|
|
1163
|
+
const n = i.x - r.x;
|
|
1164
|
+
if (n <= 0)
|
|
1165
|
+
return r.time;
|
|
1166
|
+
const o = (a - r.x) / n;
|
|
1167
|
+
return r.time + (i.time - r.time) * o;
|
|
1168
|
+
}
|
|
1169
|
+
return e[e.length - 1].time;
|
|
1170
|
+
}
|
|
1171
|
+
function re(a) {
|
|
1172
|
+
const e = (a % 100 + 100) % 100, t = M();
|
|
1173
|
+
for (let r = 0; r < t.length - 1; r += 1) {
|
|
1174
|
+
const i = t[r], n = t[r + 1];
|
|
1175
|
+
if (e < i.percent || e > n.percent)
|
|
1176
|
+
continue;
|
|
1177
|
+
const o = n.percent - i.percent;
|
|
1178
|
+
if (o <= 0)
|
|
1179
|
+
return i.color;
|
|
1180
|
+
const s = (e - i.percent) / o;
|
|
1181
|
+
return ie(i.color, n.color, s);
|
|
1182
|
+
}
|
|
1183
|
+
return t[t.length - 1].color;
|
|
1184
|
+
}
|
|
1185
|
+
function ie(a, e, t) {
|
|
1186
|
+
const r = $(a), i = $(e);
|
|
1187
|
+
return ne({
|
|
1188
|
+
r: Math.round(r.r + (i.r - r.r) * t),
|
|
1189
|
+
g: Math.round(r.g + (i.g - r.g) * t),
|
|
1190
|
+
b: Math.round(r.b + (i.b - r.b) * t)
|
|
1191
|
+
});
|
|
1192
|
+
}
|
|
1193
|
+
function $(a) {
|
|
1194
|
+
const e = a.replace("#", "");
|
|
1195
|
+
return {
|
|
1196
|
+
r: Number.parseInt(e.slice(0, 2), 16),
|
|
1197
|
+
g: Number.parseInt(e.slice(2, 4), 16),
|
|
1198
|
+
b: Number.parseInt(e.slice(4, 6), 16)
|
|
1199
|
+
};
|
|
1200
|
+
}
|
|
1201
|
+
function ne(a) {
|
|
1202
|
+
return `#${[a.r, a.g, a.b].map((e) => e.toString(16).padStart(2, "0")).join("")}`;
|
|
1203
|
+
}
|
|
1204
|
+
function oe() {
|
|
1205
|
+
try {
|
|
1206
|
+
if (typeof Intl.supportedValuesOf == "function")
|
|
1207
|
+
return Intl.supportedValuesOf("timeZone");
|
|
1208
|
+
} catch {
|
|
1209
|
+
return E;
|
|
1210
|
+
}
|
|
1211
|
+
return E;
|
|
1212
|
+
}
|
|
1213
|
+
function d(a) {
|
|
1214
|
+
const e = ["..", "assets", "weather", a].join("/");
|
|
1215
|
+
return new URL(e, import.meta.url).href;
|
|
1216
|
+
}
|
|
1217
|
+
function ce(a) {
|
|
1218
|
+
try {
|
|
1219
|
+
const t = new URL(window.location.href).searchParams.get(a);
|
|
1220
|
+
return t ? fe(t) : null;
|
|
1221
|
+
} catch {
|
|
1222
|
+
return null;
|
|
1223
|
+
}
|
|
1224
|
+
}
|
|
1225
|
+
function se(a, e) {
|
|
1226
|
+
const t = new URL(window.location.href);
|
|
1227
|
+
return t.searchParams.set(e, ue(a)), t.toString();
|
|
1228
|
+
}
|
|
1229
|
+
function le(a) {
|
|
1230
|
+
try {
|
|
1231
|
+
const e = window.localStorage.getItem(a);
|
|
1232
|
+
return e ? b(JSON.parse(e)) : null;
|
|
1233
|
+
} catch {
|
|
1234
|
+
return null;
|
|
1235
|
+
}
|
|
1236
|
+
}
|
|
1237
|
+
function de(a, e) {
|
|
1238
|
+
window.localStorage.setItem(a, JSON.stringify(e));
|
|
1239
|
+
}
|
|
1240
|
+
function ue(a) {
|
|
1241
|
+
return pe(JSON.stringify(b(a)));
|
|
1242
|
+
}
|
|
1243
|
+
function fe(a) {
|
|
1244
|
+
const e = he(a);
|
|
1245
|
+
return b(JSON.parse(e));
|
|
1246
|
+
}
|
|
1247
|
+
function pe(a) {
|
|
1248
|
+
return btoa(unescape(encodeURIComponent(a))).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/g, "");
|
|
1249
|
+
}
|
|
1250
|
+
function he(a) {
|
|
1251
|
+
const e = a.replace(/-/g, "+").replace(/_/g, "/").padEnd(Math.ceil(a.length / 4) * 4, "=");
|
|
1252
|
+
return decodeURIComponent(escape(atob(e)));
|
|
1253
|
+
}
|
|
1254
|
+
async function N(a) {
|
|
1255
|
+
if (navigator.clipboard?.writeText) {
|
|
1256
|
+
await navigator.clipboard.writeText(a);
|
|
1257
|
+
return;
|
|
1258
|
+
}
|
|
1259
|
+
const e = document.createElement("textarea");
|
|
1260
|
+
e.value = a, document.body.append(e), e.select(), document.execCommand("copy"), e.remove();
|
|
1261
|
+
}
|
|
1262
|
+
function ge(a, e, t) {
|
|
1263
|
+
return a === "partly-cloudy" ? me(e, t) ? d("Partly_Cloudy_Day.webp") : d("Partly_Cloudy.webp") : A[a] || A.cloudy;
|
|
1264
|
+
}
|
|
1265
|
+
function me(a, e) {
|
|
1266
|
+
return a && typeof a.isDay == "boolean" ? a.isDay : e >= 6 && e < 18;
|
|
1267
|
+
}
|
|
1268
|
+
function m(a) {
|
|
1269
|
+
const e = String(a.weatherQuery || a.label || "").trim().toLowerCase(), t = String(a.timeZone || "").trim().toLowerCase();
|
|
1270
|
+
return `${e}__${t}`;
|
|
1271
|
+
}
|
|
1272
|
+
function k(a) {
|
|
1273
|
+
return `${a.label.toLowerCase()}__${a.timeZone.toLowerCase()}`;
|
|
1274
|
+
}
|
|
1275
|
+
async function be(a, e, t) {
|
|
1276
|
+
return e ? ke(a, e, t) : we(a, t);
|
|
1277
|
+
}
|
|
1278
|
+
async function ke(a, e, t) {
|
|
1279
|
+
const r = await fetch(e, {
|
|
1280
|
+
method: "POST",
|
|
1281
|
+
headers: {
|
|
1282
|
+
"Content-Type": "application/json"
|
|
1283
|
+
},
|
|
1284
|
+
body: JSON.stringify({ locations: a }),
|
|
1285
|
+
signal: t
|
|
1286
|
+
});
|
|
1287
|
+
if (!r.ok)
|
|
1288
|
+
throw new Error(`Weather endpoint returned ${r.status}`);
|
|
1289
|
+
const i = await r.json();
|
|
1290
|
+
return {
|
|
1291
|
+
fetchedAt: String(i?.fetchedAt || (/* @__PURE__ */ new Date()).toISOString()),
|
|
1292
|
+
locations: Array.isArray(i?.locations) ? i.locations : []
|
|
1293
|
+
};
|
|
1294
|
+
}
|
|
1295
|
+
async function we(a, e) {
|
|
1296
|
+
const t = await Promise.all(
|
|
1297
|
+
a.map(async (r) => {
|
|
1298
|
+
try {
|
|
1299
|
+
return await ye(r, e);
|
|
1300
|
+
} catch (i) {
|
|
1301
|
+
return {
|
|
1302
|
+
label: r.label,
|
|
1303
|
+
timeZone: r.timeZone,
|
|
1304
|
+
weatherQuery: String(r.weatherQuery || r.label || "").trim(),
|
|
1305
|
+
weather: {
|
|
1306
|
+
state: "fail",
|
|
1307
|
+
condition: "unknown",
|
|
1308
|
+
description: i instanceof Error ? i.message : "Weather request failed"
|
|
1309
|
+
}
|
|
1310
|
+
};
|
|
1311
|
+
}
|
|
1312
|
+
})
|
|
1313
|
+
);
|
|
1314
|
+
return {
|
|
1315
|
+
fetchedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1316
|
+
locations: t
|
|
1317
|
+
};
|
|
1318
|
+
}
|
|
1319
|
+
async function ye(a, e) {
|
|
1320
|
+
const t = String(a.label || "").trim(), r = String(a.timeZone || "").trim(), i = String(a.weatherQuery || a.label || "").trim();
|
|
1321
|
+
if (!i)
|
|
1322
|
+
throw new Error("Weather place missing");
|
|
1323
|
+
const n = await xe(i, e), o = await _e(n.latitude, n.longitude, r, e), s = Number(o.weather_code), l = Number(o.is_day) === 1, p = Se(s, l);
|
|
1324
|
+
return {
|
|
1325
|
+
label: t,
|
|
1326
|
+
timeZone: r,
|
|
1327
|
+
weatherQuery: i,
|
|
1328
|
+
weather: {
|
|
1329
|
+
state: "pass",
|
|
1330
|
+
condition: p.condition,
|
|
1331
|
+
description: p.description,
|
|
1332
|
+
code: s,
|
|
1333
|
+
isDay: l,
|
|
1334
|
+
temperature: Number.isFinite(Number(o.temperature_2m)) ? Number(o.temperature_2m) : null,
|
|
1335
|
+
temperatureUnit: "°C",
|
|
1336
|
+
cloudCover: Number.isFinite(Number(o.cloud_cover)) ? Number(o.cloud_cover) : null,
|
|
1337
|
+
precipitation: Number.isFinite(Number(o.precipitation)) ? Number(o.precipitation) : null,
|
|
1338
|
+
latitude: n.latitude,
|
|
1339
|
+
longitude: n.longitude,
|
|
1340
|
+
locationName: n.displayName
|
|
1341
|
+
}
|
|
1342
|
+
};
|
|
1343
|
+
}
|
|
1344
|
+
async function xe(a, e) {
|
|
1345
|
+
const t = a.toLowerCase(), r = v.get(t);
|
|
1346
|
+
if (r && r.expiresAt > Date.now())
|
|
1347
|
+
return r.value;
|
|
1348
|
+
const i = Array.from(
|
|
1349
|
+
new Set([a, a.split(",")[0].trim(), a.replace(/\s+/g, " ").trim()].filter(Boolean))
|
|
1350
|
+
);
|
|
1351
|
+
let n = null;
|
|
1352
|
+
for (const s of i) {
|
|
1353
|
+
const l = new URL("https://geocoding-api.open-meteo.com/v1/search");
|
|
1354
|
+
l.searchParams.set("name", s), l.searchParams.set("count", "1"), l.searchParams.set("language", "en"), l.searchParams.set("format", "json");
|
|
1355
|
+
const p = await fetch(l, { signal: e });
|
|
1356
|
+
if (!p.ok)
|
|
1357
|
+
throw new Error(`Geocoding failed with ${p.status}`);
|
|
1358
|
+
const y = await p.json();
|
|
1359
|
+
if (n = Array.isArray(y.results) && y.results[0] || null, n)
|
|
1360
|
+
break;
|
|
1361
|
+
}
|
|
1362
|
+
if (!n)
|
|
1363
|
+
throw new Error(`No weather location found for ${a}`);
|
|
1364
|
+
const o = {
|
|
1365
|
+
latitude: Number(n.latitude),
|
|
1366
|
+
longitude: Number(n.longitude),
|
|
1367
|
+
displayName: [n.name, n.admin1 || n.country].filter(Boolean).join(", ")
|
|
1368
|
+
};
|
|
1369
|
+
return v.set(t, {
|
|
1370
|
+
expiresAt: Date.now() + 864e5,
|
|
1371
|
+
value: o
|
|
1372
|
+
}), o;
|
|
1373
|
+
}
|
|
1374
|
+
async function _e(a, e, t, r) {
|
|
1375
|
+
const i = `${a}:${e}:${t}`, n = C.get(i);
|
|
1376
|
+
if (n && n.expiresAt > Date.now())
|
|
1377
|
+
return n.value;
|
|
1378
|
+
const o = new URL("https://api.open-meteo.com/v1/forecast");
|
|
1379
|
+
o.searchParams.set("latitude", String(a)), o.searchParams.set("longitude", String(e)), o.searchParams.set("current", "temperature_2m,weather_code,is_day,cloud_cover,precipitation"), o.searchParams.set("timezone", t || "auto"), o.searchParams.set("forecast_days", "1");
|
|
1380
|
+
const s = await fetch(o, { signal: r });
|
|
1381
|
+
if (!s.ok)
|
|
1382
|
+
throw new Error(`Weather fetch failed with ${s.status}`);
|
|
1383
|
+
const l = await s.json();
|
|
1384
|
+
if (!l.current)
|
|
1385
|
+
throw new Error("Current weather unavailable");
|
|
1386
|
+
return C.set(i, {
|
|
1387
|
+
expiresAt: Date.now() + 9e5,
|
|
1388
|
+
value: l.current
|
|
1389
|
+
}), l.current;
|
|
1390
|
+
}
|
|
1391
|
+
function Se(a, e) {
|
|
1392
|
+
return a === 0 ? {
|
|
1393
|
+
condition: e ? "clear-day" : "clear-night",
|
|
1394
|
+
description: e ? "Clear sky" : "Clear night"
|
|
1395
|
+
} : a === 1 || a === 2 ? {
|
|
1396
|
+
condition: "partly-cloudy",
|
|
1397
|
+
description: "Partly cloudy"
|
|
1398
|
+
} : a === 3 ? {
|
|
1399
|
+
condition: "cloudy",
|
|
1400
|
+
description: "Overcast"
|
|
1401
|
+
} : a === 45 || a === 48 ? {
|
|
1402
|
+
condition: "fog",
|
|
1403
|
+
description: "Fog"
|
|
1404
|
+
} : [51, 53, 55, 56, 57, 61, 63, 65, 66, 67, 80, 81, 82].includes(a) ? {
|
|
1405
|
+
condition: "rain",
|
|
1406
|
+
description: "Rain"
|
|
1407
|
+
} : [71, 73, 75, 77, 85, 86].includes(a) ? {
|
|
1408
|
+
condition: "snow",
|
|
1409
|
+
description: "Snow"
|
|
1410
|
+
} : [95, 96, 99].includes(a) ? {
|
|
1411
|
+
condition: "storm",
|
|
1412
|
+
description: "Thunderstorm"
|
|
1413
|
+
} : {
|
|
1414
|
+
condition: "cloudy",
|
|
1415
|
+
description: "Cloudy"
|
|
1416
|
+
};
|
|
1417
|
+
}
|
|
1418
|
+
function ve(a) {
|
|
1419
|
+
const e = String(a.label || "").trim().toLowerCase(), t = String(a.timeZone || "").trim().toLowerCase(), r = String(a.weatherQuery || "").trim().toLowerCase();
|
|
1420
|
+
return e === "macau" || e === "manila" || e === "macau / manila" || r === "macau" || r === "manila" || t === "asia/macau" || t === "asia/manila";
|
|
1421
|
+
}
|
|
1422
|
+
function Ce(a) {
|
|
1423
|
+
const e = String(a.label || "").trim().toLowerCase(), t = String(a.timeZone || "").trim().toLowerCase(), r = String(a.weatherQuery || "").trim().toLowerCase();
|
|
1424
|
+
return e === "gold coast" || r === "gold coast" || r === "gold coast, australia" || t === "australia/brisbane";
|
|
1425
|
+
}
|
|
1426
|
+
function Ae(a, e) {
|
|
1427
|
+
const t = T(a.timeZone), r = T(e.timeZone);
|
|
1428
|
+
return t !== r ? t - r : a.label.localeCompare(e.label);
|
|
1429
|
+
}
|
|
1430
|
+
function T(a) {
|
|
1431
|
+
const e = {
|
|
1432
|
+
"America/Los_Angeles": 0,
|
|
1433
|
+
"Asia/Jerusalem": 1,
|
|
1434
|
+
"Asia/Kolkata": 2,
|
|
1435
|
+
"Asia/Macau": 3,
|
|
1436
|
+
"Australia/Sydney": 4
|
|
1437
|
+
};
|
|
1438
|
+
return Object.prototype.hasOwnProperty.call(e, a) ? e[a] : Number.MAX_SAFE_INTEGER;
|
|
1439
|
+
}
|
|
1440
|
+
function c(a) {
|
|
1441
|
+
return String(a).replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
1442
|
+
}
|
|
1443
|
+
export {
|
|
1444
|
+
I as WORLD_CLOCK_TAG_NAME,
|
|
1445
|
+
L as WorldClockStripElement,
|
|
1446
|
+
Ee as createWorldClockStrip,
|
|
1447
|
+
w as defaultClockLocations,
|
|
1448
|
+
R as defineWorldClockStrip,
|
|
1449
|
+
fe as deserializeWorldClockConfig,
|
|
1450
|
+
G as getFallbackWeatherCondition,
|
|
1451
|
+
me as isDaytimeWeather,
|
|
1452
|
+
Se as mapWeatherCode,
|
|
1453
|
+
u as normalizeClockLocations,
|
|
1454
|
+
ue as serializeWorldClockConfig
|
|
1455
|
+
};
|
|
1456
|
+
//# sourceMappingURL=index.js.map
|