PageSourceSearch

https://rideshareguides.com/assets/DriverProfitSuite-BUioSxay.js

js rideshareguides.com collected 2026-10-08 20:47:18 UTC 200,739 bytes, 14 lines download raw bytes

1import{aY as ps,u as Pe,r as l,dm as fs,j as e,S as we,O as Ze,aL as it,c as P,h as Ts,a4 as Ds,m as be,d as te,a as X,dn as bs,U as yt,V as Xe,al as q,w as Rs,ak as Ms,ax as Ls,L as Ne,l as et,dp as zt,bk as gs,bj as Is,dq as Ps,aH as js,b as Tt,ag as Ns,b5 as Us,g as Os}from"./index-Bn97Kz8X.js";import{S as Gs}from"./SEO-BjAPr8No.js";import{B as Ys}from"./BackToDriverHQ-BcTdxsIk.js";import{G as We}from"./gauge-BQwbNuWb.js";import{A as qs}from"./arrow-down-right-KK4zRoDJ.js";import{C as ye}from"./calendar-days-87MNVOcb.js";import{C as Ie}from"./clock-3-CzVCToOo.js";import{F as fe}from"./fuel-8_O-CQ9l.js";import{S as _t}from"./save-CihL1j8F.js";import{T as Je}from"./trending-up-BIXCMs2b.js";import{R as ue}from"./refresh-ccw-CEw9j-hC.js";import{D as Dt}from"./download-DAiJMK76.js";import{B as Rt}from"./badge-check-Ch_7psaO.js";/**
2 * @license lucide-react v0.462.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const Hs=ps("FileDown",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M12 18v-6",key:"17g6i2"}],["path",{d:"m9 15 3 3 3-3",key:"1npd3o"}]]);/**
7 * @license lucide-react v0.462.0 - ISC
8 *
9 * This source code is licensed under the ISC license.
10 * See the LICENSE file in the root directory of this source tree.
11 */const oe=ps("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]),Vs="rsg:profit-suite",St=1,Ws=24*60*60*1e3;function ys(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function ws(t){return ys(t)&&Object.values(t).every(s=>typeof s=="string")}function Qs(t){return ys(t)&&t.version===St&&typeof t.expiresAt=="number"&&Number.isFinite(t.expiresAt)&&ws(t.values)}function Et(){if(typeof window>"u")return null;try{return window.sessionStorage}catch{return null}}function ct(t,s){try{t.removeItem(s)}catch{}}function vs(t,s){const r=String(s||"").trim();if(!r)return"";const a=t==="real-pay"?"real-pay-draft":"gas-mileage-draft";try{return`${Vs}:${a}:v${St}:${encodeURIComponent(r)}`}catch{return""}}function Fs(t,s){if(!t)return null;const r=Et();if(!r)return null;let a;try{const n=r.getItem(t);if(!n)return null;a=JSON.parse(n)}catch{return ct(r,t),null}return!Qs(a)||a.expiresAt<=Date.now()||s&&(Object.keys(a.values).length!==s.length||s.some(n=>typeof a.values[n]!="string"))?(ct(r,t),null):a.values}function ut(t,s){if(!t||!ws(s))return;const r=Et();if(r)try{r.setItem(t,JSON.stringify({version:St,expiresAt:Date.now()+Ws,values:s}))}catch{}}function ks(t){if(!t)return;const s=Et();s&&ct(s,t)}const Ks="rpm-save-diag-2",Zs=["response","data","body","cause","error","details","errors","issues","validationErrors","fieldErrors","violations"],Js=["message","error","reason","detail","details","title"],Xs=["field","fieldName","field_name","path","property","propertyName"],er=["errors","fieldErrors","validationErrors","violations"],tr=["requestId","request_id","correlationId","correlation_id","traceId","trace_id"],sr=new Set(["x-request-id","x-correlation-id","request-id","correlation-id"]);function ht(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Ae(t,s){try{return t[s]}catch{return}}function rr(t){const s=t.trim();if(!(!s||s.length>12e3||!s.startsWith("{")&&!s.startsWith("[")))try{return JSON.parse(s)}catch{return}}function ar(t){const s=[],r=[],a=new WeakSet,n=(i,d)=>{if(d>4||s.length>=48||i===null||i===void 0)return;if(typeof i=="string"){const m=rr(i);m!==void 0?n(m,d+1):i.trim()&&r.push(i);return}if(typeof i!="object"||a.has(i))return;if(a.add(i),Array.isArray(i)){i.slice(0,24).forEach(m=>n(m,d+1));return}const c=i;s.push(c),Zs.forEach(m=>{const o=Ae(c,m);o!==void 0&&n(o,d+1)})};return n(t,0),{nodes:s,strings:r}}function nr(t){const s=typeof t=="number"?t:typeof t=="string"&&/^\d{3}$/.test(t.trim())?Number(t):NaN;return Number.isInteger(s)&&s>=100&&s<=599?s:null}function ir(t){const s=new Set;
11return(t||[]).forEach(r=>{if(typeof r!="string"&&typeof r!="number")return;const a=String(r).trim();a&&s.add(a)}),[...s].sort((r,a)=>a.length-r.length).slice(0,32)}function or(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function lr(t,s){let r=t.slice(0,1200).replace(/\s+/g," ").trim();return s.forEach(a=>{try{r=r.replace(new RegExp(or(a),"gi"),"[redacted]")}catch{}}),r.replace(/[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}/gi,"[redacted-email]").replace(/\+?\d[\d(). -]{6,}\d/g,"[redacted-phone]").replace(/\b[0-9a-f]{8}-[0-9a-f-]{27,}\b/gi,"[redacted-id]").replace(/\b(?:bearer|basic)\s+[A-Za-z0-9._~+/=-]+/gi,"[redacted-authorization]").replace(/\b((?:user|account|owner|member|contact)[ _-]?id|email|phone|token|secret|password|authorization|api[ _-]?key)\s*[:=]\s*(?:"[^"]*"|'[^']*'|[^\s,;]+)/gi,"$1: [redacted]").replace(/\b\d+(?:\.\d+)?\b/g,"[redacted-number]").replace(/\b[A-Za-z0-9_-]{28,}\b/g,"[redacted-token]").slice(0,240).trim()}function cr(t,s){const r=typeof t=="string"||typeof t=="number"?String(t).trim():"";return!r||r.length>64||!/^[A-Za-z0-9][A-Za-z0-9_.:-]*$/.test(r)||/^\d+$/.test(r)||/^[0-9a-f]{8}-[0-9a-f-]{27,}$/i.test(r)||/^[A-Za-z0-9_-]{28,}$/.test(r)||s.some(a=>a.toLowerCase()===r.toLowerCase())?null:r}function Mt(t,s){const r=typeof t=="string"||typeof t=="number"?String(t).trim():"";return!r||r.length>120||!/^[A-Za-z0-9][A-Za-z0-9._:/-]*$/.test(r)||s.some(a=>a.toLowerCase()===r.toLowerCase())?null:r}function zs(t){const s=typeof t=="string"?t.trim():"";return/^[A-Za-z][A-Za-z0-9_.-]{0,63}$/.test(s)?s:null}function dr(t,s){const{nodes:r,strings:a}=ar(t),n=ir(s),i=p=>{for(const u of r){const j=nr(Ae(u,p));if(j!==null)return j}return null},d=()=>{for(const p of r)for(const u of["code","errorCode","error_code","machineCode","machine_code"]){const j=cr(Ae(p,u),n);if(j)return j}return null},c=new Set,m=p=>{if(Array.isArray(p)){p.slice(0,16).forEach(m);return}const u=zs(p);u&&c.add(u)};r.forEach(p=>{Xs.forEach(u=>m(Ae(p,u))),er.forEach(u=>{const j=Ae(p,u);if(ht(j))try{Object.keys(j).slice(0,16).forEach(m)}catch{}})});let o=null;for(const p of r){for(const u of tr)if(o=Mt(Ae(p,u),n),o)break;if(!o){const u=Ae(p,"headers");if(ht(u))try{for(const[j,w]of Object.entries(u))if(sr.has(j.toLowerCase())&&(o=Mt(w,n),o))break}catch{}}if(o)break}const k=[];r.forEach(p=>Js.forEach(u=>{const j=Ae(p,u);typeof j=="string"&&j.trim()&&k.push(j)})),k.push(...a);const N=k.map(p=>lr(p,n)).find(Boolean)||null;return{status:i("status"),statusCode:i("statusCode"),code:d(),message:N,validationFields:[...c].slice(0,16),requestId:o}}function xr(t){const s={},r=[];if(!ht(t))return{fields:s,nullFieldNames:r};try{Object.keys(t).slice(0,32).forEach(a=>{const n=zs(a);if(!n)return;const i=Ae(t,a);s[n]=i===null?"null":Array.isArray(i)?"array":typeof i,i===null&&r.push(n)})}catch{}return{fields:s,nullFieldNames:r}}function mr(){if(typeof window>"u")return{hostname:null,pathname:null,framed:!1};let t=!1;try{t=window.top!==window}catch{t=!0}return{hostname:window.location.hostname||null,pathname:window.location.pathname||null,framed:t}}function ur(t,s){return`RPM-${t.replace(/\D/g,"").slice(0,12)||"unknown"}-${s==="session-check"?"S":s==="create"?"C":"H"}`}function Lt(t){const s=new Date().toISOString(),r=mr();let a=[];if(ht(t.payload))try{a=Object.values(t.payload)}catch{a=[]}const n=xr(t.payload);return{revision:Ks,reference:ur(s,t.stage),timestamp:s,stage:t.stage,...r,sessionCheck:t.sessionCheck,ownerMatch:t.ownerMatch,payloadFields:n.fields,nullFieldNames:n.nullFieldNames,error:dr(t.error,a)}}function hr(t){const s=Object.entries(t.payloadFields).map(([n,i])=>`${n}:${i}`).join(", ")||"none",r=t.nullFieldNames.join(", ")||"none",a=t.error.validationFields.join(", ")||"none";return["RSG save help details",`revision: ${t.revision}`,`support-reference: ${t.reference}`,`timestamp: ${t.timestamp}`,`stage: ${t.stage}`,`hostname: ${t.hostname||"unknown"}`,`pathname: ${t.pathname||"unknown"}`,`framed: ${t.framed}`,`session-check: ${t.sessionCheck}`,`owner-match: ${t.ownerMatch}`,`payload-fields: ${s}`,`payload-null-fields: ${r}`,`error-status: ${t.error.status??"unknown"}`,`error-status-code: ${t.error.statusCode??"unknown"}`,`error-code: ${t.error.code||"unknown"}`,`error-message: ${t.error.message||"unknown"}`,`validation-fields: ${a}`,`request-id: ${t.error.requestId||"unknown"}`].join(`
12`)}const pr=.3,fr=["shiftDate","startTime","endTime","zone","hours","gross","miles","gas"];function lt(){const t=new Date,s=t.getFullYear(),r=String(t.getMonth()+1).padStart(2,"0"),a=String(t.getDate()).padStart(2,"0");return`${s}-${r}-${a}`}function st(t){return[...t].sort((s,r)=>String(r.shift_date||"").localeCompare(String(s.shift_date||"")))}function It(t,s,r,a,n){const i=r*n,d=t-a,c=d-i;return{gross:t,gas:a,miles:r,vehicle:i,afterGas:d,net:c,hourly:s>0?c/s:0}}function je(t){return`${t<0?"-":""}$${Math.abs(t).toFixed(2)}`}function br(t){const[s,r,a]=t.split("-").map(Number);return!s||!r||!a?t:new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric"}).format(new Date(s,r-1,a))}
12function Pt(t){const s=String(t||"").trim(),r=/^(\d{1,2}):(\d{2})$/.exec(s);if(!r)return s;const a=Number(r[1]),n=Number(r[2]);if(a<0||a>23||n<0||n>59)return s;const i=a>=12?"PM":"AM";return`${a%12||12}:${String(n).padStart(2,"0")} ${i}`}function gr(t){var c,m;const s=t&&typeof t=="object"?t:{},r=[t,s,s.response,(c=s.response)==null?void 0:c.data,s.data,s.cause,(m=s.cause)==null?void 0:m.data];if(r.map(o=>Number((o==null?void 0:o.status)??(o==null?void 0:o.statusCode)??0)).some(o=>o===401||o===419))return!0;const n=new Set(["401","unauthorized","authentication_required","auth_required","not_authenticated","invalid_session","session_expired","token_expired","login_required","sign_in_required","logged_out"]);if(r.map(o=>String((o==null?void 0:o.code)??(o==null?void 0:o.errorCode)??(o==null?void 0:o.error_code)??"").trim().toLowerCase()).some(o=>n.has(o)))return!0;const d=r.map(o=>typeof o=="string"?o:[o==null?void 0:o.message,o==null?void 0:o.error,o==null?void 0:o.reason,o==null?void 0:o.details].join(" ")).join(" ").toLowerCase();return/authentication required|authentication failed|auth(?:entication)? required|not authenticated|unauthori[sz]ed|sign[ -]?in required|log[ -]?in required|session (?:could not be verified|expired|ended|invalid)|invalid(?: or expired)? session|token expired|reauthenticat|logged out/i.test(d)}function jr(){try{if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return`rpm-${crypto.randomUUID().replace(/-/g,"").slice(0,24)}`}catch{}return`rpm-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function Nr(t){var a,n;const s=t&&typeof t=="object"?t:{},r=[s,s.data,s.response,(a=s.response)==null?void 0:a.data,s.cause,(n=s.cause)==null?void 0:n.data];for(const i of r){const d=(i==null?void 0:i.code)??(i==null?void 0:i.errorCode)??(i==null?void 0:i.error_code);if(typeof d!="string")continue;const c=d.trim().toLowerCase().replace(/-/g,"_");if(/^[a-z0-9_]{1,80}$/.test(c))return c}return""}function yr(t){var a,n;const s=t&&typeof t=="object"?t:{},r=[s,s.data,s.response,(a=s.response)==null?void 0:a.data,s.cause,(n=s.cause)==null?void 0:n.data];for(const i of r){const d=typeof(i==null?void 0:i.phase)=="string"?i.phase.trim():"";if(/^[A-Za-z0-9_-]{1,40}$/.test(d))return d}return""}function wr(t){const s=yr(t);if(!s)return t;const r=t&&typeof t=="object"?t:{},a=typeof r.message=="string"&&r.message.trim()?`${r.message.trim()} (save phase: ${s})`:`Save phase: ${s}`;return Object.assign(new Error(a),{code:r.code,correlationId:r.correlationId,data:r.data,phase:s})}function vr(t){var a,n,i,d;const r=[t==null?void 0:t.id,(a=t==null?void 0:t.data)==null?void 0:a.id,(i=(n=t==null?void 0:t.data)==null?void 0:n.user)==null?void 0:i.id,(d=t==null?void 0:t.user)==null?void 0:d.id].find(c=>typeof c=="string"&&c.trim()||typeof c=="number");return r===void 0?"":String(r).trim()}async function Fr(t){const s=String(t||"").trim();try{const r=await yt.me(),a=vr(r);return!a||!s?{status:"uncertain",ownerMatch:"unknown",error:new Error("Authenticated account id could not be read.")}:a!==s?{status:"uncertain",ownerMatch:"mismatched",error:new Error("The signed-in account changed while this page was open.")}:{status:"available",ownerId:a,ownerMatch:"matched"}}catch(r){return gr(r)?{status:"missing",ownerMatch:"unknown",error:r}:{status:"uncertain",ownerMatch:"unknown",error:r}}}function $e({label:t,value:s,accent:r=!1}){return e.jsxs("div",{className:`rounded-[14px] border p-3.5 ${r?"border-[#F45815]/25 bg-[#FFF4EC]":"border-zinc-200 bg-white"}`,children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.14em] text-zinc-500",children:t}),e.jsx("p",{className:`mt-1.5 font-mono text-[17px] font-black ${r?"text-[#B9380B]":"text-zinc-950"}`,children:s})]})}function kr({userId:t,history:s,costSettings:r,loadingHistory:a=!1,historyError:n,onHistoryChange:i,onRetry:d}){const c=Pe(),[m,o]=l.useState(()=>st(s||[])),[k,N]=l.useState(s===void 0),[p,u]=l.useState(null),[j,w]=l.useState(lt()),[z,f]=l.useState(""),[C,h]=l.useState(""),[$,_]=l.useState(""),[g,v]=l.useState(""),[F,L]=l.useState(""),[S,Q]=l.useState(""),[M,H]=l.useState("0"),[T,B]=l.useState(null),[K,R]=l.useState(null),[O,se]=l.useState(null),[V,le]=l.useState(!1),[I,re]=l.useState(null),[U,W]=l.useState("idle"),de=l.useRef(null),ae=vs("real-pay",t),G=l.useRef(!1),ne=l.useRef(null),ie=l.useRef(0),Ce=l.useRef({shiftDate:j,startTime:z,endTime:C,zone:$,hours:g,gross:F,miles:S,gas:M});Ce.current={shiftDate:j,startTime:z,endTime:C,zone:$,hours:g,gross:F,miles:S,gas:M};const he=Number.isFinite(Number(r==null?void 0:r.operating_cost_per_mile))&&Number(r==null?void 0:r.operating_cost_per_mile)>=0?Number(r==null?void 0:r.operating_cost_per_mile):pr,ve=l.useMemo(()=>({hours:Number(g)||0,gross:Number(F)||0,miles:Number(S)||0,gas:Number(M)||0}),[g,F,S,M]),Z=l.useMemo(()=>
12It(ve.gross,ve.hours,ve.miles,ve.gas,he),[ve,he]),gt=V||a||k;l.useEffect(()=>{if(!t||ne.current===t||(ne.current!==null&&ne.current!==t&&(ie.current+=1,G.current=!1,w(lt()),f(""),h(""),_(""),v(""),L(""),Q(""),H("0")),ne.current=t,G.current))return;const b=Fs(ae,fr);b&&(w(b.shiftDate),f(b.startTime),h(b.endTime),_(b.zone),v(b.hours),L(b.gross),Q(b.miles),H(b.gas))},[ae,t]),l.useEffect(()=>{if(!t||ne.current!==t)return;const x=Ce.current;if(!(x.shiftDate!==lt()||[x.startTime,x.endTime,x.zone,x.hours,x.gross,x.miles].some(ge=>ge.trim()!=="")||x.gas.trim()!=="0"))return;const D=ie.current,ee=window.setTimeout(()=>{ie.current===D&&ut(ae,x)},250);return()=>window.clearTimeout(ee)},[ae,C,M,F,g,S,j,z,t,$]),l.useEffect(()=>{const x=()=>{const b=Ce.current,D=b.shiftDate!==lt()||[b.startTime,b.endTime,b.zone,b.hours,b.gross,b.miles].some(ee=>ee.trim()!=="")||b.gas.trim()!=="0";G.current&&t&&ne.current===t&&D&&ut(ae,b)};return window.addEventListener("pagehide",x),()=>{window.removeEventListener("pagehide",x),x()}},[ae,t]),l.useEffect(()=>{s!==void 0&&(o(st(s)),N(!1))},[s]);const Ue=l.useCallback(async()=>{const x=await fs(t),b=st(x||[]);return o(b),i==null||i(b),b},[i,t]);l.useEffect(()=>{if(s!==void 0)return;let x=!0;return N(!0),Ue().catch(b=>{console.error("Failed to load Driver Profit Suite history:",b),x&&u("We could not load your saved shifts. Try again before logging a new shift.")}).finally(()=>{x&&N(!1)}),()=>{x=!1}},[s,Ue]);const jt=()=>{if(d){d();return}u(null),N(!0),Ue().catch(()=>u("We could not load your saved shifts. Try again.")).finally(()=>N(!1))},E=l.useCallback((x,b,D,ee,ge)=>{const ke=Lt({stage:x,error:wr(b),sessionCheck:(D==null?void 0:D.status)||"not-run",ownerMatch:(D==null?void 0:D.ownerMatch)||"not-run",payload:ee}),De=hr(ke);return re({reference:ke.reference,text:De}),W("idle"),console.error("Real Pay Meter save diagnostic:",ke),B(ge),ke},[]),y=l.useCallback(async()=>{var x;if(I){if(W("copying"),typeof navigator<"u"&&((x=navigator.clipboard)!=null&&x.writeText))try{await navigator.clipboard.writeText(I.text),W("copied");return}catch{}W("manual"),typeof window<"u"&&window.setTimeout(()=>{var b,D;(b=de.current)==null||b.focus(),(D=de.current)==null||D.select()},0)}},[I]),Y=()=>{if(!j)return"Choose the date for this shift.";z.trim(),C.trim();const x=Number(g);if(!Number.isFinite(x)||x<=0||x>24)return"Hours must be greater than 0 and no more than 24.";for(const[b,D]of[["gross earnings",F],["total miles",S],["gas paid",M]]){if(D.trim()==="")return`Enter ${b}, using 0 when that is honest.`;if(!Number.isFinite(Number(D))||Number(D)<0)return`${b[0].toUpperCase()}${b.slice(1)} must be 0 or more.`}return null},ce=async x=>{x.preventDefault();const b=Y();if(b){B(b),R(null),re(null),W("idle");return}le(!0),B(null),R(null),se(null),re(null),W("idle");const D=jr();let ee=null,ge="session-check",ke=null,De;try{if(ge="session-check",ee=await Fr(t),ee.status!=="available"){E(ge,ee.error,ee,void 0,ee.status==="missing"?"Your RSG sign-in has ended. Use the account controls in the header or footer to sign in again, then try saving this shift. Your entered values are still here.":"We could not confirm your RSG account yet. Your entered values are still here. Try saving again.");return}const Re=ee,Me={expected_account_id:t,correlation_id:D,user_id:Re.ownerId,shift_date:j,start_time:z.trim(),end_time:C.trim(),zone:$.trim()||null,total_hours:Number(g),platforms:[],gross_earnings:Number(F),tips:0,total_miles:Number(S),dead_miles:null,fuel_cost:Number(M),tolls:0,other_fees:0,notes:null};De=Me,ge="create";let pe=null;try{const xe=await bs(Me),Be=xe==null?void 0:xe.shift;if(!Be||typeof Be!="object"||typeof Be.id!="string")throw Object.assign(new Error("The shift save acknowledgement was incomplete."),{code:"shift_save_unacknowledged",phase:"response",correlationId:D});pe={...Be}}catch(xe){throw ke=xe,xe}ie.current+=1,G.current=!1,ks(ae);try{ge="history-refresh";const xe=await Ue(),Be=String((pe==null?void 0:pe.id)??"").trim(),ot=!!Be&&xe.some(He=>String((He==null?void 0:He.id)??"").trim()===Be);if(pe&&!ot){const He=st([pe,...xe]);o(He),i==null||i(He)}}catch(xe){const Be=Lt({stage:"history-refresh",error:xe,sessionCheck:Re.status,ownerMatch:Re.ownerMatch,payload:De});console.error("Real Pay Meter history refresh diagnostic:",Be);const ot=pe?st([pe,...m]):m;o(ot),i==null||i(ot),se("Your shift was saved, but the history could not refresh. Reload this page to confirm it.")}R("Shift saved to your private history."),f(""),h(""),_(""),v(""),L(""),Q(""),H("0")}catch(Re){const Me=ke??Re,pe=Nr(Me),xe=(ee==null?void 0:ee.status)==="missing"?"Your RSG sign-in has ended. Use the account controls in the header or footer to sign in again, then try saving this shift. Your entered values are still here.":pe==="caller_session_rejected"?"Your RSG sign-in could not be verified by the save service. Use the account controls in the header or footer to sign in again, then try saving this shift. Your entered values are still here.":pe==="missing_caller_credential"?"We c
12ould not access your account credential. Refresh the page and try again. Your entered values are still here.":pe==="account_mismatch"?"The signed-in account changed while this page was open. Refresh the page and try again. Your entered values are still here.":"We could not save this shift yet. Your entered values are still here. Try saving again.";E(ge,Me,ee,De,xe)}finally{le(!1)}},A=n||p,Fe=m;return e.jsxs("div",{className:"overflow-hidden rounded-[24px] border border-zinc-200 bg-white shadow-[0_16px_44px_rgba(24,24,27,0.07)]",children:[e.jsxs("div",{className:"border-b border-zinc-100 px-5 py-5 sm:px-7 sm:py-6",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-[14px] bg-[#F45815] text-white shadow-[0_8px_20px_rgba(244,88,21,0.2)]",children:e.jsx(We,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-black uppercase tracking-[0.18em] text-[#B9380B]",children:"Free tool 01"}),e.jsx("h3",{className:"mt-1 font-['Poppins',sans-serif] text-[24px] font-black leading-none tracking-[-0.04em] text-zinc-950 sm:text-[28px]",children:"Real Pay Meter"}),e.jsx("p",{className:"mt-2 max-w-[52ch] text-[13px] leading-relaxed text-zinc-600",children:"Log the shift, then see what remains after gas and a standard vehicle-cost estimate."})]})]}),e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full border border-emerald-200 bg-emerald-50 px-3 py-1.5 text-[10px] font-black uppercase tracking-[0.12em] text-emerald-800",children:[e.jsx(we,{className:"h-3.5 w-3.5"})," Private history"]})]}),e.jsxs("div",{className:"mt-5 flex flex-wrap items-center gap-x-4 gap-y-2 text-[11px] font-semibold text-zinc-600",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(Ze,{className:"h-3.5 w-3.5 text-[#0F8B88]"})," Fuel is logged separately"]}),e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(qs,{className:"h-3.5 w-3.5 text-[#F45815]"})," No earnings guarantee"]}),e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(oe,{className:"h-3.5 w-3.5 text-[#F45815]"})," ",Fe.length," saved shift",Fe.length===1?"":"s"]})]})]}),e.jsxs("form",{id:"real-pay-meter-form",onSubmit:ce,className:"scroll-mt-28 border-b border-zinc-100 bg-[#FFFCF9] px-5 py-5 sm:px-7 sm:py-7",children:[e.jsxs("div",{className:"flex items-end justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.18em] text-[#B9380B]",children:"Add a real shift"}),e.jsx("h4",{className:"mt-1 text-[19px] font-black tracking-tight text-zinc-950",children:"Five numbers. Clearer pay."})]}),e.jsx("span",{className:"hidden rounded-full border border-[#F45815]/20 bg-white px-3 py-1.5 text-[10px] font-bold text-zinc-600 sm:inline-flex",children:"No sample data"})]}),e.jsxs("div",{className:"mt-5 grid gap-4 sm:grid-cols-2 lg:grid-cols-4",children:[e.jsxs("label",{className:"block",children:[e.jsxs("span",{className:"mb-1.5 flex items-center gap-1.5 text-[10px] font-black uppercase tracking-[0.12em] text-zinc-700",children:[e.jsx(ye,{className:"h-3.5 w-3.5 text-[#F45815]"})," Date"]}),e.jsx("input",{type:"date",value:j,onChange:x=>{G.current=!0,w(x.target.value),B(null)},required:!0,className:"h-12 w-full rounded-[12px] border border-zinc-200 bg-white px-3 text-[16px] font-semibold text-zinc-900 outline-none transition focus:border-[#F45815] focus:ring-2 focus:ring-[#F45815]/20"})]}),e.jsxs("label",{className:"block",children:[e.jsxs("span",{className:"mb-1.5 flex items-center gap-1.5 text-[10px] font-black uppercase tracking-[0.12em] text-zinc-700",children:[e.jsx(Ie,{className:"h-3.5 w-3.5 text-[#F45815]"})," Hours"]}),e.jsx("input",{type:"number",inputMode:"decimal",min:"0.1",max:"24",step:"0.1",value:g,onChange:x=>{G.current=!0,v(x.target.value),B(null)},placeholder:"4.5",required:!0,className:"h-12 w-full rounded-[12px] border border-zinc-200 bg-white px-3 text-[16px] font-semibold text-zinc-900 outline-none transition focus:border-[#F45815] focus:ring-2 focus:ring-[#F45815]/20"})]}),e.jsxs("label",{className:"block",children:[e.jsxs("span",{className:"mb-1.5 flex items-center gap-1.5 text-[10px] font-black uppercase tracking-[0.12em] text-zinc-700",children:[e.jsx(Ie,{className:"h-3.5 w-3.5 text-[#F45815]"})," Start time ",e.jsx("span",{className:"font-semibold normal-case tracking-normal text-zinc-500",children:"(optional)"})]}),e.jsx("input",{type:"time",value:z,onChange:x=>{G.current=!0,f(x.target.value),B(null)},"aria-describedby":"shift-time-help",className:"h-12 w-full rounded-[12px] border border-zinc-200 bg-white px-3 text-[16px] font-semibold text-zinc-900 outline-none transition focus:border-[#F45815] focus:ring-2 focus:ring-[#F45815]/20"})]}),e.jsxs("label",{className:"block",children:[e.jsxs("span",{className:"mb-1.5 flex items-center gap-1.5 text-[10px] font-black uppercase tracking-[0.12em] text-zinc-700",children:[e.jsx(Ie,{className:"h-3.5 w-3.5 text-[#F45815]"})," End time ",e.jsx("span",{className:"font-semibold normal-case tracking-normal text-zinc-500",children:"(optional)"})]}),e.jsx("input",{type:"time",value:C,onChange:x=>{G.current=!0,h(x.target.value),B(null)},"aria-describedby":"shift-time-help",className:"h-12 w-full rounded-[12px] border border-zinc-200 bg-white px-3 text-[16px] font-semibold text-zinc-900 outline-none transition focus:border-[#F45815] focus:ring-2 focus:ring-[#F45815]/20"})]}),e.jsxs("label",{className:"block",children:[e.jsxs("span",{className:"mb-1.5 flex items-center gap-1.5 text-[10px] font-black uppercase tracking-[0.12em] text-zinc-700",children:[e.jsx("span",{className:"text-[#F45815]",children:"$"})," Gross earnings"]}),e.jsx("input",{type:"number",inputMode:"decimal",min:"0",step:"0.01",value:F,onChange:x=>{G.current=!0,L(x.target.value),B(null)},placeholder:"0.00",required:!0,className:"h-12 w-full rounded-[12px] border border-zinc-200 bg-white px-3 text-[16px] font-semibold text-zinc-900 outline-none transition focus:border-[#F45815] focus:ring-2 focus:ring-[#F45815]/20"})]}),e.jsxs("label",{className:"block",children:[e.jsxs("span",{className:"mb-1.5 flex items-center gap-1.5 text-[10px] font-black uppercase tracking-[0.12em] text-zinc-700",children:[e.jsx(it,{className:"h-3.5 w-3.5 text-[#F45815]"})," Total miles"]}),e.jsx("input",{type:"number",inputMode:"decimal",min:"0",step:"0.1",value:S,onChange:x=>{G.current=!0,Q(x.target.value),B(null)},placeholder:"0",required:!0,className:"h-12 w-full rounded-[12px] border border-zinc-200 bg-white px-3 text-[16px] font-semibold text-zinc-900 outline-none transition focus:border-[#F45815] focus:ring-2 focus:ring-[#F45815]/20"})]}),e.jsxs("label",{className:"block",children:[e.jsxs("span",{className:"mb-1.5 flex items-center gap-1.5 text-[10px] font-black uppercase tracking-[0.12em] text-zinc-700",children:[e.jsx(fe,{className:"h-3.5 w-3.5 text-[#F45815]"})," Gas paid"]}),e.jsx("input",{type:"number",inputMode:"decimal",min:"0",step:"0.01",value:M,onChange:x=>{G.current=!0,H(x.target.value),B(null)},placeholder:"0.00",required:!0,className:"h-12 w-full rounded-[12px] border border-zinc-200 bg-white px-3 text-[16px] font-semibold text-zinc-900 outline-none transition focus:border-[#F45815] focus:ring-2 focus:ring-[#F45815]/20"})]}),e.jsxs("label",{className:"block",children:[e.jsxs("span",{className:"mb-1.5 flex items-center gap-1.5 text-[10px] font-black uppercase tracking-[0.12em] text-zinc-700",children:[e.jsx(it,{className:"h-3.5 w-3.5 text-[#F45815]"})," Work zone ",e.jsx("span",{className:"font-semibold normal-case tracking-normal text-zinc-500",children:"(optional)"})]}),e.jsx("input",{type:"text",inputMode:"text",maxLength:120,value:$,onChange:x=>{G.current=!0,_(x.target.value),B(null)},placeholder:"Downtown or airport",className:"h-12 w-full rounded-[12px] border border-zinc-200 bg-white px-3 text-[16px] font-semibold text-zinc-900 outline-none transition focus:border-[#F45815] focus:ring-2 focus:ring-[#F45815]/20"})]})]}),e.jsx("p",{id:"shift-time-help",className:"mt-3 text-[11px] leading-relaxed text-zinc-600",children:"Start and end times are each optional. They can cross midnight, and they never change the hours calculation you enter."}),e.jsxs("div",{className:"mt-5 rounded-[18px] border border-[#F45815]/20 bg-white p-4 sm:p-5",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.16em] text-[#B9380B]",children:"Live math"}),e.jsxs("p",{className:"text-[11px] font-semibold text-zinc-600",children:["Vehicle-cost estimate: ",e.jsxs("span",{className:"font-mono font-black text-zinc-950",children:["$",he.toFixed(2),"/mi"]})]})]}),e.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-6",children:[e.jsx($e,{label:"Gross",value:je(Z.gross)}),e.jsx($e,{label:"Gas",value:`-${je(Z.gas)}`}),e.jsx($e,{label:"Vehicle cost",value:`-${je(Z.vehicle)}`}),e.jsx($e,{label:"After gas",value:je(Z.afterGas)}),e.jsx($e,{label:"Net estimate",value:je(Z.net),accent:!0}),e.jsx($e,{label:"After-cost hourly",value:ve.hours>0?`${je(Z.hourly)}/hr`:"—",accent:!0})]}),e.jsxs("p",{className:"mt-3 text-[11px] leading-relaxed text-zinc-600",children:["Net estimate = gross earnings − gas paid − (total miles × $",he.toFixed(2),"). The vehicle-cost estimate covers wear, maintenance, depreciation, and insurance reserve. Fuel stays separate so it is not counted twice."]})]}),T&&e.jsxs("div",{role:"alert",className:"mt-4 flex items-start gap-2 rounded-[12px] border border-red-200 bg-red-50 px-3.5 py-3 text-[12px] font-semibold leading-relaxed text-red-800",children:[e.jsx(P,{className:"mt-0.5 h-4 w-4 shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{children:T}),I&&e.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[e.jsxs("span",{className:"rounded-full border border-red-200 bg-white px-2.5 py-1 text-[10px] font-black uppercase tracking-[0.1em] text-red-700",children:["Support ref ",I.reference]}),e.jsxs("button",{type:"button",onClick:()=>{y()},disabled:U==="copying",className:"inline-flex min-h-[36px] items-center gap-1.5 rounded-full border border-red-300 bg-white px-3 py-1.5 text-[11px] font-black text-red-800 transition hover:bg-red-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-red-500/40 focu
12s-visible:ring-offset-2 disabled:cursor-wait disabled:opacity-60","aria-label":"Copy safe save help details",children:[U==="copied"?e.jsx(Ts,{className:"h-3.5 w-3.5"}):e.jsx(Ds,{className:"h-3.5 w-3.5"}),U==="copied"?"Copied help details":U==="copying"?"Copying help details":"Copy help details"]}),U==="copied"&&e.jsx("span",{role:"status",className:"text-[11px] font-bold text-red-700",children:"Safe details copied."}),U==="manual"&&e.jsxs("div",{className:"basis-full rounded-[10px] border border-red-200 bg-white p-2.5",children:[e.jsx("p",{className:"text-[11px] font-semibold leading-relaxed text-red-800",children:"Clipboard access is unavailable. Select the safe details below and copy them."}),e.jsx("textarea",{ref:de,readOnly:!0,value:I.text,onFocus:x=>x.currentTarget.select(),onClick:x=>x.currentTarget.select(),"aria-label":"Safe save help details to copy",rows:6,className:"mt-2 w-full resize-y rounded-[8px] border border-red-200 bg-red-50/40 p-2 text-[11px] leading-relaxed text-zinc-700 outline-none focus:border-red-400 focus:ring-2 focus:ring-red-500/20"})]})]})]})]}),K&&e.jsxs(be.div,{...c?{}:{initial:{opacity:0,y:5},animate:{opacity:1,y:0}},role:"status",className:"mt-4 flex items-start gap-2 rounded-[12px] border border-emerald-200 bg-emerald-50 px-3.5 py-3 text-[12px] font-semibold text-emerald-800",children:[e.jsx(te,{className:"mt-0.5 h-4 w-4 shrink-0"}),K]}),O&&e.jsxs("div",{role:"status",className:"mt-4 flex items-start gap-2 rounded-[12px] border border-amber-200 bg-amber-50 px-3.5 py-3 text-[12px] font-semibold leading-relaxed text-amber-900",children:[e.jsx(P,{className:"mt-0.5 h-4 w-4 shrink-0"}),O]}),e.jsxs("div",{className:"mt-5 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsx("p",{className:"text-[11px] leading-relaxed text-zinc-500",children:"Use 0 for a real zero. This tool records math and logging only."}),e.jsx("button",{type:"submit",disabled:gt,className:"inline-flex min-h-[50px] w-full items-center justify-center gap-2 rounded-[14px] bg-[#F45815] px-6 text-[14px] font-black text-white shadow-[0_10px_22px_rgba(244,88,21,0.22)] transition hover:-translate-y-0.5 hover:bg-[#E94E0E] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#F45815] focus-visible:ring-offset-2 disabled:cursor-wait disabled:opacity-60 sm:w-auto",children:V?e.jsxs(e.Fragment,{children:[e.jsx(X,{className:"h-4 w-4 animate-spin"})," Saving shift"]}):e.jsxs(e.Fragment,{children:[e.jsx(_t,{className:"h-4 w-4"})," Save real shift"]})})]}),e.jsx("p",{className:"mt-4 text-[11px] font-semibold text-zinc-500",children:"Informational only — not tax or financial advice."})]}),e.jsxs("section",{id:"profit-history","aria-labelledby":"profit-history-title",className:"px-5 py-5 sm:px-7 sm:py-7",children:[e.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.18em] text-[#B9380B]",children:"Your saved history"}),e.jsxs("h4",{id:"profit-history-title",className:"mt-1 flex items-center gap-2 text-[20px] font-black tracking-tight text-zinc-950",children:[e.jsx(oe,{className:"h-5 w-5 text-[#F45815]"})," Real shifts, newest first"]})]}),e.jsx("span",{className:"rounded-full border border-zinc-200 bg-zinc-50 px-3 py-1.5 text-[10px] font-bold text-zinc-600",children:a||k?"Loading":`${Fe.length} saved`})]}),A&&e.jsxs("div",{role:"alert",className:"mt-5 flex flex-wrap items-center justify-between gap-3 rounded-[14px] border border-amber-200 bg-amber-50 px-4 py-3 text-[12px] font-semibold leading-relaxed text-amber-900",children:[e.jsxs("span",{className:"flex items-start gap-2",children:[e.jsx(P,{className:"mt-0.5 h-4 w-4 shrink-0"}),A]}),e.jsxs("button",{type:"button",onClick:jt,className:"inline-flex min-h-[36px] items-center gap-1.5 rounded-full border border-amber-300 bg-white px-3 py-1.5 text-[11px] font-black text-amber-900 transition hover:bg-amber-100",children:[e.jsx(X,{className:"h-3.5 w-3.5"})," Try again"]})]}),a||k?e.jsxs("div",{className:"mt-5 space-y-3","aria-label":"Loading saved shifts",children:[e.jsx("div",{className:"h-[104px] animate-pulse rounded-[16px] bg-zinc-100"}),e.jsx("div",{className:"h-[104px] animate-pulse rounded-[16px] bg-zinc-100"})]}):!A&&Fe.length===0?e.jsxs("div",{className:"mt-5 rounded-[16px] border border-dashed border-zinc-300 bg-[#FFFCF9] px-5 py-9 text-center",children:[e.jsx("span",{className:"mx-auto flex h-11 w-11 items-center justify-center rounded-full bg-[#FFF1E8] text-[#F45815]",children:e.jsx(oe,{className:"h-5 w-5"})}),e.jsx("p",{className:"mt-3 text-[15px] font-black text-zinc-950",children:"Your history starts with your next shift."}),e.jsx("p",{className:"mx-auto mt-1.5 max-w-[42ch] text-[12px] leading-relaxed text-zinc-600",children:"There is no sample data here. Save a real shift above and the Meter will keep it tied to your account."})]}):e.jsx("div",{className:"mt-5 space-y-3",children:Fe.map((x,b)=>{var De,Re,Me;const D=It(Number(x.gross_earnings)||0,Number(x.total_hours)||0,Number(x.total_miles)||0,Number(x.fuel_cost)||0,he),ge=!!((De=x.start_time)!=null&&De.trim()&&((Re=x.end_time)!=null&&Re.trim()))?`${Pt(x.start_time)} to ${Pt(x.end_time)}`:"Time window not captured",ke=(Me=x.zone)==null?void 0:Me.trim();return e.jsxs(be.article,{...c?{}:{initial:{opacity:0,y:8}
12,animate:{opacity:1,y:0},transition:{delay:Math.min(b*.04,.2)}},className:"rounded-[16px] border border-zinc-200 bg-white p-4 transition hover:border-[#F45815]/30 hover:shadow-[0_10px_24px_rgba(244,88,21,0.07)]",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full bg-zinc-950 px-2.5 py-1 text-[11px] font-bold text-white",children:[e.jsx(ye,{className:"h-3 w-3"}),br(x.shift_date)]}),e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full border border-zinc-200 bg-zinc-50 px-2.5 py-1 text-[11px] font-semibold text-zinc-700",children:[e.jsx(Ie,{className:"h-3 w-3"}),Number(x.total_hours).toFixed(1)," hours"]})]}),e.jsxs("p",{className:"mt-2 text-[11px] text-zinc-500",children:[ge,ke?` · Zone: ${ke}`:""," · ",Number(x.total_miles).toFixed(1)," miles"]})]}),e.jsxs("div",{className:`rounded-[12px] px-3 py-2 text-right ${D.net>=0?"bg-[#FFF4EC] text-[#B9380B]":"bg-red-50 text-red-800"}`,children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.12em]",children:"After costs"}),e.jsx("p",{className:"mt-0.5 font-mono text-[17px] font-black",children:je(D.net)}),e.jsxs("p",{className:"text-[11px] font-bold",children:[je(D.hourly),"/hr"]})]})]}),e.jsxs("div",{className:"mt-3 grid grid-cols-3 gap-2",children:[e.jsx($e,{label:"Gross",value:je(D.gross)}),e.jsx($e,{label:"Gas",value:je(D.gas)}),e.jsx($e,{label:"Vehicle",value:je(D.vehicle)})]})]},x.id||`${x.shift_date}-${b}`)})}),e.jsxs("p",{className:"mt-5 flex items-start gap-2 text-[11px] leading-relaxed text-zinc-500",children:[e.jsx(we,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-[#0F8B88]"})," Your history is loaded by your authenticated account. It is not shared with another driver through this tool."]})]})]})}const zr=.3,_r=.5,rt={Overnight:"12:00–5:59 AM",Morning:"6:00–11:59 AM",Afternoon:"12:00–4:59 PM",Evening:"5:00–11:59 PM"};function dt(){const t=new Date;return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`}function Ut(t){const s=t.created_at;if(typeof s!="string"&&typeof s!="number")return null;const r=Date.parse(String(s));return Number.isFinite(r)?r:null}function Ct(t){return[...t].sort((s,r)=>{const a=String(r.shift_date||"").localeCompare(String(s.shift_date||""));if(a!==0)return a;const n=Ut(s),i=Ut(r);if(n===null&&i!==null)return 1;if(n!==null&&i===null)return-1;if(n!==null&&i!==null&&n!==i)return i-n;const d=String(s.id||""),c=String(r.id||"");return c===d?0:c>d?1:-1})}function Sr(t){const s=Number(t==null?void 0:t.operating_cost_per_mile);return Number.isFinite(s)&&s>=0?s:zr}function Te(t){const s=typeof t=="number"?t:Number(t);return Number.isFinite(s)?s:null}function _s(t,s){const r=Te(t.total_hours),a=Te(t.gross_earnings),n=Te(t.total_miles),i=Te(t.fuel_cost),d=Te(t.tips)??0,c=Te(t.tolls)??0,m=Te(t.other_fees)??0;return r===null||r<=0||a===null||n===null||i===null?null:{hours:r,net:a+d-i-n*s-c-m}}function Er(t){const s=String(t||"").trim().replace(/\s+/g," ");return s?{key:s.toLowerCase(),label:s}:null}function Cr(t){const s=/^(\d{1,2}):(\d{2})(?::\d{2})?$/.exec(String(t||"").trim());if(!s)return null;const r=Number(s[1]),a=Number(s[2]);return r<0||r>23||a<0||a>59?null:r<6?"Overnight":r<12?"Morning":r<17?"Afternoon":"Evening"}function Ot(t,s,r,a){const n=t.get(s)||{label:r,count:0,totalHours:0,totalNet:0};n.count+=1,n.totalHours+=a.hours,n.totalNet+=a.net,t.set(s,n)}function Gt(t,s){const r=[...t.values()].sort((a,n)=>{const i=a.totalHours>0?a.totalNet/a.totalHours:Number.NEGATIVE_INFINITY;return(n.totalHours>0?n.totalNet/n.totalHours:Number.NEGATIVE_INFINITY)-i||n.count-a.count||a.label.localeCompare(n.label)})[0];return r?{label:r.label,count:r.count,averageHourly:r.totalHours>0?r.totalNet/r.totalHours:0,detail:s==null?void 0:s[r.label]}:null}function pt(t){return(t<0?"-":"")+"$"+Math.abs(t).toFixed(2)}function Br(t){const s=String(t||"").trim();if(!Bt(s))return s||"Not captured";const[r,a,n]=s.split("-").map(Number);return new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric"}).format(new Date(r,a-1,n))}
12function Yt(t){const s=String(t||"").trim(),r=/^(\d{1,2}):(\d{2})(?::\d{2})?$/.exec(s);if(!r)return s||"Not captured";const a=Number(r[1]),n=Number(r[2]);if(a<0||a>23||n<0||n>59)return s||"Not captured";const i=a>=12?"PM":"AM";return`${a%12||12}:${String(n).padStart(2,"0")} ${i}`}function qt(t,s,r=""){const a=Te(t);return a===null?"Not captured":`${a.toFixed(s)}${r}`}function Ht(t){const s=Te(t);return s===null?"Not captured":pt(s)}function tt(t,s){return`${t} ${s}${t===1?"":"s"}`}function Bt(t){const s=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t);if(!s)return!1;const r=new Date(Number(s[1]),Number(s[2])-1,Number(s[3]));return r.getFullYear()===Number(s[1])&&r.getMonth()===Number(s[2])-1&&r.getDate()===Number(s[3])}function wt(t){const s=/^(\d{2}):(\d{2})$/.exec(t);return!!(s&&Number(s[1])<=23&&Number(s[2])<=59)}function ft(t){const s=String(t||"").trim();if(!wt(s))return null;const[r,a]=s.split(":").map(Number);return r*60+a}function $r(t,s){const r=ft(t),a=ft(s);return r===null||a===null?null:(a<=r?a+1440-r:a-r)/60}function $t(t){const s=Number(t.hours),r=ft(t.startTime),a=ft(t.endTime),n=$r(t.startTime,t.endTime);return!Number.isFinite(s)||r===null||a===null||n===null||Math.abs(s-n)<=_r?null:{enteredHours:s,elapsedHours:n,overnight:a<=r}}function Ar(t){return $t({hours:String(t.total_hours??""),startTime:String(t.start_time||""),endTime:String(t.end_time||"")})}function At(t){return Bt(t)&&t>dt()}function Tr(t,s,r=!1){return JSON.stringify([s,t.shiftDate,t.startTime,t.endTime,t.zone,t.hours,t.gross,t.miles,t.gas,r])}function Dr(){try{if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return`bsf-${crypto.randomUUID().replace(/-/g,"").slice(0,24)}`}catch{}return`bsf-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function Rr(t,s=!1){if(!Bt(t.shiftDate))return"Choose a valid date for this shift.";if(At(t.shiftDate))return"Shift date cannot be in the future. Choose today or an earlier date.";const r=Number(t.hours);if(!Number.isFinite(r)||r<=0||r>24)return"Hours must be greater than 0 and no more than 24.";if(!t.startTime||!wt(t.startTime))return"Enter a valid start time, such as 08:30.";if(t.endTime&&!wt(t.endTime))return"Enter a valid end time, such as 14:30, or leave it blank.";if($t(t)&&!s)return"Confirm the time mismatch above before saving. The estimate will use the hours you entered.";for(const[i,d]of[["gross earnings",t.gross],["total miles",t.miles],["gas paid",t.gas]]){if(!d.trim())return`Enter ${i}, using 0 when that is honest.`;if(!Number.isFinite(Number(d))||Number(d)<0)return`${i[0].toUpperCase()}${i.slice(1)} must be 0 or more.`}const n=t.zone.trim();return n?n.length>120?"Work zone must be 120 characters or fewer.":null:"Enter the work zone for this shift."}function Le({label:t,hint:s,id:r,className:a="",...n}){return e.jsxs("label",{htmlFor:r,className:"block",children:[e.jsxs("span",{className:"text-[11px] font-black text-zinc-800",children:[t,n.required&&e.jsx("span",{className:"ml-1 text-[#F45815]","aria-hidden":"true",children:"*"})]}),e.jsx("input",{id:r,className:`mt-2 min-h-[46px] w-full rounded-[12px] border border-zinc-300 bg-white px-3.5 text-[14px] font-semibold text-zinc-950 outline-none transition placeholder:text-zinc-400 focus:border-[#3D9BE9] focus:ring-2 focus:ring-[#3D9BE9]/20 disabled:cursor-not-allowed disabled:bg-zinc-100 ${a}`,...n}),s&&e.jsx("span",{className:"mt-1.5 block text-[10px] leading-relaxed text-zinc-500",children:s})]})}function Mr({userId:t,history:s,onHistoryChange:r}){const[a,n]=l.useState(dt()),[i,d]=l.useState(""),[c,m]=l.useState(""),[o,k]=l.useState(""),[N,p]=l.useState(""),[u,j]=l.useState(""),[w,z]=l.useState(""),[f,C]=l.useState("0"),[h,$]=l.useState(!1),[_,g]=l.useState(null),[v,F]=l.useState(null),[L,S]=l.useState(!1),Q=l.useRef(null),[M,H]=l.useState(0),T=l.useCallback(()=>{H(I=>I+1)},[]);l.useEffect(()=>{var I;_&&((I=Q.current)==null||I.focus())},[_,M]);const B=l.useRef(null),K={shiftDate:a,startTime:i,endTime:c,zone:o,hours:N,gross:u,miles:w,gas:f},R=$t(K),O=_?"best-shift-entry-error":void 0,se=()=>{B.current=null},V=(I,re=!1)=>U=>{se(),I(U.target.value),re&&S(!1),g(null),F(null)},le=async I=>{if(I.preventDefault(),h)return;const re=Rr(K,L);if(re){g(re),T(),F(null);return}$(!0),g(null),F(null);const U=Tr(K,t,L),W=B.current,de=(W==null?void 0:W.fingerprint)===U?W.correlationId:Dr();B.current={fingerprint:U,correlationId:de};try{const ae={expected_account_id:t,correlation_id:de,user_id:t,shift_date:a,start_time:i.trim(),end_time:c.trim(),zone:o.trim(),total_hours:Number(N),platforms:[],gross_earnings:Number(u),tips:0,total_miles:Number(w),dead_miles:null,fuel_cost:Number(f),tolls:0,other_fees:0,notes:null,mismatch_acknowledged:!!(R&&L)},G=await bs(ae),ne=G==null?void 0:G.shift;if(!ne||typeof ne!="object"||typeof ne.id!="string")throw new Error("The shift save acknowledgement was incomplete.");const ie=ne,Ce=String(ie.id),he={...ie,id:Ce,user_id:String(ie.user_id||t),...R?{mismatch_acknowledged:!0}:{}},ve=s.some(Z=>String(Z.id)===Ce)?s.map(Z=>String(Z.id)===Ce?he:Z):[he,...s];r==null||r(Ct(ve)),B.current=null,F("Comparison shift saved to your private history."),S(!1),n(dt()),d(""),m(""),k(""),p(""),j(""),z(""),C("0")}catch(ae){console.error("Best-Shift Finder shift save failed:",ae),g("We could not save this shift yet. Your entered values are still here. Try saving again."),T()}finally{$(!1)}};return e.jsxs("form",{id:"best-shift-entry-form",className:"mt-7 scroll-mt-28 rounded-[19px] border border-[#B8DAF5] bg-[#F4FAFF] p-4 sm:p-6",onSubmit:le,noValidate:!0,"aria-labelledby":"best-shift-entry-title","aria-describedby":O,"aria-busy":h,children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-[12px] bg-white text-[#3D9BE9]",children:e.jsx(ye,{className:"h-5 w-5","aria-hidden":"true"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.16em] text-[#1C6AA8]",children:"Independent entry"}),e.jsx("h3",{id:"best-shift-entry-title",className:"mt-1 text-[20px] font-black tracking-tight text-zinc-950",children:"Log a shift for comparison"}
12),e.jsx("p",{className:"mt-2 max-w-[62ch] text-[12px] leading-relaxed text-zinc-600",children:"Use this form on its own to save a real shift, including the start time and work zone that make this comparison useful. It stays in your same private shift history."})]})]}),e.jsxs("div",{className:"mt-5 grid gap-4 sm:grid-cols-2 lg:grid-cols-4",children:[e.jsx(Le,{id:"best-shift-date",label:"Shift date",type:"date",value:a,max:dt(),onChange:V(n),required:!0,autoComplete:"off","aria-describedby":O,disabled:h}),e.jsx(Le,{id:"best-shift-hours",label:"Hours worked",type:"number",min:"0.01",max:"24",step:"0.25",inputMode:"decimal",value:N,onChange:V(p,!0),required:!0,placeholder:"8","aria-describedby":O,disabled:h}),e.jsx(Le,{id:"best-shift-start",label:"Start time",type:"time",value:i,onChange:V(d,!0),required:!0,autoComplete:"off","aria-describedby":O,disabled:h}),e.jsx(Le,{id:"best-shift-end",label:"End time",type:"time",value:c,onChange:V(m,!0),hint:"Optional",autoComplete:"off","aria-describedby":O,disabled:h})]}),R&&e.jsxs("div",{id:"best-shift-time-mismatch",className:"mt-4 flex items-start gap-3 rounded-[13px] border border-amber-300 bg-amber-50 px-3.5 py-3 text-[11px] leading-relaxed text-amber-950",role:"note","aria-live":"polite",children:[e.jsx(P,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-700","aria-hidden":"true"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-black",children:"Clock span and entered hours differ."}),e.jsxs("p",{className:"mt-1",children:["The clock span is ",R.elapsedHours.toFixed(1)," hours",R.overnight?" across midnight":"",", but you entered ",R.enteredHours.toFixed(1)," hours. Entered hours stay authoritative, so the hourly estimate will use ",R.enteredHours.toFixed(1)," hours."]}),e.jsxs("label",{className:"mt-3 flex min-h-[44px] cursor-pointer items-start gap-2 rounded-[10px] border border-amber-200 bg-white px-3 py-2.5 font-bold",children:[e.jsx("input",{type:"checkbox",checked:L,onChange:I=>{se(),S(I.target.checked),g(null)},disabled:h,"aria-describedby":_?"best-shift-time-mismatch best-shift-entry-error":"best-shift-time-mismatch",className:"mt-0.5 h-4 w-4 shrink-0 accent-amber-700"}),e.jsx("span",{children:"I understand and want to save using the entered hours."})]})]})]}),e.jsxs("div",{className:"mt-4 grid gap-4 sm:grid-cols-2 lg:grid-cols-4",children:[e.jsx(Le,{id:"best-shift-gross",label:"Gross earnings",type:"number",min:"0",step:"0.01",inputMode:"decimal",value:u,onChange:V(j),required:!0,placeholder:"0.00",autoComplete:"transaction-amount","aria-describedby":O,disabled:h}),e.jsx(Le,{id:"best-shift-miles",label:"Total miles",type:"number",min:"0",step:"0.1",inputMode:"decimal",value:w,onChange:V(z),required:!0,placeholder:"0",autoComplete:"off","aria-describedby":O,disabled:h}),e.jsx(Le,{id:"best-shift-gas",label:"Gas paid",type:"number",min:"0",step:"0.01",inputMode:"decimal",value:f,onChange:V(C),required:!0,placeholder:"0.00",autoComplete:"transaction-amount","aria-describedby":O,disabled:h}),e.jsx(Le,{id:"best-shift-zone",label:"Work zone",type:"text",maxLength:120,inputMode:"text",value:o,onChange:V(k),required:!0,placeholder:"Palm Beach",autoComplete:"address-level2","aria-describedby":O,disabled:h})]}),e.jsxs("p",{className:"mt-4 flex items-start gap-2 text-[11px] leading-relaxed text-zinc-600",children:[e.jsx(it,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-[#1C6AA8]","aria-hidden":"true"}),"Start time and work zone are required for this comparison. End time is optional. Save only details from a real shift."]}),_&&e.jsxs("div",{ref:Q,id:"best-shift-entry-error",tabIndex:-1,className:"mt-4 flex items-start gap-2 rounded-[12px] border border-red-200 bg-red-50 px-3.5 py-3 text-[12px] font-semibold leading-relaxed text-red-800 focus:outline-none focus:ring-2 focus:ring-red-400 focus:ring-offset-2",role:"alert",children:[e.jsx(P,{className:"mt-0.5 h-4 w-4 shrink-0","aria-hidden":"true"}),e.jsx("p",{children:_})]}),v&&e.jsxs("div",{className:"mt-4 flex items-start gap-3 rounded-[12px] border border-emerald-200 bg-emerald-50 px-3.5 py-3 text-[12px] font-semibold text-emerald-800",role:"status","aria-live":"polite",children:[e.jsx(te,{className:"mt-0.5 h-4 w-4 shrink-0","aria-hidden":"true"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{children:v}),e.jsxs("a",{href:"#best-shift-history",className:"mt-2 inline-flex min-h-[44px] items-center gap-1.5 rounded-[10px] border border-emerald-300 bg-white px-3 py-2 text-[11px] font-black text-emerald-900 transition hover:bg-emerald-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-emerald-500/40 focu
12s-visible:ring-offset-2",children:["Review saved history ",e.jsx(q,{className:"h-3.5 w-3.5","aria-hidden":"true"})]})]})]}),e.jsxs("button",{type:"submit",disabled:h,className:"mt-5 inline-flex min-h-[50px] w-full items-center justify-center gap-2 rounded-[13px] bg-[#3D9BE9] px-5 py-3 text-[13px] font-black text-white shadow-[0_10px_22px_rgba(61,155,233,0.18)] transition hover:bg-[#2789D8] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#3D9BE9] focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-60 sm:w-auto",children:[h?e.jsx(X,{className:"h-4 w-4 animate-spin","aria-hidden":"true"}):e.jsx(_t,{className:"h-4 w-4","aria-hidden":"true"}),h?"Saving shift...":"Save shift for comparison"]})]})}function Lr({history:t,rate:s,loading:r=!1,error:a,reduceMotion:n}){const[i,d]=l.useState(!1),c=Ct(t),m=i?c:c.slice(0,3);return e.jsxs("section",{id:"best-shift-history","aria-labelledby":"best-shift-history-title",className:"mt-7 scroll-mt-36 rounded-[19px] border border-[#B8DAF5] bg-[#F4FAFF] p-4 sm:p-6",children:[e.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.18em] text-[#1C6AA8]",children:"Private account history"}),e.jsxs("h4",{id:"best-shift-history-title",className:"mt-1 flex items-center gap-2 text-[20px] font-black tracking-tight text-zinc-950",children:[e.jsx(oe,{className:"h-5 w-5 shrink-0 text-[#3D9BE9]","aria-hidden":"true"})," Your Best-Shift Finder history"]}),e.jsx("p",{className:"mt-2 text-[12px] leading-relaxed text-zinc-600",children:"Saved here by this tool, newest first. No sample records are added."})]}),e.jsx("span",{className:"shrink-0 rounded-full border border-[#B8DAF5] bg-white px-3 py-1.5 text-[10px] font-bold text-[#1C6AA8]",children:tt(t.length,"saved shift")})]}),a&&e.jsxs("div",{role:"alert",className:"mt-5 flex items-start gap-2 rounded-[13px] border border-amber-200 bg-amber-50 px-3.5 py-3 text-[11px] font-semibold leading-relaxed text-amber-950",children:[e.jsx(P,{className:"mt-0.5 h-4 w-4 shrink-0","aria-hidden":"true"}),e.jsxs("p",{children:[a,t.length>0?" Showing the shifts already loaded here.":" Try again above to reload your private history."]})]}),r?e.jsxs("div",{className:"mt-5 space-y-3","aria-label":"Loading saved Best-Shift Finder history",children:[e.jsx("div",{className:"h-[118px] animate-pulse rounded-[16px] bg-white/80"}),e.jsx("div",{className:"h-[118px] animate-pulse rounded-[16px] bg-white/80"})]}):c.length===0?a?null:e.jsxs("div",{className:"mt-5 rounded-[16px] border border-dashed border-[#B8DAF5] bg-white/80 px-5 py-9 text-center",children:[e.jsx("span",{className:"mx-auto flex h-11 w-11 items-center justify-center rounded-full bg-[#EAF5FE] text-[#3D9BE9]",children:e.jsx(oe,{className:"h-5 w-5","aria-hidden":"true"})}),e.jsx("p",{className:"mt-3 text-[15px] font-black text-zinc-950",children:"Your Best-Shift Finder history starts here."}),e.jsx("p",{className:"mx-auto mt-1.5 max-w-[42ch] text-[12px] leading-relaxed text-zinc-600",children:"Save a real shift with the form above, and it will appear here with its pay, miles, gas, and after-cost estimate."})]}):e.jsx("div",{id:"best-shift-history-list",className:"mt-5 space-y-3",children:m.map((o,k)=>{const N=_s(o,s),p=Ar(o),u=At(String(o.shift_date||"")),j=String(o.zone||"").trim()||"Not captured",w=N&&N.net<0?"border-red-200 bg-red-50 text-red-800":"border-[#F8C9B9] bg-[#FFF4EC] text-[#B9380B]";return e.jsx(be.article,{...n?{}:{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{delay:Math.min(k*.04,.2)}},className:"rounded-[16px] border border-zinc-200 bg-white p-4 transition hover:border-[#3D9BE9]/40 hover:shadow-[0_10px_24px_rgba(61,155,233,0.08)]",children:e.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full bg-zinc-950 px-2.5 py-1 text-[11px] font-bold text-white",children:[e.jsx(ye,{className:"h-3 w-3","aria-hidden":"true"}),Br(o.shift_date)]}),e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full border border-zinc-200 bg-zinc-50 px-2.5 py-1 text-[11px] font-semibold text-zinc-700",children:[e.jsx(Ie,{className:"h-3 w-3","aria-hidden":"true"}),qt(o.total_hours,1," hours")]})]}),e.jsxs("dl",{className:"mt-4 grid min-w-0 grid-cols-2 gap-2 sm:grid-cols-3",children:[e.jsxs("div",{className:"min-w-0 rounded-[12px] border border-zinc-200 bg-zinc-50 p-2.5",children:[e.jsx("dt",{className:"text-[9px] font-black uppercase tracking-[0.12em] text-zinc-500",children:"Start time"}),e.jsx("dd",{className:"mt-1 break-words text-[12px] font-bold text-zinc-900",children:Yt(o.start_time)})]}),e.jsxs("div",{className:"min-w-0 rounded-[12px] border border-zinc-200 bg-zinc-50 p-2.5",children:[e.jsx("dt",{className:"text-[9px] font-black uppercase tracking-[0.12em] text-zinc-500",children:"End time"}),e.jsx("dd",{className:"mt-1 break-words text-[12px] font-bold text-zinc-900",children:Yt(o.end_time)})]}),e.jsxs("div",{className:"col-span-2 min-w-0 rounded-[12px] border border-zinc-200 bg-zinc-50 p-2.5 sm:col-span-1",children:[e.jsx("dt",{className:"text-[9px] font-black uppercase tracking-[0.12em] text-zinc-500",children:"Work zone"}),e.jsx("dd",{className:"mt-1 break-words text-[12px] font-bold text-zinc-900",children:j})]}),e.jsxs("div",{className:"min-w-0 rounded-[12px] border border-zinc-200 bg-zinc-50 p-2.5",children:[e.jsx("dt",{className:"text-[9px] font-black uppercase tracking-[0.12em] text-zinc-500",children:"Gross earnings"}),e.jsx("dd",{className:"mt-1 break-words font-mono text-[12px] font-black text-zinc-900",children:Ht(o.gross_earnings)})]}),e.jsxs("div",{className:"min-w-0 rounded-[12px] border border-zinc-200 bg-zinc-50 p-2.5",children:[e.jsx("dt",{className:"text-[9px] font-black uppercase tracking-[0.12em] text-zinc-500",children:"Total miles"}),e.jsx("dd",{className:"mt-1 break-words text-[12px] font-bold text-zinc-900",children:qt(o.total_miles,1," miles")})]}),e.jsxs("div",{className:"min-w-0 rounded-[12px] border border-zinc-200 bg-zinc-50 p-2.5",children:[e.jsx("dt",{className:"text-[9px] font-black uppercase tracking-[0.12em] text-zinc-500",children:"Gas paid"}),e.jsx("dd",{className:"mt-1 break-words font-mono text-[12px] font-black text-zinc-900",children:Ht(o.fuel_cost)})]})]}),u&&e.jsxs("p",{className:"mt-3 flex items-start gap-1.5 rounded-[10px] border border-amber-200 bg-amber-50 px-2.5 py-2 text-[10px] font-semibold leading-relaxed text-amber-950",children:[e.jsx(P,{className:"mt-0.5 h-3.5 w-3.5 shrink-0","aria-hidden":"true"}),"Future-dated, so it stays visible here but is excluded from comparisons."]}),p&&e.jsxs("p",{className:"mt-3 flex items-start gap-1.5 rounded-[10px] border border-amber-200 bg-amber-50 px-2.5 py-2 text-[10px] font-semibold leading-relaxed text-amber-950",children:[e.jsx(P,{className:"mt-0.5 h-3.5 w-3.5 shrink-0","aria-hidden":"true"}),"Entered ",p.enteredHours.toFixed(1)," hours were used for this estimate. The clock span is ",p.elapsedHours.toFixed(1)," hours."]})]}),e.jsxs("div",{className:`w-full shrink-0 rounded-[13px] border px-3 py-2.5 sm:w-[164px] ${w}`,children:[e.jsx("p",{className:"text-[9px] font-black uppercase tracking-[0.12em]",children:"After-cost estimate"}),e.jsx("p",{className:"mt-1 font-mono text-[20px] font-black",children:N?pt(N.net):"Not available"}),e.jsx("p",{className:"mt-0.5 text-[11px] font-bold",children:N?`${pt(N.net/N.hours)}/hr estimate`:"Complete pay details needed"}),e.jsxs("p",{className:"mt-1 text-[10px] font-semibold opacity-80",children:["At $",s.toFixed(2),"/mi"]})]})]})},o.id||`${o.shift_date}-${k}`)})}),!r&&c.length>3&&e.jsxs("div",{className:"mt-4 flex flex-col gap-3 rounded-[14px] border border-[#B8DAF5] bg-white/70 p-3.5 sm:flex-row sm:items-center sm:justify-between",children:[e.jsx("p",{className:"text-[11px] font-semibold text-zinc-600",children:i?`Showing all ${c.length} saved shifts.`:`Showing 3 of ${c.length} saved shifts.`}),e.jsx("button",{type:"button",onClick:()=>d(o=>!o),"aria-expanded":i,"aria-pressed":i,"aria-controls":"best-shift-history-list",className:"inline-flex min-h-[44px] w-full items-center justify-center rounded-[11px] border border-[#3D9BE9]/35 bg-[#F4FAFF] px-4 py-2.5 text-[12px] font-black text-[#1C6AA8] transition hover:border-[#3D9BE9] hover:bg-[#
12EAF5FE] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#3D9BE9]/40 focus-visible:ring-offset-2 sm:w-auto",children:i?"Show latest 3":`View all ${c.length} saved shifts`})]}),e.jsxs("p",{className:"mt-5 flex items-start gap-2 text-[11px] leading-relaxed text-zinc-500",children:[e.jsx(we,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-[#0F8B88]","aria-hidden":"true"})," These real shifts stay inside your signed-in account and update after a successful save."]})]})}function Vt({title:t,icon:s,summary:r,missingMessage:a,teal:n=!1}){const i=n?"border-[#B9E4E1] bg-[#F2FBFA] text-[#0F7774]":"border-[#F8C9B9] bg-[#FFF8F3] text-[#B9380B]";return e.jsxs("article",{className:"rounded-[20px] border border-zinc-200 bg-white p-5 shadow-[0_8px_24px_rgba(24,24,27,0.04)] sm:p-6",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsx("span",{className:`flex h-11 w-11 items-center justify-center rounded-[14px] border ${i}`,children:e.jsx(s,{className:"h-5 w-5","aria-hidden":"true"})}),e.jsx("span",{className:`rounded-full border px-2.5 py-1 text-[9px] font-black uppercase tracking-[0.16em] ${i}`,children:(r==null?void 0:r.count)===1?"Early signal":r?"Observed history":"Awaiting details"})]}),e.jsx("h3",{className:"mt-5 text-[18px] font-black tracking-tight text-zinc-950",children:t}),r?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mt-5 flex flex-wrap items-end justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.14em] text-zinc-500",children:"After-cost hourly"}),e.jsxs("p",{className:"mt-1 font-mono text-[28px] font-black tracking-tight text-zinc-950",children:[pt(r.averageHourly),e.jsx("span",{className:"ml-1 text-[13px] font-bold text-zinc-500",children:"/hr estimate"})]})]}),e.jsx("p",{className:"text-right text-[11px] font-bold text-zinc-600",children:tt(r.count,"saved shift")})]}),e.jsxs("p",{className:"mt-3 text-[12px] leading-relaxed text-zinc-600",children:["Average after-cost hourly estimate observed in your saved history.",r.detail?` Start-time range: ${r.detail}.`:""]}),r.count===1&&e.jsx("p",{className:"mt-3 rounded-[12px] border border-amber-200 bg-amber-50 px-3 py-2.5 text-[11px] font-semibold leading-relaxed text-amber-950",children:"One saved shift is an early signal. Add more real shifts to improve this comparison."})]}):e.jsxs("div",{className:"mt-5 rounded-[14px] border border-dashed border-zinc-300 bg-[#FFFCF9] p-4",children:[e.jsx("p",{className:"text-[13px] font-black text-zinc-950",children:"No qualifying pattern yet."}),e.jsx("p",{className:"mt-1.5 text-[12px] leading-relaxed text-zinc-600",children:a})]})]})}function Wt({loading:t,error:s,historyCount:r,completeCount:a,zoneCount:n,timeCount:i,futureCount:d,onRetry:c}){return t?e.jsxs("div",{className:"mt-6 flex items-start gap-4 roun
12ded-[18px] border border-[#B9E4E1] bg-[#F2FBFA] p-5",role:"status","aria-live":"polite","aria-busy":"true",children:[e.jsx("span",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-[14px] bg-white text-[#0F7774]",children:e.jsx(X,{className:"h-5 w-5 animate-spin","aria-hidden":"true"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-[16px] font-black text-zinc-950",children:"Reading your saved shifts"}),e.jsx("p",{className:"mt-1.5 text-[12px] leading-relaxed text-zinc-600",children:"Your private history is still loading. Patterns will appear after the saved records are ready."})]})]}):s?e.jsxs("div",{className:"mt-6 flex flex-wrap items-start justify-between gap-4 rounded-[18px] border border-amber-200 bg-amber-50 p-5",role:"alert",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-[13px] bg-white text-amber-800",children:e.jsx(P,{className:"h-5 w-5","aria-hidden":"true"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-[16px] font-black text-zinc-950",children:"Your saved patterns are unavailable"}),e.jsx("p",{className:"mt-1.5 text-[12px] leading-relaxed text-amber-950",children:s})]})]}),c&&e.jsxs("button",{type:"button",onClick:c,className:"inline-flex min-h-[38px] items-center gap-1.5 rounded-full border border-amber-300 bg-white px-3.5 py-1.5 text-[11px] font-black text-amber-950 transition hover:bg-amber-100",children:[e.jsx(ue,{className:"h-3.5 w-3.5","aria-hidden":"true"})," Try again"]})]}):e.jsxs("div",{className:"mt-6 rounded-[18px] border border-dashed border-[#F8C9B9] bg-[#FFF8F3] p-5",children:[e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("span",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-[14px] bg-white text-[#F45815]",children:e.jsx(Je,{className:"h-5 w-5","aria-hidden":"true"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-[16px] font-black text-zinc-950",children:"Add the details that make a comparison useful."}),e.jsx("p",{className:"mt-1.5 text-[12px] leading-relaxed text-zinc-600",children:r?`You have ${tt(r,"saved shift")}.${d?` ${tt(d,"future-dated record")} ${d===1?"is":"are"} excluded from comparisons.`:""} The finder has ${a} with complete pay details, ${n} with a work zone, and ${i} with a valid start time. Add another complete shift below with both a start time and work zone.`:"No saved shifts yet. Log your first real shift below, including a start time and work zone, so this tool has something to compare."})]})]}),e.jsxs("div",{className:"mt-4 grid grid-cols-3 gap-2",children:[e.jsxs("div",{className:"rounded-[12px] border border-white bg-white p-3 text-center",children:[e.jsx("p",{className:"font-mono text-[18px] font-black text-zinc-950",children:r}),e.jsx("p",{className:"mt-1 text-[9px] font-black uppercase tracking-[0.12em] text-zinc-500",children:"Saved"})]}),e.jsxs("div",{className:"rounded-[12px] border border-white bg-white p-3 text-center",children:[e.jsx("p",{className:"font-mono text-[18px] font-black text-zinc-950",children:n}),e.jsx("p",{className:"mt-1 text-[9px] font-black uppercase tracking-[0.12em] text-zinc-500",children:"With zone"})]}),e.jsxs("div",{className:"rounded-[12px] border border-white bg-white p-3 text-center",children:[e.jsx("p",{className:"font-mono text-[18px] font-black text-zinc-950",children:i}),e.jsx("p",{className:"mt-1 text-[9px] font-black uppercase tracking-[0.12em] text-zinc-500",children:"With start time"})]})]}),e.jsxs("a",{href:"#best-shift-entry-form",className:"mt-4 inline-flex min-h-[44px] items-center justify-center gap-2 rounded-[12px] bg-[#F45815] px-4 py-2.5 text-[12px] font-black text-white transition hover:bg-[#E94E0E] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#F45815] focus-visible:ring-offset-2",children:[r?"Log another comparison shift":"Log your first comparison shift"," ",e.jsx(q,{className:"h-4 w-4","aria-hidden":"true"})]})]})}function Ir({userId:t,history:s=[],costSettings:r,loadingHistory:a=!1,historyError:n,onHistoryChange:i,onRetry:d}){const c=Pe(),m=l.useMemo(()=>Ct(s),[s]),o=l.useMemo(()=>{const p=Sr(r),u=new Map,j=new Map;let w=0,z=0,f=0,C=0;return m.forEach(h=>{if(At(String(h.shift_date||""))){C+=1;return}const $=_s(h,p);if(!$)return;w+=1;const _=Er(h.zone),g=Cr(h.start_time);_&&(z+=1,Ot(u,_.key,_.label,$)),g&&(f+=1,Ot(j,g,g,$))}),{rate:p,completeCount:w,zoneCount:z,timeCount:f,futureCount:C,zone:Gt(u),time:Gt(j,rt)}},[r,m]),k=!!(o.zone||o.time),N=c?{}:{initial:{opacity:0,y:12}
12,animate:{opacity:1,y:0},transition:{duration:.45,ease:[.22,1,.36,1]}};return e.jsxs(be.section,{...N,"aria-labelledby":"best-shift-finder-title",className:"overflow-hidden rounded-[24px] border border-zinc-200 bg-white shadow-[0_16px_44px_rgba(24,24,27,0.07)]",children:[e.jsx("div",{className:"border-b border-zinc-100 px-5 py-5 sm:px-7 sm:py-6",children:e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-[14px] bg-[#0F8B88] text-white shadow-[0_8px_20px_rgba(15,139,136,0.2)]",children:e.jsx(Je,{className:"h-5 w-5","aria-hidden":"true"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-black uppercase tracking-[0.18em] text-[#0F7774]",children:"Free tool 02"}),e.jsx("h3",{id:"best-shift-finder-title",className:"mt-1 font-['Poppins',sans-serif] text-[24px] font-black leading-none tracking-[-0.04em] text-zinc-950 sm:text-[28px]",children:"Best-Shift Finder"}),e.jsx("p",{className:"mt-2 max-w-[58ch] text-[13px] leading-relaxed text-zinc-600",children:"Compare the start-time windows and work zones attached to your real saved shifts."})]})]}),e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full border border-[#B9E4E1] bg-[#F2FBFA] px-3 py-1.5 text-[10px] font-black uppercase tracking-[0.12em] text-[#0F7774]",children:[e.jsx(Xe,{className:"h-3.5 w-3.5","aria-hidden":"true"})," Your history only"]})]})}),e.jsxs("div",{className:"px-5 py-5 sm:px-7 sm:py-7",children:[a||n?e.jsx(Wt,{loading:a,error:n,historyCount:s.length,completeCount:o.completeCount,zoneCount:o.zoneCount,timeCount:o.timeCount,futureCount:o.futureCount,onRetry:d}):k?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[e.jsx(Vt,{title:"Strongest observed work zone",icon:Xe,summary:o.zone,missingMessage:"Use the comparison form below to add a work zone to a real shift."}),e.jsx(Vt,{title:"Strongest observed start-time window",icon:Ie,summary:o.time,missingMessage:"Use the comparison form below to add a valid start time to a real shift.",teal:!0})]}),e.jsxs("p",{className:"mt-4 rounded-[13px] border border-zinc-200 bg-zinc-50 px-3.5 py-3 text-[11px] leading-relaxed text-zinc-600",children:["Showing patterns from ",tt(o.completeCount,"complete shift"),". ",o.zoneCount," include a work zone and ",o.timeCount," include a valid start time. Records without that detail are left out of that comparison.",o.futureCount?` ${tt(o.futureCount,"future-dated record")} ${o.futureCount===1?"is":"are"} excluded because comparisons use today or earlier shifts.`:""]}),e.jsxs("a",{href:"#best-shift-entry-form",className:"mt-4 inline-flex min-h-[44px] items-center gap-2 rounded-[12px] border border-[#3D9BE9]/35 bg-[#F4FAFF] px-4 py-2.5 text-[12px] font-black text-[#1C6AA8] transition hover:border-[#3D9BE9] hover:bg-[#EAF5FE] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#3D9BE9]/40 focus-visible:ring-offset-2",children:["Log another comparison shift ",e.jsx(q,{className:"h-4 w-4","aria-hidden":"true"})]})]}):e.jsx(Wt,{historyCount:s.length,completeCount:o.completeCount,zoneCount:o.zoneCount,timeCount:o.timeCount,futureCount:o.futureCount}),e.jsx(Mr,{userId:t,history:m,onHistoryChange:i}),e.jsx(Lr,{history:m,rate:o.rate,loading:a,error:n,reduceMotion:c})]}),e.jsxs("div",{className:"border-t border-zinc-100 bg-[#FFFCF9] px-5 py-5 sm:px-7",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-[10px] bg-white text-[#F45815]",children:e.jsx(fe,{className:"h-4 w-4","aria-hidden":"true"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.16em] text-[#B9380B]",children:"How this is calculated"}),e.jsxs("p",{className:"mt-1.5 text-[11px] leading-relaxed text-zinc-600",children:["Each group uses the shared after-cost formula: (gross earnings + saved tips − fuel cost − total miles × $",o.rate.toFixed(2)," operating cost per mile − saved tolls − saved other fees) ÷ total hours. When those optional fields are present on a saved record, they are included. Tool 2’s form currently saves tips, tolls, and other fees as $0 because it does not collect them. Start-time windows use ",rt.Overnight,", ",rt.Morning,", ",rt.Afternoon,", or ",rt.Evening,"."]})]})]}),e.jsx("p",{className:"mt-4 text-[11px] font-semibold text-zinc-500",children:"Informational only, not tax or financial advice."})]})]})}const Pr=.3,Ur=5e3,Qt=240,Kt=1e6,Zt=1e7,Jt=1e5,Xt=1e5,es="Enter miles, fuel paid, or both. At least one of these two fields must be greater than zero.",Ss="https://www.buildy.ai",Es="9xrrufffexrbbkhc2dshz",Or=["entryDate","miles","fuelCost","gallons","pricePerGallon","notes"];function Ye(t){return!!(t&&typeof t=="object"&&!Array.isArray(t))}const Gr="rsg:gas-mileage-log:interest:v1",Yr=120,qr=254,Hr=120;function Vr(){if(typeof window>"u")return null;try{const t=window.sessionStorage.getItem(Gr);if(!t)return null;const s=JSON.parse(t);if(!Ye(s)||s.submitted!==!0||typeof s.name!="string"||typeof s.email!="string"||typeof s.cityArea!="string")return null;const r={name:s.name.trim().slice(0,Yr),email:s.email.trim().slice(0,qr),cityArea:s.cityArea.trim().slice(0,Hr)};return r.name&&r.email&&r.cityArea?r:null}catch{return null}}function Oe(){const t=new Date;return`${t.getFullYear()}
12-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`}function Wr(t){const s=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t.trim());if(!s)return!1;const r=new Date(Date.UTC(Number(s[1]),Number(s[2])-1,Number(s[3])));return r.getUTCFullYear()===Number(s[1])&&r.getUTCMonth()===Number(s[2])-1&&r.getUTCDate()===Number(s[3])}function Ee(t){if(t==null||String(t).trim()==="")return null;const s=typeof t=="number"?t:Number(t);return Number.isFinite(s)?s:null}function Se(t){return`${t<0?"-":""}$${Math.abs(t).toFixed(2)}`}function bt(t){return`${t.toFixed(1)} mi`}function Qr(t){const s=String(t||"").trim(),r=/^(\d{4})-(\d{2})-(\d{2})$/.exec(s);if(!r)return"Date not recorded";const a=new Date(Number(r[1]),Number(r[2])-1,Number(r[3]));return a.getFullYear()!==Number(r[1])||a.getMonth()!==Number(r[2])-1||a.getDate()!==Number(r[3])?"Date not recorded":new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric"}).format(a)}function Kr(t){const s=Number(t==null?void 0:t.operating_cost_per_mile);return Number.isFinite(s)&&s>=0?s:Pr}function Zr(t){return[...t].sort((s,r)=>String(r.entry_date||"").localeCompare(String(s.entry_date||""))||String(r.created_at||"").localeCompare(String(s.created_at||"")))}function ts(t,s){return t.reduce((r,a)=>{const n=Ee(a.miles),i=Ee(a.fuel_cost);return n!==null&&n>=0&&(r.miles+=n,r.reserve+=n*s),i!==null&&i>=0&&(r.fuel+=i),r.combined=r.fuel+r.reserve,r},{miles:0,fuel:0,reserve:0,combined:0})}function Jr(){try{if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return`gml-${crypto.randomUUID().replace(/-/g,"").slice(0,24)}`}catch{}return`gml-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function Xr(t,s){return JSON.stringify([t,...s])}function ss(t){return typeof t=="string"?t.trim().replace(/^Bearer\s+/i,""):""}async function Cs(){var t,s;try{const r=ss(await((s=(t=Ls.auth).getToken)==null?void 0:s.call(t)));if(r)return r}catch{}try{return ss(typeof localStorage>"u"?"":localStorage.getItem("sb_token"))}catch{return""}}function ea(){const s="https://www.buildy.ai/api".replace(/\/api\/?$/,"").replace(/\/$/,"")||Ss,r="9xrrufffexrbbkhc2dshz".trim()||Es;return`${s}/api/apps/${r}/functions/save-driver-gas-mileage`}function ta(){const s="https://www.buildy.ai/api".replace(/\/api\/?$/,"").replace(/\/$/,"")||Ss,r="9xrrufffexrbbkhc2dshz".trim()||Es;return`${s}/api/apps/${r}/functions/get-driver-gas-mileage`}function vt(t,s){const r=Ye(t)?t.error??t.message:t instanceof Error?t.message:null;if(typeof r!="string")return s;const a=r.replace(/[\u0000-\u001f\u007f]/g," ").replace(/\s+/g," ").trim().slice(0,240);return a&&!/(?:bearer\s+|access[_-]?token|refresh[_-]?token|authorization\s*:|password|secret)/i.test(a)?a:s}async function sa(t){const s=await Cs();if(!s)throw new Error("Your account credential is unavailable. Refresh the page and try again.");let r;try{r=await fetch(ea(),{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${s}`},body:JSON.stringify(t)})}catch{throw new Error("The private save service could not be reached. Your values are still here. Try again.")}let a;try{a=await r.json()}catch{throw new Error("The private save service returned an invalid response. Your values are still here. Try again.")}const n=Ye(a)?a.record:null;if(!r.ok||!Ye(a)||a.success!==!0||a.acknowledged!==!0||!Ye(n)||typeof n.id!="string")throw new Error(vt(a,"We could not save this entry yet. Your values are still here. Try again."));return n}function at({label:t,icon:s,optional:r=!1,className:a="",...n}){const i=!!n.required;return e.jsxs("label",{className:"block",children:[e.jsxs("span",{className:"mb-1.5 flex items-center gap-1.5 text-[10px] font-black uppercase tracking-[0.12em] text-zinc-700",children:[s&&e.jsx(s,{className:"h-3.5 w-3.5 text-[#0F8B88]","aria-hidden":"true"}),t,i&&e.jsx("span",{className:"font-semibold normal-case tracking-normal text-[#B9380B]",children:"(required)"}),r&&e.jsx("span",{className:"font-semibold normal-case tracking-normal text-zinc-500",children:"(optional)"})]}),e.jsx("input",{...n,className:`h-12 w-full rounded-[12px] border border-zinc-200 bg-white px-3 text-[16px] font-semibold text-zinc-900 outline-none transition placeholder:text-zinc-400 focus:border-[#F45815] focus:ring-2 focus:ring-[#F45815]/20 ${a}`})]})}function me({label:t,value:s,accent:r=!1}){return e.jsxs("div",{className:`rounded-[14px] border p-3.5 ${r?"border-[#B9E4E1] bg-[#F2FBFA]":"border-zinc-200 bg-white"}`,children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.13em] text-zinc-500",children:t}),e.jsx("p",{className:`mt-1.5 font-mono text-[17px] font-black ${r?"text-[#0F7774]":"text-zinc-950"}`,children:s})]})}function rs({loading:t,error:s,onRetry:r}){return t?e.jsxs("div",{className:"mt-5 flex items-start gap-3 rounded-[16px] border border-[#B9E4E1] bg-[#F2FBFA] p-5",role:"status","aria-live":"polite","aria-busy":"true",children:[e.jsx(X,{className:"mt-0.5 h-5 w-5 animate-spin text-[#0F7774]"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[14px] font-black text-zinc-950",children:"Reading your saved entries"}),e.jsx("p",{className:"mt-1 text-[11px] leading-relaxed text-zinc-600",children:"Totals and history will appear after your private account records are ready."})]})]}
12):s?e.jsxs("div",{className:"mt-5 flex flex-wrap items-start justify-between gap-3 rounded-[16px] border border-amber-200 bg-amber-50 p-5",role:"alert",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(P,{className:"mt-0.5 h-5 w-5 shrink-0 text-amber-800"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[14px] font-black text-amber-950",children:"Your saved history is unavailable"}),e.jsx("p",{className:"mt-1 text-[11px] leading-relaxed text-amber-950",children:s})]})]}),e.jsxs("button",{type:"button",onClick:r,className:"inline-flex min-h-[38px] items-center gap-1.5 rounded-full border border-amber-300 bg-white px-3 py-1.5 text-[11px] font-black text-amber-950 hover:bg-amber-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-500 focus-visible:ring-offset-2",children:[e.jsx(ue,{className:"h-3.5 w-3.5"})," Try again"]})]}):null}function ra({entry:t,index:s,rate:r,reduceMotion:a}){var o;const n=Ee(t.miles),i=Ee(t.fuel_cost),d=Ee(t.gallons),c=Ee(t.price_per_gallon),m=n!==null&&n>=0?n*r:null;return e.jsxs(be.article,{...a?{}:{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{delay:Math.min(s*.04,.2)}},className:"rounded-[16px] border border-zinc-200 bg-white p-4 transition hover:border-[#0F8B88]/30 hover:shadow-[0_10px_24px_rgba(15,139,136,0.07)]",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full bg-zinc-950 px-2.5 py-1 text-[11px] font-bold text-white",children:[e.jsx(ye,{className:"h-3 w-3","aria-hidden":"true"}),Qr(t.entry_date)]}),e.jsxs("p",{className:"mt-2 text-[11px] font-semibold text-zinc-600",children:[n===null?"Not recorded":bt(n)," · ",i===null?"Not recorded":Se(i)]})]}),e.jsxs("div",{className:"rounded-[12px] bg-[#F2FBFA] px-3 py-2 text-right text-[#0F7774]",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.12em]",children:"Vehicle reserve"}),e.jsx("p",{className:"mt-0.5 font-mono text-[17px] font-black",children:m===null?"Not calculated":Se(m)})]})]}),e.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2 sm:grid-cols-4",children:[e.jsx(me,{label:"Miles",value:n===null?"Not recorded":bt(n)}),e.jsx(me,{label:"Fuel",value:i===null?"Not recorded":Se(i)}),e.jsx(me,{label:"Gallons",value:d===null?"Not recorded":`${d.toFixed(2)} gal`}),e.jsx(me,{label:"Price / gallon",value:c===null?"Not recorded":`${Se(c)}/gal`})]}),e.jsx("p",{className:"mt-3 border-t border-zinc-100 pt-3 text-[11px] leading-relaxed text-zinc-600",children:(o=t.notes)!=null&&o.trim()?`Note: ${t.notes.trim()}`:"No note added for this entry."})]},t.id||s)}function aa({userId:t,costSettings:s,onLoadedEntryCountChange:r}){const a=Pe(),n=Kr(s),[i,d]=l.useState([]),[c,m]=l.useState(!0),[o,k]=l.useState(null),[N,p]=l.useState(!1),[u,j]=l.useState(Oe()),[w,z]=l.useState(""),[f,C]=l.useState(""),[h,$]=l.useState(""),[_,g]=l.useState(""),[v,F]=l.useState(""),[L,S]=l.useState(!1),[Q,M]=l.useState(null),[H,T]=l.useState(null),[B,K]=l.useState(null),[R,O]=l.useState(null),se=vs("gas-mileage",t),V=l.useRef(!1),le=l.useRef(null),I=l.useRef(0),re=l.useRef({entryDate:u,miles:w,fuelCost:f,gallons:h,pricePerGallon:_,notes:v}),U=l.useRef(null),W=l.useRef(0);re.current={entryDate:u,miles:w,fuelCost:f,gallons:h,pricePerGallon:_,notes:v},l.useEffect(()=>{if(!t||le.current===t||(le.current!==null&&le.current!==t&&(I.current+=1,V.current=!1,U.current=null,j(Oe()),z(""),C(""),$(""),g(""),F("")),le.current=t,V.current))return;const y=Fs(se,Or);y&&(j(y.entryDate),z(y.miles),C(y.fuelCost),$(y.gallons),g(y.pricePerGallon),F(y.notes))},[se,t]),l.useEffect(()=>{if(!t||le.current!==t)return;const E=re.current;if(!(E.entryDate!==Oe()||[E.miles,E.fuelCost,E.gallons,E.pricePerGallon,E.notes].some(A=>A.trim()!=="")))return;const Y=I.current,ce=window.setTimeout(()=>{I.current===Y&&ut(se,E)},250);return()=>window.clearTimeout(ce)},[se,u,f,h,w,v,_,t]),l.useEffect(()=>{const E=()=>{const y=re.current,Y=y.entryDate!==Oe()||[y.miles,y.fuelCost,y.gallons,y.pricePerGallon,y.notes].some(ce=>ce.trim()!=="");V.current&&t&&le.current===t&&Y&&ut(se,y)};return window.addEventListener("pagehide",E),()=>{window.removeEventListener("pagehide",E),E()}},[se,t]),l.useEffect(()=>
12{O(Vr())},[]);const de=l.useCallback(async()=>{const E=await Cs();if(!E)throw new Error("Your account credential is unavailable. Refresh the page and try again.");let y;try{y=await fetch(ta(),{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${E}`},body:JSON.stringify({expected_account_id:t})})}catch{throw new Error("The private history service could not be reached. Try again.")}let Y;try{Y=await y.json()}catch{throw new Error("The private history service returned an invalid response. Try again.")}if(!y.ok||!Ye(Y)||Y.success!==!0||!Array.isArray(Y.entries)||typeof Y.capped!="boolean")throw new Error(vt(Y,"We could not read your private fuel and mileage history. Try again."));const ce=Y.entries.map(A=>{if(!Ye(A)||typeof A.id!="string"||typeof A.user_id!="string"||A.user_id!==t||typeof A.entry_date!="string")throw new Error("History response contained an invalid entry.");return{id:A.id,user_id:A.user_id,request_key:typeof A.request_key=="string"?A.request_key:null,entry_date:A.entry_date,miles:Ee(A.miles),fuel_cost:Ee(A.fuel_cost),gallons:Ee(A.gallons),price_per_gallon:Ee(A.price_per_gallon),notes:typeof A.notes=="string"?A.notes:null,created_at:typeof A.created_at=="string"?A.created_at:null}});return{rows:Zr(ce),capped:Y.capped}},[t]),ae=l.useCallback(async()=>{const E=++W.current;m(!0),k(null);try{const y=await de();return E!==W.current?!1:(d(y.rows),p(y.capped),r==null||r(y.rows.length),!0)}catch(y){return console.error("Failed to load driver gas and mileage entries:",y),E===W.current&&(d([]),p(!1),k("We could not read your private fuel and mileage history. Totals are hidden until it loads successfully.")),!1}finally{E===W.current&&m(!1)}},[de,r]);l.useEffect(()=>{ae()},[ae]);const G=l.useMemo(()=>ts(i,n),[i,n]),ne=new Date().getFullYear(),ie=l.useMemo(()=>{const E=i.filter(y=>String(y.entry_date||"")>=`${ne}-10-01`&&String(y.entry_date||"")<=`${ne}-12-31`);return{count:E.length,totals:ts(E,n)}},[ne,i,n]),Ce=[u,w,f,h,_,v],he=!c&&!o,ve=()=>{if(!Wr(u))return"Choose a valid date for this entry.";if(u>Oe())return"Entry date cannot be in the future. Choose today or an earlier date.";const E=[["Miles",w,Kt],["Fuel paid",f,Zt],["Gallons",h,Jt],["Price per gallon",_,Xt]];for(const[y,Y,ce]of E){if(Y.trim()==="")continue;const A=Number(Y);if(!Number.isFinite(A)||A<0||A>ce)return`${y} must be a finite number from 0 to its allowed limit.`}return(w.trim()===""?0:Number(w))===0&&(f.trim()===""?0:Number(f))===0?es:v.length>Qt?"Note must be 240 characters or fewer.":null},Z=E=>y=>{U.current=null,V.current=!0,E(y.target.value),M(null),T(null),K(null)},gt=async E=>{var x;if(E.preventDefault(),L)return;const y=ve();if(y){M(y),T(null);return}S(!0),M(null),T(null),K(null);const Y=Xr(t,Ce),ce=U.current,A=(ce==null?void 0:ce.fingerprint)===Y?ce.requestKey:Jr();U.current={fingerprint:Y,requestKey:A};const Fe=b=>b.trim()===""?null:Number(b);try{await sa({expected_account_id:t,request_key:A,entry_date:u,miles:Fe(w),fuel_cost:Fe(f),gallons:Fe(h),price_per_gallon:Fe(_),notes:v.trim()||null});const b=await ae(),D=((x=U.current)==null?void 0:x.fingerprint)===Y&&U.current.requestKey===A;U.current=null,D&&(I.current+=1,V.current=!1,ks(se)),T("Entry saved to your private history."),b||K("Your entry was saved, but history is temporarily unavailable. Try again above to confirm the complete record."),D&&(j(Oe()),z(""),C(""),$(""),g(""),F(""))}catch(b){console.error("Failed to save driver gas and mileage entry:",b),M(vt(b,"We could not save this entry yet. Your values are still here. Try again."))}finally{S(!1)}},Ue=()=>void ae(),jt=a?{}:{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.45,ease:[.22,1,.36,1]}};return e.jsxs(be.section,{...jt,id:"gas-mileage-log","aria-labelledby":"gas-mileage-log-title",className:"overflow-hidden rounded-[24px] border border-zinc-200 bg-white shadow-[0_16px_44px_rgba(24,24,27,0.07)]",children:[e.jsxs("div",{className:"border-b border-zinc-100 px-5 py-5 sm:px-7 sm:py-6",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-[14px] bg-[#0F8B88] text-white shadow-[0_8px_20px_rgba(15,139,136,0.2)]",children:e.jsx(fe,{className:"h-5 w-5","aria-hidden":"true"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-black uppercase tracking-[0.18em] text-[#0F7774]",children:"Free tool 03 · Available now"}),e.jsx("h3",{id:"gas-mileage-log-title",className:"mt-1 font-['Poppins',sans-serif] text-[24px] font-black leading-none tracking-[-0.04em] text-zinc-950 sm:text-[28px]",children:"Gas & Mileage Log"}),e.jsx("p",{className:"mt-2 max-w-[58ch] text-[13px] leading-relaxed text-zinc-600",children:"Keep fuel payments and miles in one private record, then see the running vehicle-cost reserve attached to the miles you log."})]})]}),e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full border border-[#B9E4E1] bg-[#F2FBFA] px-3 py-1.5 text-[10px] font-black uppercase tracking-[0.12em] text-[#0F7774]",children:[e.jsx(we,{className:"h-3.5 w-3.5","aria-hidden":"true"})," Account-owned history"]})]}),e.jsxs("div",{className:"mt-5 flex flex-wrap items-center gap-x-4 gap-y-2 text-[11px] font-semibold text-zinc-600",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(Ze,{className:"h-3.5 w-3.5 text-[#0F8B88]"})," Separate from fuel on a shift"]}),e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(oe,{className:"h-3.5 w-3.5 text-[#F45815]"}),c?" Reading saved entries":o?" History unavailable":N?` ${i.length.toLocaleStr
12ing()} newest loaded`:` ${i.length} saved entr${i.length===1?"y":"ies"}`]})]})]}),e.jsxs("form",{id:"gas-mileage-entry-form",onSubmit:gt,noValidate:!0,className:"border-b border-zinc-100 bg-[#FFFCF9] px-5 py-5 sm:px-7 sm:py-7",children:[R&&e.jsxs("aside",{"aria-labelledby":"gas-mileage-interest-title",className:"mb-6 rounded-[16px] border border-[#B9E4E1] bg-[#F2FBFA] p-4 shadow-[0_8px_20px_rgba(15,139,136,0.06)] sm:p-5",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-[11px] bg-white text-[#0F7774]",children:e.jsx(te,{className:"h-4 w-4","aria-hidden":"true"})}),e.jsxs("div",{children:[e.jsx("p",{id:"gas-mileage-interest-title",className:"text-[10px] font-black uppercase tracking-[0.15em] text-[#0F7774]",children:"Details carried from your interest form"}),e.jsx("p",{className:"mt-1.5 text-[11px] leading-relaxed text-zinc-700",children:"These details came from the optional interest form. Your private log stays attached to this signed-in account. The fields below are only for the actual date, miles, fuel, gallons, price per gallon, and note."})]})]}),e.jsxs("dl",{className:"mt-4 grid gap-2 sm:grid-cols-3",children:[e.jsxs("div",{className:"rounded-[12px] border border-white/80 bg-white/70 px-3 py-2.5",children:[e.jsxs("dt",{className:"flex items-center gap-1.5 text-[10px] font-black uppercase tracking-[0.12em] text-zinc-500",children:[e.jsx(Rs,{className:"h-3.5 w-3.5 text-[#0F8B88]","aria-hidden":"true"}),"Name"]}),e.jsx("dd",{className:"mt-1 break-words text-[12px] font-bold text-zinc-950",children:R.name})]}),e.jsxs("div",{className:"rounded-[12px] border border-white/80 bg-white/70 px-3 py-2.5",children:[e.jsxs("dt",{className:"flex items-center gap-1.5 text-[10px] font-black uppercase tracking-[0.12em] text-zinc-500",children:[e.jsx(Ms,{className:"h-3.5 w-3.5 text-[#0F8B88]","aria-hidden":"true"}),"Email"]}),e.jsx("dd",{className:"mt-1 break-words text-[12px] font-bold text-zinc-950",children:R.email})]}),e.jsxs("div",{className:"rounded-[12px] border border-white/80 bg-white/70 px-3 py-2.5",children:[e.jsxs("dt",{className:"flex items-center gap-1.5 text-[10px] font-black uppercase tracking-[0.12em] text-zinc-500",children:[e.jsx(it,{className:"h-3.5 w-3.5 text-[#0F8B88]","aria-hidden":"true"}),"City or area"]}),e.jsx("dd",{className:"mt-1 break-words text-[12px] font-bold text-zinc-950",children:R.cityArea})]})]}),e.jsx("p",{className:"mt-3 text-[10px] font-semibold leading-relaxed text-zinc-500",children:"These contact details are read-only here. They are not saved with mileage entries."})]}),e.jsxs("div",{className:"flex items-end justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.18em] text-[#B9380B]",children:"Add a real entry"}),e.jsx("h4",{className:"mt-1 text-[19px] font-black tracking-tight text-zinc-950",children:"Record what you can verify."})]}),e.jsx("span",{className:"hidden rounded-full border border-[#B9E4E1] bg-white px-3 py-1.5 text-[10px] font-bold text-[#0F7774] sm:inline-flex",children:"No sample data"})]}),e.jsx("p",{id:"gas-mileage-required-group",className:"mt-5 rounded-[12px] border border-[#B9E4E1] bg-[#F2FBFA] px-3.5 py-3 text-[11px] font-semibold leading-relaxed text-[#0F7774]",children:es}),e.jsxs("div",{className:"mt-4 grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:[e.jsx(at,{label:"Date",icon:ye,type:"date",value:u,max:Oe(),onChange:Z(j),required:!0}),e.jsx(at,{label:"Miles",icon:it,type:"number",inputMode:"decimal",min:"0",max:String(Kt),step:"0.1",value:w,onChange:Z(z),"aria-describedby":"gas-mileage-required-group",placeholder:"Leave blank if not recorded"}),e.jsx(at,{label:"Fuel paid",icon:fe,type:"number",inputMode:"decimal",min:"0",max:String(Zt),step:"0.01",value:f,onChange:Z(C),"aria-describedby":"gas-mileage-required-group",placeholder:"Leave blank if not recorded"}),e.jsx(at,{label:"Gallons",icon:fe,optional:!0,type:"number",inputMode:"decimal",min:"0",max:String(Jt),step:"0.01",value:h,onChange:Z($),placeholder:"Optional"}),e.jsx(at,{label:"Price per gallon",icon:fe,optional:!0,type:"number",inputMode:"decimal",min:"0",max:String(Xt),step:"0.001",value:_,onCh
12ange:Z(g),placeholder:"Optional"}),e.jsxs("label",{className:"block sm:col-span-2 lg:col-span-1",children:[e.jsxs("span",{className:"mb-1.5 flex items-center gap-1.5 text-[10px] font-black uppercase tracking-[0.12em] text-zinc-700",children:[e.jsx(Ze,{className:"h-3.5 w-3.5 text-[#0F8B88]"})," Note ",e.jsx("span",{className:"font-semibold normal-case tracking-normal text-zinc-500",children:"(optional)"})]}),e.jsx("input",{type:"text",maxLength:Qt,value:v,onChange:Z(F),placeholder:"Receipt, tank, or odometer note",className:"h-12 w-full rounded-[12px] border border-zinc-200 bg-white px-3 text-[16px] font-semibold text-zinc-900 outline-none transition placeholder:text-zinc-400 focus:border-[#F45815] focus:ring-2 focus:ring-[#F45815]/20"})]})]}),Q&&e.jsxs("div",{role:"alert",className:"mt-4 flex items-start gap-2 rounded-[12px] border border-red-200 bg-red-50 px-3.5 py-3 text-[12px] font-semibold leading-relaxed text-red-800",children:[e.jsx(P,{className:"mt-0.5 h-4 w-4 shrink-0"}),Q]}),H&&e.jsxs("div",{role:"status",className:"mt-4 flex items-start gap-2 rounded-[12px] border border-emerald-200 bg-emerald-50 px-3.5 py-3 text-[12px] font-semibold text-emerald-800",children:[e.jsx(te,{className:"mt-0.5 h-4 w-4 shrink-0"}),H]}),B&&e.jsxs("div",{role:"status",className:"mt-4 flex items-start gap-2 rounded-[12px] border border-amber-200 bg-amber-50 px-3.5 py-3 text-[12px] font-semibold leading-relaxed text-amber-900",children:[e.jsx(P,{className:"mt-0.5 h-4 w-4 shrink-0"}),B]}),e.jsxs("div",{className:"mt-5 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("p",{className:"text-[11px] leading-relaxed text-zinc-500",children:["The reserve uses a $",n.toFixed(2),"/mi rate and excludes fuel. When no saved setting is available, the suite uses its $0.30/mi standard."]}),e.jsx("button",{type:"submit",disabled:L,className:"inline-flex min-h-[50px] w-full items-center justify-center gap-2 rounded-[14px] bg-[#F45815] px-6 text-[14px] font-black text-white shadow-[0_10px_22px_rgba(244,88,21,0.22)] transition hover:-translate-y-0.5 hover:bg-[#E94E0E] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#F45815] focus-visible:ring-offset-2 disabled:cursor-wait disabled:opacity-60 sm:w-auto",children:L?e.jsxs(e.Fragment,{children:[e.jsx(X,{className:"h-4 w-4 animate-spin"})," Saving entry"]}):e.jsxs(e.Fragment,{children:[e.jsx(_t,{className:"h-4 w-4"})," Save private entry"]})})]}),e.jsx("p",{className:"mt-4 text-[11px] font-semibold text-zinc-500",children:"Informational only, not tax or financial advice."})]}),e.jsxs("div",{className:"px-5 py-5 sm:px-7 sm:py-7",children:[e.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.18em] text-[#0F7774]",children:"Running totals"}),e.jsx("h4",{className:"mt-1 text-[20px] font-black tracking-tight text-zinc-950",children:"Your logged cost picture"})]}),e.jsx("span",{className:"rounded-full border border-zinc-200 bg-zinc-50 px-3 py-1.5 text-[10px] font-bold text-zinc-600",children:c?"Reading":
12o?"Unavailable":N?`${i.length.toLocaleString()} newest`:`${i.length} saved`})]}),e.jsx(rs,{loading:c,error:o,onRetry:Ue}),he&&e.jsxs(e.Fragment,{children:[N&&e.jsxs("div",{className:"mt-4 flex items-start gap-3 rounded-[14px] border border-amber-200 bg-amber-50 p-4",role:"status",children:[e.jsx(P,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-800"}),e.jsxs("p",{className:"text-[11px] leading-relaxed text-amber-950",children:["Showing the newest ",Ur.toLocaleString()," entries. Older records are not included in the totals shown here."]})]}),e.jsxs("div",{className:"mt-5 grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-5",children:[e.jsx(me,{label:"Miles logged",value:bt(G.miles)}),e.jsx(me,{label:"Fuel paid",value:Se(G.fuel)}),e.jsx(me,{label:"Vehicle reserve",value:Se(G.reserve),accent:!0}),e.jsx(me,{label:"Tracked cost",value:Se(G.combined),accent:!0}),e.jsx(me,{label:N?"Entries loaded":"Entry count",value:String(i.length)})]}),e.jsxs("div",{className:"mt-4 flex items-start gap-3 rounded-[14px] border border-[#B9E4E1] bg-[#F2FBFA] p-4",children:[e.jsx(Ze,{className:"mt-0.5 h-4 w-4 shrink-0 text-[#0F7774]","aria-hidden":"true"}),e.jsx("p",{className:"text-[11px] leading-relaxed text-zinc-700",children:"Fuel in this log is separate from fuel already entered on an individual Real Pay Meter shift. Keep each real cost in one place so you can avoid double counting."})]}),e.jsxs("section",{className:"mt-7 border-t border-zinc-100 pt-7","aria-labelledby":"gas-mileage-q4-title",children:[e.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.18em] text-[#B9380B]",children:"Organize before tax season"}),e.jsxs("h4",{id:"gas-mileage-q4-title",className:"mt-1 text-[20px] font-black tracking-tight text-zinc-950",children:["Q4 summary, ",ne]})]}),e.jsx("span",{className:"rounded-full border border-[#F8C9B9] bg-[#FFF8F3] px-3 py-1.5 text-[10px] font-bold text-[#B9380B]",children:"Starting point only"})]}),e.jsxs("div",{className:"mt-5 grid grid-cols-2 gap-2 sm:grid-cols-4",children:[e.jsx(me,{label:"Q4 miles",value:bt(ie.totals.miles)}),e.jsx(me,{label:"Q4 fuel",value:Se(ie.totals.fuel)}),e.jsx(me,{label:"Q4 reserve",value:Se(ie.totals.reserve),accent:!0}),e.jsx(me,{label:"Q4 tracked cost",value:Se(ie.totals.combined),accent:!0})]}),ie.count===0?e.jsxs("div",{className:"mt-4 flex items-start gap-3 rounded-[14px] border border-dashed border-[#F8C9B9] bg-[#FFF8F3] p-4",children:[e.jsx(ye,{className:"mt-0.5 h-4 w-4 shrink-0 text-[#B9380B]","aria-hidden":"true"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[13px] font-black text-zinc-950",children:"No Q4 entries yet."}),e.jsx("p",{className:"mt-1 text-[11px] leading-relaxed text-zinc-700",children:"Entries dated October 1 through December 31 will appear here after you save them. This is an organized tax-prep starting point, not a tax calculation or advice."})]})]}):e.jsxs("p",{className:"mt-4 rounded-[14px] border border-zinc-200 bg-zinc-50 p-4 text-[11px] leading-relaxed text-zinc-700",children:["Based on ",ie.count," real Q4 entr",ie.count===1?"y":"ies"," in this account. Review the underlying records with your tax professional before using them for a filing."]})]})]}),e.jsxs("section",{className:"mt-7 border-t border-zinc-100 pt-7","aria-labelledby":"gas-mileage-history-title",children:[e.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.18em] text-[#0F7774]",children:"Your saved history"}),e.jsxs("h4",{id:"gas-mileage-history-title",className:"mt-1 flex items-center gap-2 text-[20px] font-black tracking-tight text-zinc-950",children:[e.jsx(oe,{className:"h-5 w-5 text-[#0F8B88]"})," Fuel and mileage records"]})]}),e.jsxs("a",{href:"#gas-mileage-entry-form",className:"inline-flex min-h-[40px] items-center gap-1.5 rounded-full border border-[#F45815] bg-white px-3.5 py-1.5 text-[11px] font-black text-[#B9380B] transition hover:bg-[#FFF1E8] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#F45815] focus-visible:ring-offset-2",children:["Add entry ",e.jsx(q,{className:"h-3.5 w-3.5"})]})]}),e.jsx(rs,{loading:c,error:o,onRetry:Ue}),he&&(i.length===0?e.jsxs("div",{className:"mt-5 rounded-[16px] border border-dashed border-zinc-300 bg-[#FFFCF9] px-5 py-9 text-center",children:[e.jsx("span",{className:"mx-auto flex h-11 w-11 items-center justify-center rounded-full bg-[#F2FBFA] text-[#0F7774]",children:e.jsx(oe,{className:"h-5 w-5"})}),e.jsx("p",{className:"mt-3 text-[15px] font-black text-zinc-950",children:"No fuel or mileage entr
12ies yet."}),e.jsx("p",{className:"mx-auto mt-1.5 max-w-[44ch] text-[12px] leading-relaxed text-zinc-600",children:"There is no sample data here. Save a real fuel-only, mileage-only, or combined entry above to start your private record."})]}):e.jsx("div",{className:"mt-5 space-y-3",children:i.map((E,y)=>e.jsx(ra,{entry:E,index:y,rate:n,reduceMotion:a},E.id||`${E.entry_date}-${y}`))})),he&&e.jsxs("p",{className:"mt-5 flex items-start gap-2 text-[11px] leading-relaxed text-zinc-500",children:[e.jsx(we,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-[#0F8B88]","aria-hidden":"true"}),"Only your authenticated account is used to load these records. ",N?"Totals and cards cover the newest loaded records only.":"Optional details remain clearly marked when they were not recorded."]})]}),e.jsxs("a",{href:"#real-pay-meter",className:"mt-7 inline-flex min-h-[44px] items-center gap-2 rounded-[12px] bg-[#F45815] px-4 py-2.5 text-[12px] font-black text-white transition hover:bg-[#E94E0E] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#F45815] focus-visible:ring-offset-2",children:["Back to Real Pay Meter ",e.jsx(q,{className:"h-4 w-4","aria-hidden":"true"})]}),e.jsx("p",{className:"mt-4 text-[11px] font-semibold text-zinc-500",children:"Informational only, not tax or financial advice."})]})]})}const na=.3,as=200,Nt=5e3,ia=["record_type","source","date","start_time","end_time","zone","total_hours","gross_earnings","tips","total_miles","fuel_cost","tolls","other_fees","vehicle_cost_reserve","gallons","price_per_gallon","notes"];function oa(t){const s=Number(t);return Number.isFinite(s)&&s>=0?s:na}function la(t){if(t==null)return"";const s=String(t);return/[",\r\n]/.test(s)?`"${s.replace(/"/g,'""')}"`:s}function ns(t,s){if(t==null||String(t).trim()==="")return"";const r=Number(t);return Number.isFinite(r)?(r*s).toFixed(2):""}function ca(t,s,r){return`${[[...ia],...t.map(n=>["shift","Real Pay Meter / Best-Shift Finder",n.shift_date,n.start_time,n.end_time,n.zone,n.total_hours,n.gross_earnings,n.tips,n.total_miles,n.fuel_cost,n.tolls,n.other_fees,ns(n.total_miles,r),"","",n.notes]),...s.map(n=>["gas_mileage","Gas & Mileage Log",n.entry_date,"","","","","","",n.miles,n.fuel_cost,"","",ns(n.miles,r),n.gallons,n.price_per_gallon,n.notes])].map(n=>n.map(la).join(",")).join(`\r
13`)}\r
14`}function is(t,s,r){return`${t} ${t===1?s:r}`}function da({userId:t,shifts:s,unlocked:r,checkingEntitlement:a,entitlementError:n,operatingCostPerMile:i,onRetryEntitlement:d}){const c=Pe(),m=oa(i),[o,k]=l.useState("idle"),[N,p]=l.useState(null),[u,j]=l.useState(null);l.useEffect(()=>{r||(k("idle"),p(null),j(null))},[r]);const w=async()=>{if(!r||a||o==="exporting")return;k("exporting"),p(null),j(null);let h=null;try{const $=await zt.filter({user_id:t},"-entry_date",Nt);if(!Array.isArray(s)||!Array.isArray($))throw new Error("History response was not a list");const _=s,g=$;if(_.length===0&&g.length===0){k("empty");return}const v=`rsg-driver-profit-history-${new Date().toISOString().slice(0,10)}.csv`,F=ca(_,g,m);if(typeof window>"u"||typeof URL>"u"||typeof URL.createObjectURL!="function")throw new Error("Browser download unavailable");const L=new Blob(["\uFEFF",F],{type:"text/csv;charset=utf-8;"});h=URL.createObjectURL(L);const S=document.createElement("a");S.href=h,S.download=v,S.style.display="none",document.body.appendChild(S),S.click(),S.remove(),window.setTimeout(()=>{h&&URL.revokeObjectURL(h)},1e3),j({shiftCount:_.length,gasCount:g.length,filename:v}),k("success")}catch($){h&&URL.revokeObjectURL(h),console.error("Failed to export Driver Profit Suite history:",$),p("We could not finish because one of your account histories could not be read. No partial CSV was downloaded."),k("error")}},z=c?{}:{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.45,ease:[.22,1,.36,1]}},f=u?[u.shiftCount>=as?`the ${as.toLocaleString()} newest shift records`:null,u.gasCount>=Nt?`the ${Nt.toLocaleString()} newest gas/mileage records`:null].filter(h=>!!h).join(" and "):"",C=o==="success"?"Export again":o==="empty"?"Add a record first":"Download account history CSV";return e.jsxs(be.section,{...z,id:"profit-history-export","aria-labelledby":"profit-history-export-title",className:"mt-14 overflow-hidden rounded-[24px] border border-zinc-200 bg-white shadow-[0_16px_44px_rgba(24,24,27,0.07)] sm:mt-20",children:[e.jsx("div",{className:"border-b border-zinc-800 bg-zinc-950 px-5 py-5 text-white sm:px-7 sm:py-6",children:e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-[14px] bg-[#F45815] text-white shadow-[0_8px_20px_rgba(244,88,21,0.24)]",children:e.jsx(Hs,{className:"h-5 w-5","aria-hidden":"true"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-black uppercase tracking-[0.18em] text-[#FFB15F]",children:"Paid benefit · Founding Unlock"}),e.jsx("h3",{id:"profit-history-export-title",className:"mt-1 font-['Poppins',sans-serif] text-[24px] font-black leading-none tracking-[-0.04em] sm:text-[28px]",children:"Export your account history"}),e.jsx("p",{className:"mt-2 max-w-[60ch] text-[13px] leading-relaxed text-zinc-300",children:"Take your account-owned shift and fuel records with you in one local CSV when you need a broader view."})]})]}),e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full border border-[#2C6F6D] bg-[#123B3B] px-3 py-1.5 text-[10px] font-black uppercase tracking-[0.12em] text-[#B9E4E1]",children:[e.jsx(we,{className:"h-3.5 w-3.5","aria-hidden":"true"})," Private by account"]})]})}),e.jsx("div",{className:"bg-[#FFFCF9] p-5 sm:p-7",children:a?e.jsxs("div",{role:"status","aria-live":"polite","aria-busy":"true",className:"flex items-start gap-3 rounded-[16px] border border-[#B9E4E1] bg-[#F2FBFA] p-5",children:[e.jsx(X,{className:"mt-0.5 h-5 w-5 shrink-0 animate-spin text-[#0F7774]"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[14px] font-black text-zinc-950",children:"Checking your Founding Unlock"}),e.jsx("p",{className:"mt-1 text-[12px] leading-relaxed text-zinc-600",children:"We confirm access before reading either private history. Your three free tools remain available above."})]})]}
14):n?e.jsxs("div",{role:"alert",className:"flex flex-wrap items-start justify-between gap-4 rounded-[16px] border border-amber-200 bg-amber-50 p-5",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(P,{className:"mt-0.5 h-5 w-5 shrink-0 text-amber-700"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[14px] font-black text-amber-950",children:"We could not confirm export access"}),e.jsx("p",{className:"mt-1 text-[12px] leading-relaxed text-amber-900",children:n}),e.jsx("p",{className:"mt-2 text-[11px] font-semibold text-amber-900",children:"Your free tools are still available. No history was read by this card."})]})]}),e.jsxs("button",{type:"button",onClick:d,disabled:!d,className:"inline-flex min-h-[40px] shrink-0 items-center gap-1.5 rounded-full border border-amber-300 bg-white px-3.5 py-2 text-[11px] font-black text-amber-950 transition hover:bg-amber-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-500 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",children:[e.jsx(ue,{className:"h-3.5 w-3.5"})," Try again"]})]}):r?e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full border border-emerald-200 bg-emerald-50 px-3 py-1.5 text-[10px] font-black uppercase tracking-[0.12em] text-emerald-800",children:[e.jsx(te,{className:"h-3.5 w-3.5","aria-hidden":"true"})," Founding Unlock active"]}),e.jsxs("span",{className:"rounded-full border border-[#B9E4E1] bg-[#F2FBFA] px-3 py-1.5 text-[10px] font-bold text-[#0F7774]",children:["$",m.toFixed(2),"/mi reserve rate"]})]}),e.jsx("h4",{className:"mt-4 text-[22px] font-black tracking-tight text-zinc-950",children:"One download, both private histories."}),e.jsxs("p",{className:"mt-2 max-w-[66ch] text-[13px] leading-relaxed text-zinc-600",children:["The CSV includes every shift record and every Gas & Mileage Log record this account can read. Shift fuel stays separate from fuel logged in the mileage record. Vehicle-cost reserve is a labeled estimate based on each record’s miles and your current $",m.toFixed(2),"/mi setting."]})]}),e.jsxs("div",{className:"rounded-[16px] border border-zinc-200 bg-white p-4 sm:max-w-[255px]",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.14em] text-[#0F7774]",children:"Local download"}),e.jsx("p",{className:"mt-1 text-[12px] leading-relaxed text-zinc-600",children:"Both histories are read only after you choose this button. The file stays in this browser and is not uploaded to an outside service."})]})]}),e.jsxs("div",{role:"note",className:"mt-5 flex items-start gap-3 rounded-[14px] border border-amber-200 bg-amber-50 p-4",children:[e.jsx(oe,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-800","aria-hidden":"true"}),e.jsxs("p",{className:"text-[11px] leading-relaxed text-amber-950",children:[e.jsx("span",{className:"font-black",children:"Current export bounds:"})," up to the 200 newest shift records and the 5,000 newest gas/mileage records are included. Older records are not included once an account reaches a limit."]})]}),e.jsxs("div",{className:"mt-5 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("p",{className:"flex items-start gap-2 text-[11px] leading-relaxed text-zinc-500",children:[e.jsx(oe,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-[#0F8B88]","aria-hidden":"true"}),"The export keeps the shift and fuel records as separate rows, with stable labeled columns."]}),e.jsx("button",{type:"button",onClick:w,disabled:o==="exporting"||o==="empty",className:"inline-flex min-h-[50px] w-full items-center justify-center gap-2 rounded-[14px] bg-[#F45815] px-6 text-[13px] font-black text-white shadow-[0_10px_22px_rgba(244,88,21,0.22)] transition hover:-translate-y-0.5 hover:bg-[#E94E0E] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#F45815] focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-60 sm:w-auto",children:o==="exporting"?e.jsxs(e.Fragment,{children:[e.jsx(X,{className:"h-4 w-4 animate-spin"})," Preparing your CSV"]}):o==="empty"?e.jsxs(e.Fragment,{children:[e.jsx(oe,{className:"h-4 w-4"})," ",C]}):o==="success"?e.jsxs(e.Fragment,{children:[e.jsx(Dt,{className:"h-4 w-4"})," ",C]}):e.jsxs(e.Fragment,{children:[e.jsx(Dt,{className:"h-4 w-4"})," ",C]})})]}),o==="error"&&e.jsxs("div",{role:"alert",className:"mt-4 flex flex-wrap items-start justify-between gap-3 rounded-[14px] border border-red-200 bg-red-50 p-4",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(P,{className:"mt-0.5 h-4 w-4 shrink-0 text-red-700"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[12px] font-black text-red-950",children:"Export could not finish"}),e.jsxs("p",{className:"mt-1 text-[11px] leading-relaxed text-red-900",children:[N," Try again when your connection is ready."]})]})]}),e.jsxs("button",{type:"button",onClick:w,className:"inline-flex min-h-[36px] items-center gap-1.5 rounded-full border border-red-300 bg-white px-3 py-1.5 text-[11px] font-black text-red-950 hover:bg-red-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-red-500 focus-visible:ring-offset-2",children:[e.jsx(ue,{className:"h-3.5 w-3.5"})," Try again"]})]}),o==="empty"&&e.jsxs("div",{role:"status",className:"mt-4 flex flex-wrap items-start justify-between gap-3 rounded-[14px] border border-dashed border-[#F8C9B9] bg-[#FFF8F3] p-4",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(oe,{className:"mt-0.5 h-4 w-4 shrink-0 text-[#B9380B]"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[12px] font-black text-zinc-950",children:"There is no history to export yet."}),e.jsx("p",{className:"mt-1 text-[11px] leading-relaxed text-zinc-700",children:"Add a real shift or gas and mileage record first. The download stays disabled until this account has something to export."})]})]}),e.jsxs("button",{type:"button",onClick:w,className:"inline-flex min-h-[36px] items-center gap-1.5 rounded-full border border-[#F45815] bg-white px-3 py-1.5 text-[11px] font-black text-[#B9380B] hover:bg-[#FFF1E8] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#F45815] focus-visible:ring-offset-2",children:[e.jsx(ue,{className:"h-3.5 w-3.5"})," Try again"]})]}),o==="success"&&u&&e.jsxs("div",{role:"status",className:"mt-4 flex items-start gap-2 rounded-[14px] border border-emerald-200 bg-emerald-50 p-4",children:[e.jsx(te,{className:"mt-0.5 h-4 w-4 shrink-0 text-emerald-700"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[12px] font-black text-emerald-950",children:"CSV downloaded to this browser."}),e.jsxs("p",{className:"mt-1 text-[11px] leading-relaxed text-emerald-900",children:[is(u.shiftCount,"shift record","shift records")," and ",is(u.gasCount,"gas/mileage record","gas/mileage records")," were included in ",u.filename,". No records were invented or combined."]}),f&&e.jsxs("p",{className:"mt-2 text-[11px] font-semibold leading-relaxed text-emerald-900",children:["This download reached ",f,"; older records may not be included."]})]})]}),e.jsxs("p",{className:"mt-5 flex items-start gap-2 text-[11px] leading-relaxed text-zinc-500",children:[e.jsx(we,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-[#0F8B88]","aria-hidden":"true"}),"This CSV contains records from this authenticated account. It supports organization help only, and is not tax or financial advice."]})]}):e.jsxs("div",{className:"grid gap-5 lg:grid-cols-[1fr_auto] lg:items-center",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-[14px] bg-[#FFF1E8] text-[#F45815]",children:e.jsx(Ne,{className:"h-5 w-5","aria-hidden":"true"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-black uppercase tracking-[0.16em] text-[#B9380B]",children:"Account history export is a paid benefit"}),e.jsx("h4",{className:"mt-1 text-[21px] font-black tracking-tight text-zinc-950",children:"Keep your account history in one place."}
14),e.jsx("p",{className:"mt-2 max-w-[62ch] text-[13px] leading-relaxed text-zinc-600",children:"The three free tools stay usable with sign-in. The $11 one-time Founding Unlock adds account-owned CSV export within the current account-history read limits, built for your own organization and review."}),e.jsx("p",{className:"mt-3 text-[11px] font-semibold text-zinc-500",children:"No history is fetched until an unlocked account chooses the download."})]})]}),e.jsxs("div",{className:"rounded-[18px] border border-[#F8C9B9] bg-white p-4 lg:min-w-[235px]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.15em] text-[#B9380B]",children:"Founding Unlock"}),e.jsxs("p",{className:"mt-1 text-[22px] font-black text-zinc-950",children:["$11 ",e.jsx("span",{className:"text-[12px] font-bold text-zinc-500",children:"one time"})]})]}),e.jsx(fe,{className:"h-5 w-5 text-[#0F8B88]","aria-hidden":"true"})]}),e.jsxs(et,{to:"/starter-kit",className:"mt-4 inline-flex min-h-[44px] w-full items-center justify-center gap-2 rounded-[12px] bg-[#F45815] px-4 py-2.5 text-[12px] font-black text-white transition hover:-translate-y-0.5 hover:bg-[#E94E0E] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#F45815] focus-visible:ring-offset-2",children:["Get the $11 Founding Unlock ",e.jsx(q,{className:"h-4 w-4"})]})]})]})})]})}const xa=.3,xt=5e3,mt=5e3,ma={Overnight:"12:00–5:59 AM",Morning:"6:00–11:59 AM",Afternoon:"12:00–4:59 PM",Evening:"5:00–11:59 PM"};function nt(t){if(t==null||String(t).trim()==="")return null;const s=typeof t=="number"?t:Number(t);return Number.isFinite(s)?s:null}function Ve(t,s){return t.reduce((r,a)=>{const n=a&&typeof a=="object"?nt(a[s]):null;return r+(n??0)},0)}function ua(t){const s=Number(t);return Number.isFinite(s)&&s>=0?s:xa}function Ge(t){const s=Number.isFinite(t)?t:0;return`${s<0?"-":""}$${Math.abs(s).toFixed(2)}`}function Ft(t,s){return`${t} ${s}${t===1?"":"s"}`}function ha(t,s){const r=nt(t.total_hours),a=nt(t.gross_earnings),n=nt(t.total_miles),i=nt(t.fuel_cost);return r===null||r<=0||a===null||n===null||i===null?null:{hours:r,net:a-i-n*s}}function pa(t){const s=String(t||"").trim().replace(/\s+/g," ");return s?{key:s.toLowerCase(),label:s}:null}function fa(t){const s=/^(\d{1,2}):(\d{2})(?::\d{2})?$/.exec(String(t||"").trim());if(!s)return null;const r=Number(s[1]),a=Number(s[2]);return r<0||r>23||a<0||a>59?null:r<6?"Overnight":r<12?"Morning":r<17?"Afternoon":"Evening"}function os(t,s,r,a){const n=t.get(s)||{label:r,count:0,hours:0,net:0};n.count+=1,n.hours+=a.hours,n.net+=a.net,t.set(s,n)}function ls(t,s){const r=[...t.values()].sort((a,n)=>{const i=a.hours>0?a.net/a.hours:Number.NEGATIVE_INFINITY;return(n.hours>0?n.net/n.hours:Number.NEGATIVE_INFINITY)-i||n.count-a.count||a.label.localeCompare(n.label)})[0];return r?{label:r.label,count:r.count,hourly:r.hours>0?r.net/r.hours:0,detail:s==null?void 0:s[r.label]}:null}function Bs(t){const s=/^(\d{4})-(\d{2})-(\d{2})$/.exec(String(t||"").trim());if(!s)return!1;const r=new Date(Number(s[1]),Number(s[2])-1,Number(s[3]));return r.getFullYear()===Number(s[1])&&r.getMonth()===Number(s[2])-1&&r.getDate()===Number(s[3])}function ba(t){if(!Bs(t))return"Date not recorded";const[s,r,a]=t.split("-").map(Number);return new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric"}).format(new Date(s,r-1,a))}function ga(t){const s=[...t.shifts.map(r=>r.shift_date),...t.entries.map(r=>r.entry_date)].map(r=>String(r||"")).filter(Bs).sort();return s[s.length-1]||null}function cs(t,s){return t.filter(r=>r&&typeof r=="object"&&String(r.user_id??"").trim()===s)}function ze({label:t,value:s,tone:r="plain"}){const a=r==="orange"?"border-[#F8C9B9] bg-[#FFF4EC] text-[#B9380B]":r==="teal"?"border-[#B9E4E1] bg-[#F2FBFA] text-[#0F7774]":"border-zinc-200 bg-white text-zinc-950",n=s.length>14;return e.jsxs("div",{className:`min-h-[78px] rounded-[14px] border p-3.5 ${a}`,children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.12em] text-zinc-500",children:t}),e.jsx("p",{className:`mt-1.5 break-words font-black ${n?"text-[13px] leading-snug":"font-mono text-[17px]"}`,children:s})]})}function ds({title:t,icon:s,pattern:r,missingMessage:a,teal:n=!1}){const i=n?"border-[#B9E4E1] bg-[#F2FBFA] text-[#0F7774]":"border-[#F8C9B9] bg-[#FFF8F3] text-[#B9380B]";return e.jsxs("article",{className:"rounded-[18px] border border-zinc-200 bg-white p-5",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsx("span",{className:`flex h-10 w-10 items-center justify-center rounded-[12px] border ${i}`,children:e.jsx(s,{className:"h-5 w-5","aria-hidden":"true"})}),e.jsx("span",{className:`rounded-full border px-2.5 py-1 text-[9px] font-black uppercase tracking-[0.14em] ${i}`,children:r?r.count===1?"Early signal":"Observed history":"No qualifying pattern"})]}),e.jsx("h5",{className:"mt-4 text-[17px] font-black tracking-tight text-zinc-950",children:t}),r?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"mt-3 text-[19px] font-black tracking-tight text-zinc-950",children:r.label}),e.jsxs("p",{className:"mt-2 font-mono text-[26px] font-black tracking-tight text-zinc-950",children:[Ge(r.hourly),e.jsx("span",{className:"ml-1 text-[12px] font-bold text-zinc-500",children:"/hr estimate"})]}),e.jsxs("p",{className:"mt-2 text-[11px] leading-relaxed text-zinc-600",children:[Ft(r.count,"complete shift")," in this group. ",r.detail?`Window: ${r.detail}.`:"Grouped by the work zone saved on the shift."]}
14),r.count===1&&e.jsx("p",{className:"mt-3 rounded-[11px] border border-amber-200 bg-amber-50 px-3 py-2.5 text-[11px] font-semibold leading-relaxed text-amber-950",children:"One complete shift is an early signal. Add more real shifts before treating it as a pattern."})]}):e.jsxs("div",{className:"mt-4 rounded-[12px] border border-dashed border-zinc-300 bg-[#FFFCF9] p-3.5",children:[e.jsx("p",{className:"text-[13px] font-black text-zinc-950",children:"No qualifying pattern yet."}),e.jsx("p",{className:"mt-1 text-[11px] leading-relaxed text-zinc-600",children:a})]})]})}function ja(){return e.jsxs("div",{className:"mt-5 flex flex-col gap-3 rounded-[15px] border border-[#B9E4E1] bg-[#F2FBFA] p-4 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.15em] text-[#0F7774]",children:"Keep building your history"}),e.jsx("p",{className:"mt-1 text-[12px] leading-relaxed text-zinc-700",children:"Use the free tools above to add real records to this account."})]}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row",children:[e.jsxs("a",{href:"#real-pay-meter",className:"inline-flex min-h-[42px] items-center justify-center gap-1.5 rounded-[11px] bg-[#F45815] px-3.5 py-2 text-[11px] font-black text-white hover:bg-[#E94E0E] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#F45815] focus-visible:ring-offset-2",children:["Log a shift ",e.jsx(q,{className:"h-3.5 w-3.5","aria-hidden":"true"})]}),e.jsxs("a",{href:"#gas-mileage-log-section",className:"inline-flex min-h-[42px] items-center justify-center gap-1.5 rounded-[11px] border border-[#0F8B88] bg-white px-3.5 py-2 text-[11px] font-black text-[#0F7774] hover:bg-[#EAF8F7] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#0F8B88] focus-visible:ring-offset-2",children:["Add fuel or mileage ",e.jsx(q,{className:"h-3.5 w-3.5","aria-hidden":"true"})]})]})]})}function Na({summary:t,rate:s}){const r=[t.shiftHistoryAtLimit?{label:"Saved shifts",limit:xt}:null,t.gasMileageHistoryAtLimit?{label:"Gas & Mileage Log",limit:mt}:null].filter(m=>!!m),a=r.length===2?`Showing the newest ${r[0].limit.toLocaleString()} records for Saved shifts and Gas & Mileage Log. Older records are not included in these totals or patterns yet.`:r.length===1?`Showing the newest ${r[0].limit.toLocaleString()} records for ${r[0].label}. Older records are not included in these totals or patterns yet.`:null,n=t.activityCount===0,i=t.completeCount>t.zoneCount||t.completeCount>t.timeCount,d=!n&&(t.shiftCount===0||t.gasCount===0||t.incompleteCount>0||i),c=[t.shiftCount===0?"Your account has no saved shifts yet.":"",t.gasCount===0?"Your separate Gas & Mileage Log has no entries yet.":"",t.incompleteCount>0?`${Ft(t.incompleteCount,"shift")} need${t.incompleteCount===1?"s":""} complete pay details before every comparison can be trusted.`:"",t.completeCount>t.zoneCount?"Some complete shifts are missing a work zone.":"",t.completeCount>t.timeCount?"Some complete shifts are missing a valid start time.":""].filter(Boolean).join(" ");return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col gap-3 border-b border-zinc-100 pb-5 sm:flex-row sm:items-end sm:justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.17em] text-[#0F7774]",children:"Verified account view"}),e.jsx("h4",{className:"mt-1 text-[22px] font-black tracking-tight text-zinc-950",children:"Your recorded profit picture"}),e.jsx("p",{className:"mt-1.5 max-w-[62ch] text-[12px] leading-relaxed text-zinc-600",children:"The dashboard combines your saved shifts with your separate fuel and mileage log. It never adds log fuel to shift net."})]}),e.jsxs("span",{className:"inline-flex items-center gap-1.5 self-start rounded-full border border-zinc-200 bg-white px-3 py-1.5 text-[10px] font-bold text-zinc-600 sm:self-auto",children:[e.jsx(oe,{className:"h-3.5 w-3.5 text-[#0F8B88]"}),t.latestDate?`Latest activity · ${ba(t.latestDate)}`:"Dates not recorded"]})]}),e.jsxs("div",{className:"mt-5 grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-5",children:[e.jsx(ze,{label:"Saved shifts",value:String(t.shiftCount)}),e.jsx(ze,{label:"Shift hours",value:t.shiftCount?`${t.hours.toFixed(1)} hours`:"No shift history yet"}),e.jsx(ze,{label:"Recorded gross earnings",value:t.shiftCount?Ge(t.gross):"No shift history yet"}),e.jsx(ze,{label:"Shift fuel",value:t.shiftCount?Ge(t.shiftFuel):"No shift history yet"}),e.jsx(ze,{label:"Shift miles",value:t.shiftCount?`${t.miles.toFixed(1)} mi`:"No shift history yet"}),e.jsx(ze,{label:"Vehicle-cost reserve",value:t.shiftCount?Ge(t.reserve):"No shift history yet",tone
14:"orange"}),e.jsx(ze,{label:"After-cost estimate",value:t.shiftCount?Ge(t.afterCost):"No shift history yet",tone:"orange"}),e.jsx(ze,{label:"After-cost hourly estimate",value:t.afterHourly===null?t.shiftCount?"No complete shift yet":"No shift history yet":`${Ge(t.afterHourly)}/hr`,tone:"orange"}),e.jsx(ze,{label:"Gas & Mileage tracked cost",value:t.gasCount?Ge(t.logTrackedCost):"No log entries yet",tone:"teal"}),e.jsx(ze,{label:"Total account activity",value:String(t.activityCount),tone:"teal"})]}),e.jsxs("div",{className:"mt-5 flex items-start gap-3 rounded-[14px] border border-[#F8C9B9] bg-[#FFF8F3] p-4",children:[e.jsx(Ze,{className:"mt-0.5 h-4 w-4 shrink-0 text-[#B9380B]","aria-hidden":"true"}),e.jsxs("p",{className:"text-[11px] leading-relaxed text-zinc-700",children:[e.jsxs("span",{className:"font-black text-zinc-950",children:["Rate used: $",s.toFixed(2),"/mi."]})," After-cost estimate = recorded gross earnings minus fuel entered on each shift, minus shift miles multiplied by this vehicle-cost reserve. Gas & Mileage Log tracked cost stays separate and is not added to shift net."]})]}),t.historyReadLimitReached&&a&&e.jsxs("div",{role:"status",className:"mt-5 flex items-start gap-3 rounded-[14px] border border-amber-300 bg-amber-50 p-4",children:[e.jsx(oe,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-800","aria-hidden":"true"}),e.jsxs("p",{className:"text-[11px] leading-relaxed text-amber-950",children:[e.jsx("span",{className:"font-black",children:"History read limit:"})," ",a]})]}),(n||d)&&e.jsxs("div",{className:`mt-5 rounded-[15px] border p-4 ${n?"border-dashed border-[#F8C9B9] bg-[#FFF8F3]":"border-amber-200 bg-amber-50"}`,children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Je,{className:`mt-0.5 h-4 w-4 shrink-0 ${n?"text-[#B9380B]":"text-amber-800"}`,"aria-hidden":"true"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[13px] font-black text-zinc-950",children:n?"No saved activity yet.":"This view is useful, with a few details still missing."}),e.jsx("p",{className:"mt-1 text-[11px] leading-relaxed text-zinc-700",children:n?"Save a real shift or a fuel and mileage entry to start your account history view. There is no sample data here.":c})]})]}),e.jsx(ja,{})]}),e.jsxs("section",{className:"mt-7 border-t border-zinc-100 pt-7","aria-labelledby":"profit-dashboard-patterns-title",children:[e.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.16em] text-[#B9380B]",children:"Patterns from your history"}),e.jsx("h5",{id:"profit-dashboard-patterns-title",className:"mt-1 text-[20px] font-black tracking-tight text-zinc-950",children:"Where your complete shifts performed best"})]}),e.jsx("span",{className:"rounded-full border border-zinc-200 bg-white px-3 py-1.5 text-[10px] font-bold text-zinc-600",children:"Complete shifts only"})]}),e.jsx("p",{className:"mt-2 text-[11px] leading-relaxed text-zinc-600",children:"This uses the same after-cost hourly comparison as Best-Shift Finder. A single record is labeled as an early signal, and missing zone or start-time details produce no winner."}),e.jsxs("div",{className:"mt-4 grid gap-3 lg:grid-cols-2",children:[e.jsx(ds,{title:"Strongest observed work zone",icon:Xe,pattern:t.zone,missingMessage:"Add a work zone to a complete shift in the Real Pay Meter."}),e.jsx(ds,{title:"Strongest observed start-time window",icon:Ie,pattern:t.time,missingMessage:"Add a valid start time to a complete shift in the Real Pay Meter.",teal:!0})]}),e.jsxs("p",{className:"mt-4 text-[11px] leading-relaxed text-zinc-500",children:[Ft(t.completeCount,"complete shift")," support the comparison. ",t.zoneCount," include a work zone and ",t.timeCount," include a valid start time. Records without those details stay out of that pattern."]})]}),e.jsxs("div",{className:"mt-6 flex items-start gap-2 border-t border-zinc-100 pt-5 text-[11px] leading-relaxed text-zinc-500",children:[e.jsx(we,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-[#0F8B88]","aria-hidden":"true"}),"Only records returned for this authenticated account are included. This dashboard supports organization help and is not tax or financial advice."]})]})}function ya({userId:t,unlocked:s,checkingEntitlement:r,entitlementError:a,operatingCostPerMile:n,onRetryEntitlement:i}){const d=Pe(),[c,m]=l.useState(null),[o,k]=l.useState(!1),[N,p]=l.useState(null),[u,j]=l.useState(0),w=(a==null?void 0:a.trim())||null,z=s&&!r&&!w,f=ua(n);l.useEffect(()=>{let g=!0;return z?(m(null),p(null),k(!0),(async()=>{try{const[v,F]=await Promise.all([gs.filter({user_id:t},"-shift_date",xt),zt.filter({user_id:t},"-entry_date",mt)]);if(!Array.isArray(v)||!Array.isArray(F))throw new Error("Account history response was not a list");const L={shifts:cs(v,t),entries:cs(F,t)};g&&m(L)}catch(v){console.error("Failed to load combined Driver Profit Suite history:",v),g&&(m(null),p("We could not read both private histories for this dashboard. No partial dashboard was kept. Try again when your account history is available."))}finally{g&&k(!1)}})(),()=>{g=!1}):(m(null),p(null),k(!1),()=>{g=!1})},[z,u,t]);const C=l.useMemo(()=>{const g=c||{shifts:[],entries:[]},{shifts:v,entries:F}=g,L=Ve(v,"total_hours"),S=Ve(v,"gross_earnings"),Q=Ve(v,"fuel_cost"),M=Ve(v,"total_miles"),H=M*f,T=S-Q-H,B=L>0?T/L:null,K=Ve(F,"fuel_cost")+Ve(F,"miles")*f,R=new Map,O=new Map;let se=0,V=0,le=0,I=0;return v.forEach(re=>{const U=ha(re,f);if(!U){V+=1;return}se+=1;const W=pa(re.zone),de=fa(re.start_time);W&&(le+=1,os(R,W.key,W.label,U)),de&&(I+=1,os(O,de,de,U))}),{shiftCount:v.length,gasCount:F.length,activityCount:v.length+F.length,hours:L,gross:S,shiftFuel:Q,miles:M,reserve:H,afterCost:T,afterHourly:B,logTrackedCost:K,completeCount:se,incompleteCount:V,zoneCount:le,timeCount:I,zone:ls(R),time:ls(O,ma),latestDate:ga(g),shiftHistoryAtLimit:v.length>=xt,gasMileageHistoryAtLimit:F.length>=mt,historyReadLimitReached:v.length>=xt||F.length>=mt}},[c,f]),h=()=>{i?i():j(g=>g+1)},$=d?{}:{initial:{opacity:0,y:12}
14,animate:{opacity:1,y:0},transition:{duration:.45,ease:[.22,1,.36,1]}},_=z&&(o||!c)&&!N;return e.jsxs(be.section,{...$,id:"combined-profit-dashboard","aria-labelledby":"combined-profit-dashboard-title",className:"mt-14 overflow-hidden rounded-[24px] border border-zinc-200 bg-white shadow-[0_16px_44px_rgba(24,24,27,0.07)] sm:mt-20",children:[e.jsx("div",{className:"border-b border-zinc-800 bg-zinc-950 px-5 py-5 text-white sm:px-7 sm:py-6",children:e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-[14px] bg-[#F45815] text-white shadow-[0_8px_20px_rgba(244,88,21,0.24)]",children:e.jsx(We,{className:"h-5 w-5","aria-hidden":"true"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-black uppercase tracking-[0.18em] text-[#FFB15F]",children:"Paid benefit · Founding Unlock"}),e.jsx("h3",{id:"combined-profit-dashboard-title",className:"mt-1 font-['Poppins',sans-serif] text-[24px] font-black leading-none tracking-[-0.04em] sm:text-[28px]",children:"Combined Profit Dashboard"}
14),e.jsx("p",{className:"mt-2 max-w-[62ch] text-[13px] leading-relaxed text-zinc-300",children:"Account history view for your saved shifts and separate Gas & Mileage Log activity."})]})]}),e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full border border-[#2C6F6D] bg-[#123B3B] px-3 py-1.5 text-[10px] font-black uppercase tracking-[0.12em] text-[#B9E4E1]",children:[r?e.jsx(X,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":"true"}):w?e.jsx(P,{className:"h-3.5 w-3.5","aria-hidden":"true"}):s?e.jsx(te,{className:"h-3.5 w-3.5","aria-hidden":"true"}):e.jsx(Ne,{className:"h-3.5 w-3.5","aria-hidden":"true"}),r?"Checking access":w?"Access needs review":s?"Verified access":"Founding Unlock required"]})]})}),e.jsx("div",{className:"bg-[#FFFCF9] p-5 sm:p-7",children:r?e.jsxs("div",{role:"status","aria-live":"polite","aria-busy":"true",className:"flex items-start gap-3 rounded-[16px] border border-[#B9E4E1] bg-[#F2FBFA] p-5",children:[e.jsx(X,{className:"mt-0.5 h-5 w-5 shrink-0 animate-spin text-[#0F7774]"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[14px] font-black text-zinc-950",children:"Checking your Founding Unlock"}),e.jsx("p",{className:"mt-1 text-[12px] leading-relaxed text-zinc-600",children:"We confirm access before reading either full private history. Your three free tools remain available above."})]})]}):w?e.jsxs("div",{role:"alert",className:"flex flex-wrap items-start justify-between gap-4 rounded-[16px] border border-amber-200 bg-amber-50 p-5",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(P,{className:"mt-0.5 h-5 w-5 shrink-0 text-amber-700"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[14px] font-black text-amber-950",children:"We could not confirm dashboard access"}),e.jsx("p",{className:"mt-1 text-[12px] leading-relaxed text-amber-900",children:w}),e.jsx("p",{className:"mt-2 text-[11px] font-semibold text-amber-900",children:"No full history was read by this card. Your free tools remain available."})]})]}),e.jsxs("button",{type:"button",onClick:h,className:"inline-flex min-h-[40px] shrink-0 items-center gap-1.5 rounded-full border border-amber-300 bg-white px-3.5 py-2 text-[11px] font-black text-amber-950 hover:bg-amber-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-500 focus-visible:ring-offset-2",children:[e.jsx(ue,{className:"h-3.5 w-3.5"})," Try again"]})]}):s?N?e.jsxs("div",{role:"alert",className:"flex flex-wrap items-start justify-between gap-4 rounded-[16px] border border-amber-200 bg-amber-50 p-5",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(P,{className:"mt-0.5 h-5 w-5 shrink-0 text-amber-700"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[14px] font-black text-amber-950",children:"Your combined history is unavailable"}),e.jsx("p",{className:"mt-1 text-[12px] leading-relaxed text-amber-900",children:N})]})]}),e.jsxs("button",{type:"button",onClick:h,className:"inline-flex min-h-[40px] shrink-0 items-center gap-1.5 rounded-full border border-amber-300 bg-white px-3.5 py-2 text-[11px] font-black text-amber-950 hover:bg-amber-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-500 focus-visible:ring-offset-2",children:[e.jsx(ue,{className:"h-3.5 w-3.5"})," Try again"]})]}):_?e.jsxs("div",{role:"status","aria-live":"polite","aria-busy":"true",className:"flex items-start gap-3 rounded-[16px] border border-[#B9E4E1] bg-[#F2FBFA] p-5",children:[e.jsx(X,{className:"mt-0.5 h-5 w-5 shrink-0 animate-spin text-[#0F7774]"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[14px] font-black text-zinc-950",children:"Reading your account history"}),e.jsx("p",{className:"mt-1 text-[12px] leading-relaxed text-zinc-600",children:"The dashboard is loading your own shift and Gas & Mileage Log records. No other account is included."})]})]}):e.jsx(Na,{summary:C,rate:f}):e.jsxs("div",{className:"grid gap-5 lg:grid-cols-[1fr_auto] lg:items-center",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-[14px] bg-[#FFF1E8] text-[#F45815]",children:e.jsx(Ne,{className:"h-5 w-5","aria-hidden":"true"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-black uppercase tracking-[0.16em] text-[#B9380B]",children:"Paid dashboard benefit"}),e.jsx("h4",{className:"mt-1 text-[21px] font-black tracking-tight text-zinc-950",children:"Bring the whole picture together."}
14),e.jsx("p",{className:"mt-2 max-w-[62ch] text-[13px] leading-relaxed text-zinc-600",children:"The $11 one-time Founding Unlock adds this combined account history view for your own account. It uses your saved shift history and separate Gas & Mileage Log activity after verified access."}),e.jsx("p",{className:"mt-3 text-[11px] font-semibold text-zinc-500",children:"No full history is fetched while this account is locked."})]})]}),e.jsxs("div",{className:"rounded-[18px] border border-[#F8C9B9] bg-white p-4 lg:min-w-[235px]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.15em] text-[#B9380B]",children:"Founding Unlock"}),e.jsxs("p",{className:"mt-1 text-[22px] font-black text-zinc-950",children:["$11 ",e.jsx("span",{className:"text-[12px] font-bold text-zinc-500",children:"one time"})]})]}),e.jsx(fe,{className:"h-5 w-5 text-[#0F8B88]","aria-hidden":"true"})]}),e.jsxs(et,{to:"/starter-kit",className:"mt-4 inline-flex min-h-[44px] w-full items-center justify-center gap-2 rounded-[12px] bg-[#F45815] px-4 py-2.5 text-[12px] font-black text-white hover:bg-[#E94E0E] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#F45815] focus-visible:ring-offset-2",children:["Get the $11 Founding Unlock ",e.jsx(q,{className:"h-4 w-4","aria-hidden":"true"})]})]})]})})]})}const wa=.3;function Qe(t){if(t==null||String(t).trim()==="")return null;const s=typeof t=="number"?t:Number(t);return Number.isFinite(s)&&s>=0?s:null}function va(t){const s=Number(t);return Number.isFinite(s)&&s>=0?s:wa}function _e(t){const s=Number.isFinite(t)?t:0;return`${s<0?"-":""}$${Math.abs(s).toFixed(2)}`}function Fa(t){const s=String(t||"").trim(),r=/^(\d{4})-(\d{2})-(\d{2})$/.exec(s);if(!r)return!1;const a=new Date(Number(r[1]),Number(r[2])-1,Number(r[3]));return a.getFullYear()===Number(r[1])&&a.getMonth()===Number(r[2])-1&&a.getDate()===Number(r[3])}function Ke(t,s,r){const a=String(t||"").trim();return Fa(a)&&a>=s&&a<=r}function xs(t,s){return t.filter(r=>r&&typeof r=="object"&&String(r.user_id??"").trim()===s)}function qe(t){const[s,r,a]=t.split("-").map(Number);return new Intl.DateTimeFormat("en-US",{month:"long",day:"numeric",year:"numeric"}).format(new Date(s,r-1,a))}function ka(t,s){return new Intl.DateTimeFormat("en-US",{month:"long"}).format(new Date(t,s-1,1))}function za(t,s){const r=new Date(t,s,0).getDate();return`${qe(`${t}-${String(s).padStart(2,"0")}-01`)} to ${qe(`${t}-${String(s).padStart(2,"0")}-${String(r).padStart(2,"0")}`)}`}function ms(t,s){return t.reduce((r,a)=>{const n=Qe(a.total_hours),i=Qe(a.gross_earnings),d=Qe(a.fuel_cost),c=Qe(a.total_miles);return r.count+=1,r.hours+=n??0,r.gross+=i??0,r.fuel+=d??0,r.miles+=c??0,c!==null&&(r.reserve+=c*s),n!==null&&n>0&&i!==null&&d!==null&&c!==null&&i!==null&&d!==null&&c!==null&&n!==null?(r.afterCost+=i-d-c*s,r.afterHours+=n):r.incomplete+=1,r},{count:0,hours:0,gross:0,fuel:0,miles:0,reserve:0,afterCost:0,afterHours:0,incomplete:0})}function us(t,s){return t.reduce((r,a)=>{const n=Qe(a.miles),i=Qe(a.fuel_cost);return r.count+=1,r.miles+=n??0,r.fuel+=i??0,n!==null&&(r.reserve+=n*s),r.trackedCost+=(i??0)+(n??0)*s,r},{count:0,fuel:0,miles:0,reserve:0,trackedCost:0})}function _a(t,s,r){const a=`${r}-10-01`,n=`${r}-12-31`,i=[10,11,12].map(d=>{const c=`${r}-${String(d).padStart(2,"0")}-01`,m=`${r}-${String(d).padStart(2,"0")}-${String(new Date(r,d,0).getDate()).padStart(2,"0")}`,o=t.shifts.filter(u=>Ke(u.shift_date,c,m)),k=t.entries.filter(u=>Ke(u.entry_date,c,m)),N=ms(o,s),p=us(k,s);return{month:d,shifts:N,entries:p,activity:N.count+p.count}});return{shifts:ms(t.shifts.filter(d=>Ke(d.shift_date,a,n)),s),entries:us(t.entries.filter(d=>Ke(d.entry_date,a,n)),s),months:i}}function J({label:t,value:s,tone:r="plain"}){const a=r==="orange"?"border-[#F8C9B9] bg-[#FFF4EC] text-[#B9380B]":r==="teal"?"border-[#B9E4E1] bg-[#F2FBFA] text-[#0F7774]":"border-zinc-200 bg-white text-zinc-950";return e.jsxs("div",{className:`min-h-[74px] rounded-[14px] border p-3 ${a}`,children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.11em] text-zinc-500",children:t}),e.jsx("p",{className:`mt-1.5 break-words font-black ${s.length>17?"text-[12px] leading-snug":"font-mono text-[16px]"}`,children:s})]})}function $s(){return e.jsxs("div",{className:"mt-5 flex flex-col gap-2.5 rounded-[15p
14x] border border-[#B9E4E1] bg-[#F2FBFA] p-4 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.14em] text-[#0F7774]",children:"Add real Q4 records"}),e.jsx("p",{className:"mt-1 text-[11px] leading-relaxed text-zinc-700",children:"Use the free tools above during the active season, then return here."})]}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row",children:[e.jsxs("a",{href:"#real-pay-meter",className:"inline-flex min-h-[42px] items-center justify-center gap-1.5 rounded-[11px] bg-[#F45815] px-3.5 py-2 text-[11px] font-black text-white hover:bg-[#E94E0E] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#F45815] focus-visible:ring-offset-2",children:["Log a shift ",e.jsx(q,{className:"h-3.5 w-3.5","aria-hidden":"true"})]}),e.jsxs("a",{href:"#gas-mileage-log-section",className:"inline-flex min-h-[42px] items-center justify-center gap-1.5 rounded-[11px] border border-[#0F8B88] bg-white px-3.5 py-2 text-[11px] font-black text-[#0F7774] hover:bg-[#EAF8F7] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#0F8B88] focus-visible:ring-offset-2",children:["Add fuel or mileage ",e.jsx(q,{className:"h-3.5 w-3.5","aria-hidden":"true"})]})]})]})}function Sa({year:t,month:s,shifts:r,entries:a,activity:n}){return e.jsxs("article",{className:"rounded-[17px] border border-zinc-200 bg-white p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[16px] font-black tracking-tight text-zinc-950",children:ka(t,s)}),e.jsx("p",{className:"mt-1 text-[10px] font-semibold text-zinc-500",children:za(t,s)})]}),e.jsx("span",{className:`rounded-full border px-2.5 py-1 text-[9px] font-black uppercase tracking-[0.12em] ${n?"border-[#B9E4E1] bg-[#F2FBFA] text-[#0F7774]":"border-dashed border-zinc-300 bg-[#FFFCF9] text-zinc-500"}`,children:n?`${n} ${n===1?"record":"records"}`:"No records yet"})]}),n?e.jsxs("div",{className:"mt-4 grid grid-cols-2 gap-2",children:[e.jsx(J,{label:"Shift count",value:String(r.count)}),e.jsx(J,{label:"Log entries",value:String(a.count),tone:"teal"}),e.jsx(J,{label:"Activity",value:String(n)}),e.jsx(J,{label:"Shift after-cost",value:r.count?_e(r.afterCost):"No shift records",tone:"orange"}),e.jsx(J,{label:"Log tracked cost",value:a.count?_e(a.trackedCost):"No log entries",tone:"teal"})]}):e.jsxs("div",{className:"mt-4 rounded-[12px] border border-dashed border-[#F8C9B9] bg-[#FFF8F3] p-3.5",children:[e.jsx("p",{className:"text-[12px] font-black text-zinc-950",children:"No records yet."}),e.jsx("p",{className:"mt-1 text-[11px] leading-relaxed text-zinc-600",children:"No saved shift or Gas & Mileage Log activity falls in this month."})]})]})}function Ea({summary:t,rate:s,year:r}){const{shifts:a,entries:n}=t,i=[a.count===0?"No Q4 shifts are saved yet.":"",n.count===0?"No Q4 Gas & Mileage Log entries are saved yet.":"",a.incomplete===1?"One shift record is missing numeric pay details and stays out of the after-cost estimate.":a.incomplete>1?`${a.incomplete} shift records are missing numeric pay details and stay out of the after-cost estimate.`:""].filter(Boolean),d=i.length>0,c=a.afterHours>0?a.afterCost/a.afterHours:null;return e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-col gap-3 border-b border-zinc-100 pb-5 sm:flex-row sm:items-end sm:justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.17em] text-[#0F7774]",children:"Verified seasonal view"}),e.jsx("h4",{className:"mt-1 text-[22px] font-black tracking-tight text-zinc-950",children:"Your Q4 organization snapshot"}),e.jsxs("p",{className:"mt-1.5 max-w-[66ch] text-[12px] leading-relaxed text-zinc-600",children:["Active range: ",qe(`${r}-10-01`)," to ",qe(`${r}-12-31`),". These totals use only real records returned for this account."]})]}),e.jsxs("span",{className:"inline-flex items-center gap-1.5 self-start rounded-full border border-[#F8C9B9] bg-[#FFF8F3] px-3 py-1.5 text-[10px] font-black uppercase tracking-[0.12em] text-[#B9380B] sm:self-auto",children:[e.jsx(ye,{className:"h-3.5 w-3.5","aria-hidden":"true"})," Starting point only"]})]}
14),d&&e.jsxs("div",{role:"status",className:"mt-5 rounded-[15px] border border-amber-200 bg-amber-50 p-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(P,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-800","aria-hidden":"true"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[13px] font-black text-amber-950",children:"Partial Q4 picture so far."}),e.jsxs("p",{className:"mt-1 text-[11px] leading-relaxed text-amber-900",children:[i.join(" ")," Add more real records in the free tools above as the season continues."]})]})]}),e.jsx($s,{})]}),e.jsxs("section",{className:"mt-6","aria-labelledby":"q4-shift-metrics-title",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("h5",{id:"q4-shift-metrics-title",className:"text-[16px] font-black tracking-tight text-zinc-950",children:"Q4 shift history"}),e.jsxs("span",{className:"text-[10px] font-bold text-zinc-500",children:[a.count," ",a.count===1?"shift":"shifts"]})]}),e.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-4",children:[e.jsx(J,{label:"Shift count",value:String(a.count)}),e.jsx(J,{label:"Hours",value:a.count?`${a.hours.toFixed(1)} hours`:"No shift records"}),e.jsx(J,{label:"Recorded gross earnings",value:a.count?_e(a.gross):"No shift records"}),e.jsx(J,{label:"Shift fuel",value:a.count?_e(a.fuel):"No shift records"}),e.jsx(J,{label:"Shift miles",value:a.count?`${a.miles.toFixed(1)} mi`:"No shift records"}),e.jsx(J,{label:"Vehicle-cost reserve",value:a.count?_e(a.reserve):"No shift records",tone:"orange"}),e.jsx(J,{label:"After-cost estimate",value:a.count?_e(a.afterCost):"No shift records",tone:"orange"}),e.jsx(J,{label:"After-cost hourly estimate",value:c===null?"No positive hours":`${_e(c)}/hr`,tone:"orange"})]})]}),e.jsxs("section",{className:"mt-6 border-t border-zinc-100 pt-6","aria-labelledby":"q4-log-metrics-title",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h5",{id:"q4-log-metrics-title",className:"text-[16px] font-black tracking-tight text-zinc-950",children:"Separate Gas & Mileage Log"}),e.jsx("p",{className:"mt-1 text-[11px] leading-relaxed text-zinc-600",children:"Log tracked cost never gets added to shift net."})]}),e.jsxs("span",{className:"text-[10px] font-bold text-zinc-500",children:[n.count," ",n.count===1?"entry":"entries"]})]}),e.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-5",children:[e.jsx(J,{label:"Entry count",value:String(n.count),tone:"teal"}),e.jsx(J,{label:"Fuel paid",value:n.count?_e(n.fuel):"No log entries",tone:"teal"}),e.jsx(J,{label:"Miles logged",value:n.count?`${n.miles.toFixed(1)} mi`:"No log entries",tone:"teal"}),e.jsx(J,{label:"Vehicle reserve",value:n.count?_e(n.reserve):"No log entries",tone:"teal"}),e.jsx(J,{label:"Tracked cost",value:n.count?_e(n.trackedCost):"No log entries",tone:"teal"})]}),e.jsxs("p",{className:"mt-3 flex items-start gap-2 rounded-[12px] border border-[#B9E4E1] bg-[#F2FBFA] px-3.5 py-3 text-[11px] leading-relaxed text-zinc-700",children:[e.jsx(Ze,{className:"mt-0.5 h-4 w-4 shrink-0 text-[#0F7774]","aria-hidden":"true"}),"Log tracked cost = log fuel paid plus logged miles multiplied by the $",s.toFixed(2),"/mi vehicle-cost reserve. It is separate from shift fuel and is not added to shift net."]})]}),e.jsxs("section",{className:"mt-6 border-t border-zinc-100 pt-6","aria-labelledby":"q4-month-breakdown-title",children:[e.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.16em] text-[#B9380B]",children:"October to December"}),e.jsx("h5",{id:"q4-month-breakdown-title",className:"mt-1 text-[20px] font-black tracking-tight text-zinc-950",children:"Monthly activity breakdown"})]}),e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-[10px] font-bold text-zinc-500",children:[e.jsx(Ie,{className:"h-3.5 w-3.5 text-[#0F8B88]"})," Real records only"]})]}),e.jsx("div",{className:"mt-4 grid gap-3 lg:grid-cols-3",children:t.months.map(m=>e.jsx(Sa,{year:r,...m},m.month))})]}),e.jsxs("div",{className:"mt-6 flex items-start gap-2 border-t border-zinc-100 pt-5 text-[11px] leading-relaxed text-zinc-500",children:[e.jsx(we,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-[#0F8B88]","aria-hidden":"true"}),"Organization starting point only. This is not tax, legal, accounting, or financial advice."]})]})}function Ca({userId:t,unlocked:s,checkingEntitlement:r,entitlementError:a,operatingCostPerMile:n,onRetryEntitlement:i}){const d=Pe(),[c,m]=l.useState(null),[o,k]=l.useState(!1),[N,p]=l.useState(null),[u,j]=l.useState(0),w=new Date,z=w.getFullYear(),f=w.getMonth()+1,C=f>=10&&f<=12,h=`${z}-10-01`,$=`${z}
14-12-31`,_=va(n),g=(a==null?void 0:a.trim())||null,v=C&&s&&!r&&!g;l.useEffect(()=>{let M=!0;return v?(m(null),p(null),k(!0),(async()=>{try{const[H,T]=await Promise.all([gs.filter({user_id:t},"-shift_date",5e3),zt.filter({user_id:t},"-entry_date",5e3)]);if(!Array.isArray(H)||!Array.isArray(T))throw new Error("Q4 history response was not a list");const B=xs(H,t).filter(R=>Ke(R.shift_date,h,$)),K=xs(T,t).filter(R=>Ke(R.entry_date,h,$));M&&m({shifts:B,entries:K})}catch(H){console.error("Failed to load Driver Profit Suite Q4 history:",H),M&&(m(null),p("We could not read both private histories for this Q4 layer. No partial totals were kept. Try again when your account history is available."))}finally{M&&k(!1)}})(),()=>{M=!1}):(m(null),p(null),k(!1),()=>{M=!1})},[v,u,h,$,t]);const F=l.useMemo(()=>c?_a(c,_,z):null,[c,_,z]),L=()=>{i?i():j(M=>M+1)},S=d?{}:{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.45,ease:[.22,1,.36,1]}},Q=r?"Checking access":g?"Access needs review":s?C?"Verified access":"Opens October 1":"Founding Unlock required";return e.jsxs(be.section,{...S,id:"q4-profit-layer","aria-labelledby":"q4-profit-layer-title",className:"mt-14 overflow-hidden rounded-[24px] border border-zinc-200 bg-white shadow-[0_16px_44px_rgba(24,24,27,0.07)] sm:mt-20",children:[e.jsx("div",{className:"border-b border-zinc-800 bg-zinc-950 px-5 py-5 text-white sm:px-7 sm:py-6",children:e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-[14px] bg-[#F45815] text-white shadow-[0_8px_20px_rgba(244,88,21,0.24)]",children:e.jsx(ye,{className:"h-5 w-5","aria-hidden":"true"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-black uppercase tracking-[0.18em] text-[#FFB15F]",children:"Paid benefit · Founding Unlock"}),e.jsx("h3",{id:"q4-profit-layer-title",className:"mt-1 font-['Poppins',sans-serif] text-[24px] font-black leading-none tracking-[-0.04em] sm:text-[28px]",children:"Seasonal Q4 organization layer"}
14),e.jsx("p",{className:"mt-2 max-w-[62ch] text-[13px] leading-relaxed text-zinc-300",children:C?"A seasonal view of your real October, November, and December shift and Gas & Mileage Log records.":`Next opening: ${qe(`${z}-10-01`)}. The layer organizes records saved during Q4.`})]})]}),e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full border border-[#2C6F6D] bg-[#123B3B] px-3 py-1.5 text-[10px] font-black uppercase tracking-[0.12em] text-[#B9E4E1]",children:[r?e.jsx(X,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":"true"}):g?e.jsx(P,{className:"h-3.5 w-3.5","aria-hidden":"true"}):s?C?e.jsx(te,{className:"h-3.5 w-3.5","aria-hidden":"true"}):e.jsx(ye,{className:"h-3.5 w-3.5","aria-hidden":"true"}):e.jsx(Ne,{className:"h-3.5 w-3.5","aria-hidden":"true"}),Q]})]})}),e.jsx("div",{className:"bg-[#FFFCF9] p-5 sm:p-7",children:r?e.jsxs("div",{role:"status","aria-live":"polite","aria-busy":"true",className:"flex items-start gap-3 rounded-[16px] border border-[#B9E4E1] bg-[#F2FBFA] p-5",children:[e.jsx(X,{className:"mt-0.5 h-5 w-5 shrink-0 animate-spin text-[#0F7774]"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[14px] font-black text-zinc-950",children:"Checking your Founding Unlock"}),e.jsx("p",{className:"mt-1 text-[12px] leading-relaxed text-zinc-600",children:"Access is confirmed before either private history is read. Your three free tools remain available above."})]})]}):g?e.jsxs("div",{role:"alert",className:"flex flex-wrap items-start justify-between gap-4 rounded-[16px] border border-amber-200 bg-amber-50 p-5",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(P,{className:"mt-0.5 h-5 w-5 shrink-0 text-amber-700"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[14px] font-black text-amber-950",children:"We could not confirm Q4 access"}),e.jsx("p",{className:"mt-1 text-[12px] leading-relaxed text-amber-900",children:g}),e.jsx("p",{className:"mt-2 text-[11px] font-semibold text-amber-900",children:"No Q4 history was read by this card. Your free tools remain available."})]})]}),e.jsxs("button",{type:"button",onClick:L,className:"inline-flex min-h-[40px] shrink-0 items-center gap-1.5 rounded-full border border-amber-300 bg-white px-3.5 py-2 text-[11px] font-black text-amber-950 hover:bg-amber-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-500 focus-visible:ring-offset-2",children:[e.jsx(ue,{className:"h-3.5 w-3.5","aria-hidden":"true"})," Try again"]})]}):s?C?N?e.jsxs("div",{role:"alert",className:"flex flex-wrap items-start justify-between gap-4 rounded-[16px] border border-amber-200 bg-amber-50 p-5",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(P,{className:"mt-0.5 h-5 w-5 shrink-0 text-amber-700"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[14px] font-black text-amber-950",children:"Your Q4 history is unavailable"}),e.jsx("p",{className:"mt-1 text-[12px] leading-relaxed text-amber-900",children:N})]})]}),e.jsxs("button",{type:"button",onClick:L,className:"inline-flex min-h-[40px] shrink-0 items-center gap-1.5 rounded-full border border-amber-300 bg-white px-3.5 py-2 text-[11px] font-black text-amber-950 hover:bg-amber-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-500 focus-visible:ring-offset-2",children:[e.jsx(ue,{className:"h-3.5 w-3.5","aria-hidden":"true"})," Try again"]})]}):o||!c?e.jsxs("div",{role:"status","aria-live":"polite","aria-busy":"true",className:"flex items-start gap-3 rounded-[16px] border border-[#B9E4E1] bg-[#F2FBFA] p-5",children:[e.jsx(X,{className:"mt-0.5 h-5 w-5 shrink-0 animate-spin text-[#0F7774]"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[14px] font-black text-zinc-950",children:"Reading your Q4 history"}),e.jsx("p",{className:"mt-1 text-[12px] leading-relaxed text-zinc-600",children:"Both private histories must load before any seasonal totals appear. No sample records are used."})]})]}):F&&F.shifts.count+F.entries.count===0?e.jsxs("div",{className:"rounded-[16px] border border-dashed border-[#F8C9B9] bg-[#FFF8F3] p-5",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(oe,{className:"mt-0.5 h-5 w-5 shrink-0 text-[#B9380B]","aria-hidden":"true"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[14px] font-black text-zinc-950",children:"No Q4 records yet."}),e.jsx("p",{className:"mt-1 text-[12px] leading-relaxed text-zinc-700",children:"Save a real shift or Gas & Mileage Log entry dated from October 1 through December 31. This seasonal view will organize the records after both histories load successfully."}),e.jsx("p",{className:"mt-3 text-[11px] font-semibold text-zinc-600",children:"Organization starting point only, not tax, legal, accounting, or financial advice."})]})]}),e.jsx($s,{})]}):F?e.jsx(Ea,{summary:F,rate:_,year:z}):null:e.jsxs("div",{className:"flex items-start gap-3 rounded-[16px] border border-[#F8C9B9] bg-[#FFF8F3] p-5",children:[e.jsx(ye,{className:"mt-0.5 h-5 w-5 shrink-0 text-[#B9380B]","aria-hidden":"true"}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-[14px] font-black text-zinc-950",children:["The Q4 layer opens ",qe(`${z}-10-01`),"."]}),e.jsx("p",{className:"mt-1 text-[12px] leading-relaxed text-zinc-700",children:"During October, November, and December, this card will organize the real records you save in the Driver Profit Suite. It stays closed until the season begins, so no full history is read early."}),e.jsx("p",{className:"mt-3 text-[11px] font-semibold text-[#B9380B]",children:"Founding Unlock verified. Current season: upcoming. Organization starting point only, not tax, legal, accounting, or financial advice."})]})]}):e.jsxs("div",{className:"grid gap-5 lg:grid-cols-[1fr_auto] lg:items-center",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-[14px] bg-[#FFF1E8] text-[#F45815]",children:e.jsx(Ne,{className:"h-5 w-5","aria-hidden":"true"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-black uppercase tracking-[0.16em] text-[#B9380B]",children:"Seasonal paid benefit"}),e.jsx("h4",{className:"mt-1 text-[21px] font-black tracking-tight text-zinc-950",children:"Organize the quarter from your own records."}
14),e.jsx("p",{className:"mt-2 max-w-[62ch] text-[13px] leading-relaxed text-zinc-600",children:"The $11 one-time Founding Unlock adds this seasonal Q4 view for your account. It organizes real shift history and separate Gas & Mileage Log entries during the active season."}),e.jsxs("p",{className:"mt-3 text-[11px] font-semibold text-zinc-500",children:["The current Q4 layer opens ",qe(`${z}-10-01`),". No Q4 history is fetched while this account is locked."]})]})]}),e.jsxs("div",{className:"rounded-[18px] border border-[#F8C9B9] bg-white p-4 lg:min-w-[235px]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.15em] text-[#B9380B]",children:"Founding Unlock"}),e.jsxs("p",{className:"mt-1 text-[22px] font-black text-zinc-950",children:["$11 ",e.jsx("span",{className:"text-[12px] font-bold text-zinc-500",children:"one time"})]})]}),e.jsx(fe,{className:"h-5 w-5 text-[#0F8B88]","aria-hidden":"true"})]}),e.jsxs(et,{to:"/starter-kit",className:"mt-4 inline-flex min-h-[44px] w-full items-center justify-center gap-2 rounded-[12px] bg-[#F45815] px-4 py-2.5 text-[12px] font-black text-white hover:bg-[#E94E0E] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#F45815] focus-visible:ring-offset-2",children:["Get the $11 Founding Unlock ",e.jsx(q,{className:"h-4 w-4","aria-hidden":"true"})]})]})]})})]})}function Ba({unlocked:t,checkingEntitlement:s,entitlementError:r,onRetryEntitlement:a}){const n=Pe(),i=(r==null?void 0:r.trim())||null,d=()=>a==null?void 0:a(),c=s?"Checking access":i?"Access needs review":t?"Verified status":"Status locked",m=n?{}:{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.45,ease:[.22,1,.36,1]}};return e.jsxs(be.section,{...m,id:"founding-driver-status","aria-labelledby":"founding-driver-status-title",className:"mt-14 overflow-hidden rounded-[24px] border border-zinc-200 bg-white shadow-[0_16px_44px_rgba(24,24,27,0.07)] sm:mt-20",children:[e.jsx("div",{className:"border-b border-zinc-800 bg-zinc-950 px-5 py-5 text-white sm:px-7 sm:py-6",children:e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-[14px] bg-[#F2E9C6] text-[#76520F] shadow-[0_8px_20px_rgba(216,182,91,0.16)]",children:e.jsx(Rt,{className:"h-5 w-5","aria-hidden":"true"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-black uppercase tracking-[0.18em] text-[#FFB15F]",children:"Paid benefit · Founding Unlock"}),e.jsx("h3",{id:"founding-driver-status-title",className:"mt-1 font-['Poppins',sans-serif] text-[24px] font-black leading-none tracking-[-0.04em] sm:text-[28px]",children:"Founding Driver status"}),e.jsx("p",{className:"mt-2 max-w-[60ch] text-[13px] leading-relaxed text-zinc-300",children:"A private account status for the RSG South Florida tri-market launch window."})]})]}),e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full border border-[#2C6F6D] bg-[#123B3B] px-3 py-1.5 text-[10px] font-black uppercase tracking-[0.12em] text-[#B9E4E1]",children:[s?e.jsx(X,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":"true"}):i?e.jsx(P,{className:"h-3.5 w-3.5","aria-hidden":"true"}):t?e.jsx(te,{className:"h-3.5 w-3.5","aria-hidden":"true"}):e.jsx(Ne,{className:"h-3.5 w-3.5","aria-hidden":"true"}),c]})]})}),e.jsx("div",{className:"bg-[#FFFCF9] p-5 sm:p-7",children:s?e.jsxs("div",{role:"status","aria-live":"polite","aria-busy":"true",className:"flex items-start gap-3 rounded-[16px] border border-[#B9E4E1] bg-[#F2FBFA] p-5",children:[e.jsx(X,{className:"mt-0.5 h-5 w-5 shrink-0 animate-spin text-[#0F7774]","aria-hidden":"true"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[14px] font-black text-zinc-950",children:"Checking your Founding Unlock"}),e.jsx("p",{className:"mt-1 text-[12px] leading-relaxed text-zinc-600",children:"We confirm the signed-in account before showing its Founding Driver status. Your three free tools remain available above."})]})]}):i?e.jsxs("div",{role:"alert",className:"flex flex-wrap items-start justify-between gap-4 roun
14ded-[16px] border border-amber-200 bg-amber-50 p-5",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(P,{className:"mt-0.5 h-5 w-5 shrink-0 text-amber-700","aria-hidden":"true"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[14px] font-black text-amber-950",children:"We could not confirm Founding Driver status"}),e.jsx("p",{className:"mt-1 text-[12px] leading-relaxed text-amber-900",children:i}),e.jsx("p",{className:"mt-2 text-[11px] font-semibold text-amber-900",children:"No status was changed. Your three free tools remain available above."})]})]}),e.jsxs("button",{type:"button",onClick:d,disabled:!a,className:"inline-flex min-h-[40px] shrink-0 items-center gap-1.5 rounded-full border border-amber-300 bg-white px-3.5 py-2 text-[11px] font-black text-amber-950 transition hover:bg-amber-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-500 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",children:[e.jsx(ue,{className:"h-3.5 w-3.5","aria-hidden":"true"})," Try again"]})]}):t?e.jsxs("div",{children:[e.jsxs("div",{className:"grid gap-6 lg:grid-cols-[minmax(0,1fr)_minmax(240px,0.72fr)] lg:items-start",children:[e.jsxs("div",{children:[e.jsxs("span",{className:"inline-flex items-center gap-2 rounded-full border border-[#D8B65B] bg-[#FBF4D9] px-3.5 py-2 text-[11px] font-black tracking-[0.16em] text-[#76520F] shadow-[0_8px_18px_rgba(169,127,33,0.12)]",children:[e.jsx(Rt,{className:"h-4 w-4","aria-hidden":"true"})," FOUNDING DRIVER"]}),e.jsx("h4",{className:"mt-5 text-[22px] font-black tracking-tight text-zinc-950",children:"Verified for this signed-in account."}),e.jsx("p",{className:"mt-2 max-w-[66ch] text-[13px] leading-relaxed text-zinc-600",children:"This status is shown after the account’s verified $11 Driver Profit Suite Founding Unlock. It marks the account-tied status for the RSG South Florida tri-market launch window."}),e.jsx("p",{className:"mt-3 max-w-[66ch] text-[11px] leading-relaxed text-zinc-500",children:"The badge appears here inside the private suite. It does not create a public profile placement or change a driver directory listing."})]}),e.jsxs("aside",{className:"rounded-[18px] border border-[#E5D39A] bg-[#FFFDF5] p-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-[12px] bg-[#F2E9C6] text-[#76520F]",children:e.jsx(Xe,{className:"h-5 w-5","aria-hidden":"true"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.15em] text-[#76520F]",children:"Launch window"}),e.jsx("p",{className:"mt-1 text-[16px] font-black tracking-tight text-zinc-950",children:"South Florida tri-market"}),e.jsx("p",{className:"mt-1 text-[11px] leading-relaxed text-zinc-600",children:"Palm Beach · Fort Lauderdale · Miami"})]})]}),e.jsxs("div",{className:"mt-4 flex items-start gap-2 border-t border-[#E5D39A] pt-3 text-[11px] font-semibold leading-relaxed text-zinc-600",children:[e.jsx(we,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-[#0F7774]","aria-hidden":"true"}),"Tied to this account’s verified purchase"]})]})]}),e.jsxs("p",{className:"mt-6 flex items-start gap-2 border-t border-zinc-200 pt-5 text-[11px] leading-relaxed text-zinc-500",children:[e.jsx(we,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-[#0F8B88]","aria-hidden":"true"}),"The $11 Driver Profit Suite status is separate from the $497 Academy/RSG Founder offer."]})]}):e.jsxs("div",{className:"grid gap-5 lg:grid-cols-[minmax(0,1fr)_auto] lg:items-center",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-[14px] bg-[#FFF1E8] text-[#F45815]",children:e.jsx(Ne,{className:"h-5 w-5","aria-hidden":"true"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-black uppercase tracking-[0.16em] text-[#B9380B]",children:"Account-tied paid benefit"}),e.jsx("h4",{className:"mt-1 text-[21px] font-black tracking-tight text-zinc-950",children:"Your Founding Driver status is waiting for verified access."}),e.jsx("p",{className:"mt-2 max-w-[64ch] text-[13px] leading-relaxed text-zinc-600",children:"The $11 one-time Founding Unlock adds this account-tied status after the purchase is verified. Your three free tools remain available with sign-in, even while this benefit is locked."}),e.jsx("p",{className:"mt-3 text-[11px] font-semibold leading-relaxed text-zinc-500",children:"This Driver Profit Suite offer is separate from the $497 Academy/RSG Founder offer."})]})]}),e.jsxs("div",{className:"rounded-[18px] border border-[#F8C9B9] bg-white p-4 lg:min-w-[235px]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.15em] text-[#B9380B]",children:"Founding Unlock"}),e.jsxs("p",{className:"mt-1 text-[22px] font-black text-zinc-950",children:["$11 ",e.jsx("span",{className:"text-[12px] font-bold text-zinc-500",children:"one time"})]})]}),e.jsx(Xe,{className:"h-5 w-5 text-[#0F8B88]","aria-hidden":"true"})]}),e.jsxs(et,{to:"/starter-kit",className:"mt-4 inline-flex min-h-[44px] w-full items-center justify-center gap-2 rounded-[12px] bg-[#F45815] px-4 py-2.5 text-[12px] font-black text-white transition hover:-translate-y-0.5 hover:bg-[#
14E94E0E] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#F45815] focus-visible:ring-offset-2",children:["Get the $11 Founding Unlock ",e.jsx(q,{className:"h-4 w-4","aria-hidden":"true"})]})]})]})})]})}const hs=.3,$a=["driver-profit-suite-founding-unlock-11","starter-kit-11"];function Aa(t,s){return t.some(r=>r.userId!==null&&r.userId!==void 0&&String(r.userId)===s&&r.status==="paid"&&r.access_granted===!0&&$a.includes(r.product_key))}function Ta(t){return[...t].sort((s,r)=>String(r.shift_date||"").localeCompare(String(s.shift_date||"")))}function As(){const t=typeof window<"u"?`${window.location.origin}${window.location.pathname}${window.location.search}${window.location.hash}`:"https://rideshareguides.com/profit-suite";return Os(t)}function kt(){const t=As();if(!(typeof window>"u")){if(window.top&&window.top!==window){window.top.location.href=t;return}window.location.href=t}}function Da({state:t}){const s=As(),r=t==="blocked",a=r?"Not signed in":t==="redirecting"?"Opening RSG sign-in":"Checking your RSG account",n=r?"This page is signed out. Use Log in to return here after your account is confirmed.":t==="redirecting"?"Opening the secure account sign-in now.":"Your saved shifts will appear only after your account is confirmed.";return e.jsxs("div",{className:"min-h-screen bg-white text-zinc-900",children:[e.jsx(js,{email:null,isAuthenticated:!1,onSignIn:kt,onSignOut:()=>{},guestSignInLabel:"Log in",hideMenuGuestSignIn:!0}),e.jsx("main",{className:"flex min-h-[54vh] items-center justify-center px-5 py-12",children:e.jsxs("div",{className:"w-full max-w-[460px] rounded-[24px] border border-zinc-200 bg-white p-7 text-center shadow-[0_16px_44px_rgba(24,24,27,0.07)] sm:p-9",children:[e.jsx("div",{className:"mx-auto flex h-14 w-14 items-center justify-center rounded-[18px] bg-[#FFF1E8] text-[#F45815]",children:r?e.jsx(Ne,{className:"h-6 w-6"}):e.jsx(X,{className:"h-6 w-6 animate-spin"})}),e.jsxs("p",{className:"mt-5 text-[10px] font-black uppercase tracking-[0.2em] text-[#B9380B]",children:[e.jsx(Us,{className:"text-[0.9em]"})," member area"]}),e.jsx("h1",{className:"mt-2 text-[24px] font-black tracking-tight text-zinc-950",children:a}),e.jsx("p",{className:"mt-3 text-[13px] leading-relaxed text-zinc-600",children:n}),r&&e.jsxs("a",{href:s,target:"_top","aria-label":"Log in to Driver Profit Suite",className:"mt-6 inline-flex min-h-[48px] w-full items-center justify-center gap-2 rounded-[13px] bg-[#F45815] px-5 text-[14px] font-black text-white transition hover:bg-[#E94E0E] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#F45815] focus-visible:ring-offset-2",children:["Log in to Driver Profit Suite ",e.jsx(q,{className:"h-4 w-4"})]})]})}),e.jsx(Ns,{accountEmail:null,isAuthenticated:!1})]})}function Qa(){const t=Pe(),[s,r]=l.useState("checking"),[a,n]=l.useState(null),[i,d]=l.useState([]),[c,m]=l.useState(0),[o,k]=l.useState(null),[N,p]=l.useState(!1),[u,j]=l.useState(null),[w,z]=l.useState(null),[f,C]=l.useState("checking"),[h,$]=l.useState(null),_=l.useCallback(()=>{try{kt()}catch(T){console.error("Could not redirect to RSG login:",T),r("blocked")}},[]);l.useEffect(()=>{let T=!0;return(async()=>{try{const B=await yt.me();if(!(B!=null&&B.id))throw new Error("Authenticated user id missing");T&&(n({id:String(B.id),email:B.email||null}),r("authenticated"))}catch{T&&(r("redirecting"),_())}})(),()=>{T=!1}},[_]);const g=l.useCallback(async()=>{r("blocked"),n(null),d([]),m(0),k(null),p(!1),j(null),z(null),C("checking"),$(null);try{await yt.logout()}catch(T){console.error("Could not log out of Driver Profit Suite:",T)}},[]),v=l.useCallback(async T=>{p(!0),j(null),z(null),C("checking"),$(null);const[B,K,R]=await Promise.allSettled([fs(T),Is.filter({user_id:T},"-created_at",10),Ps.filter({userId:T},"-created_at",20)]);if(B.status==="fulfilled"?d(Ta(B.value||[])):(console.error("Failed to load DriverShift records:",B.reason),d([]),j("We could not load your saved shifts. Try again before logging a new shift.")),K.status==="fulfilled"){const O=K.value||[];k(O[0]||{user_id:T,operating_cost_per_mile:hs})}else console.error("Failed to load DriverCostSettings records:",K.reason),k(null),z("We could not load your saved vehicle-cost setting. Try again before saving a shift.");if(R.status==="fulfilled"&&Array.isArray(R.value))C(Aa(R.value,T)?"unlocked":"locked");else{const O=R.status==="rejected"?R.reason:new Error("Purchase access response was not a list");console.error("Failed to check Founding Unlock entitlement:",O),C("error"),$("We could not confirm your Founding Unlock right now. Try again to check access. Your free tools remain available.")}p(!1)},[]);l.useEffect(()=>{s==="authenticated"&&(a!=null&&a.id)&&v(a.id)},[s,v,a==null?void 0:a.id]);
14const F=e.jsx(Gs,{title:"Driver Profit Suite | RideShareGuides",description:"Free RSG member tools for South Florida drivers, plus account-owned CSV export within current history limits for Founding Unlock holders.",url:"https://rideshareguides.com/profit-suite",noindex:!0});if(s!=="authenticated"||!a)return e.jsxs(e.Fragment,{children:[F,e.jsx(Da,{state:s})]});const L=t?{}:{initial:{opacity:0,y:14},animate:{opacity:1,y:0},transition:{duration:.55,ease:[.22,1,.36,1]}},S=()=>void v(a.id),Q=Number.isFinite(Number(o==null?void 0:o.operating_cost_per_mile))&&Number(o==null?void 0:o.operating_cost_per_mile)>=0?Number(o==null?void 0:o.operating_cost_per_mile):hs,M=i.length>0||c>0,H=i.length+c;return e.jsxs("div",{className:"min-h-screen w-full overflow-x-hidden bg-white text-zinc-900 selection:bg-[#F45815] selection:text-white",children:[F,e.jsx(js,{email:a.email||null,isAuthenticated:s==="authenticated",onSignIn:kt,onSignOut:g,guestSignInLabel:"Log in",hideMenuGuestSignIn:!0}),e.jsx("div",{className:"border-b border-zinc-100 bg-white",children:e.jsx("div",{className:"mx-auto flex max-w-[1180px] justify-end px-5 py-3 sm:px-7 lg:px-10",children:e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full border border-[#B9E4E1] bg-[#F2FBFA] px-3 py-1.5 text-[10px] font-black uppercase tracking-[0.12em] text-[#0F7774]",children:[e.jsx(Ne,{className:"h-3.5 w-3.5"})," Private member area"]})})}),e.jsxs("main",{className:"mx-auto max-w-[1180px] px-5 pb-16 pt-6 sm:px-7 sm:pb-24 sm:pt-9 lg:px-10",children:[e.jsx(Ys,{wrapperClassName:"mb-7 sm:mb-10"}),e.jsxs(be.section,{...L,className:"grid gap-8 lg:grid-cols-[1.08fr_0.92fr] lg:items-center lg:gap-14",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full border border-[#F45815]/20 bg-[#FFF1E8] px-3 py-1.5 text-[10px] font-black uppercase tracking-[0.16em] text-[#B9380B]",children:[e.jsx(Tt,{className:"h-3.5 w-3.5"})," Free tools, then the full picture"]}),e.jsx("h1",{className:"mt-5 max-w-[12ch] font-['Poppins',sans-serif] text-[40px] font-black leading-[0.94] tracking-[-0.05em] text-zinc-950 sm:text-[58px]",children:"See what your shift produced after costs."}),e.jsx("p",{className:"mt-5 max-w-[56ch] text-[14px] leading-[1.75] text-zinc-600 sm:text-[16px]",children:"Use three free tools with your signed-in RSG account to record one shift, compare your own work patterns, and log gas and mileage. After that first real record is saved, the $11 one-time Founding Unlock brings your account-owned records into a complete profit picture over time within the current account-history read limits, adds account-owned CSV export, seasonal organization, and Founding Driver status. No recurring charge."}),e.jsxs("div",{className:"mt-6 flex flex-wrap gap-2",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full border border-[#B9E4E1] bg-[#F2FBFA] px-3 py-1.5 text-[10px] font-black uppercase tracking-[0.16em] text-[#0F7774]",children:[e.jsx(Xe,{className:"h-3.5 w-3.5"})," South Florida tri-market"]}),e.jsx("span",{className:"rounded-full border border-zinc-200 bg-white px-3 py-1.5 text-[10px] font-bold text-zinc-600",children:"Palm Beach · Fort Lauderdale · Miami"})]})]}),e.jsxs("aside",{className:"relative overflow-hidden rounded-[24px] border border-zinc-200 bg-white p-5 shadow-[0_14px_36px_rgba(15,139,136,0.08)] sm:p-6",children:[e.jsx("div",{className:"pointer-events-none absolute -right-14 -top-16 h-44 w-44 rounded-full bg-[#B9E4E1]/40 blur-3xl"}),e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.18em] text-[#0F7774]",children:"Suite path"}),e.jsx("h2",{className:"mt-1 text-[21px] font-black tracking-tight text-zinc-950",children:"Start with one real record."})]}),e.jsx("span",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-[#FFF1E8] text-[#F45815]",children:e.jsx(We,{className:"h-5 w-5"})})]}),e.jsxs("div",{className:"mt-6 space-y-3",children:[e.jsxs("a",{href:"#real-pay-meter","aria-label":"Open the Real Pay Meter tool",className:"group flex items-center gap-3 rounded-[14px] border border-[#F8C9B9] bg-[#FFF8F3] p-3 text-left transition duration-200 hover:-translate-y-0.5 hover:border-[#F45815] hover:bg-[#FFF1E8] hover:shadow-[0_8px_18px_rgba(244,88,21,0.12)] focu
14s-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#F45815] focus-visible:ring-offset-2",children:[e.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-[#F45815] text-white",children:e.jsx(We,{className:"h-4 w-4","aria-hidden":"true"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-[13px] font-black text-zinc-950",children:"Real Pay Meter"}),e.jsx("p",{className:"text-[11px] text-[#B9380B]",children:"Free with sign-in · start here"})]}),e.jsx("span",{"aria-hidden":"true",className:"ml-auto flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-[#B9380B] transition-transform duration-200 group-hover:translate-x-0.5 group-focus-visible:translate-x-0.5",children:e.jsx(q,{className:"h-4 w-4"})})]}),e.jsxs("a",{href:"#best-shift-finder","aria-label":"Open the Best-Shift Finder tool",className:"group flex items-center gap-3 rounded-[14px] border border-[#B8DAF5] bg-[#F4FAFF] p-3 text-left transition duration-200 hover:-translate-y-0.5 hover:border-[#3D9BE9] hover:bg-[#EAF5FE] hover:shadow-[0_8px_18px_rgba(61,155,233,0.12)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#3D9BE9] focus-visible:ring-offset-2",children:[e.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-[#3D9BE9] text-white",children:e.jsx(Je,{className:"h-4 w-4","aria-hidden":"true"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-[13px] font-black text-zinc-950",children:"Best-Shift Finder"}),e.jsx("p",{className:"text-[11px] text-[#1C6AA8]",children:"Free with sign-in · compare patterns"})]}),e.jsx("span",{"aria-hidden":"true",className:"ml-auto flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-[#1C6AA8] transition-transform duration-200 group-hover:translate-x-0.5 group-focus-visible:translate-x-0.5",children:e.jsx(q,{className:"h-4 w-4"})})]}),e.jsxs("a",{href:"#gas-mileage-log-section","aria-label":"Open the Gas and Mileage Log tool",className:"group flex items-center gap-3 rounded-[14px] border border-[#B9E4E1] bg-[#F2FBFA] p-3 text-left transition duration-200 hover:-translate-y-0.5 hover:border-[#0F7774] hover:bg-[#E5F6F4] hover:shadow-[0_8px_18px_rgba(15,119,116,0.12)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#0F7774] focus-visible:ring-offset-2",children:[e.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-[#0F7774] text-white",children:e.jsx(fe,{className:"h-4 w-4","aria-hidden":"true"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-[13px] font-black text-zinc-950",children:"Gas & Mileage Log"}),e.jsx("p",{className:"text-[11px] text-[#0F7774]",children:"Free with sign-in · track costs"})]}),e.jsx("span",{"aria-hidden":"true",className:"ml-auto flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-[#0F7774] transition-transform duration-200 group-hover:translate-x-0.5 group-focus-visible:translate-x-0.5",children:e.jsx(q,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"mt-4 flex items-start gap-2 rounded-[13px] border border-[#F8C9B9] bg-[#FFF8F3] px-3 py-2.5",children:[e.jsx(Ne,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-[#F45815]"}),e.jsx("p",{className:"text-[11px] font-bold leading-relaxed text-zinc-700",children:"After your first real record, unlock the full profit picture for $11 once."})]})]})]})]}),e.jsxs("section",{id:"access-ladder","aria-labelledby":"access-ladder-title",className:"mt-12 overflow-hidden rounded-[24px] border border-zinc-200 bg-[#FFFCF9] p-5 shadow-[0_14px_36px_rgba(24,24,27,0.05)] sm:mt-16 sm:p-7",children:[e.jsxs("div",{className:"flex flex-col gap-4 border-b border-zinc-200 pb-5 sm:flex-row sm:items-end sm:justify-between",children:[e.jsxs("div",{className:"max-w-[700px]",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.18em] text-[#B9380B]",children:"How the value builds"}),e.jsx("h2",{id:"access-ladder-title",className:"mt-2 text-[28px] font-black leading-[1.02] tracking-[-0.04em] text-zinc-950 sm:text-[38px]",children:"Use the free tools first. Then own the full picture."}),e.jsx("p",{className:"mt-3 text-[13px] leading-relaxed text-zinc-600",children:"The free tools answer what happened on one shift. The one-time $11 Founding Unlock organizes your history over time within the current account-history read limits, gives you an account-owned file you can keep, and adds your account-tied foun
14ding status. No recurring charge."})]}),e.jsx("span",{className:"inline-flex w-fit items-center rounded-full border border-[#F8C9B9] bg-[#FFF8F3] px-3 py-1.5 text-[10px] font-black uppercase tracking-[0.14em] text-[#B9380B]",children:"Free first · unlock next"})]}),e.jsxs("div",{className:"mt-5 grid gap-4 lg:grid-cols-2",children:[e.jsxs("article",{className:"rounded-[19px] border border-[#B9E4E1] bg-white p-5 shadow-[0_8px_24px_rgba(15,139,136,0.06)] sm:p-6",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.16em] text-[#0F7774]",children:"Step 1 · Free access"}),e.jsx("h3",{className:"mt-2 text-[22px] font-black tracking-tight text-zinc-950",children:"Build your real record"})]}),e.jsx("span",{className:"rounded-full bg-[#0F7774] px-3 py-1.5 text-[13px] font-black text-white",children:"$0"})]}),e.jsx("p",{className:"mt-4 text-[13px] leading-relaxed text-zinc-600",children:"Sign in and use all three Driver Profit Suite tools at no cost. Start with a shift you worked or a fuel record you can verify."}),e.jsxs("ul",{className:"mt-5 space-y-2.5 text-[13px] font-semibold text-zinc-800",children:[e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(te,{className:"h-4 w-4 shrink-0 text-[#F45815]"})," Real Pay Meter"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(te,{className:"h-4 w-4 shrink-0 text-[#3D9BE9]"})," Best-Shift Finder"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(te,{className:"h-4 w-4 shrink-0 text-[#0F7774]"})," Gas & Mileage Log"]})]}),e.jsxs("a",{href:"#real-pay-meter",className:"mt-6 inline-flex min-h-[44px] items-center gap-2 rounded-full border border-[#0F7774]/30 bg-[#F2FBFA] px-4 py-2.5 text-[12px] font-black text-[#0F7774] transition hover:border-[#0F7774] hover:bg-[#E5F6F4] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#0F7774]/35 focus-visible:ring-offset-2",children:["Log your first shift ",e.jsx(q,{className:"h-3.5 w-3.5"})]})]}),e.jsxs("article",{className:"rounded-[19px] border border-[#F45815]/30 bg-[#FFF8F3] p-5 shadow-[0_8px_24px_rgba(244,88,21,0.08)] sm:p-6",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.16em] text-[#B9380B]",children:"Step 2 · One-time upgrade"}),e.jsx("h3",{className:"mt-2 text-[22px] font-black tracking-tight text-zinc-950",children:"Unlock the complete record"})]}),e.jsx("span",{className:"rounded-full bg-[#F45815] px-3 py-1.5 text-[13px] font-black text-white",children:"$11 once"})]}),e.jsx("p",{className:"mt-4 text-[13px] leading-relaxed text-zinc-600",children:"Once your first real record is saved, pay $11 once to connect and organize your account-owned history within the current account-history read limits. The free tools stay free while the paid layer adds the full picture and no recurring charge."}),e.jsxs("ul",{className:"mt-5 space-y-2.5 text-[13px] font-semibold text-zinc-800",children:[e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx(te,{className:"mt-0.5 h-4 w-4 shrink-0 text-[#F45815]"})," ",e.jsx("span",{children:"Combined Profit Dashboard"})]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx(te,{className:"mt-0.5 h-4 w-4 shrink-0 text-[#F45815]"})," ",e.jsx("span",{children:"Account-owned CSV export within current history limits"})]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx(te,{className:"mt-0.5 h-4 w-4 shrink-0 text-[#F45815]"})," ",e.jsxs("span",{children:["Seasonal Q4 organization layer when active ",e.jsx("span",{className:"font-normal text-zinc-500",children:"(currently upcoming)"})]})]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx(te,{className:"mt-0.5 h-4 w-4 shrink-0 text-[#F45815]"})," ",e.jsx("span",{children:"Founding Driver status and badge in the private suite"})]})]}),f==="unlocked"?e.jsxs("div",{role:"status",className:"mt-6 rounded-[14px] border border-[#0F7774]/25 bg-[#F2FBFA] p-4",children:[e.jsxs("p",{className:"flex items-center gap-2 text-[13px] font-black text-[#0F7774]",children:[e.jsx(te,{className:"h-4 w-4"})," Founding Unlock active"]}),e.jsx("p",{className:"mt-1 text-[12px] leading-relaxed text-zinc-600",children:"Verified on this signed-in account. No second purchase is needed."}),e.jsxs("a",{href:"#paid-layer",className:"mt-3 inline-flex min-h-[40px] items-center gap-1.5 rounded-full border border-[#0F7774]/30 bg-white px-3.5 py-2 text-[11px] font-black text-[#0F7774] transition hover:border-[#0F7774] hover:bg-[#
14E5F6F4] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#0F7774]/35 focus-visible:ring-offset-2",children:["Open the paid layer ",e.jsx(q,{className:"h-3.5 w-3.5"})]})]}):f==="checking"?e.jsxs("div",{role:"status",className:"mt-6 flex items-center gap-2 rounded-[14px] border border-zinc-200 bg-white p-4 text-[12px] font-semibold text-zinc-600",children:[e.jsx(X,{className:"h-4 w-4 animate-spin text-[#F45815]"})," Checking your Founding Unlock status."]}):f==="error"?e.jsxs("div",{role:"alert",className:"mt-6 rounded-[14px] border border-amber-200 bg-amber-50 p-4",children:[e.jsx("p",{className:"text-[12px] font-bold text-amber-950",children:"We could not confirm your Founding Unlock yet."}),e.jsx("p",{className:"mt-1 text-[12px] leading-relaxed text-amber-900",children:"Your free tools remain available. Check access again before purchasing."}),e.jsxs("button",{type:"button",onClick:S,className:"mt-3 inline-flex min-h-[40px] items-center gap-1.5 rounded-full border border-amber-300 bg-white px-3.5 py-2 text-[11px] font-black text-amber-950 hover:bg-amber-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-500/40 focus-visible:ring-offset-2",children:[e.jsx(ue,{className:"h-3.5 w-3.5"})," Check again"]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(et,{to:"/starter-kit",className:"mt-6 inline-flex min-h-[50px] w-full items-center justify-center gap-2 rounded-[13px] bg-[#F45815] px-5 py-3 text-center text-[13px] font-black text-white shadow-[0_12px_24px_rgba(244,88,21,0.18)] transition hover:-translate-y-0.5 hover:bg-[#E94E0E] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#F45815] focus-visible:ring-offset-2",children:["Unlock the full picture for $11 once ",e.jsx(q,{className:"h-4 w-4"})]}),e.jsx("p",{className:"mt-2 text-[11px] leading-relaxed text-zinc-500",children:"Your purchase stays tied to this signed-in RSG account."})]})]})]})]}),w&&e.jsxs("div",{role:"alert",className:"mt-8 flex flex-wrap items-center justify-between gap-3 rounded-[14px] border border-amber-200 bg-amber-50 px-4 py-3 text-[12px] font-semibold leading-relaxed text-amber-950",children:[e.jsxs("span",{className:"flex items-start gap-2",children:[e.jsx(ue,{className:"mt-0.5 h-4 w-4 shrink-0"}),w]}),e.jsxs("button",{type:"button",onClick:S,className:"inline-flex min-h-[38px] items-center gap-1.5 rounded-full border border-amber-300 bg-white px-3 py-1.5 text-[11px] font-black text-amber-950 hover:bg-amber-100",children:[e.jsx(ue,{className:"h-3.5 w-3.5"})," Try again"]})]}),e.jsx("nav",{"aria-label":"Driver Profit Suite tools",className:"sticky top-[68px] z-30 mb-5 rounded-[16px] border border-zinc-200 bg-white/95 p-2 shadow-[0_10px_28px_rgba(24,24,27,0.08)] backdrop-blur sm:top-[76px] sm:mb-7",children:e.jsxs("div",{className:"flex items-center gap-2 overflow-x-auto px-1 pb-1 sm:pb-0",children:[e.jsx("span",{className:"shrink-0 px-2 text-[10px] font-black uppercase tracking-[0.16em] text-zinc-500",children:"Jump to a tool"}),e.jsxs("a",{href:"#real-pay-meter",className:"inline-flex min-h-[46px] shrink-0 items-center gap-2 rounded-[12px] border border-[#F8C9B9] bg-[#FFF8F3] px-3.5 py-2 text-[11px] font-black text-[#B9380B] transition hover:border-[#F45815] hover:bg-[#FFF1E8] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#F45815]/40 focus-visible:ring-offset-2",children:[e.jsx(We,{className:"h-4 w-4","aria-hidden":"true"})," Tool 1 · Real Pay Meter"]}),e.jsxs("a",{href:"#best-shift-finder",className:"inline-flex min-h-[46px] shrink-0 items-center gap-2 rounded-[12px] border border-[#B8DAF5] bg-[#F4FAFF] px-3.5 py-2 text-[11px] font-black text-[#1C6AA8] transition hover:border-[#3D9BE9] hover:bg-[#EAF5FE] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#3D9BE9]/40 focus-visible:ring-offset-2",children:[e.jsx(Je,{className:"h-4 w-4","aria-hidden":"true"})," Tool 2 · Best-Shift Finder"]}),e.jsxs("a",{href:"#gas-mileage-log-section",className:"inline-flex min-h-[46px] shrink-0 items-center gap-2 rounded-[12px] border border-[#B9E4E1] bg-[#F2FBFA] px-3.5 py-2 text-[11px] font-black text-[#0F7774] transition hover:border-[#0F7774] hover:bg-[#
14E5F6F4] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#0F7774]/40 focus-visible:ring-offset-2",children:[e.jsx(fe,{className:"h-4 w-4","aria-hidden":"true"})," Tool 3 · Gas & Mileage"]})]})}),e.jsxs("section",{id:"real-pay-meter",className:"mt-14 scroll-mt-36 border-t-4 border-[#F45815] pt-5 sm:mt-20 sm:pt-6","aria-labelledby":"real-pay-meter-section-title",children:[e.jsxs("div",{className:"mb-6 rounded-[18px] border border-[#F8C9B9] bg-[#FFF8F3] p-4 sm:p-5",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-[14px] bg-[#F45815] text-white shadow-[0_8px_20px_rgba(244,88,21,0.2)]",children:e.jsx(We,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.18em] text-[#B9380B]",children:"Free tool 01 · RSG orange/coral"}),e.jsx("h2",{id:"real-pay-meter-section-title",className:"mt-2 text-[30px] font-black leading-none tracking-[-0.04em] text-zinc-950 sm:text-[40px]",children:"See the shift after costs."}),e.jsx("p",{className:"mt-2 max-w-[58ch] text-[13px] leading-relaxed text-zinc-600",children:"Start with the one number your own shift can verify: what remains after recorded fuel and the vehicle-cost reserve."})]})]}),e.jsx("span",{className:"inline-flex items-center rounded-full border border-[#F8C9B9] bg-white px-3 py-1.5 text-[10px] font-black uppercase tracking-[0.12em] text-[#B9380B]",children:"Free with sign-in"})]}),e.jsx("p",{className:"mt-4 border-t border-[#F8C9B9] pt-3 text-[12px] leading-relaxed text-zinc-600",children:"Real history only. No example earnings, no guarantees, and no money moves through this tool."})]}),e.jsx(kr,{userId:a.id,history:i,costSettings:o,loadingHistory:N,historyError:u,onHistoryChange:d,onRetry:S})]}),M&&f==="locked"&&e.jsxs(be.aside,{...L,"aria-labelledby":"post-save-upgrade-title",className:"mt-6 rounded-[22px] border border-[#F45815]/35 bg-[#FFF8F3] p-5 shadow-[0_14px_34px_rgba(244,88,21,0.1)] sm:p-7",children:[e.jsxs("div",{className:"flex flex-col gap-5 lg:flex-row lg:items-start lg:justify-between",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-[14px] bg-[#F45815] text-white shadow-[0_10px_22px_rgba(244,88,21,0.2)]",children:e.jsx(Tt,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.18em] text-[#B9380B]",children:"Your free result is ready"}),e.jsx("h2",{id:"post-save-upgrade-title",className:"mt-2 text-[25px] font-black leading-[1.02] tracking-[-0.035em] text-zinc-950 sm:text-[32px]",children:"You have a real record. Now see the full picture."}),e.jsx("p",{className:"mt-3 max-w-[66ch] text-[13px] leading-relaxed text-zinc-700",children:"Your first real record gives you a cost or shift result you can verify. The $11 one-time Founding Unlock brings your account’s shift and gas records into one organized view within the current account-history read limits, with account-owned CSV export, seasonal organization, and Founding Driver status. The three free tools stay free."})]})]}),e.jsxs("div",{className:"shrink-0 rounded-[16px] border border-[#F8C9B9] bg-white px-4 py-3 lg:min-w-[160px]",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.14em] text-[#B9380B]",children:"On this account"}),e.jsxs("p",{className:"mt-1 text-[20px] font-black text-zinc-950",children:[H," saved ",H===1?"record":"records"]}),e.jsxs("p",{className:"mt-1 text-[11px] text-zinc-500",children:[i.length," shift",i.length===1?"":"s"," · ",c," gas/mileage entr",c===1?"y":"ies"]}),e.jsx("p",{className:"mt-1 text-[11px] text-zinc-500",children:"Real history only"})]})]}),e.jsxs("div",{className:"mt-5 flex flex-col gap-3 border-t border-[#F8C9B9] pt-5 sm:flex-row sm:items-center sm:justify-between",children:[e.jsx("p",{className:"text-[11px] font-semibold text-zinc-600",children:"One payment. No recurring charge. Your access stays tied to this account."}),e.jsxs(et,{to:"/starter-kit",className:"inline-flex min-h-[50px] w-full items-center justify-center gap-2 rounded-[13px] bg-[#F45815] px-5 py-3 text-center text-[13px] font-black text-white shadow-[0_12px_24px_rgba(244,88,21,0.2)] transition hover:-translate-y-0.5 hover:bg-[#
14E94E0E] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#F45815] focus-visible:ring-offset-2 sm:w-auto",children:["Unlock My Full Profit Picture for $11 once ",e.jsx(q,{className:"h-4 w-4"})]})]})]}),e.jsxs("section",{id:"best-shift-finder",className:"mt-14 scroll-mt-36 border-t-4 border-[#3D9BE9] pt-5 sm:mt-20 sm:pt-6","aria-labelledby":"best-shift-finder-section-title",children:[e.jsxs("div",{className:"mb-6 rounded-[18px] border border-[#B8DAF5] bg-[#F4FAFF] p-4 sm:p-5",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-[14px] bg-[#3D9BE9] text-white shadow-[0_8px_20px_rgba(61,155,233,0.2)]",children:e.jsx(Je,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.18em] text-[#1C6AA8]",children:"Free tool 02 · RSG blue"}),e.jsx("h2",{id:"best-shift-finder-section-title",className:"mt-2 text-[30px] font-black leading-none tracking-[-0.04em] text-zinc-950 sm:text-[40px]",children:"Read the patterns in your own shifts."}),e.jsx("p",{className:"mt-2 max-w-[58ch] text-[13px] leading-relaxed text-zinc-600",children:"Compare the work windows and zones attached to your real saved shifts. One record starts the picture, more records make the comparison more useful."})]})]}),e.jsx("span",{className:"inline-flex items-center rounded-full border border-[#B8DAF5] bg-white px-3 py-1.5 text-[10px] font-black uppercase tracking-[0.12em] text-[#1C6AA8]",children:"Free with sign-in"})]}),e.jsx("p",{className:"mt-4 border-t border-[#B8DAF5] pt-3 text-[12px] leading-relaxed text-zinc-600",children:"Strongest observed results only. A single shift is an early signal, not a proven pattern."})]}),e.jsx(Ir,{userId:a.id,history:i,costSettings:o,loadingHistory:N,historyError:u,onHistoryChange:d,onRetry:S})]}),e.jsxs("section",{id:"gas-mileage-log-section",className:"mt-14 scroll-mt-36 border-t-4 border-[#0F7774] pt-5 sm:mt-20 sm:pt-6","aria-labelledby":"gas-mileage-log-section-title",children:[e.jsxs("div",{className:"mb-6 rounded-[18px] border border-[#B9E4E1] bg-[#F2FBFA] p-4 sm:p-5",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-[14px] bg-[#0F7774] text-white shadow-[0_8px_20px_rgba(15,119,116,0.2)]",children:e.jsx(fe,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.18em] text-[#0F7774]",children:"Free tool 03 · suite teal"}),e.jsx("h2",{id:"gas-mileage-log-section-title",className:"mt-2 text-[30px] font-black leading-none tracking-[-0.04em] text-zinc-950 sm:text-[40px]",children:"Organize every mile and fuel payment."}),e.jsx("p",{className:"mt-2 max-w-[58ch] text-[13px] leading-relaxed text-zinc-600",children:"Keep vehicle costs in a separate account-owned record so your shift result and your running cost picture stay easy to understand."})]})]}),e.jsx("span",{className:"inline-flex items-center rounded-full border border-[#B9E4E1] bg-white px-3 py-1.5 text-[10px] font-black uppercase tracking-[0.12em] text-[#0F7774]",children:"Free with sign-in"})]}),e.jsx("p",{className:"mt-4 border-t border-[#B9E4E1] pt-3 text-[12px] leading-relaxed text-zinc-600",children:"Available now for signed-in members. Use your own records to build a careful running-cost and seasonal starting point."})]}),e.jsx(aa,{userId:a.id,costSettings:o,onLoadedEntryCountChange:m})]}),e.jsx("section",{id:"paid-layer",className:"mt-14 scroll-mt-28 border-t border-zinc-200 pt-10 sm:mt-20 sm:pt-14","aria-labelledby":"paid-layer-title",children:e.jsxs("div",{className:"rounded-[22px] border border-[#F45815]/30 bg-[#FFF8F3] p-5 shadow-[0_14px_34px_rgba(244,88,21,0.08)] sm:p-7",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-[14px] bg-[#F45815] text-white shadow-[0_10px_22px_rgba(244,88,21,0.2)]",children:e.jsx(Ne,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.18em] text-[#B9380B]",children:"Founding Unlock · one-time $11"}),e.jsx("h2",{id:"paid-layer-title",className:"mt-2 text-[28px] font-black leading-[1.02] tracking-[-0.04em] text-zinc-950 sm:text-[40px]",children:"Turn separate records into your full profit picture."}),e.jsx("p",{className:"mt-3 max-w-[72ch] text-[13px] leading-relaxed text-zinc-700",children:f==="unlocked"?"Your verified Founding Unlock is active. The four sections below organize the real records you keep in this account.":"The four sections below are what the one-time $11 Founding Unlock opens. Your free tools remain available above, while this paid layer brings your history together within the current account-history read limits, gives you an account-owned CSV file you can keep, organizes Q4, and adds your founding status."})]})]}),e.jsxs("div",{className:"mt-5 flex flex-wrap gap-2 border-t border-[#F8C9B9] pt-4 text-[10px] font-black uppercase tracking-[0.1em] text-[#B9380B]",children:[e.jsx("span",{className:"rounded-full border border-[#F8C9B9] bg-white px-3 py-1.5",children:"Combined dashboard"}),e.jsx("span",{className:"rounded-full border border-[#F8C9B9] bg-white px-3 py-1.5",children:"Account-owned CSV"}),e.jsx("span",{className:"rounded-full border border-[#F8C9B9] bg-white px-3 py-1.5",children:"Seasonal organization"}),e.jsx("span",{className:"rounded-full border border-[#F8C9B9] bg-white px-3 py-1.5",children:"Founding status"})]})]})}),e.jsx(ya,{userId:a.id,unlocked:f==="unlocked",checkingEntitlement:f==="checking",entitlementError:f==="error"?h:null,operatingCostPerMile:Q,onRetryEntitlement:S}),e.jsx(Ca,{userId:a.id,unlocked:f==="unlocked",checkingEntitlement:f==="checking",entitlementError:f==="error"?h:null,operatingCostPerMile:Q,onRetryEntitlement:S}),e.jsx(Ba,{unlocked:f==="unlocked",checkingEntitlement:f==="checking",entitlementError:f==="error"?h:null,onRetryEntitlement:S}),e.jsx(da,{userId:a.id,shifts:i,unlocked:f==="unlocked",checkingEntitlement:f==="checking",entitlementError:f==="error"?h:null,operatingCostPerMile:Q,onRetryEntitlement:S})]}),e.jsx(Ns,{accountEmail:a.email||null,isAuthenticated:!!a,onLogout:g})]})}
14export{Qa 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.