1import{f as W,u as X,r as c,t as p,b as i,j as e,A as Y,n as v,C as b,c as w,d as y,B as m,e as h}from"./index-bM8UT4Os.js";import{I as $}from"./input-BwpLlRYf.js";import{L as F}from"./label-2Seh_wFH.js";import{T as Z}from"./textarea-DArC7VX4.js";import{P as z}from"./plus-DSaqw8wa.js";import{U as _}from"./upload-BrcrR4wG.js";import{I as ee}from"./image-CNPVod1c.js";import{C as se}from"./chevron-left-Bx_6cTqG.js";import{C as te}from"./chevron-right-RXMaR5IV.js";import{T as re}from"./trash-2-4iirX7DH.js";import"./dialog-CxcTDVnZ.js";import"./useComposition-DO5dIJEj.js";/** 2 * @license lucide-react v0.453.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 ae=W("ArrowLeftRight",[["path",{d:"M8 3 4 7l4 4",key:"9rb6wj"}],["path",{d:"M4 7h16",key:"6tx8e3"}],["path",{d:"m16 21 4-4-4-4",key:"siv7j2"}],["path",{d:"M20 17H4",key:"h6l3hr"}]]);function he(){X();const[E,P]=c.useState(!1),[a,f]=c.useState(0),[C,k]=c.useState(!1),[D,S]=c.useState(null),[x,U]=c.useState(null),[l,u]=c.useState({weight:"",bodyFatPercentage:"",notes:""}),M=c.useRef(null),[d,H]=c.useState(!1),[j,I]=c.useState(null),[A,L]=c.useState(null),{data:r,refetch:T}=p.progress.getAll.useQuery(),{data:R}=p.progress.getComparison.useQuery(),N=p.progress.add.useMutation({onSuccess:()=>{i.success("é²åº¦ç¸å·²å³å¥½ï¼ð¸"),B(),T()},onError:()=>{i.error("å³åå°ï¼è©¦å¤æ¬¡å¦")}}),K=p.progress.delete.useMutation({onSuccess:()=>{i.success("å·²åªåå²"),T()},onError:()=>{i.error("åªåå°ï¼è©¦å¤æ¬¡å¦")}}),B=()=>{u({weight:"",bodyFatPercentage:"",notes:""}),P(!1),S(null),U(null)},G=s=>{const t=s.target.files?.[0];if(!t)return;if(t.size>10*1024*1024){i.error("ç¸ç太大åï¼æå¤§ 10MB");return}U(t);const g=new FileReader;g.onload=o=>{S(o.target?.result)},g.readAsDataURL(t)},J=async s=>{if(s.preventDefault(),!x){i.error("å æå¼µç¸å å¦");return}k(!0);try{const t=new FileReader;t.onload=async g=>{const o=(g.target?.result).split(",")[1],n=await fetch("/api/upload-progress-photo",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({imageBase64:o,mimeType:x.type})});if(!n.ok)throw new Error("Upload failed");const{url:V}=await n.json();await N.mutateAsync({photoUrl:V,photoDate:new Date,weight:l.weight?parseFloat(l.weight):void 0,bodyFatPercentage:l.bodyFatPercentage?parseFloat(l.bodyFatPercentage):void 0,notes:l.notes||void 0})},t.readAsDataURL(x)}catch{i.error("å³åå°ï¼è©¦å¤æ¬¡å¦")}finally{k(!1)}},O=s=>{confirm("çä¿è¦åªå¢å¼µç¸ï¼")&&K.mutate({id:s})},Q=()=>{a>0&&f(a-1)},q=()=>{r&&a<r.length-1&&f(a+1)};return e.jsx(Y,{"data-loc":"client/src/pages/ProgressAlbum.tsx:147",title:"é²åº¦ç¸ç°¿",showBack:!0,children:e.jsx("div",{"data-loc":"client/src/pages/ProgressAlbum.tsx:148",className:"py-6 px-4",children:e.jsxs("div",{"data-loc":"client/src/pages/ProgressAlbum.tsx:149",className:"max-w-2xl mx-auto space-y-5",children:[e.jsxs("div",{"data-loc":"client/src/pages/ProgressAlbum.tsx:151",className:"text-left",children:[e.jsxs("h1",{"data-loc":"client/src/pages/ProgressAlbum.tsx:152",className:"text-2xl md:text-3xl font-bold text-foreground flex items-center gap-2",children:[e.jsx(v,{"data-loc":"client/src/pages/ProgressAlbum.tsx:153",className:"w-6 h-6 text-rose-500"}),"é²åº¦ç¸ç°¿"]}),e.jsx("p",{"data-loc":"client/src/pages/ProgressAlbum.tsx:156",className:"text-sm text-muted-foreground mt-1",children:"å®æèªæï¼è¨é身é«è®åï¼è¦è鲿¥ ðª"})]}),r&&r.length>=2&&e.jsxs(b,{"data-loc":"client/src/pages/ProgressAlbum.tsx:163",className:"card-premium",children:[e.jsx(w,{"data-loc":"client/src/pages/ProgressAlbum.tsx:164",className:"pb-2",children:e.jsxs("div",{"data-loc":"client/src/pages/ProgressAlbum.tsx:165",className:"flex items-center justify-between",children:[e.jsxs(y,{"data-loc":"client/src/pages/ProgressAlbum.tsx:166",className:"text-base text-foreground flex items-center gap-2",children:[e.jsx(ae,{"data-loc":"client/src/pages/ProgressAlbum.tsx:167",className:"w-4 h-4"}),d?"æç¸å°æ¯":"ð åå¾å°æ¯"]}),e.jsx(m,{"data-loc":"client/src/pages/ProgressAlbum.tsx:170",variant:"ghost",size:"sm",onClick:()=>{H(!d),d||(I(r.length-1),L(0))},className:"text-xs text-rose-400 hover:text-rose-300",children:d?"æ¶èµ·":"èªè¨å°æ¯"})]})}),e.jsx(h,{"data-loc":"client/src/pages/ProgressAlbum.tsx:187",children:(()=>{const s=d&&j!==null?r[j]:R?.before,t=d&&A!==null?r[A]:R?.after;if(!s||!t)return null;const g=Math.round((new Date(t.photoDate).getTime()-new Date(s.photoDate).getTime())/(1e3*60*60*24));return e.jsxs(e.Fragment,{children:[e.jsx("div",{"data-loc":"client/src/pages/ProgressAlbum.tsx:205",className:"text-center mb-3",children:e.jsxs("span",{"data-loc":"client/src/pages/ProgressAlbum.tsx:206",className:"inline-flex items-center gap-1 px-3 py-1 rounded-full bg-rose-500/20 text-rose-400 text-sm font-bold",children:["Day ",Math.abs(g)]})}),e.jsxs("div",{"data-loc":"client/src/pages/ProgressAlbum.tsx:211",className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{"data-loc":"client/src/pages/ProgressAlbum.tsx:213",className:"text-center",children:[e.jsx("div",{"data-loc":"client/src/pages/ProgressAlbum.tsx:214",className:"mb-2 bg-secondary rounded-lg overflow-hidden h-48 flex items-center justify-center",children:e.jsx("img",{"data-loc":"client/src/pages/ProgressAlbum.tsx:215",src:s.photoUrl,alt:"ä¹å",className:"w-full h-full object-cover"})}),e.jsx("p",{"data-loc":"client/src/pages/ProgressAlbum.tsx:221",className:"text-xs text-muted-foreground font-medium",children:"ä¹å"}),e.jsx("p",{"data-loc":"client/src/pages/ProgressAlbum.tsx:222",className:"text-xs text-muted-foreground",children:new Date(s.photoDate).toLocaleDateString("zh-HK")}),s.weight&&e.jsxs("p",{"data-loc":"client/src/pages/ProgressAlbum.tsx:226",className:"text-xs text-foreground
6/80 mt-1",children:[Number(s.weight)," kg"]})]}),e.jsxs("div",{"data-loc":"client/src/pages/ProgressAlbum.tsx:231",className:"text-center",children:[e.jsx("div",{"data-loc":"client/src/pages/ProgressAlbum.tsx:232",className:"mb-2 bg-secondary rounded-lg overflow-hidden h-48 flex items-center justify-center border-2 border-rose-500/50",children:e.jsx("img",{"data-loc":"client/src/pages/ProgressAlbum.tsx:233",src:t.photoUrl,alt:"ç¾å¨",className:"w-full h-full object-cover"})}),e.jsx("p",{"data-loc":"client/src/pages/ProgressAlbum.tsx:239",className:"text-xs text-rose-400 font-semibold",children:"èå®¶"}),e.jsx("p",{"data-loc":"client/src/pages/ProgressAlbum.tsx:240",className:"text-xs text-muted-foreground",children:new Date(t.photoDate).toLocaleDateString("zh-HK")}),t.weight&&e.jsxs("p",{"data-loc":"client/src/pages/ProgressAlbum.tsx:244",className:"text-xs text-foreground/80 mt-1",children:[Number(t.weight)," kg"]})]})]}),s.weight&&t.weight&&e.jsxs("div",{"data-loc":"client/src/pages/ProgressAlbum.tsx:251",className:"mt-3 pt-3 border-t border-border grid grid-cols-2 gap-3",children:[e.jsxs("div",{"data-loc":"client/src/pages/ProgressAlbum.tsx:252",className:"bg-primary/10 p-2 rounded-lg text-center",children:[e.jsx("p",{"data-loc":"client/src/pages/ProgressAlbum.tsx:253",className:"text-xs text-muted-foreground",children:"é«éè®å"}),e.jsxs("p",{"data-loc":"client/src/pages/ProgressAlbum.tsx:254",className:"text-sm font-bold text-primary",children:[Number(t.weight)-Number(s.weight)>0?"+":"",(Number(t.weight)-Number(s.weight)).toFixed(1)," kg"]})]}),s.bodyFatPercentage&&t.bodyFatPercentage&&e.jsxs("div",{"data-loc":"client/src/pages/ProgressAlbum.tsx:260",className:"bg-green-500/10 p-2 rounded-lg text-center",children:[e.jsx("p",{"data-loc":"client/src/pages/ProgressAlbum.tsx:261",className:"text-xs text-muted-foreground",children:"é«èè®å"}),e.jsxs("p",{"data-loc":"client/src/pages/ProgressAlbum.tsx:262",className:`text-sm font-bold ${Number(t.bodyFatPercentage)-Number(s.bodyFatPercentage)<0?"text-green-400":"text-orange-400"}`,children:[Number(t.bodyFatPercentage)-Number(s.bodyFatPercentage)>0?"+":"",(Number(t.bodyFatPercentage)-Number(s.bodyFatPercentage)).toFixed(1),"%"]})]})]}),d&&e.jsxs("div",{"data-loc":"client/src/pages/ProgressAlbum.tsx:276",className:"mt-4 pt-3 border-t border-border",children:[e.jsx("p",{"data-loc":"client/src/pages/ProgressAlbum.tsx:277",className:"text-xs text-muted-foreground mb-2 text-center",children:"æå
©å¼µç¸å°æ¯ï¼æ³ç¸®ååæï¼"}),e.jsxs("div",{"data-loc":"client/src/pages/ProgressAlbum.tsx:278",className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{"data-loc":"client/src/pages/ProgressAlbum.tsx:280",children:[e.jsx("p",{"data-loc":"client/src/pages/ProgressAlbum.tsx:281",className:"text-xs text-muted-foreground mb-1 text-center",children:"ä¹å"}),e.jsx("div",{"data-loc":"client/src/pages/ProgressAlbum.tsx:282",className:"grid grid-cols-4 gap-1",children:r.map((o,n)=>e.jsx("button",{"data-loc":"client/src/pages/ProgressAlbum.tsx:284",onClick:()=>I(n),className:`rounded overflow-hidden h-10 border-2 transition-all ${n===j?"border-blue-400 scale-105":"border-border opacity-60 hover:opacity-100"}`,children:e.jsx("img",{"data-loc":"client/src/pages/ProgressAlbum.tsx:291",src:o.photoUrl,alt:"",className:"w-full h-full object-cover"})},`before-${o.id}`))})]}),e.jsxs("div",{"data-loc":"client/src/pages/ProgressAlbum.tsx:297",children:[e.jsx("p",{"data-loc":"client/src/pages/ProgressAlbum.tsx:298",className:"text-xs text-muted-foreground mb-1 text-center",children:"èå®¶"}),e.jsx("div",{"data-loc":"client/src/pages/ProgressAlbum.tsx:299",className:"grid grid-cols-4 gap-1",children:r.map((o,n)=>e.jsx("button",{"data-loc":"client/src/pages/ProgressAlbum.tsx:301",onClick:()=>L(n),className:`rounded overflow-hidden h-10 border-2 transition-all ${n===A?"border-rose-400 scale-105":"border-border opacity-60 hover:opacity-100"}`,children:e.jsx("img",{"data-loc":"client/src/pages/ProgressAlbum.tsx:308",src:o.photoUrl,alt:"",className:"w-full h-full object-cover"})},`after-${o.id}`))})]})]})]})]})})()})]}),E?e.jsxs(b,{"data-loc":"client/src/pages/ProgressAlbum.tsx:333",children:[e.jsx(w,{"data-loc":"client/src/pages/ProgressAlbum.tsx:334",className:"pb-3",children:e.jsxs(y,{"data-loc":"client/src/pages/ProgressAlbum.tsx:335",className:"text-lg flex items-center gap-2",children:[e.jsx(_,{"data-loc":"client/src/pages/ProgressAlbum.tsx:336",className:"w-4 h-4"}),"å³é²åº¦ç¸"]})}),e.jsx(h,{"data-loc":"client/src/pages/ProgressAlbum.tsx:340",children:e.jsxs("form",{"data-loc":"client/src/pages/ProgressAlbum.tsx:341",onSubmit:J,className:"space-y-4",children:[e.jsx("div",{"data-loc":"client/src/pages/ProgressAlbum.tsx:343",onClick:()=>M.current?.click(),className:"border-2 border-dashed border-rose-500/30 rounded-lg p-6 text-center cursor-pointer hover:border-rose-500/60 transition-colors",children:D?e.jsxs("div",{"data-loc":"client/src/pages/ProgressAlbum.tsx:348",className:"relative",children:[e.jsx("img",{"data-loc":"client/src/pages/ProgressAlbum.tsx:349",src:D,alt:"Preview",className:"max-h-48 mx-auto rounded-lg"}),e.jsx("p",{"data-loc":"client/src/pages/ProgressAlbum.tsx:350",className:"text-xs text-muted-foreground mt-2",children:"é»ææ´æç¸ç"})]}):e.jsxs(e.Fragment,{children:[e.jsx(v,{"data-loc":"client/src/pages/ProgressAlbum.tsx:354",className:"w-10 h-10 text-rose-400 mx-auto mb-2"}),e.jsx("p",{"data-loc":"client/src/pages/ProgressAlbum.tsx:355",className:"text-sm text-foreground
6/80",children:"黿æç¸ / å½±ç¸"}),e.jsx("p",{"data-loc":"client/src/pages/ProgressAlbum.tsx:356",className:"text-xs text-muted-foreground mt-1",children:"æ¯æ´ JPGãPNGï¼æå¤§ 10MBï¼"})]})}),e.jsx("input",{"data-loc":"client/src/pages/ProgressAlbum.tsx:360",ref:M,type:"file",accept:"image/*",onChange:G,className:"hidden"}),e.jsxs("div",{"data-loc":"client/src/pages/ProgressAlbum.tsx:369",className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{"data-loc":"client/src/pages/ProgressAlbum.tsx:370",children:[e.jsx(F,{"data-loc":"client/src/pages/ProgressAlbum.tsx:371",className:"text-sm",children:"é«é (kg)"}),e.jsx($,{"data-loc":"client/src/pages/ProgressAlbum.tsx:372",type:"number",step:"0.1",placeholder:"ä¾å¦ 65.5",value:l.weight,onChange:s=>u({...l,weight:s.target.value}),className:"mt-1"})]}),e.jsxs("div",{"data-loc":"client/src/pages/ProgressAlbum.tsx:381",children:[e.jsx(F,{"data-loc":"client/src/pages/ProgressAlbum.tsx:382",className:"text-sm",children:"é«èç (%)"}),e.jsx($,{"data-loc":"client/src/pages/ProgressAlbum.tsx:383",type:"number",step:"0.1",placeholder:"ä¾å¦ 18.5",value:l.bodyFatPercentage,onChange:s=>u({...l,bodyFatPercentage:s.target.value}),className:"mt-1"})]})]}),e.jsxs("div",{"data-loc":"client/src/pages/ProgressAlbum.tsx:395",children:[e.jsx(F,{"data-loc":"client/src/pages/ProgressAlbum.tsx:396",className:"text-sm",children:"å註"}),e.jsx(Z,{"data-loc":"client/src/pages/ProgressAlbum.tsx:397",placeholder:"ä¾å¦ï¼æè¦ºèèæ´çµå¯¦å",value:l.notes,onChange:s=>u({...l,notes:s.target.value}),rows:2,className:"mt-1"})]}),e.jsxs("div",{"data-loc":"client/src/pages/ProgressAlbum.tsx:407",className:"flex gap-3",children:[e.jsx(m,{"data-loc":"client/src/pages/ProgressAlbum.tsx:408",type:"submit",className:"flex-1 bg-rose-500 hover:bg-rose-600",disabled:C||N.isPending||!x,children:C||N.isPending?"å³ç·...":"å³ä¸å» ð¸"}),e.jsx(m,{"data-loc":"client/src/pages/ProgressAlbum.tsx:415",type:"button",variant:"outline",onClick:B,children:"ç®å¦"})]})]})})]}):e.jsxs(m,{"data-loc":"client/src/pages/ProgressAlbum.tsx:325",onClick:()=>P(!0),className:"w-full bg-rose-500 hover:bg-rose-600 text-foreground py-5",children:[e.jsx(z,{"data-loc":"client/src/pages/ProgressAlbum.tsx:329",className:"w-5 h-5 mr-2"}),"影張é²åº¦ç¸"]}),r&&r.length>0?e.jsxs(b,{"data-loc":"client/src/pages/ProgressAlbum.tsx:426",children:[e.jsx(w,{"data-loc":"client/src/pages/ProgressAlbum.tsx:427",className:"pb-3",children:e.jsxs(y,{"data-loc":"client/src/pages/ProgressAlbum.tsx:428",className:"text-lg flex items-center gap-2",children:[e.jsx(ee,{"data-loc":"client/src/pages/ProgressAlbum.tsx:429",className:"w-4 h-4"}),"æéç· (",r.length," å¼µ)"]})}),e.jsxs(h,{"data-loc":"client/src/pages/ProgressAlbum.tsx:433",children:[e.jsxs("div",{"data-loc":"client/src/pages/ProgressAlbum.tsx:435",className:"relative mb-4",children:[e.jsx("div",{"data-loc":"client/src/pages/ProgressAlbum.tsx:436",className:"bg-secondary rounded-lg overflow-hidden h-72 flex items-center justify-center",children:e.jsx("img",{"data-loc":"client/src/pages/ProgressAlbum.tsx:437",src:r[a].photoUrl,alt:`Progress ${a+1}`,className:"w-full h-full object-contain"})}),r.length>1&&e.jsxs(e.Fragment,{children:[e.jsx("button",{"data-loc":"client/src/pages/ProgressAlbum.tsx:447",onClick:Q,disabled:a===0,className:"absolute left-2 top-1/2 -translate-y-1/2 bg-black/60 hover:bg-black/80 p-2 rounded-full disabled:opacity-30 text-foreground",children:e.jsx(se,{"data-loc":"client/src/pages/ProgressAlbum.tsx:452",className:"w-5 h-5"})}),e.jsx("button",{"data-loc":"client/src/pages/ProgressAlbum.tsx:454",onClick:q,disabled:a===r.length-1,className:"absolute right-2 top-1/2 -translate-y-1/2 bg-black/60 hover:bg-black/80 p-2 rounded-full disabled:opacity-30 text-foreground",children:e.jsx(te,{"data-loc":"client/src/pages/ProgressAlbum.tsx:459",className:"w-5 h-5"})})]})]}),e.jsx("div",{"data-loc":"client/src/pages/ProgressAlbum.tsx:466",className:"bg-secondary/60 p-3 rounded-lg mb-4",children:e.jsxs("div",{"data-loc":"client/src/pages/ProgressAlbum.tsx:467",className:"flex justify-between items-start",children:[e.jsxs("div",{"data-loc":"client/src/pages/ProgressAlbum.tsx:468",children:[e.jsx("p",{"data-loc":"client/src/pages/ProgressAlbum.tsx:469",className:"text-sm text-foreground
6/80",children:new Date(r[a].photoDate).toLocaleDateString("zh-HK",{year:"numeric",month:"long",day:"numeric"})}),e.jsxs("div",{"data-loc":"client/src/pages/ProgressAlbum.tsx:476",className:"flex gap-3 mt-1",children:[r[a].weight&&e.jsxs("span",{"data-loc":"client/src/pages/ProgressAlbum.tsx:478",className:"text-xs text-blue-300",children:[r[a].weight," kg"]}),r[a].bodyFatPercentage&&e.jsxs("span",{"data-loc":"client/src/pages/ProgressAlbum.tsx:481",className:"text-xs text-green-300",children:[r[a].bodyFatPercentage,"% é«è"]})]}),r[a].notes&&e.jsx("p",{"data-loc":"client/src/pages/ProgressAlbum.tsx:485",className:"text-xs text-muted-foreground mt-1",children:r[a].notes})]}),e.jsx(m,{"data-loc":"client/src/pages/ProgressAlbum.tsx:488",variant:"ghost",size:"sm",onClick:()=>O(r[a].id),className:"text-muted-foreground hover:text-red-400",children:e.jsx(re,{"data-loc":"client/src/pages/ProgressAlbum.tsx:494",className:"w-4 h-4"})})]})}),e.jsx("div",{"data-loc":"client/src/pages/ProgressAlbum.tsx:500",className:"grid grid-cols-5 gap-2",children:r.map((s,t)=>e.jsx("button",{"data-loc":"client/src/pages/ProgressAlbum.tsx:502",onClick:()=>f(t),className:`relative rounded-lg overflow-hidden h-16 border-2 transition-all ${t===a?"border-rose-500":"border-border"}`,children:e.jsx("img",{"data-loc":"client/src/pages/ProgressAlbum.tsx:509",src:s.photoUrl,alt:`Thumbnail ${t+1}`,className:"w-full h-full object-cover"})},s.id))})]})]}):e.jsx(b,{"data-loc":"client/src/pages/ProgressAlbum.tsx:520",children:e.jsxs(h,{"data-loc":"client/src/pages/ProgressAlbum.tsx:521",className:"pt-10 pb-10 text-center",children:[e.jsx(v,{"data-loc":"client/src/pages/ProgressAlbum.tsx:522",className:"w-12 h-12 text-foreground/70 mx-auto mb-3"}),e.jsx("p",{"data-loc":"client/src/pages/ProgressAlbum.tsx:523",className:"text-muted-foreground mb-1",children:"ä»²æªæé²åº¦ç¸"}),e.jsx("p",{"data-loc":"client/src/pages/ProgressAlbum.tsx:524",className:"text-xs text-muted-foreground mb-4",children:"éå§å½±ç¬¬ä¸å¼µé²åº¦ç¸ï¼è¨éä½ å
å¥èº«ä¹æ
"}),e.jsxs(m,{"data-loc":"client/src/pages/ProgressAlbum.tsx:525",onClick:()=>P(!0),className:"bg-rose-500 hover:bg-rose-600",children:[e.jsx(z,{"data-loc":"client/src/pages/ProgressAlbum.tsx:529",className:"w-4 h-4 mr-2"}),"影張ç¸"]})]})})]})})})}export{he 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.