1import{j as e,A as _,m as q}from"./vendor-motion-hRg_q8lq.js";import{r as c}from"./vendor-react-E98sgxjj.js";import{u as g,b as T,a as f}from"./vendor-query-bOUN_gKe.js";import{du as F}from"./vendor-fa-Bn2dnpnC.js";import{n as d,u as z,U}from"./index-BKzE8EQ8.js";function x(s){return["vanity",String(s)]}function B(s,{enabled:a=!0}={}){return g({queryKey:x(s),queryFn:()=>d.getVanity(Number(s)),enabled:a&&!!s,staleTime:3e4})}function D(s){const a=T();return f({mutationFn:()=>d.assignVanity(Number(s)),onSuccess:()=>{a.invalidateQueries({queryKey:x(s)})}})}function H(s){const a=s?.address?.trim();return a?`https://${a}`:null}function J({isOpen:s,onClose:a,game:i,onChanged:l}){const{t}=z("game"),A=T(),[v,j]=c.useState(""),[N,u]=c.useState(""),[S,p]=c.useState(""),[V,k]=c.useState(!1);c.useEffect(()=>{if(!s)return;const r=Q=>{Q.key==="Escape"&&a()};return document.addEventListener("keydown",r),()=>document.removeEventListener("keydown",r)},[s,a]);const{data:n,isLoading:E}=g({queryKey:x(i.id),queryFn:()=>d.getVanity(i.id),staleTime:3e4}),o=v.trim().toLowerCase(),L=n?.label??null,{data:m}=g({queryKey:["vanity-check",o],queryFn:()=>d.checkVanity(o),enabled:o.length>=3&&o!==L,staleTime:15e3}),y=()=>A.invalidateQueries({queryKey:x(i.id)}),h=f({mutationFn:()=>d.setVanity(i.id,o),onSuccess:r=>{j(""),u(""),p(r.address||""),y(),l?.(),setTimeout(()=>p(""),3e3)},onError:r=>{p(""),u(r?.response?.data?.message||t("gameSettings.vanity.taken","That address is not available."))}}),w=f({mutationFn:()=>d.releaseVanity(i.id),onSuccess:()=>{u(""),y(),l?.()}}),K=n?.available===!1,C=m?!m.available&&!m.problem:!1,b=m?.problem,P=o.length>=3&&!C&&!b&&!h.isPending;return e.jsx(_,{children:s&&e.jsxs(e.Fragment,{children:[e.jsx(q.div,{initial:{opacity:0}
1,animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 bg-black/80 z-[1060]",onClick:a}),e.jsx(q.div,{initial:{opacity:0,scale:.95,y:20},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:20},transition:{duration:.2,ease:[.16,1,.3,1]},className:"fixed inset-0 z-[1060] flex items-center justify-center p-4 pointer-events-none",children:e.jsxs("div",{className:"relative bg-card rounded-lg border border-border p-4 pt-10 md:p-8 md:pt-8 max-w-md w-full pointer-events-auto",onClick:r=>r.stopPropagation(),children:[e.jsx("button",{onClick:a,"aria-label":t("gameSettings.cancel","Cancel"),className:"absolute top-2 right-2 md:top-4 md:right-4 w-9 h-9 flex items-center justify-center rounded-md transition-colors cursor-pointer hover:bg-foreground/4 text-muted-foreground hover:text-foreground",children:e.jsx(F,{icon:["far","xmark"]})}),e.jsx("h3",{className:"text-lg text-foreground mb-2",children:t("gameSettings.vanity.title","Web address")}),e.jsx("p",{className:"text-sm text-muted-foreground mb-5",children:t("gameSettings.vanity.helpText","Give your game its own link you can share anywhere. Leave it empty and your game stays where it is.")}),E?e.jsx("p",{className:"text-sm text-muted-foreground",children:t("gameSettings.loading","Loadingâ¦")}):K?e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:t("gameSettings.vanity.unreachable","Couldn't reach the address service.")}),e.jsx("button",{onClick:y,className:"px-3 h-8 rounded-md text-sm border border-border hover:border-foreground
1/30 cursor-pointer",children:t("gameSettings.retry","Try again")})]}):e.jsxs(e.Fragment,{children:[n?.address&&e.jsxs("div",{className:"mb-4 pb-4 border-b border-border",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:t("gameSettings.vanity.current","Your game is at")}),e.jsx("button",{onClick:()=>w.mutate(),disabled:w.isPending,className:"flex-shrink-0 px-3 h-8 rounded-md text-sm border border-border hover:border-red-500/50 hover:text-red-500 disabled:opacity-30 cursor-pointer",children:t("gameSettings.vanity.remove","Remove")})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsxs("a",{href:`https://${n.address}`,target:"_blank",rel:"noreferrer",className:"flex items-center gap-1.5 min-w-0 text-base text-accent hover:underline",children:[e.jsxs("span",{className:"truncate",children:["https://",n.address]}),e.jsx(F,{icon:["far","arrow-up-right-from-square"],className:"text-xs flex-shrink-0"})]}),e.jsx("button",{onClick:()=>{navigator.clipboard.writeText(`https://${n.address}`),k(!0),setTimeout(()=>k(!1),2e3)},className:"flex-shrink-0 text-xs px-2 py-1 rounded transition-colors cursor-pointer bg-foreground
1/8 text-muted-foreground hover:text-foreground",children:V?t("gameSettings.vanity.copied","Copied!"):t("gameSettings.vanity.copy","Copy")})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"text",value:v,onChange:r=>{j(r.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"")),u("")},placeholder:n?.label||t("gameSettings.vanity.placeholder","yourgame"),className:"flex-1 px-3 py-2 rounded-md text-sm bg-transparent border border-border text-foreground focus:outline-none focus:border-foreground transition-colors"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[".",n?.root||"tesana.com"]})]}),o.length>=3&&b&&e.jsx("p",{className:"text-xs text-amber-500 mt-2",children:b==="reserved"?t("gameSettings.vanity.reserved","That name is reserved."):t("gameSettings.vanity.invalid","Use 3â63 letters, numbers or dashes, starting and ending with a letter or number.")}),C&&e.jsx("p",{className:"text-xs text-red-500 mt-2",children:t("gameSettings.vanity.taken","That address is not available.")}),e.jsxs("div",{className:"flex items-center gap-3 mt-3",children:[e.jsx("button",{onClick:()=>h.mutate(),disabled:!P,className:"px-3 h-9 bg-foreground text-background text-sm rounded-md hover:opacity-80 transition-opacity disabled:opacity-30 cursor-pointer",children:h.isPending?t("gameSettings.saving"):n?.address?t("gameSettings.vanity.change","Change address"):t("gameSettings.vanity.claim","Claim address")}),S&&e.jsx("span",{className:"text-sm text-green-500",children:S}),N&&e.jsx("span",{className:"text-sm text-red-500",children:N})]})]})]})})]})})}const $={get:async()=>(await U.get("/play/features/")).data};function X({enabled:s=!0}={}){const{data:a,isSuccess:i,isError:l}=g({queryKey:["play-features","publishing"],queryFn:$.get,enabled:s,staleTime:3e5,retry:1}),t=a;return{autoPublish:t?.auto_publish===!0,vanityAutoAssign:t?.vanity_auto_assign===!0,ready:i||l}}export{J as V,D as a,X as b,x as c,$ as p,B as u,H as v};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.