@bagaking/dayboxing
Version:
A React component library for DayBoxing time management visualization
1 lines • 102 kB
JavaScript
"use strict";var e=require("react"),t=require("styled-components"),n=require("react-dom");function r(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var o=r(e),i=r(n);function a(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 s(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,l(r.key),r)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function c(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,s=[],c=!0,u=!1;try{if(i=(n=n.call(e)).next,0===t);else for(;!(c=(r=i.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){u=!0,o=e}finally{try{if(!c&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(u)throw o}}return s}}(e,t)||p(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 u(e){return function(e){if(Array.isArray(e))return a(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||p(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 l(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 p(e,t){if(e){if("string"==typeof e)return a(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)?a(e,t):void 0}}var f=Array.from(["sleep","work","life","relax","improve"]),d={s:"sleep",w:"work",l:"life",r:"relax",i:"improve"},g={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},m={colors:{sleep:"#A78BFA",work:"#60A5FA",life:"#34D399",relax:"#FBBF24",improve:"#F472B6",background:"#ffffff",text:"#1f2937"},cellSize:40,gap:2,borderRadius:4},h=[{id:"day_length",type:"overall",priority:100,condition:function(e){return!0},analyze:function(e){var t=e.day.hours.length,n=[];return t>g.MAX_DAY_HOURS&&n.push({type:"warning",content:"当前时长超过".concat(g.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 s=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}),[]);s.length>3&&i.push({type:"suggestion",content:"自我提升时间(".concat(o,"小时)分散在").concat(s.length,"个时间段中。建议将短于1小时的时间段合并,形成2-3个较长的学习时段,以提高学习效率")});var c=s.filter((function(e){return e.length>4}));if(c.length>0){var u=c.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 s=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(s.length>0){var c=s.filter((function(e){return e.length<1}));if(c.length>2){var u=c.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(c.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,s=n.length,c=a/s;c>.6&&t.push({type:"warning",content:"工作时间占比".concat(Math.round(100*c),"%(").concat(a,"/").concat(s,"小时)过高。建议通过提高工作效率来减少工作时间,为生活和休息留出更多空间")});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}}}],y={sleep:0,relax:1,life:2,improve:3,work:3},v=[{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=y[r],a=y[o],s=Math.abs(a-i);s>1&&t.push({hour:e[n+1].hour,from:r,to:o,energyJump:s})}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=y[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}}}],b={start:9,end:11},x={start:14,end:16},w=function(e,t){return"".concat(String(e).padStart(2,"0"),":00-").concat(String(t).padStart(2,"0"),":00")},E=[].concat(u(v),[{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,s=1;return o.slice(1).forEach((function(e,t){e.type===i?s++:(s>4&&("work"===i||"improve"===i)&&r.push({type:"warning",content:"在".concat(w(a,a+s),"期间, 持续").concat(s,"小时进行 ").concat(i,"活动。建议每2小时休息15分钟,既能恢复精力,也能提高效率")}),i=e.type,a=e.hour,s=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>=b.start&&e.hour<b.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(w(b.start,b.end),"黄金时段,安排了").concat(Array.from(r).join("、"),"等活动。建议将这个注意力最集中的时段用于工作或自我提升,其他活动可调整到下午或晚上")});var o=e.day.hours.filter((function(e){return e.hour>=x.start&&e.hour<x.start+2}));return o.every((function(e){return"work"===e.type||"improve"===e.type}))&&o.length>0&&t.push({type:"suggestion",content:"在".concat(w(x.start,x.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(w(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 s=1;s<n.length-1;s++){var c=n[s-1].type,u=n[s].type;"sleep"===c&&"work"===u&&t.push({type:"suggestion",content:"在".concat(n[s].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}}}]),T=function(e,t){return"".concat(String(e).padStart(2,"0"),":00-").concat(String(t).padStart(2,"0"),":00")},S=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,u(i.map((function(e){return e.length}))))}},R=function(e,t){var n=e.filter((function(e){return e.hour>=t&&e.hour<t+2})),r=u(new Set(n.map((function(e){return e.type}))));return{type:r[0]||"undefined",duration:n.length,isConsistent:1===r.length}},M=[{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=S(e.day.hours,t.startHour,t.endHour);"full"===t.type&&"sleep"===t.mainType||n.push({type:"warning",content:"A段(".concat(T(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 S(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(T(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=R(e.day.hours,t.startHour),r=[];switch(n.type){case"sleep":r.push({type:"warning",content:"B段开始时仍在睡眠(".concat(T(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(T(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&&R(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(T(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(T(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(T(o.startHour,o.endHour),"),且延长").concat(a,"小时,说明工作压力较大。建议优化工作计划,避免经常性加班")}),o.endHour>o.startHour+4){var s=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}));s&&"full"!==s.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}}}],O={},k={},H={};Object.defineProperty(H,"__esModule",{value:!0}),H.FORMAT_TEMPLATES=H.FORMAT_OPTIONS=H.ESTIMATION_PREFERENCE=H.PATTERNS=H.ERROR_MESSAGES=H.TIME_RANGES=void 0,H.TIME_RANGES={Q:{min:10,max:20,avg:15},POMO:{min:20,max:40,avg:30},CC:{min:80,max:100,avg:90}},H.ERROR_MESSAGES={NEGATIVE:"Time units cannot be negative",NON_INTEGER:"Time units must be integers",INVALID_FORMAT:e=>`Invalid format: ${e}`},H.PATTERNS={UNIT:/^(\d+)(cc|pomo|q)$/},H.ESTIMATION_PREFERENCE={MINIMAL:"minimal",MAXIMAL:"maximal",AVERAGE:"average"},H.FORMAT_OPTIONS={HIDE_ZERO:"hide-when-zero",NO_PAD_ZERO:"no-pad-zero"},H.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 C={};Object.defineProperty(C,"__esModule",{value:!0}),C.formatTime=C.fromMinutes=C.toMinutes=void 0;const A=H;function _(e){return Object.values(A.FORMAT_OPTIONS).includes(e)}function N(e){var t,n,r;return(null!==(t=e.cc)&&void 0!==t?t:0)*A.TIME_RANGES.CC.avg+(null!==(n=e.pomo)&&void 0!==n?n:0)*A.TIME_RANGES.POMO.avg+(null!==(r=e.q)&&void 0!==r?r:0)*A.TIME_RANGES.Q.avg}C.toMinutes=N,C.fromMinutes=function(e){const t=Math.floor(e/A.TIME_RANGES.CC.avg),n=e%A.TIME_RANGES.CC.avg,r=Math.floor(n/A.TIME_RANGES.POMO.avg),o=n%A.TIME_RANGES.POMO.avg;return{cc:t,pomo:r,q:Math.floor(o/A.TIME_RANGES.Q.avg)}},C.formatTime=function(e,t=A.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(!_(t))throw new Error(`Invalid format option: "${t}". Valid options are: ${Object.values(A.FORMAT_OPTIONS).join(", ")}`);o.add(t)}}return{template:n,options:o}}(null==t?A.FORMAT_TEMPLATES.KH:t),o=function(e){var t,n,r;const o=N(e),i=Math.floor(o/60),a=Math.floor(o%60),s=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:s}}(e),i=!Object.values(o).some((e=>0!==e));if(i&&r.has(A.FORMAT_OPTIONS.HIDE_ZERO))return"";let a=n;function s(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(A.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(A.FORMAT_OPTIONS.NO_PAD_ZERO)?t.toString():t.toString().padStart(o,"0"),c=new RegExp(`${e}+`,"g");let u,l=0,p="";for(;null!==(u=c.exec(a));){p+=s(a,u.index)%2==1?a.slice(l,c.lastIndex):a.slice(l,u.index)+i,l=c.lastIndex}p+=a.slice(l),a=p}})),a=a.trim().replace(/"([^"]*?)"/g,"$1"),a},Object.defineProperty(k,"__esModule",{value:!0}),k.KHTimeUnit=void 0;const I=H,P=C;class z{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,P.fromMinutes)(e);this.setUnits(t),this._isDirectInput=!1}else if("string"==typeof e){const t=z.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(I.ERROR_MESSAGES.NON_INTEGER);if(this._isDirectInput&&(this._q<0||this._pomo<0||this._cc<0)&&this.toMinutes()<0)throw new Error(I.ERROR_MESSAGES.NEGATIVE)}toMinutes(){return(0,P.toMinutes)({q:this._q,pomo:this._pomo,cc:this._cc})}toHours(){return this.toMinutes()/60}toSeconds(){return 60*this.toMinutes()}toString(e){return(0,P.formatTime)({q:this._q,pomo:this._pomo,cc:this._cc},null!=e?e:I.FORMAT_TEMPLATES.KH)}static fromHours(e){return new z(60*e)}static fromSeconds(e){return new z(e/60)}static fromMinutes(e){return new z(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(I.PATTERNS.UNIT);if(!n)throw new Error(I.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 z(this.toMinutes()+e.toMinutes())}subtract(e){const t=new z(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*I.TIME_RANGES.CC.min+this._pomo*I.TIME_RANGES.POMO.min+this._q*I.TIME_RANGES.Q.min,max:this._cc*I.TIME_RANGES.CC.max+this._pomo*I.TIME_RANGES.POMO.max+this._q*I.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 z(e);let n=e;const r={cc:0,pomo:0,q:0};for(;n>0;)n>=I.TIME_RANGES.CC.max?(r.cc++,n-=I.TIME_RANGES.CC.max):n>=I.TIME_RANGES.POMO.max?(r.pomo++,n-=I.TIME_RANGES.POMO.max):n>0&&(r.q++,n-=I.TIME_RANGES.Q.max);const o=new z(r);o._isDirectInput=!1,n=e;const i={cc:0,pomo:0,q:0};for(;n>0;)n>I.TIME_RANGES.CC.min?(i.cc++,n-=I.TIME_RANGES.CC.min):n>I.TIME_RANGES.POMO.min?(i.pomo++,n-=I.TIME_RANGES.POMO.min):n>0&&(i.q++,n-=I.TIME_RANGES.Q.min);const a=new z(i);return a._isDirectInput=!1,{asMinimal:o,asMaximal:a,asAverage:t}}clone(){return new z({q:this._q,pomo:this._pomo,cc:this._cc})}scale(e){const t=Math.round(this.toMinutes()*e),n=new z(t);return n._isDirectInput=!1,n}}k.KHTimeUnit=z,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=k;Object.defineProperty(e,"KHTimeUnit",{enumerable:!0,get:function(){return t.KHTimeUnit}});var n=H;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}})}(O);var L,D=function(e){return 60*e},j=function(e,t){return"".concat(String(e).padStart(2,"0"),":00-").concat(String(t).padStart(2,"0"),":00")},F=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:D(r.end-r.start+1)})),r=null)})),n},B=[{id:"cc_cycles",type:"feature",priority:88,condition:function(e){return!0},analyze:function(e){var t=[],n=F(e.day.hours,["work","improve"]);n.forEach((function(e){var n,r=j(e.start,e.end+1),o=O.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=O.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=F(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(j(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,s=n[r].type;"work"!==a&&"improve"!==a||"work"!==s&&"improve"!==s?t.push({type:"suggestion",content:"在".concat(n[r].hour,":00的").concat(a,"到").concat(s,"切换可以安排短暂缓冲(5-15分钟),帮助调整状态")}):t.push({type:"warning",content:"在".concat(n[r].hour,":00从").concat(a,"直接切换到").concat(s,",建议安排一个Q单位(15分钟)作为过渡,避免疲劳累积")})}}return F(n,["work","improve"]).forEach((function(e){e.minutes>120&&t.push({type:"warning",content:"".concat(j(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}}}],q=((L=new(function(){return s((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,u(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(u(h),u(E),u(B),u(M))),L),G=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?q.analyzeByType(o,"segment"):[],features:q.analyzeByType(o,"feature")}:{overall:q.analyzeByType(o,"overall"),features:q.analyzeByType(o,"feature"),segment:t?q.analyzeByType(o,"segment"):[]}},U=function(e){return e.length?e.reduce((function(e,t){return t&&t.type&&(e[t.type]=(e[t.type]||0)+1),e}),{}):{}},$=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=c(e,2)[1];return c(t,2)[1]-n})).map((function(e){var n=c(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=c(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})},X=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=$(U(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,s={segment:"F",startHour:o,endHour:o,type:"full",mainType:"undefined",mainTypeHours:0,distribution:{}};if(!e.length||i<o)return s;var c=e.filter((function(e){return e.hour>=o&&e.hour<o+a}));if(c.length>0){var u=$(U(c)),l=Math.min(c[c.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 s}(e.hours,t,n);return[].concat(u(r),[o])},Y=function(e){return e<0?String(e+24).padStart(2,"0"):e>=24?String(e-24).padStart(2,"0"):String(e).padStart(2,"0")},V=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=G(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}}},W=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")},Q=function(e){return e.secondaryType?"balance"===e.type?"Ba":"chaos"===e.type?"Ch":"Mi":"Fu"},K=function(e,t){var n=G(e,void 0,t,"overall");return{status:n.overall?n.overall.some((function(e){return"warning"===e.status}))?"warning":"success":"info",title:"日程总体分析",advices:[].concat(u(n.overall?n.overall.flatMap((function(e){return e.advices})):[]),u(n.features?n.features.flatMap((function(e){return e.advices})):[])),stats:{duration:e.hours.length,mainTypePercent:0,secondaryTypePercent:0}}},Z=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=p(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,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,i=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw i}}}}(e.blocks);try{for(o.s();!(t=o.n()).done;){var i=t.value;if("string"!=typeof i)for(var a=i,s=0;s<a.duration;s++)n.push({hour:r,type:a.type,comment:a.comment}),r++;else{var c=i;n.push({hour:r,type:c}),r++}}}catch(e){o.e(e)}finally{o.f()}return n},J=function(t){var n=t.patterns,r=t.dates,o=t.onChange,i=e.useState(n.map((function(e,t){return function(e,t){var n={date:t,hours:Z(e),segments:[]};return Object.assign(Object.assign({},n),{qhSegments:X(n)})}(e,r[t])}))),a=c(i,2),s=a[0],l=a[1];return{data:s,updateHour:e.useCallback((function(e,t,n,r){l((function(i){return i.map((function(i){if(i.date!==e)return i;var a=i.hours.findIndex((function(e){return e.hour===t}));if(-1===a)return i;var s=i.hours[a],c=u(i.hours);c[a]=Object.assign(Object.assign({},s),{type:n,comment:r||s.comment}),null==o||o({hour:t,date:e,oldType:s.type,newType:n,comment:r});var l=Object.assign(Object.assign({},i),{hours:c});return Object.assign(Object.assign({},l),{qhSegments:X(l)})}))}))}),[o])}},ee=function(t){var n,r=t.hour,o=t.date,i=t.theme,a=t.editable,s=t.customTypes,c=t.typeOrder,u=t.onChange,l=t.render,p=t.onHover;return l?e.createElement(e.Fragment,null,l(r,o)):e.createElement("div",{className:"hour-cell",style:{width:i.cellSize,height:i.cellSize,backgroundColor:(n=r.type,s&&n in s?s[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=c||f,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)},te=t.div.withConfig({displayName:"SegmentsContainer"})(["display:flex;flex-direction:column;gap:","px;width:150px;"],(function(e){return e.theme.gap})),ne=t.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);}"]),re=t.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")}),ne,(function(e){return"".concat(e.color,"25")})),oe=t.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}),ne),ie=t.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}),ne),ae=t.div.withConfig({displayName:"SegmentContent"})(["flex:1;min-width:0;transition:transform 0.2s ease;",":hover &{transform:translateX(2px);}"],ne),se=t.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})),ce=t.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);}"],ne),ue=function(t){var n=t.segments,r=t.theme,o=t.onSegmentHover;return e.createElement(te,{theme:r},n.map((function(t){var n=r.colors[t.mainType],i=Q(t);return e.createElement(ne,{key:t.segment,theme:r,onMouseEnter:function(e){return null==o?void 0:o(t,e)},onMouseLeave:function(e){return null==o?void 0:o(null,e)}},e.createElement(re,{color:n},e.createElement(oe,{color:n},t.segment),e.createElement(ie,{color:n},i)),e.createElement(ae,null,e.createElement(se,{color:n,"data-type":t.mainType},t.mainType,t.secondaryType&&e.createElement(e.Fragment,null,e.createElement("span",{style:{opacity:.3}},"/"),e.createElement("span",{style:{color:r.colors[t.secondaryType]}},t.secondaryType))),e.createElement(ce,null,"".concat(t.startHour,":00-").concat(t.endHour,":00"))))})))},le=function(t){var n=t.day,r=t.theme,o=t.direction,i=void 0===o?"horizontal":o,a=t.showDateLabel,s=t.renderDateLabel,c=t.renderHour,u=t.onHourChange,l=t.editable,p=void 0!==l&&l,f=t.customTypes,d=t.onHover,g=t.onSegmentHover,m=t.pinClassName,h=t.typeOrder,y=e.useRef(null),v=n.hours.reduce((function(e,t,n){var r=Math.floor(n/7);return e[r]||(e[r]=[]),e[r].push(t),e}),[]),b=function(e,t){d&&d(e,t,y)};return e.createElement("div",{ref:y,className:"day-row ".concat(m),style:{display:"flex",flexDirection:"horizontal"===i?"row":"column",alignItems:"flex-start",gap:2*r.gap,marginBottom:4*r.gap,position:"relative"}},n.qhSegments&&e.createElement("div",{style:{display:"flex",flexDirection:"column",gap:r.gap,paddingTop:a?"24px":0}},e.createElement(ue,{segments:n.qhSegments,theme:r,onSegmentHover:function(e,t){g&&g(e,t,y)}})),e.createElement("div",{style:{display:"flex",flexDirection:"column",minHeight:v.length*(r.cellSize+r.gap)-r.gap}},a&&e.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),e.createElement("div",{className:"hours-rows",style:{display:"flex",flexDirection:"column",gap:r.gap,flex:1}},v.map((function(t,o){return e.createElement("div",{key:o,className:"hours-row",style:{display:"flex",gap:r.gap,height:r.cellSize}},t.map((function(t){return e.createElement(ee,{key:t.hour,hour:t,date:n.date,theme:r,editable:p,customTypes:f,typeOrder:h,onChange:u,render:c,onHover:b})})))})))))},pe=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},fe=t.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 pe(e.theme)?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.05)"}),(function(e){return pe(e.theme)?"rgba(255,255,255,0.45)":"rgba(0,0,0,0.45)"})),de=function(t){var n=t.day,r=t.theme,o=t.onClick,i=t.renderDateLabel;return e.createElement(fe,{theme:r,onClick:function(e){return null==o?void 0:o(n,e)}},i?i(n.date):n.date)},ge=t.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})),me=function(t){var n=t.data,r=t.direction,o=t.theme,i=t.showDateLabel,a=t.renderDateLabel,s=t.renderHour,c=t.onHourChange,u=t.editable,l=t.customTypes,p=t.typeOrder,f=t.onHover,d=t.onSegmentHover,g=t.onDateTitleClick;return e.createElement(ge,{theme:o},n.map((function(t){return e.createElement("div",{key:t.date,className:"day-container"},i&&e.createElement(de,{day:t,theme:o,onClick:g,renderDateLabel:a}),e.createElement(le,{day:t,theme:o,direction:r,showDateLabel:!1,renderHour:s,onHourChange:c,editable:u,customTypes:l,typeOrder:p,onHover:f,onSegmentHover:d}))})))};function he(){return"undefined"!=typeof window}function ye(e){return xe(e)?(e.nodeName||"").toLowerCase():"#document"}function ve(e){var t;return(null==e||null==(t=e.ownerDocument)?void 0:t.defaultView)||window}function be(e){var t;return null==(t=(xe(e)?e.ownerDocument:e.document)||window.document)?void 0:t.documentElement}function xe(e){return!!he()&&(e instanceof Node||e instanceof ve(e).Node)}function we(e){return!!he()&&(e instanceof Element||e instanceof ve(e).Element)}function Ee(e){return!!he()&&(e instanceof HTMLElement||e instanceof ve(e).HTMLElement)}function Te(e){return!(!he()||"undefined"==typeof ShadowRoot)&&(e instanceof ShadowRoot||e instanceof ve(e).ShadowRoot)}function Se(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=Ce(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!["inline","contents"].includes(o)}function Re(e){return["table","td","th"].includes(ye(e))}function Me(e){return[":popover-open",":modal"].some((t=>{try{return e.matches(t)}catch(e){return!1}}))}function Oe(e){const t=ke(),n=we(e)?Ce(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 ke(){return!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}function He(e){return["html","body","#document"].includes(ye(e))}function Ce(e){return ve(e).getComputedStyle(e)}function Ae(e){return we(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function _e(e){if("html"===ye(e))return e;const t=e.assignedSlot||e.parentNode||Te(e)&&e.host||be(e);return Te(t)?t.host:t}function Ne(e){const t=_e(e);return He(t)?e.ownerDocument?e.ownerDocument.body:e.body:Ee(t)&&Se(t)?t:Ne(t)}function Ie(e,t,n){var r;void 0===t&&(t=[]),void 0===n&&(n=!0);const o=Ne(e),i=o===(null==(r=e.ownerDocument)?void 0:r.body),a=ve(o);if(i){const e=Pe(a);return t.concat(a,a.visualViewport||[],Se(o)?o:[],e&&n?Ie(e):[])}return t.concat(o,Ie(o,[],n))}function Pe(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}const ze=Math.min,Le=Math.max,De=Math.round,je=Math.floor,Fe=e=>({x:e,y:e}),Be={left:"right",right:"left",bottom:"top",top:"bottom"},qe={start:"end",end:"start"};function Ge(e,t,n){return Le(e,ze(t,n))}function Ue(e,t){return"function"==typeof e?e(t):e}function $e(e){return e.split("-")[0]}function Xe(e){return e.split("-")[1]}function Ye(e){return"x"===e?"y":"x"}function Ve(e){return"y"===e?"height":"width"}function We(e){return["top","bottom"].includes($e(e))?"y":"x"}function Qe(e){return Ye(We(e))}function Ke(e){return e.replace(/start|end/g,(e=>qe[e]))}function Ze(e){return e.replace(/left|right|bottom|top/g,(e=>Be[e]))}function Je(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 et(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 tt(e,t,n){let{reference:r,floating:o}=e;const i=We(t),a=Qe(t),s=Ve(a),c=$e(t),u="y"===i,l=r.x+r.width/2-o.width/2,p=r.y+r.height/2-o.height/2,f=r[s]/2-o[s]/2;let d;switch(c){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(Xe(t)){case"start":d[a]-=f*(n&&u?-1:1);break;case"end":d[a]+=f*(n&&u?-1:1)}return d}async function nt(e,t){var n;void 0===t&&(t={});const{x:r,y:o,platform:i,rects:a,elements:s,strategy:c}=e,{boundary:u="clippingAncestors",rootBoundary:l="viewport",elementContext:p="floating",altBoundary:f=!1,padding:d=0}=Ue(t,e),g=Je(d),m=s[f?"floating"===p?"reference":"floating":p],h=et(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(s.floating)),boundary:u,rootBoundary:l,strategy:c})),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(s.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=et(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:s,rect:y,offsetParent:v,strategy:c}):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 rt(e){const t=ze(...e.map((e=>e.left))),n=ze(...e.map((e=>e.top)));return{x:t,y:n,width:Le(...e.map((e=>e.right)))-t,height:Le(...e.map((e=>e.bottom)))-n}}function ot(e){const t=Ce(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=Ee(e),i=o?e.offsetWidth:n,a=o?e.offsetHeight:r,s=De(n)!==i||De(r)!==a;return s&&(n=i,r=a),{width:n,height:r,$:s}}function it(e){return we(e)?e:e.contextElement}function at(e){const t=it(e);if(!Ee(t))return Fe(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:i}=ot(t);let a=(i?De(n.width):n.width)/r,s=(i?De(n.height):n.height)/o;return a&&Number.isFinite(a)||(a=1),s&&Number.isFinite(s)||(s=1),{x:a,y:s}}const st=Fe(0);function ct(e){const t=ve(e);return ke()&&t.visualViewport?{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}:st}function ut(e,t,n,r){void 0===t&&(t=!1),void 0===n&&(n=!1);const o=e.getBoundingClientRect(),i=it(e);let a=Fe(1);t&&(r?we(r)&&(a=at(r)):a=at(e));const s=function(e,t,n){return void 0===t&&(t=!1),!(!n||t&&n!==ve(e))&&t}(i,n,r)?ct(i):Fe(0);let c=(o.left+s.x)/a.x,u=(o.top+s.y)/a.y,l=o.width/a.x,p=o.height/a.y;if(i){const e=ve(i),t=r&&we(r)?ve(r):r;let n=e,o=Pe(n);for(;o&&r&&t!==n;){const e=at(o),t=o.getBoundingClientRect(),r=Ce(o),i=t.left+(o.clientLeft+parseFloat(r.paddingLeft))*e.x,a=t.top+(o.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,u*=e.y,l*=e.x,p*=e.y,c+=i,u+=a,n=ve(o),o=Pe(n)}}return et({width:l,height:p,x:c,y:u})}function lt(e,t){const n=Ae(e).scrollLeft;return t?t.left+n:ut(be(e)).left+n}function pt(e,t,n){void 0===n&&(n=!1);const r=e.getBoundingClientRect();return{x:r.left+t.scrollLeft-(n?0:lt(e,r)),y:r.top+t.scrollTop}}function ft(e,t,n){let r;if("viewport"===t)r=function(e,t){const n=ve(e),r=be(e),o=n.visualViewport;let i=r.clientWidth,a=r.clientHeight,s=0,c=0;if(o){i=o.width,a=o.height;const e=ke();(!e||e&&"fixed"===t)&&(s=o.offsetLeft,c=o.offsetTop)}return{width:i,height:a,x:s,y:c}}(e,n);else if("document"===t)r=function(e)