import{_ as e,K as l,i as a,c as t,j as n,h as o,aj as r,o as s,a as u,g as i,f as c,b as v,n as d,F as g,s as p,e as h,d as m,q as x,t as f,Q as y,ai as w,v as b,x as k,an as S,C as j}from"./index-BSOHXgJs.js";import{_ as q}from"./SLLoading-BGZbIvaK.js";import{F as L}from"./FuncBar-3ZIJM1sL.js";const T={class:"w-full h-full px-7 py-6 relative overflow-hidden"},_={key:0},H={key:1,class:"text-negative-default"},C={key:0,class:"w-full py-10 flex flex-col items-center text-lg font-semibold"},F=(e=>(b("data-v-d0b54d4d"),e=e(),k(),e))((()=>v("span",null,"No Logs",-1))),N={key:1,class:"flex h-full items-center justify-center"},$=e({__name:"LogPage",setup(e){const b=l().id,k=a(),$=t((()=>{var e;const l=null==(e=k.value)?void 0:e.map(((e,l)=>{const a=e,t=""!==K.value&&a.toLowerCase().includes(K.value);return{isTarget:t,index:l+1,value:t?B(a,K.value):a}})),a=M(l);return E.value.map(((e,t)=>l.push({index:a+t+1,value:e,error:!0}))),l})),I=t((()=>{var e;let l=1;const a=null==(e=$.value)?void 0:e.length;return a&&(l=""===$.value[a-1].index?$.value[a-2].index:$.value[a-1].index),l?8*l.length+"px":"0px"})),M=e=>{const l=null==e?void 0:e.reduce(((e,l)=>l.index&&Number(l.index)>Number(e)?l.index:e),0);return Number(l)},P=t((()=>{var e;return(null==(e=k.value)?void 0:e.join("\n"))+E.value.join("\n")})),B=(e,l)=>{let a=e.split(new RegExp(`(${l})`,"i"));return a=a.filter((e=>""!==e)),a},E=a([]),K=a(""),Q=e=>{K.value=e.toLowerCase()},R=a([0,0]),V=a(16),z=t((()=>{var e;return(null==(e=$.value)?void 0:e.length)*V.value})),A=S((e=>{const l=e.target;D(l)}),100),D=e=>{const l=V.value,a=Math.ceil(e.clientHeight/l),t=Math.floor(e.scrollTop/l),n=t+a;e.scrollTop<=30*l?R.value[0]=0:R.value[0]=t-30,e.scrollTop+e.clientHeight>=e.scrollHeight-30*l?R.value[1]=$.value.length-1:R.value[1]=n+30},G=t((()=>R.value[0]*V.value));return n((async()=>{const{data:e}=await o.get(`/experiment/${b}/recent_log`).catch((e=>{3404===e.data.code&&(k.value=[])}));k.value=e.logs||[],e.error&&(E.value=e.error),r((()=>{D(document.querySelector(".log-container")),(()=>{const e=document.querySelector(".log-line");if(!e)return 0;const l=window.getComputedStyle(e);V.value=parseFloat(l.getPropertyValue("line-height"))})(),document.querySelector(".log-container").scrollHeight>document.querySelector(".log-container").clientHeight&&(document.querySelector(".log-container").scrollTop=document.querySelector(".log-container").scrollHeight)}))})),(e,l)=>{const a=j;return s(),u("div",T,[k.value?(s(),i(L,{key:0,class:"pb-6",onInput:Q,content:P.value,placeholder:e.$t("experiment.func-bar.placeholder.log"),filename:"print.log"},null,8,["content","placeholder"])):c("",!0),v("section",{class:"log-container",onScroll:l[0]||(l[0]=(...e)=>m(A)&&m(A)(...e))},[k.value?(s(),u("div",{key:0,class:"log-area",style:d({height:z.value+"px"})},[v("div",{class:"log-board",style:d({top:G.value+"px"})},[(s(!0),u(g,null,p($.value.slice(R.value[0],R.value[1]+1),((e,l)=>(s(),u("div",{class:"log-line",key:e.value+R.value[0]+l},[v("span",{class:x(["w-8 text-right flex-shrink-0 text-dimmest select-none",{"text-negative-default":e.error}]),style:d({width:I.value})},f(e.index),7),e.error?(s(),u("div",H,f(e.value),1)):(s(),u("div",_,[y(v("span",null,f(e.value),513),[[w,!e.isTarget]]),y(v("span",null,[(s(!0),u(g,null,p(e.value,(e=>(s(),u("span",{key:e,class:x({"bg-warning-dimmest":e.toLowerCase()===K.value})},f(e),3)))),128))],512),[[w,e.isTarget]])]))])))),128))],4),0===k.value.length&&0===E.value.length?(s(),u("div",C,[h(a,{class:"magnifier",icon:"search"}),F])):c("",!0)],4)):(s(),u("div",N,[h(q)]))],32)])}}},[["__scopeId","data-v-d0b54d4d"]]);export{$ as default};
