PageSourceSearch

https://workspace.amy.vc/build/assets/Builder-BZ88e9Ix.js

js amy.vc collected 2026-09-29 04:05:10 UTC 72,802 bytes, 1 lines download raw bytes

1import{P as bt}from"./page-wrapper-BhhC63X1.js";import{_ as xt}from"./workflow-status-pill.vue_vue_type_script_setup_true_lang-CFtmZzaN.js";import{_ as V}from"./index-CdFf6ajF.js";import{a as wt,b as ht,_ as kt}from"./TooltipTrigger-BzgAonwi.js";import{H as L,r as _t,P as $t,Y as St,y as Ct,A as ue,L as ne,l as At,c as Et,J as Vt,w as re,a as Be}from"./index.min-Bz6HI3KO.js";import{l as Se,r as G,h as Mt}from"./index.esm-DEpV9LmX.js";import{d as J,o as r,c as f,i as t,f as s,u as e,w as n,b as c,t as v,e as y,a as $,h as Z,F as O,r as B,j as _,g as A,n as Y,x as Ut,m as It,y as Rt}from"./runtime-core.esm-bundler-BUvReHWE.js";import{_ as zt}from"./connected-integrations-block.vue_vue_type_script_setup_true_lang-CaF75rIW.js";import{_ as ie}from"./Input-O8KQDvSY.js";import{_ as he,a as qe,b as We}from"./PopoverTrigger-DxhxTHP3.js";import{C as Tt}from"./chevron-down-Bo-CHAhe.js";import{S as Ot}from"./search-D-yEvsaU.js";import{L as Lt}from"./loader-circle-BAWv281s.js";import{C as Pt}from"./check-BPFsxgot.js";import{a as Ce,b as Ae,c as Ee,_ as Ve}from"./SheetTitle-BtPsMhPO.js";import{a as Me,_ as jt}from"./AppSidebarLayout.vue_vue_type_script_setup_true_lang-C9t7LDYR.js";import{_ as Ft}from"./_plugin-vue_export-helper-DlAUqK2U.js";import{w as Fe}from"./runtime-dom.esm-bundler-DF9jAoLn.js";import{f as Dt,a as Nt,_ as Ue,b as de}from"./format-utils-Vk0Tsug7.js";import{_ as Bt}from"./Progress-DltnFYaV.js";import{_ as D}from"./Label-Dr6wrjVe.js";import{_ as ke}from"./SheetFooter-CZEWGiMn.js";import{_ as He,a as Ge,b as ce}from"./TabsTrigger-Btfi-iHy.js";import{_ as me}from"./TabsContent-CkOXJfJl.js";import{r as _e}from"./routine-safety-BwhC213S.js";import{_ as Q,a as ee,b as te,c as oe,d as X}from"./SelectValue-BB1Qbg0_.js";import{C as qt,W as Wt,D as Ht,d as $e,b as De}from"./cron-utils-CFp-fpck.js";import{_ as Gt,a as Yt}from"./SelectLabel-DohCT8of.js";import{_ as Ye}from"./Switch-BLEMyNls.js";import{t as W}from"./index-DwAqpwV7.js";import{_ as Zt}from"./routine-safety-panel.vue_vue_type_script_setup_true_lang-DyUqCGVE.js";import{_ as Ne}from"./Textarea-DD2iTrYa.js";import{u as Jt}from"./useLayoutState-BmgBCaET.js";import{_ as Kt}from"./AiDraftDialog.vue_vue_type_script_setup_true_lang-Dvtl8E9-.js";import{_ as Xt}from"./StepCard.vue_vue_type_script_setup_true_lang-D9Iu--LJ.js";import"./utils-CbKt2VT1.js";import"./index-DbCWOK1g.js";import"./index-C_ruiPkq.js";import"./Primitive-Df2ZtYIB.js";import"./index-BHQBzW9e.js";import"./useForwardPropsEmits-Bs-ETVDb.js";import"./useForwardExpose-EU6gKQUl.js";import"./index-CKGhAOWA.js";import"./PopperContent-CnWgbpq2.js";import"./createContext-DotT5HnY.js";import"./useDirection-BajPvpr3.js";import"./Presence-C94u67O_.js";import"./floating-ui.vue-BDzmPUf6.js";import"./floating-ui.core-DCxx1uK7.js";import"./Teleport-DBROd62h.js";import"./VisuallyHidden-BTThHY0S.js";import"./_commonjsHelpers-DsqdWQfm.js";import"./index-C44AX5GR.js";import"./FocusScope-Cs0kAqFs.js";import"./getActiveElement-FUKBWQwh.js";import"./useFocusGuards-Zx43C-zy.js";import"./createLucideIcon-CccRPEsi.js";import"./DialogTitle-CcNjIHvO.js";import"./utils-DNyje9Vd.js";import"./x-9b06GRG8.js";import"./SidebarProvider.vue_vue_type_script_setup_true_lang-Cd_6gxzh.js";import"./Sonner-aBveEqPT.js";import"./triangle-alert-QxDeVQre.js";import"./info-gsN3FbMr.js";import"./circle-check-BIsXtuSU.js";import"./panel-preferences-Bt_XhXna.js";/* empty css              */import"./index-BRYcmm05.js";import"./DropdownMenuTrigger-DNBlKlGE.js";import"./useTypeahead-BP0g_Hrs.js";import"./RovingFocusGroup-DMg0bC4f.js";import"./Collection-Cy86eJQv.js";import"./usePrimitiveElement-Bhd42cIk.js";import"./utils-CC-pqV_U.js";import"./chevrons-up-down-BwW3959k.js";import"./DialogDescription-saL4Th7I.js";import"./chevron-right-DKVEio2w.js";import"./RovingFocusItem-ZyYPmn1p.js";import"./useNonce-B7wjIY0m.js";import"./clamp-BstbYvQo.js";import"./ohash.D__AXeF1-C-E83dC9.js";import"./useFormControl-CQzcO_1L.js";import"./useForwardScopeId-DM5mWMHG.js";import"./VisuallyHiddenInput-CmwcWgOj.js";import"./AlertDialogTitle-CWxMhkH2.js";import"./AlertDialogAction-y2py-19J.js";import"./DialogTitle-DvnScpSA.js";import"./DialogDescription-CU6zewOx.js";import"./DialogFooter-bQFHN5Xf.js";import"./index-IfTLRNcZ.js";import"./book-open-BbG7-ZlG.js";import"./lightbulb-BTHpzb77.js";import"./file-text-DDra2qku.js";import"./index-ELTtuWHW.js";const Qt={class:"flex flex-col gap-4 lg:flex-row lg:items-start lg:justify-between"},eo={class:"space-y-2"},to={class:"flex items-center gap-3"},oo={class:"text-2xl font-normal tracking-tight text-amy-fg-primary"},so={class:"flex flex-wrap items-center gap-2"},lo={key:0,class:"text-muted-foreground"},no={class:"inline-flex"},ao=J({__name:"builder-header",props:{workflow:{},mode:{},saving:{type:Boolean,default:!1},runDisabled:{type:Boolean,default:!1}},emits:["save","open-ai-draft","open-help","open-run","open-run-history","open-schedule"],setup(i){return(b,a)=>(r(),f("div",Qt,[t("div",eo,[s(e(Se),{href:b.route("assistant.admin.workflows.index"),class:"inline-flex items-center gap-1 text-xs text-muted-foreground transition-colors hover:text-foreground"},{default:n(()=>[s(e(L),{icon:e(_t),size:12},null,8,["icon"]),a[5]||(a[5]=c(" Back to workflows ",-1))]),_:1},8,["href"]),t("div",to,[t("h1",oo,v(i.mode==="create"?"New workflow":i.workflow.name||"Untitled workflow"),1),s(xt,{status:i.workflow.status},null,8,["status"])])]),t("div",so,[s(e(V),{variant:"outline",size:"sm",onClick:a[0]||(a[0]=g=>b.$emit("open-ai-draft"))},{default:n(()=>[s(e(L),{icon:e($t),size:14},null,8,["icon"]),a[6]||(a[6]=c(" Build with AI ",-1))]),_:1}),s(e(V),{variant:"ghost",size:"sm",onClick:a[1]||(a[1]=g=>b.$emit("open-help"))},{default:n(()=>[s(e(L),{icon:e(St),size:14},null,8,["icon"]),a[7]||(a[7]=c(" How it works ",-1))]),_:1}),s(e(V),{variant:"outline",disabled:i.workflow.id===null||i.runDisabled,onClick:a[2]||(a[2]=g=>b.$emit("open-run"))},{default:n(()=>[s(e(L),{icon:e(Ct),size:14},null,8,["icon"]),a[8]||(a[8]=c(" Run ",-1)),i.workflow.id!==null?(r(),f("span",lo,"("+v(i.workflow.total_runs)+")",1)):y("",!0)]),_:1},8,["disabled"]),i.workflow.id!==null?(r(),$(e(V),{key:0,variant:"outline",onClick:a[3]||(a[3]=g=>b.$emit("open-schedule"))},{default:n(()=>[s(e(L),{icon:e(ue),size:14},null,8,["icon"]),a[9]||(a[9]=c(" Schedule workflow ",-1))]),_:1})):(r(),$(e(kt),{key:1},{default:n(()=>[s(e(wt),{"as-child":""},{default:n(()=>[t("span",no,[s(e(V),{variant:"outline",disabled:""},{default:n(()=>[s(e(L),{icon:e(ue),size:14},null,8,["icon"]),a[10]||(a[10]=c(" Schedule workflow ",-1))]),_:1})])]),_:1}),s(e(ht),null,{default:n(()=>[...a[11]||(a[11]=[c(" Save this workflow before adding a schedule. ",-1)])]),_:1})]),_:1}
1)),a[12]||(a[12]=t("span",{class:"hidden h-6 w-px bg-border/70 sm:block","aria-hidden":"true"},null,-1)),s(e(V),{disabled:i.saving,onClick:a[4]||(a[4]=g=>b.$emit("save"))},{default:n(()=>[i.saving?(r(),$(e(L),{key:0,icon:e(ne),size:14,class:"animate-spin"},null,8,["icon"])):y("",!0),c(" "+v(i.saving?i.mode==="create"?"Creating":"Saving":i.mode==="create"?"Create":"Save"),1)]),_:1},8,["disabled"])])]))}}),fe=J({__name:"customer-integrations-block",props:{integrations:{},loading:{type:Boolean},visible:{type:Boolean}},setup(i){return(b,a)=>(r(),$(zt,{integrations:i.integrations,loading:i.loading,visible:i.visible,title:"Composio integrations",description:"Connected apps Amyga can use during a run.","unavailable-message":"Nothing returned. The customer may have no integrations connected, or Amyga is unreachable.","empty-message":"No connected apps for this customer yet."},null,8,["integrations","loading","visible"]))}}),ro={key:0,class:"min-w-0 truncate text-left"},uo={key:0,class:"ml-1 text-amy-fg-muted"},io={key:1,class:"text-amy-fg-muted"},co={class:"border-b p-2"},mo={class:"relative"},fo={class:"max-h-72 overflow-y-auto p-1"},po=["onClick"],vo={class:"min-w-0 flex-1"},go={class:"truncate font-medium"},yo={key:0,class:"truncate text-[11px] text-muted-foreground"},bo={key:0,class:"px-2 py-6 text-center text-xs text-muted-foreground"},Ie=J({__name:"customer-select",props:{modelValue:{},customers:{},placeholder:{default:"Pick a customer..."},selectedLabel:{},selectedSublabel:{}},emits:["update:modelValue"],setup(i,{emit:b}){const a=i,g=b,w=_(!1),o=_(""),h=_(!1),S=_([]);let M=null,P=0;const H=A(()=>{const u=new Map;for(const d of[...a.customers,...S.value])u.set(d.id,d);return Array.from(u.values())}),z=A(()=>o.value.trim()!==""?S.value:H.value),U=A(()=>H.value.find(u=>u.id===a.modelValue)??(a.modelValue!==null&&a.selectedLabel?{id:a.modelValue,label:a.selectedLabel,sublabel:a.selectedSublabel??void 0}:void 0));function j(u){const d=new Map;for(const k of[...S.value,...u])d.set(k.id,k);S.value=Array.from(d.values())}async function I(u){const d=++P;h.value=!0;try{const k=new URL(route("assistant.admin.workflows.customer-search"),window.location.origin);k.searchParams.set("q",u);const T=await fetch(k.toString(),{headers:{Accept:"application/json","X-Requested-With":"XMLHttpRequest"}});if(!T.ok)throw new Error(`Customer search failed with ${T.status}`);const N=await T.json();d===P&&(S.value=N.customers??[])}finally{d===P&&(h.value=!1)}}function C(){M!==null&&window.clearTimeout(M),M=window.setTimeout(()=>{I(o.value.trim())},250)}function x(u){j([u]),g("update:modelValue",u.id),w.value=!1,o.value=""}return Z(w,u=>{u&&I(o.value.trim())}),Z(o,()=>{w.value&&C()}),(u,d)=>(r(),$(e(We),{open:w.value,"onUpdate:open":d[1]||(d[1]=k=>w.value=k)},{default:n(()=>[s(e(he),{"as-child":""},{default:n(()=>[s(e(V),{type:"button",variant:"outline",class:"w-full justify-between gap-2 bg-amy-bg-card-solid font-normal"},{default:n(()=>[U.value?(r(),f("span",ro,[c(v(U.value.label)+" ",1),U.value.sublabel?(r(),f("span",uo," ("+v(U.value.sublabel)+") ",1)):y("",!0)])):(r(),f("span",io,v(i.placeholder),1)),s(e(Tt),{class:"size-4 shrink-0 text-amy-fg-muted"})]),_:1})]),_:1}),s(e(qe),{align:"start",class:"p-0"},{default:n(()=>[t("div",co,[t("div",mo,[s(e(Ot),{class:"pointer-events-none absolute left-2.5 top-1/2 size-4 -translate-y-1/2 text-amy-fg-muted"}),s(e(ie),{modelValue:o.value,"onUpdate:modelValue":d[0]||(d[0]=k=>o.value=k),class:"pl-8 pr-8",placeholder:"Search customers..."},null,8,["modelValue"]),h.value?(r(),$(e(Lt),{key:0,class:"absolute right-2.5 top-1/2 size-4 -translate-y-1/2 animate-spin text-amy-fg-muted"})):y("",!0)])]),t("div",fo,[(r(!0),f(O,null,B(z.value,k=>(r(),f("button",{key:k.id,type:"button",class:"flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-left text-sm transition-colors hover:bg-accent hover:text-accent-foreground",onClick:T=>x(k)},[t("div",vo,[t("div",go,v(k.label),1),k.sublabel?(r(),f("div",yo,v(k.sublabel),1)):y("",!0)]),k.id===i.modelValue?(r(),$(e(Pt),{key:0,class:"size-4 shrink-0"})):y("",!0)],8,po))),128)),z.value.length===0&&!h.value?(r(),f("div",bo," No customers found. ")):y("",!0)])]),_:1})]),_:1},8,["open"]))}}),xo={class:"mt-4 flex gap-1 border-b border-amy-border-default px-4"},wo={key:0,class:"space-y-5 px-4 py-6"},ho={key:1,class:"space-y-5 px-4 py-6"},ko=J({__name:"help-drawer",props:{open:{type:Boolean}},emits:["update:open"],setup(i,{emit:b}){const a=b,g=_("whats-a-step");return(w,o)=>(r(),$(e(Ve),{open:i.open,"onUpdate:open":o[2]||(o[2]=h=>a("update:open",h))},{default:n(()=>[s(e(Ce),{side:"right",class:"w-full overflow-y-auto sm:max-w-xl"},{default:n(()=>[s(e(Ae),null,{default:n(()=>[s(e(Ee),null,{default:n(()=>[...o[3]||(o[3]=[c("How workflows work",-1)])]),_:1}),s(e(Me),null,{default:n(()=>[...o[4]||(o[4]=[c(" A short, plain-English tour. Pick a section. ",-1)])]),_:1})]),_:1}),t("div",xo,[t("button",{type:"button",class:Y(["border-b-2 px-3 py-2 text-xs font-medium transition-colors",g.value==="whats-a-step"?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground"]),onClick:o[0]||(o[0]=h=>g.value="whats-a-step")}," 1. The basics ",2),t("button",{type:"button",class:Y(["border-b-2 px-3 py-2 text-xs font-medium transition-colors",g.value==="example"?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground"]),onClick:o[1]||(o[1]=h=>g.value="example")}
1," 2. Example ",2)]),g.value==="whats-a-step"?(r(),f("div",wo,[...o[5]||(o[5]=[t("p",{class:"text-sm leading-relaxed text-foreground"},[c(" A "),t("strong",null,"workflow"),c(" is a list of "),t("strong",null,"steps"),c(". Each step is one instruction to the AI. The AI runs them in order, and at every step it already knows everything that happened before. ")],-1),t("div",{class:"rounded-lg border border-amy-border-default bg-amy-bg-card p-5"},[t("div",{class:"space-y-3"},[t("div",{class:"convo-bubble flex items-start gap-2"},[t("div",{class:"convo-tag step"},"1"),t("div",{class:"flex-1 rounded-md border border-amy-border-default bg-amy-bg-card-solid p-2.5"},[t("div",{class:"text-[10px] font-semibold uppercase tracking-wide text-muted-foreground"}," You write "),t("div",{class:"mt-1 font-mono text-[11px] text-foreground"},` "Fetch the customer's CRM record." `)])]),t("div",{class:"convo-bubble flex items-start gap-2"},[t("div",{class:"convo-tag ai"},"AI"),t("div",{class:"flex-1 rounded-md border border-amy-success/30 bg-amy-success-muted p-2.5"},[t("div",{class:"text-[10px] font-semibold uppercase tracking-wide text-amy-success"}," AI replies "),t("div",{class:"mt-1 font-mono text-[11px] text-foreground"},' "Acme Inc, Series B SaaS, …" ')])]),t("div",{class:"convo-bubble flex items-start gap-2"},[t("div",{class:"convo-tag step"},"2"),t("div",{class:"flex-1 rounded-md border border-amy-border-default bg-amy-bg-card-solid p-2.5"},[t("div",{class:"text-[10px] font-semibold uppercase tracking-wide text-muted-foreground"}," You write "),t("div",{class:"mt-1 font-mono text-[11px] text-foreground"},' "Now summarise their recent emails." ')])]),t("div",{class:"convo-bubble flex items-start gap-2"},[t("div",{class:"convo-tag ai"},"AI"),t("div",{class:"flex-1 rounded-md border border-amy-success/30 bg-amy-success-muted p-2.5"},[t("div",{class:"text-[10px] font-semibold uppercase tracking-wide text-amy-success"}," AI replies "),t("div",{class:"mt-1 font-mono text-[11px] text-foreground"},' "Three open threads: pricing, demo, intro to CFO." ')])])]),t("p",{class:"mt-3 text-center text-[10px] text-muted-foreground"}," It's one conversation. The AI carries everything forward as it goes. ")],-1),t("div",{class:"space-y-2 text-xs text-muted-foreground"},[t("p",null,[t("strong",{class:"text-foreground"},"By default the AI sees every earlier step's output."),c(" Just write what to do next, in plain English. ")]),t("p",null,[t("strong",{class:"text-foreground"},"Need to reference one specific step?"),c(" Each step has a reference key (default "),t("code",{class:"rounded bg-amy-chip px-1 font-mono"},"step_1"),c(", "),t("code",{class:"rounded bg-amy-chip px-1 font-mono"},"step_2"),c(", … (rename it in the step settings). Type "),t("code",{class:"rounded bg-amy-chip px-1 font-mono"},"{{"),c(" in any prompt and an autocomplete shows the keys you can use. ")]),t("p",null,[t("strong",{class:"text-foreground"},"Tools come along for the ride."),c(" If the customer has Gmail, Drive, Attio etc. connected, the AI can call them as part of any step. You don't have to wire that up. ")]),t("p",null,[t("strong",{class:"text-foreground"},"Why multiple steps?"),c(' Clearer visibility ("Step 2 of 3 done…") and the ability to re-run from a failed step instead of redoing the whole thing. ')])],-1)])])):y("",!0),g.value==="example"?(r(),f("div",ho,[...o[6]||(o[6]=[t("h3",{class:"text-sm font-medium text-foreground"},"Meeting Prepper (3 steps)",-1),t("p",{class:"text-xs text-muted-foreground"}," Each step is one instruction. The AI runs them in order, carrying context forward. ",-1),t("ol",{class:"space-y-3"},[t("li",{class:"example-step rounded-md border border-amy-border-default bg-amy-bg-card p-3"},[t("div",{class:"text-[10px] uppercase tracking-wide text-muted-foreground"}," Step 1 "),t("p",{class:"mt-1 text-xs text-foreground"},[t("strong",null,"Prompt:"),c(` "Fetch the CRM record for the customer we're running this for. Tell me the company name, stage, and last interaction." `)]),t("p",{class:"mt-1 text-[11px] text-muted-foreground"}," The AI calls Attio, reads the record, returns a short summary. ")]),t("li",{class:"example-step rounded-md border border-amy-border-default bg-amy-bg-card p-3"},[t("div",{class:"text-[10px] uppercase tracking-wide text-muted-foreground"}," Step 2 "),t("p",{class:"mt-1 text-xs text-foreground"},[t("strong",null,"Prompt:"),c(` "Search the user's Gmail for emails to and from this company. Summarise the open threads." `)]),t("p",{class:"mt-1 text-[11px] text-muted-foreground"}," The AI already knows who the company is from step 1. It doesn't need to be told again. It searches, reads, summarises. ")]),t("li",{class:"example-step rounded-md border border-amy-border-default bg-amy-bg-card p-3"},[t("div",{class:"text-[10px] uppercase tracking-wide text-muted-foreground"}," Step 3 "),t("p",{class:"mt-1 text-xs text-foreground"},[t("strong",null,"Prompt:"),c(' "Write a meeting prepper using everything above. Then email it to the user via Gmail." ')]),t("p",{class:"mt-1 text-[11px] text-muted-foreground"}," The AI has the company info, the email threads, and the user's address, all from earlier in the conversation. It writes the prepper and sends it. ")])],-1),t("div",{class:"rounded-md border border-amy-border-strong bg-amy-bg-card p-3"},[t("p",{class:"text-xs text-foreground"},[t("strong",null,"One workflow, three small instructions."),c(" Each step builds on the last. No wiring, no variables, no special syntax. ")])],-1)])])):y("",!0)]),_:1})]),_:1},8,["open"]))}}),_o=Ft(ko,[["__scopeId","data-v-86bb8028"]]),$o={class:"space-y-3"},So={key:0,class:"rounded-lg border border-dashed border-amy-border-strong bg-amy-bg-card px-4 py-10 text-center"},Co={key:1,class:"divide-y divide-amy-border-default rounded-lg border border-amy-border-default bg-amy-bg-card"},Ao={class:"flex items-start justify-between gap-4"},Eo={class:"min-w-0 flex-1"},Vo={class:"flex items-center gap-2"},Mo={class:"truncate text-sm font-medium text-foreground"},Uo={class:"text-[10px] uppercase tracking-wide text-muted-foreground"},Io={class:"mt-0.5 flex flex-wrap items-center gap-x-2.5 gap-y-0.5 text-[11px] text-muted-foreground"},Ro={key:0},zo={class:"flex shrink-0 items-center justify-end gap-1.5"},To={class:"flex items-center gap-1"},Oo=["href"],Lo=["href"],Ze=J({__name:"recent-runs",props:{runs:{},workflowId:{}},setup(i){return(b,a)=>(r(),f("div",$o,[i.runs.length===0?(r(),f("div",So,[...a[2]||(a[2]=[t("div",{class:"text-sm font-medium text-foreground"},"No runs yet",-1),t("p",{class:"mx-auto mt-1 max-w-xs text-xs text-muted-foreground"},[c(" Trigger a run from the "),t("strong",null,"Run now"),c(" tab. Past runs will show up here. ")],-1)])])):(r(),f("div",Co,[(r(!0),f(O,null,B(i.runs,g=>(r(),$(e(Se),{key:g.id,href:i.workflowId!==null?b.route("assistant.admin.workflows.runs.show",{workflow:i.workflowId,run:g.id}):"#",class:"block px-4 py-3 transition-colors hover:bg-amy-chip"},{default:n(()=>[t("div",Ao,[t("div",Eo,[t("div",Vo,[t("span",Mo,v(g.customer_label??"Unknown customer"),1),t("span",Uo,v(g.mode),1)]),t("div",Io,[t("span",null,v(e(Dt)(g.started_at)),1),g.duration_seconds!==null?(r(),f("span",Ro,"· "+v(e(Nt)(g.duration_seconds)),1)):y("",!0),t("span",null,"· "+v(g.triggered_by),1),t("span",null,"· "+v(g.completed_step_count)+"/"+v(g.step_count)+" steps",1)])]),t("div",zo,[t("div",To,[g.langfuse_trace_url?(r(),f("a",{key:0,href:g.langfuse_trace_url,target:"_blank",rel:"noopener noreferrer",class:"inline-flex h-6 w-6 items-center justify-center rounded-md border border-amy-border-default bg-amy-bg-card-solid transition-colors hover:bg-amy-chip","aria-label":"Open Langfuse trace",onClick:a[0]||(a[0]=Fe(()=>{},["stop"]))},[...a[3]||(a[3]=[t("img",{src:"https://langfuse.com/brand-assets/icon/color/langfuse-icon.svg",alt:"",class:"h-3.5 w-3.5"},null,-1)])],8,Oo)):y("",!0),g.trigger_run_url?(r(),f("a",{key:1,href:g.trigger_run_url,target:"_blank",rel:"noopener noreferrer",class:"inline-flex h-6 w-6 items-center justify-center rounded-md border border-amy-border-default bg-amy-bg-card-solid transition-colors hover:bg-amy-chip","aria-label":"Open Trigger.dev run",onClick:a[1]||(a[1]=Fe(()=>{},["stop"]))},[...a[4]||(a[4]=[t("img",{src:"https://trigger.dev/assets/triggerdev-logo--dark.svg",alt:"",class:"h-3.5 w-3.5"},null,-1)])],8,Lo)):y("",!0)]),a[5]||(a[5]=t("span",{class:"h-4 w-px bg-border/70","aria-hidden":"true"},null,-1)),s(Ue,{status:g.status},null,8,["status"])])]),g.status==="running"||g.status==="queued"?(r(),$(e(Bt),{key:0,"model-value":g.step_count>0?Math.round(g.completed_step_count/g.step_count*100):0,class:"mt-2.5 h-0.5"},null,8,["model-value"])):y("",!0)]),_:2},1032,["href"]))),128))]))]))}});function pe(){const i=_([]),b=_(!1);let a=0;async function g(o){const h=++a;if(o===null){i.value=[],b.value=!1;return}b.value=!0;try{const S=new URLSearchParams({scope_type:"account",scope_id:o}),M=await fetch(`${route("assistant.admin.workflows.customer-integrations")}?${S.toString()}`,{headers:{Accept:"application/json","X-Requested-With":"XMLHttpRequest"},credentials:"same-origin"});if(!M.ok)throw new Error(`Customer integrations fetch failed (${M.status})`);const P=await M.json();h===a&&(i.value=P.integrations??[])}catch(S){h===a&&(i.value=[]),console.warn("[useCustomerIntegrations] fetch failed",S)}finally{h===a&&(b.value=!1)}}function w(){a+=1,i.value=[],b.value=!1}return{integrations:i,loading:b,fetchFor:g,reset:w}}const Po={key:0,class:"ml-1.5 text-[10px] text-muted-foreground"},jo={key:0,class:"space-y-1.5"},Fo={key:1,class:"rounded-md border border-amy-border-default bg-amy-bg-card px-3 py-2 text-xs"},Do={class:"mt-0.5 font-medium text-foreground"},No={key:0,class:"mt-0.5 text-[11px] text-muted-foreground"},Bo={key:2,class:"text-xs leading-5 text-amy-fg-secondary"},qo={class:"flex w-full gap-2"},Wo=J({__name:"run-sheet",props:{open:{type:Boolean},tab:{},workflow:{},customers:{},recentRuns:{}},emits:["update:open","update:tab"],setup(i,{emit:b}){const a=i,g=b,w=A(()=>a.workflow.scope==="unscoped"),o=_(null),h=_(!1),{integrations:S,loading:M,fetchFor:P,reset:H}=pe();Z(()=>a.open,u=>{u&&(o.value=a.workflow.scope==="account"?a.workflow.scope_id:null)},{immediate:!0});const z=A(()=>{const u=w.value?o.value:a.workflow.scope_id;return u===null?null:a.customers.find(d=>d.id===u)??null}),U=A(()=>w.value?o.value:a.workflow.scope_id),j=A(()=>h.value||a.workflow.id===null||w.value&&o.value===null?!1:!_e(a.workflow.safety));function I(){g("update:open",!1)}function C(u){g("update:tab",u)}function x(){!j.value||a.workflow.id===null||G.post(route("assistant.admin.workflows.runs.trigger",a.workflow.id),{customer_id:w.value?o.value:a.workflow.scope_id,mode:"live"},{preserveScroll:!0,onStart:()=>{h.value=!0},onFinish:()=>{h.value=!1}})}return Z(()=>[a.open,U.value],([u,d])=>{if(!u){H();return}P(d)},{immediate:!0}),(u,d)=>(r(),$(e(Ve),{open:i.open,"onUpdate:open":d[2]||(d[2]=k=>g("update:open",k))},{default:n(()=>[s(e(Ce),{side:"right",class:"flex w-full flex-col sm:max-w-2xl"},{default:n(()=>[s(e(Ae),null,{default:n(()=>[s(e(Ee),null,{default:n(()=>[...d[3]||(d[3]=[c("Run workflow",-1)])]),_:1}),s(e(Me),null,{default:n(()=>[d[4]||(d[4]=c(" Triggers ",-1)),t("strong",null,v(i.workflow.name||"this workflow"),1),d[5]||(d[5]=c(" once for the chosen customer. ",-1))]),_:1})]),_:1}),s(e(He),{"model-value":i.tab,class:"flex flex-1 flex-col overflow-hidden px-4 pt-4","onUpdate:modelValue":d[1]||(d[1]=k=>C(String(k??"")))},{default:n(()=>[s(e(Ge),{class:"grid w-full grid-cols-2"},{default:n(()=>[s(e(ce),{value:"now"},{default:n(()=>[...d[6]||(d[6]=[c("Run now",-1)])]),_:1}),s(e(ce),{value:"history"},{default:n(()=>[d[7]||(d[7]=c(" Recent runs ",-1)),i.recentRuns.length>
10?(r(),f("span",Po,v(i.workflow.total_runs),1)):y("",!0)]),_:1})]),_:1}),s(e(me),{value:"now",class:"flex-1 space-y-5 overflow-y-auto py-5"},{default:n(()=>[w.value?(r(),f("div",jo,[s(e(D),null,{default:n(()=>[...d[8]||(d[8]=[c("Customer",-1)])]),_:1}),s(Ie,{modelValue:o.value,"onUpdate:modelValue":d[0]||(d[0]=k=>o.value=k),customers:i.customers},null,8,["modelValue","customers"])])):z.value?(r(),f("div",Fo,[d[9]||(d[9]=t("div",{class:"text-muted-foreground"},"Will run for",-1)),t("div",Do,v(z.value.label),1),z.value.sublabel?(r(),f("div",No,v(z.value.sublabel),1)):y("",!0)])):y("",!0),s(fe,{integrations:e(S),loading:e(M),visible:U.value!==null},null,8,["integrations","loading","visible"]),e(_e)(i.workflow.safety)?(r(),f("p",Bo," Resolve the workflow safety check before running this version. ")):y("",!0)]),_:1}),s(e(me),{value:"history",class:"flex-1 overflow-y-auto py-5"},{default:n(()=>[s(Ze,{runs:i.recentRuns,"workflow-id":i.workflow.id},null,8,["runs","workflow-id"])]),_:1})]),_:1},8,["model-value"]),s(e(ke),null,{default:n(()=>[t("div",qo,[s(e(V),{class:"flex-1",variant:"outline",onClick:I},{default:n(()=>[c(v(i.tab==="now"?"Cancel":"Close"),1)]),_:1}),i.tab==="history"&&i.workflow.id!==null?(r(),$(e(Se),{key:0,href:u.route("assistant.admin.workflows.runs.index",i.workflow.id),class:"flex-1"},{default:n(()=>[s(e(V),{variant:"outline",class:"w-full"},{default:n(()=>[d[10]||(d[10]=c(" Full history ",-1)),s(e(L),{icon:e(At),size:12},null,8,["icon"])]),_:1})]),_:1},8,["href"])):y("",!0),i.tab==="now"?(r(),$(e(V),{key:1,class:"flex-1",disabled:!j.value,onClick:x},{default:n(()=>[h.value?(r(),$(e(L),{key:0,icon:e(ne),size:14,class:"animate-spin"},null,8,["icon"])):y("",!0),c(" "+v(h.value?"Running":"Run"),1)]),_:1},8,["disabled"])):y("",!0)])]),_:1})]),_:1})]),_:1},8,["open"]))}}),Ho={class:"space-y-1.5"},Go={key:0,class:"flex min-h-9 items-center justify-between gap-3"},Yo={class:"text-sm text-amy-fg-primary"},Zo={key:1,class:"flex gap-2"},Jo={class:"grid sm:grid-cols-[220px_1fr]"},Ko={class:"border-b border-amy-border-default bg-amy-bg-card p-3 sm:border-b-0 sm:border-r"},Xo={class:"space-y-3"},Qo={class:"mb-1 px-2 text-[11px] font-medium text-muted-foreground"},es={class:"space-y-0.5"},ts=["onClick"],os={class:"space-y-4 p-4"},ss={class:"space-y-1.5"},ls={key:0,class:"space-y-1.5"},ns={key:1,class:"space-y-1.5"},as={key:2,class:"grid grid-cols-2 gap-2"},rs={class:"space-y-1.5"},us={class:"space-y-1.5"},is={key:3,class:"space-y-1.5"},ds={class:"flex flex-wrap gap-1"},cs=["onClick"],ms={key:4,class:"space-y-1.5"},fs={class:"rounded-md border border-amy-border-default bg-amy-bg-card px-3 py-2"},ps={key:0,class:"flex items-center justify-between text-xs"},vs={class:"font-mono text-foreground"},gs={key:2,class:"text-xs text-foreground"},ys={class:"flex justify-end gap-2"},bs={key:2,class:"text-[11px] text-muted-foreground"},xs={key:3,class:"text-[11px] text-amy-warning"},Je=J({__name:"cron-input",props:{modelValue:{},presentation:{default:"input"}},emits:["update:modelValue"],setup(i,{emit:b}){const a=i,g=b,w=_(!1),o=Ut({...Ht}),h=A(()=>$e(a.modelValue)),S=A(()=>{const x=h.value;return x===null?"Runs on a custom schedule.":`Runs ${x.charAt(0).toLowerCase()}${x.slice(1)}.`}),M=Array.from({length:24},(x,u)=>u),P=[0,5,10,15,20,25,30,35,40,45,50,55],H=[{value:"daily",label:"Every day"},{value:"weekdays",label:"Every weekday (Mon–Fri)"},{value:"weekly",label:"Once a week"},{value:"monthly",label:"Once a month"},{value:"hourly",label:"Every hour"},{value:"every_minutes",label:"Every X minutes"}];function z(x){g("update:modelValue",x),w.value=!1}function U(){g("update:modelValue",De(o)),w.value=!1}const j=A(()=>De(o)),I=A(()=>$e(j.value));Z(w,x=>{x&&C(a.modelValue)});function C(x){if(x===null)return;const u=x.trim().split(/\s+/);if(u.length!==5)return;const[d,k,T,,N]=u,le=/^\d+$/.test(d)?Number(d):o.minute,ae=/^\d+$/.test(k)?Number(k):o.hour;if(o.minute=le,o.hour=ae,d==="*"&&(k==="*"||k==="?")&&(T==="*"||T==="?")&&(N==="*"||N==="?")){o.frequency="every_minutes",o.everyMinutes=1;return}if(/^\*\/\d+$/.test(d)){o.frequency="every_minutes",o.everyMinutes=Number(d.split("/")[1]);return}if((T==="*"||T==="?")&&(N==="*"||N==="?")){o.frequency="daily";return}if((T==="*"||T==="?")&&N==="1-5"){o.frequency="weekdays";return}if((T==="*"||T==="?")&&/^\d+$/.test(N)){o.frequency="weekly",o.weekday=Number(N);return}/^\d+$/.test(T)&&(N==="*"||N==="?")&&(o.frequency="monthly",o.dayOfMonth=Number(T))}return(x,u)=>(r(),f("div",Ho,[i.presentation==="summary"?(r(),$(e(D),{key:0,class:"text-xs"},{default:n(()=>[...u[9]||(u[9]=[c(" Frequency ",-1)])]),_:1})):(r(),$(e(D),{key:1,class:"flex items-center gap-1.5"},{default:n(()=>[s(e(L),{icon:e(Et),size:12},null,8,["icon"]),u[10]||(u[10]=c(" Cron expression ",-1))]),_:1})),s(e(We),{open:w.value,"onUpdate:open":u[8]||(u[8]=d=>w.value=d)},{default:n(()=>[i.presentation==="summary"?(r(),f("div",Go,[t("p",Yo,v(S.value),1),s(e(he),{"as-child":""},{default:n(()=>[s(e(V),{variant:"outline",size:"sm",type:"button"},{default:n(()=>[s(e(L),{icon:e(ue),size:14},null,8,["icon"]),u[11]||(u[11]=c(" Edit ",-1))]),_:1})]),_:1})])):(r(),f("div",Zo,[s(e(ie),{"model-value":i.modelValue??"",placeholder:"0 9 * * 1-5",class:"font-mono text-[13px]","onUpdate:modelValue":u[0]||(u[0]=d=>g("update:modelValue",String(d??"")))},null,8,["model-value"]),s(e(he),{"as-child":""},{default:n(()=>[s(e(V),{variant:"outline",size:"default",type:"button"},{default:n(()=>[s(e(L),{icon:e(ue),size:14},null,8,["icon"]),u[12]||(u[12]=c(" Build ",-1))]),_:1})]),_:1})])),s(e(qe),{class:"max-h-[calc(100vh-2rem)] w-[calc(100vw-2rem)] max-w-[640px] overflow-y-auto p-0",align:"end"},{default:n(()=>[t("div",Jo,[t("div",Ko,[u[13]||(u[13]=t("h4",{class:"mb-2 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground"}," Common schedules ",-1)),t("div",Xo,[(r(!0),f(O,null,B(e(qt),d=>(r(),f("div",{key:d.label},[t("p",Qo,v(d.label),1),t("div",es,[(r(!0),f(O,null,B(d.presets,k=>(r(),f("button",{key:k.expression,type:"button",class:Y(["group flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-left text-xs font-medium text-foreground transition-colors hover:bg-amy-chip-hover",{"bg-amy-chip text-foreground":i.modelValue===k.expression}]),onClick:T=>z(k.expression)},[i.modelValue===k.expression?(r(),$(e(L),{key:0,icon:e(Vt),size:11,class:"shrink-0 text-amy-accent-strong"},null,8,["icon"])):y("",!0),t("span",null,v(k.label),1)],10,ts))),128))])]))),128))])]),t("div",os,[u[25]||(u[25]=t("div",null,[t("h4",{class:"text-[10px] font-semibold uppercase tracking-wide text-muted-foreground"}," Build your own "),t("p",{class:"mt-1 text-xs text-muted-foreground"}," Pick a frequency, then a time. ")],-1)),t("div",ss,[s(e(D),{class:"text-xs"},{default:n(()=>[...u[14]||(u[14]=[c("Frequency",-1)])]),_:1}),s(e(Q),{"model-value":o.frequency,"onUpdate:modelValue":u[1]||(u[1]=d=>o.frequency=String(d??""))},{default:n(()=>[s(e(ee),null,{default:n(()=>[s(e(te))]),_:1}),s(e(oe),null,{default:n(()=>[(r(),f(O,null,B(H,d=>s(e(X),{key:d.value,value:d.value},{default:n(()=>[c(v(d.label),1)]),_:2},1032,["value"])),64))]),_:1})]),_:1},8,["model-value"])]),o.frequency==="every_minutes"?(r(),f("div",ls,[s(e(D),{class:"text-xs"},{default:n(()=>[...u[15]||(u[15]=[c("Every N minutes",-1)])]),_:1}),s(e(Q),{"model-value":String(o.everyMinutes),"onUpdate:modelValue":u[2]||(u[2]=d=>o.everyMinutes=Number(d??0))},{default:n(()=>[s(e(ee),null,{default:n(()=>[s(e(te))]),_:1}),s(e(oe),null,{default:n(()=>[(r(),f(O,null,B([1,5,10,15,20,30],d=>s(e(X),{key:d,value:String(d)},{default:n(()=>[c(" Every "+v(d)+" minute"+v(d===1?"":"s"),1)]),_:2},1032,["value"])),64))]),_:1})]),_:1},8,["model-value"])])):o.frequency==="hourly"?(r(),f("div",ns,[s(e(D),{class:"text-xs"},{default:n(()=>[...u[16]||(u[16]=[c("Minutes past the hour",-1)])]),_:1}),s(e(Q),{"model-value":String(o.minute),"onUpdate:modelValue":u[3]||(u[3]=d=>o.minute=Number(d??0))},{default:n(()=>[s(e(ee),null,{default:n(()=>[s(e(te))]),_:1}),s(e(oe),null,{default:n(()=>[(r(),f(O,null,B(P,d=>s(e(X),{key:d,value:String(d)},{default:n(()=>[c(" :"+v(String(d).padStart(2,"0")),1)]),_:2},1032,["value"])),64))]),_:1})]),_:1},8,["model-value"])])):(r(),f("div",as,[t("div",rs,[s(e(D),{class:"text-xs"},{default:n(()=>[...u[17]||(u[17]=[c("Hour",-1)])]),_:1}),s(e(Q),{"model-value":String(o.hour),"onUpdate:modelValue":u[4]||(u[4]=d=>o.hour=Number(d??0))},{default:n(()=>[s(e(ee),null,{default:n(()=>[s(e(te))]),_:1}),s(e(oe),{class:"max-h-64"},{default:n(()=>[(r(!0),f(O,null,B(e(M),d=>(r(),$(e(X),{key:d,value:String(d)},{default:n(()=>[c(v(String(d).padStart(2,"0"))+":00 ",1)]),_:2},1032,["value"]))),128))]),_:1})]),_:1},8,["model-value"])]),t("div",us,[s(e(D),{class:"text-xs"},{default:n(()=>[...u[18]||(u[18]=[c("Minute",-1)])]),_:1}),s(e(Q),{"model-value":String(o.minute),"onUpdate:modelValue":u[5]||(u[5]=d=>o.minute=Number(d??0))},{default:n(()=>[s(e(ee),null,{default:n(()=>[s(e(te))]),_:1}),s(e(oe),null,{default:n(()=>[(r(),f(O,null,B(P,d=>s(e(X),{key:d,value:String(d)},{default:n(()=>[c(" :"+v(String(d).padStart(2,"0")),1)]),_:2},1032,["value"])),64))]),_:1})]),_:1},8,["model-value"])])])),o.frequency==="weekly"?(r(),f("div",is,[s(e(D),{class:"text-xs"},{default:n(()=>[...u[19]||(u[19]=[c("Day of week",-1)])]),_:1}),t("div",ds,[(r(!0),f(O,null,B(e(Wt),d=>(r(),f("button",{key:d.value,type:"button",class:Y(["rounded-md border px-2.5 py-1 text-xs transition-colors",o.weekday===d.value?"border-amy-border-strong bg-amy-chip text-foreground":"border-amy-border-default bg-amy-bg-card text-muted-foreground hover:bg-amy-chip-hover"]),onClick:k=>o.weekday=d.value},v(d.short),11,cs))),128))])])):y("",!0),o.frequency==="monthly"?(r(),f("div",ms,[s(e(D),{class:"text-xs"},{default:n(()=>[...u[20]||(u[20]=[c("Day of month",-1)])]),_:1}),s(e(Q),{"model-value":String(o.dayOfMonth),"onUpdate:modelValue":u[6]||(u[6]=d=>o.dayOfMonth=Number(d??0))},{default:n(()=>[s(e(ee),null,{default:n(()=>[s(e(te))]),_:1}),s(e(oe),{class:"max-h-64"},{default:n(()=>[(r(),f(O,null,B(28,d=>s(e(X),{key:d,value:String(d)},{default:n(()=>[c(" Day "+v(d),1)]),_:2},1032,["value"])),64))]),_:1})]),_:1},8,["model-value"]),u[21]||(u[21]=t("p",{class:"text-[10px] text-muted-foreground"}," Limited to 1–28 so it works every month. ",-1))])):y("",!0),t("div",fs,[i.presentation==="input"?
1(r(),f("div",ps,[u[22]||(u[22]=t("span",{class:"text-muted-foreground"},"Will run",-1)),t("code",vs,v(j.value),1)])):y("",!0),I.value?(r(),f("div",{key:1,class:Y(["text-xs text-foreground",i.presentation==="input"?"mt-1":void 0])},v(I.value),3)):i.presentation==="summary"?(r(),f("div",gs," Custom schedule ")):y("",!0)]),t("div",ys,[s(e(V),{variant:"outline",size:"sm",onClick:u[7]||(u[7]=d=>w.value=!1)},{default:n(()=>[...u[23]||(u[23]=[c(" Cancel ",-1)])]),_:1}),s(e(V),{size:"sm",onClick:U},{default:n(()=>[...u[24]||(u[24]=[c(" Apply ",-1)])]),_:1})])])])]),_:1})]),_:1},8,["open"]),i.presentation==="input"&&h.value?(r(),f("p",bs,[u[26]||(u[26]=t("span",{class:"font-medium text-foreground"},"Runs",-1)),c(" "+v(h.value.toLowerCase())+". ",1)])):i.presentation==="input"&&i.modelValue?(r(),f("p",xs," Custom expression. Make sure it's valid. ")):y("",!0)]))}}),ws=[{value:"UTC",label:"UTC",region:"UTC"},{value:"Europe/London",label:"London (GMT/BST)",region:"Europe"},{value:"Europe/Dublin",label:"Dublin",region:"Europe"},{value:"Europe/Lisbon",label:"Lisbon",region:"Europe"},{value:"Europe/Madrid",label:"Madrid",region:"Europe"},{value:"Europe/Paris",label:"Paris",region:"Europe"},{value:"Europe/Berlin",label:"Berlin",region:"Europe"},{value:"Europe/Amsterdam",label:"Amsterdam",region:"Europe"},{value:"Europe/Zurich",label:"Zurich",region:"Europe"},{value:"Europe/Stockholm",label:"Stockholm",region:"Europe"},{value:"Europe/Athens",label:"Athens",region:"Europe"},{value:"America/New_York",label:"New York (Eastern)",region:"Americas"},{value:"America/Chicago",label:"Chicago (Central)",region:"Americas"},{value:"America/Denver",label:"Denver (Mountain)",region:"Americas"},{value:"America/Los_Angeles",label:"Los Angeles (Pacific)",region:"Americas"},{value:"America/Toronto",label:"Toronto",region:"Americas"},{value:"America/Sao_Paulo",label:"São Paulo",region:"Americas"},{value:"Asia/Dubai",label:"Dubai",region:"Asia"},{value:"Asia/Singapore",label:"Singapore",region:"Asia"},{value:"Asia/Hong_Kong",label:"Hong Kong",region:"Asia"},{value:"Asia/Tokyo",label:"Tokyo",region:"Asia"},{value:"Asia/Kolkata",label:"Mumbai / Kolkata",region:"Asia"},{value:"Australia/Sydney",label:"Sydney",region:"Oceania"},{value:"Pacific/Auckland",label:"Auckland",region:"Oceania"}],hs=[{region:"UTC",label:"UTC"},{region:"Europe",label:"Europe"},{region:"Americas",label:"Americas"},{region:"Asia",label:"Asia"},{region:"Oceania",label:"Oceania"}],Ke=J({__name:"timezone-select",props:{modelValue:{}},emits:["update:modelValue"],setup(i,{emit:b}){const a=b,g=A(()=>hs.map(w=>({...w,zones:ws.filter(o=>o.region===w.region)})));return(w,o)=>(r(),$(e(Q),{"model-value":i.modelValue,"onUpdate:modelValue":o[0]||(o[0]=h=>a("update:modelValue",String(h??"")))},{default:n(()=>[s(e(ee),null,{default:n(()=>[s(e(te))]),_:1}),s(e(oe),{class:"max-h-72"},{default:n(()=>[(r(!0),f(O,null,B(g.value,h=>(r(),$(e(Gt),{key:h.region},{default:n(()=>[s(e(Yt),null,{default:n(()=>[c(v(h.label),1)]),_:2},1024),(r(!0),f(O,null,B(h.zones,S=>(r(),$(e(X),{key:S.value,value:S.value},{default:n(()=>[c(v(S.label),1)]),_:2},1032,["value"]))),128))]),_:2},1024))),128))]),_:1})]),_:1},8,["model-value"]))}}),ks={class:"space-y-5 px-1 py-4"},_s={class:"flex items-start justify-between gap-4 rounded-lg border border-amy-border-strong bg-amy-bg-card px-4 py-3.5"},$s={class:"space-y-4 rounded-lg border border-amy-border-strong bg-amy-bg-card p-4"},Ss={class:"space-y-1.5"},Cs={key:0,class:"grid grid-cols-2 gap-4 px-1 text-xs"},As={class:"space-y-1"},Es={class:"flex items-center gap-1.5"},Vs={class:"text-[11px] text-muted-foreground"},Ms={class:"space-y-1"},Us={class:"text-foreground"},Is={key:1,class:"rounded-lg border border-dashed border-amy-border-strong bg-amy-bg-card px-4 py-6 text-center text-xs text-muted-foreground"},Rs=J({__name:"account-schedule-form",props:{schedule:{},cron:{},timezone:{},enabled:{type:Boolean}},emits:["update:cron","update:timezone","update:enabled"],setup(i){return(b,a)=>(r(),f("div",ks,[t("div",_s,[a[3]||(a[3]=t("div",{class:"space-y-0.5"},[t("div",{class:"text-sm font-medium text-foreground"},"Enable recurring runs"),t("div",{class:"text-xs text-muted-foreground"},[c(" Off: workflow only runs when manually triggered via "),t("strong",null,"Run"),c(". ")])],-1)),s(e(Ye),{"model-value":i.enabled,"onUpdate:modelValue":a[0]||(a[0]=g=>b.$emit("update:enabled",g))},null,8,["model-value"])]),i.enabled?(r(),f(O,{key:0},[t("div",$s,[s(Je,{"model-value":i.cron,"onUpdate:modelValue":a[1]||(a[1]=g=>b.$emit("update:cron",g))},null,8,["model-value"]),t("div",Ss,[s(e(D),null,{default:n(()=>[...a[4]||(a[4]=[c("Timezone",-1)])]),_:1}),s(Ke,{"model-value":i.timezone,"onUpdate:modelValue":a[2]||(a[2]=g=>b.$emit("update:timezone",g))},null,8,["model-value"])])]),i.schedule?(r(),f("div",Cs,[t("div",As,[a[5]||(a[5]=t("div",{class:"text-[10px] uppercase tracking-wide text-muted-foreground"}," Last run ",-1)),t("div",Es,[i.schedule.last_run_status?(r(),$(Ue,{key:0,status:i.schedule.last_run_status},null,8,["status"])):y("",!0)]),t("div",Vs,v(e(de)(i.schedule.last_run_at)),1)]),t("div",Ms,[a[6]||(a[6]=t("div",{class:"text-[10px] uppercase tracking-wide text-muted-foreground"}," Next run ",-1)),t("div",Us,v(e(de)(i.schedule.next_run_at)),1)])])):y("",!0)],64)):(r(),f("div",Is,[...a[7]||(a[7]=[c(" Recurring runs are off. The workflow only runs when triggered via ",-1),t("strong",null,"Run",-1),c(". ",-1)])]))]))}}),zs={class:"space-y-5 px-1 py-4"},Ts={class:"overflow-hidden rounded-lg border border-amy-border-strong bg-amy-bg-card"},Os={class:"flex items-center gap-2"},Ls={class:"text-[11px] text-muted-foreground"},Ps={key:0,class:"space-y-4 border-t border-amy-border-strong px-4 py-4"},js={class:"space-y-1.5"},Fs={class:"space-y-1.5"},Ds={class:"flex justify-end"},Ns={key:0,class:"space-y-2"},Bs={class:"flex items-center justify-between text-[11px] text-muted-foreground"},qs={class:"divide-y divide-amy-border-strong rounded-lg border border-amy-border-strong bg-amy-bg-card"},Ws={class:"flex items-start justify-between gap-4"},Hs={class:"min-w-0 flex-1"},Gs={class:"flex items-center gap-2"},Ys={class:"truncate text-sm font-medium text-foreground"}
1,Zs={key:0,class:"text-[10px] uppercase tracking-wide text-muted-foreground"},Js={class:"mt-0.5 text-xs text-foreground"},Ks={class:"mt-0.5 flex flex-wrap items-center gap-x-2.5 text-[11px] text-muted-foreground"},Xs={class:"font-mono"},Qs={key:0},el={key:0,class:"mt-1 flex items-center gap-1.5 text-[11px] text-muted-foreground"},tl={class:"flex shrink-0 items-center gap-1"},ol={key:1,class:"rounded-lg border border-dashed border-amy-border-strong bg-amy-bg-card px-4 py-10 text-center"},sl=J({__name:"unscoped-schedule-list",props:{schedules:{},customers:{},adding:{type:Boolean,default:!1},addSuccessCount:{default:0},togglingScheduleId:{default:null},deletingScheduleId:{default:null}},emits:["add","toggle","delete"],setup(i,{emit:b}){const a=i,g=b,w=_(!1),o=_(null),h=_("0 9 * * 1-5"),S=_("Europe/London"),{integrations:M,loading:P,fetchFor:H,reset:z}=pe(),U=A(()=>!a.adding&&o.value!==null&&(h.value??"").trim()!=="");function j(){o.value=null,h.value="0 9 * * 1-5",S.value="Europe/London",z()}function I(){!U.value||o.value===null||h.value===null||g("add",{customerId:o.value,cron:h.value,timezone:S.value})}return Z(()=>a.addSuccessCount,(C,x)=>{C>x&&(j(),w.value=!1)}),Z(()=>[w.value,o.value],([C,x])=>{if(!C){z();return}H(x)},{immediate:!0}),(C,x)=>(r(),f("div",zs,[t("div",Ts,[t("button",{type:"button",class:"flex w-full items-center justify-between px-4 py-3 text-left text-sm font-medium transition-colors hover:bg-amy-chip",onClick:x[0]||(x[0]=u=>w.value=!w.value)},[t("span",Os,[s(e(L),{icon:e(re),size:14,class:"text-muted-foreground"},null,8,["icon"]),x[4]||(x[4]=c(" Schedule for a customer ",-1))]),t("span",Ls,v(w.value?"Close":"Open"),1)]),w.value?(r(),f("div",Ps,[t("div",js,[s(e(D),null,{default:n(()=>[...x[5]||(x[5]=[c("Customer",-1)])]),_:1}),s(Ie,{modelValue:o.value,"onUpdate:modelValue":x[1]||(x[1]=u=>o.value=u),customers:i.customers},null,8,["modelValue","customers"])]),s(Je,{modelValue:h.value,"onUpdate:modelValue":x[2]||(x[2]=u=>h.value=u)},null,8,["modelValue"]),t("div",Fs,[s(e(D),null,{default:n(()=>[...x[6]||(x[6]=[c("Timezone",-1)])]),_:1}),s(Ke,{modelValue:S.value,"onUpdate:modelValue":x[3]||(x[3]=u=>S.value=u)},null,8,["modelValue"])]),s(fe,{integrations:e(M),loading:e(P),visible:o.value!==null},null,8,["integrations","loading","visible"]),t("div",Ds,[s(e(V),{size:"sm",disabled:!U.value,onClick:I},{default:n(()=>[i.adding?(r(),$(e(L),{key:0,icon:e(ne),size:13,class:"animate-spin"},null,8,["icon"])):y("",!0),c(" "+v(i.adding?"Saving":"Save"),1)]),_:1},8,["disabled"])])])):y("",!0)]),i.schedules.length>0?(r(),f("div",Ns,[t("div",Bs,[x[7]||(x[7]=t("span",{class:"font-medium uppercase tracking-wide"},"Active schedules",-1)),t("span",null,v(i.schedules.length)+" customer"+v(i.schedules.length===1?"":"s"),1)]),t("div",qs,[(r(!0),f(O,null,B(i.schedules,u=>(r(),f("div",{key:u.id,class:Y(["px-4 py-3",{"opacity-60":!u.enabled}])},[t("div",Ws,[t("div",Hs,[t("div",Gs,[t("span",Ys,v(u.customer_label),1),u.enabled?y("",!0):(r(),f("span",Zs," paused "))]),t("div",Js,v(e($e)(u.cron)??u.cron),1),t("div",Ks,[t("code",Xs,v(u.cron),1),t("span",null,"· "+v(u.timezone),1),u.next_run_at?(r(),f("span",Qs,"· next "+v(e(de)(u.next_run_at)),1)):y("",!0)]),u.last_run_at?(r(),f("div",el,[x[8]||(x[8]=t("span",null,"Last:",-1)),u.last_run_status?(r(),$(Ue,{key:0,status:u.last_run_status},null,8,["status"])):y("",!0),t("span",null,v(e(de)(u.last_run_at)),1)])):y("",!0)]),t("div",tl,[s(e(Ye),{"model-value":u.enabled,disabled:i.togglingScheduleId!==null||i.deletingScheduleId!==null,"onUpdate:modelValue":()=>g("toggle",u)},null,8,["model-value","disabled","onUpdate:modelValue"]),s(e(V),{size:"icon",variant:"ghost","aria-label":"Delete schedule",disabled:i.deletingScheduleId!==null||i.togglingScheduleId!==null,onClick:d=>g("delete",u)},{default:n(()=>[s(e(L),{icon:i.deletingScheduleId===u.id?e(ne):e(Be),size:14,class:Y([i.deletingScheduleId===u.id?"animate-spin":"","text-muted-foreground hover:text-destructive"])},null,8,["icon","class"])]),_:2},1032,["disabled","onClick"])])])],2))),128))])])):w.value?y("",!0):(r(),f("div",ol,[...x[9]||(x[9]=[t("div",{class:"text-sm font-medium text-foreground"},"No customers scheduled yet",-1),t("p",{class:"mx-auto mt-1 max-w-xs text-xs text-muted-foreground"},[c(" Open "),t("strong",null,"Schedule for a customer"),c(" above to bind this template to a customer's cadence. ")],-1)])]))]))}}),ll={key:0,class:"ml-1.5 text-[10px] text-muted-foreground"},nl={key:1},al={class:"flex gap-2"},rl=J({__name:"schedule-sheet",props:{open:{type:Boolean},tab:{},workflow:{},schedules:{},customers:{},recentRuns:{}},emits:["update:open","update:tab"],setup(i,{emit:b}){const a=i,g=b,w=A(()=>a.workflow.scope==="account"),o=A(()=>w.value?a.schedules[0]:void 0),h=A(()=>w.value?a.workflow.scope_id:null),{integrations:S,loading:M,fetchFor:P,reset:H}=pe(),z=_("0 9 * * 1-5"),U=_("Europe/London"),j=_(!0),I=_(!1),C=_(!1),x=_(!1),u=_(0),d=_(null),k=_(null);function T(){o.value?(z.value=o.value.cron,U.value=o.value.timezone,j.value=o.value.enabled):(z.value="0 9 * * 1-5",U.value="Europe/London",j.value=!0)}Z(()=>a.open,R=>{R&&T()},{immediate:!0}),Z(()=>[a.open,h.value],([R,F])=>{if(!R||!w.value){H();return}P(F)},{immediate:!0});function N(){g("update:open",!1)}function le(R){g("update:tab",R)}function ae(){if(I.value||a.workflow.id===null||a.workflow.scope_id===null)return;const R={customer_id:a.workflow.scope_id,cron:z.value,timezone:U.value,enabled:j.value};o.value?G.patch(route("assistant.admin.workflows.schedules.update",{workflow:a.workflow.id,schedule:o.value.id}),R,{preserveScroll:!0,onStart:()=>{I.value=!0},onFinish:()=>{I.value=!1},onSuccess:()=>{W.success("Schedule updated."),N()},onError:()=>{W.error("Could not update schedule.")}}):G.post(route("assistant.admin.workflows.schedules.store",a.workflow.id),R,{preserveScroll:!0,onStart:()=>{I.value=!0},onFinish:()=>{I.value=!1},onSuccess:()=>{W.success("Schedule added."),N()},onError:()=>{W.error("Could not add schedule.")}})}function ve(){C.value||a.workflow.id===null||o.value===void 0||window.confirm("Remove the schedule for this workflow?")&&G.delete(route("assistant.admin.workflows.schedules.destroy",{workflow:a.workflow.id,schedule:o.value.id}),{preserveScroll:!0,onStart:()=>{C.value=!0},onFinish:()=>{C.value=!1},onSuccess:()=>{W.success("Schedule removed.")},onError:()=>{W.error("Could not remove schedule.")}})}function ge(R){x.value||a.workflow.id===null||G.post(route("assistant.admin.workflows.schedules.store",a.workflow.id),{customer_id:R.customerId,cron:R.cron,timezone:R.timezone},{preserveScroll:!0,onStart:()=>{x.value=!0},onFinish:()=>{x.value=!1},onSuccess:()=>{u.value+=1,W.success("Schedule added.")},onError:()=>{W.error("Could not add schedule.")}})}function ye(R){d.value!==null||a.workflow.id===null||G.patch(route("assistant.admin.workflows.schedules.update",{workflow:a.workflow.id,schedule:R.id}),{enabled:!R.enabled},{preserveScroll:!0,onStart:()=>{d.value=R.id},onFinish:()=>{d.value=null},onSuccess:()=>{W.success(R.enabled?"Schedule paused.":"Schedule resumed.")},onError:()=>{W.error("Could not update schedule.")}})}function be(R){k.value!==null||a.workflow.id===null||G.delete(route("assistant.admin.workflows.schedules.destroy",{workflow:a.workflow.id,schedule:R.id}),{preserveScroll:!0,onStart:()=>{k.value=R.id},onFinish:()=>{k.value=null},onSuccess:()=>{W.success("Schedule removed.")},onError:()=>{W.error("Could not remove schedule.")}})}return(R,F)=>(r(),$(e(Ve),{open:i.open,"onUpdate:open":F[4]||(F[4]=K=>g("update:open",K))},{default:n(()=>[s(e(Ce),{side:"right",class:Y(["flex flex-col",w.value?"w-full sm:max-w-xl":"w-full sm:max-w-2xl"])},{default:n(()=>[s(e(Ae),null,{default:n(()=>[s(e(Ee),null,{default:n(()=>[c(v(w.value?`Schedule for ${i.workflow.scope_label??"this customer"}`:"Schedule workflow"),1)]),_:1}),s(e(Me),null,{default:n(()=>[w.value?(r(),f(O,{key:0},[c(" This workflow is pinned to one customer, so it has at most one schedule. Set when it should run automatically. ")],64)):(r(),f(O,{key:1},[c(" Set when this workflow runs for each customer. Each customer can have their own cadence. ")],64))]),_:1})]),_:1}),s(e(He),{"model-value":i.tab,class:"flex flex-1 flex-col overflow-hidden px-4 pt-4","onUpdate:modelValue":F[3]||(F[3]=K=>le(String(K??"")))},{default:n(()=>[s(e(Ge),{class:"grid w-full grid-cols-2"},{default:n(()=>[s(e(ce),{value:"config"},{default:n(()=>[...F[5]||(F[5]=[c("Schedule",-1)])]),_:1}),s(e(ce),{value:"history"},{default:n(()=>[F[6]||(F[6]=c(" Recent runs ",-1)),i.recentRuns.length>
10?(r(),f("span",ll,v(i.workflow.total_runs),1)):y("",!0)]),_:1})]),_:1}),s(e(me),{value:"config",class:"flex-1 space-y-5 overflow-y-auto py-5"},{default:n(()=>[w.value?(r(),$(Rs,{key:0,schedule:o.value,cron:z.value,timezone:U.value,enabled:j.value,"onUpdate:cron":F[0]||(F[0]=K=>z.value=K),"onUpdate:timezone":F[1]||(F[1]=K=>U.value=K),"onUpdate:enabled":F[2]||(F[2]=K=>j.value=K)},null,8,["schedule","cron","timezone","enabled"])):y("",!0),w.value?(r(),$(fe,{key:1,integrations:e(S),loading:e(M),visible:h.value!==null},null,8,["integrations","loading","visible"])):(r(),$(sl,{key:2,schedules:i.schedules,customers:i.customers,adding:x.value,"add-success-count":u.value,"toggling-schedule-id":d.value,"deleting-schedule-id":k.value,onAdd:ge,onToggle:ye,onDelete:be},null,8,["schedules","customers","adding","add-success-count","toggling-schedule-id","deleting-schedule-id"]))]),_:1}),s(e(me),{value:"history",class:"flex-1 overflow-y-auto py-5"},{default:n(()=>[s(Ze,{runs:i.recentRuns,"workflow-id":i.workflow.id},null,8,["runs","workflow-id"])]),_:1})]),_:1},8,["model-value"]),i.tab==="config"&&w.value?(r(),$(e(ke),{key:0,class:"flex-row items-center justify-between gap-2"},{default:n(()=>[o.value?(r(),$(e(V),{key:0,variant:"ghost",size:"sm",class:"text-destructive hover:text-destructive",disabled:C.value,onClick:ve},{default:n(()=>[s(e(L),{icon:C.value?e(ne):e(Be),size:13,class:Y({"animate-spin":C.value})},null,8,["icon","class"]),c(" "+v(C.value?"Removing":"Remove"),1)]),_:1},8,["disabled"])):(r(),f("span",nl)),t("div",al,[s(e(V),{variant:"outline",onClick:N},{default:n(()=>[...F[7]||(F[7]=[c("Cancel",-1)])]),_:1}),s(e(V),{disabled:I.value,onClick:ae},{default:n(()=>[I.value?(r(),$(e(L),{key:0,icon:e(ne),size:13,class:"animate-spin"},null,8,["icon"])):y("",!0),c(" "+v(I.value?o.value?"Updating":"Saving":o.value?"Update":"Save"),1)]),_:1},8,["disabled"])])]),_:1})):(r(),$(e(ke),{key:1},{default:n(()=>[s(e(V),{variant:"outline",onClick:N},{default:n(()=>[c(v(i.tab==="history"?"Close":"Done"),1)]),_:1})]),_:1}))]),_:1},8,["class"])]),_:1},8,["open"]))}}),ul=[{id:"anthropic/claude-opus-4.8",name:"Claude Opus 4.8",provider:"Anthropic",context:"1M",input_price:"$5.00/M",output_price:"$25.00/M",fast:!1,description:"Default premium model for workflow execution."},{id:"anthropic/claude-opus-4.7",name:"Claude Opus 4.7",provider:"Anthropic",context:"1M",input_price:"$5.00/M",output_price:"$25.00/M",fast:!1,description:"Previous premium workflow model."},{id:"anthropic/claude-sonnet-5",name:"Claude Sonnet 5",provider:"Anthropic",context:"1M",input_price:"$2.00/M",output_price:"$10.00/M",fast:!0,description:"Fast Anthropic workflow model."},{id:"zai/glm-5.2-fast",name:"GLM 5.2 Fast",provider:"Z.ai",context:"1M",input_price:"$3.00/M",output_price:"$10.25/M",fast:!0,description:"Fast Z.ai workflow model."},{id:"zai/glm-5.2",name:"GLM 5.2",provider:"Z.ai",context:"1M",input_price:"$0.95/M",output_price:"$3.00/M",fast:!1,description:"Z.ai workflow model for heavier steps."},{id:"zai/glm-4.7",name:"GLM 4.7",provider:"Z.ai",context:"205K",input_price:"$2.25/M",output_price:"$2.75/M",fast:!0,description:"Fast general-purpose workflow model."},{id:"google/gemini-3.5-flash",name:"Gemini 3.5 Flash",provider:"Google",context:"1M",input_price:"$1.50/M",output_price:"$9.00/M",fast:!1,description:"Large-context Google model for broad workflow tasks."},{id:"openai/gpt-5.5",name:"GPT-5.5",provider:"OpenAI",context:"1M",input_price:"$5.00/M",output_price:"$30.00/M",fast:!1,description:"Premium OpenAI model for higher-stakes reasoning."},{id:"deepseek/deepseek-v4-flash",name:"DeepSeek V4 Flash",provider:"DeepSeek",context:"1M",input_price:"$0.14/M",output_price:"$0.28/M",fast:!1,description:"Low-cost long-context workflow model."},{id:"anthropic/claude-haiku-4.5",name:"Claude Haiku 4.5",provider:"Anthropic",context:"200K",input_price:"$1.00/M",output_price:"$5.00/M",fast:!1,description:"Anthropic model for concise workflow execution."}];function il(){const i=_([]),b=_(!1);let a=0;async function g(o){if(o===null){i.value=[];return}const h=++a;b.value=!0;try{const S=new URLSearchParams({scope_type:"account",scope_id:o}),M=await fetch(`${route("assistant.admin.workflows.customer-context-library")}?${S.toString()}`,{headers:{Accept:"application/json","X-Requested-With":"XMLHttpRequest"},credentials:"same-origin"});if(!M.ok)throw new Error(`Customer context fetch failed (${M.status})`);const P=await M.json();h===a&&(i.value=P.context_library_items??[])}catch(S){h===a&&(i.value=[]),console.warn("[useCustomerContextLibrary] fetch failed",S)}finally{h===a&&(b.value=!1)}}function w(){a+=1,i.value=[],b.value=!1}return{items:i,loading:b,fetchFor:g,reset:w}}const dl={class:"grid grid-cols-1 gap-6 lg:grid-cols-[minmax(0,1fr)_320px]"},cl={class:"space-y-3"},ml={class:"flex items-center justify-between"},fl={class:"text-xs text-muted-foreground"},pl={key:0,class:"text-xs text-destructive"},vl={key:1,class:"rounded-lg border border-dashed border-amy-border-strong bg-amy-bg-card p-10 text-center"},gl={class:"mt-4 flex justify-center"},yl={key:0,class:"flex justify-center"},bl={key:2,class:"flex flex-wrap items-center justify-center gap-2 pt-2"},xl={key:3,class:"flex justify-center"},wl={key:4,class:"rounded-lg border border-amy-border-default bg-amy-bg-card p-4 shadow-sm"},hl={class:"flex items-start justify-between gap-4"},kl={class:"flex items-center gap-2"},_l={class:"flex h-6 min-w-6 items-center justify-center rounded-full border border-amy-border-default bg-amy-chip text-xs font-medium text-amy-fg-muted"},$l={class:"text-xs text-muted-foreground"},Sl={class:"flex items-center gap-2"},Cl={class:"mt-4 grid gap-3 md:grid-cols-2"},Al={class:"space-y-1.5"},El={class:"flex flex-col"},Vl={class:"text-[11px] text-muted-foreground"},Ml={class:"space-y-1.5"},Ul={key:0,class:"space-y-1.5 md:col-span-2"},Il={key:0,class:"text-[11px] text-destructive"},Rl={class:"space-y-1.5 md:col-span-2"},zl={key:0,class:"text-[11px] text-destructive"},Tl={class:"space-y-5"},Ol={class:"space-y-4 rounded-lg border border-amy-border-default bg-amy-bg-card p-4"},Ll={class:"space-y-1.5"},Pl={key:0,class:"text-[11px] text-destructive"},jl={class:"space-y-1.5"},Fl={key:0,class:"text-[11px] text-destructive"},Dl={class:"space-y-4 rounded-lg border border-amy-border-default bg-amy-bg-card p-4"},Nl={class:"grid grid-cols-2 gap-2"},Bl={key:0,class:"text-[11px] text-destructive"},ql={key:1,class:"space-y-1.5"},Wl={key:0,class:"text-[11px] text-destructive"},Hl={key:2,class:"text-[11px] text-muted-foreground"},za=J({layout:jt,__name:"Builder",props:{workflow:{},models:{},customers:{},schedules:{default:()=>[]},recentRuns:{default:()=>[]},mode:{}},setup(i){const b=i,{setBreadcrumbs:a,setConstrained:g}=Jt();a([{title:"Admin · Workflows",href:route("assistant.admin.workflows.index")},{title:b.mode==="create"?"New workflow":b.workflow.name||"Untitled",href:b.workflow.id!==null?route("assistant.admin.workflows.edit",b.workflow.id):route("assistant.admin.workflows.create")}]),g(!1);const w=ul,o=_(we(JSON.parse(JSON.stringify(b.workflow)))),h=_(!1),S=_(!1),M=_(!1),P=_("now"),H=_(!1),z=_("config"),U=_(!1),j=_(!1),I=_(!1),C=_({});let x=null,u=null;const d=A(()=>_e(b.workflow.safety));function k(m="now"){P.value=m,M.value=!0}function T(m="config"){z.value=m,H.value=!0}function N(){b.mode!=="edit"||o.value.id===null||G.reload({only:["schedules"]})}function le(){x!==null&&(window.clearInterval(x),x=null)}Z(H,m=>{le(),m&&(N(),x=window.setInterval(N,6e4))});const{integrations:ae,loading:ve,fetchFor:ge,reset:ye}=pe(),{items:be,loading:R,fetchFor:F,reset:K}=il(),Re=A(()=>o.value.scope==="account"?b.customers:[]),Xe=A(()=>o.value.scope_id===null?void 0:Re.value.find(m=>m.id===o.value.scope_id)),Qe=A(()=>Xe.value?.label??o.value.scope_label??null),ze=A(()=>o.value.scope==="account"&&o.value.scope_id!==null),et=ze;function q(...m){for(const l of m){const p=C.value[l];if(Array.isArray(p))return p[0]??null;if(p!==void 0)return p}return null}function tt(m){const l=`steps.${m}.`;return Object.fromEntries(Object.entries(C.value).filter(([p])=>p.startsWith(l)).map(([p,E])=>[p.slice(l.length),E]))}function xe(){return w[0]?.id??"anthropic/claude-opus-4.8"}function ot(m){const l=m?.trim()??"";return l==="claude-opus-4-7"?xe():w.some(p=>p.id===l)?l:xe()}function we(m){return m.steps=m.steps.map((l,p)=>({...l,position:p+1,name:l.name?.trim()||`Step ${p+1}`,output_key:l.output_key?.trim()||`step_${p+1}`,model:ot(l.model),include_workflow_system_prompt:l.include_workflow_system_prompt??!0,include_core_memories:l.include_core_memories??!0,context_library_ids:l.context_library_ids??[]})),m.delivery={enabled:m.delivery?.enabled??!1,channel:m.delivery?.channel??"email",recipient:m.delivery?.recipient??"customer_user",output_key:m.delivery?.output_key??null,subject_template:m.delivery?.subject_template??`${m.name||"Workflow"} - {{today_date}}`,custom_text:m.delivery?.custom_text??""},m}Z(()=>o.value.scope,()=>{o.value.scope_id=null,o.value.scope_label=null,o.value.steps=o.value.steps.map(m=>({...m,context_library_ids:[]})),ye(),K()}),Z(()=>o.value.scope_id,(m,l)=>{l!==void 0&&m!==l&&(o.value.steps=o.value.steps.map(p=>({...p,context_library_ids:[]}))),ge(m),F(m)},{immediate:!0});function Te(){const m=o.value.steps.length+1;
1o.value.steps.push({id:null,position:m,name:`Step ${m}`,output_key:`step_${m}`,model:xe(),system:"",include_workflow_system_prompt:!0,include_core_memories:!0,prompt:"",carry_previous_outputs:!0,context_library_ids:[]})}function st(){o.value.delivery.enabled=!0,o.value.delivery.subject_template.trim()===""&&(o.value.delivery.subject_template=`${o.value.name||"Workflow"} - {{today_date}}`)}function lt(){o.value.delivery.enabled=!1}function nt(m,l){o.value.steps[m]=l}function at(m){o.value.steps.splice(m,1),o.value.steps.forEach((l,p)=>{l.position=p+1})}function rt(m,l){const p=l==="up"?m-1:m+1;if(p<0||p>=o.value.steps.length)return;const E=o.value.steps[m];o.value.steps[m]=o.value.steps[p],o.value.steps[p]=E,o.value.steps.forEach((se,yt)=>{se.position=yt+1})}function ut(m){o.value=we({...o.value,name:m.name||o.value.name,description:m.description??o.value.description,delivery:{...o.value.delivery,...m.delivery},steps:m.steps.map((l,p)=>({...l,id:null,position:p+1,context_library_ids:l.context_library_ids??[]}))}),C.value={}}function it(m){const l=[{key:"today_date",description:"Current run date, e.g. Thursday, May 14, 2026"},{key:"current_date",description:"Current run date as YYYY-MM-DD"},{key:"current_time",description:"Current run time, e.g. 14:30:00 UTC"},{key:"current_datetime",description:"Current run date and time as ISO 8601"},{key:"current_timezone",description:"Timezone used for the current run timestamp"}],p=o.value.steps.slice(0,m).filter(E=>(E.output_key??"").trim()!=="").map(E=>({key:E.output_key,description:`Output of ${E.name?.trim()!==""?E.name:`Step ${E.position}`}`}));return[...l,...p]}const Oe=A(()=>o.value.steps.filter(m=>(m.output_key??"").trim()!=="").map(m=>({key:m.output_key,label:m.name?.trim()!==""?m.name:`Step ${m.position}`}))),Le=[{value:"email",label:"Email to customer",description:"Send from Amy email to the selected customer account email."},{value:"slack",label:"Slack DM",description:"Send a direct message from the Amy Slack app to the selected customer."},{value:"telegram",label:"Telegram to customer",description:"Send from Amy Telegram when the customer has Telegram connected."}],Pe=A(()=>Le.find(m=>m.value===o.value.delivery.channel)?.label??"Email"),dt=A(()=>{if(o.value.delivery.output_key===null)return"Last step output";const m=Oe.value.find(l=>l.key===o.value.delivery.output_key);return m===void 0?o.value.delivery.output_key:`${m.label}: ${m.key}`}),je=A(()=>o.value.steps.length+(o.value.delivery.enabled?1:0));function ct(){const m={};return o.value.name.trim()===""&&(m.name="Give this workflow a name."),o.value.scope==="account"&&o.value.scope_id===null&&(m.scope_id="Pick the customer account this workflow is pinned to."),o.value.steps.forEach((l,p)=>{(l.output_key??"").trim()===""&&(m[`steps.${p}.output_key`]="Add a reference key for this step."),(l.output_key??"").trim()==="delivery"&&(m[`steps.${p}.output_key`]="delivery is reserved for the Amy delivery step."),(l.model??"").trim()===""&&(m[`steps.${p}.model`]="Pick a model for this step."),l.prompt.trim()===""&&(m[`steps.${p}.prompt`]="Add a prompt for this step.")}),o.value.delivery.enabled&&o.value.steps.length===0&&(m["delivery.enabled"]="Add at least one prompt step before delivery."),o.value.delivery.enabled&&o.value.delivery.channel==="email"&&o.value.delivery.subject_template.trim()===""&&(m["delivery.subject_template"]="Add a subject or title template."),m}function mt(){if(U.value)return;const m=ct();if(Object.keys(m).length>0){C.value=m,W.error("Please fix the highlighted fields before saving.");return}const l=JSON.parse(JSON.stringify(we(o.value))),p=b.mode==="create"?"Workflow created.":"Workflow saved.",E={preserveScroll:!0,onStart:()=>{U.value=!0,C.value={}},onError:se=>{C.value=se??{},W.error("Please fix the highlighted fields before saving.")},onSuccess:()=>{C.value={},W.success(p)},onFinish:()=>{U.value=!1}};b.mode==="create"?G.post(route("assistant.admin.workflows.store"),l,E):o.value.id!==null&&G.patch(route("assistant.admin.workflows.update",o.value.id),l,E)}function ft(m){o.value.id===null||j.value||G.post(route("assistant.admin.workflows.safety.approve",{workflow:o.value.id,version:m}),{},{preserveScroll:!0,onStart:()=>{j.value=!0},onSuccess:()=>{W.success("Workflow confirmed.")},onFinish:()=>{j.value=!1}})}function pt(m){o.value.id===null||I.value||G.post(route("assistant.admin.workflows.safety.retry",{workflow:o.value.id,version:m}),{},{preserveScroll:!0,onStart:()=>{I.value=!0},onFinish:()=>{I.value=!1}})}function vt(){G.reload({only:["workflow","schedules"],onSuccess:()=>{o.value.status=b.workflow.status,o.value.version=b.workflow.version,o.value.safety=b.workflow.safety}})}function gt(){o.value.id!==null&&(u=`admin.workflow.${o.value.id}`,window.Echo?.private(u).listen("ManagedOutcomeWorkflowSafetyUpdated",vt))}return It(()=>{if(gt(),typeof window>"u"||o.value.id===null)return;const m=new URLSearchParams(window.location.search);m.get("run")==="1"||m.get("test")==="1"?k("now"):m.get("runs")==="1"&&k("history"),m.get("schedule")==="1"?T("config"):m.get("schedules")==="1"&&T("history")}),Rt(()=>{le(),u!==null&&window.Echo?.leave(u)}),(m,l)=>(r(),f(O,null,[s(e(Mt),{title:`${o.value.name||"New workflow"} · Admin Workflows`},null,8,["title"]),s(bt,null,{default:n(()=>[s(ao,{workflow:o.value,mode:i.mode,saving:U.value,"run-disabled":d.value,onSave:mt,onOpenAiDraft:l[0]||(l[0]=p=>S.value=!0),onOpenHelp:l[1]||(l[1]=p=>h.value=!0),onOpenRun:l[2]||(l[2]=p=>k("now")),onOpenRunHistory:l[3]||(l[3]=p=>k("history")),onOpenSchedule:l[4]||(l[4]=p=>T("config"))},null,8,["workflow","mode","saving","run-disabled"]),s(_o,{open:h.value,"onUpdate:open":l[5]||(l[5]=p=>h.value=p)},null,8,["open"]),s(Kt,{open:S.value,workflow:o.value,"onUpdate:open":l[6]||(l[6]=p=>S.value=p),onApply:ut},null,8,["open","workflow"]),t("div",dl,[t("div",cl,[t("div",ml,[l[20]||(l[20]=t("h2",{class:"text-sm font-medium text-foreground"},"Steps",-1)),t("span",fl,v(je.value)+" step"+v(je.value===1?"":"s"),1)]),q("steps")?(r(),f("p",pl,v(q("steps")),1
1)):y("",!0),o.value.steps.length===0?(r(),f("div",vl,[l[22]||(l[22]=t("h3",{class:"text-sm font-medium text-foreground"}," No steps yet ",-1)),l[23]||(l[23]=t("p",{class:"mt-1 text-xs text-muted-foreground"},[c(" Each step is a prompt the AI runs. The AI sees earlier outputs by default. You can also reference a specific one with "),t("code",{class:"rounded bg-amy-chip px-1 font-mono"},"{{ step_1 }}"),c(". ")],-1)),t("div",gl,[s(e(V),{size:"sm",variant:"outline",onClick:Te},{default:n(()=>[s(e(L),{icon:e(re),size:12},null,8,["icon"]),l[21]||(l[21]=c(" Add first step ",-1))]),_:1})])])):y("",!0),(r(!0),f(O,null,B(o.value.steps,(p,E)=>(r(),f(O,{key:E},[s(Xt,{step:p,"is-first":E===0,"is-last":E===o.value.steps.length-1,models:e(w),"variable-suggestions":it(E),"context-library-items":e(be),"context-library-loading":e(R),"context-library-visible":e(et),"initially-open":E===o.value.steps.length-1,errors:tt(E),onUpdate:se=>nt(E,se),onDelete:()=>at(E),onMove:se=>rt(E,se)},null,8,["step","is-first","is-last","models","variable-suggestions","context-library-items","context-library-loading","context-library-visible","initially-open","errors","onUpdate","onDelete","onMove"]),E<o.value.steps.length-1?(r(),f("div",yl,[...l[24]||(l[24]=[t("div",{class:"h-5 w-0.5 rounded-full bg-amy-border-strong","aria-hidden":"true"},null,-1)])])):y("",!0)],64))),128)),o.value.steps.length>0?(r(),f("div",bl,[s(e(V),{size:"sm",variant:"outline",onClick:Te},{default:n(()=>[s(e(L),{icon:e(re),size:12},null,8,["icon"]),l[25]||(l[25]=c(" Add step ",-1))]),_:1}),o.value.delivery.enabled?y("",!0):(r(),$(e(V),{key:0,size:"sm",variant:"outline",onClick:st},{default:n(()=>[s(e(L),{icon:e(re),size:12},null,8,["icon"]),l[26]||(l[26]=c(" Deliver as Amy ",-1))]),_:1}))])):y("",!0),o.value.delivery.enabled?(r(),f("div",xl,[...l[27]||(l[27]=[t("div",{class:"h-5 w-0.5 rounded-full bg-amy-border-strong","aria-hidden":"true"},null,-1)])])):y("",!0),o.value.delivery.enabled?(r(),f("div",wl,[t("div",hl,[t("div",null,[t("div",kl,[t("span",_l,v(o.value.steps.length+1),1),t("div",null,[l[28]||(l[28]=t("h3",{class:"text-sm font-semibold text-foreground"}," Deliver as Amy ",-1)),t("p",$l,v(Pe.value)+" · "+v(dt.value),1)])])]),t("div",Sl,[l[30]||(l[30]=t("span",{class:"rounded-full border border-amy-border-default bg-amy-chip px-2 py-0.5 text-[11px] font-medium text-amy-fg-muted"}," Final step ",-1)),s(e(V),{size:"sm",variant:"ghost",onClick:lt},{default:n(()=>[...l[29]||(l[29]=[c(" Remove ",-1)])]),_:1})])]),t("div",Cl,[t("div",Al,[s(e(D),null,{default:n(()=>[...l[31]||(l[31]=[c("Channel",-1)])]),_:1}),s(e(Q),{"model-value":o.value.delivery.channel,"onUpdate:modelValue":l[7]||(l[7]=p=>o.value.delivery.channel=String(p??"email"))},{default:n(()=>[s(e(ee),null,{default:n(()=>[s(e(te),null,{default:n(()=>[c(v(Pe.value),1)]),_:1})]),_:1}),s(e(oe),null,{default:n(()=>[(r(),f(O,null,B(Le,p=>s(e(X),{key:p.value,value:p.value,"text-value":p.label},{default:n(()=>[t("div",El,[t("span",null,v(p.label),1),t("span",Vl,v(p.description),1)])]),_:2},1032,["value","text-value"])),64))]),_:1})]),_:1},8,["model-value"])]),t("div",Ml,[s(e(D),null,{default:n(()=>[...l[32]||(l[32]=[c("Send output",-1)])]),_:1}),s(e(Q),{"model-value":o.value.delivery.output_key??"__final__","onUpdate:modelValue":l[8]||(l[8]=p=>o.value.delivery.output_key=String(p??"")==="__final__"?null:String(p))},{default:n(()=>[s(e(ee),null,{default:n(()=>[s(e(te),{placeholder:"Last step output"})]),_:1}),s(e(oe),null,{default:n(()=>[s(e(X),{value:"__final__"},{default:n(()=>[...l[33]||(l[33]=[c(" Last step output ",-1)])]),_:1}),(r(!0),f(O,null,B(Oe.value,p=>(r(),$(e(X),{key:p.key,value:p.key},{default:n(()=>[c(v(p.label)+": "+v(p.key),1)]),_:2},1032,["value"]))),128))]),_:1})]),_:1},8,["model-value"])]),o.value.delivery.channel==="email"?(r(),f("div",Ul,[s(e(D),null,{default:n(()=>[...l[34]||(l[34]=[c("Subject",-1)])]),_:1}),s(e(ie),{modelValue:o.value.delivery.subject_template,"onUpdate:modelValue":l[9]||(l[9]=p=>o.value.delivery.subject_template=p),class:Y(q("delivery.subject_template")?"border-destructive focus-visible:ring-destructive/20":void 0),placeholder:"Meeting Prep - {{today_date}}"},null,8,["modelValue","class"]),l[35]||(l[35]=t("p",{class:"text-[11px] text-muted-foreground"}
1,[t("code",{class:"rounded bg-amy-chip px-1 font-mono"},"{{ today_date }}"),c(" is available and will print Thursday, May 28, 2026. ")],-1)),q("delivery.subject_template")?(r(),f("p",Il,v(q("delivery.subject_template")),1)):y("",!0)])):y("",!0),t("div",Rl,[s(e(D),null,{default:n(()=>[...l[36]||(l[36]=[c("Custom text",-1)])]),_:1}),s(e(Ne),{modelValue:o.value.delivery.custom_text,"onUpdate:modelValue":l[10]||(l[10]=p=>o.value.delivery.custom_text=p),rows:3,placeholder:"Optional text to show before the workflow output."},null,8,["modelValue"]),q("delivery.custom_text")?(r(),f("p",zl,v(q("delivery.custom_text")),1)):y("",!0)]),l[37]||(l[37]=t("p",{class:"text-[11px] text-muted-foreground md:col-span-2"}," Recipient is the selected customer account. ",-1))])])):y("",!0)]),t("aside",Tl,[i.mode==="edit"?(r(),$(Zt,{key:0,safety:i.workflow.safety,approving:j.value,retrying:I.value,onApprove:ft,onRetry:pt},null,8,["safety","approving","retrying"])):y("",!0),t("section",Ol,[l[40]||(l[40]=t("h3",{class:"text-xs font-semibold uppercase tracking-wide text-muted-foreground"}," Details ",-1)),t("div",Ll,[s(e(D),null,{default:n(()=>[...l[38]||(l[38]=[c("Name",-1)])]),_:1}),s(e(ie),{modelValue:o.value.name,"onUpdate:modelValue":l[11]||(l[11]=p=>o.value.name=p),class:Y(q("name")?"border-destructive focus-visible:ring-destructive/20":void 0),placeholder:"e.g. Meeting Prepper"},null,8,["modelValue","class"]),q("name")?(r(),f("p",Pl,v(q("name")),1)):y("",!0)]),t("div",jl,[s(e(D),null,{default:n(()=>[...l[39]||(l[39]=[c("Description",-1)])]),_:1}),s(e(Ne),{modelValue:o.value.description,"onUpdate:modelValue":l[12]||(l[12]=p=>o.value.description=p),rows:3,placeholder:"What does this workflow do?"},null,8,["modelValue"]),q("description")?(r(),f("p",Fl,v(q("description")),1)):y("",!0)])]),t("section",Dl,[l[45]||(l[45]=t("h3",{class:"text-xs font-semibold uppercase tracking-wide text-muted-foreground"}," Scope ",-1)),t("div",Nl,[t("button",{type:"button",class:Y(["rounded-md border px-3 py-2.5 text-left transition-colors",o.value.scope==="unscoped"?"border-amy-accent-strong bg-amy-accent-muted":"border-amy-border-default hover:bg-amy-chip/60"]),onClick:l[13]||(l[13]=p=>o.value.scope="unscoped")},[...l[41]||(l[41]=[t("span",{class:"block text-xs font-medium text-foreground"},"Unscoped",-1),t("span",{class:"mt-0.5 block text-[10px] leading-tight text-muted-foreground"}," Reusable template ",-1)])],2),t("button",{type:"button",class:Y(["rounded-md border px-3 py-2.5 text-left transition-colors",o.value.scope==="account"?"border-amy-accent-strong bg-amy-accent-muted":"border-amy-border-default hover:bg-amy-chip/60"]),onClick:l[14]||(l[14]=p=>o.value.scope="account")},[...l[42]||(l[42]=[t("span",{class:"block text-xs font-medium text-foreground"},"Account",-1),t("span",{class:"mt-0.5 block text-[10px] leading-tight text-muted-foreground"}," Pinned to one customer ",-1)])],2)]),q("scope")?(r(),f("p",Bl,v(q("scope")),1)):y("",!0),o.value.scope==="account"?(r(),f("div",ql,[s(e(D),null,{default:n(()=>[...l[43]||(l[43]=[c("Customer account",-1)])]),_:1}),s(Ie,{modelValue:o.value.scope_id,"onUpdate:modelValue":l[15]||(l[15]=p=>o.value.scope_id=p),customers:Re.value,"selected-label":Qe.value},null,8,["modelValue","customers","selected-label"]),q("scope_id")?(r(),f("p",Wl,v(q("scope_id")),1)):y("",!0),l[44]||(l[44]=t("p",{class:"text-[11px] text-muted-foreground"}," Readiness is checked against this customer. Connected apps appear below. ",-1))])):(r(),f("p",Hl," Reusable template, bound to a customer at run time. Readiness is checked against the chosen customer when the workflow fires. "))]),s(fe,{integrations:e(ae),loading:e(ve),visible:ze.value},null,8,["integrations","loading","visible"])])]),s(Wo,{open:M.value,tab:P.value,workflow:o.value,customers:i.customers,"recent-runs":i.recentRuns,"onUpdate:open":l[16]||(l[16]=p=>M.value=p),"onUpdate:tab":l[17]||(l[17]=p=>P.value=p)},null,8,["open","tab","workflow","customers","recent-runs"]),s(rl,{open:H.value,tab:z.value,workflow:o.value,schedules:i.schedules,customers:i.customers,"recent-runs":i.recentRuns,"onUpdate:open":l[18]||(l[18]=p=>H.value=p),"onUpdate:tab":l[19]||(l[19]=p=>z.value=p)},null,8,["open","tab","workflow","schedules","customers","recent-runs"])]),_:1})],64))}});
1export{za as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.