import{Z as te,e as R,r as C,az as re,z as D,B as ne,aA as oe,aB as ae,y as q,s as se,m as ie,q as $}from"./CGQLQ9ei.js";function ce(e){let r=9;for(let n=0;n<e.length;)r=Math.imul(r^e.charCodeAt(n++),9**9);return((r^r>>>9)+65536).toString(16).substring(1,8).toLowerCase()}function N(e,r){const n=[],t=r.resolveKeyData||(s=>s.key),o=r.resolveValueData||(s=>s.value);for(const[s,u]of Object.entries(e))n.push(...(Array.isArray(u)?u:[u]).map(p=>{const f={key:s,value:p},d=o(f);return typeof d=="object"?N(d,r):Array.isArray(d)?d:{[typeof r.key=="function"?r.key(f):r.key]:t(f),[typeof r.value=="function"?r.value(f):r.value]:d}}).flat());return n}function F(e,r){return Object.entries(e).map(([n,t])=>{if(typeof t=="object"&&(t=F(t,r)),r.resolve){const o=r.resolve({key:n,value:t});if(typeof o<"u")return o}return typeof t=="number"&&(t=t.toString()),typeof t=="string"&&r.wrapValue&&(t=t.replace(new RegExp(r.wrapValue,"g"),`\\${r.wrapValue}`),t=`${r.wrapValue}${t}${r.wrapValue}`),`${n}${r.keyValueSeparator||""}${t}`}).join(r.entrySeparator||"")}const h=e=>({keyValue:e,metaKey:"property"}),P=e=>({keyValue:e}),j={appleItunesApp:{unpack:{entrySeparator:", ",resolve({key:e,value:r}){return`${m(e)}=${r}`}}},articleExpirationTime:h("article:expiration_time"),articleModifiedTime:h("article:modified_time"),articlePublishedTime:h("article:published_time"),bookReleaseDate:h("book:release_date"),charset:{metaKey:"charset"},contentSecurityPolicy:{unpack:{entrySeparator:"; ",resolve({key:e,value:r}){return`${m(e)} ${r}`}},metaKey:"http-equiv"},contentType:{metaKey:"http-equiv"},defaultStyle:{metaKey:"http-equiv"},fbAppId:h("fb:app_id"),msapplicationConfig:P("msapplication-Config"),msapplicationTileColor:P("msapplication-TileColor"),msapplicationTileImage:P("msapplication-TileImage"),ogAudioSecureUrl:h("og:audio:secure_url"),ogAudioUrl:h("og:audio"),ogImageSecureUrl:h("og:image:secure_url"),ogImageUrl:h("og:image"),ogSiteName:h("og:site_name"),ogVideoSecureUrl:h("og:video:secure_url"),ogVideoUrl:h("og:video"),profileFirstName:h("profile:first_name"),profileLastName:h("profile:last_name"),profileUsername:h("profile:username"),refresh:{metaKey:"http-equiv",unpack:{entrySeparator:";",resolve({key:e,value:r}){if(e==="seconds")return`${r}`}}},robots:{unpack:{entrySeparator:", ",resolve({key:e,value:r}){return typeof r=="boolean"?`${m(e)}`:`${m(e)}:${r}`}}},xUaCompatible:{metaKey:"http-equiv"}},W=new Set(["og","book","article","profile"]);function z(e){var t;const r=m(e),n=r.indexOf(":");return W.has(r.substring(0,n))?"property":((t=j[e])==null?void 0:t.metaKey)||"name"}function ue(e){var r;return((r=j[e])==null?void 0:r.keyValue)||m(e)}function m(e){const r=e.replace(/([A-Z])/g,"-$1").toLowerCase(),n=r.indexOf("-"),t=r.substring(0,n);return t==="twitter"||W.has(t)?e.replace(/([A-Z])/g,":$1").toLowerCase():r}function T(e){if(Array.isArray(e))return e.map(n=>T(n));if(typeof e!="object"||Array.isArray(e))return e;const r={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(r[m(n)]=T(e[n]));return r}function le(e,r){const n=j[r];return r==="refresh"?`${e.seconds};url=${e.url}`:F(T(e),{keyValueSeparator:"=",entrySeparator:", ",resolve({value:t,key:o}){if(t===null)return"";if(typeof t=="boolean")return`${o}`},...n==null?void 0:n.unpack})}const B=new Set(["og:image","og:video","og:audio","twitter:image"]);function Z(e){const r={};for(const n in e){if(!Object.prototype.hasOwnProperty.call(e,n))continue;const t=e[n];String(t)!=="false"&&n&&(r[n]=t)}return r}function H(e,r){const n=Z(r),t=m(e),o=z(t);if(B.has(t)){const s={};for(const u in n)Object.prototype.hasOwnProperty.call(n,u)&&(s[`${e}${u==="url"?"":`${u[0].toUpperCase()}${u.slice(1)}`}`]=n[u]);return K(s).sort((u,p)=>{var f,d;return(((f=u[o])==null?void 0:f.length)||0)-(((d=p[o])==null?void 0:d.length)||0)})}return[{[o]:t,...n}]}function K(e){const r=[],n={};for(const o in e){if(!Object.prototype.hasOwnProperty.call(e,o))continue;const s=e[o];if(!Array.isArray(s)){if(typeof s=="object"&&s){if(B.has(m(o))){r.push(...H(o,s));continue}n[o]=Z(s)}else n[o]=s;continue}for(const u of s)r.push(...typeof u=="string"?K({[o]:u}):H(o,u))}const t=N(n,{key({key:o}){return z(o)},value({key:o}){return o==="charset"?"charset":"content"},resolveKeyData({key:o}){return ue(o)},resolveValueData({value:o,key:s}){return o===null?"_null":typeof o=="object"?le(o,s):typeof o=="number"?o.toString():o}});return[...r,...t].map(o=>(o.content==="_null"&&(o.content=null),o))}const fe=new Set(["onload","onerror"]);let pe;function G(){return pe}const J=Symbol("ScriptProxyTarget");function Q(){}Q[J]=!0;function de(e){return e.key||ce(e.src||(typeof e.innerHTML=="string"?e.innerHTML:""))}function ge(e,r){var M,U,E;const n=typeof e=="string"?{src:e}:e,t=r||{},o=t.head||G();if(!o)throw new Error("Missing Unhead context.");const s=de(n),u=(M=o._scripts)==null?void 0:M[s];if(u)return u.setupTriggerHandler(t.trigger),u;(U=t.beforeInit)==null||U.call(t);const p=a=>{i.status=a,o.hooks.callHook("script:updated",Y)};fe.forEach(a=>{const c=typeof n[a]=="function"?n[a].bind(t.eventContext):null;n[a]=l=>{p(a==="onload"?"loaded":a==="onerror"?"error":"loading"),c==null||c(l)}});const f={loaded:[],error:[]},d=(a,c)=>{if(f[a]){const l=f[a].push(c);return()=>{var g;return(g=f[a])==null?void 0:g.splice(l-1,1)}}return c(i.instance),()=>{}},w=new Promise(a=>{if(o.ssr)return;const c=g=>requestAnimationFrame(()=>a(g)),l=o.hooks.hook("script:updated",({script:g})=>{const y=g.status;if(g.id===s&&(y==="loaded"||y==="error")){if(y==="loaded")if(typeof t.use=="function"){const _=t.use();_&&c(_)}else c({});else y==="error"&&a(!1);l()}})}),i=Object.assign(w,{instance:!o.ssr&&((E=t==null?void 0:t.use)==null?void 0:E.call(t))||null,proxy:null,id:s,status:"awaitingLoad",remove(){var a,c;return(a=i._triggerAbortController)==null||a.abort(),i._triggerPromises=[],i.entry?(i.entry.dispose(),p("removed"),(c=o._scripts)==null||delete c[s],!0):!1},load(a){var c;if((c=i._triggerAbortController)==null||c.abort(),i._triggerPromises=[],!i.entry){p("loading");const l={defer:!0,fetchpriority:"low"};n.src&&(n.src.startsWith("http")||n.src.startsWith("//"))&&(l.crossorigin="anonymous",l.referrerpolicy="no-referrer"),i.entry=o.push({script:[{...l,...n,key:`script.${s}`}]},t)}return a&&d("loaded",a),w},onLoaded(a){return d("loaded",a)},onError(a){return d("error",a)},setupTriggerHandler(a){if(i.status==="awaitingLoad")if((typeof a>"u"||a==="client")&&!o.ssr||a==="server")i.load();else if(a instanceof Promise){if(o.ssr)return;i._triggerAbortController||(i._triggerAbortController=new AbortController,i._triggerAbortPromise=new Promise(l=>{i._triggerAbortController.signal.addEventListener("abort",()=>{i._triggerAbortController=null,l()})})),i._triggerPromises=i._triggerPromises||[];const c=i._triggerPromises.push(Promise.race([a.then(l=>typeof l>"u"||l?i.load:void 0),i._triggerAbortPromise]).catch(()=>{}).then(l=>{l==null||l()}).finally(()=>{var l;(l=i._triggerPromises)==null||l.splice(c,1)}))}else typeof a=="function"&&a(i.load)},_cbs:f});w.then(a=>{var c,l;a!==!1?(i.instance=a,(c=f.loaded)==null||c.forEach(g=>g(a)),f.loaded=null):((l=f.error)==null||l.forEach(g=>g()),f.error=null)});const Y={script:i};i.setupTriggerHandler(t.trigger),i.$script=i;const O=(a,c,l)=>new Proxy((c?a==null?void 0:a[c]:a)||Q,{get(g,y,_){var v;if(o.hooks.callHook("script:instance-fn",{script:i,fn:y,exists:y in g}),!c){const S=(v=t.stub)==null?void 0:v.call(t,{script:i,fn:y});if(S)return S}return g&&y in g&&typeof g[y]<"u"?Reflect.get(g,y,_):y===Symbol.iterator?[][Symbol.iterator]:O(c?a==null?void 0:a[c]:a,y,l||[y])},async apply(g,y,_){if(o.ssr&&g[J])return;let v;const S=b=>{v=b||v;for(let x=0;x<(l||[]).length;x++){const ee=(l||[])[x];b=b==null?void 0:b[ee]}return b};let A=S(i.instance);return A||(A=await new Promise(b=>{i.onLoaded(x=>{b(S(x))})})),typeof A=="function"?Reflect.apply(A,v,_):A}});i.proxy=O(i.instance);const V=new Proxy(i,{get(a,c){const l=c in i||String(c)[0]==="_"?i:i.proxy;return c==="then"||c==="catch"?i[c].bind(i):Reflect.get(l,c,l)}});return o._scripts=Object.assign(o._scripts||{},{[s]:V}),V}function ye(e){return typeof e=="function"?e():R(e)}function k(e){if(e instanceof Promise||e instanceof Date||e instanceof RegExp)return e;const r=ye(e);if(!e||!r)return r;if(Array.isArray(r))return r.map(n=>k(n));if(typeof r=="object"){const n={};for(const t in r)if(Object.prototype.hasOwnProperty.call(r,t)){if(t==="titleTemplate"||t[0]==="o"&&t[1]==="n"){n[t]=R(r[t]);continue}n[t]=k(r[t])}return n}return r}const he="usehead",I=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},L="__unhead_injection_handler__";function X(){if(L in I)return I[L]();const e=te(he);return e||G()}function me(e,r={}){const n=r.head||X();if(n)return n.ssr?n.push(e,r):be(n,e,r)}function be(e,r,n={}){const t=C(!1),o=C({});re(()=>{o.value=t.value?{}:k(r)});const s=e.push(o.value,n);return D(o,p=>{s.patch(p)}),q()&&(ne(()=>{s.dispose()}),oe(()=>{t.value=!0}),ae(()=>{t.value=!1})),s}function _e(e,r){if(!r)return;const n=(t,o)=>{if(!e._cbs[t])return o(e.instance),()=>{};let s=e._cbs[t].push(o);const u=()=>{var p;s&&((p=e._cbs[t])==null||p.splice(s-1,1),s=null)};return $(u),u};e.onLoaded=t=>n("loaded",t),e.onError=t=>n("error",t),$(()=>{var t;(t=e._triggerAbortController)==null||t.abort()})}function we(e,r){const n=typeof e=="string"?{src:e}:e,t=r||{},o=(t==null?void 0:t.head)||X();t.head=o;const s=q();if(t.eventContext=s,s&&typeof t.trigger>"u")t.trigger=se;else if(ie(t.trigger)){const p=t.trigger;let f;t.trigger=new Promise(d=>{f=D(p,w=>{w&&d(!0)},{immediate:!0}),$(()=>d(!1),!0)}).then(d=>(f==null||f(),d))}o._scriptStatusWatcher=o._scriptStatusWatcher||o.hooks.hook("script:updated",({script:p})=>{p._statusRef.value=p.status});const u=ge(n,t);return u._statusRef=u._statusRef||C(u.status),_e(u,s),new Proxy(u,{get(p,f,d){return Reflect.get(p,f==="status"?"_statusRef":f,d)}})}function Se(e,r){const{title:n,titleTemplate:t,...o}=e;return me({title:n,titleTemplate:t,_flatMeta:o},{...r,transform(s){const u=K({...s._flatMeta});return delete s._flatMeta,{...s,meta:u}}})}export{me as a,we as b,X as i,Se as u};