PageSourceSearch

https://innogist.ai/assets/ExternalScenarioBuilderPage-sHDBrdIQ.js

js innogist.ai collected 2026-10-05 15:17:48 UTC 29,226 bytes, 1 lines download raw bytes

1import{j as e,b1 as V,r as l,be as A,U as W,t as Z,f as J,o as U,aP as K,a_ as q,C as D,ay as E,Z as P,c as B,aS as ee}from"./index-sy1_3QS7.js";import{P as te}from"./PageHeader-CmmBonTW.js";import{u as ae,a as re,b as se}from"./useExternalScenarios-D9VqK6LN.js";import{T as z,N as de}from"./NarrativeEditor-Cxqdwr5m.js";import"./Breadcrumbs-qrbEhwT8.js";import"./SignalStrengthMeter-Bn8fV5ja.js";const C={political:{dot:"bg-red-500",legend:"bg-red-500",label:"Political"},economic:{dot:"bg-amber-500",legend:"bg-amber-500",label:"Economic"},social:{dot:"bg-green-500",legend:"bg-green-500",label:"Social"},technological:{dot:"bg-indigo-500",legend:"bg-indigo-500",label:"Technological"},environmental:{dot:"bg-cyan-500",legend:"bg-cyan-500",label:"Environmental"},legal:{dot:"bg-violet-500",legend:"bg-violet-500",label:"Legal"}};function M(o){return 8+(o-1)/4*(100-2*8)}function ne({items:o,onItemClick:c,selectedIds:d=[]}){const n=o.filter(t=>t.impact_score!==null&&t.uncertainty_score!==null);return e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("div",{className:"relative w-full",style:{paddingBottom:"75%"},children:e.jsxs("div",{className:"absolute inset-0 border border-brand-border-subtle dark:border-brand-dark-border rounded-lg bg-white dark:bg-gray-900 overflow-hidden",children:[e.jsxs("div",{className:"absolute inset-0 pointer-events-none",children:[e.jsx("div",{className:"absolute left-1/2 top-0 bottom-0 border-l border-dashed border-brand-border dark:border-brand-dark-border"}),e.jsx("div",{className:"absolute top-1/2 left-0 right-0 border-t border-dashed border-brand-border dark:border-brand-dark-border"})]}),e.jsx("div",{className:"absolute top-2 left-2 text-xs text-gray-400 dark:text-brand-dark-text-muted select-none",children:"Low Impact / High Uncertainty"}),e.jsx("div",{className:"absolute top-2 right-2 text-xs font-semibold text-indigo-600 dark:text-indigo-400 select-none text-right",children:"Driving Forces"}),e.jsx("div",{className:"absolute bottom-2 left-2 text-xs text-gray-400 dark:text-brand-dark-text-muted select-none",children:"Low Impact / Low Uncertainty"}),e.jsx("div",{className:"absolute bottom-2 right-2 text-xs text-gray-400 dark:text-brand-dark-text-muted select-none text-right",children:"High Impact / Low Uncertainty"}),e.jsx("div",{className:"absolute bottom-0 left-0 right-0 flex justify-center pb-0.5",children:e.jsx("span",{className:"text-xs text-brand-text-muted dark:text-brand-dark-text-muted select-none",children:"Impact →"})}),e.jsx("div",{className:"absolute left-0 top-0 bottom-0 flex items-center",style:{writingMode:"vertical-rl",transform:"rotate(180deg)"},children:e.jsx("span",{className:"text-xs text-brand-text-muted dark:text-brand-dark-text-muted select-none pl-0.5",children:"Uncertainty →"})}),n.map(t=>{const i=M(t.impact_score),b=100-M(t.uncertainty_score),u=C[t.category]??C.political,g=d.includes(t.id);return e.jsx("button",{title:t.title,onClick:()=>c==null?void 0:c(t),className:["absolute w-3 h-3 rounded-full -translate-x-1/2 -translate-y-1/2","transition-transform hover:scale-150 focus:outline-none",u.dot,g?"ring-2 ring-offset-1 ring-indigo-500 scale-125":"",c?"cursor-pointer":"cursor-default"].filter(Boolean).join(" "),style:{left:`${i}%`,top:`${b}%`},"aria-label":t.title},t.id)})]})}),e.jsx("div",{className:"flex flex-wrap gap-x-4 gap-y-1",children:Object.entries(C).map(([t,{legend:i,label:b}])=>e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${i} flex-shrink-0`}),e.jsx("span",{className:"text-xs text-brand-text-muted dark:text-brand-dark-text-muted",children:b})]},t))}),n.length===0&&e.jsx("p",{className:"text-sm text-center text-brand-text-muted dark:text-brand-dark-text-muted py-4",children:"No PESTEL items with impact and uncertainty scores yet."})]})}function ie({organizationId:o,pestelItems:c,onPairSelected:d,aiGuided:n=!0}){const i=!V(o,{feature:"financial_analysis",minRole:"MEMBER"}).allowed,[b,u]=l.useState(n?"ai":"manual"),g=i?"manual":b,[k,y]=l.useState([]),[h,j]=l.useState(""),[p,f]=l.useState(""),[N,_]=l.useState(""),[s,a]=l.useState(""),[m,x]=l.useState(""),[w,v]=l.useState(""),I=ae(),Y=I.isPending,X=h&&p&&h===p,H=h&&p&&!X&&N.trim()&&s.trim()&&m.trim()&&w.trim();function $(){I.mutate({orgId:o},{onSuccess:r=>{y(r)}})}function O(r){d({pestelIdX:r.pestel_id_x,pestelIdY:r.pestel_id_y,axisXLowLabel:r.suggested_x_low,axisXHighLabel:r.suggested_x_high,axisYLowLabel:r.suggested_y_low,axisYHighLabel:r.suggested_y_high})}function Q(){H&&d({pestelIdX:h,pestelIdY:p,axisXLowLabel:N,axisXHighLabel:s,axisYLowLabel:m,axisYHighLabel:w})}function G(r){const S=Math.round(r*100);return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex-1 h-1.5 bg-gray-200 dark:bg-gray-700 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full bg-indigo-500",style:{width:`${S}%`}})}),e.jsxs("span",{className:"text-xs text-brand-text-muted dark:text-brand-dark-text-muted w-8 text-right",children:[S,"%"]})]})}return e.jsxs("div",{className:"flex flex-col gap-4",children:[g==="ai"&&e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-sm text-brand-text-muted dark:text-brand-dark-text-muted",children:"Let AI suggest the best driving force pairings based on your PESTEL analysis."}),e.jsx(A,{variant:"primary",size:"sm",isLoading:Y,onClick:$,children:Y?"Analysing…":"Suggest Pairings"})]}),k.length>0&&e.jsx("div",{className:"flex flex-col gap-3",children:k.map((r,S)=>e.jsxs("button",{onClick:()=>O(r),className:"flex flex-col gap-2 p-4 rounded-lg border border-brand-border-subtle dark:border-brand-dark-border bg-white dark:bg-gray-900 hover:border-indigo-400 dark:hover:border-indigo-500 hover:bg-indigo-50 dark:hover:bg-indigo-900/20 text-left transition-colors focus:outline-none focus:ring-2 focus:ring-focus",children:[e.jsxs("span",{className:"font-medium text-sm text-brand-text-primary dark:text-brand-dark-text-primary",children:[r.pestel_title_x,e.jsx("span",{className:"mx-2 text-gray-400",children:"×"}),r.pestel_title_y]}),e.jsxs("div",{className:"w-full",children:[e.jsx("span",{className:"text-xs text-brand-text-muted dark:text-brand-dark-text-muted mb-1 block",children:"Independence"}),G(r.independence_score)]}),e.jsx("p",{className:"text-xs text-brand-text-muted dark:text-brand-dark-text-muted leading-relaxed",children:r.rationale}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 mt-1",children:[e.jsxs("div",{className:"text-xs",children:[e.jsx("span",{className:"text-gray-400 dark:text-brand-dark-text-muted",children:"X: "}),e.jsxs("span",{className:"text-brand-text-secondary dark:text-brand-dark-text-secondary",children:[r.suggested_x_low," → ",r.suggested_x_high]})]}),e.jsxs("div",{className:"text-xs",children:[e.jsx("span",{className:"text-gray-400 dark:text-brand-dark-text-muted",children:"Y: "}),e.jsxs("span",{className:"text-brand-text-secondary dark:text-brand-dark-text-secondary",children:[r.suggested_y_low," → ",r.suggested_y_high]})]})]})]},S))}),e.jsx("button",{onClick:()=>u("manual"),className:"text-sm text-indigo-600 dark:text-indigo-400 hover:underline text-left self-start",children:"Or select forces manually"})]}),g==="manual"&&e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("label",{className:"text-sm font-medium text-brand-text-secondary dark:text-brand-dark-text-secondary",children:"X-Axis Driving Force"}),e.jsxs("select",{value:h,onChange:r=>j(r.target.value),className:"rounded-lg border border-brand-border dark:border-brand-dark-border bg-brand-bg-card dark:bg-brand-dark-bg-card text-sm text-brand-text-primary dark:text-brand-dark-text-primary px-3 py-2 focus:outline-none focus:ring-2 focus:ring-focus",children:[e.jsx("option",{value:"",children:"Select PESTEL item…"}),c.map(r=>
1e.jsxs("option",{value:r.id,children:["[",r.category.charAt(0).toUpperCase(),"] ",r.title]},r.id))]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 mt-1",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-brand-text-muted dark:text-brand-dark-text-muted",children:"Low label"}),e.jsx("input",{type:"text",value:N,onChange:r=>_(r.target.value),placeholder:"e.g. Permissive",className:"mt-0.5 w-full rounded border border-brand-border dark:border-brand-dark-border bg-brand-bg-card dark:bg-brand-dark-bg-card text-sm text-brand-text-primary dark:text-brand-dark-text-primary px-2 py-1.5 focus:outline-none focus:ring-1 focus:ring-focus"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-brand-text-muted dark:text-brand-dark-text-muted",children:"High label"}),e.jsx("input",{type:"text",value:s,onChange:r=>a(r.target.value),placeholder:"e.g. Restrictive",className:"mt-0.5 w-full rounded border border-brand-border dark:border-brand-dark-border bg-brand-bg-card dark:bg-brand-dark-bg-card text-sm text-brand-text-primary dark:text-brand-dark-text-primary px-2 py-1.5 focus:outline-none focus:ring-1 focus:ring-focus"})]})]})]}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("label",{className:"text-sm font-medium text-brand-text-secondary dark:text-brand-dark-text-secondary",children:"Y-Axis Driving Force"}),e.jsxs("select",{value:p,onChange:r=>f(r.target.value),className:"rounded-lg border border-brand-border dark:border-brand-dark-border bg-brand-bg-card dark:bg-brand-dark-bg-card text-sm text-brand-text-primary dark:text-brand-dark-text-primary px-3 py-2 focus:outline-none focus:ring-2 focus:ring-focus",children:[e.jsx("option",{value:"",children:"Select PESTEL item…"}),c.map(r=>e.jsxs("option",{value:r.id,children:["[",r.category.charAt(0).toUpperCase(),"] ",r.title]},r.id))]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 mt-1",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-brand-text-muted dark:text-brand-dark-text-muted",children:"Low label"}),e.jsx("input",{type:"text",value:m,onChange:r=>x(r.target.value),placeholder:"e.g. Slow adoption",className:"mt-0.5 w-full rounded border border-brand-border dark:border-brand-dark-border bg-brand-bg-card dark:bg-brand-dark-bg-card text-sm text-brand-text-primary dark:text-brand-dark-text-primary px-2 py-1.5 focus:outline-none focus:ring-1 focus:ring-focus"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-brand-text-muted dark:text-brand-dark-text-muted",children:"High label"}),e.jsx("input",{type:"text",value:w,onChange:r=>v(r.target.value),placeholder:"e.g. Rapid adoption",className:"mt-0.5 w-full rounded border border-brand-border dark:border-brand-dark-border bg-brand-bg-card dark:bg-brand-dark-bg-card text-sm text-brand-text-primary dark:text-brand-dark-text-primary px-2 py-1.5 focus:outline-none focus:ring-1 focus:ring-focus"})]})]})]})]}),X&&e.jsx("p",{className:"text-sm text-red-600 dark:text-red-400",children:"X and Y axes cannot use the same PESTEL item."}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(A,{variant:"primary",size:"sm",disabled:!H,onClick:Q,children:"Use This Pairing"}),n&&!i&&e.jsx("button",{onClick:()=>u("ai"),className:"text-sm text-indigo-600 dark:text-indigo-400 hover:underline",children:"Back to AI suggestions"})]})]})]})}const L=["top_left","top_right","bottom_left","bottom_right"],T={top_left:"Top Left",top_right:"Top Right",bottom_left:"Bottom Left",bottom_right:"Bottom Right"},F=[{label:"Score PESTEL"},{label:"Select Forces"},{label:"Build Matrix"},{label:"Draft Narratives"}];function le({currentStep:o}){return e.jsx("nav",{"aria-label":"Progress",className:"mb-8",children:e.jsx("ol",{className:"flex items-center gap-0",children:F.map((c,d)=>{const n=d+1,t=n<o,i=n===o;return e.jsxs(q.Fragment,{children:[e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("div",{className:["flex items-center justify-center w-8 h-8 rounded-full text-sm font-semibold flex-shrink-0 transition-colors",t?"bg-indigo-600 text-white":i?"bg-indigo-100 dark:bg-indigo-900/40 text-indigo-700 dark:text-indigo-300 ring-2 ring-indigo-600":"bg-gray-100 dark:bg-gray-800 text-gray-400 dark:text-brand-dark-text-muted"].join(" "),children:t?e.jsx(D,{className:"w-4 h-4"}):n}),e.jsx("span",{className:["text-sm font-medium hidden sm:block",i?"text-brand-text-primary dark:text-brand-dark-text-primary":t?"text-indigo-600 dark:text-indigo-400":"text-gray-400 dark:text-brand-dark-text-muted"].join(" "),children:c.label})]}),d<F.length-1&&e.jsx("div",{className:"flex-1 mx-3 h-px bg-gray-200 dark:bg-gray-700"})]},n)})})})}function R({title:o,badge:c,defaultOpen:d=!1,children:n}){const[t,i]=l.useState(d),b=l.useId();return e.jsxs("div",{className:"rounded-xl border border-brand-border-subtle dark:border-brand-dark-border overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:()=>i(u=>!u),"aria-expanded":t,"aria-controls":t?b:void 0,className:"flex w-full items-center gap-3 px-4 py-3 text-left transition-colors hover:bg-brand-bg-subtle dark:hover:bg-brand-dark-bg-subtle",children:[e.jsx(P,{className:ee("w-4 h-4 flex-shrink-0 text-brand-text-muted transition-transform duration-150",t&&"rotate-90"),"aria-hidden":"true"}),e.jsx("span",{className:"flex-1 text-sm font-semibold text-brand-text-primary dark:text-brand-dark-text-primary",children:o}),c&&e.jsx("span",{className:"flex-shrink-0 text-xs font-medium text-brand-text-muted dark:text-brand-dark-text-muted",children:c})]}),t&&e.jsx("div",{id:b,className:"border-t border-brand-border-subtle dark:border-brand-dark-border",children:n})]})}const oe=["political","economic","social","technological","environmental","legal"],ce={political:"Political",economic:"Economic",social:"Social",technological:"Technological",environmental:"Environmental",legal:"Legal"};function xe({orgId:o,onNext:c}){const[d,n]=l.useState([]),[t,i]=l.useState({}),[b,u]=l.useState(!0),[g,k]=l.useState(null),[y,h]=l.useState({});l.useEffect(()=>{async function s(){try{u(!0);const{data:a}=await B.get(`/organizations/${o}/pestel-items`);n(a);const m={};for(const x of a)m[x.id]={impact:x.impact_score,uncertainty:x.uncertainty_score};i(m)}catch{k("Failed to load PESTEL items.")}finally{u(!1)}}o&&s()},[o]);async function j(s,a,m){i(v=>({...v,[s]:{...v[s],[a]:m}}));const x={},w=t[s]??{};x.impact_score=a==="impact"?m:w.impact??null,x.uncertainty_score=a==="uncertainty"?m:w.uncertainty??null,h(v=>({...v,[s]:!0}));try{await B.put(`/pestel-items/${s}`,x)}catch{}finally{h(v=>({...v,[s]:!1}))}}const p=d.map(s=>{var a,m;return{...s,impact_score:((a=t[s.id])==null?void 0:a.impact)??s.impact_score,uncertainty_score:((m=t[s.id])==null?void 0:m.uncertainty)??s.uncertainty_score}}),f=p.filter(s=>s.impact_score!==null&&s.uncertainty_score!==null).length,N=s=>{const a=t[s.id]??{impact:null,uncertainty:null};return e.jsxs("tr",{className:"bg-white dark:bg-gray-900 hover:bg-gray-50 dark:hover:bg-gray-800/50 transition-colors",children:[e.jsxs("td",{className:"px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-xs font-medium bg-brand-bg-subtle dark:bg-brand-dark-bg-subtle text-gray-600 dark:text-gray-300 uppercase",children:s.category.charAt(0)}),e.jsx("span",{className:"text-brand-text-primary dark:text-brand-dark-text-primary font-medium line-clamp-1",children:s.title}),y[s.id]&&e.jsx(E,{className:"w-3 h-3 animate-spin text-gray-400"})]}),s.description&&e.jsx("p",{className:"text-xs text-brand-text-muted dark:text-brand-dark-text-muted mt-0.5 line-clamp-1 ml-7",children:s.description})]}),["impact","uncertainty"].map(m=>e.jsx("td",{className:"px-4 py-3",children:e.jsxs("select",{value:a[m]??"",onChange:x=>j(s.id,m,x.target.value===""?null:Number(x.target.value)),className:"w-20 rounded border border-brand-border dark:border-brand-dark-border bg-brand-bg-card dark:bg-brand-dark-bg-card text-brand-text-primary dark:text-brand-dark-text-primary px-2 py-1 text-sm focus:outline-none focus:ring-2 focus:ring-focus",children:[e.jsx("option",{value:"",children:"—"}),[1,2,3,4,5].map(x=>e.jsx("option",{value:x,children:x},x))]})},m))]},s.id)},_=()=>e.jsx("thead",{children:e.jsxs("tr",{className:"bg-gray-50 dark:bg-gray-800 text-xs uppercase tracking-wide text-brand-text-muted dark:text-brand-dark-text-muted",children:[e.jsx("th",{className:"text-left px-4 py-3 font-medium",children:"Item"}),e.jsx("th",{className:"text-left px-4 py-3 font-medium w-24",children:"Impact (1-5)"}),e.jsx("th",{className:"text-left px-4 py-3 font-medium w-32",children:"Uncertainty (1-5)"})]})});return b?e.jsx("div",{className:"flex items-center justify-center py-16",children:e.jsx(E,{className:"w-6 h-6 animate-spin text-indigo-600 dark:text-indigo-300"})}):g?e.jsxs("div",{className:"flex items-center gap-2 text-red-600 dark:text-red-400 py-8",children:[e.jsx(U,{className:"w-5 h-5 flex-shrink-0"}),e.jsx("span",{children:g})]}):e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsxs("p",{className:"text-sm text-brand-text-muted dark:text-brand-dark-text-muted",children:["Score each PESTEL item on ",e.jsx("strong",{children:"impact"})," (how much it affects your strategy) and"," ",e.jsx("strong",{children:"uncertainty"})," (how unpredictable it is). Items scoring high on both are driving forces — the best candidates for scenario axes."]}),d.length===0?e.jsx("div",{className:"rounded-xl border border-brand-border-subtle dark:border-brand-dark-border px-4 py-8 text-center text-sm text-gray-400 dark:text-brand-dark-text-muted",children:"No PESTEL items found. Add items in the PESTEL Analysis page first."}):e.jsx("div",{className:"flex flex-col gap-3",children:oe.map(s=>{const a=p.filter(x=>x.category===s);if(a.length===0)return null;const m=a.filter(x=>x.impact_score!==null&&x.uncertainty_score!==null).length;return e.jsx(R,{title:ce[s],badge:`${m}/${a.length} scored`,children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx(_,{}),e.jsx("tbody",{className:"divide-y divide-gray-100 dark:divide-gray-700",children:a.map(N)})]})})},s)})}),f>=2&&e.jsx(R,{title:"Impact / Uncertainty Matrix Preview",children:e.jsx("div",{className:"p-4",children:e.jsx(ne,{items:p})})}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsxs("p",{className:"text-sm text-brand-text-muted dark:text-brand-dark-text-muted",children:[f," item",f!==1?"s":""," scored",f<2&&" — score at least 2 items to continue"]}),e.jsxs("button",{onClick:()=>c(p),disabled:f<2,className:"flex items-center gap-2 px-5 py-2 bg-indigo-600 hover:bg-indigo-700 disabled:bg-gray-300 dark:disabled:bg-gray-700 text-white disabled:text-gray-500 dark:disabled:text-brand-dark-text-secondary font-medium rounded-lg transition-colors",children:["Next",e.jsx(P,{className:"w-4 h-4"})]})]})]})}function be({orgId:o,scoredItems:c,onNext:d,onBack:n}){const[t,i]=l.useState(null);return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx("p",{className:"text-sm text-brand-text-muted dark:text-brand-dark-text-muted",children:"Choose two driving forces from your PESTEL analysis. These will form the X and Y axes of your 2x2 scenario matrix. Use AI suggestions for the best combination or select manually."}),e.jsx(ie,{organizationId:o,pestelItems:c.filter(b=>b.impact_score!==null&&b.uncertainty_score!==null),onPairSelected:b=>i(b)}),t&&e.jsxs("div",{className:"rounded-lg bg-indigo-50 dark:bg-indigo-900/20 border border-indigo-200 dark:border-indigo-700 p-4",children:[e.jsx("p",{className:"text-sm font-medium text-indigo-800 dark:text-indigo-300 mb-1",children:"Pairing selected"}),e.jsxs("p",{className:"text-xs text-indigo-700 dark:text-indigo-400",children:["X-axis: ",t.axisXLowLabel," → ",t.axisXHighLabel]}),e.jsxs("p",{className:"text-xs text-indigo-700 dark:text-indigo-400",children:["Y-axis: ",t.axisYLowLabel," → ",t.axisYHighLabel]})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsx("button",{onClick:n,className:"text-sm text-brand-text-muted dark:text-brand-dark-text-muted hover:text-gray-700 dark:hover:text-gray-200 transition-colors",children:"Back"}),e.jsxs("button",{onClick:()=>t&&d(t),disabled:!t,className:"flex items-center gap-2 px-5 py-2 bg-indigo-600 hover:bg-indigo-700 disabled:bg-gray-300 dark:disabled:bg-gray-700 text-white disabled:text-gray-500 dark:disabled:text-brand-dark-text-secondary font-medium rounded-lg transition-colors",children:["Next",e.jsx(P,{className:"w-4 h-4"})]})]})]})}function me({orgId:o,planId:c,axisConfig:d,onNext:n,onBack:t}){const[i,b]=l.useState(""),[u,g]=l.useState(""),[k,y]=l.useState(""),[h,j]=l.useState({top_left:"",top_right:"",bottom_left:"",bottom_right:""}),p=re(),f=L.every(a=>h[a].trim()),N=i.trim()&&f;async function _(){N&&p.mutate({orgId:o,strategic_plan_id:c,name:i.trim(),description:u.trim()||null,time_horizon:k.trim()||null,axis_x_pestel_id:d.pestelIdX,axis_x_low_label:d.axisXLowLabel,axis_x_high_label:d.axisXHighLabel,axis_y_pestel_id:d.pestelIdY,axis_y_low_label:d.axisYLowLabel,axis_y_high_label:d.axisYHighLabel,scenarios:L.map(a=>({quadrant:a,name:h[a].trim()}))},{onSuccess:a=>{n(a.id,h)}})}const s=L.map(a=>({id:a,organization_id:o,scenario_set_id:"",quadrant:a,name:h[a]||T[a],narrative:null,assumed_conditions:null,ai_draft:null,user_contributions:null,scenario_status:"ai_draft",created_at:"",updated_at:""}));return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx("p",{className:"text-sm text-brand-text-muted dark:text-brand-dark-text-muted",children:"Give your scenario set a name and name each of the four quadrant scenarios. The matrix preview updates as you type."}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-brand-text-secondary dark:text-brand-dark-text-secondary mb-1",children:["Scenario Set Name ",e.jsx("span",{className:"text-red-500 dark:text-red-300",children:"*"})]}),e.jsx("input",{type:"text",value:i,onChange:a=>b(a.target.value),placeholder:"e.g. 6G Telecom Futures 2030",className:"w-full rounded-lg border border-brand-border dark:border-brand-dark-border bg-brand-bg-card dark:bg-brand-dark-bg-card text-brand-text-primary dark:text-brand-dark-text-primary px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-focus"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-brand-text-secondary dark:text-brand-dark-text-secondary mb-1",children:"Description"}),e.jsx("textarea",{value:u,onChange:a=>g(a.target.value),rows:2,placeholder:"Brief description of this scenario exercise",className:"w-full rounded-lg border border-brand-border dark:border-brand-dark-border bg-brand-bg-card dark:bg-brand-dark-bg-card text-brand-text-primary dark:text-brand-dark-text-primary px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-focus resize-y"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-brand-text-secondary dark:text-brand-dark-text-secondary mb-1",children:"Time Horizon"}),e.jsx("input",{type:"text",value:k,onChange:a=>y(a.target.value),placeholder:"e.g. 2030, 3-5 years",className:"w-full rounded-lg border border-brand-border dark:border-brand-dark-border bg-brand-bg-card dark:bg-brand-dark-bg-card text-brand-text-primary dark:text-brand-dark-text-primary px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-focus"})]}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm font-medium text-brand-text-secondary dark:text-brand-dark-text-secondary mb-2",children:["Quadrant Names ",e.jsx("span",{className:"text-red-500 dark:text-red-300",children:"*"})]}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:L.map(a=>e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-brand-text-muted dark:text-brand-dark-text-muted mb-1",children:T[a]}),e.jsx("input",{type:"text",value:h[a],onChange:m=>j(x=>({...x,[a]:m.target.value})),placeholder:`e.g. ${T[a]} scenario`,className:"w-full rounded border border-brand-border dark:border-brand-dark-border bg-brand-bg-card dark:bg-brand-dark-bg-card text-brand-text-primary dark:text-brand-dark-text-primary 
1px-2 py-1.5 text-sm focus:outline-none focus:ring-2 focus:ring-focus"})]},a))})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-wide text-brand-text-muted dark:text-brand-dark-text-muted mb-3",children:"Matrix Preview"}),e.jsx(z,{axisXLowLabel:d.axisXLowLabel,axisXHighLabel:d.axisXHighLabel,axisYLowLabel:d.axisYLowLabel,axisYHighLabel:d.axisYHighLabel,scenarios:s})]})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsx("button",{onClick:t,className:"text-sm text-brand-text-muted dark:text-brand-dark-text-muted hover:text-gray-700 dark:hover:text-gray-200 transition-colors",children:"Back"}),e.jsxs("button",{onClick:_,disabled:!N||p.isPending,className:"flex items-center gap-2 px-5 py-2 bg-indigo-600 hover:bg-indigo-700 disabled:bg-gray-300 dark:disabled:bg-gray-700 text-white disabled:text-gray-500 dark:disabled:text-brand-dark-text-secondary font-medium rounded-lg transition-colors",children:[p.isPending&&e.jsx(E,{className:"w-4 h-4 animate-spin"}),"Create Scenarios",e.jsx(P,{className:"w-4 h-4"})]})]})]})}function ue({setId:o,onFinish:c,onBack:d}){const{data:n,isLoading:t}=se(o,{enabled:!!o}),[i,b]=l.useState(null),u=i&&n?n.scenarios.find(g=>g.quadrant===i)??null:null;return t?e.jsx("div",{className:"flex items-center justify-center py-16",children:e.jsx(E,{className:"w-6 h-6 animate-spin text-indigo-600 dark:text-indigo-300"})}):n?e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx("p",{className:"text-sm text-brand-text-muted dark:text-brand-dark-text-muted",children:"Click a quadrant to open its narrative editor. Generate AI drafts, respond to guided prompts, or write narratives directly. You can always return later — click Finish when ready."}),e.jsx(z,{axisXLowLabel:n.axis_x_low_label??"",axisXHighLabel:n.axis_x_high_label??"",axisYLowLabel:n.axis_y_low_label??"",axisYHighLabel:n.axis_y_high_label??"",scenarios:n.scenarios,activeQuadrant:i,onQuadrantClick:g=>b(k=>k===g?null:g)}),u&&e.jsxs("div",{className:"border border-indigo-200 dark:border-indigo-700 rounded-xl p-5 bg-indigo-50 dark:bg-indigo-900/10",children:[e.jsx("h3",{className:"text-sm font-semibold text-brand-text-primary dark:text-brand-dark-text-primary mb-4",children:u.name}),e.jsx(de,{scenario:u})]}),!u&&e.jsx("p",{className:"text-sm text-gray-400 dark:text-brand-dark-text-muted text-center py-2",children:"Click a quadrant above to draft its narrative."}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsx("button",{onClick:d,className:"text-sm text-brand-text-muted dark:text-brand-dark-text-muted hover:text-gray-700 dark:hover:text-gray-200 transition-colors",children:"Back"}),e.jsxs("button",{onClick:c,className:"flex items-center gap-2 px-5 py-2 bg-indigo-600 hover:bg-indigo-700 text-white font-medium rounded-lg transition-colors",children:[e.jsx(D,{className:"w-4 h-4"}),"Finish"]})]})]}):e.jsx("p",{className:"text-red-500 dark:text-red-300 py-4",children:"Failed to load scenario set. Please refresh."})}function je(){const{orgId:o}=W(),[c]=Z(),d=J(),n=c.get("plan_id")??"",[t,i]=l.useState(1),[b,u]=l.useState([]),[g,k]=l.useState(null),[y,h]=l.useState(null),j=o??"",p=l.useCallback(()=>{d(y?`/external-scenarios/${y}`:-1)},[y,d]);return!j||!n?e.jsxs("div",{className:"flex flex-col items-center justify-center py-24 gap-3",children:[e.jsx(U,{className:"w-10 h-10 text-red-400"}),e.jsx("p",{className:"text-brand-text-muted dark:text-brand-dark-text-muted",children:"Missing organization or plan context. Please navigate here from the Scenario Planning page."}),e.jsx("button",{onClick:()=>d(-1),className:"text-sm text-indigo-600 dark:text-indigo-400 hover:underline",children:"Go back"})]}):e.jsxs(e.Fragment,{children:[e.jsx("header",{className:"bg-white dark:bg-brand-dark-bg-card border-b border-gray-200 dark:border-brand-dark-border px-4 lg:px-6 py-4",children:e.jsx(te,{title:"Build External Scenario Set",subtitle:"Create a 2x2 scenario matrix from your PESTEL driving forces",icon:e.jsx(K,{className:"w-8 h-8 text-indigo-600 dark:text-indigo-400"}),breadcrumbs:[{label:"Scenario Planning",href:"/scenarios"},{label:"New External Scenario"}],className:"mb-0"})}),e.jsxs("main",{className:"flex-1 overflow-y-auto p-6 lg:p-8 w-full",children:[e.jsx(le,{currentStep:t}),e.jsxs("div",{className:"bg-white dark:bg-brand-dark-bg-card rounded-xl border border-brand-border-subtle dark:border-brand-dark-border p-6",children:[t===1&&e.jsx(xe,{orgId:j,onNext:f=>{u(f),i(2)}}),t===2&&e.jsx(be,{orgId:j,scoredItems:b,onNext:f=>{k(f),i(3)},onBack:()=>i(1)}),t===3&&g&&e.jsx(me,{orgId:j,planId:n,axisConfig:g,onNext:(f,N)=>{h(f),i(4)}
1,onBack:()=>i(2)}),t===4&&y&&e.jsx(ue,{setId:y,onFinish:p,onBack:()=>i(3)})]})]})]})}export{je as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.