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;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _PlayAssetsDialog_instances, _PlayAssetsDialog_renderFilesystemPicker, _PlayAssetsDialog_setFilesystem, _PlayAssetsDialog_renderLocalFs, _PlayAssetsDialog_filesystemTitle_get;
import { customElement, property, query } from 'lit/decorators.js';
import { css, html, LitElement } from 'lit';
import { PlayDialog } from './play-dialog/play-dialog.js';
import { choose } from 'lit-html/directives/choose.js';
import { when } from 'lit-html/directives/when.js';
import { cssReset } from '../utils/css-reset.js';
import { Bubble } from '../utils/bubble.js';
import { emptyAssetsState } from './play-assets/play-assets.js';
import './play-assets/play-assets-virtual-fs.js';
import './play-assets/play-assets-local-directory.js';
import './play-assets/play-assets-local-archive.js';
import './play-dialog/play-dialog.js';
let PlayAssetsDialog = class PlayAssetsDialog extends LitElement {
    constructor() {
        super(...arguments);
        _PlayAssetsDialog_instances.add(this);
        this.assetsState = emptyAssetsState();
        this.enableLocalAssets = false;
        _PlayAssetsDialog_renderFilesystemPicker.set(this, () => {
            return html `<fieldset>
      <legend>Filesystem type:</legend>
      <label>
        <input
          name="filesystemType"
          type="radio"
          ?checked="${this.assetsState.filesystemType === 'virtual'}"
          @change=${__classPrivateFieldGet(this, _PlayAssetsDialog_setFilesystem, "f")}
          value="virtual"
        />
        Virtual
      </label>
      <label>
        <input
          name="filesystemType"
          type="radio"
          ?checked="${this.assetsState.filesystemType === 'local'}"
          @change=${__classPrivateFieldGet(this, _PlayAssetsDialog_setFilesystem, "f")}
          value="local"
        />
        Local
      </label>
    </fieldset>`;
        });
        _PlayAssetsDialog_setFilesystem.set(this, (ev) => {
            const filesystemType = ev.currentTarget.value;
            this.dispatchEvent(Bubble('assets-filesystem-change', {
                kind: 'filesystem-type',
                filesystemType
            }));
        });
        _PlayAssetsDialog_renderLocalFs.set(this, () => {
            return html `
      <div id="localFs">
        ${when(this.assetsState.hasFileAccessAPI, () => html `<play-assets-local-directory
              .assetsState=${this.assetsState}
            ></play-assets-local-directory>`)}
        <play-assets-local-archive
          .assetsState=${this.assetsState}
        ></play-assets-local-archive>
      </div>
    `;
        });
    }
    open() {
        this._dialog.open();
    }
    close() {
        this._dialog.close();
    }
    render() {
        return html `
      <play-dialog
        dialog-title="Assets"
        description="Manage static assets available to blocks in :play"
      >
        ${when(this.enableLocalAssets, __classPrivateFieldGet(this, _PlayAssetsDialog_renderFilesystemPicker, "f"))}

        <fieldset>
          <legend>${__classPrivateFieldGet(this, _PlayAssetsDialog_instances, "a", _PlayAssetsDialog_filesystemTitle_get)}:</legend>
          ${choose(this.assetsState.filesystemType, [
            [
                'virtual',
                () => html `<play-assets-virtual-fs
                  .assetsState=${this.assetsState}
                ></play-assets-virtual-fs>`
            ],
            ['local', __classPrivateFieldGet(this, _PlayAssetsDialog_renderLocalFs, "f")]
        ])}
        </fieldset>
      </play-dialog>
    `;
    }
};
_PlayAssetsDialog_renderFilesystemPicker = new WeakMap();
_PlayAssetsDialog_setFilesystem = new WeakMap();
_PlayAssetsDialog_renderLocalFs = new WeakMap();
_PlayAssetsDialog_instances = new WeakSet();
_PlayAssetsDialog_filesystemTitle_get = function _PlayAssetsDialog_filesystemTitle_get() {
    return this.assetsState.filesystemType === 'virtual'
        ? 'Manage files'
        : 'Filesystem source';
};
PlayAssetsDialog.styles = css `
    ${cssReset}

    legend {
      font-weight: bold;
    }

    fieldset {
      margin-bottom: var(--space);
    }

    #localFs {
      display: flex;
      flex-direction: column;
      gap: 8px;
    }
  `;
__decorate([
    property({ attribute: false })
], PlayAssetsDialog.prototype, "assetsState", void 0);
__decorate([
    property({ attribute: 'enable-local-assets', type: Boolean })
], PlayAssetsDialog.prototype, "enableLocalAssets", void 0);
__decorate([
    query('play-dialog', true)
], PlayAssetsDialog.prototype, "_dialog", void 0);
PlayAssetsDialog = __decorate([
    customElement('play-assets-dialog')
], PlayAssetsDialog);
export { PlayAssetsDialog };
//# sourceMappingURL=play-assets-dialog.js.map