// packages/block-library/src/gallery/utils.js
import {
  LINK_DESTINATION_ATTACHMENT,
  LINK_DESTINATION_MEDIA,
  LINK_DESTINATION_NONE,
  LINK_DESTINATION_MEDIA_WP_CORE,
  LINK_DESTINATION_ATTACHMENT_WP_CORE,
  LINK_DESTINATION_LIGHTBOX
} from "./constants";
import {
  LINK_DESTINATION_ATTACHMENT as IMAGE_LINK_DESTINATION_ATTACHMENT,
  LINK_DESTINATION_MEDIA as IMAGE_LINK_DESTINATION_MEDIA,
  LINK_DESTINATION_NONE as IMAGE_LINK_DESTINATION_NONE
} from "../image/constants";
function getHrefAndDestination(image, galleryDestination, imageDestination, attributes, lightboxSetting) {
  switch (imageDestination ? imageDestination : galleryDestination) {
    case LINK_DESTINATION_MEDIA_WP_CORE:
    case LINK_DESTINATION_MEDIA:
      return {
        href: image?.source_url || image?.url,
        linkDestination: IMAGE_LINK_DESTINATION_MEDIA,
        lightbox: lightboxSetting?.enabled ? { ...attributes?.lightbox, enabled: false } : void 0
      };
    case LINK_DESTINATION_ATTACHMENT_WP_CORE:
    case LINK_DESTINATION_ATTACHMENT:
      return {
        href: image?.link,
        linkDestination: IMAGE_LINK_DESTINATION_ATTACHMENT,
        lightbox: lightboxSetting?.enabled ? { ...attributes?.lightbox, enabled: false } : void 0
      };
    case LINK_DESTINATION_LIGHTBOX:
      return {
        href: void 0,
        lightbox: !lightboxSetting?.enabled ? { ...attributes?.lightbox, enabled: true } : void 0,
        linkDestination: IMAGE_LINK_DESTINATION_NONE
      };
    case LINK_DESTINATION_NONE:
      return {
        href: void 0,
        linkDestination: IMAGE_LINK_DESTINATION_NONE,
        lightbox: void 0
      };
  }
  return {};
}
export {
  getHrefAndDestination
};
//# sourceMappingURL=utils.js.map
