<link rel="import" href="chrome://resources/html/polymer.html">

<link rel="import" href="chrome://resources/cr_elements/shared_vars_css.html">
<link rel="import" href="chrome://resources/html/cr.html">
<link rel="import" href="chrome://resources/html/load_time_data.html">
<link rel="import" href="chrome://resources/html/cr/ui/focus_outline_manager.html">
<link rel="import" href="chrome://resources/html/util.html">
<link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html">
<link rel="import" href="../cloud_print_interface.html">
<link rel="import" href="../cloud_print_interface_manager.html">
<link rel="import" href="../native_layer.html">
<link rel="import" href="../data/destination.html">
<link rel="import" href="../data/document_info.html">
<link rel="import" href="../data/measurement_system.html">
<link rel="import" href="../data/model.html">
<link rel="import" href="../data/state.html">
<link rel="import" href="print_preview_vars_css.html">
<link rel="import" href="strings.html">
<link rel="import" href="settings_behavior.html">
<link rel="import" href="preview_area.html">
<link rel="import" href="sidebar.html">

<dom-module id="print-preview-app">
  <template>
    <style>
      :host {
        display: flex;
        height: 100%;
        user-select: none;
      }

      @media (prefers-color-scheme: dark) {
        :host {
          background: var(--google-grey-900);
        }
      }

      :host([new-print-preview-layout_]) {
        flex-direction: row-reverse;
      }

      print-preview-sidebar {
        flex: none;
        width: var(--print-preview-sidebar-width);
      }

      #preview-area-container {
        align-items: center;
        background-color: var(--preview-area-background-color);
        flex: 1;
      }

      :host([new-print-preview-layout_]) #preview-area-container {
        background-color: var(--preview-area-background-color-new);
      }
    </style>
    <print-preview-state id="state" state="{{state}}" error="{{error_}}">
    </print-preview-state>
    <print-preview-model id="model" settings="{{settings}}"
        controls-managed="{{controlsManaged_}}" destination="[[destination_]]"
        document-settings="[[documentSettings_]]"
        margins="[[margins_]]" page-size="[[pageSize_]]"
        on-preview-setting-changed="onPreviewSettingChanged_"
        on-sticky-setting-changed="onStickySettingChanged_"
        on-setting-valid-changed="onSettingValidChanged_">
    </print-preview-model>
    <print-preview-document-info id="documentInfo"
        document-settings="{{documentSettings_}}" margins="{{margins_}}"
        page-size="{{pageSize_}}">
    </print-preview-document-info>
    <print-preview-sidebar id="sidebar"
        cloud-print-interface="[[cloudPrintInterface_]]"
        cloud-print-error-message="[[cloudPrintErrorMessage_]]"
        destination-state="{{destinationState_}}"
        controls-managed="[[controlsManaged_]]" destination="{{destination_}}"
        error="{{error_}}" new-print-preview-layout="[[newPrintPreviewLayout_]]"
        page-count="[[documentSettings_.pageCount]]"
        settings="[[settings]]" state="[[state]]" on-focus="onSidebarFocus_"
<if expr="is_macosx">
        on-open-pdf-in-preview="onOpenPdfInPreview_"
</if>
<if expr="not chromeos">
        on-print-with-system-dialog="onPrintWithSystemDialog_"
</if>
        on-print-requested="onPrintRequested_"
        on-cancel-requested="onCancelRequested_">
    </print-preview-sidebar>
    <div id="preview-area-container">
      <print-preview-preview-area id="previewArea" settings="[[settings]]"
          destination="[[destination_]]" error="{{error_}}"
          document-modifiable="[[documentSettings_.isModifiable]]"
          margins="[[margins_]]" page-size="[[pageSize_]]" state="[[state]]"
          measurement-system="[[measurementSystem_]]"
          new-print-preview-layout="[[newPrintPreviewLayout_]]"
          preview-state="{{previewState_}}" on-preview-start="onPreviewStart_">
      </print-preview-preview-area>
    </div>
  </template>
  <script src="app.js"></script>
</dom-module>
