1import{f as Y,c as r,o as i,a as e,y as j,u as Q,g as W,r as v,K as J,q as k,L as X,i as p,d as T,t as c,j as s,m as $,v as A,s as L,J as G,h as O,H as Z,D as ee,b as S,B as te,w as R,F as se,k as oe,e as ae}from"#entry";import{u as ne}from"./CI36eZX6.js";import{u as le}from"./Dy9pVEbO.js";import"./DKLWY9DJ.js";const re={class:"inline-flex items-center gap-1.5"},ie={class:"relative inline-flex group"},de=Y({__name:"AddMultipleDogsButton",props:{buttonClass:{},hintClass:{}},emits:["click"],setup(F){return(N,m)=>(i(),r("div",re,[e("button",{type:"button",class:j(["bg-white hover:bg-gray-50 text-gray-900 border border-gray-200 px-4 py-2 rounded-lg font-semibold transition-colors",F.buttonClass]),onClick:m[0]||(m[0]=C=>N.$emit("click"))}," Add Multiple Dogs ",2),e("span",ie,[e("button",{type:"button",class:j(["h-6 w-6 rounded-full border border-current text-xs font-bold leading-none inline-flex items-center justify-center opacity-80 hover:opacity-100",F.hintClass]),"aria-label":"First 3 dogs are free then each dog will cost £2"}," ? ",2),m[1]||(m[1]=e("span",{role:"tooltip",class:"pointer-events-none absolute right-0 top-full z-30 mt-2 w-64 rounded-lg bg-slate-900 px-3 py-2 text-xs font-medium text-white shadow-lg opacity-0 translate-y-1 group-hover:opacity-100 group-hover:translate-y-0 group-focus-within:opacity-100 group-focus-within:translate-y-0 transition"}," First 3 dogs are free then each dog will cost £2. ",-1))])]))}}),ue={key:0,class:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50",role:"dialog","aria-modal":"true","aria-labelledby":"extra-dogs-title"},ce={class:"bg-white rounded-2xl shadow-xl w-full max-w-lg max-h-[90vh] overflow-y-auto p-6"},ge={class:"text-sm text-gray-600 mb-5"},pe={key:0,class:"mb-4 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700"},me={class:"mb-4"},ye={key:1,class:"mb-4"},be={class:"grid grid-cols-1 sm:grid-cols-2 gap-3"},fe={class:"text-sm text-gray-600"},xe={class:"text-sm text-gray-600"},he={class:"mb-5 rounded-lg bg-slate-50 border border-slate-200 px-4 py-3 text-sm space-y-1"},ve={key:0,class:"flex justify-between gap-3"},we={class:"text-gray-600"},_e={class:"font-medium"},ke={key:1,class:"flex justify-between gap-3"},$e={class:"text-gray-600"},Ce={class:"font-medium"},De={key:2,class:"flex justify-between gap-3"},Me={class:"font-medium"},Pe={class:"flex justify-between gap-3 border-t border-slate-200 pt-2 text-base"},Ae={class:"font-bold text-gray-900"},Se={key:2,class:"grid sm:grid-cols-2 gap-3 mb-4"},Ee={class:"sm:col-span-2"},Fe={class:"sm:col-span-2"},Ne={class:"sm:col-span-2"},Ie={key:3,class:"text-xs text-gray-500 mb-4"},Ue={key:4,class:"text-xs text-gray-500 mb-4"},Te={class:"flex flex-wrap gap-2 justify-end"},Ve=["disabled"],je=["disabled"],z=3,qe=200,K=180,H=91,Be=Y({__name:"ExtraDogsPackModal",props:{open:{type:Boolean},existingDogCount:{}},emits:["close","created"],setup(F,{emit:N}){const m=F,C=N,f=Q(),_=W(),M=v(1),g=v("second"),w=v(!1),x=v(""),a=J({name:"",email:"",phone:"",line1:"",line2:"",city:"",postcode:"",country:"GB"}),D=z,P=k(()=>m.existingDogCount+1),y=k(()=>{const n=Math.floor(Number(M.value)||0);return Math.min(100,Math.max(0,n))}),V=k(()=>Math.max(0,z-m.existingDogCount)),E=k(()=>Math.min(y.value,V.value)),I=k(()=>Math.max(0,y.value-E.value)),h=k(()=>I.value>0),U=k(()=>I.value*qe),q=k(()=>h.value?g.value==="first"?K:H:0),B=k(()=>U.value+q.value),l=k(()=>w.value?h.value?"Redirecting to paymentâ¦":"Adding dogsâ¦":h.value?`Go â pay ${o(B.value)}`:`Add ${y.value} free dog${y.value===1?"":"s"}`),o=n=>new Intl.NumberFormat("en-GB",{style:"currency",currency:"GBP"}).format((n||0)/100),u=async()=>{if(!_.userId)return;a.email=_.user?.email||a.email;const{data:n}=await f.from("doghealthy_users").select("full_name, phone, billing_name, address_line1, address_line2, address_city, address_postcode, address_country").eq("id",_.userId).maybeSingle();n&&(a.name=n.billing_name||n.full_name||a.name,n.phone&&(a.phone=n.phone),n.address_line1&&(a.line1=n.address_line1),n.address_line2&&(a.line2=n.address_line2),n.address_city&&(a.city=n.address_city),n.address_postcode&&(a.postcode=n.address_postcode),n.address_country&&(a.country=n.address_country))};X(()=>m.open,async n=>{if(!n)return;x.value="",w.value=!1;const t=Math.max(0,z-m.existingDogCount);M.value=t>0?t:1,g.value="second",await u()});const b=async()=>
1{if(x.value="",y.value<1){x.value="Enter how many dogs you want to add.";return}if(h.value&&(!a.name||!a.email||!a.line1||!a.city||!a.postcode)){x.value="Please complete the shipping address for NFC stickers.";return}w.value=!0;try{const{data:n}=await f.auth.getSession(),t=n.session?.access_token;if(!t)throw new Error("Please log in again.");const d=await $fetch("/.netlify/functions/extra-dogs-create-checkout",{method:"POST",headers:{Authorization:`Bearer ${t}`},body:{quantity:y.value,postageClass:g.value,shipping:{...a}}});if(d?.free){C("created",{names:d.names||[],dogIds:d.dogIds||[]}),C("close"),w.value=!1;return}if(!d?.url)throw new Error("No checkout URL returned");window.location.href=d.url}catch(n){x.value=n?.data?.error||n?.message||"Unable to start checkout.",w.value=!1}};return(n,t)=>F.open?(i(),r("div",ue,[e("div",ce,[t[25]||(t[25]=e("h2",{id:"extra-dogs-title",class:"text-xl font-bold text-gray-900 mb-2"}," Add Multiple Dogs ",-1)),e("p",ge,[T(" Your first "+c(s(D))+" dogs are free. After that each dog is ",1),t[11]||(t[11]=e("strong",null,"£2",-1)),T(" and includes NFC + QR codes. Weâll create placeholder profiles (dog"+c(s(P))+", dog"+c(s(P)+1)+"â¦) that you can rename. ",1)]),s(x)?(i(),r("div",pe,c(s(x)),1)):p("",!0),e("div",me,[t[12]||(t[12]=e("label",{class:"block text-sm font-medium text-gray-700 mb-1",for:"extra-qty"}," How many dogs do you want to add? ",-1)),$(e("input",{id:"extra-qty","onUpdate:modelValue":t[0]||(t[0]=d=>L(M)?M.value=d:null),type:"number",min:"1",max:"100",class:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500"},null,512),[[A,s(M),void 0,{number:!0}]])]),s(h)?(i(),r("div",ye,[t[15]||(t[15]=e("p",{class:"block text-sm font-medium text-gray-700 mb-2"},"Postage for NFC stickers",-1)),e("div",be,[e("label",{class:j(["flex items-start gap-3 p-3 border rounded-xl cursor-pointer",s(g)==="first"?"border-blue-500 bg-blue-50":"border-gray-200"])},[$(e("input",{"onUpdate:modelValue":t[1]||(t[1]=d=>L(g)?g.value=d:null),type:"radio",value:"first",class:"mt-1"},null,512),[[G,s(g)]]),e("span",null,[t[13]||(t[13]=e("span",{class:"font-semibold text-gray-900 block"},"1st Class stamp",-1)),e("span",fe,c(o(K)),1)])],2),e("label",{class:j(["flex items-start gap-3 p-3 border rounded-xl cursor-pointer",s(g)==="second"?"border-blue-500 bg-blue-50":"border-gray-200"])},[$(e("input",{"onUpdate:modelValue":t[2]||(t[2]=d=>L(g)?g.value=d:null),type:"radio",value:"second",class:"mt-1"},null,512),[[G,s(g)]]),e("span",null,[t[14]||(t[14]=e("span",{class:"font-semibold text-gray-900 block"},"2nd Class stamp",-1)),e("span",xe,c(o(H)),1)])],2)])])):p("",!0),e("dl",he,[s(E)>0?(i(),r("div",ve,[e("dt",we,c(s(E))+" à free dogs",1),e("dd",_e,c(o(0)),1)])):p("",!0),s(I)>0?(i(),r("div",ke,[e("dt",$e,c(s(I))+" à extra dogs @ £2 (NFC + QR)",1),e("dd",Ce,c(o(s(U))),1)])):p("",!0),s(h)?(i(),r("div",De,[t[16]||(t[16]=e("dt",{class:"text-gray-600"},"Postage",-1)),e("dd",Me,c(o(s(q))),1)])):p("",!0),e("div",Pe,[t[17]||(t[17]=e("dt",{class:"font-semibold text-gray-900"},"Total",-1)),e("dd",Ae,c(o(s(B))),1)])]),s(h)?(i(),r("div",Se,[e("div",Ee,[t[18]||(t[18]=e("label",{class:"block text-sm font-medium text-gray-700 mb-1"},"Full name",-1)),$(e("input",{"onUpdate:modelValue":t[3]||(t[3]=d=>s(a).name=d),type:"text",class:"w-full px-3 py-2 border border-gray-300 rounded-lg"},null,512),[[A,s(a).name]])]),e("div",null,[t[19]||(t[19]=e("label",{class:"block text-sm font-medium text-gray-700 mb-1"},"Email",-1)),$(e("input",{"onUpdate:modelValue":t[4]||(t[4]=d=>s(a).email=d),type:"email",class:"w-full px-3 py-2 border border-gray-300 rounded-lg"},null,512),[[A,s(a).email]])]),e("div",null,[t[20]||(t[20]=e("label",{class:"block text-sm font-medium text-gray-700 mb-1"},"Phone",-1)),$(e("input",{"onUpdate:modelValue":t[5]||(t[5]=d=>s(a).phone=d),type:"tel",class:"w-full px-3 py-2 border border-gray-300 rounded-lg"},null,512),[[A,s(a).phone]])]),e("div",Fe,[t[21]||(t[21]=e("label",{class:"block text-sm font-medium text-gray-700 mb-1"},"Address line 1",-1)),$(e("input",{"onUpdate:modelValue":t[6]||(t[6]=d=>s(a).line1=d),type:"text",class:"w-full px-3 py-2 border border-gray-300 rounded-lg"},null,512),[[A,s(a).line1]])]),e("div",Ne,[t[22]||(t[22]=e("label",{class:"block text-sm font-medium text-gray-700 mb-1"},"Address line 2",-1)),$(e("input",{"onUpdate:modelValue":t[7]||(t[7]=d=>s(a).line2=d),type:"text",class:"w-full px-3 py-2 border border-gray-300 rounded-lg"},null,512),[[A,s(a).line2]])]),e("div",null,[t[23]||(t[23]=e("label",{class:"block text-sm font-medium text-gray-700 mb-1"},"City",-1)),$(e("input",{"onUpdate:modelValue":t[8]||(t[8]=d=>s(a).city=d),type:"text",class:"w-full px-3 py-2 border border-gray-300 rounded-lg"},null,512),[[A,s(a).city]])]),e("div",null,[t[24]||(t[24]=e("label",{class:"block text-sm font-medium text-gray-700 mb-1"}
1,"Postcode",-1)),$(e("input",{"onUpdate:modelValue":t[9]||(t[9]=d=>s(a).postcode=d),type:"text",class:"w-full px-3 py-2 border border-gray-300 rounded-lg uppercase"},null,512),[[A,s(a).postcode]])])])):p("",!0),s(h)?(i(),r("p",Ie," Pay securely with Stripe Checkout (card; PayPal appears if enabled on your Stripe account). ")):(i(),r("p",Ue," These dogs are within your free allowance â no payment needed. ")),e("div",Te,[e("button",{type:"button",class:"px-4 py-2 border border-gray-300 rounded-lg text-sm font-medium hover:bg-gray-50",disabled:s(w),onClick:t[10]||(t[10]=d=>n.$emit("close"))}," Cancel ",8,Ve),e("button",{type:"button",class:"px-5 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg text-sm font-semibold disabled:opacity-60",disabled:s(w)||s(y)<1,onClick:b},c(s(l)),9,je)])])])):p("",!0)}}),Re={class:"min-h-screen bg-gray-50"},Le={class:"relative max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 h-full flex items-center justify-between"},ze={class:"flex items-center gap-3"},Ye={class:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8"},Ge={key:0,class:"flex justify-between items-center mb-8"},Oe={class:"flex items-center gap-3"},Ke={key:2,class:"text-center py-12"},He={key:3,class:"bg-red-50 border border-red-200 rounded-lg p-4 text-red-700"},Qe={key:4,class:"text-center py-12"},We={key:0,class:"mb-6"},Je=["src","alt"],Xe={key:1,class:"text-6xl mb-4"},Ze={class:"flex flex-wrap items-center justify-center gap-3"},et={key:5,class:"grid md:grid-cols-2 lg:grid-cols-3 gap-6"},tt={class:"aspect-square bg-gray-200 relative"},st=["src","alt"],ot={key:1,class:"flex items-center justify-center h-full text-6xl"},at={class:"p-6"},nt={class:"text-xl font-bold text-gray-900 mb-2"},lt={class:"space-y-1 text-sm text-gray-600 mb-4"},rt={key:0},it={key:1},dt={key:2},ut={key:3},ct={class:"flex gap-2"},gt=3,ft=Y({__name:"index",setup(F){const{fetchImageWithFallback:N}=ne(),m=v(""),C=v(null);O(async()=>{try{const l=await N("happy dog owner",{orientation:"landscape",width:1920,height:600});l&&(m.value=l.url)}catch{}try{const l=await N("cute dog puppy",{orientation:"portrait",width:400,height:400});l&&(C.value=l)}catch{}});const f=W(),_=Z(),M=Q();le({title:"My Dogs â Manage Dog Profiles",description:"Manage your DogHealthy dog profiles. Track health records, vaccinations, medications, appointments and NFC tags for every dog in your UK household.",keywords:"my dogs DogHealthy, dog profiles, pet health dashboard UK",path:"/dogs",index:!1});const g=v([]),w=v(!0),x=v(""),a=v(!1),D=v(""),P=v(!1),y=ee(),V=async()=>{f.loading&&await new Promise(l=>{const o=()=>{f.loading?setTimeout(o,50):l()};o()})},E=async()=>{w.value=!0,x.value="";try{if(await V(),!f.isAuthenticated||!f.userId){_.push("/auth/login");return}const{data:l,error:o}=await M.from("doghealthy_dogs").select("*").eq("user_id",f.userId).eq("is_active",!0).order("created_at",{ascending:!1});if(o)throw o;g.value=l?.map(u=>({id:u.id,name:u.name,breed:u.breed,gender:u.gender,birthDate:u.birth_date,weightKg:u.weight_kg!=null?Number(u.weight_kg):void 0,photoUrl:u.photo_url}))||[]}catch(l){console.error("Error loading dogs:",l),x.value=l.message||"Failed to load dogs"}finally{w.value=!1}},I=l=>{const o=new Date(l),u=new Date,b=u.getFullYear()-o.getFullYear(),n=u.getMonth()-o.getMonth();return b>0?n<0?`${b-1} years old`:`${b} years old`:n>0?`${n} months old`:"Less than a month old"},h=async()=>{if(await V(),!f.isAuthenticated||!f.userId){_.push("/auth/login");return}a.value=!0},U=async()=>{try{if(await V(),!f.isAuthenticated||!f.userId){_.push("/auth/login");return}if(g.value.length>=gt){a.value=!0;return}_.push("/dogs/new")}catch(l){console.error("Error handling Add Dog click:",l),_.push("/dogs/new")}},q=async l=>{a.value=!1;const o=l?.names?.length?l.names.join(", "):"your dogs";P.value=!1,D.value=`Added ${o}. You can rename them anytime.`,await E()},B=async l=>{D.value="Confirming payment and creating your extra dogsâ¦",P.value=!1;try{const{data:o}=await M.auth.getSession(),u=o.session?.access_token,b=await $fetch("/.netlify/functions/extra-dogs-confirm",{method:"POST",headers:u?{Authorization:`Bearer ${u}`}:{},body:{sessionId:l}}),n=b.names?.length?b.names.join(", "):`${b.quantity||""} extra dogs`;D.value=`Payment received. Added ${n}. You can rename them anytime. NFC + QR are ready.`,await E(),await _.replace({path:"/dogs",query:{}})}catch(o){P.value=!0,D.value=o?.data?.error||o?.message||"Payment may have succeeded; refresh if the new dogs do not appear."}};return O(async()=>{await E(),y.query.pack==="cancelled"&&(P.value=!0,D.value="Checkout was cancelled. You can add extra dogs whenever you are ready.",a.value=!0),y.query.addPack==="1"&&(a.value=!0);const l=typeof y.query.session_id=="string"?y.query.session_id:"";y.query.pack==="success"&&l.startsWith("cs_")&&await B(l)}),(l,o)=>{const u=ae,b=de,n=Be;return i(),r("div",Re,[s(m)?(i(),r("div",{key:0,class:"relative h-64 bg-cover bg-center",style:te({backgroundImage:`url(${s(m)})`})},[o[3]||(o[3]=e("div",{class:"absolute inset-0 bg-black opacity-30"},null,-1)),e("div",Le,[o[2]||(o[2]=e("div",null,[e("h1",{class:"text-4xl font-bold text-white mb-2"},"My Dogs"),e("p",{class:"text-xl text-white"},"Manage all your furry friends in one place")],-1)),e("div",ze,[S(u,{to:"/vets",class:"hidden sm:inline-flex bg-gray-100/90 hover:bg-gray-200 text-gray-800 px-4 py-2 rounded-lg font-semibold transition-colors"},{default:R(()=>[...o[1]||(o[1]=[T(" ð¥ Vets ",-1)])]),_:1}),e("button",{type:"button",onClick:U,class:"bg-blue-600 hover:bg-blue-700 text-white px-6 py-2 rounded-lg font-semibold transition-colors"}," + Add Dog "),S(b,{"button-class":"bg-white/95 hover:bg-white border-0","hint-class":"text-white border-white",onClick:h})])])],4)):p("",!0),e("div",Ye,[s(m)?p("",!0):(i(),r("div",Ge,[o[5]||(o[5]=e("h1",{class:"text-3xl font-bold text-gray-900"},"My Dogs",-1)),e("div",Oe,[S(u,{to:"/vets",class:"bg-gray-100 hover:bg-gray-200 text-gray-800 px-4 py-2 rounded-lg font-semibold transition-colors"},{default:R(()=>[...o[4]||(o[4]=[T(" ð¥ Vets ",-1)])]),_:1}),e("button",{type:"button",onClick:U,class:"bg-blue-600 hover:bg-blue-700 text-white px-6 py-2 rounded-lg font-semibold transition-colors"}," + Add Dog "),S(b,{"hint-class":"text-slate-600 border-slate-400",onClick:h})])])),s(D)?(i(),r("div",{key:1,class:j(["mb-6 rounded-lg border px-4 py-3 text-sm",s(P)?"border-red-200 bg-red-50 text-red-700":"border-green-200 bg-green-50 text-green-800"])},c(s(D)),3)):p("",!0),s(w)?(i(),r("div",Ke,[...o[6]||(o[6]=[e("div",{class:"inline-block animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600"},null,-1),e("p",{class:"mt-4 text-gray-600"},"Loading your dogs...",-1)])])):s(x)?(i(),r("div",He,c(s(x)),1)):!s(g)||s(g).length===0?(i(),r("div",Qe,[s(C)?(i(),r("div",We,[s(C)?(i(),r("img",{key:0,src:s(C).url,alt:s(C).description||"Happy dog",width:"256",height:"256",class:"w-64 h-64 mx-auto rounded-full object-cover",loading:"lazy",decoding:"async"},null,8,Je)):p("",!0)])):(i(),r("div",Xe,"ð")),o[7]||(o[7]=e("h2",{class:"text-2xl font-semibold text-gray-900 mb-2"},"No dogs yet",-1)),o[8]||(o[8]=e("p",{class:"text-gray-600 mb-4"},"Start by adding your first furry friend! Tracking your dog's health information helps ensure they live a long, happy, and healthy life.",-1)),o[9]||(o[9]=e("p",{class:"text-sm text-gray-500 mb-6"},"You can track vaccinations, medications, appointments, health records, and more for each of your dogs.",-1)),e("div",Ze,[e("button",{type:"button",onClick:U,class:"inline-block bg-blue-600 hover:bg-blue-700 text-white px-6 py-3 rounded-lg font-semibold transition-colors"}," Add Your First Dog "),S(b,{"hint-class":"text-slate-600 border-slate-400",onClick:h})])])):(i(),r("div",et,[(i(!0),r(se,null,oe(s(g),t=>(i(),r("div",{key:t.id,class:"bg-white rounded-lg shadow-md overflow-hidden hover:shadow-lg transition-shadow"},[e("div",tt,[t.photoUrl?(i(),r("img",{key:0,src:t.photoUrl,alt:t.name,width:"400",height:"320",class:"w-full h-full object-cover",loading:"lazy",decoding:"async"},null,8,st)):(i(),r("div",ot," ð "))]),e("div",at,[e("h3",nt,c(t.name),1),e("div",lt,[t.breed?(i(),r("p",rt,c(t.breed),1)):p("",!0),t.gender?(i(),r("p",it,c(t.gender),1)):p("",!0),t.birthDate?(i(),r("p",dt,c(I(t.birthDate)),1)):p("",!0),t.weightKg?(i(),r("p",ut,c(t.weightKg)+" kg",1)):p("",!0)]),e("div",ct,[S(u,{to:`/dogs/${t.id}`,class:"flex-1 bg-blue-600 hover:bg-blue-700 text-white text-center px-4 py-2 rounded-lg font-semibold transition-colors"},{default:R(()=>[...o[10]||(o[10]=[T(" View Details ",-1)])]),_:1},8,["to"]),S(u,{to:`/dogs/${t.id}/edit`,class:"bg-gray-200 hover:bg-gray-300 text-gray-800 px-4 py-2 rounded-lg font-semibold transition-colors"},{default:R(()=>[...o[11]||(o[11]=[T(" Edit ",-1)])]),_:1},8,["to"])])])]))),128))]))]),S(n,{open:s(a),"existing-dog-count":s(g).length,onClose:o[
10]||(o[0]=t=>a.value=!1),onCreated:q},null,8,["open","existing-dog-count"])])}}});export{ft 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.