import{j as e}from"./jsx-runtime-C4_65a1U.js";import{r as j}from"./index-B9zr-vzA.js";import{L as g,f as N}from"./chunk-JZWAC4HX-5kJHQiQ9.js";import{s as P}from"./progress-bar-BwLqNk15.js";import{c as b}from"./misc-DRDyxdMg.js";import{u as _}from"./pe-P58jSSsB.js";import{a as I,b as v}from"./root-loader-Cnwtpb_k.js";(function(){try{var n=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};n.SENTRY_RELEASE={id:"8a6db0ac5fe78363b0c97fe458a96ce773bf357c"};var t=new n.Error().stack;t&&(n._sentryDebugIds=n._sentryDebugIds||{},n._sentryDebugIds[t]="ce2f077c-f53e-4548-91fd-a8dcac8b0c01",n._sentryDebugIdIdentifier="sentry-dbid-ce2f077c-f53e-4548-91fd-a8dcac8b0c01")}catch{}})();function E(n){const t=N();return j.useEffect(()=>{t.state==="idle"&&t.data!=null&&n?.("fetcher-done")},[t,n]),t}function O({className:n,file:t,appFile:a,appName:p,syncTo:r,line:o,column:u,children:l,onUpdate:s}){const i=E(s),m=_();if(!t&&!a)return console.error('LaunchEditor: requires either "file" or "appFile" prop.'),null;const d=typeof a=="string"?[a]:a,f=t?"file":"appFile",h=r?.file?"file":r?.appFile?"appFile":"";return e.jsxs(i.Form,{action:"/launch-editor",method:"POST",className:"flex items-center",children:[m,P,e.jsx("input",{type:"hidden",name:"line",value:typeof o=="number"?o:void 0}),e.jsx("input",{type:"hidden",name:"column",value:u}),e.jsx("input",{type:"hidden",name:"type",value:f}),e.jsx("input",{type:"hidden",name:"file",value:t}),e.jsx("input",{type:"hidden",name:"appName",value:p}),d?.map(c=>e.jsx("input",{type:"hidden",name:"appFile",value:c},c)),r?e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"hidden",name:"syncTo.type",value:h}),e.jsx("input",{type:"hidden",name:"syncTo.file",value:r.file}),e.jsx("input",{type:"hidden",name:"syncTo.appName",value:r.appName}),e.jsx("input",{type:"hidden",name:"syncTo.appFile",value:r.appFile})]}):null,e.jsx("button",{type:"submit",className:b("launch_button",i.state==="idle"?null:"cursor-progress",i.data?.status==="error"?"cursor-not-allowed":null,n),children:l})]})}function L({className:n,file:t,appFile:a,appName:p,line:r,children:o}){const u=I(),l=v();if(Array.isArray(a))return e.jsx("div",{children:"Cannot open more than one file"});if(t){const c=x=>x.replace(/\\/g,"/"),y=ENV.EPICSHOP_GITHUB_ROOT.replace("/tree/","/blob/");return e.jsx("a",{className:"launch_button !no-underline",href:c(t).replace(c(ENV.EPICSHOP_CONTEXT_CWD),y)+(r?`#L${r}`:""),rel:"noreferrer",target:"_blank",children:o})}const s=u.find(c=>c.name===p),i=ENV.EPICSHOP_GITHUB_ROOT.replace("/tree/","/blob/"),[m,d]=a?a.split(","):["",""],f=r||(d?Number(d):void 0),h=[...s?.relativePath.split(l.separator)??[],m].join("/");return e.jsx("a",{className:b("launch_button !no-underline",n),href:`${i}/${h}${f?`#L${f}`:""}`,rel:"noreferrer",target:"_blank",children:o})}function k({appFile:n="README.mdx",appName:t,file:a,relativePath:p}){const r=E(),o=l=>{if(!l.altKey||ENV.EPICSHOP_DEPLOYED)return;l.preventDefault();const s=new FormData,i=a?"file":"appFile";s.append(i,a??n),s.append("type",i),t&&s.append("appName",t),r.submit(s,{method:"POST",action:"/launch-editor"})},u=ENV.EPICSHOP_GITHUB_ROOT.replace(/\/tree\/|\/blob\//,"/edit/");return e.jsxs(g,{className:"self-center font-mono text-sm",onClick:o,target:"_blank",to:`${u}/${p}`.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?L:O;export{k as E,w as L};
//# sourceMappingURL=launch-editor-CwyOLU4S.js.map
