{{#d-modal-body}}
  {{#if unpublished}}
    <p>{{i18n "topic.publish_page.unpublished"}}</p>
  {{else}}
    {{#conditional-loading-spinner condition=initializing}}
      <p class="publish-description">{{i18n "topic.publish_page.description"}}</p>

      <form>
        <div class="controls">
          <label>{{i18n "topic.publish_page.slug"}}</label>
          {{text-field
            value=publishedPage.slug
            onChange=(action "checkSlug")
            onChangeImmediate=(action "startCheckSlug")
            disabled=existing
            class="publish-slug"
          }}
        </div>

        <div class="controls">
          <label>{{i18n "topic.publish_page.public"}}</label>

          <p class="description">
            {{input
              type="checkbox"
              checked=(readonly publishedPage.public)
              click=(action "onChangePublic" value="target.checked")
            }}
            {{i18n "topic.publish_page.public_description"}}
          </p>
        </div>
      </form>

      <div class="publish-url">
        {{conditional-loading-spinner condition=checking}}

        {{#if existing}}
          <div class="current-url">
            {{i18n "topic.publish_page.publish_url"}}
            <div>
              <a href={{publishedPage.url}} target="_blank" rel="noopener noreferrer">{{publishedPage.url}}</a>
            </div>
          </div>
        {{else}}
          {{#if showUrl}}
            <div class="valid-slug">
              {{i18n "topic.publish_page.preview_url"}}
              <div class="example-url">{{publishedPage.url}}</div>
            </div>
          {{/if}}

          {{#if invalid}}
            {{i18n "topic.publish_page.invalid_slug"}} <span class="invalid-slug">{{reason}}.</span>
          {{/if}}
        {{/if}}

      </div>
    {{/conditional-loading-spinner}}
  {{/if}}
{{/d-modal-body}}

<div class="modal-footer">
  {{#if showUnpublish}}
    {{d-button
      label="topic.publish_page.unpublish"
      icon="trash-alt"
      class="btn-danger"
      isLoading=unpublishing
      action=(action "unpublish")
    }}

    {{d-button class="close-publish-page" icon="times" label="close" action=(action "closeModal")}}
  {{else if unpublished}}
    {{d-button label="topic.publish_page.publishing_settings" action=(action "startNew")}}
  {{else}}
    {{d-button
      label="topic.publish_page.publish"
      class="btn-primary publish-page"
      icon="file"
      disabled=disabled
      isLoading=saving
      action=(action "publish") }}
  {{/if}}
</div>
