"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/constant.ts var EXCEPTION_FIELD = ["secureUrl", "siteName", "appId"]; // src/utils.ts var camelcase = (attrName) => attrName.replace(/([A-Z])/g, EXCEPTION_FIELD.includes(attrName) ? "_$1" : ":$1").toLowerCase(); var toAttrs = (name, content, field, prefix) => { const _name = prefix ? `${prefix}:${name}` : name; if (typeof content === "number") { return { [field]: _name, content: `${content}` }; } else if (Array.isArray(content)) { return content.map((_content) => ({ [field]: _name, content: _content })); } else if (typeof content === "object") { return Object.entries(content).map(([key, value]) => toAttrs(camelcase(key), value, field, _name)); } return { [field]: _name, content }; }; // src/transform.ts var transform = (options) => { const basicOGMetaAttrs = Object.entries(options.basic || {}).map(([name, content]) => toAttrs(camelcase(name), content, "property", "og")); const twitterOGMetaAttrs = Object.entries(options.twitter || {}).map(([name, content]) => toAttrs(camelcase(name), content, "name", "twitter")); const facebookOGMetaAttrs = Object.entries(options.facebook || {}).map(([name, content]) => toAttrs(camelcase(name), content, "property", "fb")); const attrs = [...basicOGMetaAttrs.flat(), ...twitterOGMetaAttrs.flat(3), ...facebookOGMetaAttrs.flat()]; return attrs.map((_attrs) => ({ attrs: _attrs, tag: "meta", injectTo: "head" })); }; // src/index.ts var src_default = (options) => ({ name: "vite-plugin-open-graph", transformIndexHtml(html) { return { html, tags: transform(options || {}) }; } }); exports.default = src_default;