1import{j as e}from"./vendor-radix-Cshc0K_j.js";import{r as d,h as Qe,i as He,L as _s,u as Ps}from"./vendor-react-CfDhItdx.js";import{P as Ms}from"./jobsDemoSteps-BvZiyif1.js";import{OpportunitiesHub as Ts}from"./OpportunitiesHub-GMZT_2xN.js";import{S as As,u as Rs}from"./useAIReceptionistCalls-BatFEl-p.js";import{u as qe}from"./useFeatureFlags-UWB8J8gd.js";import{S as Ds,i as Es,q as Ls,u as Fs}from"./DashboardHeader-CqP36Ugx.js";import{u as Os}from"./useProductUpdates-CifJWj0o.js";import{u as We}from"./usePublicUrl-DRA56MWW.js";import{g as Is,h as Us,r as $s,s as Ye,i as Bs,t as Je,c as Gs}from"./useQuoteEngine-B_gsSl3o.js";import{u as zs,A as Qs,a as Hs,R as Ve,b as qs,M as Ws}from"./Dashboard-SIhgf-Rk.js";import{C as Ys,u as Js}from"./CallsPreviewSection-DbDFnHH5.js";import{u as Ke}from"./useConfirmSignOut-Cmz1A9Cy.js";import{z as Vs,q as y,E as ce,A as Ks,ba as Xs,bt as Zs,ay as q,bC as et,bG as D,ap as ve,L as ne,bm as st,K as Ce,X as Ne,aB as H,j as k,a8 as tt,I as Fe,Y as z,Z as W,S as Xe,aa as de,F as me,a2 as B,s as ge,l as ae,aU as it,aL as rt,aM as at,aN as nt,az as we,C as S,c as _,aw as lt,N as xe,b9 as Ze,bb as Se,a1 as es,a9 as ot,c7 as ss,bc as ct,aA as K,g as ye,aC as dt,$ as ts,M as ue,ax as is,t as mt,B as xt,b8 as be,a5 as ut,aK as ht,ag as pt}from"./index-y9XPgVzP.js";import{L as rs}from"./log-out-B_vaD_a8.js";import{B as le}from"./briefcase-CXn8tVrB.js";import{E as ft}from"./ellipsis-BvrfBjSa.js";import{Z as ke}from"./zap-DyJiguP5.js";import{T as _e}from"./trending-up-CmRI2OHB.js";import{S as Pe}from"./settings-Bmm9B9Uo.js";import{T as gt}from"./target-BIwF5HAh.js";import{A as bt,a as jt,b as vt}from"./avatar-D04yHRt8.js";import{a as Nt}from"./vendor-query-CjzA0R3G.js";import{T as Me}from"./textarea-1B7nmw2F.js";import{n as wt,d as yt}from"./imageCompression-BB7Akwqa.js";import{M as kt}from"./map-pin-oWY4_5Yl.js";import{C as Ct}from"./usePersistMobileKnowledge-BQ84xvfR.js";import{S as St}from"./ConversationList-CjrzHh19.js";import{u as _t}from"./useAIReceptionistSettings-DgL4gaz0.js";import{u as Pt}from"./useCollections-CnSpv0hS.js";import{F as as}from"./folder-qC5xDQjX.js";import{P as ns}from"./pencil-2sCIUnmJ.js";import{T as ls}from"./trash-2-pPJcG1aT.js";import{a as Mt}from"./vendor-date-DbbbO-EH.js";import{u as Tt,c as Oe,f as os,T as At}from"./useAnalytics-oek44PZq.js";import{S as cs}from"./smartphone-C1Ycto1v.js";import{M as ds}from"./monitor-CK2c5X7G.js";import{T as Rt}from"./tablet-9IgmBUoN.js";import{A as Dt,a as Et,b as Lt,c as Ft,d as Ot,e as It,f as Ut,g as $t}from"./alert-dialog-pVEpA8iY.js";import{D as Bt,a as Gt,b as zt,c as je}from"./dropdown-menu-C_rXgXzO.js";import{I as ms}from"./image-off-BYFpcvnK.js";import{E as Qt}from"./ellipsis-vertical-CY5IXmZ5.js";import{E as Ht}from"./eye-off-CmxuW4AG.js";import{_ as qt}from"./index-wLBhUoFB.js";import{D as Wt}from"./download-Dtbe8D4b.js";import{S as oe}from"./switch-C3EItzNh.js";import{i as Yt,w as Jt,G as Vt,a as Kt}from"./googleReviewSource-j3fGQ3kf.js";import{S as Te}from"./send-BsHs60wM.js";import{m as Ie}from"./settingsSidebarState-ici2d6cJ.js";import{C as Xt,a as Zt,b as ei}from"./collapsible-D45mc-vF.js";import{f as si}from"./productUpdatesStorage-8OdlPGkB.js";import{A as ti}from"./award-BX1XPSxW.js";import{C as ii}from"./code-xml-W8gblNud.js";import{C as ri}from"./calendar-BImnbmrI.js";import{M as ai,H as ni,S as li}from"./scroll-text-ChjbklS3.js";import{P as oi}from"./phone-forwarded-BFplilfo.js";import{S as ci}from"./sliders-horizontal-BwWqRQcO.js";import{B as di}from"./bell-DDw_27yK.js";import{U as mi}from"./UpdatePrompt-BSyjvX12.js";import"./shield-check-DYG7We3h.js";import"./sortable.esm-BLLnEWRq.js";import"./grip-vertical-C9flhWNE.js";import"./chart-column-dR8bfncX.js";import"./skeleton-DlDVEZRa.js";import"./useSEOAudit-DMOoNmNK.js";import"./seoAudit-U4SR3iUM.js";import"./quoteEngineCalc-CPRQXAxH.js";import"./circle-dot-B3EOS05V.js";import"./imageOptimization-CMmNkbqD.js";import"./websiteOptIn-BpyA8Lk0.js";import"./select-BJfkvRaZ.js";import"./usePNSetupPreferences-DjRIO1Yb.js";import"./pnQueryKeys-ejWwDxYo.js";import"./sheet-DAbHbLVL.js";import"./image-plus-xdk3T8F0.js";import"./leadSources-Cy31MnbE.js";import"./useDesignWebsiteActive-DMQ3wtoh.js";import"./layout-grid-BRDOZg-b.js";
1import"./layers-DZ9LOIKk.js";import"./paintbrush-C3Zmfw4k.js";import"./type-BiSY0mU5.js";import"./settings-2-CHqFOaoM.js";import"./move-CSIkdU56.js";import"./PnActionConfirmSheet-wCKVuw8C.js";import"./PnCustomerConflictPicker-BAi9zvVW.js";import"./radio-group-CAkkkcKK.js";import"./circle-E9wjKatn.js";import"./aiReceptionistSpecialNumbers-LJLSqJjD.js";import"./reviewService-IiyrlgtE.js";import"./pagination-pMEsRdT1.js";import"./link-2-CQo-BaDs.js";import"./user-plus-BuzyO9tK.js";import"./folder-open-C7O1c6dp.js";import"./pnReconnectResume-nWQUwaV_.js";import"./usePoweredNow-DRNtKraO.js";import"./user-Y1zv3yoe.js";import"./wrench-gvzNNweX.js";import"./triangle-alert-BfBxJsqE.js";import"./outreachMatrix-DIgwposU.js";import"./initials-qGxgYIKb.js";import"./contactsJoin-BKHUfLQF.js";import"./ContactTimeline-BA6vYJCL.js";import"./CallRecordingAudio-DZkbYDq_.js";import"./useCallRecordingPlaybackUrl-BCNiu5rq.js";import"./circle-play-BnKWjtYp.js";import"./CallAnswerSummary-CRHQvMVh.js";import"./confirm-dialog-BZ_uRgQ6.js";import"./user-round-CDmJL6IL.js";import"./useProjects-DiM8V090.js";import"./pound-sterling-DGC1geTb.js";import"./arrow-up-right-B1wh3Yfb.js";import"./popover-HNgA2lJL.js";import"./maximize-2-BbPb2hTO.js";import"./list-D0znZZbZ.js";import"./useVideoStorage-BmHd6Tyg.js";import"./UpgradeDialog-Cqrc0SeP.js";import"./MediaPicker-f8tMAF5x.js";import"./useCoverImages-B8zmkfT0.js";import"./AssetUrlField-B2MzrO2x.js";import"./useUnsplashSearch-BbumZ_wJ.js";import"./useDebouncedValue-Cu9QjjwJ.js";import"./images-CuhuQg0r.js";import"./upload-Bz6JZyfA.js";import"./VideoStorageStats-Dj4sSyDT.js";import"./jobService-Cdv8Q3Az.js";import"./supabaseReorder-BsRncKMD.js";import"./earth-BeMTJ8gr.js";import"./tag-BpYMD4XK.js";import"./ShareProfileButton-_QcNIyEm.js";import"./circle-help-BnjsVtKZ.js";import"./publicLocation-CJnaXk5g.js";import"./publicQuoteService-DHaPA5Wg.js";import"./CompanyOnboardingWizard-BGFNW01A.js";import"./yourAreaRadius-CWLXXnEJ.js";import"./mobilePreviewTheme-Bq8ZpTW3.js";import"./MobilePreviewThemeToggle-Djfh7Vep.js";import"./sun-CiTIC-uN.js";import"./moon-B1aCA1eR.js";import"./config-Bpt0qT1M.js";import"./ReceptionistStepActions-C-Kv2pCs.js";import"./useTemplates-CajhEyFH.js";import"./defaultContentService-Bkvg-gtx.js";import"./vendor-forms-Cpwam5X-.js";import"./ReceptionistStepHeader-CPzPd-BT.js";import"./calculator-ECFLsEhf.js";import"./useIndustries-DTaWlm6N.js";import"./industryIcons-D0Vl068N.js";import"./tree-pine-DPUPHJl3.js";import"./hammer-ZoA9DxdI.js";import"./grid-3x3-BoIziSuM.js";import"./bug-nYjS57pO.js";import"./companyFAQs-CfL-S-0e.js";import"./useDashboardSummary-CqyPtuTJ.js";import"./sidebarShared-BzA00QJR.js";import"./separator-B7z1khrk.js";import"./book-open-DXq02PVC.js";import"./slider-CwNRCsJC.js";import"./aiReceptionistAnswerDelay-BFZAVhVM.js";import"./lock-DU37vZDd.js";import"./bell-off-Ck6otW3h.js";import"./useCheckout-CAC97zcG.js";import"./purchasePolicy-DkBR7xDt.js";import"./zod-DXHZBxbk.js";import"./alert-CKPN5GY_.js";import"./useJobs-CkSmxPwH.js";import"./useSupabaseRealtime-VCNU8XL9.js";import"./useNotifyPublishedBindings-BPRPTxhF.js";import"./useCompanyDocuments-DWa_A6X6.js";import"./queryKeys-DXnMyrEj.js";import"./pdfToImage-B8BZKv9l.js";import"./useReviews-D8fZtx9X.js";import"./insuranceDetailsSteps-d3LIEcN3.js";import"./usePendingKnowledgeGapCount-DxlzX42h.js";import"./usePNOAuthCallback-LSujQUvg.js";import"./CompanyInitials-LOuvnh7_.js";import"./useAirCustomerStatus-CrLdPlQH.js";import"./Step3ForwardingSetup-BZBwQzYK.js";import"./companionDialogChrome-BhYDsctU.js";import"./timer-C5af8n-U.js";import"./info-DZ3Hl51h.js";import"./message-circle-Y4Y21b4r.js";import"./useAIReceptionistCheckout-BjHMpncv.js";import"./credit-card-T938iPd1.js";import"./CustomHtmlManagedHoldingPage-T3lelbls.js";import"./buttonColors-Cw_YQAT3.js";import"./pen-C_ajJo11.js";import"./rich-text-editor-DlR-s7uA.js";import"./index-CdocqogG.js";import"./vendor-tiptap-CUMf5rR2.js";import"./fonts-CBZXAJnd.js";import"./pageSlugDenylist-g9-8QCpX.js";import"./extensions-CnNzwzKt.js";import"./accordion-cBKDaTkY.js";import"./italic-D_qPzxXf.js";import"./list-ordered-CA9MDYJQ.js";import"./quote-B8d_1QB0.js";import"./align-right-DSPKDMVm.js";import"./minus-RRBOl9wy.js";import"./vendor-supabase-cPZYlnRj.js";import"./vendor-charts-DiRvbK1V.js";import"./useBlogPosts-dhpjiU20.js";import"./useCustomHtmlModeActive-DDrC1HFg.js";import"./customHtmlMode-CW4dsG1N.js";import"./SectionBoundary-C6_-b6uc.js";import"./DesignWebsiteWalkthrough-BKlj88k6.js";import"./refresh-ccw-Bh4xHnmd.js";import"./InsuranceDetailsWalkthrough-HhfWZh6t.js";import"./file-check-B1fKFs_T.js";import"./clock-3-ICSd_v-N.js";import"./shield-alert-zI6l7mp7.js";import"./voicemail-CSaoJWOP.js";import"./useContactsDirectory-BquzDBGa.js";import"./geocoding-Bv0vkhcV.js";import"./CompanionConfirmDialog-CexZ2ALq.js";import"./storeIap-DRZ7I73P.js";import"./pause-DNs2U1zn.js";import"./useAIReceptionistBlocklist-BiJmd_jr.js";import"./aiReceptionistVoicemailMessage-BURA0Sxe.js";import"./circle-x-DVA3SzXz.js";import"./archive-B402ijWz.js";import"./aiReceptionistVoices-BpoiButi.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 xi=Vs("Printer",[["path",{d:"M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2",key:"143wyd"}],["path",{d:"M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6",key:"1itne7"}],["rect",{x:"6",y:"14",width:"12",height:"8",rx:"1",key:"1ue0tg"}]]);function ui({children:s,className:t,noBottomPadding:i}){return e.jsx("div",{className:y("min-h-screen bg-background","pl-[env(safe-area-inset-left)]","pr-[env(safe-area-inset-right)]",!i&&"pb-[calc(env(safe-area-inset-bottom)+6rem)]",t),style:{minHeight:"100dvh"},children:s})}function hi({companyName:s,companyLogo:t,username:i,customDomain:r,isPublished:a=!0,onSetupWebsite:n,visible:m=!0}){const c=r?`https://${r}`:i?`https://hereismywork.com/${i}`:void 0,l=e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-sm font-medium truncate max-w-[140px]",children:s}),i&&e.jsx("p",{className:"text-[10px] text-primary/70 flex items-center justify-end gap-0.5",children:a?e.jsxs(e.Fragment,{children:["View Website ",e.jsx(ce,{className:"h-2.5 w-2.5"})]}):"Set up website"})]}),e.jsxs(bt,{className:"h-10 w-10 border-2 border-primary/20 dark:border-primary/15 shadow-sm ring-1 ring-primary/10",children:[e.jsx(jt,{src:t,alt:s}),e.jsx(vt,{className:"text-xs font-semibold bg-primary/10 text-primary",children:s==null?void 0:s.slice(0,2).toUpperCase()})]})]});return e.jsx("header",{className:y("fixed top-0 left-0 right-0 z-40","ios-glass dark:ios-glass-dark","border-b border-primary/15 dark:border-primary/10","px-4 pb-2","pt-[env(safe-area-inset-top)]","shadow-[0_1px_3px_rgba(0,0,0,0.05)]","transition-transform duration-300 ease-out",!m&&"-translate-y-full"),children:e.jsxs("div",{className:"flex items-center justify-between py-1",children:[e.jsx(Ks,{size:"md",variant:"icon"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ds,{variant:"mobile"}),(t||s)&&(a&&c?e.jsx("a",{href:c,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 ios-press",children:l}):e.jsx("button",{type:"button",onClick:n,className:"flex items-center gap-2 ios-press",children:l}))]})]})})}const pi=[{id:"overview",icon:Xs,label:"Home"},{id:"jobs",icon:le,label:"Jobs"},{id:"inbox",icon:Zs,label:"Inbox"},{id:"reviews",icon:q,label:"Reviews"},{id:"more",icon:ft,label:"More"}],fi=[{id:"quotes",icon:ke,label:"Quote Engine"},{id:"insights",icon:_e,label:"Insights"},{id:"marketing",icon:et,label:"Marketing"},{id:"settings",icon:Pe,label:"Settings"}];function gi(s,t,i,r){const a=[];return t&&a.push({id:"opportunities",icon:gt,label:"Leads",badgeCount:r}),s&&a.push({id:"calls",icon:ve,label:"Calls",badgeCount:i}),[...a,...fi]}function bi({activeTab:s,onTabChange:t,fabConfig:i,jobsCount:r,reviewsCount:a,inboxCount:n,callsCount:m,leadsCount:c,showCalls:l=!1,showOpportunitiesHub:h=!1,onSignOut:u}){const[x,o]=d.useState(!1),[g,p]=d.useState(!!i),C=d.useRef(i?i.label:""),P=d.useMemo(()=>gi(l,h,m,c),[l,h,m,c]),{requestSignOut:b,dialog:v}=Ke(u??(()=>{}));d.useEffect(()=>{const N=i?i.label:"";if(N!==C.current){p(!1);const U=setTimeout(()=>{C.current=N,p(!!i)},150);return()=>clearTimeout(U)}p(!!i)},[i]);const f=P.some(N=>N.id===s),j=N=>{D("light"),N==="more"?o(!x):(o(!1),t(N))},M=()=>{D("medium"),i==null||i.onPress()},R=N=>{if(N==="jobs")return r;if(N==="reviews")return a;
6if(N==="inbox")return n};return e.jsxs(e.Fragment,{children:[x&&e.jsx("div",{className:"fixed inset-0 z-40 bg-black/30 animate-in fade-in duration-200",onClick:()=>o(!1)}),x&&e.jsx("div",{className:y("fixed bottom-[calc(env(safe-area-inset-bottom)+5rem)] left-4 right-4 z-50","bg-background rounded-2xl shadow-2xl border","animate-in slide-in-from-bottom-4 duration-200","overflow-hidden"),children:e.jsxs("div",{className:"p-2",children:[P.map(N=>{const U=N.icon,E=s===N.id,O=N.badgeCount??0;return e.jsxs("button",{onClick:()=>j(N.id),className:y("w-full flex items-center gap-3 px-4 py-3 rounded-xl","transition-all duration-200","active:scale-95",E?"bg-primary/10 text-primary":"hover:bg-muted/50"),children:[e.jsx(U,{className:y("h-5 w-5",E?"text-primary":"text-muted-foreground")}),e.jsx("span",{className:y("flex-1 text-left font-medium",E?"text-primary":"text-foreground"),children:N.label}),O>0&&e.jsx("span",{className:y("min-w-[20px] h-[20px] px-1.5","text-[11px] font-bold","bg-red-500 text-white","rounded-full flex items-center justify-center"),children:O>99?"99+":O})]},N.id)}),u&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mx-2 my-1 border-t border-border"}),e.jsxs("button",{onClick:()=>{o(!1),b()},className:y("w-full flex items-center gap-3 px-4 py-3 rounded-xl","transition-all duration-200","active:scale-95","hover:bg-muted/50 text-red-600"),children:[e.jsx(rs,{className:"h-5 w-5"}),e.jsx("span",{className:"font-medium",children:"Log Out"})]})]})]})}),e.jsxs("nav",{className:y("fixed bottom-0 left-0 right-0 z-50","pb-[calc(env(safe-area-inset-bottom)+1.5rem)]","px-4"),children:[e.jsx("div",{className:y("bg-background rounded-full shadow-lg border","flex items-center justify-around","h-14 px-2"),children:pi.map(N=>{const U=N.icon,E=N.id==="more"?f||x:s===N.id,O=R(N.id);return e.jsxs("button",{onClick:()=>j(N.id),className:y("relative flex flex-col items-center justify-center","flex-1 h-full rounded-full","transition-all duration-200","active:scale-95","px-2"),children:[E&&e.jsx("div",{className:"absolute inset-0 bg-muted/60 backdrop-blur-md rounded-full border border-border/50"}),e.jsxs("div",{className:"relative z-10",children:[e.jsx(U,{className:y("h-5 w-5 transition-colors mb-0.5",E?"text-foreground":"text-muted-foreground")}),O!==void 0&&O>0&&e.jsx("span",{className:y("absolute -top-1 -right-2","min-w-[18px] h-[18px] px-1","text-[10px] font-bold","bg-red-500 text-white","rounded-full flex items-center justify-center","border-2 border-background"),children:O>99?"99+":O})]}),e.jsx("span",{className:y("text-[11px] font-medium transition-colors relative z-10",E?"text-foreground":"text-muted-foreground"),children:N.label})]},N.id)})}),i&&g&&e.jsxs("button",{onClick:M,className:y("absolute bottom-[calc(env(safe-area-inset-bottom)+5.75rem)] right-6","w-14 h-14 rounded-full","bg-[#ffba00] text-black","flex items-center justify-center","shadow-2xl shadow-[#ffba00]/40","border-4 border-background","active:scale-90 transition-transform","z-40"),children:[e.jsx("span",{className:"sr-only",children:i.label}),e.jsx(i.icon,{className:y("h-6 w-6 transition-opacity duration-150")})]})]}),u&&v]})}function ji({children:s,onRefresh:t,className:i,onScrollDirectionChange:r}){const[a,n]=d.useState(!1),[m,c]=d.useState(!1),[l,h]=d.useState(0),u=d.useRef(0),x=d.useRef(null),o=d.useRef(0),g=8,p=80,C=120,P=j=>{var M;((M=x.current)==null?void 0:M.scrollTop)===0&&(u.current=j.touches[0].clientY,n(!0))},b=j=>{var N;if(!a||m)return;const R=j.touches[0].clientY-u.current;if(R>0&&((N=x.current)==null?void 0:N.scrollTop)===0){const U=Math.min(R*.5,C);h(U)}},v=async()=>{if(a){if(l>=p&&!m){c(!0),h(60);try{await t()}finally{c(!1)}}n(!1),h(0)}},f=Math.min(l/p,1);return e.jsxs("div",{ref:x,className:y("relative overflow-auto",i),onTouchStart:P,onTouchMove:b,onTouchEnd:v,onScroll:j=>{const M=j.currentTarget.scrollTop,R=M-o.current;Math.abs(R)>g&&(r==null||r(R>0?"down":"up"),o.current=M),M<=0&&(r==null||r("up"),o.current=0)},children:[e.jsx("div",{className:y("absolute left-1/2 -translate-x-1/2 z-10","flex items-center justify-center","transition-opacity duration-200",l>
60?"opacity-100":"opacity-0"),style:{top:Math.max(l-40,8)},children:e.jsx("div",{className:y("w-10 h-10 rounded-full bg-background shadow-lg border","flex items-center justify-center"),children:m?e.jsx(ne,{className:"h-5 w-5 animate-spin text-primary"}):e.jsx("svg",{className:"h-5 w-5 text-primary transition-transform",style:{transform:`rotate(${f*180}deg)`,opacity:f},viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M12 5v14M5 12l7-7 7 7"})})})}),e.jsx("div",{style:{transform:`translateY(${l}px)`,transition:a?"none":"transform 0.3s ease-out"},className:"pb-[calc(env(safe-area-inset-bottom)+5rem)]",children:s})]})}function vi({open:s,onClose:t,companyId:i,onJobCreated:r}){const a=Qe(),n=Nt(),{canUse:m,increment:c}=st(),[l,h]=d.useState("photos"),[u,x]=d.useState([]),[o,g]=d.useState(""),[p,C]=d.useState(""),[P,b]=d.useState(""),[v,f]=d.useState(!1),[j,M]=d.useState(!1),R=d.useRef(null),N=d.useRef(null),U=d.useRef(null),E=d.useMemo(()=>u.map(w=>URL.createObjectURL(w)),[u]);d.useEffect(()=>()=>{E.forEach(w=>URL.revokeObjectURL(w))},[E]);const O=typeof window<"u"&&/iPad|iPhone|iPod/.test(navigator.userAgent);d.useEffect(()=>{const w=window.innerHeight,T=L=>{const G=L.target;(G.tagName==="INPUT"||G.tagName==="TEXTAREA")&&(document.body.style.height=`${w}px`,document.body.style.overflow="hidden",setTimeout(()=>{G.scrollIntoView({behavior:"smooth",block:"center"})},300))},F=()=>{document.body.style.height="",document.body.style.overflow=""};return document.addEventListener("focusin",T),document.addEventListener("focusout",F),()=>{document.removeEventListener("focusin",T),document.removeEventListener("focusout",F),document.body.style.height="",document.body.style.overflow=""}},[]);const Y=d.useCallback(async w=>{const T=Array.from(w.target.files||[]);if(T.length===0)return;D("medium");const F=[];for(const L of T)if(L.type.startsWith("image/")&&wt(L))try{const G=await yt(L);F.push(G)}catch{F.push(L)}else F.push(L);x(L=>[...L,...F].slice(0,10)),w.target.value=""},[]),$=w=>{D("light"),x(T=>T.filter((F,L)=>L!==w))},I=()=>{var w;D("light"),(w=R.current)==null||w.click()},Re=()=>{if(u.length===0){B({title:"Add at least one photo",variant:"destructive"});return}D("light"),h("details")},X=()=>{D("light"),h("photos")},Z=async()=>{if(!m){t(),a("/dashboard/upgrade");return}if(!o){B({title:"Enter a title first",variant:"destructive"});return}M(!0);try{const{data:w,error:T}=await ge.functions.invoke("ai-job-description",{body:{title:o,location:P}});if(T)throw T;w!=null&&w.description&&(C(w.description),D("success"),c())}catch(w){ae.error("Failed to generate description:",w),B({title:"Failed to generate description",variant:"destructive"})}finally{M(!1)}},ee=async()=>{if(!o.trim()){B({title:"Enter a job title",variant:"destructive"});return}if(f(!0),D("medium"),!Es()){Ls({type:"create_job",payload:{company_id:i,title:o.trim(),description:p.trim()||null,location:P.trim()||null,is_published:!1,completion_date:new Date().toISOString().split("T")[0]}}),D("success"),B({title:"Queued for sync",description:"Job will be created when you're back online. You can add photos then."}),document.body.style.height="",document.body.style.overflow="",x([]),g(""),C(""),b(""),h("photos"),t(),f(!1);return}try{const{data:w,error:T}=await ge.from("jobs").insert({company_id:i,title:o.trim(),description:p.trim()||null,location:P.trim()||null,is_published:!0,completion_date:new Date().toISOString().split("T")[0]}).select().single();if(T)throw T;for(let F=0;F<u.length;F++){const L=u[F],G=L.name.split(".").pop(),pe=`${i}/${w.id}/${Date.now()}-${F}.${G}`;let se;try{se=(await it("job-media",pe,L)).publicUrl}catch(te){ae.error("Upload error:",te);continue}await ge.from("job_media").insert({job_id:w.id,media_url:se,media_type:L.type.startsWith("video")?"video":"image",display_order:F})}D("success"),B({title:"Job created!",description:"Your work has been added to your website"}),n.invalidateQueries({queryKey:["jobs"]}),document.body.style.height="",document.body.style.overflow="",x([]),g(""),C(""),b(""),h("photos"),t(),r==null||r(w.id)}catch(w){ae.error("Error creating job:",w);const T=w instanceof Error?w.message:"Failed to create job";B({title:"Failed to create job",description:T,variant:"destructive"})}finally{f(!1)}},he=()=>{document.body.style.height="",document.body.style.overflow="",x([]),g(""),C(""),b(""),h("photos"),t()};return s?e.jsxs("div",{ref:U,className:"fixed inset-0 z-[100] bg-background flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 pb-3 pt-[calc(env(safe-area-inset-top)+0.75rem)] border-b",children:[l==="details"?e.jsxs("button",{onClick:X,className:"p-2 -m-2 flex items-center gap-1 text-muted-foreground",children:[e.jsx(Ce,{className:"h-5 w-5"}),e.jsx("span",{className:"text-sm",children:"Back"})]}):e.jsx("button",{onClick:he,className:"p-2 -m-2",children:e.jsx(Ne,{className:"h-6 w-6"})}),e.jsx("h2",{className:"font-semibold",children:l==="photos"?"Add Photos":"Job Details"}),e.jsx("div",{className:"w-16"})]}),l==="photos"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex-1 overflow-auto p-4",children:[u.length===0?e.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-center",children:[e.jsx("div",{className:"w-20 h-20 rounded-full bg-primary/10 flex items-center justify-center mb-4",children:e.jsx(H,{className:"h-10 w-10 text-primary"})}),e.jsx("h3",{className:"font-semibold text-lg mb-2",children:"Capture Your Work"}),e.jsx("p",{className:"text-muted-foreground text-sm max-w-[250px]",children:"Take photos of your completed job or select from your gallery"})]}):e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[u.map((w,T)=>e.jsxs("div",{className:"relative aspect-square",children:[e.jsx("img",{src:E[T],alt:`Photo ${T+1}`,className:"w-full h-full object-cover rounded-lg"}),e.jsx("button",{onClick:()=>$(T),className:"absolute top-1 right-1 w-6 h-6 bg-black/60 rounded-full flex items-center justify-center",children:e.jsx(Ne,{className:"h-4 w-4 text-white"})}),T===0&&e.jsx("span",{className:"absolute bottom-1 left-1 text-[10px] bg-primary text-primary-foreground px-1.5 py-0.5 rounded",children:"Cover"})]},T)),u.length<10&&e.jsxs("button",{onClick:I,className:"aspect-square border-2 border-dashed border-muted-foreground
6/30 rounded-lg flex flex-col items-center justify-center text-muted-foreground hover:border-primary hover:text-primary transition-colors",children:[e.jsx(H,{className:"h-6 w-6 mb-1"}),e.jsx("span",{className:"text-xs",children:"Add More"})]})]}),u.length>0&&e.jsxs("p",{className:"text-center text-sm text-muted-foreground mt-4",children:[u.length," of 10 photos"]})]}),e.jsx("div",{className:"p-4 border-t bg-background space-y-3 pb-[calc(env(safe-area-inset-bottom)+1rem)]",children:u.length===0?e.jsxs(e.Fragment,{children:[e.jsxs(k,{onClick:I,className:"w-full h-14 text-base",size:"lg",children:[e.jsx(H,{className:"h-5 w-5 mr-2"}),"Take Photo"]}),e.jsxs(k,{onClick:()=>{var w;return(w=N.current)==null?void 0:w.click()},variant:"outline",className:"w-full h-12",children:[e.jsx(tt,{className:"h-5 w-5 mr-2"}),"Choose from Gallery"]})]}):e.jsxs("div",{className:"flex gap-3",children:[e.jsxs(k,{onClick:I,variant:"outline",className:"flex-1 h-12",children:[e.jsx(H,{className:"h-5 w-5 mr-2"}),"Add More"]}),e.jsxs(k,{onClick:Re,className:"flex-1 h-12",children:[e.jsx(Fe,{className:"h-5 w-5 mr-2"}),"Continue"]})]})})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex-1 overflow-auto p-4 space-y-4",children:[e.jsxs("div",{className:"flex gap-2 overflow-x-auto pb-2",children:[u.slice(0,5).map((w,T)=>e.jsx("img",{src:E[T],alt:"",className:"w-16 h-16 rounded-lg object-cover flex-shrink-0"},T)),u.length>5&&e.jsx("div",{className:"w-16 h-16 rounded-lg bg-muted flex items-center justify-center flex-shrink-0",children:e.jsxs("span",{className:"text-sm font-medium",children:["+",u.length-5]})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(z,{htmlFor:"title",children:"Job Title *"}),e.jsx(W,{id:"title",placeholder:"e.g., Kitchen Renovation, Bathroom Refit",value:o,onChange:w=>g(w.target.value),className:"h-12"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(z,{htmlFor:"location",children:"Location"}),e.jsxs("div",{className:"relative",children:[e.jsx(kt,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(W,{id:"location",placeholder:"e.g., London, Manchester",value:P,onChange:w=>b(w.target.value),className:"h-12 pl-10"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(z,{htmlFor:"description",children:"Description"}),m?e.jsxs(k,{type:"button",variant:"ghost",size:"sm",onClick:Z,disabled:j||!o,className:"h-7 text-xs",children:[j?e.jsx(ne,{className:"h-3 w-3 mr-1 animate-spin"}):e.jsx(Xe,{className:"h-3 w-3 mr-1"}),"AI Generate"]}):de.isNative?null:e.jsxs(k,{type:"button",variant:"default",size:"sm",onClick:Z,className:"h-7 text-xs bg-gradient-to-r from-amber-500 to-orange-500 hover:from-amber-600 hover:to-orange-600 text-white",children:[e.jsx(me,{className:"h-3 w-3 mr-1"}),"Upgrade"]})]}),e.jsx(Me,{id:"description",placeholder:"Describe the work you did...",value:p,onChange:w=>C(w.target.value),rows:4})]})]}),e.jsx("div",{className:"p-4 border-t bg-background pb-[calc(env(safe-area-inset-bottom)+1rem)]",children:e.jsx(k,{onClick:ee,disabled:v||!o.trim(),className:"w-full h-14 text-base",size:"lg",children:v?e.jsxs(e.Fragment,{children:[e.jsx(ne,{className:"h-5 w-5 mr-2 animate-spin"}),"Creating Job..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Fe,{className:"h-5 w-5 mr-2"}),"Create Job"]})})})]}),e.jsx("input",{ref:R,type:"file",accept:"image/*",...!O&&{capture:"environment"},className:"hidden",onChange:Y}),e.jsx("input",{ref:N,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:Y})]}):null}function Ni({companyId:s}){const[t]=He(),[i,r]=d.useState(null),{isEnabled:a,subscriptionState:n,hasSmsFeatures:m}=_t(),c=t.get("success")==="true"&&t.get("air_checkout")==="1",l=(c||rt(s))&&n==="none";return d.useEffect(()=>{l&&r(null)},[l]),zs(s,n==="pending"),d.useEffect(()=>{c&&at(s)},[c,s]),d.useEffect(()=>{n==="provisioned"&&nt(s)},[s,n]),e.jsxs("div",{className:"flex flex-col pb-28",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[e.jsx("h1",{className:"text-lg font-semibold text-foreground",children:"Calls"}),e.jsxs(_s,{to:"/dashboard/settings/ai-receptionist/setup",className:"flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors","aria-label":"AI Receptionist settings",children:[e.jsx(Pe,{className:"h-4 w-4"}),"Settings"]})]}),e.jsx("div",{children:l?e.jsx(Qs,{companyId:s,awaitingSubscription:l}
6):i?e.jsx(St,{initialStep:i,onClose:()=>r(null),onComplete:()=>r(null)}):a?e.jsxs(e.Fragment,{children:[e.jsx(Hs,{compact:!0}),e.jsx(Ys,{companyId:s,hasSmsFeatures:m,onSetupForwarding:()=>r("forwarding")})]}):e.jsx("div",{className:"p-4",children:e.jsx(Ct,{onContinue:()=>r("forwarding"),onCompleteProfile:()=>r("confirm_trade"),theatre:!0})})})]})}const wi=[{hex:"#ef4444",label:"Red"},{hex:"#f97316",label:"Orange"},{hex:"#eab308",label:"Yellow"},{hex:"#22c55e",label:"Green"},{hex:"#3b82f6",label:"Blue"},{hex:"#a855f7",label:"Purple"},{hex:"#ec4899",label:"Pink"},{hex:"#06b6d4",label:"Cyan"}];function Ue({initialName:s="",initialColor:t="#3b82f6",onSave:i,onCancel:r,isSaving:a}){const[n,m]=d.useState(s),[c,l]=d.useState(t);return e.jsxs("div",{className:"space-y-4",children:[e.jsx(W,{placeholder:"e.g. Kitchens, Bathroomsâ¦",value:n,onChange:h=>m(h.target.value),autoFocus:!0}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"Colour"}),e.jsx("div",{className:"flex gap-2 flex-wrap",children:wi.map(h=>e.jsx("button",{onClick:()=>l(h.hex),className:`w-8 h-8 rounded-full transition-transform ${c===h.hex?"scale-125 ring-2 ring-offset-2 ring-foreground":""}`,style:{backgroundColor:h.hex},"aria-label":h.label},h.hex))})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(k,{variant:"outline",className:"flex-1",onClick:r,children:"Cancel"}),e.jsx(k,{className:"flex-1",disabled:!n.trim()||a,onClick:()=>i(n.trim(),c),children:"Save"})]})]})}function yi({companyId:s,onBack:t}){const{collections:i,isLoading:r,createCollection:a,updateCollection:n,deleteCollection:m}=Pt(s),[c,l]=d.useState("list"),[h,u]=d.useState(null),[x,o]=d.useState(null),g=i.find(b=>b.id===h),p=(b,v)=>{a.mutate({name:b,color:v,icon:"Folder",companyId:s},{onSuccess:()=>l("list")})},C=(b,v)=>{h&&n.mutate({id:h,name:b,color:v},{onSuccess:()=>{l("list"),u(null)}})},P=b=>{D("medium"),m.mutate(b,{onSuccess:()=>o(null)})};return e.jsxs("div",{className:"p-4 space-y-4 pb-24",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:t,className:"p-1 -ml-1 text-muted-foreground",children:e.jsx(Ce,{className:"h-5 w-5"})}),e.jsx("h2",{className:"font-semibold text-base flex-1",children:"Collections"}),c==="list"&&e.jsxs(k,{size:"sm",onClick:()=>l("create"),children:[e.jsx(we,{className:"h-4 w-4 mr-1"})," New"]})]}),c==="create"&&e.jsx(S,{variant:"glass",children:e.jsxs(_,{className:"p-4",children:[e.jsx("p",{className:"font-medium text-sm mb-3",children:"New Collection"}),e.jsx(Ue,{onSave:p,onCancel:()=>l("list"),isSaving:a.isPending})]})}),c==="edit"&&g&&e.jsx(S,{variant:"glass",children:e.jsxs(_,{className:"p-4",children:[e.jsx("p",{className:"font-medium text-sm mb-3",children:"Edit Collection"}),e.jsx(Ue,{initialName:g.name,initialColor:g.color,onSave:C,onCancel:()=>{l("list"),u(null)},isSaving:n.isPending})]})}),r&&e.jsx("div",{className:"space-y-3",children:[1,2,3].map(b=>e.jsx("div",{className:"h-16 bg-muted/50 rounded-xl animate-pulse"},b))}),!r&&i.length===0&&c==="list"&&e.jsx(S,{className:"border-dashed",children:e.jsxs(_,{className:"py-8 text-center",children:[e.jsx(as,{className:"h-10 w-10 text-muted-foreground mx-auto mb-3"}),e.jsx("h3",{className:"font-semibold mb-1",children:"No collections yet"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Group your jobs into categories like Kitchens, Bathrooms, Roofingâ¦"}),e.jsxs(k,{onClick:()=>l("create"),children:[e.jsx(we,{className:"h-4 w-4 mr-1"})," Create Collection"]})]})}),i.length>0&&c==="list"&&e.jsx(S,{variant:"glass",children:e.jsx(_,{className:"p-0 divide-y",children:i.map(b=>e.jsx("div",{children:x===b.id?e.jsxs("div",{className:"p-4 space-y-2",children:[e.jsxs("p",{className:"text-sm font-medium",children:['Delete "',b.name,'"?']}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Jobs in this collection won't be deleted."}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(k,{variant:"outline",size:"sm",className:"flex-1",onClick:()=>o(null),children:"Cancel"}),e.jsx(k,{variant:"destructive",size:"sm",className:"flex-1",disabled:m.isPending,onClick:()=>
6P(b.id),children:"Delete"})]})]}):e.jsxs("div",{className:"flex items-center gap-3 p-4",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg flex items-center justify-center flex-shrink-0",style:{backgroundColor:`${b.color}20`},children:e.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:b.color}})}),e.jsx("span",{className:"flex-1 font-medium text-sm",children:b.name}),e.jsx("button",{className:"p-2 text-muted-foreground hover:text-foreground",onClick:()=>{u(b.id),l("edit")},children:e.jsx(ns,{className:"h-4 w-4"})}),e.jsx("button",{className:"p-2 text-muted-foreground hover:text-destructive",onClick:()=>{D("light"),o(b.id)},children:e.jsx(ls,{className:"h-4 w-4"})})]})},b.id))})})]})}function Ae({icon:s,title:t,description:i,action:r,className:a}){return e.jsx(S,{className:y("border-dashed",a),children:e.jsxs(_,{className:"py-12 text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-muted flex items-center justify-center mx-auto mb-4",children:s}),e.jsx("h3",{className:"font-semibold mb-2",children:t}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4 max-w-[280px] mx-auto",children:i}),r&&e.jsx(k,{onClick:r.onClick,size:"sm",className:"gap-2",children:r.label})]})})}function ki(s){return s.split(" ").slice(0,2).map(t=>t[0]).join("").toUpperCase()}const $e=[{bg:"bg-blue-500",text:"text-white"},{bg:"bg-emerald-500",text:"text-white"},{bg:"bg-violet-500",text:"text-white"},{bg:"bg-amber-500",text:"text-white"},{bg:"bg-rose-500",text:"text-white"},{bg:"bg-cyan-500",text:"text-white"},{bg:"bg-indigo-500",text:"text-white"},{bg:"bg-orange-500",text:"text-white"}];function Ci(s){let t=0;for(let i=0;i<s.length;i++)t=s.charCodeAt(i)+((t<<5)-t);return $e[Math.abs(t)%$e.length]}function Si({messages:s,onViewMessage:t,onShareWebsite:i}){const r=s.filter(n=>!n.is_read).length,a=d.useMemo(()=>[...s].sort((n,m)=>n.is_read!==m.is_read?n.is_read?1:-1:new Date(m.created_at).getTime()-new Date(n.created_at).getTime()),[s]);return e.jsxs("div",{className:"flex flex-col pb-28",children:[e.jsxs("div",{className:"space-y-4 px-4 pt-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight text-foreground",children:"Inbox"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Search and reply to messages from your website."})]}),e.jsx("div",{className:"rounded-xl border border-border bg-muted/20 px-4 py-3",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:r>0?`${r} unread message${r===1?"":"s"}`:"All caught up in your website inbox"})})]}),e.jsx("div",{className:"p-4 space-y-4",children:a.length===0?e.jsx(Ae,{icon:e.jsx(lt,{className:"h-8 w-8 text-muted-foreground"}),title:"No messages yet",description:"When visitors send a message from your website, it'll show up here. Once you've replied, the conversation stays archived for your records.",action:i?{label:"Share my website",onClick:i}:void 0}):e.jsx("div",{className:"space-y-2",children:a.map(n=>{const m=ki(n.sender_name),c=n.is_read?{bg:"bg-muted",text:"text-muted-foreground"}:Ci(n.sender_name);return e.jsx(S,{variant:"glass",className:y("cursor-pointer rounded-2xl border border-border active:scale-[0.99] transition-all",!n.is_read&&"border-l-[3px] border-l-primary bg-primary/5"),onClick:()=>t==null?void 0:t(n),children:e.jsx(_,{className:"p-3",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative flex-shrink-0",children:[e.jsx("div",{className:y("w-11 h-11 rounded-full flex items-center justify-center text-xs font-bold",c.bg,c.text),children:m}),!n.is_read&&e.jsx("div",{className:"absolute -top-0.5 -right-0.5 w-3.5 h-3.5 rounded-full bg-primary border-2 border-background"})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("p",{className:y("text-sm truncate",n.is_read?"font-medium text-foreground":"font-bold text-foreground"),children:n.sender_name}),e.jsx("span",{className:"text-[11px] text-muted-foreground flex-shrink-0",children:Mt(new Date(n.created_at),{addSuffix:!0})})]}),e.jsx("p",{className:y("text-sm truncate mt-0.5",n.is_read?"text-muted-foreground":"text-foreground
6/80"),children:n.message})]}),e.jsx(xe,{className:"h-4 w-4 text-muted-foreground/50 flex-shrink-0"})]})})},n.id)})})})]})}const _i={direct:"Direct",google:"Google",social:"Social",referral:"Referral",qr_code:"QR Code"};function re({label:s,value:t,change:i,icon:r,iconColor:a}){const n=i>=0;return e.jsx(S,{variant:"glass",children:e.jsxs(_,{className:"p-4",children:[e.jsxs("div",{className:"flex items-start justify-between mb-2",children:[e.jsx("div",{className:`w-8 h-8 rounded-lg ${a} flex items-center justify-center`,children:e.jsx(r,{className:"h-4 w-4"})}),e.jsxs("span",{className:`flex items-center gap-0.5 text-xs font-medium ${n?"text-emerald-600":"text-red-500"}`,children:[n?e.jsx(_e,{className:"h-3 w-3"}):e.jsx(At,{className:"h-3 w-3"}),Math.abs(i),"%"]})]}),e.jsx("p",{className:"text-2xl font-bold",children:os(t)}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:s})]})})}function Pi({label:s,value:t,total:i,color:r}){const a=i>0?Math.round(t/i*100):0;return e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between text-xs mb-1",children:[e.jsx("span",{className:"text-muted-foreground",children:s}),e.jsxs("span",{className:"font-medium",children:[a,"%"]})]}),e.jsx("div",{className:"h-1.5 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full ${r} rounded-full`,style:{width:`${a}%`}})})]})}function Mi({companyId:s}){var u;const{data:t,isLoading:i}=Tt(s,30);if(i)return e.jsx("div",{className:"p-4 space-y-4",children:[1,2,3].map(x=>e.jsx("div",{className:"h-24 bg-muted/50 rounded-xl animate-pulse"},x))});const r=t==null?void 0:t.current_period,a=t==null?void 0:t.previous_period;if(!r)return e.jsxs("div",{className:"p-4 flex flex-col items-center justify-center min-h-[60vh] text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-primary/10 flex items-center justify-center mb-4",children:e.jsx(_e,{className:"h-8 w-8 text-primary"})}),e.jsx("h3",{className:"font-semibold mb-2",children:"No data yet"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Share your website link to start collecting visitor insights."})]});const n=Oe(r.unique_visitors,(a==null?void 0:a.unique_visitors)??0),m=Oe(r.page_views,(a==null?void 0:a.page_views)??0),c=Object.values(r.sources).reduce((x,o)=>x+o,0),l=Object.values(r.devices).reduce((x,o)=>x+o,0),h=((u=t==null?void 0:t.top_jobs)==null?void 0:u.slice(0,3))??[];return e.jsxs("div",{className:"p-4 space-y-4 pb-24",children:[e.jsxs("div",{className:"flex items-center justify-between px-1",children:[e.jsx("h2",{className:"font-semibold text-base",children:"Insights"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Last 30 days"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(re,{label:"Unique Visitors",value:r.unique_visitors,change:n,icon:Ze,iconColor:"bg-blue-500/10 text-blue-600"}),e.jsx(re,{label:"Page Views",value:r.page_views,change:m,icon:Se,iconColor:"bg-purple-500/10 text-purple-600"}),e.jsx(re,{label:"QR Code Scans",value:r.sources.qr_code,change:0,icon:es,iconColor:"bg-amber-500/10 text-amber-600"}),e.jsx(re,{label:"Google Organic",value:r.sources.google,change:0,icon:ot,iconColor:"bg-green-500/10 text-green-600"})]}),c>0&&e.jsx(S,{variant:"glass",children:e.jsxs(_,{className:"p-4 space-y-3",children:[e.jsx("h3",{className:"font-semibold text-sm",children:"Traffic Sources"}),Object.entries(r.sources).filter(([,x])=>x>0).sort(([,x],[,o])=>o-x).map(([x,o])=>e.jsx(Pi,{label:_i[x]??x,value:o,total:c,color:"bg-primary"},x))]})}),l>0&&e.jsx(S,{variant:"glass",children:e.jsxs(_,{className:"p-4",children:[e.jsx("h3",{className:"font-semibold text-sm mb-3",children:"Devices"}),e.jsx("div",{className:"flex items-center justify-around",children:[{key:"mobile",icon:cs,label:"Mobile",color:"text-blue-600"},{key:"desktop",icon:ds,label:"Desktop",color:"text-purple-600"},{key:"tablet",icon:Rt,label:"Tablet",color:"text-amber-600"}].map(({key:x,icon:o,label:g,color:p})=>{const C=r.devices[x]??0,P=l>0?Math.round(C/l*100):0;return e.jsxs("div",{className:"flex flex-col items-center gap-1",children:[e.jsx(o,{className:`h-5 w-5 ${p}`}),e.jsxs("span",{className:"text-lg font-bold",children:[P,"%"]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:g})]},x)})})]})}),h.length>0&&e.jsx(S,{variant:"glass",children:e.jsxs(_,{className:"p-4",children:[e.jsx("h3",{className:"font-semibold text-sm mb-3",children:"Top Jobs"}),e.jsx("div",{className:"space-y-2",children:h.map((x,o)=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"text-xs font-bold text-muted-foreground w-4",children:["#",o+1]}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("p",{className:"text-sm truncate text-muted-foreground",children:[x.job_id.slice(0,8),"â¦"]})}),e.jsxs("span",{className:"text-sm font-medium",children:[os(x.views)," views"]})]},x.job_id))})]})})]})}function Ti(){return de.isNative?ss("Share"):"share"in navigator}async function Ai(s){try{if(de.isNative&&ss("Share"))return await As.share({title:s.title,text:s.text,url:s.url,dialogTitle:s.dialogTitle||"Share"}),!0;if("share"in navigator){const t={title:s.title,text:s.text,url:s.url};return Object.keys(t).forEach(i=>
6{t[i]===void 0&&delete t[i]}),await navigator.share(t),!0}return!1}catch(t){return t.name!=="AbortError"&&ae.error("Share failed:",t),!1}}async function Ri(s){const t=s.username?`https://hereismywork.com/${s.username}/job/${s.slug}`:`https://hereismywork.com/job/${s.slug}`;return Ai({title:`Check out this work: ${s.title}`,text:"Take a look at this completed job on Here Is My Work",url:t,dialogTitle:"Share Job"})}function Di({jobs:s,username:t,onViewJob:i,onEditJob:r,onDeleteJob:a,onShareJob:n,onAddJob:m}){const[c,l]=d.useState("published"),[h,u]=d.useState(""),x=s.filter(p=>p.is_published).length,o=s.filter(p=>!p.is_published).length,g=s.filter(p=>{var b;const C=c==="all"||c==="published"&&p.is_published||c==="unpublished"&&!p.is_published,P=!h||p.title.toLowerCase().includes(h.toLowerCase())||((b=p.location)==null?void 0:b.toLowerCase().includes(h.toLowerCase()));return C&&P});return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"sticky top-0 z-10 ios-glass-thick border-b p-4 space-y-3",children:[e.jsxs("div",{className:"flex gap-2 overflow-x-auto pb-1 -mx-4 px-4 scrollbar-hide",children:[e.jsxs("button",{onClick:()=>l("published"),className:y("flex items-center gap-1.5 px-3 py-1.5 rounded-full text-sm font-medium whitespace-nowrap transition-colors",c==="published"?"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400":"bg-muted text-muted-foreground"),children:[e.jsx(Se,{className:"h-3.5 w-3.5"}),"Published (",x,")"]}),e.jsxs("button",{onClick:()=>l("all"),className:y("flex items-center gap-1.5 px-3 py-1.5 rounded-full text-sm font-medium whitespace-nowrap transition-colors",c==="all"?"bg-primary/10 text-primary":"bg-muted text-muted-foreground"),children:[e.jsx(le,{className:"h-3.5 w-3.5"}),"All (",s.length,")"]}),e.jsxs("button",{onClick:()=>l("unpublished"),className:y("flex items-center gap-1.5 px-3 py-1.5 rounded-full text-sm font-medium whitespace-nowrap transition-colors",c==="unpublished"?"bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-400":"bg-muted text-muted-foreground"),children:[e.jsx(ms,{className:"h-3.5 w-3.5"}),"Drafts (",o,")"]})]}),e.jsx(W,{placeholder:"Search jobs...",value:h,onChange:p=>u(p.target.value),className:"h-9"})]}),e.jsx("div",{className:"flex-1 overflow-auto p-4 pb-28 space-y-3",children:g.length===0?e.jsx(Ae,{icon:e.jsx(le,{className:"h-8 w-8 text-muted-foreground"}),title:h?"No jobs match your search":c==="unpublished"?"No drafts":"No jobs yet",description:h?"Try adjusting your search terms":c==="unpublished"?"All your jobs are published! Great work.":"Start showcasing your work by adding your first completed job. Take photos and share your website with customers.",action:!h&&c!=="unpublished"?{label:"Add Your First Job",onClick:m}:void 0}):g.map(p=>e.jsx(xs,{job:p,username:t,onView:()=>i(p),onEdit:()=>r(p),onDelete:()=>a(p),onShare:()=>n(p)},p.id))})]})}function xs({job:s,username:t,onView:i,onEdit:r,onDelete:a,onShare:n}){const[m,c]=d.useState(!1),l=async x=>{x.stopPropagation(),!(Ti()&&t&&await Ri({slug:s.slug||s.id,title:s.title,username:t}))&&n()},h=x=>{x.stopPropagation(),c(!0)},u=()=>{c(!1),a()};return e.jsxs(e.Fragment,{children:[e.jsx(S,{variant:"glass",className:"relative transition-transform active:scale-[0.99] cursor-pointer",onClick:i,children:e.jsx(_,{className:"p-0",children:e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:"w-24 h-24 flex-shrink-0",children:s.job_media&&s.job_media.length>0?e.jsx("img",{src:s.job_media[0].media_url,alt:s.title,className:"w-full h-full object-cover rounded-l-xl"}):e.jsx("div",{className:"w-full h-full bg-muted flex items-center justify-center rounded-l-xl",children:e.jsx(ms,{className:"h-8 w-8 text-muted-foreground"})})}),e.jsxs("div",{className:"flex-1 p-3 min-w-0",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h3",{className:"font-semibold text-sm truncate",children:s.title}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:s.location||"No location"})]}),e.jsxs(Bt,{children:[e.jsx(Gt,{asChild:!0,children:e.jsx(k,{variant:"ghost",size:"icon",className:"h-8 w-8 -mr-2",children:e.jsx(Qt,{className:"h-4 w-4"})})}),e.jsxs(zt,{align:"end",children:[e.jsxs(je,{onClick:r,children:[e.jsx(ct,{className:"h-4 w-4 mr-2"}),"Edit"]}),e.jsxs(je,{onClick:x=>{x.stopPropagation(),l(x)},children:[e.jsx(K,{className:"h-4 w-4 mr-2"}),"Share"]}),e.jsxs(je,{onClick:h,className:"text-destructive",children:[e.jsx(ls,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[e.jsx(ye,{variant:"secondary",className:y("text-[10px] px-2 py-0.5",s.is_published?"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400":"bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-400"),children:s.is_published?e.jsxs(e.Fragment,{children:[e.jsx(Se,{className:"h-3 w-3 mr-1"}),"Published"]}):e.jsxs(e.Fragment,{children:[e.jsx(Ht,{className:"h-3 w-3 mr-1"}),"Draft"]})}),s.tags&&s.tags.length>0&&e.jsx(ye,{variant:"outline",className:"text-[10px] px-2 py-0.5",children:s.tags[0]})]})]}),e.jsx("div",{className:"flex items-center pr-2",children:e.jsx(xe,{className:"h-5 w-5 text-muted-foreground"})})]})})}),e.jsx(Dt,{open:m,onOpenChange:c,children:e.jsxs(Et,{children:[e.jsxs(Lt,{children:[e.jsx(Ft,{children:"Delete Job"}),e.jsxs(Ot,{children:['Are you sure you want to delete "',s.title,'"? This action cannot be undone.']})]}),e.jsxs(It,{children:[e.jsx(Ut,{children:"Cancel"}),e.jsx($t,{onClick:u,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})})]})}function Ei({username:s,companyName:t,portfolioUrl:i}){const[r,a]=d.useState(!1),n=i??"",m=!!n,c=m?n:"Set up your website to get a shareable link",l=()=>{if(!m){B({variant:"destructive",title:"Website not live yet",description:"Set up your website first to get a shareable link."});return}navigator.clipboard.writeText(n),B({title:"Link copied!",description:"Share your website link anywhere"})},h=async()=>
6{if(!m){l();return}if(navigator.share)try{await navigator.share({title:t||"My Website",text:"Check out my work!",url:n})}catch{l()}else l()},u=()=>{if(!m){l();return}const o=encodeURIComponent(`Check out my work: ${n}`);window.open(`https://wa.me/?text=${o}`,"_blank")},x=()=>{const o=document.getElementById("mobile-qr-code");if(!o)return;const g=new XMLSerializer().serializeToString(o),p=document.createElement("canvas"),C=p.getContext("2d"),P=new Image;P.onload=()=>{if(p.width=512,p.height=512,C){C.fillStyle="white",C.fillRect(0,0,p.width,p.height),C.drawImage(P,0,0,p.width,p.height);const b=document.createElement("a");b.download=`${s||"portfolio"}-qr-code.png`,b.href=p.toDataURL("image/png"),b.click()}},P.src="data:image/svg+xml;base64,"+btoa(g),B({title:"QR Code downloaded!",description:"Print it for business cards or flyers"})};return e.jsxs("div",{className:"p-4 space-y-4 pb-24",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-bold",children:"Marketing"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Share and promote your website"})]}),e.jsx("div",{className:"w-12 h-12 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(K,{className:"h-6 w-6 text-primary"})})]}),e.jsx(S,{variant:"glass",children:e.jsxs(_,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-primary/10 flex items-center justify-center",children:e.jsx(dt,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-semibold",children:"Your Website Link"}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:c})]})]}),e.jsxs("div",{className:`grid grid-cols-2 gap-2 ${m?"":"opacity-50 pointer-events-none"}`,children:[e.jsxs(k,{onClick:l,variant:"outline",className:"h-auto py-3 flex-col gap-2",disabled:!m,children:[e.jsx(ts,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs",children:"Copy Link"})]}),e.jsxs(k,{onClick:h,className:"h-auto py-3 flex-col gap-2",disabled:!m,children:[e.jsx(K,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs",children:"Share"})]})]})]})}),e.jsx(S,{variant:"glass",children:e.jsxs(_,{className:"p-4",children:[e.jsx("h3",{className:"font-semibold mb-3",children:"Quick Share"}),e.jsxs("div",{className:`grid grid-cols-4 gap-3 ${m?"":"opacity-50 pointer-events-none"}`,children:[e.jsxs("button",{onClick:u,disabled:!m,className:"flex flex-col items-center gap-2 p-3 rounded-lg hover:bg-muted transition-colors",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-[#25D366]/10 flex items-center justify-center",children:e.jsx("svg",{className:"h-6 w-6 text-[#25D366]",viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("path",{d:"M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.262.489 1.694.625.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 01-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 01-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 012.893 6.994c-.003 5.45-4.437 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0012.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.142 1.588 5.945L.057 24l6.305-1.654a11.882 11.882 0 005.683 1.448h.005c6.554 0 11.89-5.335 11.893-11.893a11.821 11.821 0 00-3.48-8.413z"})})}),e.jsx("span",{className:"text-xs",children:"WhatsApp"})]}),e.jsxs("button",{onClick:()=>window.open(`mailto:?subject=Check out my website&body=${n}`,"_blank"),className:"flex flex-col items-center gap-2 p-3 rounded-lg hover:bg-muted transition-colors",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-blue-500/10 flex items-center justify-center",children:e.jsxs("svg",{className:"h-6 w-6 text-blue-500",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),e.jsx("path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"})]})}),e.jsx("span",{className:"text-xs",children:"Email"})]}),e.jsxs("button",{onClick:()=>window.open(`sms:?body=Check out my website: ${n}`,"_blank"),className:"flex flex-col items-center gap-2 p-3 rounded-lg hover:bg-muted transition-colors",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-green-500/10 flex items-center justify-center",children:e.jsx(cs,{className:"h-6 w-6 text-green-500"})}),e.jsx("span",{className:"text-xs",children:"SMS"})]}),e.jsxs("button",{onClick:()=>a(!r),className:y("flex flex-col items-center gap-2 p-3 rounded-lg transition-colors",r?"bg-primary/10":"hover:bg-muted"),children:[e.jsx("div",{className:y("w-12 h-12 rounded-full flex items-center justify-center",r?"bg-primary/20":"bg-muted"),children:e.jsx(es,{className:y("h-6 w-6",r?"text-primary":"text-muted-foreground")})}),e.jsx("span",{className:"text-xs",children:"QR Code"})]})]})]})}),r&&m&&e.jsx(S,{className:"overflow-hidden",children:e.jsx(_,{className:"p-6",children:e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx("div",{className:"bg-white p-4 rounded-xl shadow-sm",children:e.jsx(qt,{id:"mobile-qr-code",value:n,size:200,level:"H"})}),e.jsx("p",{className:"text-xs text-muted-foreground mt-4 text-center",children:"Scan to view your website"}),e.jsxs(k,{onClick:x,variant:"outline",className:"mt-4",children:[e.jsx(Wt,{className:"h-4 w-4 mr-2"}),"Download QR Code"]})]})})}),e.jsx(S,{className:"bg-primary/5 border-primary/20",children:e.jsxs(_,{className:"p-4",children:[e.jsxs("h3",{className:"font-semibold mb-2 flex items-center gap-2",children:[e.jsx(xi,{className:"h-4 w-4"}),"Marketing Tips"]}),e.jsxs("ul",{className:"text-sm text-muted-foreground space-y-2",children:[e.jsx("li",{children:"⢠Add QR code to business cards"}),e.jsx("li",{children:"⢠Include website link in email signature"}),e.jsx("li",{children:"⢠Share on van signage or uniforms"}),e.jsx("li",{children:"⢠Add to invoices and quotes"})]})]})}),m&&e.jsx(k,{asChild:!0,variant:"outline",className:"w-full",children:e.jsxs("a",{href:n,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(ce,{className:"h-4 w-4 mr-2"}),"View Your Website"]})})]})}const Be="himw_desktop_editing_banner_dismissed";function us(){const[s,t]=d.useState(()=>localStorage.getItem(Be)==="true");if(s)return null;const i=()=>{localStorage.setItem(Be,"true"),t(!0)};return e.jsx(S,{variant:"glass",className:"border-blue-200/60",children:e.jsx(_,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-9 h-9 rounded-lg bg-blue-500/10 flex items-center justify-center flex-shrink-0",children:e.jsx(ds,{className:"h-5 w-5 text-blue-600"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm",children:"Want to edit your website?"}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Open ",e.jsx("span",{className:"font-medium text-foreground",children:"hereismywork.com"})," on a desktop or laptop to customise your design."]})]}),e.jsx("button",{onClick:i,className:"flex-shrink-0 text-muted-foreground hover:text-foreground transition-colors -mt-0.5 -mr-0.5 p-1","aria-label":"Dismiss",children:e.jsx(Ne,{className:"h-4 w-4"})})]})})})}function Li({jobs:s,reviewsCount:t,averageRating:i,onAddJob:r,onViewJobs:a,onViewReviews:n,onSharePortfolio:m,onViewJob:c,onEditJob:l,onDeleteJob:h,onShareJob:u,username:x}){const o=s.filter(p=>p.is_published).length,g=s.slice(0,5);return e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(S,{variant:"glass",className:"cursor-pointer ios-
6press",onClick:a,children:e.jsx(_,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-primary/15 flex items-center justify-center",children:e.jsx(le,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:o}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Published Jobs"})]})]})})}),e.jsx(S,{variant:"glass",className:"cursor-pointer ios-press",onClick:n,children:e.jsx(_,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-[#00b67a]/15 flex items-center justify-center",children:e.jsx(q,{className:"h-5 w-5 text-[#00b67a]"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:i.toFixed(1)}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[t," Reviews"]})]})]})})})]}),e.jsx(S,{variant:"glass",children:e.jsxs(_,{className:"p-4",children:[e.jsx("h3",{className:"font-semibold mb-3",children:"Quick Actions"}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs(k,{variant:"glass",className:"h-auto py-3 flex-col gap-2",onClick:r,children:[e.jsx(H,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs",children:"Add Job"})]}),e.jsxs(k,{variant:"glass",className:"h-auto py-3 flex-col gap-2",onClick:m,children:[e.jsx(K,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs",children:"Share"})]}),e.jsxs(k,{variant:"glass",className:"h-auto py-3 flex-col gap-2",onClick:n,children:[e.jsx(ue,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs",children:"Reviews"})]})]})]})}),e.jsx(us,{}),g.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3 px-1",children:[e.jsx("h3",{className:"font-semibold",children:"Recent Jobs"}),e.jsx(k,{variant:"ghost",size:"sm",onClick:a,children:"View All"})]}),e.jsx("div",{className:"space-y-3",children:g.map(p=>e.jsx(xs,{job:p,username:x,onView:()=>{c?c(p):a()},onEdit:()=>l==null?void 0:l(p),onDelete:()=>h==null?void 0:h(p),onShare:()=>u==null?void 0:u(p)},p.id))}),s.length>g.length&&e.jsxs(k,{variant:"outline",className:"w-full mt-4",onClick:a,children:["View All ",s.length," Jobs"]})]}),s.length===0&&e.jsx(S,{className:"border-dashed",children:e.jsxs(_,{className:"py-8 text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-primary/10 flex items-center justify-center mx-auto mb-4",children:e.jsx(H,{className:"h-8 w-8 text-primary"})}),e.jsx("h3",{className:"font-semibold mb-2",children:"Add Your First Job"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Upload photos of your completed work to build your website"}),e.jsxs(k,{onClick:r,children:[e.jsx(H,{className:"h-4 w-4 mr-2"}),"Add Job"]})]})}),e.jsx("div",{className:"h-24"})]})}const Fi={budget:"Budget",mid:"Mid-range",premium:"Premium",luxury:"Luxury"},Oi=[{value:"fixed",label:"Fixed"},{value:"range",label:"Range"},{value:"from",label:"From"}];function J(s){return(s/100).toFixed(0)}function V(s){const t=parseFloat(s.replace(/[^0-9.]/g,""));return isNaN(t)?0:Math.round(t*100)}function Ii({product:s,companyId:t,onDone:i}){const r=Je(),[a,n]=d.useState(J(s.price_min_pence)),[m,c]=d.useState(J(s.price_max_pence)),[l,h]=d.useState(s.price_format),u=V(a)!==s.price_min_pence||V(m)!==s.price_max_pence||l!==s.price_format,x=()=>{r.mutate({...s,price_min_pence:V(a),price_max_pence:V(l==="fixed"?a:m),price_format:l,service_id:s.service_id,company_id:t},{onSuccess:i})};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(z,{className:"text-xs text-muted-foreground mb-2 block",children:"Price format"}),e.jsx("div",{className:"flex gap-2",children:Oi.map(o=>e.jsx("button",{onClick:()=>h(o.value),className:`flex-1 py-2 rounded-lg text-xs font-medium border transition-colors ${l===o.value?"bg-foreground text-background border-foreground":"border-border text-muted-foreground hover:bg-muted/50"}`,children:o.label},o.value))})]}),e.jsxs("div",{className:`grid gap-3 ${l==="range"?"grid-cols-2":"grid-cols-1"}`,children:[e.jsxs("div",{children:[e.jsx(z,{className:"text-xs text-muted-foreground mb-1.5 block",children:l==="range"?"Min price (£)":"Price (£)"}),e.jsx(W,{type:"number",inputMode:"decimal",value:a,onChange:o=>n(o.target.value),placeholder:"0"})]}),l==="range"&&e.jsxs("div",{children:[e.jsx(z,{className:"text-xs text-muted-foreground mb-1.5 block",children:"Max price (£)"}),e.jsx(W,{type:"number",inputMode:"decimal",value:m,onChange:o=>c(o.target.value),placeholder:"0"})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(k,{variant:"outline",className:"flex-1",onClick:i,children:"Cancel"}),e.jsx(k,{className:"flex-1",disabled:!u||r.isPending,onClick:x,children:r.isPending?"Savingâ¦":"Save"})]})]})}function Ui({service:s,companyId:t,configId:i,onBack:r}){const{data:a=[]}=Bs(t),n=Ye(),m=Je(),c=a.filter(v=>v.service_id===s.id).sort((v,f)=>v.display_order-f.display_order),[l,h]=d.useState(s.name),[u,x]=d.useState(s.description??""),[o,g]=d.useState(null),p=l.trim()!==s.name||u!==(s.description??""),C=()=>{l.trim()&&n.mutate({...s,name:l.trim(),description:u.trim()||null,config_id:i,company_id:t})},P=()=>{D("light"),n.mutate({...s,is_active:!s.is_active,config_id:i,company_id:t})},b=v=>{D("light"),m.mutate({...v,is_active:!v.is_active,service_id:v.service_id,company_id:t})};return e.jsxs("div",{className:"p-4 space-y-4 pb-24",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:r,className:"p-1 -ml-1 text-muted-foreground",children:e.jsx(Ce,{className:"h-5 w-5"})}),e.jsx("h2",{className:"font-semibold text-base flex-1 truncate",children:s.name})]}),e.jsx(S,{variant:"glass",children:e.jsxs(_,{className:"p-4 space-y-3",children:[e.jsxs("div",{children:[e.jsx(z,{className:"text-xs text-muted-foreground mb-1.5 block",children:"Service name"}
6),e.jsx(W,{value:l,onChange:v=>h(v.target.value),placeholder:"e.g. Boiler Service"})]}),e.jsxs("div",{children:[e.jsx(z,{className:"text-xs text-muted-foreground mb-1.5 block",children:"Description"}),e.jsx(Me,{value:u,onChange:v=>x(v.target.value),placeholder:"Optional short descriptionâ¦",rows:2,className:"resize-none"})]}),e.jsx(k,{size:"sm",className:"w-full",disabled:!p||!l.trim()||n.isPending,onClick:C,children:n.isPending?"Savingâ¦":"Save Details"})]})}),e.jsx(S,{variant:"glass",children:e.jsx(_,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:"Active"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:s.is_active?"Shown to homeowners":"Hidden from homeowners"})]}),e.jsx(oe,{checked:s.is_active,onCheckedChange:P,disabled:n.isPending})]})})}),c.length>0&&e.jsxs("div",{children:[e.jsx("h3",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2 px-1",children:"Pricing"}),e.jsx(S,{variant:"glass",children:e.jsx(_,{className:"p-0 divide-y",children:c.map(v=>{const f=o===v.id,j=v.price_format==="fixed"?`£${J(v.price_min_pence)}`:v.price_format==="from"?`From £${J(v.price_min_pence)}`:`£${J(v.price_min_pence)} â £${J(v.price_max_pence)}`;return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-3 p-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"font-medium text-sm",children:Fi[v.tier]??v.tier}),!v.is_active&&e.jsx("span",{className:"text-[10px] bg-muted text-muted-foreground px-1.5 py-0.5 rounded-full",children:"Off"})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:j})]}),e.jsx("button",{onClick:()=>{D("light"),b(v)},className:"mr-1",children:e.jsx(oe,{checked:v.is_active,disabled:m.isPending})}),e.jsx("button",{onClick:()=>{D("light"),g(f?null:v.id)},className:"p-1.5 rounded-lg bg-muted/60 text-muted-foreground",children:e.jsx(ns,{className:"h-3.5 w-3.5"})})]}),f&&e.jsx("div",{className:"px-4 pb-4",children:e.jsx("div",{className:"bg-muted/40 rounded-xl p-4",children:e.jsx(Ii,{product:v,companyId:t,onDone:()=>g(null)})})})]},v.id)})})})]})]})}function $i({companyId:s}){const{isPremium:t}=is(),{data:i,isLoading:r}=Is(t?s:void 0),{data:a=[]}=Us(i==null?void 0:i.id),n=$s(),m=Ye(),[c,l]=d.useState(null),h=c==null?void 0:c.id;if(d.useEffect(()=>{if(h){const o=a.find(g=>g.id===h);o&&l(o)}},[a,h]),!t)return e.jsxs("div",{className:"p-4 flex flex-col items-center justify-center min-h-[60vh] text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-amber-500/10 flex items-center justify-center mb-4",children:e.jsx(me,{className:"h-8 w-8 text-amber-500"})}),e.jsx("h3",{className:"font-semibold mb-2",children:"Premium Feature"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:de.isNative?"The Quote Engine is unavailable for this account in the app.":"The Quote Engine is available on the Premium plan. Upgrade at hereismywork.com to start generating leads."})]});if(r)return e.jsx("div",{className:"flex items-center justify-center py-16",children:e.jsx(ne,{className:"h-6 w-6 animate-spin text-muted-foreground"})});if(!i)return e.jsxs("div",{className:"p-4 flex flex-col items-center justify-center min-h-[60vh] text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-primary/10 flex items-center justify-center mb-4",children:e.jsx(ke,{className:"h-8 w-8 text-primary"})}),e.jsx("h3",{className:"font-semibold mb-2",children:"Not set up yet"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Set up your Quote Engine at"," ",e.jsx("span",{className:"font-medium text-foreground",children:"hereismywork.com"})," ","on a desktop first, then manage it here."]})]});if(c)return e.jsx(Ui,{service:c,companyId:s,configId:i.id,onBack:()=>l(null)});const u=()=>{D("light"),n.mutate({companyId:s,data:{is_published:!i.is_published}})},x=o=>{D("light"),m.mutate({...o,is_active:!o.is_active,config_id:i.id,company_id:s})};return e.jsxs("div",{className:"p-4 space-y-4 pb-24",children:[e.jsxs("div",{className:"flex items-center gap-2 px-1",children:[e.jsx(ke,{className:"h-5 w-5 text-amber-500"}),e.jsx("h2",{className:"font-semibold text-base",children:"Quote Engine"})]}),e.jsx(S,{variant:"glass",children:e.jsx(_,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:"Published"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:i.is_published?"Visible on your portfolio":"Hidden from your portfolio"})]}),e.jsx(oe,{checked:i.is_published,onCheckedChange:u,disabled:n.isPending})]})})}),a.length>0&&e.jsxs("div",{children:[e.jsx("h3",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2 px-1",children:"Services"}),e.jsx(S,{variant:"glass",children:e.jsx(_,{className:"p-0 divide-y",children:a.map(o=>e.jsxs("div",{className:"flex items-center gap-3 p-4",children:[e.jsxs("button",{className:"flex-1 min-w-0 text-left",onClick:()=>{D("light"),l(o)},children:[e.jsx("p",{className:"font-medium text-sm truncate",children:o.name}),o.description&&e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:o.description})]}),e.jsx(oe,{checked:o.is_active,onCheckedChange:()=>x(o),disabled:m.isPending}),e.jsx("button",{onClick:()=>{D("light"),l(o)},className:"text-muted-foreground",children:e.jsx(xe,{className:"h-4 w-4"})})]},o.id))})})]}),e.jsx(S,{variant:"glass",className:"border-dashed",children:e.jsx(_,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-9 h-9 rounded-lg bg-muted flex items-center justify-center flex-shrink-0",children:e.jsx(ce,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium",children:"More options on desktop"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Questions, add-ons & property modifiers at"," ",e.jsx("span",{className:"font-medium text-foreground",children:"hereismywork.com"})]})]})]})})})]})}function Bi({reviews:s,averageRating:t,username:i,onReplyToReview:r,onRequestReview:a}){const[n,m]=d.useState(null),[c,l]=d.useState(null),[h,u]=d.useState(""),x=s.filter(f=>!f.tm_reply||typeof f.tm_reply=="string"&&f.tm_reply.trim()==="").length,o=s.length-x,g=s.length>0?Math.round(o/s.length*100):0,p=d.useMemo(()=>[...s].sort((f,j)=>{const M=!!f.tm_reply&&f.tm_reply.trim()!=="",R=!!j.tm_reply&&j.tm_reply.trim()!=="";return M!==R?M?1:-1:new Date(j.review_date).getTime()-new Date(f.review_date).getTime()}),[s]),C=f=>{h.trim()&&(r==null||r(f,h.trim()),u(""),l(null))},{buildUrl:P}=We(),b=()=>{const f=P("/review");f&&(navigator.clipboard.writeText(f),B({title:"Link copied!",description:"Share this link to collect reviews"}))},v=[5,4,3,2,1].map(f=>({stars:f,count:s.filter(j=>Math.round(j.overall_rating)===f).length,percentage:s.length>0?s.filter(j=>Math.round(j.overall_rating)===f).length/s.length*100:0}));return e.jsxs("div",{className:"p-4 pb-28 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-bold",children:"Reviews"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s.length>0?`${s.length} reviews`:"No reviews yet"})]}),e.jsx("div",{className:"w-12 h-12 rounded-full bg-emerald-500/10 flex items-center justify-center",children:e.jsx(q,{className:"h-6 w-6 text-emerald-600"})})]}),e.jsx(S,{variant:"glass",children:e.jsxs(_,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-4xl font-bold",children:t.toFixed(1)}),e.jsx("div",{className:"flex gap-0.5 justify-center my-1",children:[1,2,3,4,5].map(f=>e.jsx(q,{className:y("h-4 w-4",f<=Math.round(t)?"fill-[#00b67a] text-[#00b67a]":"text-muted")},f))}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[s.length," reviews"]})]}),e.jsx("div",{className:"flex-1 space-y-1",children:v.map(({stars:f,count:j,percentage:M})=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs w-3",children:f}),e.jsx("div",{className:"flex-1 h-2 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-[#00b67a] transition-all",style:{width:`${M}%`}})}),e.jsx("span",{className:"text-xs text-muted-foreground w-6",children:j})]},f))})]}),e.jsxs("div",{className:"mt-4 pt-4 border-t flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ue,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm",children:"Reply rate"})]}),e.jsxs(ye,{variant:"secondary",className:y(g>=80?"bg-green-100 text-green-700":g>=50?"bg-amber-100 text-amber-700":"bg-red-100 text-red-700"),children:[g,"%"]})]})]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs(k,{variant:"outline",className:"h-auto py-3 flex-col gap-2",onClick:b,children:[e.jsx(ts,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs",children:"Copy Review Link"})]}),e.jsxs(k,{variant:"outline",className:"h-auto py-3 flex-col gap-2",onClick:a,children:[e.jsx(Te,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs",children:"Request Review"})]})]}),x>0&&e.jsx(S,{className:"border-amber-200 bg-amber-50 dark:border-amber-800 dark:bg-amber-950/30",children:e.jsx(_,{className:"p-3",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-9 h-9 rounded-full bg-amber-100 dar
6k:bg-amber-900/50 flex items-center justify-center flex-shrink-0",children:e.jsx(Ve,{className:"h-4 w-4 text-amber-600 dark:text-amber-400"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-sm font-semibold text-amber-900 dark:text-amber-200",children:[x," review",x!==1?"s":""," awaiting your reply"]}),e.jsx("p",{className:"text-xs text-amber-700 dark:text-amber-400",children:"Replying builds trust with future customers"})]})]})})}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"font-semibold",children:x>0?"Needs Reply":"Recent Reviews"}),s.length===0?e.jsx(Ae,{icon:e.jsx(q,{className:"h-8 w-8 text-[#00b67a]"}),title:"No Reviews Yet",description:"Share your review link with customers to start collecting feedback. Reviews help build trust and attract new customers.",action:{label:"Copy Review Link",onClick:b}}):p.slice(0,10).map(f=>e.jsx(Gi,{review:f,isExpanded:n===f.id,isReplying:c===f.id,replyText:h,onToggle:()=>m(n===f.id?null:f.id),onStartReply:()=>{l(f.id),m(f.id)},onCancelReply:()=>{l(null),u("")},onReplyTextChange:u,onSubmitReply:()=>C(f.id)},f.id))]})]})}function Gi({review:s,isExpanded:t,isReplying:i,replyText:r,onToggle:a,onStartReply:n,onCancelReply:m,onReplyTextChange:c,onSubmitReply:l}){const h=new Date(s.review_date).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"}),u=!!s.tm_reply&&s.tm_reply.trim()!=="",x=Yt(s),o=Jt(s);return e.jsx(S,{variant:"glass",className:y("transition-all cursor-pointer",t&&"ring-2 ring-primary/20",!u&&"border-l-[3px] border-l-amber-400"),onClick:a,children:e.jsxs(_,{className:"p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:y("w-8 h-8 rounded-full flex items-center justify-center",u?"bg-primary/10":"bg-amber-100 dark:bg-amber-900/50"),children:e.jsx("span",{className:y("text-xs font-semibold",u?"text-primary":"text-amber-700 dark:text-amber-300"),children:s.reviewer_name.slice(0,2).toUpperCase()})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("p",{className:"font-medium text-sm",children:s.reviewer_name}),x&&e.jsx(Vt,{compact:!0})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:h})]})]}),e.jsx("div",{className:"flex gap-0.5",children:[1,2,3,4,5].map(g=>e.jsx("div",{className:y("w-5 h-5 flex items-center justify-center rounded-sm",g<=Math.round(s.overall_rating)?"bg-[#00b67a]":"bg-muted"),children:e.jsx(q,{className:y("h-3 w-3",g<=Math.round(s.overall_rating)?"fill-white text-white":"text-muted-foreground")})},g))})]}),s.review_summary&&e.jsx("p",{className:y("mt-3 text-sm",!t&&"line-clamp-2"),children:s.review_summary}),t&&s.detailed_review&&e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:s.detailed_review}),u?e.jsxs("div",{className:"mt-3 pt-3 border-t",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-emerald-600",children:[e.jsx(ue,{className:"h-3 w-3"}),e.jsx("span",{className:"font-medium",children:"You replied"})]}),t&&e.jsx("p",{className:"mt-2 text-sm bg-muted/50 p-3 rounded-lg",children:s.tm_reply})]}):e.jsx("div",{className:"mt-3 pt-3 border-t",children:i?e.jsxs("div",{className:"space-y-2",onClick:g=>g.stopPropagation(),children:[e.jsx(Me,{placeholder:"Write your reply...",value:r,onChange:g=>c(g.target.value),className:"min-h-[80px] text-sm",autoFocus:!0}),o&&e.jsx(Kt,{}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx(k,{variant:"ghost",size:"sm",onClick:g=>{g.stopPropagation(),m()},children:"Cancel"}),e.jsxs(k,{size:"sm",onClick:g=>{g.stopPropagation(),l()},disabled:!r.trim(),children:[e.jsx(Te,{className:"h-3.5 w-3.5 mr-1.5"}),"Reply"]})]})]}):e.jsxs("button",{className:"flex items-center gap-2 text-xs text-amber-600 dark:text-amber-400 font-medium",onClick:g=>{g.stopPropagation(),n()},children:[e.jsx(Ve,{className:"h-3.5 w-3.5"}),"Tap to reply"]})})]})})}const hs="mobile-settings:expanded-groups",zi={general:{bg:"bg-slate-500/10",text:"text-slate-600"},"whats-new":{bg:"bg-orange-500/10",text:"text-orange-600"},business:{bg:"bg-blue-500/10",text:"text-blue-600"},contact:{bg:"bg-green-500/10",text:"text-green-600"},documents:{bg:"bg-orange-500/10",text:"text-orange-600"},collections:{bg:"bg-purple-500/10",text:"text-purple-600"},trust:{bg:"bg-amber-500/10",text:"text-amber-600"},pages:{bg:"bg-indigo-500/10",text:"text-indigo-600"},seo:{bg:"bg-teal-500/10",text:"text-teal-600"},reviews:{bg:"bg-emerald-500/10",text:"text-emerald-600"},embed:{bg:"bg-violet-500/10",text:"text-violet-600"},appointments:{bg:"bg-blue-500/10",text:"text-blue-600"},"ai-receptionist/setup":{bg:"bg-indigo-500/10",text:"text-indigo-600"},"ai-receptionist/voice":{bg:"bg-purple-500/10",text:"text-purple-600"},"ai-receptionist/greeting":{bg:"bg-rose-500/10",text:"text-rose-600"},"ai-receptionist/call-instructions":{bg:"bg-orange-500/10",text:"text-orange-600"},"ai-receptionist/special-numbers":{bg:"bg-emerald-500/10",text:"text-emerald-600"}
6,"ai-receptionist/instructions":{bg:"bg-violet-500/10",text:"text-violet-600"},"ai-receptionist/notifications":{bg:"bg-rose-500/10",text:"text-rose-600"},"ai-receptionist/sms":{bg:"bg-cyan-500/10",text:"text-cyan-600"},"ai-receptionist/team":{bg:"bg-amber-500/10",text:"text-amber-700"}},Qi=[{title:"General",items:[{id:"general",icon:Pe,label:"General Settings",description:"App preferences"},{id:"whats-new",icon:Xe,label:"What's new",description:"Product updates and improvements",route:"/dashboard/updates"}]},{title:"Profile",items:[{id:"business",icon:xt,label:"Business Details",description:"Name, logo, bio"},{id:"contact",icon:ve,label:"Contact Details",description:"Phone, email, address"}]},{title:"Documents",items:[{id:"documents",icon:be,label:"Docs & Insurance",description:"Certificates and policies"}]},{title:"Portfolio",items:[{id:"collections",icon:as,label:"Collections",description:"Organise your work"}]},{title:"Marketing",items:[{id:"trust",icon:ti,label:"Trust & Proof",description:"Credentials and stats"},{id:"pages",icon:be,label:"Custom Pages",description:"About, services, etc.",premium:!0},{id:"contact-forms",icon:be,label:"Contact Forms",description:"Enquiry form profiles"},{id:"seo",icon:ut,label:"SEO Settings",description:"Search optimisation",premium:!0}]},{title:"Reviews",items:[{id:"reviews",icon:q,label:"Review Settings",description:"Manage review collection"},{id:"embed",icon:ii,label:"Website widgets",description:"Add to your website"}]},{title:"Appointments",items:[{id:"appointments",icon:ri,label:"Appointments",description:"Availability & booking"}]},{title:"AI Receptionist",items:[{id:"ai-receptionist/setup",icon:ve,label:"Setup",description:"Forwarding guide"},{id:"ai-receptionist/voice",icon:ai,label:"Voice",description:"Choose and preview voices"},{id:"ai-receptionist/greeting",icon:ni,label:"Greeting",description:"What Sarah says when she answers"},{id:"ai-receptionist/call-instructions",icon:li,label:"Call Instructions",description:"How Sarah should handle calls"},{id:"ai-receptionist/special-numbers",icon:oi,label:"Special contacts",description:"Trusted callers who reach you first"},{id:"ai-receptionist/instructions",icon:ci,label:"Call Behavior",description:"Spam, quotes, limits, and routing"},{id:"ai-receptionist/notifications",icon:di,label:"Notifications",description:"Email and push alert filters"},{id:"ai-receptionist/sms",icon:ue,label:"SMS",description:"Texts and follow-ups"},{id:"ai-receptionist/team",icon:Ze,label:"Team",description:"People, numbers, and invites"}]}];function Hi(){if(typeof window>"u")return[];try{const s=window.localStorage.getItem(hs);if(!s)return[];const t=JSON.parse(s);return Array.isArray(t)?t.filter(i=>typeof i=="string"):[]}catch{return[]}}function qi(s){if(!(typeof window>"u"))try{window.localStorage.setItem(hs,JSON.stringify([...s]))}catch{}}function Wi(s,t){return s.filter(i=>i.items.length>1).filter(i=>i.items.some(r=>{const a=r.id==="business"?"/dashboard/settings":`/dashboard/settings/${r.id}`;return t===a||t.startsWith(`${a}/`)})).map(i=>i.title)}function Ge({group:s,isPremium:t,onItemClick:i,productUpdatesUnreadCount:r=0}){return e.jsx(e.Fragment,{children:s.items.map(a=>{const n=a.icon,m=zi[a.id]||{bg:"bg-muted",text:"text-muted-foreground"},c=a.id==="whats-new"?r:a.badgeCount,l=a.id==="whats-new"&&c?si(c):c;return e.jsxs("button",{onClick:()=>i(a),className:"w-full flex items-center gap-3 p-4 text-left hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:`relative w-9 h-9 rounded-lg ${m.bg} flex items-center justify-center flex-shrink-0`,children:[e.jsx(n,{className:`h-5 w-5 ${m.text}`}),c&&c>0?e.jsx("span",{className:"absolute -right-1 -top-1 flex h-4 min-w-[1rem] items-center justify-center rounded-full bg-orange-500 px-1 text-[10px] font-bold leading-none text-white",children:l}):null]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-sm",children:a.label}),a.premium&&!t&&e.jsx(me,{className:"h-3.5 w-3.5 text-amber-500"})]}),a.description&&e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:a.description})]}),a.external?e.jsx(ce,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(xe,{className:"h-4 w-4 text-muted-foreground"})]},a.id)})})}function Yi({companyName:s,username:t,onSignOut:i,onNavigateToSettings:r,productUpdatesUnreadCount:a=0}){const n=Ps(),m=Qe(),{company:c}=mt(),{isEnabled:l}=qe(c==null?void 0:c.id),h=l("website_widgets_enabled"),u=l("ai_receptionist_team"),{isPremium:x}=is(),{requestSignOut:o,dialog:g}=Ke(i),p=d.useMemo(()=>Qi.map(j=>({...j,items:j.items.filter(M=>(M.id!=="embed"||h)&&(M.id!=="ai-receptionist/team"||u))})),[h,u]),C=d.useMemo(()=>Wi(p,n.pathname),[n.pathname,p]),[P,b]=d.useState(()=>Ie(Hi(),C));d.useEffect(()=>{b(j=>Ie([...j],C))},[C]);const v=j=>{j.external?window.open("/help","_blank"):j.route?m(j.route):r&&r(j.id)},f=(j,M)=>{b(R=>{const N=new Set(R);return M?N.add(j):N.delete(j),qi(N),N})};return e.jsxs("div",{className:"p-4 space-y-4 pb-24",children:[e.jsx(S,{variant:"glass",children:e.jsx(_,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-14 h-14 roun
6ded-full bg-primary/10 flex items-center justify-center",children:e.jsx("span",{className:"text-lg font-bold text-primary",children:(s==null?void 0:s.slice(0,2).toUpperCase())||"HI"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h2",{className:"font-semibold truncate",children:s||"Your Business"}),t&&e.jsxs("p",{className:"text-sm text-muted-foreground truncate",children:["hereismywork.com/",t]}),e.jsx("div",{className:"flex items-center gap-2 mt-1",children:x?e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-medium text-amber-600 bg-amber-100 px-2 py-0.5 rounded-full",children:[e.jsx(me,{className:"h-3 w-3"}),"Premium"]}):e.jsx("span",{className:"text-xs text-muted-foreground",children:"Free Plan"})})]})]})})}),e.jsx(us,{}),p.map(j=>{const M=j.items.length>1,R=!M||P.has(j.title);return e.jsx("div",{children:M?e.jsxs(Xt,{open:R,onOpenChange:N=>f(j.title,N),children:[e.jsx(Zt,{asChild:!0,children:e.jsxs("button",{type:"button","aria-expanded":R,className:"flex w-full items-center justify-between gap-2 px-1 mb-2 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring rounded-sm",children:[e.jsx("span",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wider",children:j.title}),e.jsx(ht,{className:y("h-4 w-4 text-muted-foreground transition-transform duration-200",R&&"rotate-180"),"aria-hidden":"true"})]})}),e.jsx(ei,{children:e.jsx(S,{variant:"glass",children:e.jsx(_,{className:"p-0 divide-y",children:e.jsx(Ge,{group:j,isPremium:x,onItemClick:v,productUpdatesUnreadCount:a})})})})]}):e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2 px-1",children:j.title}),e.jsx(S,{variant:"glass",children:e.jsx(_,{className:"p-0 divide-y",children:e.jsx(Ge,{group:j,isPremium:x,onItemClick:v,productUpdatesUnreadCount:a})})})]})},j.title)}),e.jsxs(k,{variant:"outline",className:"w-full text-destructive hover:text-destructive hover:bg-destructive/10",onClick:o,children:[e.jsx(rs,{className:"h-4 w-4 mr-2"}),"Sign Out"]}),e.jsxs("p",{className:"text-center text-xs text-muted-foreground",children:["Here Is My Work ⢠",pt]}),g]})}const ze=["overview","jobs","inbox","calls","opportunities","reviews","marketing","settings","invoices","insights","leads","collections","quotes"];function so({companyId:s,companyName:t,companyLogo:i,username:r,customDomain:a,jobs:n,reviews:m,messages:c=[],unreadCount:l=0,invoices:h=[],onRefresh:u,onAddJob:x,onViewJob:o,onEditJob:g,onDeleteJob:p,onShareJob:C,onReplyToReview:P,onRequestReview:b,onSignOut:v,onNavigateToSettings:f,onViewMessage:j,onViewInvoice:M,showCalls:R=!1,onSetupWebsite:N,isWebsitePublished:U=!0}){const{baseUrl:E,isPublished:O}=We(),[Y]=He(),[$,I]=d.useState(()=>{const A=Y.get("tab");return A&&ze.includes(A)?A:"overview"}),[Re,X]=d.useState(!1),[Z,ee]=d.useState(!1),[he,w]=d.useState(!0),T=d.useCallback(A=>{w(A==="up")},[]);Fs();const{updateAvailable:F,handleUpdate:L,dismissUpdate:G,updateMessage:pe,forceUpdate:se}=qs(),{isEnabled:te}=qe(s),De=te("opportunities_hub"),{unreadCount:ps}=Rs(R?s:void 0,{timeRange:"all"}),{data:fs=0}=Gs(De?s:void 0),{unreadCount:gs}=Os();d.useEffect(()=>{const A=Y.get("tab");A&&ze.includes(A)&&I(A)},[Y]);const ie=d.useCallback(()=>{ee(!0)},[]),bs=d.useCallback(async()=>{await u(),I("jobs")},[u]),Ee=d.useCallback(()=>{b==null||b()},[b]),fe=d.useCallback(async()=>{if(!O||!U){N==null||N();return}if(!E)return;const A=E;if(navigator.share)try{await navigator.share({title:t||"Check out my portfolio",url:A})}catch{}else try{await navigator.clipboard.writeText(A)}catch{}},[E,O,U,t,N]),js=d.useMemo(()=>{switch($){case"overview":case"jobs":case"inbox":return{icon:we,label:"Add Job",onPress:ie};case"reviews":return{icon:Te,label:"Request Review",onPress:Ee};case"marketing":return{icon:K,label:"Share Website",onPress:fe};default:return}},[$,ie,Ee,fe]),Q=d.useMemo(()=>["overview","jobs","inbox","reviews"],[]),vs=d.useCallback(()=>{const A=Q.indexOf($);A<Q.length-1&&I(Q[A+1])},[$,Q]),Ns=d.useCallback(()=>{const A=Q.indexOf($);A>0&&I(Q[A-1])},[$,Q]),ws=Js({onSwipeLeft:vs,onSwipeRight:Ns,threshold:75}),ys=d.useCallback(async()=>{X(!0);try{await u()}finally{X(!1)}},[u]),Le=m.length>0?m.reduce((A,Ss)=>A+Ss.overall_rating,0)/m.length:0,ks=()=>{I("marketing")},Cs=()=>{switch($){case"overview":return e.jsx(Li,{jobs:n,reviewsCount:m.length,averageRating:Le,onAddJob:ie,onViewJobs:()=>I("jobs"),onViewReviews:()=>I("reviews"),onSharePortfolio:ks,onViewJob:o,onEditJob:g,onDeleteJob:p,onShareJob:C,username:r});case"jobs":return e.jsx(Di,{jobs:n,username:r,onViewJob:o,onEditJob:g,onDeleteJob:p,onShareJob:C,onAddJob:ie});case"inbox":return e.jsx(Si,{messages:c,onViewMessage:j,onShareWebsite:fe});case"calls":return e.jsx(Ni,{companyId:s});case"opportunities":return e.jsx(Ts,{companyId:s});case"reviews":return e.jsx(Bi,{reviews:m,averageRating:Le,username:r,onReplyToReview:P,onRequestReview:b});case"marketing":return e.jsx(Ei,{username:r,companyName:t,portfolioUrl:E||void 0});case"insights":return e.jsx(Mi,{companyId:s});case"quotes":return e.jsx($i,{companyId:s});case"collections":return e.jsx(yi,{companyId:s,onBack:()=>I("settings")});case"settings":return e.jsx(Yi,{companyName:t,username:r,onSignOut:v,productUpdatesUnreadCount:gs,onNavigateToSettings:A=>{A==="collections"?I("collections"):f==null||f(A)}});default:return null}};return e.jsxs(ui,{children:[e.jsx(hi,{companyName:t,companyLogo:i,username:r,customDomain:a,isPublished:U&&O,onSetupWebsite:N,visible:he}),e.jsx("div",{...ws,children:e.jsx(ji,{onRefresh:ys,className:"h-[100dvh]",onScrollDirectionChange:T,children:e.jsxs("div",{className:"pt-[calc(env(safe-area-inset-top)+3rem)]",children:[e.jsx(Ws,{}),e.jsx(Ms,{blocked:$!=="overview",companyId:s}),Cs()]})})}),e.jsx(bi,{activeTab:$,onTabChange:I,fabConfig:js,jobsCount:0,reviewsCount:0,inboxCount:l,showCalls:R,showOpportunitiesHub:De,callsCount:ps,leadsCount:fs,onSignOut:v}),e.jsx(vi,{open:Z,onClose:()=>ee(!1),companyId:s,onJobCreated:bs}),F&&e.jsx(mi,{onUpdate:L,onDismiss:G,message:pe,forceUpdate:se})]})}
6export{so as MobileDashboard}; 7//# sourceMappingURL=MobileDashboard-CgUQYux8.js.map
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.