import Vue from 'vue';
import uuid from '../uuid/uuid';
var SpritesService = /** @class */ (function () {
    function SpritesService() {
        this.externalSpriteIdPrefixes = new Map();
    }
    /** @deprecated Use addInternalSprites or addExternalSprites instead */
    SpritesService.prototype.addSprites = function (sprites) {
        return this.addInternalSprites(sprites);
    };
    SpritesService.prototype.addInternalSprites = function (sprites) {
        var div = document.createElement('div');
        var id = uuid.generate();
        div.id = id;
        div.setAttribute('aria-hidden', 'true');
        div.style.display = 'none';
        div.innerHTML = sprites;
        document.body.insertBefore(div, document.body.childNodes[0]);
        return id;
    };
    SpritesService.prototype.removeInternalSprite = function (id) {
        if (document.getElementById(id) !== null) {
            document.getElementById(id).remove();
        }
        else {
            Vue.prototype.$log.warn("unable to remove internal sprite with id=" + id);
        }
    };
    SpritesService.prototype.addExternalSprites = function (sprites, externalSpriteIdPrefix) {
        if (this.isInExternalSprites(externalSpriteIdPrefix)) {
            Vue.prototype.$log.warn('"' + externalSpriteIdPrefix + '" already exists in the externalSpriteIdPrefixes. You are overwriting a sprites collection.');
        }
        this.externalSpriteIdPrefixes.set(externalSpriteIdPrefix, sprites);
    };
    SpritesService.prototype.getExternalSpritesFromSpriteId = function (spriteId) {
        if (spriteId && this.isInExternalSprites(this.getExternalSpriteIdPrefixFromSpriteId(spriteId))) {
            return this.getExternalSprites(this.getExternalSpriteIdPrefixFromSpriteId(spriteId)) + '#' + spriteId;
        }
    };
    SpritesService.prototype.isInExternalSprites = function (externalSpriteIdPrefix) {
        return externalSpriteIdPrefix !== undefined && this.externalSpriteIdPrefixes.has(externalSpriteIdPrefix);
    };
    SpritesService.prototype.getExternalSpriteIdPrefixFromSpriteId = function (spriteId) {
        if (spriteId.indexOf(SpritesService.externalSpriteIdPrefixSeparator) !== -1) {
            return spriteId.split(SpritesService.externalSpriteIdPrefixSeparator)[0];
        }
    };
    SpritesService.prototype.getExternalSprites = function (externalSpriteIdPrefix) {
        return this.externalSpriteIdPrefixes.get(externalSpriteIdPrefix);
    };
    SpritesService.externalSpriteIdPrefixSeparator = '-';
    return SpritesService;
}());
export { SpritesService };
var SpritesPlugin = {
    install: function (v, options) {
        v.prototype.$log.debug('$svg', 'plugin.install');
        var svg = new SpritesService();
        (v.prototype).$svg = svg;
    }
};
export default SpritesPlugin;
//# sourceMappingURL=sprites.js.map