// packages/block-library/src/file/deprecated.js
import clsx from "clsx";
import {
  __experimentalGetElementClassName,
  RichText,
  useBlockProps
} from "@wordpress/block-editor";
import { __, sprintf } from "@wordpress/i18n";
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
var v3 = {
  attributes: {
    id: {
      type: "number"
    },
    href: {
      type: "string"
    },
    fileId: {
      type: "string",
      source: "attribute",
      selector: "a:not([download])",
      attribute: "id"
    },
    fileName: {
      type: "string",
      source: "html",
      selector: "a:not([download])"
    },
    textLinkHref: {
      type: "string",
      source: "attribute",
      selector: "a:not([download])",
      attribute: "href"
    },
    textLinkTarget: {
      type: "string",
      source: "attribute",
      selector: "a:not([download])",
      attribute: "target"
    },
    showDownloadButton: {
      type: "boolean",
      default: true
    },
    downloadButtonText: {
      type: "string",
      source: "html",
      selector: "a[download]"
    },
    displayPreview: {
      type: "boolean"
    },
    previewHeight: {
      type: "number",
      default: 600
    }
  },
  supports: {
    anchor: true,
    align: true
  },
  save({ attributes }) {
    const {
      href,
      fileId,
      fileName,
      textLinkHref,
      textLinkTarget,
      showDownloadButton,
      downloadButtonText,
      displayPreview,
      previewHeight
    } = attributes;
    const pdfEmbedLabel = RichText.isEmpty(fileName) ? __("PDF embed") : sprintf(
      /* translators: %s: filename. */
      __("Embed of %s."),
      fileName
    );
    const hasFilename = !RichText.isEmpty(fileName);
    const describedById = hasFilename ? fileId : void 0;
    return href && /* @__PURE__ */ jsxs("div", { ...useBlockProps.save(), children: [
      displayPreview && /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
        "object",
        {
          className: "wp-block-file__embed",
          data: href,
          type: "application/pdf",
          style: {
            width: "100%",
            height: `${previewHeight}px`
          },
          "aria-label": pdfEmbedLabel
        }
      ) }),
      hasFilename && /* @__PURE__ */ jsx(
        "a",
        {
          id: describedById,
          href: textLinkHref,
          target: textLinkTarget,
          rel: textLinkTarget ? "noreferrer noopener" : void 0,
          children: /* @__PURE__ */ jsx(RichText.Content, { value: fileName })
        }
      ),
      showDownloadButton && /* @__PURE__ */ jsx(
        "a",
        {
          href,
          className: clsx(
            "wp-block-file__button",
            __experimentalGetElementClassName("button")
          ),
          download: true,
          "aria-describedby": describedById,
          children: /* @__PURE__ */ jsx(RichText.Content, { value: downloadButtonText })
        }
      )
    ] });
  }
};
var v2 = {
  attributes: {
    id: {
      type: "number"
    },
    href: {
      type: "string"
    },
    fileId: {
      type: "string",
      source: "attribute",
      selector: "a:not([download])",
      attribute: "id"
    },
    fileName: {
      type: "string",
      source: "html",
      selector: "a:not([download])"
    },
    textLinkHref: {
      type: "string",
      source: "attribute",
      selector: "a:not([download])",
      attribute: "href"
    },
    textLinkTarget: {
      type: "string",
      source: "attribute",
      selector: "a:not([download])",
      attribute: "target"
    },
    showDownloadButton: {
      type: "boolean",
      default: true
    },
    downloadButtonText: {
      type: "string",
      source: "html",
      selector: "a[download]"
    },
    displayPreview: {
      type: "boolean"
    },
    previewHeight: {
      type: "number",
      default: 600
    }
  },
  supports: {
    anchor: true,
    align: true
  },
  save({ attributes }) {
    const {
      href,
      fileId,
      fileName,
      textLinkHref,
      textLinkTarget,
      showDownloadButton,
      downloadButtonText,
      displayPreview,
      previewHeight
    } = attributes;
    const pdfEmbedLabel = RichText.isEmpty(fileName) ? __("PDF embed") : sprintf(
      /* translators: %s: filename. */
      __("Embed of %s."),
      fileName
    );
    const hasFilename = !RichText.isEmpty(fileName);
    const describedById = hasFilename ? fileId : void 0;
    return href && /* @__PURE__ */ jsxs("div", { ...useBlockProps.save(), children: [
      displayPreview && /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
        "object",
        {
          className: "wp-block-file__embed",
          data: href,
          type: "application/pdf",
          style: {
            width: "100%",
            height: `${previewHeight}px`
          },
          "aria-label": pdfEmbedLabel
        }
      ) }),
      hasFilename && /* @__PURE__ */ jsx(
        "a",
        {
          id: describedById,
          href: textLinkHref,
          target: textLinkTarget,
          rel: textLinkTarget ? "noreferrer noopener" : void 0,
          children: /* @__PURE__ */ jsx(RichText.Content, { value: fileName })
        }
      ),
      showDownloadButton && /* @__PURE__ */ jsx(
        "a",
        {
          href,
          className: "wp-block-file__button",
          download: true,
          "aria-describedby": describedById,
          children: /* @__PURE__ */ jsx(RichText.Content, { value: downloadButtonText })
        }
      )
    ] });
  }
};
var v1 = {
  attributes: {
    id: {
      type: "number"
    },
    href: {
      type: "string"
    },
    fileName: {
      type: "string",
      source: "html",
      selector: "a:not([download])"
    },
    textLinkHref: {
      type: "string",
      source: "attribute",
      selector: "a:not([download])",
      attribute: "href"
    },
    textLinkTarget: {
      type: "string",
      source: "attribute",
      selector: "a:not([download])",
      attribute: "target"
    },
    showDownloadButton: {
      type: "boolean",
      default: true
    },
    downloadButtonText: {
      type: "string",
      source: "html",
      selector: "a[download]"
    },
    displayPreview: {
      type: "boolean"
    },
    previewHeight: {
      type: "number",
      default: 600
    }
  },
  supports: {
    anchor: true,
    align: true
  },
  save({ attributes }) {
    const {
      href,
      fileName,
      textLinkHref,
      textLinkTarget,
      showDownloadButton,
      downloadButtonText,
      displayPreview,
      previewHeight
    } = attributes;
    const pdfEmbedLabel = RichText.isEmpty(fileName) ? __("PDF embed") : sprintf(
      /* translators: %s: filename. */
      __("Embed of %s."),
      fileName
    );
    return href && /* @__PURE__ */ jsxs("div", { ...useBlockProps.save(), children: [
      displayPreview && /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
        "object",
        {
          className: "wp-block-file__embed",
          data: href,
          type: "application/pdf",
          style: {
            width: "100%",
            height: `${previewHeight}px`
          },
          "aria-label": pdfEmbedLabel
        }
      ) }),
      !RichText.isEmpty(fileName) && /* @__PURE__ */ jsx(
        "a",
        {
          href: textLinkHref,
          target: textLinkTarget,
          rel: textLinkTarget ? "noreferrer noopener" : void 0,
          children: /* @__PURE__ */ jsx(RichText.Content, { value: fileName })
        }
      ),
      showDownloadButton && /* @__PURE__ */ jsx(
        "a",
        {
          href,
          className: "wp-block-file__button",
          download: true,
          children: /* @__PURE__ */ jsx(RichText.Content, { value: downloadButtonText })
        }
      )
    ] });
  }
};
var deprecated = [v3, v2, v1];
var deprecated_default = deprecated;
export {
  deprecated_default as default
};
//# sourceMappingURL=deprecated.js.map
