import{F as A,aD as V,c1 as K,r as u,ck as L,cl as N,cm as R,aH as B,bW as U,Q as E,W as M,R as P,X as T,e as W,c2 as _,ah as x,m as p}from"./vendor-Dd8T34zR.js";import{g as Q,a6 as z,bp as D,Q as F}from"./index-Vd7lvnU9.js";import{b as G}from"./customComponents-0bLbuA3c.js";const j=A({__name:"builder-io",props:{apiKey:{},isVisible:{type:Boolean}},emits:["setState"],setup(s,{emit:m}){const v=m,c=s,t=u(!1),e=u(null),n=u(!1),{storeId:f,cultureName:h,organizationId:y}=Q,{isAuthenticated:g,userGroups:b}=z(),{getUrlWithoutLocale:k}=D();function w(){e.value=null,t.value=!1,n.value=!1}V(()=>{r(window.location.pathname)}),K((a,o)=>{a.path!==o.path&&(w(),r(a.path))});async function r(a){if(c.apiKey){n.value=!0,l("loading");const o=k(a);e.value=await L({model:"page",apiKey:c.apiKey,options:N(new URLSearchParams(location.search)),userAttributes:{urlPath:o,locale:h,organizationId:y,isAuthenticated:g.value,storeId:f,groupName:b.value}}),n.value=!1,t.value=!!e.value||R(),t.value?l("ready"):l("empty")}}function l(a){v("setState",{state:a})}const d=x(null),S=B(d),i=p(()=>!!S.value&&!!e.value?.data),C=p(()=>F(e.value?.data?.title).title.value);U({title:()=>i.value?C.value:void 0,keywords:()=>i.value?e.value?.data?.keywords:void 0,description:()=>i.value?e.value?.data?.description:void 0});const I=()=>G;return(a,o)=>s.isVisible&&t.value?(P(),E("div",{key:0,ref_key:"builderIoAnchor",ref:d},[T(W(_),{model:"page",content:e.value,"api-key":s.apiKey,"custom-components":I()},null,8,["content","api-key","custom-components"])],512)):M("",!0)}});export{j as default};
//# sourceMappingURL=builder-io-Cb1B8Jdr.js.map
