// @bun
var{defineProperty:R,getOwnPropertyNames:Z,getOwnPropertyDescriptor:_}=Object,$=Object.prototype.hasOwnProperty;function C(j){return this[j]}var l=(j)=>{var z=(W??=new WeakMap).get(j),A;if(z)return z;if(z=R({},"__esModule",{value:!0}),j&&typeof j==="object"||typeof j==="function"){for(var B of Z(j))if(!$.call(z,B))R(z,B,{get:C.bind(j,B),enumerable:!(A=_(j,B))||A.enumerable})}return W.set(j,z),z},W;var I=(j)=>j;function h(j,z){this[j]=I.bind(null,z)}var x=(j,z)=>{for(var A in z)R(j,A,{get:z[A],enumerable:!0,configurable:!0,set:h.bind(z,A)})};var D=(j,z)=>()=>(j&&(z=j(j=0)),z);var r=import.meta.require;var m={};x(m,{useTitle:()=>T,useSeoMeta:()=>X,usePageTitle:()=>T,useHead:()=>O,resetHead:()=>V,renderHtmlAttrs:()=>b,renderHead:()=>q,renderBodyAttrs:()=>H,processTitleDirective:()=>d,processMetaDirective:()=>u,processHeadDirective:()=>k,getPageMeta:()=>P,getHead:()=>M,definePageMeta:()=>y,applyHead:()=>p});function M(){return K}function P(){return Q}function V(){K={},S.length=0,Q={}}function O(j){K=w(K,j)}function w(j,z){return{title:z.title??j.title,titleTemplate:z.titleTemplate??j.titleTemplate,base:z.base??j.base,meta:[...j.meta||[],...z.meta||[]],link:[...j.link||[],...z.link||[]],script:[...j.script||[],...z.script||[]],style:[...j.style||[],...z.style||[]],htmlAttrs:{...j.htmlAttrs,...z.htmlAttrs},bodyAttrs:{...j.bodyAttrs,...z.bodyAttrs}}}function X(j){let z=[];if(j.description)z.push({name:"description",content:j.description});if(j.keywords){let L=Array.isArray(j.keywords)?j.keywords.join(", "):j.keywords;z.push({name:"keywords",content:L})}if(j.author)z.push({name:"author",content:j.author});if(j.robots)z.push({name:"robots",content:j.robots});let A=j.ogTitle??j.title,B=j.ogDescription??j.description;if(A)z.push({property:"og:title",content:A});if(B)z.push({property:"og:description",content:B});if(j.ogImage)z.push({property:"og:image",content:j.ogImage});if(j.ogUrl)z.push({property:"og:url",content:j.ogUrl});if(j.ogType)z.push({property:"og:type",content:j.ogType});if(j.ogSiteName)z.push({property:"og:site_name",content:j.ogSiteName});if(j.ogLocale)z.push({property:"og:locale",content:j.ogLocale});let E=j.twitterTitle??j.title,F=j.twitterDescription??j.description,G=j.twitterImage??j.ogImage;if(j.twitterCard)z.push({name:"twitter:card",content:j.twitterCard});if(E)z.push({name:"twitter:title",content:E});if(F)z.push({name:"twitter:description",content:F});if(G)z.push({name:"twitter:image",content:G});if(j.twitterSite)z.push({name:"twitter:site",content:j.twitterSite});if(j.twitterCreator)z.push({name:"twitter:creator",content:j.twitterCreator});if(j.articleAuthor)z.push({property:"article:author",content:j.articleAuthor});if(j.articlePublishedTime)z.push({property:"article:published_time",content:j.articlePublishedTime});if(j.articleModifiedTime)z.push({property:"article:modified_time",content:j.articleModifiedTime});if(j.articleSection)z.push({property:"article:section",content:j.articleSection});if(j.articleTags)for(let L of j.articleTags)z.push({property:"article:tag",content:L});let J=[];if(j.canonical)J.push({rel:"canonical",href:j.canonical});O({title:j.title,titleTemplate:j.titleTemplate,meta:z,link:J})}function y(j){if(Q={...Q,...j},j.title||j.description)X({title:j.title,description:j.description})}function T(j){let z=typeof j==="function"?j():j;O({title:z})}function q(j=K){let z=[];if(j.title){let A=j.title;if(j.titleTemplate)A=typeof j.titleTemplate==="function"?j.titleTemplate(A):j.titleTemplate.replace("%s",A);z.push(`<title>${N(A)}</title>`)}if(j.base){let A=Object.entries(j.base).map(([B,E])=>`${B}="${N(E)}"`).join(" ");z.push(`<base ${A}>`)}for(let A of j.meta||[]){let B=Object.entries(A).filter(([E,F])=>F!==void 0).map(([E,F])=>{return`${E==="httpEquiv"?"http-equiv":E}="${N(String(F))}"`}).join(" ");z.push(`<meta ${B}>`)}for(let A of j.link||[]){let B=Object.entries(A).filter(([E,F])=>F!==void 0).map(([E,F])=>`${E}="${N(String(F))}"`).join(" ");z.push(`<link ${B}>`)}for(let A of j.script||[]){let{content:B,...E}=A,F=Object.entries(E).filter(([G,J])=>J!==void 0).map(([G,J])=>{if(typeof J==="boolean")return J?G:"";return`${G}="${N(String(J))}"`}).filter(Boolean).join(" ");if(B)z.push(`<script ${F}>${B}</script>`);else z.push(`<script ${F}></script>`)}for(let A of j.style||[]){let B=A.type?` type="${A.type}"`:"";z.push(`<style${B}>${A.content}</style>`)}return z.join(`
`)}function b(j=K){if(!j.htmlAttrs)return"";return Object.entries(j.htmlAttrs).map(([z,A])=>`${z}="${N(A)}"`).join(" ")}function H(j=K){if(!j.bodyAttrs)return"";return Object.entries(j.bodyAttrs).map(([z,A])=>`${z}="${N(A)}"`).join(" ")}function N(j){return j.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function p(j=K){if(typeof document>"u")return;if(j.title){let z=j.title;if(j.titleTemplate)z=typeof j.titleTemplate==="function"?j.titleTemplate(z):j.titleTemplate.replace("%s",z);document.title=z}for(let z of j.meta||[]){let A=z.name?`meta[name="${z.name}"]`:z.property?`meta[property="${z.property}"]`:null;if(A){let B=document.querySelector(A);if(!B){if(B=document.createElement("meta"),z.name)B.setAttribute("name",z.name);if(z.property)B.setAttribute("property",z.property);document.head.appendChild(B)}B.setAttribute("content",z.content)}}for(let z of j.link||[]){let A=`link[rel="${z.rel}"]${z.href?`[href="${z.href}"]`:""}`,B=document.querySelector(A);if(!B)B=document.createElement("link"),document.head.appendChild(B);for(let[E,F]of Object.entries(z))if(F!==void 0)B.setAttribute(E,String(F))}if(j.htmlAttrs)for(let[z,A]of Object.entries(j.htmlAttrs))document.documentElement.setAttribute(z,A);if(j.bodyAttrs)for(let[z,A]of Object.entries(j.bodyAttrs))document.body.setAttribute(z,A)}function k(j){let z="";return{content:j.replace(/@head\s*([\s\S]*?)@endhead/g,(B,E)=>{return z+=E.trim()+`
`,""}),headContent:z.trim()}}function d(j,z){return j.replace(/@title\s*\(\s*(?:(['"`])(.+?)\1|([^)]+))\s*\)/g,(A,B,E,F)=>{let G=B?E:z[(F||"").trim()]??F;return O({title:G}),""})}function u(j,z){return j.replace(/@meta\s*\(\s*(['"`])(.+?)\1\s*,\s*(?:(['"`])(.+?)\3|([^)]+))\s*\)/g,(A,B,E,F,G,J)=>{let L=F?G:J,U=F?L:z[(L||"").trim()]??L,Y=E.includes(":")?{property:E,content:U}:{name:E,content:U};return O({meta:[Y]}),""})}var K,S,Q;var v=D(()=>{K={},S=[],Q={}});v();export{T as useTitle,X as useSeoMeta,T as usePageTitle,O as useHead,V as resetHead,b as renderHtmlAttrs,q as renderHead,H as renderBodyAttrs,d as processTitleDirective,u as processMetaDirective,k as processHeadDirective,P as getPageMeta,M as getHead,y as definePageMeta,p as applyHead};
