UNPKG

@bagaking/dayboxing

Version:

A React component library for DayBoxing time management visualization

1 lines 102 kB
import*as e from"react";import t,{useState as n,useCallback as r,useRef as o,useLayoutEffect as i,useEffect as a,useMemo as c}from"react";import s,{css as u}from"styled-components";import*as l from"react-dom";function p(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function f(e,t,n){return t&&function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,m(r.key),r)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function d(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,i,a,c=[],s=!0,u=!1;try{if(i=(n=n.call(e)).next,0===t);else for(;!(s=(r=i.call(n)).done)&&(c.push(r.value),c.length!==t);s=!0);}catch(e){u=!0,o=e}finally{try{if(!s&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(u)throw o}}return c}}(e,t)||h(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function g(e){return function(e){if(Array.isArray(e))return p(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||h(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function m(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t);if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==typeof t?t:t+""}function h(e,t){if(e){if("string"==typeof e)return p(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?p(e,t):void 0}}var y=Array.from(["sleep","work","life","relax","improve"]),v={s:"sleep",w:"work",l:"life",r:"relax",i:"improve"},b={MIN_DAY_HOURS:21,MAX_DAY_HOURS:28,MIN_SLEEP_HOURS:6,MAX_SLEEP_HOURS:9,MIN_WORK_HOURS:4,MAX_WORK_HOURS:10,MAX_CONTINUOUS_WORK:4,MAX_CONTINUOUS_IMPROVE:4,MIN_LIFE_RATIO:.2},x={colors:{sleep:"#A78BFA",work:"#60A5FA",life:"#34D399",relax:"#FBBF24",improve:"#F472B6",background:"#ffffff",text:"#1f2937"},cellSize:40,gap:2,borderRadius:4},w={colors:{sleep:"#DDD6FE",work:"#BFDBFE",life:"#A7F3D0",relax:"#FDE68A",improve:"#F472B6",background:"#ffffff",text:"#1f2937"}},E={colors:{sleep:"#8B5CF6",work:"#3B82F6",life:"#10B981",relax:"#F59E0B",improve:"#F472B6",background:"#1F2937",text:"#F9FAFB"}},T=[{id:"day_length",type:"overall",priority:100,condition:function(e){return!0},analyze:function(e){var t=e.day.hours.length,n=[];return t>b.MAX_DAY_HOURS&&n.push({type:"warning",content:"当前时长超过".concat(b.MAX_DAY_HOURS,"小时,建议及时结束当天行程,避免过度疲劳")}),t>24&&(t>26?n.push({type:"warning",content:"已接近长日上限,建议尽快结束当天行程"}):n.push({type:"suggestion",content:"当前为长日模式(".concat(t,"h),建议不超过28小时")})),t<24&&(t<21?n.push({type:"warning",content:"当前时长不足21小时,可能错过重要活动时间"}):n.push({type:"suggestion",content:"当前为短日模式(".concat(t,"h),建议不少于21小时")})),n.push({type:"tip",content:"保持规律的作息时间有助于提高生活质量和工作效率"}),{status:n.some((function(e){return"warning"===e.type}))?"warning":"success",title:n.some((function(e){return"warning"===e.type}))?"日程长度异常":"日程长度正常",advices:n}}},{id:"sleep_distribution",type:"overall",priority:95,condition:function(e){return!0},analyze:function(e){var t=e.day.hours.filter((function(e){return"sleep"===e.type})),n=t.length,r=[];n<6?r.push({type:"warning",content:"睡眠时间不足,建议保持 6-9 小时以确保充分休息"}):n>9&&r.push({type:"warning",content:"睡眠时间偏多,建议控制在 9 小时以内以提高时间利用效率"});var o=t.reduce((function(e,n,r){return 0===r||t[r-1].hour!==n.hour-1?e.push([n]):e[e.length-1].push(n),e}),[]);o.length>1&&(o.filter((function(e){return e.length<=2})).length>0&&r.push({type:"suggestion",content:"存在碎片化睡眠,建议调整作息保持连续充足的休息时间"}));return r.push({type:"tip",content:"良好的睡眠质量需要规律的作息和合适的睡眠环境"}),{status:r.some((function(e){return"warning"===e.type}))?"warning":"success",title:"睡眠分布分析",advices:r}}},{id:"work_improve_balance",type:"overall",priority:90,condition:function(e){return!0},analyze:function(e){var t=e.day.hours.filter((function(e){return"work"===e.type})),n=e.day.hours.filter((function(e){return"improve"===e.type})),r=t.length,o=n.length,i=[];if(r<4)i.push({type:"warning",content:"当前工作时间为".concat(r,"小时,低于建议的最少工作时间(6小时)。建议增加").concat(6-r,"小时工作时间,以保证基本工作产出")});else if(r>10){var a=r-10;i.push({type:"warning",content:"当前工作时间为".concat(r,"小时,超出建议的最大工作时间(10小时)。建议减少").concat(a,"小时工作时间,将多出的时间用于自我提升或休息")})}if(0===o)i.push({type:"suggestion",content:"今日无自我提升时间。建议每天至少安排2小时用于自我提升,可以从工作时间(".concat(r,"小时)中调配")});else{var c=n.reduce((function(e,t,r){return 0===r||n[r-1].hour!==t.hour-1?e.push([t]):e[e.length-1].push(t),e}),[]);c.length>3&&i.push({type:"suggestion",content:"自我提升时间(".concat(o,"小时)分散在").concat(c.length,"个时间段中。建议将短于1小时的时间段合并,形成2-3个较长的学习时段,以提高学习效率")});var s=c.filter((function(e){return e.length>4}));if(s.length>0){var u=s.map((function(e){return"".concat(e[0].hour,":00-").concat(e[e.length-1].hour+1,":00")})).join("、");i.push({type:"warning",content:"在".concat(u,"存在超过4小时的连续学习。建议每2小时休息15-20分钟,保持专注度")})}}var l=t.reduce((function(e,n,r){return 0===r||t[r-1].hour!==n.hour-1?e.push([n]):e[e.length-1].push(n),e}),[]);if(l.length>4){var p=l.filter((function(e){return e.length<=2}));if(p.length>0){var f=p.map((function(e){return"".concat(e[0].hour,":00-").concat(e[e.length-1].hour+1,":00")})).join("、");i.push({type:"suggestion",content:"工作时间过于碎片化,在".concat(f,"存在").concat(p.length,"个短工作时段。建议合并这些时段,形成较长的工作区块以提高专注度")})}}var d=l.filter((function(e){return e.length>4}));if(d.length>0){var g=d.map((function(e){return"".concat(e[0].hour,":00-").concat(e[e.length-1].hour+1,":00")})).join("、");i.push({type:"warning",content:"在".concat(g,"存在超过4小时的连续工作。建议每90-120分钟休息15分钟,既能保持效率,也符合人体自然能量周期")})}r>8&&0===o&&i.push({type:"suggestion",content:"当前工作时间(".concat(r,"小时)较长但无自我提升时间。建议从工作时间中调配2-3小时用于个人成长,既能缓解工作压力,也能促进长期发展")});var m=o/(r+o);if(m<.2&&r>6){var h=Math.ceil(.2*(r+o));i.push({type:"suggestion",content:"自我提升时间占比(".concat(Math.round(100*m),"%)较低。建议将自我提升时间从").concat(o,"小时增加到").concat(h,"小时,在完成必要工作的基础上,加强个人成长")})}if(r+o>14){var y=r+o-14;i.push({type:"warning",content:"高强度工作和学习时间共计".concat(r+o,"小时,超出建议的每日总量(14小时)。建议减少").concat(y,"小时,并增加休息时间,以维持长期可持续性")})}return o/r<.2&&i.push({type:"tip",content:"自我提升与工作的最少配比是1:4。当前配比为".concat(o,":").concat(r,",可以通过调整时间分配来优化")}),{status:i.some((function(e){return"warning"===e.type}))?"warning":"success",title:"工作与自我提升分析",advices:i}}},{id:"life_work_balance",type:"overall",priority:85,condition:function(e){return!0},analyze:function(e){var t=e.day.hours.filter((function(e){return"work"===e.type})).length,n=e.day.hours.filter((function(e){return"life"===e.type})).length,r=e.day.hours.filter((function(e){return"relax"===e.type})).length,o=e.day.hours.length,i=[],a=(n+r)/o;a<.2&&i.push({type:"warning",content:"生活时间比例仅为".concat(Math.round(100*a),"%(").concat(n+r,"小时),低于建议的20%(").concat(Math.ceil(.2*o),"小时)。建议增加").concat(Math.ceil(.2*o)-(n+r),"小时生活和休闲活动")}),t>0&&0===n&&i.push({type:"warning",content:"当天".concat(t,"小时工作时间中未安排生活时间。建议每4小时工作插入至少30分钟生活时间,既能提高工作效率,也能保持生活质量")}),t>8&&0===r&&i.push({type:"suggestion",content:"工作时间达到".concat(t,"小时,但未安排休闲时间。建议在工作结束后安排1-2小时的休闲活动,帮助身心恢复")});var c=e.day.hours.reduce((function(e,t,n,r){return"life"===t.type&&(0===n||"life"!==r[n-1].type?e.push([t]):e[e.length-1].push(t)),e}),[]);if(c.length>0){var s=c.filter((function(e){return e.length<1}));if(s.length>2){var u=s.map((function(e){return"".concat(e[0].hour,":00-").concat(e[e.length-1].hour+1,":00")})).join("、");i.push({type:"suggestion",content:"在".concat(u,"存在").concat(s.length,"个短于1小时的生活时间段。建议合并相近的时间段,形成较完整的生活节奏")})}}var l=Math.round(.25*o);return n>0&&Math.abs(n-l)<=2?i.push({type:"tip",content:"当前生活时间分配合理(".concat(n,"小时),接近理想值").concat(l,"小时。保持这种平衡有助于提高生活质量")}):i.push({type:"tip",content:"生活时间的理想分配是总时间的25%(约".concat(l,"小时)。可以通过调整工作强度和效率来达到这个目标")}),{status:i.some((function(e){return"warning"===e.type}))?"warning":"success",title:"工作生活平衡分析",advices:i}}},{id:"pressure_indicators",type:"overall",priority:80,condition:function(e){return!0},analyze:function(e){var t=[],n=e.day.hours,r=n.filter((function(e){return"work"===e.type&&e.hour>=22}));r.length>0&&r.reduce((function(e,t){var n=e[e.length-1];return n&&n[n.length-1].hour===t.hour-1?n.push(t):e.push([t]),e}),[]).forEach((function(e){t.push({type:"warning",content:"在".concat(e[0].hour,":00-").concat(e[e.length-1].hour+1,":00存在深夜工作。建议调整到9:00-18:00的高效工作时段,深夜时段建议用于休息或自我提升")})}));var o=0,i=-1;n.forEach((function(e,n){"work"===e.type?(0===o&&(i=e.hour),++o>4&&t.push({type:"warning",content:"在".concat(i,":00-").concat(e.hour+1,":00存在").concat(o,"小时连续工作。建议在").concat(i+2,":00和").concat(i+4,":00各安排15-20分钟休息,保持工作效率")})):o=0}));var a=n.filter((function(e){return"work"===e.type})).length,c=n.length,s=a/c;s>.6&&t.push({type:"warning",content:"工作时间占比".concat(Math.round(100*s),"%(").concat(a,"/").concat(c,"小时)过高。建议通过提高工作效率来减少工作时间,为生活和休息留出更多空间")});var u=n.reduce((function(e,t,n,r){return"work"===t.type&&n>0&&"work"===r[n-1].type&&e.push(n),e}),[]);if(u.length>3){var l=u.filter((function(e,t){return t%3==1})).map((function(e){return"".concat(n[e].hour,":00")})).join("、");t.push({type:"suggestion",content:"工作间隔较少,建议在".concat(l,"等时间点增加15-20分钟的休息,既能恢复精力,也能提高后续工作效率")})}return t.some((function(e){return"warning"===e.type}))?t.push({type:"tip",content:"高强度工作可能影响长期表现。建议:1)建立规律作息 2)保持适度运动 3)定期压力评估"}):t.push({type:"tip",content:"当前工作压力在可控范围。建议继续保持规律作息,做好工作计划,让高效工作成为习惯"}),{status:t.some((function(e){return"warning"===e.type}))?"warning":"success",title:"压力指标分析",advices:t}}}],S={sleep:0,relax:1,life:2,improve:3,work:3},R=[{id:"energy_transitions",type:"feature",priority:85,condition:function(e){return!0},analyze:function(e){var t=function(e){for(var t=[],n=0;n<e.length-1;n++){var r=e[n].type,o=e[n+1].type,i=S[r],a=S[o],c=Math.abs(a-i);c>1&&t.push({hour:e[n+1].hour,from:r,to:o,energyJump:c})}return t}(e.day.hours),n=[];t.forEach((function(e){var t=e.hour,r=e.from,o=e.to,i=e.energyJump;i>2?n.push({type:"warning",content:"在".concat(t,":00,从").concat(r,"直接切换到").concat(o,",能量差异过大(").concat(i,"级)。建议通过生活活动作为过渡,帮助身心调整到合适状态")}):2===i&&n.push({type:"tip",content:"在".concat(t,":00,活动从").concat(r,"切换到").concat(o,"。建议预留5-10分钟的过渡时间,以便更好地适应新的活动")})}));var r=e.day.hours.reduce((function(e,t,n,r){return"work"!==t.type&&"improve"!==t.type||(0===n||"work"!==r[n-1].type&&"improve"!==r[n-1].type?e.push([t]):e[e.length-1].push(t)),e}),[]);r.forEach((function(e){if(e.length>2){var t=e[0].hour,r=e[e.length-1].hour;n.push({type:"suggestion",content:"在".concat(t,":00-").concat(r+1,":00期间连续进行高强度活动").concat(e.length,"小时。建议每90-120分钟安排15分钟休息,符合人体自然能量周期")})}}));var o=e.day.hours.reduce((function(e,t){var n=S[t.type];return e[n]=(e[n]||0)+1,e}),{})[3]||0,i=e.day.hours.length;return o/i>.5&&n.push({type:"warning",content:"高能量活动占比".concat(Math.round(o/i*100),"%(").concat(o,"小时)过高。建议增加中低强度活动,保持能量水平的可持续性")}),n.push({type:"tip",content:"合理的能量分配模式:早晨规划、上午专注、午后缓冲、傍晚总结。遵循这个节奏可以充分利用人体自然能量周期"}),{status:n.some((function(e){return"warning"===e.type}))?"warning":"success",title:"能量转换分析",advices:n}}}],M={start:9,end:11},O={start:14,end:16},k=function(e,t){return"".concat(String(e).padStart(2,"0"),":00-").concat(String(t).padStart(2,"0"),":00")},H=[].concat(g(R),[{id:"continuous_blocks",type:"feature",priority:90,condition:function(e){return!0},analyze:function(e){var t,n,r=[],o=e.day.hours,i=null===(t=o[0])||void 0===t?void 0:t.type,a=null===(n=o[0])||void 0===n?void 0:n.hour,c=1;return o.slice(1).forEach((function(e,t){e.type===i?c++:(c>4&&("work"===i||"improve"===i)&&r.push({type:"warning",content:"在".concat(k(a,a+c),"期间, 持续").concat(c,"小时进行 ").concat(i,"活动。建议每2小时休息15分钟,既能恢复精力,也能提高效率")}),i=e.type,a=e.hour,c=1)})),{status:r.some((function(e){return"warning"===e.type}))?"warning":"success",title:"连续时间块分析",advices:r}}},{id:"golden_hours",type:"feature",priority:85,condition:function(e){return!0},analyze:function(e){var t=[],n=e.day.hours.filter((function(e){return e.hour>=M.start&&e.hour<M.end})),r=new Set(n.map((function(e){return e.type})));!(r.has("work")||r.has("improve"))&&n.length>0&&t.push({type:"warning",content:"在".concat(k(M.start,M.end),"黄金时段,安排了").concat(Array.from(r).join("、"),"等活动。建议将这个注意力最集中的时段用于工作或自我提升,其他活动可调整到下午或晚上")});var o=e.day.hours.filter((function(e){return e.hour>=O.start&&e.hour<O.start+2}));return o.every((function(e){return"work"===e.type||"improve"===e.type}))&&o.length>0&&t.push({type:"suggestion",content:"在".concat(k(O.start,O.start+2),"午后时段安排了高强度活动。建议在这个生理疲劳期转为低强度任务,或安排15-30分钟休息")}),t.push({type:"tip",content:"合理利用时间段特点:上午9-11点适合创造性工作,下午2-4点适合常规任务,晚上8点后避免高强度活动"}),{status:t.some((function(e){return"warning"===e.type}))?"warning":"success",title:"时间效率分析",advices:t}}},{id:"activity_transitions",type:"feature",priority:75,condition:function(e){return!0},analyze:function(e){for(var t=[],n=e.day.hours,r=0,o=-1,i=0,a=1;a<n.length;a++)n[a].type!==n[a-1].type&&(r++,o===n[a-1].hour&&++i>=2&&t.push({type:"warning",content:"在".concat(k(n[a-2].hour,n[a].hour+1),"期间,活动频繁切换(").concat(n[a-2].type,"→").concat(n[a-1].type,"→").concat(n[a].type,")。建议合并相似活动,减少切换成本")}),o=n[a].hour);for(var c=1;c<n.length-1;c++){var s=n[c-1].type,u=n[c].type;"sleep"===s&&"work"===u&&t.push({type:"suggestion",content:"在".concat(n[c].hour,":00从睡眠直接进入工作。建议先进行15-30分钟的生活整理或准备活动,帮助身心进入工作状态")})}return r>8&&t.push({type:"tip",content:"当天活动切换次数较多(".concat(r,"次)。可以通过合并相似活动、设置固定工作时段等方式来减少不必要的切换")}),{status:t.some((function(e){return"warning"===e.type}))?"warning":"success",title:"活动转换分析",advices:t}}}]),C=function(e,t){return"".concat(String(e).padStart(2,"0"),":00-").concat(String(t).padStart(2,"0"),":00")},A=function(e,t,n){var r=e.filter((function(e){return e.hour>=t&&e.hour<n&&"sleep"===e.type})),o=r.length,i=r.reduce((function(e,t,n){return 0===n||r[n-1].hour!==t.hour-1?e.push([t]):e[e.length-1].push(t),e}),[]);return{totalSleep:o,continuousBlocks:i,isFragmented:i.length>1,longestBlock:Math.max.apply(Math,g(i.map((function(e){return e.length}))))}},_=function(e,t){var n=e.filter((function(e){return e.hour>=t&&e.hour<t+2})),r=g(new Set(n.map((function(e){return e.type}))));return{type:r[0]||"undefined",duration:n.length,isConsistent:1===r.length}},N=[{id:"a_segment",type:"segment",priority:95,condition:function(e){var t;return"A"===(null===(t=e.segment)||void 0===t?void 0:t.segment)},analyze:function(e){var t=e.segment,n=[],r=A(e.day.hours,t.startHour,t.endHour);"full"===t.type&&"sleep"===t.mainType||n.push({type:"warning",content:"A段(".concat(C(t.startHour,t.endHour),")不是完整的睡眠时间,当前睡眠时长").concat(r.totalSleep,"小时。建议调整作息,确保A段全部用于睡眠")}),r.isFragmented&&n.push({type:"warning",content:"A段睡眠出现".concat(r.continuousBlocks.length,"次中断,最长连续睡眠仅").concat(r.longestBlock,"小时。建议保持睡眠环境稳定,避免睡眠碎片化")});var o=e.allSegments.filter((function(e){return"A"!==e.segment})).filter((function(e){return"sleep"===e.mainType||"sleep"===e.secondaryType}));o.length>0&&(o.filter((function(t){return A(e.day.hours,t.startHour,t.endHour).totalSleep<=2})).length===o.length?n.push({type:"tip",content:"其他时段的睡眠时长均不超过2小时,符合小憩的特点,有助于恢复精力"}):n.push({type:"warning",content:"存在超过2小时的非A段睡眠,建议将主要睡眠时间集中在A段,保持作息规律"}));return{status:n.some((function(e){return"warning"===e.type}))?"warning":"success",title:"A段睡眠分析",advices:n}}},{id:"b_segment_type",type:"segment",priority:90,condition:function(e){var t;return"B"===(null===(t=e.segment)||void 0===t?void 0:t.segment)},analyze:function(e){var t=e.segment,n=[];return"chaos"===t.type&&n.push({type:"warning",content:"B段(".concat(C(t.startHour,t.endHour),")活动过于混乱。建议设定明确的主要活动类型,减少频繁切换")}),"balance"===t.type&&n.push({type:"suggestion",content:"B段活动出现".concat(t.mainType,"和").concat(t.secondaryType,"的均衡状态,可能影响主要任务的专注度。建议突出重点活动,其他活动作为辅助")}),"mix"!==t.type&&n.push({type:"warning",content:"B段不是Mix Part,当前为".concat(t.type," Part。建议保持一个主导活动类型,同时适当配合其他活动")}),{status:n.some((function(e){return"warning"===e.type}))?"warning":"success",title:"B段类型分析",advices:n}}},{id:"b_segment_start",type:"segment",priority:92,condition:function(e){var t;return"B"===(null===(t=e.segment)||void 0===t?void 0:t.segment)},analyze:function(e){var t=e.segment,n=_(e.day.hours,t.startHour),r=[];switch(n.type){case"sleep":r.push({type:"warning",content:"B段开始时仍在睡眠(".concat(C(t.startHour,t.startHour+n.duration),"),说明作息时间偏后。建议提前").concat(n.duration,"小时入睡,保证A段完整睡眠")});break;case"life":n.isConsistent&&r.push({type:"tip",content:"B段以生活活动开始,这是理想的晨间安排,有助于平稳过渡到工作状态"});break;case"relax":r.push({type:"suggestion",content:"B段以休闲活动开始(".concat(C(t.startHour,t.startHour+n.duration),"),建议改为生活或工作活动,提高早间效率")});break;case"work":var o=e.historicalDays&&e.historicalDays.length>=3&&e.historicalDays.every((function(e){var t,n=null===(t=e.qhSegments)||void 0===t?void 0:t.find((function(e){return"B"===e.segment})),r=n&&_(e.hours,n.startHour);return"work"===(null==r?void 0:r.type)||"relax"===(null==r?void 0:r.type)}));r.push({type:"warning",content:o?"连续多天B段直接开始工作,说明工作压力持续偏大,建议调整节奏,避免透支":"B段直接开始工作(".concat(C(t.startHour,t.startHour+n.duration),"),建议预留生活过渡时间,帮助调整状态")});break;case"improve":r.push({type:"tip",content:"以自我提升活动开始新的一天,体现了良好的学习意愿和自我管理能力"});break;default:r.push({type:"warning",content:"B段开始活动类型异常,请检查数据记录是否准确"})}return{status:r.some((function(e){return"warning"===e.type}))?"warning":"success",title:"B段开始方式分析",advices:r}}},{id:"c_segment",type:"segment",priority:85,condition:function(e){var t;return"C"===(null===(t=e.segment)||void 0===t?void 0:t.segment)},analyze:function(e){var t=e.segment,n=[];"chaos"===t.type&&n.push({type:"warning",content:"C段(".concat(C(t.startHour,t.endHour),")活动混乱。建议保持相对固定的活动安排,避免频繁切换任务类型")});for(var r=e.day.hours.filter((function(e){return e.hour>=t.startHour&&e.hour<t.endHour})),o=0,i=1;i<r.length;i++)r[i].type!==r[i-1].type&&o++;return o>3&&n.push({type:"suggestion",content:"C段活动切换过于频繁(".concat(o,"次),建议合并同类活动,保持工作或学习的连续性")}),n.push({type:"tip",content:"C段是一天中精力开始下降的时段,适合安排常规性工作或放松活动"}),{status:n.some((function(e){return"warning"===e.type}))?"warning":"success",title:"C段活动分析",advices:n}}},{id:"f_segment",type:"segment",priority:80,condition:function(e){var t;return"F"===(null===(t=e.segment)||void 0===t?void 0:t.segment)},analyze:function(e){var t,n,r,o=e.segment,i=[],a=o.endHour-o.startHour;if(a>7&&i.push({type:"warning",content:"F段延长过多(".concat(a,"小时),超出建议的最大浮动范围(7小时)。建议及时结束当天行程,避免影响次日状态")}),"mix"===o.type&&"work"===o.mainType&&a>3&&i.push({type:"warning",content:"F段以工作为主(".concat(C(o.startHour,o.endHour),"),且延长").concat(a,"小时,说明工作压力较大。建议优化工作计划,避免经常性加班")}),o.endHour>o.startHour+4){var c=null===(r=null===(n=null===(t=e.historicalDays)||void 0===t?void 0:t[0])||void 0===n?void 0:n.qhSegments)||void 0===r?void 0:r.find((function(e){return"A"===e.segment}));c&&"full"!==c.type&&i.push({type:"warning",content:"F段延长影响了次日A段的睡眠质量,建议控制当天结束时间,保证充足休息"})}return a>0&&i.push({type:"tip",content:"F段作为浮动时间,建议用于:1)处理计划外事务 2)补充学习时间 3)适度放松。当前用于".concat(o.mainType).concat(o.secondaryType?"和"+o.secondaryType:"")}),{status:i.some((function(e){return"warning"===e.type}))?"warning":"success",title:"F段分析",advices:i}}}],I={},P={},z={};Object.defineProperty(z,"__esModule",{value:!0}),z.FORMAT_TEMPLATES=z.FORMAT_OPTIONS=z.ESTIMATION_PREFERENCE=z.PATTERNS=z.ERROR_MESSAGES=z.TIME_RANGES=void 0,z.TIME_RANGES={Q:{min:10,max:20,avg:15},POMO:{min:20,max:40,avg:30},CC:{min:80,max:100,avg:90}},z.ERROR_MESSAGES={NEGATIVE:"Time units cannot be negative",NON_INTEGER:"Time units must be integers",INVALID_FORMAT:e=>`Invalid format: ${e}`},z.PATTERNS={UNIT:/^(\d+)(cc|pomo|q)$/},z.ESTIMATION_PREFERENCE={MINIMAL:"minimal",MAXIMAL:"maximal",AVERAGE:"average"},z.FORMAT_OPTIONS={HIDE_ZERO:"hide-when-zero",NO_PAD_ZERO:"no-pad-zero"},z.FORMAT_TEMPLATES={KH:'CC"cc" PP"pomo" QQ"q" :: hide-when-zero no-pad-zero',HUMAN:"HH小时 MM分钟",STANDARD:"HH:MM:SS",SIMPLE:"HHh MMm :: hide-when-zero no-pad-zero",FULL:'HH "hours" MM "minutes" :: hide-when-zero'};var L={};Object.defineProperty(L,"__esModule",{value:!0}),L.formatTime=L.fromMinutes=L.toMinutes=void 0;const D=z;function F(e){return Object.values(D.FORMAT_OPTIONS).includes(e)}function j(e){var t,n,r;return(null!==(t=e.cc)&&void 0!==t?t:0)*D.TIME_RANGES.CC.avg+(null!==(n=e.pomo)&&void 0!==n?n:0)*D.TIME_RANGES.POMO.avg+(null!==(r=e.q)&&void 0!==r?r:0)*D.TIME_RANGES.Q.avg}L.toMinutes=j,L.fromMinutes=function(e){const t=Math.floor(e/D.TIME_RANGES.CC.avg),n=e%D.TIME_RANGES.CC.avg,r=Math.floor(n/D.TIME_RANGES.POMO.avg),o=n%D.TIME_RANGES.POMO.avg;return{cc:t,pomo:r,q:Math.floor(o/D.TIME_RANGES.Q.avg)}},L.formatTime=function(e,t=D.FORMAT_TEMPLATES.KH){const{template:n,options:r}=function(e){const t=(e||"").split("::");if(t.length>2)throw new Error("Invalid format");let[n,r]=t;n=n.trim(),r=null==r?void 0:r.trim();const o=new Set;if(r){const e=r.split(" ").filter(Boolean);for(const t of e){if(!F(t))throw new Error(`Invalid format option: "${t}". Valid options are: ${Object.values(D.FORMAT_OPTIONS).join(", ")}`);o.add(t)}}return{template:n,options:o}}(null==t?D.FORMAT_TEMPLATES.KH:t),o=function(e){var t,n,r;const o=j(e),i=Math.floor(o/60),a=Math.floor(o%60),c=Math.floor(o%1*60);return{CC:null!==(t=e.cc)&&void 0!==t?t:0,PP:null!==(n=e.pomo)&&void 0!==n?n:0,QQ:null!==(r=e.q)&&void 0!==r?r:0,HH:i,MM:a,SS:c}}(e),i=!Object.values(o).some((e=>0!==e));if(i&&r.has(D.FORMAT_OPTIONS.HIDE_ZERO))return"";let a=n;function c(e,t){let n=0;for(let r=0;r<t;r++)'"'===e[r]&&n++;return n%2}return Object.entries(o).forEach((([e,t])=>{if(0===t&&r.has(D.FORMAT_OPTIONS.HIDE_ZERO)&&!i)a=function(e,t){let n=e.replace(new RegExp(`${t}+\\s*"[^"]*"`),"");return n=n.replace(new RegExp(`${t}+\\s*`),""),n}(a,e);else{const o=function(e,t){const n=e.match(new RegExp(`${t}+`));return n?n[0].length:1}(n,e),i=r.has(D.FORMAT_OPTIONS.NO_PAD_ZERO)?t.toString():t.toString().padStart(o,"0"),s=new RegExp(`${e}+`,"g");let u,l=0,p="";for(;null!==(u=s.exec(a));){p+=c(a,u.index)%2==1?a.slice(l,s.lastIndex):a.slice(l,u.index)+i,l=s.lastIndex}p+=a.slice(l),a=p}})),a=a.trim().replace(/"([^"]*?)"/g,"$1"),a},Object.defineProperty(P,"__esModule",{value:!0}),P.KHTimeUnit=void 0;const B=z,q=L;class G{get q(){return this._q}get pomo(){return this._pomo}get cc(){return this._cc}constructor(e){if(this._q=0,this._pomo=0,this._cc=0,this._isDirectInput=!1,this._isDirectInput=!0,"number"==typeof e){const t=(0,q.fromMinutes)(e);this.setUnits(t),this._isDirectInput=!1}else if("string"==typeof e){const t=G.parseString(e);this.setUnits(t)}else this.setUnits(e);this.validate()}setUnits(e){var t,n,r;this._q=null!==(t=e.q)&&void 0!==t?t:0,this._pomo=null!==(n=e.pomo)&&void 0!==n?n:0,this._cc=null!==(r=e.cc)&&void 0!==r?r:0}validate(){if(!Number.isInteger(this._q)||!Number.isInteger(this._pomo)||!Number.isInteger(this._cc))throw new Error(B.ERROR_MESSAGES.NON_INTEGER);if(this._isDirectInput&&(this._q<0||this._pomo<0||this._cc<0)&&this.toMinutes()<0)throw new Error(B.ERROR_MESSAGES.NEGATIVE)}toMinutes(){return(0,q.toMinutes)({q:this._q,pomo:this._pomo,cc:this._cc})}toHours(){return this.toMinutes()/60}toSeconds(){return 60*this.toMinutes()}toString(e){return(0,q.formatTime)({q:this._q,pomo:this._pomo,cc:this._cc},null!=e?e:B.FORMAT_TEMPLATES.KH)}static fromHours(e){return new G(60*e)}static fromSeconds(e){return new G(e/60)}static fromMinutes(e){return new G(e)}static parseString(e){const t={q:0,pomo:0,cc:0},n=e.toLowerCase().trim().split(/\s+/);for(const e of n){const n=e.match(B.PATTERNS.UNIT);if(!n)throw new Error(B.ERROR_MESSAGES.INVALID_FORMAT(e));const[,r,o]=n,i=parseInt(r,10);switch(o){case"cc":t.cc=i;break;case"pomo":t.pomo=i;break;case"q":t.q=i}}return t}add(e){return new G(this.toMinutes()+e.toMinutes())}subtract(e){const t=new G(this.toMinutes()-e.toMinutes());return t._isDirectInput=!1,t}equals(e){const t=this.getTimeRange(),n=e.getTimeRange();return 0===this.toMinutes()||0===e.toMinutes()?this.toMinutes()===e.toMinutes():t.min<=n.max&&t.max>=n.min}isLongerThan(e){return this.toMinutes()>e.toMinutes()}isShorterThan(e){return this.toMinutes()<e.toMinutes()}isWithinRange(e){const t=this.getTimeRange();return e>=t.min&&e<=t.max}getTimeRange(){return{min:this._cc*B.TIME_RANGES.CC.min+this._pomo*B.TIME_RANGES.POMO.min+this._q*B.TIME_RANGES.Q.min,max:this._cc*B.TIME_RANGES.CC.max+this._pomo*B.TIME_RANGES.POMO.max+this._q*B.TIME_RANGES.Q.max}}static sumRange(e){return e.reduce(((e,t)=>{const n=t.getTimeRange();return{min:e.min+n.min,max:e.max+n.max,average:e.average+t.toMinutes()}}),{min:0,max:0,average:0})}static estimateFromMinutes(e){const t=new G(e);let n=e;const r={cc:0,pomo:0,q:0};for(;n>0;)n>=B.TIME_RANGES.CC.max?(r.cc++,n-=B.TIME_RANGES.CC.max):n>=B.TIME_RANGES.POMO.max?(r.pomo++,n-=B.TIME_RANGES.POMO.max):n>0&&(r.q++,n-=B.TIME_RANGES.Q.max);const o=new G(r);o._isDirectInput=!1,n=e;const i={cc:0,pomo:0,q:0};for(;n>0;)n>B.TIME_RANGES.CC.min?(i.cc++,n-=B.TIME_RANGES.CC.min):n>B.TIME_RANGES.POMO.min?(i.pomo++,n-=B.TIME_RANGES.POMO.min):n>0&&(i.q++,n-=B.TIME_RANGES.Q.min);const a=new G(i);return a._isDirectInput=!1,{asMinimal:o,asMaximal:a,asAverage:t}}clone(){return new G({q:this._q,pomo:this._pomo,cc:this._cc})}scale(e){const t=Math.round(this.toMinutes()*e),n=new G(t);return n._isDirectInput=!1,n}}P.KHTimeUnit=G,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.ESTIMATION_PREFERENCE=e.FORMAT_TEMPLATES=e.FORMAT_OPTIONS=e.TIME_RANGES=e.KHTimeUnit=void 0;var t=P;Object.defineProperty(e,"KHTimeUnit",{enumerable:!0,get:function(){return t.KHTimeUnit}});var n=z;Object.defineProperty(e,"TIME_RANGES",{enumerable:!0,get:function(){return n.TIME_RANGES}}),Object.defineProperty(e,"FORMAT_OPTIONS",{enumerable:!0,get:function(){return n.FORMAT_OPTIONS}}),Object.defineProperty(e,"FORMAT_TEMPLATES",{enumerable:!0,get:function(){return n.FORMAT_TEMPLATES}}),Object.defineProperty(e,"ESTIMATION_PREFERENCE",{enumerable:!0,get:function(){return n.ESTIMATION_PREFERENCE}})}(I);var U,$=function(e){return 60*e},X=function(e,t){return"".concat(String(e).padStart(2,"0"),":00-").concat(String(t).padStart(2,"0"),":00")},V=function(e,t){var n=[],r=null;return e.forEach((function(e,o){t.includes(e.type)?r?r.end=e.hour:r={start:e.hour,end:e.hour,type:e.type}:r&&(n.push(Object.assign(Object.assign({},r),{minutes:$(r.end-r.start+1)})),r=null)})),n},Y=[{id:"cc_cycles",type:"feature",priority:88,condition:function(e){return!0},analyze:function(e){var t=[],n=V(e.day.hours,["work","improve"]);n.forEach((function(e){var n,r=X(e.start,e.end+1),o=I.KHTimeUnit.estimateFromMinutes(e.minutes);e.minutes>60&&((n=e.minutes)>=80&&n<=100?t.push({type:"tip",content:"".concat(r,"的").concat(e.type,"时段符合CC单位(").concat(o.toString(),"),是理想的工作周期")}):t.push({type:"suggestion",content:"".concat(r,"的").concat(e.type,"时段长度为").concat(e.minutes,"分钟,不符合标准CC单位(80-100分钟)。建议调整为90分钟,更符合人体自然节律")}))}));var r=n.reduce((function(e,t){return e+t.minutes}),0);if(r>0){var o=I.KHTimeUnit.estimateFromMinutes(r);t.push({type:"tip",content:"今日高强度活动总时长约为".concat(o.toString(),",建议每个CC单位(90分钟)后安排15-20分钟休息")})}return{status:t.some((function(e){return"warning"===e.type}))?"warning":"success",title:"工作周期分析",advices:t}}},{id:"pomo_focus",type:"feature",priority:86,condition:function(e){return!0},analyze:function(e){var t=[],n=V(e.day.hours,["work","improve"]).filter((function(e){return(t=e.minutes)>=25&&t<=35;var t}));n.length>0&&n.forEach((function(e){t.push({type:"tip",content:"".concat(X(e.start,e.end+1),"的").concat(e.type,"时段符合番茄工作法(").concat(e.minutes,"分钟),适合高强度专注任务")})}));var r=n.length;return r>=4&&t.push({type:"suggestion",content:"今日完成".concat(r,"个番茄工作周期,建议每4个番茄钟后安排较长休息(15-30分钟)")}),{status:"success",title:"专注时间分析",advices:t}}},{id:"q_transitions",type:"feature",priority:84,condition:function(e){return!0},analyze:function(e){for(var t=[],n=e.day.hours,r=1;r<n.length;r++)if(n[r].type!==n[r-1].type){for(var o=!1,i=Math.max(0,r-1);i<=Math.min(n.length-1,r+1);i++)if("life"===n[i].type||"relax"===n[i].type){o=!0;break}if(!o){var a=n[r-1].type,c=n[r].type;"work"!==a&&"improve"!==a||"work"!==c&&"improve"!==c?t.push({type:"suggestion",content:"在".concat(n[r].hour,":00的").concat(a,"到").concat(c,"切换可以安排短暂缓冲(5-15分钟),帮助调整状态")}):t.push({type:"warning",content:"在".concat(n[r].hour,":00从").concat(a,"直接切换到").concat(c,",建议安排一个Q单位(15分钟)作为过渡,避免疲劳累积")})}}return V(n,["work","improve"]).forEach((function(e){e.minutes>120&&t.push({type:"warning",content:"".concat(X(e.start,e.end+1),"连续").concat(e.type,"时间过长,建议每90-120分钟安排一个Q单位(15分钟)休息")})})),{status:t.some((function(e){return"warning"===e.type}))?"warning":"success",title:"活动切换分析",advices:t}}}],W=((U=new(function(){return f((function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.rules=[],t&&this.addRules(t)}),[{key:"addRule",value:function(e){this.rules.push(e),this.sortRules()}},{key:"addRules",value:function(e){var t;(t=this.rules).push.apply(t,g(e)),this.sortRules()}},{key:"sortRules",value:function(){this.rules.sort((function(e,t){return t.priority-e.priority}))}},{key:"analyze",value:function(e){return this.rules.filter((function(t){return t.condition(e)})).map((function(t){return t.analyze(e)}))}},{key:"analyzeByType",value:function(e,t){return this.rules.filter((function(n){return n.type===t&&n.condition(e)})).map((function(t){return t.analyze(e)}))}}])}())).addRules([].concat(g(T),g(H),g(Y),g(N))),U),K=function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"segment",o={day:e,segment:t,allSegments:e.qhSegments||[],historicalDays:n,stats:t?{duration:t.endHour-t.startHour,mainTypePercent:t.mainTypeHours/(t.endHour-t.startHour)*100,secondaryTypePercent:t.secondaryTypeHours?t.secondaryTypeHours/(t.endHour-t.startHour)*100:0}:void 0};return"segment"===r?{segment:t?W.analyzeByType(o,"segment"):[],features:W.analyzeByType(o,"feature")}:{overall:W.analyzeByType(o,"overall"),features:W.analyzeByType(o,"feature"),segment:t?W.analyzeByType(o,"segment"):[]}},Q=function(e){return e.length?e.reduce((function(e,t){return t&&t.type&&(e[t.type]=(e[t.type]||0)+1),e}),{}):{}},Z=function(e){var t=Object.values(e).reduce((function(e,t){return e+t}),0);if(!t)return{type:"full",mainType:"undefined",mainTypeHours:0,distribution:{}};var n=Object.entries(e).sort((function(e,t){var n=d(e,2)[1];return d(t,2)[1]-n})).map((function(e){var n=d(e,2),r=n[0],o=n[1];return{type:r,count:o,ratio:o/t}})),r=n.reduce((function(e,t){var n=t.type,r=t.ratio;return e[n]=r,e}),{});if(0===n.length)return{type:"full",mainType:"undefined",mainTypeHours:0,distribution:r};var o=d(n,2),i=o[0],a=o[1];return 1===n.length||i.ratio>.8?{type:"full",mainType:i.type,mainTypeHours:i.count,distribution:r}:i.ratio>=.35&&a.ratio>=.35?{type:"balance",mainType:i.type,secondaryType:a.type,mainTypeHours:i.count,secondaryTypeHours:a.count,distribution:r}:i.ratio>=.6&&a.count>=2?{type:"mix",mainType:i.type,secondaryType:a.type,mainTypeHours:i.count,secondaryTypeHours:a.count,distribution:r}:n.length>=3&&n.slice(0,3).every((function(e){return e.ratio>=.2}))?{type:"chaos",mainType:i.type,secondaryType:a.type,mainTypeHours:i.count,secondaryTypeHours:a.count,distribution:r}:Object.assign(Object.assign(Object.assign(Object.assign({type:"mix",mainType:i.type},(null==a?void 0:a.count)>=2?{secondaryType:a.type}:{}),{mainTypeHours:i.count}),(null==a?void 0:a.count)>=2?{secondaryTypeHours:a.count}:{}),{distribution:r})},J=function(e){if(!e.hours.length)return[];var t=e.hours[0].hour,n=function(e){if(!e.length)return"normal";var t=e[e.length-1].hour-e[0].hour+1;return t>24?t<=28?"long":"normal":t<24&&t>=21?"short":"normal"}(e.hours),r=[{segment:"A",startHour:t,endHour:t+7},{segment:"B",startHour:t+7,endHour:t+14},{segment:"C",startHour:t+14,endHour:t+21}].map((function(t){var n=e.hours.filter((function(e){return e.hour>=t.startHour&&e.hour<t.endHour})),r=Z(Q(n));return Object.assign(Object.assign(Object.assign(Object.assign({},t),{type:r.type,mainType:r.mainType,mainTypeHours:r.mainTypeHours}),r.secondaryType?{secondaryType:r.secondaryType,secondaryTypeHours:r.secondaryTypeHours}:{}),{distribution:r.distribution})})),o=function(e,t,n){var r,o=t+21,i=null===(r=e[e.length-1])||void 0===r?void 0:r.hour,a="long"===n?7:3,c={segment:"F",startHour:o,endHour:o,type:"full",mainType:"undefined",mainTypeHours:0,distribution:{}};if(!e.length||i<o)return c;var s=e.filter((function(e){return e.hour>=o&&e.hour<o+a}));if(s.length>0){var u=Z(Q(s)),l=Math.min(s[s.length-1].hour+1,o+a);return Object.assign(Object.assign({segment:"F",startHour:o,endHour:l,type:u.type,mainType:u.mainType,mainTypeHours:u.mainTypeHours},u.secondaryType?{secondaryType:u.secondaryType,secondaryTypeHours:u.secondaryTypeHours}:{}),{distribution:u.distribution})}return c}(e.hours,t,n);return[].concat(g(r),[o])},ee=function(e){return e<0?String(e+24).padStart(2,"0"):e>=24?String(e-24).padStart(2,"0"):String(e).padStart(2,"0")},te=function(e){var t=e.endHour-e.startHour;return{duration:t,mainTypePercent:e.mainTypeHours&&t>0?Math.round(e.mainTypeHours/t*100):0,secondaryTypePercent:e.secondaryTypeHours&&t>0?Math.round(e.secondaryTypeHours/t*100):0,hasSecondary:!!e.secondaryType}},ne=function(e,t,n){var r,o=null==n?void 0:n.find((function(t){var n;return null===(n=t.qhSegments)||void 0===n?void 0:n.some((function(t){return t===e}))}));if(!o)return{status:"warning",title:"无法获取完整数据",advices:[{type:"warning",content:"缺少当天数据,无法进行完整分析"}],stats:{duration:e.endHour-e.startHour,mainTypePercent:e.mainTypeHours/(e.endHour-e.startHour)*100,secondaryTypePercent:e.secondaryTypeHours?e.secondaryTypeHours/(e.endHour-e.startHour)*100:0}};var i=K(o,e,n,"segment");return{status:i.segment.some((function(e){return"warning"===e.status}))?"warning":"success",title:(null===(r=i.segment[0])||void 0===r?void 0:r.title)||"".concat(e.segment,"段分析"),advices:i.segment.flatMap((function(e){return e.advices})),stats:{duration:e.endHour-e.startHour,mainTypePercent:e.mainTypeHours/(e.endHour-e.startHour)*100,secondaryTypePercent:e.secondaryTypeHours?e.secondaryTypeHours/(e.endHour-e.startHour)*100:0}}},re=function(e){return e.secondaryType?"balance"===e.type?"".concat(e.mainType,"-").concat(e.secondaryType," Balance Part"):"chaos"===e.type?"Chaos Part":"".concat(e.mainType,"-").concat(e.secondaryType," Mix Part"):"".concat(e.mainType," Full Part")},oe=function(e){return e.secondaryType?"balance"===e.type?"Ba":"chaos"===e.type?"Ch":"Mi":"Fu"},ie=function(e,t){var n=K(e,void 0,t,"overall");return{status:n.overall?n.overall.some((function(e){return"warning"===e.status}))?"warning":"success":"info",title:"日程总体分析",advices:[].concat(g(n.overall?n.overall.flatMap((function(e){return e.advices})):[]),g(n.features?n.features.flatMap((function(e){return e.advices})):[])),stats:{duration:e.hours.length,mainTypePercent:0,secondaryTypePercent:0}}},ae=function(e,t,n){var r;switch(t){case"moveStart":return Object.assign(Object.assign({},e),{startHour:null!==(r=n.startHour)&&void 0!==r?r:e.startHour});case"addBlock":return n.block&&void 0!==n.blockIndex?Object.assign(Object.assign({},e),{blocks:[].concat(g(e.blocks.slice(0,n.blockIndex)),[n.block],g(e.blocks.slice(n.blockIndex)))}):e;case"removeBlock":return void 0===n.blockIndex?e:Object.assign(Object.assign({},e),{blocks:e.blocks.filter((function(e,t){return t!==n.blockIndex}))});case"updateBlock":return n.block&&void 0!==n.blockIndex?Object.assign(Object.assign({},e),{blocks:e.blocks.map((function(e,t){return t===n.blockIndex&&n.block?n.block:e}))}):e;default:return e}},ce=function(e){var t,n=[],r=e.startHour,o=function(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=h(e))||t){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){c=!0,i=e},f:function(){try{a||null==n.return||n.return()}finally{if(c)throw i}}}}(e.blocks);try{for(o.s();!(t=o.n()).done;){var i=t.value;if("string"!=typeof i)for(var a=i,c=0;c<a.duration;c++)n.push({hour:r,type:a.type,comment:a.comment}),r++;else{var s=i;n.push({hour:r,type:s}),r++}}}catch(e){o.e(e)}finally{o.f()}return n},se=function(e){var t=function(e,t){return{type:e,duration:t}};switch(e){case"work":return{startHour:0,blocks:[t("sleep",9),t("life",1),t("work",2),t("life",2),t("work",4),t("life",1),t("work",2),t("life",1),t("relax",2)]};case"improve":return{startHour:0,blocks:[t("sleep",7),t("life",1),t("improve",2),t("work",2),t("life",2),t("improve",2),t("work",2),t("life",3),t("relax",3)]};case"balanced":return{startHour:1,blocks:[{type:"sleep",duration:7},{type:"life",duration:1},"improve",{type:"work",duration:2},{type:"life",duration:2},{type:"work",duration:4},{type:"life",duration:2},{type:"work",duration:2},"life","improve","relax"]};default:return{startHour:0,blocks:[]}}},ue=function(e){var t=e.patterns,o=e.dates,i=e.onChange,a=n(t.map((function(e,t){return function(e,t){var n={date:t,hours:ce(e),segments:[]};return Object.assign(Object.assign({},n),{qhSegments:J(n)})}(e,o[t])}))),c=d(a,2),s=c[0],u=c[1];return{data:s,updateHour:r((function(e,t,n,r){u((function(o){return o.map((function(o){if(o.date!==e)return o;var a=o.hours.findIndex((function(e){return e.hour===t}));if(-1===a)return o;var c=o.hours[a],s=g(o.hours);s[a]=Object.assign(Object.assign({},c),{type:n,comment:r||c.comment}),null==i||i({hour:t,date:e,oldType:c.type,newType:n,comment:r});var u=Object.assign(Object.assign({},o),{hours:s});return Object.assign(Object.assign({},u),{qhSegments:J(u)})}))}))}),[i])}},le=function(e){var n,r=e.hour,o=e.date,i=e.theme,a=e.editable,c=e.customTypes,s=e.typeOrder,u=e.onChange,l=e.render,p=e.onHover;return l?t.createElement(t.Fragment,null,l(r,o)):t.createElement("div",{className:"hour-cell",style:{width:i.cellSize,height:i.cellSize,backgroundColor:(n=r.type,c&&n in c?c[n].color:i.colors[n]||i.colors.life),borderRadius:i.borderRadius,cursor:a?"pointer":"default",display:"flex",alignItems:"center",justifyContent:"center",color:i.colors.text,fontSize:"0.8em",transition:"background-color 0.2s ease",userSelect:"none"},onClick:function(){if(a&&u){var e=s||y,t=e.indexOf(r.type),n=e[(t+1)%e.length];u({hour:r.hour,date:o,oldType:r.type,newType:n})}},onMouseEnter:function(e){p&&p({hour:r.hour,type:r.type,date:o,comment:r.comment},e)},onMouseLeave:function(e){p&&p(null,e)}},r.hour)},pe=s.div.withConfig({displayName:"SegmentsContainer"})(["display:flex;flex-direction:column;gap:","px;width:150px;"],(function(e){return e.theme.gap})),fe=s.div.attrs((function(e){return{style:{height:"".concat(e.theme.cellSize,"px"),display:"flex",alignItems:"center",gap:"6px",padding:"0 8px",backgroundColor:"rgba(255, 255, 255, 0.98)",borderRadius:"".concat(e.theme.borderRadius,"px"),boxShadow:"0 1px 3px rgba(0, 0, 0, 0.05)",position:"relative",cursor:"pointer",transition:"all 0.2s ease"}}})).withConfig({displayName:"SegmentItem"})(["&:hover{background-color:rgba(255,255,255,1);box-shadow:0 2px 6px rgba(0,0,0,0.08);transform:translateY(-1px);}&:active{transform:translateY(0);box-shadow:0 1px 3px rgba(0,0,0,0.05);}"]),de=s.div.withConfig({displayName:"TypeBlock"})(["width:48px;height:24px;border-radius:4px;background-color:",";display:flex;align-items:center;justify-content:center;flex-shrink:0;position:relative;gap:2px;transition:background-color 0.2s ease;",":hover &{background-color:",";}"],(function(e){return"".concat(e.color,"15")}),fe,(function(e){return"".concat(e.color,"25")})),ge=s.span.withConfig({displayName:"SegmentLabel"})(["font-size:11px;font-weight:500;color:",";opacity:0.8;padding:0 2px;border-radius:2px;transition:opacity 0.2s ease;",":hover &{opacity:1;}"],(function(e){return e.color}),fe),me=s.span.withConfig({displayName:"TypeLabel"})(["font-size:10px;font-weight:600;color:",";opacity:0.6;padding:0 2px;border-radius:2px;transition:opacity 0.2s ease;",":hover &{opacity:0.8;}"],(function(e){return e.color}),fe),he=s.div.withConfig({displayName:"SegmentContent"})(["flex:1;min-width:0;transition:transform 0.2s ease;",":hover &{transform:translateX(2px);}"],fe),ye=s.div.withConfig({displayName:"SegmentTypes"})(["font-size:10px;display:flex;align-items:center;gap:3px;margin-bottom:1px;color:",';transition:color 0.2s ease;&[data-type="improve"]{font-style:italic;}'],(function(e){return e.color})),ve=s.div.withConfig({displayName:"SegmentTime"})(["font-size:9px;color:rgba(0,0,0,0.45);font-family:monospace;transition:color 0.2s ease;",":hover &{color:rgba(0,0,0,0.65);}"],fe),be=function(e){var n=e.segments,r=e.theme,o=e.onSegmentHover;return t.createElement(pe,{theme:r},n.map((function(e){var n=r.colors[e.mainType],i=oe(e);return t.createElement(fe,{key:e.segment,theme:r,onMouseEnter:function(t){return null==o?void 0:o(e,t)},onMouseLeave:function(e){return null==o?void 0:o(null,e)}},t.createElement(de,{color:n},t.createElement(ge,{color:n},e.segment),t.createElement(me,{color:n},i)),t.createElement(he,null,t.createElement(ye,{color:n,"data-type":e.mainType},e.mainType,e.secondaryType&&t.createElement(t.Fragment,null,t.createElement("span",{style:{opacity:.3}},"/"),t.createElement("span",{style:{color:r.colors[e.secondaryType]}},e.secondaryType))),t.createElement(ve,null,"".concat(e.startHour,":00-").concat(e.endHour,":00"))))})))},xe=function(e){var n=e.day,r=e.theme,i=e.direction,a=void 0===i?"horizontal":i,c=e.showDateLabel,s=e.renderDateLabel,u=e.renderHour,l=e.onHourChange,p=e.editable,f=void 0!==p&&p,d=e.customTypes,g=e.onHover,m=e.onSegmentHover,h=e.pinClassName,y=e.typeOrder,v=o(null),b=n.hours.reduce((function(e,t,n){var r=Math.floor(n/7);return e[r]||(e[r]=[]),e[r].push(t),e}),[]),x=function(e,t){g&&g(e,t,v)};return t.createElement("div",{ref:v,className:"day-row ".concat(h),style:{display:"flex",flexDirection:"horizontal"===a?"row":"column",alignItems:"flex-start",gap:2*r.gap,marginBottom:4*r.gap,position:"relative"}},n.qhSegments&&t.createElement("div",{style:{display:"flex",flexDirection:"column",gap:r.gap,paddingTop:c?"24px":0}},t.createElement(be,{segments:n.qhSegments,theme:r,onSegmentHover:function(e,t){m&&m(e,t,v)}})),t.createElement("div",{style:{display:"flex",flexDirection:"column",minHeight:b.length*(r.cellSize+r.gap)-r.gap}},c&&t.createElement("div",{className:"date-label",style:{minWidth:100,fontSize:"14px",fontWeight:500,marginBottom:2*r.gap,color:r.colors.text}},s?s(n.date):n.date),t.createElement("div",{className:"hours-rows",style:{display:"flex",flexDirection:"column",gap:r.gap,flex:1}},b.map((function(e,o){return t.createElement("div",{key:o,className:"hours-row",style:{display:"flex",gap:r.gap,height:r.cellSize}},e.map((function(e){return t.createElement(le,{key:e.hour,hour:e,date:n.date,theme:r,editable:f,customTypes:d,typeOrder:y,onChange:l,render:u,onHover:x})})))})))))},we=function(e){return t=e.colors.text,n=t.replace("#",""),parseInt(n.substr(0,2),16)/255*.2126+parseInt(n.substr(2,2),16)/255*.7152+parseInt(n.substr(4,2),16)/255*.0722>.5;var t,n},Ee=s.div.withConfig({displayName:"DateTitleContainer"})(["font-size:14px;font-weight:500;color:",";padding:6px 12px;margin-bottom:","px;border-radius:","px;cursor:pointer;transition:all 0.2s ease;display:inline-block;position:relative;&:hover{background-color:",';&::after{content:"查看当日分析";position:absolute;bottom:-20px;left:50%;transform:translateX(-50%);font-size:12px;color:',";white-space:nowrap;}}"],(function(e){return e.theme.colors.text}),(function(e){return 2*e.theme.gap}),(function(e){return e.theme.borderRadius}),(function(e){return we(e.theme)?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.05)"}),(function(e){return we(e.theme)?"rgba(255,255,255,0.45)":"rgba(0,0,0,0.45)"})),Te=function(e){var n=e.day,r=e.theme,o=e.onClick,i=e.renderDateLabel;return t.createElement(Ee,{theme:r,onClick:function(e){return null==o?void 0:o(n,e)}},i?i(n.date):n.date)},Se=s.div.withConfig({displayName:"GridContainer"})([".day-container{margin-bottom:","px;&:last-child{margin-bottom:0;}}color:",";background:",";transition:color 0.3s ease,background-color 0.3s ease;"],(function(e){return 4*e.theme.gap}),(function(e){return e.theme.colors.text}),(function(e){return e.theme.colors.background})),Re=function(e){var n=e.data,r=e.direction,o=e.theme,i=e.showDateLabel,a=e.renderDateLabel,c=e.renderHour,s=e.onHourChange,u=e.editable,l=e.customTypes,p=e.typeOrder,f=e.onHover,d=e.onSegmentHover,g=e.onDateTitleClick;return t.createElement(Se,{theme:o},n.map((function(e){return t.createElement("div",{key:e.date,className:"day-container"},i&&t.createElement(Te,{day:e,theme:o,onClick:g,renderDateLabel:a}),t.createElement(xe,{day:e,theme:o,direction:r,showDateLabel:!1,renderHour:c,onHourChange:s,editable:u,customTypes:l,typeOrder:p,onHover:f,onSegmentHover:d}))})))};function Me(){return"undefined"!=typeof window}function Oe(e){return Ce(e)?(e.nodeName||"").toLowerCase():"#document"}function ke(e){var t;return(null==e||null==(t=e.ownerDocument)?void 0:t.defaultView)||window}function He(e){var t;return null==(t=(Ce(e)?e.ownerDocument:e.document)||window.document)?void 0:t.documentElement}function Ce(e){return!!Me()&&(e instanceof Node||e instanceof ke(e).Node)}function Ae(e){return!!Me()&&(e instanceof Element||e instanceof ke(e).Element)}function _e(e){return!!Me()&&(e instanceof HTMLElement||e instanceof ke(e).HTMLElement)}function Ne(e){return!(!Me()||"undefined"==typeof ShadowRoot)&&(e instanceof ShadowRoot||e instanceof ke(e).ShadowRoot)}function Ie(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=je(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!["inline","contents"].includes(o)}function Pe(e){return["table","td","th"].includes(Oe(e))}function ze(e){return[":popover-open",":modal"].some((t=>{try{return e.matches(t)}catch(e){return!1}}))}function Le(e){const t=De(),n=Ae(e)?je(e):e;return"none"!==n.transform||"none"!==n.perspective||!!n.containerType&&"normal"!==n.containerType||!t&&!!n.backdropFilter&&"none"!==n.backdropFilter||!t&&!!n.filter&&"none"!==n.filter||["transform","perspective","filter"].some((e=>(n.willChange||"").includes(e)))||["paint","layout","strict","content"].some((e=>(n.contain||"").includes(e)))}function De(){return!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}function Fe(e){return["html","body","#document"].includes(Oe(e))}function je(e){return ke(e).getComputedStyle(e)}function Be(e){return Ae(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function qe(e){if("html"===Oe(e))return e;const t=e.assignedSlot||e.parentNode||Ne(e)&&e.host||He(e);return Ne(t)?t.host:t}function Ge(e){const t=qe(e);return Fe(t)?e.ownerDocument?e.ownerDocument.body:e.body:_e(t)&&Ie(t)?t:Ge(t)}function Ue(e,t,n){var r;void 0===t&&(t=[]),void 0===n&&(n=!0);const o=Ge(e),i=o===(null==(r=e.ownerDocument)?void 0:r.body),a=ke(o);if(i){const e=$e(a);return t.concat(a,a.visualViewport||[],Ie(o)?o:[],e&&n?Ue(e):[])}return t.concat(o,Ue(o,[],n))}function $e(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}const Xe=Math.min,Ve=Math.max,Ye=Math.round,We=Math.floor,Ke=e=>({x:e,y:e}),Qe={left:"right",right:"left",bottom:"top",top:"bottom"},Ze={start:"end",end:"start"};function Je(e,t,n){return Ve(e,Xe(t,n))}function et(e,t){return"function"==typeof e?e(t):e}function tt(e){return e.split("-")[0]}function nt(e){return e.split("-")[1]}function rt(e){return"x"===e?"y":"x"}function ot(e){return"y"===e?"height":"width"}function it(e){return["top","bottom"].includes(tt(e))?"y":"x"}function at(e){return rt(it(e))}function ct(e){return e.replace(/start|end/g,(e=>Ze[e]))}function st(e){return e.replace(/left|right|bottom|top/g,(e=>Qe[e]))}function ut(e){return"number"!=typeof e?function(e){return{top:0,right:0,bottom:0,left:0,...e}}(e):{top:e,right:e,bottom:e,left:e}}function lt(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function pt(e,t,n){let{reference:r,floating:o}=e;const i=it(t),a=at(t),c=ot(a),s=tt(t),u="y"===i,l=r.x+r.width/2-o.width/2,p=r.y+r.height/2-o.height/2,f=r[c]/2-o[c]/2;let d;switch(s){case"top":d={x:l,y:r.y-o.height};break;case"bottom":d={x:l,y:r.y+r.height};break;case"right":d={x:r.x+r.width,y:p};break;case"left":d={x:r.x-o.width,y:p};break;default:d={x:r.x,y:r.y}}switch(nt(t)){case"start":d[a]-=f*(n&&u?-1:1);break;case"end":d[a]+=f*(n&&u?-1:1)}return d}async function ft(e,t){var n;void 0===t&&(t={});const{x:r,y:o,platform:i,rects:a,elements:c,strategy:s}=e,{boundary:u="clippingAncestors",rootBoundary:l="viewport",elementContext:p="floating",altBoundary:f=!1,padding:d=0}=et(t,e),g=ut(d),m=c[f?"floating"===p?"reference":"floating":p],h=lt(await i.getClippingRect({element:null==(n=await(null==i.isElement?void 0:i.isElement(m)))||n?m:m.contextElement||await(null==i.getDocumentElement?void 0:i.getDocumentElement(c.floating)),boundary:u,rootBoundary:l,strategy:s})),y="floating"===p?{x:r,y:o,width:a.floating.width,height:a.floating.height}:a.reference,v=await(null==i.getOffsetParent?void 0:i.getOffsetParent(c.floating)),b=await(null==i.isElement?void 0:i.isElement(v))&&await(null==i.getScale?void 0:i.getScale(v))||{x:1,y:1},x=lt(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:y,offsetParent:v,strategy:s}):y);return{top:(h.top-x.top+g.top)/b.y,bottom:(x.bottom-h.bottom+g.bottom)/b.y,left:(h.left-x.left+g.left)/b.x,right:(x.right-h.right+g.right)/b.x}}function dt(e){const t=Xe(...e.map((e=>e.left))),n=Xe(...e.map((e=>e.top)));return{x:t,y:n,width:Ve(...e.map((e=>e.right)))-t,height:Ve(...e.map((e=>e.bottom)))-n}}function gt(e){const t=je(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=_e(e),i=