import{a}from"./chunk-QFPCSRLT.js";import"./chunk-J3SVE4GM.js";import"./chunk-7EYXEF6M.js";import"./chunk-SBZEOPXX.js";function c(){let t=null,n=null;return{promise:new Promise((o,i)=>{t=o,n=i}),resolve:t,reject:n}}var u=t=>{let{createHost:n}=t;return{__type:"host",create:e=>({}),host:e=>{var o,i;let{applicationId:r}=e??{},s=typeof window<"u"?window.wixEmbedsAPI:void 0,l=n(e),f=p();return{...l,apiBaseUrl:f,getMonitoringClient:s==null||s.getMonitoringClientFunction==null?void 0:s.getMonitoringClientFunction(r),essentials:{language:typeof window<"u"?(o=window.commonConfig)==null?void 0:o.language:void 0,locale:typeof window<"u"?(i=window.commonConfig)==null?void 0:i.locale:void 0}}},auth:e=>{let o=typeof window<"u"?window.wixEmbedsAPI:void 0;e||(e=o==null||o.getAccessTokenFunction==null?void 0:o.getAccessTokenFunction());let i=!1,{resolve:r,promise:s}=c();return{getAuthHeaders:async()=>{if(!e&&i&&(e=await s),!e)throw new Error("Failed to resolve auth token");return{headers:{Authorization:await e()}}},getAccessTokenInjector:()=>(i=!0,l=>{r(l)})}}}};function p(){let t=typeof window<"u"?window.wixEmbedsAPI:void 0,n=t==null||t.getExternalBaseUrl==null?void 0:t.getExternalBaseUrl();if(!n)return;let e=new URL(n);return e!=null&&e.pathname&&e.pathname!=="/"?""+e.hostname+e.pathname:e.hostname}var w=t=>{let{clientSdk:n,applicationId:e}=t;return{invoke:async o=>{let{namespace:i,method:r,args:s}=o;if(!n)throw new Error("Wix Site SDK only works in a Wix site environment. Learn more: https://dev.wix.com/docs/sdk/host-modules/site/introduction");return n.invoke({namespace:i,method:r,args:s,applicationId:e,accessToken:"accessToken"})},getAccessToken:()=>{throw new Error("Not implemented")},observeState:()=>({disconnect:()=>{}})}};var m=function(t){var n,e,o;let i=(n=(e=typeof $wixContext<"u"?$wixContext.clientSdk:void 0)!=null?e:t?.clientSdk)!=null?n:typeof window<"u"?(o=window)==null?void 0:o.clientSdk:void 0,{applicationId:r}=t||{};if(!r)throw new Error('"createHost" was called without a required field "applicationId"');return{channel:w({clientSdk:i,applicationId:r}),close:()=>{}}};var d=u({createHost:m});var P=t=>{let n=d.host({applicationId:t}),e=d.auth(),o=e.getAccessTokenInjector();return a({auth:e,host:n}).enableContext("module"),{injectGetAccessToken:o}},_=({host:t,auth:n})=>{a({host:t,auth:n}).enableContext("module")};export{P as enableClient,_ as enablePanelClient};
//# sourceMappingURL=site.js.map