
// Map external modules to globals
const React = window.React;
const ReactDOM = window.ReactDOM;
const require = (name) => {
  if (name === 'react') return React;
  if (name === 'react-dom') return ReactDOM;
  throw new Error('Unknown module: ' + name);
};

"use strict";var SemiontDashboard=(()=>{var se=Object.create;var M=Object.defineProperty;var ne=Object.getOwnPropertyDescriptor;var ae=Object.getOwnPropertyNames;var oe=Object.getPrototypeOf,ie=Object.prototype.hasOwnProperty;var S=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,n)=>(typeof require<"u"?require:t)[n]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var re=(e,t)=>{for(var n in t)M(e,n,{get:t[n],enumerable:!0})},F=(e,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ae(t))!ie.call(e,o)&&o!==n&&M(e,o,{get:()=>t[o],enumerable:!(a=ne(t,o))||a.enumerable});return e};var N=(e,t,n)=>(n=e!=null?se(oe(e)):{},F(t||!e||!e.__esModule?M(n,"default",{value:e,enumerable:!0}):n,e)),ce=e=>F(M({},"__esModule",{value:!0}),e);var De={};re(De,{WebDashboardApp:()=>q});var s=N(S("react"),1);var i=N(S("react"),1),le="semiont-tag semiont-tag--secondary semiont-tag--compact",me=new Set(["graph","neo4j","janusgraph","neptune"]),de=e=>e.toLowerCase().startsWith("inference.");function pe(e){let t=e.indexOf(".");if(t!==-1){let n=e.slice(0,t),a=e.slice(t+1);return n.charAt(0).toUpperCase()+n.slice(1)+" ("+a.charAt(0).toUpperCase()+a.slice(1)+")"}return e.charAt(0).toUpperCase()+e.slice(1)}var V=["proxy","frontend","backend","database"];function ue(e){switch(e){case"healthy":return"semiont-indicator semiont-indicator--online";case"unhealthy":return"semiont-indicator semiont-indicator--offline";case"warning":return"semiont-indicator semiont-indicator--busy";default:return"semiont-indicator"}}function ge(e){switch(e){case"healthy":return"healthy";case"unhealthy":return"unhealthy";case"warning":return"warning";default:return"unknown"}}function ve(e){switch(e){case"healthy":return"semiont-badge semiont-badge--success";case"unhealthy":return"semiont-badge semiont-badge--error";case"warning":return"semiont-badge semiont-badge--warning";default:return"semiont-badge semiont-badge--info"}}var he=({service:e})=>{let t=e.evidence&&e.evidence.length>0?[...e.evidence]:(()=>{let a=e.details||"",o=[],p=a.match(/[Pp][Ii][Dd]:\s*(\d+)/),v=a.match(/[Cc]ontainer:\s*(\S+)/);return p&&o.push(`pid ${p[1]}`),v&&o.push(`container ${v[1].slice(0,12)}`),e.runningCount!==void 0&&e.desiredCount!==void 0&&o.push(`${e.runningCount}/${e.desiredCount} tasks`),o})();e.checkedAt&&t.push(`checked ${new Date(e.checkedAt).toLocaleTimeString()}`);let n=fe(e);return i.default.createElement("div",{className:"service-row"},i.default.createElement("div",{className:"service-row__indicator"},i.default.createElement("span",{className:ue(e.status)})),i.default.createElement("div",{className:"service-row__name"},pe(e.name)),i.default.createElement("div",{className:"service-row__host"},e.hostname?i.default.createElement("span",{className:"service-row__hostname"},e.hostname):i.default.createElement("span",{className:"service-row__hostname service-row__hostname--dim"},"\u2014")),i.default.createElement("div",{className:"service-row__status"},i.default.createElement("span",{className:ve(e.status)},i.default.createElement("span",{className:"semiont-badge__text"},ge(e.status)))),i.default.createElement("div",{className:"service-row__tags"},t.map((a,o)=>i.default.createElement("span",{key:o,className:le},a))),i.default.createElement("div",{className:"service-row__actions"},n.map((a,o)=>i.default.createElement("a",{key:o,href:a.url,target:"_blank",rel:"noopener noreferrer",className:"semiont-tag semiont-tag--info semiont-tag--compact"},a.label))))};function fe(e){let t=[],n=e.awsRegion||"us-east-1";return e.ecsServiceName&&e.ecsClusterName&&(t.push({label:"Console \u2197",url:`https://console.aws.amazon.com/ecs/home?region=${n}#/clusters/${e.ecsClusterName}/services/${e.ecsServiceName}/details`}),e.logGroupName&&t.push({label:"Logs \u2197",url:`https://console.aws.amazon.com/cloudwatch/home?region=${n}#logsV2:log-groups/log-group/${encodeURIComponent(e.logGroupName)}`})),e.rdsInstanceId&&t.push({label:"Console \u2197",url:`https://console.aws.amazon.com/rds/home?region=${n}#database:id=${e.rdsInstanceId};is-cluster=false`}),t}var H=({services:e})=>{let n=[...e.filter(a=>!me.has(a.name.toLowerCase())&&!de(a.name))].sort((a,o)=>{let p=V.indexOf(a.name.toLowerCase()),v=V.indexOf(o.name.toLowerCase());return p===-1&&v===-1?a.name.localeCompare(o.name):p===-1?1:v===-1?-1:p-v});return i.default.createElement("div",{className:"service-list"},i.default.createElement("div",{className:"service-list__header"},i.default.createElement("div",{className:"service-row__indicator"}),i.default.createElement("div",{className:"service-row__name"},"Service"),i.default.createElement("div",{className:"service-row__host"},"Address"),i.default.createElement("div",{className:"service-row__status"},"Status"),i.default.createElement("div",{className:"service-row__tags"},"Details"),i.default.createElement("div",{className:"service-row__actions"})),n.map((a,o)=>i.default.createElement(he,{key:o,service:a})))};var g=N(S("react"),1);var d=N(S("react"),1),be="semiont-tag semiont-tag--secondary semiont-tag--compact",f=({indicator:e,label:t,value:n,tags:a})=>d.default.createElement("div",{className:"mm-row"},d.default.createElement("div",{className:"mm-row__indicator"},d.default.createElement("span",{className:e})),d.default.createElement("div",{className:"mm-row__label"},t),d.default.createElement("div",{className:"mm-row__value"},n),d.default.createElement("div",{className:"mm-row__tags"},a==null?void 0:a.filter(Boolean).map((o,p)=>d.default.createElement("span",{key:p,className:be},o)))),y=({title:e,children:t})=>d.default.createElement("div",{className:"mm-group"},d.default.createElement("div",{className:"mm-group__title"},e),d.default.createElement("div",{className:"mm-list"},t));function we(e){switch(e){case"healthy":return"semiont-indicator semiont-indicator--online";case"unhealthy":return"semiont-indicator semiont-indicator--offline";default:return"semiont-indicator"}}function Se(e){return e.includes(".")?e.slice(e.indexOf(".")+1).replace(/^\w/,t=>t.toUpperCase()):e}var L=({inferenceServices:e})=>e.length===0?null:d.default.createElement(y,{title:"Inference"},e.map(t=>d.default.createElement(f,{key:t.name,indicator:we(t.status),label:Se(t.name),value:t.status,tags:t.evidence})));function j(e){if(e===0)return"0 B";let t=1024,n=["B","KB","MB","GB","TB"],a=Math.floor(Math.log(e)/Math.log(t));return`${(e/Math.pow(t,a)).toFixed(1)} ${n[a]}`}function T(e,t=40){return e.length<=t?e:"\u2026"+e.slice(e.length-t+1)}function Ne(e){switch(e.state){case"active":return"semiont-indicator semiont-indicator--online semiont-indicator--pulse";case"idle":return"semiont-indicator semiont-indicator--online";case"error":return"semiont-indicator semiont-indicator--offline";default:return"semiont-indicator"}}function ye(e){switch(e){case"healthy":return"semiont-indicator semiont-indicator--online";case"unhealthy":return"semiont-indicator semiont-indicator--offline";default:return"semiont-indicator"}}var O=({makeMeaning:e,inferenceServices:t})=>g.default.createElement("div",{className:"mm-sections"},g.default.createElement(y,{title:"System of Record"},g.default.createElement(f,{indicator:"semiont-indicator semiont-indicator--online",label:"Event Log",value:e.eventLog.eventCount!==void 0?e.eventLog.eventCount.toLocaleString()+" events":"unknown",tags:[e.eventLog.streamCount!==void 0&&`${e.eventLog.streamCount} streams`,e.eventLog.sizeBytes!==void 0&&j(e.eventLog.sizeBytes),e.eventLog.path&&T(e.eventLog.path)]}),g.default.createElement(f,{indicator:"semiont-indicator semiont-indicator--online",label:"Content Store",value:e.contentStore.sizeBytes!==void 0?j(e.contentStore.sizeBytes):"unknown",tags:[e.contentStore.fileCount!==void 0&&`${e.contentStore.fileCount} files`,e.contentStore.path&&T(e.contentStore.path)]})),g.default.createElement(y,{title:"Projections"},g.default.createElement(f,{indicator:ye(e.graph.status),label:"Graph",value:e.graph.status,tags:[e.graph.address,e.graph.database,...e.graph.evidence??[]]}),g.default.createElement(f,{indicator:"semiont-indicator semiont-indicator--online",label:"Materialized Views",value:e.materializedViews.fileCount!==void 0?`${e.materializedViews.fileCount} projections`:"unknown",tags:[e.materializedViews.lastUpdated&&`updated ${new Date(e.materializedViews.lastUpdated).toLocaleTimeString()}`,e.materializedViews.path&&T(e.materializedViews.path)]})),g.default.createElement(y,{title:"Actors"},["gatherer","matcher","stower","browser"].map(n=>{let a=e.actors[n];return g.default.createElement(f,{key:n,indicator:Ne(a),label:n.charAt(0).toUpperCase()+n.slice(1),value:a.state,tags:[a.provider,a.model,a.errorMessage&&a.errorMessage.slice(0,40)]})})),g.default.createElement(L,{inferenceServices:t}));var r=N(S("react"),1);var b="semiont-tag semiont-tag--secondary semiont-tag--compact",ke={"reference-annotation":"Reference Annotation","highlight-annotation":"Highlight Annotation","assessment-annotation":"Assessment Annotation","comment-annotation":"Comment Annotation","tag-annotation":"Tag Annotation",generation:"Generation"};function Ce(e){let t=Date.now()-e.getTime(),n=Math.floor(t/6e4);if(n<1)return"just now";if(n<60)return`${n}m ago`;let a=Math.floor(n/60);return a<24?`${a}h ago`:`${Math.floor(a/24)}d ago`}function _e(e){return e.state==="error"?"semiont-indicator semiont-indicator--offline":e.activeCount>0?"semiont-indicator semiont-indicator--online semiont-indicator--pulse":e.pendingCount>10?"semiont-indicator semiont-indicator--busy":"semiont-indicator semiont-indicator--online"}var K=({workers:e,inferenceServices:t})=>r.default.createElement("div",{className:"mm-sections"},r.default.createElement("div",{className:"mm-group"},r.default.createElement("div",{className:"mm-group__title"},"Workers"),r.default.createElement("div",{className:"mm-list"},r.default.createElement("div",{className:"mm-row mm-row--header"},r.default.createElement("div",{className:"mm-row__indicator"}),r.default.createElement("div",{className:"mm-row__label"},"Worker"),r.default.createElement("div",{className:"mm-row__value"},"Status"),r.default.createElement("div",{className:"mm-row__tags"},"Details")),e.map((n,a)=>r.default.createElement("div",{key:a,className:"mm-row"},r.default.createElement("div",{className:"mm-row__indicator"},r.default.createElement("span",{className:_e(n)})),r.default.createElement("div",{className:"mm-row__label"},ke[n.type]),r.default.createElement("div",{className:"mm-row__value"},n.state),r.default.createElement("div",{className:"mm-row__tags"},r.default.createElement("span",{className:n.activeCount>0?"semiont-tag semiont-tag--success semiont-tag--compact":b},n.activeCount," active"),r.default.createElement("span",{className:b},n.pendingCount," pending"),n.completedCount>0&&r.default.createElement("span",{className:b},n.completedCount," done"),n.failedCount>0&&r.default.createElement("span",{className:"semiont-tag semiont-tag--warning semiont-tag--compact"},n.failedCount," failed"),n.state==="idle"&&!n.lastProcessed&&r.default.createElement("span",{className:b},"never used"),n.lastProcessed&&n.state==="idle"&&r.default.createElement("span",{className:b},"last used ",Ce(new Date(n.lastProcessed))),n.lastProcessed&&n.state!=="idle"&&r.default.createElement("span",{className:b},"last ",new Date(n.lastProcessed).toLocaleTimeString())))))),r.default.createElement(L,{inferenceServices:t}));var Me={eventLog:{path:""},contentStore:{path:""},graph:{status:"unknown"},materializedViews:{path:""},actors:{gatherer:{state:"unknown"},matcher:{state:"unknown"},stower:{state:"unknown"},browser:{state:"unknown"}}},U=({logs:e,service:t})=>{let n=t?e.filter(a=>a.service===t||!t):e;return s.default.createElement("div",{className:"semiont-panel semiont-panel--bordered dashboard-logs"},s.default.createElement("div",{className:"semiont-panel-header"},s.default.createElement("span",{className:"semiont-panel-header__title"},"Recent Logs")),n.length===0?s.default.createElement("div",{className:"logs-empty"},"No recent logs"):s.default.createElement("div",{className:"logs-list"},n.slice(0,50).map((a,o)=>s.default.createElement("div",{key:o,className:`log-entry log-entry--${a.level}`},s.default.createElement("span",{className:"log-timestamp"},new Date(a.timestamp).toLocaleTimeString()),s.default.createElement("span",{className:"log-service"},a.service),s.default.createElement("span",{className:`log-level semiont-badge semiont-badge--${a.level==="error"?"error":a.level==="warn"?"warning":"info"}`},s.default.createElement("span",{className:"semiont-badge__text"},a.level.toUpperCase())),s.default.createElement("span",{className:"log-message"},a.message)))))},Le=({active:e,onChange:t,webHealthy:n,webTotal:a,mmHealthy:o,mmTotal:p,wkHealthy:v,wkTotal:D})=>{let A=[{id:"make-meaning",label:"Make Meaning",healthy:o,total:p},{id:"workers",label:"Workers",healthy:v,total:D},{id:"web",label:"Web Interface",healthy:n,total:a}];function w(c,k){return k===0?"semiont-badge semiont-badge--info":c===k?"semiont-badge semiont-badge--success":c===0?"semiont-badge semiont-badge--error":"semiont-badge semiont-badge--warning"}return s.default.createElement("div",{className:"dashboard-tabs"},A.map(c=>s.default.createElement("button",{key:c.id,className:`dashboard-tab${e===c.id?" dashboard-tab--active":""}`,onClick:()=>t(c.id)},c.label,s.default.createElement("span",{className:w(c.healthy,c.total)},s.default.createElement("span",{className:"semiont-badge__text"},c.healthy,"/",c.total)))))},P=({time:e,label:t})=>s.default.createElement("span",{className:"tab-update-time"},t,": ",e?e.toLocaleTimeString():"\u2014"),q=({environment:e})=>{let[t,n]=(0,s.useState)("make-meaning"),[a,o]=(0,s.useState)([]),[p,v]=(0,s.useState)([]),[D,A]=(0,s.useState)(null),[w,c]=(0,s.useState)(Me),[k,E]=(0,s.useState)(null),[I,J]=(0,s.useState)([]),[Q,X]=(0,s.useState)(null),[W,$]=(0,s.useState)(!1),[x,z]=(0,s.useState)(!1);if((0,s.useEffect)(()=>{let m=window.io;if(!m){console.error("Socket.IO not loaded");return}let h=m();return h.on("connect",()=>$(!0)),h.on("disconnect",()=>$(!1)),h.on("services-update",u=>{o(u.services),v(u.logs),A(new Date),z(!0)}),h.on("make-meaning-update",u=>{let{lastUpdate:_,...te}=u;c(te),E(_?new Date(_):new Date)}),h.on("actors-update",u=>{c(_=>({..._,actors:u.actors})),u.lastUpdate&&E(new Date(u.lastUpdate))}),h.on("workers-update",u=>{J(u.workers),X(u.lastUpdate?new Date(u.lastUpdate):new Date),x||z(!0)}),()=>h.disconnect()},[]),!x)return s.default.createElement("div",{className:"dashboard-container"},s.default.createElement("div",{className:"dashboard-loading"},s.default.createElement("div",{className:"semiont-spinner"})));let C=a.find(m=>m.name.toLowerCase()==="graph"),l=C?{...w,graph:{...w.graph,status:C.status==="healthy"?"healthy":C.status==="unhealthy"?"unhealthy":"unknown",evidence:C.evidence}}:w,Y=new Set(["graph","neo4j","janusgraph","neptune"]),B=a.filter(m=>m.name.toLowerCase().startsWith("inference.")),G=a.filter(m=>!Y.has(m.name.toLowerCase())&&!m.name.toLowerCase().startsWith("inference.")),Z=G.filter(m=>m.status==="healthy").length,R=[l.eventLog.eventCount!==void 0,l.contentStore.fileCount!==void 0,l.graph.status==="healthy",l.materializedViews.fileCount!==void 0,l.actors.gatherer.state!=="error"&&l.actors.gatherer.state!=="unknown",l.actors.matcher.state!=="error"&&l.actors.matcher.state!=="unknown",l.actors.stower.state!=="error"&&l.actors.stower.state!=="unknown",l.actors.browser.state!=="error"&&l.actors.browser.state!=="unknown"].filter(Boolean).length,ee=I.filter(m=>m.state!=="error").length;return s.default.createElement("div",{className:"dashboard-container"},s.default.createElement("header",{className:"dashboard-header semiont-panel semiont-panel--bordered"},s.default.createElement("div",{className:"dashboard-header-left"},s.default.createElement("h1",{className:"dashboard-title"},"Semiont Dashboard"),s.default.createElement("span",{className:"semiont-badge semiont-badge--info dashboard-env"},s.default.createElement("span",{className:"semiont-badge__text"},e))),s.default.createElement("div",{className:"dashboard-header-right"},s.default.createElement("span",{className:`semiont-indicator ${W?"semiont-indicator--online":"semiont-indicator--offline"}`}),s.default.createElement("span",{className:"dashboard-connection-label"},W?"Live":"Disconnected"))),s.default.createElement("div",{className:"semiont-panel semiont-panel--bordered dashboard-tab-panel"},s.default.createElement(Le,{active:t,onChange:n,webHealthy:Z,webTotal:G.length,mmHealthy:R,mmTotal:8,wkHealthy:ee,wkTotal:I.length}),s.default.createElement("div",{className:"tab-content"},t==="web"&&s.default.createElement(s.default.Fragment,null,s.default.createElement("div",{className:"tab-meta"},s.default.createElement(P,{time:D,label:"updated"})),s.default.createElement(H,{services:a}),s.default.createElement(U,{logs:p})),t==="make-meaning"&&s.default.createElement(s.default.Fragment,null,s.default.createElement("div",{className:"tab-meta"},s.default.createElement(P,{time:k,label:"updated"})),s.default.createElement(O,{makeMeaning:l,inferenceServices:B}),s.default.createElement(U,{logs:[]})),t==="workers"&&s.default.createElement(s.default.Fragment,null,s.default.createElement("div",{className:"tab-meta"},s.default.createElement(P,{time:Q,label:"updated"})),s.default.createElement(K,{workers:I,inferenceServices:B}),s.default.createElement(U,{logs:[]})))))};typeof window<"u"&&(window.SemiontDashboard=window.SemiontDashboard||{},window.SemiontDashboard.WebDashboardApp=q);return ce(De);})();
// Ensure global is set
if (typeof window !== "undefined") { window.SemiontDashboard = SemiontDashboard; }
//# sourceMappingURL=dashboard.js.map
