import { withBase } from 'ufo'; import { u as useRuntimeConfig, p as useRequestEvent } from '../server.mjs'; const TEXT_TAGS = ["p", "h1", "h2", "h3", "h4", "h5", "h6", "li"]; function isTag(vnode, tag) { if (vnode.type === tag) { return true; } if (typeof vnode.type === "object" && vnode.type.tag === tag) { return true; } if (vnode.tag === tag) { return true; } return false; } function isText(vnode) { return isTag(vnode, "text") || typeof vnode.children === "string"; } function nodeChildren(node) { var _a; if (Array.isArray(node.children) || typeof node.children === "string") { return node.children; } if (typeof ((_a = node.children) == null ? void 0 : _a.default) === "function") { return node.children.default(); } return []; } function nodeTextContent(node) { if (!node) { return ""; } if (Array.isArray(node)) { return node.map(nodeTextContent).join(""); } if (isText(node)) { return node.children || node.value; } const children = nodeChildren(node); if (Array.isArray(children)) { return children.map(nodeTextContent).join(""); } return ""; } function unwrap(vnode, tags = ["p"]) { if (Array.isArray(vnode)) { return vnode.flatMap((node) => unwrap(node, tags)); } let result = vnode; if (tags.some((tag) => tag === "*" || isTag(vnode, tag))) { result = nodeChildren(vnode) || vnode; if (!Array.isArray(result) && TEXT_TAGS.some((tag) => isTag(vnode, tag))) { result = [result]; } } return result; } function flatUnwrap(vnodes, tags = ["p"]) { vnodes = Array.isArray(vnodes) ? vnodes : [vnodes]; if (!tags.length) { return vnodes; } return vnodes.flatMap((vnode) => flatUnwrap(unwrap(vnode, [tags[0]]), tags.slice(1))).filter((vnode) => !(isText(vnode) && nodeTextContent(vnode).trim() === "")); } const withContentBase = (url) => withBase(url, useRuntimeConfig().public.content.api.baseURL); const useUnwrap = () => ({ unwrap, flatUnwrap }); const useContentDisabled = () => { console.warn("useContent is only accessible when you are using `documentDriven` mode."); console.warn("Learn more by visiting: https://content.nuxtjs.org/guide/writing/document-driven"); throw new Error("useContent is only accessible when you are using `documentDriven` mode."); }; const addPrerenderPath = (path) => { const event = useRequestEvent(); event.node.res.setHeader( "x-nitro-prerender", [ event.node.res.getHeader("x-nitro-prerender"), path ].filter(Boolean).join(",") ); }; const shouldUseClientDB = () => { useRuntimeConfig().public.content; { return false; } }; export { addPrerenderPath as a, useUnwrap as b, shouldUseClientDB as s, useContentDisabled as u, withContentBase as w }; //# sourceMappingURL=utils-6d756e03.mjs.map