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AAK,KAAK,OAAO,SAAQ,SAAU,GACtC,EAAS,GAAQ,EACrB,IACA,EAAa,OAAO,OAAO,EAAU,EACzC,CAEA,OAAO,KAAK,GAAY,QAAQ,SAAU,GACtC,IAAI,EAAO,KAAK,MAAM,GACtB,GAAK,EAAL,CAIA,IAAI,EAAe,KAAK,QAAQ,aAC5B,EAAW,KAAK,QAAQ,GACvB,GACD,KAAK,WAAW,SAAW,EAAe,uBAG9C,IAAI,EAAQ,EAAM,IAAS,KAE3B,GAAI,IAAU,KAAK,QAAQ,oBAAqB,CAC5C,OAAO,KAAK,KAAK,OAAO,QAAQ,SAAU,GACtC,IAAI,EAAQ,IAAI,OAAO,IAAO,EAAO,IAAM,MAC3C,EAAQ,EAAM,QAAQ,EAAO,KAAK,MAAM,GAC5C,EAAE,KAAK,OAEP,IAAI,EAAO,EAAK,SAAS,QAAQ,aAAc,GAC/C,KAAK,QAAQ,OAAS,KAAK,IAAI,GAE/B,IAAI,EAAW,KAAK,QAAQ,EAAK,UAC7B,IACA,KAAK,UAAU,GACf,KAAK,QAAQ,OAAS,KAAK,IAAI,SAAW,EAAO,cAErD,KAAK,UAAU,EAAU,KAAK,UAAU,GAC5C,CACA,KAAK,QAAQ,OAAS,KAAK,IAAI,aAAe,EAAO,WAAa,EAAQ,IAzB1E,MAFI,KAAK,WAAW,SAAW,EAAO,mBA4B1C,EAAE,KAAK,MACX,EACA,IAAI,UAAU,WAAa,WACvB,KAAK,MAAQ,CAAC,CAClB,EACA,IAAI,UAAU,YAAc,SAAU,GAClC,KAAK,MAAQ,OAAO,OAAO,KAAK,MAAO,EAC3C,EACI,SACA,OAAO,QAAU","file":"/npm/@oothkoo/seo-js@1.0.5/seo.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/@oothkoo/seo-js@1.0.5/seo.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","function Seo (options) {\n    this.options = Object.assign(this.getDefaultOptions(), options)\n    this.clearMetas()\n    this.clearTerms()\n}\nSeo.prototype.version = '1.0.5'\nSeo.prototype.getDefaultOptions = function () {\n    return {\n        debug: false,\n        headSelector: 'head',\n        ignoreEmptyTagValue: true\n    }\n}\nSeo.prototype.use = function (metas) {\n    if (Array.isArray(metas)) {\n        metas.forEach(function (meta) {\n            this.metas[meta.name] = meta\n        }.bind(this))\n    }\n    else if (typeof metas === 'object') {\n        this.metas[metas.name] = metas\n    }\n}\nSeo.prototype.getMessageText = function (message) {\n    return '[Seo.js] - ' + message + '.'\n}\nSeo.prototype.log = function (message) {\n    console.log(this.getMessageText(message))\n}\nSeo.prototype.clearMetas = function () {\n    this.metas = {}\n}\nSeo.prototype.getMetaTypeTag = function (name) {\n    return {\n        name: name,\n        selector: name,\n        template: '<' + name + '>{value}</' + name + '>'\n    }\n}\nSeo.prototype.tag = function (names) {\n    if (Array.isArray(names)) {\n        return names.map(function (name) {\n            return this.getMetaTypeTag(name)\n        }.bind(this))\n    }\n    else if (typeof names === 'string') {\n        return this.getMetaTypeTag(names)\n    }\n}\nSeo.prototype.getMetaTypeName = function (name) {\n    return {\n        name: name,\n        selector: 'meta[name=\"' + name + '\"]',\n        template: '<meta name=\"' + name + '\" content=\"{value}\" />'\n    }\n}\nSeo.prototype.metaName = function (names) {\n    if (Array.isArray(names)) {\n        return names.map(function (name) {\n            return this.getMetaTypeName(name)\n        }.bind(this))\n    }\n    else if (typeof names === 'string') {\n        return this.getMetaTypeName(names)\n    }\n}\nSeo.prototype.getMetaTypeProperty = function (name) {\n    return {\n        name: name,\n        selector: 'meta[property=\"' + name + '\"]',\n        template: '<meta property=\"' + name + '\" content=\"{value}\" />'\n    }\n}\nSeo.prototype.metaProperty = function (names) {\n    if (Array.isArray(names)) {\n        return names.map(function (name) {\n            return this.getMetaTypeProperty(name)\n        }.bind(this))\n    }\n    else if (typeof names === 'string') {\n        return this.getMetaTypeProperty(names)\n    }\n}\nSeo.prototype.getMetaTypeLink = function (name) {\n    return {\n        name: name,\n        selector: 'link[rel=\"' + name + '\"]',\n        template: '<link rel=\"' + name + '\" href=\"{value}\" />'\n    }\n}\nSeo.prototype.link = function (names) {\n    if (Array.isArray(names)) {\n        return names.map(function (name) {\n            return this.getMetaTypeLink(name)\n        }.bind(this))\n    }\n    else if (typeof names === 'string') {\n        return this.getMetaTypeLink(names)\n    }\n}\nSeo.prototype.throwError = function (message) {\n    throw new Error(this.getMessageText(message))\n}\nSeo.prototype.domRemove = function (el) {\n    this.domFind(this.options.headSelector).removeChild(el)\n}\nSeo.prototype.domFind = function (selector) {\n    return document.querySelector(selector)\n}\nSeo.prototype.domCreate = function (html) {\n    var node = document.implementation.createHTMLDocument()\n    node.body.innerHTML = html\n    return node.body.firstChild;\n}\nSeo.prototype.domAppend = function (el1, el2) {\n    return el1.appendChild(el2)\n}\nSeo.prototype.clear = function () {\n    Object.keys(this.metas).forEach(function (name) {\n        var meta = this.metas[name]\n        var metaNode = this.domFind(meta.selector)\n        if (metaNode) {\n            this.domRemove(metaNode)\n        }\n    }.bind(this))\n}\nSeo.prototype.update = function (metas, only) {\n\n    var finalMetas = {}\n    if (only) {\n        finalMetas = metas\n    }\n    else {\n        var defMetas = {}\n        Object.keys(this.metas).forEach(function (name) {\n            defMetas[name] = ''\n        })\n        finalMetas = Object.assign(defMetas, metas)\n    }\n\n    Object.keys(finalMetas).forEach(function (name) {\n        var meta = this.metas[name]\n        if (!meta) {\n            this.throwError('meta (' + name + ') not registered')\n            return\n        }\n        var headSelector = this.options.headSelector\n        var headNode = this.domFind(headSelector)\n        if (!headNode) {\n            this.throwError('head (' + headSelector + ') element not found')\n        }\n\n        var value = metas[name] || null\n\n        if (value || !this.options.ignoreEmptyTagValue) {\n            Object.keys(this.terms).forEach(function (term) {\n                var regex = new RegExp('\\{' + term + '\\}', 'gi')\n                value = value.replace(regex, this.terms[term])\n            }.bind(this))\n\n            var html = meta.template.replace(/\\{value\\}/g, value)\n            this.options.debug && this.log(html)\n\n            var metaNode = this.domFind(meta.selector)\n            if (metaNode) {\n                this.domRemove(metaNode)\n                this.options.debug && this.log('meta (' + name + ') removed')\n            }\n            this.domAppend(headNode, this.domCreate(html))\n        }\n        this.options.debug && this.log('meta name[' + name + '] value[' + value + ']')\n    }.bind(this))\n}\nSeo.prototype.clearTerms = function () {\n    this.terms = {}\n}\nSeo.prototype.updateTerms = function (terms) {\n    this.terms = Object.assign(this.terms, terms)\n}\nif (module) {\n    module.exports = Seo\n}\n"]}