/*!
 * lightGallery Proofing Plugin | 2.9.1 | April 3rd 2026
 * http://www.lightgalleryjs.com/
 * Copyright (c) 2026 ShutterPress;
 * @license GPLv3
 */

(function (global, factory) {
    typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
    typeof define === 'function' && define.amd ? define(factory) :
    (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.lgProofing = factory());
})(this, (function () { 'use strict';

    /**
     * List of lightGallery events
     * All events should be documented here
     * Below interfaces are used to build the website documentations
     * */
    var lGEvents = {
        afterAppendSlide: 'lgAfterAppendSlide',
        init: 'lgInit',
        hasVideo: 'lgHasVideo',
        containerResize: 'lgContainerResize',
        updateSlides: 'lgUpdateSlides',
        afterAppendSubHtml: 'lgAfterAppendSubHtml',
        beforeOpen: 'lgBeforeOpen',
        afterOpen: 'lgAfterOpen',
        slideItemLoad: 'lgSlideItemLoad',
        beforeSlide: 'lgBeforeSlide',
        afterSlide: 'lgAfterSlide',
        posterClick: 'lgPosterClick',
        dragStart: 'lgDragStart',
        dragMove: 'lgDragMove',
        dragEnd: 'lgDragEnd',
        beforeNextSlide: 'lgBeforeNextSlide',
        beforePrevSlide: 'lgBeforePrevSlide',
        beforeClose: 'lgBeforeClose',
        afterClose: 'lgAfterClose',
        rotateLeft: 'lgRotateLeft',
        rotateRight: 'lgRotateRight',
        flipHorizontal: 'lgFlipHorizontal',
        flipVertical: 'lgFlipVertical',
        autoplay: 'lgAutoplay',
        autoplayStart: 'lgAutoplayStart',
        autoplayStop: 'lgAutoplayStop',
    };

    var Proofing = /** @class */ (function () {
        function Proofing(instance) {
            this.buttonClass = 'lg-proofing';
            this.statusClassPrefix = 'lg-proofing-status-';
            this.baseButtonClasses = ['lg-icon', this.buttonClass];
            this.core = instance;
        }
        Proofing.prototype.init = function () {
            this.appendProofingIcon();
            this.bindEvents();
            this.updateProofingState(this.core.index);
        };
        Proofing.prototype.appendProofingIcon = function () {
            if (this.core.outer.find("." + this.buttonClass).get()) {
                return;
            }
            this.core.$toolbar.append("<button type=\"button\" aria-label=\"Proofing status\" class=\"" + this.baseButtonClasses.join(' ') + "\">\n                <svg viewBox=\"0 0 24 24\" width=\"18\" height=\"18\" aria-hidden=\"true\" focusable=\"false\">\n                    <path fill=\"currentColor\" d=\"M12 2a7 7 0 0 0-7 7c0 1.9.77 3.62 2 4.89V22l5-2.5L17 22v-8.11A6.97 6.97 0 0 0 19 9a7 7 0 0 0-7-7Zm0 2a5 5 0 0 1 5 5c0 1.35-.53 2.58-1.4 3.47l-.6.58V18.76l-3-1.5-3 1.5v-5.71l-.6-.58A4.97 4.97 0 0 1 7 9a5 5 0 0 1 5-5Z\"/>\n                </svg>\n            </button>");
        };
        Proofing.prototype.bindEvents = function () {
            var _this = this;
            this.core.LGel.on(lGEvents.afterOpen + ".proofing", function () {
                _this.updateProofingState(_this.core.index);
            });
            this.core.LGel.on(lGEvents.afterSlide + ".proofing", function (event) {
                _this.updateProofingState(event.detail.index);
            });
            this.core.LGel.on(lGEvents.updateSlides + ".proofing", function () {
                _this.updateProofingState(_this.core.index);
            });
        };
        Proofing.prototype.getProofingStatus = function (index) {
            var _a;
            var galleryItem = this.core.galleryItems[index];
            var itemStatus = galleryItem === null || galleryItem === void 0 ? void 0 : galleryItem.proofingStatus;
            if (itemStatus) {
                return itemStatus;
            }
            var sourceItem = (_a = this.core.items) === null || _a === void 0 ? void 0 : _a[index];
            return (sourceItem === null || sourceItem === void 0 ? void 0 : sourceItem.getAttribute('data-proofing-status')) || undefined;
        };
        Proofing.prototype.updateProofingState = function (index) {
            var _this = this;
            var $button = this.core.outer.find("." + this.buttonClass).first();
            var button = $button.get();
            if (!button) {
                return;
            }
            var classNames = Array.from(button.classList);
            classNames.forEach(function (className) {
                if (className.indexOf(_this.statusClassPrefix) === 0) {
                    $button.removeClass(className);
                }
            });
            var status = this.getProofingStatus(index);
            if (!status) {
                return;
            }
            var normalizedStatus = status
                .trim()
                .toLowerCase()
                .replace(/[^a-z0-9]+/g, '-')
                .replace(/^-+|-+$/g, '');
            if (!normalizedStatus) {
                return;
            }
            $button.addClass("" + this.statusClassPrefix + normalizedStatus);
        };
        Proofing.prototype.destroy = function () {
            this.core.outer.find("." + this.buttonClass).remove();
            this.core.LGel.off('.proofing');
        };
        Proofing.pluginName = 'proofing';
        return Proofing;
    }());

    return Proofing;

}));
//# sourceMappingURL=lg-proofing.umd.js.map
