import{d as A,H as D,eN as R,r as k,o as C,G as x,b as p,ev as N,f as c,w as u,c as f,u as d,ae as O,ar as b,bA as V,e as y,ez as F,I as j,bG as T,ex as B,aD as J,eE as E,eF as $,v as z}from"./outputWidgets.3c3deba7.js";import{e as M}from"./toggleHighContrast.2076150f.js";import{v as G}from"./string.dc95a94c.js";import{E as U}from"./icons.c5a369ef.js";import{f as H}from"./index.a4d94226.js";import{A as L,F as P}from"./Form.21b032af.js";import{A as W}from"./index.9c0f1ee5.js";import{A as q}from"./index.c3c37865.js";import{A as K}from"./index.288cdbc6.js";(function(){try{var s=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},t=new Error().stack;t&&(s._sentryDebugIds=s._sentryDebugIds||{},s._sentryDebugIds[t]="86dfced6-46e9-43de-9834-53a59d74b28d",s._sentryDebugIdIdentifier="sentry-dbid-86dfced6-46e9-43de-9834-53a59d74b28d")}catch{}})();class Q{async list(t){const n=new URLSearchParams({stage:t});return await(await fetch(`/_editor/api/stage_runs?${n}`)).json()}}const X=new Q;class g{constructor(t){this.dto=t}static async list(t){return(await X.list(t)).map(r=>new g(r))}get id(){return this.dto.id}get data(){return this.dto.data}get assignee(){return this.dto.assignee}get stage(){return this.dto.stage}get status(){return this.dto.status}get createdAt(){return new Date(this.dto.createdAt)}}const Y=s=>(E("data-v-1a85240c"),s=s(),$(),s),Z=Y(()=>y("span",null," Fix with AI ",-1)),ee=A({__name:"StageRunSelector",props:{stage:{},stageRunId:{},enableStartThread:{type:Boolean}},emits:["fix-invalid-json","update:stage-run-id","update:enable-start-thread"],setup(s,{emit:t}){var h;const n=s,r=D(()=>{if(!n.stage.testData)return{valid:!0,parsed:{}};const e=G(n.stage.testData);return e.valid&&!R.exports.isObject(e.parsed)?{valid:!1,message:"Thread data must be an object."}:e});function m(){r.value.valid||t("fix-invalid-json",n.stage.testData,r.value.message)}const v=k(null),S=e=>{const a=l.stageRuns.find(I=>I.id===e),i=JSON.stringify(a==null?void 0:a.data,null,2);t("update:stage-run-id",e),o.setValue(i),o.updateOptions({readOnly:!!e})},w=()=>{t("update:stage-run-id",null),o.setValue("{}"),o.updateOptions({readOnly:!1})},_=e=>{t("update:enable-start-thread",e),o.setValue("{}"),o.updateOptions({readOnly:e})};let o;C(async()=>{l.stageRuns=await g.list(n.stage.id),l.options=l.stageRuns.filter(e=>e.status==="waiting").map(e=>({value:e.id,label:`Started ${H(e.createdAt,{addSuffix:!0})}`})),o=M.create(v.value,{language:"json",value:n.stage.testData,fontFamily:"monospace",lineNumbers:"off",minimap:{enabled:!1},scrollbar:{vertical:"hidden",horizontal:"visible"}}),o.onDidChangeModelContent(()=>{n.stage.testData=o.getValue()})});const l=x({stageRuns:[],options:[],loading:!1,stageRunId:(h=n.stageRunId)!=null?h:void 0});return(e,a)=>(p(),N(J,null,[c(d(P),{layout:"vertical"},{default:u(()=>[e.stage.isInitial?(p(),f(d(V),{key:1,checked:e.enableStartThread,onChange:a[3]||(a[3]=i=>_(i.target.checked))},{default:u(()=>[b(" Continue with the thread after this ")]),_:1},8,["checked"])):(p(),f(d(L),{key:0,label:"Select a thread or edit the test thread data"},{default:u(()=>[c(d(O),{value:l.stageRunId,"onUpdate:value":a[0]||(a[0]=i=>l.stageRunId=i),placeholder:"No thread selected","filter-option":"",style:{width:"100%"},"allow-clear":!0,options:l.options,disabled:e.stage.isInitial,"not-found-content":"There are no waiting threads",onSelect:a[1]||(a[1]=i=>S(i)),onClear:a[2]||(a[2]=i=>w())},null,8,["value","options","disabled"])]),_:1}))]),_:1}),c(d(W),{orientation:"left"},{default:u(()=>[b("Data")]),_:1}),y("div",{ref_key:"dataJson",ref:v,class:F(["data-container",{threaded:!!e.stageRunId,invalid:!r.value.valid}])},null,2),r.value.valid===!1?(p(),f(d(K),{key:0,type:"error",message:"Invalid JSON",description:r.value.message},{action:u(()=>[c(d(T),{onClick:m},{default:u(()=>[c(d(q),{align:"center",gap:"small"},{default:u(()=>[c(j,{path:d(U)},null,8,["path"]),Z]),_:1})]),_:1})]),_:1},8,["description"])):B("",!0)],64))}});const ue=z(ee,[["__scopeId","data-v-1a85240c"]]);export{ue as S};
//# sourceMappingURL=StageRunSelector.035c9e5c.js.map
