import{s as Y,n as D,o as O}from"../chunks/scheduler.9cda857a.js";import{S as K,i as ss,e as j,s as l,c as d,h as ts,a as y,d as a,b as n,f as z,g as T,j as Z,k as W,l as as,m as e,n as w,t as J,o as U,p as $}from"../chunks/index.003612b0.js";import{C as es}from"../chunks/CopyLLMTxtMenu.44d08a39.js";import{C as F}from"../chunks/CodeBlock.a90632f1.js";import{H as X,E as ls}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.e5cfda8c.js";function ns(G){let p,C,I,E,i,_,o,q,r,H="From inside a Space’s iframe, you can check if a user is logged in or not on the main site, and if they have a PRO subscription or if one of their orgs has a paid subscription.",Q,u,V,c,k="<code>event.data.plan</code> will be of type:",A,m,v,h,P='You will get both the user’s status (logged out = <code>&quot;anonymous&quot;</code>) and their <a href="https://huggingface.co/pricing">plan</a>.',x,M,S,f,R='<li><a href="https://huggingface.co/spaces/huggingfacejs/plan" rel="nofollow">https://huggingface.co/spaces/huggingfacejs/plan</a></li>',B,g,L,b,N;return i=new es({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),o=new X({props:{title:"How to get a user’s plan and status in Spaces",local:"how-to-get-a-users-plan-and-status-in-spaces",headingTag:"h1"}}),u=new F({props:{code:"d2luZG93LmFkZEV2ZW50TGlzdGVuZXIoJTIybWVzc2FnZSUyMiUyQyUyMChldmVudCklMjAlM0QlM0UlMjAlN0IlMEElMjAlMjAlMjAlMjBpZiUyMChldmVudC5kYXRhLnR5cGUlMjAlM0QlM0QlM0QlMjAlMjJVU0VSX1BMQU4lMjIpJTIwJTdCJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwY29uc29sZS5sb2coJTIycGxhbiUyMiUyQyUyMGV2ZW50LmRhdGEucGxhbiklM0IlMEElMjAlMjAlMjAlMjAlN0QlMEElN0QpJTBBJTBBd2luZG93LnBhcmVudC5wb3N0TWVzc2FnZSglN0IlMEElMjAlMjAlMjAlMjB0eXBlJTNBJTIwJTIyVVNFUl9QTEFOX1JFUVVFU1QlMjIlMEElN0QlMkMlMjAlMjJodHRwcyUzQSUyRiUyRmh1Z2dpbmdmYWNlLmNvJTIyKSUzQg==",highlighted:`<span class="hljs-variable language_">window</span>.<span class="hljs-title function_">addEventListener</span>(<span class="hljs-string">&quot;message&quot;</span>, <span class="hljs-function">(<span class="hljs-params">event</span>) =&gt;</span> {
    <span class="hljs-keyword">if</span> (event.<span class="hljs-property">data</span>.<span class="hljs-property">type</span> === <span class="hljs-string">&quot;USER_PLAN&quot;</span>) {
        <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(<span class="hljs-string">&quot;plan&quot;</span>, event.<span class="hljs-property">data</span>.<span class="hljs-property">plan</span>);
    }
})

<span class="hljs-variable language_">window</span>.<span class="hljs-property">parent</span>.<span class="hljs-title function_">postMessage</span>({
    <span class="hljs-attr">type</span>: <span class="hljs-string">&quot;USER_PLAN_REQUEST&quot;</span>
}, <span class="hljs-string">&quot;https://huggingface.co&quot;</span>);`,wrap:!1}}),m=new F({props:{code:"JTdCJTBBJTIwJTIwJTIwJTIwdXNlciUzQSUyMCUyMmFub255bW91cyUyMiUyQyUwQSUyMCUyMCUyMCUyMG9yZyUzQSUyMHVuZGVmaW5lZCUwQSU3RCUyMCU3QyUyMCU3QiUwQSUyMCUyMCUyMCUyMHVzZXIlM0ElMjAlMjJwcm8lMjIlMjAlN0MlMjAlMjJmcmVlJTIyJTJDJTBBJTIwJTIwJTIwJTIwb3JnJTNBJTIwdW5kZWZpbmVkJTIwJTdDJTIwJTIydGVhbSUyMiUyMCU3QyUyMCUyMmVudGVycHJpc2UlMjIlMjAlN0MlMjAlMjJwbHVzJTIyJTIwJTdDJTIwJTIyYWNhZGVtaWElMjIlMEElN0Q=",highlighted:`{
    <span class="hljs-attr">user</span>: <span class="hljs-string">&quot;anonymous&quot;</span>,
    <span class="hljs-attr">org</span>: <span class="hljs-literal">undefined</span>
} | {
    <span class="hljs-attr">user</span>: <span class="hljs-string">&quot;pro&quot;</span> | <span class="hljs-string">&quot;free&quot;</span>,
    <span class="hljs-attr">org</span>: <span class="hljs-literal">undefined</span> | <span class="hljs-string">&quot;team&quot;</span> | <span class="hljs-string">&quot;enterprise&quot;</span> | <span class="hljs-string">&quot;plus&quot;</span> | <span class="hljs-string">&quot;academia&quot;</span>
}`,wrap:!1}}),M=new X({props:{title:"Examples",local:"examples",headingTag:"h2"}}),g=new ls({props:{source:"https://github.com/huggingface/hub-docs/blob/main/docs/hub/spaces-get-user-plan.md"}}),{c(){p=j("meta"),C=l(),I=j("p"),E=l(),d(i.$$.fragment),_=l(),d(o.$$.fragment),q=l(),r=j("p"),r.textContent=H,Q=l(),d(u.$$.fragment),V=l(),c=j("p"),c.innerHTML=k,A=l(),d(m.$$.fragment),v=l(),h=j("p"),h.innerHTML=P,x=l(),d(M.$$.fragment),S=l(),f=j("ul"),f.innerHTML=R,B=l(),d(g.$$.fragment),L=l(),b=j("p"),this.h()},l(s){const t=ts("svelte-u9bgzb",document.head);p=y(t,"META",{name:!0,content:!0}),t.forEach(a),C=n(s),I=y(s,"P",{}),z(I).forEach(a),E=n(s),T(i.$$.fragment,s),_=n(s),T(o.$$.fragment,s),q=n(s),r=y(s,"P",{"data-svelte-h":!0}),Z(r)!=="svelte-1fo9f5x"&&(r.textContent=H),Q=n(s),T(u.$$.fragment,s),V=n(s),c=y(s,"P",{"data-svelte-h":!0}),Z(c)!=="svelte-1y3xon2"&&(c.innerHTML=k),A=n(s),T(m.$$.fragment,s),v=n(s),h=y(s,"P",{"data-svelte-h":!0}),Z(h)!=="svelte-1ctc9w1"&&(h.innerHTML=P),x=n(s),T(M.$$.fragment,s),S=n(s),f=y(s,"UL",{"data-svelte-h":!0}),Z(f)!=="svelte-16n2ey6"&&(f.innerHTML=R),B=n(s),T(g.$$.fragment,s),L=n(s),b=y(s,"P",{}),z(b).forEach(a),this.h()},h(){W(p,"name","hf:doc:metadata"),W(p,"content",ps)},m(s,t){as(document.head,p),e(s,C,t),e(s,I,t),e(s,E,t),w(i,s,t),e(s,_,t),w(o,s,t),e(s,q,t),e(s,r,t),e(s,Q,t),w(u,s,t),e(s,V,t),e(s,c,t),e(s,A,t),w(m,s,t),e(s,v,t),e(s,h,t),e(s,x,t),w(M,s,t),e(s,S,t),e(s,f,t),e(s,B,t),w(g,s,t),e(s,L,t),e(s,b,t),N=!0},p:D,i(s){N||(J(i.$$.fragment,s),J(o.$$.fragment,s),J(u.$$.fragment,s),J(m.$$.fragment,s),J(M.$$.fragment,s),J(g.$$.fragment,s),N=!0)},o(s){U(i.$$.fragment,s),U(o.$$.fragment,s),U(u.$$.fragment,s),U(m.$$.fragment,s),U(M.$$.fragment,s),U(g.$$.fragment,s),N=!1},d(s){s&&(a(C),a(I),a(E),a(_),a(q),a(r),a(Q),a(V),a(c),a(A),a(v),a(h),a(x),a(S),a(f),a(B),a(L),a(b)),a(p),$(i,s),$(o,s),$(u,s),$(m,s),$(M,s),$(g,s)}}}const ps='{"title":"How to get a user’s plan and status in Spaces","local":"how-to-get-a-users-plan-and-status-in-spaces","sections":[{"title":"Examples","local":"examples","sections":[],"depth":2}],"depth":1}';function is(G){return O(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class hs extends K{constructor(p){super(),ss(this,p,is,ns,Y,{})}}export{hs as component};
