PageSourceSearch

https://portal.wavespestcontrol.com/assets/TechLawnDiagnosticPage-UerTQ8aP.js

js wavespestcontrol.com collected 2026-10-06 18:18:13 UTC 12,081 bytes, 1 lines download raw bytes

1import{A as le,ax as de,r as p,j as t,bF as ce}from"./index-C7xls3vf.js";import{u as ue}from"./techBasePath-BasAzfff.js";const pe="",F=5,n={card:"var(--tfx-card, #ffffff)",border:"var(--tfx-border, #d6d3d1)",teal:"var(--tfx-accent, #1c1917)",green:"var(--tfx-ok, #1c1917)",amber:"var(--tfx-amber, #854d0e)",red:"var(--tfx-red, #a32d2d)",text:"var(--tfx-text, #1c1917)",muted:"var(--tfx-muted, #57534e)",white:"var(--tfx-on-accent, #ffffff)",head:"var(--tfx-text, #1c1917)",sunk:"var(--tfx-bg, #fafaf9)",redBg:"var(--tfx-red-bg, #fcebeb)",okBg:"var(--tfx-card, #ffffff)"},v="var(--tfx-font, 'Roboto', system-ui, sans-serif)",K="var(--tfx-font, 'Roboto', system-ui, sans-serif)",ge={mild:n.green,moderate:n.amber,severe:n.red},he={standard:"Standard",conservative:"Conservative",label_limited:"Label-limited",minimal:"Minimal"};async function L(s,a={}){const c=ce(),l=await fetch(`${pe}/api${s}`,{...a,headers:{"Content-Type":"application/json",Authorization:`Bearer ${c}`,...a.headers||{}}}),o=await l.json().catch(()=>({}));if(!l.ok)throw new Error((o==null?void 0:o.error)||`Request failed (${l.status})`);return o}function me(s){return new Promise((a,c)=>{const l=new FileReader;l.onload=()=>a(String(l.result||"")),l.onerror=()=>c(new Error("Could not read photo")),l.readAsDataURL(s)})}function fe(s,a=1600,c=.85){return new Promise(l=>{const o=new Image;o.onload=()=>{const k=Math.max(o.width,o.height);if(k<=a){l(s);return}const d=a/k,h=document.createElement("canvas");h.width=Math.round(o.width*d),h.height=Math.round(o.height*d),h.getContext("2d").drawImage(o,0,0,h.width,h.height),l(h.toDataURL("image/jpeg",c))},o.onerror=()=>l(s),o.src=s})}function ye(s,a="image/jpeg"){const c=/^data:([^;,]+)[;,]/.exec(String(s||""));return c?c[1]:a}function b(s,a=n.white,c=!1){return{minHeight:46,padding:"0 16px",border:"none",borderRadius:4,background:s,color:a,fontFamily:v,fontWeight:500,fontSize:15,cursor:c?"not-allowed":"pointer",opacity:c?.55:1}}const S={width:"100%",boxSizing:"border-box",minHeight:44,padding:"0 12px",background:n.sunk,border:`1px solid ${n.border}`,borderRadius:4,color:n.text,fontSize:15,fontFamily:K,outline:"none"};function w({children:s,style:a}){return t.jsx("div",{style:{background:n.card,border:`1px solid ${n.border}`,borderRadius:6,padding:16,marginBottom:14,...a},children:s})}function ve(){var Z,G;const s=le(),a=ue(),[c]=de(),l=c.get("visit"),[o,k]=p.useState([]),[d,h]=p.useState({name:"",email:"",phone:""}),[m,z]=p.useState({line1:"",city:"",state:"",zip:""}),[E,W]=p.useState(!1),[r,H]=p.useState(null),[C,N]=p.useState({releaseMode:null,findingsSource:null,provenance:null,diagnosisRunId:null}),[q,U]=p.useState(null),[T,J]=p.useState(null),[M,Y]=p.useState(null),[u,x]=p.useState(""),[Q,g]=p.useState(""),[V,f]=p.useState(""),P=p.useRef(null),ee=r?"review":"capture",$=((Z=r==null?void 0:r.diagnosis)==null?void 0:Z.findings)||[],A=!!r,te=async e=>{g("");const i=Array.from(e||[]).slice(0,F-o.length);try{const y=await Promise.all(i.map(async(j,O)=>{const _=await me(j),R=await fe(_,1600,.85);return{id:`${Date.now()}-${O}`,dataUrl:R,base64:R.split(",")[1]||"",mimeType:ye(R,j.type||"image/jpeg")}}));k(j=>[...j,...y].slice(0,F))}catch(y){g(y.message)}P.current&&(P.current.value="")},I=()=>{const e={};return d.name.trim()&&(e.name=d.name.trim()),d.email.trim()&&(e.email=d.email.trim()),d.phone.trim()&&(e.phone=d.phone.trim()),Object.keys(e).length?e:null},B=()=>{const e={};return["line1","city","state","zip"].forEach(i=>{m[i].trim()&&(e[i]=m[i].trim())}),Object.keys(e).length?e:null},ne=async()=>{if(!o.length){g("Add at least one photo first.");return}x("analyze"),g(""),f("");try{const e=await L("/tech/lawn-diagnostic/analyze",{method:"POST",body:JSON.stringify({photos:o.map(i=>({data:i.base64,mimeType:i.mimeType}))})});H(e.reportContract||null),N({releaseMode:e.releaseMode||null,findingsSource:e.findingsSource||null,provenance:e.provenance||null,diagnosisRunId:e.diagnosisRunId||null})}catch(e){g(e.message)}finally{x("")}},D=async e=>{var O,_;if(q)return q;const i=((O=r==null?void 0:r.input_assessment)==null?void 0:O.photo_quality)||"limited",y=((_=r==null?void 0:r.input_assessment)==null?void 0:_.photo_limitations)||[],j=await L("/tech/lawn-diagnostic",{method:"POST",body:JSON.stringify({mode:e,findings:$,photos:o.map(R=>({photo_id:R.id,quality:i,limitations:y})),appliedProducts:[],compliance:{},diagnosisRunId:(C==null?void 0:C.diagnosisRunId)||null,contact:I(),address:B()})});
1return U(j.id),j.id},oe=async()=>{x("save"),g(""),f("");try{await D("internal"),f("Saved to your diagnostics.")}catch(e){g(e.message)}finally{x("")}},re=async()=>{x("send"),g(""),f("");try{const e=await D("prospect"),i=await L(`/tech/lawn-diagnostic/${e}/send`,{method:"POST",body:JSON.stringify({contact:I(),address:B()})}),y=`${window.location.origin}${i.url||`/lawn-report/${i.token}`}`;J({url:y,expiresAt:i.expiresAt})}catch(e){g(e.message)}finally{x("")}},ie=async()=>{x("lead"),g(""),f("");try{const e=await D(I()||B()?"prospect":"internal"),i=await L(`/tech/lawn-diagnostic/${e}/lead`,{method:"POST",body:JSON.stringify({contact:I(),address:B()})});Y(i.leadId||null),f("Saved as a lead in the pipeline.")}catch(e){g(e.message)}finally{x("")}},ae=()=>{k([]),h({name:"",email:"",phone:""}),z({line1:"",city:"",state:"",zip:""}),W(!1),H(null),N({releaseMode:null,findingsSource:null,provenance:null,diagnosisRunId:null}),U(null),J(null),Y(null),g(""),f("")},se=async()=>{try{await navigator.clipboard.writeText(T.url),f("Link copied.")}catch{f("Copy failed — long-press the link to copy.")}},X=t.jsxs("div",{style:{display:"grid",gap:8,marginTop:12},children:[t.jsx("input",{style:S,placeholder:"Name",value:d.name,onChange:e=>h({...d,name:e.target.value})}),t.jsx("input",{style:S,placeholder:"Email",type:"email",value:d.email,onChange:e=>h({...d,email:e.target.value})}),t.jsx("input",{style:S,placeholder:"Phone",type:"tel",value:d.phone,onChange:e=>h({...d,phone:e.target.value})}),t.jsx("input",{style:S,placeholder:"Street address",value:m.line1,onChange:e=>z({...m,line1:e.target.value})}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"2fr 1fr 1fr",gap:8},children:[t.jsx("input",{style:S,placeholder:"City",value:m.city,onChange:e=>z({...m,city:e.target.value})}),t.jsx("input",{style:S,placeholder:"State",value:m.state,onChange:e=>z({...m,state:e.target.value})}),t.jsx("input",{style:S,placeholder:"ZIP",value:m.zip,onChange:e=>z({...m,zip:e.target.value})})]})]});return t.jsxs("div",{style:{maxWidth:480,margin:"0 auto",color:n.text,fontFamily:K},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:14},children:[t.jsx("button",{type:"button",onClick:()=>s(l?`${a}?visit=${encodeURIComponent(l)}`:a),style:{background:"transparent",border:`1px solid ${n.border}`,color:n.text,padding:"8px 12px",borderRadius:4,fontSize:14,cursor:"pointer"},children:"← Back"}),t.jsx("h1",{style:{fontFamily:v,fontSize:20,fontWeight:500,color:n.head,margin:0},children:"Lawn Diagnostic"})]}),Q?t.jsx(w,{style:{borderColor:n.red,background:n.redBg},children:t.jsx("span",{style:{color:n.red},children:Q})}):null,V?t.jsx(w,{style:{borderColor:n.green,background:n.okBg},children:t.jsx("span",{style:{color:n.green},children:V})}):null,ee==="capture"?t.jsxs(t.Fragment,{children:[t.jsxs(w,{children:[t.jsxs("div",{style:{fontFamily:v,fontWeight:500,fontSize:16,color:n.head,marginBottom:10},children:["Photos (",o.length,"/",F,")"]}),o.length?t.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(90px, 1fr))",gap:8,marginBottom:12},children:o.map(e=>t.jsxs("div",{style:{position:"relative"},children:[t.jsx("img",{src:e.dataUrl,alt:"lawn",style:{width:"100%",height:90,objectFit:"cover",borderRadius:4,border:`1px solid ${n.border}`}}),t.jsx("button",{onClick:()=>k(i=>i.filter(y=>y.id!==e.id)),"aria-label":"Remove photo",style:{position:"absolute",top:4,right:4,width:24,height:24,borderRadius:999,border:"none",background:"rgba(0,0,0,0.6)",color:"#fff",cursor:"pointer",fontSize:14,lineHeight:"24px",padding:0},children:"×"})]},e.id))}):null,t.jsx("input",{ref:P,type:"file",accept:"image/*",capture:"environment",multiple:!0,onChange:e=>te(e.target.files),style:{display:"none"}}),o.length<F?t.jsx("button",{onClick:()=>{var e;return(e=P.current)==null?void 0:e.click()},style:b(n.sunk,n.teal),children:"+ Add photo"}):null]}),t.jsxs(w,{children:[t.jsxs("button",{onClick:()=>W(e=>!e),style:{...b("transparent",n.muted),padding:0,minHeight:0,fontWeight:500},children:[E?"▾":"▸"," Prospect details (for sending a report)"]}),E?X:null]}),t.jsx("button",{onClick:ne,disabled:u==="analyze"||!o.length,style:{...b(n.teal),width:"100%"},children:u==="analyze"?"Analyzing…":"Analyze lawn"})]}):t.jsxs(t.Fragment,{children:[t.jsxs(w,{children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:10},children:[t.jsx("div",{style:{fontFamily:v,fontWeight:500,fontSize:16,color:n.head},children:"Diagnosis"}),C.releaseMode?t.jsx("span",{style:{padding:"4px 10px",borderRadius:4,background:n.sunk,border:`1px solid ${n.border}`,color:n.muted,fontSize:12,fontWeight:500,fontFamily:v},children:he[C.releaseMode]||C.releaseMode}):null]}),r!=null&&r.customer_summary?t.jsx("p",{style:{margin:"0 0 12px",color:n.text,fontSize:14,lineHeight:1.55},children:r.customer_summary}):null,$.length?t.jsx("div",{style:{display:"grid",gap:8},children:$.map((e,i)=>t.jsxs("div",{style:{background:n.sunk,border:`1px solid ${n.border}`,borderLeft:`4px solid ${ge[e.severity]||n.teal}`,borderRadius:4,padding:"10px 12px"},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:8},children:[t.jsx("span",{style:{fontFamily:v,fontWeight:500,fontSize:14,color:n.head},children:e.name}),t.jsx("span",{style:{color:n.muted,fontSize:12},children:e.confidence})]}),e.customer_wording?t.jsx("div",{style:{color:n.muted,fontSize:13,marginTop:4,lineHeight:1.5},children:e.customer_wording}):null,e.confirmation_step?t.jsxs("div",{style:{color:n.amber,fontSize:12,marginTop:4},children:["Confirm: ",e.confirmation_step]}):null]},`${e.name}-${i}`))}):t.jsx("p",{style:{color:n.muted,fontSize:14,margin:0},children:"No defensible finding from these photos — capture clearer or closer shots for a diagnosis you can send."}),(G=r==null?void 0:r.watering)!=null&&G.customer_sequence?t.jsxs("div",{style:{marginTop:12,paddingTop:12,borderTop:`1px solid ${n.border}`},children:[t.jsx("div",{style:{color:n.muted,fontSize:12,textTransform:"uppercase",letterSpacing:"0.06em",marginBottom:4},children:"Watering"}),t.jsx("div",{style:{color:n.text,fontSize:13,lineHeight:1.5},children:r.watering.customer_sequence})]}):null]}),T?t.jsxs(w,{style:{borderColor:n.green},children:[t.jsx("div",{style:{fontFamily:v,fontWeight:500,color:n.head,marginBottom:8},children:"Report link ready"}),t.jsx("div",{style:{wordBreak:"break-all",color:n.teal,fontSize:13,marginBottom:10},children:T.url}),t.jsx("button",{onClick:se,style:b(n.green),children:"Copy link"})]}):null,t.jsxs(w,{children:[t.jsx("div",{style:{fontFamily:v,fontWeight:500,fontSize:16,color:n.head},children:"Prospect details"}),t.jsx("div",{style:{color:n.muted,fontSize:12,marginTop:4},children:"A name plus an email or address is required to send a report."}),X]}),t.jsxs("div",{style:{display:"grid",gap:8},children:[t.jsx("button",{onClick:oe,disabled:!!u||!A,style:b(n.sunk,n.teal,!!u||!A),children:u==="save"?"Saving…":"Save internally"}),t.jsx("button",{onClick:re,disabled:!!u||!A,style:b(n.teal,n.white,!!u||!A),children:u==="send"?"Sending…":T?"Re-send report":"Send prospect report"}),t.jsx("button",{onClick:ie,disabled:!!u||!!M,style:b(n.sunk,n.green,!!u||!!M),children:u==="lead"?"Saving…":M?"Saved as lead ✓":"Save as lead"}),t.jsx("button",{onClick:ae,disabled:!!u,style:b("transparent",n.muted,!!u),children:"Start over"})]}),r&&!$.length?t.jsx("p",{style:{color:n.muted,fontSize:12,marginTop:10},children:"No specific diagnosis from these photos — you can still send a calm service-summary report."}):null]})]})}export{ve 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.