var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import { css, html, LitElement } from 'lit';
import { customElement, property, query } from 'lit/decorators.js';
import { defaultSettings } from '../storage/settings-save.js';
import { Bubble } from '../utils/bubble.js';
import { PlayDialog } from './play-dialog/play-dialog.js';
import { cssReset } from '../utils/css-reset.js';
import './play-button.js';
import './play-dialog/play-dialog.js';
let PlaySettingsDialog = class PlaySettingsDialog extends LitElement {
    constructor() {
        super(...arguments);
        this.allowStorage = false;
        this.remoteRuntimeOrigin = defaultSettings.remoteRuntimeOrigin;
        this.runtimeDebugLogging = false;
        this.sandboxApp = false;
        this.useExperimentalBlocks = false;
        this.useLocalRuntime = false;
        this.useRemoteRuntime = false;
        this.useSpeculativeExecution = false;
        this.useUIRequest = false;
        this.enableLocalAssets = false;
    }
    open() {
        this._dialog.open();
    }
    close() {
        this._dialog.close();
    }
    render() {
        const description = `Settings are ${this.allowStorage ? 'saved and ' : ''}not shareable.`;
        return html `
      <play-dialog dialog-title="Settings" description="${description}">
        <fieldset>
          <legend>Reddit Internal</legend>
          <p>Runtime settings take effect on subsequent execution.</p>
          <label>
            <input
              ?checked="${this.useLocalRuntime}"
              type="checkbox"
              @change=${(ev) => this.dispatchEvent(Bubble('use-local-runtime', ev.currentTarget.checked))}
            />
            Use local runtime. Execute apps locally whenever possible. Default:
            ${onOff(defaultSettings.useLocalRuntime)}.
          </label>
          <label>
            <input
              ?checked="${this.sandboxApp}"
              type="checkbox"
              @change=${(ev) => this.dispatchEvent(Bubble('sandbox-app', ev.currentTarget.checked))}
            />
            Sandbox app execution. Sandboxing is slower but may be more
            production-like. Default: ${onOff(defaultSettings.sandboxApp)}.
          </label>
          <label>
            <input
              ?checked="${this.runtimeDebugLogging}"
              type="checkbox"
              @change=${(ev) => this.dispatchEvent(Bubble('runtime-debug-logging', ev.currentTarget.checked))}
            />
            Enable runtime debug logging. May also require enabling verbose
            DevTools console logs. Default:
            ${onOff(defaultSettings.runtimeDebugLogging)}.
          </label>
          <label>
            <input
              ?checked="${this.useRemoteRuntime}"
              type="checkbox"
              @change=${(ev) => this.dispatchEvent(Bubble('use-remote-runtime', ev.currentTarget.checked))}
            />
            Use remote runtime. Upload on every change and execute apps remotely
            as needed. Default: ${onOff(defaultSettings.useRemoteRuntime)}.
          </label>
          <label>
            <input
              type="text"
              value="${this.remoteRuntimeOrigin}"
              @change=${(ev) => this.dispatchEvent(Bubble('edit-remote-runtime-origin', ev.currentTarget.value))}
            />
            Remote runtime origin. Destination for app uploads and remote
            execution. Default: ${defaultSettings.remoteRuntimeOrigin}.
          </label>
          <label>
            <input
              ?checked="${this.useExperimentalBlocks}"
              type="checkbox"
              @change=${(ev) => this.dispatchEvent(Bubble('use-experimental-blocks', ev.currentTarget.checked))}
            />
            Use experimental blocks. Default:
            ${onOff(defaultSettings.useExperimentalBlocks)}.
          </label>
          <label>
            <input
              ?checked="${this.useUIRequest}"
              type="checkbox"
              @change=${(ev) => this.dispatchEvent(Bubble('use-ui-request', ev.currentTarget.checked))}
            />
            Use UI Request (multithreading). Default:
            ${onOff(defaultSettings.useUIRequest)}.
          </label>
          <label>
            <input
              ?checked="${this.useSpeculativeExecution}"
              type="checkbox"
              @change=${(ev) => this.dispatchEvent(Bubble('use-speculative-execution', ev.currentTarget.checked))}
            />
            Use speculative execution (only valid when UI request is enabled).
            Default: ${onOff(defaultSettings.useSpeculativeExecution)}.
          </label>
          <label>
            <input
              ?checked="${this.enableLocalAssets}"
              type="checkbox"
              @change="${(ev) => this.dispatchEvent(Bubble('enable-local-assets', ev.currentTarget.checked))}"
            />
            Enable experimental local filesystem assets. Default:
            ${onOff(defaultSettings.enableLocalAssets)}
          </label>
        </fieldset>
      </play-dialog>
    `;
    }
};
PlaySettingsDialog.styles = css `
    ${cssReset}

    legend {
      font-weight: bold;
    }

    input[type='checkbox'] {
      float: left;
      margin-inline-end: var(--space);
    }

    input[type='text'] {
      display: block;
      width: 100%;
    }

    label {
      cursor: pointer; /* Finger. */
      display: block; /* Each control starts a new block. */
      margin-bottom: var(--space);
    }
  `;
__decorate([
    property({ attribute: 'allow-storage', type: Boolean })
], PlaySettingsDialog.prototype, "allowStorage", void 0);
__decorate([
    property({ attribute: 'remote-runtime-origin' })
], PlaySettingsDialog.prototype, "remoteRuntimeOrigin", void 0);
__decorate([
    property({ attribute: 'runtime-debug-logging', type: Boolean })
], PlaySettingsDialog.prototype, "runtimeDebugLogging", void 0);
__decorate([
    property({ attribute: 'sandbox-app', type: Boolean })
], PlaySettingsDialog.prototype, "sandboxApp", void 0);
__decorate([
    property({ attribute: 'use-experimental-blocks', type: Boolean })
], PlaySettingsDialog.prototype, "useExperimentalBlocks", void 0);
__decorate([
    property({ attribute: 'use-local-runtime', type: Boolean })
], PlaySettingsDialog.prototype, "useLocalRuntime", void 0);
__decorate([
    property({ attribute: 'use-remote-runtime', type: Boolean })
], PlaySettingsDialog.prototype, "useRemoteRuntime", void 0);
__decorate([
    property({ attribute: 'use-speculative-execution', type: Boolean })
], PlaySettingsDialog.prototype, "useSpeculativeExecution", void 0);
__decorate([
    property({ attribute: 'use-ui-request', type: Boolean })
], PlaySettingsDialog.prototype, "useUIRequest", void 0);
__decorate([
    property({ attribute: 'enable-local-assets', type: Boolean })
], PlaySettingsDialog.prototype, "enableLocalAssets", void 0);
__decorate([
    query('play-dialog', true)
], PlaySettingsDialog.prototype, "_dialog", void 0);
PlaySettingsDialog = __decorate([
    customElement('play-settings-dialog')
], PlaySettingsDialog);
export { PlaySettingsDialog };
/** Translate a boolean to on / off. */
function onOff(on) {
    return on ? 'on' : 'off';
}
//# sourceMappingURL=play-settings-dialog.js.map