import{g as K,j as e,c as T,X as P,r as n,k as B,Y as R,b as $,t as p,F as D,l as h,P as I,B as r,a as N}from"./main-BzPVmAp-.js";import{M as O}from"./index-Fy_dqHL_.js";import{b as J,f as V,w as X}from"./index-B-RBPprY.js";import{F as Y}from"./index-2r9flV8X.js";import{T as q}from"./index-SGIbgpRk.js";import"./index-CDeD9lyT.js";import"./index-CUuSmggi.js";import"./addEventListener-CzbSevz3.js";import"./index-7u0Bo8e4.js";import"./index-CSq209pq.js";import"./index-sAnz6zLe.js";import"./index-BQm1iTRH.js";import"./UpOutlined-B_NQN-zy.js";import"./Table-kIlrKW-9.js";import"./Dropdown-Clv_Pvnt.js";import"./index-BZ6Sq__j.js";import"./index-CUrh6kIn.js";import"./index-Djhsc5K4.js";import"./study-page-D4nenWxt.js";import"./usePagination-CGdUxo17.js";import"./RedoOutlined-d_QTXv-s.js";import"./index-Cl0Hi3Gl.js";import"./callSuper-CKCGYiRV.js";import"./index-RAxRq3bL.js";import"./index-D0tEL95I.js";import"./index-BfzdirmR.js";import"./DeleteOutlined-DoDR38qq.js";import"./index-BF4b68Hp.js";import"./index-5ngX0NHj.js";import"./rgb-BwIoVOhg.js";const be=()=>{const{analysisId:d}=K();if(!d)return e.jsx("div",{children:"404"});const g=T(),w=P(),{location:x}=w.state||{},y=n.useRef(null),[t,F]=n.useState(null),{messageApi:m}=B(),[E,C]=n.useState(""),[o,j]=n.useState(null),{eventSourceRef:l,status:G,reconnect:H}=R(),[b,k]=n.useState("pipeline_script"),[S,z]=n.useState({}),[A,v]=n.useState(!1);n.useEffect(()=>{var s;if(l){const i=a=>{const f=JSON.parse(a.data);d==f.analysis_id&&(f.event=="analysis_complete"||f.event=="analysis_failed")&&c()};return(s=l.current)==null||s.addEventListener("message",i),()=>{var a;console.log("removeEventListener"),(a=l.current)==null||a.removeEventListener("message",i)}}},[l.current]);const L=async s=>(await J(s)).data,u=async()=>{o&&(await X(o,y.current.getValue()),m.success("保存成功"))},c=async()=>{const i=(await V(d)).data;F(i),j(i.pipeline_script),z({pipeline_script:i.pipeline_script,script_config_file:i.script_config_file})};n.useEffect(()=>{o&&_(o)},[o]);const _=async(s,i=!1)=>{s&&L(s).then(a=>{C(a.data),i&&m.success(`脚本加载成功: ${s}`)})};n.useEffect(()=>{const s=i=>{(i.ctrlKey||i.metaKey)&&i.key==="s"&&(i.preventDefault(),typeof u=="function"&&u())};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s)}},[]);const{openModal:M}=$();return n.useEffect(()=>{c()},[]),e.jsxs("div",{children:[e.jsx(q,{size:"small",activeKey:b,onChange:s=>{k(s),j(S[s]),v(s==="params_path")},tabBarExtraContent:e.jsxs(D,{gap:"small",align:"center",children:[e.jsx(h,{color:"cyan",children:t==null?void 0:t.container_name}),e.jsx(h,{color:"cyan",children:t==null?void 0:t.analysis_status}),e.jsx(h,{color:"cyan",children:t==null?void 0:t.analysis_name}),e.jsx(I,{title:"是否生成脚本",onConfirm:async()=>{await N.post(`/analysis/convert-ipynb/${t.analysis_id}`),m.success("是否生成脚本成功!")},children:e.jsx(r,{size:"small",color:"cyan",variant:"solid",children:"生成脚本"})}),e.jsx(r,{size:"small",color:"cyan",variant:"solid",onClick:()=>{window.open(`http://10.110.1.11:8888/jupyter/notebooks/${t.jupyter_notebook_path}`,"_blank")},children:"jupyter"}),e.jsx(p,{title:e.jsx(e.Fragment,{children:o}),children:e.jsx(r,{size:"small",color:"cyan",variant:"solid",onClick:u,children:"保存"})}),e.jsx(p,{title:e.jsx(e.Fragment,{children:o}),children:e.jsx(r,{size:"small",color:"cyan",variant:"solid",onClick:()=>{_(o,!0)},children:"刷新脚本"})}),e.jsx(r,{size:"small",color:"cyan",variant:"solid",onClick:c,children:"刷新"}),x&&e.jsx(r,{size:"small",color:"cyan",variant:"solid",onClick:()=>{g(x)},children:"返回"})]}),items:[{key:"pipeline_script",label:e.jsx(p,{title:e.jsx(e.Fragment,{children:e.jsx("ul",{children:e.jsx("li",{children:t==null?void 0:t.pipeline_script})})}),children:"脚本"})},{key:"script_config_file",label:e.jsx(p,{title:e.jsx(e.Fragment,{children:e.jsx("ul",{children:e.jsx("li",{children:t==null?void 0:t.script_config_file})})}),children:"脚本配置"})}]}),e.jsx(O,{format:A,value:E,editorRef:y,defaultLanguage:"python",height:"50vh"}),e.jsx(Y,{callback:c,analysis:t,operatePipeline:{openModal:M}})]})};export{be as default};
