1import{f as X,u as ka,a as Sa,r,t as f,b as m,j as e,A as Ca,F as Je,C as A,c as Xe,d as Ze,q as ea,e as Se,B as o,v as K,L as Da,n as Fa,X as Ce,ao as aa}from"./index-bM8UT4Os.js";import{I as p}from"./input-BwpLlRYf.js";import{L as w}from"./label-2Seh_wFH.js";import{S as V,a as q,b as Q,c as W,d as u}from"./select-CDP2pHh8.js";import{S as ta}from"./ShareStoryCard-DlVZW7GD.js";import{S as sa}from"./html2canvas-pro.esm-DOKDsR1V.js";import{C as Ta}from"./calendar-days-D6maf-Ok.js";import{C as $a}from"./chevron-left-Bx_6cTqG.js";import{C as Ia}from"./chevron-right-RXMaR5IV.js";import{P as De}from"./plus-DSaqw8wa.js";import{S as Pa}from"./search-DTymBQkO.js";import{B as za}from"./bookmark-Dym4i0oW.js";import{T as J}from"./trash-2-4iirX7DH.js";import{C as Aa}from"./chevron-up-TG6jWiKP.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 Ea=X("Filter",[["polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3",key:"1yg77f"}]]);/** 7 * @license lucide-react v0.453.0 - ISC 8 * 9 * This source code is licensed under the ISC license. 10 * See the LICENSE file in the root directory of this source tree. 11 */const Ha=X("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);/** 12 * @license lucide-react v0.453.0 - ISC 13 * 14 * This source code is licensed under the ISC license. 15 * See the LICENSE file in the root directory of this source tree. 16 */const Ua=X("Pen",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]]);/** 17 * @license lucide-react v0.453.0 - ISC 18 * 19 * This source code is licensed under the ISC license. 20 * See the LICENSE file in the root directory of this source tree. 21 */const Ba=X("Store",[["path",{d:"m2 7 4.41-4.41A2 2 0 0 1 7.83 2h8.34a2 2 0 0 1 1.42.59L22 7",key:"ztvudi"}],["path",{d:"M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8",key:"1b2hhj"}],["path",{d:"M15 22v-4a2 2 0 0 0-2-2h-2a2 2 0 0 0-2 2v4",key:"2ebpfo"}],["path",{d:"M2 7h20",key:"1fcdvo"}],["path",{d:"M22 7v3a2 2 0 0 1-2 2a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 16 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 12 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 8 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 4 12a2 2 0 0 1-2-2V7",key:"6c3vgh"}]]),Fe={mcdonalds:{name:"麥ç¶å",items:[{name:"å·¨ç¡é¸",calories:563,protein:26,carbs:45,fat:33},{name:"麥é¦é",calories:450,protein:15,carbs:43,fat:25},{name:"麥辣éè ¿å ",calories:520,protein:22,carbs:46,fat:28},{name:"è¯æ¢ï¼ä¸ï¼",calories:340,protein:4,carbs:44,fat:16},{name:"è¯æ¢ï¼å¤§ï¼",calories:444,protein:5,carbs:57,fat:21},{name:"é翼ï¼4ä»¶ï¼",calories:440,protein:28,carbs:16,fat:30},{name:"麥ç¸éï¼2ä»¶ï¼",calories:410,protein:30,carbs:18,fat:24},{name:"豬æ³èæ¼¢å ¡",calories:430,protein:18,carbs:35,fat:24},{name:"éæ³å ",calories:380,protein:15,carbs:38,fat:18},{name:"èææ¹",calories:240,protein:2,carbs:34,fat:11}]},cafeDeCoral:{name:"大家æ¨",items:[{name:"çå³éæ¼é£¯",calories:780,protein:35,carbs:85,fat:32},{name:"åç飯",calories:650,protein:28,carbs:80,fat:22},{name:"çéµé£¯",calories:720,protein:30,carbs:78,fat:30},{name:"åå±çè ©é£¯",calories:700,protein:25,carbs:82,fat:28},{name:"ææ´²çç±³",calories:620,protein:18,carbs:75,fat:26},{name:"ä¹¾ççæ²³",calories:680,protein:22,carbs:72,fat:32},{name:"é翼飯",calories:650,protein:30,carbs:76,fat:24},{name:"éèç²",calories:380,protein:15,carbs:55,fat:10},{name:"åæª¸è¶",calories:120,protein:0,carbs:30,fat:0},{name:"ç±å¥¶è¶",calories:150,protein:3,carbs:22,fat:6},{name:"䏿éæé£¯ï¼å¥åº·é¤ï¼",calories:520,protein:35,carbs:55,fat:16},{name:"ç¡éª¨éæ³é£¯ï¼å¥åº·é¤ï¼",calories:480,protein:38,carbs:50,fat:12},{name:"éè¸æ²å¾ï¼å¥åº·é¤ï¼",calories:350,protein:32,carbs:25,fat:12},{name:"è¸é飯ï¼å¥åº·é¤ï¼",calories:450,protein:30,carbs:52,fat:10}]},fairwood:{name:"大快活",items:[{name:"鵿¿é¤ï¼éæï¼",calories:620,protein:32,carbs:65,fat:24},{name:"鵿¿é¤ï¼è±¬æï¼",calories:680,protein:28,carbs:68,fat:30},{name:"ç豬æé£¯",calories:750,protein:30,carbs:82,fat:32},{name:"æ¥å¼åå±é£¯",calories:650,protein:22,carbs:80,fat:25},{name:"鿳飝",calories:580,protein:24,carbs:72,fat:20},{name:"éé«é£¯",calories:700,protein:35,carbs:75,fat:28},{name:"çè飯",calories:680,protein:30,carbs:78,fat:26},{name:"䏿é飯ï¼å¥åº·é¤ï¼",calories:490,protein:33,carbs:52,fat:14},{name:"éè¸é£¯ï¼å¥åº·é¤ï¼",calories:450,protein:36,carbs:48,fat:10},{name:"éæ³æ²å¾ï¼å¥åº·é¤ï¼",calories:320,protein:30,carbs:18,fat:14},{name:"ç¡éª¨éæ³é£¯ï¼å¥åº·é¤ï¼",calories:460,protein:35,carbs:50,fat:11}]},kfc:{name:"KFC",items:[{name:"å®¶ééï¼1ä»¶ï¼",calories:260,protein:18,carbs:10,fat:17},{name:"è¾£èéï¼1ä»¶ï¼",calories:280,protein:17,carbs:14,fat:18},{name:"é翼ï¼2ä»¶ï¼",calories:320,protein:20,carbs:12,fat:22},{name:"è¯æ¢ï¼ä¸ï¼",calories:330,protein:4,carbs:42,fat:16},{name:"éèå·",calories:480,protein:22,carbs:45,fat:24},{name:"è¡æ»",calories:220,protein:4,carbs:26,fat:12},{name:"ç²ç±³ï¼ä¸ï¼",calories:140,protein:4,carbs:28,fat:2}]},yoshinoya:{name:"åéå®¶",items:[{name:"çè飯ï¼ä¸¦ï¼",calories:650,protein:22,carbs:82,fat:24},{name:"çè飯ï¼å¤§ï¼",calories:850,protein:30,carbs:105,fat:32},{name:"éè飯",calories:580,protein:28,carbs:75,fat:18},{name:"åå±çè飯",calories:720,protein:24,carbs:88,fat:28},{name:"䏿é飯",calories:550,protein:26,carbs:72,fat:16},{name:"å³å湯",calories:45,protein:3,carbs:4,fat:2}]},maxims:{name:"ç¾å¿ MX",items:[{name:"åç飯",calories:630,protein:26,carbs:78,fat:22},{name:"çè飯",calories:700,protein:28,carbs:80,fat:28},{name:"ååè飯",calories:680,protein:20,carbs:85,fat:26},{name:"è¸é£¯ï¼æéª¨ï¼",calories:550,protein:22,carbs:72,fat:18}
21,{name:"é²å麵",calories:420,protein:18,carbs:55,fat:14},{name:"西å¤å£«",calories:380,protein:8,carbs:42,fat:20}]},tamjai:{name:"èä»ä¸å¥",items:[{name:"åå æ¹¯åºç±³ç·ï¼è±¬èçï¼",calories:420,protein:22,carbs:55,fat:12},{name:"麻辣湯åºç±³ç·ï¼éè¸ï¼",calories:380,protein:32,carbs:48,fat:8},{name:"æ¸
湯米ç·ï¼çèï¼",calories:450,protein:28,carbs:52,fat:14},{name:"å¬è湯åºç±³ç·ï¼è±¬èçï¼",calories:400,protein:20,carbs:50,fat:12},{name:"å åºéè¸ï¼å®é»ï¼",calories:120,protein:24,carbs:0,fat:2},{name:"å åºç丸ï¼å®é»ï¼",calories:150,protein:18,carbs:3,fat:7},{name:"å åºè±¬èçï¼å®é»ï¼",calories:130,protein:16,carbs:1,fat:7},{name:"å åºå¢¨é丸ï¼å®é»ï¼",calories:90,protein:10,carbs:8,fat:3},{name:"å¥åº·é¤ï¼éè¸ç±³ç·ï¼æ¸
湯ï¼",calories:340,protein:34,carbs:40,fat:5},{name:"å¥åº·é¤ï¼ä¸æéç±³ç·ï¼æ¸
湯ï¼",calories:380,protein:30,carbs:42,fat:10},{name:"å¥åº·é¤ï¼éæ³ç±³ç·ï¼æ¸
湯ï¼",calories:350,protein:32,carbs:42,fat:6}]},subway:{name:"Subway",items:[{name:"éè¸è 6åï¼å
¨éº¥ï¼",calories:320,protein:28,carbs:38,fat:6},{name:"ç«éè¸ 6åï¼å
¨éº¥ï¼",calories:280,protein:20,carbs:40,fat:4},{name:"éæ§é 6å",calories:380,protein:22,carbs:42,fat:14},{name:"義å¼è丸 6å",calories:450,protein:24,carbs:44,fat:20},{name:"éè¸è 12åï¼å
¨éº¥ï¼",calories:640,protein:56,carbs:76,fat:12},{name:"ç°åæ²æ",calories:180,protein:12,carbs:14,fat:8},{name:"æ²å¥é¤
",calories:210,protein:2,carbs:28,fat:10}]},matsuya:{name:"æ¾å±",items:[{name:"ç½ä¸¹ç丼ï¼ä¸¦ï¼",calories:680,protein:24,carbs:85,fat:26},{name:"ç½ä¸¹ç丼ï¼å¤§ï¼",calories:900,protein:32,carbs:110,fat:35},{name:"豬æå®é£",calories:750,protein:35,carbs:78,fat:30},{name:"éæå®é£",calories:680,protein:38,carbs:72,fat:22},{name:"çèå®é£",calories:720,protein:30,carbs:80,fat:28},{name:"å³åæ±",calories:40,protein:3,carbs:4,fat:1},{name:"溫æ³è",calories:70,protein:6,carbs:1,fat:5}]},sushiro:{name:"壽å¸é",items:[{name:"䏿é壽å¸ï¼2貫ï¼",calories:120,protein:8,carbs:14,fat:4},{name:"åæ¿å£½å¸ï¼2貫ï¼",calories:110,protein:9,carbs:14,fat:3},{name:"è¦å£½å¸ï¼2貫ï¼",calories:90,protein:7,carbs:14,fat:1},{name:"ç䏿éè
¹ï¼2貫ï¼",calories:140,protein:7,carbs:14,fat:6},{name:"帶åè»è¦ï¼2貫ï¼",calories:130,protein:8,carbs:16,fat:4},{name:"çåçï¼2貫ï¼",calories:100,protein:5,carbs:16,fat:2},{name:"豬骨湯æéºµ",calories:520,protein:22,carbs:65,fat:18},{name:"è¶ç¢è¸",calories:80,protein:6,carbs:5,fat:4},{name:"æè±ï¼å°ï¼",calories:120,protein:10,carbs:8,fat:5}]},genkiSushi:{name:"å
氣壽å¸",items:[{name:"䏿é壽å¸ï¼2貫ï¼",calories:115,protein:8,carbs:14,fat:4},{name:"åæ¿å£½å¸ï¼2貫ï¼",calories:105,protein:9,carbs:13,fat:3},{name:"è¦å£½å¸ï¼2貫ï¼",calories:85,protein:7,carbs:13,fat:1},{name:"é°»éè
¹ï¼2貫ï¼",calories:130,protein:7,carbs:14,fat:5},{name:"çåçï¼2貫ï¼",calories:95,protein:5,carbs:15,fat:2},{name:"ç¸éåå·ï¼2ä»¶ï¼",calories:180,protein:10,carbs:18,fat:8},{name:"å³åæ±",calories:45,protein:3,carbs:4,fat:2}]},taipan:{name:"太è",items:[{name:"ç鴨飯",calories:750,protein:32,carbs:78,fat:32},{name:"åç飯",calories:620,protein:26,carbs:76,fat:20},{name:"æ²¹é飯",calories:680,protein:35,carbs:75,fat:24},{name:"çè飯",calories:700,protein:28,carbs:78,fat:28},{name:"ç´
è±æ²å°",calories:280,protein:4,carbs:52,fat:6},{name:"åæª¸è¶",calories:120,protein:0,carbs:30,fat:0},{name:"叏餿¹¯ç²éºµ",calories:450,protein:18,carbs:60,fat:14},{name:"æ²¹é飯ï¼å»ç®å°é£¯ï¼",calories:480,protein:34,carbs:45,fat:14},{name:"䏿éæé£¯ï¼å¥åº·é¤ï¼",calories:510,protein:34,carbs:50,fat:16},{name:"éè¸é£¯ï¼å¥åº·é¤ï¼",calories:430,protein:36,carbs:45,fat:8}]},tsui_wah:{name:"ç¿ è¯",items:[{name:"ä¹¾ççæ²³",calories:720,protein:24,carbs:75,fat:34},{name:"ææ´²çç±³",calories:650,protein:18,carbs:78,fat:28},{name:"çç«è
æé£¯",calories:680,protein:28,carbs:76,fat:26},{name:"奶油豬ä»å
",calories:350,protein:12,carbs:38,fat:16},{name:"絲襪奶è¶",calories:180,protein:4,carbs:24,fat:8},{name:"西å¤å£«",calories:400,protein:10,carbs:42,fat:22},{name:"å
¬ä»éºµ",calories:380,protein:15,carbs:52,fat:12}]}
21,chaRestaurant:{name:"è¶é¤å»³å¸¸è¦",items:[{name:"ç¡éª¨æµ·åé飯",calories:650,protein:35,carbs:72,fat:22},{name:"ç½åé飯",calories:580,protein:32,carbs:70,fat:16},{name:"豬æé£¯",calories:720,protein:30,carbs:78,fat:30},{name:"çè
©æ²³",calories:480,protein:22,carbs:58,fat:16},{name:"éèæ²³",calories:420,protein:15,carbs:55,fat:14},{name:"å¤å£«ï¼å¥¶æ²¹è±çé¬ï¼",calories:320,protein:8,carbs:36,fat:16},{name:"ç´
è±å°",calories:250,protein:4,carbs:48,fat:4},{name:"åé´é´¦",calories:140,protein:0,carbs:34,fat:0},{name:"常é¤ï¼Aé¤ï¼çèå¤å£«+奶è¶ï¼",calories:520,protein:14,carbs:48,fat:30}]},starbucks:{name:"Starbucks",items:[{name:"鮮奶æ¿éµï¼Grandeï¼",calories:190,protein:10,carbs:18,fat:8},{name:"ç¾å¼åå¡ï¼Grandeï¼",calories:15,protein:1,carbs:2,fat:0},{name:"ç¦ç³çªå¥æµï¼Grandeï¼",calories:380,protein:10,carbs:52,fat:14},{name:"æ¹è¶æ¿éµï¼Grandeï¼",calories:240,protein:8,carbs:34,fat:8},{name:"æå°æ¨ï¼èèï¼Grandeï¼",calories:320,protein:4,carbs:68,fat:4},{name:"éèå·ï¼ç
§çéï¼",calories:380,protein:22,carbs:38,fat:14},{name:"èæ²å¾ä¸ææ²»",calories:420,protein:18,carbs:36,fat:22},{name:"é¦èèç³",calories:350,protein:5,carbs:48,fat:16}]},gymFriendly:{name:"ðª Gymåé«èç½ç²¾é¸",items:[{name:"Subway éè¸ 6åï¼å
¨éº¥ï¼ç¡é¬ï¼",calories:290,protein:28,carbs:36,fat:4},{name:"èä»å¥åº·é¤ï¼éè¸ç±³ç·ï¼æ¸
湯ï¼",calories:340,protein:34,carbs:40,fat:5},{name:"大家æ¨ç¡éª¨éæ³é£¯ï¼å¥åº·é¤ï¼",calories:480,protein:38,carbs:50,fat:12},{name:"大快活éè¸é£¯ï¼å¥åº·é¤ï¼",calories:450,protein:36,carbs:48,fat:10},{name:"大家æ¨ä¸æéæé£¯ï¼å¥åº·é¤ï¼",calories:520,protein:35,carbs:55,fat:16},{name:"太èéè¸é£¯ï¼å¥åº·é¤ï¼",calories:430,protein:36,carbs:45,fat:8},{name:"太è䏿éæé£¯ï¼å¥åº·é¤ï¼",calories:510,protein:34,carbs:50,fat:16},{name:"æ¾å±éæå®é£",calories:680,protein:38,carbs:72,fat:22},{name:"KFC å®¶ééï¼2ä»¶ï¼å»ç®ï¼",calories:320,protein:34,carbs:4,fat:18},{name:"è¶é¤å»³ç½åé飯ï¼å°é£¯ï¼",calories:480,protein:32,carbs:50,fat:14},{name:"å¤§å¿«æ´»ä¸æé飯ï¼å¥åº·é¤ï¼",calories:490,protein:33,carbs:52,fat:14},{name:"èä»å¥åº·é¤ï¼ä¸æéç±³ç·ï¼æ¸
湯ï¼",calories:380,protein:30,carbs:42,fat:10}]}};function ct(){ka();const Te=Sa(),[Z,$e]=r.useState(()=>Te),[n,Ie]=r.useState(Te),[Pe,ze]=r.useState(!1),[Ae,la]=r.useState(!1),[ee,ca]=r.useState("breakfast"),[ae,te]=r.useState(""),[E,se]=r.useState(""),[le,ce]=r.useState(""),[re,oe]=r.useState(""),[ne,ie]=r.useState(""),[de,Ee]=r.useState(!1),[D,H]=r.useState(null),[$,ge]=r.useState(""),[j,I]=r.useState("all"),[P,He]=r.useState("all"),[Ue,xe]=r.useState(null),[ra,U]=r.useState(!1),[me,pe]=r.useState(""),[Be,B]=r.useState(null),[ue,oa]=r.useState("all"),[g,S]=r.useState(null),[Re,R]=r.useState(null),[Ra,_a]=r.useState({}),[z,_e]=r.useState("today"),[he,_]=r.useState(null),[fe,na]=r.useState(null),[i,F]=r.useState(null),[O,ia]=r.useState(""),[Y,da]=r.useState("all"),{data:be}=f.profile.getProfile.useQuery(),{data:G}=f.recommendations.getDaily.useQuery(),L=G?.calories?.targetCalories||Number(be?.tdee)||2e3,ga=G?.calories?.macroTargets?.protein,xa=G?.calories?.macroTargets?.carbs,ma=G?.calories?.macroTargets?.fat,N=Z.getFullYear(),v=Z.getMonth()+1,{data:M}=f.meals.getMonthSummary.useQuery({year:N,month:v}),{data:x,refetch:Me}=f.meals.getByDate.useQuery({date:n},{enabled:!!n}),b=f.useUtils(),{data:T,refetch:je}=f.meals.getFavourites.useQuery(),Le=f.meals.addFavourite.useMutation({onSuccess:()=>{m.success("å·²å å
¥å¸¸é¤ â"),B(null),pe(""),je()},onError:a=>m.error(a.message||"å å
¥å¤±æ")}),Ne=f.meals.removeFavourite.useMutation({onSuccess:()=>{m.success("已移é¤å¸¸é¤"),R(null),je()},onError:()=>m.error("ç§»é¤å¤±æ")}),ve=f.meals.updateFavourite.useMutation({onSuccess:()=>{m.success("常é¤å·²æ´æ° â
"),S(null),je()},onError:a=>m.error(a.message||"æ´æ°å¤±æ")}),Oe=f.meals.logFromFavourite.useMutation({onSuccess:()=>{m.success("å·²å¾å¸¸é¤è¨é ð½ï¸"),U(!1),Me(),b.meals.getMonthSummary.invalidate({year:N,month:v})},onError:a=>m.error(a.message||"è¨é失æ")}),Ye=f.meals.add.useMutation({onSuccess:()=>
21{if(m.success("è¨éæåï¼ç¹¼çºå æ²¹ ðª"),ee==="dinner"&&be?.mealPattern){const a=be.mealPattern,t=a==="skip_breakfast"?16:a==="fasting_1410"?14:0;if(t>0){const s=new Date,d=new Date(s.getTime()+t*60*60*1e3).toLocaleTimeString("zh-HK",{hour:"2-digit",minute:"2-digit",hour12:!1});setTimeout(()=>{m.info(`â
æ·é£æéï¼ä¸ä¸é¤ææ© ${d} å¯ä»¥é£ï¼${t}å°æå¾ï¼`,{duration:8e3})},1500)}}te(""),se(""),ce(""),oe(""),ie(""),ze(!1),Me(),b.meals.getMonthSummary.invalidate({year:N,month:v}),n&&(b.meals.getByDate.invalidate({date:n}),b.hydration.getByDate.invalidate({date:n}),b.workouts.getByDate.invalidate({date:n}),b.sleep.getByDate.invalidate({date:n}),b.supplements.getDailyChecklist.invalidate({date:n.toISOString().slice(0,10)}))},onError:()=>m.error("è¨éåå°ï¼è©¦å¤æ¬¡")}),pa=f.meals.delete.useMutation({onSuccess:()=>{m.success("è¨éå·²å·å"),Me(),b.meals.getMonthSummary.invalidate({year:N,month:v}),n&&(b.meals.getByDate.invalidate({date:n}),b.hydration.getByDate.invalidate({date:n}),b.workouts.getByDate.invalidate({date:n}),b.sleep.getByDate.invalidate({date:n}),b.supplements.getDailyChecklist.invalidate({date:n.toISOString().slice(0,10)}))},onError:()=>m.error("å·åå°")}),Ge=r.useMemo(()=>{const a=new Date(N,v-1,1),t=new Date(N,v,0),s=a.getDay(),l=t.getDate(),d=[];for(let c=0;c<s;c++)d.push({date:null,dateStr:""});for(let c=1;c<=l;c++){const h=`${N}-${String(v).padStart(2,"0")}-${String(c).padStart(2,"0")}`,k=M?.find(y=>y.date===h);d.push({date:c,dateStr:h,data:k})}return d},[N,v,M]),ye=r.useMemo(()=>{if(!M||M.length===0)return 0;const a=new Date;`${a.getFullYear()}${String(a.getMonth()+1).padStart(2,"0")}${String(a.getDate()).padStart(2,"0")}`;const t=M.map(d=>d.date).sort().reverse();let s=0,l=new Date(a);for(let d=0;d<31;d++){const c=`${l.getFullYear()}-${String(l.getMonth()+1).padStart(2,"0")}-${String(l.getDate()).padStart(2,"0")}`;if(t.includes(c))s++;else if(d>0)break;l.setDate(l.getDate()-1)}return s},[M]),ua=r.useMemo(()=>{if(!M||M.length===0)return{avgCalories:0,daysRecorded:0,onTargetDays:0};const a=M.reduce((s,l)=>s+l.totalCalories,0),t=M.filter(s=>Math.abs(s.totalCalories-L)<L*.15).length;return{avgCalories:Math.round(a/M.length),daysRecorded:M.length,onTargetDays:t}},[M,L]),we=r.useMemo(()=>{const a=$.trim().toLowerCase(),t=[],s=D?[[D,Fe[D]]]:Object.entries(Fe);for(const[l,d]of s)for(const c of d.items)a&&!c.name.toLowerCase().includes(a)&&!d.name.toLowerCase().includes(a)||j==="low"&&c.calories>400||j==="mid"&&c.calories>600||j==="high"&&c.calories<=600||P==="high"&&c.protein<20||t.push({restaurant:d.name,restaurantKey:l,...c});return t},[$,D,j,P]),Ke=$.trim()!==""||j!=="all"||P!=="all",Ve=a=>{if(!a)return"empty";const t=a.totalCalories/L;return t>=.85&&t<=1.15?"on-target":t<.85?"under":"over"},ha=async a=>{if(a.preventDefault(),!ae||!E){m.error("å
¥è¿é£ç©ååç±éå
");return}await Ye.mutateAsync({mealType:ee,foodItems:[{name:ae,calories:parseFloat(E),protein:parseFloat(le)||0,carbs:parseFloat(re)||0,fat:parseFloat(ne)||0}],totalCalories:parseFloat(E),protein:parseFloat(le)||0,carbs:parseFloat(re)||0,fat:parseFloat(ne)||0,aiAnalyzed:!1,date:n||void 0})},fa=()=>$e(new Date(N,v-2,1)),ba=()=>$e(new Date(N,v,1)),{data:qe=[],refetch:Qe}=f.meals.getHistory.useQuery({limit:100,offset:0},{enabled:z==="history"}),ke=f.meals.update.useMutation({onSuccess:()=>{m.success("æ´æ°æå"),_(null),F(null),Qe()},onError:a=>m.error(`æ´æ°å¤±æ: ${a.message}`)}),Ma=f.meals.delete.useMutation({onSuccess:()=>{m.success("å·²åªé¤"),Qe(),b.meals.getMonthSummary.invalidate({year:N,month:v})},onError:a=>m.error(`åªé¤å¤±æ: ${a.message}`)}),We=r.useMemo(()=>qe.filter(a=>{const t=Y==="all"||a.mealType===Y,s=O===""||Array.isArray(a.foodItems)&&a.foodItems.some(l=>l.name?.toLowerCase().includes(O.toLowerCase()));return t&&s}),[qe,Y,O]),ja=a=>({breakfast:"æ©é¤",lunch:"åé¤",dinner:"æé¤",snack:"å°é£"})[a]||a,La=a=>({breakfast:"bg-amber-500/20 text-amber-400",lunch:"bg-blue-500/20 text-blue-400",dinner:"bg-purple-500/20 text-purple-400",snack:"bg-green-500/20 text-green-400"})[a]||"bg-gray-500/20 text-gray-400",Na=a=>{_(a.id),F({...a})},va=async()=>
21{if(!i||he===null)return;const a=typeof i.totalCalories=="string"?parseInt(i.totalCalories):i.totalCalories||0,t=typeof i.protein=="string"?parseInt(i.protein):i.protein||0,s=typeof i.carbs=="string"?parseInt(i.carbs):i.carbs||0,l=typeof i.fat=="string"?parseInt(i.fat):i.fat||0;await ke.mutateAsync({id:he,mealType:i.mealType,foodItems:i.foodItems,totalCalories:a,protein:t,carbs:s,fat:l,portionPercentage:i.portionPercentage||100})},ya=a=>{confirm("確å®è¦åªé¤å¢åè¨éï¼")&&Ma.mutate({id:a})};return e.jsxs(Ca,{"data-loc":"client/src/pages/MealLog.tsx:602",title:"飲é£è¨é",showBack:!0,children:[e.jsx("div",{"data-loc":"client/src/pages/MealLog.tsx:603",className:"px-4 py-5 sm:py-7",children:e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:604",className:"mx-auto max-w-3xl space-y-5",children:[e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:606",className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:607",children:[e.jsx("p",{"data-loc":"client/src/pages/MealLog.tsx:608",className:"section-kicker",children:"DAILY FUEL LOG"}),e.jsx("h1",{"data-loc":"client/src/pages/MealLog.tsx:609",className:"mt-1 text-2xl font-bold tracking-tight md:text-3xl",children:"飲é£è¨é"}),e.jsx("p",{"data-loc":"client/src/pages/MealLog.tsx:610",className:"mt-1 text-sm text-muted-foreground",children:"è¿½è¹¤æ¯æ¥çé¤ï¼ä»¤æ¯ä¸é¤é½ç徿¸
æ¥ã"})]}),ye>0&&e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:613",className:"flex items-center gap-2",children:[e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:614",className:"flex items-center gap-2 rounded-full bg-gradient-to-r from-amber-400 to-orange-500 px-4 py-2 text-slate-950 shadow-[0_10px_22px_rgba(251,146,60,0.26)]",children:[e.jsx(Je,{"data-loc":"client/src/pages/MealLog.tsx:615",className:"w-5 h-5"}),e.jsx("span",{"data-loc":"client/src/pages/MealLog.tsx:616",className:"font-bold text-lg",children:ye}),e.jsx("span",{"data-loc":"client/src/pages/MealLog.tsx:617",className:"text-sm",children:"æ¥é£çº"})]}),e.jsx(ta,{"data-loc":"client/src/pages/MealLog.tsx:619",type:"streak",data:{streakDays:ye,totalDays:ua.daysRecorded,currentMonth:`${N}å¹´${v}æ`},trigger:e.jsx("button",{"data-loc":"client/src/pages/MealLog.tsx:627",className:"w-8 h-8 rounded-full bg-white/10 hover:bg-white/20 border border-white/20 flex items-center justify-center transition-colors",children:e.jsx(sa,{"data-loc":"client/src/pages/MealLog.tsx:628",className:"w-3.5 h-3.5 text-muted-foreground"})})})]})]}),e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:637",className:"mb-6 flex gap-2 rounded-2xl border border-white/8 bg-black/15 p-1.5 backdrop-blur-xl",children:[e.jsxs("button",{"data-loc":"client/src/pages/MealLog.tsx:638",onClick:()=>_e("today"),className:`flex items-center gap-2 px-4 py-2 rounded-full text-sm font-medium transition-all ${z==="today"?"bg-gradient-to-r from-violet-600 to-indigo-500 text-white shadow-[0_6px_18px_rgba(124,58,237,0.32)]":"text-muted-foreground hover:bg-white/[0.08]"}`,children:[e.jsx(Ta,{"data-loc":"client/src/pages/MealLog.tsx:646",className:"w-4 h-4"}),"仿¥è¨é"]}),e.jsxs("button",{"data-loc":"client/src/pages/MealLog.tsx:649",onClick:()=>_e("history"),className:`flex items-center gap-2 px-4 py-2 rounded-full text-sm font-medium transition-all ${z==="history"?"bg-gradient-to-r from-violet-600 to-indigo-500 text-white shadow-[0_6px_18px_rgba(124,58,237,0.32)]":"text-muted-foreground hover:bg-white/[0.08]"}`,children:[e.jsx(Ha,{"data-loc":"client/src/pages/MealLog.tsx:657",className:"w-4 h-4"}),"æ·å²è¨é"]})]}),z==="today"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:666",className:"card-glass-subtle mb-5 rounded-2xl p-2.5",children:[e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:667",className:"flex items-center justify-between mb-2 px-1",children:[e.jsx("button",{"data-loc":"client/src/pages/MealLog.tsx:668",onClick:fa,className:"p-1 rounded-full hover:bg-muted/40 transition-colors",children:e.jsx($a,{"data-loc":"client/src/pages/MealLog.tsx:669",className:"w-4 h-4 text-muted-foreground"})}),e.jsx("span",{"data-loc":"client/src/pages/MealLog.tsx:671",className:"text-sm font-semibold",children:Z.toLocaleDateString("zh-TW",{year:"numeric",month:"long"})}),e.jsx("button",{"data-loc":"client/src/pages/MealLog.tsx:674",onClick:ba,className:"p-1 rounded-full hover:bg-muted/40 transition-colors",children:e.jsx(Ia,{"data-loc":"client/src/pages/MealLog.tsx:675",className:"w-4 h-4 text-muted-foreground"})})]}),e.jsx("div",{"data-loc":"client/src/pages/MealLog.tsx:678",className:"flex gap-1 overflow-x-auto pb-1 scrollbar-hide px-1",children:Ge.filter(a=>a.date!==null).map((a,t)=>{const s=new Date,d=`${s.getFullYear()}
21-${String(s.getMonth()+1).padStart(2,"0")}-${String(s.getDate()).padStart(2,"0")}`===a.dateStr,h=(n?`${n.getFullYear()}-${String(n.getMonth()+1).padStart(2,"0")}-${String(n.getDate()).padStart(2,"0")}`:"")===a.dateStr,k=!!a.data,y=Ve(a.data),C=["æ¥","ä¸","äº","ä¸","å","äº","å "],wa=new Date(a.dateStr+"T12:00:00").getDay();return e.jsxs("button",{"data-loc":"client/src/pages/MealLog.tsx:690",onClick:()=>Ie(new Date(a.dateStr+"T12:00:00")),className:`flex-shrink-0 flex flex-col items-center gap-1 px-2.5 py-2 rounded-2xl transition-all duration-200 min-w-[44px] 22 ${h?"bg-gradient-to-b from-violet-600 to-indigo-500 text-white shadow-md scale-105":d?"bg-cyan-300/12 text-cyan-200 ring-1 ring-cyan-300/22":"hover:bg-white/[0.06]"} 23 `,children:[e.jsx("span",{"data-loc":"client/src/pages/MealLog.tsx:697",className:`text-[10px] opacity-70 ${d&&!h?"font-extrabold text-cyan-200":"font-medium"}`,children:C[wa]}),e.jsx("span",{"data-loc":"client/src/pages/MealLog.tsx:698",className:`text-sm ${d&&!h?"font-extrabold text-cyan-200":"font-bold"}`,children:a.date}),e.jsx("div",{"data-loc":"client/src/pages/MealLog.tsx:699",className:`w-1.5 h-1.5 rounded-full transition-all ${k?y==="on-target"?"bg-green-500":y==="over"?"bg-red-400":"bg-yellow-400":"bg-transparent"}`})]},t)})})]}),e.jsxs(A,{"data-loc":"client/src/pages/MealLog.tsx:711",className:"card-glass-subtle mb-5 border-white/8",children:[e.jsx(Xe,{"data-loc":"client/src/pages/MealLog.tsx:712",className:"pb-2 cursor-pointer",onClick:()=>la(a=>!a),children:e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:713",className:"flex items-center justify-between",children:[e.jsx(Ze,{"data-loc":"client/src/pages/MealLog.tsx:714",className:"text-sm font-semibold",children:"å ¨ææ¦è¦½"}),e.jsx(ea,{"data-loc":"client/src/pages/MealLog.tsx:715",className:`w-4 h-4 text-muted-foreground transition-transform duration-200 ${Ae?"rotate-180":""}`})]})}),Ae&&e.jsxs(Se,{"data-loc":"client/src/pages/MealLog.tsx:719",className:"pt-0",children:[e.jsx("div",{"data-loc":"client/src/pages/MealLog.tsx:721",className:"grid grid-cols-7 gap-1 mb-1",children:["æ¥","ä¸","äº","ä¸","å","äº","å "].map(a=>e.jsx("div",{"data-loc":"client/src/pages/MealLog.tsx:723",className:"text-center text-[10px] font-medium text-muted-foreground py-1",children:a},a))}),e.jsx("div",{"data-loc":"client/src/pages/MealLog.tsx:727",className:"grid grid-cols-7 gap-1",children:Ge.map((a,t)=>{if(a.date===null)return e.jsx("div",{"data-loc":"client/src/pages/MealLog.tsx:729"},t);const s=Ve(a.data),l=new Date,c=`${l.getFullYear()}-${String(l.getMonth()+1).padStart(2,"0")}-${String(l.getDate()).padStart(2,"0")}`===a.dateStr,k=(n?`${n.getFullYear()}-${String(n.getMonth()+1).padStart(2,"0")}-${String(n.getDate()).padStart(2,"0")}`:"")===a.dateStr;return e.jsxs("button",{"data-loc":"client/src/pages/MealLog.tsx:737",onClick:()=>Ie(new Date(a.dateStr+"T12:00:00")),className:`relative aspect-square rounded-lg flex flex-col items-center justify-center text-xs font-medium transition-all duration-200 hover:scale-105 24 ${k?"ring-2 ring-primary shadow-md":""} 25 ${c?"ring-1 ring-primary/50":""} 26 ${s==="on-target"?"bg-green-500/20 text-green-700 dark:text-green-400":""} 27 ${s==="under"?"bg-yellow-500/15 text-yellow-700 dark:text-yellow-400":""} 28 ${s==="over"?"bg-red-500/15 text-red-700 dark:text-red-400":""} 29 ${s==="empty"?"bg-muted/30 text-muted-foreground":""} 30 `,children:[e.jsx("span",{"data-loc":"client/src/pages/MealLog.tsx:749",children:a.date}),a.data&&e.jsx("span",{"data-loc":"client/src/pages/MealLog.tsx:750",className:"text-[8px] opacity-60",children:Math.round(a.data.totalCalories)})]},t)})}),e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:756",className:"flex items-center gap-3 mt-3 text-[10px] text-muted-foreground justify-center",children:[e.jsxs("span",{"data-loc":"client/src/pages/MealLog.tsx:757",className:"flex items-center gap-1",children:[e.jsx("span",{"data-loc":"client/src/pages/MealLog.tsx:757",className:"w-2.5 h-2.5 rounded bg-green-500/20"})," 鿍"]}),e.jsxs("span",{"data-loc":"client/src/pages/MealLog.tsx:758",className:"flex items-center gap-1",children:[e.jsx("span",{"data-loc":"client/src/pages/MealLog.tsx:758",className:"w-2.5 h-2.5 rounded bg-yellow-500/15"})," åå°"]}),e.jsxs("span",{"data-loc":"client/src/pages/MealLog.tsx:759",className:"flex items-center gap-1",children:[e.jsx("span",{"data-loc":"client/src/pages/MealLog.tsx:759",className:"w-2.5 h-2.5 rounded bg-red-500/15"})," è¶ æ¨"]}),e.jsxs("span",{"data-loc":"client/src/pages/MealLog.tsx:760",className:"flex items-center gap-1",children:[e.jsx("span",{"data-loc":"client/src/pages/MealLog.tsx:760",className:"w-2.5 h-2.5 rounded bg-muted/30"}
30)," æªè¨é"]})]})]})]}),(()=>{const a=x?Math.round(x.reduce((y,C)=>y+(Number(C.totalCalories)||0),0)):0,t=x?Math.round(x.reduce((y,C)=>y+(Number(C.protein)||0),0)):0,s=x?Math.round(x.reduce((y,C)=>y+(Number(C.carbs)||0),0)):0,l=x?Math.round(x.reduce((y,C)=>y+(Number(C.fat)||0),0)):0,d=Math.max(0,L-a),c=ga||Math.round(L*.25/4),h=xa||Math.round(L*.5/4),k=ma||Math.round(L*.25/9);return e.jsx(A,{"data-loc":"client/src/pages/MealLog.tsx:780",className:"card-warm-action mb-5 overflow-hidden border-0",children:e.jsxs(Se,{"data-loc":"client/src/pages/MealLog.tsx:781",className:"p-5",children:[e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:782",className:"mb-3 flex items-center justify-between",children:[e.jsx("span",{"data-loc":"client/src/pages/MealLog.tsx:783",className:"section-kicker text-amber-100/80",children:"TODAY'S ENERGY"}),e.jsx(Je,{"data-loc":"client/src/pages/MealLog.tsx:784",className:"h-4 w-4 text-amber-200"})]}),e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:787",className:"flex items-center justify-between mb-5",children:[e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:789",className:"text-center w-20",children:[e.jsx("p",{"data-loc":"client/src/pages/MealLog.tsx:790",className:"text-2xl font-bold text-amber-100",children:a}),e.jsx("p",{"data-loc":"client/src/pages/MealLog.tsx:791",className:"text-xs text-muted-foreground mt-0.5",children:"å·²é£"})]}),e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:794",className:"relative w-36 h-36",children:[e.jsxs("svg",{"data-loc":"client/src/pages/MealLog.tsx:795",className:"w-full h-full -rotate-90",viewBox:"0 0 120 120",children:[e.jsx("circle",{"data-loc":"client/src/pages/MealLog.tsx:797",cx:"60",cy:"60",r:"50",fill:"none",stroke:"currentColor",strokeWidth:"9",className:"text-white/10"}),a>0&&e.jsx("circle",{"data-loc":"client/src/pages/MealLog.tsx:800",cx:"60",cy:"60",r:"50",fill:"none",stroke:a>L?"#ef4444":"#f97316",strokeWidth:"9",strokeLinecap:"round",strokeDasharray:2*Math.PI*50,strokeDashoffset:2*Math.PI*50*(1-Math.min(1,a/L)),style:{transition:"stroke-dashoffset 0.6s ease"}})]}),e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:811",className:"absolute inset-0 flex flex-col items-center justify-center",children:[e.jsx("p",{"data-loc":"client/src/pages/MealLog.tsx:812",className:"text-3xl font-extrabold leading-none text-amber-100",children:d}),e.jsx("p",{"data-loc":"client/src/pages/MealLog.tsx:813",className:"mt-1 text-[11px] text-amber-100/60",children:"å©é¤ kcal"})]})]}),e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:817",className:"text-center w-20",children:[e.jsx("p",{"data-loc":"client/src/pages/MealLog.tsx:818",className:"text-2xl font-bold text-amber-100",children:L}),e.jsx("p",{"data-loc":"client/src/pages/MealLog.tsx:819",className:"text-xs text-muted-foreground mt-0.5",children:"ç®æ¨"})]})]}),e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:823",className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:825",className:"rounded-xl border border-cyan-200/12 bg-cyan-300/8 p-2.5",children:[e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:826",className:"flex items-center gap-1 mb-1.5",children:[e.jsx("div",{"data-loc":"client/src/pages/MealLog.tsx:827",className:"w-2.5 h-2.5 rounded-full bg-cyan-200"}),e.jsx("span",{"data-loc":"client/src/pages/MealLog.tsx:828",className:"text-xs font-semibold",children:"èç½è³ª"})]}),e.jsx("div",{"data-loc":"client/src/pages/MealLog.tsx:830",className:"h-1.5 rounded-full bg-muted/30 overflow-hidden mb-1.5",children:e.jsx("div",{"data-loc":"client/src/pages/MealLog.tsx:831",className:"h-full rounded-full bg-cyan-200 transition-all duration-500",style:{width:`${c>0?Math.min(100,t/c*100):0}%`}})}),e.jsxs("p",{"data-loc":"client/src/pages/MealLog.tsx:833",className:"text-xs text-muted-foreground",children:[t,e.jsxs("span",{"data-loc":"client/src/pages/MealLog.tsx:833",className:"opacity-60",children:["/",c,"g"]})]})]}),e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:836",className:"rounded-xl border border-violet-200/12 bg-violet-300/8 p-2.5",children:[e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:837",className:"flex items-center gap-1 mb-1.5",children:[e.jsx("div",{"data-loc":"client/src/pages/MealLog.tsx:838",className:"w-2.5 h-2.5 rounded-full bg-violet-300"}),e.jsx("span",{"data-loc":"client/src/pages/MealLog.tsx:839",className:"text-xs font-semibold",children:"碳水"})]}),e.jsx("div",{"data-loc":"client/src/pages/MealLog.tsx:841",className:"h-1.5 rounded-full bg-muted/30 overflow-hidden mb-1.5",children:e.jsx("div",{"data-loc":"client/src/pages/MealLog.tsx:842",className:"h-full rounded-full bg-violet-300 transition-all duration-500",style:{width:`${h>0?Math.min(100,s/h*100):0}%`}})}),e.jsxs("p",{"data-loc":"client/src/pages/MealLog.tsx:844",className:"text-xs text-muted-foreground",children:[s,e.jsxs("span",{"data-loc":"client/src/pages/MealLog.tsx:844",className:"opacity-60",children:["/",h,"g"]})]})]}),e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:847",className:"rounded-xl border border-amber-200/12 bg-amber-300/8 p-2.5",children:[e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:848",className:"flex items-center gap-1 mb-1.5",children:[e.jsx("div",{"data-loc":"client/src/pages/MealLog.tsx:849",className:"w-2.5 h-2.5 rounded-full bg-amber-200"}),e.jsx("span",{"data-loc":"client/src/pages/MealLog.tsx:850",className:"text-xs font-semibold",children:"èèª"})]}),e.jsx("div",{"data-loc":"client/src/pages/MealLog.tsx:852",className:"h-1.5 rounded-full bg-muted/30 overflow-hidden mb-1.5",children:e.jsx("div",{"data-loc":"client/src/pages/MealLog.tsx:853",className:"h-full rounded-full bg-amber-200 transition-all duration-500",style:{width:`${k>0?Math.min(100,l/k*100):0}%`}})}),e.jsxs("p",{"data-loc":"client/src/pages/MealLog.tsx:855",className:"text-xs text-muted-foreground",children:[l,e.jsxs("span",{"data-loc":"client/src/pages/MealLog.tsx:855",className:"opacity-60",children:["/",k,"g"]})]})]})]})]})})})(),n&&e.jsxs(A,{"data-loc":"client/src/pages/MealLog.tsx:865",className:"card-glass-subtle mb-6 border-white/8",children:[e.jsx(Xe,{"data-loc":"client/src/pages/MealLog.tsx:866",className:"pb-3",children:e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:867",className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsx(Ze,{"data-loc":"client/src/pages/MealLog.tsx:868",className:"text-lg",children:n.toLocaleDateString("zh-TW",{month:"long",day:"numeric",weekday:"short"})}),e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:871",className:"grid w-full grid-cols-3 gap-2 sm:flex sm:w-auto",children:[e.jsxs(o,{"data-loc":"client/src/pages/MealLog.tsx:872",size:"sm",className:"w-full whitespace-nowrap sm:w-auto",onClick:()=>ze(!Pe),children:[e.jsx(De,{"data-loc":"client/src/pages/MealLog.tsx:873",className:"w-4 h-4 mr-1"})," å å
¥"]}),e.jsxs(o,{"data-loc":"client/src/pages/MealLog.tsx:875",size:"sm",variant:"outline",className:"w-full whitespace-nowrap sm:w-auto",onClick:()=>U(!0),children:[e.jsx(K,{"data-loc":"client/src/pages/MealLog.tsx:876",className:"w-4 h-4 mr-1 text-amber-500"})," 常é¤"]}),e.jsx(o,{"data-loc":"client/src/pages/MealLog.tsx:878",size:"sm",variant:"outline",className:"w-full whitespace-nowrap sm:w-auto",asChild:!0,children:e.jsxs(Da,{"data-loc":"client/src/pages/MealLog.tsx:879",href:"/food-recognition",children:[e.jsx(Fa,{"data-loc":"client/src/pages/MealLog.tsx:880",className:"w-4 h-4 mr-1"})," AI èå¥"]})})]})]})}),e.jsxs(Se,{"data-loc":"client/src/pages/MealLog.tsx:886",children:[Pe&&e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:889",className:"mb-4 space-y-3",children:[e.jsxs(o,{"data-loc":"client/src/pages/MealLog.tsx:891",type:"button",variant:de?"default":"outline",size:"sm",className:"w-full",onClick:()=>{Ee(!de),H(null)},children:[e.jsx(Ba,{"data-loc":"client/src/pages/MealLog.tsx:898",className:"w-4 h-4 mr-1"})," å¿«é¤éé¸"]}),de&&e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:903",className:"card-glass-subtle space-y-3 rounded-xl p-3",children:[e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:905",className:"relative",children:[e.jsx(Pa,{"data-loc":"client/src/pages/MealLog.tsx:906",className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(p,{"data-loc":"client/src/pages/MealLog.tsx:907",placeholder:"æé£ç©å / é¤å»³å...",value:$,onChange:a=>ge(a.target.value),className:"input-fitdiet h-9 pl-9 text-sm"}),$&&e.jsx("button",{"data-loc":"client/src/pages/MealLog.tsx:914",type:"button",onClick:()=>ge(""),className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:e.jsx(Ce,{"data-loc":"client/src/pages/MealLog.tsx:915",className:"w-3.5 h-3.5"})})]}),e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:921",className:"flex flex-wrap gap-2 items-center",children:[e.jsx(Ea,{"data-loc":"client/src/pages/MealLog.tsx:922",className:"w-3.5 h-3.5 text-muted-foreground"}),e.jsx(o,{"data-loc":"client/src/pages/MealLog.tsx:923",type:"button",variant:j==="all"?"default":"outline",size:"sm",className:"text-xs h-6 px-2",onClick:()=>I("all"),children:"å
¨é¨ç±é"}),e.jsx(o,{"data-loc":"client/src/pages/MealLog.tsx:924",type:"button",variant:j==="low"?"default":"outline",size:"sm",className:"text-xs h-6 px-2",onClick:()=>I(j==="low"?"all":"low"),children:"â¤400 kcal"}),e.jsx(o,{"data-loc":"client/src/pages/MealLog.tsx:925",type:"button",variant:j==="mid"?"default":"outline",size:"sm",className:"text-xs h-6 px-2",onClick:()=>I(j==="mid"?"all":"mid"),children:"â¤600 kcal"}),e.jsx(o,{"data-loc":"client/src/pages/MealLog.tsx:926",type:"button",variant:j==="high"?"default":"outline",size:"sm",className:"text-xs h-6 px-2",onClick:()=>I(j==="high"?"all":"high"),children:"600 kcal"}),e.jsx("span",{"data-loc":"client/src/pages/MealLog.tsx:927",className:"text-muted-foreground
30/50",children:"|"}),e.jsx(o,{"data-loc":"client/src/pages/MealLog.tsx:928",type:"button",variant:P==="high"?"default":"outline",size:"sm",className:"text-xs h-6 px-2",onClick:()=>He(P==="high"?"all":"high"),children:"ðª é«èç½ â¥20g"})]}),e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:932",className:"flex flex-wrap gap-1.5",children:[e.jsx(o,{"data-loc":"client/src/pages/MealLog.tsx:933",type:"button",variant:D===null?"default":"outline",size:"sm",className:"text-xs h-6 px-2",onClick:()=>H(null),children:"å
¨é¨é¤å»³"}),Object.entries(Fe).map(([a,t])=>e.jsx(o,{"data-loc":"client/src/pages/MealLog.tsx:943",type:"button",variant:D===a?"default":"outline",size:"sm",className:"text-xs h-6 px-2",onClick:()=>H(D===a?null:a),children:t.name},a))]}),Ke&&e.jsxs("p",{"data-loc":"client/src/pages/MealLog.tsx:958",className:"text-xs text-muted-foreground",children:["æ¾å° ",e.jsx("span",{"data-loc":"client/src/pages/MealLog.tsx:959",className:"font-semibold text-primary",children:we.length})," åçµæ"]}),(Ke||D)&&e.jsx("div",{"data-loc":"client/src/pages/MealLog.tsx:965",className:"grid grid-cols-1 gap-1.5 max-h-56 overflow-y-auto",children:we.length>0?we.map((a,t)=>e.jsxs("button",{"data-loc":"client/src/pages/MealLog.tsx:967",type:"button",className:"flex items-center justify-between p-2 rounded-md bg-background/50 hover:bg-primary/10 border border-border/50 transition-colors text-left",onClick:()=>{te(`${a.restaurant} ${a.name}`),se(String(a.calories)),ce(String(a.protein)),oe(String(a.carbs)),ie(String(a.fat)),Ee(!1),H(null),ge(""),I("all"),He("all"),m.success(`å·²æå ${a.name}ï¼å¯ç´æ¥è¨ä½`)},children:[e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:985",className:"flex flex-col gap-0.5 min-w-0",children:[e.jsx("span",{"data-loc":"client/src/pages/MealLog.tsx:986",className:"text-sm font-medium text-foreground truncate",children:a.name}),e.jsx("span",{"data-loc":"client/src/pages/MealLog.tsx:987",className:"text-[10px] text-muted-foreground/70",children:a.restaurant})]}),e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:989",className:"flex items-center gap-2 ml-2 shrink-0",children:[a.protein>=20&&e.jsx("span",{"data-loc":"client/src/pages/MealLog.tsx:990",className:"text-[10px] px-1.5 py-0.5 rounded bg-green-500/20 text-green-400",children:"é«èç½"}),e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:991",className:"text-right",children:[e.jsx("span",{"data-loc":"client/src/pages/MealLog.tsx:992",className:"text-xs font-medium text-orange-400",children:a.calories}),e.jsx("span",{"data-loc":"client/src/pages/MealLog.tsx:993",className:"text-[10px] text-muted-foreground",children:" kcal"})]})]})]},t)):e.jsx("div",{"data-loc":"client/src/pages/MealLog.tsx:998",className:"text-center py-4 text-sm text-muted-foreground",children:"æå°ç¡çµæï¼è©¦ä¸å
¶ä»ééµå"})})]}),e.jsxs("form",{"data-loc":"client/src/pages/MealLog.tsx:1008",onSubmit:ha,className:"card-glass-subtle space-y-3 rounded-xl p-4",children:[e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:1009",className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:1010",children:[e.jsx(w,{"data-loc":"client/src/pages/MealLog.tsx:1011",className:"text-xs",children:"餿¬¡"}),e.jsxs(V,{"data-loc":"client/src/pages/MealLog.tsx:1012",value:ee,onValueChange:a=>ca(a),children:[e.jsx(q,{"data-loc":"client/src/pages/MealLog.tsx:1013",className:"mt-1 h-9",children:e.jsx(Q,{"data-loc":"client/src/pages/MealLog.tsx:1013"})}),e.jsxs(W,{"data-loc":"client/src/pages/MealLog.tsx:1014",children:[e.jsx(u,{"data-loc":"client/src/pages/MealLog.tsx:1015",value:"breakfast",children:"æ©é¤"}),e.jsx(u,{"data-loc":"client/src/pages/MealLog.tsx:1016",value:"lunch",children:"åé¤"}),e.jsx(u,{"data-loc":"client/src/pages/MealLog.tsx:1017",value:"dinner",children:"æé¤"}),e.jsx(u,{"data-loc":"client/src/pages/MealLog.tsx:1018",value:"snack",children:"é¶é£"})]})]})]}),e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:1022",children:[e.jsx(w,{"data-loc":"client/src/pages/MealLog.tsx:1023",className:"text-xs",children:"é£ç©"}),e.jsx(p,{"data-loc":"client/src/pages/MealLog.tsx:1024",className:"input-fitdiet mt-1 h-9",placeholder:"ä¾
30ï¼éè¸è",value:ae,onChange:a=>te(a.target.value)})]})]}),e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:1027",className:"grid grid-cols-4 gap-2",children:[e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:1028",children:[e.jsx(w,{"data-loc":"client/src/pages/MealLog.tsx:1028",className:"text-xs",children:"ç±é"}),e.jsx(p,{"data-loc":"client/src/pages/MealLog.tsx:1028",className:"input-fitdiet mt-1 h-9",type:"number",placeholder:"kcal",value:E,onChange:a=>se(a.target.value)})]}),e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:1029",children:[e.jsx(w,{"data-loc":"client/src/pages/MealLog.tsx:1029",className:"text-xs",children:"èç½è³ª"}),e.jsx(p,{"data-loc":"client/src/pages/MealLog.tsx:1029",className:"input-fitdiet mt-1 h-9",type:"number",placeholder:"g",value:le,onChange:a=>ce(a.target.value)})]}),e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:1030",children:[e.jsx(w,{"data-loc":"client/src/pages/MealLog.tsx:1030",className:"text-xs",children:"碳水"}),e.jsx(p,{"data-loc":"client/src/pages/MealLog.tsx:1030",className:"input-fitdiet mt-1 h-9",type:"number",placeholder:"g",value:re,onChange:a=>oe(a.target.value)})]}),e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:1031",children:[e.jsx(w,{"data-loc":"client/src/pages/MealLog.tsx:1031",className:"text-xs",children:"èèª"}),e.jsx(p,{"data-loc":"client/src/pages/MealLog.tsx:1031",className:"input-fitdiet mt-1 h-9",type:"number",placeholder:"g",value:ne,onChange:a=>ie(a.target.value)})]})]}),e.jsxs(o,{"data-loc":"client/src/pages/MealLog.tsx:1033",type:"submit",className:"w-full",disabled:Ye.isPending,children:[e.jsx(De,{"data-loc":"client/src/pages/MealLog.tsx:1034",className:"w-4 h-4 mr-1"})," è¨ä½"]})]})]}),x&&x.length>0?e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:1042",className:"space-y-2",children:[x.map(a=>{const t={breakfast:"ð
æ©é¤",lunch:"ð½ï¸ åé¤",dinner:"ð æé¤",snack:"ð¿ é¶é£"},s=typeof a.foodItems=="string"?JSON.parse(a.foodItems):a.foodItems;let l=typeof a.photos=="string"?JSON.parse(a.photos):a.photos||[];l=(l||[]).filter(c=>!!c.url),l.length===0&&(a.primaryPhotoUrl?l=[{url:a.primaryPhotoUrl,type:"finished"}]:a.photoUrl&&(l=[{url:a.photoUrl,type:"finished"}]));const d=Array.isArray(s)&&s.length>0?s.length<=2?s.map(c=>c.name).join("ã"):`${s[0]?.name} +${s.length-1}`:"æªç¥é£ç©";return e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:1056",className:"p-3 rounded-2xl card-premium",children:[l.length>0?e.jsx("div",{"data-loc":"client/src/pages/MealLog.tsx:1059",className:"flex gap-2 overflow-x-auto pb-1 scrollbar-hide mb-3",children:l.map((c,h)=>e.jsx("button",{"data-loc":"client/src/pages/MealLog.tsx:1061",type:"button",onClick:()=>xe(c.url),className:"flex-shrink-0 w-20 h-20 rounded-xl overflow-hidden bg-muted/30 border border-border/40",children:e.jsx("img",{"data-loc":"client/src/pages/MealLog.tsx:1067",src:c.url,alt:`${d} ${h+1}`,className:"w-full h-full object-cover",loading:"lazy"})},h))}):e.jsx("div",{"data-loc":"client/src/pages/MealLog.tsx:1072",className:"flex items-center gap-3 mb-2",children:e.jsx("div",{"data-loc":"client/src/pages/MealLog.tsx:1073",className:"flex-shrink-0 w-20 h-20 rounded-xl bg-muted/30 border border-border/40 flex items-center justify-center text-2xl",children:a.mealType==="breakfast"?"ð
":a.mealType==="lunch"?"ð½ï¸":a.mealType==="dinner"?"ð":"ð¿"})}),e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:1079",className:"flex items-center gap-3",children:[e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:1081",className:"flex-1 min-w-0",children:[e.jsx("div",{"data-loc":"client/src/pages/MealLog.tsx:1082",className:"flex items-center gap-1.5 mb-0.5",children:e.jsx("span",{"data-loc":"client/src/pages/MealLog.tsx:1083",className:"text-[10px] text-muted-foreground",children:t[a.mealType]||a.mealType})}),e.jsx("p",{"data-loc":"client/src/pages/MealLog.tsx:1085",className:"font-semibold text-sm leading-tight truncate",children:d}),e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:1086",className:"flex items-center gap-1 mt-1",children:[e.jsxs("span",{"data-loc":"client/src/pages/MealLog.tsx:1087",className:"text-base font-bold text-orange-500",children:["ð¥ ",Math.round(Number(a.totalCalories)||0)]}),e.jsx("span",{"data-loc":"client/src/pages/MealLog.tsx:1088",className:"text-xs text-muted-foreground",children:"kcal"})]}),e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:1090",className:"flex gap-2 mt-1",children:[e.jsxs("span",{"data-loc":"client/src/pages/MealLog.tsx:1091",className:"text-[11px] text-yellow-500",children:["ð¡ ",Math.round(Number(a.protein)||0),"g"]}),e.jsxs("span",{"data-loc":"client/src/pages/MealLog.tsx:1092",className:"text-[11px] text-pink-400",children:["ð£ ",Math.round(Number(a.carbs)||0),"g"]}),e.jsxs("span",{"data-loc":"client/src/pages/MealLog.tsx:1093",className:"text-[11px] text-teal-400",children:["ð¢ ",Math.round(Number(a.fat)||0),"g"]})]})]}),e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:1097",className:"flex flex-col gap-1 flex-shrink-0",children:[e.jsx(o,{"data-loc":"client/src/pages/MealLog.tsx:1098",variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>{const c=typeof a.foodItems=="string"?JSON.parse(a.foodItems):a.foodItems,h=Array.isArray(c)&&c.length>0?c.map(k=>k.name).join(" + "):"æªå½å常é¤";pe(h),B(a.id)},children:e.jsx(za,{"data-loc":"client/src/pages/MealLog.tsx:1107",className:"w-3.5 h-3.5 text-amber-500"})}),e.jsx(o,{"data-loc":"client/src/pages/MealLog.tsx:1109",variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>pa.mutate({id:a.id}),children:e.jsx(J,{"data-loc":"client/src/pages/MealLog.tsx:1110",className:"w-3.5 h-3.5 text-destructive"})})]})]})]},a.id)}),e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:1118",className:"mt-3 pt-3 border-t border-border flex justify-between items-center",children:[e.jsx("span",{"data-loc":"client/src/pages/MealLog.tsx:1119",className:"text-sm font-medium",children:"ç¶æ¥åè¨"}),e.jsxs("span",{"data-loc":"client/src/pages/MealLog.tsx:1120",className:"text-sm font-bold text-primary",children:[Math.round(x.reduce((a,t)=>a+(Number(t.totalCalories)||0),0))," kcal"]})]}),e.jsx("div",{"data-loc":"client/src/pages/MealLog.tsx:1125",className:"mt-3 flex justify-center",children:e.jsx(ta,{"data-loc":"client/src/pages/MealLog.tsx:1126",type:"meal",data:{date:n.toLocaleDateString("zh-HK",{year:"numeric",month:"long",day:"numeric"}),calories:Math.round(x.reduce((a,t)=>a+(Number(t.totalCalories)||0),0)),calorieTarget:L,protein:Math.round(x.reduce((a,t)=>a+(Number(t.protein)||0),0)),carbs:Math.round(x.reduce((a,t)=>a+(Number(t.carbs)||0),0)),fat:Math.round(x.reduce((a,t)=>a+(Number(t.fat)||0),0)),mealCount:x.length,photoUrl:x.find(a=>a.photoUrl)?.photoUrl||void 0,meals:x.map(a=>{const t=typeof a.foodItems=="string"?JSON.parse(a.foodItems):a.foodItems;return{name:Array.isArray(t)&&t.length>0?t.length<=2?t.map(s=>s.name).join("ã"):`${t[0]?.name} +${t.length-1}`:"æªç¥",photoUrl:a.photoUrl||void 0,mealType:a.mealType,calories:Math.round(Number(a.totalCalories)||0)}})},trigger:e.jsxs(o,{"data-loc":"client/src/pages/MealLog.tsx:1148",variant:"outline",size:"sm",className:"gap-1.5 text-xs",children:[e.jsx(sa,{"data-loc":"client/src/pages/MealLog.tsx:1149",className:"w-3.5 h-3.5"}),"åäº«ä»æ¥é£²é£ Story"]})})})]}):e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:1157",className:"text-center py-6 text-muted-foreground",children:[e.jsx("p",{"data-loc":"client/src/pages/MealLog.tsx:1158",children:"墿¥ä»²æªæè¨é"}),e.jsx("p",{"data-loc":"client/src/pages/MealLog.tsx:1159",className:"text-xs mt-1",children:"æ³ãå å
¥ãæè
ãAI èå¥ãéå§è¨ä½"})]})]})]})]}),z==="history"&&e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:1169",className:"space-y-4",children:[e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:1171",className:"flex gap-3",children:[e.jsx(p,{"data-loc":"client/src/pages/MealLog.tsx:1172",placeholder:"æå°é£ç©å稱...",value:O,onChange:a=>ia(a.target.value),className:"flex-1"}),e.jsxs(V,{"data-loc":"client/src/pages/MealLog.tsx:1178",value:Y,onValueChange:da,children:[e.jsx(q,{"data-loc":"client/src/pages/MealLog.tsx:1179",className:"w-28",children:e.jsx(Q,{"data-loc":"client/src/pages/MealLog.tsx:1180"})}),e.jsxs(W,{"data-loc":"client/src/pages/MealLog.tsx:1182",children:[e.jsx(u,{"data-loc":"client/src/pages/MealLog.tsx:1183",value:"all",children:"å
¨é¨"}),e.jsx(u,{"data-loc":"client/src/pages/MealLog.tsx:1184",value:"breakfast",children:"æ©é¤"}),e.jsx(u,{"data-loc":"client/src/pages/MealLog.tsx:1185",value:"lunch",children:"åé¤"}),e.jsx(u,{"data-loc":"client/src/pages/MealLog.tsx:1186",value:"dinner",children:"æé¤"}),e.jsx(u,{"data-loc":"client/src/pages/MealLog.tsx:1187",value:"snack",children:"å°é£"})]})]})]}),We.length===0?e.jsx(A,{"data-loc":"client/src/pages/MealLog.tsx:1194",className:"card-premium p-8 text-center",children:e.jsx("p",{"data-loc":"client/src/pages/MealLog.tsx:1195",className:"text-muted-foreground",children:"å飲é£è¨é"})}):We.map(a=>e.jsx(A,{"data-loc":"client/src/pages/MealLog.tsx:1199",className:"card-premium overflow-hidden",children:e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:1200",className:"p-4",children:[e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:1201",className:"flex items-start justify-between mb-3",children:[e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:1202",className:"flex-1",children:[e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:1203",className:"flex items-center gap-2 mb-2",children:[e.jsx("span",{"data-loc":"client/src/pages/MealLog.tsx:1204",className:`px-2 py-1 rounded text-xs font-medium ${La(a.mealType)}`,children:ja(a.mealType)}),e.jsx("span",{"data-loc":"client/src/pages/MealLog.tsx:1207",className:"text-xs text-muted-foreground",children:new Date(a.createdAt).toLocaleStr
30ing("zh-HK")})]}),e.jsx("div",{"data-loc":"client/src/pages/MealLog.tsx:1211",className:"text-sm text-muted-foreground",children:Array.isArray(a.foodItems)?a.foodItems.map(t=>t.name).join(" + "):"ç¡é£ç©"})]}),e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:1215",className:"flex gap-2",children:[e.jsx(o,{"data-loc":"client/src/pages/MealLog.tsx:1216",size:"sm",variant:"outline",onClick:()=>Na(a),children:e.jsx(Ua,{"data-loc":"client/src/pages/MealLog.tsx:1217",className:"w-4 h-4"})}),e.jsx(o,{"data-loc":"client/src/pages/MealLog.tsx:1219",size:"sm",variant:"outline",onClick:()=>ya(a.id),children:e.jsx(J,{"data-loc":"client/src/pages/MealLog.tsx:1220",className:"w-4 h-4"})}),e.jsx(o,{"data-loc":"client/src/pages/MealLog.tsx:1222",size:"sm",variant:"ghost",onClick:()=>na(fe===a.id?null:a.id),children:fe===a.id?e.jsx(Aa,{"data-loc":"client/src/pages/MealLog.tsx:1223",className:"w-4 h-4"}):e.jsx(ea,{"data-loc":"client/src/pages/MealLog.tsx:1223",className:"w-4 h-4"})})]})]}),e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:1227",className:"grid grid-cols-4 gap-2 text-xs",children:[e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:1228",className:"text-center p-2 bg-white/10 dark:bg-white/5 rounded",children:[e.jsx("div",{"data-loc":"client/src/pages/MealLog.tsx:1229",className:"font-semibold text-foreground",children:a.totalCalories}),e.jsx("div",{"data-loc":"client/src/pages/MealLog.tsx:1230",className:"text-muted-foreground",children:"å¡è·¯é"})]}),e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:1232",className:"text-center p-2 bg-white/10 dark:bg-white/5 rounded",children:[e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:1233",className:"font-semibold text-green-400",children:[a.protein,"g"]}),e.jsx("div",{"data-loc":"client/src/pages/MealLog.tsx:1234",className:"text-muted-foreground",children:"èç½è³ª"})]}),e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:1236",className:"text-center p-2 bg-white/10 dark:bg-white/5 rounded",children:[e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:1237",className:"font-semibold text-amber-400",children:[a.carbs,"g"]}),e.jsx("div",{"data-loc":"client/src/pages/MealLog.tsx:1238",className:"text-muted-foreground",children:"碳水"})]}),e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:1240",className:"text-center p-2 bg-white/10 dark:bg-white/5 rounded",children:[e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:1241",className:"font-semibold text-red-400",children:[a.fat,"g"]}),e.jsx("div",{"data-loc":"client/src/pages/MealLog.tsx:1242",className:"text-muted-foreground",children:"èèª"})]})]}),fe===a.id&&e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:1246",className:"mt-4 pt-4 border-t space-y-3",children:[a.photoUrl&&e.jsx("div",{"data-loc":"client/src/pages/MealLog.tsx:1248",className:"flex justify-center",children:e.jsx("img",{"data-loc":"client/src/pages/MealLog.tsx:1249",src:a.photoUrl,alt:"é£ç©ç¸",className:"max-w-xs max-h-48 rounded"})}),e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:1252",className:"text-sm",children:[e.jsx("p",{"data-loc":"client/src/pages/MealLog.tsx:1253",className:"font-medium text-foreground mb-2",children:"é£ç©è©³æ
ï¼"}),e.jsx("ul",{"data-loc":"client/src/pages/MealLog.tsx:1254",className:"space-y-1 text-muted-foreground",children:Array.isArray(a.foodItems)&&a.foodItems.map((t,s)=>e.jsxs("li",{"data-loc":"client/src/pages/MealLog.tsx:1256",className:"text-xs",children:["⢠",t.name," - ",t.calories,"kcal",t.quantity&&` (${t.quantity})`]},s))})]})]})]})},a.id)),he!==null&&i&&e.jsx("div",{"data-loc":"client/src/pages/MealLog.tsx:1269",className:"fixed inset-0 z-[100] flex items-center justify-center bg-black/60 backdrop-blur-sm p-4",onClick:()=>_(null),children:e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:1270",className:"bg-card rounded-2xl p-5 w-full max-w-sm shadow-2xl border border-border",onClick:a=>a.stopPropagation(),children:[e.jsx("h3",{"data-loc":"client/src/pages/MealLog.tsx:1271",className:"text-lg font-bold mb-4",children:"編輯飲é£è¨é"}),e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:1272",className:"space-y-3",children:[e.jsxs(V,{"data-loc":"client/src/pages/MealLog.tsx:1273",value:i.mealType||"",onValueChange:a=>F({...i,mealType:a}),children:[e.jsx(q,{"data-loc":"client/src/pages/MealLog.tsx:1274",children:e.jsx(Q,{"data-loc":"client/src/pages/MealLog.tsx:1274"})}),e.jsxs(W,{"data-loc":"client/src/pages/MealLog.tsx:1275",children:[e.jsx(u,{"data-loc":"client/src/pages/MealLog.tsx:1276",value:"breakfast",children:"æ©é¤"}),e.jsx(u,{"data-loc":"client/src/pages/MealLog.tsx:1277",value:"lunch",children:"åé¤"}),e.jsx(u,{"data-loc":"client/src/pages/MealLog.tsx:1278",value:"dinner",children:"æé¤"}),e.jsx(u,{"data-loc":"client/src/pages/MealLog.tsx:1279",value:"snack",children:"å°é£"})]})]}),e.jsx(p,{"data-loc":"client/src/pages/MealLog.tsx:1282",type:"number",placeholder:"å¡è·¯é",value:i.totalCalories||0,onChange:a=>F({...i,totalCalories:parseInt(a.target.value)||0})}),e.jsx(p,{"data-loc":"client/src/pages/MealLog.tsx:1283",type:"number",placeholder:"èç½è³ª (g)",value:i.protein||0,onChange:a=>F({...i,protein:parseInt(a.target.value)||0})}),e.jsx(p,{"data-loc":"client/src/pages/MealLog.tsx:1284",type:"number",placeholder:"碳水 (g)",value:i.carbs||0,onChange:a=>F({...i,carbs:parseInt(a.target.value)||0})}),e.jsx(p,{"data-loc":"client/src/pages/MealLog.tsx:1285",type:"number",placeholder:"èèª (g)",value:i.fat||0,onChange:a=>F({...i,fat:parseInt(a.target.value)||0})})]}),e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:1287",className:"flex gap-3 mt-4",children:[e.jsx(o,{"data-loc":"client/src/pages/MealLog.tsx:1288",variant:"outline",className:"flex-1",onClick:()=>_(null),children:"åæ¶"}),e.jsx(o,{"data-loc":"client/src/pages/MealLog.tsx:1289",className:"flex-1",onClick:va,disabled:ke.isPending,children:ke.isPending?"ä¿åä¸...":"ä¿å"})]})]})})]})]})}),Be!==null&&e.jsx("div",{"data-loc":"client/src/pages/MealLog.tsx:1303",className:"fixed inset-0 z-[100] flex items-center justify-center bg-black/60 backdrop-blur-sm p-4",onClick:()=>B(null),children:e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:1304",className:"bg-card rounded-2xl p-5 w-full max-w-sm shadow-2xl border border-border",onClick:a=>a.stopPropagation(),children:[e.jsxs("h3",{"data-loc":"client/src/pages/MealLog.tsx:1305",className:"text-lg font-bold mb-3 flex items-center gap-2",children:[e.jsx(K,{"data-loc":"client/src/pages/MealLog.tsx:1306",className:"w-5 h-5 text-amber-500"}),"å å
¥å¸¸é¤"]}),e.jsx("p",{"data-loc":"client/src/pages/MealLog.tsx:1309",className:"text-sm text-muted-foreground mb-3",children:"ç°ååæ¹ä¾¿ä¸æ¬¡æè¿åºåï¼"}),e.jsx(p,{"data-loc":"client/src/pages/MealLog.tsx:1310",value:me,onChange:a=>
30pe(a.target.value),placeholder:"ä¾å¦ï¼å¤§å®¶æ¨å¥åº·éæ³é£¯",className:"mb-4",autoFocus:!0}),e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:1317",className:"flex gap-2",children:[e.jsx(o,{"data-loc":"client/src/pages/MealLog.tsx:1318",variant:"outline",className:"flex-1",onClick:()=>B(null),children:"åæ¶"}),e.jsx(o,{"data-loc":"client/src/pages/MealLog.tsx:1319",className:"flex-1",disabled:!me.trim()||Le.isPending,onClick:()=>{Le.mutate({recordId:Be,name:me.trim()})},children:Le.isPending?"ä¿åä¸...":"â ä¿å常é¤"})]})]})}),ra&&e.jsx("div",{"data-loc":"client/src/pages/MealLog.tsx:1335",className:"fixed inset-0 z-[100] flex items-end sm:items-center justify-center bg-black/60 backdrop-blur-sm",onClick:()=>U(!1),children:e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:1336",className:"bg-card rounded-t-2xl sm:rounded-2xl p-5 w-full max-w-md max-h-[80vh] overflow-y-auto shadow-2xl border border-border",onClick:a=>a.stopPropagation(),children:[e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:1337",className:"flex items-center justify-between mb-4",children:[e.jsxs("h3",{"data-loc":"client/src/pages/MealLog.tsx:1338",className:"text-lg font-bold flex items-center gap-2",children:[e.jsx(K,{"data-loc":"client/src/pages/MealLog.tsx:1339",className:"w-5 h-5 text-amber-500"}),"æå
常é¤"]}),e.jsx(o,{"data-loc":"client/src/pages/MealLog.tsx:1342",variant:"ghost",size:"sm",onClick:()=>U(!1),children:e.jsx(Ce,{"data-loc":"client/src/pages/MealLog.tsx:1343",className:"w-4 h-4"})})]}),T&&T.length>0&&e.jsx("div",{"data-loc":"client/src/pages/MealLog.tsx:1348",className:"flex gap-1.5 mb-3 overflow-x-auto pb-1",children:["all","breakfast","lunch","dinner","snack"].map(a=>{const t={all:"å
¨é¨",breakfast:"ð
æ©é¤",lunch:"ð½ï¸ åé¤",dinner:"ð æé¤",snack:"ð¿ é¶é£"},s=a==="all"?T.length:T.filter(l=>l.mealType===a).length;return a!=="all"&&s===0?null:e.jsxs("button",{"data-loc":"client/src/pages/MealLog.tsx:1354",onClick:()=>oa(a),className:`px-3 py-1.5 rounded-full text-xs font-medium whitespace-nowrap transition-all ${ue===a?"bg-primary text-primary-foreground shadow-sm":"bg-muted/40 text-muted-foreground hover:bg-muted/60"}`,children:[t[a]," (",s,")"]},a)})}),T&&T.length>0?e.jsx("div",{"data-loc":"client/src/pages/MealLog.tsx:1370",className:"space-y-2",children:T.filter(a=>ue==="all"||a.mealType===ue).map(a=>{const t={breakfast:"ð
æ©é¤",lunch:"ð½ï¸ åé¤",dinner:"ð æé¤",snack:"ð¿ é¶é£"};return e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:1374",className:"flex items-center gap-3 p-3 bg-muted/20 rounded-lg border border-border/50",children:[a.photoUrl&&e.jsx("img",{"data-loc":"client/src/pages/MealLog.tsx:1376",src:a.photoUrl,alt:a.name,className:"w-12 h-12 rounded-lg object-cover flex-shrink-0"}),e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:1378",className:"flex-1 min-w-0",children:[e.jsx("div",{"data-loc":"client/src/pages/MealLog.tsx:1379",className:"font-medium text-sm truncate",children:a.name}),e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:1380",className:"text-xs text-muted-foreground",children:[t[a.mealType]," · ",Math.round(Number(a.totalCalories)||0)," kcal",a.restaurantName&&` · ${a.restaurantName}`]}),e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:1384",className:"text-xs text-muted-foreground",children:["P",Math.round(Number(a.protein)||0),"g · C",Math.round(Number(a.carbs)||0),"g · F",Math.round(Number(a.fat)||0),"g"]})]}),e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:1388",className:"flex flex-col gap-1 flex-shrink-0",children:[e.jsxs(o,{"data-loc":"client/src/pages/MealLog.tsx:1389",size:"sm",className:"h-7 text-xs px-2",disabled:Oe.isPending,onClick:()=>{Oe.mutate({favouriteId:a.id,date:n||void 0})},children:[e.jsx(De,{"data-loc":"client/src/pages/MealLog.tsx:1400",className:"w-3 h-3 mr-0.5"}),"è¨é"]}),e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:1402",className:"flex gap-0.5",children:[e.jsx(o,{"data-loc":"client/src/pages/MealLog.tsx:1403",variant:"ghost",size:"sm",className:"h-6 w-6 p-0",title:"編輯常é¤",onClick:()=>S({id:a.id,name:a.name,mealType:a.mealType,totalCalories:String(Math.round(Number(a.totalCalories)||0)),protein:String(Math.round(Number(a.protein)||0)),carbs:String(Math.round(Number(a.carbs)||0)),fat:String(Math.round(Number(a.fat)||0))}),children:e.jsx(aa,{"data-loc":"client/src/pages/MealLog.tsx:1418",className:"w-3 h-3 text-muted-foreground"})}),e.jsx(o,{"data-loc":"client/src/pages/MealLog.tsx:1420",variant:"ghost",size:"sm",className:"h-6 w-6 p-0",title:"åªé¤å¸¸é¤",onClick:()=>R(a.id),children:e.jsx(J,{"data-loc":"client/src/pages/MealLog.tsx:1427",className:"w-3 h-3 text-destructive"})})]})]})]},a.id)})}):e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:1436",className:"text-center py-8 text-muted-foreground",children:[e.jsx(K,{"data-loc":"client/src/pages/MealLog.tsx:1437",className:"w-10 h-10 mx-auto mb-2 opacity-30"}),e.jsx("p",{"data-loc":"client/src/pages/MealLog.tsx:1438",children:"ä½ ä»²æªæå¸¸é¤"}),e.jsx("p",{"data-loc":"client/src/pages/MealLog.tsx:1439",className:"text-xs mt-1",children:"å¨é£²é£è¨éæãâãå³å¯å å
¥å¸¸é¤"})]})]})}),g&&e.jsx("div",{"data-loc":"client/src/pages/MealLog.tsx:1448",className:"fixed inset-0 z-[110] flex items-center justify-center bg-black/60 backdrop-blur-sm p-4",onClick:()=>S(null),children:e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:1449",className:"bg-card rounded-2xl p-5 w-full max-w-sm shadow-2xl border border-border",onClick:a=>a.stopPropagation(),children:[e.jsxs("h3",{"data-loc":"client/src/pages/MealLog.tsx:1450",className:"text-lg font-bold mb-4 flex items-center gap-2",children:[e.jsx(aa,{"data-loc":"client/src/pages/MealLog.tsx:1451",className:"w-5 h-5 text-primary"}),"編輯常é¤"]}),e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:1454",className:"space-y-3",children:[e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:1455",children:[e.jsx(w,{"data-loc":"client/src/pages/MealLog.tsx:1456",className:"text-xs",children:"常é¤å稱"}),e.jsx(p,{"data-loc":"client/src/pages/MealLog.tsx:1457",value:g.name,onChange:a=>S({...g,name:a.target.value}),className:"mt-1"})]}),e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:1463",children:[e.jsx(w,{"data-loc":"client/src/pages/MealLog.tsx:1464",className:"text-xs",children:"åé¡"}),e.jsxs(V,{"data-loc":"client/src/pages/MealLog.tsx:1465",value:g.mealType,onValueChange:a=>S({...g,mealType:a}),children:[e.jsx(q,{"data-loc":"client/src/pages/MealLog.tsx:1466",className:"mt-1",children:e.jsx(Q,{"data-loc":"client/src/pages/MealLog.tsx:1467"})}),e.jsxs(W,{"data-loc":"client/src/pages/MealLog.tsx:1469",children:[e.jsx(u,{"data-loc":"client/src/pages/MealLog.tsx:1470",value:"breakfast",children:"ð
æ©é¤"}),e.jsx(u,{"data-loc":"client/src/pages/MealLog.tsx:1471",value:"lunch",children:"ð½ï¸ åé¤"}),e.jsx(u,{"data-loc":"client/src/pages/MealLog.tsx:1472",value:"dinner",children:"ð æé¤"}),e.jsx(u,{"data-loc":"client/src/pages/MealLog.tsx:1473",value:"snack",children:"ð¿ é¶é£"})]})]})]}),e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:1477",className:"grid grid-cols-4 gap-2",children:[e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:1478",children:[e.jsx(w,{"data-loc":"client/src/pages/MealLog.tsx:1479",className:"text-xs",children:"ç±é"}),e.jsx(p,{"data-loc":"client/src/pages/MealLog.tsx:1480",className:"mt-1 h-9",type:"number",value:g.totalCalories,onChange:a=>S({...g,totalCalories:a.target.value})})]}),e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:1482",children:[e.jsx(w,{"data-loc":"client/src/pages/MealLog.tsx:1483",className:"text-xs",children:"èç½è³ª"}),e.jsx(p,{"data-loc":"client/src/pages/MealLog.tsx:1484",className:"mt-1 h-9",type:"number",value:g.protein,onChange:a=>S({...g,protein:a.target.value})})]}),e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:1486",children:[e.jsx(w,{"data-loc":"client/src/pages/MealLog.tsx:1487",className:"text-xs",children:"碳水"}),e.jsx(p,{"data-loc":"client/src/pages/MealLog.tsx:1488",className:"mt-1 h-9",type:"number",value:g.carbs,onChange:a=>S({...g,carbs:a.target.value})})]}),e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:1490",children:[e.jsx(w,{"data-loc":"client/src/pages/MealLog.tsx:1491",className:"text-xs",children:"èèª"}),e.jsx(p,{"data-loc":"client/src/pages/MealLog.tsx:1492",className:"mt-1 h-9",type:"number",value:g.fat,onChange:a=>S({...g,fat:a.target.value})})]})]})]}),e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:1496",className:"flex gap-2 mt-4",children:[e.jsx(o,{"data-loc":"client/src/pages/MealLog.tsx:1497",variant:"outline",className:"flex-1",onClick:()=>S(null),children:"åæ¶"}),e.jsx(o,{"data-loc":"client/src/pages/MealLog.tsx:1498",className:"flex-1",disabled:!g.name.trim()||ve.isPending,onClick:()=>{ve.mutate({id:g.id,name:g.name.trim(),mealType:g.mealType,totalCalories:Number(g.totalCalories)||0,protein:Number(g.protein)||0,carbs:Number(g.carbs)||0,fat:Number(g.fat)||0})},children:ve.isPending?"ä¿åä¸...":"â
ä¿å"})]})]})}),Re!==null&&e.jsx("div",{"data-loc":"client/src/pages/MealLog.tsx:1522",className:"fixed inset-0 z-[110] flex items-center justify-center bg-black/60 backdrop-blur-sm p-4",onClick:()=>R(null),children:e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:1523",className:"bg-card rounded-2xl p-5 w-full max-w-xs shadow-2xl border border-border text-center",onClick:a=>a.stopPropagation(),children:[e.jsx(J,{"data-loc":"client/src/pages/MealLog.tsx:1524",className:"w-10 h-10 mx-auto mb-3 text-destructive opacity-80"}),e.jsx("h3",{"data-loc":"client/src/pages/MealLog.tsx:1525",className:"text-lg font-bold mb-2",children:"確å
30®åªé¤ï¼"}),e.jsx("p",{"data-loc":"client/src/pages/MealLog.tsx:1526",className:"text-sm text-muted-foreground mb-4",children:"åªé¤å¾ç¡æ³å¾©åï¼ä½ 確å®è¦ç§»é¤å¢å常é¤ï¼"}),e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:1527",className:"flex gap-2",children:[e.jsx(o,{"data-loc":"client/src/pages/MealLog.tsx:1528",variant:"outline",className:"flex-1",onClick:()=>R(null),children:"åæ¶"}),e.jsx(o,{"data-loc":"client/src/pages/MealLog.tsx:1529",variant:"destructive",className:"flex-1",disabled:Ne.isPending,onClick:()=>Ne.mutate({id:Re}),children:Ne.isPending?"åªé¤ä¸...":"確å®åªé¤"})]})]})}),Ue&&e.jsxs("div",{"data-loc":"client/src/pages/MealLog.tsx:1544",className:"fixed inset-0 z-[100] flex items-center justify-center bg-black/80 backdrop-blur-sm p-4",onClick:()=>xe(null),children:[e.jsx("button",{"data-loc":"client/src/pages/MealLog.tsx:1548",type:"button",onClick:()=>xe(null),className:"absolute top-4 right-4 w-10 h-10 rounded-full bg-white/10 hover:bg-white/20 flex items-center justify-center transition-colors",children:e.jsx(Ce,{"data-loc":"client/src/pages/MealLog.tsx:1553",className:"w-6 h-6 text-foreground"})}),e.jsx("img",{"data-loc":"client/src/pages/MealLog.tsx:1555",src:Ue,alt:"é£ç©ç¸ç",className:"max-w-full max-h-[85vh] rounded-xl object-contain shadow-2xl",onClick:a=>a.stopPropagation()})]})]})}export{ct 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.