/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
import { c as l } from "../../chunks/runtime.js";
import { css as o, html as e } from "lit";
import { watch as i } from "@arcgis/core/core/reactiveUtils.js";
import { LitElement as r } from "@arcgis/lumina";
import { u as n } from "../../chunks/useHandles.js";
const c = o`:host{display:flex;flex-direction:column;height:100%}.layout-section{padding:var(--calcite-spacing-sm) var(--calcite-spacing-sm);display:flex;flex-direction:column;flex-grow:1;gap:var(--calcite-spacing-md)}.panel-container{display:flex;flex-grow:1;flex-direction:column;gap:var(--calcite-spacing-sm)}.advanced-options-section{border:1px solid var(--calcite-color-border-1);margin-bottom:var(--calcite-spacing-sm)}`;
class d extends r {
  constructor() {
    super(...arguments), this._handles = n("disconnect"), this.hideAdvancedOptions = !1, this.autoPopulateAuthor = !1, this.hideFeatureAttributes = !1, this.hideIncludeTables = !1;
  }
  static {
    this.properties = { _selectedTemplate: 16, _showSelectedTemplateTitleText: 16, hideAdvancedOptions: 5, autoPopulateAuthor: 5, viewModel: 0, messages: 0, showTemplateSelector: 0, selectExportsTab: 0, hideFeatureAttributes: 5, hideIncludeTables: 5 };
  }
  static {
    this.styles = c;
  }
  loaded() {
    this.manager.onLifecycle(() => [
      i(() => this.viewModel.templateOptions.id, (t) => {
        this._handles.removeHandles("template-handle"), this._selectedTemplate = t ? this.viewModel.getLayoutTemplateById(t) ?? void 0 : void 0, this._handles.addHandles(i(() => this._selectedTemplate?.layoutTemplateInfo?.layoutOptions?.hasTitleText, () => {
          this._showSelectedTemplateTitleText = this._selectedTemplate?.layoutTemplateInfo?.layoutOptions?.hasTitleText ?? !0;
        }, { initial: !0 }), "template-handle");
      }, { initial: !0 })
    ]);
  }
  render() {
    return e`<section class="layout-section" tabindex=-1><div class="panel-container">${this._renderTitleInput()}${this._renderTemplateSelect()}${this._renderFileFormatSection()}${this._renderAdvancedSection()}</div>${this._renderExportButton()}</section>`;
  }
  _renderTitleInput() {
    if (!this._showSelectedTemplateTitleText)
      return null;
    const { title: t, titlePlaceHolder: s } = this.messages;
    return e`<calcite-label>${t}<calcite-input .placeholder=${s} .value=${this.viewModel.templateOptions.title ?? ""} @calciteInputInput=${(a) => {
      this.viewModel.templateOptions.title = a.currentTarget.value;
    }}></calcite-input></calcite-label>`;
  }
  _renderTemplateSelect() {
    return e`<div><calcite-label>${this.messages.template}<arcgis-print-template-select .messages=${this.messages} .viewModel=${this.viewModel} .showTemplateSelector=${this.showTemplateSelector}></arcgis-print-template-select></calcite-label><arcgis-print-preview-input .viewModel=${this.viewModel} .messages=${this.messages}></arcgis-print-preview-input></div>`;
  }
  _renderFileFormatSection() {
    return e`<arcgis-print-format-select .viewModel=${this.viewModel} .messages=${this.messages}></arcgis-print-format-select>`;
  }
  _renderAdvancedSection() {
    return this.hideAdvancedOptions ? null : e`<calcite-block .ariaLabel=${this.messages.advancedOptions} class="advanced-options-section" collapsible .disabled=${!this._selectedTemplate} .heading=${this.messages.advancedOptions}><arcgis-print-layout-advanced-options .autoPopulateAuthor=${this.autoPopulateAuthor} .hideFeatureAttributes=${this.hideFeatureAttributes} .hideIncludeTables=${this.hideIncludeTables} .messages=${this.messages} .viewModel=${this.viewModel}></arcgis-print-layout-advanced-options></calcite-block>`;
  }
  _renderExportButton() {
    return e`<arcgis-print-export-button .fileName=${this.viewModel.templateOptions.title ?? void 0} .messages=${this.messages} .viewModel=${this.viewModel} .selectExportsTab=${this.selectExportsTab}></arcgis-print-export-button>`;
  }
}
l("arcgis-print-layout-panel", d);
export {
  d as PrintLayoutPanel
};
