function App(){const[e,s]=useTweaks(window.TWEAK_DEFAULTS),[c,l]=useState({alerts:1,workspaceBadges:{ops:1,marketing:1,personal:3},suggestionFor:null,suggestionsDismissed:{}}),[V,N]=useState([{id:"tk-1",label:"Run podcast pipeline \xB7 2026-05-27",meta:"stage 3 of 5 \xB7 gen-agt",status:"running",progress:64},{id:"tk-2",label:"Enrich Acme Dynamics inbound",meta:"sales-agt \xB7 4 sources",status:"running",progress:32},{id:"tk-3",label:"Replay Postiz syndication \xB7 05-27",meta:"awaiting OpenRouter quota",status:"warn",progress:0}]);function L(){const t=(window.location.hash||"").replace(/^#/,"");if(!t)return null;const[n,o]=t.split("/");if(!window.STREAMS[n])return null;const d=window.STREAMS[n],a=d.subPages.some(w=>w.id===o);return{stream:n,subPage:a?o:d.subPages[0].id}}const x=L()||(e.opsMode?{stream:"podcast",subPage:"overview"}:{stream:"personal",subPage:"inbox"}),[i,z]=useState(x),[p,E]=useState(()=>{const t=(window.location.hash||"").replace(/^#/,"").split("/"),n=t[0],o=window.__LAZY_MANIFEST__;return n&&o&&o[n]&&!(window.STREAMS&&window.STREAMS[n])?{stream:n,sub:t[1]||null}:null});useEffect(()=>{let t=!1;const n=window.CANVAS_ACTIONS;if(!(!n||typeof n.getOnboardingStatus!="function"))return n.getOnboardingStatus().then(o=>{t||!o||o.stage&&typeof o.onboardingStep=="number"&&s("onboardingStep",o.onboardingStep)}),()=>{t=!0}},[]),useEffect(()=>{window.NAV={go:(t,n)=>{if(!window.STREAMS[t])return;const o=window.STREAMS[t],d=n&&o.subPages.some(a=>a.id===n)?n:o.subPages[0].id;z({stream:t,subPage:d}),window.location.hash=`${t}/${d}`}}},[]),useEffect(()=>{const t=`${i.stream}/${i.subPage}`;(window.location.hash||"").replace(/^#/,"")!==t&&history.replaceState(null,"","#"+t)},[i]),useEffect(()=>{const t=window.__LAZY_MANIFEST__;if(t&&window.NAV&&typeof window.NAV.go=="function"&&typeof window.__lazyLoadStream=="function"&&!window.NAV.go.__lazyWrapped){const o=window.NAV.go,d=(a,w)=>{const Y=window.__lazyLoaded&&window.__lazyLoaded[a];if(!window.STREAMS[a]&&t[a]&&!Y){window.location.hash=w?`${a}/${w}`:a,window.__lazyLoadStream(a,()=>{window.dispatchEvent(new CustomEvent("lazy-stream-loaded",{detail:{streamId:a}}))});return}o(a,w)};d.__lazyWrapped=!0,window.NAV.go=d}function n(o){const d=o&&o.detail&&o.detail.streamId;if(!d||!window.STREAMS[d])return;const w=(window.location.hash||"").replace(/^#/,"").split("/");w[0]===d&&window.NAV.go(d,w[1])}return window.addEventListener("lazy-stream-loaded",n),()=>window.removeEventListener("lazy-stream-loaded",n)},[]),useEffect(()=>{if(!p)return;let t=!1,n=45;const o=()=>{if(!t){if(window.STREAMS&&window.STREAMS[p.stream]){window.NAV&&typeof window.NAV.go=="function"&&window.NAV.go(p.stream,p.sub),E(null);return}if(n--<=0){E(null);return}setTimeout(o,30)}};return o(),()=>{t=!0}},[p]);const[I,_]=useState({}),f=`${i.stream}/${i.subPage}`,[B,y]=useState(!1),[D,M]=useState(!1);useEffect(()=>{window.applyTenant(e.tenant,e.tokenOverrides||{},e.theme)},[e.tenant,e.tokenOverrides,e.theme]),useEffect(()=>{document.body.dataset.reducedMotion=e.reducedMotion?"1":"0",document.documentElement.style.setProperty("--app-density",e.density)},[e.reducedMotion,e.density]),useEffect(()=>{if(typeof e.onboardingStep=="number"&&e.onboardingStep<6){(i.subPage!=="onboarding"||i.stream!=="personal")&&window.NAV.go("personal","onboarding");return}if(!e.opsMode&&i.stream!=="personal"&&window.NAV.go("personal","inbox"),e.opsMode&&i.stream==="personal"){const t=window.visibleOpsStreams&&window.visibleOpsStreams(e.role)||["podcast"];window.NAV.go(t[0]||"podcast","overview")}},[e.opsMode,e.onboardingStep]),useEffect(()=>{if(!e.opsMode)return;const t=window.visibleOpsStreams&&window.visibleOpsStreams(e.role)||[];if(!t.includes(i.stream))window.NAV.go(t[0]||"podcast",null);else{const n=window.visibleSubPages&&window.visibleSubPages(i.stream,e.role)||[];n.length&&!n.some(o=>o.id===i.subPage)&&window.NAV.go(i.stream,n[0].id)}},[e.role]),useEffect(()=>{const t={"product/sales":{text:"Records benefit from split detail \u2014 keeps the deal context visible.",apply:()=>s("detail","split")},"product/threads":{text:"Threads feel right in split detail.",apply:()=>s("detail","split")},"ops/overview":{text:"Dashboards drop the drawer. Set detail \u2192 none.",apply:()=>s("detail","none")},"platform/integrations":{text:"Tile grids work best when detail opens as a drawer (default).",apply:()=>s("detail","drawer")}},n=`${i.stream}/${i.subPage}`,o=t[n];if(!o||c.suggestionsDismissed[n]){l(a=>({...a,suggestionFor:null}));return}const d=setTimeout(()=>{l(a=>({...a,suggestionFor:{key:n,...o}}))},1100);return()=>clearTimeout(d)},[i.stream,i.subPage,c.suggestionsDismissed]);function F(){const t=c.suggestionFor;t&&(t.apply(),l(n=>({...n,suggestionFor:null,suggestionsDismissed:{...n.suggestionsDismissed,[t.key]:!0}})))}function $(){const t=c.suggestionFor;t&&l(n=>({...n,suggestionFor:null,suggestionsDismissed:{...n.suggestionsDismissed,[t.key]:!0}}))}function C(t){s({tenant:t,solution:null})}function W(t){s("solution",t)}const v=typeof e.solution=="string"&&e.solution?e.solution:null;window.__SCOPE_CONTEXT={tenant:e.tenant,solution:v},useEffect(()=>{window.dispatchEvent(new CustomEvent("scopechange",{detail:{tenant:e.tenant,solution:v}}))},[e.tenant,v]);const k=window.resolveKind(i.stream,i.subPage,{tenant:e.tenant,solution:v}),b=k.stream,P=k.subPage,r=k.kind;function T(t,n){return e.respectKindDefaults&&e[t]==="auto"||e[t]==="auto"?n:e[t]}const S={view:T("view",r.defaultView),detail:T("detail",r.defaultDetail),agentPresence:T("agentPresence",r.agentTreatment)},O=r.mockItems||[],R=I[f],g=O.find(t=>t.id===R)||null;function G(t){_(n=>({...n,[f]:n[f]===t?null:t}))}function m(){_(t=>({...t,[f]:null}))}useEffect(()=>{const t=()=>y(!0);return document.addEventListener("palette-open",t),()=>document.removeEventListener("palette-open",t)},[]);function K(t){N(t==="_all"?[]:n=>n.filter(o=>o.id!==t))}if(window.__decisionsCritiqueExpanded=e.critiqueExpanded,window.__decisionsTraceSchema=e.traceSchema,window.__decisionsRunStatus=e.runStatus,window.__opsMode=e.opsMode,window.__domainAccentOn=e.domainAccent!==!1,window.__theme=e.theme||"dark",window.__authenticated=e.authenticated!==!1,window.__onboardingStep=typeof e.onboardingStep=="number"?e.onboardingStep:6,window.__filterRailByServices=e.filterRailByServices===!0,window.__setTweak=s,typeof document<"u"&&document.body.setAttribute("data-theme",e.theme||"dark"),p&&!(window.STREAMS&&window.STREAMS[p.stream]))return React.createElement("div",{className:"app lazy-boot","data-tenant":e.tenant,"aria-busy":"true"},React.createElement("div",{style:{position:"fixed",inset:0,display:"flex",alignItems:"center",justifyContent:"center"}},React.createElement("div",{className:"lazy-boot-spinner",role:"status","aria-label":"Loading view"})),React.createElement("style",null,".lazy-boot-spinner{width:28px;height:28px;border-radius:50%;border:3px solid rgba(127,127,127,.25);border-top-color:rgba(127,127,127,.9);animation:lazyBootSpin .7s linear infinite}@keyframes lazyBootSpin{to{transform:rotate(360deg)}}"));const H=window.VIEWS[S.view]||window.VIEWS.table,q=(e.showRoster||e.showActivity)&&b.id!=="personal",u=S.detail,A=u==="none"||P.kind==="placeholder"||["streamOverview","dashboard","placeholder","financeForm","financeEur","financeCredits","decisionTimeline","brandbook","markdownPreview","treeView","diffView","auditLog","killSwitch","chartFunnel","chartCohort","promptDiff","codeEditor","domainsHub","articleReader","videoPlayer","podcastPlayer","templateBrowser","imageGallery","marketplaceListing","forumThread","designGallery","emailPreview","pagePreview","socialBoard","bannerBoard","posterBoard","deckBoard","videoBoard","servicesGrid","onboardingWizard","dailyPicks","builderWorkshop","ceuWizard","entityOverview","visualBuilder","supportChat","replaysList","flowEditor","impersonateConsole","entityGraph","vaultLibrary","megadocStatus","unifiedAsk","picsApp","diyApp","promptLibrary","agentCatalog","closeoutBoard"].includes(S.view),h=!A&&!!g&&(u==="drawer"||u==="split"||u==="stack"||u==="tab"),U=c.suggestionFor&&c.suggestionFor.key===f?c.suggestionFor:null;return React.createElement("div",{className:"app","data-tenant":e.tenant},React.createElement(GlobalHeartbeat,{prefs:{heartbeat:e.heartbeat},context:c}),React.createElement(TopBar,{tenant:{id:e.tenant,...window.TENANTS[e.tenant]},onTenantChange:C,solution:v,onSolutionChange:W,prefs:e,setTweak:s,opsMode:e.opsMode,setOpsMode:t=>s("opsMode",t),onOpenPalette:()=>y(!0),role:e.role,onRoleChange:t=>s("role",t),theme:e.theme||"dark",onToggleTheme:()=>s("theme",e.theme==="light"?"dark":"light"),authenticated:e.authenticated!==!1,onLogin:()=>s("authenticated",!0),onLogout:()=>s("authenticated",!1),onOpenMegaMenu:()=>M(!0)}),React.createElement("div",{className:"main-grid"},React.createElement(StreamRail,{active:i.stream,onSelect:t=>window.NAV.go(t,null),collapsed:e.railCollapsed,onCollapse:()=>s("railCollapsed",!e.railCollapsed),opsMode:e.opsMode,context:c,role:e.role}),React.createElement("main",{className:"canvas"},React.createElement(SubNav,{stream:b,activeSub:i.subPage,onSelectSub:t=>window.NAV.go(b.id,t),role:e.role}),React.createElement("div",{className:"canvas-scroll"},b.id==="finances"&&e.adminBridge!=="ok"&&React.createElement(BridgeStatusBanner,{state:e.adminBridge,role:e.role}),React.createElement(HeroPanel,{kind:r,prefs:e,onPrimary:()=>{},onSuggestion:t=>t===null?$():F(),contextSuggestion:U}),r.heroKpis&&r.heroKpis.length>0&&React.createElement(KpiStrip,{kind:r,prefs:{heartbeat:e.heartbeat}}),React.createElement("div",{className:`work-region detail-${u} ${h?"detail-open":""}`},!A&&r.schema&&r.schema.length>0&&React.createElement(ViewToolbar,{kind:r,effective:S,setTweak:s}),React.createElement("div",{className:"work-list"},React.createElement(H,{kind:r,items:O,onSelect:G,selectedId:R,contextStream:b,contextSubPage:P})),u==="split"&&h&&React.createElement("div",{className:"detail-split"},React.createElement(DetailContent,{item:g,kind:r,onClose:m,embedded:!0})),u==="tab"&&h&&React.createElement("div",{className:"detail-tab"},React.createElement("div",{className:"detail-tab-bar"},React.createElement("span",{className:"detail-tab-chip"},React.createElement("span",{className:"mono"},g.id),React.createElement("button",{onClick:m},React.createElement(MIcon,{name:"close",size:12})))),React.createElement(DetailContent,{item:g,kind:r,onClose:m,embedded:!0})),u==="stack"&&h&&React.createElement("div",{className:"detail-stack",onClick:t=>{t.target.classList.contains("detail-stack")&&m()}},React.createElement("div",{className:"detail-stack-card"},React.createElement(DetailContent,{item:g,kind:r,onClose:m,embedded:!1})))))),q&&React.createElement("aside",{className:`right-panels${e.rosterOpen?"":" roster-collapsed"}`},React.createElement(AgentRoster,{visible:e.showRoster,open:e.rosterOpen,onToggle:()=>s("rosterOpen",!e.rosterOpen)}),React.createElement(ActivityFeed,{visible:e.showActivity}))),u==="drawer"&&!A&&React.createElement(Drawer,{open:h,item:g,kind:r,onClose:m}),React.createElement(TasksTray,{tasks:V,onDismiss:K,visible:e.showTasksTray}),window.ServiceUnlockModal?React.createElement(window.ServiceUnlockModal,null):null,window.AgentSupport?React.createElement(window.AgentSupport,null):null,React.createElement(MegaMenu,{open:D,onClose:()=>M(!1),streams:window.STREAMS,role:e.role,onPick:t=>window.NAV.go(t,null),theme:e.theme||"dark",authenticated:e.authenticated!==!1,onLogin:()=>s("authenticated",!0),onToggleTheme:()=>s("theme",e.theme==="light"?"dark":"light")}),React.createElement(CommandPalette,{open:B,onClose:()=>y(!1),prefs:e,setTweak:s,onTenantChange:C,kinds:window.KIND_REGISTRY,activeWorkspace:i.stream,onNav:(t,n)=>window.NAV.go(t,n)}),React.createElement(MainTweaks,{t:e,setTweak:s}))}function ViewToolbar({kind:e,effective:s,setTweak:c}){return React.createElement("div",{className:"view-toolbar"},React.createElement("div",{className:"vt-left"},React.createElement("span",{className:"vt-label mono"},e.label," \xB7 ",e.mockItems.length,e.moreCount?` (+${e.moreCount} more)`:"")),React.createElement("div",{className:"vt-right"},React.createElement("div",{className:"vt-views"},window.VIEW_OPTIONS.filter(l=>!["streamOverview","placeholder"].includes(l.value)).map(l=>React.createElement("button",{key:l.value,className:`vt-view ${s.view===l.value?"on":""}`,title:`View \u2192 ${l.label}`,onClick:()=>c("view",l.value)},React.createElement(MIcon,{name:l.icon,size:14})))),React.createElement("button",{className:"vt-aux"},React.createElement(MIcon,{name:"filter_list",size:16})),React.createElement("button",{className:"vt-aux"},React.createElement(MIcon,{name:"sort",size:16}))))}ReactDOM.createRoot(document.getElementById("root")).render(React.createElement(App,null));
