@beechcms/api 0.6.7 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/assets/dashboard/0auth_mcp.svg +1 -0
  2. package/assets/dashboard/assets/{chart-D_uST30B.js → chart-CYgKoF6U.js} +6 -6
  3. package/assets/dashboard/assets/dist-DHabpZqA.js +140 -0
  4. package/assets/dashboard/assets/index-BZMSpYrl.js +3613 -0
  5. package/assets/dashboard/assets/index-Dex2YZcC.css +1 -0
  6. package/assets/dashboard/assets/json-code-editor-DtZpKDXm.js +12 -0
  7. package/assets/dashboard/assets/pie-chart-recharts-C7WAhcCk.js +1 -0
  8. package/assets/dashboard/assets/richtext-render-x0TT0116.js +258 -0
  9. package/assets/dashboard/assets/timeseries-chart-recharts-B9RquiY6.js +1 -0
  10. package/assets/dashboard/assets/w3c-keyname-BOAvb0qz.js +1 -0
  11. package/assets/dashboard/index.html +4 -2
  12. package/dist/auth/auth.app.d.ts +13 -0
  13. package/dist/auth/index.d.ts +6 -0
  14. package/dist/factory.d.ts +14 -1
  15. package/dist/features/oauth/authorization-request.d.ts +127 -0
  16. package/dist/features/oauth/authorize.d.ts +97 -0
  17. package/dist/features/oauth/consents.d.ts +75 -0
  18. package/dist/features/oauth/constants.d.ts +48 -0
  19. package/dist/features/oauth/index.d.ts +31 -0
  20. package/dist/features/oauth/revoke.d.ts +29 -0
  21. package/dist/features/oauth/token-issuance.d.ts +49 -0
  22. package/dist/features/oauth/token.d.ts +38 -0
  23. package/dist/features/search/constants.d.ts +43 -0
  24. package/dist/features/search/handlers/embed.d.ts +31 -0
  25. package/dist/features/search/handlers/full-text-search.d.ts +28 -0
  26. package/dist/features/search/index.d.ts +20 -0
  27. package/dist/features/search/jobs/semantic-search.hooks.d.ts +21 -0
  28. package/dist/features/search/jobs/semantic-search.worker.d.ts +101 -0
  29. package/dist/features/search/public-search.router.d.ts +15 -0
  30. package/dist/features/search/search.d.ts +14 -6
  31. package/dist/features/search/semantic-search.hooks.d.ts +2 -0
  32. package/dist/features/search/semantic-search.worker.d.ts +21 -0
  33. package/dist/features/search/types.d.ts +100 -0
  34. package/dist/features/search/utils/search-utils.d.ts +56 -0
  35. package/dist/features/seeds/seeds.destructive.d.ts +6 -0
  36. package/dist/features/seeds/seeds.handler.d.ts +14 -0
  37. package/dist/features/seeds/seeds.helpers.d.ts +118 -0
  38. package/dist/features/seeds/seeds.mcp.d.ts +37 -0
  39. package/dist/features/upload/index.d.ts +2 -2
  40. package/dist/index.js +3544 -1368
  41. package/dist/middleware/auth.middleware.d.ts +34 -4
  42. package/dist/middleware/oauth-scope.middleware.d.ts +60 -0
  43. package/dist/middleware/rate-limit.middleware.d.ts +4 -2
  44. package/dist/middleware/repository.middleware.d.ts +9 -1
  45. package/dist/public/api-key-middleware.d.ts +0 -4
  46. package/dist/public/public-add.d.ts +1 -1
  47. package/dist/rate-limit/in-memory-rate-limiter.d.ts +1 -8
  48. package/dist/shared/db/repositories/content.repository.d1.d.ts +4 -2
  49. package/dist/shared/db/repositories/d1-oauth-authorization-code.repository.d.ts +9 -0
  50. package/dist/shared/db/repositories/d1-oauth-client.repository.d.ts +6 -0
  51. package/dist/shared/db/repositories/d1-oauth-consent.repository.d.ts +10 -0
  52. package/dist/shared/db/repositories/d1-oauth-token.repository.d.ts +12 -0
  53. package/dist/shared/db/repositories/d1-search.query.d.ts +54 -0
  54. package/dist/shared/db/repositories/d1-vector.repository.d.ts +11 -0
  55. package/dist/shared/db/repositories/in-memory-seed.repository.d.ts +2 -1
  56. package/dist/shared/db/repositories/seed.repository.d1.d.ts +3 -1
  57. package/dist/shared/db/repositories/time-trap-token.repository.d1.d.ts +7 -0
  58. package/dist/shared/storage/factory.d.ts +84 -4
  59. package/dist/shared/storage/r2-bucket.d.ts +127 -0
  60. package/dist/shared/storage/s3-bucket.d.ts +104 -10
  61. package/dist/shared/storage/upload.d.ts +33 -5
  62. package/dist/shared/utils/dual-key-rate-limiter.d.ts +21 -0
  63. package/dist/shared/utils/media-utils.d.ts +3 -3
  64. package/dist/shared/utils/opaque-token.d.ts +13 -0
  65. package/dist/types.d.ts +49 -1
  66. package/migrations/0000_v040_base.sql +184 -1
  67. package/migrations/_archive/0000_schema_init.sql +257 -0
  68. package/migrations/_archive/0001_init.sql +25 -0
  69. package/migrations/_archive/0002_seed_admin.sql +10 -0
  70. package/migrations/_archive/0003_refresh_tokens.sql +17 -0
  71. package/migrations/_archive/0004_seed_projects.sql +18 -0
  72. package/migrations/_archive/0005_update_projects.sql +56 -0
  73. package/migrations/_archive/0006_add_slug_and_unique_index.sql +7 -0
  74. package/migrations/_archive/0007_cleanup_test_data.sql +4 -0
  75. package/migrations/_archive/0008_seed_content_entries.sql +104 -0
  76. package/migrations/_archive/0009_public_idempotency.sql +11 -0
  77. package/migrations/_archive/0010_seed_real_data.sql +31 -0
  78. package/migrations/_archive/0010_testsite_data.sql +31 -0
  79. package/migrations/_archive/0011_analytics.sql +10 -0
  80. package/migrations/_archive/0012_seed_analytics.sql +17 -0
  81. package/migrations/_archive/0013_system_stats.sql +8 -0
  82. package/migrations/_archive/0014_activity_logs.sql +15 -0
  83. package/migrations/_archive/0015_notifications.sql +12 -0
  84. package/migrations/_archive/0016_fts5_global_search.sql +81 -0
  85. package/migrations/_archive/0017_seed_clienti.sql +90 -0
  86. package/migrations/_archive/0018_draft_data.sql +3 -0
  87. package/migrations/_archive/0019_drop_fts_triggers.sql +7 -0
  88. package/migrations/_archive/0020_composite_indexes.sql +15 -0
  89. package/migrations/_archive/0021_media_objects.sql +15 -0
  90. package/migrations/_archive/0022_analytics_seed.sql +23 -0
  91. package/migrations/_archive/0023_user_profile.sql +4 -0
  92. package/migrations/_archive/0024_activity_user_name.sql +3 -0
  93. package/migrations/_archive/0025_password_reset_tokens.sql +11 -0
  94. package/migrations/_archive/0026_remove_dev_admin.sql +4 -0
  95. package/migrations/_archive/0027_v040_doctype_architecture.sql +51 -0
  96. package/migrations/_archive/0029_fts_all_text_branches.sql +281 -0
  97. package/migrations/_archive/0031_site_settings.sql +9 -0
  98. package/migrations/_archive/0032_seeds.sql +28 -0
  99. package/migrations/_archive/0033_dashboard_layouts.sql +14 -0
  100. package/migrations/_archive/0034_kanban_foundation.sql +24 -0
  101. package/migrations/_archive/0035_setup_lock.sql +10 -0
  102. package/migrations/_archive/0036_notification_type_success.sql +23 -0
  103. package/migrations/_archive/0037_time_trap_tokens.sql +13 -0
  104. package/migrations/_archive/0038_oauth_authorization.sql +95 -0
  105. package/migrations/_archive/0039_oauth_client_beech_mcp.sql +20 -0
  106. package/package.json +3 -5
  107. package/assets/dashboard/assets/index-B58kBLrh.css +0 -1
  108. package/assets/dashboard/assets/index-DjniT5Z9.js +0 -745
  109. package/assets/dashboard/assets/pie-chart-recharts-CnVomiSi.js +0 -1
  110. package/assets/dashboard/assets/timeseries-chart-recharts-CTqi8qnV.js +0 -1
  111. /package/migrations/{0029_automations.sql → _archive/0029_automations.sql} +0 -0
@@ -0,0 +1 @@
1
+ import{o as e,r as t,s as n,u as r}from"./index-BZMSpYrl.js";import{$t as i,A as a,An as o,At as s,B as c,Cn as l,D as u,Dn as d,E as f,En as p,F as m,Fn as h,Gt as g,H as _,Ht as v,I as y,In as b,Jt as x,K as S,Kt as C,L as w,M as T,Mn as E,Mt as D,N as O,Nn as k,Nt as A,O as j,On as M,Ot as ee,Pn as te,Pt as ne,Qt as re,R as ie,Rt as ae,S as oe,Sn as se,St as ce,T as le,Tn as N,Tt as ue,U as de,Ut as fe,V as pe,W as me,Wt as he,Xt as ge,Yt as _e,Zt as ve,_ as ye,_n as be,_t as xe,a as Se,an as Ce,bn as P,bt as we,c as Te,cn as Ee,d as De,dn as Oe,en as F,f as ke,fn as Ae,g as je,gn as Me,gt as I,h as Ne,hn as Pe,ht as Fe,i as Ie,j as Le,jn as Re,jt as ze,k as Be,kn as Ve,kt as L,l as He,ln as Ue,lt as We,m as Ge,mn as Ke,mt as qe,n as Je,nn as Ye,nt as R,o as Xe,on as Ze,ot as Qe,p as $e,pn as et,qt as z,r as tt,rt as nt,s as rt,sn as it,st as B,t as at,tn as ot,un as st,v as ct,vn as V,vt as lt,w as ut,wn as dt,wt as ft,x as pt,xn as H,xt as mt,y as ht,yn as gt,yt as _t,z as vt,zt as yt}from"./chart-CYgKoF6U.js";var U=r(e());function bt(){return bt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},bt.apply(null,arguments)}var xt=e=>{var{cx:n,cy:r,r:i,className:a}=e,o=t(`recharts-dot`,a);return M(n)&&M(r)&&M(i)?U.createElement(`circle`,bt({},h(e),se(e),{className:o,cx:n,cy:r,r:i})):null},St=[`points`];function Ct(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function wt(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Ct(Object(n),!0).forEach(function(t){Tt(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ct(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Tt(e,t,n){return(t=Et(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Et(e){var t=Dt(e,`string`);return typeof t==`symbol`?t:t+``}function Dt(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Ot(){return Ot=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Ot.apply(null,arguments)}function kt(e,t){if(e==null)return{};var n,r,i=At(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function At(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function jt(e){var{option:n,dotProps:r,className:i}=e;if((0,U.isValidElement)(n))return(0,U.cloneElement)(n,r);if(typeof n==`function`)return n(r);var a=t(i,typeof n==`boolean`?``:n.className),o=r??{},{points:s}=o,c=kt(o,St);return U.createElement(xt,Ot({},c,{className:a}))}function Mt(e,t){return e==null?!1:t?!0:e.length===1}function Nt(e){var{points:t,dot:n,className:r,dotClassName:i,dataKey:o,baseProps:s,needClip:c,clipPathId:l,zIndex:u=L.scatter}=e;if(!Mt(t,n))return null;var d=a(n),f=te(n),p=t.map((e,r)=>{var a=wt(wt(wt({r:3},s),f),{},{index:r,cx:e.x??void 0,cy:e.y??void 0,dataKey:o,value:e.value,payload:e.payload,points:t});return U.createElement(jt,{key:`dot-${r}`,option:n,dotProps:a,className:i})}),m={};return c&&l!=null&&(m.clipPath=`url(#clipPath-${d?``:`dots-`}${l})`),U.createElement(_,{zIndex:u},U.createElement(E,Ot({className:r},m),p))}function Pt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Ft(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Pt(Object(n),!0).forEach(function(t){It(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Pt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function It(e,t,n){return(t=Lt(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Lt(e){var t=Rt(e,`string`);return typeof t==`symbol`?t:t+``}function Rt(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var zt=e=>{var{point:t,childIndex:n,mainColor:r,activeDot:i,dataKey:a,clipPath:o}=e;if(i===!1||t.x==null||t.y==null)return null;var s=Ft(Ft(Ft({},{index:n,dataKey:a,cx:t.x,cy:t.y,r:4,fill:r??`none`,strokeWidth:2,stroke:`#fff`,payload:t.payload,value:t.value}),b(i)),se(i)),c=(0,U.isValidElement)(i)?(0,U.cloneElement)(i,s):typeof i==`function`?i(s):U.createElement(xt,s);return U.createElement(E,{className:`recharts-active-dot`,clipPath:o},c)};function Bt(e){var{points:t,mainColor:n,activeDot:r,itemDataKey:i,clipPath:a,zIndex:o=L.activeDot}=e,s=P(S),c=Ge();if(t==null||c==null)return null;var l=t.find(e=>c.includes(e.payload));return d(l)?null:U.createElement(_,{zIndex:o},U.createElement(zt,{point:l,childIndex:Number(s),mainColor:n,dataKey:i,activeDot:r,clipPath:a}))}var Vt=(e,t,n)=>{var r=n??e;if(!d(r))return dt(r,t,0)},Ht=(e,t,n)=>{var r={},i=e.filter(ft),a=e.filter(e=>e.stackId==null),o=i.reduce((e,t)=>{var n=e[t.stackId];return n??=[],n.push(t),e[t.stackId]=n,e},r),s=Object.entries(o).map(e=>{var[r,i]=e;return{stackId:r,dataKeys:i.map(e=>e.dataKey),barSize:Vt(t,n,i[0]?.barSize)}}),c=a.map(e=>({stackId:void 0,dataKeys:[e.dataKey].filter(e=>e!=null),barSize:Vt(t,n,e.barSize)}));return[...s,...c]};function Ut(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Wt(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Ut(Object(n),!0).forEach(function(t){Gt(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ut(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Gt(e,t,n){return(t=Kt(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Kt(e){var t=qt(e,`string`);return typeof t==`symbol`?t:t+``}function qt(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Jt(e,t,n,r,i){var a=r.length;if(!(a<1)){var o=dt(e,n,0,!0),s,c=[];if(be(r[0]?.barSize)){var l=!1,u=n/a,d=r.reduce((e,t)=>e+(t.barSize||0),0);d+=(a-1)*o,d>=n&&(d-=(a-1)*o,o=0),d>=n&&u>0&&(l=!0,u*=.9,d=a*u);var f={offset:((n-d)/2>>0)-o,size:0};s=r.reduce((e,t)=>{var n={stackId:t.stackId,dataKeys:t.dataKeys,position:{offset:f.offset+f.size+o,size:l?u:t.barSize??0}},r=[...e,n];return f=n.position,r},c)}else{var p=dt(t,n,0,!0);n-2*p-(a-1)*o<=0&&(o=0);var m=(n-2*p-(a-1)*o)/a;m>1&&(m>>=0);var h=be(i)?Math.min(m,i):m;s=r.reduce((e,t,n)=>[...e,{stackId:t.stackId,dataKeys:t.dataKeys,position:{offset:p+(m+o)*n+(m-h)/2,size:h}}],c)}return s}}var Yt=(e,t,n,r,i,a,o)=>{var s=d(o)?t:o,c=Jt(n,r,i===a?a:i,e,s);return i!==a&&c!=null&&(c=c.map(e=>Wt(Wt({},e),{},{position:Wt(Wt({},e.position),{},{offset:e.position.offset-i/2})}))),c},Xt=(e,t)=>{var n=ue(t);if(!(!e||n==null||t==null)){var{stackId:r}=t;if(r!=null){var i=e[r];if(i){var{stackedData:a}=i;if(a)return a.find(e=>e.key===n)}}}},Zt=(e,t)=>{if(!(e==null||t==null)){var n=e.find(e=>e.stackId===t.stackId&&t.dataKey!=null&&e.dataKeys.includes(t.dataKey));if(n!=null)return n.position}};function Qt(e,t){return e&&typeof e==`object`&&`zIndex`in e&&typeof e.zIndex==`number`&&be(e.zIndex)?e.zIndex:t}function $t(e){return(e%180+180)%180}var en=function(e){var{width:t,height:n}=e,r=$t(arguments.length>1&&arguments[1]!==void 0?arguments[1]:0)*Math.PI/180,i=Math.atan(n/t),a=r>i&&r<Math.PI-i?n/Math.sin(r):t/Math.cos(r);return Math.abs(a)};function tn(e,t){if(t<1)return[];if(t===1)return e;for(var n=[],r=0;r<e.length;r+=t){var i=e[r];i!==void 0&&n.push(i)}return n}function nn(e,t,n){return en({width:e.width+t.width,height:e.height+t.height},n)}function rn(e,t,n){var r=n===`width`,{x:i,y:a,width:o,height:s}=e;return t===1?{start:r?i:a,end:r?i+o:a+s}:{start:r?i+o:a+s,end:r?i:a}}function an(e,t,n,r,i){if(e*t<e*r||e*t>e*i)return!1;var a=n();return e*(t-e*a/2-r)>=0&&e*(t+e*a/2-i)<=0}function on(e,t){return tn(e,t+1)}function sn(e,t,n,r,i){for(var a=(r||[]).slice(),{start:o,end:s}=t,c=0,l=1,u=o,d=function(){var t=r?.[c];if(t===void 0)return{v:tn(r,l)};var a=c,d,f=()=>(d===void 0&&(d=n(t,a)),d),p=t.coordinate,m=c===0||an(e,p,f,u,s);m||(c=0,u=o,l+=1),m&&(u=p+e*(f()/2+i),c+=l)},f;l<=a.length;)if(f=d(),f)return f.v;return[]}function cn(e,t,n,r,i){var a=(r||[]).slice().length;if(a===0)return[];for(var{start:o,end:s}=t,c=1;c<=a;c++){for(var l=(a-1)%c,u=o,d=!0,f=function(){var t=r[m];if(t==null)return 0;var a=m,o,c=()=>(o===void 0&&(o=n(t,a)),o),f=t.coordinate,p=m===l||an(e,f,c,u,s);if(!p)return d=!1,1;p&&(u=f+e*(c()/2+i))},p,m=l;m<a&&(p=f(),!(p!==0&&p===1));m+=c);if(d){for(var h=[],g=l;g<a;g+=c){var _=r[g];_!=null&&h.push(_)}return h}}return[]}function ln(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function W(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?ln(Object(n),!0).forEach(function(t){un(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ln(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function un(e,t,n){return(t=dn(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function dn(e){var t=fn(e,`string`);return typeof t==`symbol`?t:t+``}function fn(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function pn(e,t,n,r,i){for(var a=(r||[]).slice(),o=a.length,{start:s}=t,{end:c}=t,l=function(t){var r=a[t];if(r==null)return 1;var l=r,u,d=()=>(u===void 0&&(u=n(r,t)),u);if(t===o-1){var f=e*(l.coordinate+e*d()/2-c);a[t]=l=W(W({},l),{},{tickCoord:f>0?l.coordinate-f*e:l.coordinate})}else a[t]=l=W(W({},l),{},{tickCoord:l.coordinate});l.tickCoord!=null&&an(e,l.tickCoord,d,s,c)&&(c=l.tickCoord-e*(d()/2+i),a[t]=W(W({},l),{},{isShow:!0}))},u=o-1;u>=0;u--)if(l(u))continue;return a}function mn(e,t,n,r,i,a){var o=(r||[]).slice(),s=o.length,{start:c,end:l}=t;if(a){var u=r[s-1];if(u!=null){var d=n(u,s-1),f=e*(u.coordinate+e*d/2-l);o[s-1]=u=W(W({},u),{},{tickCoord:f>0?u.coordinate-f*e:u.coordinate}),u.tickCoord!=null&&an(e,u.tickCoord,()=>d,c,l)&&(l=u.tickCoord-e*(d/2+i),o[s-1]=W(W({},u),{},{isShow:!0}))}}for(var p=a?s-1:s,m=function(t){var r=o[t];if(r==null)return 1;var a=r,s,u=()=>(s===void 0&&(s=n(r,t)),s);if(t===0){var d=e*(a.coordinate-e*u()/2-c);o[t]=a=W(W({},a),{},{tickCoord:d<0?a.coordinate-d*e:a.coordinate})}else o[t]=a=W(W({},a),{},{tickCoord:a.coordinate});a.tickCoord!=null&&an(e,a.tickCoord,u,c,l)&&(c=a.tickCoord+e*(u()/2+i),o[t]=W(W({},a),{},{isShow:!0}))},h=0;h<p;h++)if(m(h))continue;return o}function hn(e,t,n){var{tick:r,ticks:i,viewBox:a,minTickGap:o,orientation:s,interval:c,tickFormatter:l,unit:u,angle:d}=e;if(!i||!i.length||!r)return[];if(M(c)||g.isSsr)return on(i,M(c)?c:0)??[];var f=[],p=s===`top`||s===`bottom`?`width`:`height`,m=u&&p===`width`?vt(u,{fontSize:t,letterSpacing:n}):{width:0,height:0},h=(e,r)=>{var i=typeof l==`function`?l(e.value,r):e.value;return p===`width`?nn(vt(i,{fontSize:t,letterSpacing:n}),m,d):vt(i,{fontSize:t,letterSpacing:n})[p]},_=i[0],v=i[1],y=i.length>=2&&_!=null&&v!=null?Ve(v.coordinate-_.coordinate):1,b=rn(a,y,p);return c===`equidistantPreserveStart`?sn(y,b,h,i,o):c===`equidistantPreserveEnd`?cn(y,b,h,i,o):(f=c===`preserveStart`||c===`preserveStartEnd`?mn(y,b,h,i,o,c===`preserveStartEnd`):pn(y,b,h,i,o),f.filter(e=>e.isShow))}var gn=e=>{var{ticks:t,label:n,labelGapWithTick:r=5,tickSize:i=0,tickMargin:a=0}=e,o=0;if(t){Array.from(t).forEach(e=>{if(e){var t=e.getBoundingClientRect();t.width>o&&(o=t.width)}});var s=n?n.getBoundingClientRect().width:0,c=i+a,l=o+c+s+(n?r:0);return Math.round(l)}return 0},_n=[`axisLine`,`width`,`height`,`className`,`hide`,`ticks`,`axisType`,`axisId`];function vn(e,t){if(e==null)return{};var n,r,i=yn(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function yn(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function bn(){return bn=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},bn.apply(null,arguments)}function xn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function G(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?xn(Object(n),!0).forEach(function(t){Sn(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):xn(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Sn(e,t,n){return(t=Cn(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Cn(e){var t=wn(e,`string`);return typeof t==`symbol`?t:t+``}function wn(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var Tn={x:0,y:0,width:0,height:0,viewBox:{x:0,y:0,width:0,height:0},orientation:`bottom`,ticks:[],stroke:`#666`,tickLine:!0,axisLine:!0,tick:!0,mirror:!1,minTickGap:5,tickSize:6,tickMargin:2,interval:`preserveEnd`,zIndex:L.axis};function En(e){var{x:n,y:r,width:i,height:a,orientation:o,mirror:s,axisLine:c,otherSvgProps:l}=e;if(!c)return null;var u=G(G(G({},l),h(c)),{},{fill:`none`});if(o===`top`||o===`bottom`){var d=+(o===`top`&&!s||o===`bottom`&&s);u=G(G({},u),{},{x1:n,y1:r+d*a,x2:n+i,y2:r+d*a})}else{var f=+(o===`left`&&!s||o===`right`&&s);u=G(G({},u),{},{x1:n+f*i,y1:r,x2:n+f*i,y2:r+a})}return U.createElement(`line`,bn({},u,{className:t(`recharts-cartesian-axis-line`,Re(c,`className`))}))}function Dn(e,t,n,r,i,a,o,s,c){var l,u,d,f,p,m,h=s?-1:1,g=e.tickSize||o,_=M(e.tickCoord)?e.tickCoord:e.coordinate;switch(a){case`top`:l=u=e.coordinate,f=n+ +!s*i,d=f-h*g,m=d-h*c,p=_;break;case`left`:d=f=e.coordinate,u=t+ +!s*r,l=u-h*g,p=l-h*c,m=_;break;case`right`:d=f=e.coordinate,u=t+ +s*r,l=u+h*g,p=l+h*c,m=_;break;default:l=u=e.coordinate,f=n+ +s*i,d=f+h*g,m=d+h*c,p=_;break}return{line:{x1:l,y1:d,x2:u,y2:f},tick:{x:p,y:m}}}function On(e,t){switch(e){case`left`:return t?`start`:`end`;case`right`:return t?`end`:`start`;default:return`middle`}}function kn(e,t){switch(e){case`left`:case`right`:return`middle`;case`top`:return t?`start`:`end`;default:return t?`end`:`start`}}function An(e){var{option:n,tickProps:r,value:i}=e,a,o=t(r.className,`recharts-cartesian-axis-tick-value`);if(U.isValidElement(n))a=U.cloneElement(n,G(G({},r),{},{className:o}));else if(typeof n==`function`)a=n(G(G({},r),{},{className:o}));else{var s=`recharts-cartesian-axis-tick-value`;typeof n!=`boolean`&&(s=t(s,Le(n))),a=U.createElement(w,bn({},r,{className:s}),i)}return a}function jn(e){var{ticks:t,axisType:n,axisId:r}=e,i=gt();return(0,U.useEffect)(()=>r==null||n==null?o:(i(ke({ticks:t.map(e=>({value:e.value,coordinate:e.coordinate,offset:e.offset,index:e.index})),axisId:r,axisType:n})),()=>{i(De({axisId:r,axisType:n}))}),[i,t,r,n]),null}var Mn=(0,U.forwardRef)((e,n)=>{var{ticks:r=[],tick:i,tickLine:a,stroke:o,tickFormatter:s,unit:c,padding:u,tickTextProps:d,orientation:f,mirror:p,x:m,y:g,width:v,height:y,tickSize:x,tickMargin:S,fontSize:C,letterSpacing:w,getTicksConfig:T,events:D,axisType:O,axisId:k}=e,A=hn(G(G({},T),{},{ticks:r}),C,w),j=h(T),M=b(i),ee=ie(j.textAnchor)?j.textAnchor:On(f,p),te=kn(f,p),ne={};typeof a==`object`&&(ne=a);var re=G(G({},j),{},{fill:`none`},ne),ae=A.map(e=>G({entry:e},Dn(e,m,g,v,y,f,x,p,S))),oe=ae.map(e=>{var{entry:n,line:r}=e;return U.createElement(E,{className:`recharts-cartesian-axis-tick`,key:`tick-${n.value}-${n.coordinate}-${n.tickCoord}`},a&&U.createElement(`line`,bn({},re,r,{className:t(`recharts-cartesian-axis-tick-line`,Re(a,`className`))})))}),se=ae.map((e,t)=>{var{entry:n,tick:r}=e,a=G(G({},G(G(G(G({verticalAnchor:te},j),{},{textAnchor:ee,stroke:`none`,fill:o},r),{},{index:t,payload:n,visibleTicksCount:A.length,tickFormatter:s,padding:u},d),{},{angle:d?.angle??j.angle??0})),M);return U.createElement(E,bn({className:`recharts-cartesian-axis-tick-label`,key:`tick-label-${n.value}-${n.coordinate}-${n.tickCoord}`},l(D,n,t)),i&&U.createElement(An,{option:i,tickProps:a,value:`${typeof s==`function`?s(n.value,t):n.value}${c||``}`}))});return U.createElement(`g`,{className:`recharts-cartesian-axis-ticks recharts-${O}-ticks`},U.createElement(jn,{ticks:A,axisId:k,axisType:O}),se.length>0&&U.createElement(_,{zIndex:L.label},U.createElement(`g`,{className:`recharts-cartesian-axis-tick-labels recharts-${O}-tick-labels`,ref:n},se)),oe.length>0&&U.createElement(`g`,{className:`recharts-cartesian-axis-tick-lines recharts-${O}-tick-lines`},oe))}),Nn=(0,U.forwardRef)((e,n)=>{var{axisLine:r,width:i,height:a,className:o,hide:s,ticks:c,axisType:l,axisId:u}=e,d=vn(e,_n),[f,p]=(0,U.useState)(``),[g,v]=(0,U.useState)(``),b=(0,U.useRef)(null);(0,U.useImperativeHandle)(n,()=>({getCalculatedWidth:()=>gn({ticks:b.current,label:e.labelRef?.current,labelGapWithTick:5,tickSize:e.tickSize,tickMargin:e.tickMargin})}));var x=(0,U.useCallback)(e=>{if(e){var t=e.getElementsByClassName(`recharts-cartesian-axis-tick-value`);b.current=t;var n=t[0];if(n){var r=window.getComputedStyle(n),i=r.fontSize,a=r.letterSpacing;(i!==f||a!==g)&&(p(i),v(a))}}},[f,g]);return s||i!=null&&i<=0||a!=null&&a<=0?null:U.createElement(_,{zIndex:e.zIndex},U.createElement(E,{className:t(`recharts-cartesian-axis`,o)},U.createElement(En,{x:e.x,y:e.y,width:i,height:a,orientation:e.orientation,mirror:e.mirror,axisLine:r,otherSvgProps:h(e)}),U.createElement(Mn,{ref:x,axisType:l,events:d,fontSize:f,getTicksConfig:e,height:e.height,letterSpacing:g,mirror:e.mirror,orientation:e.orientation,padding:e.padding,stroke:e.stroke,tick:e.tick,tickFormatter:e.tickFormatter,tickLine:e.tickLine,tickMargin:e.tickMargin,tickSize:e.tickSize,tickTextProps:e.tickTextProps,ticks:c,unit:e.unit,width:e.width,x:e.x,y:e.y,axisId:u}),U.createElement(m,{x:e.x,y:e.y,width:e.width,height:e.height,lowerWidth:e.width,upperWidth:e.width},U.createElement(y,{label:e.label,labelRef:e.labelRef}),e.children)))}),Pn=U.forwardRef((e,t)=>{var n=H(e,Tn);return U.createElement(Nn,bn({},n,{ref:t}))});Pn.displayName=`CartesianAxis`;var Fn=[`x1`,`y1`,`x2`,`y2`,`key`],In=[`offset`],Ln=[`xAxisId`,`yAxisId`],Rn=[`xAxisId`,`yAxisId`];function zn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function K(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?zn(Object(n),!0).forEach(function(t){Bn(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):zn(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Bn(e,t,n){return(t=Vn(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Vn(e){var t=Hn(e,`string`);return typeof t==`symbol`?t:t+``}function Hn(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Un(){return Un=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Un.apply(null,arguments)}function Wn(e,t){if(e==null)return{};var n,r,i=Gn(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Gn(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var Kn=e=>{var{fill:t}=e;if(!t||t===`none`)return null;var{fillOpacity:n,x:r,y:i,width:a,height:o,ry:s}=e;return U.createElement(`rect`,{x:r,y:i,ry:s,width:a,height:o,stroke:`none`,fill:t,fillOpacity:n,className:`recharts-cartesian-grid-bg`})};function qn(e){var{option:t,lineItemProps:n}=e,r;if(U.isValidElement(t))r=U.cloneElement(t,n);else if(typeof t==`function`)r=t(n);else{var{x1:i,y1:a,x2:o,y2:s,key:c}=n,l=h(Wn(n,Fn))??{},{offset:u}=l,d=Wn(l,In);r=U.createElement(`line`,Un({},d,{x1:i,y1:a,x2:o,y2:s,fill:`none`,key:c}))}return r}function Jn(e){var{x:t,width:n,horizontal:r=!0,horizontalPoints:i}=e;if(!r||!i||!i.length)return null;var{xAxisId:a,yAxisId:o}=e,s=Wn(e,Ln),c=i.map((e,i)=>{var a=K(K({},s),{},{x1:t,y1:e,x2:t+n,y2:e,key:`line-${i}`,index:i});return U.createElement(qn,{key:`line-${i}`,option:r,lineItemProps:a})});return U.createElement(`g`,{className:`recharts-cartesian-grid-horizontal`},c)}function Yn(e){var{y:t,height:n,vertical:r=!0,verticalPoints:i}=e;if(!r||!i||!i.length)return null;var{xAxisId:a,yAxisId:o}=e,s=Wn(e,Rn),c=i.map((e,i)=>{var a=K(K({},s),{},{x1:e,y1:t,x2:e,y2:t+n,key:`line-${i}`,index:i});return U.createElement(qn,{option:r,lineItemProps:a,key:`line-${i}`})});return U.createElement(`g`,{className:`recharts-cartesian-grid-vertical`},c)}function Xn(e){var{horizontalFill:t,fillOpacity:n,x:r,y:i,width:a,height:o,horizontalPoints:s,horizontal:c=!0}=e;if(!c||!t||!t.length||s==null)return null;var l=s.map(e=>Math.round(e+i-i)).sort((e,t)=>e-t);i!==l[0]&&l.unshift(0);var u=l.map((e,s)=>{var c=l[s+1],u=c==null?i+o-e:c-e;if(u<=0)return null;var d=s%t.length;return U.createElement(`rect`,{key:`react-${s}`,y:e,x:r,height:u,width:a,stroke:`none`,fill:t[d],fillOpacity:n,className:`recharts-cartesian-grid-bg`})});return U.createElement(`g`,{className:`recharts-cartesian-gridstripes-horizontal`},u)}function Zn(e){var{vertical:t=!0,verticalFill:n,fillOpacity:r,x:i,y:a,width:o,height:s,verticalPoints:c}=e;if(!t||!n||!n.length)return null;var l=c.map(e=>Math.round(e+i-i)).sort((e,t)=>e-t);i!==l[0]&&l.unshift(0);var u=l.map((e,t)=>{var c=l[t+1],u=c==null?i+o-e:c-e;if(u<=0)return null;var d=t%n.length;return U.createElement(`rect`,{key:`react-${t}`,x:e,y:a,width:u,height:s,stroke:`none`,fill:n[d],fillOpacity:r,className:`recharts-cartesian-grid-bg`})});return U.createElement(`g`,{className:`recharts-cartesian-gridstripes-vertical`},u)}var Qn=(e,t)=>{var{xAxis:n,width:r,height:i,offset:a}=e;return Ue(hn(K(K(K({},Tn),n),{},{ticks:Oe(n,!0),viewBox:{x:0,y:0,width:r,height:i}})),a.left,a.left+a.width,t)},$n=(e,t)=>{var{yAxis:n,width:r,height:i,offset:a}=e;return Ue(hn(K(K(K({},Tn),n),{},{ticks:Oe(n,!0),viewBox:{x:0,y:0,width:r,height:i}})),a.top,a.top+a.height,t)},er={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:`#ccc`,fill:`none`,verticalFill:[],horizontalFill:[],xAxisId:0,yAxisId:0,syncWithTicks:!1,zIndex:L.grid};function tr(e){var t=ve(),n=_e(),r=re(),a=K(K({},H(e,er)),{},{x:M(e.x)?e.x:r.left,y:M(e.y)?e.y:r.top,width:M(e.width)?e.width:r.width,height:M(e.height)?e.height:r.height}),{xAxisId:o,yAxisId:s,x:c,y:l,width:u,height:d,syncWithTicks:f,horizontalValues:p,verticalValues:m}=a,h=F(),g=P(e=>Qe(e,`xAxis`,o,h)),v=P(e=>Qe(e,`yAxis`,s,h));if(!Me(u)||!Me(d)||!M(c)||!M(l))return null;var y=a.verticalCoordinatesGenerator||Qn,b=a.horizontalCoordinatesGenerator||$n,{horizontalPoints:x,verticalPoints:S}=a;if((!x||!x.length)&&typeof b==`function`){var C=p&&p.length,w=b({yAxis:v?K(K({},v),{},{ticks:C?p:v.ticks}):void 0,width:t??u,height:n??d,offset:r},C?!0:f);i(Array.isArray(w),`horizontalCoordinatesGenerator should return Array but instead it returned [${typeof w}]`),Array.isArray(w)&&(x=w)}if((!S||!S.length)&&typeof y==`function`){var T=m&&m.length,E=y({xAxis:g?K(K({},g),{},{ticks:T?m:g.ticks}):void 0,width:t??u,height:n??d,offset:r},T?!0:f);i(Array.isArray(E),`verticalCoordinatesGenerator should return Array but instead it returned [${typeof E}]`),Array.isArray(E)&&(S=E)}return U.createElement(_,{zIndex:a.zIndex},U.createElement(`g`,{className:`recharts-cartesian-grid`},U.createElement(Kn,{fill:a.fill,fillOpacity:a.fillOpacity,x:a.x,y:a.y,width:a.width,height:a.height,ry:a.ry}),U.createElement(Xn,Un({},a,{horizontalPoints:x})),U.createElement(Zn,Un({},a,{verticalPoints:S})),U.createElement(Jn,Un({},a,{offset:r,horizontalPoints:x,xAxis:g,yAxis:v})),U.createElement(Yn,Un({},a,{offset:r,verticalPoints:S,xAxis:g,yAxis:v}))))}tr.displayName=`CartesianGrid`;var nr=[`children`];function rr(e,t){if(e==null)return{};var n,r,i=ir(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function ir(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var ar=(0,U.createContext)({data:[],xAxisId:`xAxis-0`,yAxisId:`yAxis-0`,dataPointFormatter:()=>({x:0,y:0,value:0}),errorBarOffset:0});function or(e){var{children:t}=e,n=rr(e,nr);return U.createElement(ar.Provider,{value:n},t)}function sr(e,t){var n=P(t=>_t(t,e)),r=P(e=>ce(e,t)),i=n?.allowDataOverflow??R.allowDataOverflow,a=r?.allowDataOverflow??nt.allowDataOverflow;return{needClip:i||a,needClipX:i,needClipY:a}}function cr(e){var{xAxisId:t,yAxisId:n,clipPathId:r}=e,i=Ne(),{needClipX:a,needClipY:o,needClip:s}=sr(t,n);if(!s||!i)return null;var{x:c,y:l,width:u,height:d}=i;return U.createElement(`clipPath`,{id:`clipPath-${r}`},U.createElement(`rect`,{x:a?c:c-u/2,y:o?l:l-d/2,width:a?u:u*2,height:o?d:d*2}))}var lr=(e,t,n,r)=>B(e,`xAxis`,t,r),ur=(e,t,n,r)=>I(e,`xAxis`,t,r),dr=(e,t,n,r)=>B(e,`yAxis`,n,r),fr=(e,t,n,r)=>I(e,`yAxis`,n,r),pr=V([z,lr,dr,ur,fr],(e,t,n,r,i)=>Ke(e,`xAxis`)?Ce(t,r,!1):Ce(n,i,!1)),mr=(e,t,n,r,i)=>i;function hr(e){return e.type===`line`}var gr=V([z,lr,dr,ur,fr,V([xe,mr],(e,t)=>e.filter(hr).find(e=>e.id===t)),pr,yt],(e,t,n,r,i,a,o,s)=>{var{chartData:c,dataStartIndex:l,dataEndIndex:u}=s;if(!(a==null||t==null||n==null||r==null||i==null||r.length===0||i.length===0||o==null||e!==`horizontal`&&e!==`vertical`)){var{dataKey:d,data:f}=a,p=f!=null&&f.length>0?f:c?.slice(l,u+1);if(p!=null)return Ur({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataKey:d,bandSize:o,displayedData:p})}});function _r(e){var t=b(e),n=3,r=2;if(t!=null){var{r:i,strokeWidth:a}=t,o=Number(i),s=Number(a);return(Number.isNaN(o)||o<0)&&(o=n),(Number.isNaN(s)||s<0)&&(s=r),{r:o,strokeWidth:s}}return{r:n,strokeWidth:r}}var vr=[`id`],yr=[`type`,`layout`,`connectNulls`,`needClip`,`shape`],br=[`activeDot`,`animateNewValues`,`animationBegin`,`animationDuration`,`animationEasing`,`connectNulls`,`dot`,`hide`,`isAnimationActive`,`label`,`legendType`,`xAxisId`,`yAxisId`,`id`];function xr(){return xr=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},xr.apply(null,arguments)}function Sr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function q(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Sr(Object(n),!0).forEach(function(t){Cr(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Sr(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Cr(e,t,n){return(t=wr(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function wr(e){var t=Tr(e,`string`);return typeof t==`symbol`?t:t+``}function Tr(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Er(e,t){if(e==null)return{};var n,r,i=Dr(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Dr(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var Or=e=>{var{dataKey:t,name:n,stroke:r,legendType:i,hide:a}=e;return[{inactive:a,dataKey:t,type:i,color:r,value:Ae(n,t),payload:e}]},kr=U.memo(e=>{var{dataKey:t,data:n,stroke:r,strokeWidth:i,fill:a,name:s,hide:c,unit:l,tooltipType:u,id:d}=e,f={dataDefinedOnItem:n,getPosition:o,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:t,nameKey:void 0,name:Ae(s,t),hide:c,type:u,color:r,unit:l,graphicalItemId:d}};return U.createElement(ut,{tooltipEntrySettings:f})}),Ar=(e,t)=>`${t}px ${e}px`;function jr(e,t){for(var n=e.length%2==0?e:[...e,0],r=[],i=0;i<t;++i)r.push(...n);return r}var Mr=(e,t,n)=>{var r=n.reduce((e,t)=>e+t,0);if(!r)return Ar(t,e);for(var i=Math.floor(e/r),a=e%r,o=[],s=0,c=0;s<n.length;c+=(l=n[s])??0,++s){var l,u=n[s];if(u!=null&&c+u>a){o=[...n.slice(0,s),a-c];break}}var d=o.length%2==0?[0,t]:[t];return[...jr(n,i),...o,...d].map(e=>`${e}px`).join(`, `)};function Nr(e){var{clipPathId:t,points:n,props:r}=e,{dot:i,dataKey:a,needClip:o}=r,{id:s}=r,c=h(Er(r,vr));return U.createElement(Nt,{points:n,dot:i,className:`recharts-line-dots`,dotClassName:`recharts-line-dot`,dataKey:a,baseProps:c,needClip:o,clipPathId:t})}function Pr(e){var{showLabels:t,children:n,points:r}=e,i=(0,U.useMemo)(()=>r?.map(e=>{var t={x:e.x??0,y:e.y??0,width:0,lowerWidth:0,upperWidth:0,height:0};return q(q({},t),{},{value:e.value,payload:e.payload,viewBox:t,parentViewBox:void 0,fill:void 0})}),[r]);return U.createElement(T,{value:t?i:void 0},n)}function Fr(e){var{clipPathId:t,pathRef:n,points:r,strokeDasharray:i,props:a}=e,{type:o,layout:s,connectNulls:c,needClip:l,shape:u}=a,d=q(q({},k(Er(a,yr))),{},{fill:`none`,className:`recharts-line-curve`,clipPath:l?`url(#clipPath-${t})`:void 0,points:r,type:o,layout:s,connectNulls:c,strokeDasharray:i??a.strokeDasharray});return U.createElement(U.Fragment,null,r?.length>1&&U.createElement(j,xr({shapeType:`curve`,option:u},d,{pathRef:n})),U.createElement(Nr,{points:r,clipPathId:t,props:a}))}function Ir(e){try{return e&&e.getTotalLength&&e.getTotalLength()||0}catch{return 0}}function Lr(e){var{clipPathId:t,props:n,pathRef:r,previousPointsRef:i,longestAnimatedLengthRef:a}=e,{points:o,strokeDasharray:s,isAnimationActive:c,animationBegin:l,animationDuration:u,animationEasing:d,animateNewValues:f,width:p,height:m,onAnimationEnd:h,onAnimationStart:g}=n,_=i.current,y=v(o,`recharts-line-`),b=(0,U.useRef)(y),[x,S]=(0,U.useState)(!1),C=!x,w=(0,U.useCallback)(()=>{typeof h==`function`&&h(),S(!1)},[h]),T=(0,U.useCallback)(()=>{typeof g==`function`&&g(),S(!0)},[g]),E=Ir(r.current),D=(0,U.useRef)(0);b.current!==y&&(D.current=a.current,b.current=y);var k=D.current;return U.createElement(Pr,{points:o,showLabels:C},n.children,U.createElement(fe,{animationId:y,begin:l,duration:u,isActive:c,easing:d,onAnimationEnd:w,onAnimationStart:T,key:y},e=>{var l=N(k,E+k,e),u=Math.min(l,E),d=c?s?Mr(u,E,`${s}`.split(/[,\s]+/gim).map(e=>parseFloat(e))):Ar(E,u):s==null?void 0:String(s);if(e>0&&E>0&&(i.current=o,a.current=Math.max(a.current,u)),_){var h=_.length/o.length,g=e===1?o:o.map((t,n)=>{var r=Math.floor(n*h);if(_[r]){var i=_[r];return q(q({},t),{},{x:N(i.x,t.x,e),y:N(i.y,t.y,e)})}return f?q(q({},t),{},{x:N(p*2,t.x,e),y:N(m/2,t.y,e)}):q(q({},t),{},{x:t.x,y:t.y})});return i.current=g,U.createElement(Fr,{props:n,points:g,clipPathId:t,pathRef:r,strokeDasharray:d})}return U.createElement(Fr,{props:n,points:o,clipPathId:t,pathRef:r,strokeDasharray:d})}),U.createElement(O,{label:n.label}))}function Rr(e){var{clipPathId:t,props:n}=e,r=(0,U.useRef)(null),i=(0,U.useRef)(0),a=(0,U.useRef)(null);return U.createElement(Lr,{props:n,clipPathId:t,previousPointsRef:r,longestAnimatedLengthRef:i,pathRef:a})}var zr=(e,t)=>({x:e.x??void 0,y:e.y??void 0,value:e.value,errorVal:et(e.payload,t)}),Br=class extends U.Component{render(){var{hide:e,dot:n,points:r,className:i,xAxisId:o,yAxisId:s,top:c,left:l,width:u,height:d,id:f,needClip:p,zIndex:m}=this.props;if(e)return null;var h=t(`recharts-line`,i),g=f,{r:v,strokeWidth:y}=_r(n),b=a(n),x=v*2+y,S=p?`url(#clipPath-${b?``:`dots-`}${g})`:void 0;return U.createElement(_,{zIndex:m},U.createElement(E,{className:h},p&&U.createElement(`defs`,null,U.createElement(cr,{clipPathId:g,xAxisId:o,yAxisId:s}),!b&&U.createElement(`clipPath`,{id:`clipPath-dots-${g}`},U.createElement(`rect`,{x:l-x/2,y:c-x/2,width:u+x,height:d+x}))),U.createElement(or,{xAxisId:o,yAxisId:s,data:r,dataPointFormatter:zr,errorBarOffset:0},U.createElement(Rr,{props:this.props,clipPathId:g}))),U.createElement(Bt,{activeDot:this.props.activeDot,points:r,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:S}))}},Vr={activeDot:!0,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:`ease`,connectNulls:!1,dot:!0,fill:`#fff`,hide:!1,isAnimationActive:`auto`,label:!1,legendType:`line`,stroke:`#3182bd`,strokeWidth:1,xAxisId:0,yAxisId:0,zIndex:L.line,type:`linear`};function Hr(e){var t=H(e,Vr),{activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:o,connectNulls:s,dot:c,hide:l,isAnimationActive:u,label:d,legendType:f,xAxisId:p,yAxisId:m,id:h}=t,g=Er(t,br),{needClip:_}=sr(p,m),v=Ne(),y=ge(),b=F(),x=P(e=>gr(e,p,m,b,h));if(y!==`horizontal`&&y!==`vertical`||x==null||v==null)return null;var{height:S,width:C,x:w,y:T}=v;return U.createElement(Br,xr({},g,{id:h,connectNulls:s,dot:c,activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:o,isAnimationActive:u,hide:l,label:d,legendType:f,xAxisId:p,yAxisId:m,points:x,layout:y,height:S,width:C,left:w,top:T,needClip:_}))}function Ur(e){var{layout:t,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:a,dataKey:o,bandSize:s,displayedData:c}=e;return c.map((e,c)=>{var l=et(e,o);if(t===`horizontal`)return{x:Ee({axis:n,ticks:i,bandSize:s,entry:e,index:c}),y:(d(l)?null:r.scale.map(l))??null,value:l,payload:e};var u=d(l)?null:n.scale.map(l),f=Ee({axis:r,ticks:a,bandSize:s,entry:e,index:c});return u==null||f==null?null:{x:u,y:f,value:l,payload:e}}).filter(Boolean)}function Wr(e){var t=H(e,Vr),n=F();return U.createElement(pt,{id:t.id,type:`line`},e=>U.createElement(U.Fragment,null,U.createElement(oe,{legendPayload:Or(t)}),U.createElement(kr,{dataKey:t.dataKey,data:t.data,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,tooltipType:t.tooltipType,id:e}),U.createElement(ht,{type:`line`,id:e,data:t.data,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,dataKey:t.dataKey,hide:t.hide,isPanorama:n}),U.createElement(Hr,xr({},t,{id:e}))))}var Gr=U.memo(Wr,C);Gr.displayName=`Line`;function J(e,t){return e.graphicalItems.cartesianItems.find(e=>e.id===t)?.xAxisId??0}function Y(e,t){return e.graphicalItems.cartesianItems.find(e=>e.id===t)?.yAxisId??0}var Kr=(e,t,n)=>B(e,`xAxis`,J(e,t),n),qr=(e,t,n)=>I(e,`xAxis`,J(e,t),n),Jr=(e,t,n)=>B(e,`yAxis`,Y(e,t),n),Yr=(e,t,n)=>I(e,`yAxis`,Y(e,t),n),Xr=V([z,Kr,Jr,qr,Yr],(e,t,n,r,i)=>Ke(e,`xAxis`)?Ce(t,r,!1):Ce(n,i,!1)),Zr=V([xe,(e,t)=>t],(e,t)=>e.filter(e=>e.type===`area`).find(e=>e.id===t)),Qr=e=>Ke(z(e),`xAxis`)?`yAxis`:`xAxis`,$r=(e,t)=>Qr(e)===`yAxis`?Y(e,t):J(e,t),ei=V([z,Kr,Jr,qr,Yr,V([Zr,(e,t,n)=>qe(e,Qr(e),$r(e,t),n)],(e,t)=>{if(!(e==null||t==null)){var{stackId:n}=e,r=ue(e);if(!(n==null||r==null)){var i=(t[n]?.stackedData)?.find(e=>e.key===r);if(i!=null)return i.map(e=>[e[0],e[1]])}}}),ae,Xr,Zr,D],(e,t,n,r,i,a,o,s,c,l)=>{var{chartData:u,dataStartIndex:d,dataEndIndex:f}=o;if(!(c==null||e!==`horizontal`&&e!==`vertical`||t==null||n==null||r==null||i==null||r.length===0||i.length===0||s==null)){var{data:p}=c,m=p&&p.length>0?p:u?.slice(d,f+1);if(m!=null)return Ti({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataStartIndex:d,areaSettings:c,stackedData:a,displayedData:m,chartBaseValue:l,bandSize:s})}}),ti=[`id`],ni=[`activeDot`,`animationBegin`,`animationDuration`,`animationEasing`,`connectNulls`,`dot`,`fill`,`fillOpacity`,`hide`,`isAnimationActive`,`legendType`,`stroke`,`xAxisId`,`yAxisId`];function X(){return X=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},X.apply(null,arguments)}function ri(e,t){if(e==null)return{};var n,r,i=ii(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function ii(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function ai(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function oi(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?ai(Object(n),!0).forEach(function(t){si(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ai(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function si(e,t,n){return(t=ci(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ci(e){var t=li(e,`string`);return typeof t==`symbol`?t:t+``}function li(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function ui(e,t){return e&&e!==`none`?e:t}var di=e=>{var{dataKey:t,name:n,stroke:r,fill:i,legendType:a,hide:o}=e;return[{inactive:o,dataKey:t,type:a,color:ui(r,i),value:Ae(n,t),payload:e}]},fi=U.memo(e=>{var{dataKey:t,data:n,stroke:r,strokeWidth:i,fill:a,name:s,hide:c,unit:l,tooltipType:u,id:d}=e,f={dataDefinedOnItem:n,getPosition:o,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:t,nameKey:void 0,name:Ae(s,t),hide:c,type:u,color:ui(r,a),unit:l,graphicalItemId:d}};return U.createElement(ut,{tooltipEntrySettings:f})});function pi(e){var{clipPathId:t,points:n,props:r}=e,{needClip:i,dot:a,dataKey:o}=r,s=h(r);return U.createElement(Nt,{points:n,dot:a,className:`recharts-area-dots`,dotClassName:`recharts-area-dot`,dataKey:o,baseProps:s,needClip:i,clipPathId:t})}function mi(e){var{showLabels:t,children:n,points:r}=e,i=r.map(e=>{var t={x:e.x??0,y:e.y??0,width:0,lowerWidth:0,upperWidth:0,height:0};return oi(oi({},t),{},{value:e.value,payload:e.payload,parentViewBox:void 0,viewBox:t,fill:void 0})});return U.createElement(T,{value:t?i:void 0},n)}function hi(e){var{points:t,baseLine:n,needClip:r,clipPathId:i,props:a}=e,{layout:o,type:s,stroke:c,connectNulls:l,isRange:u}=a,{id:d}=a,f=ri(a,ti),p=h(f),m=k(f);return U.createElement(U.Fragment,null,t?.length>1&&U.createElement(E,{clipPath:r?`url(#clipPath-${i})`:void 0},U.createElement(he,X({},m,{id:d,points:t,connectNulls:l,type:s,baseLine:n,layout:o,stroke:`none`,className:`recharts-area-area`})),c!==`none`&&U.createElement(he,X({},p,{className:`recharts-area-curve`,layout:o,type:s,connectNulls:l,fill:`none`,points:t})),c!==`none`&&u&&Array.isArray(n)&&U.createElement(he,X({},p,{className:`recharts-area-curve`,layout:o,type:s,connectNulls:l,fill:`none`,points:n}))),U.createElement(pi,{points:t,props:f,clipPathId:i}))}function gi(e){var{alpha:t,baseLine:n,points:r,strokeWidth:i}=e,a=r[0]?.y,o=r[r.length-1]?.y;if(!be(a)||!be(o))return null;var s=t*Math.abs(a-o),c=Math.max(...r.map(e=>e.x||0));return M(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(e=>e.x||0),c)),M(c)?U.createElement(`rect`,{x:0,y:a<o?a:a-s,width:c+(i?parseInt(`${i}`,10):1),height:Math.floor(s)}):null}function _i(e){var{alpha:t,baseLine:n,points:r,strokeWidth:i}=e,a=r[0]?.x,o=r[r.length-1]?.x;if(!be(a)||!be(o))return null;var s=t*Math.abs(a-o),c=Math.max(...r.map(e=>e.y||0));return M(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(e=>e.y||0),c)),M(c)?U.createElement(`rect`,{x:a<o?a:a-s,y:0,width:s,height:Math.floor(c+(i?parseInt(`${i}`,10):1))}):null}function vi(e){var{alpha:t,layout:n,points:r,baseLine:i,strokeWidth:a}=e;return n===`vertical`?U.createElement(gi,{alpha:t,points:r,baseLine:i,strokeWidth:a}):U.createElement(_i,{alpha:t,points:r,baseLine:i,strokeWidth:a})}function yi(e){var{needClip:t,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:a}=e,{points:o,baseLine:s,isAnimationActive:c,animationBegin:l,animationDuration:u,animationEasing:f,onAnimationStart:m,onAnimationEnd:h}=r,g=v((0,U.useMemo)(()=>({points:o,baseLine:s}),[o,s]),`recharts-area-`),_=x(),[y,b]=(0,U.useState)(!1),S=!y,C=(0,U.useCallback)(()=>{typeof h==`function`&&h(),b(!1)},[h]),w=(0,U.useCallback)(()=>{typeof m==`function`&&m(),b(!0)},[m]);if(_==null)return null;var T=i.current,D=a.current;return U.createElement(mi,{showLabels:S,points:o},r.children,U.createElement(fe,{animationId:g,begin:l,duration:u,isActive:c,easing:f,onAnimationEnd:C,onAnimationStart:w,key:g},e=>{if(T){var l=T.length/o.length,u=e===1?o:o.map((t,n)=>{var r=Math.floor(n*l);if(T[r]){var i=T[r];return oi(oi({},t),{},{x:N(i.x,t.x,e),y:N(i.y,t.y,e)})}return t}),f=M(s)?N(D,s,e):d(s)||p(s)?N(D,0,e):s.map((t,n)=>{var r=Math.floor(n*l);if(Array.isArray(D)&&D[r]){var i=D[r];return oi(oi({},t),{},{x:N(i.x,t.x,e),y:N(i.y,t.y,e)})}return t});return e>0&&(i.current=u,a.current=f),U.createElement(hi,{points:u,baseLine:f,needClip:t,clipPathId:n,props:r})}return e>0&&(i.current=o,a.current=s),U.createElement(E,null,c&&U.createElement(`defs`,null,U.createElement(`clipPath`,{id:`animationClipPath-${n}`},U.createElement(vi,{alpha:e,points:o,baseLine:s,layout:_,strokeWidth:r.strokeWidth}))),U.createElement(E,{clipPath:`url(#animationClipPath-${n})`},U.createElement(hi,{points:o,baseLine:s,needClip:t,clipPathId:n,props:r})))}),U.createElement(O,{label:r.label}))}function bi(e){var{needClip:t,clipPathId:n,props:r}=e,i=(0,U.useRef)(null),a=(0,U.useRef)();return U.createElement(yi,{needClip:t,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:a})}var xi=class extends U.PureComponent{render(){var{hide:e,dot:n,points:r,className:i,top:o,left:s,needClip:c,xAxisId:l,yAxisId:u,width:d,height:f,id:p,baseLine:m,zIndex:h}=this.props;if(e)return null;var g=t(`recharts-area`,i),v=p,{r:y,strokeWidth:b}=_r(n),x=a(n),S=y*2+b,C=c?`url(#clipPath-${x?``:`dots-`}${v})`:void 0;return U.createElement(_,{zIndex:h},U.createElement(E,{className:g},c&&U.createElement(`defs`,null,U.createElement(cr,{clipPathId:v,xAxisId:l,yAxisId:u}),!x&&U.createElement(`clipPath`,{id:`clipPath-dots-${v}`},U.createElement(`rect`,{x:s-S/2,y:o-S/2,width:d+S,height:f+S}))),U.createElement(bi,{needClip:c,clipPathId:v,props:this.props})),U.createElement(Bt,{points:r,mainColor:ui(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:C}),this.props.isRange&&Array.isArray(m)&&U.createElement(Bt,{points:m,mainColor:ui(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:C}))}},Si={activeDot:!0,animationBegin:0,animationDuration:1500,animationEasing:`ease`,connectNulls:!1,dot:!1,fill:`#3182bd`,fillOpacity:.6,hide:!1,isAnimationActive:`auto`,legendType:`line`,stroke:`#3182bd`,strokeWidth:1,type:`linear`,label:!1,xAxisId:0,yAxisId:0,zIndex:L.area};function Ci(e){var{activeDot:t,animationBegin:n,animationDuration:r,animationEasing:i,connectNulls:a,dot:o,fill:s,fillOpacity:c,hide:l,isAnimationActive:u,legendType:d,stroke:f,xAxisId:p,yAxisId:m}=e,h=ri(e,ni),g=ge(),_=de(),{needClip:v}=sr(p,m),y=F(),{points:b,isRange:x,baseLine:S}=P(t=>ei(t,e.id,y))??{},C=Ne();if(g!==`horizontal`&&g!==`vertical`||C==null||_!==`AreaChart`&&_!==`ComposedChart`)return null;var{height:w,width:T,x:E,y:D}=C;return!b||!b.length?null:U.createElement(xi,X({},h,{activeDot:t,animationBegin:n,animationDuration:r,animationEasing:i,baseLine:S,connectNulls:a,dot:o,fill:s,fillOpacity:c,height:w,hide:l,layout:g,isAnimationActive:u,isRange:x,legendType:d,needClip:v,points:b,stroke:f,width:T,left:E,top:D,xAxisId:p,yAxisId:m}))}var wi=(e,t,n,r,i)=>{var a=n??t;if(M(a))return a;var o=e===`horizontal`?i:r,s=o.scale.domain();if(o.type===`number`){var c=Math.max(s[0],s[1]),l=Math.min(s[0],s[1]);return a===`dataMin`?l:a===`dataMax`||c<0?c:Math.max(Math.min(s[0],s[1]),0)}return a===`dataMin`?s[0]:a===`dataMax`?s[1]:s[0]};function Ti(e){var{areaSettings:{connectNulls:t,baseValue:n,dataKey:r},stackedData:i,layout:a,chartBaseValue:o,xAxis:s,yAxis:c,displayedData:l,dataStartIndex:u,xAxisTicks:d,yAxisTicks:f,bandSize:p}=e,m=i&&i.length,h=wi(a,o,n,s,c),g=a===`horizontal`,_=!1,v=l.map((e,n)=>{var a;if(m)a=i[u+n];else{var o=et(e,r);Array.isArray(o)?(a=o,_=!0):a=[h,o]}var l=a?.[1]??null,v=l==null||m&&!t&&et(e,r)==null;return g?{x:Ee({axis:s,ticks:d,bandSize:p,entry:e,index:n}),y:v?null:c.scale.map(l)??null,value:a,payload:e}:{x:v?null:s.scale.map(l)??null,y:Ee({axis:c,ticks:f,bandSize:p,entry:e,index:n}),value:a,payload:e}});return{points:v,baseLine:(m||_?v.map(e=>{var t=Array.isArray(e.value)?e.value[0]:null;return g?{x:e.x,y:t!=null&&e.y!=null?c.scale.map(t)??null:null,payload:e.payload}:{x:t==null?null:s.scale.map(t)??null,y:e.y,payload:e.payload}}):g?c.scale.map(h):s.scale.map(h))??0,isRange:_}}function Ei(e){var t=H(e,Si),n=F();return U.createElement(pt,{id:t.id,type:`area`},e=>U.createElement(U.Fragment,null,U.createElement(oe,{legendPayload:di(t)}),U.createElement(fi,{dataKey:t.dataKey,data:t.data,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,tooltipType:t.tooltipType,id:e}),U.createElement(ht,{type:`area`,id:e,data:t.data,dataKey:t.dataKey,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,stackId:st(t.stackId),hide:t.hide,barSize:void 0,baseValue:t.baseValue,isPanorama:n,connectNulls:t.connectNulls}),U.createElement(Ci,X({},t,{id:e}))))}var Di=U.memo(Ei,C);Di.displayName=`Area`;var Oi=`Invariant failed`;function ki(e,t){if(!e)throw Error(Oi)}function Ai(){return Ai=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Ai.apply(null,arguments)}function ji(e){return U.createElement(j,Ai({shapeType:`rectangle`,activeClassName:`recharts-active-bar`,inActiveClassName:`recharts-inactive-bar`},e))}var Mi=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return(n,r)=>{if(M(e))return e;var i=M(n)||d(n);return i?e(n,r):(!i&&ki(!1,`minPointSize callback function received a value with type of ${typeof n}. Currently only numbers or null/undefined are supported.`),t)}},Ni=(e,t,n)=>n,Pi=V([xe,(e,t)=>t],(e,t)=>e.filter(e=>e.type===`bar`).find(e=>e.id===t)),Fi=V([Pi],e=>e?.maxBarSize),Ii=(e,t,n,r)=>r,Li=V([z,xe,J,Y,Ni],(e,t,n,r,i)=>t.filter(t=>e===`horizontal`?t.xAxisId===n:t.yAxisId===r).filter(e=>e.isPanorama===i).filter(e=>e.hide===!1).filter(e=>e.type===`bar`)),Ri=(e,t,n)=>{var r=z(e),i=J(e,t),a=Y(e,t);if(!(i==null||a==null))return r===`horizontal`?qe(e,`yAxis`,a,n):qe(e,`xAxis`,i,n)},zi=V([Li,A,(e,t)=>{var n=z(e),r=J(e,t),i=Y(e,t);if(!(r==null||i==null))return n===`horizontal`?We(e,`xAxis`,r):We(e,`yAxis`,i)}],Ht),Bi=(e,t,n)=>{var r=Pi(e,t);if(r==null)return 0;var i=J(e,t),a=Y(e,t);if(i==null||a==null)return 0;var o=z(e),s=ne(e),{maxBarSize:c}=r,l=d(c)?s:c,u,f;return o===`horizontal`?(u=B(e,`xAxis`,i,n),f=I(e,`xAxis`,i,n)):(u=B(e,`yAxis`,a,n),f=I(e,`yAxis`,a,n)),Ce(u,f,!0)??l??0},Vi=(e,t,n)=>{var r=z(e),i=J(e,t),a=Y(e,t);if(!(i==null||a==null)){var o,s;return r===`horizontal`?(o=B(e,`xAxis`,i,n),s=I(e,`xAxis`,i,n)):(o=B(e,`yAxis`,a,n),s=I(e,`yAxis`,a,n)),Ce(o,s)}},Hi=V([Ye,ot,(e,t,n)=>{var r=J(e,t);if(r!=null)return B(e,`xAxis`,r,n)},(e,t,n)=>{var r=Y(e,t);if(r!=null)return B(e,`yAxis`,r,n)},(e,t,n)=>{var r=J(e,t);if(r!=null)return I(e,`xAxis`,r,n)},(e,t,n)=>{var r=Y(e,t);if(r!=null)return I(e,`yAxis`,r,n)},V([V([zi,ne,ze,s,Bi,Vi,Fi],Yt),Pi],Zt),z,ae,Vi,V([Ri,Pi],Xt),Pi,Ii],(e,t,n,r,i,a,o,s,c,l,u,d,f)=>{var{chartData:p,dataStartIndex:m,dataEndIndex:h}=c;if(!(d==null||o==null||t==null||s!==`horizontal`&&s!==`vertical`||n==null||r==null||i==null||a==null||l==null)){var{data:g}=d,_=g!=null&&g.length>0?g:p?.slice(m,h+1);if(_!=null)return Sa({layout:s,barSettings:d,pos:o,parentViewBox:t,bandSize:l,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:a,stackedData:u,displayedData:_,offset:e,cells:f,dataStartIndex:m})}}),Ui=[`index`];function Wi(){return Wi=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Wi.apply(null,arguments)}function Gi(e,t){if(e==null)return{};var n,r,i=Ki(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Ki(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var qi=(0,U.createContext)(void 0),Ji=e=>{var t=(0,U.useContext)(qi);if(t!=null)return t.stackId;if(e!=null)return st(e)},Yi=(e,t)=>`recharts-bar-stack-clip-path-${e}-${t}`,Xi=e=>{var t=(0,U.useContext)(qi);if(t!=null){var{stackId:n}=t;return`url(#${Yi(n,e)})`}},Zi=e=>{var{index:t}=e,n=Gi(e,Ui),r=Xi(t);return U.createElement(E,Wi({className:`recharts-bar-stack-layer`,clipPath:r},n))},Qi=[`onMouseEnter`,`onMouseLeave`,`onClick`],$i=[`value`,`background`,`tooltipPosition`],ea=[`id`],ta=[`onMouseEnter`,`onClick`,`onMouseLeave`];function Z(){return Z=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Z.apply(null,arguments)}function na(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Q(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?na(Object(n),!0).forEach(function(t){ra(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):na(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function ra(e,t,n){return(t=ia(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ia(e){var t=aa(e,`string`);return typeof t==`symbol`?t:t+``}function aa(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function oa(e,t){if(e==null)return{};var n,r,i=sa(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function sa(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var ca=e=>{var{dataKey:t,name:n,fill:r,legendType:i,hide:a}=e;return[{inactive:a,dataKey:t,type:i,color:r,value:Ae(n,t),payload:e}]},la=U.memo(e=>{var{dataKey:t,stroke:n,strokeWidth:r,fill:i,name:a,hide:s,unit:c,tooltipType:l,id:u}=e,d={dataDefinedOnItem:void 0,getPosition:o,settings:{stroke:n,strokeWidth:r,fill:i,dataKey:t,nameKey:void 0,name:Ae(a,t),hide:s,type:l,color:i,unit:c,graphicalItemId:u}};return U.createElement(ut,{tooltipEntrySettings:d})});function ua(e){var t=P(S),{data:n,dataKey:r,background:i,allOtherBarProps:a}=e,{onMouseEnter:o,onMouseLeave:s,onClick:c}=a,d=oa(a,Qi),p=f(o,r,a.id),m=u(s),h=le(c,r,a.id);if(!i||n==null)return null;var g=b(i);return U.createElement(_,{zIndex:Qt(i,L.barBackground)},n.map((e,n)=>{var{value:a,background:o,tooltipPosition:s}=e,c=oa(e,$i);if(!o)return null;var u=p(e,n),f=m(e,n),_=h(e,n),v=Q(Q(Q(Q(Q({option:i,isActive:String(n)===t},c),{},{fill:`#eee`},o),g),l(d,e,n)),{},{onMouseEnter:u,onMouseLeave:f,onClick:_,dataKey:r,index:n,className:`recharts-bar-background-rectangle`});return U.createElement(ji,Z({key:`background-bar-${n}`},v))}))}function da(e){var{showLabels:t,children:n,rects:r}=e,i=r?.map(e=>{var t={x:e.x,y:e.y,width:e.width,lowerWidth:e.width,upperWidth:e.width,height:e.height};return Q(Q({},t),{},{value:e.value,payload:e.payload,parentViewBox:e.parentViewBox,viewBox:t,fill:e.fill})});return U.createElement(T,{value:t?i:void 0},n)}function fa(e){var{shape:t,activeBar:n,baseProps:r,entry:i,index:a,dataKey:o}=e,s=P(S),c=P(me),l=n&&String(i.originalDataIndex)===s&&(c==null||o===c),[u,d]=(0,U.useState)(!1),[f,p]=(0,U.useState)(!1);(0,U.useEffect)(()=>{var e;return l?(d(!0),e=requestAnimationFrame(()=>{p(!0)})):p(!1),()=>{cancelAnimationFrame(e)}},[l]);var m=(0,U.useCallback)(()=>{l||d(!1)},[l]),h=l&&f,g=l||u,v=l?n===!0?t:n:t,y=U.createElement(ji,Z({},r,{name:String(r.name)},i,{isActive:h,option:v,index:a,dataKey:o,onTransitionEnd:m}));return g?U.createElement(_,{zIndex:L.activeBar},U.createElement(Zi,{index:i.originalDataIndex},y)):y}function pa(e){var{shape:t,baseProps:n,entry:r,index:i,dataKey:a}=e;return U.createElement(ji,Z({},n,{name:String(n.name)},r,{isActive:!1,option:t,index:i,dataKey:a}))}function ma(e){var{data:t,props:n}=e,r=h(n)??{},{id:i}=r,a=oa(r,ea),{shape:o,dataKey:s,activeBar:c}=n,{onMouseEnter:d,onClick:p,onMouseLeave:m}=n,g=oa(n,ta),_=f(d,s,i),v=u(m),y=le(p,s,i);return t?U.createElement(U.Fragment,null,t.map((e,t)=>U.createElement(Zi,Z({index:e.originalDataIndex,key:`rectangle-${e?.x}-${e?.y}-${e?.value}-${t}`,className:`recharts-bar-rectangle`},l(g,e,t),{onMouseEnter:_(e,t),onMouseLeave:v(e,t),onClick:y(e,t)}),c?U.createElement(fa,{shape:o,activeBar:c,baseProps:a,entry:e,index:t,dataKey:s}):U.createElement(pa,{shape:o,baseProps:a,entry:e,index:t,dataKey:s})))):null}function ha(e){var{props:t,previousRectanglesRef:n}=e,{data:r,layout:i,isAnimationActive:a,animationBegin:o,animationDuration:s,animationEasing:c,onAnimationEnd:l,onAnimationStart:u}=t,d=n.current,f=v(t,`recharts-bar-`),[p,m]=(0,U.useState)(!1),h=!p,g=(0,U.useCallback)(()=>{typeof l==`function`&&l(),m(!1)},[l]),_=(0,U.useCallback)(()=>{typeof u==`function`&&u(),m(!0)},[u]);return U.createElement(da,{showLabels:h,rects:r},U.createElement(fe,{animationId:f,begin:o,duration:s,isActive:a,easing:c,onAnimationEnd:g,onAnimationStart:_,key:f},e=>{var a=e===1?r:r?.map((t,n)=>{var r=d&&d[n];if(r)return Q(Q({},t),{},{x:N(r.x,t.x,e),y:N(r.y,t.y,e),width:N(r.width,t.width,e),height:N(r.height,t.height,e)});if(i===`horizontal`){var a=N(0,t.height,e),o=N(t.stackedBarStart,t.y,e);return Q(Q({},t),{},{y:o,height:a})}var s=N(0,t.width,e),c=N(t.stackedBarStart,t.x,e);return Q(Q({},t),{},{width:s,x:c})});return e>0&&(n.current=a??null),a==null?null:U.createElement(E,null,U.createElement(ma,{props:t,data:a}))}),U.createElement(O,{label:t.label}),t.children)}function ga(e){var t=(0,U.useRef)(null);return U.createElement(ha,{previousRectanglesRef:t,props:e})}var _a=0,va=(e,t)=>{var n=Array.isArray(e.value)?e.value[1]:e.value;return{x:e.x,y:e.y,value:n,errorVal:et(e,t)}},ya=class extends U.PureComponent{render(){var{hide:e,data:n,dataKey:r,className:i,xAxisId:a,yAxisId:o,needClip:s,background:c,id:l}=this.props;if(e||n==null)return null;var u=t(`recharts-bar`,i),d=l;return U.createElement(E,{className:u,id:l},s&&U.createElement(`defs`,null,U.createElement(cr,{clipPathId:d,xAxisId:a,yAxisId:o})),U.createElement(E,{className:`recharts-bar-rectangles`,clipPath:s?`url(#clipPath-${d})`:void 0},U.createElement(ua,{data:n,dataKey:r,background:c,allOtherBarProps:this.props}),U.createElement(ga,this.props)))}},ba={activeBar:!1,animationBegin:0,animationDuration:400,animationEasing:`ease`,background:!1,hide:!1,isAnimationActive:`auto`,label:!1,legendType:`rect`,minPointSize:_a,xAxisId:0,yAxisId:0,zIndex:L.bar};function xa(e){var{xAxisId:t,yAxisId:n,hide:r,legendType:i,minPointSize:a,activeBar:o,animationBegin:s,animationDuration:l,animationEasing:u,isAnimationActive:d}=e,{needClip:f}=sr(t,n),p=ge(),m=F(),h=Be(e.children,c),g=P(t=>Hi(t,e.id,m,h));if(p!==`vertical`&&p!==`horizontal`)return null;var _,v=g?.[0];return _=v==null||v.height==null||v.width==null?0:p===`vertical`?v.height/2:v.width/2,U.createElement(or,{xAxisId:t,yAxisId:n,data:g,dataPointFormatter:va,errorBarOffset:_},U.createElement(ya,Z({},e,{layout:p,needClip:f,data:g,xAxisId:t,yAxisId:n,hide:r,legendType:i,minPointSize:a,activeBar:o,animationBegin:s,animationDuration:l,animationEasing:u,isAnimationActive:d})))}function Sa(e){var{layout:t,barSettings:{dataKey:n,minPointSize:r,hasCustomShape:i},pos:a,bandSize:o,xAxis:s,yAxis:c,xAxisTicks:l,yAxisTicks:u,stackedData:d,displayedData:f,offset:m,cells:h,parentViewBox:g,dataStartIndex:_}=e,v=t===`horizontal`?c:s,y=d?v.scale.domain():null,b=Ze({numericAxis:v}),x=v.scale.map(b);return f.map((e,f)=>{var v,S,C,w,T,E;if(d){var D=d[f+_];if(D==null)return null;v=Pe(D,y)}else v=et(e,n),Array.isArray(v)||(v=[b,v]);var O=Mi(r,_a)(v[1],f);if(t===`horizontal`){var k=c.scale.map(v[0]),A=c.scale.map(v[1]);if(k==null||A==null)return null;S=it({axis:s,ticks:l,bandSize:o,offset:a.offset,entry:e,index:f}),C=A??k??void 0,w=a.size;var j=k-A;if(T=p(j)?0:j,E={x:S,y:m.top,width:w,height:m.height},Math.abs(O)>0&&Math.abs(T)<Math.abs(O)){var M=Ve(T||O)*(Math.abs(O)-Math.abs(T));C-=M,T+=M}}else{var ee=s.scale.map(v[0]),te=s.scale.map(v[1]);if(ee==null||te==null)return null;if(S=ee,C=it({axis:c,ticks:u,bandSize:o,offset:a.offset,entry:e,index:f}),w=te-ee,T=a.size,E={x:m.left,y:C,width:m.width,height:T},Math.abs(O)>0&&Math.abs(w)<Math.abs(O)){var ne=Ve(w||O)*(Math.abs(O)-Math.abs(w));w+=ne}}return S==null||C==null||w==null||T==null||!i&&(w===0||T===0)?null:Q(Q({},e),{},{stackedBarStart:x,x:S,y:C,width:w,height:T,value:d?v:v[1],payload:e,background:E,tooltipPosition:{x:S+w/2,y:C+T/2},parentViewBox:g,originalDataIndex:f},h&&h[f]&&h[f].props)}).filter(Boolean)}function Ca(e){var t=H(e,ba),n=Ji(t.stackId),r=F();return U.createElement(pt,{id:t.id,type:`bar`},e=>U.createElement(U.Fragment,null,U.createElement(oe,{legendPayload:ca(t)}),U.createElement(la,{dataKey:t.dataKey,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,tooltipType:t.tooltipType,id:e}),U.createElement(ht,{type:`bar`,id:e,data:void 0,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,dataKey:t.dataKey,stackId:n,hide:t.hide,barSize:t.barSize,minPointSize:t.minPointSize,maxBarSize:t.maxBarSize,isPanorama:r,hasCustomShape:t.shape!=null}),U.createElement(_,{zIndex:t.zIndex},U.createElement(xa,Z({},t,{id:e})))))}var wa=U.memo(Ca,C);wa.displayName=`Bar`;var Ta=[`domain`,`range`],Ea=[`domain`,`range`];function Da(e,t){if(e==null)return{};var n,r,i=Oa(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Oa(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function ka(e,t){return e===t?!0:Array.isArray(e)&&e.length===2&&Array.isArray(t)&&t.length===2?e[0]===t[0]&&e[1]===t[1]:!1}function Aa(e,t){if(e===t)return!0;var{domain:n,range:r}=e,i=Da(e,Ta),{domain:a,range:o}=t,s=Da(t,Ea);return!ka(n,a)||!ka(r,o)?!1:C(i,s)}var ja=[`type`],Ma=[`dangerouslySetInnerHTML`,`ticks`,`scale`],Na=[`id`,`scale`];function Pa(){return Pa=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Pa.apply(null,arguments)}function Fa(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Ia(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Fa(Object(n),!0).forEach(function(t){La(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Fa(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function La(e,t,n){return(t=Ra(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Ra(e){var t=za(e,`string`);return typeof t==`symbol`?t:t+``}function za(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Ba(e,t){if(e==null)return{};var n,r,i=Va(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Va(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function Ha(e){var t=gt(),n=(0,U.useRef)(null),r=x(),{type:i}=e,a=Ba(e,ja),o=ee(r,`xAxis`,i),s=(0,U.useMemo)(()=>{if(o!=null)return Ia(Ia({},a),{},{type:o})},[a,o]);return(0,U.useLayoutEffect)(()=>{s!=null&&(n.current===null?t(je(s)):n.current!==s&&t(ct({prev:n.current,next:s})),n.current=s)},[s,t]),(0,U.useLayoutEffect)(()=>()=>{n.current&&=(t(ye(n.current)),null)},[t]),null}var Ua=e=>{var{xAxisId:n,className:r}=e,i=P(ot),a=F(),o=`xAxis`,s=P(e=>Fe(e,o,n,a)),c=P(e=>mt(e,n)),l=P(e=>lt(e,n)),u=P(e=>we(e,n));if(c==null||l==null||u==null)return null;var{dangerouslySetInnerHTML:d,ticks:f,scale:p}=e,m=Ba(e,Ma),{id:h,scale:g}=u,_=Ba(u,Na);return U.createElement(Pn,Pa({},m,_,{x:l.x,y:l.y,width:c.width,height:c.height,className:t(`recharts-${o} ${o}`,r),viewBox:i,ticks:s,axisType:o,axisId:n}))},Wa={allowDataOverflow:R.allowDataOverflow,allowDecimals:R.allowDecimals,allowDuplicatedCategory:R.allowDuplicatedCategory,angle:R.angle,axisLine:Tn.axisLine,height:R.height,hide:!1,includeHidden:R.includeHidden,interval:R.interval,label:!1,minTickGap:R.minTickGap,mirror:R.mirror,orientation:R.orientation,padding:R.padding,reversed:R.reversed,scale:R.scale,tick:R.tick,tickCount:R.tickCount,tickLine:Tn.tickLine,tickSize:Tn.tickSize,type:R.type,niceTicks:R.niceTicks,xAxisId:0},Ga=U.memo(e=>{var t=H(e,Wa);return U.createElement(U.Fragment,null,U.createElement(Ha,{allowDataOverflow:t.allowDataOverflow,allowDecimals:t.allowDecimals,allowDuplicatedCategory:t.allowDuplicatedCategory,angle:t.angle,dataKey:t.dataKey,domain:t.domain,height:t.height,hide:t.hide,id:t.xAxisId,includeHidden:t.includeHidden,interval:t.interval,minTickGap:t.minTickGap,mirror:t.mirror,name:t.name,orientation:t.orientation,padding:t.padding,reversed:t.reversed,scale:t.scale,tick:t.tick,tickCount:t.tickCount,tickFormatter:t.tickFormatter,ticks:t.ticks,type:t.type,unit:t.unit,niceTicks:t.niceTicks}),U.createElement(Ua,t))},Aa);Ga.displayName=`XAxis`;function Ka(){return Ka=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Ka.apply(null,arguments)}function qa(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Ja(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?qa(Object(n),!0).forEach(function(t){Ya(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):qa(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Ya(e,t,n){return(t=Xa(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Xa(e){var t=Za(e,`string`);return typeof t==`symbol`?t:t+``}function Za(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var Qa=Ja({accessibilityLayer:!0,barCategoryGap:`10%`,barGap:4,layout:`horizontal`,margin:{top:5,right:5,bottom:5,left:5},responsive:!1,reverseStackOrder:!1,stackOffset:`none`,syncMethod:`index`},He),$a=(0,U.forwardRef)(function(e,t){var n=H(e.categoricalChartProps,Qa),{chartName:r,defaultTooltipEventType:i,validateTooltipEventTypes:a,tooltipPayloadSearcher:o,categoricalChartProps:s}=e,c={chartName:r,defaultTooltipEventType:i,validateTooltipEventTypes:a,tooltipPayloadSearcher:o,eventEmitter:void 0};return U.createElement(Te,{preloadedState:{options:c},reduxStoreName:s.id??r},U.createElement($e,{chartData:s.data}),U.createElement(rt,{layout:n.layout,margin:n.margin}),U.createElement(Se,{throttleDelay:n.throttleDelay,throttledEvents:n.throttledEvents}),U.createElement(Xe,{baseValue:n.baseValue,accessibilityLayer:n.accessibilityLayer,barCategoryGap:n.barCategoryGap,maxBarSize:n.maxBarSize,stackOffset:n.stackOffset,barGap:n.barGap,barSize:n.barSize,syncId:n.syncId,syncMethod:n.syncMethod,className:n.className,reverseStackOrder:n.reverseStackOrder}),U.createElement(Ie,Ka({},n,{ref:t})))}),eo=[`axis`],to=(0,U.forwardRef)((e,t)=>U.createElement($a,{chartName:`LineChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:eo,tooltipPayloadSearcher:pe,categoricalChartProps:e,ref:t})),no=[`axis`,`item`],ro=(0,U.forwardRef)((e,t)=>U.createElement($a,{chartName:`BarChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:no,tooltipPayloadSearcher:pe,categoricalChartProps:e,ref:t})),io=[`axis`],ao=(0,U.forwardRef)((e,t)=>U.createElement($a,{chartName:`AreaChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:io,tooltipPayloadSearcher:pe,categoricalChartProps:e,ref:t})),$=n();function oo({kind:e,data:t,color:n,chartConfig:r}){return e===`bar`?(0,$.jsx)(at,{config:r,className:`h-full w-full`,children:(0,$.jsxs)(ro,{data:t,children:[(0,$.jsx)(tr,{vertical:!1,strokeDasharray:`3 3`}),(0,$.jsx)(Ga,{dataKey:`label`,tickLine:!1,axisLine:!1,tickMargin:8,minTickGap:24}),(0,$.jsx)(Je,{content:(0,$.jsx)(tt,{})}),(0,$.jsx)(wa,{dataKey:`value`,fill:n,radius:4})]})}):e===`area`?(0,$.jsx)(at,{config:r,className:`h-full w-full`,children:(0,$.jsxs)(ao,{data:t,children:[(0,$.jsx)(tr,{vertical:!1,strokeDasharray:`3 3`}),(0,$.jsx)(Ga,{dataKey:`label`,tickLine:!1,axisLine:!1,tickMargin:8,minTickGap:24}),(0,$.jsx)(Je,{content:(0,$.jsx)(tt,{})}),(0,$.jsx)(Di,{dataKey:`value`,type:`monotone`,fill:n,fillOpacity:.2,stroke:n})]})}):(0,$.jsx)(at,{config:r,className:`h-full w-full`,children:(0,$.jsxs)(to,{data:t,children:[(0,$.jsx)(tr,{vertical:!1,strokeDasharray:`3 3`}),(0,$.jsx)(Ga,{dataKey:`label`,tickLine:!1,axisLine:!1,tickMargin:8,minTickGap:24}),(0,$.jsx)(Je,{content:(0,$.jsx)(tt,{})}),(0,$.jsx)(Gr,{dataKey:`value`,type:`monotone`,stroke:n,strokeWidth:2,dot:!1})]})})}export{oo as default};
@@ -0,0 +1 @@
1
+ for(var e={8:`Backspace`,9:`Tab`,10:`Enter`,12:`NumLock`,13:`Enter`,16:`Shift`,17:`Control`,18:`Alt`,20:`CapsLock`,27:`Escape`,32:` `,33:`PageUp`,34:`PageDown`,35:`End`,36:`Home`,37:`ArrowLeft`,38:`ArrowUp`,39:`ArrowRight`,40:`ArrowDown`,44:`PrintScreen`,45:`Insert`,46:`Delete`,59:`;`,61:`=`,91:`Meta`,92:`Meta`,106:`*`,107:`+`,108:`,`,109:`-`,110:`.`,111:`/`,144:`NumLock`,145:`ScrollLock`,160:`Shift`,161:`Shift`,162:`Control`,163:`Control`,164:`Alt`,165:`Alt`,173:`-`,186:`;`,187:`=`,188:`,`,189:`-`,190:`.`,191:`/`,192:"`",219:`[`,220:`\\`,221:`]`,222:`'`},t={48:`)`,49:`!`,50:`@`,51:`#`,52:`$`,53:`%`,54:`^`,55:`&`,56:`*`,57:`(`,59:`:`,61:`+`,173:`_`,186:`:`,187:`+`,188:`<`,189:`_`,190:`>`,191:`?`,192:`~`,219:`{`,220:`|`,221:`}`,222:`"`},n=typeof navigator<`u`&&/Mac/.test(navigator.platform),r=typeof navigator<`u`&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),i=0;i<10;i++)e[48+i]=e[96+i]=String(i);for(var i=1;i<=24;i++)e[i+111]=`F`+i;for(var i=65;i<=90;i++)e[i]=String.fromCharCode(i+32),t[i]=String.fromCharCode(i);for(var a in e)t.hasOwnProperty(a)||(t[a]=e[a]);function o(i){var a=!(n&&i.metaKey&&i.shiftKey&&!i.ctrlKey&&!i.altKey||r&&i.shiftKey&&i.key&&i.key.length==1||i.key==`Unidentified`)&&i.key||(i.shiftKey?t:e)[i.keyCode]||i.key||`Unidentified`;return a==`Esc`&&(a=`Escape`),a==`Del`&&(a=`Delete`),a==`Left`&&(a=`ArrowLeft`),a==`Up`&&(a=`ArrowUp`),a==`Right`&&(a=`ArrowRight`),a==`Down`&&(a=`ArrowDown`),a}export{o as n,t as r,e as t};
@@ -8,8 +8,10 @@
8
8
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
9
9
  <link href="https://fonts.googleapis.com/css2?family=Inter:ital,wght@0,300;0,400;0,500;0,600;0,700;1,300;1,400;1,500;1,600;1,700&display=swap" rel="stylesheet" />
10
10
  <title>dashboard</title>
11
- <script type="module" crossorigin src="/admin/assets/index-DjniT5Z9.js"></script>
12
- <link rel="stylesheet" crossorigin href="/admin/assets/index-B58kBLrh.css">
11
+ <script type="module" crossorigin src="/admin/assets/index-BZMSpYrl.js"></script>
12
+ <link rel="modulepreload" crossorigin href="/admin/assets/w3c-keyname-BOAvb0qz.js">
13
+ <link rel="modulepreload" crossorigin href="/admin/assets/dist-DHabpZqA.js">
14
+ <link rel="stylesheet" crossorigin href="/admin/assets/index-Dex2YZcC.css">
13
15
  </head>
14
16
  <body>
15
17
  <div id="root"></div>
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @module @beechcms/api/auth
3
+ * @description Authentication router sub-application providing login, refresh, and logout endpoints.
4
+ */
5
+ import { Hono } from 'hono';
6
+ import type { Env, Variables } from '../types';
7
+ /**
8
+ * Hono router for all authentication endpoints (`/auth/login`, `/auth/refresh`, `/auth/logout`).
9
+ */
10
+ export declare const authApp: Hono<{
11
+ Bindings: Env;
12
+ Variables: Variables;
13
+ }, import("hono/types").BlankSchema, "/">;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @module @beechcms/api/auth
3
+ * @description Public barrel export for the authentication vertical slice.
4
+ */
5
+ export { authApp } from './auth.app';
6
+ export { AUTH_ERRORS } from './constants';
package/dist/factory.d.ts CHANGED
@@ -2,11 +2,13 @@ import { Hono } from 'hono';
2
2
  import type { Seed, ContentRepository, IdempotencyRepository, BeechBucket, MediaRepository, SystemStatsRepository, BeechHooks, JobRegistry } from '@beechcms/core';
3
3
  import type { Env, Variables, AppEnv } from './types';
4
4
  export type { Env, Variables, AppEnv } from './types';
5
- import type { ISeedRepository, IAutomationRepository, IAutomationRunner } from '@beechcms/core';
5
+ import type { IRateLimiterRegistry } from './middleware/rate-limit.middleware';
6
+ import type { ISeedRepository, IAutomationRepository, IAutomationRunner, ITimeTrapTokenRepository, IRoleGuard } from '@beechcms/core';
6
7
  export interface BeechConfig {
7
8
  seeds: Seed[] | Record<string, Seed>;
8
9
  repository?: ContentRepository;
9
10
  idempotencyRepository?: IdempotencyRepository;
11
+ timeTrapTokenRepository?: ITimeTrapTokenRepository;
10
12
  bucket?: BeechBucket;
11
13
  mediaRepository?: MediaRepository;
12
14
  systemStatsRepository?: SystemStatsRepository;
@@ -35,6 +37,17 @@ export interface BeechConfig {
35
37
  * export. Handlers receive an engine-mediated JobContext — never raw D1.
36
38
  */
37
39
  jobs?: JobRegistry;
40
+ /**
41
+ * Optional rate limiter registry override. When provided, replaces the default
42
+ * in-memory TokenBucket registry for all requests. Useful in tests to inject
43
+ * a pre-exhausted limiter without relying on Cloudflare bindings.
44
+ */
45
+ rateLimiterRegistry?: IRateLimiterRegistry;
46
+ /**
47
+ * Optional role-guard override. Defaults to AllowAllRoleGuard, which grants
48
+ * every requested scope; inject a restrictive guard to exercise the denial path.
49
+ */
50
+ roleGuard?: IRoleGuard;
38
51
  }
39
52
  /**
40
53
  * Builds a fully configured Hono app. Seeds are hydrated from D1 at runtime via
@@ -0,0 +1,127 @@
1
+ import { PKCE_CHALLENGE_METHOD, type OAuthClientRecord, type OAuthScope } from '@beechcms/core';
2
+ import { type OAuthErrorCode } from './constants';
3
+ /**
4
+ * The raw authorization request parameters as received over the wire
5
+ * (e.g., from query search parameters or JSON body).
6
+ */
7
+ export interface RawAuthorizationRequest {
8
+ /** OAuth 2.0 response_type (e.g. 'code'). */
9
+ responseType?: string;
10
+ /** The registered client identifier. */
11
+ clientId?: string;
12
+ /** The redirection URI where the response will be sent. */
13
+ redirectUri?: string;
14
+ /** Space-delimited list of requested scopes. */
15
+ scope?: string;
16
+ /** Opaque value used by the client to maintain state between the request and callback. */
17
+ state?: string;
18
+ /** PKCE code challenge derived from the client verifier. */
19
+ codeChallenge?: string;
20
+ /** PKCE code challenge transformation method ('S256'). */
21
+ codeChallengeMethod?: string;
22
+ }
23
+ /**
24
+ * An authorization request that has successfully passed all syntactic,
25
+ * cryptographic (PKCE), and client-registered allowlist checks.
26
+ */
27
+ export interface ValidAuthorizationRequest {
28
+ /** The validated client identifier. */
29
+ clientId: string;
30
+ /** The verified redirection URI matching registered client URIs. */
31
+ redirectUri: string;
32
+ /** List of parsed and validated OAuth scopes. */
33
+ scopes: OAuthScope[];
34
+ /** The validated client state parameter. */
35
+ state: string;
36
+ /** The PKCE S256 code challenge string. */
37
+ codeChallenge: string;
38
+ /** The confirmed PKCE method, strictly 'S256'. */
39
+ codeChallengeMethod: typeof PKCE_CHALLENGE_METHOD;
40
+ }
41
+ /**
42
+ * Result of validating an authorization request.
43
+ *
44
+ * Distinguishes between:
45
+ * - Successful validation (`ok: true`).
46
+ * - `fatal` errors: MUST NOT redirect back to the client because the client identity
47
+ * or `redirect_uri` itself cannot be verified as trusted (RFC 6749 §4.1.2.1).
48
+ * - `redirectable` errors: The client and redirect target are trusted, so the failure
49
+ * can safely be returned to the client as query parameters on its `redirect_uri`.
50
+ */
51
+ export type AuthorizationRequestValidation = {
52
+ ok: true;
53
+ request: ValidAuthorizationRequest;
54
+ } | {
55
+ ok: false;
56
+ kind: 'fatal';
57
+ error: OAuthErrorCode;
58
+ description: string;
59
+ } | {
60
+ ok: false;
61
+ kind: 'redirectable';
62
+ error: OAuthErrorCode;
63
+ description: string;
64
+ redirectUri: string;
65
+ state: string;
66
+ };
67
+ /**
68
+ * Extracts raw authorization request parameters from URL search parameters.
69
+ *
70
+ * @param params - The URL search parameters from the incoming HTTP request.
71
+ * @returns The extracted raw authorization request properties.
72
+ */
73
+ export declare function readAuthorizationRequestFromQuery(params: URLSearchParams): RawAuthorizationRequest;
74
+ /**
75
+ * Matches a requested `redirect_uri` against the client's registered allowlist.
76
+ *
77
+ * Follows OAuth 2.1 §8.4.2 specifications:
78
+ * - Loopback URIs (`127.0.0.1`, `::1`, `[::1]`) are compared on `protocol`, `hostname`,
79
+ * and `pathname` only. A native client or CLI binds an ephemeral port at runtime,
80
+ * so the registered port is not knowable in advance.
81
+ * - URIs containing a fragment identifier (`#`) are strictly rejected (RFC 6749 §3.1.2).
82
+ * - Every other URI must match character-for-character.
83
+ *
84
+ * @param requested - The redirect_uri provided in the authorization request.
85
+ * @param registered - The list of redirect URIs pre-registered for the client.
86
+ * @returns True if the requested URI matches an allowed registered URI.
87
+ */
88
+ export declare function matchesRegisteredRedirectUri(requested: string, registered: readonly string[]): boolean;
89
+ /**
90
+ * Validates a raw authorization request against a resolved, active client record.
91
+ *
92
+ * Order of evaluation is load-bearing for security:
93
+ * 1. `redirect_uri` is checked first against `client.redirectUris`. If invalid, missing,
94
+ * or carrying a fragment, a `fatal` error is returned (no redirection permitted).
95
+ * 2. If the redirect target is trusted, remaining validation errors (`state`, `response_type`,
96
+ * PKCE `code_challenge_method`, `code_challenge`, scopes) are reported as `redirectable`
97
+ * back to the client's `redirect_uri`.
98
+ *
99
+ * @param raw - The unparsed request fields.
100
+ * @param client - The active client record resolved from persistence.
101
+ * @returns A tagged union describing success or whether the error is fatal vs redirectable.
102
+ */
103
+ export declare function validateAuthorizationRequest(raw: RawAuthorizationRequest, client: OAuthClientRecord): AuthorizationRequestValidation;
104
+ /**
105
+ * Builds the client-facing redirection URL carrying an OAuth error response.
106
+ *
107
+ * Preserves any pre-existing query parameters present on `redirectUri`
108
+ * and appends `error`, `error_description`, and `state`.
109
+ *
110
+ * @param redirectUri - The target client callback URL.
111
+ * @param error - The OAuth error code (e.g., 'invalid_scope').
112
+ * @param description - Human-readable explanation of the error.
113
+ * @param state - The client's state value to preserve CSRF protection.
114
+ * @returns Serialized URL string ready for redirection.
115
+ */
116
+ export declare function buildErrorRedirect(redirectUri: string, error: string, description: string, state: string): string;
117
+ /**
118
+ * Builds the client-facing redirection URL carrying a freshly issued authorization code.
119
+ *
120
+ * Preserves any pre-existing query parameters on `redirectUri` and appends `code` and `state`.
121
+ *
122
+ * @param redirectUri - The target client callback URL.
123
+ * @param code - The plaintext authorization code issued to the client.
124
+ * @param state - The client's state value.
125
+ * @returns Serialized URL string ready for redirection.
126
+ */
127
+ export declare function buildSuccessRedirect(redirectUri: string, code: string, state: string): string;
@@ -0,0 +1,97 @@
1
+ import type { Context } from 'hono';
2
+ import { type OAuthScope } from '@beechcms/core';
3
+ import type { Env, Variables } from '../../types';
4
+ /** Context type alias for OAuth route handlers. */
5
+ type OAuthContext = Context<{
6
+ Bindings: Env;
7
+ Variables: Variables;
8
+ }>;
9
+ /**
10
+ * Metadata payload returned to the dashboard SPA consent screen
11
+ * to render client information, requested scopes, and determine whether
12
+ * user interaction is required.
13
+ */
14
+ export interface AuthorizationRequestMetadata {
15
+ /** Basic display details of the requesting OAuth client. */
16
+ client: {
17
+ clientId: string;
18
+ name: string;
19
+ };
20
+ /** Every OAuth scope requested by the client in this flow. */
21
+ requestedScopes: OAuthScope[];
22
+ /** Scopes not yet covered by pre-existing active consent (only ones needing a prompt). */
23
+ newScopes: OAuthScope[];
24
+ /** False if an active consent already covers all requested scopes (incremental consent). */
25
+ consentRequired: boolean;
26
+ /** Validated client redirection target. */
27
+ redirectUri: string;
28
+ /** Opaque client CSRF state string. */
29
+ state: string;
30
+ }
31
+ /**
32
+ * Request body sent by the dashboard SPA consent screen when the user
33
+ * submits an authorization decision (approval or rejection).
34
+ */
35
+ export interface ConsentDecisionBody {
36
+ /** OAuth response_type ('code'). */
37
+ response_type: string;
38
+ /** The requesting client identifier. */
39
+ client_id: string;
40
+ /** The redirection target URL. */
41
+ redirect_uri: string;
42
+ /** Space-separated scope string. */
43
+ scope: string;
44
+ /** Client state string. */
45
+ state: string;
46
+ /** PKCE code challenge. */
47
+ code_challenge: string;
48
+ /** PKCE code challenge method ('S256'). */
49
+ code_challenge_method: string;
50
+ /** True if the resource owner approved the grant; false if denied. */
51
+ approved: boolean;
52
+ }
53
+ /**
54
+ * `GET /oauth/authorize`
55
+ *
56
+ * Unauthenticated browser entry point for the authorization code flow.
57
+ * Validates the client and redirect target. If valid, redirects the user's browser
58
+ * to the dashboard consent screen SPA (`/admin/oauth/consent`) preserving all query parameters.
59
+ *
60
+ * Error handling:
61
+ * - Fatal errors (missing client, invalid redirect_uri) return HTTP 400 without redirection.
62
+ * - Redirectable errors (invalid scope, response_type != code) redirect to the client's `redirect_uri`.
63
+ *
64
+ * @param context - Hono request context.
65
+ * @returns HTTP 302 redirect to consent screen or error response.
66
+ */
67
+ export declare function authorizeHandler(context: OAuthContext): Promise<Response>;
68
+ /**
69
+ * `GET /oauth/authorize/request`
70
+ *
71
+ * Authenticated endpoint called by the dashboard consent screen (admin JWT required).
72
+ * Resolves the request parameters, inspects pre-existing consents for this user and client,
73
+ * and returns metadata determining which scopes need explicit user confirmation.
74
+ *
75
+ * @param context - Hono request context with authenticated JWT claims in `jwtPayload`.
76
+ * @returns JSON response containing `AuthorizationRequestMetadata`.
77
+ */
78
+ export declare function authorizeRequestHandler(context: OAuthContext): Promise<Response>;
79
+ /**
80
+ * `POST /oauth/authorize/consent`
81
+ *
82
+ * Authenticated endpoint called when the user submits an approval/rejection decision.
83
+ *
84
+ * Workflow:
85
+ * 1. Re-validates the client and authorization parameters.
86
+ * 2. If denied by the user, returns a redirect to `redirect_uri` with `access_denied`.
87
+ * 3. If approved, delegates scope arbitration to `roleGuard.arbitrate(role, scopes)`
88
+ * to prevent granting scopes the user's role does not possess.
89
+ * 4. Records the granted consent in `oauthConsentRepository`.
90
+ * 5. Issues a high-entropy authorization code with 60s TTL, stores its SHA-256 hash in
91
+ * `oauthAuthorizationCodeRepository`, and returns the client callback URL with the code.
92
+ *
93
+ * @param context - Hono request context with authenticated JWT claims in `jwtPayload`.
94
+ * @returns JSON response containing `{ redirectTo: string }`.
95
+ */
96
+ export declare function consentHandler(context: OAuthContext): Promise<Response>;
97
+ export {};
@@ -0,0 +1,75 @@
1
+ import type { Context } from 'hono';
2
+ import type { OAuthScope } from '@beechcms/core';
3
+ import type { Env, Variables } from '../../types';
4
+ /** Context type alias for OAuth route handlers. */
5
+ type OAuthContext = Context<{
6
+ Bindings: Env;
7
+ Variables: Variables;
8
+ }>;
9
+ /**
10
+ * One row of the dashboard "Connected apps" list: a live consent, enriched with
11
+ * the client's display name and with token liveness.
12
+ */
13
+ export interface ConnectedAppSummary {
14
+ /** Stable identifier of the OAuth client (e.g. `beech-mcp-cli`). */
15
+ clientId: string;
16
+ /** Human-readable client name; falls back to `clientId` when the client row was disabled. */
17
+ name: string;
18
+ /** Scopes the resource owner has cumulatively granted to this client. */
19
+ scopes: OAuthScope[];
20
+ /** Unix seconds when consent was first granted. */
21
+ grantedAt: number;
22
+ /** Unix seconds of the most recent consent update (scope widening). */
23
+ updatedAt: number;
24
+ /** Creation time of the newest live token, or null when no token is currently valid. */
25
+ lastIssuedAt: number | null;
26
+ /** True when at least one unexpired, unrevoked token exists for this client. */
27
+ hasActiveTokens: boolean;
28
+ }
29
+ /**
30
+ * Successful response payload returned when revoking a connected application.
31
+ */
32
+ export interface RevokeConsentResponse {
33
+ /** Indicates that the authorization revocation succeeded. */
34
+ revoked: boolean;
35
+ /** Count of active access and refresh tokens revoked during cascade. */
36
+ tokensRevoked: number;
37
+ }
38
+ /**
39
+ * `GET /oauth/consents`
40
+ *
41
+ * Lists all OAuth 2.1 clients the authenticated resource owner has authorized.
42
+ *
43
+ * Protected by admin JWT authentication (`authMiddleware()` with default `acceptOAuth: false`).
44
+ * Mounted outside `/api` so an OAuth access token can never enumerate or tamper with the
45
+ * consent ledger that governs it.
46
+ *
47
+ * Each consent record is enriched with:
48
+ * 1. The client's display name from `IOAuthClientRepository.findActiveById` (falls back to `clientId`).
49
+ * 2. Token activity information from `IOAuthTokenRepository.listAuthorizedClientsForUser`.
50
+ *
51
+ * @param context - Hono request context with authenticated JWT claims in `jwtPayload`,
52
+ * clock accessor, and injected OAuth repositories.
53
+ * @returns HTTP 200 JSON response containing an array of {@link ConnectedAppSummary} items.
54
+ */
55
+ export declare function listConsentsHandler(context: OAuthContext): Promise<Response>;
56
+ /**
57
+ * `DELETE /oauth/consents/:clientId`
58
+ *
59
+ * Cascading revocation for an authorized client: revokes the consent row AND
60
+ * invalidates every active access and refresh token issued to that client for the user.
61
+ *
62
+ * Security & Data Invariants:
63
+ * - Protected by admin JWT authentication only (`authMiddleware()`).
64
+ * - Cascade behavior: tokens are revoked even when the consent row was already revoked,
65
+ * preventing orphaned active tokens.
66
+ * - Fails with HTTP 404 (`not_found`) if neither an active consent nor active tokens exist
67
+ * for the specified client.
68
+ *
69
+ * @param context - Hono request context containing the `clientId` route parameter
70
+ * and authenticated JWT claims in `jwtPayload`.
71
+ * @returns HTTP 200 JSON response with {@link RevokeConsentResponse} on success,
72
+ * or HTTP 404 JSON response if no active authorization exists for the client.
73
+ */
74
+ export declare function revokeConsentHandler(context: OAuthContext): Promise<Response>;
75
+ export {};
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Authorization code lifetime in seconds.
3
+ * @see {@link https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-12#section-4.1.2 | OAuth 2.1 §4.1.2} recommends <= 60s.
4
+ */
5
+ export declare const AUTHORIZATION_CODE_TTL_SECONDS = 60;
6
+ /**
7
+ * Access token lifetime in seconds (15 minutes).
8
+ * Matches the admin JWT convention used throughout BeechCMS.
9
+ */
10
+ export declare const ACCESS_TOKEN_TTL_SECONDS = 900;
11
+ /**
12
+ * Refresh token lifetime in seconds (30 days).
13
+ */
14
+ export declare const REFRESH_TOKEN_TTL_SECONDS: number;
15
+ /**
16
+ * Dashboard SPA route path that renders the OAuth user consent screen.
17
+ */
18
+ export declare const CONSENT_SCREEN_PATH = "/admin/oauth/consent";
19
+ /**
20
+ * Standard error codes defined by OAuth 2.0 / 2.1 and PKCE specifications.
21
+ * @see {@link https://datatracker.ietf.org/doc/html/rfc6749#section-4.1.2.1 | RFC 6749 §4.1.2.1} (Authorization Error Response)
22
+ * @see {@link https://datatracker.ietf.org/doc/html/rfc6749#section-5.2 | RFC 6749 §5.2} (Token Error Response)
23
+ * @see {@link https://datatracker.ietf.org/doc/html/rfc7636 | RFC 7636} (PKCE)
24
+ */
25
+ export declare const OAUTH_ERRORS: {
26
+ /** The request is missing a required parameter, includes an invalid parameter value, or is otherwise malformed. */
27
+ readonly INVALID_REQUEST: "invalid_request";
28
+ /** Client authentication failed (e.g., unknown client or client is disabled). */
29
+ readonly INVALID_CLIENT: "invalid_client";
30
+ /** The provided authorization grant (code, verifier) or refresh token is invalid, expired, revoked, or already consumed. */
31
+ readonly INVALID_GRANT: "invalid_grant";
32
+ /** The requested scope is invalid, unknown, or exceeds the scope granted/allowed for the client. */
33
+ readonly INVALID_SCOPE: "invalid_scope";
34
+ /** The authenticated client is not authorized to use this authorization grant type. */
35
+ readonly UNAUTHORIZED_CLIENT: "unauthorized_client";
36
+ /** The authorization server does not support obtaining an authorization code using this response type. */
37
+ readonly UNSUPPORTED_RESPONSE_TYPE: "unsupported_response_type";
38
+ /** The authorization grant type is not supported by the authorization server. */
39
+ readonly UNSUPPORTED_GRANT_TYPE: "unsupported_grant_type";
40
+ /** The resource owner or authorization server denied the request. */
41
+ readonly ACCESS_DENIED: "access_denied";
42
+ /** The authorization server encountered an unexpected condition that prevented it from fulfilling the request. */
43
+ readonly SERVER_ERROR: "server_error";
44
+ };
45
+ /**
46
+ * Union of supported OAuth error code literals.
47
+ */
48
+ export type OAuthErrorCode = (typeof OAUTH_ERRORS)[keyof typeof OAUTH_ERRORS];
@@ -0,0 +1,31 @@
1
+ import { Hono } from 'hono';
2
+ import type { Env, Variables } from '../../types';
3
+ /**
4
+ * OAuth 2.1 Authorization Server feature router.
5
+ *
6
+ * Implements authorization code flow with PKCE (RFC 7636), refresh token rotation,
7
+ * and token revocation (RFC 7009).
8
+ *
9
+ * Route segmentation and authentication boundaries:
10
+ * 1. **Public browser entry point**:
11
+ * - `GET /oauth/authorize` -> Unauthenticated. Validates client and redirect_uri,
12
+ * then redirects the user to the dashboard SPA consent screen.
13
+ * 2. **Authenticated consent APIs**:
14
+ * - `GET /oauth/authorize/request` -> Protected by `authMiddleware()` (admin JWT).
15
+ * Returns metadata for rendering the consent UI.
16
+ * - `POST /oauth/authorize/consent` -> Protected by `authMiddleware()` (admin JWT).
17
+ * Validates role via `roleGuard`, records consent, and issues an authorization code.
18
+ * 3. **Client-facing token endpoints**:
19
+ * - `POST /oauth/token` -> Public endpoint authenticated by grant parameters
20
+ * (code + code_verifier, or refresh_token).
21
+ * - `POST /oauth/revoke` -> Public RFC 7009 endpoint for token invalidation.
22
+ * 4. **Connected-apps management**:
23
+ * - `GET /oauth/consents` -> Protected by `authMiddleware()` (admin JWT).
24
+ * Lists the OAuth clients the resource owner has authorized.
25
+ * - `DELETE /oauth/consents/:clientId` -> Protected by `authMiddleware()` (admin JWT).
26
+ * Cascade-revokes the consent and every live token for that client.
27
+ */
28
+ export declare const oauthApp: Hono<{
29
+ Bindings: Env;
30
+ Variables: Variables;
31
+ }, import("hono/types").BlankSchema, "/">;