import { __decorate, __metadata } from "tslib";
import '@material/web/checkbox/checkbox.js';
import '@operato/i18n/ox-i18n.js';
import '@things-factory/setting-base';
import { css, html, LitElement } from 'lit';
import { customElement, property } from 'lit/decorators.js';
import { i18next, localize } from '@operato/i18n';
import { clientSettingStore } from '@operato/shell/object-store.js';
let BoardViewSettingLet = class BoardViewSettingLet extends localize(i18next)(LitElement) {
    render() {
        return html `
      <setting-let>
        <ox-i18n slot="title" msgid="title.board view setting"></ox-i18n>

        <div slot="content">
          <label>
            <md-checkbox id="auto-refresh" @change=${e => this.onChange(e)} ?checked=${this.autoRefresh}></md-checkbox>
            ${String(i18next.t('label.auto refresh board view'))}
          </label>
        </div>
      </setting-let>
    `;
    }
    async firstUpdated() {
        var _a;
        const { autoRefresh = true } = ((_a = (await clientSettingStore.get('board-view'))) === null || _a === void 0 ? void 0 : _a.value) || {};
        this.autoRefresh = autoRefresh;
    }
    async onChange(e) {
        var _a;
        this.autoRefresh = e.target.checked;
        const { autoRefresh: valueFromStore } = ((_a = (await clientSettingStore.get('board-view'))) === null || _a === void 0 ? void 0 : _a.value) || {};
        if (this.autoRefresh === valueFromStore) {
            return;
        }
        try {
            await clientSettingStore.put({
                key: 'board-view',
                value: {
                    autoRefresh: this.autoRefresh
                }
            });
        }
        catch (e) {
            console.error(e);
        }
    }
};
BoardViewSettingLet.styles = [
    css `
      label {
        display: flex;
        gap: 10px;
        align-items: center;

        font: var(--label-font);
        color: var(--md-sys-color-on-surface);
        text-transform: var(--label-text-transform);
      }
    `
];
__decorate([
    property({ type: Boolean }),
    __metadata("design:type", Boolean)
], BoardViewSettingLet.prototype, "autoRefresh", void 0);
BoardViewSettingLet = __decorate([
    customElement('board-view-setting-let')
], BoardViewSettingLet);
export { BoardViewSettingLet };
//# sourceMappingURL=board-view-setting-let.js.map