@w6w/ui 0.2.69 → 0.2.70

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use client";"use strict";var wn=Object.defineProperty;var mn=(t,s,n)=>s in t?wn(t,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[s]=n;var xe=(t,s,n)=>mn(t,typeof s!="symbol"?s+"":s,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("./connection-app-meta-ChRGxZex.cjs"),x=require("react"),e=require("react/jsx-runtime"),U=require("./CodeBlock-85y9qvE3.cjs"),hn=require("@codemirror/lang-yaml"),pn=require("@codemirror/view"),fn=require("@uiw/react-codemirror"),es=require("react-dom");class be extends Error{constructor(n,a,i,r){super(i);xe(this,"status");xe(this,"code");xe(this,"body");this.name="ApiError",this.status=n,this.code=a,this.body=r}}function xn(t){const s=t.baseUrl.replace(/\/$/,""),n=t.fetch??globalThis.fetch,a=async()=>typeof t.token=="function"?await t.token():t.token;async function i(l,o){const c=new Headers(o==null?void 0:o.headers),d=await a();d&&c.set("authorization",`Bearer ${d}`),o!=null&&o.body&&!c.has("content-type")&&c.set("content-type","application/json");let m;try{m=await n(`${s}${l}`,{...o,headers:c})}catch(w){throw new be(0,"network_error",`Could not reach the w6w server (${(o==null?void 0:o.method)??"GET"} ${s}${l}). It may be down or unreachable. (${w.message})`)}const g=await m.text();let j=null;if(g)try{j=JSON.parse(g)}catch{if(!m.ok)throw new be(m.status,"bad_response",`Server returned a non-JSON ${m.status} response: ${g.slice(0,200)}`)}if(!m.ok){const w=(j==null?void 0:j.error)??{};throw new be(m.status,w.code??"error",w.message??m.statusText,j)}return{status:m.status,data:j}}async function r(l,o){const{data:c}=await i(l,o);return c}return{listApps:async()=>{const l=async()=>{const o=[];let c;for(;;){const d=new URLSearchParams({limit:"200"});c&&d.set("cursor",c);const m=await r(`/apps?${d}`);if(o.push(...m.apps),!m.nextCursor||m.nextCursor===c)return o;c=m.nextCursor}};try{return await l()}catch(o){if(o instanceof be&&(o.code==="snapshot_expired"||o.code==="unknown_snapshot"))return await l();throw o}},listAppsByIds:async l=>{const o=Array.from(new Set(l)),c=[];for(let d=0;d<o.length;d+=100){const g=o.slice(d,d+100).map(encodeURIComponent).join(","),j=await r(`/apps?ids=${g}`);c.push(...j.apps)}return c},getAppAuth:async l=>(await r(`/apps/${encodeURIComponent(l)}/auths`)).auths??[],createConnection:(l,o)=>r(`/apps/${encodeURIComponent(l)}/connections`,{method:"POST",body:JSON.stringify(o)}).then(c=>c.connection),updateConnection:(l,o)=>r(`/connections/${encodeURIComponent(l)}`,{method:"PATCH",body:JSON.stringify(o)}).then(c=>c.connection),listCredentials:l=>{const o=new URLSearchParams;(l==null?void 0:l.contract)!==void 0&&o.set("contract",l.contract),(l==null?void 0:l.appId)!==void 0&&o.set("appId",l.appId),(l==null?void 0:l.authKey)!==void 0&&o.set("authKey",l.authKey);const c=o.toString();return r(`/credentials${c?`?${c}`:""}`).then(d=>d.credentials??[])},createCredential:l=>r("/credentials",{method:"POST",body:JSON.stringify(l)}).then(o=>o.credential),getCredential:l=>r(`/credentials/${encodeURIComponent(l)}`).then(o=>o.credential),rotateCredential:(l,o)=>r(`/credentials/${encodeURIComponent(l)}/rotate`,{method:"POST",body:JSON.stringify(o)}).then(c=>c.credential),setCredentialStatus:(l,o)=>r(`/credentials/${encodeURIComponent(l)}/${o==="disabled"?"disable":"enable"}`,{method:"POST"}).then(c=>c.credential),testCredential:l=>r(`/credentials/${encodeURIComponent(l)}/test`,{method:"POST"}),credentialDependents:l=>r(`/credentials/${encodeURIComponent(l)}/dependents`).then(o=>o.dependents),deleteCredential:async l=>{await r(`/credentials/${encodeURIComponent(l)}`,{method:"DELETE"})},startAppOAuthFlow:(l,o,c)=>r(`/apps/${encodeURIComponent(l)}/oauth-config/${encodeURIComponent(o)}/authorize-url`,{method:"POST",body:JSON.stringify(c)}),getAppActions:l=>r(`/apps/${encodeURIComponent(l)}`).then(o=>o.actions??[]),listConnectionsForApp:l=>r(`/apps/${encodeURIComponent(l)}/connections`).then(o=>o.connections??[]),listConnections:()=>r("/connections").then(l=>l.connections??[]),invokeAction:(l,o,c,d={})=>r(`/apps/${encodeURIComponent(l)}/actions/${encodeURIComponent(o)}/invoke`,{method:"POST",body:JSON.stringify({params:c,connectionId:d.connectionId,project:d.project,state:d.state,workflowId:d.workflowId,timeoutMs:d.timeoutMs})}),listSavedTests:l=>r(`/connections/${encodeURIComponent(l)}/saved-tests`).then(o=>o.savedTests??[]),createSavedTest:(l,o)=>r(`/connections/${encodeURIComponent(l)}/saved-tests`,{method:"POST",body:JSON.stringify(o)}).then(c=>c.savedTest),updateSavedTest:(l,o,c)=>r(`/connections/${encodeURIComponent(l)}/saved-tests/${encodeURIComponent(o)}`,{method:"PATCH",body:JSON.stringify(c)}).then(d=>d.savedTest),deleteSavedTest:(l,o)=>r(`/connections/${encodeURIComponent(l)}/saved-tests/${encodeURIComponent(o)}`,{method:"DELETE"}).then(()=>{}),recordTestRun:(l,o)=>r(`/connections/${encodeURIComponent(l)}/test-runs`,{method:"POST",body:JSON.stringify(o)}).then(()=>{}),listTestRuns:l=>r(`/connections/${encodeURIComponent(l)}/test-runs`).then(o=>o.runs??[]),saveStepTest:(l,o,c)=>r(`/workflows/${encodeURIComponent(l)}/steps/${encodeURIComponent(o)}/tests`,{method:"POST",body:JSON.stringify(c)}).then(d=>d.stepTest),listStepTests:(l,o)=>r(`/workflows/${encodeURIComponent(l)}/steps/${encodeURIComponent(o)}/tests`).then(c=>c.stepTests??[]),loadNodeSamples:l=>r(`/workflows/${encodeURIComponent(l)}/node-samples`).then(o=>o.nodeSamples??[]),loadTestInputs:l=>r(`/workflows/${encodeURIComponent(l)}/test-inputs`).then(o=>o.testInputs??[]),saveTestInput:(l,o,c)=>r(`/workflows/${encodeURIComponent(l)}/nodes/${encodeURIComponent(o)}/test-input`,{method:"PUT",body:JSON.stringify({input:c})}).then(()=>{}),recordStepTestRun:(l,o,c)=>r(`/workflows/${encodeURIComponent(l)}/steps/${encodeURIComponent(o)}/test-runs`,{method:"POST",body:JSON.stringify(c)}).then(()=>{}),listFunctions:()=>r("/functions").then(l=>l.functions??[]),getFunction:l=>r(`/functions/${encodeURIComponent(l)}`).then(o=>({...o.function,valid:o.valid})),invokeFunction:(l,o)=>r(`/functions/${encodeURIComponent(l)}/invoke`,{method:"POST",body:JSON.stringify({inputs:o})}).then(c=>c.output),listWorkflows:()=>r("/workflows").then(l=>l.workflows??[]),getWorkflow:l=>r(`/workflows/${encodeURIComponent(l)}`).then(o=>o.workflow),runWorkflow:(l,o={})=>i(`/workflows/${encodeURIComponent(l)}/run?wait=true`,{method:"POST",body:JSON.stringify({variables:o.variables,input:o.input,entry:o.entry})}).then(({status:c,data:d})=>({...d??{},terminal:c===200}))}}const gn=x.createContext(void 0);function Oe({title:t,subtitle:s,icon:n,trailing:a,active:i=!1,onClick:r,href:l,ariaLabel:o}){const c=e.jsxs(e.Fragment,{children:[n!=null&&e.jsx("span",{className:"w6w-list-item-icon",children:n}),e.jsxs("span",{className:"w6w-list-item-body",children:[e.jsx("span",{className:"w6w-list-item-title",children:t}),s!=null&&e.jsx("span",{className:"w6w-list-item-subtitle",children:s})]}),a!=null&&e.jsx("span",{className:"w6w-list-item-trailing",children:a})]}),d=`w6w-list-item${i?" active":""}`;return l!==void 0?e.jsx("a",{className:d,href:l,"aria-current":i?"true":void 0,"aria-label":o,onClick:r,children:c}):r?e.jsx("button",{type:"button",className:d,"aria-pressed":i,"aria-label":o,onClick:r,children:c}):e.jsx("div",{className:d,"aria-label":o,children:c})}function ze(t){const s=Date.parse(t);if(Number.isNaN(s))return"";const n=Math.max(0,Math.round((Date.now()-s)/1e3));if(n<45)return"just now";const a=Math.round(n/60);if(a<60)return`${a}m ago`;const i=Math.round(a/60);if(i<24)return`${i}h ago`;const r=Math.round(i/24);return r<7?`${r}d ago`:new Date(s).toLocaleDateString()}function Ot(t){const s={};for(const n of(t==null?void 0:t.params)??[])n.key&&n.default!==void 0&&(s[n.key]=n.default);return s}function vn(t){var n,a,i;const s=t.indexOf("{");if(s>=0)try{const r=JSON.parse(t.slice(s)),l=((a=(n=r==null?void 0:r.errors)==null?void 0:n[0])==null?void 0:a.message)??(typeof(r==null?void 0:r.error)=="object"?(i=r.error)==null?void 0:i.message:r==null?void 0:r.error)??(r==null?void 0:r.message);if(typeof l=="string"&&l.trim()){const o=t.slice(0,s).replace(/[:\s]+$/,"");return o?`${o}: ${l.trim()}`:l.trim()}}catch{}return t}function ts(t){return typeof t=="object"&&t!==null&&typeof t.status=="number"&&typeof t.code=="string"}function jn(t){if(!ts(t))return{headline:(t==null?void 0:t.message)??"The action failed to run."};const s=vn(t.message??""),n=`${t.status} ${t.code} ${t.message??""}`.toLowerCase();return t.status===401||t.status===403||/\b(401|403)\b|forbidden|unauthorized|not authorized|permission|scope|access denied|invalid api key|invalid credential/.test(n)?{headline:"Permission denied by the provider — this is a credential/scope problem, not a w6w error.",hint:"The connection's API key is missing the permissions this action needs. Fix it at the provider — e.g. SendGrid → Settings → API Keys → give the key the required scopes (or Full Access), or create a new key — then update this connection's credential and try again.",detail:s}:{headline:"The action returned an error.",detail:s}}function bn(t){const s=ts(t)?t.body??t.raw:null;return(s==null?void 0:s.apiCalls)??[]}function Ge(){const[t,s]=x.useState(""),[n,a]=x.useState(void 0),[i,r]=x.useState(!1);return{text:t,value:n,invalid:i,onChange:o=>{s(o);const c=o.trim();if(c===""){r(!1);return}try{const d=JSON.parse(c);d!==null&&typeof d=="object"&&!Array.isArray(d)?(a(d),r(!1)):r(!0)}catch{r(!0)}}}}function yn({appId:t,actions:s,connectionId:n,action:a,seedValues:i,onSavedTestsChanged:r,seedTestId:l,onDirtyChange:o,onTestSaved:c,onDeleted:d,embedded:m=!1}){var It;const g=p.useW6WApi(),j=x.useMemo(()=>{const y=[...s];return y.sort((O,z)=>(O.title||O.key).localeCompare(z.title||z.key)),y},[s]),[w,f]=x.useState((a==null?void 0:a.key)??""),v=a??s.find(y=>y.key===w)??null,[u,h]=x.useState(!1),[b,N]=x.useState(null),[S,k]=x.useState(void 0),[R,A]=x.useState([]),D=Ge(),_=Ge(),V=Ge(),[M,P]=x.useState(""),[T,F]=x.useState(""),C=D.invalid||_.invalid||V.invalid,B=()=>{const y={};return D.text.trim()!==""&&D.value!==void 0&&(y.body=D.value),_.text.trim()!==""&&_.value!==void 0&&(y.query=_.value),V.text.trim()!==""&&V.value!==void 0&&(y.headers=V.value),M&&(y.target=M),T.trim()!==""&&(y.match=T.trim()),Object.keys(y).length>0?y:void 0},[I,W]=x.useState("form"),[Q,Z]=x.useState(""),[X,le]=x.useState(!1),[q,E]=x.useState(!1),K=(v==null?void 0:v.key)??null,re=i?{...i}:Ot(v),[oe,$]=x.useState(()=>({key:K,values:re})),[L,J]=x.useState(l??null),[Y,ce]=x.useState(re);if(oe.key!==K){const y=Ot(v);$({key:K,values:y}),ce(y),J(l??null),N(null),k(void 0),A([])}const[H,ue]=x.useState(l);l!==H&&(ue(l),J(l??null));const[Nt,zs]=x.useState(i);if(i!==Nt){const y=JSON.stringify(i??null)!==JSON.stringify(Nt??null);if(zs(i),i&&y){const O={...i};$({key:K,values:O}),ce(O),N(null),k(void 0),A([])}}const te=oe.values,kt=y=>$({key:K,values:y}),St=x.useMemo(()=>JSON.stringify(te)!==JSON.stringify(Y),[te,Y]);x.useEffect(()=>{o==null||o(St)},[St]);const Gs=()=>{Z(JSON.stringify(te,null,2)),le(!1),W("json")},Xs=async y=>{if(!v||C)return;const O=v.key;h(!0),N(null),k(void 0),A([]);let z;const we=B();try{const se=await g.invokeAction(t,O,y,{connectionId:n,...we?{overrides:we}:{}});k(se.value),A(se.apiCalls??[]),z={ok:!0,summary:"OK",result:se.value}}catch(se){const Lt=jn(se);N(Lt),A(bn(se)),z={ok:!1,summary:Lt.headline}}finally{h(!1)}if(n)try{await g.recordTestRun(n,{savedTestId:L??null,actionKey:O,ok:z.ok,summary:z.summary.slice(0,200),result:z.result}),qe(),rn(),r==null||r()}catch{}},Zs=()=>Xs(te),[Ce,Ct]=x.useState(null),[Ee,fe]=x.useState(null),[Qs,en]=x.useState(0),[tn,Ae]=x.useState(!1),[Ve,Je]=x.useState(""),[sn,He]=x.useState(!1),qe=()=>en(y=>y+1);x.useEffect(()=>{if(!n){Ct(null);return}let y=!1;return fe(null),g.listSavedTests(n).then(O=>!y&&Ct(O)).catch(O=>!y&&fe(O.message)),()=>{y=!0}},[g,n,Qs]);const Et=K?(Ce??[]).filter(y=>y.actionKey===K):[],[nn,Ye]=x.useState(null),[an,ln]=x.useState(0),rn=()=>ln(y=>y+1);x.useEffect(()=>{const y=g.listTestRuns;if(!n||!y){Ye(null);return}let O=!1;return y(n).then(z=>!O&&Ye(z)).catch(()=>!O&&Ye(null)),()=>{O=!0}},[g,n,an]);const At=K?(nn??[]).filter(y=>y.actionKey===K).slice().sort((y,O)=>Date.parse(O.occurredAt)-Date.parse(y.occurredAt)):[],on=()=>{!n||!v||(Je(""),fe(null),Ae(!0))},cn=()=>{!n||!v||(L?Rt():on())},Rt=async()=>{if(!(!n||!v))try{let y;if(L)y=await g.updateSavedTest(n,L,{values:te});else{const O=Ve.trim();if(!O)return;y=await g.createSavedTest(n,{actionKey:v.key,name:O,values:te}),J(y.id)}ce({...te}),Ae(!1),Je(""),qe(),r==null||r(),c==null||c(y)}catch(y){fe(y.message)}},dn=y=>{const O={...y.values};$({key:K,values:O}),ce(O),J(y.id),W("form"),N(null),k(void 0),A([])},un=async()=>{if(!n||!L)return;const y=L;try{await g.deleteSavedTest(n,y),J(null),qe(),r==null||r(),d==null||d(y)}catch(O){fe(O.message)}},$t=e.jsxs("div",{className:"w6w-stack",style:{gap:"var(--w6w-sp-1-5)"},children:[e.jsxs("div",{className:"w6w-field-labelrow",style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx("span",{className:"w6w-muted w6w-small",children:"Parameters"}),e.jsxs("div",{style:{display:"flex",gap:"var(--w6w-sp-1)"},children:[e.jsx("button",{type:"button",className:`w6w-btn w6w-btn-sm w6w-btn-ghost${I==="form"?" active":""}`,"aria-pressed":I==="form",onClick:()=>W("form"),children:"Form"}),e.jsx("button",{type:"button",className:`w6w-btn w6w-btn-sm w6w-btn-ghost${I==="json"?" active":""}`,"aria-pressed":I==="json",onClick:Gs,children:"JSON"}),!m&&e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-sm w6w-btn-ghost","aria-pressed":q,title:q?"Collapse the params editor":"Open the params editor in a larger view","aria-label":q?"Collapse the params editor":"Open the params editor in a larger view",onClick:()=>E(y=>!y),children:q?"⤡":"⤢"})]})]}),I==="form"?e.jsx(p.ParamsForm,{params:(v==null?void 0:v.params)??[],values:te,onChange:kt,dynamic:v?{appId:t,actionKey:v.key,connectionId:n}:void 0}):e.jsxs(e.Fragment,{children:[e.jsx(p.JsonEditor,{value:Q,onChange:Z,minHeight:q?"50vh":"200px","aria-label":"Params JSON",onValidChange:y=>{y!==null&&typeof y=="object"&&!Array.isArray(y)&&kt(y)},onValidityChange:({valid:y})=>le(!y)}),X&&e.jsx("span",{className:"w6w-hint",style:{color:"var(--w6w-danger)"},children:"Invalid JSON"})]})]}),Tt=e.jsxs("details",{className:"w6w-section","data-testid":"overrides-region",children:[e.jsxs("summary",{className:"w6w-section-summary",children:[e.jsx("span",{className:"w6w-section-title",children:"Overrides"}),e.jsx("span",{className:"w6w-section-subtitle",children:"Reach a vendor field this action's own params don't declare"})]}),e.jsxs("div",{className:"w6w-stack w6w-section-body",style:{gap:"var(--w6w-sp-2)"},children:[e.jsxs("div",{className:"w6w-field",children:[e.jsx("span",{children:"Body"}),e.jsx(p.JsonEditor,{value:D.text,onChange:D.onChange,minHeight:"80px","aria-label":"Overrides body (JSON)"}),D.invalid&&e.jsx("span",{className:"w6w-hint",style:{color:"var(--w6w-danger)"},children:"Invalid JSON"})]}),e.jsxs("div",{className:"w6w-field",children:[e.jsx("span",{children:"Query"}),e.jsx(p.JsonEditor,{value:_.text,onChange:_.onChange,minHeight:"80px","aria-label":"Overrides query (JSON)"}),_.invalid&&e.jsx("span",{className:"w6w-hint",style:{color:"var(--w6w-danger)"},children:"Invalid JSON"})]}),e.jsxs("div",{className:"w6w-field",children:[e.jsx("span",{children:"Headers"}),e.jsx(p.JsonEditor,{value:V.text,onChange:V.onChange,minHeight:"80px","aria-label":"Overrides headers (JSON)"}),V.invalid&&e.jsx("span",{className:"w6w-hint",style:{color:"var(--w6w-danger)"},children:"Invalid JSON"})]}),e.jsxs("label",{className:"w6w-field",children:[e.jsx("span",{children:"Target"}),e.jsxs("select",{"aria-label":"Overrides target",value:M,onChange:y=>P(y.target.value),children:[e.jsx("option",{value:"",children:"— default (first) —"}),e.jsx("option",{value:"first",children:"first"}),e.jsx("option",{value:"first-write",children:"first-write"}),e.jsx("option",{value:"all",children:"all"})]})]}),e.jsxs("label",{className:"w6w-field",children:[e.jsx("span",{children:"Match"}),e.jsx("input",{type:"text","aria-label":"Overrides match",value:T,placeholder:"Restrict to requests whose URL contains…",onChange:y=>F(y.target.value)})]}),e.jsx("span",{className:"w6w-hint",children:"Merged onto the outbound request at the wire, never into the params above — name a field the way the vendor's own API documents it."})]})]}),Re=n?e.jsxs("div",{className:"w6w-stack",style:{gap:"var(--w6w-sp-1-5)"},children:[e.jsx("div",{className:"w6w-field-labelrow",style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:e.jsx("span",{className:"w6w-muted w6w-small",children:"Saved tests"})}),Ee&&e.jsx("span",{className:"w6w-hint",style:{color:"var(--w6w-danger)"},children:Ee}),Et.length===0?e.jsx("p",{className:"w6w-muted w6w-small",children:"No saved tests for this action yet."}):e.jsx("ul",{className:"w6w-stack",style:{listStyle:"none",margin:0,padding:0,gap:"var(--w6w-sp-1-5)"},children:Et.map(y=>e.jsx("li",{children:e.jsx(Oe,{title:y.name,subtitle:y.lastRunAt?e.jsxs("span",{children:[e.jsx("span",{style:{color:y.lastRunOk?"var(--w6w-success)":"var(--w6w-danger)"},children:y.lastRunOk?"✓":"✗"})," ",y.lastRunSummary?`${y.lastRunSummary} · `:"",ze(y.lastRunAt)]}):`saved ${ze(y.updatedAt)}`,active:y.id===L,onClick:()=>dn(y)})},y.id))}),g.listTestRuns&&At.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w6w-field-labelrow",style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:e.jsx("span",{className:"w6w-muted w6w-small",children:"Recent runs"})}),e.jsx("ul",{className:"w6w-stack",style:{listStyle:"none",margin:0,padding:0,gap:"var(--w6w-sp-1-5)"},children:At.map(y=>e.jsx("li",{children:e.jsx(Oe,{title:e.jsxs("span",{children:[e.jsx("span",{style:{color:y.ok?"var(--w6w-success)":"var(--w6w-danger)"},children:y.ok?"✓":"✗"})," ",y.actionKey]}),subtitle:e.jsxs("span",{children:[y.summary?`${y.summary} · `:"",ze(y.occurredAt)]})})},y.id))})]})]}):null,_t=(It=Ce==null?void 0:Ce.find(y=>y.id===L))==null?void 0:It.name;return e.jsxs("div",{className:`w6w-stack${m?" w6w-tester-embedded-root":""}`,children:[!a&&(s.length===0?e.jsx("p",{className:"w6w-muted w6w-small",children:"This app exposes no actions."}):e.jsxs("label",{className:"w6w-field",children:[e.jsxs("span",{children:["Action",K?"":" *"]}),e.jsx(p.Combobox,{value:w,placeholder:"— pick an action —",onChange:f,options:j.map(y=>({value:y.key,label:`${y.title??y.key} (${y.key})`}))})]})),v?e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsxs("strong",{children:[v.title??v.key," ",e.jsx("code",{className:"w6w-muted",children:v.key})]}),v.description&&e.jsx("p",{className:"w6w-muted w6w-small",style:{margin:"var(--w6w-sp-0-5) 0 0"},children:v.description})]}),(()=>{const y=b?e.jsxs("div",{className:"w6w-result w6w-error",children:[e.jsx("strong",{children:b.headline}),b.hint&&e.jsx("div",{style:{marginTop:"var(--w6w-sp-1-5)"},children:b.hint}),b.detail&&e.jsx("div",{className:"w6w-muted w6w-small",style:{marginTop:"var(--w6w-sp-1-5)",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:b.detail})]}):null,O=S!==void 0?e.jsxs("div",{className:"w6w-stack",style:{gap:"var(--w6w-sp-1)"},children:[e.jsx("strong",{className:"w6w-small",children:"Result"}),e.jsx(p.ResultViewer,{value:S})]}):null,z=e.jsxs("div",{className:"w6w-stack",style:{gap:"var(--w6w-sp-3)"},children:[$t,Tt,y,O,e.jsx(p.ApiCallsPanel,{calls:R})]}),we=e.jsxs("div",{className:`w6w-tester-actions${m||q?" w6w-tester-actions-footer":""}`,style:{display:"flex",gap:"var(--w6w-sp-2)"},children:[e.jsx("button",{type:"button",className:"w6w-btn",disabled:u||C,onClick:Zs,children:u?"Running…":"Run action"}),n&&e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:cn,children:"Save test"}),n&&L&&e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",style:{marginLeft:"auto",color:"var(--w6w-danger)"},onClick:()=>He(!0),children:"Delete"})]}),se=e.jsxs("div",{className:"w6w-stack",style:{gap:"var(--w6w-sp-3)"},children:[z,we]});return m?e.jsxs("div",{className:"w6w-tester-embedded",children:[e.jsx("div",{className:"w6w-tester-embedded-scroll",children:e.jsxs("div",{className:"w6w-card-stack",children:[e.jsxs("div",{className:"card",children:[e.jsx("div",{className:"section-head",children:e.jsx("h3",{children:"Parameters"})}),e.jsxs("div",{className:"w6w-stack",style:{gap:"var(--w6w-sp-3)"},children:[$t,Tt,y]})]}),(O||R.length>0)&&e.jsxs("div",{className:"card",children:[e.jsx("div",{className:"section-head",children:e.jsx("h3",{children:"Result"})}),e.jsxs("div",{className:"w6w-stack",style:{gap:"var(--w6w-sp-3)"},children:[S!==void 0&&e.jsx(p.ResultViewer,{value:S}),e.jsx(p.ApiCallsPanel,{calls:R})]})]}),Re&&e.jsxs("div",{className:"card",children:[e.jsx("div",{className:"section-head",children:e.jsx("h3",{children:"Saved tests and history"})}),Re]})]})}),we]}):q?e.jsx(p.Modal,{title:`Edit params — ${v.title??v.key}`,onClose:()=>E(!1),size:"full",children:e.jsxs("div",{className:"w6w-tester-popout",children:[e.jsx("div",{className:"w6w-tester-popout-scroll",children:Re?e.jsxs("div",{style:{display:"flex",gap:"var(--w6w-sp-4)",alignItems:"flex-start"},children:[e.jsx("div",{style:{flex:1,minWidth:0},children:z}),e.jsx("div",{style:{width:260,flexShrink:0},children:Re})]}):z}),we]})}):se})(),tn&&e.jsx(p.Modal,{title:"Save test",onClose:()=>Ae(!1),children:e.jsxs("form",{className:"w6w-stack",style:{gap:"var(--w6w-sp-3)"},onSubmit:y=>{y.preventDefault(),Rt()},children:[e.jsxs("label",{className:"w6w-field",children:[e.jsx("span",{children:"Name this saved test"}),e.jsx("input",{type:"text",value:Ve,placeholder:"e.g. valid sender",onChange:y=>Je(y.target.value)})]}),Ee&&e.jsx("span",{className:"w6w-hint",style:{color:"var(--w6w-danger)"},children:Ee}),e.jsxs("div",{style:{display:"flex",gap:"var(--w6w-sp-2)",justifyContent:"flex-end"},children:[e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:()=>Ae(!1),children:"Cancel"}),e.jsx("button",{type:"submit",className:"w6w-btn",disabled:!Ve.trim(),children:"Save"})]})]})}),sn&&e.jsx(p.ConfirmModal,{title:"Delete saved test",message:_t?`Delete "${_t}"? This cannot be undone.`:"Delete this saved test? This cannot be undone.",confirmLabel:"Delete",onConfirm:()=>{He(!1),un()},onClose:()=>He(!1)})]}):!a&&e.jsx("p",{className:"w6w-muted w6w-small",children:"Pick an action above to test it."})]})}function Nn(t){const s=p.useEffectiveTheme(t.theme),{copied:n,copy:a}=U.useCopyToClipboard(t.value),i=x.useMemo(()=>[hn.yaml(),pn.EditorView.theme(p.EDITOR_THEME_SPEC)],[]);function r(l){t.onChange(l)}return e.jsxs("div",{className:"w6w-yaml-editor","aria-label":t["aria-label"]??"YAML editor",children:[e.jsx(fn,{value:t.value,onChange:r,extensions:i,placeholder:t.placeholder,readOnly:t.readOnly,editable:!t.readOnly,theme:s,height:t.height,minHeight:t.minHeight??"240px",maxHeight:t.maxHeight,basicSetup:{lineNumbers:!0,foldGutter:!0,highlightActiveLine:!t.readOnly,autocompletion:!0,bracketMatching:!0,closeBrackets:!0}}),t.copyable!==!1&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:`w6w-icon-btn w6w-copyable-btn${n?" is-copied":""}`,"aria-label":"Copy",onClick:()=>void a(),children:n?e.jsx(U.CheckGlyph,{}):e.jsx(U.CopyGlyph,{})}),e.jsx("span",{className:"w6w-copyable-status","aria-live":"polite",children:n?"Copied":""})]})]})}const Xe="…";function ss(t,s,n="end"){if(s===void 0||s<1||s>=t.length)return t;if(n==="start")return`${Xe}${t.slice(t.length-s)}`;if(n==="end")return`${t.slice(0,s)}${Xe}`;const a=Math.ceil(s/2),i=s-a;return`${t.slice(0,a)}${Xe}${t.slice(t.length-i)}`}function ns(t){const{value:s,chars:n,crop:a="end",label:i,className:r,copiedMs:l}=t,o=ss(s,n,a),c=["w6w-copyable--bare",r].filter(Boolean).join(" ");return e.jsx(U.Copyable,{value:s,readOnly:!0,label:i,className:c,copiedMs:l,children:e.jsx("span",{children:o})})}const kn={ok:"Operational",degraded:"Degraded",down:"Down",unknown:"Unknown"};function Fe({state:t,label:s,ariaLabel:n}){const a=s??kn[t];return e.jsxs("span",{className:`w6w-health-pill w6w-health-pill-${t}`,"aria-label":n,children:[e.jsx("span",{className:"w6w-health-pill-dot","aria-hidden":"true"}),e.jsx("span",{className:"w6w-health-pill-label",children:a})]})}const Sn={ok:"Operational",degraded:"Degraded",down:"Down",unknown:"Unknown"};function as({days:t,ariaLabel:s}){return t.length===0?null:e.jsx("div",{className:"w6w-uptime-strip",role:"img","aria-label":s??`${t.length}-day status`,children:t.map((n,a)=>e.jsx("span",{className:`w6w-uptime-cell w6w-uptime-cell-${n.state}`,title:n.label??`${n.day} — ${Sn[n.state]}`},`${n.day}-${a}`))})}const is="—",Pt=["B","KiB","MiB","GiB","TiB","PiB"];function ls(t){if(t===null||!Number.isFinite(t))return is;if(t<1024)return`${Math.round(t)} B`;let s=t,n=0;for(;s>=1024&&n<Pt.length-1;)s/=1024,n+=1;return`${s.toFixed(1)} ${Pt[n]}`}function ie(t){return t===null||!Number.isFinite(t)?is:`${Math.round(t*100)}%`}function Ne(t){if(t===void 0||t.load1===null)return null;const s=t.cpuLimit??t.cpus;return s===null||s<=0?null:t.load1/s}function ke(t){if(t===void 0)return null;const{memoryTotal:s,memoryAvailable:n}=t;return s===null||n===null||s<=0?null:(s-n)/s}function Cn(t,s,n){return t<s?s:t>n?n:t}function En(t,s,n,a){const i=t.length;if(i<2)return"";const r=[];for(let l=0;l<i;l++){const o=t[l];if(o===null)continue;const c=l/(i-1)*s,d=a<=0?n:n-Cn(o,0,a)/a*n;r.push(`${Number(c.toFixed(2))},${Number(d.toFixed(2))}`)}return r.join(" ")}const An="—",Dt=100,Mt=24;function nt({values:t,max:s,className:n}){const a=En(t,Dt,Mt,s);return a===""?null:e.jsx("svg",{className:n,viewBox:`0 0 ${Dt} ${Mt}`,preserveAspectRatio:"none","aria-hidden":"true",focusable:"false",children:e.jsx("polyline",{points:a,fill:"none",stroke:"var(--w6w-accent)",strokeWidth:2,vectorEffect:"non-scaling-stroke"})})}function Ze(t){return t===null?An:t.toFixed(2)}function Pe(t){let s=1;for(const n of t)n!==null&&n>s&&(s=n);return s}function Ie({label:t,value:s,values:n,max:a}){return e.jsxs("li",{className:"w6w-server-resources__row",children:[e.jsx("span",{className:"w6w-server-resources__label",children:t}),e.jsx("span",{className:"w6w-server-resources__value",children:s}),e.jsx(nt,{className:"w6w-server-resources__spark",values:n,max:a})]})}function ct(t){const s=t[t.length-1],n=t.map(r=>Ne(r)),a=t.map(r=>ke(r)),i=t.map(r=>r.processRss);return{last:s,cpuValues:n,memoryValues:a,rssValues:i}}function Rn({samples:t,title:s="Server resources",intervalMs:n}){const{last:a,cpuValues:i,memoryValues:r,rssValues:l}=ct(t);return e.jsxs("section",{className:"w6w-server-resources w6w-server-resources--card","aria-label":s,children:[e.jsx("h3",{className:"w6w-server-resources__title",children:s}),e.jsxs("ul",{className:"w6w-server-resources__rows",children:[e.jsx(Ie,{label:"CPU",value:ie(Ne(a)),values:i,max:Pe(i)}),e.jsx(Ie,{label:"Memory",value:ie(ke(a)),values:r,max:1}),e.jsx(Ie,{label:"Process",value:ls((a==null?void 0:a.processRss)??null),values:l,max:Pe(l)})]}),e.jsx("p",{className:"w6w-server-resources__meta",children:`Load ${Ze((a==null?void 0:a.load1)??null)} / ${Ze((a==null?void 0:a.load5)??null)} / ${Ze((a==null?void 0:a.load15)??null)}`}),n!==void 0&&e.jsx("p",{className:"w6w-server-resources__meta",children:`Sampled every ${n/1e3}s`})]})}function $n({samples:t,title:s="Server"}){const{last:n,cpuValues:a}=ct(t);return e.jsxs("section",{className:"w6w-server-resources w6w-server-resources--small","aria-label":s,children:[e.jsx("h3",{className:"w6w-server-resources__title",children:s}),e.jsxs("ul",{className:"w6w-server-resources__rows",children:[e.jsx(Ie,{label:"CPU",value:ie(Ne(n)),values:a,max:Pe(a)}),e.jsxs("li",{className:"w6w-server-resources__row",children:[e.jsx("span",{className:"w6w-server-resources__label",children:"Memory"}),e.jsx("span",{className:"w6w-server-resources__value",children:ie(ke(n))})]})]})]})}function Tn({samples:t,onExpand:s}){const{last:n,cpuValues:a,memoryValues:i}=ct(t);return e.jsxs("aside",{className:"w6w-server-resources w6w-server-resources--rail",children:[e.jsxs("div",{className:"w6w-server-resources__rail-row",children:[e.jsx("span",{className:"w6w-server-resources__label",children:"CPU"}),e.jsx("span",{className:"w6w-server-resources__value",children:ie(Ne(n))}),e.jsx(nt,{className:"w6w-server-resources__spark",values:a,max:Pe(a)})]}),e.jsxs("div",{className:"w6w-server-resources__rail-row",children:[e.jsx("span",{className:"w6w-server-resources__label",children:"MEM"}),e.jsx("span",{className:"w6w-server-resources__value",children:ie(ke(n))}),e.jsx(nt,{className:"w6w-server-resources__spark",values:i,max:1})]}),s!==void 0&&e.jsx("button",{type:"button",className:"w6w-server-resources__expand","aria-label":"Show server resources",onClick:s,children:"Details"})]})}function _n({samples:t}){const s=t[t.length-1],n=ie(Ne(s)),a=ie(ke(s));return e.jsx("span",{className:"w6w-server-resources w6w-server-resources--badge",children:`CPU ${n} · MEM ${a}`})}const In=1,Ln=1440*60*1e3;function On(t,s,n){const a=s.startedAt??s.updatedAt;if(a===void 0)return null;const i=Date.parse(a),r=s.resolvedAt!==void 0?Date.parse(s.resolvedAt):s.startedAt!==void 0?n:i,l=Date.parse(`${t.from}T00:00:00.000Z`),o=Date.parse(`${t.to}T00:00:00.000Z`)+Ln,c=o-l;if(r<l||i>=o)return null;const d=i<l,m=r>o,g=Math.max(i,l),j=Math.min(r,o),w=(g-l)/c*100,f=(j-g)/c*100,v=Math.max(f,In);return{leftPct:w,widthPct:v,clippedStart:d,clippedEnd:m}}const Pn={ok:"Operational",degraded:"Degraded",down:"Down",unknown:"Unknown"},Dn="This vendor publishes no incident history.",Mn="No incidents in this window.";function Bn(t){const s=t.startedAt??t.updatedAt,n=[t.title];return t.components!==void 0&&t.components.length>0&&n.push(`(${t.components.join(", ")})`),s!==void 0&&n.push(t.resolvedAt!==void 0?`${s} – ${t.resolvedAt}`:`${s} – ongoing`),n.join(" ")}function Fn({window:t,days:s,incidents:n,vendorEmptyLabel:a,nowMs:i=Date.now(),ariaLabel:r}){const l=s.length,o=l>0?100/l:0,c=n===void 0?a??Dn:n.length===0?a??Mn:null;return e.jsx("div",{className:"w6w-history-timeline",role:"img","aria-label":r??`${l}-day history`,children:e.jsxs("div",{className:"w6w-history-plot",children:[e.jsx("div",{className:"w6w-history-lane w6w-history-lane-execution",children:s.map((d,m)=>e.jsx("span",{className:`w6w-history-cell w6w-history-cell-${d.state}`,style:{left:`${m*o}%`,width:`${o}%`},title:d.label??`${d.day} — ${Pn[d.state]}`},`${d.day}-${m}`))}),e.jsx("div",{className:"w6w-history-lane w6w-history-lane-vendor",children:c!==null?e.jsx("span",{className:"w6w-history-empty",title:c,children:c}):n==null?void 0:n.map((d,m)=>{const g=On(t,d,i);if(g===null)return null;const j=[g.clippedStart?"w6w-history-bar-clip-start":"",g.clippedEnd?"w6w-history-bar-clip-end":""].filter(Boolean).join(" ");return e.jsx("span",{className:`w6w-history-bar w6w-history-bar-${d.state}${j?` ${j}`:""}`,style:{left:`${g.leftPct}%`,width:`${g.widthPct}%`},title:Bn(d)},d.id??`${d.title}-${m}`)})}),e.jsxs("div",{className:"w6w-history-axis",children:[e.jsx("span",{className:"w6w-history-tick w6w-history-tick-start",style:{left:"0%"},children:t.from}),e.jsx("span",{className:"w6w-history-tick w6w-history-tick-end",style:{left:"100%"},children:t.to})]})]})})}function Un({label:t,children:s,className:n}){const[a,i]=x.useState(!1),r=x.useId();return e.jsxs("span",{className:["w6w-info-tip",n??""].filter(Boolean).join(" "),children:[e.jsx(p.IconButton,{label:t,icon:"info","aria-expanded":a,"aria-controls":r,onClick:()=>i(l=>!l)}),a&&e.jsx("span",{id:r,className:"w6w-info-tip-body w6w-muted w6w-small",children:s})]})}function Wn(t){const{label:s,onClick:n,disabled:a,className:i,...r}=t;return e.jsx(p.IconButton,{label:s,onClick:n,disabled:a,className:i,icon:"edit","data-testid":r["data-testid"]})}const $e=4;function dt({actions:t,label:s="Actions",disabled:n,"data-testid":a}){const i=t.filter(h=>!!h),r=x.useRef(null),l=x.useRef(null),o=x.useId(),[c,d]=x.useState(!1),[m,g]=x.useState(null),[j,w]=x.useState(null),f=x.useCallback(h=>{var b;d(!1),w(null),h&&((b=r.current)==null||b.focus({preventScroll:!0}))},[]);if(x.useLayoutEffect(()=>{if(!c)return;const h=r.current,b=l.current;if(!h||!b)return;const N=h.getBoundingClientRect(),S=b.offsetWidth,k=b.offsetHeight,R=window.innerHeight||document.documentElement.clientHeight,A=N.bottom+$e,D=A+k>R&&N.top-$e-k>=0?N.top-$e-k:A;w({top:D,left:Math.max($e,N.right-S)})},[c]),x.useEffect(()=>{var h,b;!c||!j||(b=(h=l.current)==null?void 0:h.querySelector("[role=menuitem]"))==null||b.focus({preventScroll:!0})},[c,j]),x.useEffect(()=>{if(!c)return;const h=k=>{var R,A;return k instanceof Node&&((R=l.current)==null?void 0:R.contains(k))||k instanceof Node&&((A=r.current)==null?void 0:A.contains(k))},b=k=>{h(k.target)||f(!1)},N=k=>{var R;k.target instanceof Node&&((R=l.current)!=null&&R.contains(k.target))||f(!1)},S=()=>f(!1);return document.addEventListener("pointerdown",b,!0),document.addEventListener("mousedown",b,!0),document.addEventListener("scroll",N,!0),window.addEventListener("resize",S),window.addEventListener("blur",S),()=>{document.removeEventListener("pointerdown",b,!0),document.removeEventListener("mousedown",b,!0),document.removeEventListener("scroll",N,!0),window.removeEventListener("resize",S),window.removeEventListener("blur",S)}},[c,f]),i.length===0)return null;const v=h=>{h.disabled||(f(!0),h.onSelect())},u=()=>{var h;if(c){f(!1);return}g(((h=r.current)==null?void 0:h.closest("dialog"))??document.body),d(!0)};return e.jsxs("span",{className:"w6w-row-actions",onClick:h=>h.stopPropagation(),children:[e.jsx(p.IconButton,{ref:r,label:s,icon:"more-horizontal",onClick:u,disabled:n,className:"w6w-row-actions-trigger","aria-haspopup":"menu","aria-expanded":c,"aria-controls":c?o:void 0,"data-testid":a}),c&&m&&es.createPortal(e.jsx("div",{ref:l,id:o,className:"w6w-row-menu",role:"menu","aria-label":s,style:j?{top:j.top,left:j.left}:{top:0,left:0,visibility:"hidden"},onClick:h=>h.stopPropagation(),onKeyDown:h=>{var k;h.stopPropagation();const b=[...((k=l.current)==null?void 0:k.querySelectorAll("[role=menuitem]"))??[]],N=b.indexOf(document.activeElement),S=R=>{var A;return(A=b[(R+b.length)%b.length])==null?void 0:A.focus()};if(h.key==="ArrowDown")S(N+1);else if(h.key==="ArrowUp")S(N<0?-1:N-1);else if(h.key==="Home")S(0);else if(h.key==="End")S(-1);else if(h.key==="Escape")f(!0);else if(h.key==="Tab")f(!1);else if(h.key==="Enter"||h.key===" ")N>=0&&v(i[N]);else return;h.preventDefault()},children:i.map(h=>e.jsxs("button",{type:"button",role:"menuitem",tabIndex:-1,"aria-disabled":h.disabled||void 0,className:`w6w-row-menu-item${h.danger?" w6w-row-menu-item-danger":""}`,"data-testid":h["data-testid"],onClick:()=>v(h),children:[h.icon&&e.jsx(U.Icon,{name:h.icon,size:14}),e.jsx("span",{children:h.label})]},h.label))}),m)]})}function Kn(t){const{branch:s,shortSha:n,lastSyncLabel:a,onSyncNow:i,syncing:r,className:l,...o}=t,[c,d]=x.useState(!1),m=x.useRef(null);return x.useEffect(()=>{if(!c)return;const g=w=>{m.current&&!m.current.contains(w.target)&&d(!1)},j=w=>w.key==="Escape"&&d(!1);return document.addEventListener("mousedown",g),document.addEventListener("keydown",j),()=>{document.removeEventListener("mousedown",g),document.removeEventListener("keydown",j)}},[c]),e.jsxs("div",{className:`w6w-repo-sync${l?` ${l}`:""}`,ref:m,"data-testid":o["data-testid"],children:[e.jsxs("button",{type:"button",className:"w6w-repo-sync-trigger","aria-haspopup":"menu","aria-expanded":c,"aria-busy":r,onClick:()=>d(g=>!g),children:[e.jsxs("span",{className:"w6w-repo-sync-icon",children:[e.jsx(U.Icon,{name:"github"}),r&&e.jsx(U.Icon,{name:"sync",size:10,className:"w6w-repo-sync-spin"})]}),e.jsx("span",{className:"w6w-repo-sync-branch",children:s}),n!=null&&e.jsx("code",{className:"w6w-repo-sync-sha",children:n})]}),c&&e.jsxs("div",{className:"w6w-repo-sync-menu",role:"menu",children:[e.jsxs("div",{className:"w6w-repo-sync-detail",children:[e.jsx("span",{children:s}),n!=null&&e.jsx("code",{children:n}),a!=null&&e.jsx("span",{children:a})]}),e.jsx("button",{type:"button",role:"menuitem",className:"w6w-repo-sync-item","data-testid":"repo-sync-now",disabled:r,onClick:i,children:r?"Syncing…":"Sync now"})]})]})}const Vn={pending:"Pending",running:"Running",succeeded:"Succeeded",failed:"Failed",skipped:"Skipped",queued:"Queued",canceled:"Canceled"};function Se({state:t,label:s,ariaLabel:n}){const a=s??Vn[t];return e.jsxs("span",{className:`w6w-step-pill w6w-step-pill-${t}`,"aria-label":n,children:[e.jsx("span",{className:"w6w-step-pill-dot","aria-hidden":"true"}),e.jsx("span",{className:"w6w-step-pill-label",children:a})]})}const Jn="—",Qe=1e3,et=6e4;function Ue(t){return t==null||!Number.isFinite(t)||t<0?Jn:t<Qe?`${Math.round(t)} ms`:t<et?`${(t/Qe).toFixed(1)} s`:`${Math.floor(t/et)}m ${Math.round(t%et/Qe)}s`}function ye(t){const s=new Date(t);return Number.isNaN(s.getTime())?t:s.toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"})}const Hn={function:"Function",endpoint:"Endpoint",workflow:"Workflow"},qn={manual:"Manual",schedule:"Schedule",webhook:"Webhook",event:"Event",replay:"Replay"};function Bt(t){if(!t.trigger)return null;const s=qn[t.trigger]??t.trigger;return t.triggerNodeId?`${s} · ${t.triggerNodeId}`:s}function Yn({items:t,selectedId:s=null,onSelect:n,showCallable:a=!1,loading:i=!1,emptyLabel:r,hasPrev:l,hasNext:o,onPrev:c,onNext:d,onRerun:m,rerunningId:g=null}){const j=c||d?e.jsxs("div",{className:"w6w-execution-list-pager",children:[e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost","data-testid":"execution-list-prev",disabled:!l,onClick:c,children:"Previous"}),e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost","data-testid":"execution-list-next",disabled:!o,onClick:d,children:"Next"})]}):null;let w;return i&&t.length===0?w=e.jsx("p",{"data-testid":"execution-list-loading",children:"Loading…"}):t.length===0?w=e.jsx("p",{"data-testid":"execution-list-empty",children:r??"No executions yet."}):w=e.jsx("ul",{className:"w6w-execution-list-rows",children:t.map(f=>e.jsxs("li",{"data-testid":"execution-row","data-execution-id":f.id,children:[e.jsx(Oe,{icon:e.jsx(Se,{state:f.status}),title:e.jsxs(e.Fragment,{children:[a?f.callableName:ye(f.startedAt),f.rerunOf&&e.jsx("span",{className:"w6w-execution-rerun-tag","data-testid":"execution-row-rerun-tag",title:`Re-run of ${f.rerunOf}`,children:"Re-run"})]}),subtitle:e.jsxs(e.Fragment,{children:[a?`${Hn[f.kind]} · ${ye(f.startedAt)}`:f.id,Bt(f)&&e.jsx("span",{className:"w6w-execution-trigger","data-testid":"execution-row-trigger",children:` · ${Bt(f)}`}),f.inputPreview&&e.jsxs(e.Fragment,{children:[" · ",e.jsx("code",{className:"w6w-execution-input-preview","data-testid":"execution-row-input",title:f.inputPreview,children:f.inputPreview})]})]}),trailing:Ue(f.durationMs),active:f.id===s,onClick:n?()=>n(f.id):void 0}),m&&e.jsx(p.IconButton,{icon:"sync",label:"Re-run",title:f.id===g?"Re-running…":"Re-run with the same input",className:"w6w-execution-list-rerun","data-testid":"execution-row-rerun",disabled:g!==null,onClick:()=>m(f.id)})]},f.id))}),e.jsxs("div",{className:"w6w-execution-list","data-testid":"execution-list",children:[w,j]})}function ut(t){const s=p.internalNodeDef(t.app,t.action);return{trigger:t.trigger===!0||(s==null?void 0:s.group)==="trigger",appName:t.appName??(s==null?void 0:s.displayName)??t.app,actionName:t.actionName??(s==null?void 0:s.label)??t.action}}function wt(t){const s=n=>{for(const a of[n.startedAt,n.finishedAt]){const i=Date.parse(a??"");if(Number.isFinite(i))return i}return Number.POSITIVE_INFINITY};return t.map(n=>({step:n,time:s(n)})).sort((n,a)=>n.time===a.time?0:n.time-a.time).map(({step:n})=>n)}function rs({steps:t,emptyLabel:s,onDismiss:n,runError:a,stepErrors:i}){const r=n?e.jsx("div",{className:"w6w-execution-log-head",children:e.jsx(p.IconButton,{label:"Dismiss run log","data-testid":"execution-log-dismiss",onClick:n,children:"×"})}):null,l=i??[],o=a||l.length>0?e.jsxs("div",{className:"w6w-execution-log-errors w6w-stack",children:[a&&e.jsx(he,{error:a}),l.map((g,j)=>e.jsx(he,{label:g.label??g.stepId,error:g.error},`${g.stepId}:${j}`))]}):null,c=wt(t.filter(g=>!De(g))),d=t.filter(De),m=d.length>0?e.jsx(at,{steps:d}):null;return c.length===0?e.jsxs(e.Fragment,{children:[r,o,e.jsx("div",{className:"w6w-execution-log-empty",children:e.jsx("p",{className:"w6w-muted w6w-small",children:s??"No nodes have run yet."})}),m]}):e.jsxs(e.Fragment,{children:[r,o,e.jsx("ol",{className:"w6w-execution-log",children:c.map(g=>e.jsx(cs,{step:g},g.id))}),m]})}const De=t=>t.status==="skipped"&&t.skipReason==="not_on_path",os={condition:"condition false",stopped:"run stopped",disabled:"disabled"};function at({steps:t}){const s=t.length;return e.jsxs("details",{className:"w6w-execution-log-off-path","data-testid":"execution-log-off-path",children:[e.jsx("summary",{className:"w6w-muted w6w-small",children:`${s} ${s===1?"step":"steps"} on other paths, not part of this run`}),e.jsx("ul",{className:"w6w-muted w6w-small",children:t.map(n=>e.jsx("li",{children:n.label??n.id},n.id))})]})}function cs({step:t,defaultOpen:s=!1}){var d,m;const[n,a]=x.useState(s),i=t.node?ut(t.node):null,r=e.jsxs("div",{className:"w6w-execution-log-row-header",children:[e.jsx(Se,{state:t.status}),i&&e.jsx("span",{className:`w6w-execution-log-kind${i.trigger?" w6w-execution-log-kind-trigger":""}`,"data-testid":"execution-log-kind",children:i.trigger?"Trigger":"Node"}),e.jsxs("span",{className:"w6w-execution-log-row-title",children:[e.jsx("span",{className:"w6w-execution-log-row-label",children:t.label??t.id}),i&&e.jsx("span",{className:"w6w-execution-log-row-uses","data-testid":"execution-log-uses",children:i.appName===i.actionName?i.appName:`${i.appName} · ${i.actionName}`})]}),t.status==="skipped"&&t.skipReason&&t.skipReason!=="not_on_path"&&e.jsx("span",{className:"w6w-execution-log-skip-reason","data-testid":"execution-log-skip-reason",children:os[t.skipReason]}),e.jsx(Gn,{startedAt:t.startedAt,finishedAt:t.finishedAt})]}),l=t.error?e.jsx(he,{error:t.error}):null,o=Array.isArray(t.iterations)?e.jsx(ds,{step:t}):null,c=ws(t)?e.jsx(ms,{step:t}):null;return t.input===void 0&&t.output===void 0&&!t.meta&&!c&&!((d=t.logs)!=null&&d.length)?e.jsxs("li",{className:"w6w-execution-log-row",children:[e.jsx("div",{className:"w6w-section",children:r}),l,o]}):e.jsxs("li",{className:"w6w-execution-log-row",children:[e.jsxs("details",{className:"w6w-section",open:n,onToggle:g=>a(g.currentTarget.open),children:[e.jsx("summary",{className:"w6w-section-summary",children:r}),n&&e.jsxs("div",{className:"w6w-execution-log-row-body w6w-section-body w6w-stack",children:[e.jsx(us,{input:t.input}),e.jsx(Me,{title:"Input",value:t.input,defaultOpen:s}),e.jsx(Me,{title:"Output",value:t.output,defaultOpen:s}),!!((m=t.logs)!=null&&m.length)&&e.jsxs("div",{className:"w6w-execution-log-json w6w-stack",children:[e.jsx("strong",{className:"w6w-small",children:"Console"}),e.jsx(U.CodeBlock,{code:t.logs.join(`
2
- `),language:"plaintext"})]}),t.meta&&e.jsxs("div",{className:"w6w-execution-log-json w6w-stack",children:[e.jsx("strong",{className:"w6w-small",children:"Metadata"}),e.jsx(U.CodeBlock,{code:JSON.stringify(t.meta,null,2),language:"json"})]}),c]})]}),l,o]})}function ds({step:t}){var f,v;const s=[...t.iterations??[]].sort((u,h)=>u.index-h.index),n=t.iterationsTotal??s.length,a=t.iterationsFailed??s.filter(u=>u.status==="failed").length,i=s.find(u=>u.status==="failed"),r=(i==null?void 0:i.index)??((f=s[s.length-1])==null?void 0:f.index),[l,o]=x.useState(r),[c,d]=x.useState(!1),m=s.find(u=>u.index===l),g=[],j=new Map;for(const u of wt(s.flatMap(h=>h.steps)))j.has(u.id)||(g.push(u.id),j.set(u.id,u.label??u.id));const w=(i==null?void 0:i.failedNodeId)??((v=i==null?void 0:i.steps.find(u=>u.status==="failed"))==null?void 0:v.id);return e.jsxs("div",{className:"w6w-execution-log-foreach w6w-stack",children:[e.jsxs("div",{className:"w6w-small","data-testid":"execution-log-foreach-summary",children:[e.jsxs("span",{children:[n===1?"1 item":`${n} items`,a>0?` · ${a} failed`:""]}),i&&w!==void 0&&e.jsxs("div",{children:[j.get(w)??w," failed in iteration ",i.index]}),t.iterationsTruncated===!0&&e.jsx("div",{className:"w6w-muted",children:`showing ${s.length} of ${n}`})]}),e.jsx("div",{className:"w6w-execution-log-iteration-chips",children:s.map(u=>e.jsxs("button",{type:"button",className:`w6w-execution-log-iteration-chip w6w-execution-log-iteration-chip-${u.status}`,"data-testid":"execution-log-iteration-chip","data-status":u.status,"aria-pressed":l===u.index,title:`Show iteration ${u.index}'s input and output`,onClick:()=>{o(u.index),d(!0)},children:[u.index," · ",u.status]},u.index))}),m&&e.jsx("div",{className:"w6w-small w6w-muted","data-testid":"execution-log-iteration-current",children:`Iteration ${m.index} · ${m.status}`}),e.jsx("ul",{className:"w6w-execution-log-subrows",children:g.map(u=>e.jsx(zn,{id:u,label:j.get(u)??u,iterations:s,selected:l,open:c,onSelect:o},u))})]})}function zn({id:t,label:s,iterations:n,selected:a,open:i,onSelect:r}){var o;const l=(o=n.find(c=>c.index===a))==null?void 0:o.steps.find(c=>c.id===t);return e.jsxs("li",{className:"w6w-execution-log-subrow w6w-stack",children:[e.jsxs("div",{className:"w6w-execution-log-subrow-head",children:[e.jsx("strong",{className:"w6w-small",children:s}),e.jsx("select",{className:"w6w-select","aria-label":`Iteration for ${s}`,"data-testid":"execution-log-iteration-select",value:a===void 0?"":String(a),onChange:c=>r(Number(c.currentTarget.value)),children:n.map(c=>e.jsx("option",{value:String(c.index),children:`iteration ${c.index} (${c.status})`},c.index))})]}),l?e.jsx("ol",{className:"w6w-execution-log",children:e.jsx(cs,{step:l,defaultOpen:i},`${a}:${i}`)}):e.jsx("p",{className:"w6w-muted w6w-small",children:"Did not run in this iteration."})]})}function he({error:t,label:s}){return e.jsxs("div",{className:"w6w-result w6w-error",children:[s!==void 0&&e.jsx("strong",{className:"w6w-execution-log-error-label",children:s}),t.code&&e.jsx("div",{className:"w6w-small w6w-execution-log-error-code",children:e.jsx("code",{children:t.code})}),t.message]})}function Gn({startedAt:t,finishedAt:s}){if(t&&s){const n=mt(t,s);return e.jsxs("span",{className:"w6w-execution-log-timing",children:[t," → ",s,n&&e.jsxs("span",{children:[" (",n,")"]})]})}return t?e.jsxs("span",{className:"w6w-execution-log-timing",children:["Started ",t]}):e.jsx("span",{className:"w6w-execution-log-timing",children:"—"})}function mt(t,s){const n=Date.parse(t),a=Date.parse(s);if(!Number.isFinite(n)||!Number.isFinite(a)||a<n)return null;const i=a-n;if(i<1e3)return`${i}ms`;const r=i/1e3;if(r<60)return`${r.toFixed(1)}s`;const l=Math.floor(r/60),o=Math.round(r%60);return`${l}m ${o}s`}function Me({title:t,value:s,defaultOpen:n=!1}){const[a,i]=x.useState(n);return s===void 0?e.jsxs("div",{className:"w6w-execution-log-json w6w-stack",children:[e.jsx("strong",{className:"w6w-small",children:t}),e.jsx("p",{className:"w6w-muted w6w-small",children:"Not available."})]}):e.jsxs("details",{className:"w6w-execution-log-json",open:a,onToggle:r=>{r.target===r.currentTarget&&i(r.currentTarget.open)},children:[e.jsx("summary",{children:e.jsx("strong",{className:"w6w-small",children:t})}),a&&e.jsx(p.ResultViewer,{value:s,format:"json"})]})}const Be=t=>typeof t=="object"&&t!==null&&!Array.isArray(t);function Ft(t){if(!Be(t)||!Array.isArray(t.conditions))return;const s=t.conditions.filter(n=>Be(n)&&typeof n.op=="string"&&"result"in n);if(s.length!==0)return{rows:s,combinator:typeof t.combinator=="string"?t.combinator:void 0,result:typeof t.condition=="boolean"?t.condition:void 0}}function us({input:t}){const s=[],n=Ft(t);if(n&&s.push({trace:n}),Be(t)&&Array.isArray(t.routes))for(const a of t.routes){const i=Ft(a);!i||!Be(a)||s.push({title:String(a.label??a.id??"Route"),trace:i})}return s.length===0?null:e.jsxs("div",{className:"w6w-execution-log-json w6w-stack","data-testid":"execution-log-conditions",children:[e.jsx("strong",{className:"w6w-small",children:"Condition"}),s.map(({title:a,trace:i},r)=>e.jsxs("div",{className:"w6w-stack",children:[a&&e.jsx("span",{className:"w6w-small w6w-muted",children:a}),(i.combinator&&i.rows.length>1||i.result!==void 0)&&e.jsxs("span",{className:"w6w-small w6w-muted","data-testid":"execution-log-condition-summary",children:[i.combinator&&i.rows.length>1&&p.conditionCombinatorLabel(i.combinator),i.combinator&&i.rows.length>1&&i.result!==void 0&&" · ",i.result!==void 0&&e.jsxs(e.Fragment,{children:["Result:"," ",e.jsx("span",{className:i.result?"w6w-execution-log-condition-true":"w6w-execution-log-condition-false",children:i.result?"true":"false"})]})]}),e.jsx("div",{className:"w6w-data-table-frame",children:e.jsxs("table",{className:"w6w-data-table w6w-execution-log-conditions",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Left"}),e.jsx("th",{children:"Operator"}),e.jsx("th",{children:"Right"}),e.jsx("th",{children:"Result"})]})}),e.jsx("tbody",{children:i.rows.map((l,o)=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("code",{children:Ut(l.left)})}),e.jsx("td",{children:p.conditionOperatorLabel(l.op)}),e.jsx("td",{children:e.jsx("code",{children:Ut(l.right)})}),e.jsx("td",{className:l.result?"w6w-execution-log-condition-true":"w6w-execution-log-condition-false",children:l.result?"true":"false"})]},o))})]})})]},a??r))]})}function Ut(t){return JSON.stringify(t)??"undefined"}const Wt={not_object:"Not written — the output isn't an object, so it can't be merged at the root",missing_source:"Not written — the output has no value at that field",null_append:"Not appended — the value was null",append_not_array:"Not appended — the existing value isn't a list",write_too_large:"Not written — the value is too large",run_too_large:"Not written — the run's state would grow past its size limit",too_deep:"Not written — the value is nested too deeply",key_too_long:"Not written — a key in the value is too long",forbidden_key:"Not written — the value uses a reserved key name",log_truncated:"Later state changes aren't shown — the run's state log reached its limit"};function Xn(t){return Object.hasOwn(Wt,t)?Wt[t]:t}function ws(t){const s=Array.isArray(t.stateWrites)&&t.stateWrites.length>0,n=t.stateAfter;return s||typeof n=="object"&&n!==null&&Object.keys(n).length>0}const Kt=120;function Vt(t){if(t===void 0)return"(not set)";const s=JSON.stringify(t)??String(t);return s.length>Kt?`${s.slice(0,Kt)}…`:s}function ms({step:t}){const s=Array.isArray(t.stateWrites)?t.stateWrites:[],n=t.stateAfter;return e.jsxs("div",{className:"w6w-execution-log-state w6w-stack","data-testid":"execution-log-state",children:[e.jsx("strong",{className:"w6w-small",children:"State"}),s.length>0&&e.jsx("ul",{className:"w6w-execution-log-state-writes",children:s.map((a,i)=>{const r=Array.isArray(a.path)?a.path:[],l=`state${r.length?`.${r.join(".")}`:""}${a.item!==void 0?` (item ${a.item})`:""}`;return a.warning!==void 0?e.jsx("li",{className:"w6w-execution-log-state-write w6w-execution-log-state-warning w6w-small","data-testid":"execution-log-state-write","data-warning":a.warning,children:`${l}: ${Xn(a.warning)}`},i):e.jsx("li",{className:"w6w-execution-log-state-write w6w-small","data-testid":"execution-log-state-write",children:`${l}: ${Vt(a.old)} → ${Vt(a.new)}`},i)})}),typeof n=="object"&&n!==null&&e.jsxs("div",{className:"w6w-stack","data-testid":"execution-log-state-after",children:[e.jsx("span",{className:"w6w-small w6w-muted",children:"State after this step"}),e.jsx(U.CodeBlock,{code:JSON.stringify(n,null,2),language:"json"})]})]})}function Zn(t){return t.find(s=>s.status==="failed")??[...t].reverse().find(s=>s.status==="running")??t[t.length-1]}function Qn({steps:t,emptyLabel:s,runError:n,stepErrors:a,selectedStepId:i,onSelectStep:r}){const[l,o]=x.useState(null),c=x.useRef(null),d=wt(t.filter(h=>!De(h))),m=t.filter(De),g=i!==void 0?i:l,j=d.find(h=>h.id===g)??Zn(d),w=h=>{o(h),r==null||r(h)},f=h=>{var S,k;if(h.key!=="ArrowDown"&&h.key!=="ArrowUp")return;h.preventDefault();const b=d.findIndex(R=>R.id===(j==null?void 0:j.id)),N=d[Math.min(Math.max(b+(h.key==="ArrowDown"?1:-1),0),d.length-1)];N&&(w(N.id),(k=(S=c.current)==null?void 0:S.querySelector(`[data-step-id="${CSS.escape(N.id)}"]`))==null||k.focus())},v=a??[],u=n||v.length>0?e.jsxs("div",{className:"w6w-log-view-errors w6w-stack",children:[n&&e.jsx(he,{error:n}),v.map((h,b)=>e.jsx(he,{label:h.label??h.stepId,error:h.error},`${h.stepId}:${b}`))]}):null;return d.length===0?e.jsxs("div",{className:"w6w-log-view w6w-log-view-is-empty","data-testid":"execution-log-view",children:[u,e.jsx("div",{className:"w6w-execution-log-empty",children:e.jsx("p",{className:"w6w-muted w6w-small",children:s??"No nodes have run yet."})}),m.length>0&&e.jsx(at,{steps:m})]}):e.jsxs("div",{className:"w6w-log-view","data-testid":"execution-log-view",children:[u,e.jsxs("div",{className:"w6w-log-view-cols",children:[e.jsxs("div",{className:"w6w-log-view-list-col",children:[e.jsx("ul",{ref:c,className:"w6w-log-view-list","aria-label":"Steps of this run",onKeyDown:f,children:d.map(h=>e.jsx(ea,{step:h,selected:h.id===(j==null?void 0:j.id),onSelect:()=>w(h.id)},h.id))}),m.length>0&&e.jsx(at,{steps:m})]}),e.jsx("div",{className:"w6w-log-view-detail-col","data-testid":"execution-log-detail",children:j&&e.jsx(sa,{step:j},j.id)})]})]})}function ea({step:t,selected:s,onSelect:n}){const a=t.node?ut(t.node):null,i=t.startedAt&&t.finishedAt?mt(t.startedAt,t.finishedAt):t.status==="running"?"running…":null;return e.jsx("li",{children:e.jsxs("button",{type:"button",className:`w6w-log-view-item${s?" w6w-log-view-item-selected":""}`,"aria-current":s?"true":void 0,"data-step-id":t.id,"data-status":t.status,"data-testid":"execution-log-item",onClick:n,children:[e.jsx("span",{className:`w6w-step-pill-${t.status} w6w-log-view-dot`,role:"img","aria-label":t.status,title:t.status}),e.jsxs("span",{className:"w6w-log-view-item-title",children:[e.jsx("span",{className:"w6w-log-view-item-label",children:t.label??t.id}),a&&e.jsxs("span",{className:"w6w-log-view-item-uses",children:[a.trigger?"Trigger · ":"",a.appName===a.actionName?a.appName:`${a.appName} · ${a.actionName}`]})]}),i&&e.jsx("span",{className:"w6w-log-view-item-time",children:i})]})})}function ta(t){const s=new Date(t);if(!Number.isFinite(s.getTime()))return t;const n=(a,i=2)=>String(a).padStart(i,"0");return`${n(s.getHours())}:${n(s.getMinutes())}:${n(s.getSeconds())}.${n(s.getMilliseconds(),3)}`}function Jt({iso:t}){if(!t)return e.jsx("span",{className:"w6w-muted",children:"—"});const s=new Date(t);return e.jsx("time",{dateTime:t,title:Number.isFinite(s.getTime())?s.toString():t,children:ta(t)})}function sa({step:t}){var a;const s=t.node?ut(t.node):null,n=t.startedAt&&t.finishedAt?mt(t.startedAt,t.finishedAt):null;return e.jsxs("div",{className:"w6w-log-view-detail w6w-stack",children:[e.jsxs("div",{className:"w6w-log-view-detail-head",children:[e.jsxs("div",{className:"w6w-log-view-detail-title",children:[e.jsx("strong",{children:t.label??t.id}),s&&e.jsxs("span",{className:"w6w-muted w6w-small",children:[s.trigger?"Trigger · ":"",s.appName===s.actionName?s.appName:`${s.appName} · ${s.actionName}`]})]}),e.jsx(Se,{state:t.status}),t.status==="skipped"&&t.skipReason&&t.skipReason!=="not_on_path"&&e.jsx("span",{className:"w6w-execution-log-skip-reason",children:os[t.skipReason]})]}),e.jsxs("dl",{className:"w6w-log-view-timing","data-testid":"execution-log-timing",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Started"}),e.jsx("dd",{children:e.jsx(Jt,{iso:t.startedAt})})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Finished"}),e.jsx("dd",{children:e.jsx(Jt,{iso:t.finishedAt})})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Elapsed"}),e.jsx("dd",{children:n??(t.status==="running"?"running…":"—")})]})]}),t.error&&e.jsx(he,{error:t.error}),Array.isArray(t.iterations)&&e.jsx(ds,{step:t}),e.jsx(us,{input:t.input}),e.jsxs("div",{className:"w6w-log-view-io",children:[e.jsx(Me,{title:"Input",value:t.input,defaultOpen:!0}),e.jsx(Me,{title:"Output",value:t.output,defaultOpen:!0})]}),!!((a=t.logs)!=null&&a.length)&&e.jsxs("div",{className:"w6w-execution-log-json w6w-stack",children:[e.jsx("strong",{className:"w6w-small",children:"Console"}),e.jsx(U.CodeBlock,{code:t.logs.join(`
3
- `),language:"plaintext"})]}),t.meta&&e.jsxs("div",{className:"w6w-execution-log-json w6w-stack",children:[e.jsx("strong",{className:"w6w-small",children:"Metadata"}),e.jsx(U.CodeBlock,{code:JSON.stringify(t.meta,null,2),language:"json"})]}),ws(t)&&e.jsx(ms,{step:t})]})}const hs=120,ps=()=>Math.round((typeof window<"u"?window.innerHeight:800)*.85),ge=t=>Math.min(Math.max(t,hs),ps());function na({children:t,open:s,onOpenChange:n,title:a="Logs",summary:i,onClear:r,defaultHeight:l=320,windowClassName:o,windowTitle:c="Logs",barActions:d,"data-testid":m="execution-log-dock"}){const g=x.useId(),[j,w]=x.useState("docked"),[f,v]=x.useState(()=>ge(l)),[u,h]=x.useState(null),b=x.useRef(null),N=x.useRef(null),S=x.useCallback(()=>{const P=b.current;b.current=null,h(null),P&&!P.closed&&P.close()},[]);x.useEffect(()=>S,[S]);const k=x.useCallback(()=>{S(),w("docked"),n(!0)},[S,n]),R=()=>{var F,C;const P=((C=(F=N.current)==null?void 0:F.closest("[data-theme]"))==null?void 0:C.getAttribute("data-theme"))??void 0,T=aa(c,o,P);if(!T){w("floating"),n(!0);return}b.current=T.window,h(T.host),w("window"),n(!0),T.window.addEventListener("pagehide",()=>{b.current===T.window&&(b.current=null,h(null),w("docked"))})},A=P=>{var W;P.preventDefault();const T=P.clientY,F=f,C=P.currentTarget;(W=C.setPointerCapture)==null||W.call(C,P.pointerId);const B=Q=>v(ge(F+(T-Q.clientY))),I=()=>{C.removeEventListener("pointermove",B),C.removeEventListener("pointerup",I),C.removeEventListener("pointercancel",I)};C.addEventListener("pointermove",B),C.addEventListener("pointerup",I),C.addEventListener("pointercancel",I)},D=P=>{const T=P.shiftKey?64:16;if(P.key==="ArrowUp")v(F=>ge(F+T));else if(P.key==="ArrowDown")v(F=>ge(F-T));else return;P.preventDefault()},_=j==="docked",V=s&&_,M=e.jsx("div",{id:g,className:"w6w-log-dock-body",hidden:!s,style:_?{height:f}:void 0,children:t});return e.jsxs("div",{ref:N,className:`w6w-log-dock w6w-log-dock-${j}${V?" w6w-log-dock-open":""}`,"data-testid":m,"data-mode":j,children:[V&&e.jsx("div",{className:"w6w-log-dock-resize",role:"separator","aria-orientation":"horizontal","aria-label":"Resize log","aria-valuenow":f,"aria-valuemin":hs,"aria-valuemax":ps(),tabIndex:0,onPointerDown:A,onKeyDown:D,onDoubleClick:()=>v(ge(l))}),e.jsxs("div",{className:"w6w-log-dock-bar",children:[e.jsxs("button",{type:"button",className:"w6w-log-dock-toggle","aria-expanded":s&&_,"aria-controls":g,"data-testid":"execution-log-dock-toggle",onClick:()=>_?n(!s):k(),children:[e.jsx(U.Icon,{name:s&&_?"chevron-down":"chevron-up",size:14}),e.jsx("span",{className:"w6w-log-dock-title",children:a})]}),i!==void 0&&e.jsx("div",{className:"w6w-log-dock-summary",children:i}),e.jsxs("div",{className:"w6w-log-dock-actions",children:[d,r&&e.jsx(p.IconButton,{icon:"trash",label:"Clear log","data-testid":"execution-log-dismiss",onClick:r}),_?e.jsx(p.IconButton,{icon:"external-link",label:"Open log in a separate window","data-testid":"execution-log-popout",onClick:R}):e.jsx(p.IconButton,{icon:"panel-bottom",label:"Dock log to the bottom","data-testid":"execution-log-dock-back",onClick:k})]})]}),j==="docked"&&M,j==="floating"&&e.jsx(ia,{title:a,onDock:k,onClose:()=>{w("docked"),n(!1)},children:M}),j==="window"&&u&&es.createPortal(M,u)]})}function aa(t,s,n){if(typeof window>"u"||typeof window.open!="function")return null;let a=null;try{a=window.open("","","popup,width=960,height=640")}catch{return null}if(!(a!=null&&a.document))return null;const i=a.document;i.title=t;for(const l of Array.from(document.querySelectorAll('link[rel="stylesheet"], style'))){const o=l.cloneNode(!0);o.tagName==="LINK"&&(o.href=l.href),i.head.appendChild(o)}for(const l of Array.from(document.documentElement.attributes))(l.name==="class"||l.name==="style"||l.name.startsWith("data-"))&&i.documentElement.setAttribute(l.name,l.value);i.body.className="w6w-log-window-body";const r=i.createElement("div");return r.className=["w6w-log-window",s].filter(Boolean).join(" "),n&&(r.setAttribute("data-theme",n),i.body.setAttribute("data-theme",n)),i.body.appendChild(r),{window:a,host:r}}function ia({title:t,children:s,onDock:n,onClose:a}){const[i,r]=x.useState({right:24,bottom:56}),l=o=>{var j;if(o.target.closest("button"))return;o.preventDefault();const c={x:o.clientX,y:o.clientY,...i},d=o.currentTarget;(j=d.setPointerCapture)==null||j.call(d,o.pointerId);const m=w=>r({right:Math.max(0,c.right-(w.clientX-c.x)),bottom:Math.max(0,c.bottom-(w.clientY-c.y))}),g=()=>{d.removeEventListener("pointermove",m),d.removeEventListener("pointerup",g)};d.addEventListener("pointermove",m),d.addEventListener("pointerup",g)};return e.jsxs("section",{className:"w6w-log-float","aria-label":typeof t=="string"?t:"Logs",style:{right:i.right,bottom:i.bottom},"data-testid":"execution-log-float",children:[e.jsxs("div",{className:"w6w-log-float-head",onPointerDown:l,children:[e.jsx("strong",{className:"w6w-small",children:t}),e.jsxs("div",{className:"w6w-log-dock-actions",children:[e.jsx(p.IconButton,{icon:"panel-bottom",label:"Dock log to the bottom",onClick:n}),e.jsx(p.IconButton,{icon:"close",label:"Close log",onClick:a})]})]}),s]})}const la={status:"",kind:"",from:"",to:"",q:""},ra=[{value:"",label:"Any status"},{value:"queued",label:"Queued"},{value:"running",label:"Running"},{value:"succeeded",label:"Succeeded"},{value:"failed",label:"Failed"},{value:"canceled",label:"Canceled"}],oa=[{value:"",label:"Any type"},{value:"function",label:"Function"},{value:"endpoint",label:"Endpoint"},{value:"workflow",label:"Workflow"}];function ca({value:t,onChange:s,showKind:n=!1,searchPlaceholder:a="Search by id or name",disabled:i=!1}){const r=t.status!==""||t.kind!==""||t.from!==""||t.to!==""||t.q!=="";return e.jsxs("div",{className:"w6w-execution-filters","data-testid":"execution-filters",children:[e.jsx("input",{type:"search",className:"w6w-execution-filters-search","data-testid":"execution-filter-q","aria-label":"Search executions",placeholder:a,value:t.q,disabled:i,onChange:l=>s({...t,q:l.target.value})}),e.jsx("select",{className:"w6w-execution-filters-select","data-testid":"execution-filter-status","aria-label":"Status",value:t.status,disabled:i,onChange:l=>s({...t,status:l.target.value}),children:ra.map(l=>e.jsx("option",{value:l.value,children:l.label},l.value))}),n&&e.jsx("select",{className:"w6w-execution-filters-select","data-testid":"execution-filter-kind","aria-label":"Type",value:t.kind,disabled:i,onChange:l=>s({...t,kind:l.target.value}),children:oa.map(l=>e.jsx("option",{value:l.value,children:l.label},l.value))}),e.jsx("input",{type:"date",className:"w6w-execution-filters-date","data-testid":"execution-filter-from","aria-label":"From date",value:t.from,disabled:i,onChange:l=>s({...t,from:l.target.value})}),e.jsx("input",{type:"date",className:"w6w-execution-filters-date","data-testid":"execution-filter-to","aria-label":"To date",value:t.to,disabled:i,onChange:l=>s({...t,to:l.target.value})}),r&&e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-execution-filters-clear","data-testid":"execution-filter-clear",disabled:i,onClick:()=>s({...la}),children:"Clear"})]})}const Le="—";function da({stats:t,label:s}){const n=[{testid:"execution-stat-total",label:"Executions",value:t?String(t.total):Le},{testid:"execution-stat-success-rate",label:"Success rate",value:ua(t==null?void 0:t.successRate)},{testid:"execution-stat-failed",label:"Failed",value:t?String(t.failed):Le},{testid:"execution-stat-avg-duration",label:"Avg duration",value:t?Ue(t.avgDurationMs):Le}];return t&&t.inFlight>0&&n.push({testid:"execution-stat-in-flight",label:"In flight",value:String(t.inFlight)}),e.jsxs("section",{className:"w6w-execution-stats","data-testid":"execution-stats",children:[s!=null&&e.jsx("p",{className:"w6w-execution-stats-label",children:s}),e.jsx("div",{className:"w6w-execution-stats-cards",children:n.map(a=>e.jsxs("div",{className:"w6w-execution-stat","data-testid":a.testid,children:[e.jsx("span",{className:"w6w-execution-stat-value","data-stat-value":a.value,children:a.value}),e.jsx("span",{className:"w6w-execution-stat-label",children:a.label})]},a.testid))})]})}function ua(t){return t==null||!Number.isFinite(t)?Le:`${Math.round(t*100)}%`}const wa={function:"Function",endpoint:"Endpoint",workflow:"Workflow"};function ma(t){return JSON.stringify(t,null,2)??"null"}function ha({execution:t,loading:s=!1,errorMessage:n,onClose:a,onOpenInEditor:i,onBack:r,onRerun:l,rerunning:o=!1,onOpenExecution:c}){return e.jsxs("section",{className:"w6w-execution-detail w6w-stack","data-testid":"execution-detail",children:[r&&e.jsx("div",{className:"w6w-execution-detail-back",children:e.jsxs("button",{type:"button",className:"w6w-btn w6w-btn-ghost","data-testid":"execution-detail-back",onClick:r,children:[e.jsx("span",{"aria-hidden":"true",children:"←"})," Back"]})}),n!=null&&e.jsx("p",{role:"alert",className:"w6w-execution-detail-error-message","data-testid":"execution-detail-error-message",children:n}),t?e.jsx(pa,{execution:t,onClose:a,onOpenInEditor:i,onRerun:l,rerunning:o,onOpenExecution:c}):s?e.jsx("p",{className:"w6w-muted","data-testid":"execution-detail-loading",children:"Loading…"}):e.jsx("p",{className:"w6w-muted","data-testid":"execution-detail-empty",children:"No execution selected."})]})}function pa({execution:t,onClose:s,onOpenInEditor:n,onRerun:a,rerunning:i,onOpenExecution:r}){const l=t.rerunOf;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"w6w-execution-detail-head",children:[e.jsxs("div",{className:"w6w-execution-detail-title",children:[e.jsx("h3",{className:"w6w-execution-detail-name",children:t.callableName}),e.jsxs("div",{className:"w6w-execution-detail-meta",children:[e.jsx(Se,{state:t.status}),e.jsx("span",{className:"w6w-execution-detail-kind w6w-muted w6w-small",children:wa[t.kind]})]})]}),(a||n||s)&&e.jsxs("div",{className:"w6w-execution-detail-actions",children:[a&&e.jsxs("button",{type:"button",className:"w6w-btn w6w-execution-detail-rerun","data-testid":"execution-detail-rerun",title:"Run it again with the same input",disabled:i,onClick:a,children:[e.jsx(U.Icon,{name:"sync",size:14})," ",i?"Re-running…":"Re-run"]}),n&&e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost","data-testid":"execution-detail-open-editor",onClick:n,children:"Open in visual editor"}),s&&e.jsx(p.IconButton,{label:"Close","data-testid":"execution-detail-close",onClick:s,children:"×"})]})]}),e.jsx("p",{className:"w6w-execution-detail-id-line",children:e.jsx("code",{className:"w6w-execution-detail-id","data-testid":"execution-detail-id",children:t.id})}),l&&e.jsxs("p",{className:"w6w-execution-detail-rerun-of","data-testid":"execution-detail-rerun-of",children:[e.jsx("span",{className:"w6w-execution-rerun-tag",children:"Re-run"}),e.jsx("span",{className:"w6w-muted w6w-small",children:"of"}),r?e.jsx("button",{type:"button",className:"w6w-execution-detail-rerun-of-link","data-testid":"execution-detail-rerun-of-link",onClick:()=>r(l),children:e.jsx("code",{children:l})}):e.jsx("code",{children:l})]}),e.jsxs("dl",{className:"w6w-execution-detail-timing",children:[e.jsx(tt,{label:"Started",value:ye(t.startedAt)}),e.jsx(tt,{label:"Finished",value:t.finishedAt?ye(t.finishedAt):"—"}),e.jsx(tt,{label:"Duration",value:Ue(t.durationMs)})]}),t.steps!==void 0&&e.jsxs("section",{className:"w6w-execution-detail-section w6w-stack","data-testid":"execution-detail-steps",children:[e.jsx("strong",{className:"w6w-small",children:"Nodes"}),e.jsx(rs,{steps:t.steps,emptyLabel:"No nodes ran."})]}),t.input!==void 0&&e.jsx(st,{title:"Input",testid:"execution-detail-input",value:t.input}),t.output!==void 0&&e.jsx(st,{title:"Output",testid:"execution-detail-output",value:t.output}),t.error!=null&&e.jsx(st,{title:"Error",testid:"execution-detail-error",value:t.error})]})}function tt({label:t,value:s}){return e.jsxs("div",{className:"w6w-execution-detail-timing-item",children:[e.jsx("dt",{children:t}),e.jsx("dd",{children:s})]})}function st({title:t,testid:s,value:n}){return e.jsxs("section",{className:"w6w-execution-detail-section w6w-stack","data-testid":s,children:[e.jsx("strong",{className:"w6w-small",children:t}),e.jsx(U.CodeBlock,{code:ma(n),language:"json"})]})}function fs(t){const s=[];for(const n of t)n.p95Ms!==null&&s.push({appId:n.appId,displayName:n.displayName,calls:n.calls,p95Ms:n.p95Ms,state:n.state,errorCount:n.errors.e4xx+n.errors.e429+n.errors.eAuth+n.errors.e5xx});return s}function fa(t){return t.attention==="now"||t.attention==="recent"}function xs(t){const s={now:[],recent:[],clear:[]};for(const n of t)n.attention==="now"?s.now.push(n):n.attention==="recent"?s.recent.push(n):s.clear.push(n);return s}function gs(t){return t.uptime.map(s=>({day:s.day,state:s.state}))}const it=3,vs=5;function js(t,s={}){const n=s.compact??!1,{now:a,recent:i}=xs(t),r=a.length+i.length,l=n?a.slice(0,it):a,o=n?i.slice(0,Math.max(0,it-l.length)):i,c=n?t.slice(0,s.limit??vs):[...t];return{attentionCount:r,shownNow:l,shownRecent:o,hiddenAttentionCount:r-l.length-o.length,shownTable:c,hiddenTableCount:t.length-c.length}}const Te=640,ve=340,G={top:16,right:24,bottom:40,left:56};function Ht(t){if(t<=0)return 1;const s=10**Math.floor(Math.log10(t)),n=[1,2,5,10];for(const a of n)if(t<=a*s)return a*s;return 10*s}function qt(t,s=5){return Array.from({length:s+1},(n,a)=>Math.round(t*a/s))}function bs({services:t,getHref:s,onOpen:n}){const a=fs(t);if(a.length===0)return e.jsx("p",{className:"w6w-muted w6w-small",children:"No timed calls in this window yet."});const i=Ht(Math.max(...a.map(u=>u.calls))),r=Ht(Math.max(...a.map(u=>u.p95Ms))),l=Math.max(1,...a.map(u=>u.errorCount)),o=Te-G.left-G.right,c=ve-G.top-G.bottom,d=u=>G.left+u/i*o,m=u=>G.top+u/r*c,g=u=>16+u/l*14,j=qt(i),w=qt(r),f=18,v=G.top+c/2;return e.jsxs("div",{className:"w6w-rel-scatter",children:[e.jsxs("svg",{viewBox:`0 0 ${Te} ${ve}`,style:{aspectRatio:`${Te} / ${ve}`},role:"img","aria-label":"API performance: calls versus p95 latency, one point per API",children:[e.jsx("rect",{x:G.left,y:G.top,width:o,height:c,className:"w6w-rel-scatter-plot-bg"}),w.map(u=>e.jsxs("g",{children:[e.jsx("line",{x1:G.left,x2:Te-G.right,y1:m(u),y2:m(u),className:"w6w-rel-scatter-grid"}),e.jsx("text",{x:G.left-8,y:m(u),className:"w6w-rel-scatter-axis-label",textAnchor:"end",children:u})]},`y-${u}`)),j.map(u=>e.jsx("text",{x:d(u),y:ve-G.bottom+18,className:"w6w-rel-scatter-axis-label",textAnchor:"middle",children:u},`x-${u}`)),e.jsx("text",{x:f,y:v,className:"w6w-rel-scatter-axis-title",textAnchor:"middle",transform:`rotate(-90, ${f}, ${v})`,children:"p95 (ms)"}),e.jsx("text",{x:G.left+o/2,y:ve-4,className:"w6w-rel-scatter-axis-title",textAnchor:"middle",children:"calls in this window"}),a.map(u=>{const h=g(u.errorCount),b=d(u.calls),N=m(u.p95Ms),S=e.jsxs(e.Fragment,{children:[e.jsx("circle",{cx:b,cy:N,r:h/2+2.5,className:`w6w-rel-scatter-ring w6w-rel-scatter-ring-${u.state}`,children:e.jsxs("title",{children:[u.displayName," — ",u.calls," calls, ",u.p95Ms," ms p95, ",u.errorCount," errors"]})}),e.jsx("circle",{cx:b,cy:N,r:h/2,className:`w6w-rel-scatter-point w6w-rel-scatter-point-${u.state}`})]});return s?e.jsx("a",{href:s(u.appId),className:"w6w-rel-scatter-point-link",onClick:n?k=>n(u.appId,k):void 0,children:S},u.appId):n?e.jsx("g",{role:"button",tabIndex:0,className:"w6w-rel-scatter-point-link",onClick:k=>n(u.appId,k),onKeyDown:k=>{(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),k.currentTarget.dispatchEvent(new MouseEvent("click",{bubbles:!0})))},children:S},u.appId):e.jsx("g",{children:S},u.appId)})]}),e.jsx("p",{className:"w6w-muted w6w-small w6w-rel-scatter-note",children:"Up is faster, right is more calls — top-right is the best outcome. Icon size is the error count in this window; ring colour is exec status."})]})}function Yt(t){const s=new Date(t);return Number.isNaN(s.getTime())?t:s.toLocaleDateString(void 0,{month:"short",day:"numeric"})}function ys({appId:t,className:s,title:n,getHref:a,onOpen:i,children:r}){return a?e.jsx("a",{className:s,href:a(t),title:n,onClick:i?l=>i(t,l):void 0,children:r}):i?e.jsx("button",{type:"button",className:s,title:n,onClick:l=>i(t,l),children:r}):e.jsx("div",{className:s,title:n,children:r})}function Ns({service:t}){return e.jsxs("span",{className:"w6w-rel-signal",children:[e.jsx(Fe,{state:t.state}),t.ongoingOutageId&&e.jsx("span",{className:"w6w-rel-tag",children:"outage open"}),t.calls===0&&e.jsx("span",{className:"w6w-muted w6w-small",children:"no calls"})]})}function ks({vendor:t}){if(!t)return e.jsx("span",{className:"w6w-muted w6w-small",children:"not published"});const s=t.state==="unknown";return e.jsxs("span",{className:"w6w-rel-signal",title:t.message??void 0,children:[e.jsx(Fe,{state:t.state,label:s?"Unavailable":void 0}),!s&&t.message&&e.jsx("span",{className:"w6w-rel-vendor-msg w6w-small",children:t.message})]})}function xa({service:t,getHref:s,onOpen:n}){return e.jsxs(ys,{appId:t.appId,className:"w6w-rel-issue-card",title:`${t.displayName} — open service detail`,getHref:s,onOpen:n,children:[e.jsxs("span",{className:"w6w-rel-issue-head",children:[e.jsx(p.AppIcon,{src:t.iconSrc,srcDark:t.iconSrcDark,brandColor:t.brandColor,name:t.displayName,size:24}),e.jsxs("span",{className:"w6w-rel-issue-head-text",children:[e.jsx("strong",{children:t.displayName}),t.attention==="recent"&&e.jsx("span",{className:"w6w-muted w6w-small",children:"trouble earlier in this window"})]})]}),e.jsxs("span",{className:"w6w-rel-issue-signals",children:[e.jsxs("span",{className:"w6w-rel-issue-signal",children:[e.jsx("span",{className:"w6w-muted w6w-small",children:"w6w exec"}),e.jsx(Ns,{service:t})]}),e.jsxs("span",{className:"w6w-rel-issue-signal",children:[e.jsx("span",{className:"w6w-muted w6w-small",children:"API status"}),e.jsx(ks,{vendor:t.vendorStatus})]})]})]})}function ga({service:t,getHref:s,onOpen:n}){const a=t.calls===0;return e.jsxs("tr",{className:`w6w-rel-tr${t.attention!=="none"?" w6w-rel-attention":""}`,"data-attention":t.attention==="none"?void 0:t.attention,children:[e.jsx("td",{className:"w6w-rel-td-service",children:e.jsxs(ys,{appId:t.appId,className:"w6w-rel-open",getHref:s,onOpen:n,children:[e.jsx(p.AppIcon,{src:t.iconSrc,srcDark:t.iconSrcDark,brandColor:t.brandColor,name:t.displayName,size:28}),e.jsxs("span",{className:"w6w-rel-td-service-text",children:[e.jsx("strong",{children:t.displayName}),e.jsx("code",{className:"w6w-muted w6w-small",children:t.appId})]})]})}),e.jsxs("td",{className:"w6w-rel-td-status",children:[e.jsxs("span",{className:"w6w-rel-status-row",children:[e.jsx("span",{className:"w6w-rel-status-label w6w-muted w6w-small",children:"Ops"}),e.jsx(Ns,{service:t})]}),e.jsxs("span",{className:"w6w-rel-status-row",children:[e.jsx("span",{className:"w6w-rel-status-label w6w-muted w6w-small",children:"API"}),e.jsx(ks,{vendor:t.vendorStatus})]})]}),e.jsx("td",{className:"w6w-rel-td-uptime",children:a?e.jsx("span",{className:"w6w-rel-idle-note",children:"No calls in this window"}):e.jsxs(e.Fragment,{children:[e.jsx(as,{days:gs(t),ariaLabel:`${t.displayName}, ${t.uptime.length}-day status, oldest day first`}),e.jsxs("span",{className:"w6w-muted w6w-small",children:[t.calls," calls"]})]})}),e.jsx("td",{className:"w6w-rel-td-p95",children:t.p95Ms===null?"—":`${t.p95Ms} ms`})]})}function va({services:t,window:s,days:n,compact:a=!1,showChart:i,limit:r,getHref:l,onOpen:o,showAllHref:c,onShowAll:d,slots:m}){const g=n??(s==null?void 0:s.days)??30,j=t.length>0&&t.every(R=>R.calls>0&&R.state==="ok"),{attentionCount:w,shownNow:f,shownRecent:v,hiddenAttentionCount:u,shownTable:h,hiddenTableCount:b}=js(t,{compact:a,limit:r}),N=i??!a,S=c!==void 0||d!==void 0,k=R=>{const A=R.startsWith("Show")?"w6w-muted w6w-small":void 0;return c!==void 0?e.jsx("a",{href:c,className:A,onClick:d,children:R}):d?e.jsx("button",{type:"button",className:`w6w-rel-show-all${A?` ${A}`:""}`,onClick:d,children:R}):null};return e.jsxs("section",{className:"w6w-rel-section",children:[e.jsxs("h3",{className:"w6w-rel-heading",children:[e.jsxs("span",{children:[(m==null?void 0:m.header)??"Service reliability"," ",s&&e.jsxs("span",{className:"w6w-muted w6w-small",children:[Yt(s.from)," – ",Yt(s.to)," · ",s.days," days"]})]}),a&&k("Show all services →"),m==null?void 0:m.actions]}),e.jsxs("div",{className:a?"w6w-rel-card":void 0,children:[e.jsx("p",{className:"w6w-muted w6w-small w6w-rel-intro",children:"Connected services across your account. Performance for the selected project."}),j&&e.jsxs("div",{className:a?"w6w-rel-allclear":"w6w-rel-card w6w-rel-allclear",children:[e.jsx("h4",{children:"All clear"}),e.jsxs("p",{children:["Every service you called in the last ",g," days came back"," ",e.jsx(Fe,{state:"ok"})," — no degraded stretches, no outages."]})]}),t.length===0&&((m==null?void 0:m.empty)??e.jsx("div",{className:a?void 0:"w6w-rel-card",children:e.jsx("p",{className:"w6w-muted",children:"No services yet — connect an integration or use a service in this project."})})),t.length>0&&e.jsxs(e.Fragment,{children:[w>0&&e.jsxs("div",{className:"w6w-rel-group",children:[e.jsxs("h4",{className:"w6w-rel-group-head",children:["Needs attention"," ",e.jsxs("span",{className:"w6w-muted w6w-small",children:[f.length+v.length," of ",w]})]}),e.jsx("div",{className:"w6w-rel-issues",children:[...f,...v].map(R=>e.jsx(xa,{service:R,getHref:l,onOpen:o},R.appId))}),u>0&&e.jsxs("p",{className:"w6w-muted w6w-small w6w-rel-more-note",children:[u," more ",u===1?"needs":"need"," ","attention",S&&e.jsxs(e.Fragment,{children:[" — ",k("view all →")]})]})]}),N&&e.jsxs("div",{className:"w6w-rel-group",children:[e.jsx("h4",{className:"w6w-rel-group-head",children:"Performance across your APIs"}),e.jsx(bs,{services:t,getHref:l,onOpen:o})]}),h.length>0&&e.jsxs("div",{className:"w6w-rel-group",children:[e.jsxs("h4",{className:"w6w-rel-group-head",children:[a?"Services":"All services"," ",e.jsx("span",{className:"w6w-muted w6w-small",children:a?`${h.length} of ${t.length}`:t.length})]}),e.jsx("div",{className:"w6w-rel-table-wrap",children:e.jsxs("table",{className:"w6w-rel-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Service"}),e.jsx("th",{children:"Status"}),e.jsxs("th",{children:["Last ",g," days"]}),e.jsx("th",{children:"Latency"})]})}),e.jsx("tbody",{children:h.map(R=>e.jsx(ga,{service:R,getHref:l,onOpen:o},R.appId))})]})}),b>0&&e.jsxs("p",{className:"w6w-muted w6w-small w6w-rel-more-note",children:[b," more",S&&e.jsxs(e.Fragment,{children:[" — ",k("view all →")]})]})]})]})]})]})}function ja({tone:t="muted",title:s,children:n,"data-testid":a}){return e.jsx("span",{className:`w6w-callable-list-status w6w-callable-list-status-${t}`,title:s,"data-testid":a,children:n})}const me="all",ne="archived";function ba(t,s){return s===""?!0:[t.id,t.searchText,typeof t.title=="string"?t.title:void 0,typeof t.description=="string"?t.description:void 0].some(a=>a==null?void 0:a.toLowerCase().includes(s))}function ya({rows:t,title:s,icon:n,description:a,emptyCopy:i,newLabel:r="New",openRowTitle:l,testIds:o,loading:c,error:d,onCreate:m,creating:g,onImport:j,onOpen:w,getHref:f,groups:v=[],filter:u,onFilterChange:h,showArchived:b,onShowArchivedChange:N,searchPlaceholder:S="Search by name",slots:k}){var q;const[R,A]=x.useState(me),[D,_]=x.useState(""),V=u??(b===void 0?void 0:b?ne:me),M=V??R,P=E=>{V===void 0&&A(E),h==null||h(E),E===ne!=(M===ne)&&(N==null||N(E===ne))},T=t.filter(E=>!E.archived),F=t.length-T.length,C=E=>M===ne?E.archived:!E.archived&&(M===me||E.group===M),B=D.trim().toLowerCase(),I=t.filter(E=>C(E)&&ba(E,B)),W=[{key:me,label:"All",count:T.length},...v.map(E=>({...E,count:T.filter(K=>K.group===E.key).length})),{key:ne,label:"Archived",count:F}],Q=((q=W.find(E=>E.key===M))==null?void 0:q.label)??M,Z=w!==void 0||f!==void 0,X=[{key:"main",header:"Name",render:E=>{const K=E.icon!==void 0?E.icon:n?e.jsx(U.Icon,{name:n,size:16}):null,re=e.jsxs("span",{className:"w6w-callable-list-cell",title:Z?l:void 0,children:[K!=null&&e.jsx("span",{className:"w6w-callable-list-icon","aria-hidden":"true",children:K}),e.jsxs("span",{className:"w6w-callable-list-main",children:[e.jsxs("span",{className:"w6w-callable-list-title-line",children:[e.jsx("span",{className:"w6w-callable-list-name",children:E.title}),E.status]}),E.description!=null&&E.description!==""&&e.jsx("span",{className:"w6w-muted w6w-small w6w-callable-list-row-desc",children:E.description}),E.meta!=null&&e.jsx("span",{className:"w6w-muted w6w-callable-list-meta",children:E.meta})]})]});return w&&!f?e.jsx("button",{type:"button",className:"w6w-callable-list-open",children:re}):re}},{key:"trail",header:"",align:"right",width:"1%",render:E=>E.archived||E.badges!=null||E.trailing!=null?e.jsxs("span",{className:"w6w-callable-list-trail",children:[E.badges,E.archived&&e.jsx("span",{className:"w6w-callable-list-badge","data-testid":o==null?void 0:o.archivedBadge,children:"archived"}),E.trailing]}):null}];I.some(E=>E.menu!=null)&&X.push({key:"menu",header:"",align:"right",link:!1,actions:!0,render:E=>E.menu??null});const le=M===me&&B===""&&t.length>0&&T.length===0;return e.jsxs("section",{className:"w6w-callable-list",children:[e.jsxs("div",{className:"w6w-callable-list-head",children:[e.jsx("div",{className:"w6w-callable-list-heading",children:(k==null?void 0:k.header)??e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"w6w-callable-list-title",children:s}),a!=null&&e.jsx("p",{className:"w6w-muted w6w-small w6w-callable-list-description",children:a})]})}),e.jsxs("div",{className:"w6w-callable-list-actions",children:[k==null?void 0:k.actions,j&&e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost","data-testid":o==null?void 0:o.importOpen,onClick:j,children:"Import"}),m&&e.jsx("button",{type:"button",className:"w6w-btn",disabled:g,onClick:m,children:g?"Creating…":r})]})]}),t.length>0&&e.jsxs("div",{className:"w6w-callable-list-filters",children:[e.jsx("fieldset",{className:"w6w-subtabs w6w-callable-list-tabs","aria-label":"Filter by status",children:W.map(E=>e.jsxs("button",{type:"button",className:`w6w-subtab${M===E.key?" active":""}`,"aria-pressed":M===E.key,"data-testid":E.key===ne&&(o!=null&&o.showArchived)?o.showArchived:o!=null&&o.filterTab?`${o.filterTab}-${E.key}`:void 0,onClick:()=>P(E.key),children:[E.label,e.jsx("span",{className:"w6w-callable-list-count",children:E.count})]},E.key))}),e.jsx("input",{type:"search",className:"w6w-callable-list-search",placeholder:S,"aria-label":S,value:D,"data-testid":o==null?void 0:o.search,onChange:E=>_(E.target.value)})]}),d&&e.jsx("div",{className:"w6w-error",children:d}),e.jsxs("div",{className:"w6w-callable-list-body",children:[c&&e.jsx("p",{className:"w6w-muted",children:"Loading…"}),I.length===0&&!c?le?e.jsx(p.EmptyState,{testId:"w6w-callable-list-empty",action:e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:()=>P(ne),children:"Show archived"}),children:t.length===1?"The only item is archived.":`All ${t.length} items are archived.`}):t.length>0?e.jsx(p.EmptyState,{testId:"w6w-callable-list-empty",action:e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:()=>{_(""),P(me)},children:"Show all"}),children:B!==""?`Nothing in ${Q} matches "${D.trim()}".`:`Nothing in ${Q}.`}):e.jsx(p.EmptyState,{testId:"w6w-callable-list-empty",children:(k==null?void 0:k.empty)??i}):e.jsx(p.DataTable,{columns:X,rows:I,rowKey:E=>E.id,className:"w6w-data-table-rows",loading:c,getRowHref:f?E=>f(E.id):void 0,onRowClick:w?(E,K)=>w(E.id,K):void 0})]})]})}function Na({connections:t,appsById:s,loading:n,error:a,onOpen:i,getHref:r,onEdit:l,onDelete:o,busy:c,slots:d}){const m=s??new Map,g=l!==void 0||o!==void 0,j=[{key:"name",header:"Name",render:w=>{const f=p.resolveConnectionAppMeta(w,m),v=w.displayName||w.id;return e.jsxs("span",{className:"w6w-connection-cell-name",children:[e.jsx(p.AppIcon,{src:f==null?void 0:f.iconSvg,srcDark:f==null?void 0:f.iconSvgDark,brandColor:f==null?void 0:f.brandColor,name:(f==null?void 0:f.displayName)??w.appId}),e.jsxs("span",{className:"w6w-connection-cell-text",children:[e.jsxs("span",{className:"w6w-connection-cell-title",children:[e.jsx("strong",{className:"w6w-connection-name",title:v,children:v}),e.jsx("span",{className:`w6w-connection-status${w.state==="connected"?"":" w6w-connection-status-warn"}`,title:w.state,children:w.state}),w.lastTestOk===!1&&e.jsx("span",{className:"w6w-connection-status w6w-connection-status-danger",title:"Last test failed — update or re-test.",children:"invalid"})]}),e.jsx("span",{className:"w6w-connection-app w6w-muted",children:(f==null?void 0:f.displayName)??w.appId})]})]})}}];return g&&j.push({key:"actions",header:"",align:"right",link:!1,actions:!0,render:w=>w.builtIn===!0?null:e.jsx(dt,{label:`Actions for ${w.displayName||w.id}`,"data-testid":`connection-actions-${w.id}`,actions:[l&&{label:"Edit",icon:"edit",onSelect:()=>l(w),"data-testid":`connection-edit-${w.id}`},o&&{label:"Delete",icon:"delete",danger:!0,disabled:c,onSelect:()=>o(w),"data-testid":`connection-delete-${w.id}`}]})}),e.jsxs("section",{className:"w6w-connection-list",children:[((d==null?void 0:d.header)!=null||(d==null?void 0:d.actions)!=null)&&e.jsxs("div",{className:"w6w-connection-list-head",children:[e.jsx("div",{className:"w6w-connection-list-heading",children:d==null?void 0:d.header}),e.jsx("div",{className:"w6w-connection-list-actions",children:d==null?void 0:d.actions})]}),a&&e.jsx("div",{className:"w6w-error",children:a}),n&&e.jsx("p",{className:"w6w-muted",children:"Loading…"}),t.length===0&&!n?e.jsx(p.EmptyState,{testId:"w6w-connection-list-empty",children:(d==null?void 0:d.empty)??"No connections yet."}):e.jsx(p.DataTable,{columns:j,rows:t,rowKey:w=>w.id,loading:n,getRowHref:r?w=>w.builtIn===!0?void 0:r(w.id):void 0,onRowClick:i?(w,f)=>w.builtIn===!0?void 0:i(w.id,f):void 0})]})}function ka({connection:t,onClose:s,onSaved:n}){const a=p.useW6WApi(),i=a.updateConnection,r=t.builtIn===!0,l=!r&&typeof i=="function",[o,c]=x.useState(t.displayName??""),[d,m]=x.useState(t.authKey),[g,j]=x.useState({}),[w,f]=x.useState(null),[v,u]=x.useState(null),[h,b]=x.useState(!1),[N,S]=x.useState({}),[k,R]=x.useState(null),[A,D]=x.useState(null),[_,V]=x.useState(null),[M,P]=x.useState(null);x.useEffect(()=>{if(!l)return;let $=!1;return f(null),a.getAppAuth(t.appId).then(L=>!$&&f(L)).catch(L=>!$&&u(L.message)),()=>{$=!0}},[a,l,t.appId]);const T=w==null?void 0:w.find($=>$.key===d),F=d!==t.authKey,C=(w==null?void 0:w.filter($=>$.key===t.authKey||$.available!==!1&&!$.autoSatisfied&&["apiKey","bearer","basic","custom"].includes($.type)))??[],B=(T==null?void 0:T.type)==="oauth2",I=B?[]:(T==null?void 0:T.fields)??[],W=t.credentialId,Q=!F&&!!W&&typeof a.rotateCredential=="function"&&(A!==null?!A.startsWith("legacy:"):(T==null?void 0:T.type)==="serviceAccount")&&_!==!0&&!B,Z=Q&&_===!1&&T!==void 0&&!T.serviceAccount,X=Q&&!Z,le=!F&&!B&&!!W&&typeof a.getCredential=="function"&&_===null,q=X&&(T!=null&&T.serviceAccount)?p.bindingFieldsFor(T.serviceAccount):[];x.useEffect(()=>{if(!l||F||B||!W||typeof a.getCredential!="function")return;let $=!1;return a.getCredential(W).then(L=>{$||(R(L.connectionCount),D(L.contract),V(L.private===!0))}).catch(()=>{}),()=>{$=!0}},[a,l,F,B,W]);function E(){if(Z)return o!==(t.displayName??"")?{displayName:o}:null;if(X){const J={};o!==(t.displayName??"")&&(J.displayName=o);const Y=p.buildBinding(q,N);return Y&&(J.binding=Y),J.displayName===void 0&&J.binding===void 0?null:J}const $={};for(const J of Z?[]:I){const Y=g[J.key];Y!==void 0&&Y!==""&&($[J.key]=Y)}const L={};return F&&(L.authKey=d,L.credential=$),o!==(t.displayName??"")&&(L.displayName=o),Object.keys($).length>0&&(L.credential=$),L.displayName===void 0&&L.credential===void 0?null:L}async function K(){if(!l||!i||h)return;u(null);const $=E(),L=Object.fromEntries((Z?[]:I).filter(H=>g[H.key]!==void 0&&g[H.key]!=="").map(H=>[H.key,g[H.key]])),J=Object.keys(L).length>0;if(!$&&!J){u("Nothing to update — change the name or a credential or binding field.");return}if(F||X&&J){const H=I.filter(ue=>ue.required&&!(ue.key in L));if(H.length>0){u(`Enter the full new credential: ${H.map(ue=>ue.label).join(", ")}.`);return}}const Y=p.parseJsonFields(I,L);if("error"in Y){u(Y.error);return}b(!0);let ce=!1;try{X&&J&&W&&a.rotateCredential?(await a.rotateCredential(W,{source:Y.values}),ce=!0,j({}),P(null)):$!=null&&$.credential&&($.credential=Y.values);const H=$?await i.call(a,t.id,$):t;j({}),n(H)}catch(H){u(ce?`The credential was saved, but the other changes failed. Click Save to retry them. ${H.message}`:H.message)}finally{b(!1)}}async function re(){if(!(!W||!a.testCredential)){u(null);try{P(await a.testCredential(W))}catch($){u($.message)}}}const oe=p.useEnterSubmit(K,{enabled:l&&!h});return e.jsx(p.Modal,{title:"Edit connection",onClose:s,children:e.jsxs("div",{className:"w6w-stepconfig",children:[e.jsx("div",{className:"w6w-modal-body",children:e.jsxs("div",{className:"w6w-stack",children:[r&&e.jsx("p",{className:"w6w-muted w6w-small",children:"This connection is built in — it has no stored credential to edit."}),!r&&e.jsx("p",{className:"w6w-muted w6w-small","data-w6w":"connection-ownership",children:t.accessScope==="user"?"Only me":"This account"}),!r&&!l&&e.jsx("p",{className:"w6w-muted w6w-small",children:"Editing connections is not available here."}),l&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"w6w-field",children:[e.jsx("span",{children:"Display name"}),e.jsx("input",{type:"text",value:o,onChange:$=>c($.target.value),placeholder:"Connection name",maxLength:80,name:"w6w-connection-label",autoComplete:"off","data-1p-ignore":"true","data-lpignore":"true","data-bwignore":"true","data-form-type":"other",...oe})]}),C.some($=>$.key!==t.authKey)&&e.jsxs("label",{className:"w6w-field",children:[e.jsx("span",{children:"Authentication method"}),e.jsxs("select",{name:"w6w-connection-auth",value:d,disabled:h,onChange:$=>{m($.target.value),j({}),S({}),P(null),u(null)},children:[!C.some($=>$.key===t.authKey)&&e.jsx("option",{value:t.authKey,children:t.authKey}),C.map($=>e.jsx("option",{value:$.key,children:$.displayName??$.key},$.key))]})]}),F&&e.jsx("p",{className:"w6w-muted w6w-small",children:"Enter the new credential and click Save. This connection stays linked to your existing workflows."}),w===null&&!v&&e.jsx("p",{className:"w6w-muted w6w-small",children:"Loading auth fields…"}),T&&e.jsx(p.AuthGuide,{auth:T}),B&&e.jsx("p",{className:"w6w-muted w6w-small",children:C.some($=>$.key!==t.authKey)?"This connection uses OAuth. Choose another authentication method above to use a key or token.":"This is an OAuth connection. You can rename it here; its credential is renewed by re-authorizing it."}),X&&q.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"w6w-muted w6w-small",children:"Leave a binding field blank to keep it unchanged."}),e.jsx(p.AuthFieldsForm,{mode:"edit",fields:q,values:N,onChange:S,enterSubmitProps:oe})]}),Q&&e.jsxs("div",{className:"w6w-stack","data-w6w":"credential-section",children:[typeof a.testCredential=="function"&&e.jsxs("div",{children:[e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:re,children:"Test credential"}),M&&e.jsxs("p",{className:"w6w-small","data-w6w":"credential-health",children:["Credential health: ",M.ok?"ok":M.code??"failed"]})]}),e.jsxs("p",{className:"w6w-small","data-w6w":"app-access",children:["App access:"," ",t.lastTestOk===!0?"passed":t.lastTestOk===!1?"failed":"never tested"]}),X&&!le&&I.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"w6w-muted w6w-small",children:["Leave the credential blank to keep it unchanged. To replace it, enter the full new credential and click Save.",k!==null&&k>1&&` This credential is used by ${k} connections; saving a new credential updates all of them.`]}),e.jsx(p.AuthFieldsForm,{mode:"edit",fields:I,values:g,onChange:j,enterSubmitProps:oe})]}),Z&&e.jsx("p",{className:"w6w-muted w6w-small","data-w6w":"shared-credential-note",children:"Uses a shared credential. Rotate it in Settings → Credentials."})]}),!X&&!Z&&!le&&I.length>0&&e.jsxs(e.Fragment,{children:[!F&&e.jsx("p",{className:"w6w-muted w6w-small",children:"Leave a field blank to keep it unchanged. Filled fields replace the stored credential."}),e.jsx(p.AuthFieldsForm,{mode:"edit",fields:I,values:g,onChange:j,enterSubmitProps:oe})]})]}),v&&e.jsx("div",{className:"w6w-result w6w-error",children:v})]})}),e.jsxs("div",{className:"w6w-modal-actions",children:[e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:s,children:"Cancel"}),l&&e.jsx("button",{type:"button",className:"w6w-btn",disabled:h,onClick:K,children:h?"Saving…":"Save"})]})]})})}function Sa({conn:t,app:s,children:n}){return e.jsxs("div",{className:"w6w-connection-header","data-testid":"connection-header",children:[e.jsx(p.AppIcon,{src:s==null?void 0:s.iconSvg,srcDark:s==null?void 0:s.iconSvgDark,brandColor:s==null?void 0:s.brandColor,name:(s==null?void 0:s.displayName)??t.appId,size:56}),e.jsxs("div",{className:"w6w-connection-header-main",children:[e.jsx("h2",{className:"w6w-connection-header-title",children:t.displayName||t.id}),e.jsxs("div",{className:"w6w-muted w6w-small w6w-connection-header-meta",children:[e.jsx(ns,{value:t.id,className:"w6w-connection-id-copy"})," · App"," ",e.jsx("code",{children:t.appId})," · Auth ",e.jsx("code",{children:t.authKey})," ·"," ",e.jsx("span",{className:`w6w-connection-tag${t.state==="connected"?"":" w6w-connection-tag-warn"}`,children:t.state}),t.lastTestOk===!1&&e.jsx("span",{className:"w6w-connection-tag w6w-connection-tag-danger",title:"Last test failed — update or re-test.",children:"invalid"})]})]}),n&&e.jsx("div",{className:"w6w-connection-header-actions",children:n})]})}function Ss(t,s=Date.now()){const n=new Date(t).getTime();if(Number.isNaN(n))return"recently";const a=Math.max(0,Math.round((s-n)/1e3));if(a<45)return"just now";const i=Math.round(a/60);if(i<60)return`${i}m ago`;const r=Math.round(i/60);if(r<24)return`${r}h ago`;const l=Math.round(r/24);return l<30?`${l}d ago`:new Date(t).toLocaleDateString()}function Ca({conn:t,refreshable:s,onChanged:n,className:a}){const i=p.useW6WApi(),[r,l]=x.useState(s??null),[o,c]=x.useState(t.autoRefresh!==!1),[d,m]=x.useState(!1),[g,j]=x.useState(null);if(x.useEffect(()=>c(t.autoRefresh!==!1),[t.autoRefresh]),x.useEffect(()=>{if(s!==void 0){l(s);return}let v=!1;return i.getAppAuth(t.appId).then(u=>{var h;return!v&&l(((h=u.find(b=>b.key===t.authKey))==null?void 0:h.refreshable)===!0)}).catch(()=>!v&&l(!1)),()=>{v=!0}},[i,t.appId,t.authKey,s]),t.builtIn||r!==!0)return null;const w=i.updateConnection;async function f(v){if(w){j(null),m(!0),c(v);try{const u=await w.call(i,t.id,{autoRefresh:v});n==null||n(u)}catch(u){c(!v),j(u.message)}finally{m(!1)}}}return e.jsxs("section",{className:`w6w-keepalive${a?` ${a}`:""}`,"data-testid":"connection-keepalive",children:[e.jsx("h3",{children:"Token refresh"}),e.jsxs("label",{className:"w6w-checkbox",children:[e.jsx("input",{type:"checkbox",name:"w6w-connection-keepalive",checked:o,disabled:!w||d,onChange:v=>f(v.target.checked)}),e.jsxs("span",{children:[e.jsx("strong",{children:"Keep connected"}),e.jsxs("span",{className:"w6w-muted w6w-small",children:[" ",o?"Refresh the token automatically, even when nothing uses this connection.":"Off: the token is refreshed only when something uses this connection, so an idle one may need reconnecting."]})]})]}),t.lastRefreshedAt&&e.jsxs("p",{className:"w6w-muted w6w-small","data-testid":"connection-last-refreshed",children:["Last refreshed"," ",e.jsx("time",{dateTime:t.lastRefreshedAt,title:t.lastRefreshedAt,children:Ss(t.lastRefreshedAt)})]}),t.refreshFailingSince&&e.jsxs("p",{className:"w6w-keepalive-warning","data-testid":"connection-refresh-failing",children:["Token refresh failing since"," ",e.jsx("time",{dateTime:t.refreshFailingSince,children:new Date(t.refreshFailingSince).toLocaleDateString()})," ","— reconnect if this persists"]}),g&&e.jsx("div",{className:"w6w-result w6w-error",children:g})]})}const Ea=t=>String(t);function zt(t){const s=Math.min(100,Math.max(0,t));return Number(s.toFixed(4))}function Aa({label:t,used:s,limit:n,reserved:a=0,format:i,className:r,testId:l}){const o=i??Ea,c=Number.isFinite(a)&&a>0,d=n>0?zt(s/n*100):100,m=c&&n>0?zt(Math.min(100-d,a/n*100)):0,g=s>=n,j=`${o(s)} / ${o(n)}`,w=["w6w-budget-meter"];return g&&w.push("w6w-budget-meter-over"),r&&w.push(r),e.jsxs("div",{role:"meter",className:w.join(" "),"aria-label":t,"aria-valuemin":0,"aria-valuenow":s,"aria-valuemax":n,"aria-valuetext":j,"data-testid":l,children:[e.jsxs("div",{className:"w6w-budget-meter-head",children:[e.jsx("span",{className:"w6w-budget-meter-label",children:t}),e.jsx("span",{className:"w6w-budget-meter-value",children:j})]}),e.jsxs("div",{className:"w6w-budget-meter-track",children:[e.jsx("div",{className:"w6w-budget-meter-used",style:{width:`${d}%`}}),c&&e.jsx("div",{className:"w6w-budget-meter-reserved",style:{width:`${m}%`}})]})]})}const Cs={kv:"Key-value",doc:"Document",table:"Table"},Ra=["kv","doc","table"],ht=["string","number","integer","boolean","date","datetime"],Es=5242880;function $a(t){var n;const s=(n=t.schema)==null?void 0:n.valueType;return typeof s=="string"&&ht.includes(s)?s:"string"}function Ta(t){var a,i;if(t.kind!=="table")return null;const s=(a=t.schema)==null?void 0:a.columns;if(!Array.isArray(s))return null;const n=(i=t.schema)==null?void 0:i.key;return typeof n=="string"?{columns:s,key:n}:{columns:s}}function _a(t,s){const n=t==null?void 0:t.match(/filename="([^"]*)"/),a=n==null?void 0:n[1];return a!==void 0&&a!==""?a:`${s}.csv`}const As={required:"Required.",not_a_number:"Enter a number.",not_an_integer:"Enter a whole number.",not_a_boolean:"Enter true or false.",not_a_date:"Enter a date as YYYY-MM-DD.",not_a_datetime:"Enter a date-time like 2026-01-31T09:30:00Z."},Ia=/^-?(0|[1-9]\d*)(\.\d+)?([eE][+-]?\d+)?$/,La=/^-?(0|[1-9]\d*)$/,Oa=/^\d{4}-\d{2}-\d{2}$/,Pa=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})$/;function Da(t,s){return s===2?t%4===0&&t%100!==0||t%400===0?29:28:[31,0,31,30,31,30,31,31,30,31,30,31][s-1]}function pt(t){if(!Oa.test(t))return null;const s=Number(t.slice(0,4)),n=Number(t.slice(5,7)),a=Number(t.slice(8,10));return n<1||n>12||a<1||a>Da(s,n)?null:{year:s,month:n,day:a}}function ae(t){return{ok:!1,problem:t,message:As[t]}}function We(t,s,n){const a=s.trim();if(a==="")return n?ae("required"):{ok:!0,value:void 0};switch(t){case"string":return{ok:!0,value:s};case"number":{if(!Ia.test(a))return ae("not_a_number");const i=Number(a);return Number.isFinite(i)?{ok:!0,value:i}:ae("not_a_number")}case"integer":{if(!La.test(a))return ae("not_an_integer");const i=Number(a);return Number.isSafeInteger(i)?{ok:!0,value:i}:ae("not_an_integer")}case"boolean":return a==="true"?{ok:!0,value:!0}:a==="false"?{ok:!0,value:!1}:ae("not_a_boolean");case"date":return pt(a)===null?ae("not_a_date"):{ok:!0,value:a};case"datetime":return Rs(a)?{ok:!0,value:a}:ae("not_a_datetime")}}function Rs(t){if(!Pa.test(t)||pt(t.slice(0,10))===null)return!1;const s=Number(t.slice(11,13)),n=Number(t.slice(14,16)),a=Number(t.slice(17,19));if(s>23||n>59||a>59)return!1;const r=t.slice(19).match(/(Z|([+-])(\d{2}):(\d{2}))$/);return r===null||r[1]==="Z"?!0:Number(r[3])<=23&&Number(r[4])<=59}function Ke(t,s){if(s==null)return"";if((t==="string"||t==="date"||t==="datetime")&&typeof s=="string")return s;if((t==="number"||t==="integer")&&typeof s=="number"&&Number.isFinite(s))return String(s);if(t==="boolean"&&typeof s=="boolean")return s?"true":"false";const n=JSON.stringify(s);return n===void 0?"":n}function Ma(t,s){switch(t){case"string":return typeof s=="string";case"number":return typeof s=="number"&&Number.isFinite(s);case"integer":return Number.isSafeInteger(s);case"boolean":return typeof s=="boolean";case"date":return typeof s=="string"&&pt(s)!==null;case"datetime":return typeof s=="string"&&Rs(s)}}const pe="The request failed.",$s="Could not reach the server.";function de(t){return typeof t=="string"&&t.length>0?t:void 0}function Ts(t){return Number.isInteger(t)&&t>=0?t:void 0}function _s(t,s,n){const a={message:pe};typeof n=="number"&&(a.status=n);const i=t!==null&&typeof t=="object"?t.error:void 0;if(i!==null&&typeof i=="object"){const r=i,l=de(r.code);l!==void 0&&(a.code=l);const o=de(r.field);o!==void 0&&(a.field=o);const c=de(r.column);c!==void 0&&(a.column=c);const d=Ts(r.row);d!==void 0&&(a.row=d);const m=de(r.message);m!==void 0&&(a.message=m)}if(a.message===pe)for(const r of s){const l=de(r);if(l!==void 0){a.message=l;break}}return a}function Ba(t){try{const s=t!==null&&typeof t=="object"?t:void 0,n=s==null?void 0:s.raw,a=s==null?void 0:s.message;return _s(n,[a],s==null?void 0:s.status)}catch{return{message:pe}}}function Is(t){try{if(t.status===0)return{status:0,code:"network_error",message:$s};let s;try{s=JSON.parse(t.text)}catch{return{status:t.status,message:pe}}return _s(s,[],t.status)}catch{return{message:pe}}}function Ls(t){const s=de(t.column);if(s!==void 0){const a=Ts(t.row);return a===void 0?{kind:"cell",column:s}:{kind:"cell",column:s,row:a}}const n=de(t.field);return n!==void 0?{kind:"field",field:n}:{kind:"form"}}function lt(t){return t+2}const ft="\0new",xt="Changed by someone else since you loaded it.",rt="Enter a JSON object or array.",Os="The file is larger than 5 MB.";function Ps(t){const s=t.value;return s!==null&&typeof s=="object"&&!Array.isArray(s)?s:{}}function Fa(t,s){const n=Ps(t),a={};for(const i of s)a[i.name]=Ke(i.type,n[i.name]);return{id:t.key,version:t.version,cells:a}}function Ua(t){const s={};for(const n of t)s[n.name]=n.default===void 0?"":Ke(n.type,n.default);return{id:ft,version:null,cells:s}}function Wa(t,s,n){const a=[];for(const i of n)(t.cells[i.name]??"")!==(s.cells[i.name]??"")&&a.push(i.name);return a}function Ka(t,s){const n={},a={};for(const i of s){const r=We(i.type,t.cells[i.name]??"",i.required);r.ok?r.value!==void 0&&(n[i.name]=r.value):a[i.name]=r.message}return Object.keys(a).length>0?{ok:!1,errors:a}:{ok:!0,value:n}}function Va(t,s){if(t===null)return;const n=Date.parse(t);if(!Number.isFinite(n))return;const a=Math.ceil((n-s)/1e3);return a>0?a:void 0}function Ja(t,s,n){if(t.id===ft)return n===void 0?{kind:"insert",value:s}:{kind:"insert",value:s,ttlSeconds:n};const a={kind:"put",key:t.id,value:s,ifVersion:t.version??0};return n===void 0?a:{...a,ttlSeconds:n}}function Ha(t,s){const n=Ls(t);return n.kind!=="cell"||!s.some(a=>a.name===n.column)?null:{[n.column]:t.message}}function qa(t){return t.status===409&&t.code==="version_conflict"}function Ds(t){let s;try{s=JSON.parse(t)}catch{return{ok:!1,message:rt}}return s===null||typeof s!="object"?{ok:!1,message:rt}:{ok:!0,value:s}}function Ya(t,s){if(t==="string")return{ok:!0,value:s};const n=We(t,s,!0);return n.ok?{ok:!0,value:n.value}:{ok:!1,message:n.message}}function za(t){if(t.status===200){let a=0;try{const i=JSON.parse(t.text);typeof i.imported=="number"&&Number.isFinite(i.imported)&&(a=i.imported)}catch{a=0}return{ok:!0,message:`Imported ${a} row${a===1?"":"s"}.`}}const s=Is(t);return s.row===void 0?{ok:!1,message:s.message}:{ok:!1,message:`${s.column?`Line ${lt(s.row)}, column ${s.column}`:`Line ${lt(s.row)}`}: ${s.message}`}}function Ga({stores:t,loading:s,error:n,onOpen:a,getHref:i,onEdit:r,onArchive:l,busy:o,formatSize:c,slots:d}){const m=c??ls,g=r!==void 0||l!==void 0,j=[{key:"name",header:"Name",render:w=>e.jsx("strong",{children:w.name})},{key:"kind",header:"Kind",render:w=>Cs[w.kind]},{key:"entries",header:"Entries",align:"right",render:w=>String(w.entryCount)},{key:"size",header:"Size",align:"right",render:w=>m(w.sizeBytes)}];return g&&j.push({key:"actions",header:"",align:"right",link:!1,actions:!0,render:w=>e.jsx(dt,{label:`Actions for ${w.name||w.id}`,"data-testid":`data-store-actions-${w.id}`,actions:[r&&{label:"Edit",icon:"edit",onSelect:()=>r(w),"data-testid":`data-store-edit-${w.id}`},l&&{label:"Archive",icon:"archive",danger:!0,disabled:o,onSelect:()=>l(w),"data-testid":`data-store-archive-${w.id}`}]})}),e.jsxs("section",{className:"w6w-data-store-list",children:[((d==null?void 0:d.header)!=null||(d==null?void 0:d.actions)!=null)&&e.jsxs("div",{className:"w6w-data-store-list-head",children:[e.jsx("div",{className:"w6w-data-store-list-heading",children:d==null?void 0:d.header}),e.jsx("div",{className:"w6w-data-store-list-actions",children:d==null?void 0:d.actions})]}),n&&e.jsx("div",{className:"w6w-error",children:n}),s&&e.jsx("p",{className:"w6w-muted",children:"Loading…"}),t.length===0&&!s?e.jsx(p.EmptyState,{testId:"w6w-data-store-list-empty",children:(d==null?void 0:d.empty)??"No data stores yet."}):e.jsx(p.DataTable,{columns:j,rows:t,rowKey:w=>w.id,loading:s,getRowHref:i?w=>i(w.id):void 0,onRowClick:a?(w,f)=>a(w.id,f):void 0})]})}function Xa(t){return t.name!==""&&t.required===!0&&(t.type==="string"||t.type==="integer")}function Za(t,s){const{default:n,...a}=t,i=We(t.type,s,!1);return i.ok?i.value===void 0?{column:a}:{column:{...a,default:i.value}}:{column:a,error:i.message}}function Qa(t){const{columns:s,onChange:n,keyColumn:a,onKeyColumnChange:i,columnErrors:r}=t,[l,o]=x.useState({}),c=s.filter(Xa),d=c.some(f=>f.name===a)?a:"";x.useEffect(()=>{a!==""&&d===""&&i("")},[a,d,i]);function m(){n([...s,{name:"",type:"string",required:!1}])}function g(f,v){n(s.map((u,h)=>h===f?{...u,...v}:u))}function j(f,v,u,h){const b={...s[f],...h,type:v},{column:N,error:S}=Za(b,u);o(k=>({...k,[f]:S===void 0?{text:u}:{text:u,error:S}})),n(s.map((k,R)=>R===f?N:k))}function w(f){o(v=>{const u={};for(const[h,b]of Object.entries(v)){const N=Number(h);N<f?u[N]=b:N>f&&(u[N-1]=b)}return u}),n(s.filter((v,u)=>u!==f))}return e.jsxs("div",{className:"w6w-data-columns",children:[e.jsxs("div",{className:"w6w-data-columns-head",children:[e.jsx("h3",{children:"Columns"}),e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:m,children:"+ Add column"})]}),e.jsx("p",{className:"w6w-muted w6w-small",children:"Each column has a name, a scalar type, whether it must be set, and an optional default."}),s.length===0&&e.jsx("p",{className:"w6w-muted w6w-small",children:"No columns yet."}),s.length>0&&e.jsxs("div",{className:"w6w-data-columns-row w6w-data-columns-colhead","aria-hidden":"true",children:[e.jsx("span",{children:"Name"}),e.jsx("span",{children:"Type"}),e.jsx("span",{}),e.jsx("span",{children:"Default"}),e.jsx("span",{})]}),e.jsx("ul",{className:"w6w-data-columns-list","data-testid":"data-columns",children:s.map((f,v)=>{const u=l[v],h=(u==null?void 0:u.text)??Ke(f.type,f.default);return e.jsxs("li",{className:"w6w-data-columns-row",children:[e.jsx("input",{type:"text",value:f.name,placeholder:"name","aria-label":"Column name",onChange:b=>g(v,{name:b.target.value})}),e.jsx("select",{value:f.type,"aria-label":"Column type",onChange:b=>j(v,b.target.value,h),children:ht.map(b=>e.jsx("option",{value:b,children:b},b))}),e.jsxs("label",{className:"w6w-data-columns-required",children:[e.jsx("input",{type:"checkbox",checked:f.required,"aria-label":"Required",onChange:b=>g(v,{required:b.target.checked})}),e.jsx("span",{className:"w6w-muted w6w-small",children:"required"})]}),e.jsx("input",{type:"text",value:h,placeholder:"default","aria-label":"Column default",onChange:b=>j(v,f.type,b.target.value)}),e.jsx(p.DeleteButton,{label:`Remove column ${f.name||v+1}`,onClick:()=>w(v)}),(u==null?void 0:u.error)!==void 0&&e.jsx("div",{className:"w6w-result w6w-error w6w-data-columns-error","data-testid":`data-store-column-default-error-${v}`,children:u.error}),f.name!==""&&r[f.name]!==void 0&&e.jsx("div",{className:"w6w-result w6w-error w6w-data-columns-error","data-testid":`data-store-column-error-${f.name}`,children:r[f.name]})]},v)})}),e.jsxs("label",{className:"w6w-field",children:[e.jsx("span",{children:"Key column"}),e.jsxs("select",{value:d,onChange:f=>i(f.target.value),children:[e.jsx("option",{value:"",children:"(none — rows get generated keys)"}),c.map(f=>e.jsx("option",{value:f.name,children:f.name},f.name))]}),e.jsx("span",{className:"w6w-hint",children:"Only a required, string or integer column can name a row's key."})]})]})}function ei({result:t,busy:s,onImport:n,onRefuse:a,onExport:i}){function r(l){var d;const o=l.target,c=(d=o.files)==null?void 0:d[0];if(c!==void 0){if(o.value="",c.size>Es){a(Os);return}n(c)}}return e.jsxs("div",{className:"w6w-data-csv-panel","data-testid":"csv-panel",children:[e.jsxs("div",{className:"w6w-data-csv-panel-actions",children:[e.jsx("input",{type:"file",accept:".csv,text/csv","data-testid":"csv-file","aria-label":"Import CSV",onChange:r}),e.jsx("button",{className:"w6w-btn w6w-btn-ghost",type:"button","data-testid":"csv-export",disabled:s,onClick:i,children:"Export CSV"})]}),t!==null&&e.jsx("div",{className:t.ok?"w6w-result":"w6w-result w6w-error","data-testid":"csv-result",children:t.message})]})}function ti({rows:t,empty:s,loading:n,searchValue:a,hasMore:i,onOpen:r,onSearch:l,onNew:o,onLoadMore:c}){const[d,m]=x.useState(a??""),g=w=>{w.preventDefault(),l(d)},j=[{key:"key",header:"Key",width:"26%",render:w=>e.jsx("button",{type:"button",className:"w6w-data-entry-key",title:w.key,"data-testid":"entry-key",onClick:f=>{f.stopPropagation(),r(w.key)},children:w.key})},{key:"value",header:"Value",render:w=>w.copyText!==void 0?e.jsx(U.Copyable,{value:w.copyText,label:"Copy value",className:"w6w-copyable--bare",children:e.jsx("span",{className:"w6w-data-entry-preview",children:w.preview})}):e.jsx("span",{className:"w6w-data-entry-preview",children:w.preview})}];return e.jsxs("div",{children:[e.jsxs("form",{className:"w6w-data-entries-toolbar","data-testid":"entry-search",onSubmit:g,children:[e.jsx("input",{type:"search","data-testid":"entry-prefix",value:d,placeholder:"Key prefix","aria-label":"Key prefix",onChange:w=>m(w.target.value)}),e.jsx("button",{className:"w6w-btn w6w-btn-ghost",type:"submit",children:"Search"}),e.jsx("button",{className:"w6w-btn w6w-data-entry-new",type:"button","data-testid":"entry-new",onClick:o,children:"+ New entry"})]}),e.jsx(p.DataTable,{className:"w6w-data-entry-list",onRowClick:w=>r(w.key),columns:j,rows:t,rowKey:w=>w.key,empty:e.jsx("div",{className:"w6w-muted w6w-small",children:n?"Loading…":s??"No entries match this key prefix."})}),i&&e.jsx("button",{className:"w6w-btn w6w-btn-ghost",type:"button","data-testid":"entries-load-more",onClick:c,children:"Load more"})]})}function si({kind:t,isNew:s,entryKey:n,newKey:a,expiresAt:i,text:r,error:l,conflict:o,saving:c,onTextChange:d,onKeyChange:m,onDelete:g,onSave:j,onCancel:w,onReload:f}){const[v,u]=x.useState(s),[h,b]=x.useState(!1),N=x.useRef(null);x.useEffect(()=>{var _;s||(_=N.current)==null||_.focus()},[s]);const S=t==="doc"?"document":"entry",k=t==="doc"?Ds(r):void 0,R=k!==void 0&&!k.ok,A=l||(h&&k&&!k.ok?k.message:null),D=e.jsxs(e.Fragment,{children:[s?e.jsxs("label",{className:"w6w-field",children:[e.jsx("span",{children:"Key"}),e.jsx("input",{"data-testid":"entry-new-key",value:a??"",placeholder:"Key","aria-label":"Key",onChange:_=>m(_.target.value)})]}):i?e.jsxs("p",{className:"w6w-muted w6w-small",children:["Expires ",i]}):null,t==="doc"?e.jsx(p.JsonEditor,{value:r,readOnly:!v,onChange:_=>{b(!1),d(_)},onFocus:()=>b(!1),onBlur:()=>b(!0),showDiagnostics:h,minHeight:"min(50vh, 400px)",maxHeight:"60vh"}):e.jsx(U.Copyable,{value:r,label:"Copy value",children:e.jsx("input",{type:"text","data-testid":"entry-value",value:r,"aria-label":"Value",readOnly:!v,onChange:_=>d(_.target.value)})}),A&&e.jsx("div",{className:"w6w-field-error",role:"alert","data-testid":"entry-value-error",children:A}),o&&e.jsxs("div",{className:"w6w-error","data-testid":"entry-conflict",children:[xt," ",e.jsx("button",{className:"w6w-btn w6w-btn-ghost",type:"button","data-testid":"entry-reload",onClick:f,children:"Reload"})]})]});return e.jsxs(p.Modal,{title:s?`New ${S}`:v?`Edit ${S}`:t==="doc"?"Document":"Entry",subtitle:s?void 0:n,size:t==="doc"?"wide":"default",onClose:c?()=>{}:w,children:[e.jsx("div",{className:"w6w-modal-body","data-testid":"entry-editor",children:D}),e.jsxs("div",{className:"w6w-modal-actions",children:[!s&&g&&e.jsx(p.DeleteButton,{label:"Delete entry",className:"w6w-data-entry-delete",disabled:c,onClick:g}),e.jsx("button",{ref:N,className:"w6w-btn w6w-btn-ghost",type:"button",disabled:c,onClick:w,children:v?"Cancel":"Close"}),v?e.jsx("button",{className:"w6w-btn",type:"button","data-testid":"entry-save",disabled:!!o||!!c||R||s&&!(a!=null&&a.trim()),onClick:j,children:"Save"}):e.jsx("button",{className:"w6w-btn",type:"button",disabled:c,onClick:()=>u(!0),children:"Edit"})]})]})}const _e=t=>t.isNew?"new":t.id;function ni({columns:t,keyColumn:s,rows:n,error:a,loading:i,empty:r,searchValue:l,hasMore:o,onCellChange:c,onSave:d,onDelete:m,onReload:g,onAddRow:j,onLoadMore:w,onSearch:f}){const[v,u]=x.useState(l??""),h=N=>{N.preventDefault(),f(v)},b=[...t.map(N=>({key:N.name,header:e.jsxs(e.Fragment,{children:[N.name," ",e.jsx("span",{className:"w6w-muted w6w-small",children:N.type})]}),render:S=>{var R;const k=(R=S.cellErrors)==null?void 0:R[N.name];return e.jsxs("div",{className:"w6w-data-cell",children:[e.jsx("input",{"data-row":_e(S),"data-column":N.name,value:S.cells[N.name]??"",readOnly:N.name===s&&!S.isNew,"aria-label":`${N.name} (${N.type})`,onChange:A=>c(S.id,N.name,A.target.value)}),k!==void 0&&e.jsx("div",{className:"w6w-data-cell-error","data-row":_e(S),"data-column":N.name,children:k})]})}})),{key:"actions",header:"",actions:!0,render:N=>e.jsxs("div",{className:"w6w-data-row-actions",children:[e.jsx("span",{className:"w6w-muted w6w-small",children:N.version===null?"":`v${N.version}`}),e.jsx(p.IconButton,{icon:"check",label:"Save row","data-row":_e(N),"data-testid":"row-save",disabled:!N.isNew&&!N.dirty||!!N.conflict,onClick:()=>d(N.id)}),e.jsx(p.DeleteButton,{label:"Delete entry",onClick:()=>m(N.id)}),N.conflict&&e.jsxs("div",{className:"w6w-error","data-row":_e(N),"data-testid":"row-conflict",children:[xt," ",e.jsx(p.IconButton,{icon:"sync",label:"Reload row","data-testid":"row-reload",onClick:()=>g(N.id)})]})]})}];return e.jsxs("div",{children:[a!=null&&a!==""&&e.jsx("div",{className:"w6w-error","data-testid":"grid-error",children:a}),e.jsxs("form",{className:"w6w-data-entries-toolbar","data-testid":"entry-search",onSubmit:h,children:[e.jsx("input",{type:"search","data-testid":"entry-prefix",value:v,placeholder:"Key prefix","aria-label":"Key prefix",onChange:N=>u(N.target.value)}),e.jsx("button",{className:"w6w-btn w6w-btn-ghost",type:"submit",children:"Search"}),e.jsx("button",{className:"w6w-btn w6w-btn-ghost",type:"button","data-testid":"grid-add-row",onClick:j,children:"Add row"})]}),e.jsx("div",{className:"w6w-data-grid-scroll","data-testid":"data-grid-scroll",children:e.jsx(p.DataTable,{columns:b,rows:n,rowKey:N=>N.id,empty:e.jsx("div",{className:"w6w-muted w6w-small",children:i?"Loading…":r??"No rows match this key prefix."})})}),o&&e.jsx("button",{className:"w6w-btn w6w-btn-ghost",type:"button","data-testid":"entries-load-more",onClick:w,children:"Load more"})]})}class ee extends Error{constructor(n,a){super(a);xe(this,"code");this.name="CallableRunError",this.code=n}}function Ms(t,s){const n=s==null?void 0:s.trim();if(n)return n;const a=t.split(".").filter(i=>i!=="");return a[a.length-1]??t}function Bs(t,s,n="send_confirmation"){const a=`${s}.${n}`;return t.find(i=>i.tags.includes(a))??null}function gt(t){return p.callableTriggers(t).map(s=>{var n;return{id:s.id,fields:p.asFieldDefs((n=s.with)==null?void 0:n.fields)}})}function ai(t){return"callableId"in t}function Fs(t,s,n,a){if(ai(t)){const r={kind:t.kind,id:t.callableId,input:{[t.field]:s}};return t.kind==="workflow"&&(r.entry=t.entry),r}const i={kind:t.kind,id:t.id,input:{[n]:s}};if(t.kind==="workflow"){const r=a?gt(a)[0]:void 0;if(!r)throw new ee("no-trigger",`Workflow ${t.name} has no manual trigger.`);i.entry=r.id}return i}async function Us(t,s){if(s.kind==="workflow"){const n=await t.runWorkflow(s.id,{entry:s.entry,input:s.input});if(n.error||n.status==="failed"||n.status==="error"){const a=n.error;throw new ee("failed",typeof a=="string"?a:a?JSON.stringify(a):`Workflow ${n.status}`)}return n.output}if(s.kind==="function")return t.invokeFunction(s.id,s.input);if(!t.invokeEndpoint)throw new ee("unsupported","This host does not support running endpoints.");return t.invokeEndpoint(s.id,s.input)}async function vt(t,s,n,a,i){const r=s.kind==="workflow"?await t.getWorkflow(s.id):void 0,l=Fs(s,n,a,r);return Us(t,i?{...l,input:{...l.input,...i}}:l)}async function ii(t,s){if(s.kind==="workflow"){let n;try{n=await t.getWorkflow(s.callableId)}catch{return`Workflow ${s.callableId} no longer exists.`}return!s.entry||!gt(n).some(a=>a.id===s.entry)?`Step ${s.entry??"(none)"} is no longer a manual trigger of ${s.callableId}.`:null}if(s.kind==="function")try{await t.getFunction(s.callableId)}catch{return`Function ${s.callableId} no longer exists.`}return null}async function Ws(t,s,n){if(!t.getCallableBinding)throw new ee("unsupported","This host does not support callable bindings.");const a=await t.getCallableBinding(s);if(!a)throw new ee("unbound",`No callable is bound to ${s}.`);const i=await ii(t,a);if(i)throw new ee("stale",i);return Us(t,Fs(a,n,a.field))}function Ks(t){return t instanceof Error?t:new Error(String(t))}function jt({onResult:t,onError:s}){const[n,a]=x.useState({status:"idle"}),i=x.useRef(!0);x.useEffect(()=>(i.current=!0,()=>{i.current=!1}),[]);const r=x.useRef({onResult:t,onError:s});r.current={onResult:t,onError:s};const l=x.useCallback(async o=>{var c,d,m,g;a({status:"loading"});try{const j=await o();i.current&&a({status:"success",output:j}),(d=(c=r.current).onResult)==null||d.call(c,j)}catch(j){const w=Ks(j);i.current&&a({status:"error",error:w}),(g=(m=r.current).onError)==null||g.call(m,w)}},[]);return{state:n,run:l}}function Vs(t){const s=p.useW6WApi(),[n,a]=x.useState({status:"loading"});return x.useEffect(()=>{let i=!0;if(!s.listCallables){a({status:"error",error:new ee("unsupported","This host does not support listing callables.")});return}return a({status:"loading"}),s.listCallables({tag:t}).then(r=>i&&a({status:"ready",refs:r})).catch(r=>i&&a({status:"error",error:Ks(r)})),()=>{i=!1}},[s,t]),n}function bt({error:t,onSetup:s}){const n=t instanceof ee&&(t.code==="stale"||t.code==="unbound");return e.jsxs("div",{className:"w6w-error w6w-small",role:"alert",children:[t.message,n&&s&&e.jsxs(e.Fragment,{children:[" ",e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:s,children:"Set up"})]})]})}function yt({callable:t,bindingKey:s,data:n,prop:a="data",onClose:i,onSetup:r,onResult:l,onError:o,title:c}){const d=p.useW6WApi(),{state:m,run:g}=jt({onResult:l,onError:o}),[j,w]=x.useState(""),[f,v]=x.useState(null),u=s||((t==null?void 0:t.name)??"callable"),h=()=>{let b;if(j.trim())try{const N=JSON.parse(j);if(!N||typeof N!="object"||Array.isArray(N))throw new Error("not an object");b=N}catch{v("Additional inputs must be a JSON object.");return}v(null),s?g(()=>Ws(d,s,n)):t&&g(()=>vt(d,t,n,a,b))};return e.jsxs(p.Modal,{title:c??`Run ${u}`,onClose:i,children:[e.jsx("div",{className:"w6w-modal-body",children:m.status==="success"?e.jsx(p.ResultViewer,{value:m.output}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"w6w-muted w6w-small",children:["Run ",u," with this data?"]}),e.jsx("pre",{className:"w6w-small",children:JSON.stringify(n,null,2)}),e.jsxs("label",{className:"w6w-small",children:["Additional inputs (JSON, optional)",e.jsx("textarea",{"aria-label":"Additional inputs",value:j,disabled:m.status==="loading",onChange:b=>w(b.target.value)})]}),f&&e.jsx("div",{className:"w6w-error w6w-small",children:f}),m.status==="error"&&e.jsx(bt,{error:m.error,onSetup:r})]})}),e.jsxs("div",{className:"w6w-modal-actions",children:[e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:i,children:m.status==="success"?"Close":"Cancel"}),m.status!=="success"&&e.jsx("button",{type:"button",className:"w6w-btn",onClick:h,disabled:m.status==="loading",children:m.status==="loading"?"Running…":"Run"})]})]})}function li({tag:t="",bindingKey:s,defaultAction:n,data:a,as:i,confirm:r=!1,label:l="Run",onSetup:o,onResult:c,onError:d}){const m=p.useW6WApi(),g=Vs(s?"":t),{state:j,run:w}=jt({onResult:c,onError:d}),[f,v]=x.useState(!1),u=Ms(t,i),h=g.status==="ready"?Bs(g.refs,t,n):null;let b=j.status==="loading",N=j.status==="loading"?"Running…":l;s||(g.status==="loading"?(b=!0,N="Loading…"):g.status==="ready"&&!h?(b=!0,N="No default action"):g.status==="error"&&(b=!0));const S=()=>{if(r)return v(!0);s?w(()=>Ws(m,s,a)):h&&w(()=>vt(m,h,a,u))},R=(!s&&g.status==="error"?g.error:null)??(j.status==="error"?j.error:null);return e.jsxs("span",{className:"w6w-run-callable",children:[e.jsx("button",{type:"button",className:"w6w-btn",disabled:b,onClick:S,children:N}),j.status==="success"&&e.jsx("span",{className:"w6w-muted w6w-small",children:" Done"}),R&&e.jsx(bt,{error:R,onSetup:o}),f&&e.jsx(yt,{callable:h??void 0,bindingKey:s,data:a,prop:u,onSetup:o,onClose:()=>v(!1),onResult:c,onError:d})]})}function ri({tag:t,defaultAction:s,data:n,as:a,confirm:i=!1,label:r="Run",onResult:l,onError:o}){const c=p.useW6WApi(),d=Vs(t),{state:m,run:g}=jt({onResult:l,onError:o}),[j,w]=x.useState(null),[f,v]=x.useState(!1),u=Ms(t,a),h=d.status==="ready"?d.refs:[],b=Bs(h,t,s),N=j??(b==null?void 0:b.id)??"",S=h.find(A=>A.id===N)??null,k=()=>{if(S){if(i)return v(!0);g(()=>vt(c,S,n,u))}},R=d.status==="error"?d.error:m.status==="error"?m.error:null;return e.jsxs("span",{className:"w6w-run-callables",children:[e.jsxs("select",{"aria-label":"Callable",value:N,disabled:d.status!=="ready"||m.status==="loading",onChange:A=>w(A.target.value),children:[d.status==="loading"&&e.jsx("option",{value:"",children:"Loading…"}),d.status==="ready"&&!S&&e.jsx("option",{value:"",disabled:!0,children:h.length===0?"Nothing to run":"Choose…"}),h.map(A=>e.jsx("option",{value:A.id,children:A.name},A.id))]})," ",e.jsx("button",{type:"button",className:"w6w-btn",disabled:!S||m.status==="loading",onClick:k,children:m.status==="loading"?"Running…":r}),m.status==="success"&&e.jsx("span",{className:"w6w-muted w6w-small",children:" Done"}),R&&e.jsx(bt,{error:R}),f&&S&&e.jsx(yt,{callable:S,data:n,prop:u,onClose:()=>v(!1),onResult:l,onError:o})]})}const Gt=t=>t instanceof Error?t:new Error(String(t));function oi({hostKey:t,tag:s="",onSaved:n,onError:a}){var F;const i=p.useW6WApi(),[r,l]=x.useState(null),[o,c]=x.useState(null),[d,m]=x.useState(""),[g,j]=x.useState({status:"idle"}),[w,f]=x.useState(""),[v,u]=x.useState(""),[h,b]=x.useState(!1),[N,S]=x.useState(!1),k=x.useRef(a);k.current=a;const R=x.useRef(C=>{var I;const B=Gt(C);c(B),(I=k.current)==null||I.call(k,B)}).current;x.useEffect(()=>{let C=!0;if(!i.listCallables||!i.saveCallableBinding){R(new ee("unsupported","This host does not support callable bindings."));return}return i.listCallables({tag:s}).then(B=>C&&l(B)).catch(B=>C&&R(B)),()=>{C=!1}},[i,s,R]);const A=(r==null?void 0:r.find(C=>C.id===d))??null;x.useEffect(()=>{if(f(""),u(""),S(!1),!A)return j({status:"idle"});let C=!0;return j({status:"loading"}),(async()=>{if(A.kind==="workflow"){const I=gt(await i.getWorkflow(A.id));return I.length===0?{status:"error",message:"This workflow has no manual trigger."}:{status:"ready",triggers:I,fields:[]}}if(A.kind==="function"){const I=await i.getFunction(A.id);return{status:"ready",triggers:[],fields:I.inputs.map(W=>W.key)}}return{status:"ready",triggers:[],fields:[]}})().then(I=>C&&j(I)).catch(I=>C&&j({status:"error",message:Gt(I).message})),()=>{C=!1}},[i,A]);const D=g.status==="ready"?g.triggers:[],_=D.length===1?D[0].id:w,V=(A==null?void 0:A.kind)==="workflow"?((F=D.find(C=>C.id===_))==null?void 0:F.fields.map(C=>C.key).filter(C=>!!C))??[]:g.status==="ready"?g.fields:[],M=(A==null?void 0:A.kind)==="workflow",P=!!A&&!!v&&(!M||!!_)&&!h,T=async()=>{if(!A||!i.saveCallableBinding)return;const C={kind:A.kind,callableId:A.id,field:v,...M?{entry:_}:{}};b(!0);try{await i.saveCallableBinding(t,C),S(!0),n==null||n(C)}catch(B){R(B)}finally{b(!1)}};return o&&!r?e.jsx("div",{className:"w6w-error w6w-small",role:"alert",children:o.message}):e.jsxs("div",{className:"w6w-callable-binding-setup",children:[e.jsxs("label",{className:"w6w-small",children:["Callable",e.jsxs("select",{"aria-label":"Callable",value:d,disabled:!r,onChange:C=>m(C.target.value),children:[e.jsx("option",{value:"",disabled:!0,children:r?"Choose…":"Loading…"}),(r??[]).map(C=>e.jsxs("option",{value:C.id,children:[C.name," (",C.kind,")"]},C.id))]})]}),g.status==="error"&&e.jsx("div",{className:"w6w-error w6w-small",role:"alert",children:g.message}),D.length>1&&e.jsxs("label",{className:"w6w-small",children:["Trigger",e.jsxs("select",{"aria-label":"Trigger",value:w,onChange:C=>{f(C.target.value),u("")},children:[e.jsx("option",{value:"",disabled:!0,children:"Choose…"}),D.map(C=>e.jsx("option",{value:C.id,children:C.id},C.id))]})]}),g.status==="ready"&&(!M||_)&&e.jsxs("div",{className:"w6w-small",children:["Field",V.length>0?e.jsxs("select",{"aria-label":"Field",value:v,onChange:C=>u(C.target.value),children:[e.jsx("option",{value:"",disabled:!0,children:"Choose…"}),V.map(C=>e.jsx("option",{value:C,children:C},C))]}):e.jsx("input",{"aria-label":"Field",value:v,placeholder:"input name",onChange:C=>u(C.target.value)})]}),e.jsx("button",{type:"button",className:"w6w-btn",disabled:!P,onClick:T,children:h?"Saving…":"Save binding"}),N&&e.jsx("span",{className:"w6w-muted w6w-small",children:" Saved"}),o&&r&&e.jsx("div",{className:"w6w-error w6w-small",role:"alert",children:o.message})]})}const ci={pending:"Pending",verified:"Verified",revoked:"Revoked",suspended:"Suspended"};function Js({status:t,className:s,testId:n}){return e.jsx("span",{className:["w6w-publisher-badge",`w6w-publisher-badge-${t}`,s].filter(Boolean).join(" "),"data-status":t,"data-testid":n,children:ci[t]})}function je({label:t,value:s,id:n}){return e.jsxs("div",{className:"w6w-verification-row","data-testid":`verification-${n}`,children:[e.jsx("span",{className:"w6w-verification-label",children:t}),e.jsx("code",{className:"w6w-verification-value",children:s}),e.jsx(U.Copyable,{value:s,label:`Copy ${t}`,children:e.jsx("span",{children:"Copy"})})]})}function Hs({instructions:t,className:s,testId:n}){const{dns:a,wellKnown:i,domain:r}=t;return e.jsxs("div",{className:["w6w-verification",s].filter(Boolean).join(" "),"data-testid":n,children:[e.jsxs("p",{children:["Prove you control ",r," with either method:"]}),e.jsx("h4",{children:"DNS record"}),e.jsx(je,{label:"Type",value:a.type,id:"dns-type"}),e.jsx(je,{label:"Name",value:a.name,id:"dns-name"}),e.jsx(je,{label:"Value",value:a.value,id:"dns-value"}),e.jsx("h4",{children:"Well-known file"}),e.jsx(je,{label:"URL",value:i.url,id:"wk-url"}),e.jsx(je,{label:"Body",value:i.body,id:"wk-body"})]})}function di({namespaces:t,onVerify:s,onRevoke:n,detail:a,busyPrefix:i,canManage:r=!0,className:l,testId:o}){return t.length===0?e.jsx("p",{className:l,"data-testid":o,children:"No namespaces claimed yet."}):e.jsx("ul",{className:["w6w-namespace-list",l].filter(Boolean).join(" "),"data-testid":o,children:t.map(c=>e.jsxs("li",{"data-testid":`namespace-${c.prefix}`,children:[e.jsx("strong",{children:c.prefix})," ",e.jsx("span",{children:c.domain})," ",e.jsx(Js,{status:c.status}),c.status==="pending"?e.jsxs(e.Fragment,{children:[e.jsx(Hs,{instructions:c.instructions}),e.jsx("button",{type:"button","data-testid":`verify-${c.prefix}`,disabled:i===c.prefix,onClick:()=>s(c.prefix),children:"Verify"}),a!=null&&a[c.prefix]?e.jsx("p",{role:"alert","data-testid":`detail-${c.prefix}`,children:a[c.prefix]}):null]}):null,c.status!=="revoked"?e.jsx("button",{type:"button","data-testid":`revoke-${c.prefix}`,disabled:!r,onClick:()=>n(c.prefix),children:"Revoke"}):null]},c.prefix))})}function ui({members:t,canManage:s,onAdd:n,onRemove:a,className:i,testId:r}){const[l,o]=x.useState(""),[c,d]=x.useState("developer");return e.jsxs("div",{className:["w6w-publisher-members",i].filter(Boolean).join(" "),"data-testid":r,children:[e.jsx("ul",{className:"w6w-publisher-member-list",children:t.map(m=>e.jsxs("li",{"data-testid":`member-${m.subject}`,children:[e.jsx("span",{children:m.subject})," ",e.jsx("span",{children:m.role}),e.jsx("button",{type:"button","data-testid":`remove-${m.subject}`,disabled:!s,onClick:()=>a(m.subject),children:"Remove"})]},m.subject))}),e.jsxs("form",{className:"w6w-publisher-member-add",onSubmit:m=>{m.preventDefault();const g=l.trim();!g||!s||(n(g,c),o(""))},children:[e.jsx("input",{"aria-label":"Member subject","data-testid":"member-subject",value:l,disabled:!s,onChange:m=>o(m.target.value)}),e.jsxs("select",{"aria-label":"Member role","data-testid":"member-role",value:c,disabled:!s,onChange:m=>d(m.target.value),children:[e.jsx("option",{value:"developer",children:"developer"}),e.jsx("option",{value:"owner",children:"owner"})]}),e.jsx("button",{type:"submit","data-testid":"member-add",disabled:!s||!l.trim(),children:"Add member"})]})]})}function wi({onCreate:t,busy:s,error:n,className:a,testId:i}){const[r,l]=x.useState(""),[o,c]=x.useState(""),d=r.trim()!==""&&o.trim()!=="";return e.jsxs("form",{className:["w6w-publisher-form",a].filter(Boolean).join(" "),"data-testid":i,onSubmit:m=>{m.preventDefault(),d&&!s&&t({slug:r.trim(),displayName:o.trim()})},children:[e.jsx("h3",{children:"Become a publisher"}),e.jsx("p",{children:"Create a publisher to claim namespaces and publish apps."}),e.jsx("input",{"aria-label":"Publisher slug","data-testid":"publisher-slug",value:r,onChange:m=>l(m.target.value)}),e.jsx("input",{"aria-label":"Display name","data-testid":"publisher-display-name",value:o,onChange:m=>c(m.target.value)}),e.jsx("button",{type:"submit","data-testid":"publisher-create",disabled:!d||s,children:"Become a publisher"}),n?e.jsx("p",{role:"alert",children:n}):null]})}const mi={private:"Not submitted",submitted:"Submitted for review",in_review:"In review",changes_requested:"Changes requested",listed:"Listed",rejected:"Rejected",suspended:"Suspended",delisted:"Delisted"},hi={submitted:"Submitted",in_review:"In review",changes_requested:"Changes requested",approved:"Approved",rejected:"Rejected",auto_approved:"Auto-approved",superseded:"Superseded"},pi={validator:"Validator",digest:"Digest",sandbox_describe:"Sandbox describe",auth_test_hook:"Auth test hook",health_check:"Health check",network_wildcard:"Network wildcard",listing_copy:"Listing copy",capability_summary:"Capability summary",reviewer_notes:"Reviewer notes"};function fi({listing:t,submissions:s,className:n,testId:a}){return!t&&s.length===0?null:e.jsxs("div",{className:["w6w-listing-status",n].filter(Boolean).join(" "),"data-testid":a,children:[t?e.jsx("span",{className:"w6w-listing-state","data-listing-state":t.state,children:mi[t.state]??t.state}):null,t!=null&&t.listedVersion?e.jsxs("span",{className:"w6w-listing-listed-version",children:["v",t.listedVersion]}):null,s.length>0?e.jsx("ol",{className:"w6w-listing-submissions",children:s.map(i=>e.jsxs("li",{className:"w6w-listing-submission","data-submission-id":i.id,"data-submission-status":i.status,children:[e.jsxs("div",{className:"w6w-listing-submission-head",children:[e.jsx("span",{className:"w6w-listing-submission-status",children:hi[i.status]??i.status}),e.jsxs("span",{className:"w6w-listing-submission-version",children:["v",i.version]}),e.jsx("time",{className:"w6w-listing-submission-when",dateTime:i.createdAt,children:i.createdAt})]}),i.checks.length>0?e.jsx("ul",{className:"w6w-listing-checks",children:i.checks.map(r=>e.jsxs("li",{className:"w6w-listing-check","data-check-key":r.key,"data-check-outcome":r.outcome,children:[e.jsx("span",{className:"w6w-listing-check-key",children:pi[r.key]??r.key}),e.jsx("span",{className:"w6w-listing-check-outcome",children:r.outcome}),e.jsx("span",{className:"w6w-listing-check-message",children:r.message})]},r.key))}):null,i.reasons?e.jsx("p",{className:"w6w-listing-reasons",children:i.reasons}):null,i.hasReviewerNotes?e.jsx("span",{className:"w6w-listing-notes-sent",children:"Reviewer notes sent"}):null]},i.id))}):null]})}const xi={invalid_body:"Some of these listing details aren't valid. Fix the highlighted fields and try again.",namespace_owned:"Another publisher already owns one of this app's namespaces.",namespace_reserved:"One of this app's namespaces is reserved by W6W.",publisher_suspended:"Your publisher account is suspended, so it can't submit apps for listing.",not_publisher_tier:"This publisher's plan doesn't include submitting apps for listing.",unknown_version:"That version doesn't exist for this app. Deploy it first, then submit.",submission_pending:"This app already has a submission waiting for a decision. Submit again once it's decided.",listing_delisted:"This app's listing was delisted. Ask W6W to review it again before submitting.",invalid_transition:"This listing can't go back to submitted from where it is now.",stale_submission:"A reviewer already decided on an older submission. Reload to see the current state.",app_delisted:"This app was delisted, so it can't be submitted for listing.",app_suspended:"This app is suspended. It can't take new connections or submissions until it's reinstated.",not_found:"We couldn't find that app on this publisher account."},gi="Something went wrong submitting this listing. Try again in a moment.";function qs(t){return xi[t]??gi}const ot=280,Xt=5,Zt=4e3;function Qt(t){if(!/^https:\/\//i.test(t))return!1;try{return new URL(t).hostname!==""}catch{return!1}}function vi(t){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)}function Ys(t){const s=[],{version:n,listing:a}=t;n.trim()===""&&s.push({field:"version",message:"Choose the app version to submit."});const i=a.summary.trim();i===""?s.push({field:"summary",message:"Add a one-line summary of what the app does."}):i.length>ot&&s.push({field:"summary",message:`Keep the summary to ${ot} characters or fewer (it's ${i.length}).`}),a.categories.length>Xt&&s.push({field:"categories",message:`Pick at most ${Xt} categories (you picked ${a.categories.length}).`});const r=a.supportUrl.trim();r===""?s.push({field:"supportUrl",message:"Add an https support URL reviewers can open."}):Qt(r)||s.push({field:"supportUrl",message:"The support URL must start with https://."});const l=(a.privacyUrl??"").trim();l!==""&&!Qt(l)&&s.push({field:"privacyUrl",message:"The privacy URL must start with https://."});const o=a.contactEmail.trim();o===""?s.push({field:"contactEmail",message:"Add a contact email so reviewers can reach you."}):vi(o)||s.push({field:"contactEmail",message:"That contact email doesn't look like an email address."});const c=(a.reviewerNotes??"").trim();return c.length>Zt&&s.push({field:"reviewerNotes",message:`Keep reviewer notes to ${Zt} characters or fewer (they're ${c.length}).`}),s}function ji(t){const s=t.listing.summary.trim(),n=(t.listing.iconRef??"").trim(),a=(t.listing.privacyUrl??"").trim(),i=(t.listing.reviewerNotes??"").trim(),r=t.listing.categories.map(l=>l.trim()).filter(Boolean);return{version:t.version.trim(),listing:{summary:s,...n?{iconRef:n}:{},categories:r,supportUrl:t.listing.supportUrl.trim(),...a?{privacyUrl:a}:{},contactEmail:t.listing.contactEmail.trim(),...i?{reviewerNotes:i}:{}}}}const bi={version:"",summary:"",iconRef:"",categories:"",supportUrl:"",privacyUrl:"",contactEmail:"",reviewerNotes:""};function yi({appId:t,versions:s,onSubmit:n,busy:a,errorCode:i,className:r,testId:l}){const[o,c]=x.useState(bi),[d,m]=x.useState([]),g=u=>h=>c(b=>({...b,[u]:h})),j={version:o.version,listing:{summary:o.summary,iconRef:o.iconRef,categories:o.categories.split(",").map(u=>u.trim()).filter(Boolean).filter((u,h,b)=>b.indexOf(u)===h),supportUrl:o.supportUrl,privacyUrl:o.privacyUrl,contactEmail:o.contactEmail,reviewerNotes:o.reviewerNotes}},w=u=>`listing-${u.replace(/[A-Z]/g,h=>`-${h.toLowerCase()}`)}`,f=u=>{var h;return((h=d.find(b=>b.field===u))==null?void 0:h.message)??""},v=(u,h,b,N)=>e.jsxs("label",{className:"w6w-listing-form-field","data-field":b,children:[e.jsx("span",{className:"w6w-listing-form-label",children:h}),e.jsx("input",{"aria-label":h,"aria-invalid":f(b)!==""||void 0,"data-testid":w(u),value:o[u],onChange:S=>g(u)(S.target.value)}),N?e.jsx("span",{className:"w6w-listing-form-hint",children:N}):null,f(b)?e.jsx("span",{className:"w6w-listing-form-error",role:"alert","data-field-error":b,children:f(b)}):null]});return e.jsxs("form",{className:["w6w-listing-form",r].filter(Boolean).join(" "),"data-testid":l,"data-app-id":t,noValidate:!0,onSubmit:u=>{u.preventDefault();const h=Ys(j);m(h),h.length===0&&!a&&n(ji(j))},children:[e.jsx("h3",{children:"Submit for listing"}),e.jsx("p",{children:"Reviewers check this version, then W6W lists it in the catalog."}),e.jsxs("label",{className:"w6w-listing-form-field","data-field":"version",children:[e.jsx("span",{className:"w6w-listing-form-label",children:"Version"}),e.jsx("input",{"aria-label":"Version",list:"listing-versions","aria-invalid":f("version")!==""||void 0,"data-testid":"listing-version",value:o.version,onChange:u=>g("version")(u.target.value)}),e.jsx("datalist",{id:"listing-versions",children:(s??[]).map(u=>e.jsx("option",{value:u},u))}),f("version")?e.jsx("span",{className:"w6w-listing-form-error",role:"alert","data-field-error":"version",children:f("version")}):null]}),v("summary","Summary","summary",`Up to ${ot} characters.`),v("iconRef","Icon reference","iconRef"),v("categories","Categories","categories","Comma-separated, up to five."),v("supportUrl","Support URL","supportUrl","https:// only."),v("privacyUrl","Privacy URL","privacyUrl","Optional, https:// only."),v("contactEmail","Contact email","contactEmail","Where reviewers reach you."),v("reviewerNotes","Notes for the reviewer","reviewerNotes","Optional, up to 4000 characters."),e.jsx("button",{type:"submit","data-testid":"listing-submit",disabled:a,children:"Submit for listing"}),i?e.jsx("p",{className:"w6w-listing-error",role:"alert",children:qs(i)}):null]})}exports.AddConnectionModal=p.AddConnectionModal;exports.ApiCallsPanel=p.ApiCallsPanel;exports.AppConnectionForm=p.AppConnectionForm;exports.AppIcon=p.AppIcon;exports.AppPicker=p.AppPicker;exports.AuthFieldsForm=p.AuthFieldsForm;exports.AuthGuide=p.AuthGuide;exports.CanvasLayer=p.CanvasLayer;exports.CodeEditor=p.CodeEditor;exports.Combobox=p.Combobox;exports.ConfirmModal=p.ConfirmModal;exports.CredentialPicker=p.CredentialPicker;exports.DataTable=p.DataTable;exports.DelegationSteps=p.DelegationSteps;exports.DeleteButton=p.DeleteButton;exports.EmptyState=p.EmptyState;exports.ExpressionEditorModal=p.ExpressionEditorModal;exports.ExpressionInput=p.ExpressionInput;exports.ExpressionOptionsProvider=p.ExpressionOptionsProvider;exports.HTML_PREVIEW_CSP=p.HTML_PREVIEW_CSP;exports.HtmlPreview=p.HtmlPreview;exports.IconButton=p.IconButton;exports.JsonEditor=p.JsonEditor;exports.LastUsedNote=p.LastUsedNote;exports.Markdown=p.Markdown;exports.Modal=p.Modal;exports.NodeConfigForm=p.NodeConfigForm;exports.ParamsForm=p.ParamsForm;exports.PropertyEntryForm=p.PropertyEntryForm;exports.PublisherBadge=p.PublisherBadge;exports.RESULT_RENDER_MAX_CHARS=p.RESULT_RENDER_MAX_CHARS;exports.ResultViewer=p.ResultViewer;exports.RetryPolicyFields=p.RetryPolicyFields;exports.SecretJsonField=p.SecretJsonField;exports.StepBuilderModal=p.StepBuilderModal;exports.W6WUIProvider=p.W6WUIProvider;exports.connectionAppIdsToLookUp=p.connectionAppIdsToLookUp;exports.detectResultFormat=p.detectResultFormat;exports.effectiveNodeOutput=p.effectiveNodeOutput;exports.effectiveNodeOutputs=p.effectiveNodeOutputs;exports.filterOptions=p.filterOptions;exports.findTestInput=p.findTestInput;exports.htmlPreviewSrcDoc=p.htmlPreviewSrcDoc;exports.indexNodeSamples=p.indexNodeSamples;exports.isExprValue=p.isExprValue;exports.isFormResolvedOptions=p.isFormResolvedOptions;exports.isSecretValue=p.isSecretValue;exports.isTestRequired=p.isTestRequired;exports.keyClientId=p.keyClientId;exports.previewNodeOutputs=p.previewNodeOutputs;exports.rememberableInput=p.rememberableInput;exports.requiredParamsFilled=p.requiredParamsFilled;exports.resolveConnectionAppMeta=p.resolveConnectionAppMeta;exports.resultCopyText=p.resultCopyText;exports.secretClipboard=p.secretClipboard;exports.shapeToSkeleton=p.shapeToSkeleton;exports.shouldUseCombobox=p.shouldUseCombobox;exports.splitFrontmatter=p.splitFrontmatter;exports.startOAuthPopup=p.startOAuthPopup;exports.testInputSavesSettled=p.testInputSavesSettled;exports.trackTestInputSave=p.trackTestInputSave;exports.useEnterSubmit=p.useEnterSubmit;exports.useExpressionOptions=p.useExpressionOptions;exports.useRememberedTestInput=p.useRememberedTestInput;exports.useW6WApi=p.useW6WApi;exports.CodeBlock=U.CodeBlock;exports.Copyable=U.Copyable;exports.Icon=U.Icon;exports.iconNames=U.iconNames;exports.ATTENTION_DISPLAY_CAP=it;exports.ActionTestForm=yn;exports.ApiError=be;exports.BudgetMeter=Aa;exports.CELL_PROBLEM_COPY=As;exports.CSV_MAX_BYTES=Es;exports.CSV_TOO_LARGE_COPY=Os;exports.CallableBindingSetup=oi;exports.CallableList=ya;exports.CallableListStatus=ja;exports.ColumnsEditor=Qa;exports.ConnectionHeader=Sa;exports.ConnectionKeepAlive=Ca;exports.ConnectionList=Na;exports.CopyableText=ns;exports.CreatePublisherForm=wi;exports.CreateSharedCredentialContext=gn;exports.CsvPanel=ei;exports.DATA_STORE_ERROR_FALLBACK=pe;exports.DATA_STORE_KINDS=Ra;exports.DATA_STORE_KIND_LABEL=Cs;exports.DATA_STORE_NETWORK_ERROR=$s;exports.DOC_VALUE_COPY=rt;exports.DataEntryEditor=si;exports.DataEntryList=ti;exports.DataStoreList=Ga;exports.DataTableGrid=ni;exports.EditButton=Wn;exports.EditConnectionModal=ka;exports.ExecutionDetail=ha;exports.ExecutionFilters=ca;exports.ExecutionList=Yn;exports.ExecutionLogDock=na;exports.ExecutionLogPanel=rs;exports.ExecutionLogView=Qn;exports.ExecutionStats=da;exports.HealthStatusPill=Fe;exports.HistoryTimeline=Fn;exports.InfoTip=Un;exports.ListItem=Oe;exports.ListingStatus=fi;exports.NEW_ROW_ID=ft;exports.NamespaceList=di;exports.PublisherMembers=ui;exports.PublisherStatusBadge=Js;exports.RECENT_DISPLAY_CAP=vs;exports.ReliabilityChart=bs;exports.ReliabilityList=va;exports.RepoSyncIndicator=Kn;exports.RowActionsMenu=dt;exports.RunCallableButton=li;exports.RunCallableModal=yt;exports.RunCallables=ri;exports.SCALAR_TYPES=ht;exports.ServerResourcesBadge=_n;exports.ServerResourcesCard=Rn;exports.ServerResourcesCardSmall=$n;exports.ServerResourcesRail=Tn;exports.StepStatusPill=Se;exports.SubmitListingForm=yi;exports.UptimeStrip=as;exports.VERSION_CONFLICT_COPY=xt;exports.VerificationInstructionsBlock=Hs;exports.YamlEditor=Nn;exports.buildRowValue=Ka;exports.cellErrorsOf=Ha;exports.createW6WApi=xn;exports.cropText=ss;exports.csvFilenameOf=_a;exports.csvImportMessage=za;exports.csvLineOf=lt;exports.dirtyColumns=Wa;exports.displayBoard=js;exports.draftFromEntry=Fa;exports.errorPlacement=Ls;exports.formatDurationMs=Ue;exports.formatExecutionTime=ye;exports.isCellValue=Ma;exports.isVersionConflict=qa;exports.kvValueOf=Ya;exports.kvValueTypeOf=$a;exports.listingErrorCopy=qs;exports.locateDataStoreError=Ba;exports.locateRawResponseError=Is;exports.needsAttention=fa;exports.newRowDraft=Ua;exports.parseCell=We;exports.parseDocText=Ds;exports.partitionBoard=xs;exports.performancePoints=fs;exports.refreshRelativeTime=Ss;exports.remainingTtlSeconds=Va;exports.rowValueOf=Ps;exports.rowWriteOf=Ja;exports.serializeCell=Ke;exports.tableSchemaOf=Ta;exports.uptimeDays=gs;exports.validateListingInput=Ys;
1
+ "use client";"use strict";var fn=Object.defineProperty;var xn=(t,s,n)=>s in t?fn(t,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[s]=n;var xe=(t,s,n)=>xn(t,typeof s!="symbol"?s+"":s,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("./connection-app-meta-CQ85y_6M.cjs"),f=require("react"),e=require("react/jsx-runtime"),K=require("./CodeBlock-85y9qvE3.cjs"),gn=require("@codemirror/lang-yaml"),vn=require("@codemirror/view"),jn=require("@uiw/react-codemirror"),ns=require("react-dom");class be extends Error{constructor(n,a,i,l){super(i);xe(this,"status");xe(this,"code");xe(this,"body");this.name="ApiError",this.status=n,this.code=a,this.body=l}}function bn(t){const s=t.baseUrl.replace(/\/$/,""),n=t.fetch??globalThis.fetch,a=async()=>typeof t.token=="function"?await t.token():t.token;async function i(o,r){const c=new Headers(r==null?void 0:r.headers),d=await a();d&&c.set("authorization",`Bearer ${d}`),r!=null&&r.body&&!c.has("content-type")&&c.set("content-type","application/json");let m;try{m=await n(`${s}${o}`,{...r,headers:c})}catch(w){throw new be(0,"network_error",`Could not reach the w6w server (${(r==null?void 0:r.method)??"GET"} ${s}${o}). It may be down or unreachable. (${w.message})`)}const x=await m.text();let j=null;if(x)try{j=JSON.parse(x)}catch{if(!m.ok)throw new be(m.status,"bad_response",`Server returned a non-JSON ${m.status} response: ${x.slice(0,200)}`)}if(!m.ok){const w=(j==null?void 0:j.error)??{};throw new be(m.status,w.code??"error",w.message??m.statusText,j)}return{status:m.status,data:j}}async function l(o,r){const{data:c}=await i(o,r);return c}return{listApps:async()=>{const o=async()=>{const r=[];let c;for(;;){const d=new URLSearchParams({limit:"200"});c&&d.set("cursor",c);const m=await l(`/apps?${d}`);if(r.push(...m.apps),!m.nextCursor||m.nextCursor===c)return r;c=m.nextCursor}};try{return await o()}catch(r){if(r instanceof be&&(r.code==="snapshot_expired"||r.code==="unknown_snapshot"))return await o();throw r}},listAppsByIds:async o=>{const r=Array.from(new Set(o)),c=[];for(let d=0;d<r.length;d+=100){const x=r.slice(d,d+100).map(encodeURIComponent).join(","),j=await l(`/apps?ids=${x}`);c.push(...j.apps)}return c},getAppAuth:async o=>(await l(`/apps/${encodeURIComponent(o)}/auths`)).auths??[],createConnection:(o,r)=>l(`/apps/${encodeURIComponent(o)}/connections`,{method:"POST",body:JSON.stringify(r)}).then(c=>c.connection),updateConnection:(o,r)=>l(`/connections/${encodeURIComponent(o)}`,{method:"PATCH",body:JSON.stringify(r)}).then(c=>c.connection),listCredentials:o=>{const r=new URLSearchParams;(o==null?void 0:o.contract)!==void 0&&r.set("contract",o.contract),(o==null?void 0:o.appId)!==void 0&&r.set("appId",o.appId),(o==null?void 0:o.authKey)!==void 0&&r.set("authKey",o.authKey);const c=r.toString();return l(`/credentials${c?`?${c}`:""}`).then(d=>d.credentials??[])},createCredential:o=>l("/credentials",{method:"POST",body:JSON.stringify(o)}).then(r=>r.credential),getCredential:o=>l(`/credentials/${encodeURIComponent(o)}`).then(r=>r.credential),rotateCredential:(o,r)=>l(`/credentials/${encodeURIComponent(o)}/rotate`,{method:"POST",body:JSON.stringify(r)}).then(c=>c.credential),setCredentialStatus:(o,r)=>l(`/credentials/${encodeURIComponent(o)}/${r==="disabled"?"disable":"enable"}`,{method:"POST"}).then(c=>c.credential),testCredential:o=>l(`/credentials/${encodeURIComponent(o)}/test`,{method:"POST"}),credentialDependents:o=>l(`/credentials/${encodeURIComponent(o)}/dependents`).then(r=>r.dependents),deleteCredential:async o=>{await l(`/credentials/${encodeURIComponent(o)}`,{method:"DELETE"})},startAppOAuthFlow:(o,r,c)=>l(`/apps/${encodeURIComponent(o)}/oauth-config/${encodeURIComponent(r)}/authorize-url`,{method:"POST",body:JSON.stringify(c)}),getAppActions:o=>l(`/apps/${encodeURIComponent(o)}`).then(r=>r.actions??[]),listConnectionsForApp:o=>l(`/apps/${encodeURIComponent(o)}/connections`).then(r=>r.connections??[]),listConnections:()=>l("/connections").then(o=>o.connections??[]),invokeAction:(o,r,c,d={})=>l(`/apps/${encodeURIComponent(o)}/actions/${encodeURIComponent(r)}/invoke`,{method:"POST",body:JSON.stringify({params:c,connectionId:d.connectionId,project:d.project,state:d.state,workflowId:d.workflowId,timeoutMs:d.timeoutMs})}),listSavedTests:o=>l(`/connections/${encodeURIComponent(o)}/saved-tests`).then(r=>r.savedTests??[]),createSavedTest:(o,r)=>l(`/connections/${encodeURIComponent(o)}/saved-tests`,{method:"POST",body:JSON.stringify(r)}).then(c=>c.savedTest),updateSavedTest:(o,r,c)=>l(`/connections/${encodeURIComponent(o)}/saved-tests/${encodeURIComponent(r)}`,{method:"PATCH",body:JSON.stringify(c)}).then(d=>d.savedTest),deleteSavedTest:(o,r)=>l(`/connections/${encodeURIComponent(o)}/saved-tests/${encodeURIComponent(r)}`,{method:"DELETE"}).then(()=>{}),recordTestRun:(o,r)=>l(`/connections/${encodeURIComponent(o)}/test-runs`,{method:"POST",body:JSON.stringify(r)}).then(()=>{}),listTestRuns:o=>l(`/connections/${encodeURIComponent(o)}/test-runs`).then(r=>r.runs??[]),saveStepTest:(o,r,c)=>l(`/workflows/${encodeURIComponent(o)}/steps/${encodeURIComponent(r)}/tests`,{method:"POST",body:JSON.stringify(c)}).then(d=>d.stepTest),listStepTests:(o,r)=>l(`/workflows/${encodeURIComponent(o)}/steps/${encodeURIComponent(r)}/tests`).then(c=>c.stepTests??[]),loadNodeSamples:o=>l(`/workflows/${encodeURIComponent(o)}/node-samples`).then(r=>r.nodeSamples??[]),loadTestInputs:o=>l(`/workflows/${encodeURIComponent(o)}/test-inputs`).then(r=>r.testInputs??[]),saveTestInput:(o,r,c)=>l(`/workflows/${encodeURIComponent(o)}/nodes/${encodeURIComponent(r)}/test-input`,{method:"PUT",body:JSON.stringify({input:c})}).then(()=>{}),recordStepTestRun:(o,r,c)=>l(`/workflows/${encodeURIComponent(o)}/steps/${encodeURIComponent(r)}/test-runs`,{method:"POST",body:JSON.stringify(c)}).then(()=>{}),listFunctions:()=>l("/functions").then(o=>o.functions??[]),getFunction:o=>l(`/functions/${encodeURIComponent(o)}`).then(r=>({...r.function,valid:r.valid})),invokeFunction:(o,r)=>l(`/functions/${encodeURIComponent(o)}/invoke`,{method:"POST",body:JSON.stringify({inputs:r})}).then(c=>c.output),listWorkflows:()=>l("/workflows").then(o=>o.workflows??[]),getWorkflow:o=>l(`/workflows/${encodeURIComponent(o)}`).then(r=>r.workflow),runWorkflow:(o,r={})=>i(`/workflows/${encodeURIComponent(o)}/run?wait=true`,{method:"POST",body:JSON.stringify({variables:r.variables,input:r.input,entry:r.entry})}).then(({status:c,data:d})=>({...d??{},terminal:c===200}))}}const yn=f.createContext(void 0);function Pe({title:t,subtitle:s,icon:n,trailing:a,active:i=!1,onClick:l,href:o,ariaLabel:r}){const c=e.jsxs(e.Fragment,{children:[n!=null&&e.jsx("span",{className:"w6w-list-item-icon",children:n}),e.jsxs("span",{className:"w6w-list-item-body",children:[e.jsx("span",{className:"w6w-list-item-title",children:t}),s!=null&&e.jsx("span",{className:"w6w-list-item-subtitle",children:s})]}),a!=null&&e.jsx("span",{className:"w6w-list-item-trailing",children:a})]}),d=`w6w-list-item${i?" active":""}`;return o!==void 0?e.jsx("a",{className:d,href:o,"aria-current":i?"true":void 0,"aria-label":r,onClick:l,children:c}):l?e.jsx("button",{type:"button",className:d,"aria-pressed":i,"aria-label":r,onClick:l,children:c}):e.jsx("div",{className:d,"aria-label":r,children:c})}function Xe(t){const s=Date.parse(t);if(Number.isNaN(s))return"";const n=Math.max(0,Math.round((Date.now()-s)/1e3));if(n<45)return"just now";const a=Math.round(n/60);if(a<60)return`${a}m ago`;const i=Math.round(a/60);if(i<24)return`${i}h ago`;const l=Math.round(i/24);return l<7?`${l}d ago`:new Date(s).toLocaleDateString()}function Bt(t){const s={};for(const n of(t==null?void 0:t.params)??[])n.key&&n.default!==void 0&&(s[n.key]=n.default);return s}function Nn(t){var n,a,i;const s=t.indexOf("{");if(s>=0)try{const l=JSON.parse(t.slice(s)),o=((a=(n=l==null?void 0:l.errors)==null?void 0:n[0])==null?void 0:a.message)??(typeof(l==null?void 0:l.error)=="object"?(i=l.error)==null?void 0:i.message:l==null?void 0:l.error)??(l==null?void 0:l.message);if(typeof o=="string"&&o.trim()){const r=t.slice(0,s).replace(/[:\s]+$/,"");return r?`${r}: ${o.trim()}`:o.trim()}}catch{}return t}function as(t){return typeof t=="object"&&t!==null&&typeof t.status=="number"&&typeof t.code=="string"}function kn(t){if(!as(t))return{headline:(t==null?void 0:t.message)??"The action failed to run."};const s=Nn(t.message??""),n=`${t.status} ${t.code} ${t.message??""}`.toLowerCase();return t.status===401||t.status===403||/\b(401|403)\b|forbidden|unauthorized|not authorized|permission|scope|access denied|invalid api key|invalid credential/.test(n)?{headline:"Permission denied by the provider — this is a credential/scope problem, not a w6w error.",hint:"The connection's API key is missing the permissions this action needs. Fix it at the provider — e.g. SendGrid → Settings → API Keys → give the key the required scopes (or Full Access), or create a new key — then update this connection's credential and try again.",detail:s}:{headline:"The action returned an error.",detail:s}}function Sn(t){const s=as(t)?t.body??t.raw:null;return(s==null?void 0:s.apiCalls)??[]}function Ze(){const[t,s]=f.useState(""),[n,a]=f.useState(void 0),[i,l]=f.useState(!1);return{text:t,value:n,invalid:i,onChange:r=>{s(r);const c=r.trim();if(c===""){l(!1);return}try{const d=JSON.parse(c);d!==null&&typeof d=="object"&&!Array.isArray(d)?(a(d),l(!1)):l(!0)}catch{l(!0)}}}}function Cn({appId:t,actions:s,connectionId:n,action:a,seedValues:i,onSavedTestsChanged:l,seedTestId:o,onDirtyChange:r,onTestSaved:c,onDeleted:d,embedded:m=!1}){var Dt;const x=h.useW6WApi(),j=f.useMemo(()=>{const y=[...s];return y.sort((B,z)=>(B.title||B.key).localeCompare(z.title||z.key)),y},[s]),[w,p]=f.useState((a==null?void 0:a.key)??""),v=a??s.find(y=>y.key===w)??null,[u,g]=f.useState(!1),[b,N]=f.useState(null),[S,k]=f.useState(void 0),[T,A]=f.useState([]),F=Ze(),C=Ze(),P=Ze(),[O,I]=f.useState(""),[$,D]=f.useState(""),E=F.invalid||C.invalid||P.invalid,U=()=>{const y={};return F.text.trim()!==""&&F.value!==void 0&&(y.body=F.value),C.text.trim()!==""&&C.value!==void 0&&(y.query=C.value),P.text.trim()!==""&&P.value!==void 0&&(y.headers=P.value),O&&(y.target=O),$.trim()!==""&&(y.match=$.trim()),Object.keys(y).length>0?y:void 0},[L,W]=f.useState("form"),[Q,Z]=f.useState(""),[X,le]=f.useState(!1),[q,R]=f.useState(!1),V=(v==null?void 0:v.key)??null,re=i?{...i}:Bt(v),[oe,_]=f.useState(()=>({key:V,values:re})),[M,J]=f.useState(o??null),[Y,ce]=f.useState(re);if(oe.key!==V){const y=Bt(v);_({key:V,values:y}),ce(y),J(o??null),N(null),k(void 0),A([])}const[H,ue]=f.useState(o);o!==H&&(ue(o),J(o??null));const[Et,Qs]=f.useState(i);if(i!==Et){const y=JSON.stringify(i??null)!==JSON.stringify(Et??null);if(Qs(i),i&&y){const B={...i};_({key:V,values:B}),ce(B),N(null),k(void 0),A([])}}const te=oe.values,Rt=y=>_({key:V,values:y}),At=f.useMemo(()=>JSON.stringify(te)!==JSON.stringify(Y),[te,Y]);f.useEffect(()=>{r==null||r(At)},[At]);const en=()=>{Z(JSON.stringify(te,null,2)),le(!1),W("json")},tn=async y=>{if(!v||E)return;const B=v.key;g(!0),N(null),k(void 0),A([]);let z;const we=U();try{const se=await x.invokeAction(t,B,y,{connectionId:n,...we?{overrides:we}:{}});k(se.value),A(se.apiCalls??[]),z={ok:!0,summary:"OK",result:se.value}}catch(se){const Mt=kn(se);N(Mt),A(Sn(se)),z={ok:!1,summary:Mt.headline}}finally{g(!1)}if(n)try{await x.recordTestRun(n,{savedTestId:M??null,actionKey:B,ok:z.ok,summary:z.summary.slice(0,200),result:z.result}),ze(),un(),l==null||l()}catch{}},sn=()=>tn(te),[Ce,Tt]=f.useState(null),[Ee,fe]=f.useState(null),[nn,an]=f.useState(0),[ln,Re]=f.useState(!1),[He,qe]=f.useState(""),[rn,Ye]=f.useState(!1),ze=()=>an(y=>y+1);f.useEffect(()=>{if(!n){Tt(null);return}let y=!1;return fe(null),x.listSavedTests(n).then(B=>!y&&Tt(B)).catch(B=>!y&&fe(B.message)),()=>{y=!0}},[x,n,nn]);const $t=V?(Ce??[]).filter(y=>y.actionKey===V):[],[on,Ge]=f.useState(null),[cn,dn]=f.useState(0),un=()=>dn(y=>y+1);f.useEffect(()=>{const y=x.listTestRuns;if(!n||!y){Ge(null);return}let B=!1;return y(n).then(z=>!B&&Ge(z)).catch(()=>!B&&Ge(null)),()=>{B=!0}},[x,n,cn]);const It=V?(on??[]).filter(y=>y.actionKey===V).slice().sort((y,B)=>Date.parse(B.occurredAt)-Date.parse(y.occurredAt)):[],wn=()=>{!n||!v||(qe(""),fe(null),Re(!0))},mn=()=>{!n||!v||(M?_t():wn())},_t=async()=>{if(!(!n||!v))try{let y;if(M)y=await x.updateSavedTest(n,M,{values:te});else{const B=He.trim();if(!B)return;y=await x.createSavedTest(n,{actionKey:v.key,name:B,values:te}),J(y.id)}ce({...te}),Re(!1),qe(""),ze(),l==null||l(),c==null||c(y)}catch(y){fe(y.message)}},hn=y=>{const B={...y.values};_({key:V,values:B}),ce(B),J(y.id),W("form"),N(null),k(void 0),A([])},pn=async()=>{if(!n||!M)return;const y=M;try{await x.deleteSavedTest(n,y),J(null),ze(),l==null||l(),d==null||d(y)}catch(B){fe(B.message)}},Lt=e.jsxs("div",{className:"w6w-stack",style:{gap:"var(--w6w-sp-1-5)"},children:[e.jsxs("div",{className:"w6w-field-labelrow",style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx("span",{className:"w6w-muted w6w-small",children:"Parameters"}),e.jsxs("div",{style:{display:"flex",gap:"var(--w6w-sp-1)"},children:[e.jsx("button",{type:"button",className:`w6w-btn w6w-btn-sm w6w-btn-ghost${L==="form"?" active":""}`,"aria-pressed":L==="form",onClick:()=>W("form"),children:"Form"}),e.jsx("button",{type:"button",className:`w6w-btn w6w-btn-sm w6w-btn-ghost${L==="json"?" active":""}`,"aria-pressed":L==="json",onClick:en,children:"JSON"}),!m&&e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-sm w6w-btn-ghost","aria-pressed":q,title:q?"Collapse the params editor":"Open the params editor in a larger view","aria-label":q?"Collapse the params editor":"Open the params editor in a larger view",onClick:()=>R(y=>!y),children:q?"⤡":"⤢"})]})]}),L==="form"?e.jsx(h.ParamsForm,{params:(v==null?void 0:v.params)??[],values:te,onChange:Rt,dynamic:v?{appId:t,actionKey:v.key,connectionId:n}:void 0}):e.jsxs(e.Fragment,{children:[e.jsx(h.JsonEditor,{value:Q,onChange:Z,minHeight:q?"50vh":"200px","aria-label":"Params JSON",onValidChange:y=>{y!==null&&typeof y=="object"&&!Array.isArray(y)&&Rt(y)},onValidityChange:({valid:y})=>le(!y)}),X&&e.jsx("span",{className:"w6w-hint",style:{color:"var(--w6w-danger)"},children:"Invalid JSON"})]})]}),Ot=e.jsxs("details",{className:"w6w-section","data-testid":"overrides-region",children:[e.jsxs("summary",{className:"w6w-section-summary",children:[e.jsx("span",{className:"w6w-section-title",children:"Overrides"}),e.jsx("span",{className:"w6w-section-subtitle",children:"Reach a vendor field this action's own params don't declare"})]}),e.jsxs("div",{className:"w6w-stack w6w-section-body",style:{gap:"var(--w6w-sp-2)"},children:[e.jsxs("div",{className:"w6w-field",children:[e.jsx("span",{children:"Body"}),e.jsx(h.JsonEditor,{value:F.text,onChange:F.onChange,minHeight:"80px","aria-label":"Overrides body (JSON)"}),F.invalid&&e.jsx("span",{className:"w6w-hint",style:{color:"var(--w6w-danger)"},children:"Invalid JSON"})]}),e.jsxs("div",{className:"w6w-field",children:[e.jsx("span",{children:"Query"}),e.jsx(h.JsonEditor,{value:C.text,onChange:C.onChange,minHeight:"80px","aria-label":"Overrides query (JSON)"}),C.invalid&&e.jsx("span",{className:"w6w-hint",style:{color:"var(--w6w-danger)"},children:"Invalid JSON"})]}),e.jsxs("div",{className:"w6w-field",children:[e.jsx("span",{children:"Headers"}),e.jsx(h.JsonEditor,{value:P.text,onChange:P.onChange,minHeight:"80px","aria-label":"Overrides headers (JSON)"}),P.invalid&&e.jsx("span",{className:"w6w-hint",style:{color:"var(--w6w-danger)"},children:"Invalid JSON"})]}),e.jsxs("label",{className:"w6w-field",children:[e.jsx("span",{children:"Target"}),e.jsxs("select",{"aria-label":"Overrides target",value:O,onChange:y=>I(y.target.value),children:[e.jsx("option",{value:"",children:"— default (first) —"}),e.jsx("option",{value:"first",children:"first"}),e.jsx("option",{value:"first-write",children:"first-write"}),e.jsx("option",{value:"all",children:"all"})]})]}),e.jsxs("label",{className:"w6w-field",children:[e.jsx("span",{children:"Match"}),e.jsx("input",{type:"text","aria-label":"Overrides match",value:$,placeholder:"Restrict to requests whose URL contains…",onChange:y=>D(y.target.value)})]}),e.jsx("span",{className:"w6w-hint",children:"Merged onto the outbound request at the wire, never into the params above — name a field the way the vendor's own API documents it."})]})]}),Ae=n?e.jsxs("div",{className:"w6w-stack",style:{gap:"var(--w6w-sp-1-5)"},children:[e.jsx("div",{className:"w6w-field-labelrow",style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:e.jsx("span",{className:"w6w-muted w6w-small",children:"Saved tests"})}),Ee&&e.jsx("span",{className:"w6w-hint",style:{color:"var(--w6w-danger)"},children:Ee}),$t.length===0?e.jsx("p",{className:"w6w-muted w6w-small",children:"No saved tests for this action yet."}):e.jsx("ul",{className:"w6w-stack",style:{listStyle:"none",margin:0,padding:0,gap:"var(--w6w-sp-1-5)"},children:$t.map(y=>e.jsx("li",{children:e.jsx(Pe,{title:y.name,subtitle:y.lastRunAt?e.jsxs("span",{children:[e.jsx("span",{style:{color:y.lastRunOk?"var(--w6w-success)":"var(--w6w-danger)"},children:y.lastRunOk?"✓":"✗"})," ",y.lastRunSummary?`${y.lastRunSummary} · `:"",Xe(y.lastRunAt)]}):`saved ${Xe(y.updatedAt)}`,active:y.id===M,onClick:()=>hn(y)})},y.id))}),x.listTestRuns&&It.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w6w-field-labelrow",style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:e.jsx("span",{className:"w6w-muted w6w-small",children:"Recent runs"})}),e.jsx("ul",{className:"w6w-stack",style:{listStyle:"none",margin:0,padding:0,gap:"var(--w6w-sp-1-5)"},children:It.map(y=>e.jsx("li",{children:e.jsx(Pe,{title:e.jsxs("span",{children:[e.jsx("span",{style:{color:y.ok?"var(--w6w-success)":"var(--w6w-danger)"},children:y.ok?"✓":"✗"})," ",y.actionKey]}),subtitle:e.jsxs("span",{children:[y.summary?`${y.summary} · `:"",Xe(y.occurredAt)]})})},y.id))})]})]}):null,Pt=(Dt=Ce==null?void 0:Ce.find(y=>y.id===M))==null?void 0:Dt.name;return e.jsxs("div",{className:`w6w-stack${m?" w6w-tester-embedded-root":""}`,children:[!a&&(s.length===0?e.jsx("p",{className:"w6w-muted w6w-small",children:"This app exposes no actions."}):e.jsxs("label",{className:"w6w-field",children:[e.jsxs("span",{children:["Action",V?"":" *"]}),e.jsx(h.Combobox,{value:w,placeholder:"— pick an action —",onChange:p,options:j.map(y=>({value:y.key,label:`${y.title??y.key} (${y.key})`}))})]})),v?e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsxs("strong",{children:[v.title??v.key," ",e.jsx("code",{className:"w6w-muted",children:v.key})]}),v.description&&e.jsx("p",{className:"w6w-muted w6w-small",style:{margin:"var(--w6w-sp-0-5) 0 0"},children:v.description})]}),(()=>{const y=b?e.jsxs("div",{className:"w6w-result w6w-error",children:[e.jsx("strong",{children:b.headline}),b.hint&&e.jsx("div",{style:{marginTop:"var(--w6w-sp-1-5)"},children:b.hint}),b.detail&&e.jsx("div",{className:"w6w-muted w6w-small",style:{marginTop:"var(--w6w-sp-1-5)",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:b.detail})]}):null,B=S!==void 0?e.jsxs("div",{className:"w6w-stack",style:{gap:"var(--w6w-sp-1)"},children:[e.jsx("strong",{className:"w6w-small",children:"Result"}),e.jsx(h.ResultViewer,{value:S})]}):null,z=e.jsxs("div",{className:"w6w-stack",style:{gap:"var(--w6w-sp-3)"},children:[Lt,Ot,y,B,e.jsx(h.ApiCallsPanel,{calls:T})]}),we=e.jsxs("div",{className:`w6w-tester-actions${m||q?" w6w-tester-actions-footer":""}`,style:{display:"flex",gap:"var(--w6w-sp-2)"},children:[e.jsx("button",{type:"button",className:"w6w-btn",disabled:u||E,onClick:sn,children:u?"Running…":"Run action"}),n&&e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:mn,children:"Save test"}),n&&M&&e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",style:{marginLeft:"auto",color:"var(--w6w-danger)"},onClick:()=>Ye(!0),children:"Delete"})]}),se=e.jsxs("div",{className:"w6w-stack",style:{gap:"var(--w6w-sp-3)"},children:[z,we]});return m?e.jsxs("div",{className:"w6w-tester-embedded",children:[e.jsx("div",{className:"w6w-tester-embedded-scroll",children:e.jsxs("div",{className:"w6w-card-stack",children:[e.jsxs("div",{className:"card",children:[e.jsx("div",{className:"section-head",children:e.jsx("h3",{children:"Parameters"})}),e.jsxs("div",{className:"w6w-stack",style:{gap:"var(--w6w-sp-3)"},children:[Lt,Ot,y]})]}),(B||T.length>0)&&e.jsxs("div",{className:"card",children:[e.jsx("div",{className:"section-head",children:e.jsx("h3",{children:"Result"})}),e.jsxs("div",{className:"w6w-stack",style:{gap:"var(--w6w-sp-3)"},children:[S!==void 0&&e.jsx(h.ResultViewer,{value:S}),e.jsx(h.ApiCallsPanel,{calls:T})]})]}),Ae&&e.jsxs("div",{className:"card",children:[e.jsx("div",{className:"section-head",children:e.jsx("h3",{children:"Saved tests and history"})}),Ae]})]})}),we]}):q?e.jsx(h.Modal,{title:`Edit params — ${v.title??v.key}`,onClose:()=>R(!1),size:"full",children:e.jsxs("div",{className:"w6w-tester-popout",children:[e.jsx("div",{className:"w6w-tester-popout-scroll",children:Ae?e.jsxs("div",{style:{display:"flex",gap:"var(--w6w-sp-4)",alignItems:"flex-start"},children:[e.jsx("div",{style:{flex:1,minWidth:0},children:z}),e.jsx("div",{style:{width:260,flexShrink:0},children:Ae})]}):z}),we]})}):se})(),ln&&e.jsx(h.Modal,{title:"Save test",onClose:()=>Re(!1),children:e.jsxs("form",{className:"w6w-stack",style:{gap:"var(--w6w-sp-3)"},onSubmit:y=>{y.preventDefault(),_t()},children:[e.jsxs("label",{className:"w6w-field",children:[e.jsx("span",{children:"Name this saved test"}),e.jsx("input",{type:"text",value:He,placeholder:"e.g. valid sender",onChange:y=>qe(y.target.value)})]}),Ee&&e.jsx("span",{className:"w6w-hint",style:{color:"var(--w6w-danger)"},children:Ee}),e.jsxs("div",{style:{display:"flex",gap:"var(--w6w-sp-2)",justifyContent:"flex-end"},children:[e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:()=>Re(!1),children:"Cancel"}),e.jsx("button",{type:"submit",className:"w6w-btn",disabled:!He.trim(),children:"Save"})]})]})}),rn&&e.jsx(h.ConfirmModal,{title:"Delete saved test",message:Pt?`Delete "${Pt}"? This cannot be undone.`:"Delete this saved test? This cannot be undone.",confirmLabel:"Delete",onConfirm:()=>{Ye(!1),pn()},onClose:()=>Ye(!1)})]}):!a&&e.jsx("p",{className:"w6w-muted w6w-small",children:"Pick an action above to test it."})]})}function En(t){const s=h.useEffectiveTheme(t.theme),{copied:n,copy:a}=K.useCopyToClipboard(t.value),i=f.useMemo(()=>[gn.yaml(),vn.EditorView.theme(h.EDITOR_THEME_SPEC)],[]);function l(o){t.onChange(o)}return e.jsxs("div",{className:"w6w-yaml-editor","aria-label":t["aria-label"]??"YAML editor",children:[e.jsx(jn,{value:t.value,onChange:l,extensions:i,placeholder:t.placeholder,readOnly:t.readOnly,editable:!t.readOnly,theme:s,height:t.height,minHeight:t.minHeight??"240px",maxHeight:t.maxHeight,basicSetup:{lineNumbers:!0,foldGutter:!0,highlightActiveLine:!t.readOnly,autocompletion:!0,bracketMatching:!0,closeBrackets:!0}}),t.copyable!==!1&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:`w6w-icon-btn w6w-copyable-btn${n?" is-copied":""}`,"aria-label":"Copy",onClick:()=>void a(),children:n?e.jsx(K.CheckGlyph,{}):e.jsx(K.CopyGlyph,{})}),e.jsx("span",{className:"w6w-copyable-status","aria-live":"polite",children:n?"Copied":""})]})]})}const Qe="…";function is(t,s,n="end"){if(s===void 0||s<1||s>=t.length)return t;if(n==="start")return`${Qe}${t.slice(t.length-s)}`;if(n==="end")return`${t.slice(0,s)}${Qe}`;const a=Math.ceil(s/2),i=s-a;return`${t.slice(0,a)}${Qe}${t.slice(t.length-i)}`}function ls(t){const{value:s,chars:n,crop:a="end",label:i,className:l,copiedMs:o}=t,r=is(s,n,a),c=["w6w-copyable--bare",l].filter(Boolean).join(" ");return e.jsx(K.Copyable,{value:s,readOnly:!0,label:i,className:c,copiedMs:o,children:e.jsx("span",{children:r})})}const Rn={ok:"Operational",degraded:"Degraded",down:"Down",unknown:"Unknown"};function Ue({state:t,label:s,ariaLabel:n}){const a=s??Rn[t];return e.jsxs("span",{className:`w6w-health-pill w6w-health-pill-${t}`,"aria-label":n,children:[e.jsx("span",{className:"w6w-health-pill-dot","aria-hidden":"true"}),e.jsx("span",{className:"w6w-health-pill-label",children:a})]})}const An={ok:"Operational",degraded:"Degraded",down:"Down",unknown:"Unknown"};function rs({days:t,ariaLabel:s}){return t.length===0?null:e.jsx("div",{className:"w6w-uptime-strip",role:"img","aria-label":s??`${t.length}-day status`,children:t.map((n,a)=>e.jsx("span",{className:`w6w-uptime-cell w6w-uptime-cell-${n.state}`,title:n.label??`${n.day} — ${An[n.state]}`},`${n.day}-${a}`))})}const os="—",Ft=["B","KiB","MiB","GiB","TiB","PiB"];function cs(t){if(t===null||!Number.isFinite(t))return os;if(t<1024)return`${Math.round(t)} B`;let s=t,n=0;for(;s>=1024&&n<Ft.length-1;)s/=1024,n+=1;return`${s.toFixed(1)} ${Ft[n]}`}function ie(t){return t===null||!Number.isFinite(t)?os:`${Math.round(t*100)}%`}function Ne(t){if(t===void 0||t.load1===null)return null;const s=t.cpuLimit??t.cpus;return s===null||s<=0?null:t.load1/s}function ke(t){if(t===void 0)return null;const{memoryTotal:s,memoryAvailable:n}=t;return s===null||n===null||s<=0?null:(s-n)/s}function Tn(t,s,n){return t<s?s:t>n?n:t}function $n(t,s,n,a){const i=t.length;if(i<2)return"";const l=[];for(let o=0;o<i;o++){const r=t[o];if(r===null)continue;const c=o/(i-1)*s,d=a<=0?n:n-Tn(r,0,a)/a*n;l.push(`${Number(c.toFixed(2))},${Number(d.toFixed(2))}`)}return l.join(" ")}const In="—",Ut=100,Wt=24;function rt({values:t,max:s,className:n}){const a=$n(t,Ut,Wt,s);return a===""?null:e.jsx("svg",{className:n,viewBox:`0 0 ${Ut} ${Wt}`,preserveAspectRatio:"none","aria-hidden":"true",focusable:"false",children:e.jsx("polyline",{points:a,fill:"none",stroke:"var(--w6w-accent)",strokeWidth:2,vectorEffect:"non-scaling-stroke"})})}function et(t){return t===null?In:t.toFixed(2)}function De(t){let s=1;for(const n of t)n!==null&&n>s&&(s=n);return s}function _e({label:t,value:s,values:n,max:a}){return e.jsxs("li",{className:"w6w-server-resources__row",children:[e.jsx("span",{className:"w6w-server-resources__label",children:t}),e.jsx("span",{className:"w6w-server-resources__value",children:s}),e.jsx(rt,{className:"w6w-server-resources__spark",values:n,max:a})]})}function ht(t){const s=t[t.length-1],n=t.map(l=>Ne(l)),a=t.map(l=>ke(l)),i=t.map(l=>l.processRss);return{last:s,cpuValues:n,memoryValues:a,rssValues:i}}function _n({samples:t,title:s="Server resources",intervalMs:n}){const{last:a,cpuValues:i,memoryValues:l,rssValues:o}=ht(t);return e.jsxs("section",{className:"w6w-server-resources w6w-server-resources--card","aria-label":s,children:[e.jsx("h3",{className:"w6w-server-resources__title",children:s}),e.jsxs("ul",{className:"w6w-server-resources__rows",children:[e.jsx(_e,{label:"CPU",value:ie(Ne(a)),values:i,max:De(i)}),e.jsx(_e,{label:"Memory",value:ie(ke(a)),values:l,max:1}),e.jsx(_e,{label:"Process",value:cs((a==null?void 0:a.processRss)??null),values:o,max:De(o)})]}),e.jsx("p",{className:"w6w-server-resources__meta",children:`Load ${et((a==null?void 0:a.load1)??null)} / ${et((a==null?void 0:a.load5)??null)} / ${et((a==null?void 0:a.load15)??null)}`}),n!==void 0&&e.jsx("p",{className:"w6w-server-resources__meta",children:`Sampled every ${n/1e3}s`})]})}function Ln({samples:t,title:s="Server"}){const{last:n,cpuValues:a}=ht(t);return e.jsxs("section",{className:"w6w-server-resources w6w-server-resources--small","aria-label":s,children:[e.jsx("h3",{className:"w6w-server-resources__title",children:s}),e.jsxs("ul",{className:"w6w-server-resources__rows",children:[e.jsx(_e,{label:"CPU",value:ie(Ne(n)),values:a,max:De(a)}),e.jsxs("li",{className:"w6w-server-resources__row",children:[e.jsx("span",{className:"w6w-server-resources__label",children:"Memory"}),e.jsx("span",{className:"w6w-server-resources__value",children:ie(ke(n))})]})]})]})}function On({samples:t,onExpand:s}){const{last:n,cpuValues:a,memoryValues:i}=ht(t);return e.jsxs("aside",{className:"w6w-server-resources w6w-server-resources--rail",children:[e.jsxs("div",{className:"w6w-server-resources__rail-row",children:[e.jsx("span",{className:"w6w-server-resources__label",children:"CPU"}),e.jsx("span",{className:"w6w-server-resources__value",children:ie(Ne(n))}),e.jsx(rt,{className:"w6w-server-resources__spark",values:a,max:De(a)})]}),e.jsxs("div",{className:"w6w-server-resources__rail-row",children:[e.jsx("span",{className:"w6w-server-resources__label",children:"MEM"}),e.jsx("span",{className:"w6w-server-resources__value",children:ie(ke(n))}),e.jsx(rt,{className:"w6w-server-resources__spark",values:i,max:1})]}),s!==void 0&&e.jsx("button",{type:"button",className:"w6w-server-resources__expand","aria-label":"Show server resources",onClick:s,children:"Details"})]})}function Pn({samples:t}){const s=t[t.length-1],n=ie(Ne(s)),a=ie(ke(s));return e.jsx("span",{className:"w6w-server-resources w6w-server-resources--badge",children:`CPU ${n} · MEM ${a}`})}const Dn=1,Mn=1440*60*1e3;function Bn(t,s,n){const a=s.startedAt??s.updatedAt;if(a===void 0)return null;const i=Date.parse(a),l=s.resolvedAt!==void 0?Date.parse(s.resolvedAt):s.startedAt!==void 0?n:i,o=Date.parse(`${t.from}T00:00:00.000Z`),r=Date.parse(`${t.to}T00:00:00.000Z`)+Mn,c=r-o;if(l<o||i>=r)return null;const d=i<o,m=l>r,x=Math.max(i,o),j=Math.min(l,r),w=(x-o)/c*100,p=(j-x)/c*100,v=Math.max(p,Dn);return{leftPct:w,widthPct:v,clippedStart:d,clippedEnd:m}}const Fn={ok:"Operational",degraded:"Degraded",down:"Down",unknown:"Unknown"},Un="This vendor publishes no incident history.",Wn="No incidents in this window.";function Kn(t){const s=t.startedAt??t.updatedAt,n=[t.title];return t.components!==void 0&&t.components.length>0&&n.push(`(${t.components.join(", ")})`),s!==void 0&&n.push(t.resolvedAt!==void 0?`${s} – ${t.resolvedAt}`:`${s} – ongoing`),n.join(" ")}function Vn({window:t,days:s,incidents:n,vendorEmptyLabel:a,nowMs:i=Date.now(),ariaLabel:l}){const o=s.length,r=o>0?100/o:0,c=n===void 0?a??Un:n.length===0?a??Wn:null;return e.jsx("div",{className:"w6w-history-timeline",role:"img","aria-label":l??`${o}-day history`,children:e.jsxs("div",{className:"w6w-history-plot",children:[e.jsx("div",{className:"w6w-history-lane w6w-history-lane-execution",children:s.map((d,m)=>e.jsx("span",{className:`w6w-history-cell w6w-history-cell-${d.state}`,style:{left:`${m*r}%`,width:`${r}%`},title:d.label??`${d.day} — ${Fn[d.state]}`},`${d.day}-${m}`))}),e.jsx("div",{className:"w6w-history-lane w6w-history-lane-vendor",children:c!==null?e.jsx("span",{className:"w6w-history-empty",title:c,children:c}):n==null?void 0:n.map((d,m)=>{const x=Bn(t,d,i);if(x===null)return null;const j=[x.clippedStart?"w6w-history-bar-clip-start":"",x.clippedEnd?"w6w-history-bar-clip-end":""].filter(Boolean).join(" ");return e.jsx("span",{className:`w6w-history-bar w6w-history-bar-${d.state}${j?` ${j}`:""}`,style:{left:`${x.leftPct}%`,width:`${x.widthPct}%`},title:Kn(d)},d.id??`${d.title}-${m}`)})}),e.jsxs("div",{className:"w6w-history-axis",children:[e.jsx("span",{className:"w6w-history-tick w6w-history-tick-start",style:{left:"0%"},children:t.from}),e.jsx("span",{className:"w6w-history-tick w6w-history-tick-end",style:{left:"100%"},children:t.to})]})]})})}function Jn({label:t,children:s,className:n}){const[a,i]=f.useState(!1),l=f.useId();return e.jsxs("span",{className:["w6w-info-tip",n??""].filter(Boolean).join(" "),children:[e.jsx(h.IconButton,{label:t,icon:"info","aria-expanded":a,"aria-controls":l,onClick:()=>i(o=>!o)}),a&&e.jsx("span",{id:l,className:"w6w-info-tip-body w6w-muted w6w-small",children:s})]})}function Hn(t){const{label:s,onClick:n,disabled:a,className:i,...l}=t;return e.jsx(h.IconButton,{label:s,onClick:n,disabled:a,className:i,icon:"edit","data-testid":l["data-testid"]})}const Te=4;function pt({actions:t,label:s="Actions",disabled:n,"data-testid":a}){const i=t.filter(g=>!!g),l=f.useRef(null),o=f.useRef(null),r=f.useId(),[c,d]=f.useState(!1),[m,x]=f.useState(null),[j,w]=f.useState(null),p=f.useCallback(g=>{var b;d(!1),w(null),g&&((b=l.current)==null||b.focus({preventScroll:!0}))},[]);if(f.useLayoutEffect(()=>{if(!c)return;const g=l.current,b=o.current;if(!g||!b)return;const N=g.getBoundingClientRect(),S=b.offsetWidth,k=b.offsetHeight,T=window.innerHeight||document.documentElement.clientHeight,A=N.bottom+Te,F=A+k>T&&N.top-Te-k>=0?N.top-Te-k:A;w({top:F,left:Math.max(Te,N.right-S)})},[c]),f.useEffect(()=>{var g,b;!c||!j||(b=(g=o.current)==null?void 0:g.querySelector("[role=menuitem]"))==null||b.focus({preventScroll:!0})},[c,j]),f.useEffect(()=>{if(!c)return;const g=k=>{var T,A;return k instanceof Node&&((T=o.current)==null?void 0:T.contains(k))||k instanceof Node&&((A=l.current)==null?void 0:A.contains(k))},b=k=>{g(k.target)||p(!1)},N=k=>{var T;k.target instanceof Node&&((T=o.current)!=null&&T.contains(k.target))||p(!1)},S=()=>p(!1);return document.addEventListener("pointerdown",b,!0),document.addEventListener("mousedown",b,!0),document.addEventListener("scroll",N,!0),window.addEventListener("resize",S),window.addEventListener("blur",S),()=>{document.removeEventListener("pointerdown",b,!0),document.removeEventListener("mousedown",b,!0),document.removeEventListener("scroll",N,!0),window.removeEventListener("resize",S),window.removeEventListener("blur",S)}},[c,p]),i.length===0)return null;const v=g=>{g.disabled||(p(!0),g.onSelect())},u=()=>{var g;if(c){p(!1);return}x(((g=l.current)==null?void 0:g.closest("dialog"))??document.body),d(!0)};return e.jsxs("span",{className:"w6w-row-actions",onClick:g=>g.stopPropagation(),children:[e.jsx(h.IconButton,{ref:l,label:s,icon:"more-horizontal",onClick:u,disabled:n,className:"w6w-row-actions-trigger","aria-haspopup":"menu","aria-expanded":c,"aria-controls":c?r:void 0,"data-testid":a}),c&&m&&ns.createPortal(e.jsx("div",{ref:o,id:r,className:"w6w-row-menu",role:"menu","aria-label":s,style:j?{top:j.top,left:j.left}:{top:0,left:0,visibility:"hidden"},onClick:g=>g.stopPropagation(),onKeyDown:g=>{var k;g.stopPropagation();const b=[...((k=o.current)==null?void 0:k.querySelectorAll("[role=menuitem]"))??[]],N=b.indexOf(document.activeElement),S=T=>{var A;return(A=b[(T+b.length)%b.length])==null?void 0:A.focus()};if(g.key==="ArrowDown")S(N+1);else if(g.key==="ArrowUp")S(N<0?-1:N-1);else if(g.key==="Home")S(0);else if(g.key==="End")S(-1);else if(g.key==="Escape")p(!0);else if(g.key==="Tab")p(!1);else if(g.key==="Enter"||g.key===" ")N>=0&&v(i[N]);else return;g.preventDefault()},children:i.map(g=>e.jsxs("button",{type:"button",role:"menuitem",tabIndex:-1,"aria-disabled":g.disabled||void 0,className:`w6w-row-menu-item${g.danger?" w6w-row-menu-item-danger":""}`,"data-testid":g["data-testid"],onClick:()=>v(g),children:[g.icon&&e.jsx(K.Icon,{name:g.icon,size:14}),e.jsx("span",{children:g.label})]},g.label))}),m)]})}function qn(t){const{branch:s,shortSha:n,lastSyncLabel:a,onSyncNow:i,syncing:l,className:o,...r}=t,[c,d]=f.useState(!1),m=f.useRef(null);return f.useEffect(()=>{if(!c)return;const x=w=>{m.current&&!m.current.contains(w.target)&&d(!1)},j=w=>w.key==="Escape"&&d(!1);return document.addEventListener("mousedown",x),document.addEventListener("keydown",j),()=>{document.removeEventListener("mousedown",x),document.removeEventListener("keydown",j)}},[c]),e.jsxs("div",{className:`w6w-repo-sync${o?` ${o}`:""}`,ref:m,"data-testid":r["data-testid"],children:[e.jsxs("button",{type:"button",className:"w6w-repo-sync-trigger","aria-haspopup":"menu","aria-expanded":c,"aria-busy":l,onClick:()=>d(x=>!x),children:[e.jsxs("span",{className:"w6w-repo-sync-icon",children:[e.jsx(K.Icon,{name:"github"}),l&&e.jsx(K.Icon,{name:"sync",size:10,className:"w6w-repo-sync-spin"})]}),e.jsx("span",{className:"w6w-repo-sync-branch",children:s}),n!=null&&e.jsx("code",{className:"w6w-repo-sync-sha",children:n})]}),c&&e.jsxs("div",{className:"w6w-repo-sync-menu",role:"menu",children:[e.jsxs("div",{className:"w6w-repo-sync-detail",children:[e.jsx("span",{children:s}),n!=null&&e.jsx("code",{children:n}),a!=null&&e.jsx("span",{children:a})]}),e.jsx("button",{type:"button",role:"menuitem",className:"w6w-repo-sync-item","data-testid":"repo-sync-now",disabled:l,onClick:i,children:l?"Syncing…":"Sync now"})]})]})}const Yn={pending:"Pending",running:"Running",succeeded:"Succeeded",failed:"Failed",skipped:"Skipped",queued:"Queued",canceled:"Canceled"};function Se({state:t,label:s,ariaLabel:n}){const a=s??Yn[t];return e.jsxs("span",{className:`w6w-step-pill w6w-step-pill-${t}`,"aria-label":n,children:[e.jsx("span",{className:"w6w-step-pill-dot","aria-hidden":"true"}),e.jsx("span",{className:"w6w-step-pill-label",children:a})]})}const zn="—",tt=1e3,st=6e4;function We(t){return t==null||!Number.isFinite(t)||t<0?zn:t<tt?`${Math.round(t)} ms`:t<st?`${(t/tt).toFixed(1)} s`:`${Math.floor(t/st)}m ${Math.round(t%st/tt)}s`}function ye(t){const s=new Date(t);return Number.isNaN(s.getTime())?t:s.toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"})}const Gn={function:"Function",endpoint:"Endpoint",workflow:"Workflow"},Xn={manual:"Manual",schedule:"Schedule",webhook:"Webhook",event:"Event",replay:"Replay"};function nt(t){if(!t.trigger)return null;const s=Xn[t.trigger]??t.trigger;return t.triggerNodeId?`${s} · ${t.triggerNodeId}`:s}function Zn({items:t,selectedId:s=null,onSelect:n,showCallable:a=!1,loading:i=!1,emptyLabel:l,hasPrev:o,hasNext:r,onPrev:c,onNext:d,onRerun:m,rerunningId:x=null}){const j=c||d?e.jsxs("div",{className:"w6w-execution-list-pager",children:[e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost","data-testid":"execution-list-prev",disabled:!o,onClick:c,children:"Previous"}),e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost","data-testid":"execution-list-next",disabled:!r,onClick:d,children:"Next"})]}):null;let w;return i&&t.length===0?w=e.jsx("p",{"data-testid":"execution-list-loading",children:"Loading…"}):t.length===0?w=e.jsx("p",{"data-testid":"execution-list-empty",children:l??"No executions yet."}):w=e.jsx("ul",{className:"w6w-execution-list-rows",children:t.map(p=>e.jsxs("li",{"data-testid":"execution-row","data-execution-id":p.id,children:[e.jsx(Pe,{icon:e.jsx(Se,{state:p.status}),title:e.jsxs(e.Fragment,{children:[a?p.callableName:ye(p.startedAt),p.triggerLabel&&e.jsx("span",{className:"w6w-execution-trigger-chip","data-testid":"execution-row-trigger-chip",title:nt(p)??void 0,children:p.triggerLabel}),p.rerunOf&&e.jsx("span",{className:"w6w-execution-rerun-tag","data-testid":"execution-row-rerun-tag",title:`Re-run of ${p.rerunOf}`,children:"Re-run"})]}),subtitle:e.jsxs(e.Fragment,{children:[a?`${Gn[p.kind]} · ${ye(p.startedAt)}`:p.id,!p.triggerLabel&&nt(p)&&e.jsx("span",{className:"w6w-execution-trigger","data-testid":"execution-row-trigger",children:` · ${nt(p)}`}),p.inputPreview&&e.jsxs(e.Fragment,{children:[" · ",e.jsx("code",{className:"w6w-execution-input-preview","data-testid":"execution-row-input",title:p.inputPreview,children:p.inputPreview})]})]}),trailing:We(p.durationMs),active:p.id===s,onClick:n?()=>n(p.id):void 0}),m&&e.jsx(h.IconButton,{icon:"sync",label:"Re-run",title:p.id===x?"Re-running…":"Re-run with the same input",className:"w6w-execution-list-rerun","data-testid":"execution-row-rerun",disabled:x!==null,onClick:()=>m(p.id)})]},p.id))}),e.jsxs("div",{className:"w6w-execution-list","data-testid":"execution-list",children:[w,j]})}function Ke(t){const s=h.internalNodeDef(t.app,t.action);return{trigger:t.trigger===!0||(s==null?void 0:s.group)==="trigger",appName:t.appName??(s==null?void 0:s.displayName)??t.app,actionName:t.actionName??(s==null?void 0:s.label)??t.action}}function ft(t){const s=n=>{for(const a of[n.startedAt,n.finishedAt]){const i=Date.parse(a??"");if(Number.isFinite(i))return i}return Number.POSITIVE_INFINITY};return t.map(n=>({step:n,time:s(n)})).sort((n,a)=>n.time===a.time?0:n.time-a.time).map(({step:n})=>n)}function ds({steps:t,emptyLabel:s,onDismiss:n,runError:a,stepErrors:i}){const l=n?e.jsx("div",{className:"w6w-execution-log-head",children:e.jsx(h.IconButton,{label:"Dismiss run log","data-testid":"execution-log-dismiss",onClick:n,children:"×"})}):null,o=i??[],r=a||o.length>0?e.jsxs("div",{className:"w6w-execution-log-errors w6w-stack",children:[a&&e.jsx(he,{error:a}),o.map((x,j)=>e.jsx(he,{label:x.label??x.stepId,error:x.error},`${x.stepId}:${j}`))]}):null,c=ft(t.filter(x=>!Me(x))),d=t.filter(Me),m=d.length>0?e.jsx(ot,{steps:d}):null;return c.length===0?e.jsxs(e.Fragment,{children:[l,r,e.jsx("div",{className:"w6w-execution-log-empty",children:e.jsx("p",{className:"w6w-muted w6w-small",children:s??"No nodes have run yet."})}),m]}):e.jsxs(e.Fragment,{children:[l,r,e.jsx("ol",{className:"w6w-execution-log",children:c.map(x=>e.jsx(ws,{step:x},x.id))}),m]})}const Me=t=>t.status==="skipped"&&t.skipReason==="not_on_path",us={condition:"condition false",stopped:"run stopped",disabled:"disabled"};function ot({steps:t}){const s=t.length;return e.jsxs("details",{className:"w6w-execution-log-off-path","data-testid":"execution-log-off-path",children:[e.jsx("summary",{className:"w6w-muted w6w-small",children:`${s} ${s===1?"step":"steps"} on other paths, not part of this run`}),e.jsx("ul",{className:"w6w-muted w6w-small",children:t.map(n=>e.jsx("li",{children:n.label??n.id},n.id))})]})}function ws({step:t,defaultOpen:s=!1}){var d,m;const[n,a]=f.useState(s),i=t.node?Ke(t.node):null,l=e.jsxs("div",{className:"w6w-execution-log-row-header",children:[e.jsx(Se,{state:t.status}),i&&e.jsx("span",{className:`w6w-execution-log-kind${i.trigger?" w6w-execution-log-kind-trigger":""}`,"data-testid":"execution-log-kind",children:i.trigger?"Trigger":"Node"}),e.jsxs("span",{className:"w6w-execution-log-row-title",children:[e.jsx("span",{className:"w6w-execution-log-row-label",children:t.label??t.id}),i&&e.jsx("span",{className:"w6w-execution-log-row-uses","data-testid":"execution-log-uses",children:i.appName===i.actionName?i.appName:`${i.appName} · ${i.actionName}`})]}),t.status==="skipped"&&t.skipReason&&t.skipReason!=="not_on_path"&&e.jsx("span",{className:"w6w-execution-log-skip-reason","data-testid":"execution-log-skip-reason",children:us[t.skipReason]}),e.jsx(ea,{startedAt:t.startedAt,finishedAt:t.finishedAt})]}),o=t.error?e.jsx(he,{error:t.error}):null,r=Array.isArray(t.iterations)?e.jsx(ms,{step:t}):null,c=ps(t)?e.jsx(fs,{step:t}):null;return t.input===void 0&&t.output===void 0&&!t.meta&&!c&&!((d=t.logs)!=null&&d.length)?e.jsxs("li",{className:"w6w-execution-log-row",children:[e.jsx("div",{className:"w6w-section",children:l}),o,r]}):e.jsxs("li",{className:"w6w-execution-log-row",children:[e.jsxs("details",{className:"w6w-section",open:n,onToggle:x=>a(x.currentTarget.open),children:[e.jsx("summary",{className:"w6w-section-summary",children:l}),n&&e.jsxs("div",{className:"w6w-execution-log-row-body w6w-section-body w6w-stack",children:[e.jsx(hs,{input:t.input}),e.jsx(Be,{title:"Input",value:t.input,defaultOpen:s}),e.jsx(Be,{title:"Output",value:t.output,defaultOpen:s}),!!((m=t.logs)!=null&&m.length)&&e.jsxs("div",{className:"w6w-execution-log-json w6w-stack",children:[e.jsx("strong",{className:"w6w-small",children:"Console"}),e.jsx(K.CodeBlock,{code:t.logs.join(`
2
+ `),language:"plaintext"})]}),t.meta&&e.jsxs("div",{className:"w6w-execution-log-json w6w-stack",children:[e.jsx("strong",{className:"w6w-small",children:"Metadata"}),e.jsx(K.CodeBlock,{code:JSON.stringify(t.meta,null,2),language:"json"})]}),c]})]}),o,r]})}function ms({step:t}){var p,v;const s=[...t.iterations??[]].sort((u,g)=>u.index-g.index),n=t.iterationsTotal??s.length,a=t.iterationsFailed??s.filter(u=>u.status==="failed").length,i=s.find(u=>u.status==="failed"),l=(i==null?void 0:i.index)??((p=s[s.length-1])==null?void 0:p.index),[o,r]=f.useState(l),[c,d]=f.useState(!1),m=s.find(u=>u.index===o),x=[],j=new Map;for(const u of ft(s.flatMap(g=>g.steps)))j.has(u.id)||(x.push(u.id),j.set(u.id,u.label??u.id));const w=(i==null?void 0:i.failedNodeId)??((v=i==null?void 0:i.steps.find(u=>u.status==="failed"))==null?void 0:v.id);return e.jsxs("div",{className:"w6w-execution-log-foreach w6w-stack",children:[e.jsxs("div",{className:"w6w-small","data-testid":"execution-log-foreach-summary",children:[e.jsxs("span",{children:[n===1?"1 item":`${n} items`,a>0?` · ${a} failed`:""]}),i&&w!==void 0&&e.jsxs("div",{children:[j.get(w)??w," failed in iteration ",i.index]}),t.iterationsTruncated===!0&&e.jsx("div",{className:"w6w-muted",children:`showing ${s.length} of ${n}`})]}),e.jsx("div",{className:"w6w-execution-log-iteration-chips",children:s.map(u=>e.jsxs("button",{type:"button",className:`w6w-execution-log-iteration-chip w6w-execution-log-iteration-chip-${u.status}`,"data-testid":"execution-log-iteration-chip","data-status":u.status,"aria-pressed":o===u.index,title:`Show iteration ${u.index}'s input and output`,onClick:()=>{r(u.index),d(!0)},children:[u.index," · ",u.status]},u.index))}),m&&e.jsx("div",{className:"w6w-small w6w-muted","data-testid":"execution-log-iteration-current",children:`Iteration ${m.index} · ${m.status}`}),e.jsx("ul",{className:"w6w-execution-log-subrows",children:x.map(u=>e.jsx(Qn,{id:u,label:j.get(u)??u,iterations:s,selected:o,open:c,onSelect:r},u))})]})}function Qn({id:t,label:s,iterations:n,selected:a,open:i,onSelect:l}){var r;const o=(r=n.find(c=>c.index===a))==null?void 0:r.steps.find(c=>c.id===t);return e.jsxs("li",{className:"w6w-execution-log-subrow w6w-stack",children:[e.jsxs("div",{className:"w6w-execution-log-subrow-head",children:[e.jsx("strong",{className:"w6w-small",children:s}),e.jsx("select",{className:"w6w-select","aria-label":`Iteration for ${s}`,"data-testid":"execution-log-iteration-select",value:a===void 0?"":String(a),onChange:c=>l(Number(c.currentTarget.value)),children:n.map(c=>e.jsx("option",{value:String(c.index),children:`iteration ${c.index} (${c.status})`},c.index))})]}),o?e.jsx("ol",{className:"w6w-execution-log",children:e.jsx(ws,{step:o,defaultOpen:i},`${a}:${i}`)}):e.jsx("p",{className:"w6w-muted w6w-small",children:"Did not run in this iteration."})]})}function he({error:t,label:s}){return e.jsxs("div",{className:"w6w-result w6w-error",children:[s!==void 0&&e.jsx("strong",{className:"w6w-execution-log-error-label",children:s}),t.code&&e.jsx("div",{className:"w6w-small w6w-execution-log-error-code",children:e.jsx("code",{children:t.code})}),t.message]})}function ea({startedAt:t,finishedAt:s}){if(t&&s){const n=xt(t,s);return e.jsxs("span",{className:"w6w-execution-log-timing",children:[t," → ",s,n&&e.jsxs("span",{children:[" (",n,")"]})]})}return t?e.jsxs("span",{className:"w6w-execution-log-timing",children:["Started ",t]}):e.jsx("span",{className:"w6w-execution-log-timing",children:"—"})}function xt(t,s){const n=Date.parse(t),a=Date.parse(s);if(!Number.isFinite(n)||!Number.isFinite(a)||a<n)return null;const i=a-n;if(i<1e3)return`${i}ms`;const l=i/1e3;if(l<60)return`${l.toFixed(1)}s`;const o=Math.floor(l/60),r=Math.round(l%60);return`${o}m ${r}s`}function Be({title:t,value:s,defaultOpen:n=!1}){const[a,i]=f.useState(n);return s===void 0?e.jsxs("div",{className:"w6w-execution-log-json w6w-stack",children:[e.jsx("strong",{className:"w6w-small",children:t}),e.jsx("p",{className:"w6w-muted w6w-small",children:"Not available."})]}):e.jsxs("details",{className:"w6w-execution-log-json",open:a,onToggle:l=>{l.target===l.currentTarget&&i(l.currentTarget.open)},children:[e.jsx("summary",{children:e.jsx("strong",{className:"w6w-small",children:t})}),a&&e.jsx(h.ResultViewer,{value:s,format:"json"})]})}const Fe=t=>typeof t=="object"&&t!==null&&!Array.isArray(t);function Kt(t){if(!Fe(t)||!Array.isArray(t.conditions))return;const s=t.conditions.filter(n=>Fe(n)&&typeof n.op=="string"&&"result"in n);if(s.length!==0)return{rows:s,combinator:typeof t.combinator=="string"?t.combinator:void 0,result:typeof t.condition=="boolean"?t.condition:void 0}}function hs({input:t}){const s=[],n=Kt(t);if(n&&s.push({trace:n}),Fe(t)&&Array.isArray(t.routes))for(const a of t.routes){const i=Kt(a);!i||!Fe(a)||s.push({title:String(a.label??a.id??"Route"),trace:i})}return s.length===0?null:e.jsxs("div",{className:"w6w-execution-log-json w6w-stack","data-testid":"execution-log-conditions",children:[e.jsx("strong",{className:"w6w-small",children:"Condition"}),s.map(({title:a,trace:i},l)=>e.jsxs("div",{className:"w6w-stack",children:[a&&e.jsx("span",{className:"w6w-small w6w-muted",children:a}),(i.combinator&&i.rows.length>1||i.result!==void 0)&&e.jsxs("span",{className:"w6w-small w6w-muted","data-testid":"execution-log-condition-summary",children:[i.combinator&&i.rows.length>1&&h.conditionCombinatorLabel(i.combinator),i.combinator&&i.rows.length>1&&i.result!==void 0&&" · ",i.result!==void 0&&e.jsxs(e.Fragment,{children:["Result:"," ",e.jsx("span",{className:i.result?"w6w-execution-log-condition-true":"w6w-execution-log-condition-false",children:i.result?"true":"false"})]})]}),e.jsx("div",{className:"w6w-data-table-frame",children:e.jsxs("table",{className:"w6w-data-table w6w-execution-log-conditions",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Left"}),e.jsx("th",{children:"Operator"}),e.jsx("th",{children:"Right"}),e.jsx("th",{children:"Result"})]})}),e.jsx("tbody",{children:i.rows.map((o,r)=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("code",{children:Vt(o.left)})}),e.jsx("td",{children:h.conditionOperatorLabel(o.op)}),e.jsx("td",{children:e.jsx("code",{children:Vt(o.right)})}),e.jsx("td",{className:o.result?"w6w-execution-log-condition-true":"w6w-execution-log-condition-false",children:o.result?"true":"false"})]},r))})]})})]},a??l))]})}function Vt(t){return JSON.stringify(t)??"undefined"}const Jt={not_object:"Not written — the output isn't an object, so it can't be merged at the root",missing_source:"Not written — the output has no value at that field",null_append:"Not appended — the value was null",append_not_array:"Not appended — the existing value isn't a list",write_too_large:"Not written — the value is too large",run_too_large:"Not written — the run's state would grow past its size limit",too_deep:"Not written — the value is nested too deeply",key_too_long:"Not written — a key in the value is too long",forbidden_key:"Not written — the value uses a reserved key name",log_truncated:"Later state changes aren't shown — the run's state log reached its limit"};function ta(t){return Object.hasOwn(Jt,t)?Jt[t]:t}function ps(t){const s=Array.isArray(t.stateWrites)&&t.stateWrites.length>0,n=t.stateAfter;return s||typeof n=="object"&&n!==null&&Object.keys(n).length>0}const Ht=120;function qt(t){if(t===void 0)return"(not set)";const s=JSON.stringify(t)??String(t);return s.length>Ht?`${s.slice(0,Ht)}…`:s}function fs({step:t}){const s=Array.isArray(t.stateWrites)?t.stateWrites:[],n=t.stateAfter;return e.jsxs("div",{className:"w6w-execution-log-state w6w-stack","data-testid":"execution-log-state",children:[e.jsx("strong",{className:"w6w-small",children:"State"}),s.length>0&&e.jsx("ul",{className:"w6w-execution-log-state-writes",children:s.map((a,i)=>{const l=Array.isArray(a.path)?a.path:[],o=`state${l.length?`.${l.join(".")}`:""}${a.item!==void 0?` (item ${a.item})`:""}`;return a.warning!==void 0?e.jsx("li",{className:"w6w-execution-log-state-write w6w-execution-log-state-warning w6w-small","data-testid":"execution-log-state-write","data-warning":a.warning,children:`${o}: ${ta(a.warning)}`},i):e.jsx("li",{className:"w6w-execution-log-state-write w6w-small","data-testid":"execution-log-state-write",children:`${o}: ${qt(a.old)} → ${qt(a.new)}`},i)})}),typeof n=="object"&&n!==null&&e.jsxs("div",{className:"w6w-stack","data-testid":"execution-log-state-after",children:[e.jsx("span",{className:"w6w-small w6w-muted",children:"State after this step"}),e.jsx(K.CodeBlock,{code:JSON.stringify(n,null,2),language:"json"})]})]})}const ct="w6w.log-view.list-width",Le=140,sa=240;function na(){var t;try{const s=Number((t=globalThis.localStorage)==null?void 0:t.getItem(ct));return Number.isFinite(s)&&s>=Le?s:null}catch{return null}}function at(t){var s,n;try{t===null?(s=globalThis.localStorage)==null||s.removeItem(ct):(n=globalThis.localStorage)==null||n.setItem(ct,String(Math.round(t)))}catch{}}function xs({node:t,size:s}){if(!t)return null;const n=h.internalNodeIcon(t.app,t.action);return n?e.jsx(h.InternalIcon,{icon:n,size:s}):e.jsx(h.AppIcon,{src:t.iconSvg,srcDark:t.iconSvgDark,brandColor:t.brandColor,name:Ke(t).appName,size:s})}function aa(t){return t.find(s=>s.status==="failed")??[...t].reverse().find(s=>s.status==="running")??t[t.length-1]}function ia({steps:t,emptyLabel:s,runError:n,stepErrors:a,selectedStepId:i,onSelectStep:l}){const[o,r]=f.useState(null),c=f.useRef(null),d=f.useRef(null),m=f.useRef(null),[x,j]=f.useState(na),w=C=>{var I;const P=((I=d.current)==null?void 0:I.getBoundingClientRect().width)??0,O=P>0?Math.max(Le,P-sa):Number.POSITIVE_INFINITY;return Math.round(Math.min(Math.max(C,Le),O))},p=C=>{var U,L;C.preventDefault();const P=C.clientX,O=((U=m.current)==null?void 0:U.getBoundingClientRect().width)??x??0,I=C.currentTarget;(L=I.setPointerCapture)==null||L.call(I,C.pointerId);let $=O;const D=W=>{$=w(O+(W.clientX-P)),j($)},E=()=>{I.removeEventListener("pointermove",D),I.removeEventListener("pointerup",E),I.removeEventListener("pointercancel",E),at($)};I.addEventListener("pointermove",D),I.addEventListener("pointerup",E),I.addEventListener("pointercancel",E)},v=C=>{var $;const P=C.shiftKey?64:16,O=x??(($=m.current)==null?void 0:$.getBoundingClientRect().width)??0;let I;if(C.key==="ArrowRight")I=w(O+P);else if(C.key==="ArrowLeft")I=w(O-P);else return;C.preventDefault(),j(I),at(I)},u=()=>{j(null),at(null)},g=ft(t.filter(C=>!Me(C))),b=t.filter(Me),N=i!==void 0?i:o,S=g.find(C=>C.id===N)??aa(g),k=C=>{r(C),l==null||l(C)},T=C=>{var I,$;if(C.key!=="ArrowDown"&&C.key!=="ArrowUp")return;C.preventDefault();const P=g.findIndex(D=>D.id===(S==null?void 0:S.id)),O=g[Math.min(Math.max(P+(C.key==="ArrowDown"?1:-1),0),g.length-1)];O&&(k(O.id),($=(I=c.current)==null?void 0:I.querySelector(`[data-step-id="${CSS.escape(O.id)}"]`))==null||$.focus())},A=a??[],F=n||A.length>0?e.jsxs("div",{className:"w6w-log-view-errors w6w-stack",children:[n&&e.jsx(he,{error:n}),A.map((C,P)=>e.jsx(he,{label:C.label??C.stepId,error:C.error},`${C.stepId}:${P}`))]}):null;return g.length===0?e.jsxs("div",{className:"w6w-log-view w6w-log-view-is-empty","data-testid":"execution-log-view",children:[F,e.jsx("div",{className:"w6w-execution-log-empty",children:e.jsx("p",{className:"w6w-muted w6w-small",children:s??"No nodes have run yet."})}),b.length>0&&e.jsx(ot,{steps:b})]}):e.jsxs("div",{className:"w6w-log-view","data-testid":"execution-log-view",children:[F,e.jsxs("div",{ref:d,className:"w6w-log-view-cols",style:x===null?void 0:{gridTemplateColumns:`${x}px auto minmax(0, 1fr)`},children:[e.jsxs("div",{ref:m,className:"w6w-log-view-list-col",children:[e.jsx("ul",{ref:c,className:"w6w-log-view-list","aria-label":"Steps of this run",onKeyDown:T,children:g.map(C=>e.jsx(la,{step:C,selected:C.id===(S==null?void 0:S.id),onSelect:()=>k(C.id)},C.id))}),b.length>0&&e.jsx(ot,{steps:b})]}),e.jsx("div",{className:"w6w-log-view-divider",role:"separator","aria-orientation":"vertical","aria-label":"Resize step list","aria-valuenow":x??void 0,"aria-valuemin":Le,tabIndex:0,title:"Drag to resize · double-click to reset","data-testid":"execution-log-divider",onPointerDown:p,onKeyDown:v,onDoubleClick:u}),e.jsx("div",{className:"w6w-log-view-detail-col","data-testid":"execution-log-detail",children:S&&e.jsx(oa,{step:S},S.id)})]})]})}function la({step:t,selected:s,onSelect:n}){const a=t.node?Ke(t.node):null,i=t.startedAt&&t.finishedAt?xt(t.startedAt,t.finishedAt):t.status==="running"?"running…":null;return e.jsx("li",{children:e.jsxs("button",{type:"button",className:`w6w-log-view-item${s?" w6w-log-view-item-selected":""}`,"aria-current":s?"true":void 0,"data-step-id":t.id,"data-status":t.status,"data-testid":"execution-log-item",onClick:n,children:[e.jsxs("span",{className:`w6w-log-view-item-mark${t.node?" w6w-log-view-item-mark-icon":""}`,children:[e.jsx(xs,{node:t.node,size:20}),e.jsx("span",{className:`w6w-step-pill-${t.status} w6w-log-view-dot`,role:"img","aria-label":t.status,title:t.status})]}),e.jsxs("span",{className:"w6w-log-view-item-title",children:[e.jsx("span",{className:"w6w-log-view-item-label",children:t.label??t.id}),a&&e.jsxs("span",{className:"w6w-log-view-item-uses",children:[a.trigger?"Trigger · ":"",a.appName===a.actionName?a.appName:`${a.appName} · ${a.actionName}`]})]}),i&&e.jsx("span",{className:"w6w-log-view-item-time",children:i})]})})}function ra(t){const s=new Date(t);if(!Number.isFinite(s.getTime()))return t;const n=(a,i=2)=>String(a).padStart(i,"0");return`${n(s.getHours())}:${n(s.getMinutes())}:${n(s.getSeconds())}.${n(s.getMilliseconds(),3)}`}function Yt({iso:t}){if(!t)return e.jsx("span",{className:"w6w-muted",children:"—"});const s=new Date(t);return e.jsx("time",{dateTime:t,title:Number.isFinite(s.getTime())?s.toString():t,children:ra(t)})}function oa({step:t}){var a;const s=t.node?Ke(t.node):null,n=t.startedAt&&t.finishedAt?xt(t.startedAt,t.finishedAt):null;return e.jsxs("div",{className:"w6w-log-view-detail w6w-stack",children:[e.jsxs("div",{className:"w6w-log-view-detail-head",children:[e.jsx(xs,{node:t.node,size:24}),e.jsxs("div",{className:"w6w-log-view-detail-title",children:[e.jsx("strong",{children:t.label??t.id}),s&&e.jsxs("span",{className:"w6w-muted w6w-small",children:[s.trigger?"Trigger · ":"",s.appName===s.actionName?s.appName:`${s.appName} · ${s.actionName}`]})]}),e.jsx(Se,{state:t.status}),t.status==="skipped"&&t.skipReason&&t.skipReason!=="not_on_path"&&e.jsx("span",{className:"w6w-execution-log-skip-reason",children:us[t.skipReason]})]}),e.jsxs("dl",{className:"w6w-log-view-timing","data-testid":"execution-log-timing",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Started"}),e.jsx("dd",{children:e.jsx(Yt,{iso:t.startedAt})})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Finished"}),e.jsx("dd",{children:e.jsx(Yt,{iso:t.finishedAt})})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Elapsed"}),e.jsx("dd",{children:n??(t.status==="running"?"running…":"—")})]})]}),t.error&&e.jsx(he,{error:t.error}),Array.isArray(t.iterations)&&e.jsx(ms,{step:t}),e.jsx(hs,{input:t.input}),e.jsxs("div",{className:"w6w-log-view-io",children:[e.jsx(Be,{title:"Input",value:t.input,defaultOpen:!0}),e.jsx(Be,{title:"Output",value:t.output,defaultOpen:!0})]}),!!((a=t.logs)!=null&&a.length)&&e.jsxs("div",{className:"w6w-execution-log-json w6w-stack",children:[e.jsx("strong",{className:"w6w-small",children:"Console"}),e.jsx(K.CodeBlock,{code:t.logs.join(`
3
+ `),language:"plaintext"})]}),t.meta&&e.jsxs("div",{className:"w6w-execution-log-json w6w-stack",children:[e.jsx("strong",{className:"w6w-small",children:"Metadata"}),e.jsx(K.CodeBlock,{code:JSON.stringify(t.meta,null,2),language:"json"})]}),ps(t)&&e.jsx(fs,{step:t})]})}const gs=120,vs=()=>Math.round((typeof window<"u"?window.innerHeight:800)*.85),ge=t=>Math.min(Math.max(t,gs),vs());function ca({children:t,open:s,onOpenChange:n,title:a="Logs",summary:i,onClear:l,defaultHeight:o=320,windowClassName:r,windowTitle:c="Logs",barActions:d,"data-testid":m="execution-log-dock"}){const x=f.useId(),[j,w]=f.useState("docked"),[p,v]=f.useState(()=>ge(o)),[u,g]=f.useState(null),b=f.useRef(null),N=f.useRef(null),S=f.useCallback(()=>{const I=b.current;b.current=null,g(null),I&&!I.closed&&I.close()},[]);f.useEffect(()=>S,[S]);const k=f.useCallback(()=>{S(),w("docked"),n(!0)},[S,n]),T=()=>{var D,E;const I=((E=(D=N.current)==null?void 0:D.closest("[data-theme]"))==null?void 0:E.getAttribute("data-theme"))??void 0,$=da(c,r,I);if(!$){w("floating"),n(!0);return}b.current=$.window,g($.host),w("window"),n(!0),$.window.addEventListener("pagehide",()=>{b.current===$.window&&(b.current=null,g(null),w("docked"))})},A=I=>{var W;I.preventDefault();const $=I.clientY,D=p,E=I.currentTarget;(W=E.setPointerCapture)==null||W.call(E,I.pointerId);const U=Q=>v(ge(D+($-Q.clientY))),L=()=>{E.removeEventListener("pointermove",U),E.removeEventListener("pointerup",L),E.removeEventListener("pointercancel",L)};E.addEventListener("pointermove",U),E.addEventListener("pointerup",L),E.addEventListener("pointercancel",L)},F=I=>{const $=I.shiftKey?64:16;if(I.key==="ArrowUp")v(D=>ge(D+$));else if(I.key==="ArrowDown")v(D=>ge(D-$));else return;I.preventDefault()},C=j==="docked",P=s&&C,O=e.jsx("div",{id:x,className:"w6w-log-dock-body",hidden:!s,style:C?{height:p}:void 0,children:t});return e.jsxs("div",{ref:N,className:`w6w-log-dock w6w-log-dock-${j}${P?" w6w-log-dock-open":""}`,"data-testid":m,"data-mode":j,children:[P&&e.jsx("div",{className:"w6w-log-dock-resize",role:"separator","aria-orientation":"horizontal","aria-label":"Resize log","aria-valuenow":p,"aria-valuemin":gs,"aria-valuemax":vs(),tabIndex:0,onPointerDown:A,onKeyDown:F,onDoubleClick:()=>v(ge(o))}),e.jsxs("div",{className:"w6w-log-dock-bar",children:[e.jsxs("button",{type:"button",className:"w6w-log-dock-toggle","aria-expanded":s&&C,"aria-controls":x,"data-testid":"execution-log-dock-toggle",onClick:()=>C?n(!s):k(),children:[e.jsx(K.Icon,{name:s&&C?"chevron-down":"chevron-up",size:14}),e.jsx("span",{className:"w6w-log-dock-title",children:a})]}),i!==void 0&&e.jsx("div",{className:"w6w-log-dock-summary",children:i}),e.jsxs("div",{className:"w6w-log-dock-actions",children:[d,l&&e.jsx(h.IconButton,{icon:"trash",label:"Clear log","data-testid":"execution-log-dismiss",onClick:l}),C?e.jsx(h.IconButton,{icon:"external-link",label:"Open log in a separate window","data-testid":"execution-log-popout",onClick:T}):e.jsx(h.IconButton,{icon:"panel-bottom",label:"Dock log to the bottom","data-testid":"execution-log-dock-back",onClick:k})]})]}),j==="docked"&&O,j==="floating"&&e.jsx(ua,{title:a,onDock:k,onClose:()=>{w("docked"),n(!1)},children:O}),j==="window"&&u&&ns.createPortal(O,u)]})}function da(t,s,n){if(typeof window>"u"||typeof window.open!="function")return null;let a=null;try{a=window.open("","","popup,width=960,height=640")}catch{return null}if(!(a!=null&&a.document))return null;const i=a.document;i.title=t;for(const o of Array.from(document.querySelectorAll('link[rel="stylesheet"], style'))){const r=o.cloneNode(!0);r.tagName==="LINK"&&(r.href=o.href),i.head.appendChild(r)}for(const o of Array.from(document.documentElement.attributes))(o.name==="class"||o.name==="style"||o.name.startsWith("data-"))&&i.documentElement.setAttribute(o.name,o.value);i.body.className="w6w-log-window-body";const l=i.createElement("div");return l.className=["w6w-log-window",s].filter(Boolean).join(" "),n&&(l.setAttribute("data-theme",n),i.body.setAttribute("data-theme",n)),i.body.appendChild(l),{window:a,host:l}}function ua({title:t,children:s,onDock:n,onClose:a}){const[i,l]=f.useState({right:24,bottom:56}),o=r=>{var j;if(r.target.closest("button"))return;r.preventDefault();const c={x:r.clientX,y:r.clientY,...i},d=r.currentTarget;(j=d.setPointerCapture)==null||j.call(d,r.pointerId);const m=w=>l({right:Math.max(0,c.right-(w.clientX-c.x)),bottom:Math.max(0,c.bottom-(w.clientY-c.y))}),x=()=>{d.removeEventListener("pointermove",m),d.removeEventListener("pointerup",x)};d.addEventListener("pointermove",m),d.addEventListener("pointerup",x)};return e.jsxs("section",{className:"w6w-log-float","aria-label":typeof t=="string"?t:"Logs",style:{right:i.right,bottom:i.bottom},"data-testid":"execution-log-float",children:[e.jsxs("div",{className:"w6w-log-float-head",onPointerDown:o,children:[e.jsx("strong",{className:"w6w-small",children:t}),e.jsxs("div",{className:"w6w-log-dock-actions",children:[e.jsx(h.IconButton,{icon:"panel-bottom",label:"Dock log to the bottom",onClick:n}),e.jsx(h.IconButton,{icon:"close",label:"Close log",onClick:a})]})]}),s]})}const wa={status:"",kind:"",from:"",to:"",q:"",trigger:""},ma=[{value:"",label:"Any status"},{value:"queued",label:"Queued"},{value:"running",label:"Running"},{value:"succeeded",label:"Succeeded"},{value:"failed",label:"Failed"},{value:"canceled",label:"Canceled"}],ha=[{value:"",label:"Any type"},{value:"function",label:"Function"},{value:"endpoint",label:"Endpoint"},{value:"workflow",label:"Workflow"}];function pa({value:t,onChange:s,showKind:n=!1,searchPlaceholder:a="Search by id or name",disabled:i=!1,triggerOptions:l}){const o=t.status!==""||t.kind!==""||t.from!==""||t.to!==""||t.q!==""||(t.trigger??"")!=="";return e.jsxs("div",{className:"w6w-execution-filters","data-testid":"execution-filters",children:[e.jsx("input",{type:"search",className:"w6w-execution-filters-search","data-testid":"execution-filter-q","aria-label":"Search executions",placeholder:a,value:t.q,disabled:i,onChange:r=>s({...t,q:r.target.value})}),e.jsx("select",{className:"w6w-execution-filters-select","data-testid":"execution-filter-status","aria-label":"Status",value:t.status,disabled:i,onChange:r=>s({...t,status:r.target.value}),children:ma.map(r=>e.jsx("option",{value:r.value,children:r.label},r.value))}),l&&l.length>0&&e.jsxs("select",{className:"w6w-execution-filters-select","data-testid":"execution-filter-trigger","aria-label":"Trigger",value:t.trigger??"",disabled:i,onChange:r=>s({...t,trigger:r.target.value}),children:[e.jsx("option",{value:"",children:"Any trigger"}),l.map(r=>e.jsx("option",{value:r.value,children:r.label},r.value))]}),n&&e.jsx("select",{className:"w6w-execution-filters-select","data-testid":"execution-filter-kind","aria-label":"Type",value:t.kind,disabled:i,onChange:r=>s({...t,kind:r.target.value}),children:ha.map(r=>e.jsx("option",{value:r.value,children:r.label},r.value))}),e.jsx("input",{type:"date",className:"w6w-execution-filters-date","data-testid":"execution-filter-from","aria-label":"From date",value:t.from,disabled:i,onChange:r=>s({...t,from:r.target.value})}),e.jsx("input",{type:"date",className:"w6w-execution-filters-date","data-testid":"execution-filter-to","aria-label":"To date",value:t.to,disabled:i,onChange:r=>s({...t,to:r.target.value})}),o&&e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-execution-filters-clear","data-testid":"execution-filter-clear",disabled:i,onClick:()=>s({...wa}),children:"Clear"})]})}const Oe="—";function fa({stats:t,label:s}){const n=[{testid:"execution-stat-total",label:"Executions",value:t?String(t.total):Oe},{testid:"execution-stat-success-rate",label:"Success rate",value:xa(t==null?void 0:t.successRate)},{testid:"execution-stat-failed",label:"Failed",value:t?String(t.failed):Oe},{testid:"execution-stat-avg-duration",label:"Avg duration",value:t?We(t.avgDurationMs):Oe}];return t&&t.inFlight>0&&n.push({testid:"execution-stat-in-flight",label:"In flight",value:String(t.inFlight)}),e.jsxs("section",{className:"w6w-execution-stats","data-testid":"execution-stats",children:[s!=null&&e.jsx("p",{className:"w6w-execution-stats-label",children:s}),e.jsx("div",{className:"w6w-execution-stats-cards",children:n.map(a=>e.jsxs("div",{className:"w6w-execution-stat","data-testid":a.testid,children:[e.jsx("span",{className:"w6w-execution-stat-value","data-stat-value":a.value,children:a.value}),e.jsx("span",{className:"w6w-execution-stat-label",children:a.label})]},a.testid))})]})}function xa(t){return t==null||!Number.isFinite(t)?Oe:`${Math.round(t*100)}%`}const ga={function:"Function",endpoint:"Endpoint",workflow:"Workflow"};function va(t){return JSON.stringify(t,null,2)??"null"}function ja({execution:t,loading:s=!1,errorMessage:n,onClose:a,onOpenInEditor:i,onBack:l,onRerun:o,rerunning:r=!1,onOpenExecution:c}){return e.jsxs("section",{className:"w6w-execution-detail w6w-stack","data-testid":"execution-detail",children:[l&&e.jsx("div",{className:"w6w-execution-detail-back",children:e.jsxs("button",{type:"button",className:"w6w-btn w6w-btn-ghost","data-testid":"execution-detail-back",onClick:l,children:[e.jsx("span",{"aria-hidden":"true",children:"←"})," Back"]})}),n!=null&&e.jsx("p",{role:"alert",className:"w6w-execution-detail-error-message","data-testid":"execution-detail-error-message",children:n}),t?e.jsx(ba,{execution:t,onClose:a,onOpenInEditor:i,onRerun:o,rerunning:r,onOpenExecution:c}):s?e.jsx("p",{className:"w6w-muted","data-testid":"execution-detail-loading",children:"Loading…"}):e.jsx("p",{className:"w6w-muted","data-testid":"execution-detail-empty",children:"No execution selected."})]})}function ba({execution:t,onClose:s,onOpenInEditor:n,onRerun:a,rerunning:i,onOpenExecution:l}){const o=t.rerunOf;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"w6w-execution-detail-head",children:[e.jsxs("div",{className:"w6w-execution-detail-title",children:[e.jsx("h3",{className:"w6w-execution-detail-name",children:t.callableName}),e.jsxs("div",{className:"w6w-execution-detail-meta",children:[e.jsx(Se,{state:t.status}),e.jsx("span",{className:"w6w-execution-detail-kind w6w-muted w6w-small",children:ga[t.kind]})]})]}),(a||n||s)&&e.jsxs("div",{className:"w6w-execution-detail-actions",children:[a&&e.jsxs("button",{type:"button",className:"w6w-btn w6w-execution-detail-rerun","data-testid":"execution-detail-rerun",title:"Run it again with the same input",disabled:i,onClick:a,children:[e.jsx(K.Icon,{name:"sync",size:14})," ",i?"Re-running…":"Re-run"]}),n&&e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost","data-testid":"execution-detail-open-editor",onClick:n,children:"Open in visual editor"}),s&&e.jsx(h.IconButton,{label:"Close","data-testid":"execution-detail-close",onClick:s,children:"×"})]})]}),e.jsx("p",{className:"w6w-execution-detail-id-line",children:e.jsx("code",{className:"w6w-execution-detail-id","data-testid":"execution-detail-id",children:t.id})}),o&&e.jsxs("p",{className:"w6w-execution-detail-rerun-of","data-testid":"execution-detail-rerun-of",children:[e.jsx("span",{className:"w6w-execution-rerun-tag",children:"Re-run"}),e.jsx("span",{className:"w6w-muted w6w-small",children:"of"}),l?e.jsx("button",{type:"button",className:"w6w-execution-detail-rerun-of-link","data-testid":"execution-detail-rerun-of-link",onClick:()=>l(o),children:e.jsx("code",{children:o})}):e.jsx("code",{children:o})]}),e.jsxs("dl",{className:"w6w-execution-detail-timing",children:[e.jsx(it,{label:"Started",value:ye(t.startedAt)}),e.jsx(it,{label:"Finished",value:t.finishedAt?ye(t.finishedAt):"—"}),e.jsx(it,{label:"Duration",value:We(t.durationMs)})]}),t.steps!==void 0&&e.jsxs("section",{className:"w6w-execution-detail-section w6w-stack","data-testid":"execution-detail-steps",children:[e.jsx("strong",{className:"w6w-small",children:"Nodes"}),e.jsx(ds,{steps:t.steps,emptyLabel:"No nodes ran."})]}),t.input!==void 0&&e.jsx(lt,{title:"Input",testid:"execution-detail-input",value:t.input}),t.output!==void 0&&e.jsx(lt,{title:"Output",testid:"execution-detail-output",value:t.output}),t.error!=null&&e.jsx(lt,{title:"Error",testid:"execution-detail-error",value:t.error})]})}function it({label:t,value:s}){return e.jsxs("div",{className:"w6w-execution-detail-timing-item",children:[e.jsx("dt",{children:t}),e.jsx("dd",{children:s})]})}function lt({title:t,testid:s,value:n}){return e.jsxs("section",{className:"w6w-execution-detail-section w6w-stack","data-testid":s,children:[e.jsx("strong",{className:"w6w-small",children:t}),e.jsx(K.CodeBlock,{code:va(n),language:"json"})]})}function js(t){const s=[];for(const n of t)n.p95Ms!==null&&s.push({appId:n.appId,displayName:n.displayName,calls:n.calls,p95Ms:n.p95Ms,state:n.state,errorCount:n.errors.e4xx+n.errors.e429+n.errors.eAuth+n.errors.e5xx});return s}function ya(t){return t.attention==="now"||t.attention==="recent"}function bs(t){const s={now:[],recent:[],clear:[]};for(const n of t)n.attention==="now"?s.now.push(n):n.attention==="recent"?s.recent.push(n):s.clear.push(n);return s}function ys(t){return t.uptime.map(s=>({day:s.day,state:s.state}))}const dt=3,Ns=5;function ks(t,s={}){const n=s.compact??!1,{now:a,recent:i}=bs(t),l=a.length+i.length,o=n?a.slice(0,dt):a,r=n?i.slice(0,Math.max(0,dt-o.length)):i,c=n?t.slice(0,s.limit??Ns):[...t];return{attentionCount:l,shownNow:o,shownRecent:r,hiddenAttentionCount:l-o.length-r.length,shownTable:c,hiddenTableCount:t.length-c.length}}const $e=640,ve=340,G={top:16,right:24,bottom:40,left:56};function zt(t){if(t<=0)return 1;const s=10**Math.floor(Math.log10(t)),n=[1,2,5,10];for(const a of n)if(t<=a*s)return a*s;return 10*s}function Gt(t,s=5){return Array.from({length:s+1},(n,a)=>Math.round(t*a/s))}function Ss({services:t,getHref:s,onOpen:n}){const a=js(t);if(a.length===0)return e.jsx("p",{className:"w6w-muted w6w-small",children:"No timed calls in this window yet."});const i=zt(Math.max(...a.map(u=>u.calls))),l=zt(Math.max(...a.map(u=>u.p95Ms))),o=Math.max(1,...a.map(u=>u.errorCount)),r=$e-G.left-G.right,c=ve-G.top-G.bottom,d=u=>G.left+u/i*r,m=u=>G.top+u/l*c,x=u=>16+u/o*14,j=Gt(i),w=Gt(l),p=18,v=G.top+c/2;return e.jsxs("div",{className:"w6w-rel-scatter",children:[e.jsxs("svg",{viewBox:`0 0 ${$e} ${ve}`,style:{aspectRatio:`${$e} / ${ve}`},role:"img","aria-label":"API performance: calls versus p95 latency, one point per API",children:[e.jsx("rect",{x:G.left,y:G.top,width:r,height:c,className:"w6w-rel-scatter-plot-bg"}),w.map(u=>e.jsxs("g",{children:[e.jsx("line",{x1:G.left,x2:$e-G.right,y1:m(u),y2:m(u),className:"w6w-rel-scatter-grid"}),e.jsx("text",{x:G.left-8,y:m(u),className:"w6w-rel-scatter-axis-label",textAnchor:"end",children:u})]},`y-${u}`)),j.map(u=>e.jsx("text",{x:d(u),y:ve-G.bottom+18,className:"w6w-rel-scatter-axis-label",textAnchor:"middle",children:u},`x-${u}`)),e.jsx("text",{x:p,y:v,className:"w6w-rel-scatter-axis-title",textAnchor:"middle",transform:`rotate(-90, ${p}, ${v})`,children:"p95 (ms)"}),e.jsx("text",{x:G.left+r/2,y:ve-4,className:"w6w-rel-scatter-axis-title",textAnchor:"middle",children:"calls in this window"}),a.map(u=>{const g=x(u.errorCount),b=d(u.calls),N=m(u.p95Ms),S=e.jsxs(e.Fragment,{children:[e.jsx("circle",{cx:b,cy:N,r:g/2+2.5,className:`w6w-rel-scatter-ring w6w-rel-scatter-ring-${u.state}`,children:e.jsxs("title",{children:[u.displayName," — ",u.calls," calls, ",u.p95Ms," ms p95, ",u.errorCount," errors"]})}),e.jsx("circle",{cx:b,cy:N,r:g/2,className:`w6w-rel-scatter-point w6w-rel-scatter-point-${u.state}`})]});return s?e.jsx("a",{href:s(u.appId),className:"w6w-rel-scatter-point-link",onClick:n?k=>n(u.appId,k):void 0,children:S},u.appId):n?e.jsx("g",{role:"button",tabIndex:0,className:"w6w-rel-scatter-point-link",onClick:k=>n(u.appId,k),onKeyDown:k=>{(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),k.currentTarget.dispatchEvent(new MouseEvent("click",{bubbles:!0})))},children:S},u.appId):e.jsx("g",{children:S},u.appId)})]}),e.jsx("p",{className:"w6w-muted w6w-small w6w-rel-scatter-note",children:"Up is faster, right is more calls — top-right is the best outcome. Icon size is the error count in this window; ring colour is exec status."})]})}function Xt(t){const s=new Date(t);return Number.isNaN(s.getTime())?t:s.toLocaleDateString(void 0,{month:"short",day:"numeric"})}function Cs({appId:t,className:s,title:n,getHref:a,onOpen:i,children:l}){return a?e.jsx("a",{className:s,href:a(t),title:n,onClick:i?o=>i(t,o):void 0,children:l}):i?e.jsx("button",{type:"button",className:s,title:n,onClick:o=>i(t,o),children:l}):e.jsx("div",{className:s,title:n,children:l})}function Es({service:t}){return e.jsxs("span",{className:"w6w-rel-signal",children:[e.jsx(Ue,{state:t.state}),t.ongoingOutageId&&e.jsx("span",{className:"w6w-rel-tag",children:"outage open"}),t.calls===0&&e.jsx("span",{className:"w6w-muted w6w-small",children:"no calls"})]})}function Rs({vendor:t}){if(!t)return e.jsx("span",{className:"w6w-muted w6w-small",children:"not published"});const s=t.state==="unknown";return e.jsxs("span",{className:"w6w-rel-signal",title:t.message??void 0,children:[e.jsx(Ue,{state:t.state,label:s?"Unavailable":void 0}),!s&&t.message&&e.jsx("span",{className:"w6w-rel-vendor-msg w6w-small",children:t.message})]})}function Na({service:t,getHref:s,onOpen:n}){return e.jsxs(Cs,{appId:t.appId,className:"w6w-rel-issue-card",title:`${t.displayName} — open service detail`,getHref:s,onOpen:n,children:[e.jsxs("span",{className:"w6w-rel-issue-head",children:[e.jsx(h.AppIcon,{src:t.iconSrc,srcDark:t.iconSrcDark,brandColor:t.brandColor,name:t.displayName,size:24}),e.jsxs("span",{className:"w6w-rel-issue-head-text",children:[e.jsx("strong",{children:t.displayName}),t.attention==="recent"&&e.jsx("span",{className:"w6w-muted w6w-small",children:"trouble earlier in this window"})]})]}),e.jsxs("span",{className:"w6w-rel-issue-signals",children:[e.jsxs("span",{className:"w6w-rel-issue-signal",children:[e.jsx("span",{className:"w6w-muted w6w-small",children:"w6w exec"}),e.jsx(Es,{service:t})]}),e.jsxs("span",{className:"w6w-rel-issue-signal",children:[e.jsx("span",{className:"w6w-muted w6w-small",children:"API status"}),e.jsx(Rs,{vendor:t.vendorStatus})]})]})]})}function ka({service:t,getHref:s,onOpen:n}){const a=t.calls===0;return e.jsxs("tr",{className:`w6w-rel-tr${t.attention!=="none"?" w6w-rel-attention":""}`,"data-attention":t.attention==="none"?void 0:t.attention,children:[e.jsx("td",{className:"w6w-rel-td-service",children:e.jsxs(Cs,{appId:t.appId,className:"w6w-rel-open",getHref:s,onOpen:n,children:[e.jsx(h.AppIcon,{src:t.iconSrc,srcDark:t.iconSrcDark,brandColor:t.brandColor,name:t.displayName,size:28}),e.jsxs("span",{className:"w6w-rel-td-service-text",children:[e.jsx("strong",{children:t.displayName}),e.jsx("code",{className:"w6w-muted w6w-small",children:t.appId})]})]})}),e.jsxs("td",{className:"w6w-rel-td-status",children:[e.jsxs("span",{className:"w6w-rel-status-row",children:[e.jsx("span",{className:"w6w-rel-status-label w6w-muted w6w-small",children:"Ops"}),e.jsx(Es,{service:t})]}),e.jsxs("span",{className:"w6w-rel-status-row",children:[e.jsx("span",{className:"w6w-rel-status-label w6w-muted w6w-small",children:"API"}),e.jsx(Rs,{vendor:t.vendorStatus})]})]}),e.jsx("td",{className:"w6w-rel-td-uptime",children:a?e.jsx("span",{className:"w6w-rel-idle-note",children:"No calls in this window"}):e.jsxs(e.Fragment,{children:[e.jsx(rs,{days:ys(t),ariaLabel:`${t.displayName}, ${t.uptime.length}-day status, oldest day first`}),e.jsxs("span",{className:"w6w-muted w6w-small",children:[t.calls," calls"]})]})}),e.jsx("td",{className:"w6w-rel-td-p95",children:t.p95Ms===null?"—":`${t.p95Ms} ms`})]})}function Sa({services:t,window:s,days:n,compact:a=!1,showChart:i,limit:l,getHref:o,onOpen:r,showAllHref:c,onShowAll:d,slots:m}){const x=n??(s==null?void 0:s.days)??30,j=t.length>0&&t.every(T=>T.calls>0&&T.state==="ok"),{attentionCount:w,shownNow:p,shownRecent:v,hiddenAttentionCount:u,shownTable:g,hiddenTableCount:b}=ks(t,{compact:a,limit:l}),N=i??!a,S=c!==void 0||d!==void 0,k=T=>{const A=T.startsWith("Show")?"w6w-muted w6w-small":void 0;return c!==void 0?e.jsx("a",{href:c,className:A,onClick:d,children:T}):d?e.jsx("button",{type:"button",className:`w6w-rel-show-all${A?` ${A}`:""}`,onClick:d,children:T}):null};return e.jsxs("section",{className:"w6w-rel-section",children:[e.jsxs("h3",{className:"w6w-rel-heading",children:[e.jsxs("span",{children:[(m==null?void 0:m.header)??"Service reliability"," ",s&&e.jsxs("span",{className:"w6w-muted w6w-small",children:[Xt(s.from)," – ",Xt(s.to)," · ",s.days," days"]})]}),a&&k("Show all services →"),m==null?void 0:m.actions]}),e.jsxs("div",{className:a?"w6w-rel-card":void 0,children:[e.jsx("p",{className:"w6w-muted w6w-small w6w-rel-intro",children:"Connected services across your account. Performance for the selected project."}),j&&e.jsxs("div",{className:a?"w6w-rel-allclear":"w6w-rel-card w6w-rel-allclear",children:[e.jsx("h4",{children:"All clear"}),e.jsxs("p",{children:["Every service you called in the last ",x," days came back"," ",e.jsx(Ue,{state:"ok"})," — no degraded stretches, no outages."]})]}),t.length===0&&((m==null?void 0:m.empty)??e.jsx("div",{className:a?void 0:"w6w-rel-card",children:e.jsx("p",{className:"w6w-muted",children:"No services yet — connect an integration or use a service in this project."})})),t.length>0&&e.jsxs(e.Fragment,{children:[w>0&&e.jsxs("div",{className:"w6w-rel-group",children:[e.jsxs("h4",{className:"w6w-rel-group-head",children:["Needs attention"," ",e.jsxs("span",{className:"w6w-muted w6w-small",children:[p.length+v.length," of ",w]})]}),e.jsx("div",{className:"w6w-rel-issues",children:[...p,...v].map(T=>e.jsx(Na,{service:T,getHref:o,onOpen:r},T.appId))}),u>0&&e.jsxs("p",{className:"w6w-muted w6w-small w6w-rel-more-note",children:[u," more ",u===1?"needs":"need"," ","attention",S&&e.jsxs(e.Fragment,{children:[" — ",k("view all →")]})]})]}),N&&e.jsxs("div",{className:"w6w-rel-group",children:[e.jsx("h4",{className:"w6w-rel-group-head",children:"Performance across your APIs"}),e.jsx(Ss,{services:t,getHref:o,onOpen:r})]}),g.length>0&&e.jsxs("div",{className:"w6w-rel-group",children:[e.jsxs("h4",{className:"w6w-rel-group-head",children:[a?"Services":"All services"," ",e.jsx("span",{className:"w6w-muted w6w-small",children:a?`${g.length} of ${t.length}`:t.length})]}),e.jsx("div",{className:"w6w-rel-table-wrap",children:e.jsxs("table",{className:"w6w-rel-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Service"}),e.jsx("th",{children:"Status"}),e.jsxs("th",{children:["Last ",x," days"]}),e.jsx("th",{children:"Latency"})]})}),e.jsx("tbody",{children:g.map(T=>e.jsx(ka,{service:T,getHref:o,onOpen:r},T.appId))})]})}),b>0&&e.jsxs("p",{className:"w6w-muted w6w-small w6w-rel-more-note",children:[b," more",S&&e.jsxs(e.Fragment,{children:[" — ",k("view all →")]})]})]})]})]})]})}function Ca({tone:t="muted",title:s,children:n,"data-testid":a}){return e.jsx("span",{className:`w6w-callable-list-status w6w-callable-list-status-${t}`,title:s,"data-testid":a,children:n})}const me="all",ne="archived";function Ea(t,s){return s===""?!0:[t.id,t.searchText,typeof t.title=="string"?t.title:void 0,typeof t.description=="string"?t.description:void 0].some(a=>a==null?void 0:a.toLowerCase().includes(s))}function Ra({rows:t,title:s,icon:n,description:a,emptyCopy:i,newLabel:l="New",openRowTitle:o,testIds:r,loading:c,error:d,onCreate:m,creating:x,onImport:j,onOpen:w,getHref:p,groups:v=[],filter:u,onFilterChange:g,showArchived:b,onShowArchivedChange:N,searchPlaceholder:S="Search by name",slots:k}){var q;const[T,A]=f.useState(me),[F,C]=f.useState(""),P=u??(b===void 0?void 0:b?ne:me),O=P??T,I=R=>{P===void 0&&A(R),g==null||g(R),R===ne!=(O===ne)&&(N==null||N(R===ne))},$=t.filter(R=>!R.archived),D=t.length-$.length,E=R=>O===ne?R.archived:!R.archived&&(O===me||R.group===O),U=F.trim().toLowerCase(),L=t.filter(R=>E(R)&&Ea(R,U)),W=[{key:me,label:"All",count:$.length},...v.map(R=>({...R,count:$.filter(V=>V.group===R.key).length})),{key:ne,label:"Archived",count:D}],Q=((q=W.find(R=>R.key===O))==null?void 0:q.label)??O,Z=w!==void 0||p!==void 0,X=[{key:"main",header:"Name",render:R=>{const V=R.icon!==void 0?R.icon:n?e.jsx(K.Icon,{name:n,size:16}):null,re=e.jsxs("span",{className:"w6w-callable-list-cell",title:Z?o:void 0,children:[V!=null&&e.jsx("span",{className:"w6w-callable-list-icon","aria-hidden":"true",children:V}),e.jsxs("span",{className:"w6w-callable-list-main",children:[e.jsxs("span",{className:"w6w-callable-list-title-line",children:[e.jsx("span",{className:"w6w-callable-list-name",children:R.title}),R.status]}),R.description!=null&&R.description!==""&&e.jsx("span",{className:"w6w-muted w6w-small w6w-callable-list-row-desc",children:R.description}),R.meta!=null&&e.jsx("span",{className:"w6w-muted w6w-callable-list-meta",children:R.meta})]})]});return w&&!p?e.jsx("button",{type:"button",className:"w6w-callable-list-open",children:re}):re}},{key:"trail",header:"",align:"right",width:"1%",render:R=>R.archived||R.badges!=null||R.trailing!=null?e.jsxs("span",{className:"w6w-callable-list-trail",children:[R.badges,R.archived&&e.jsx("span",{className:"w6w-callable-list-badge","data-testid":r==null?void 0:r.archivedBadge,children:"archived"}),R.trailing]}):null}];L.some(R=>R.menu!=null)&&X.push({key:"menu",header:"",align:"right",link:!1,actions:!0,render:R=>R.menu??null});const le=O===me&&U===""&&t.length>0&&$.length===0;return e.jsxs("section",{className:"w6w-callable-list",children:[e.jsxs("div",{className:"w6w-callable-list-head",children:[e.jsx("div",{className:"w6w-callable-list-heading",children:(k==null?void 0:k.header)??e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"w6w-callable-list-title",children:s}),a!=null&&e.jsx("p",{className:"w6w-muted w6w-small w6w-callable-list-description",children:a})]})}),e.jsxs("div",{className:"w6w-callable-list-actions",children:[k==null?void 0:k.actions,j&&e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost","data-testid":r==null?void 0:r.importOpen,onClick:j,children:"Import"}),m&&e.jsx("button",{type:"button",className:"w6w-btn",disabled:x,onClick:m,children:x?"Creating…":l})]})]}),t.length>0&&e.jsxs("div",{className:"w6w-callable-list-filters",children:[e.jsx("fieldset",{className:"w6w-subtabs w6w-callable-list-tabs","aria-label":"Filter by status",children:W.map(R=>e.jsxs("button",{type:"button",className:`w6w-subtab${O===R.key?" active":""}`,"aria-pressed":O===R.key,"data-testid":R.key===ne&&(r!=null&&r.showArchived)?r.showArchived:r!=null&&r.filterTab?`${r.filterTab}-${R.key}`:void 0,onClick:()=>I(R.key),children:[R.label,e.jsx("span",{className:"w6w-callable-list-count",children:R.count})]},R.key))}),e.jsx("input",{type:"search",className:"w6w-callable-list-search",placeholder:S,"aria-label":S,value:F,"data-testid":r==null?void 0:r.search,onChange:R=>C(R.target.value)})]}),d&&e.jsx("div",{className:"w6w-error",children:d}),e.jsxs("div",{className:"w6w-callable-list-body",children:[c&&e.jsx("p",{className:"w6w-muted",children:"Loading…"}),L.length===0&&!c?le?e.jsx(h.EmptyState,{testId:"w6w-callable-list-empty",action:e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:()=>I(ne),children:"Show archived"}),children:t.length===1?"The only item is archived.":`All ${t.length} items are archived.`}):t.length>0?e.jsx(h.EmptyState,{testId:"w6w-callable-list-empty",action:e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:()=>{C(""),I(me)},children:"Show all"}),children:U!==""?`Nothing in ${Q} matches "${F.trim()}".`:`Nothing in ${Q}.`}):e.jsx(h.EmptyState,{testId:"w6w-callable-list-empty",children:(k==null?void 0:k.empty)??i}):e.jsx(h.DataTable,{columns:X,rows:L,rowKey:R=>R.id,className:"w6w-data-table-rows",loading:c,getRowHref:p?R=>p(R.id):void 0,onRowClick:w?(R,V)=>w(R.id,V):void 0})]})]})}function Aa({connections:t,appsById:s,loading:n,error:a,onOpen:i,getHref:l,onEdit:o,onDelete:r,busy:c,slots:d}){const m=s??new Map,x=o!==void 0||r!==void 0,j=[{key:"name",header:"Name",render:w=>{const p=h.resolveConnectionAppMeta(w,m),v=w.displayName||w.id;return e.jsxs("span",{className:"w6w-connection-cell-name",children:[e.jsx(h.AppIcon,{src:p==null?void 0:p.iconSvg,srcDark:p==null?void 0:p.iconSvgDark,brandColor:p==null?void 0:p.brandColor,name:(p==null?void 0:p.displayName)??w.appId}),e.jsxs("span",{className:"w6w-connection-cell-text",children:[e.jsxs("span",{className:"w6w-connection-cell-title",children:[e.jsx("strong",{className:"w6w-connection-name",title:v,children:v}),e.jsx("span",{className:`w6w-connection-status${w.state==="connected"?"":" w6w-connection-status-warn"}`,title:w.state,children:w.state}),w.lastTestOk===!1&&e.jsx("span",{className:"w6w-connection-status w6w-connection-status-danger",title:"Last test failed — update or re-test.",children:"invalid"})]}),e.jsx("span",{className:"w6w-connection-app w6w-muted",children:(p==null?void 0:p.displayName)??w.appId})]})]})}}];return x&&j.push({key:"actions",header:"",align:"right",link:!1,actions:!0,render:w=>w.builtIn===!0?null:e.jsx(pt,{label:`Actions for ${w.displayName||w.id}`,"data-testid":`connection-actions-${w.id}`,actions:[o&&{label:"Edit",icon:"edit",onSelect:()=>o(w),"data-testid":`connection-edit-${w.id}`},r&&{label:"Delete",icon:"delete",danger:!0,disabled:c,onSelect:()=>r(w),"data-testid":`connection-delete-${w.id}`}]})}),e.jsxs("section",{className:"w6w-connection-list",children:[((d==null?void 0:d.header)!=null||(d==null?void 0:d.actions)!=null)&&e.jsxs("div",{className:"w6w-connection-list-head",children:[e.jsx("div",{className:"w6w-connection-list-heading",children:d==null?void 0:d.header}),e.jsx("div",{className:"w6w-connection-list-actions",children:d==null?void 0:d.actions})]}),a&&e.jsx("div",{className:"w6w-error",children:a}),n&&e.jsx("p",{className:"w6w-muted",children:"Loading…"}),t.length===0&&!n?e.jsx(h.EmptyState,{testId:"w6w-connection-list-empty",children:(d==null?void 0:d.empty)??"No connections yet."}):e.jsx(h.DataTable,{columns:j,rows:t,rowKey:w=>w.id,loading:n,getRowHref:l?w=>w.builtIn===!0?void 0:l(w.id):void 0,onRowClick:i?(w,p)=>w.builtIn===!0?void 0:i(w.id,p):void 0})]})}function Ta({connection:t,onClose:s,onSaved:n}){const a=h.useW6WApi(),i=a.updateConnection,l=t.builtIn===!0,o=!l&&typeof i=="function",[r,c]=f.useState(t.displayName??""),[d,m]=f.useState(t.authKey),[x,j]=f.useState({}),[w,p]=f.useState(null),[v,u]=f.useState(null),[g,b]=f.useState(!1),[N,S]=f.useState({}),[k,T]=f.useState(null),[A,F]=f.useState(null),[C,P]=f.useState(null),[O,I]=f.useState(null);f.useEffect(()=>{if(!o)return;let _=!1;return p(null),a.getAppAuth(t.appId).then(M=>!_&&p(M)).catch(M=>!_&&u(M.message)),()=>{_=!0}},[a,o,t.appId]);const $=w==null?void 0:w.find(_=>_.key===d),D=d!==t.authKey,E=(w==null?void 0:w.filter(_=>_.key===t.authKey||_.available!==!1&&!_.autoSatisfied&&["apiKey","bearer","basic","custom"].includes(_.type)))??[],U=($==null?void 0:$.type)==="oauth2",L=U?[]:($==null?void 0:$.fields)??[],W=t.credentialId,Q=!D&&!!W&&typeof a.rotateCredential=="function"&&(A!==null?!A.startsWith("legacy:"):($==null?void 0:$.type)==="serviceAccount")&&C!==!0&&!U,Z=Q&&C===!1&&$!==void 0&&!$.serviceAccount,X=Q&&!Z,le=!D&&!U&&!!W&&typeof a.getCredential=="function"&&C===null,q=X&&($!=null&&$.serviceAccount)?h.bindingFieldsFor($.serviceAccount):[];f.useEffect(()=>{if(!o||D||U||!W||typeof a.getCredential!="function")return;let _=!1;return a.getCredential(W).then(M=>{_||(T(M.connectionCount),F(M.contract),P(M.private===!0))}).catch(()=>{}),()=>{_=!0}},[a,o,D,U,W]);function R(){if(Z)return r!==(t.displayName??"")?{displayName:r}:null;if(X){const J={};r!==(t.displayName??"")&&(J.displayName=r);const Y=h.buildBinding(q,N);return Y&&(J.binding=Y),J.displayName===void 0&&J.binding===void 0?null:J}const _={};for(const J of Z?[]:L){const Y=x[J.key];Y!==void 0&&Y!==""&&(_[J.key]=Y)}const M={};return D&&(M.authKey=d,M.credential=_),r!==(t.displayName??"")&&(M.displayName=r),Object.keys(_).length>0&&(M.credential=_),M.displayName===void 0&&M.credential===void 0?null:M}async function V(){if(!o||!i||g)return;u(null);const _=R(),M=Object.fromEntries((Z?[]:L).filter(H=>x[H.key]!==void 0&&x[H.key]!=="").map(H=>[H.key,x[H.key]])),J=Object.keys(M).length>0;if(!_&&!J){u("Nothing to update — change the name or a credential or binding field.");return}if(D||X&&J){const H=L.filter(ue=>ue.required&&!(ue.key in M));if(H.length>0){u(`Enter the full new credential: ${H.map(ue=>ue.label).join(", ")}.`);return}}const Y=h.parseJsonFields(L,M);if("error"in Y){u(Y.error);return}b(!0);let ce=!1;try{X&&J&&W&&a.rotateCredential?(await a.rotateCredential(W,{source:Y.values}),ce=!0,j({}),I(null)):_!=null&&_.credential&&(_.credential=Y.values);const H=_?await i.call(a,t.id,_):t;j({}),n(H)}catch(H){u(ce?`The credential was saved, but the other changes failed. Click Save to retry them. ${H.message}`:H.message)}finally{b(!1)}}async function re(){if(!(!W||!a.testCredential)){u(null);try{I(await a.testCredential(W))}catch(_){u(_.message)}}}const oe=h.useEnterSubmit(V,{enabled:o&&!g});return e.jsx(h.Modal,{title:"Edit connection",onClose:s,children:e.jsxs("div",{className:"w6w-stepconfig",children:[e.jsx("div",{className:"w6w-modal-body",children:e.jsxs("div",{className:"w6w-stack",children:[l&&e.jsx("p",{className:"w6w-muted w6w-small",children:"This connection is built in — it has no stored credential to edit."}),!l&&e.jsx("p",{className:"w6w-muted w6w-small","data-w6w":"connection-ownership",children:t.accessScope==="user"?"Only me":"This account"}),!l&&!o&&e.jsx("p",{className:"w6w-muted w6w-small",children:"Editing connections is not available here."}),o&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"w6w-field",children:[e.jsx("span",{children:"Display name"}),e.jsx("input",{type:"text",value:r,onChange:_=>c(_.target.value),placeholder:"Connection name",maxLength:80,name:"w6w-connection-label",autoComplete:"off","data-1p-ignore":"true","data-lpignore":"true","data-bwignore":"true","data-form-type":"other",...oe})]}),E.some(_=>_.key!==t.authKey)&&e.jsxs("label",{className:"w6w-field",children:[e.jsx("span",{children:"Authentication method"}),e.jsxs("select",{name:"w6w-connection-auth",value:d,disabled:g,onChange:_=>{m(_.target.value),j({}),S({}),I(null),u(null)},children:[!E.some(_=>_.key===t.authKey)&&e.jsx("option",{value:t.authKey,children:t.authKey}),E.map(_=>e.jsx("option",{value:_.key,children:_.displayName??_.key},_.key))]})]}),D&&e.jsx("p",{className:"w6w-muted w6w-small",children:"Enter the new credential and click Save. This connection stays linked to your existing workflows."}),w===null&&!v&&e.jsx("p",{className:"w6w-muted w6w-small",children:"Loading auth fields…"}),$&&e.jsx(h.AuthGuide,{auth:$}),U&&e.jsx("p",{className:"w6w-muted w6w-small",children:E.some(_=>_.key!==t.authKey)?"This connection uses OAuth. Choose another authentication method above to use a key or token.":"This is an OAuth connection. You can rename it here; its credential is renewed by re-authorizing it."}),X&&q.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"w6w-muted w6w-small",children:"Leave a binding field blank to keep it unchanged."}),e.jsx(h.AuthFieldsForm,{mode:"edit",fields:q,values:N,onChange:S,enterSubmitProps:oe})]}),Q&&e.jsxs("div",{className:"w6w-stack","data-w6w":"credential-section",children:[typeof a.testCredential=="function"&&e.jsxs("div",{children:[e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:re,children:"Test credential"}),O&&e.jsxs("p",{className:"w6w-small","data-w6w":"credential-health",children:["Credential health: ",O.ok?"ok":O.code??"failed"]})]}),e.jsxs("p",{className:"w6w-small","data-w6w":"app-access",children:["App access:"," ",t.lastTestOk===!0?"passed":t.lastTestOk===!1?"failed":"never tested"]}),X&&!le&&L.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"w6w-muted w6w-small",children:["Leave the credential blank to keep it unchanged. To replace it, enter the full new credential and click Save.",k!==null&&k>1&&` This credential is used by ${k} connections; saving a new credential updates all of them.`]}),e.jsx(h.AuthFieldsForm,{mode:"edit",fields:L,values:x,onChange:j,enterSubmitProps:oe})]}),Z&&e.jsx("p",{className:"w6w-muted w6w-small","data-w6w":"shared-credential-note",children:"Uses a shared credential. Rotate it in Settings → Credentials."})]}),!X&&!Z&&!le&&L.length>0&&e.jsxs(e.Fragment,{children:[!D&&e.jsx("p",{className:"w6w-muted w6w-small",children:"Leave a field blank to keep it unchanged. Filled fields replace the stored credential."}),e.jsx(h.AuthFieldsForm,{mode:"edit",fields:L,values:x,onChange:j,enterSubmitProps:oe})]})]}),v&&e.jsx("div",{className:"w6w-result w6w-error",children:v})]})}),e.jsxs("div",{className:"w6w-modal-actions",children:[e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:s,children:"Cancel"}),o&&e.jsx("button",{type:"button",className:"w6w-btn",disabled:g,onClick:V,children:g?"Saving…":"Save"})]})]})})}function $a({conn:t,app:s,children:n}){return e.jsxs("div",{className:"w6w-connection-header","data-testid":"connection-header",children:[e.jsx(h.AppIcon,{src:s==null?void 0:s.iconSvg,srcDark:s==null?void 0:s.iconSvgDark,brandColor:s==null?void 0:s.brandColor,name:(s==null?void 0:s.displayName)??t.appId,size:56}),e.jsxs("div",{className:"w6w-connection-header-main",children:[e.jsx("h2",{className:"w6w-connection-header-title",children:t.displayName||t.id}),e.jsxs("div",{className:"w6w-muted w6w-small w6w-connection-header-meta",children:[e.jsx(ls,{value:t.id,className:"w6w-connection-id-copy"})," · App"," ",e.jsx("code",{children:t.appId})," · Auth ",e.jsx("code",{children:t.authKey})," ·"," ",e.jsx("span",{className:`w6w-connection-tag${t.state==="connected"?"":" w6w-connection-tag-warn"}`,children:t.state}),t.lastTestOk===!1&&e.jsx("span",{className:"w6w-connection-tag w6w-connection-tag-danger",title:"Last test failed — update or re-test.",children:"invalid"})]})]}),n&&e.jsx("div",{className:"w6w-connection-header-actions",children:n})]})}function As(t,s=Date.now()){const n=new Date(t).getTime();if(Number.isNaN(n))return"recently";const a=Math.max(0,Math.round((s-n)/1e3));if(a<45)return"just now";const i=Math.round(a/60);if(i<60)return`${i}m ago`;const l=Math.round(i/60);if(l<24)return`${l}h ago`;const o=Math.round(l/24);return o<30?`${o}d ago`:new Date(t).toLocaleDateString()}function Ia({conn:t,refreshable:s,onChanged:n,className:a}){const i=h.useW6WApi(),[l,o]=f.useState(s??null),[r,c]=f.useState(t.autoRefresh!==!1),[d,m]=f.useState(!1),[x,j]=f.useState(null);if(f.useEffect(()=>c(t.autoRefresh!==!1),[t.autoRefresh]),f.useEffect(()=>{if(s!==void 0){o(s);return}let v=!1;return i.getAppAuth(t.appId).then(u=>{var g;return!v&&o(((g=u.find(b=>b.key===t.authKey))==null?void 0:g.refreshable)===!0)}).catch(()=>!v&&o(!1)),()=>{v=!0}},[i,t.appId,t.authKey,s]),t.builtIn||l!==!0)return null;const w=i.updateConnection;async function p(v){if(w){j(null),m(!0),c(v);try{const u=await w.call(i,t.id,{autoRefresh:v});n==null||n(u)}catch(u){c(!v),j(u.message)}finally{m(!1)}}}return e.jsxs("section",{className:`w6w-keepalive${a?` ${a}`:""}`,"data-testid":"connection-keepalive",children:[e.jsx("h3",{children:"Token refresh"}),e.jsxs("label",{className:"w6w-checkbox",children:[e.jsx("input",{type:"checkbox",name:"w6w-connection-keepalive",checked:r,disabled:!w||d,onChange:v=>p(v.target.checked)}),e.jsxs("span",{children:[e.jsx("strong",{children:"Keep connected"}),e.jsxs("span",{className:"w6w-muted w6w-small",children:[" ",r?"Refresh the token automatically, even when nothing uses this connection.":"Off: the token is refreshed only when something uses this connection, so an idle one may need reconnecting."]})]})]}),t.lastRefreshedAt&&e.jsxs("p",{className:"w6w-muted w6w-small","data-testid":"connection-last-refreshed",children:["Last refreshed"," ",e.jsx("time",{dateTime:t.lastRefreshedAt,title:t.lastRefreshedAt,children:As(t.lastRefreshedAt)})]}),t.refreshFailingSince&&e.jsxs("p",{className:"w6w-keepalive-warning","data-testid":"connection-refresh-failing",children:["Token refresh failing since"," ",e.jsx("time",{dateTime:t.refreshFailingSince,children:new Date(t.refreshFailingSince).toLocaleDateString()})," ","— reconnect if this persists"]}),x&&e.jsx("div",{className:"w6w-result w6w-error",children:x})]})}const _a=t=>String(t);function Zt(t){const s=Math.min(100,Math.max(0,t));return Number(s.toFixed(4))}function La({label:t,used:s,limit:n,reserved:a=0,format:i,className:l,testId:o}){const r=i??_a,c=Number.isFinite(a)&&a>0,d=n>0?Zt(s/n*100):100,m=c&&n>0?Zt(Math.min(100-d,a/n*100)):0,x=s>=n,j=`${r(s)} / ${r(n)}`,w=["w6w-budget-meter"];return x&&w.push("w6w-budget-meter-over"),l&&w.push(l),e.jsxs("div",{role:"meter",className:w.join(" "),"aria-label":t,"aria-valuemin":0,"aria-valuenow":s,"aria-valuemax":n,"aria-valuetext":j,"data-testid":o,children:[e.jsxs("div",{className:"w6w-budget-meter-head",children:[e.jsx("span",{className:"w6w-budget-meter-label",children:t}),e.jsx("span",{className:"w6w-budget-meter-value",children:j})]}),e.jsxs("div",{className:"w6w-budget-meter-track",children:[e.jsx("div",{className:"w6w-budget-meter-used",style:{width:`${d}%`}}),c&&e.jsx("div",{className:"w6w-budget-meter-reserved",style:{width:`${m}%`}})]})]})}const Ts={kv:"Key-value",doc:"Document",table:"Table"},Oa=["kv","doc","table"],gt=["string","number","integer","boolean","date","datetime"],$s=5242880;function Pa(t){var n;const s=(n=t.schema)==null?void 0:n.valueType;return typeof s=="string"&&gt.includes(s)?s:"string"}function Da(t){var a,i;if(t.kind!=="table")return null;const s=(a=t.schema)==null?void 0:a.columns;if(!Array.isArray(s))return null;const n=(i=t.schema)==null?void 0:i.key;return typeof n=="string"?{columns:s,key:n}:{columns:s}}function Ma(t,s){const n=t==null?void 0:t.match(/filename="([^"]*)"/),a=n==null?void 0:n[1];return a!==void 0&&a!==""?a:`${s}.csv`}const Is={required:"Required.",not_a_number:"Enter a number.",not_an_integer:"Enter a whole number.",not_a_boolean:"Enter true or false.",not_a_date:"Enter a date as YYYY-MM-DD.",not_a_datetime:"Enter a date-time like 2026-01-31T09:30:00Z."},Ba=/^-?(0|[1-9]\d*)(\.\d+)?([eE][+-]?\d+)?$/,Fa=/^-?(0|[1-9]\d*)$/,Ua=/^\d{4}-\d{2}-\d{2}$/,Wa=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})$/;function Ka(t,s){return s===2?t%4===0&&t%100!==0||t%400===0?29:28:[31,0,31,30,31,30,31,31,30,31,30,31][s-1]}function vt(t){if(!Ua.test(t))return null;const s=Number(t.slice(0,4)),n=Number(t.slice(5,7)),a=Number(t.slice(8,10));return n<1||n>12||a<1||a>Ka(s,n)?null:{year:s,month:n,day:a}}function ae(t){return{ok:!1,problem:t,message:Is[t]}}function Ve(t,s,n){const a=s.trim();if(a==="")return n?ae("required"):{ok:!0,value:void 0};switch(t){case"string":return{ok:!0,value:s};case"number":{if(!Ba.test(a))return ae("not_a_number");const i=Number(a);return Number.isFinite(i)?{ok:!0,value:i}:ae("not_a_number")}case"integer":{if(!Fa.test(a))return ae("not_an_integer");const i=Number(a);return Number.isSafeInteger(i)?{ok:!0,value:i}:ae("not_an_integer")}case"boolean":return a==="true"?{ok:!0,value:!0}:a==="false"?{ok:!0,value:!1}:ae("not_a_boolean");case"date":return vt(a)===null?ae("not_a_date"):{ok:!0,value:a};case"datetime":return _s(a)?{ok:!0,value:a}:ae("not_a_datetime")}}function _s(t){if(!Wa.test(t)||vt(t.slice(0,10))===null)return!1;const s=Number(t.slice(11,13)),n=Number(t.slice(14,16)),a=Number(t.slice(17,19));if(s>23||n>59||a>59)return!1;const l=t.slice(19).match(/(Z|([+-])(\d{2}):(\d{2}))$/);return l===null||l[1]==="Z"?!0:Number(l[3])<=23&&Number(l[4])<=59}function Je(t,s){if(s==null)return"";if((t==="string"||t==="date"||t==="datetime")&&typeof s=="string")return s;if((t==="number"||t==="integer")&&typeof s=="number"&&Number.isFinite(s))return String(s);if(t==="boolean"&&typeof s=="boolean")return s?"true":"false";const n=JSON.stringify(s);return n===void 0?"":n}function Va(t,s){switch(t){case"string":return typeof s=="string";case"number":return typeof s=="number"&&Number.isFinite(s);case"integer":return Number.isSafeInteger(s);case"boolean":return typeof s=="boolean";case"date":return typeof s=="string"&&vt(s)!==null;case"datetime":return typeof s=="string"&&_s(s)}}const pe="The request failed.",Ls="Could not reach the server.";function de(t){return typeof t=="string"&&t.length>0?t:void 0}function Os(t){return Number.isInteger(t)&&t>=0?t:void 0}function Ps(t,s,n){const a={message:pe};typeof n=="number"&&(a.status=n);const i=t!==null&&typeof t=="object"?t.error:void 0;if(i!==null&&typeof i=="object"){const l=i,o=de(l.code);o!==void 0&&(a.code=o);const r=de(l.field);r!==void 0&&(a.field=r);const c=de(l.column);c!==void 0&&(a.column=c);const d=Os(l.row);d!==void 0&&(a.row=d);const m=de(l.message);m!==void 0&&(a.message=m)}if(a.message===pe)for(const l of s){const o=de(l);if(o!==void 0){a.message=o;break}}return a}function Ja(t){try{const s=t!==null&&typeof t=="object"?t:void 0,n=s==null?void 0:s.raw,a=s==null?void 0:s.message;return Ps(n,[a],s==null?void 0:s.status)}catch{return{message:pe}}}function Ds(t){try{if(t.status===0)return{status:0,code:"network_error",message:Ls};let s;try{s=JSON.parse(t.text)}catch{return{status:t.status,message:pe}}return Ps(s,[],t.status)}catch{return{message:pe}}}function Ms(t){const s=de(t.column);if(s!==void 0){const a=Os(t.row);return a===void 0?{kind:"cell",column:s}:{kind:"cell",column:s,row:a}}const n=de(t.field);return n!==void 0?{kind:"field",field:n}:{kind:"form"}}function ut(t){return t+2}const jt="\0new",bt="Changed by someone else since you loaded it.",wt="Enter a JSON object or array.",Bs="The file is larger than 5 MB.";function Fs(t){const s=t.value;return s!==null&&typeof s=="object"&&!Array.isArray(s)?s:{}}function Ha(t,s){const n=Fs(t),a={};for(const i of s)a[i.name]=Je(i.type,n[i.name]);return{id:t.key,version:t.version,cells:a}}function qa(t){const s={};for(const n of t)s[n.name]=n.default===void 0?"":Je(n.type,n.default);return{id:jt,version:null,cells:s}}function Ya(t,s,n){const a=[];for(const i of n)(t.cells[i.name]??"")!==(s.cells[i.name]??"")&&a.push(i.name);return a}function za(t,s){const n={},a={};for(const i of s){const l=Ve(i.type,t.cells[i.name]??"",i.required);l.ok?l.value!==void 0&&(n[i.name]=l.value):a[i.name]=l.message}return Object.keys(a).length>0?{ok:!1,errors:a}:{ok:!0,value:n}}function Ga(t,s){if(t===null)return;const n=Date.parse(t);if(!Number.isFinite(n))return;const a=Math.ceil((n-s)/1e3);return a>0?a:void 0}function Xa(t,s,n){if(t.id===jt)return n===void 0?{kind:"insert",value:s}:{kind:"insert",value:s,ttlSeconds:n};const a={kind:"put",key:t.id,value:s,ifVersion:t.version??0};return n===void 0?a:{...a,ttlSeconds:n}}function Za(t,s){const n=Ms(t);return n.kind!=="cell"||!s.some(a=>a.name===n.column)?null:{[n.column]:t.message}}function Qa(t){return t.status===409&&t.code==="version_conflict"}function Us(t){let s;try{s=JSON.parse(t)}catch{return{ok:!1,message:wt}}return s===null||typeof s!="object"?{ok:!1,message:wt}:{ok:!0,value:s}}function ei(t,s){if(t==="string")return{ok:!0,value:s};const n=Ve(t,s,!0);return n.ok?{ok:!0,value:n.value}:{ok:!1,message:n.message}}function ti(t){if(t.status===200){let a=0;try{const i=JSON.parse(t.text);typeof i.imported=="number"&&Number.isFinite(i.imported)&&(a=i.imported)}catch{a=0}return{ok:!0,message:`Imported ${a} row${a===1?"":"s"}.`}}const s=Ds(t);return s.row===void 0?{ok:!1,message:s.message}:{ok:!1,message:`${s.column?`Line ${ut(s.row)}, column ${s.column}`:`Line ${ut(s.row)}`}: ${s.message}`}}function si({stores:t,loading:s,error:n,onOpen:a,getHref:i,onEdit:l,onArchive:o,busy:r,formatSize:c,slots:d}){const m=c??cs,x=l!==void 0||o!==void 0,j=[{key:"name",header:"Name",render:w=>e.jsx("strong",{children:w.name})},{key:"kind",header:"Kind",render:w=>Ts[w.kind]},{key:"entries",header:"Entries",align:"right",render:w=>String(w.entryCount)},{key:"size",header:"Size",align:"right",render:w=>m(w.sizeBytes)}];return x&&j.push({key:"actions",header:"",align:"right",link:!1,actions:!0,render:w=>e.jsx(pt,{label:`Actions for ${w.name||w.id}`,"data-testid":`data-store-actions-${w.id}`,actions:[l&&{label:"Edit",icon:"edit",onSelect:()=>l(w),"data-testid":`data-store-edit-${w.id}`},o&&{label:"Archive",icon:"archive",danger:!0,disabled:r,onSelect:()=>o(w),"data-testid":`data-store-archive-${w.id}`}]})}),e.jsxs("section",{className:"w6w-data-store-list",children:[((d==null?void 0:d.header)!=null||(d==null?void 0:d.actions)!=null)&&e.jsxs("div",{className:"w6w-data-store-list-head",children:[e.jsx("div",{className:"w6w-data-store-list-heading",children:d==null?void 0:d.header}),e.jsx("div",{className:"w6w-data-store-list-actions",children:d==null?void 0:d.actions})]}),n&&e.jsx("div",{className:"w6w-error",children:n}),s&&e.jsx("p",{className:"w6w-muted",children:"Loading…"}),t.length===0&&!s?e.jsx(h.EmptyState,{testId:"w6w-data-store-list-empty",children:(d==null?void 0:d.empty)??"No data stores yet."}):e.jsx(h.DataTable,{columns:j,rows:t,rowKey:w=>w.id,loading:s,getRowHref:i?w=>i(w.id):void 0,onRowClick:a?(w,p)=>a(w.id,p):void 0})]})}function ni(t){return t.name!==""&&t.required===!0&&(t.type==="string"||t.type==="integer")}function ai(t,s){const{default:n,...a}=t,i=Ve(t.type,s,!1);return i.ok?i.value===void 0?{column:a}:{column:{...a,default:i.value}}:{column:a,error:i.message}}function ii(t){const{columns:s,onChange:n,keyColumn:a,onKeyColumnChange:i,columnErrors:l}=t,[o,r]=f.useState({}),c=s.filter(ni),d=c.some(p=>p.name===a)?a:"";f.useEffect(()=>{a!==""&&d===""&&i("")},[a,d,i]);function m(){n([...s,{name:"",type:"string",required:!1}])}function x(p,v){n(s.map((u,g)=>g===p?{...u,...v}:u))}function j(p,v,u,g){const b={...s[p],...g,type:v},{column:N,error:S}=ai(b,u);r(k=>({...k,[p]:S===void 0?{text:u}:{text:u,error:S}})),n(s.map((k,T)=>T===p?N:k))}function w(p){r(v=>{const u={};for(const[g,b]of Object.entries(v)){const N=Number(g);N<p?u[N]=b:N>p&&(u[N-1]=b)}return u}),n(s.filter((v,u)=>u!==p))}return e.jsxs("div",{className:"w6w-data-columns",children:[e.jsxs("div",{className:"w6w-data-columns-head",children:[e.jsx("h3",{children:"Columns"}),e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:m,children:"+ Add column"})]}),e.jsx("p",{className:"w6w-muted w6w-small",children:"Each column has a name, a scalar type, whether it must be set, and an optional default."}),s.length===0&&e.jsx("p",{className:"w6w-muted w6w-small",children:"No columns yet."}),s.length>0&&e.jsxs("div",{className:"w6w-data-columns-row w6w-data-columns-colhead","aria-hidden":"true",children:[e.jsx("span",{children:"Name"}),e.jsx("span",{children:"Type"}),e.jsx("span",{}),e.jsx("span",{children:"Default"}),e.jsx("span",{})]}),e.jsx("ul",{className:"w6w-data-columns-list","data-testid":"data-columns",children:s.map((p,v)=>{const u=o[v],g=(u==null?void 0:u.text)??Je(p.type,p.default);return e.jsxs("li",{className:"w6w-data-columns-row",children:[e.jsx("input",{type:"text",value:p.name,placeholder:"name","aria-label":"Column name",onChange:b=>x(v,{name:b.target.value})}),e.jsx("select",{value:p.type,"aria-label":"Column type",onChange:b=>j(v,b.target.value,g),children:gt.map(b=>e.jsx("option",{value:b,children:b},b))}),e.jsxs("label",{className:"w6w-data-columns-required",children:[e.jsx("input",{type:"checkbox",checked:p.required,"aria-label":"Required",onChange:b=>x(v,{required:b.target.checked})}),e.jsx("span",{className:"w6w-muted w6w-small",children:"required"})]}),e.jsx("input",{type:"text",value:g,placeholder:"default","aria-label":"Column default",onChange:b=>j(v,p.type,b.target.value)}),e.jsx(h.DeleteButton,{label:`Remove column ${p.name||v+1}`,onClick:()=>w(v)}),(u==null?void 0:u.error)!==void 0&&e.jsx("div",{className:"w6w-result w6w-error w6w-data-columns-error","data-testid":`data-store-column-default-error-${v}`,children:u.error}),p.name!==""&&l[p.name]!==void 0&&e.jsx("div",{className:"w6w-result w6w-error w6w-data-columns-error","data-testid":`data-store-column-error-${p.name}`,children:l[p.name]})]},v)})}),e.jsxs("label",{className:"w6w-field",children:[e.jsx("span",{children:"Key column"}),e.jsxs("select",{value:d,onChange:p=>i(p.target.value),children:[e.jsx("option",{value:"",children:"(none — rows get generated keys)"}),c.map(p=>e.jsx("option",{value:p.name,children:p.name},p.name))]}),e.jsx("span",{className:"w6w-hint",children:"Only a required, string or integer column can name a row's key."})]})]})}function li({result:t,busy:s,onImport:n,onRefuse:a,onExport:i}){function l(o){var d;const r=o.target,c=(d=r.files)==null?void 0:d[0];if(c!==void 0){if(r.value="",c.size>$s){a(Bs);return}n(c)}}return e.jsxs("div",{className:"w6w-data-csv-panel","data-testid":"csv-panel",children:[e.jsxs("div",{className:"w6w-data-csv-panel-actions",children:[e.jsx("input",{type:"file",accept:".csv,text/csv","data-testid":"csv-file","aria-label":"Import CSV",onChange:l}),e.jsx("button",{className:"w6w-btn w6w-btn-ghost",type:"button","data-testid":"csv-export",disabled:s,onClick:i,children:"Export CSV"})]}),t!==null&&e.jsx("div",{className:t.ok?"w6w-result":"w6w-result w6w-error","data-testid":"csv-result",children:t.message})]})}function ri({rows:t,empty:s,loading:n,searchValue:a,hasMore:i,onOpen:l,onSearch:o,onNew:r,onLoadMore:c}){const[d,m]=f.useState(a??""),x=w=>{w.preventDefault(),o(d)},j=[{key:"key",header:"Key",width:"26%",render:w=>e.jsx("button",{type:"button",className:"w6w-data-entry-key",title:w.key,"data-testid":"entry-key",onClick:p=>{p.stopPropagation(),l(w.key)},children:w.key})},{key:"value",header:"Value",render:w=>w.copyText!==void 0?e.jsx(K.Copyable,{value:w.copyText,label:"Copy value",className:"w6w-copyable--bare",children:e.jsx("span",{className:"w6w-data-entry-preview",children:w.preview})}):e.jsx("span",{className:"w6w-data-entry-preview",children:w.preview})}];return e.jsxs("div",{children:[e.jsxs("form",{className:"w6w-data-entries-toolbar","data-testid":"entry-search",onSubmit:x,children:[e.jsx("input",{type:"search","data-testid":"entry-prefix",value:d,placeholder:"Key prefix","aria-label":"Key prefix",onChange:w=>m(w.target.value)}),e.jsx("button",{className:"w6w-btn w6w-btn-ghost",type:"submit",children:"Search"}),e.jsx("button",{className:"w6w-btn w6w-data-entry-new",type:"button","data-testid":"entry-new",onClick:r,children:"+ New entry"})]}),e.jsx(h.DataTable,{className:"w6w-data-entry-list",onRowClick:w=>l(w.key),columns:j,rows:t,rowKey:w=>w.key,empty:e.jsx("div",{className:"w6w-muted w6w-small",children:n?"Loading…":s??"No entries match this key prefix."})}),i&&e.jsx("button",{className:"w6w-btn w6w-btn-ghost",type:"button","data-testid":"entries-load-more",onClick:c,children:"Load more"})]})}function oi({kind:t,isNew:s,entryKey:n,newKey:a,expiresAt:i,text:l,error:o,conflict:r,saving:c,onTextChange:d,onKeyChange:m,onDelete:x,onSave:j,onCancel:w,onReload:p}){const[v,u]=f.useState(s),[g,b]=f.useState(!1),N=f.useRef(null);f.useEffect(()=>{var C;s||(C=N.current)==null||C.focus()},[s]);const S=t==="doc"?"document":"entry",k=t==="doc"?Us(l):void 0,T=k!==void 0&&!k.ok,A=o||(g&&k&&!k.ok?k.message:null),F=e.jsxs(e.Fragment,{children:[s?e.jsxs("label",{className:"w6w-field",children:[e.jsx("span",{children:"Key"}),e.jsx("input",{"data-testid":"entry-new-key",value:a??"",placeholder:"Key","aria-label":"Key",onChange:C=>m(C.target.value)})]}):i?e.jsxs("p",{className:"w6w-muted w6w-small",children:["Expires ",i]}):null,t==="doc"?e.jsx(h.JsonEditor,{value:l,readOnly:!v,onChange:C=>{b(!1),d(C)},onFocus:()=>b(!1),onBlur:()=>b(!0),showDiagnostics:g,minHeight:"min(50vh, 400px)",maxHeight:"60vh"}):e.jsx(K.Copyable,{value:l,label:"Copy value",children:e.jsx("input",{type:"text","data-testid":"entry-value",value:l,"aria-label":"Value",readOnly:!v,onChange:C=>d(C.target.value)})}),A&&e.jsx("div",{className:"w6w-field-error",role:"alert","data-testid":"entry-value-error",children:A}),r&&e.jsxs("div",{className:"w6w-error","data-testid":"entry-conflict",children:[bt," ",e.jsx("button",{className:"w6w-btn w6w-btn-ghost",type:"button","data-testid":"entry-reload",onClick:p,children:"Reload"})]})]});return e.jsxs(h.Modal,{title:s?`New ${S}`:v?`Edit ${S}`:t==="doc"?"Document":"Entry",subtitle:s?void 0:n,size:t==="doc"?"wide":"default",onClose:c?()=>{}:w,children:[e.jsx("div",{className:"w6w-modal-body","data-testid":"entry-editor",children:F}),e.jsxs("div",{className:"w6w-modal-actions",children:[!s&&x&&e.jsx(h.DeleteButton,{label:"Delete entry",className:"w6w-data-entry-delete",disabled:c,onClick:x}),e.jsx("button",{ref:N,className:"w6w-btn w6w-btn-ghost",type:"button",disabled:c,onClick:w,children:v?"Cancel":"Close"}),v?e.jsx("button",{className:"w6w-btn",type:"button","data-testid":"entry-save",disabled:!!r||!!c||T||s&&!(a!=null&&a.trim()),onClick:j,children:"Save"}):e.jsx("button",{className:"w6w-btn",type:"button",disabled:c,onClick:()=>u(!0),children:"Edit"})]})]})}const Ie=t=>t.isNew?"new":t.id;function ci({columns:t,keyColumn:s,rows:n,error:a,loading:i,empty:l,searchValue:o,hasMore:r,onCellChange:c,onSave:d,onDelete:m,onReload:x,onAddRow:j,onLoadMore:w,onSearch:p}){const[v,u]=f.useState(o??""),g=N=>{N.preventDefault(),p(v)},b=[...t.map(N=>({key:N.name,header:e.jsxs(e.Fragment,{children:[N.name," ",e.jsx("span",{className:"w6w-muted w6w-small",children:N.type})]}),render:S=>{var T;const k=(T=S.cellErrors)==null?void 0:T[N.name];return e.jsxs("div",{className:"w6w-data-cell",children:[e.jsx("input",{"data-row":Ie(S),"data-column":N.name,value:S.cells[N.name]??"",readOnly:N.name===s&&!S.isNew,"aria-label":`${N.name} (${N.type})`,onChange:A=>c(S.id,N.name,A.target.value)}),k!==void 0&&e.jsx("div",{className:"w6w-data-cell-error","data-row":Ie(S),"data-column":N.name,children:k})]})}})),{key:"actions",header:"",actions:!0,render:N=>e.jsxs("div",{className:"w6w-data-row-actions",children:[e.jsx("span",{className:"w6w-muted w6w-small",children:N.version===null?"":`v${N.version}`}),e.jsx(h.IconButton,{icon:"check",label:"Save row","data-row":Ie(N),"data-testid":"row-save",disabled:!N.isNew&&!N.dirty||!!N.conflict,onClick:()=>d(N.id)}),e.jsx(h.DeleteButton,{label:"Delete entry",onClick:()=>m(N.id)}),N.conflict&&e.jsxs("div",{className:"w6w-error","data-row":Ie(N),"data-testid":"row-conflict",children:[bt," ",e.jsx(h.IconButton,{icon:"sync",label:"Reload row","data-testid":"row-reload",onClick:()=>x(N.id)})]})]})}];return e.jsxs("div",{children:[a!=null&&a!==""&&e.jsx("div",{className:"w6w-error","data-testid":"grid-error",children:a}),e.jsxs("form",{className:"w6w-data-entries-toolbar","data-testid":"entry-search",onSubmit:g,children:[e.jsx("input",{type:"search","data-testid":"entry-prefix",value:v,placeholder:"Key prefix","aria-label":"Key prefix",onChange:N=>u(N.target.value)}),e.jsx("button",{className:"w6w-btn w6w-btn-ghost",type:"submit",children:"Search"}),e.jsx("button",{className:"w6w-btn w6w-btn-ghost",type:"button","data-testid":"grid-add-row",onClick:j,children:"Add row"})]}),e.jsx("div",{className:"w6w-data-grid-scroll","data-testid":"data-grid-scroll",children:e.jsx(h.DataTable,{columns:b,rows:n,rowKey:N=>N.id,empty:e.jsx("div",{className:"w6w-muted w6w-small",children:i?"Loading…":l??"No rows match this key prefix."})})}),r&&e.jsx("button",{className:"w6w-btn w6w-btn-ghost",type:"button","data-testid":"entries-load-more",onClick:w,children:"Load more"})]})}class ee extends Error{constructor(n,a){super(a);xe(this,"code");this.name="CallableRunError",this.code=n}}function Ws(t,s){const n=s==null?void 0:s.trim();if(n)return n;const a=t.split(".").filter(i=>i!=="");return a[a.length-1]??t}function Ks(t,s,n="send_confirmation"){const a=`${s}.${n}`;return t.find(i=>i.tags.includes(a))??null}function yt(t){return h.callableTriggers(t).map(s=>{var n;return{id:s.id,fields:h.asFieldDefs((n=s.with)==null?void 0:n.fields)}})}function di(t){return"callableId"in t}function Vs(t,s,n,a){if(di(t)){const l={kind:t.kind,id:t.callableId,input:{[t.field]:s}};return t.kind==="workflow"&&(l.entry=t.entry),l}const i={kind:t.kind,id:t.id,input:{[n]:s}};if(t.kind==="workflow"){const l=a?yt(a)[0]:void 0;if(!l)throw new ee("no-trigger",`Workflow ${t.name} has no manual trigger.`);i.entry=l.id}return i}async function Js(t,s){if(s.kind==="workflow"){const n=await t.runWorkflow(s.id,{entry:s.entry,input:s.input});if(n.error||n.status==="failed"||n.status==="error"){const a=n.error;throw new ee("failed",typeof a=="string"?a:a?JSON.stringify(a):`Workflow ${n.status}`)}return n.output}if(s.kind==="function")return t.invokeFunction(s.id,s.input);if(!t.invokeEndpoint)throw new ee("unsupported","This host does not support running endpoints.");return t.invokeEndpoint(s.id,s.input)}async function Nt(t,s,n,a,i){const l=s.kind==="workflow"?await t.getWorkflow(s.id):void 0,o=Vs(s,n,a,l);return Js(t,i?{...o,input:{...o.input,...i}}:o)}async function ui(t,s){if(s.kind==="workflow"){let n;try{n=await t.getWorkflow(s.callableId)}catch{return`Workflow ${s.callableId} no longer exists.`}return!s.entry||!yt(n).some(a=>a.id===s.entry)?`Step ${s.entry??"(none)"} is no longer a manual trigger of ${s.callableId}.`:null}if(s.kind==="function")try{await t.getFunction(s.callableId)}catch{return`Function ${s.callableId} no longer exists.`}return null}async function Hs(t,s,n){if(!t.getCallableBinding)throw new ee("unsupported","This host does not support callable bindings.");const a=await t.getCallableBinding(s);if(!a)throw new ee("unbound",`No callable is bound to ${s}.`);const i=await ui(t,a);if(i)throw new ee("stale",i);return Js(t,Vs(a,n,a.field))}function qs(t){return t instanceof Error?t:new Error(String(t))}function kt({onResult:t,onError:s}){const[n,a]=f.useState({status:"idle"}),i=f.useRef(!0);f.useEffect(()=>(i.current=!0,()=>{i.current=!1}),[]);const l=f.useRef({onResult:t,onError:s});l.current={onResult:t,onError:s};const o=f.useCallback(async r=>{var c,d,m,x;a({status:"loading"});try{const j=await r();i.current&&a({status:"success",output:j}),(d=(c=l.current).onResult)==null||d.call(c,j)}catch(j){const w=qs(j);i.current&&a({status:"error",error:w}),(x=(m=l.current).onError)==null||x.call(m,w)}},[]);return{state:n,run:o}}function Ys(t){const s=h.useW6WApi(),[n,a]=f.useState({status:"loading"});return f.useEffect(()=>{let i=!0;if(!s.listCallables){a({status:"error",error:new ee("unsupported","This host does not support listing callables.")});return}return a({status:"loading"}),s.listCallables({tag:t}).then(l=>i&&a({status:"ready",refs:l})).catch(l=>i&&a({status:"error",error:qs(l)})),()=>{i=!1}},[s,t]),n}function St({error:t,onSetup:s}){const n=t instanceof ee&&(t.code==="stale"||t.code==="unbound");return e.jsxs("div",{className:"w6w-error w6w-small",role:"alert",children:[t.message,n&&s&&e.jsxs(e.Fragment,{children:[" ",e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:s,children:"Set up"})]})]})}function Ct({callable:t,bindingKey:s,data:n,prop:a="data",onClose:i,onSetup:l,onResult:o,onError:r,title:c}){const d=h.useW6WApi(),{state:m,run:x}=kt({onResult:o,onError:r}),[j,w]=f.useState(""),[p,v]=f.useState(null),u=s||((t==null?void 0:t.name)??"callable"),g=()=>{let b;if(j.trim())try{const N=JSON.parse(j);if(!N||typeof N!="object"||Array.isArray(N))throw new Error("not an object");b=N}catch{v("Additional inputs must be a JSON object.");return}v(null),s?x(()=>Hs(d,s,n)):t&&x(()=>Nt(d,t,n,a,b))};return e.jsxs(h.Modal,{title:c??`Run ${u}`,onClose:i,children:[e.jsx("div",{className:"w6w-modal-body",children:m.status==="success"?e.jsx(h.ResultViewer,{value:m.output}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"w6w-muted w6w-small",children:["Run ",u," with this data?"]}),e.jsx("pre",{className:"w6w-small",children:JSON.stringify(n,null,2)}),e.jsxs("label",{className:"w6w-small",children:["Additional inputs (JSON, optional)",e.jsx("textarea",{"aria-label":"Additional inputs",value:j,disabled:m.status==="loading",onChange:b=>w(b.target.value)})]}),p&&e.jsx("div",{className:"w6w-error w6w-small",children:p}),m.status==="error"&&e.jsx(St,{error:m.error,onSetup:l})]})}),e.jsxs("div",{className:"w6w-modal-actions",children:[e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:i,children:m.status==="success"?"Close":"Cancel"}),m.status!=="success"&&e.jsx("button",{type:"button",className:"w6w-btn",onClick:g,disabled:m.status==="loading",children:m.status==="loading"?"Running…":"Run"})]})]})}function wi({tag:t="",bindingKey:s,defaultAction:n,data:a,as:i,confirm:l=!1,label:o="Run",onSetup:r,onResult:c,onError:d}){const m=h.useW6WApi(),x=Ys(s?"":t),{state:j,run:w}=kt({onResult:c,onError:d}),[p,v]=f.useState(!1),u=Ws(t,i),g=x.status==="ready"?Ks(x.refs,t,n):null;let b=j.status==="loading",N=j.status==="loading"?"Running…":o;s||(x.status==="loading"?(b=!0,N="Loading…"):x.status==="ready"&&!g?(b=!0,N="No default action"):x.status==="error"&&(b=!0));const S=()=>{if(l)return v(!0);s?w(()=>Hs(m,s,a)):g&&w(()=>Nt(m,g,a,u))},T=(!s&&x.status==="error"?x.error:null)??(j.status==="error"?j.error:null);return e.jsxs("span",{className:"w6w-run-callable",children:[e.jsx("button",{type:"button",className:"w6w-btn",disabled:b,onClick:S,children:N}),j.status==="success"&&e.jsx("span",{className:"w6w-muted w6w-small",children:" Done"}),T&&e.jsx(St,{error:T,onSetup:r}),p&&e.jsx(Ct,{callable:g??void 0,bindingKey:s,data:a,prop:u,onSetup:r,onClose:()=>v(!1),onResult:c,onError:d})]})}function mi({tag:t,defaultAction:s,data:n,as:a,confirm:i=!1,label:l="Run",onResult:o,onError:r}){const c=h.useW6WApi(),d=Ys(t),{state:m,run:x}=kt({onResult:o,onError:r}),[j,w]=f.useState(null),[p,v]=f.useState(!1),u=Ws(t,a),g=d.status==="ready"?d.refs:[],b=Ks(g,t,s),N=j??(b==null?void 0:b.id)??"",S=g.find(A=>A.id===N)??null,k=()=>{if(S){if(i)return v(!0);x(()=>Nt(c,S,n,u))}},T=d.status==="error"?d.error:m.status==="error"?m.error:null;return e.jsxs("span",{className:"w6w-run-callables",children:[e.jsxs("select",{"aria-label":"Callable",value:N,disabled:d.status!=="ready"||m.status==="loading",onChange:A=>w(A.target.value),children:[d.status==="loading"&&e.jsx("option",{value:"",children:"Loading…"}),d.status==="ready"&&!S&&e.jsx("option",{value:"",disabled:!0,children:g.length===0?"Nothing to run":"Choose…"}),g.map(A=>e.jsx("option",{value:A.id,children:A.name},A.id))]})," ",e.jsx("button",{type:"button",className:"w6w-btn",disabled:!S||m.status==="loading",onClick:k,children:m.status==="loading"?"Running…":l}),m.status==="success"&&e.jsx("span",{className:"w6w-muted w6w-small",children:" Done"}),T&&e.jsx(St,{error:T}),p&&S&&e.jsx(Ct,{callable:S,data:n,prop:u,onClose:()=>v(!1),onResult:o,onError:r})]})}const Qt=t=>t instanceof Error?t:new Error(String(t));function hi({hostKey:t,tag:s="",onSaved:n,onError:a}){var D;const i=h.useW6WApi(),[l,o]=f.useState(null),[r,c]=f.useState(null),[d,m]=f.useState(""),[x,j]=f.useState({status:"idle"}),[w,p]=f.useState(""),[v,u]=f.useState(""),[g,b]=f.useState(!1),[N,S]=f.useState(!1),k=f.useRef(a);k.current=a;const T=f.useRef(E=>{var L;const U=Qt(E);c(U),(L=k.current)==null||L.call(k,U)}).current;f.useEffect(()=>{let E=!0;if(!i.listCallables||!i.saveCallableBinding){T(new ee("unsupported","This host does not support callable bindings."));return}return i.listCallables({tag:s}).then(U=>E&&o(U)).catch(U=>E&&T(U)),()=>{E=!1}},[i,s,T]);const A=(l==null?void 0:l.find(E=>E.id===d))??null;f.useEffect(()=>{if(p(""),u(""),S(!1),!A)return j({status:"idle"});let E=!0;return j({status:"loading"}),(async()=>{if(A.kind==="workflow"){const L=yt(await i.getWorkflow(A.id));return L.length===0?{status:"error",message:"This workflow has no manual trigger."}:{status:"ready",triggers:L,fields:[]}}if(A.kind==="function"){const L=await i.getFunction(A.id);return{status:"ready",triggers:[],fields:L.inputs.map(W=>W.key)}}return{status:"ready",triggers:[],fields:[]}})().then(L=>E&&j(L)).catch(L=>E&&j({status:"error",message:Qt(L).message})),()=>{E=!1}},[i,A]);const F=x.status==="ready"?x.triggers:[],C=F.length===1?F[0].id:w,P=(A==null?void 0:A.kind)==="workflow"?((D=F.find(E=>E.id===C))==null?void 0:D.fields.map(E=>E.key).filter(E=>!!E))??[]:x.status==="ready"?x.fields:[],O=(A==null?void 0:A.kind)==="workflow",I=!!A&&!!v&&(!O||!!C)&&!g,$=async()=>{if(!A||!i.saveCallableBinding)return;const E={kind:A.kind,callableId:A.id,field:v,...O?{entry:C}:{}};b(!0);try{await i.saveCallableBinding(t,E),S(!0),n==null||n(E)}catch(U){T(U)}finally{b(!1)}};return r&&!l?e.jsx("div",{className:"w6w-error w6w-small",role:"alert",children:r.message}):e.jsxs("div",{className:"w6w-callable-binding-setup",children:[e.jsxs("label",{className:"w6w-small",children:["Callable",e.jsxs("select",{"aria-label":"Callable",value:d,disabled:!l,onChange:E=>m(E.target.value),children:[e.jsx("option",{value:"",disabled:!0,children:l?"Choose…":"Loading…"}),(l??[]).map(E=>e.jsxs("option",{value:E.id,children:[E.name," (",E.kind,")"]},E.id))]})]}),x.status==="error"&&e.jsx("div",{className:"w6w-error w6w-small",role:"alert",children:x.message}),F.length>1&&e.jsxs("label",{className:"w6w-small",children:["Trigger",e.jsxs("select",{"aria-label":"Trigger",value:w,onChange:E=>{p(E.target.value),u("")},children:[e.jsx("option",{value:"",disabled:!0,children:"Choose…"}),F.map(E=>e.jsx("option",{value:E.id,children:E.id},E.id))]})]}),x.status==="ready"&&(!O||C)&&e.jsxs("div",{className:"w6w-small",children:["Field",P.length>0?e.jsxs("select",{"aria-label":"Field",value:v,onChange:E=>u(E.target.value),children:[e.jsx("option",{value:"",disabled:!0,children:"Choose…"}),P.map(E=>e.jsx("option",{value:E,children:E},E))]}):e.jsx("input",{"aria-label":"Field",value:v,placeholder:"input name",onChange:E=>u(E.target.value)})]}),e.jsx("button",{type:"button",className:"w6w-btn",disabled:!I,onClick:$,children:g?"Saving…":"Save binding"}),N&&e.jsx("span",{className:"w6w-muted w6w-small",children:" Saved"}),r&&l&&e.jsx("div",{className:"w6w-error w6w-small",role:"alert",children:r.message})]})}const pi={pending:"Pending",verified:"Verified",revoked:"Revoked",suspended:"Suspended"};function zs({status:t,className:s,testId:n}){return e.jsx("span",{className:["w6w-publisher-badge",`w6w-publisher-badge-${t}`,s].filter(Boolean).join(" "),"data-status":t,"data-testid":n,children:pi[t]})}function je({label:t,value:s,id:n}){return e.jsxs("div",{className:"w6w-verification-row","data-testid":`verification-${n}`,children:[e.jsx("span",{className:"w6w-verification-label",children:t}),e.jsx("code",{className:"w6w-verification-value",children:s}),e.jsx(K.Copyable,{value:s,label:`Copy ${t}`,children:e.jsx("span",{children:"Copy"})})]})}function Gs({instructions:t,className:s,testId:n}){const{dns:a,wellKnown:i,domain:l}=t;return e.jsxs("div",{className:["w6w-verification",s].filter(Boolean).join(" "),"data-testid":n,children:[e.jsxs("p",{children:["Prove you control ",l," with either method:"]}),e.jsx("h4",{children:"DNS record"}),e.jsx(je,{label:"Type",value:a.type,id:"dns-type"}),e.jsx(je,{label:"Name",value:a.name,id:"dns-name"}),e.jsx(je,{label:"Value",value:a.value,id:"dns-value"}),e.jsx("h4",{children:"Well-known file"}),e.jsx(je,{label:"URL",value:i.url,id:"wk-url"}),e.jsx(je,{label:"Body",value:i.body,id:"wk-body"})]})}function fi({namespaces:t,onVerify:s,onRevoke:n,detail:a,busyPrefix:i,canManage:l=!0,className:o,testId:r}){return t.length===0?e.jsx("p",{className:o,"data-testid":r,children:"No namespaces claimed yet."}):e.jsx("ul",{className:["w6w-namespace-list",o].filter(Boolean).join(" "),"data-testid":r,children:t.map(c=>e.jsxs("li",{"data-testid":`namespace-${c.prefix}`,children:[e.jsx("strong",{children:c.prefix})," ",e.jsx("span",{children:c.domain})," ",e.jsx(zs,{status:c.status}),c.status==="pending"?e.jsxs(e.Fragment,{children:[e.jsx(Gs,{instructions:c.instructions}),e.jsx("button",{type:"button","data-testid":`verify-${c.prefix}`,disabled:i===c.prefix,onClick:()=>s(c.prefix),children:"Verify"}),a!=null&&a[c.prefix]?e.jsx("p",{role:"alert","data-testid":`detail-${c.prefix}`,children:a[c.prefix]}):null]}):null,c.status!=="revoked"?e.jsx("button",{type:"button","data-testid":`revoke-${c.prefix}`,disabled:!l,onClick:()=>n(c.prefix),children:"Revoke"}):null]},c.prefix))})}function xi({members:t,canManage:s,onAdd:n,onRemove:a,className:i,testId:l}){const[o,r]=f.useState(""),[c,d]=f.useState("developer");return e.jsxs("div",{className:["w6w-publisher-members",i].filter(Boolean).join(" "),"data-testid":l,children:[e.jsx("ul",{className:"w6w-publisher-member-list",children:t.map(m=>e.jsxs("li",{"data-testid":`member-${m.subject}`,children:[e.jsx("span",{children:m.subject})," ",e.jsx("span",{children:m.role}),e.jsx("button",{type:"button","data-testid":`remove-${m.subject}`,disabled:!s,onClick:()=>a(m.subject),children:"Remove"})]},m.subject))}),e.jsxs("form",{className:"w6w-publisher-member-add",onSubmit:m=>{m.preventDefault();const x=o.trim();!x||!s||(n(x,c),r(""))},children:[e.jsx("input",{"aria-label":"Member subject","data-testid":"member-subject",value:o,disabled:!s,onChange:m=>r(m.target.value)}),e.jsxs("select",{"aria-label":"Member role","data-testid":"member-role",value:c,disabled:!s,onChange:m=>d(m.target.value),children:[e.jsx("option",{value:"developer",children:"developer"}),e.jsx("option",{value:"owner",children:"owner"})]}),e.jsx("button",{type:"submit","data-testid":"member-add",disabled:!s||!o.trim(),children:"Add member"})]})]})}function gi({onCreate:t,busy:s,error:n,className:a,testId:i}){const[l,o]=f.useState(""),[r,c]=f.useState(""),d=l.trim()!==""&&r.trim()!=="";return e.jsxs("form",{className:["w6w-publisher-form",a].filter(Boolean).join(" "),"data-testid":i,onSubmit:m=>{m.preventDefault(),d&&!s&&t({slug:l.trim(),displayName:r.trim()})},children:[e.jsx("h3",{children:"Become a publisher"}),e.jsx("p",{children:"Create a publisher to claim namespaces and publish apps."}),e.jsx("input",{"aria-label":"Publisher slug","data-testid":"publisher-slug",value:l,onChange:m=>o(m.target.value)}),e.jsx("input",{"aria-label":"Display name","data-testid":"publisher-display-name",value:r,onChange:m=>c(m.target.value)}),e.jsx("button",{type:"submit","data-testid":"publisher-create",disabled:!d||s,children:"Become a publisher"}),n?e.jsx("p",{role:"alert",children:n}):null]})}const vi={private:"Not submitted",submitted:"Submitted for review",in_review:"In review",changes_requested:"Changes requested",listed:"Listed",rejected:"Rejected",suspended:"Suspended",delisted:"Delisted"},ji={submitted:"Submitted",in_review:"In review",changes_requested:"Changes requested",approved:"Approved",rejected:"Rejected",auto_approved:"Auto-approved",superseded:"Superseded"},bi={validator:"Validator",digest:"Digest",sandbox_describe:"Sandbox describe",auth_test_hook:"Auth test hook",health_check:"Health check",network_wildcard:"Network wildcard",listing_copy:"Listing copy",capability_summary:"Capability summary",reviewer_notes:"Reviewer notes"};function yi({listing:t,submissions:s,className:n,testId:a}){return!t&&s.length===0?null:e.jsxs("div",{className:["w6w-listing-status",n].filter(Boolean).join(" "),"data-testid":a,children:[t?e.jsx("span",{className:"w6w-listing-state","data-listing-state":t.state,children:vi[t.state]??t.state}):null,t!=null&&t.listedVersion?e.jsxs("span",{className:"w6w-listing-listed-version",children:["v",t.listedVersion]}):null,s.length>0?e.jsx("ol",{className:"w6w-listing-submissions",children:s.map(i=>e.jsxs("li",{className:"w6w-listing-submission","data-submission-id":i.id,"data-submission-status":i.status,children:[e.jsxs("div",{className:"w6w-listing-submission-head",children:[e.jsx("span",{className:"w6w-listing-submission-status",children:ji[i.status]??i.status}),e.jsxs("span",{className:"w6w-listing-submission-version",children:["v",i.version]}),e.jsx("time",{className:"w6w-listing-submission-when",dateTime:i.createdAt,children:i.createdAt})]}),i.checks.length>0?e.jsx("ul",{className:"w6w-listing-checks",children:i.checks.map(l=>e.jsxs("li",{className:"w6w-listing-check","data-check-key":l.key,"data-check-outcome":l.outcome,children:[e.jsx("span",{className:"w6w-listing-check-key",children:bi[l.key]??l.key}),e.jsx("span",{className:"w6w-listing-check-outcome",children:l.outcome}),e.jsx("span",{className:"w6w-listing-check-message",children:l.message})]},l.key))}):null,i.reasons?e.jsx("p",{className:"w6w-listing-reasons",children:i.reasons}):null,i.hasReviewerNotes?e.jsx("span",{className:"w6w-listing-notes-sent",children:"Reviewer notes sent"}):null]},i.id))}):null]})}const Ni={invalid_body:"Some of these listing details aren't valid. Fix the highlighted fields and try again.",namespace_owned:"Another publisher already owns one of this app's namespaces.",namespace_reserved:"One of this app's namespaces is reserved by W6W.",publisher_suspended:"Your publisher account is suspended, so it can't submit apps for listing.",not_publisher_tier:"This publisher's plan doesn't include submitting apps for listing.",unknown_version:"That version doesn't exist for this app. Deploy it first, then submit.",submission_pending:"This app already has a submission waiting for a decision. Submit again once it's decided.",listing_delisted:"This app's listing was delisted. Ask W6W to review it again before submitting.",invalid_transition:"This listing can't go back to submitted from where it is now.",stale_submission:"A reviewer already decided on an older submission. Reload to see the current state.",app_delisted:"This app was delisted, so it can't be submitted for listing.",app_suspended:"This app is suspended. It can't take new connections or submissions until it's reinstated.",not_found:"We couldn't find that app on this publisher account."},ki="Something went wrong submitting this listing. Try again in a moment.";function Xs(t){return Ni[t]??ki}const mt=280,es=5,ts=4e3;function ss(t){if(!/^https:\/\//i.test(t))return!1;try{return new URL(t).hostname!==""}catch{return!1}}function Si(t){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)}function Zs(t){const s=[],{version:n,listing:a}=t;n.trim()===""&&s.push({field:"version",message:"Choose the app version to submit."});const i=a.summary.trim();i===""?s.push({field:"summary",message:"Add a one-line summary of what the app does."}):i.length>mt&&s.push({field:"summary",message:`Keep the summary to ${mt} characters or fewer (it's ${i.length}).`}),a.categories.length>es&&s.push({field:"categories",message:`Pick at most ${es} categories (you picked ${a.categories.length}).`});const l=a.supportUrl.trim();l===""?s.push({field:"supportUrl",message:"Add an https support URL reviewers can open."}):ss(l)||s.push({field:"supportUrl",message:"The support URL must start with https://."});const o=(a.privacyUrl??"").trim();o!==""&&!ss(o)&&s.push({field:"privacyUrl",message:"The privacy URL must start with https://."});const r=a.contactEmail.trim();r===""?s.push({field:"contactEmail",message:"Add a contact email so reviewers can reach you."}):Si(r)||s.push({field:"contactEmail",message:"That contact email doesn't look like an email address."});const c=(a.reviewerNotes??"").trim();return c.length>ts&&s.push({field:"reviewerNotes",message:`Keep reviewer notes to ${ts} characters or fewer (they're ${c.length}).`}),s}function Ci(t){const s=t.listing.summary.trim(),n=(t.listing.iconRef??"").trim(),a=(t.listing.privacyUrl??"").trim(),i=(t.listing.reviewerNotes??"").trim(),l=t.listing.categories.map(o=>o.trim()).filter(Boolean);return{version:t.version.trim(),listing:{summary:s,...n?{iconRef:n}:{},categories:l,supportUrl:t.listing.supportUrl.trim(),...a?{privacyUrl:a}:{},contactEmail:t.listing.contactEmail.trim(),...i?{reviewerNotes:i}:{}}}}const Ei={version:"",summary:"",iconRef:"",categories:"",supportUrl:"",privacyUrl:"",contactEmail:"",reviewerNotes:""};function Ri({appId:t,versions:s,onSubmit:n,busy:a,errorCode:i,className:l,testId:o}){const[r,c]=f.useState(Ei),[d,m]=f.useState([]),x=u=>g=>c(b=>({...b,[u]:g})),j={version:r.version,listing:{summary:r.summary,iconRef:r.iconRef,categories:r.categories.split(",").map(u=>u.trim()).filter(Boolean).filter((u,g,b)=>b.indexOf(u)===g),supportUrl:r.supportUrl,privacyUrl:r.privacyUrl,contactEmail:r.contactEmail,reviewerNotes:r.reviewerNotes}},w=u=>`listing-${u.replace(/[A-Z]/g,g=>`-${g.toLowerCase()}`)}`,p=u=>{var g;return((g=d.find(b=>b.field===u))==null?void 0:g.message)??""},v=(u,g,b,N)=>e.jsxs("label",{className:"w6w-listing-form-field","data-field":b,children:[e.jsx("span",{className:"w6w-listing-form-label",children:g}),e.jsx("input",{"aria-label":g,"aria-invalid":p(b)!==""||void 0,"data-testid":w(u),value:r[u],onChange:S=>x(u)(S.target.value)}),N?e.jsx("span",{className:"w6w-listing-form-hint",children:N}):null,p(b)?e.jsx("span",{className:"w6w-listing-form-error",role:"alert","data-field-error":b,children:p(b)}):null]});return e.jsxs("form",{className:["w6w-listing-form",l].filter(Boolean).join(" "),"data-testid":o,"data-app-id":t,noValidate:!0,onSubmit:u=>{u.preventDefault();const g=Zs(j);m(g),g.length===0&&!a&&n(Ci(j))},children:[e.jsx("h3",{children:"Submit for listing"}),e.jsx("p",{children:"Reviewers check this version, then W6W lists it in the catalog."}),e.jsxs("label",{className:"w6w-listing-form-field","data-field":"version",children:[e.jsx("span",{className:"w6w-listing-form-label",children:"Version"}),e.jsx("input",{"aria-label":"Version",list:"listing-versions","aria-invalid":p("version")!==""||void 0,"data-testid":"listing-version",value:r.version,onChange:u=>x("version")(u.target.value)}),e.jsx("datalist",{id:"listing-versions",children:(s??[]).map(u=>e.jsx("option",{value:u},u))}),p("version")?e.jsx("span",{className:"w6w-listing-form-error",role:"alert","data-field-error":"version",children:p("version")}):null]}),v("summary","Summary","summary",`Up to ${mt} characters.`),v("iconRef","Icon reference","iconRef"),v("categories","Categories","categories","Comma-separated, up to five."),v("supportUrl","Support URL","supportUrl","https:// only."),v("privacyUrl","Privacy URL","privacyUrl","Optional, https:// only."),v("contactEmail","Contact email","contactEmail","Where reviewers reach you."),v("reviewerNotes","Notes for the reviewer","reviewerNotes","Optional, up to 4000 characters."),e.jsx("button",{type:"submit","data-testid":"listing-submit",disabled:a,children:"Submit for listing"}),i?e.jsx("p",{className:"w6w-listing-error",role:"alert",children:Xs(i)}):null]})}exports.AddConnectionModal=h.AddConnectionModal;exports.ApiCallsPanel=h.ApiCallsPanel;exports.AppConnectionForm=h.AppConnectionForm;exports.AppIcon=h.AppIcon;exports.AppPicker=h.AppPicker;exports.AuthFieldsForm=h.AuthFieldsForm;exports.AuthGuide=h.AuthGuide;exports.CanvasLayer=h.CanvasLayer;exports.CodeEditor=h.CodeEditor;exports.Combobox=h.Combobox;exports.ConfirmModal=h.ConfirmModal;exports.CredentialPicker=h.CredentialPicker;exports.DataTable=h.DataTable;exports.DelegationSteps=h.DelegationSteps;exports.DeleteButton=h.DeleteButton;exports.EmptyState=h.EmptyState;exports.ExpressionEditorModal=h.ExpressionEditorModal;exports.ExpressionInput=h.ExpressionInput;exports.ExpressionOptionsProvider=h.ExpressionOptionsProvider;exports.HTML_PREVIEW_CSP=h.HTML_PREVIEW_CSP;exports.HtmlPreview=h.HtmlPreview;exports.IconButton=h.IconButton;exports.JsonEditor=h.JsonEditor;exports.LastUsedNote=h.LastUsedNote;exports.Markdown=h.Markdown;exports.Modal=h.Modal;exports.NodeConfigForm=h.NodeConfigForm;exports.ParamsForm=h.ParamsForm;exports.PropertyEntryForm=h.PropertyEntryForm;exports.PublisherBadge=h.PublisherBadge;exports.RESULT_RENDER_MAX_CHARS=h.RESULT_RENDER_MAX_CHARS;exports.ResultViewer=h.ResultViewer;exports.RetryPolicyFields=h.RetryPolicyFields;exports.SecretJsonField=h.SecretJsonField;exports.StepBuilderModal=h.StepBuilderModal;exports.W6WUIProvider=h.W6WUIProvider;exports.connectionAppIdsToLookUp=h.connectionAppIdsToLookUp;exports.detectResultFormat=h.detectResultFormat;exports.effectiveNodeOutput=h.effectiveNodeOutput;exports.effectiveNodeOutputs=h.effectiveNodeOutputs;exports.filterOptions=h.filterOptions;exports.findTestInput=h.findTestInput;exports.htmlPreviewSrcDoc=h.htmlPreviewSrcDoc;exports.indexNodeSamples=h.indexNodeSamples;exports.isExprValue=h.isExprValue;exports.isFormResolvedOptions=h.isFormResolvedOptions;exports.isSecretValue=h.isSecretValue;exports.isTestRequired=h.isTestRequired;exports.keyClientId=h.keyClientId;exports.previewNodeOutputs=h.previewNodeOutputs;exports.rememberableInput=h.rememberableInput;exports.requiredParamsFilled=h.requiredParamsFilled;exports.resolveConnectionAppMeta=h.resolveConnectionAppMeta;exports.resultCopyText=h.resultCopyText;exports.secretClipboard=h.secretClipboard;exports.shapeToSkeleton=h.shapeToSkeleton;exports.shouldUseCombobox=h.shouldUseCombobox;exports.splitFrontmatter=h.splitFrontmatter;exports.startOAuthPopup=h.startOAuthPopup;exports.testInputSavesSettled=h.testInputSavesSettled;exports.trackTestInputSave=h.trackTestInputSave;exports.useEnterSubmit=h.useEnterSubmit;exports.useExpressionOptions=h.useExpressionOptions;exports.useRememberedTestInput=h.useRememberedTestInput;exports.useW6WApi=h.useW6WApi;exports.CodeBlock=K.CodeBlock;exports.Copyable=K.Copyable;exports.Icon=K.Icon;exports.iconNames=K.iconNames;exports.ATTENTION_DISPLAY_CAP=dt;exports.ActionTestForm=Cn;exports.ApiError=be;exports.BudgetMeter=La;exports.CELL_PROBLEM_COPY=Is;exports.CSV_MAX_BYTES=$s;exports.CSV_TOO_LARGE_COPY=Bs;exports.CallableBindingSetup=hi;exports.CallableList=Ra;exports.CallableListStatus=Ca;exports.ColumnsEditor=ii;exports.ConnectionHeader=$a;exports.ConnectionKeepAlive=Ia;exports.ConnectionList=Aa;exports.CopyableText=ls;exports.CreatePublisherForm=gi;exports.CreateSharedCredentialContext=yn;exports.CsvPanel=li;exports.DATA_STORE_ERROR_FALLBACK=pe;exports.DATA_STORE_KINDS=Oa;exports.DATA_STORE_KIND_LABEL=Ts;exports.DATA_STORE_NETWORK_ERROR=Ls;exports.DOC_VALUE_COPY=wt;exports.DataEntryEditor=oi;exports.DataEntryList=ri;exports.DataStoreList=si;exports.DataTableGrid=ci;exports.EditButton=Hn;exports.EditConnectionModal=Ta;exports.ExecutionDetail=ja;exports.ExecutionFilters=pa;exports.ExecutionList=Zn;exports.ExecutionLogDock=ca;exports.ExecutionLogPanel=ds;exports.ExecutionLogView=ia;exports.ExecutionStats=fa;exports.HealthStatusPill=Ue;exports.HistoryTimeline=Vn;exports.InfoTip=Jn;exports.ListItem=Pe;exports.ListingStatus=yi;exports.NEW_ROW_ID=jt;exports.NamespaceList=fi;exports.PublisherMembers=xi;exports.PublisherStatusBadge=zs;exports.RECENT_DISPLAY_CAP=Ns;exports.ReliabilityChart=Ss;exports.ReliabilityList=Sa;exports.RepoSyncIndicator=qn;exports.RowActionsMenu=pt;exports.RunCallableButton=wi;exports.RunCallableModal=Ct;exports.RunCallables=mi;exports.SCALAR_TYPES=gt;exports.ServerResourcesBadge=Pn;exports.ServerResourcesCard=_n;exports.ServerResourcesCardSmall=Ln;exports.ServerResourcesRail=On;exports.StepStatusPill=Se;exports.SubmitListingForm=Ri;exports.UptimeStrip=rs;exports.VERSION_CONFLICT_COPY=bt;exports.VerificationInstructionsBlock=Gs;exports.YamlEditor=En;exports.buildRowValue=za;exports.cellErrorsOf=Za;exports.createW6WApi=bn;exports.cropText=is;exports.csvFilenameOf=Ma;exports.csvImportMessage=ti;exports.csvLineOf=ut;exports.dirtyColumns=Ya;exports.displayBoard=ks;exports.draftFromEntry=Ha;exports.errorPlacement=Ms;exports.formatDurationMs=We;exports.formatExecutionTime=ye;exports.isCellValue=Va;exports.isVersionConflict=Qa;exports.kvValueOf=ei;exports.kvValueTypeOf=Pa;exports.listingErrorCopy=Xs;exports.locateDataStoreError=Ja;exports.locateRawResponseError=Ds;exports.needsAttention=ya;exports.newRowDraft=qa;exports.parseCell=Ve;exports.parseDocText=Us;exports.partitionBoard=bs;exports.performancePoints=js;exports.refreshRelativeTime=As;exports.remainingTtlSeconds=Ga;exports.rowValueOf=Fs;exports.rowWriteOf=Xa;exports.serializeCell=Je;exports.tableSchemaOf=Da;exports.uptimeDays=ys;exports.validateListingInput=Zs;
4
4
  //# sourceMappingURL=index.cjs.map