'use strict';
import {h, html, render, useEffect, useRef, useState} from './bundle.js';
const Logo = props => html``;
const DefaultTopic = 'mg_mqtt_dashboard';
const DefaultUrl = location.protocol == 'https:'
? 'wss://broker.hivemq.com:8884/mqtt'
: 'ws://broker.hivemq.com:8000/mqtt';
const DefaultDeviceConfig = {pin_map: [], pin_state: [], log_level: 0, pin_count: 0};
const Delay = (ms, val) => new Promise(resolve => setTimeout(resolve, ms, val));
const handleFetchError = r => r.ok || alert(`Error: ${r.statusText}`);
const LabelClass = 'text-sm truncate text-gray-500 font-medium my-auto whitespace-nowrap';
const BadgeClass = 'flex-inline text-sm rounded-md rounded px-2 py-0.5 ring-1 ring-inset';
const InputClass = 'font-normal text-sm rounded w-full flex-1 py-0.5 px-2 text-gray-700 placeholder:text-gray-400 focus:outline-none disabled:cursor-not-allowed disabled:bg-gray-100 disabled:text-gray-500 rounded border';
const TitleClass = 'font-semibold xuppercase xtext-gray-600';
const Colors = {
green: 'bg-green-100 text-green-900 ring-green-300',
yellow: 'bg-yellow-100 text-yellow-900 ring-yellow-300',
info: 'bg-zinc-100 text-zinc-900 ring-zinc-300',
red: 'bg-red-100 text-red-900 ring-red-300',
};
let MqttClient;
const Icons = {
logo: props => html``,
activity: props => html``,
refresh: props => html``,
info: props => html``,
login: props => html``,
logout: props => html``,
menu: props => html``,
upload: props => html``,
monitor: props => html``,
settings: props => html``,
download: props => html``,
file: props => html``,
check: props => html``,
rollback: props => html``,
save: props => html``,
bolt: props => html``,
delete: props => html``,
};
export function Button({title, onclick, disabled, extraClass, icon, ref, colors, hovercolor, disabledcolor}) {
const [spin, setSpin] = useState(false);
const cb = function(ev) {
const res = onclick ? onclick() : null;
if (res && typeof (res.catch) === 'function') {
setSpin(true);
res.catch(() => false).then(() => setSpin(false));
}
};
if (!colors) colors = 'bg-blue-600 hover:bg-blue-500 disabled:bg-blue-400';
return html`