/home/techb158/balavpn.abdallabala.com/.next/server/app/dashboard
Edit: /home/techb158/balavpn.abdallabala.com/.next/server/app/dashboard/page.js (68755B)
(()=>{var a={};a.id=5105,a.ids=[5105],a.modules={261:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/app-paths")},3295:a=>{"use strict";a.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},9610:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>d});let d=(0,c(97954).registerClientReference)(function(){throw Error("Attempted to call the default export of \"C:\\\\Users\\\\abd_b\\\\OneDrive\\\\Desktop\\\\COSMIC AI-Risk Dashboard\\\\Step 12 is complete Final QA, Demo Readiness, and Submission Freeze\\\\application\\\\saas-app\\\\src\\\\app\\\\dashboard\\\\page.jsx\" from the server, but it's on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"C:\\Users\\abd_b\\OneDrive\\Desktop\\COSMIC AI-Risk Dashboard\\Step 12 is complete Final QA, Demo Readiness, and Submission Freeze\\application\\saas-app\\src\\app\\dashboard\\page.jsx","default")},10846:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},19108:(a,b,c)=>{"use strict";c.r(b),c.d(b,{GlobalError:()=>E.a,__next_app__:()=>K,handler:()=>M,pages:()=>J,routeModule:()=>L,tree:()=>I});var d=c(49754),e=c(9117),f=c(46595),g=c(32324),h=c(39326),i=c(38928),j=c(20175),k=c(12),l=c(54290),m=c(12696),n=c(52574),o=c(82802),p=c(77533),q=c(45229),r=c(32822),s=c(261),t=c(26453),u=c(52474),v=c(26713),w=c(51356),x=c(62685),y=c(36225),z=c(63446),A=c(2762),B=c(45742),C=c(86439),D=c(81170),E=c.n(D),F=c(62506),G=c(91203),H={};for(let a in F)0>["default","tree","pages","GlobalError","__next_app__","routeModule","handler"].indexOf(a)&&(H[a]=()=>F[a]);c.d(b,H);let I={children:["",{children:["dashboard",{children:["__PAGE__",{},{page:[()=>Promise.resolve().then(c.bind(c,9610)),"C:\\Users\\abd_b\\OneDrive\\Desktop\\COSMIC AI-Risk Dashboard\\Step 12 is complete Final QA, Demo Readiness, and Submission Freeze\\application\\saas-app\\src\\app\\dashboard\\page.jsx"]}]},{layout:[()=>Promise.resolve().then(c.bind(c,87513)),"C:\\Users\\abd_b\\OneDrive\\Desktop\\COSMIC AI-Risk Dashboard\\Step 12 is complete Final QA, Demo Readiness, and Submission Freeze\\application\\saas-app\\src\\app\\dashboard\\layout.jsx"]}]},{layout:[()=>Promise.resolve().then(c.bind(c,61662)),"C:\\Users\\abd_b\\OneDrive\\Desktop\\COSMIC AI-Risk Dashboard\\Step 12 is complete Final QA, Demo Readiness, and Submission Freeze\\application\\saas-app\\src\\app\\layout.jsx"],"global-error":[()=>Promise.resolve().then(c.t.bind(c,81170,23)),"next/dist/client/components/builtin/global-error.js"],"not-found":[()=>Promise.resolve().then(c.t.bind(c,87028,23)),"next/dist/client/components/builtin/not-found.js"],forbidden:[()=>Promise.resolve().then(c.t.bind(c,90461,23)),"next/dist/client/components/builtin/forbidden.js"],unauthorized:[()=>Promise.resolve().then(c.t.bind(c,32768,23)),"next/dist/client/components/builtin/unauthorized.js"]}]}.children,J=["C:\\Users\\abd_b\\OneDrive\\Desktop\\COSMIC AI-Risk Dashboard\\Step 12 is complete Final QA, Demo Readiness, and Submission Freeze\\application\\saas-app\\src\\app\\dashboard\\page.jsx"],K={require:c,loadChunk:()=>Promise.resolve()},L=new d.AppPageRouteModule({definition:{kind:e.RouteKind.APP_PAGE,page:"/dashboard/page",pathname:"/dashboard",bundlePath:"",filename:"",appPaths:[]},userland:{loaderTree:I},distDir:".next",relativeProjectDir:""});async function M(a,b,d){var D;let H="/dashboard/page";"/index"===H&&(H="/");let N=(0,h.getRequestMeta)(a,"postponed"),O=(0,h.getRequestMeta)(a,"minimalMode"),P=await L.prepare(a,b,{srcPage:H,multiZoneDraftMode:!1});if(!P)return b.statusCode=400,b.end("Bad Request"),null==d.waitUntil||d.waitUntil.call(d,Promise.resolve()),null;let{buildId:Q,query:R,params:S,parsedUrl:T,pageIsDynamic:U,buildManifest:V,nextFontManifest:W,reactLoadableManifest:X,serverActionsManifest:Y,clientReferenceManifest:Z,subresourceIntegrityManifest:$,prerenderManifest:_,isDraftMode:aa,resolvedPathname:ab,revalidateOnlyGenerated:ac,routerServerContext:ad,nextConfig:ae,interceptionRoutePatterns:af}=P,ag=T.pathname||"/",ah=(0,s.normalizeAppPath)(H),{isOnDemandRevalidate:ai}=P,aj=L.match(ag,_),ak=!!_.routes[ab],al=!!(aj||ak||_.routes[ah]),am=a.headers["user-agent"]||"",an=(0,v.getBotType)(am),ao=(0,q.isHtmlBotRequest)(a),ap=(0,h.getRequestMeta)(a,"isPrefetchRSCRequest")??"1"===a.headers[u.NEXT_ROUTER_PREFETCH_HEADER],aq=(0,h.getRequestMeta)(a,"isRSCRequest")??(0,n.f)(a.headers[u.RSC_HEADER]),ar=(0,t.getIsPossibleServerAction)(a),as=(0,m.checkIsAppPPREnabled)(ae.experimental.ppr)&&(null==(D=_.routes[ah]??_.dynamicRoutes[ah])?void 0:D.renderingMode)==="PARTIALLY_STATIC",at=!1,au=!1,av=as?N:void 0,aw=as&&aq&&!ap,ax=(0,h.getRequestMeta)(a,"segmentPrefetchRSCRequest"),ay=!am||(0,q.shouldServeStreamingMetadata)(am,ae.htmlLimitedBots);ao&&as&&(al=!1,ay=!1);let az=!0===L.isDev||!al||"string"==typeof N||aw,aA=ao&&as,aB=null;aa||!al||az||ar||av||aw||(aB=ab);let aC=aB;!aC&&L.isDev&&(aC=ab),L.isDev||aa||!al||!aq||aw||(0,k.d)(a.headers);let aD={...F,tree:I,pages:J,GlobalError:E(),handler:M,routeModule:L,__next_app__:K};Y&&Z&&(0,p.setReferenceManifestsSingleton)({page:H,clientReferenceManifest:Z,serverActionsManifest:Y,serverModuleMap:(0,r.createServerModuleMap)({serverActionsManifest:Y})});let aE=a.method||"GET",aF=(0,g.getTracer)(),aG=aF.getActiveScopeSpan();try{let f=L.getVaryHeader(ab,af);b.setHeader("Vary",f);let k=async(c,d)=>{let e=new l.NodeNextRequest(a),f=new l.NodeNextResponse(b);return L.render(e,f,d).finally(()=>{if(!c)return;c.setAttributes({"http.status_code":b.statusCode,"next.rsc":!1});let d=aF.getRootSpanAttributes();if(!d)return;if(d.get("next.span_type")!==i.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${d.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let e=d.get("next.route");if(e){let a=`${aE} ${e}`;c.setAttributes({"next.route":e,"http.route":e,"next.span_name":a}),c.updateName(a)}else c.updateName(`${aE} ${a.url}`)})},m=async({span:e,postponed:f,fallbackRouteParams:g})=>{let i={query:R,params:S,page:ah,sharedContext:{buildId:Q},serverComponentsHmrCache:(0,h.getRequestMeta)(a,"serverComponentsHmrCache"),fallbackRouteParams:g,renderOpts:{App:()=>null,Document:()=>null,pageConfig:{},ComponentMod:aD,Component:(0,j.T)(aD),params:S,routeModule:L,page:H,postponed:f,shouldWaitOnAllReady:aA,serveStreamingMetadata:ay,supportsDynamicResponse:"string"==typeof f||az,buildManifest:V,nextFontManifest:W,reactLoadableManifest:X,subresourceIntegrityManifest:$,serverActionsManifest:Y,clientReferenceManifest:Z,setIsrStatus:null==ad?void 0:ad.setIsrStatus,dir:c(33873).join(process.cwd(),L.relativeProjectDir),isDraftMode:aa,isRevalidate:al&&!f&&!aw,botType:an,isOnDemandRevalidate:ai,isPossibleServerAction:ar,assetPrefix:ae.assetPrefix,nextConfigOutput:ae.output,crossOrigin:ae.crossOrigin,trailingSlash:ae.trailingSlash,previewProps:_.preview,deploymentId:ae.deploymentId,enableTainting:ae.experimental.taint,htmlLimitedBots:ae.htmlLimitedBots,devtoolSegmentExplorer:ae.experimental.devtoolSegmentExplorer,reactMaxHeadersLength:ae.reactMaxHeadersLength,multiZoneDraftMode:!1,incrementalCache:(0,h.getRequestMeta)(a,"incrementalCache"),cacheLifeProfiles:ae.experimental.cacheLife,basePath:ae.basePath,serverActions:ae.experimental.serverActions,...at?{nextExport:!0,supportsDynamicResponse:!1,isStaticGeneration:!0,isRevalidate:!0,isDebugDynamicAccesses:at}:{},experimental:{isRoutePPREnabled:as,expireTime:ae.expireTime,staleTimes:ae.experimental.staleTimes,cacheComponents:!!ae.experimental.cacheComponents,clientSegmentCache:!!ae.experimental.clientSegmentCache,clientParamParsing:!!ae.experimental.clientParamParsing,dynamicOnHover:!!ae.experimental.dynamicOnHover,inlineCss:!!ae.experimental.inlineCss,authInterrupts:!!ae.experimental.authInterrupts,clientTraceMetadata:ae.experimental.clientTraceMetadata||[]},waitUntil:d.waitUntil,onClose:a=>{b.on("close",a)},onAfterTaskError:()=>{},onInstrumentationRequestError:(b,c,d)=>L.onRequestError(a,b,d,ad),err:(0,h.getRequestMeta)(a,"invokeError"),dev:L.isDev}},l=await k(e,i),{metadata:m}=l,{cacheControl:n,headers:o={},fetchTags:p}=m;if(p&&(o[z.NEXT_CACHE_TAGS_HEADER]=p),a.fetchMetrics=m.fetchMetrics,al&&(null==n?void 0:n.revalidate)===0&&!L.isDev&&!as){let a=m.staticBailoutInfo,b=Object.defineProperty(Error(`Page changed from static to dynamic at runtime ${ab}${(null==a?void 0:a.description)?`, reason: ${a.description}`:""}
see more here https://nextjs.org/docs/messages/app-static-to-dynamic-error`),"__NEXT_ERROR_CODE",{value:"E132",enumerable:!1,configurable:!0});if(null==a?void 0:a.stack){let c=a.stack;b.stack=b.message+c.substring(c.indexOf("\n"))}throw b}return{value:{kind:w.CachedRouteKind.APP_PAGE,html:l,headers:o,rscData:m.flightData,postponed:m.postponed,status:m.statusCode,segmentData:m.segmentData},cacheControl:n}},n=async({hasResolved:c,previousCacheEntry:f,isRevalidating:g,span:i})=>{let j,k=!1===L.isDev,l=c||b.writableEnded;if(ai&&ac&&!f&&!O)return(null==ad?void 0:ad.render404)?await ad.render404(a,b):(b.statusCode=404,b.end("This page could not be found")),null;if(aj&&(j=(0,x.parseFallbackField)(aj.fallback)),j===x.FallbackMode.PRERENDER&&(0,v.isBot)(am)&&(!as||ao)&&(j=x.FallbackMode.BLOCKING_STATIC_RENDER),(null==f?void 0:f.isStale)===-1&&(ai=!0),ai&&(j!==x.FallbackMode.NOT_FOUND||f)&&(j=x.FallbackMode.BLOCKING_STATIC_RENDER),!O&&j!==x.FallbackMode.BLOCKING_STATIC_RENDER&&aC&&!l&&!aa&&U&&(k||!ak)){let b;if((k||aj)&&j===x.FallbackMode.NOT_FOUND)throw new C.NoFallbackError;if(as&&!aq){let c="string"==typeof(null==aj?void 0:aj.fallback)?aj.fallback:k?ah:null;if(b=await L.handleResponse({cacheKey:c,req:a,nextConfig:ae,routeKind:e.RouteKind.APP_PAGE,isFallback:!0,prerenderManifest:_,isRoutePPREnabled:as,responseGenerator:async()=>m({span:i,postponed:void 0,fallbackRouteParams:k||au?(0,o.u)(ah):null}),waitUntil:d.waitUntil}),null===b)return null;if(b)return delete b.cacheControl,b}}let n=ai||g||!av?void 0:av;if(at&&void 0!==n)return{cacheControl:{revalidate:1,expire:void 0},value:{kind:w.CachedRouteKind.PAGES,html:y.default.EMPTY,pageData:{},headers:void 0,status:void 0}};let p=U&&as&&((0,h.getRequestMeta)(a,"renderFallbackShell")||au)?(0,o.u)(ag):null;return m({span:i,postponed:n,fallbackRouteParams:p})},p=async c=>{var f,g,i,j,k;let l,o=await L.handleResponse({cacheKey:aB,responseGenerator:a=>n({span:c,...a}),routeKind:e.RouteKind.APP_PAGE,isOnDemandRevalidate:ai,isRoutePPREnabled:as,req:a,nextConfig:ae,prerenderManifest:_,waitUntil:d.waitUntil});if(aa&&b.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate"),L.isDev&&b.setHeader("Cache-Control","no-store, must-revalidate"),!o){if(aB)throw Object.defineProperty(Error("invariant: cache entry required but not generated"),"__NEXT_ERROR_CODE",{value:"E62",enumerable:!1,configurable:!0});return null}if((null==(f=o.value)?void 0:f.kind)!==w.CachedRouteKind.APP_PAGE)throw Object.defineProperty(Error(`Invariant app-page handler received invalid cache entry ${null==(i=o.value)?void 0:i.kind}`),"__NEXT_ERROR_CODE",{value:"E707",enumerable:!1,configurable:!0});let p="string"==typeof o.value.postponed;al&&!aw&&(!p||ap)&&(O||b.setHeader("x-nextjs-cache",ai?"REVALIDATED":o.isMiss?"MISS":o.isStale?"STALE":"HIT"),b.setHeader(u.NEXT_IS_PRERENDER_HEADER,"1"));let{value:q}=o;if(av)l={revalidate:0,expire:void 0};else if(O&&aq&&!ap&&as)l={revalidate:0,expire:void 0};else if(!L.isDev)if(aa)l={revalidate:0,expire:void 0};else if(al){if(o.cacheControl)if("number"==typeof o.cacheControl.revalidate){if(o.cacheControl.revalidate<1)throw Object.defineProperty(Error(`Invalid revalidate configuration provided: ${o.cacheControl.revalidate} < 1`),"__NEXT_ERROR_CODE",{value:"E22",enumerable:!1,configurable:!0});l={revalidate:o.cacheControl.revalidate,expire:(null==(j=o.cacheControl)?void 0:j.expire)??ae.expireTime}}else l={revalidate:z.CACHE_ONE_YEAR,expire:void 0}}else b.getHeader("Cache-Control")||(l={revalidate:0,expire:void 0});if(o.cacheControl=l,"string"==typeof ax&&(null==q?void 0:q.kind)===w.CachedRouteKind.APP_PAGE&&q.segmentData){b.setHeader(u.NEXT_DID_POSTPONE_HEADER,"2");let c=null==(k=q.headers)?void 0:k[z.NEXT_CACHE_TAGS_HEADER];O&&al&&c&&"string"==typeof c&&b.setHeader(z.NEXT_CACHE_TAGS_HEADER,c);let d=q.segmentData.get(ax);return void 0!==d?(0,B.sendRenderResult)({req:a,res:b,generateEtags:ae.generateEtags,poweredByHeader:ae.poweredByHeader,result:y.default.fromStatic(d,u.RSC_CONTENT_TYPE_HEADER),cacheControl:o.cacheControl}):(b.statusCode=204,(0,B.sendRenderResult)({req:a,res:b,generateEtags:ae.generateEtags,poweredByHeader:ae.poweredByHeader,result:y.default.EMPTY,cacheControl:o.cacheControl}))}let r=(0,h.getRequestMeta)(a,"onCacheEntry");if(r&&await r({...o,value:{...o.value,kind:"PAGE"}},{url:(0,h.getRequestMeta)(a,"initURL")}))return null;if(p&&av)throw Object.defineProperty(Error("Invariant: postponed state should not be present on a resume request"),"__NEXT_ERROR_CODE",{value:"E396",enumerable:!1,configurable:!0});if(q.headers){let a={...q.headers};for(let[c,d]of(O&&al||delete a[z.NEXT_CACHE_TAGS_HEADER],Object.entries(a)))if(void 0!==d)if(Array.isArray(d))for(let a of d)b.appendHeader(c,a);else"number"==typeof d&&(d=d.toString()),b.appendHeader(c,d)}let s=null==(g=q.headers)?void 0:g[z.NEXT_CACHE_TAGS_HEADER];if(O&&al&&s&&"string"==typeof s&&b.setHeader(z.NEXT_CACHE_TAGS_HEADER,s),!q.status||aq&&as||(b.statusCode=q.status),!O&&q.status&&G.RedirectStatusCode[q.status]&&aq&&(b.statusCode=200),p&&b.setHeader(u.NEXT_DID_POSTPONE_HEADER,"1"),aq&&!aa){if(void 0===q.rscData){if(q.postponed)throw Object.defineProperty(Error("Invariant: Expected postponed to be undefined"),"__NEXT_ERROR_CODE",{value:"E372",enumerable:!1,configurable:!0});return(0,B.sendRenderResult)({req:a,res:b,generateEtags:ae.generateEtags,poweredByHeader:ae.poweredByHeader,result:q.html,cacheControl:aw?{revalidate:0,expire:void 0}:o.cacheControl})}return(0,B.sendRenderResult)({req:a,res:b,generateEtags:ae.generateEtags,poweredByHeader:ae.poweredByHeader,result:y.default.fromStatic(q.rscData,u.RSC_CONTENT_TYPE_HEADER),cacheControl:o.cacheControl})}let t=q.html;if(!p||O||aq)return(0,B.sendRenderResult)({req:a,res:b,generateEtags:ae.generateEtags,poweredByHeader:ae.poweredByHeader,result:t,cacheControl:o.cacheControl});if(at)return t.push(new ReadableStream({start(a){a.enqueue(A.ENCODED_TAGS.CLOSED.BODY_AND_HTML),a.close()}})),(0,B.sendRenderResult)({req:a,res:b,generateEtags:ae.generateEtags,poweredByHeader:ae.poweredByHeader,result:t,cacheControl:{revalidate:0,expire:void 0}});let v=new TransformStream;return t.push(v.readable),m({span:c,postponed:q.postponed,fallbackRouteParams:null}).then(async a=>{var b,c;if(!a)throw Object.defineProperty(Error("Invariant: expected a result to be returned"),"__NEXT_ERROR_CODE",{value:"E463",enumerable:!1,configurable:!0});if((null==(b=a.value)?void 0:b.kind)!==w.CachedRouteKind.APP_PAGE)throw Object.defineProperty(Error(`Invariant: expected a page response, got ${null==(c=a.value)?void 0:c.kind}`),"__NEXT_ERROR_CODE",{value:"E305",enumerable:!1,configurable:!0});await a.value.html.pipeTo(v.writable)}).catch(a=>{v.writable.abort(a).catch(a=>{console.error("couldn't abort transformer",a)})}),(0,B.sendRenderResult)({req:a,res:b,generateEtags:ae.generateEtags,poweredByHeader:ae.poweredByHeader,result:t,cacheControl:{revalidate:0,expire:void 0}})};if(!aG)return await aF.withPropagatedContext(a.headers,()=>aF.trace(i.BaseServerSpan.handleRequest,{spanName:`${aE} ${a.url}`,kind:g.SpanKind.SERVER,attributes:{"http.method":aE,"http.target":a.url}},p));await p(aG)}catch(b){throw b instanceof C.NoFallbackError||await L.onRequestError(a,b,{routerKind:"App Router",routePath:H,routeType:"render",revalidateReason:(0,f.c)({isRevalidate:al,isOnDemandRevalidate:ai})},ad),b}}},19121:a=>{"use strict";a.exports=require("next/dist/server/app-render/action-async-storage.external.js")},19672:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>I});var d=c(21124),e=c(38301),f=c(42378),g=c(84194);class h extends e.Component{constructor(a){super(a),this.state={error:null}}static getDerivedStateFromError(a){return{error:a}}render(){if(this.state.error){let{fallback:a}=this.props;return a?"function"==typeof a?a(this.state.error):a:(0,d.jsxs)("div",{className:"empty-state",children:[(0,d.jsx)("div",{className:"empty-icon",children:"!"}),(0,d.jsxs)("p",{children:["Something went wrong in ",this.props.name||"this section","."]}),(0,d.jsx)("p",{className:"muted",style:{fontSize:12,marginTop:4},children:this.state.error.message}),(0,d.jsx)("button",{className:"button secondary small",style:{marginTop:12},onClick:()=>{this.setState({error:null}),this.props.onRetry?.()},children:"Retry"})]})}return this.props.children}}let i=["Overview","Projects","Risks","Mitigations","Gate","Integrations","Audit"],j=["Technical","Governance","Legal","Ethical","Operational"],k=["Design","Development","Testing","Deployment"],l=["OPEN","IN_MITIGATION","ACCEPTED","CLOSED"],m=["NOT_STARTED","IN_PROGRESS","DONE","REJECTED"];function n({toasts:a}){return a.length?(0,d.jsx)("div",{className:"toast-container",children:a.map(a=>(0,d.jsx)("div",{className:`toast ${a.type}`,children:a.message},a.id))}):null}function o({value:a,onChange:b,placeholder:c}){return(0,d.jsxs)("div",{className:"search-wrap",children:[(0,d.jsx)("span",{className:"search-icon",children:"⌕"}),(0,d.jsx)("input",{className:"input",value:a,onChange:a=>b(a.target.value),placeholder:c||"Search..."})]})}function p(a,b,c){return b?[...a].sort((a,d)=>{let e=a[b],f=d[b];if(null==e)return 1;if(null==f)return -1;let g="number"==typeof e?e-f:String(e).localeCompare(String(f));return"asc"===c?g:-g}):a}function q({children:a,className:b}){return(0,d.jsx)("span",{className:`badge ${b||""}`,children:a})}function r({label:a,children:b}){return(0,d.jsxs)("div",{style:{marginBottom:10},children:[(0,d.jsx)("label",{style:{display:"block",fontSize:12,color:"var(--muted)",marginBottom:3},children:a}),b]})}function s({value:a,onChange:b,type:c="text",min:e,max:f,style:g}){return(0,d.jsx)("input",{className:"input",type:c,value:a,onChange:a=>b(a.target.value),min:e,max:f,style:{width:"100%",...g}})}function t({value:a,onChange:b,options:c}){return(0,d.jsxs)("select",{className:"input",value:a,onChange:a=>b(a.target.value),style:{width:"100%"},children:[(0,d.jsx)("option",{value:"",children:"— Select —"}),(c||[]).map(a=>{let b="object"==typeof a?a.value:a,c="object"==typeof a?a.label:a;return(0,d.jsx)("option",{value:b,children:c},b)})]})}function u({label:a,onConfirm:b,onCancel:c,deleting:e}){return(0,d.jsx)("div",{className:"modal-overlay",onClick:c,children:(0,d.jsxs)("div",{className:"modal",onClick:a=>a.stopPropagation(),style:{maxWidth:380},children:[(0,d.jsxs)("h3",{children:["Delete ",a,"?"]}),(0,d.jsx)("p",{style:{fontSize:13,color:"var(--muted)"},children:"This cannot be undone."}),(0,d.jsxs)("div",{className:"modal-actions",children:[(0,d.jsx)("button",{className:"button secondary small",onClick:c,children:"Cancel"}),(0,d.jsx)("button",{className:"button small",style:{background:"var(--danger)",color:"#fff"},onClick:b,disabled:e,children:e?"Deleting...":"Delete"})]})]})})}function v({project:a,dashboard:b}){let c=(0,e.useMemo)(()=>b?[{label:"Overall Score",value:b.summary?.overallScore??"-",cls:b.summary?.overallScore>=75?"bad":b.summary?.overallScore>=50?"warn":"good",sub:`Risk level: ${b.summary?.riskLevel||"-"}`},{label:"Deployment Gate",value:b.summary?.gateStatus??"-",cls:b.summary?.gateStatus==="Ready"?"good":b.summary?.gateStatus==="Warning"?"warn":"bad",sub:b.gate?.message||""},{label:"Open Risks",value:b.summary?.openRisks??0,cls:(b.summary?.openRisks||0)>5?"bad":(b.summary?.openRisks||0)>2?"warn":"good",sub:`${b.summary?.totalRisks||0} total risks`},{label:"Mitigation",value:`${b.summary?.mitigationCompletion??0}%`,cls:40>(b.summary?.mitigationCompletion||0)?"bad":70>(b.summary?.mitigationCompletion||0)?"warn":"good",sub:"Average active-risk completion"}]:[],[b]);return b?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{className:"grid",style:{gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))"},children:c.map(a=>(0,d.jsxs)("div",{className:"metric-card",children:[(0,d.jsx)("h3",{children:a.label}),(0,d.jsx)("div",{className:`metric-value ${a.cls}`,children:a.value}),(0,d.jsx)("div",{className:"metric-sub",children:a.sub})]},a.label))}),(0,d.jsxs)("div",{className:"grid",style:{gridTemplateColumns:"1fr 1fr",marginTop:18},children:[(0,d.jsxs)("div",{className:"panel",children:[(0,d.jsx)("h2",{children:"Dimensions"}),(b.dimensions||[]).map(a=>(0,d.jsxs)("div",{style:{marginBottom:12},children:[(0,d.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:4},children:[(0,d.jsx)("span",{style:{fontSize:13},children:a.name}),(0,d.jsx)("strong",{style:{fontSize:13},children:a.score})]}),(0,d.jsx)("div",{className:"bar-wrap",children:(0,d.jsx)("div",{className:"bar-fill",style:{width:`${Math.min(a.score,100)}%`,background:a.score>=50?"var(--danger)":a.score>=25?"var(--warn)":"var(--accent)"}})})]},a.name))]}),(0,d.jsxs)("div",{className:"panel",children:[(0,d.jsx)("h2",{children:"Lifecycle"}),(b.lifecycle||[]).map(a=>(0,d.jsxs)("div",{style:{marginBottom:12},children:[(0,d.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:4},children:[(0,d.jsx)("span",{style:{fontSize:13},children:a.name}),(0,d.jsxs)("span",{className:"muted",style:{fontSize:12},children:[a.openRisks," open"]})]}),(0,d.jsx)("div",{className:"bar-wrap",children:(0,d.jsx)("div",{className:"bar-fill",style:{width:`${Math.min(a.riskScore||0,100)}%`,background:(a.riskScore||0)>=50?"var(--danger)":(a.riskScore||0)>=25?"var(--warn)":"var(--accent)"}})})]},a.name))]})]})]}):(0,d.jsx)("div",{className:"empty-state",children:(0,d.jsx)("p",{children:"Loading dashboard data..."})})}function w({project:a,onClose:b,onSaved:c,toast:f}){let[h,i]=(0,e.useState)(!1),[l,m]=(0,e.useState)({title:"",description:"",dimension:"",domain:"",lifecyclePhase:"",probability:50,impact:50,detectability:50,ownerDisplayName:""}),n=a=>b=>m(c=>({...c,[a]:b})),o=async()=>{if(!l.title.trim())return void f.add("Title is required","error");if(!l.dimension)return void f.add("Dimension is required","error");i(!0);try{await g.FH.post(`/api/projects/${a.id}/risks`,l),f.add("Risk created"),c()}catch(a){f.add(a.message||"Failed to create risk","error")}finally{i(!1)}};return(0,d.jsx)("div",{className:"modal-overlay",onClick:b,children:(0,d.jsxs)("div",{className:"modal",onClick:a=>a.stopPropagation(),style:{maxWidth:500},children:[(0,d.jsx)("h2",{children:"New Risk"}),(0,d.jsx)(r,{label:"Title *",children:(0,d.jsx)(s,{value:l.title,onChange:n("title")})}),(0,d.jsx)(r,{label:"Description",children:(0,d.jsx)("textarea",{className:"input",value:l.description,onChange:a=>n("description")(a.target.value),rows:3,style:{width:"100%",resize:"vertical"}})}),(0,d.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:8},children:[(0,d.jsx)(r,{label:"Dimension *",children:(0,d.jsx)(t,{value:l.dimension,onChange:n("dimension"),options:j})}),(0,d.jsx)(r,{label:"Domain",children:(0,d.jsx)(s,{value:l.domain,onChange:n("domain")})})]}),(0,d.jsx)(r,{label:"Lifecycle Phase",children:(0,d.jsx)(t,{value:l.lifecyclePhase,onChange:n("lifecyclePhase"),options:k})}),(0,d.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:8},children:[(0,d.jsx)(r,{label:"Probability",children:(0,d.jsx)(s,{type:"number",min:0,max:100,value:l.probability,onChange:n("probability")})}),(0,d.jsx)(r,{label:"Impact",children:(0,d.jsx)(s,{type:"number",min:0,max:100,value:l.impact,onChange:n("impact")})}),(0,d.jsx)(r,{label:"Detectability",children:(0,d.jsx)(s,{type:"number",min:0,max:100,value:l.detectability,onChange:n("detectability")})})]}),(0,d.jsx)(r,{label:"Owner",children:(0,d.jsx)(s,{value:l.ownerDisplayName,onChange:n("ownerDisplayName")})}),(0,d.jsxs)("div",{className:"modal-actions",children:[(0,d.jsx)("button",{className:"button secondary small",onClick:b,children:"Cancel"}),(0,d.jsx)("button",{className:"button small",onClick:o,disabled:h,children:h?"Saving...":"Create Risk"})]})]})})}function x({project:a,dashboard:b,toast:c,onRefresh:f}){let[h,i]=(0,e.useState)(""),[m,n]=(0,e.useState)("normalizedScore"),[v,x]=(0,e.useState)("desc"),[y,z]=(0,e.useState)(0),[A,B]=(0,e.useState)(null),[C,D]=(0,e.useState)(!1),[E,F]=(0,e.useState)(!1),[G,H]=(0,e.useState)({}),[I,J]=(0,e.useState)(null),[K,L]=(0,e.useState)(null),[M,N]=(0,e.useState)(!1),O=(0,e.useMemo)(()=>b?.topRisks?p(b.topRisks,m,v):[],[b,m,v]),P=(0,e.useMemo)(()=>{if(!h)return O;let a=h.toLowerCase();return O.filter(b=>(b.title||"").toLowerCase().includes(a)||(b.dimension||"").toLowerCase().includes(a)||(b.ownerDisplayName||"").toLowerCase().includes(a))},[O,h]),Q=P.slice(0,(y+1)*20),R=async(a,b)=>{J(a);try{await g.FH.patch(`/api/risks/${a}`,{status:b}),c.add(`Risk status updated to ${b}`),B(null),f()}catch(a){c.add(a.message,"error")}finally{J(null)}},S=async()=>{if(!G.title.trim())return void c.add("Title is required","error");J("edit");try{await g.FH.patch(`/api/risks/${A.id}`,G),c.add("Risk updated"),B(null),f()}catch(a){c.add(a.message||"Failed to update","error")}finally{J(null)}},T=async()=>{N(!0);try{await g.FH.del(`/api/risks/${K.id}`),c.add("Risk deleted"),L(null),B(null),f()}catch(a){c.add(a.message||"Failed to delete","error")}finally{N(!1)}};return b?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{style:{display:"flex",gap:8,marginBottom:12},children:[(0,d.jsx)(o,{value:h,onChange:i,placeholder:"Search risks by title, dimension, owner..."}),(0,d.jsx)("button",{className:"button small",onClick:()=>D(!0),children:"+ New Risk"})]}),(0,d.jsx)("div",{className:"table-wrap",children:(0,d.jsxs)("table",{className:"table",children:[(0,d.jsx)("thead",{children:(0,d.jsx)("tr",{children:[{key:"id",label:"ID"},{key:"title",label:"Risk"},{key:"dimension",label:"Dimension"},{key:"lifecyclePhase",label:"Phase"},{key:"normalizedScore",label:"Score"},{key:"residualScore",label:"Residual"},{key:"status",label:"Status"},{key:"ownerDisplayName",label:"Owner"}].map(a=>(0,d.jsxs)("th",{className:"sortable",onClick:()=>{var b;m===(b=a.key)?x(a=>"asc"===a?"desc":"asc"):(n(b),x("asc"))},children:[a.label," ",m===a.key?"asc"===v?"▲":"▼":""]},a.key))})}),(0,d.jsx)("tbody",{children:Q.map(a=>(0,d.jsxs)("tr",{onClick:()=>{B(a),H({title:a.title||"",description:a.description||"",dimension:a.dimension||"",domain:a.domain||"",lifecyclePhase:a.lifecyclePhase||"",probability:a.probability??50,impact:a.impact??50,detectability:a.detectability??50,ownerDisplayName:a.ownerDisplayName||""}),F(!1),L(null)},children:[(0,d.jsx)("td",{style:{fontFamily:"monospace",fontSize:12},children:a.id?.slice(0,8)}),(0,d.jsx)("td",{children:(0,d.jsx)("strong",{children:a.title})}),(0,d.jsx)("td",{children:(0,d.jsx)(q,{className:a.dimension?.toLowerCase(),children:a.dimension})}),(0,d.jsx)("td",{style:{fontSize:12},children:a.lifecyclePhase}),(0,d.jsx)("td",{children:(0,d.jsx)("strong",{children:a.normalizedScore})}),(0,d.jsx)("td",{children:(0,d.jsx)("span",{style:{color:a.residualScore>=50?"var(--danger)":a.residualScore>=25?"var(--warn)":"var(--accent)"},children:a.residualScore})}),(0,d.jsx)("td",{children:(0,d.jsx)(q,{className:a.status?.toLowerCase().replace(/\s+/g,"-"),children:a.status})}),(0,d.jsx)("td",{children:(0,d.jsx)("span",{className:"muted",children:a.ownerDisplayName||"-"})})]},a.id))})]})}),P.length>Q.length&&(0,d.jsx)("div",{style:{textAlign:"center",marginTop:12},children:(0,d.jsxs)("button",{className:"button secondary small",onClick:()=>z(a=>a+1),children:["Show more (",P.length-Q.length," remaining)"]})}),!P.length&&(0,d.jsx)("div",{className:"empty-state",children:(0,d.jsx)("p",{children:"No risks match your search"})}),C&&(0,d.jsx)(w,{project:a,onClose:()=>D(!1),onSaved:()=>{D(!1),f()},toast:c}),A&&!K&&(0,d.jsx)("div",{className:"modal-overlay",onClick:()=>B(null),children:(0,d.jsxs)("div",{className:"modal",onClick:a=>a.stopPropagation(),style:{maxWidth:520},children:[(0,d.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[(0,d.jsx)("h2",{style:{margin:0},children:A.title}),(0,d.jsx)("button",{className:"button secondary small",onClick:()=>F(!E),children:E?"View":"Edit"})]}),E?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{style:{marginTop:12},children:[(0,d.jsx)(r,{label:"Title *",children:(0,d.jsx)(s,{value:G.title,onChange:a=>H(b=>({...b,title:a}))})}),(0,d.jsx)(r,{label:"Description",children:(0,d.jsx)("textarea",{className:"input",value:G.description,onChange:a=>H(b=>({...b,description:a.target.value})),rows:2,style:{width:"100%",resize:"vertical"}})}),(0,d.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:8},children:[(0,d.jsx)(r,{label:"Dimension",children:(0,d.jsx)(t,{value:G.dimension,onChange:a=>H(b=>({...b,dimension:a})),options:j})}),(0,d.jsx)(r,{label:"Domain",children:(0,d.jsx)(s,{value:G.domain,onChange:a=>H(b=>({...b,domain:a}))})})]}),(0,d.jsx)(r,{label:"Lifecycle Phase",children:(0,d.jsx)(t,{value:G.lifecyclePhase,onChange:a=>H(b=>({...b,lifecyclePhase:a})),options:k})}),(0,d.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:8},children:[(0,d.jsx)(r,{label:"Probability",children:(0,d.jsx)(s,{type:"number",min:0,max:100,value:G.probability,onChange:a=>H(b=>({...b,probability:Number(a)}))})}),(0,d.jsx)(r,{label:"Impact",children:(0,d.jsx)(s,{type:"number",min:0,max:100,value:G.impact,onChange:a=>H(b=>({...b,impact:Number(a)}))})}),(0,d.jsx)(r,{label:"Detectability",children:(0,d.jsx)(s,{type:"number",min:0,max:100,value:G.detectability,onChange:a=>H(b=>({...b,detectability:Number(a)}))})})]}),(0,d.jsx)(r,{label:"Owner",children:(0,d.jsx)(s,{value:G.ownerDisplayName,onChange:a=>H(b=>({...b,ownerDisplayName:a}))})})]}),(0,d.jsxs)("div",{className:"modal-actions",children:[(0,d.jsx)("button",{className:"button secondary small",onClick:()=>B(null),children:"Cancel"}),(0,d.jsx)("button",{className:"button small",onClick:S,disabled:"edit"===I,children:"edit"===I?"Saving...":"Save Changes"}),(0,d.jsx)("button",{className:"button small",style:{background:"var(--danger)",color:"#fff",marginLeft:"auto"},onClick:()=>L(A),children:"Delete"})]})]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12,fontSize:13,marginTop:12},children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("span",{className:"muted",children:"Dimension"}),(0,d.jsx)("br",{}),A.dimension]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("span",{className:"muted",children:"Phase"}),(0,d.jsx)("br",{}),A.lifecyclePhase]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("span",{className:"muted",children:"Probability"}),(0,d.jsx)("br",{}),A.probability]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("span",{className:"muted",children:"Impact"}),(0,d.jsx)("br",{}),A.impact]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("span",{className:"muted",children:"Detectability"}),(0,d.jsx)("br",{}),A.detectability]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("span",{className:"muted",children:"Score"}),(0,d.jsx)("br",{}),(0,d.jsx)("strong",{children:A.normalizedScore})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("span",{className:"muted",children:"Residual"}),(0,d.jsx)("br",{}),A.residualScore]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("span",{className:"muted",children:"Owner"}),(0,d.jsx)("br",{}),A.ownerDisplayName||"-"]})]}),A.description&&(0,d.jsxs)("div",{style:{marginTop:12,fontSize:13},children:[(0,d.jsx)("span",{className:"muted",children:"Description"}),(0,d.jsx)("br",{}),A.description]}),(0,d.jsxs)("div",{style:{marginTop:16},children:[(0,d.jsx)("span",{className:"muted",style:{fontSize:12},children:"Update status:"}),(0,d.jsx)("div",{style:{display:"flex",gap:6,marginTop:6,flexWrap:"wrap"},children:l.map(a=>(0,d.jsx)("button",{className:`button small ${"OPEN"===a?"secondary":""}`,onClick:()=>R(A.id,a),disabled:I===A.id,children:a.replace("_"," ")},a))})]}),(0,d.jsx)("div",{className:"modal-actions",children:(0,d.jsx)("button",{className:"button secondary small",onClick:()=>B(null),children:"Close"})})]})]})}),K&&(0,d.jsx)(u,{label:"this risk",onConfirm:T,onCancel:()=>L(null),deleting:M})]}):(0,d.jsx)("div",{className:"empty-state",children:(0,d.jsx)("p",{children:"Loading..."})})}function y({project:a,risks:b,onClose:c,onSaved:f,toast:h}){let[i,j]=(0,e.useState)(!1),[k,l]=(0,e.useState)({riskId:"",title:"",description:"",status:"NOT_STARTED",progressPercent:0,effectivenessPercent:0,dueDate:"",ownerDisplayName:""}),n=a=>b=>l(c=>({...c,[a]:b})),o=async()=>{if(!k.title.trim())return void h.add("Title is required","error");if(!k.riskId)return void h.add("Please select a risk","error");j(!0);try{let a={...k,progressPercent:Number(k.progressPercent),effectivenessPercent:Number(k.effectivenessPercent)};a.dueDate?a.dueDate=new Date(a.dueDate).toISOString():delete a.dueDate,await g.FH.post(`/api/risks/${k.riskId}/mitigations`,a),h.add("Mitigation created"),f()}catch(a){h.add(a.message||"Failed to create mitigation","error")}finally{j(!1)}};return(0,d.jsx)("div",{className:"modal-overlay",onClick:c,children:(0,d.jsxs)("div",{className:"modal",onClick:a=>a.stopPropagation(),style:{maxWidth:500},children:[(0,d.jsx)("h2",{children:"New Mitigation"}),(0,d.jsx)(r,{label:"Risk *",children:(0,d.jsx)(t,{value:k.riskId,onChange:n("riskId"),options:(b||[]).map(a=>({value:a.id,label:a.title}))})}),(0,d.jsx)(r,{label:"Title *",children:(0,d.jsx)(s,{value:k.title,onChange:n("title")})}),(0,d.jsx)(r,{label:"Description",children:(0,d.jsx)("textarea",{className:"input",value:k.description,onChange:a=>n("description")(a.target.value),rows:2,style:{width:"100%",resize:"vertical"}})}),(0,d.jsx)(r,{label:"Status",children:(0,d.jsx)(t,{value:k.status,onChange:n("status"),options:m})}),(0,d.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:8},children:[(0,d.jsx)(r,{label:"Progress %",children:(0,d.jsx)(s,{type:"number",min:0,max:100,value:k.progressPercent,onChange:n("progressPercent")})}),(0,d.jsx)(r,{label:"Effectiveness %",children:(0,d.jsx)(s,{type:"number",min:0,max:100,value:k.effectivenessPercent,onChange:n("effectivenessPercent")})})]}),(0,d.jsx)(r,{label:"Due Date",children:(0,d.jsx)(s,{type:"date",value:k.dueDate,onChange:n("dueDate")})}),(0,d.jsx)(r,{label:"Owner",children:(0,d.jsx)(s,{value:k.ownerDisplayName,onChange:n("ownerDisplayName")})}),(0,d.jsxs)("div",{className:"modal-actions",children:[(0,d.jsx)("button",{className:"button secondary small",onClick:c,children:"Cancel"}),(0,d.jsx)("button",{className:"button small",onClick:o,disabled:i,children:i?"Saving...":"Create Mitigation"})]})]})})}function z({project:a,dashboard:b,toast:c,onRefresh:f}){let[h,i]=(0,e.useState)(""),[j,k]=(0,e.useState)("progressPercent"),[l,n]=(0,e.useState)("asc"),[v,w]=(0,e.useState)(!1),[x,z]=(0,e.useState)(null),[A,B]=(0,e.useState)(!1),[C,D]=(0,e.useState)({}),[E,F]=(0,e.useState)(null),[G,H]=(0,e.useState)(null),[I,J]=(0,e.useState)(!1),K=(0,e.useMemo)(()=>b?.mitigations?p(b.mitigations,j,l):[],[b,j,l]),L=(0,e.useMemo)(()=>b?.topRisks?b.topRisks:[],[b]),M=(0,e.useMemo)(()=>{if(!h)return K;let a=h.toLowerCase();return K.filter(b=>(b.title||"").toLowerCase().includes(a)||(b.riskTitle||"").toLowerCase().includes(a))},[K,h]),N=async()=>{if(!C.title.trim())return void c.add("Title is required","error");F("edit");try{let a={...C,progressPercent:Number(C.progressPercent),effectivenessPercent:Number(C.effectivenessPercent)};a.dueDate?a.dueDate=new Date(a.dueDate).toISOString():a.dueDate=null,await g.FH.patch(`/api/mitigations/${x.id}`,a),c.add("Mitigation updated"),z(null),f()}catch(a){c.add(a.message||"Failed to update","error")}finally{F(null)}},O=async()=>{J(!0);try{await g.FH.del(`/api/mitigations/${G.id}`),c.add("Mitigation deleted"),H(null),z(null),f()}catch(a){c.add(a.message||"Failed to delete","error")}finally{J(!1)}};return b?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{style:{display:"flex",gap:8,marginBottom:12},children:[(0,d.jsx)(o,{value:h,onChange:i,placeholder:"Search mitigations..."}),(0,d.jsx)("button",{className:"button small",onClick:()=>w(!0),children:"+ New Mitigation"})]}),(0,d.jsx)("div",{className:"table-wrap",children:(0,d.jsxs)("table",{className:"table",children:[(0,d.jsx)("thead",{children:(0,d.jsx)("tr",{children:[{key:"title",label:"Title"},{key:"riskTitle",label:"Risk"},{key:"status",label:"Status"},{key:"progressPercent",label:"Progress"},{key:"effectivenessPercent",label:"Effectiveness"},{key:"ownerDisplayName",label:"Owner"}].map(a=>(0,d.jsxs)("th",{className:"sortable",onClick:()=>{var b;j===(b=a.key)?n(a=>"asc"===a?"desc":"asc"):(k(b),n("asc"))},children:[a.label," ",j===a.key?"asc"===l?"▲":"▼":""]},a.key))})}),(0,d.jsx)("tbody",{children:M.slice(0,50).map(a=>(0,d.jsxs)("tr",{onClick:()=>{z(a),D({title:a.title||"",description:a.description||"",status:a.status||"NOT_STARTED",progressPercent:a.progressPercent??0,effectivenessPercent:a.effectivenessPercent??0,dueDate:a.dueDate?a.dueDate.slice(0,10):"",ownerDisplayName:a.ownerDisplayName||""}),B(!0),H(null)},style:{cursor:"pointer"},children:[(0,d.jsx)("td",{children:(0,d.jsx)("strong",{children:a.title})}),(0,d.jsx)("td",{children:(0,d.jsx)("span",{className:"muted",children:a.riskTitle})}),(0,d.jsx)("td",{children:(0,d.jsx)(q,{className:a.status?.toLowerCase().replace(/\s+/g,"-"),children:a.status})}),(0,d.jsx)("td",{children:(0,d.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[(0,d.jsx)("div",{className:"bar-wrap",style:{flex:1,maxWidth:80},children:(0,d.jsx)("div",{className:"bar-fill",style:{width:`${a.progressPercent||0}%`,background:(a.progressPercent||0)>=80?"var(--accent)":(a.progressPercent||0)>=30?"var(--warn)":"var(--danger)"}})}),a.progressPercent||0,"%"]})}),(0,d.jsxs)("td",{children:[a.effectivenessPercent||0,"%"]}),(0,d.jsx)("td",{children:(0,d.jsx)("span",{className:"muted",children:a.ownerDisplayName||"-"})})]},a.id))})]})}),!M.length&&(0,d.jsx)("div",{className:"empty-state",children:(0,d.jsx)("p",{children:"No mitigations found"})}),v&&(0,d.jsx)(y,{project:a,risks:L,onClose:()=>w(!1),onSaved:()=>{w(!1),f()},toast:c}),x&&!G&&(0,d.jsx)("div",{className:"modal-overlay",onClick:()=>z(null),children:(0,d.jsxs)("div",{className:"modal",onClick:a=>a.stopPropagation(),style:{maxWidth:500},children:[(0,d.jsx)("h2",{style:{margin:0},children:A?"Edit Mitigation":x.title}),(0,d.jsxs)("div",{style:{marginTop:12},children:[(0,d.jsx)(r,{label:"Title *",children:(0,d.jsx)(s,{value:C.title,onChange:a=>D(b=>({...b,title:a}))})}),(0,d.jsx)(r,{label:"Description",children:(0,d.jsx)("textarea",{className:"input",value:C.description,onChange:a=>D(b=>({...b,description:a.target.value})),rows:2,style:{width:"100%",resize:"vertical"}})}),(0,d.jsx)(r,{label:"Status",children:(0,d.jsx)(t,{value:C.status,onChange:a=>D(b=>({...b,status:a})),options:m})}),(0,d.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:8},children:[(0,d.jsx)(r,{label:"Progress %",children:(0,d.jsx)(s,{type:"number",min:0,max:100,value:C.progressPercent,onChange:a=>D(b=>({...b,progressPercent:Number(a)}))})}),(0,d.jsx)(r,{label:"Effectiveness %",children:(0,d.jsx)(s,{type:"number",min:0,max:100,value:C.effectivenessPercent,onChange:a=>D(b=>({...b,effectivenessPercent:Number(a)}))})})]}),(0,d.jsx)(r,{label:"Due Date",children:(0,d.jsx)(s,{type:"date",value:C.dueDate,onChange:a=>D(b=>({...b,dueDate:a}))})}),(0,d.jsx)(r,{label:"Owner",children:(0,d.jsx)(s,{value:C.ownerDisplayName,onChange:a=>D(b=>({...b,ownerDisplayName:a}))})})]}),(0,d.jsxs)("div",{className:"modal-actions",children:[(0,d.jsx)("button",{className:"button secondary small",onClick:()=>z(null),children:"Cancel"}),(0,d.jsx)("button",{className:"button small",onClick:N,disabled:"edit"===E,children:"edit"===E?"Saving...":"Save Changes"}),(0,d.jsx)("button",{className:"button small",style:{background:"var(--danger)",color:"#fff",marginLeft:"auto"},onClick:()=>H(x),children:"Delete"})]})]})}),G&&(0,d.jsx)(u,{label:"this mitigation",onConfirm:O,onCancel:()=>H(null),deleting:I})]}):(0,d.jsx)("div",{className:"empty-state",children:(0,d.jsx)("p",{children:"Loading..."})})}function A({project:a,dashboard:b,toast:c,onRefresh:f}){let[h,i]=(0,e.useState)(!1),[j,k]=(0,e.useState)(!1),[l,m]=(0,e.useState)({decision:"APPROVED",reviewerName:"",reason:""}),[n,o]=(0,e.useState)(!1),p=b?.gate?.criteria||[],u=b?.summary?.gateStatus||"Unknown",v=b?.gate?.id,w="Ready"===u?"good":"Warning"===u?"warn":"bad",x=async()=>{i(!0);try{await g.FH.post(`/api/projects/${a.id}/gate/evaluate`,{}),c.add("Gate evaluated"),f()}catch(a){c.add(a.message||"Evaluation failed","error")}finally{i(!1)}},y=async()=>{if(!l.reviewerName.trim())return void c.add("Reviewer name is required","error");o(!0);try{await g.FH.post(`/api/gates/${v}/decisions`,l),c.add("Decision submitted"),k(!1),f()}catch(a){c.add(a.message||"Failed to submit decision","error")}finally{o(!1)}};return b?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"dash-header",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("h1",{children:"Deployment Gate"}),(0,d.jsx)("p",{className:"muted",children:"Gate evaluation for AI deployment readiness"})]}),(0,d.jsx)("div",{className:"dash-actions",children:(0,d.jsx)("div",{className:`metric-value ${w}`,style:{fontSize:28},children:u})})]}),(0,d.jsx)("div",{className:"table-wrap",children:(0,d.jsxs)("table",{className:"table",children:[(0,d.jsx)("thead",{children:(0,d.jsxs)("tr",{children:[(0,d.jsx)("th",{children:"Criterion"}),(0,d.jsx)("th",{children:"Required"}),(0,d.jsx)("th",{children:"Actual"}),(0,d.jsx)("th",{children:"Status"})]})}),(0,d.jsx)("tbody",{children:p.map(a=>(0,d.jsxs)("tr",{children:[(0,d.jsx)("td",{children:(0,d.jsx)("strong",{children:a.name})}),(0,d.jsx)("td",{children:a.required}),(0,d.jsx)("td",{children:a.actual}),(0,d.jsx)("td",{children:(0,d.jsx)(q,{className:a.status?.toLowerCase(),children:a.status})})]},a.name))})]})}),!p.length&&(0,d.jsx)("div",{className:"empty-state",children:(0,d.jsx)("p",{children:"No gate criteria evaluated yet"})}),(0,d.jsxs)("div",{style:{marginTop:16,display:"flex",gap:8,flexWrap:"wrap"},children:[(0,d.jsx)("button",{className:"button small",onClick:x,disabled:h,children:h?"Evaluating...":"Evaluate Gate"}),v&&(0,d.jsx)("button",{className:"button secondary small",onClick:()=>k(!0),children:"Add Decision"}),(0,d.jsx)("a",{href:`/api/projects/${a?.id}/gate/history`,className:"button secondary small",target:"_blank",children:"History (API)"})]}),j&&(0,d.jsx)("div",{className:"modal-overlay",onClick:()=>k(!1),children:(0,d.jsxs)("div",{className:"modal",onClick:a=>a.stopPropagation(),style:{maxWidth:400},children:[(0,d.jsx)("h2",{children:"Gate Decision"}),(0,d.jsx)(r,{label:"Decision",children:(0,d.jsx)(t,{value:l.decision,onChange:a=>m(b=>({...b,decision:a})),options:["APPROVED","REJECTED","ACCEPTED","NEEDS_CHANGES"]})}),(0,d.jsx)(r,{label:"Reviewer Name *",children:(0,d.jsx)(s,{value:l.reviewerName,onChange:a=>m(b=>({...b,reviewerName:a}))})}),(0,d.jsx)(r,{label:"Reason",children:(0,d.jsx)("textarea",{className:"input",value:l.reason,onChange:a=>m(b=>({...b,reason:a.target.value})),rows:3,style:{width:"100%",resize:"vertical"}})}),(0,d.jsxs)("div",{className:"modal-actions",children:[(0,d.jsx)("button",{className:"button secondary small",onClick:()=>k(!1),children:"Cancel"}),(0,d.jsx)("button",{className:"button small",onClick:y,disabled:n,children:n?"Saving...":"Submit Decision"})]})]})})]}):(0,d.jsx)("div",{className:"empty-state",children:(0,d.jsx)("p",{children:"Loading..."})})}function B({project:a,dashboard:b,onClose:c,onSaved:f,toast:h}){let[i,j]=(0,e.useState)(!1),[k,l]=(0,e.useState)({provider:"TRELLO",workspaceName:"",baseUrl:"",authMode:"API_KEY"}),m=a=>b=>l(c=>({...c,[a]:b})),n=b?.gate?.workspaceId||a?.workspaceId,o=async()=>{if(!k.workspaceName.trim())return void h.add("Workspace name is required","error");j(!0);try{await g.FH.post(`/api/workspaces/${n}/integrations`,k),h.add("Integration created"),f()}catch(a){h.add(a.message||"Failed to create integration","error")}finally{j(!1)}};return(0,d.jsx)("div",{className:"modal-overlay",onClick:c,children:(0,d.jsxs)("div",{className:"modal",onClick:a=>a.stopPropagation(),style:{maxWidth:450},children:[(0,d.jsx)("h2",{children:"New Integration"}),(0,d.jsx)(r,{label:"Provider",children:(0,d.jsx)(t,{value:k.provider,onChange:m("provider"),options:["TRELLO","JIRA","ASANA","MICROSOFT_PLANNER"]})}),(0,d.jsx)(r,{label:"Workspace Name *",children:(0,d.jsx)(s,{value:k.workspaceName,onChange:m("workspaceName")})}),(0,d.jsx)(r,{label:"Base URL",children:(0,d.jsx)(s,{value:k.baseUrl,onChange:m("baseUrl")})}),(0,d.jsx)(r,{label:"Auth Mode",children:(0,d.jsx)(t,{value:k.authMode,onChange:m("authMode"),options:["API_KEY","OAUTH","BASIC"]})}),(0,d.jsxs)("div",{className:"modal-actions",children:[(0,d.jsx)("button",{className:"button secondary small",onClick:c,children:"Cancel"}),(0,d.jsx)("button",{className:"button small",onClick:o,disabled:i,children:i?"Saving...":"Create Integration"})]})]})})}function C({project:a,dashboard:b,toast:c,onRefresh:f}){let[g,h]=(0,e.useState)(!1),i=b?.integrations||[];return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"dash-header",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("h1",{children:"Integrations"}),(0,d.jsx)("p",{className:"muted",children:"Connect Trello, Jira, Asana, or Microsoft Planner"})]}),(0,d.jsx)("div",{className:"dash-actions",children:(0,d.jsx)("button",{className:"button small",onClick:()=>h(!0),children:"+ New Integration"})})]}),(0,d.jsx)("div",{className:"grid",style:{gridTemplateColumns:"repeat(auto-fit, minmax(240px, 1fr))"},children:["TRELLO","JIRA","ASANA","MICROSOFT_PLANNER"].map(a=>{let b=i.find(b=>b.provider===a);return(0,d.jsxs)("div",{className:"panel",style:{textAlign:"center"},children:[(0,d.jsx)("div",{style:{fontSize:32,marginBottom:8},children:"TRELLO"===a?"⊞":"JIRA"===a?"◆":"ASANA"===a?"◇":"▣"}),(0,d.jsx)("h3",{style:{margin:"0 0 4px"},children:a.replace("_"," ")}),(0,d.jsx)("p",{className:"muted",style:{fontSize:12,margin:"0 0 12px"},children:b?b.workspaceName:"Not configured"}),(0,d.jsx)("div",{style:{display:"flex",gap:6,justifyContent:"center"},children:b?(0,d.jsx)("a",{href:`/api/integrations/${b.id}`,className:"button secondary small",target:"_blank",children:"Manage"}):(0,d.jsx)("button",{className:"button secondary small",onClick:()=>h(!0),children:"Configure"})})]},a)})}),g&&(0,d.jsx)(B,{project:a,dashboard:b,onClose:()=>h(!1),onSaved:()=>{h(!1),f()},toast:c}),!i.length&&(0,d.jsx)("div",{style:{marginTop:12},children:(0,d.jsx)("a",{href:"/api/integration-providers",className:"button secondary small",target:"_blank",children:"Integration providers (API)"})})]})}function D({project:a,toast:b}){let[c,f]=(0,e.useState)([]),[h,i]=(0,e.useState)(!0),[j,k]=(0,e.useState)(null),l=(0,e.useCallback)(async()=>{if(a){i(!0),k(null);try{let b=await g.FH.get(`/api/projects/${a.id}/audit`);f(b.auditEvents||[])}catch(a){k(a.message||"Failed to load audit log")}finally{i(!1)}}},[a]);return h?(0,d.jsx)("div",{className:"empty-state",children:(0,d.jsx)("p",{children:"Loading audit log..."})}):j?(0,d.jsx)("div",{className:"empty-state",children:(0,d.jsx)("p",{children:j})}):c.length?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"dash-header",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("h1",{children:"Audit Log"}),(0,d.jsx)("p",{className:"muted",children:"Project activity history"})]}),(0,d.jsx)("div",{className:"dash-actions",children:(0,d.jsx)("button",{className:"button secondary small",onClick:l,children:"Refresh"})})]}),(0,d.jsx)("div",{className:"table-wrap",children:(0,d.jsxs)("table",{className:"table",children:[(0,d.jsx)("thead",{children:(0,d.jsxs)("tr",{children:[(0,d.jsx)("th",{children:"Date"}),(0,d.jsx)("th",{children:"Action"}),(0,d.jsx)("th",{children:"Entity"}),(0,d.jsx)("th",{children:"Actor"}),(0,d.jsx)("th",{children:"Details"})]})}),(0,d.jsx)("tbody",{children:c.map(a=>(0,d.jsxs)("tr",{children:[(0,d.jsx)("td",{style:{fontSize:12,whiteSpace:"nowrap"},children:new Date(a.createdAt).toLocaleString()}),(0,d.jsx)("td",{children:(0,d.jsx)(q,{className:a.action?.toLowerCase().replace(/\s+/g,"-"),children:a.action})}),(0,d.jsxs)("td",{style:{fontSize:12},children:[a.entityType," ",(0,d.jsxs)("span",{className:"muted",children:["(",a.entityId?.slice(0,8),")"]})]}),(0,d.jsx)("td",{style:{fontSize:12},children:a.actorUserId||"system"}),(0,d.jsx)("td",{style:{fontSize:12,maxWidth:300,overflow:"hidden",textOverflow:"ellipsis"},children:a.afterJson?JSON.stringify(a.afterJson).slice(0,80):"-"})]},a.id))})]})})]}):(0,d.jsx)("div",{className:"empty-state",children:(0,d.jsx)("p",{children:"No audit events recorded yet"})})}function E({projects:a,workspaceId:b,currentProjectId:c,onSwitch:f,onRefresh:h,toast:i}){let[j,k]=(0,e.useState)(null),[l,m]=(0,e.useState)(null),[n,o]=(0,e.useState)(!1),p=async()=>{k(!0);try{await g.FH.del(`/api/projects/${l.id}`),i.add(`Project "${l.name}" deleted`),m(null),h()}catch(a){i.add(a.message||"Failed to delete project","error")}finally{k(!1)}};return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"dash-header",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("h1",{children:"All Projects"}),(0,d.jsxs)("p",{className:"muted",children:[a.length," project(s) in workspace"]})]}),(0,d.jsx)("div",{className:"dash-actions",children:(0,d.jsx)("button",{className:"button small",onClick:()=>o(!0),children:"+ New Project"})})]}),(0,d.jsx)("div",{className:"table-wrap",children:(0,d.jsxs)("table",{className:"table",children:[(0,d.jsx)("thead",{children:(0,d.jsxs)("tr",{children:[(0,d.jsx)("th",{children:"Name"}),(0,d.jsx)("th",{children:"Status"}),(0,d.jsx)("th",{children:"Type"}),(0,d.jsx)("th",{children:"Created"}),(0,d.jsx)("th",{children:"Actions"})]})}),(0,d.jsx)("tbody",{children:[...a].sort((a,b)=>new Date(b.createdAt)-new Date(a.createdAt)).map(a=>(0,d.jsxs)("tr",{style:{background:a.id===c?"var(--surface-alt)":""},children:[(0,d.jsxs)("td",{children:[(0,d.jsx)("strong",{children:a.name}),a.id===c?(0,d.jsx)("span",{className:"muted",style:{fontSize:11,marginLeft:6},children:"(current)"}):"",a.description?(0,d.jsx)("div",{className:"muted",style:{fontSize:11},children:a.description}):""]}),(0,d.jsx)("td",{children:(0,d.jsx)(q,{className:a.status?.toLowerCase(),children:a.status})}),(0,d.jsx)("td",{style:{fontSize:12},children:a.projectType}),(0,d.jsx)("td",{style:{fontSize:12},children:new Date(a.createdAt).toLocaleDateString()}),(0,d.jsxs)("td",{style:{textAlign:"right",whiteSpace:"nowrap"},children:[a.id!==c&&(0,d.jsx)("button",{className:"button secondary small",style:{marginRight:6},onClick:()=>f(a.id),children:"Open"}),(0,d.jsx)("button",{className:"button small",style:{background:"var(--danger)",color:"#fff"},onClick:()=>m(a),disabled:j===a.id,children:"Delete"})]})]},a.id))})]})}),!a.length&&(0,d.jsx)("div",{className:"empty-state",children:(0,d.jsx)("p",{children:"No projects yet. Create one to get started."})}),n&&(0,d.jsx)(G,{workspaceId:b,onClose:()=>o(!1),onSaved:()=>{o(!1),h()},toast:i}),l&&(0,d.jsx)("div",{className:"modal-overlay",onClick:()=>m(null),children:(0,d.jsxs)("div",{className:"modal",onClick:a=>a.stopPropagation(),style:{maxWidth:380},children:[(0,d.jsxs)("h3",{children:['Delete "',l.name,'"?']}),(0,d.jsx)("p",{style:{fontSize:13,color:"var(--muted)"},children:"This permanently deletes the project and all its risks, mitigations, and data."}),(0,d.jsxs)("div",{className:"modal-actions",children:[(0,d.jsx)("button",{className:"button secondary small",onClick:()=>m(null),children:"Cancel"}),(0,d.jsx)("button",{className:"button small",style:{background:"var(--danger)",color:"#fff"},onClick:p,disabled:j,children:j?"Deleting...":"Delete Project"})]})]})})]})}function F({project:a,onClose:b,onSaved:c,toast:f}){let[h,i]=(0,e.useState)(!1),[j,k]=(0,e.useState)({name:a?.name||"",description:a?.description||"",subtitle:a?.subtitle||"",status:a?.status||"Active"}),l=async()=>{if(!j.name.trim())return void f.add("Project name is required","error");i(!0);try{await g.FH.patch(`/api/projects/${a.id}`,j),f.add("Project updated"),c()}catch(a){f.add(a.message||"Failed to update project","error")}finally{i(!1)}};return(0,d.jsx)("div",{className:"modal-overlay",onClick:b,children:(0,d.jsxs)("div",{className:"modal",onClick:a=>a.stopPropagation(),style:{maxWidth:450},children:[(0,d.jsx)("h2",{children:"Project Settings"}),(0,d.jsx)(r,{label:"Name *",children:(0,d.jsx)(s,{value:j.name,onChange:a=>k(b=>({...b,name:a}))})}),(0,d.jsx)(r,{label:"Subtitle",children:(0,d.jsx)(s,{value:j.subtitle,onChange:a=>k(b=>({...b,subtitle:a}))})}),(0,d.jsx)(r,{label:"Description",children:(0,d.jsx)("textarea",{className:"input",value:j.description,onChange:a=>k(b=>({...b,description:a.target.value})),rows:3,style:{width:"100%",resize:"vertical"}})}),(0,d.jsx)(r,{label:"Status",children:(0,d.jsx)(t,{value:j.status,onChange:a=>k(b=>({...b,status:a})),options:["Active","Archived","On Hold"]})}),(0,d.jsxs)("div",{className:"modal-actions",children:[(0,d.jsx)("button",{className:"button secondary small",onClick:b,children:"Cancel"}),(0,d.jsx)("button",{className:"button small",onClick:l,disabled:h,children:h?"Saving...":"Save Changes"})]})]})})}function G({workspaceId:a,onClose:b,onSaved:c,toast:f}){let[h,i]=(0,e.useState)(!1),[j,k]=(0,e.useState)({name:"",description:"",projectType:"AI-Enabler"}),l=async()=>{if(!j.name.trim())return void f.add("Project name is required","error");i(!0);try{await g.FH.post(`/api/workspaces/${a}/projects`,j),f.add("Project created"),c()}catch(a){f.add(a.message||"Failed to create project","error")}finally{i(!1)}};return(0,d.jsx)("div",{className:"modal-overlay",onClick:b,children:(0,d.jsxs)("div",{className:"modal",onClick:a=>a.stopPropagation(),style:{maxWidth:450},children:[(0,d.jsx)("h2",{children:"New Project"}),(0,d.jsx)(r,{label:"Name *",children:(0,d.jsx)(s,{value:j.name,onChange:a=>k(b=>({...b,name:a}))})}),(0,d.jsx)(r,{label:"Description",children:(0,d.jsx)("textarea",{className:"input",value:j.description,onChange:a=>k(b=>({...b,description:a.target.value})),rows:3,style:{width:"100%",resize:"vertical"}})}),(0,d.jsx)(r,{label:"Project Type",children:(0,d.jsx)(t,{value:j.projectType,onChange:a=>k(b=>({...b,projectType:a})),options:["AI-Enabler","GENERATIVE_AI","ML-Pipeline","Automation"]})}),(0,d.jsxs)("div",{className:"modal-actions",children:[(0,d.jsx)("button",{className:"button secondary small",onClick:b,children:"Cancel"}),(0,d.jsx)("button",{className:"button small",onClick:l,disabled:h,children:h?"Saving...":"Create Project"})]})]})})}function H({projects:a,workspaceId:b,currentProjectId:c,onClose:f,onSwitch:h,onSaved:i,toast:j}){let[k,l]=(0,e.useState)(null),[m,n]=(0,e.useState)(null),[o,p]=(0,e.useState)(!1),r=async()=>{l(!0);try{await g.FH.del(`/api/projects/${m.id}`),j.add(`Project "${m.name}" deleted`),n(null),i()}catch(a){j.add(a.message||"Failed to delete project","error")}finally{l(!1)}};return(0,d.jsxs)("div",{className:"modal-overlay",onClick:f,children:[(0,d.jsxs)("div",{className:"modal",onClick:a=>a.stopPropagation(),style:{maxWidth:700,maxHeight:"80vh",overflow:"auto"},children:[(0,d.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[(0,d.jsx)("h2",{style:{margin:0},children:"All Projects"}),(0,d.jsx)("button",{className:"button small",onClick:()=>p(!0),children:"+ New Project"})]}),(0,d.jsxs)("p",{className:"muted",style:{fontSize:12,marginTop:4},children:[a.length," project(s) in workspace"]}),(0,d.jsx)("div",{className:"table-wrap",style:{marginTop:12},children:(0,d.jsxs)("table",{className:"table",children:[(0,d.jsx)("thead",{children:(0,d.jsxs)("tr",{children:[(0,d.jsx)("th",{children:"Name"}),(0,d.jsx)("th",{children:"Status"}),(0,d.jsx)("th",{children:"Type"}),(0,d.jsx)("th",{children:"Created"}),(0,d.jsx)("th",{})]})}),(0,d.jsx)("tbody",{children:[...a].sort((a,b)=>new Date(b.createdAt)-new Date(a.createdAt)).map(a=>(0,d.jsxs)("tr",{style:{background:a.id===c?"var(--surface-alt)":""},children:[(0,d.jsxs)("td",{children:[(0,d.jsx)("strong",{children:a.name}),a.id===c?(0,d.jsx)("span",{className:"muted",style:{fontSize:11,marginLeft:6},children:"(current)"}):""]}),(0,d.jsx)("td",{children:(0,d.jsx)(q,{className:a.status?.toLowerCase(),children:a.status})}),(0,d.jsx)("td",{style:{fontSize:12},children:a.projectType}),(0,d.jsx)("td",{style:{fontSize:12},children:new Date(a.createdAt).toLocaleDateString()}),(0,d.jsxs)("td",{style:{textAlign:"right",whiteSpace:"nowrap"},children:[a.id!==c&&(0,d.jsx)("button",{className:"button secondary small",style:{marginRight:6},onClick:()=>{h(a.id),f()},children:"Open"}),(0,d.jsx)("button",{className:"button small",style:{background:"var(--danger)",color:"#fff"},onClick:()=>n(a),disabled:k===a.id,children:"✕"})]})]},a.id))})]})}),!a.length&&(0,d.jsx)("div",{className:"empty-state",children:(0,d.jsx)("p",{children:"No projects yet"})}),(0,d.jsx)("div",{className:"modal-actions",children:(0,d.jsx)("button",{className:"button secondary small",onClick:f,children:"Close"})})]}),m&&(0,d.jsx)("div",{className:"modal-overlay",onClick:()=>n(null),children:(0,d.jsxs)("div",{className:"modal",onClick:a=>a.stopPropagation(),style:{maxWidth:380},children:[(0,d.jsxs)("h3",{children:['Delete "',m.name,'"?']}),(0,d.jsx)("p",{style:{fontSize:13,color:"var(--muted)"},children:"This permanently deletes the project and all its risks, mitigations, and data."}),(0,d.jsxs)("div",{className:"modal-actions",children:[(0,d.jsx)("button",{className:"button secondary small",onClick:()=>n(null),children:"Cancel"}),(0,d.jsx)("button",{className:"button small",style:{background:"var(--danger)",color:"#fff"},onClick:r,disabled:k,children:k?"Deleting...":"Delete Project"})]})]})}),o&&(0,d.jsx)(G,{workspaceId:b,onClose:()=>p(!1),onSaved:()=>{p(!1),i()},toast:j})]})}function I(){let a=(0,f.useRouter)(),b=(0,f.useSearchParams)(),c=i.includes(b.get("tab"))?b.get("tab"):"Overview",[j,k]=(0,e.useState)(null),[l,m]=(0,e.useState)([]),[o,p]=(0,e.useState)(b.get("projectId")||null),[q,r]=(0,e.useState)(null),[s,t]=(0,e.useState)(!0),[u,w]=(0,e.useState)(null),[y,B]=(0,e.useState)(0),[I,J]=(0,e.useState)(!1),[K,L]=(0,e.useState)(!1),[M,N]=(0,e.useState)(null),{toasts:O,add:P}=function(){let[a,b]=(0,e.useState)([]);return{toasts:a,add:(0,e.useCallback)((a,c="success")=>{let d=Date.now()+Math.random();b(b=>[...b,{id:d,message:a,type:c}]),setTimeout(()=>b(a=>a.filter(a=>a.id!==d)),3e3)},[])}}(),Q=(0,e.useCallback)(()=>B(a=>a+1),[]);(0,e.useCallback)(async c=>{t(!0),w(null);try{let d=await g.FH.get("/api/auth/session");if(!d?.authenticated){w("Not authenticated."),t(!1);return}let e=d.memberships?.[0];if(!e){w("No organization membership found."),t(!1);return}let f=e.organizationId,h=await g.FH.get(`/api/workspaces?organizationId=${f}`),i=h.workspaces?.[0];if(!i){w("No workspace found — create one to get started."),t(!1);return}N(i.id);let j=(await g.FH.get(`/api/workspaces/${i.id}/projects`)).projects||[];if(!j.length){w("No project found — create a project to get started."),t(!1);return}m(j);let l=c?j.find(a=>a.id===c):null;if(l||(l=j[0]),l.id!==(b.get("projectId")||null)){let c=b.get("tab")||"Overview";a.replace(`/dashboard?tab=${c}&projectId=${l.id}`)}k(l);let n=await g.FH.get(`/api/projects/${l.id}/dashboard`);r(n.dashboard),t(!1)}catch(a){w(a.message||"Failed to load dashboard data"),t(!1)}},[]);let R=b=>{p(b),a.push(`/dashboard?tab=${c}&projectId=${b}`)},[S,T]=(0,e.useState)(!1);return s&&"Integrations"!==c?(0,d.jsx)("div",{className:"shell-loading",children:(0,d.jsx)("div",{className:"spinner"})}):u&&"Integrations"!==c?(0,d.jsxs)("div",{className:"empty-state",children:[(0,d.jsx)("div",{className:"empty-icon",children:"!"}),(0,d.jsx)("p",{children:u}),(0,d.jsxs)("div",{style:{marginTop:12,display:"flex",gap:8,justifyContent:"center"},children:[(0,d.jsx)("button",{className:"button secondary small",onClick:()=>B(a=>a+1),children:"Retry"}),u.includes("No project found")&&M&&(0,d.jsx)("button",{className:"button small",onClick:()=>T(!0),children:"+ Create Project"})]}),S&&M&&(0,d.jsx)(G,{workspaceId:M,onClose:()=>T(!1),onSaved:()=>{T(!1),B(a=>a+1)},toast:{add:P}})]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"dash-header",children:[(0,d.jsx)("div",{style:{display:"flex",alignItems:"center",gap:10},children:(0,d.jsxs)("div",{children:[(0,d.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,d.jsx)("select",{className:"input",value:j?.id||"",onChange:a=>R(a.target.value),style:{fontSize:16,fontWeight:700,width:"auto",minWidth:200,border:"none",background:"transparent",cursor:"pointer"},children:l.map(a=>(0,d.jsxs)("option",{value:a.id,children:[a.name," ","Active"!==a.status?`(${a.status})`:""]},a.id))}),(0,d.jsx)("button",{className:"button secondary small",style:{fontSize:14,padding:"2px 8px"},onClick:()=>J(!0),title:"Project settings",children:"⚙"}),(0,d.jsx)("button",{className:"button secondary small",onClick:()=>L(!0),children:"Projects"})]}),(0,d.jsx)("p",{className:"muted",style:{margin:0},children:j?.subtitle||j?.description||""})]})}),(0,d.jsxs)("div",{className:"dash-actions",children:[(0,d.jsx)("a",{href:`/api/projects/${j?.id}/reports/executive.html`,className:"button secondary small",target:"_blank",children:"Report"}),(0,d.jsx)("a",{href:`/api/projects/${j?.id}/reports/risk-register.csv`,className:"button secondary small",target:"_blank",children:"CSV"})]})]}),(0,d.jsx)("div",{className:"tabs",children:i.map(b=>(0,d.jsx)("button",{className:`tab ${c===b?"active":""}`,onClick:()=>a.push(`/dashboard?tab=${b}${j?`&projectId=${j.id}`:""}`),children:b},b))}),"Overview"===c&&(0,d.jsx)(h,{name:"Overview",children:(0,d.jsx)(v,{project:j,dashboard:q})},"overview"),"Projects"===c&&(0,d.jsx)(h,{name:"Projects",children:(0,d.jsx)(E,{projects:l,workspaceId:M,currentProjectId:j?.id,onSwitch:R,onRefresh:Q,toast:{add:P}})},"projects"),"Risks"===c&&(0,d.jsx)(h,{name:"Risks",children:(0,d.jsx)(x,{project:j,dashboard:q,toast:{add:P},onRefresh:Q})},"risks"),"Mitigations"===c&&(0,d.jsx)(h,{name:"Mitigations",children:(0,d.jsx)(z,{project:j,dashboard:q,toast:{add:P},onRefresh:Q})},"mitigations"),"Gate"===c&&(0,d.jsx)(h,{name:"Gate",children:(0,d.jsx)(A,{project:j,dashboard:q,toast:{add:P},onRefresh:Q})},"gate"),"Integrations"===c&&(0,d.jsx)(h,{name:"Integrations",children:(0,d.jsx)(C,{project:j,dashboard:q,toast:{add:P},onRefresh:Q})},"integrations"),"Audit"===c&&(0,d.jsx)(h,{name:"Audit",children:(0,d.jsx)(D,{project:j,toast:{add:P}})},"audit"),I&&(0,d.jsx)(F,{project:j,onClose:()=>J(!1),onSaved:()=>{J(!1),Q()},toast:{add:P}}),K&&(0,d.jsx)(H,{projects:l,workspaceId:M,currentProjectId:j?.id,onClose:()=>L(!1),onSwitch:R,onSaved:()=>{L(!1),Q()},toast:{add:P}}),(0,d.jsx)(n,{toasts:O})]})}},24744:(a,b,c)=>{"use strict";c.d(b,{default:()=>d});let d=(0,c(97954).registerClientReference)(function(){throw Error("Attempted to call the default export of \"C:\\\\Users\\\\abd_b\\\\OneDrive\\\\Desktop\\\\COSMIC AI-Risk Dashboard\\\\Step 12 is complete Final QA, Demo Readiness, and Submission Freeze\\\\application\\\\saas-app\\\\src\\\\components\\\\AppShell.jsx\" from the server, but it's on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"C:\\Users\\abd_b\\OneDrive\\Desktop\\COSMIC AI-Risk Dashboard\\Step 12 is complete Final QA, Demo Readiness, and Submission Freeze\\application\\saas-app\\src\\components\\AppShell.jsx","default")},26713:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/is-bot")},28354:a=>{"use strict";a.exports=require("util")},29294:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-async-storage.external.js")},31619:(a,b,c)=>{Promise.resolve().then(c.t.bind(c,81170,23)),Promise.resolve().then(c.t.bind(c,23597,23)),Promise.resolve().then(c.t.bind(c,36893,23)),Promise.resolve().then(c.t.bind(c,89748,23)),Promise.resolve().then(c.t.bind(c,6060,23)),Promise.resolve().then(c.t.bind(c,7184,23)),Promise.resolve().then(c.t.bind(c,69576,23)),Promise.resolve().then(c.t.bind(c,73041,23)),Promise.resolve().then(c.t.bind(c,51384,23))},33676:(a,b,c)=>{Promise.resolve().then(c.bind(c,24744))},33873:a=>{"use strict";a.exports=require("path")},35883:()=>{},41025:a=>{"use strict";a.exports=require("next/dist/server/app-render/dynamic-access-async-storage.external.js")},41459:()=>{},42378:(a,b,c)=>{"use strict";var d=c(91330);c.o(d,"useRouter")&&c.d(b,{useRouter:function(){return d.useRouter}}),c.o(d,"useSearchParams")&&c.d(b,{useSearchParams:function(){return d.useSearchParams}})},48698:(a,b,c)=>{"use strict";c.d(b,{default:()=>i});var d=c(21124),e=c(38301),f=c(42378),g=c(84194);let h=[{label:"Overview",tab:"Overview",icon:"◇"},{label:"Risks",tab:"Risks",icon:"⚠"},{label:"Mitigations",tab:"Mitigations",icon:"●"},{label:"Gate",tab:"Gate",icon:"⊞"},{label:"Integrations",tab:"Integrations",icon:"⇆"}];function i({children:a}){let[b,c]=(0,e.useState)(null),[i,j]=(0,e.useState)(!1),[k,l]=(0,e.useState)(!0),m=(0,f.useRouter)(),n=(0,f.useSearchParams)().get("tab")||"Overview";return k?(0,d.jsx)("div",{className:"shell-loading",children:(0,d.jsx)("div",{className:"spinner"})}):(0,d.jsxs)("div",{className:"app-shell",children:[(0,d.jsx)("button",{className:"sidebar-toggle",onClick:()=>j(!i),children:i?"✕":"☰"}),(0,d.jsxs)("aside",{className:`sidebar ${i?"open":""}`,children:[(0,d.jsx)("div",{className:"sidebar-brand",children:"COSMIC"}),(0,d.jsxs)("div",{className:"sidebar-user",children:[(0,d.jsx)("div",{className:"sidebar-user-name",children:b.displayName}),(0,d.jsx)("div",{className:"sidebar-user-email",children:b.email})]}),(0,d.jsx)("nav",{className:"sidebar-nav",children:h.map(a=>{let b=n===a.tab;return(0,d.jsxs)("a",{href:`/dashboard?tab=${a.tab}`,className:`sidebar-link ${b?"active":""}`,onClick:b=>{b.preventDefault(),j(!1),m.push(`/dashboard?tab=${a.tab}`)},children:[(0,d.jsx)("span",{className:"sidebar-icon",children:a.icon}),a.label]},a.tab)})}),(0,d.jsx)("div",{className:"sidebar-footer",children:(0,d.jsx)("button",{className:"sidebar-logout",onClick:g.ri,children:"Sign out"})})]}),i&&(0,d.jsx)("div",{className:"sidebar-overlay",onClick:()=>j(!1)}),(0,d.jsx)("main",{className:"app-main",children:a})]})}},61135:()=>{},61662:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>f,metadata:()=>e});var d=c(75338);c(61135);let e={title:"COSMIC AI-Risk SaaS",description:"Commercial multi-tenant COSMIC AI-Risk governance platform"};function f({children:a}){return(0,d.jsx)("html",{lang:"en",children:(0,d.jsx)("body",{children:a})})}},63033:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},84194:(a,b,c)=>{"use strict";async function d(a,b,c){let d={method:a,headers:{"Content-Type":"application/json"}};c&&(d.body=JSON.stringify(c));let e=await fetch(`${b}`,d),f=e.headers.get("content-type")?.includes("application/json")?await e.json():await e.text();if(!e.ok)throw Error(f?.error||f?.message||`Request failed (${e.status})`);return f}c.d(b,{FH:()=>e,Ht:()=>f,ri:()=>g});let e={get:a=>d("GET",a),post:(a,b)=>d("POST",a,b),put:(a,b)=>d("PUT",a,b),patch:(a,b)=>d("PATCH",a,b),del:a=>d("DELETE",a)};async function f(){try{let a=await e.get("/api/auth/session");return a.user||a.actor||null}catch{return null}}async function g(){await e.post("/api/auth/logout"),window.location.href="/"}},85498:(a,b,c)=>{Promise.resolve().then(c.bind(c,19672))},86439:a=>{"use strict";a.exports=require("next/dist/shared/lib/no-fallback-error.external")},87513:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>g});var d=c(75338),e=c(74515),f=c(24744);function g({children:a}){return(0,d.jsx)(e.Suspense,{fallback:(0,d.jsx)("div",{className:"shell-loading",children:(0,d.jsx)("div",{className:"spinner"})}),children:(0,d.jsx)(f.default,{children:a})})}},96114:(a,b,c)=>{Promise.resolve().then(c.bind(c,9610))},97228:(a,b,c)=>{Promise.resolve().then(c.bind(c,48698))},97275:(a,b,c)=>{Promise.resolve().then(c.t.bind(c,54160,23)),Promise.resolve().then(c.t.bind(c,31603,23)),Promise.resolve().then(c.t.bind(c,68495,23)),Promise.resolve().then(c.t.bind(c,75170,23)),Promise.resolve().then(c.t.bind(c,77526,23)),Promise.resolve().then(c.t.bind(c,78922,23)),Promise.resolve().then(c.t.bind(c,29234,23)),Promise.resolve().then(c.t.bind(c,12263,23)),Promise.resolve().then(c.bind(c,82146))}};var b=require("../../webpack-runtime.js");b.C(a);var c=b.X(0,[5873,4792],()=>b(b.s=19108));module.exports=c})();