liftie
Version:
Clean, simple, easy to read, fast ski resort lift status
1,558 lines (1,532 loc) • 52.5 kB
JavaScript
(() => {
var __getOwnPropNames = Object.getOwnPropertyNames;
var __commonJS = (cb, mod) => function __require() {
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
// lib/client/minimax/index.js
var require_minimax = __commonJS({
"lib/client/minimax/index.js"(exports, module) {
module.exports = minimax2;
function minimax2(node, selector) {
const my = {
trigger: node.querySelector(selector),
state: "open",
// by default trigger 'open' state
fn() {
}
};
const self2 = {
state: state2,
on
};
function onclick(e) {
e.preventDefault();
const state3 = node.classList.toggle(my.state);
my.fn.call(null, state3);
}
function state2(s) {
my.state = s;
return self2;
}
function on(fn) {
my.fn = fn;
return self2;
}
if (my.trigger) {
my.trigger.addEventListener("click", onclick);
}
return self2;
}
}
});
// lib/client/resort/dom.js
var require_dom = __commonJS({
"lib/client/resort/dom.js"(exports, module) {
function removeAllChildren(node) {
while (node.hasChildNodes()) {
node.removeChild(node.lastChild);
}
}
function next({ nextElementSibling, nextSibling }) {
return nextElementSibling || nextSibling;
}
module.exports = {
next,
removeAllChildren
};
}
});
// lib/client/resort/lifts.js
var require_lifts = __commonJS({
"lib/client/resort/lifts.js"(exports, module) {
var dom = require_dom();
module.exports = render;
module.exports.section = 0;
module.exports.type = "lifts";
var states = ["open", "hold", "scheduled", "closed"];
function renderStatus(node, status) {
dom.removeAllChildren(node);
if (status) {
node.innerHTML = Object.keys(status).map((name) => {
const klass = `status ls-${status[name]}`;
return `<li class="lift"><span class="name">${name}</span><span class="${klass}"></span></li>`;
}).join("");
}
}
function renderStats(node, stats2) {
states.forEach((s) => node.querySelector(`.ls-${s}`).innerHTML = stats2 ? stats2[s] : 0);
}
function renderColorBar(node, percentage) {
states.forEach((state2) => {
const width = `width:${percentage ? percentage[state2] : 25}%;`;
node.querySelector(`.${state2}`).setAttribute("style", width);
});
}
function render(node, { status, stats: stats2 }) {
renderStatus(node.querySelector(".lifts"), status);
renderStats(node.querySelector(".summary"), stats2);
renderColorBar(node.querySelector(".summary-color-bar"), stats2.percentage);
}
}
});
// lib/client/resort/weather.js
var require_weather = __commonJS({
"lib/client/resort/weather.js"(exports, module) {
var day = 24 * 60 * 60 * 1e3;
module.exports = render;
module.exports.section = 1;
module.exports.type = "weather";
function renderIcon(li, icon) {
if (Array.isArray(icon)) {
icon.forEach((cl, i) => li.item(i).setAttribute("class", cl));
}
}
function renderNotice(el, notice) {
if (!notice) {
return el.classList.add("hidden");
}
el.classList.remove("hidden");
el = el.querySelector("a");
el.setAttribute("href", notice.href);
el.setAttribute("title", `Go to ${notice.site}`);
el = el.querySelector("img");
el.setAttribute("src", notice.img);
el.setAttribute("style", `width:${notice.width}px;`);
el.setAttribute("alt", notice.site);
}
function render(div, weather) {
if (Date.now() - weather.timestamp > day) {
return false;
}
renderIcon(div.querySelectorAll(".weather-icon > ul > li"), weather.icon);
div.querySelector(".temperature").innerHTML = `${weather.temperature.max}°F`;
const snowforecast = div.querySelector(".snowforecast");
snowforecast.classList.toggle("hidden", !weather.snow);
if (weather.snow) {
snowforecast.innerHTML = `${weather.snow}"`;
}
div.querySelector(".conditions").innerHTML = weather.conditions;
div.querySelector(".text").innerHTML = weather.text;
renderNotice(div.querySelector(".notice"), weather.notice);
return true;
}
}
});
// node_modules/.pnpm/transform-property@0.0.1/node_modules/transform-property/index.js
var require_transform_property = __commonJS({
"node_modules/.pnpm/transform-property@0.0.1/node_modules/transform-property/index.js"(exports, module) {
var styles = [
"webkitTransform",
"MozTransform",
"msTransform",
"OTransform",
"transform"
];
var el = document.createElement("p");
var style;
for (i = 0; i < styles.length; i++) {
style = styles[i];
if (null != el.style[style]) {
module.exports = style;
break;
}
}
var i;
}
});
// node_modules/.pnpm/has-translate3d@0.0.3/node_modules/has-translate3d/index.js
var require_has_translate3d = __commonJS({
"node_modules/.pnpm/has-translate3d@0.0.3/node_modules/has-translate3d/index.js"(exports, module) {
var prop = require_transform_property();
if (!prop || !window.getComputedStyle) {
module.exports = false;
} else {
map = {
webkitTransform: "-webkit-transform",
OTransform: "-o-transform",
msTransform: "-ms-transform",
MozTransform: "-moz-transform",
transform: "transform"
};
el = document.createElement("div");
el.style[prop] = "translate3d(1px,1px,1px)";
document.body.insertBefore(el, null);
val = getComputedStyle(el).getPropertyValue(map[prop]);
document.body.removeChild(el);
module.exports = null != val && val.length && "none" != val;
}
var map;
var el;
var val;
}
});
// node_modules/.pnpm/component-emitter@1.3.1/node_modules/component-emitter/index.js
var require_component_emitter = __commonJS({
"node_modules/.pnpm/component-emitter@1.3.1/node_modules/component-emitter/index.js"(exports, module) {
if (typeof module !== "undefined") {
module.exports = Emitter;
}
function Emitter(obj) {
if (obj) return mixin(obj);
}
function mixin(obj) {
for (var key in Emitter.prototype) {
obj[key] = Emitter.prototype[key];
}
return obj;
}
Emitter.prototype.on = Emitter.prototype.addEventListener = function(event, fn) {
this._callbacks = this._callbacks || {};
(this._callbacks["$" + event] = this._callbacks["$" + event] || []).push(fn);
return this;
};
Emitter.prototype.once = function(event, fn) {
function on() {
this.off(event, on);
fn.apply(this, arguments);
}
on.fn = fn;
this.on(event, on);
return this;
};
Emitter.prototype.off = Emitter.prototype.removeListener = Emitter.prototype.removeAllListeners = Emitter.prototype.removeEventListener = function(event, fn) {
this._callbacks = this._callbacks || {};
if (0 == arguments.length) {
this._callbacks = {};
return this;
}
var callbacks = this._callbacks["$" + event];
if (!callbacks) return this;
if (1 == arguments.length) {
delete this._callbacks["$" + event];
return this;
}
var cb;
for (var i = 0; i < callbacks.length; i++) {
cb = callbacks[i];
if (cb === fn || cb.fn === fn) {
callbacks.splice(i, 1);
break;
}
}
if (callbacks.length === 0) {
delete this._callbacks["$" + event];
}
return this;
};
Emitter.prototype.emit = function(event) {
this._callbacks = this._callbacks || {};
var args = new Array(arguments.length - 1), callbacks = this._callbacks["$" + event];
for (var i = 1; i < arguments.length; i++) {
args[i - 1] = arguments[i];
}
if (callbacks) {
callbacks = callbacks.slice(0);
for (var i = 0, len = callbacks.length; i < len; ++i) {
callbacks[i].apply(this, args);
}
}
return this;
};
Emitter.prototype.listeners = function(event) {
this._callbacks = this._callbacks || {};
return this._callbacks["$" + event] || [];
};
Emitter.prototype.hasListeners = function(event) {
return !!this.listeners(event).length;
};
}
});
// node_modules/.pnpm/@pirxpilot+events@1.0.1/node_modules/@pirxpilot/events/index.js
var require_events = __commonJS({
"node_modules/.pnpm/@pirxpilot+events@1.0.1/node_modules/@pirxpilot/events/index.js"(exports, module) {
module.exports = events;
function events(el, obj) {
var handlers = {};
function bind(name, handler, opts) {
if (!handler) {
handler = name;
}
if (typeof handler === "string") {
handler = obj[handler].bind(obj);
}
el.addEventListener(name, handler, opts);
handlers[name] = {
handler,
opts
};
}
function do_unbind(name) {
var h = handlers[name];
if (!h) {
return;
}
el.removeEventListener(name, h.handler, h.opts);
delete handlers[name];
}
function unbind(name) {
if (!name) {
return unbindAll();
}
do_unbind(name);
}
function unbindAll() {
Object.keys(handlers).forEach(do_unbind);
}
return {
bind,
unbind
};
}
}
});
// node_modules/.pnpm/@pirxpilot+swipe@2.0.2/node_modules/@pirxpilot/swipe/index.js
var require_swipe = __commonJS({
"node_modules/.pnpm/@pirxpilot+swipe@2.0.2/node_modules/@pirxpilot/swipe/index.js"(exports, module) {
var has3d = require_has_translate3d();
var Emitter = require_component_emitter();
var events = require_events();
var min = Math.min;
var max = Math.max;
module.exports = Swipe;
function Swipe(el) {
if (!(this instanceof Swipe)) return new Swipe(el);
if (!el) throw new TypeError("Swipe() requires an element");
this.child = el.children[0];
this.touchAction("none");
this.currentEl = this.children().visible[0];
this.currentVisible = 0;
this.current = 0;
this.el = el;
this.refresh();
this.interval(5e3);
this.duration(300);
this.fastThreshold(200);
this.threshold(0.5);
this.show(0, 0, { silent: true });
this.bind();
}
Emitter(Swipe.prototype);
Swipe.prototype.threshold = function(n) {
this._threshold = n;
};
Swipe.prototype.fastThreshold = function(ms) {
this._fastThreshold = ms;
};
Swipe.prototype.refresh = function() {
var children = this.children();
var visible2 = children.visible.length;
var prev = this.visible || visible2;
var i = indexOf(children.visible, this.currentEl);
if (visible2 < prev && i <= this.currentVisible && i >= 0) {
this.currentVisible -= this.currentVisible - i;
} else if (visible2 > prev && i > this.currentVisible) {
this.currentVisible += i - this.currentVisible;
}
this.visible = visible2;
this.childWidth = this.el.getBoundingClientRect().width;
this.width = Math.ceil(this.childWidth * visible2);
this.child.style.width = this.width + "px";
this.child.style.height = this.height + "px";
this.show(this.currentVisible, 0, { silent: true });
};
Swipe.prototype.bind = function() {
this.events = events(this.child, this);
this.docEvents = events(document, this);
if ("PointerEvent" in window) {
this.events.bind("pointerdown", "ontouchstart");
this.events.bind("pointermove", "ontouchmove");
this.events.bind("pointerup", "ontouchend");
this.events.bind("pointercancel", "ontouchend");
} else {
this.events.bind("mousedown", "ontouchstart");
this.events.bind("mousemove", "ontouchmove");
this.docEvents.bind("mouseup", "ontouchend");
this.events.bind("touchstart", "ontouchstart");
this.events.bind("touchmove", "ontouchmove");
this.docEvents.bind("touchend", "ontouchend");
}
};
Swipe.prototype.unbind = function() {
this.events.unbind();
this.docEvents.unbind();
};
Swipe.prototype.ontouchstart = function(e) {
this.transitionDuration(0);
this.dx = 0;
this.updown = null;
if ("PointerEvent" in window) {
e.target.setPointerCapture(e.pointerId);
}
var touch = this.getTouch(e);
this.down = {
x: touch.pageX,
y: touch.pageY,
at: /* @__PURE__ */ new Date()
};
};
Swipe.prototype.ontouchmove = function(e) {
if (!this.down || this.updown) return;
var touch = this.getTouch(e);
if (!touch) return;
var down = this.down;
var x = touch.pageX;
var w = this.childWidth;
var i = this.currentVisible;
this.dx = x - down.x;
if (null == this.updown) {
var y = touch.pageY;
var dy = y - down.y;
var slope = dy / this.dx;
if (slope > 1 || slope < -1) {
this.updown = true;
return;
} else {
this.updown = false;
}
}
e.preventDefault();
var dir = this.dx < 0 ? 1 : 0;
if (this.isFirst() && 0 === dir) this.dx /= 2;
if (this.isLast() && 1 === dir) this.dx /= 2;
this.translate(i * w + -this.dx);
};
Swipe.prototype.ontouchend = function(e) {
e.stopPropagation();
if (!this.down) return;
if ("PointerEvent" in window) {
e.target.releasePointerCapture(e.pointerId);
}
var dx = this.dx;
var w = this.childWidth;
var ms = /* @__PURE__ */ new Date() - this.down.at;
var threshold = ms < this._fastThreshold ? w / 10 : w * this._threshold;
var dir = dx < 0 ? 1 : 0;
var half = Math.abs(dx) >= threshold;
this.down = null;
if (this.isFirst() && 1 == dir && half) return this.next();
if (this.isFirst()) return this.prev();
if (this.isLast() && 1 == dir) return this.next();
if (1 === dir && half) return this.next();
if (0 === dir && half) return this.prev();
this.show(this.currentVisible);
};
Swipe.prototype.duration = function(ms) {
this._duration = ms;
return this;
};
Swipe.prototype.interval = function(ms) {
this._interval = ms;
return this;
};
Swipe.prototype.play = function() {
if (this.timer) return;
this.timer = setInterval(this.cycle.bind(this), this._interval);
return this;
};
Swipe.prototype.stop = function() {
clearInterval(this.timer);
this.timer = null;
return this;
};
Swipe.prototype.cycle = function() {
if (this.isLast()) {
this.currentVisible = -1;
this.next();
} else {
this.next();
}
};
Swipe.prototype.isFirst = function() {
return this.currentVisible === 0;
};
Swipe.prototype.isLast = function() {
return this.currentVisible == this.visible - 1;
};
Swipe.prototype.prev = function() {
this.show(this.currentVisible - 1);
return this;
};
Swipe.prototype.next = function() {
this.show(this.currentVisible + 1);
return this;
};
Swipe.prototype.show = function(i, ms, options) {
options = options || {};
if (null == ms) ms = this._duration;
var self2 = this;
var children = this.children();
i = max(0, min(i, children.visible.length - 1));
this.currentVisible = i;
this.currentEl = children.visible[i];
this.current = indexOf(children.all, this.currentEl);
this.transitionDuration(ms);
this.translate(this.childWidth * i);
if (!options.silent) {
this.emit("showing", this.current, this.currentEl);
if (!ms) return this;
this.child.addEventListener("transitionend", function shown() {
if (self2.current == i) self2.emit("show", self2.current, self2.currentEl);
self2.child.removeEventListener("transitionend", shown);
});
}
return this;
};
Swipe.prototype.children = function() {
var els = this.child.children;
var ret = {
all: els,
visible: [],
hidden: []
};
for (var i = 0; i < els.length; i++) {
var el = els[i];
if (visible(el)) {
ret.visible.push(el);
} else {
ret.hidden.push(el);
}
}
return ret;
};
Swipe.prototype.transitionDuration = function(ms) {
var s = this.child.style;
s.transition = ms + "ms transform";
};
Swipe.prototype.translate = function(x) {
var s = this.child.style;
x = -x;
if (has3d) {
s.transform = "translate3d(" + x + "px, 0, 0)";
} else {
s.transform = "translateX(" + x + "px)";
}
};
Swipe.prototype.touchAction = function(value) {
var s = this.child.style;
s.touchAction = value;
};
Swipe.prototype.getTouch = function(e) {
var touch = e;
if (e.changedTouches && e.changedTouches.length > 0) {
touch = e.changedTouches[0];
}
return touch;
};
function indexOf(els, el) {
for (var i = 0; i < els.length; i++) {
if (els[i] == el) return i;
}
return -1;
}
function visible(el) {
return getComputedStyle(el).display != "none";
}
}
});
// node_modules/.pnpm/el-component@1.0.1/node_modules/el-component/index.js
var require_el_component = __commonJS({
"node_modules/.pnpm/el-component@1.0.1/node_modules/el-component/index.js"(exports, module) {
var voids = [
"area",
"base",
"br",
"col",
"embed",
"hr",
"img",
"input",
"keygen",
"link",
"menuitem",
"meta",
"param",
"source",
"track",
"wbr"
].reduce(function(o, v) {
o[v] = true;
return o;
}, /* @__PURE__ */ Object.create(null));
function htmlTag(tag2, content, attrStr) {
var text = [
"<",
tag2,
attrStr ? " " + attrStr : "",
">"
];
if (!voids[tag2]) {
text = text.concat([
content || "",
"</",
tag2,
">"
]);
}
return text;
}
function xmlTag(tag2, content, attrStr) {
var text = [
"<",
tag2,
attrStr ? " " + attrStr : ""
];
if (!content || !content.length) {
text.push("/>");
} else {
text = text.concat([
">",
content,
"</",
tag2,
">"
]);
}
return text;
}
function toStr(tagFn, tag2, content, attrs) {
var attrStr, classes, ids;
if (typeof content !== "string") {
attrs = content;
content = "";
}
tag2 = tag2 || "";
attrs = attrs || {};
classes = tag2.split(".");
tag2 = classes.shift() || "div";
if (classes.length) {
classes = classes.join(" ");
if (attrs["class"]) {
attrs["class"] += " " + classes;
} else {
attrs["class"] = classes;
}
}
ids = tag2.split("#");
if (ids.length > 1) {
tag2 = ids[0] || "div";
attrs.id = ids[1];
}
attrStr = Object.keys(attrs).map(function(attr) {
return attr + '="' + attrs[attr] + '"';
}).join(" ");
return tagFn(tag2, content, attrStr).join("");
}
module.exports = toStr.bind(null, htmlTag);
module.exports.xml = toStr.bind(null, xmlTag);
}
});
// node_modules/.pnpm/tiny-pager@1.0.0/node_modules/tiny-pager/index.js
var require_tiny_pager = __commonJS({
"node_modules/.pnpm/tiny-pager@1.0.0/node_modules/tiny-pager/index.js"(exports, module) {
var Emitter = require_component_emitter();
var el = require_el_component();
module.exports = Pager;
function Pager(el2) {
if (!(this instanceof Pager)) {
return new Pager(el2);
}
this._total = 0;
this._current = 0;
this.el = el2;
el2.addEventListener("click", this.onclick.bind(this));
}
Emitter(Pager.prototype);
Pager.prototype.total = function total(t) {
this._total = t;
return this;
};
Pager.prototype.onclick = function onclick(e) {
var page, target = e.target || e.srcElement;
page = Array.prototype.indexOf.call(this.el.children, target);
if (page < 0) {
return;
}
e.preventDefault();
e.stopPropagation();
this.select(page);
};
Pager.prototype.select = function select(page, opts) {
var silent = opts && opts.silent;
if (page === this._current) {
return;
}
Array.prototype.forEach.call(this.el.children, function(a, i) {
a.className = i == page ? "active" : "inactive";
});
this._current = page;
if (!silent) {
this.emit("show", this._current);
}
return this;
};
Pager.prototype.render = function render() {
var i, html = [];
for (i = 0; i < this._total; i++) {
html.push(i !== this._current ? "a.inactive" : "a.active");
}
this.el.innerHTML = html.map(function(item) {
return el(item);
}).join("");
return this;
};
}
});
// lib/client/resort/webcams.js
var require_webcams = __commonJS({
"lib/client/resort/webcams.js"(exports, module) {
var swipe = require_swipe();
var pager = require_tiny_pager();
module.exports = render;
module.exports.section = 1;
module.exports.type = "webcams";
var DELAY = 15 * 60 * 1e3;
function swiper(el) {
const ui = {
swipe: swipe(el.swipe),
pager: pager(el.pager)
};
function refresh(count) {
ui.swipe.refresh();
ui.pager.total(count).render();
el.pager.classList.toggle("hidden", count < 2);
}
function current() {
return ui.swipe.currentVisible;
}
ui.pager.on("show", (n) => {
ui.swipe.show(n, null, {
silent: true
});
});
ui.swipe.on("show", (n) => {
ui.pager.select(n, {
silent: true
});
});
return {
refresh,
current
};
}
function render(div, webcams) {
let cams;
let timer;
let ui;
function refresh() {
cams.forEach((it) => {
const imgs = it.node.querySelectorAll("img");
const fn = swap.bind(null, imgs, it);
for (let i = 0; i < imgs.length; i++) {
imgs[i].onload = fn;
}
imgs[it.inactive].setAttribute("src", imgs[it.active].getAttribute("src"));
});
}
function initCam(cam, { source, image, name, notice }) {
cam.querySelector("a").setAttribute("href", source);
cam.querySelector("img.active").setAttribute("src", image);
cam.querySelector("img.inactive").setAttribute("src", "");
cam.querySelector(".title").innerHTML = name;
cam.querySelector(".notice").innerHTML = notice || "";
cams.push({
node: cam,
active: 0,
inactive: 1
});
}
function init2() {
if (timer) {
clearInterval(timer);
timer = void 0;
}
cams = [];
const ul = div.querySelector("ul");
const li = ul.querySelectorAll("li");
webcams.forEach((webcam, i) => {
let cam;
if (i < li.length) {
cam = li[i];
} else {
cam = ul.appendChild(li[0].cloneNode(true));
}
initCam(cam.querySelector(".webcam"), webcam);
});
for (let i = Math.max(1, webcams.length); i < li.length; i++) {
ul.removeChild(li[i]);
}
if (!ui) {
ui = swiper({
swipe: div.querySelector(".swipe"),
pager: div.querySelector(".pager")
});
}
ui.refresh(webcams.length);
if (!cams.length) {
return false;
}
timer = setInterval(refresh, DELAY);
return true;
}
function swap(imgs, it) {
it.active = (it.active + 1) % 2;
it.inactive = (it.inactive + 1) % 2;
imgs[it.inactive].setAttribute("class", "inactive");
imgs[it.active].setAttribute("class", "active");
imgs[it.inactive].setAttribute("src", "");
}
init2();
}
}
});
// lib/client/resort/snow.js
var require_snow = __commonJS({
"lib/client/resort/snow.js"(exports, module) {
var day = 24 * 60 * 60 * 1e3;
module.exports = render;
module.exports.section = 1;
module.exports.type = "snow";
function renderField(div, field, snow) {
const el = div.querySelector(`.${field}`);
const value = snow[field];
el.querySelector(".value").innerHTML = value || "";
el.classList.toggle("hidden", !value);
}
function render(div, snow) {
if (Date.now() - snow.timestamp > day) {
return false;
}
renderField(div, "snowfall", snow);
renderField(div, "depth", snow);
renderField(div, "condition", snow);
div.querySelector(".notice").innerHTML = snow.notice || "";
return true;
}
}
});
// lib/client/resort/index.js
var require_resort = __commonJS({
"lib/client/resort/index.js"(exports, module) {
var dom = require_dom();
module.exports = resort2;
function renderOpening(node, opening) {
if (opening) {
opening = opening.split("-");
if (new Date(opening[0], opening[1] - 1, opening[2]).getTime() <= Date.now()) {
node.dataset.opening = "";
node = node.querySelector(".opening-date");
node.parentNode.removeChild(node);
}
}
}
var plugins = [
require_lifts(),
require_weather(),
require_webcams(),
require_snow()
];
function renderPlugins(node, getData) {
const sec = dom.next(node);
plugins.forEach((plugin) => {
const data = getData(plugin.type);
if (!data) {
return;
}
const el = plugin.section ? sec.querySelector(`.${plugin.type}`) : node;
if (!el) {
return;
}
const show = plugin(el, data);
if (typeof show === "boolean") {
el.classList.toggle("visible", show);
el.classList.toggle("hiddent", !show);
}
});
}
function render(node, resort3) {
const tsPrev = JSON.parse(node.dataset.timestamp);
const tsCurr = resort3.timestamp;
renderPlugins(node, (plugin) => {
if (!resort3[plugin] || !tsCurr[plugin]) {
return;
}
if (tsPrev[plugin] && tsCurr[plugin] <= tsPrev[plugin]) {
return;
}
return resort3[plugin];
});
renderOpening(node, node.dataset.opening);
node.dataset.timestamp = JSON.stringify(tsCurr);
}
var MAX = 12;
function resort2(node) {
let updateCounter = MAX;
function updateTimeToRefresh(counter) {
const ttr = node.querySelector(".time-to-refresh");
ttr.innerHTML = counter * 5;
}
function refresh(now) {
const id = node.dataset.resort;
if (!node.classList.contains("open")) {
return;
}
if (now) {
updateCounter = 0;
} else {
updateCounter -= 1;
}
if (updateCounter > 0) {
updateTimeToRefresh(updateCounter);
return;
}
updateCounter = MAX;
updateTimeToRefresh(updateCounter);
fetch(`/api/resort/${id}`).then((res) => res.json()).then((resort3) => render(node, resort3));
}
function init2() {
const ds = node.dataset;
updateTimeToRefresh(MAX);
renderPlugins(node, (plugin) => {
const data = ds[plugin];
return data && JSON.parse(data);
});
}
return {
init: init2,
refresh,
node
};
}
}
});
// node_modules/.pnpm/js-cookie@3.0.5/node_modules/js-cookie/dist/js.cookie.js
var require_js_cookie = __commonJS({
"node_modules/.pnpm/js-cookie@3.0.5/node_modules/js-cookie/dist/js.cookie.js"(exports, module) {
(function(global, factory) {
typeof exports === "object" && typeof module !== "undefined" ? module.exports = factory() : typeof define === "function" && define.amd ? define(factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, function() {
var current = global.Cookies;
var exports2 = global.Cookies = factory();
exports2.noConflict = function() {
global.Cookies = current;
return exports2;
};
}());
})(exports, function() {
"use strict";
function assign(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
target[key] = source[key];
}
}
return target;
}
var defaultConverter = {
read: function(value) {
if (value[0] === '"') {
value = value.slice(1, -1);
}
return value.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent);
},
write: function(value) {
return encodeURIComponent(value).replace(
/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,
decodeURIComponent
);
}
};
function init2(converter, defaultAttributes) {
function set(name, value, attributes) {
if (typeof document === "undefined") {
return;
}
attributes = assign({}, defaultAttributes, attributes);
if (typeof attributes.expires === "number") {
attributes.expires = new Date(Date.now() + attributes.expires * 864e5);
}
if (attributes.expires) {
attributes.expires = attributes.expires.toUTCString();
}
name = encodeURIComponent(name).replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent).replace(/[()]/g, escape);
var stringifiedAttributes = "";
for (var attributeName in attributes) {
if (!attributes[attributeName]) {
continue;
}
stringifiedAttributes += "; " + attributeName;
if (attributes[attributeName] === true) {
continue;
}
stringifiedAttributes += "=" + attributes[attributeName].split(";")[0];
}
return document.cookie = name + "=" + converter.write(value, name) + stringifiedAttributes;
}
function get(name) {
if (typeof document === "undefined" || arguments.length && !name) {
return;
}
var cookies = document.cookie ? document.cookie.split("; ") : [];
var jar = {};
for (var i = 0; i < cookies.length; i++) {
var parts = cookies[i].split("=");
var value = parts.slice(1).join("=");
try {
var found = decodeURIComponent(parts[0]);
jar[found] = converter.read(value, found);
if (name === found) {
break;
}
} catch (e) {
}
}
return name ? jar[name] : jar;
}
return Object.create(
{
set,
get,
remove: function(name, attributes) {
set(
name,
"",
assign({}, attributes, {
expires: -1
})
);
},
withAttributes: function(attributes) {
return init2(this.converter, assign({}, this.attributes, attributes));
},
withConverter: function(converter2) {
return init2(assign({}, this.converter, converter2), this.attributes);
}
},
{
attributes: { value: Object.freeze(defaultAttributes) },
converter: { value: Object.freeze(converter) }
}
);
}
var api = init2(defaultConverter, { path: "/" });
return api;
});
}
});
// node_modules/.pnpm/yields-keycode@1.1.0/node_modules/yields-keycode/index.js
var require_yields_keycode = __commonJS({
"node_modules/.pnpm/yields-keycode@1.1.0/node_modules/yields-keycode/index.js"(exports, module) {
var map = {
backspace: 8,
command: 91,
tab: 9,
clear: 12,
enter: 13,
shift: 16,
ctrl: 17,
alt: 18,
capslock: 20,
escape: 27,
esc: 27,
space: 32,
pageup: 33,
pagedown: 34,
end: 35,
home: 36,
left: 37,
up: 38,
right: 39,
down: 40,
del: 46,
comma: 188,
f1: 112,
f2: 113,
f3: 114,
f4: 115,
f5: 116,
f6: 117,
f7: 118,
f8: 119,
f9: 120,
f10: 121,
f11: 122,
f12: 123,
",": 188,
".": 190,
"/": 191,
"`": 192,
"-": 189,
"=": 187,
";": 186,
"[": 219,
"\\": 220,
"]": 221,
"'": 222
};
module.exports = function(name) {
return map[name.toLowerCase()] || name.toUpperCase().charCodeAt(0);
};
}
});
// node_modules/.pnpm/yields-k-sequence@0.1.0/node_modules/yields-k-sequence/index.js
var require_yields_k_sequence = __commonJS({
"node_modules/.pnpm/yields-k-sequence@0.1.0/node_modules/yields-k-sequence/index.js"(exports, module) {
var keycode = require_yields_keycode();
module.exports = sequence;
function sequence(keys, ms, fn) {
var codes = keys.split(/ +/).map(keycode), clen = codes.length, seq = [], i = 0, prev;
if (2 == arguments.length) {
fn = ms;
ms = 500;
}
return function(e) {
var code = codes[i++];
if (42 != code && code != e.which) return reset();
if (prev && /* @__PURE__ */ new Date() - prev > ms) return reset();
var len = seq.push(e.which);
prev = /* @__PURE__ */ new Date();
if (len != clen) return;
reset();
fn(e);
};
function reset() {
prev = null;
seq = [];
i = 0;
}
}
}
});
// node_modules/.pnpm/component-os@0.0.1/node_modules/component-os/index.js
var require_component_os = __commonJS({
"node_modules/.pnpm/component-os@0.0.1/node_modules/component-os/index.js"(exports, module) {
module.exports = os();
function os() {
var ua = navigator.userAgent;
if (/mac/i.test(ua)) return "mac";
if (/win/i.test(ua)) return "windows";
if (/linux/i.test(ua)) return "linux";
}
}
});
// node_modules/.pnpm/@pirxpilot+k@1.0.1/node_modules/@pirxpilot/k/lib/proto.js
var require_proto = __commonJS({
"node_modules/.pnpm/@pirxpilot+k@1.0.1/node_modules/@pirxpilot/k/lib/proto.js"(exports) {
var sequence = require_yields_k_sequence();
var keycode = require_yields_keycode();
var os = require_component_os();
var modifiers = {
224: "command",
91: "command",
93: "command",
16: "shift",
17: "ctrl",
18: "alt"
};
exports["super"] = "mac" == os ? "command" : "ctrl";
exports.handle = function(e, fn) {
var ignore = this.ignore;
var event = e.type;
var code = e.which;
if (fn) return this.bind(e, fn);
var mod = modifiers[code];
if ("keydown" == event && mod) {
this["super"] = exports["super"] == mod;
this[mod] = true;
this.modifiers = true;
this.active++;
return;
}
if (ignore && ignore(e)) return;
var all = this.listeners;
for (var i = 0; i < all.length; ++i) {
var invoke = true;
var obj = all[i];
var seq = obj.seq;
var mods = obj.mods;
fn = seq || obj.fn;
if (!seq && code != obj.code) continue;
if (event != obj.event) continue;
if (this.active != obj.mods.length) continue;
for (var j = 0; j < mods.length; ++j) {
if (!this[mods[j]]) {
invoke = null;
break;
}
}
if (invoke) {
fn(e);
}
}
};
exports.destroy = function() {
this.el.removeEventListener("keydown", this._handle);
this.el.removeEventListener("keyup", this._handle);
this.el.removeEventListener("keyup", this._clear);
this.el.removeEventListener("focus", this._clear);
this.listeners = [];
};
exports.unbind = function(keys, fn) {
var fns = this.listeners;
var len = fns.length;
var all;
if (0 === arguments.length) {
this.listeners = [];
return this;
}
all = parseKeys(keys);
for (var i = 0; i < all.length; ++i) {
for (var j = 0, obj; j < len; ++j) {
obj = fns[j];
if (!obj) continue;
if (fn && obj.fn != fn) continue;
if (obj.key != all[i].key) continue;
if (!matches(obj, all[i])) continue;
fns.splice(j--, 1);
}
}
return this;
};
exports.bind = function(event, keys, fn) {
var fns = this.listeners;
var len;
var all;
if (2 == arguments.length) {
fn = keys;
keys = event;
event = "keydown";
}
all = parseKeys(keys);
len = all.length;
for (var i = 0; i < len; ++i) {
var obj = all[i];
obj.seq = obj.seq && sequence(obj.key, fn);
obj.event = event;
obj.fn = fn;
fns.push(obj);
}
return this;
};
exports.up = function(keys, fn) {
return this.bind("keyup", keys, fn);
};
exports.down = function(keys, fn) {
return this.bind("keydown", keys, fn);
};
exports.clear = function(e) {
var code = e.keyCode || e.which;
if (!(code in modifiers)) return;
this.active--;
this[modifiers[code]] = null;
this.modifiers = this.command || this.shift || this.ctrl || this.alt;
};
exports.reset = function() {
this.active = 0;
this.modifiers = this.command = this.shift = this.ctrl = this.alt = null;
};
exports.ignore = function(e) {
var el = e.target || e.srcElement;
var name = el.tagName.toLowerCase();
return "textarea" == name || "select" == name || "input" == name;
};
function parseKeys(keys) {
keys = keys.replace("super", exports["super"]);
var all = "," != keys ? keys.split(/ *, */) : [","];
var ret = [];
for (var i = 0; i < all.length; ++i) {
if ("" === all[i]) continue;
var mods = all[i].split(/ *\+ */);
var key = mods.pop() || ",";
ret.push({
seq: !!(~key.indexOf(" ") || ~key.indexOf("*")),
code: keycode(key),
mods,
key
});
}
return ret;
}
function matches(a, b) {
return 0 === b.mods.length || eql(a, b);
}
function eql(a, b) {
a = a.mods.sort().toString();
b = b.mods.sort().toString();
return a == b;
}
}
});
// node_modules/.pnpm/@pirxpilot+k@1.0.1/node_modules/@pirxpilot/k/lib/index.js
var require_lib = __commonJS({
"node_modules/.pnpm/@pirxpilot+k@1.0.1/node_modules/@pirxpilot/k/lib/index.js"(exports, module) {
var proto = require_proto();
module.exports = function(el) {
function k(e, fn) {
k.handle(e, fn);
}
k._handle = proto.handle.bind(k);
k._clear = proto.clear.bind(k);
k._reset = proto.reset.bind(k);
el.addEventListener("keydown", k._handle, false);
el.addEventListener("keyup", k._handle, false);
el.addEventListener("keyup", k._clear, false);
el.addEventListener("focus", k._reset, false);
for (var p in proto) k[p] = proto[p];
k.listeners = [];
k.active = 0;
k.el = el;
return k;
};
}
});
// lib/client/state/index.js
var require_state = __commonJS({
"lib/client/state/index.js"(exports, module) {
var cookie = require_js_cookie();
var k = require_lib()(window);
module.exports = state2;
function state2(nodes, st, keys) {
const cookieName = `resorts-${st}`;
const self2 = {
load,
save,
update,
read
};
function find(id) {
return nodes.find((n) => n.dataset.resort === id);
}
function read() {
const text = cookie.get(cookieName);
return (text == null ? void 0 : text.length) ? text.split(",") : [];
}
function write(arr) {
cookie.set(cookieName, arr.join(","), {
expires: 30,
path: "/",
secure: window.location.protocol === "https:",
sameSite: "strict"
});
}
function update() {
const state3 = read().reduce((memo, id) => {
memo[id] = true;
return memo;
}, {});
nodes.forEach(({ dataset, classList }) => {
const id = dataset.resort;
state3[id] = classList.contains(st);
});
const selected = Object.keys(state3).filter((id) => state3[id]);
write(selected);
return selected;
}
function save() {
const selected = nodes.filter((n) => n.classList.contains(st)).map((n) => n.dataset.resort);
write(selected);
return selected;
}
function load() {
const selected = read();
selected.forEach((id) => {
const node = find(id);
if (node) {
node.classList.add(st);
}
});
return selected;
}
function all(on) {
nodes.forEach((n) => n.classList.toggle(st, on));
update();
}
if (keys) {
k(keys.on, all.bind(null, true));
k(keys.off, all.bind(null, false));
}
return self2;
}
}
});
// lib/client/tag/index.js
var require_tag = __commonJS({
"lib/client/tag/index.js"(exports, module) {
module.exports = tag2;
function tag2(node) {
let count;
function update(c) {
if (!count) {
return;
}
count.innerHTML = c;
node.classList.toggle("hidden", c <= 0);
}
if (node) {
count = node.querySelector(".count");
}
return {
update
};
}
}
});
// lib/client/about/index.js
var require_about = __commonJS({
"lib/client/about/index.js"(exports, module) {
var cookie = require_js_cookie();
module.exports = about2;
function about2() {
const s = document.querySelector(".hidden .about");
if (!s) {
return;
}
if (!check()) {
return;
}
const section = s.parentNode;
const trigger = s.querySelector("a.close");
trigger.addEventListener("click", (e) => {
close();
e.preventDefault();
});
open();
function check() {
return window.parent === window && typeof cookie.get("resorts-open") === "undefined";
}
function close() {
section.classList.add("hidden");
}
function open() {
section.classList.remove("hidden");
}
}
}
});
// lib/client/stats/index.js
var require_stats = __commonJS({
"lib/client/stats/index.js"(exports, module) {
module.exports = stats2;
function stats2() {
const pie = document.querySelector(".stats .pie");
if (!pie) {
return;
}
const data = JSON.parse(pie.dataset.stats);
let ac = 0;
const { style } = pie;
Object.entries(data.percentage).forEach(([key, value]) => style.setProperty(`--${key}`, `${ac += value}%`));
}
}
});
// node_modules/.pnpm/debounce@2.2.0/node_modules/debounce/index.js
var require_debounce = __commonJS({
"node_modules/.pnpm/debounce@2.2.0/node_modules/debounce/index.js"(exports, module) {
function debounce(function_, wait = 100, options = {}) {
if (typeof function_ !== "function") {
throw new TypeError(`Expected the first parameter to be a function, got \`${typeof function_}\`.`);
}
if (wait < 0) {
throw new RangeError("`wait` must not be negative.");
}
const { immediate } = typeof options === "boolean" ? { immediate: options } : options;
let storedContext;
let storedArguments;
let timeoutId;
let timestamp;
let result;
function run() {
const callContext = storedContext;
const callArguments = storedArguments;
storedContext = void 0;
storedArguments = void 0;
result = function_.apply(callContext, callArguments);
return result;
}
function later() {
const last = Date.now() - timestamp;
if (last < wait && last >= 0) {
timeoutId = setTimeout(later, wait - last);
} else {
timeoutId = void 0;
if (!immediate) {
result = run();
}
}
}
const debounced = function(...arguments_) {
if (storedContext && this !== storedContext && Object.getPrototypeOf(this) === Object.getPrototypeOf(storedContext)) {
throw new Error("Debounced method called with different contexts of the same prototype.");
}
storedContext = this;
storedArguments = arguments_;
timestamp = Date.now();
const callNow = immediate && !timeoutId;
if (!timeoutId) {
timeoutId = setTimeout(later, wait);
}
if (callNow) {
result = run();
}
return result;
};
Object.defineProperty(debounced, "isPending", {
get() {
return timeoutId !== void 0;
}
});
debounced.clear = () => {
if (!timeoutId) {
return;
}
clearTimeout(timeoutId);
timeoutId = void 0;
};
debounced.flush = () => {
if (!timeoutId) {
return;
}
debounced.trigger();
};
debounced.trigger = () => {
result = run();
debounced.clear();
};
return debounced;
}
module.exports.debounce = debounce;
module.exports = debounce;
}
});
// lib/client/boot/height.js
var require_height = __commonJS({
"lib/client/boot/height.js"(exports, module) {
var debounce = require_debounce();
module.exports = postHeight;
function notify() {
const widget = document.querySelector(".widget");
if (!widget) {
return;
}
window.parent.postMessage(
{
height: widget.scrollHei