(()=>{const c=window.React;if(!c)return;const t=c.createElement,y=c.useState,I=c.useEffect,e={surface:"var(--app-surface,#1a1a1c)",elevated:"var(--app-elevated,#2a2a2e)",rule:"var(--app-rule)",ink:"var(--app-ink,#e6e3da)",inkSoft:"var(--app-ink-soft)",inkFaint:"var(--app-ink-faint)",accent:"var(--app-accent,#00f3ff)",success:"var(--app-success,#00d4b8)",warn:"var(--app-warn,#f8d974)",fail:"var(--app-fail,#f43f6c)",mono:'var(--app-font-mono,"JetBrains Mono",SFMono-Regular,monospace)'},w={connected:{label:"Connected",color:e.success},"not-connected":{label:"Not Connected",color:e.inkFaint},expired:{label:"Expired",color:e.warn},error:{label:"Error",color:e.fail}},T={connected:[{label:"Reconnect",action:"integration.reconnect"}],expired:[{label:"Reconnect",action:"integration.reconnect"}],error:[{label:"Retry",action:"integration.retry"}],"not-connected":[{label:"Connect",action:"integration.reconnect"}]},x={title:"No sources connected",body:"Every dashboard in this canvas is running on mock data. Connect a data source to bind them to real numbers. Connectors are declared in the tenant manifest; secrets are GSM-backed \u2014 the canvas holds a reference, never the value."};function C(r){const f=String(r||"?").split(/[\s/-]+/);return((f[0]||"")[0]||"?").toUpperCase()+((f[1]||"")[0]||"").toUpperCase()}const m=r=>({flex:r?1:"none",padding:"7px 13px",fontWeight:600,fontSize:11,textTransform:"uppercase",letterSpacing:".05em",borderRadius:8,cursor:"pointer",color:r?"#0e0e10":e.accent,background:r?e.accent:"transparent",border:r?"none":`1px solid ${e.rule}`});function v(r){const f=r&&r.kind||window.KIND_REGISTRY&&window.KIND_REGISTRY.integration||{},[,R]=y(0),[o,s]=y(null),[u,S]=y(null);I(()=>{const n=()=>R(i=>i+1);return window.addEventListener("platform-integrations-live-hydrated",n),()=>window.removeEventListener("platform-integrations-live-hydrated",n)},[]);const h=f.liveData||{tenant:null,source:"none",connectors:[]},b=Array.isArray(h.connectors)?h.connectors:[],g=(n,i)=>{S({msg:n,tone:i||"info"}),setTimeout(()=>S(null),5e3)},k=(n,i,a)=>!window.CANVAS_ACTIONS||!window.CANVAS_ACTIONS.dispatch?Promise.reject(new Error("actions gateway unavailable in this build")):window.CANVAS_ACTIONS.dispatch(n,i,{confirm:a===!0}),E=(n,i)=>{s({conn:n,act:i,busy:!0}),k(i.action,{provider:n.provider},!1).then(a=>s({conn:n,act:i,preview:a,busy:!1})).catch(a=>{s(null),g(`${i.label} \xB7 ${n.provider} \u2014 ${a.message}`,"fail")})},$=()=>{if(!o||o.busy)return;const{conn:n,act:i}=o;s({...o,busy:!0}),k(i.action,{provider:n.provider},!0).then(a=>{s(null),a&&a.result==="needs-credential"?g(`${n.provider} \u2014 ${a.message}`,"warn"):g(`${n.provider} \xB7 ${i.label.toLowerCase()} applied \u2014 state: ${a&&a.state||"recorded"}`,"ok"),typeof window.platformIntegrationsLiveHydrate=="function"&&window.platformIntegrationsLiveHydrate()}).catch(a=>{s(null),g(`${i.label} \xB7 ${n.provider} \u2014 ${a.message}`,"fail")})},l={connected:0,"not-connected":0,expired:0,error:0};for(const n of b)l[n.state]!==void 0&&(l[n.state]+=1);const _=t("div",{key:"strip",style:{display:"flex",alignItems:"center",gap:16,flexWrap:"wrap",padding:"13px 17px",background:e.surface,border:`1px solid ${e.rule}`,borderRadius:12}},t("p",{style:{margin:0,flex:1,minWidth:240,fontSize:13,color:e.inkSoft}},"Integrations are the sources behind every dashboard in the canvas. ",t("span",{style:{color:e.ink}},"Secrets are GSM-backed \u2014 the canvas holds a reference, never the value.")),...[["Connected",l.connected,e.success],["Expired",l.expired,e.warn],["Error",l.error,e.fail],["Not Connected",l["not-connected"],e.inkFaint]].map(([n,i,a])=>t("div",{key:n,style:{textAlign:"right"}},t("div",{style:{fontFamily:e.mono,fontSize:18,color:a}},String(i)),t("div",{style:{fontSize:9,textTransform:"uppercase",letterSpacing:".08em",color:e.inkFaint}},n)))),A=b.map(n=>{const i=w[n.state]||w["not-connected"],a=T[n.state]||[];return t("div",{key:n.provider,style:{display:"flex",flexDirection:"column",gap:11,padding:"15px 16px",background:e.surface,border:`1px solid ${e.rule}`,borderRadius:12}},t("div",{style:{display:"flex",alignItems:"center",gap:11}},t("span",{style:{width:36,height:36,borderRadius:9,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",fontFamily:e.mono,fontSize:12,fontWeight:600,color:e.ink,background:e.elevated,border:`1px solid ${e.rule}`}},C(n.provider)),t("div",{style:{minWidth:0,flex:1}},t("div",{style:{fontWeight:600,fontSize:14,color:e.ink,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},n.provider),t("div",{style:{fontFamily:e.mono,fontSize:10,color:e.inkFaint,marginTop:2}},n.source==="live"?"live status":"manifest")),t("span",{style:{display:"inline-flex",alignItems:"center",gap:6,fontFamily:e.mono,fontSize:9.5,textTransform:"uppercase",letterSpacing:".06em",padding:"4px 9px",borderRadius:999,flexShrink:0,color:i.color,border:`1px solid ${e.rule}`}},t("span",{style:{width:6,height:6,borderRadius:"50%",background:i.color}}),i.label)),t("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",gap:"4px 12px",fontSize:11.5,color:e.inkSoft}},t("span",{style:{color:e.inkFaint}},"Last sync"),t("span",{style:{fontFamily:e.mono,color:e.ink}},n.last_sync_at||"\u2014"),t("span",{style:{color:e.inkFaint}},"Secret"),t("span",{style:{fontFamily:e.mono,color:e.accent,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},n.secret_ref||"not provisioned")),t("div",{style:{display:"flex",flexWrap:"wrap",gap:5,alignItems:"center"}},t("span",{style:{fontSize:9,textTransform:"uppercase",letterSpacing:".08em",color:e.inkFaint,marginRight:2}},n.used_by_planned?"Used by (planned)":"Used by"),...(n.used_by||[]).map(d=>t("span",{key:d,style:{fontFamily:e.mono,fontSize:10,padding:"2px 7px",borderRadius:5,color:e.inkSoft,background:e.elevated,border:`1px solid ${e.rule}`}},d))),t("div",{style:{display:"flex",gap:8,paddingTop:10,borderTop:`1px solid ${e.rule}`}},...a.map((d,W)=>t("button",{key:d.label,style:m(W===0),onClick:()=>E(n,d)},d.label))))}),N=b.length?t("div",{key:"grid",style:{display:"grid",gridTemplateColumns:"repeat(auto-fill,minmax(320px,1fr))",gap:12}},...A):t("div",{key:"empty",style:{padding:"42px 24px",textAlign:"center",background:e.surface,border:`1px dashed ${e.rule}`,borderRadius:12}},t("div",{style:{fontWeight:600,fontSize:15,color:e.ink,marginBottom:8}},x.title),t("div",{style:{fontSize:12.5,color:e.inkSoft,maxWidth:520,margin:"0 auto"}},x.body)),z=o&&t("div",{key:"dialog",style:{position:"fixed",inset:0,background:"rgba(0,0,0,.55)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:60},onClick:()=>!o.busy&&s(null)},t("div",{style:{width:420,maxWidth:"92vw",padding:"18px 20px",background:e.elevated,border:`1px solid ${e.rule}`,borderRadius:14,color:e.ink},onClick:n=>n.stopPropagation()},t("div",{style:{fontFamily:e.mono,fontSize:10,textTransform:"uppercase",letterSpacing:".08em",color:e.accent,marginBottom:6}},`HITL \xB7 ${o.act.label}`),t("div",{style:{fontWeight:600,fontSize:15,marginBottom:8}},`${o.act.label} \xB7 ${o.conn.provider}`),t("div",{style:{fontSize:12.5,color:e.inkSoft,marginBottom:12}},o.busy?"Running validate-only dry run\u2026":o.preview&&o.preview.result==="needs-credential"?o.preview.message:"Re-attempt the connection using the existing GSM credential reference. No new secret is created; the transition is recorded to the tenant-scoped status store."),!o.busy&&o.preview&&o.preview.would_write&&t("div",{style:{fontFamily:e.mono,fontSize:10.5,color:e.inkSoft,background:e.surface,border:`1px solid ${e.rule}`,borderRadius:8,padding:"8px 10px",marginBottom:12,whiteSpace:"pre-wrap"}},JSON.stringify(o.preview.would_write,null,1)),t("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"}},t("button",{style:m(!1),onClick:()=>s(null),disabled:!!o.busy},"Cancel"),!(o.preview&&o.preview.result==="needs-credential")&&t("button",{style:m(!0),onClick:$,disabled:!!o.busy},`Approve \xB7 ${o.act.label}`)))),F=u&&t("div",{key:"toast",style:{position:"fixed",right:18,bottom:18,zIndex:70,padding:"10px 14px",borderRadius:10,fontSize:12.5,color:e.ink,background:e.elevated,border:`1px solid ${u.tone==="fail"?e.fail:u.tone==="warn"?e.warn:e.rule}`}},u.msg);return t("div",{className:"view view-platform-integrations",style:{display:"flex",flexDirection:"column",gap:14}},_,N,z,F)}v.displayName="PlatformIntegrationsView",window.PLATFORM_INTEGRATIONS_VIEW_FN=v,window.VIEWS=window.VIEWS||{},window.VIEWS.platformIntegrations=v,window.KIND_REGISTRY=window.KIND_REGISTRY||{};const p=window.KIND_REGISTRY;p.integration=Object.assign(p.integration||{},{id:"integration",label:"Integrations",workspaceLabel:"Integrations",workspaceIcon:"integration_instructions",description:"Tenant-manifest connectors with GSM-backed credential references. State, last sync and reconnect/retry actions are live via /integrations/status + the /actions gateway; the aaas tenant has no connectors configured yet, so the honest default is empty.",defaultView:"platformIntegrations",defaultDetail:"none",agentTreatment:"provenance",primaryAction:null,secondaryActions:[],heroKpis:[{label:"services",value:"0",trend:"flat"},{label:"connected",value:"0",trend:"flat"},{label:"expired",value:"0",trend:"flat"},{label:"error",value:"0",trend:"flat"},{label:"not connected",value:"0",trend:"flat"}],mockItems:[],moreCount:0,liveData:p.integration&&p.integration.liveData||null})})();
