import{j as e}from"./jsx-runtime-agliiQSw.js";import{r as j}from"./index-BtyHvDgk.js";import{L as N,c as P}from"./chunk-UIGDSWPH-1hkfewjj.js";import{s as O}from"./progress-bar-CF3aJM3k.js";import{c as b}from"./misc-CJRwnByf.js";import{u as g}from"./pe-jEPZ3eFB.js";import{b as v,a as _}from"./root-loader-CIAkTEfn.js";(function(){try{var i=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};i.SENTRY_RELEASE={id:"8bd8bc3153d70a1c10ccde8d38796bd67282553d"}}catch{}})();function E(i){const t=P();return j.useEffect(()=>{t.state==="idle"&&t.data!=null&&i?.("fetcher-done")},[t,i]),t}function L({className:i,file:t,appFile:a,appName:u,syncTo:n,line:o,column:c,children:p,onUpdate:r}){const s=E(r),f=g();if(!t&&!a)return console.error('LaunchEditor: requires either "file" or "appFile" prop.'),null;const d=typeof a=="string"?[a]:a,m=t?"file":"appFile",h=n?.file?"file":n?.appFile?"appFile":"";return e.jsxs(s.Form,{action:"/launch-editor",method:"POST",className:"flex items-center",children:[f,O,e.jsx("input",{type:"hidden",name:"line",value:typeof o=="number"?o:void 0}),e.jsx("input",{type:"hidden",name:"column",value:c}),e.jsx("input",{type:"hidden",name:"type",value:m}),e.jsx("input",{type:"hidden",name:"file",value:t}),e.jsx("input",{type:"hidden",name:"appName",value:u}),d?.map(l=>e.jsx("input",{type:"hidden",name:"appFile",value:l},l)),n?e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"hidden",name:"syncTo.type",value:h}),e.jsx("input",{type:"hidden",name:"syncTo.file",value:n.file}),e.jsx("input",{type:"hidden",name:"syncTo.appName",value:n.appName}),e.jsx("input",{type:"hidden",name:"syncTo.appFile",value:n.appFile})]}):null,e.jsx("button",{type:"submit",className:b("launch_button",s.state==="idle"?null:"cursor-progress",s.data?.status==="error"?"cursor-not-allowed":null,i),children:p})]})}function I({className:i,file:t,appFile:a,appName:u,line:n,children:o}){const c=v(),p=_();if(Array.isArray(a))return e.jsx("div",{children:"Cannot open more than one file"});if(t){const l=y=>y.replace(/\\/g,"/"),x=ENV.EPICSHOP_GITHUB_ROOT.replace("/tree/","/blob/");return e.jsx("a",{className:"launch_button !no-underline",href:l(t).replace(l(ENV.EPICSHOP_CONTEXT_CWD),x)+(n?`#L${n}`:""),rel:"noreferrer",target:"_blank",children:o})}const r=c.find(l=>l.name===u),s=ENV.EPICSHOP_GITHUB_ROOT.replace("/tree/","/blob/"),[f,d]=a?a.split(","):["",""],m=n||(d?Number(d):void 0),h=[...r?.relativePath.split(p.separator)??[],f].join("/");return e.jsx("a",{className:b("launch_button !no-underline",i),href:`${s}/${h}${m?`#L${m}`:""}`,rel:"noreferrer",target:"_blank",children:o})}function k({appFile:i="README.mdx",appName:t,file:a,relativePath:u}){const n=E(),o=p=>{if(!p.altKey||ENV.EPICSHOP_DEPLOYED)return;p.preventDefault();const r=new FormData,s=a?"file":"appFile";r.append(s,a??i),r.append("type",s),t&&r.append("appName",t),n.submit(r,{method:"POST",action:"/launch-editor"})},c=ENV.EPICSHOP_GITHUB_ROOT.replace(/\/tree\/|\/blob\//,"/edit/");return e.jsxs(N,{className:"self-center font-mono text-sm",onClick:o,target:"_blank",to:`${c}/${u}`.replace(/\\/g,"/"),children:[e.jsx("span",{className:"@min-[720px]:hidden",children:"Edit"}),e.jsx("span",{className:"hidden @min-[720px]:block @min-[900px]:hidden",children:"Edit on GitHub"}),e.jsx("span",{className:"hidden @min-[900px]:block",children:"Edit this page on GitHub"})]})}const w=ENV.EPICSHOP_DEPLOYED?I:L;export{k as E,w as L};
//# sourceMappingURL=launch-editor-CXRQAcoM.js.map
