import{d as F,i as b,a as y,c as s,r as B,a4 as P,o as n,f as o,x as r,z as p,A as _,D as O,E as R,R as u,b8 as L,b as z,S as N,g as a,y as I,W as T,aB as E,_ as q}from"./index-dyx4v2bZ.js";import{W as J}from"./WdsTabs-3Pn5IB6k.js";import{W as G}from"./WdsFieldWrapper-DRQKJkmD.js";import{W as K,B as M}from"./BuilderSettings-BOOx97bk.js";import"./WdsDropdownMenu-DPkY81S5.js";import"./WdsCheckbox-CjK48piR.js";import"./useKeyValueEditor-BHh_FKR7.js";const H={class:"BuilderSettingsArtifactAPITriggerDetails"},Q={key:0,class:"BuilderSettingsArtifactAPITriggerDetails__builder"},X={key:1,class:"BuilderSettingsArtifactAPITriggerDetails__api"},Y={class:"BuilderSettingsArtifactAPITriggerDetails__steps"},Z={id:"stepCreate",class:"BuilderSettingsArtifactAPITriggerDetails__step"},ee={id:"stepPaste",class:"BuilderSettingsArtifactAPITriggerDetails__step"},te={id:"stepPoll",class:"BuilderSettingsArtifactAPITriggerDetails__step"},ie=F({__name:"BuilderSettingsArtifactAPITriggerDetails",setup(se){const l=b(y.core),C=b(y.builderManager),d=s(()=>l.getComponentById(C.firstSelectedId.value)),D=s(()=>{var i;return((i=d.value)==null?void 0:i.parentId)??""}),S=s(()=>d.value?l.getComponentDefinition(d.value.type):null),k=s(()=>{var e;const i=((e=S.value)==null?void 0:e.fields)??{};return Object.entries(i).filter(([,t])=>t.isArtifactField)}),f=(l.writerBaseUrl.value??"https://api.writer.com").replace(/\/+$/,""),h=s(()=>`curl --location --request POST '${f}/v1/agents/${l.writerAppId.value}/blueprints/${D.value}/jobs' \\
--header 'Authorization: Bearer ${l.writerApiKey.value}' \\
--header 'Content-Type: application/json' --data '{"inputs": []}'`),$=[{label:"Run in Agent Builder",value:"builder"},{label:"Run via API",value:"api"}],c=B("builder"),g=B(""),A=s(()=>{try{return JSON.parse(g.value)}catch{return null}}),{copy:W,copied:x}=P({source:h}),j=s(()=>{var i,e;return!((e=(i=A.value)==null?void 0:i.poll_url)!=null&&e.trim())}),U=s(()=>{var e;const i=((e=A.value)==null?void 0:e.poll_url)??"/v1/agents/jobs/JOB_ID";return`curl --location --request GET '${f}${i}' \\
--header 'Authorization: Bearer ${l.writerApiKey.value}'`}),{copy:V,copied:w}=P({source:U});return(i,e)=>(n(),o("div",H,[r(K,null,{default:p(()=>e[4]||(e[4]=[_("Test your trigger")])),_:1}),r(J,{modelValue:c.value,"onUpdate:modelValue":e[0]||(e[0]=t=>c.value=t),class:"BuilderSettingsArtifactAPITriggerDetails__tabs",tabs:$},null,8,["modelValue"]),c.value==="builder"?(n(),o("div",Q,[(n(!0),o(O,null,R(k.value,([t,m])=>(n(),o("div",{key:t,class:"BuilderSettingsArtifactAPITriggerDetails__field"},[r(G,{label:m.name??t,hint:m.desc,"is-expansible":!0},{default:p(()=>{var v;return[m.type==u(L).Code?(n(),z(M,{key:0,"field-key":t,"component-id":((v=d.value)==null?void 0:v.id)??"","is-expanded":!1,"input-language":"json"},null,8,["field-key","component-id"])):N("",!0)]}),_:2},1032,["label","hint"])]))),128))])):(n(),o("div",X,[a("ol",Y,[a("li",Z,[e[6]||(e[6]=a("p",{class:"BuilderSettingsArtifactAPITriggerDetails__step__hint"}," Paste the CURL command into your terminal ",-1)),r(T,{variant:"tertiary",size:"small",onClick:e[1]||(e[1]=t=>u(W)())},{default:p(()=>[r(I,{name:u(x)?"check":"clipboard"},null,8,["name"]),e[5]||(e[5]=_(" Copy cURL command "))]),_:1})]),a("li",ee,[e[7]||(e[7]=a("p",{class:"BuilderSettingsArtifactAPITriggerDetails__step__hint"}," Once the job has run, paste the result here: ",-1)),r(E,{modelValue:g.value,"onUpdate:modelValue":e[2]||(e[2]=t=>g.value=t),placeholder:"Paste cURL output here"},null,8,["modelValue"])]),a("li",te,[e[9]||(e[9]=a("p",{class:"BuilderSettingsArtifactAPITriggerDetails__step__hint"}," Lastly, paste the poll async into your terminal to retrieve your artifact ",-1)),r(T,{variant:"tertiary",size:"small",disabled:j.value,onClick:e[3]||(e[3]=t=>u(V)())},{default:p(()=>[r(I,{name:u(w)?"check":"clipboard"},null,8,["name"]),e[8]||(e[8]=_(" Copy poll async "))]),_:1},8,["disabled"])])])]))]))}}),pe=q(ie,[["__scopeId","data-v-84903d5f"]]);export{pe as default};
