1import{r as h,b5 as D,b6 as K,b7 as Y,_ as B,j as e,c as _,B as y,L as I,aT as V,b8 as H,u as b,b9 as F,C as G,ao as J,a as $,X as O,ag as U,aY as X,am as Q,A as Z,ay as W,aq as L,R as ee,b as P,I as te,T as se,ba as ne,bb as C,d as ae,aJ as re,f as le}from"./index-C-B5SaCl.js";import{e as ie,R as q,g as E,i as oe,S as M,r as ce,h as de,j as me}from"./sellerJourney-CfNjuOW7.js";import{S as ue}from"./shield-off-eedPNApH.js";import{u as xe}from"./useRecordAdvice-DzAjVKYj.js";const N=B,A={instruction:null,property:null,parties:[],people:{},readiness:null,projection:null,opportunity:null,valuation:null,vendorInput:null,fees:null,events:[]};function pe(a){const[l,n]=h.useState(!0),[r,o]=h.useState(null),[c,m]=h.useState(A),u=h.useCallback(async()=>{if(!a){m(A),n(!1);return}o(null);try{const{data:i,error:s}=await N.from("instructions").select("*").eq("id",a).maybeSingle();if(s)throw s;if(!i){m(A),o("That instruction doesn't exist, or you don't have access to it.");return}const[d,t,f,p,w,x]=await Promise.all([D(i.id),K(i.id),N.from("properties").select("id, display_address, postcode, lifecycle_state").eq("id",i.property_id).maybeSingle().then(g=>g.data??null),N.from("seller_opportunities").select("*").eq("id",i.seller_opportunity_id).maybeSingle().then(g=>g.data??null),N.from("property_fees").select("*").eq("property_id",i.property_id).maybeSingle().then(g=>g.data??null),Y(i.id,60).catch(()=>[])]),S=Array.from(new Set(d.map(g=>g.person_id).filter(Boolean))),v={};if(S.length){const{data:g}=await N.from("clients").select("id, full_name, first_name, last_name, email, phone").in("id",S);for(const j of g??[])v[j.id]={id:j.id,name:j.full_name||[j.first_name,j.last_name].filter(Boolean).join(" ")||"Seller",email:j.email??null,phone:j.phone??null}}const T=await N.from("valuation_opportunities").select("id, recommended_marketing_price, low_price, high_price, fee_percentage, fee_fixed_amount, vat_treatment, seller_expectation_amount, seller_timing, seller_moving_plans, carried_out_at, property_type, bedrooms, tenure, valuer_user_id").eq("seller_opportunity_id",i.seller_opportunity_id).order("created_at",{ascending:!1}).limit(1).maybeSingle().then(g=>g.data??null),z=T?await N.from("pvp_vendor_input").select("priorities, journey_stage, free_text, answered_at").eq("valuation_id",T.id).order("answered_at",{ascending:!1}).limit(1).maybeSingle().then(g=>g.data??null):null,R={};for(const[g,j]of Object.entries(v))R[g]=j.name;m({instruction:i,property:f,parties:d,people:v,readiness:t,projection:ie(t,d,R),opportunity:p,valuation:T,vendorInput:z,fees:w,events:x})}catch(i){o(i instanceof Error?i.message:"Couldn't load this instruction.")}finally{n(!1)}},[a]);return h.useEffect(()=>{n(!0),u()},[u]),h.useMemo(()=>({loading:l,error:r,reload:u,...c}),[l,r,u,c])}const k=a=>typeof a=="number"&&Number.isFinite(a)?`£${Math.round(a).toLocaleString("en-GB")}`:null;function he(a){const l=[],{instruction:n,valuation:r,fees:o,vendorInput:c,opportunity:m}=a,u=k((n==null?void 0:n.asking_price)??null),i=k((r==null?void 0:r.recommended_marketing_price)??null);(u||i)&&l.push({label:"Price",value:u??`${i} recommended â no agreed asking price yet`,provenance:u?"Recorded on the instruction":"Valuation recommendation",contradiction:u&&i&&u!==i?`We recommended ${i} at the valuation.`:void 0});const s=typeof(n==null?void 0:n.fee_pct)=="number"?`${n.fee_pct}%`:k((n==null?void 0:n.fee_fixed)??null),d=(o==null?void 0:o.fee_type)==="fixed"?k((o==null?void 0:o.fee_fixed)??null):typeof(o==null?void 0:o.fee_percent)=="number"?`${o.fee_percent}%`:null;(s||d)&&l.push({label:"Fee",value:s??d??"",provenance:s?"Carried across at take-on":"Property fee record",contradiction:s&&d&&s!==d?`The property record holds ${d}.`:void 0}),n!=null&&n.vat_treatment&&l.push({label:"VAT",value:n.vat_treatment==="inc_vat"?"Including VAT":"Plus VAT",provenance:"Normalised at take-on"}),r!=null&&r.seller_expectation_amount&&l.push({label:"Their expectation",value:k(r.seller_expectation_amount)??"",provenance:"Told us at the valuation"}),c!=null&&c.journey_stage&&l.push({label:"Where they are",value:String(c.journey_stage).replace(/_/g," "),provenance:"The seller told us themselves"});const t=Array.isArray(c==null?void 0:c.priorities)?c.priorities:[];return t.length&&l.push({label:"What matters to them",value:t.map(f=>String(f).replace(/_/g," ")).join(", "),provenance:"The seller told us themselves"}),r!=null&&r.seller_timing&&l.push({label:"Timing",value:String(r.seller_timing),provenance:"Recorded at the valuation"}),m!=null&&m.buying_onward&&l.push({label:"Onward move",value:String(m.buying_onward).replace(/_/g," "),provenance:"Relationship record"}),l}
1const ge={seller:"text-amber-600 dark:text-amber-400",provider:"text-sky-600 dark:text-sky-400",staff:"text-foreground",system:"text-muted-foreground"};function fe({instructionId:a,version:l,addressLabel:n,projection:r,onSelect:o,onChanged:c}){const[m,u]=h.useState(!1),{counts:i,blockers:s,readyForMarket:d,onMarket:t}=r,f=async()=>{u(!0);try{const p=await H({instruction_id:a,expected_version:l});b.success(p.outcome==="replayed"?"Already on the market â nothing changed":`${n} is on the market`),await c()}catch(p){b.error(p instanceof F?p.message:"Launch was refused. Nothing has changed.")}finally{u(!1)}};return e.jsxs("section",{className:_("rounded-lg border p-4",t||d?"border-emerald-500/40 bg-emerald-500/5":"bg-card"),children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-muted-foreground",children:"Getting ready for market"}),e.jsx("h2",{className:"mt-1 text-[15px] font-semibold leading-tight",children:t?"On the market.":s.length===0?"Nothing is standing in the way.":`${s.length} thing${s.length===1?"":"s"} preventing launch.`}),e.jsxs("p",{className:"mt-1 text-[12.5px] text-muted-foreground",children:[i.complete," of ",i.total," done",i.waitingOnSeller>0?` · ${i.waitingOnSeller} with the seller`:"",i.withProvider>0?` · ${i.withProvider} with a provider`:"",i.withUs>0?` · ${i.withUs} with us`:""]})]}),t?null:e.jsxs(y,{size:"sm",className:"h-8 shrink-0",disabled:!d||m,onClick:f,children:[m?e.jsx(I,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}):e.jsx(V,{className:"mr-1.5 h-3.5 w-3.5"}),"Put it on the market"]})]}),!t&&s.length>0?e.jsx("ul",{className:"mt-3 divide-y rounded-md border bg-background",children:s.slice(0,4).map(p=>e.jsx("li",{children:e.jsxs("button",{type:"button",onClick:()=>o(p),className:"flex w-full items-center gap-3 px-3 py-2 text-left hover:bg-muted/50",children:[e.jsxs("span",{className:"min-w-0 flex-1 truncate text-[13px]",children:[p.label,p.personName?e.jsxs("span",{className:"text-muted-foreground",children:[" · ",p.personName]}):null]}),e.jsx("span",{className:_("shrink-0 text-[11.5px]",ge[p.responsibility]??"text-muted-foreground"),children:q[p.responsibility]})]})},p.id))}):null,!t&&s.length>4?e.jsxs("p",{className:"mt-1.5 text-[11.5px] text-muted-foreground",children:["And ",s.length-4," more, grouped below."]}):null,!t&&!d&&s.length===0?e.jsx("p",{className:"mt-3 text-[12.5px] text-muted-foreground",children:"Readiness is derived by the database, and it isn't satisfied yet. Refresh if this looks wrong â nothing here can force a launch."}):null]})}function be({r:a}){return a.state==="needs_attention"?e.jsx(J,{className:"h-3.5 w-3.5 shrink-0 text-destructive"}):a.met?e.jsx($,{className:"h-3.5 w-3.5 shrink-0 text-emerald-600 dark:text-emerald-400"}):a.state==="waiting_for_seller"||a.state==="with_provider"?e.jsx(O,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}):e.jsx("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full bg-muted-foreground/50"})}function ye({projection:a,onSelect:l}){return e.jsx("div",{className:"space-y-3",children:a.areas.map(n=>e.jsxs("section",{className:"rounded-lg border bg-card",children:[e.jsxs("header",{className:"flex items-baseline justify-between gap-3 border-b px-3 py-2",children:[e.jsx("h3",{className:"text-[12.5px] font-semibold",children:n.label}),e.jsxs("p",{className:"shrink-0 text-[11.5px] text-muted-foreground",children:[n.complete,"/",n.total," done",n.blockers>0?` · ${n.blockers} blocking`:""]})]}),e.jsx("ul",{className:"divide-y",children:n.requirements.map(r=>e.jsx("li",{children:e.jsxs("button",{type:"button",onClick:()=>l(r),className:"flex w-full items-center gap-2.5 px-3 py-2 text-left hover:bg-muted/50",children:[e.jsx(be,{r}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsxs("span",{className:_("block truncate text-[13px]",r.met?"text-muted-foreground":""),children:[r.label,r.personName?e.jsxs("span",{className:"text-muted-foreground",children:[" · ",r.personName]}):null]}),r.met?null:e.jsx("span",{className:"block truncate text-[11.5px] text-muted-foreground",children:r.need})]}),e.jsx("span",{className:"shrink-0 text-[11.5px] text-muted-foreground",children:r.met?r.stateLabel:q[r.responsibility]}),e.jsx(G,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground
1/60"})]})},r.id))})]},n.area))})}const je={primary_vendor:"Primary seller",joint_vendor:"Joint seller",authorised_contact:"Authorised contact"};function Ne({projection:a,people:l,onSelect:n}){return a.sellers.length===0?null:e.jsxs("section",{className:"rounded-lg border bg-card",children:[e.jsx("header",{className:"border-b px-3 py-2",children:e.jsx("h3",{className:"text-[12.5px] font-semibold",children:"Sellers"})}),e.jsx("ul",{className:"divide-y",children:a.sellers.map(r=>{const o=r.personId?l[r.personId]:null,c=r.requirements.filter(m=>!m.met);return e.jsxs("li",{className:"px-3 py-2.5",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-3",children:[e.jsx("p",{className:"min-w-0 truncate text-[13px] font-medium",children:r.name}),e.jsx("span",{className:"shrink-0 text-[11px] uppercase tracking-[0.1em] text-muted-foreground",children:je[r.role]??r.role})]}),o!=null&&o.email||o!=null&&o.phone?e.jsx("p",{className:"mt-0.5 truncate text-[11.5px] text-muted-foreground",children:[o.email,o.phone].filter(Boolean).join(" · ")}):null,r.nothingLeftForThem&&c.length===0?e.jsxs("p",{className:"mt-1.5 flex items-center gap-1.5 text-[12px] text-emerald-600 dark:text-emerald-400",children:[e.jsx($,{className:"h-3.5 w-3.5"}),"Nothing left for them to do"]}):e.jsx("ul",{className:"mt-1.5 space-y-1",children:c.map(m=>e.jsx("li",{children:e.jsxs("button",{type:"button",onClick:()=>n(m),className:"w-full truncate text-left text-[12px] text-muted-foreground hover:text-foreground",children:[m.label," â ",m.stateLabel.toLowerCase()]})},m.id))})]},r.partyId)})})]})}function ve({instructionId:a,sellers:l}){const[n,r]=h.useState([]),[o,c]=h.useState(null),m=async()=>{const{data:s}=await B.from("instruction_party_access").select("party_id, token, expires_at, last_seen_at").eq("instruction_id",a).is("revoked_at",null);r(s??[])};h.useEffect(()=>{m()},[a]);const u=async s=>{var d;c(s);try{const t=await oe(a,s);await((d=navigator.clipboard)==null?void 0:d.writeText(E(t.token)).catch(()=>{})),b.success("Link ready and copied. Send it only to that seller."),await m()}catch(t){b.error(t instanceof M?t.message:"Couldn't create that link.")}finally{c(null)}},i=async s=>{c(s);try{await ce(s),b.success("Link withdrawn. It no longer opens."),await m()}catch(d){b.error(d instanceof M?d.message:"Couldn't withdraw that link.")}finally{c(null)}};return e.jsxs("section",{className:"rounded-lg border bg-card",children:[e.jsxs("header",{className:"border-b px-3 py-2",children:[e.jsx("h3",{className:"text-[12.5px] font-semibold",children:"Seller journey links"}),e.jsx("p",{className:"mt-0.5 text-[11.5px] text-muted-foreground",children:"Each seller gets their own private link to their own items."})]}),e.jsx("ul",{className:"divide-y",children:l.map(s=>{const d=n.find(t=>t.party_id===s.partyId);return e.jsxs("li",{className:"flex items-center gap-2 px-3 py-2",children:[e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-[13px]",children:s.name}),e.jsx("span",{className:"block text-[11.5px] text-muted-foreground",children:d?d.last_seen_at?`Opened ${new Date(d.last_seen_at).toLocaleDateString()}`:"Link active, not opened yet":"No link yet"})]}),d?e.jsxs(e.Fragment,{children:[e.jsxs(y,{size:"sm",variant:"ghost",className:"h-7 shrink-0",onClick:()=>{var t;(t=navigator.clipboard)==null||t.writeText(E(d.token)),b.success("Link copied.")},children:[e.jsx(U,{className:"mr-1.5 h-3 w-3"})," Copy"]}),e.jsxs(y,{size:"sm",variant:"ghost",className:"h-7 shrink-0 text-destructive",disabled:o===s.partyId,onClick:()=>i(s.partyId),children:[e.jsx(ue,{className:"mr-1.5 h-3 w-3"})," Withdraw"]})]}):e.jsxs(y,{size:"sm",variant:"outline",className:"h-7 shrink-0",disabled:o===s.partyId,onClick:()=>u(s.partyId),children:[o===s.partyId?e.jsx(I,{className:"mr-1.5 h-3 w-3 animate-spin"}):e.jsx(X,{className:"mr-1.5 h-3 w-3"}),"Create link"]})]},s.partyId)})})]})}function _e({facts:a}){return a.length===0?null:e.jsxs("section",{className:"rounded-lg border bg-card",children:[e.jsxs("header",{className:"border-b px-3 py-2",children:[e.jsx("h3",{className:"text-[12.5px] font-semibold",children:"What we already know"}),e.jsx("p",{className:"mt-0.5 text-[11.5px] text-muted-foreground",children:"From the valuation and the property record. Don't ask for it again."})]}
1),e.jsx("dl",{className:"divide-y",children:a.map(l=>e.jsxs("div",{className:"px-3 py-2",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-3",children:[e.jsx("dt",{className:"shrink-0 text-[11.5px] text-muted-foreground",children:l.label}),e.jsx("dd",{className:"min-w-0 truncate text-right text-[13px] font-medium",children:l.value})]}),e.jsx("p",{className:"mt-0.5 text-right text-[11px] text-muted-foreground",children:l.provenance}),l.contradiction?e.jsxs("p",{className:"mt-1 flex items-start gap-1.5 rounded border border-amber-500/40 bg-amber-500/5 px-2 py-1 text-[11.5px] text-amber-700 dark:text-amber-400",children:[e.jsx(Q,{className:"mt-0.5 h-3 w-3 shrink-0"}),l.contradiction]}):null]},l.label))})]})}function ke(a){return xe("property",a,{itemKinds:["reminder","recommendation","intelligence"]})}function we({item:a,onRespond:l}){const n=a.item_kind==="intelligence";return e.jsxs("li",{className:_("rounded-md border p-2.5",n?"border-border/60 bg-background/60":"border-intelligence-rule/30 bg-background"),children:[e.jsx("p",{className:"text-[12.5px] font-medium leading-snug",children:a.what}),e.jsx("p",{className:"mt-1 text-[11.5px] leading-snug text-muted-foreground",children:a.how}),a.restraint_note?e.jsx("p",{className:"mt-1 text-[11px] leading-snug text-muted-foreground",children:a.restraint_note}):null,n?null:e.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[e.jsxs("button",{type:"button",onClick:()=>l("completed"),className:"inline-flex items-center gap-1 rounded border px-1.5 py-0.5 text-[11px] text-muted-foreground hover:bg-muted",children:[e.jsx($,{className:"h-3 w-3"})," Done"]}),e.jsxs("button",{type:"button",onClick:()=>l("not_now"),className:"inline-flex items-center gap-1 rounded border px-1.5 py-0.5 text-[11px] text-muted-foreground hover:bg-muted",children:[e.jsx(O,{className:"h-3 w-3"})," Not now"]}),e.jsxs("button",{type:"button",onClick:()=>l("not_important"),className:"inline-flex items-center gap-1 rounded border px-1.5 py-0.5 text-[11px] text-muted-foreground hover:bg-muted",children:[e.jsx(W,{className:"h-3 w-3"})," Not relevant"]})]})]})}function Se({instructionId:a,addressLabel:l,projection:n,onSelect:r}){const o=de(a,l,n),c=o.blockers.filter(s=>s.staffActionable),m=o.blockers.filter(s=>!s.staffActionable),{advice:u,respond:i}=ke(a);return e.jsxs("section",{className:"rounded-lg border border-intelligence-rule/40 bg-intelligence-rule/5 p-3",children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-intelligence-rule",children:"Sidekick"}),e.jsx("p",{className:"mt-1 text-[13px] font-medium leading-snug",children:n.onMarket?`${l} is live. Nothing to chase here.`:me(o)}),!n.onMarket&&c.length>0?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"mt-2 text-[11.5px] text-muted-foreground",children:c.length===o.count?"All of it is with us.":`${c.length} of them ${c.length===1?"is":"are"} ours to move.`}),e.jsx("ul",{className:"mt-1.5 space-y-1",children:c.map(s=>{const d=n.blockers.find(t=>t.requirementKey===s.requirementKey&&t.partyId===s.partyId);return e.jsx("li",{children:e.jsxs("button",{type:"button",disabled:!d,onClick:()=>d&&r(d),className:_("group flex w-full items-start gap-2 rounded px-1 py-1 text-left",d?"hover:bg-background":"cursor-default"),children:[e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block text-[12.5px] leading-snug",children:s.nextAction}),e.jsx("span",{className:"block truncate text-[11px] text-muted-foreground",children:s.label})]}),e.jsx(Z,{className:"mt-0.5 h-3 w-3 shrink-0 text-muted-foreground opacity-0 group-hover:opacity-100"})]})},`${s.requirementKey}:${s.partyId??"instruction"}`)})})]}):null,!n.onMarket&&m.length>0?e.jsxs("p",{className:"mt-2 text-[11.5px] text-muted-foreground",children:["Waiting on someone else:"," ",m.map(s=>s.personName??s.label).join(", "),". I'd leave those alone unless they've gone quiet."]}):null,!n.onMarket&&o.count===0?e.jsx("p",{className:"mt-1 text-[11.5px] text-muted-foreground",children:"Everything's satisfied â it's ready to go live when you are."}):null,u.length>0?e.jsx("ul",{className:"mt-3 space-y-1.5 border-t border-intelligence-rule/20 pt-2.5",children:u.map(s=>e.jsx(we,{item:s,onRespond:d=>i(s,d)},s.id))}):null]})}const Ie={instruction_created:"Take-on started",terms_accepted:"Agency agreement accepted",requirement_satisfied:"Requirement satisfied",requirement_waived:"Requirement waived",requirement_not_applicable:"Marked not applicable",requirement_invalidated:"Evidence lapsed",went_to_market:"Put on the market",withdrawn:"Withdrawn from the market",remarketed:"Back on the market",instruction_closed:"Instruction closed"};function Te(a){var o,c;const l=Ie[a.event_type]??a.event_type.replace(/[._]/g," "),n=(o=a.payload)==null?void 0:o.requirement_key,r=(c=a.payload)==null?void 0:c.status;return n?`${l} · ${String(n)}${r?` â ${String(r)}`:""}`:l}function Ce({events:a}){return a.length===0?null:e.jsxs("section",{className:"rounded-lg border bg-card",children:[e.jsx("header",{className:"border-b px-3 py-2",children:e.jsx("h3",{className:"text-[12.5px] font-semibold",children:"What's happened"})}),e.jsx("ol",{className:"max-h-64 divide-y overflow-y-auto",children:a.map(l
1=>e.jsxs("li",{className:"flex items-baseline gap-3 px-3 py-1.5",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-[12.5px]",children:Te(l)}),e.jsx("time",{className:"shrink-0 text-[11px] text-muted-foreground",children:L(new Date(l.occurred_at),"d MMM · HH:mm")})]},l.id))})]})}const Ae={customer_actionable:"The seller will be able to do this themselves in their own window.",shared_reference:"The seller will see this as progress, but can't action it.",provider:"Handled with a provider â the seller only sees the outcome.",staff_only:"Internal only. The seller never sees this."};function $e({instructionId:a,version:l,requirement:n,onOpenChange:r,onChanged:o}){const[c,m]=h.useState(""),[u,i]=h.useState(""),[s,d]=h.useState(null);if(h.useEffect(()=>{m(""),i("")},[n==null?void 0:n.id]),!n)return null;const t=n,f=async(x,S)=>{d(x);try{await S(),await o(),r(!1)}catch(v){b.error(v instanceof F?v.message:"That didn't save. Nothing has changed.")}finally{d(null)}},p=()=>{if(t.action==="record_terms_acceptance"&&t.partyId)return f("complete",async()=>{await ne({instruction_id:a,party_id:t.partyId,acceptance_method:"recorded_by_staff",evidence:c?{note:c}:{}}),b.success(`Acceptance recorded for ${t.personName??"this seller"}`)});if(t.action==="record_agreed_asking_price"){const x=Number(u.replace(/[^0-9.]/g,""));if(!Number.isFinite(x)||x<=0){b.error("Enter the asking price the seller has agreed to.");return}return f("complete",async()=>{await C({instruction_id:a,requirement_key:t.requirementKey,status:"satisfied",party_id:t.partyId,evidence_source:"manual",evidence_ref:{agreed_asking_price:x,note:c||null},expected_version:l}),b.success("Agreed asking price recorded")})}return f("complete",async()=>{await C({instruction_id:a,requirement_key:t.requirementKey,status:"satisfied",party_id:t.partyId,evidence_source:"manual",evidence_ref:c?{note:c}:{},expected_version:l}),b.success(`${t.label} recorded`)})},w=x=>{if(!c.trim()){b.error("A reason is required â this is a judgement, and it stays on the record.");return}return f(x,async()=>{await C({instruction_id:a,requirement_key:t.requirementKey,status:x,party_id:t.partyId,evidence_source:"manual",reason:c.trim(),expected_version:l}),b.success(x==="waived"?"Waived, with your reason on the record":"Marked not applicable")})};return e.jsx(ee,{open:!!n,onOpenChange:r,title:t.personName?`${t.label} â ${t.personName}`:t.label,children:e.jsxs("div",{className:"space-y-4 px-1 pb-1",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold",children:t.personName?`${t.label} â ${t.personName}`:t.label}),e.jsx("p",{className:"mt-0.5 text-[12.5px] text-muted-foreground",children:t.need})]}),e.jsxs("dl",{className:"grid grid-cols-2 gap-x-4 gap-y-2 rounded-lg border bg-muted/30 p-3 text-[12.5px]",children:[e.jsxs("div",{children:[e.jsx("dt",{className:"text-muted-foreground",children:"Where it sits"}),e.jsx("dd",{className:"font-medium",children:t.met?"Done":q[t.responsibility]})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-muted-foreground",children:"Status"}),e.jsx("dd",{className:"font-medium",children:t.stateLabel})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-muted-foreground",children:"Stops launch"}),e.jsx("dd",{className:"font-medium",children:t.blocking?"Yes":t.met?"No â done":"No"})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-muted-foreground",children:"Seller sees"}),e.jsx("dd",{className:"font-medium",children:t.visibility==="staff_only"?"Nothing":"Yes"})]})]}),e.jsx("p",{className:"text-[12.5px] text-muted-foreground",children:Ae[t.visibility]}),t.met?e.jsxs("div",{className:"rounded-lg border border-emerald-500/40 bg-emerald-500/5 p-3 text-[12.5px]",children:[e.jsxs("p",{className:"font-medium text-emerald-700 dark:text-emerald-400",children:[t.stateLabel,t.satisfiedAt?` · ${L(new Date(t.satisfiedAt),"d MMM yyyy")}`:""]}),t.evidenceSource?e.jsxs("p",{className:"mt-0.5 text-muted-foreground",children:["Evidenced by ",t.evidenceSource,"."]}):null,t.waiverReason?e.jsxs("p",{className:"mt-0.5 text-muted-foreground",children:["Reason given: ",t.waiverReason]}):null]}):null,t.invalidatedReason?e.jsxs("div",{className:"rounded-lg border border-destructive/40 bg-destructive/5 p-3 text-[12.5px]",children:[e.jsx("p",{className:"font-medium text-destructive",children:"This evidence is no longer valid"}),e.jsx("p",{className:"mt-0.5 text-muted-foreground",children:t.invali
1datedReason})]}):null,!t.met||t.state==="needs_attention"?e.jsxs("div",{className:"space-y-3",children:[t.action==="record_agreed_asking_price"?e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(P,{htmlFor:"agreed-price",className:"text-[12.5px]",children:"Agreed asking price"}),e.jsx(te,{id:"agreed-price",inputMode:"numeric",placeholder:"£",value:u,onFocus:x=>x.currentTarget.select(),onChange:x=>i(x.target.value)})]}):null,e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(P,{htmlFor:"req-note",className:"text-[12.5px]",children:["Note or reason",t.waiverable||t.naPermitted?" (required to waive)":" (optional)"]}),e.jsx(se,{id:"req-note",rows:2,placeholder:"What happened, or why this doesn't apply",value:c,onChange:x=>m(x.target.value)})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(y,{size:"sm",className:"h-8",disabled:!!s,onClick:p,children:[s==="complete"?e.jsx(I,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}):null,t.actionLabel]}),t.waiverable?e.jsx(y,{size:"sm",variant:"outline",className:"h-8",disabled:!!s,onClick:()=>w("waived"),children:"Waive with reason"}):null,t.naPermitted?e.jsx(y,{size:"sm",variant:"ghost",className:"h-8",disabled:!!s,onClick:()=>w("not_applicable"),children:"Not applicable"}):null]}),!t.waiverable&&!t.naPermitted?e.jsx("p",{className:"text-[11.5px] text-muted-foreground",children:"This one can't be waived or skipped â it has to be genuinely satisfied."}):null]}):null]})})}function Ee(){var t;const{instructionId:a}=ae(),l=re(),n=pe(a??null),[r,o]=h.useState(null),c=h.useMemo(()=>he(n),[n]),m=r?((t=n.projection)==null?void 0:t.requirements.find(f=>f.id===r.id))??null:null;if(n.loading)return e.jsx("div",{className:"flex h-[60vh] items-center justify-center",children:e.jsx(I,{className:"h-5 w-5 animate-spin text-muted-foreground"})});if(n.error||!n.instruction||!n.projection)return e.jsxs("div",{className:"mx-auto max-w-md px-4 py-16 text-center",children:[e.jsx("h1",{className:"text-sm font-semibold",children:"We couldn't open this take-on"}),e.jsx("p",{className:"mt-1 text-[12.5px] text-muted-foreground",children:n.error??"That instruction doesn't exist, or you don't have access to it."}),e.jsx(y,{variant:"outline",size:"sm",className:"mt-3 h-8",onClick:()=>l(-1),children:"Go back"})]});const{instruction:u,projection:i,property:s}=n,d=(s==null?void 0:s.display_address)??"This property";return e.jsxs("div",{className:"flex min-h-[100dvh] flex-col bg-background",children:[e.jsxs("header",{className:"flex shrink-0 items-center gap-4 border-b bg-card px-5 py-2.5",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex min-w-0 items-baseline gap-2.5",children:[e.jsx("h1",{className:"truncate text-[16px] font-semibold leading-tight tracking-[-0.015em]",children:d}),s!=null&&s.postcode?e.jsx("span",{className:"shrink-0 text-[13px] text-muted-foreground",children:s.postcode}):null,e.jsx("span",{className:_("shrink-0 text-[10px] font-semibold uppercase tracking-[0.14em]",i.onMarket?"text-emerald-600 dark:text-emerald-400":"text-intelligence-rule"),children:i.onMarket?"On the market":"Getting ready for market"})]}),e.jsx("p",{className:"mt-0.5 truncate text-[12.5px] text-muted-foreground",children:[`Take-on started ${L(new Date(u.instructed_at),"d MMM")}`,i.sellers.length?`${i.sellers.length} seller${i.sellers.length===1?"":"s"}`:null,`${i.counts.complete}/${i.counts.total}
1 requirements done`].filter(Boolean).join(" · ")})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[s?e.jsx(y,{asChild:!0,variant:"ghost",size:"sm",className:"h-7 text-[11.5px] font-normal text-muted-foreground hover:text-foreground",children:e.jsx(le,{to:`/property/${s.id}`,children:"Property record"})}):null,e.jsx(y,{variant:"ghost",size:"icon",className:"h-7 w-7","aria-label":"Close",onClick:()=>l(-1),children:e.jsx(W,{className:"h-4 w-4"})})]})]}),e.jsxs("main",{className:"mx-auto grid w-full max-w-[1400px] flex-1 gap-4 px-4 py-4 lg:grid-cols-[minmax(0,1fr)_340px]",children:[e.jsxs("div",{className:"min-w-0 space-y-4",children:[e.jsx(fe,{instructionId:u.id,version:u.version,addressLabel:d,projection:i,onSelect:o,onChanged:n.reload}),e.jsx(ye,{projection:i,onSelect:o})]}),e.jsxs("aside",{className:"min-w-0 space-y-4",children:[e.jsx(Se,{instructionId:u.id,addressLabel:d,projection:i,onSelect:o}),e.jsx(Ne,{projection:i,people:n.people,onSelect:o}),e.jsx(ve,{instructionId:u.id,sellers:i.sellers}),e.jsx(_e,{facts:c}),e.jsx(Ce,{events:n.events})]})]}),e.jsx($e,{instructionId:u.id,version:u.version,requirement:m,onOpenChange:f=>!f&&o(null),onChanged:n.reload})]})}export{Ee 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.