ghost 6.18.1 → 6.18.2
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.
- package/components/tryghost-i18n-6.18.2.tgz +0 -0
- package/components/{tryghost-parse-email-address-6.18.1.tgz → tryghost-parse-email-address-6.18.2.tgz} +0 -0
- package/content/themes/source/package.json +1 -1
- package/core/built/admin/assets/{PolarAngleAxis-Dod0DwfL.js → PolarAngleAxis-DALH8FDm.js} +1 -1
- package/core/built/admin/assets/{_baseAssignValue-DnkbkowM.js → _baseAssignValue-D_UsvJRN.js} +1 -1
- package/core/built/admin/assets/{a-large-small-C5mgFBRg.js → a-large-small-DVyx4GMu.js} +1 -1
- package/core/built/admin/assets/admin-x-settings/admin-x-settings.js +2 -2
- package/core/built/admin/assets/admin-x-settings/{code-editor-view-BWi3-ftq.mjs → code-editor-view-DBrulgE8.mjs} +12 -12
- package/core/built/admin/assets/admin-x-settings/{index-B3PtvbUw.mjs → index-CsGHbqSU.mjs} +2 -2
- package/core/built/admin/assets/admin-x-settings/{index-Did70N9h.mjs → index-Cypgljb3.mjs} +2 -2
- package/core/built/admin/assets/admin-x-settings/{index-JaMlaX9G.mjs → index-DgGwb1L-.mjs} +1390 -1381
- package/core/built/admin/assets/admin-x-settings/{modals-Bwrf9ptQ.mjs → modals-rdo7i0D3.mjs} +9320 -8655
- package/core/built/admin/assets/{at-sign-Bz-SU-S_.js → at-sign-CGNkBrZS.js} +1 -1
- package/core/built/admin/assets/{audience-DmVdEmIe.js → audience-CJHVR7kD.js} +1 -1
- package/core/built/admin/assets/{avatar-flipboard-C7sxDVEM.js → avatar-flipboard-jqr9Aapd.js} +1 -1
- package/core/built/admin/assets/{bluesky-sharing-DJniSF6N.js → bluesky-sharing-C2749SVt.js} +1 -1
- package/core/built/admin/assets/{chart-mYz3IJwm.js → chart-BAQCVPCH.js} +1 -1
- package/core/built/admin/assets/{chunk.524.9d300778a63b42b0de62.js → chunk.524.428356d01feabbc7b932.js} +7 -7
- package/core/built/admin/assets/{chunk.582.2e363cd976d9bba998b9.js → chunk.582.b8b41ba720f49d724992.js} +9 -9
- package/core/built/admin/assets/{code-editor-view-BIQWFJ01.js → code-editor-view-YNhJ1w71.js} +1 -1
- package/core/built/admin/assets/{comments-B_-hdjc6.js → comments-CPd_iCc3.js} +1 -1
- package/core/built/admin/assets/{copy-Bpq3uhnh.js → copy-CNsHZEFR.js} +1 -1
- package/core/built/admin/assets/{data-list-BYNMbRIq.js → data-list-Dn5MkmyD.js} +1 -1
- package/core/built/admin/assets/{deleted-feed-item-B_AwUKZy.js → deleted-feed-item-Dmm_clMl.js} +1 -1
- package/core/built/admin/assets/{edit-profile-DZo2ZcOu.js → edit-profile-BLSdtROQ.js} +1 -1
- package/core/built/admin/assets/{empty-indicator-Bn5wG9-T.js → empty-indicator-C2Z0dddU.js} +1 -1
- package/core/built/admin/assets/{en-D4zIrMLN.js → en-DuTkaMAI.js} +1 -1
- package/core/built/admin/assets/{feed-Bgq4RarU.js → feed-B4Xp4C2J.js} +1 -1
- package/core/built/admin/assets/{filters-CpVwu1Gk.js → filters-gnOx5Z45.js} +1 -1
- package/core/built/admin/assets/{gh-chart-Br7NXn_b.js → gh-chart-B2aWYkGg.js} +1 -1
- package/core/built/admin/assets/{ghost-98a3c5fd6235ebd344594f491cb6d17b.js → ghost-29f8f3c80e41126ba5e3c52ad5727e8a.js} +176 -176
- package/core/built/admin/assets/ghost-transistor-BXCFhTPG.png +0 -0
- package/core/built/admin/assets/{growth-CiPDnWxJ.js → growth-BysawIWe.js} +1 -1
- package/core/built/admin/assets/{hash-Bc1e38oH.js → hash-j3sh-UI3.js} +1 -1
- package/core/built/admin/assets/{inbox-BcZNBNhk.js → inbox-1cUdr8Mm.js} +1 -1
- package/core/built/admin/assets/index-B2yksBz4.js +13 -0
- package/core/built/admin/assets/{index-CMTzNTew.js → index-B8G0f0hb.js} +3 -3
- package/core/built/admin/assets/{index-DU3bv9jz.js → index-BVoBTlp_.js} +1 -1
- package/core/built/admin/assets/{index-ETsoQLbU.js → index-BgrwCpgw.js} +1 -1
- package/core/built/admin/assets/{index-Bm5ZeLtt.js → index-BhY_SbGB.js} +1 -1
- package/core/built/admin/assets/index-CkAUXgAi.js +1 -0
- package/core/built/admin/assets/index-Cl_EPbQ2.js +1 -0
- package/core/built/admin/assets/{index-B_7QsC5T.js → index-D8CXbJm4.js} +1 -1
- package/core/built/admin/assets/index-DGBK5k9H.js +1 -0
- package/core/built/admin/assets/{index-D212VvOz.js → index-DKAlEWM4.js} +1 -1
- package/core/built/admin/assets/index-D_sGUCda.css +1 -0
- package/core/built/admin/assets/{index-BFEx_ouC.js → index-DarAAzVH.js} +1 -1
- package/core/built/admin/assets/{index-Brg4tecQ.js → index-Dz8eTtOq.js} +1 -1
- package/core/built/admin/assets/{index-Cn32t_gv.js → index-I9n711UW.js} +1 -1
- package/core/built/admin/assets/{index-CsidX7Si.js → index-WjY3mGep.js} +2 -2
- package/core/built/admin/assets/{index-Dv13wKfX.js → index-mhojl7aD.js} +1 -1
- package/core/built/admin/assets/{koenig-lexical-DZUWzN0P.js → koenig-lexical-coiS9dIC.js} +1 -1
- package/core/built/admin/assets/{kpi-card-DENsK2xK.js → kpi-card-BEFHo2gr.js} +1 -1
- package/core/built/admin/assets/{kpis-CDrs2iS1.js → kpis-D-gz-lUk.js} +1 -1
- package/core/built/admin/assets/{label-BznQtEEo.js → label-BvlHzzcJ.js} +1 -1
- package/core/built/admin/assets/{links-lpAC3T1p.js → links-tdJvBrsT.js} +1 -1
- package/core/built/admin/assets/list-filter-DPE4Xj2T.js +6 -0
- package/core/built/admin/assets/{lucide-react-CBigk-fq.js → lucide-react-ClQ3Iy7l.js} +1448 -1453
- package/core/built/admin/assets/{main-layout-_SYQRjIl.js → main-layout-DY96wK-_.js} +1 -1
- package/core/built/admin/assets/{message-square-text-cV8O_qKq.js → message-square-text-Dd1XS5-H.js} +1 -1
- package/core/built/admin/assets/{minus-NvnQTlW7.js → minus-CyEc3BE5.js} +1 -1
- package/core/built/admin/assets/modals-C06GcVIm.js +77 -0
- package/core/built/admin/assets/moderation-B0fdmlig.js +1 -0
- package/core/built/admin/assets/newsletter-Byg3ARa5.js +1 -0
- package/core/built/admin/assets/{newsletters-BexdXUhn.js → newsletters-DbH39vgA.js} +1 -1
- package/core/built/admin/assets/{note-DuaUGOeZ.js → note-Cwy-rIAF.js} +1 -1
- package/core/built/admin/assets/overview-CVMLGrVt.js +1 -0
- package/core/built/admin/assets/{pagemenu-CZyroidv.js → pagemenu-CkzsZrHC.js} +1 -1
- package/core/built/admin/assets/{post-analytics-DLK2SOSQ.js → post-analytics-aA-nG9Fq.js} +1 -1
- package/core/built/admin/assets/{post-analytics-context-CF7C67-0.js → post-analytics-context-BLkup0Xh.js} +1 -1
- package/core/built/admin/assets/{post-analytics-header-7GtJCx0W.js → post-analytics-header-D9srAPT5.js} +1 -1
- package/core/built/admin/assets/{post-share-modal-D8R7DUZP.js → post-share-modal-CkvJtrRw.js} +1 -1
- package/core/built/admin/assets/{posts-CL9UDYoW.js → posts-DDkuYoN7.js} +1 -1
- package/core/built/admin/assets/{repeat-DgH39UKE.js → repeat-B-SL0yPM.js} +1 -1
- package/core/built/admin/assets/{reply-DAaNxiy8.js → reply-BdCPoUQ9.js} +1 -1
- package/core/built/admin/assets/{select-Cor2wFXT.js → select-C7aNW8QS.js} +1 -1
- package/core/built/admin/assets/{settings-xRx917Gj.js → settings-Bzy1GNfD.js} +1 -1
- package/core/built/admin/assets/{settings-BeumESEN.js → settings-D-dhma2e.js} +23 -23
- package/core/built/admin/assets/{sort-button-BNW3i4Lb.js → sort-button-Dv8vjh13.js} +1 -1
- package/core/built/admin/assets/{source-icon-DvDuzw73.js → source-icon-DTz4isLK.js} +1 -1
- package/core/built/admin/assets/{sprout-C3cc0c-K.js → sprout-BwLQTzMf.js} +1 -1
- package/core/built/admin/assets/{square-tZp0_n7e.js → square-YF1YE9ex.js} +1 -1
- package/core/built/admin/assets/{stats-2Jelnn-Q.js → stats-C5ad0fgQ.js} +1 -1
- package/core/built/admin/assets/{stats-view-CESy8ELH.js → stats-view-BvkxPYNX.js} +1 -1
- package/core/built/admin/assets/{step-1-DrqdolAh.js → step-1-D7_s-D99.js} +1 -1
- package/core/built/admin/assets/{step-2-DmEpKck5.js → step-2-B94Yf7FF.js} +1 -1
- package/core/built/admin/assets/{step-3-Bus-0o0n.js → step-3-DswXYYf4.js} +1 -1
- package/core/built/admin/assets/{table-BQUcKHfm.js → table-D30IXfUP.js} +1 -1
- package/core/built/admin/assets/{tabs-BmdL0X4U.js → tabs-CjNdfW0y.js} +1 -1
- package/core/built/admin/assets/{tags-EchqlZUJ.js → tags-B0ux9_dT.js} +1 -1
- package/core/built/admin/assets/{tags-CLxXZlOO.js → tags-PGeGAafJ.js} +1 -1
- package/core/built/admin/assets/{tiers-nCGyTly9.js → tiers-BaXK0JoI.js} +1 -1
- package/core/built/admin/assets/{toggle-group-CM5uf7J1.js → toggle-group-DdY8HF3Y.js} +1 -1
- package/core/built/admin/assets/{topic-filter-LTRvZ8aU.js → topic-filter-Boh22uGD.js} +1 -1
- package/core/built/admin/assets/{trash-u5BxolyH.js → trash-D7ZWrnDq.js} +1 -1
- package/core/built/admin/assets/{url-helpers-D41fEt51.js → url-helpers-mt6MBIi0.js} +1 -1
- package/core/built/admin/assets/{use-growth-stats-BJ0O9ewi.js → use-growth-stats-Bg0nE0WG.js} +1 -1
- package/core/built/admin/assets/{use-infinite-virtual-scroll-APZWciOk.js → use-infinite-virtual-scroll-DoeI5IY-.js} +1 -1
- package/core/built/admin/assets/{use-simple-pagination-DVRHeaAR.js → use-simple-pagination-BJzBULR3.js} +1 -1
- package/core/built/admin/assets/{user-round-check-B6j98D6d.js → user-round-check-BLc3L-ei.js} +1 -1
- package/core/built/admin/assets/{wallet-cards-KmOh29LP.js → wallet-cards-xX4QZik7.js} +1 -1
- package/core/built/admin/assets/web-DQ2qBymm.js +1 -0
- package/core/built/admin/index.html +5 -5
- package/core/server/lib/image/cached-image-size-from-url.js +37 -25
- package/core/server/lib/lexical.js +1 -0
- package/core/server/lib/mobiledoc.js +1 -0
- package/core/server/services/email-service/email-renderer.js +6 -2
- package/core/server/services/email-service/email-service-wrapper.js +2 -2
- package/core/server/services/koenig/node-renderers/call-to-action-renderer.js +2 -2
- package/core/server/services/koenig/node-renderers/gallery-renderer.js +3 -3
- package/core/server/services/koenig/node-renderers/image-renderer.js +3 -3
- package/core/server/services/koenig/render-utils/is-content-image.js +18 -0
- package/core/server/services/koenig/render-utils/srcset-attribute.js +4 -4
- package/core/server/services/members/members-api/controllers/router-controller.js +21 -36
- package/core/server/services/members/members-api/repositories/member-repository.js +8 -1
- package/core/server/services/offers/offer-bookshelf-repository.js +3 -3
- package/core/shared/config/defaults.json +1 -1
- package/core/shared/labs.js +2 -1
- package/package.json +5 -5
- package/components/tryghost-i18n-6.18.1.tgz +0 -0
- package/core/built/admin/assets/index-BBrewxpF.css +0 -1
- package/core/built/admin/assets/index-BpcL7RmI.js +0 -13
- package/core/built/admin/assets/index-CTfJflJ2.js +0 -1
- package/core/built/admin/assets/index-D67LJ_H4.js +0 -1
- package/core/built/admin/assets/index-ZYDRMgcT.js +0 -1
- package/core/built/admin/assets/modals-XRSkribf.js +0 -77
- package/core/built/admin/assets/moderation-BQp1GEWG.js +0 -1
- package/core/built/admin/assets/newsletter-foM6KNNV.js +0 -1
- package/core/built/admin/assets/overview-DgKBNqyc.js +0 -1
- package/core/built/admin/assets/web-Cclotbnz.js +0 -1
- package/core/server/services/koenig/render-utils/is-local-content-image.js +0 -9
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{e as I,aH as ye,r as P,aP as De,j as e,B as Ce,bV as Te,bW as je,bG as Ke,aj as T,cA as J,aQ as rt,cB as $,bH as nt,ap as it,bI as ot,bJ as de,cU as z,aR as lt,af as se,aX as ct,ag as W,S as Ge,cz as dt,by as ut,bz as mt,bA as pt,bB as ht,bC as ft,bD as xt,ah as B,bR as Oe}from"./index-CMTzNTew.js";import{s as oe,g as U,d as bt,S as gt,a as vt,D as jt,b as yt}from"./stats-view-CESy8ELH.js";import{E as ce}from"./empty-indicator-Bn5wG9-T.js";import{A as St,a as At}from"./wallet-cards-KmOh29LP.js";import{G as wt,C as Nt,X as Dt,Y as Ct}from"./gh-chart-Br7NXn_b.js";import{T as Ve,a as $e,K as ue,d as Y,e as Tt,b as me}from"./tabs-BmdL0X4U.js";import{g as _t}from"./audience-DmVdEmIe.js";import{S as te,B as kt}from"./sort-button-BNW3i4Lb.js";import{S as Pt,C as Q,g as Ot,c as Mt,b as Rt}from"./url-helpers-D41fEt51.js";import{e as le,c as K,f as F,g as Et,a as Ye,b as ze,d as H}from"./table-BQUcKHfm.js";import{g as Se}from"./currency-fEUUCkj0.js";import{g as Bt}from"./source-utils-B1S3ZHA2.js";import{a as It,b as Ft,u as Lt,k as Kt}from"./stats-2Jelnn-Q.js";import{u as Gt,a as Vt}from"./tiers-nCGyTly9.js";import{C as be,a as _e,b as ke,f as Pe,c as ge,j as $t}from"./pagemenu-CZyroidv.js";import{h as ne,F as Yt,T as zt,b as he,r as Ae,H as ae,L as ie,o as X,c as Ht,S as Ut,A as Wt,I as qt,i as Me,d as Qt,J as Z,u as He,e as Xt,K as Jt,G as Zt,m as fe,l as ea,n as ta,M as aa,N as pe,O as Re,g as sa,s as ra,C as Ue,a as We,v as na,B as Ee}from"./chart-mYz3IJwm.js";import{S as qe,a as Qe,b as Xe,c as Je,f as we}from"./select-Cor2wFXT.js";import{P as ia,a as oa}from"./PolarAngleAxis-Dod0DwfL.js";import{n as la,o as ca,l as da}from"./lucide-react-CBigk-fq.js";import{u as ua}from"./use-growth-stats-BJ0O9ewi.js";import"./message-square-text-cV8O_qKq.js";import"./sprout-C3cc0c-K.js";import"./index-D212VvOz.js";import"./_baseAssignValue-DnkbkowM.js";import"./a-large-small-C5mgFBRg.js";import"./at-sign-Bz-SU-S_.js";import"./copy-Bpq3uhnh.js";import"./hash-Bc1e38oH.js";import"./inbox-BcZNBNhk.js";import"./minus-NvnQTlW7.js";import"./tags-CLxXZlOO.js";import"./square-tZp0_n7e.js";import"./user-round-check-B6j98D6d.js";import"./repeat-DgH39UKE.js";import"./reply-DAaNxiy8.js";import"./trash-u5BxolyH.js";var xe;function re(s){"@babel/helpers - typeof";return re=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(a){return typeof a}:function(a){return a&&typeof Symbol=="function"&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},re(s)}function ee(){return ee=Object.assign?Object.assign.bind():function(s){for(var a=1;a<arguments.length;a++){var n=arguments[a];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(s[t]=n[t])}return s},ee.apply(this,arguments)}function Be(s,a){var n=Object.keys(s);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(s);a&&(t=t.filter(function(r){return Object.getOwnPropertyDescriptor(s,r).enumerable})),n.push.apply(n,t)}return n}function R(s){for(var a=1;a<arguments.length;a++){var n=arguments[a]!=null?arguments[a]:{};a%2?Be(Object(n),!0).forEach(function(t){L(s,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(n)):Be(Object(n)).forEach(function(t){Object.defineProperty(s,t,Object.getOwnPropertyDescriptor(n,t))})}return s}function ma(s,a){if(!(s instanceof a))throw new TypeError("Cannot call a class as a function")}function Ie(s,a){for(var n=0;n<a.length;n++){var t=a[n];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(s,et(t.key),t)}}function pa(s,a,n){return a&&Ie(s.prototype,a),n&&Ie(s,n),Object.defineProperty(s,"prototype",{writable:!1}),s}function ha(s,a,n){return a=ve(a),fa(s,Ze()?Reflect.construct(a,n||[],ve(s).constructor):a.apply(s,n))}function fa(s,a){if(a&&(re(a)==="object"||typeof a=="function"))return a;if(a!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return xa(s)}function xa(s){if(s===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s}function Ze(){try{var s=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Ze=function(){return!!s})()}function ve(s){return ve=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},ve(s)}function ba(s,a){if(typeof a!="function"&&a!==null)throw new TypeError("Super expression must either be null or a function");s.prototype=Object.create(a&&a.prototype,{constructor:{value:s,writable:!0,configurable:!0}}),Object.defineProperty(s,"prototype",{writable:!1}),a&&Ne(s,a)}function Ne(s,a){return Ne=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,r){return t.__proto__=r,t},Ne(s,a)}function L(s,a,n){return a=et(a),a in s?Object.defineProperty(s,a,{value:n,enumerable:!0,configurable:!0,writable:!0}):s[a]=n,s}function et(s){var a=ga(s,"string");return re(a)=="symbol"?a:a+""}function ga(s,a){if(re(s)!="object"||!s)return s;var n=s[Symbol.toPrimitive];if(n!==void 0){var t=n.call(s,a);if(re(t)!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(s)}var G=(function(s){function a(n){var t;return ma(this,a),t=ha(this,a,[n]),L(t,"pieRef",null),L(t,"sectorRefs",[]),L(t,"id",Jt("recharts-pie-")),L(t,"handleAnimationEnd",function(){var r=t.props.onAnimationEnd;t.setState({isAnimationFinished:!0}),ne(r)&&r()}),L(t,"handleAnimationStart",function(){var r=t.props.onAnimationStart;t.setState({isAnimationFinished:!1}),ne(r)&&r()}),t.state={isAnimationFinished:!n.isAnimationActive,prevIsAnimationActive:n.isAnimationActive,prevAnimationId:n.animationId,sectorToFocus:0},t}return ba(a,s),pa(a,[{key:"isActiveIndex",value:function(t){var r=this.props.activeIndex;return Array.isArray(r)?r.indexOf(t)!==-1:t===r}},{key:"hasActiveIndex",value:function(){var t=this.props.activeIndex;return Array.isArray(t)?t.length!==0:t||t===0}},{key:"renderLabels",value:function(t){var r=this.props.isAnimationActive;if(r&&!this.state.isAnimationFinished)return null;var l=this.props,i=l.label,f=l.labelLine,g=l.dataKey,c=l.valueKey,o=he(this.props,!1),j=he(i,!1),A=he(f,!1),x=i&&i.offsetRadius||20,w=t.map(function(m,b){var N=(m.startAngle+m.endAngle)/2,p=Ae(m.cx,m.cy,m.outerRadius+x,N),h=R(R(R(R({},o),m),{},{stroke:"none"},j),{},{index:b,textAnchor:a.getTextAnchor(p.x,m.cx)},p),u=R(R(R(R({},o),m),{},{fill:"none",stroke:m.fill},A),{},{index:b,points:[Ae(m.cx,m.cy,m.outerRadius,N),p]}),v=g;return ae(g)&&ae(c)?v="value":ae(g)&&(v=c),I.createElement(ie,{key:"label-".concat(m.startAngle,"-").concat(m.endAngle,"-").concat(m.midAngle,"-").concat(b)},f&&a.renderLabelLineItem(f,u,"line"),a.renderLabelItem(i,h,X(m,v)))});return I.createElement(ie,{className:"recharts-pie-labels"},w)}},{key:"renderSectorsStatically",value:function(t){var r=this,l=this.props,i=l.activeShape,f=l.blendStroke,g=l.inactiveShape;return t.map(function(c,o){if(c?.startAngle===0&&c?.endAngle===0&&t.length!==1)return null;var j=r.isActiveIndex(o),A=g&&r.hasActiveIndex()?g:null,x=j?i:A,w=R(R({},c),{},{stroke:f?c.fill:c.stroke,tabIndex:-1});return I.createElement(ie,ee({ref:function(b){b&&!r.sectorRefs.includes(b)&&r.sectorRefs.push(b)},tabIndex:-1,className:"recharts-pie-sector"},Ht(r.props,c,o),{key:"sector-".concat(c?.startAngle,"-").concat(c?.endAngle,"-").concat(c.midAngle,"-").concat(o)}),I.createElement(Ut,ee({option:x,isActive:j,shapeType:"sector"},w)))})}},{key:"renderSectorsWithAnimation",value:function(){var t=this,r=this.props,l=r.sectors,i=r.isAnimationActive,f=r.animationBegin,g=r.animationDuration,c=r.animationEasing,o=r.animationId,j=this.state,A=j.prevSectors,x=j.prevIsAnimationActive;return I.createElement(Wt,{begin:f,duration:g,isActive:i,easing:c,from:{t:0},to:{t:1},key:"pie-".concat(o,"-").concat(x),onAnimationStart:this.handleAnimationStart,onAnimationEnd:this.handleAnimationEnd},function(w){var m=w.t,b=[],N=l&&l[0],p=N.startAngle;return l.forEach(function(h,u){var v=A&&A[u],C=u>0?qt(h,"paddingAngle",0):0;if(v){var S=Me(v.endAngle-v.startAngle,h.endAngle-h.startAngle),d=R(R({},h),{},{startAngle:p+C,endAngle:p+S(m)+C});b.push(d),p=d.endAngle}else{var k=h.endAngle,y=h.startAngle,D=Me(0,k-y),O=D(m),M=R(R({},h),{},{startAngle:p+C,endAngle:p+O+C});b.push(M),p=M.endAngle}}),I.createElement(ie,null,t.renderSectorsStatically(b))})}},{key:"attachKeyboardHandlers",value:function(t){var r=this;t.onkeydown=function(l){if(!l.altKey)switch(l.key){case"ArrowLeft":{var i=++r.state.sectorToFocus%r.sectorRefs.length;r.sectorRefs[i].focus(),r.setState({sectorToFocus:i});break}case"ArrowRight":{var f=--r.state.sectorToFocus<0?r.sectorRefs.length-1:r.state.sectorToFocus%r.sectorRefs.length;r.sectorRefs[f].focus(),r.setState({sectorToFocus:f});break}case"Escape":{r.sectorRefs[r.state.sectorToFocus].blur(),r.setState({sectorToFocus:0});break}}}}},{key:"renderSectors",value:function(){var t=this.props,r=t.sectors,l=t.isAnimationActive,i=this.state.prevSectors;return l&&r&&r.length&&(!i||!Qt(i,r))?this.renderSectorsWithAnimation():this.renderSectorsStatically(r)}},{key:"componentDidMount",value:function(){this.pieRef&&this.attachKeyboardHandlers(this.pieRef)}},{key:"render",value:function(){var t=this,r=this.props,l=r.hide,i=r.sectors,f=r.className,g=r.label,c=r.cx,o=r.cy,j=r.innerRadius,A=r.outerRadius,x=r.isAnimationActive,w=this.state.isAnimationFinished;if(l||!i||!i.length||!Z(c)||!Z(o)||!Z(j)||!Z(A))return null;var m=ye("recharts-pie",f);return I.createElement(ie,{tabIndex:this.props.rootTabIndex,className:m,ref:function(N){t.pieRef=N}},this.renderSectors(),g&&this.renderLabels(i),He.renderCallByParent(this.props,null,!1),(!x||w)&&Xt.renderCallByParent(this.props,i,!1))}}],[{key:"getDerivedStateFromProps",value:function(t,r){return r.prevIsAnimationActive!==t.isAnimationActive?{prevIsAnimationActive:t.isAnimationActive,prevAnimationId:t.animationId,curSectors:t.sectors,prevSectors:[],isAnimationFinished:!0}:t.isAnimationActive&&t.animationId!==r.prevAnimationId?{prevAnimationId:t.animationId,curSectors:t.sectors,prevSectors:r.curSectors,isAnimationFinished:!0}:t.sectors!==r.curSectors?{curSectors:t.sectors,isAnimationFinished:!0}:null}},{key:"getTextAnchor",value:function(t,r){return t>r?"start":t<r?"end":"middle"}},{key:"renderLabelLineItem",value:function(t,r,l){if(I.isValidElement(t))return I.cloneElement(t,r);if(ne(t))return t(r);var i=ye("recharts-pie-label-line",typeof t!="boolean"?t.className:"");return I.createElement(Yt,ee({},r,{key:l,type:"linear",className:i}))}},{key:"renderLabelItem",value:function(t,r,l){if(I.isValidElement(t))return I.cloneElement(t,r);var i=l;if(ne(t)&&(i=t(r),I.isValidElement(i)))return i;var f=ye("recharts-pie-label-text",typeof t!="boolean"&&!ne(t)?t.className:"");return I.createElement(zt,ee({},r,{alignmentBaseline:"middle",className:f}),i)}}])})(P.PureComponent);xe=G;L(G,"displayName","Pie");L(G,"defaultProps",{stroke:"#fff",fill:"#808080",legendType:"rect",cx:"50%",cy:"50%",startAngle:0,endAngle:360,innerRadius:0,outerRadius:"80%",paddingAngle:0,labelLine:!0,hide:!1,minAngle:0,isAnimationActive:!Zt.isSsr,animationBegin:400,animationDuration:1500,animationEasing:"ease",nameKey:"name",blendStroke:!1,rootTabIndex:0});L(G,"parseDeltaAngle",function(s,a){var n=fe(a-s),t=Math.min(Math.abs(a-s),360);return n*t});L(G,"getRealPieData",function(s){var a=s.data,n=s.children,t=he(s,!1),r=ea(n,ta);return a&&a.length?a.map(function(l,i){return R(R(R({payload:l},t),l),r&&r[i]&&r[i].props)}):r&&r.length?r.map(function(l){return R(R({},t),l.props)}):[]});L(G,"parseCoordinateOfPie",function(s,a){var n=a.top,t=a.left,r=a.width,l=a.height,i=aa(r,l),f=t+pe(s.cx,r,r/2),g=n+pe(s.cy,l,l/2),c=pe(s.innerRadius,i,0),o=pe(s.outerRadius,i,i*.8),j=s.maxRadius||Math.sqrt(r*r+l*l)/2;return{cx:f,cy:g,innerRadius:c,outerRadius:o,maxRadius:j}});L(G,"getComposedData",function(s){var a=s.item,n=s.offset,t=a.type.defaultProps!==void 0?R(R({},a.type.defaultProps),a.props):a.props,r=xe.getRealPieData(t);if(!r||!r.length)return null;var l=t.cornerRadius,i=t.startAngle,f=t.endAngle,g=t.paddingAngle,c=t.dataKey,o=t.nameKey,j=t.valueKey,A=t.tooltipType,x=Math.abs(t.minAngle),w=xe.parseCoordinateOfPie(t,n),m=xe.parseDeltaAngle(i,f),b=Math.abs(m),N=c;ae(c)&&ae(j)?(Re(!1,`Use "dataKey" to specify the value of pie,
|
|
1
|
+
import{e as I,aH as ye,r as P,aP as De,j as e,B as Ce,bV as Te,bW as je,bG as Ke,aj as T,cA as J,aQ as rt,cB as $,bH as nt,ap as it,bI as ot,bJ as de,cU as z,aR as lt,af as se,aX as ct,ag as W,S as Ge,cz as dt,by as ut,bz as mt,bA as pt,bB as ht,bC as ft,bD as xt,ah as B,bR as Oe}from"./index-B8G0f0hb.js";import{s as oe,g as U,d as bt,S as gt,a as vt,D as jt,b as yt}from"./stats-view-BvkxPYNX.js";import{E as ce}from"./empty-indicator-C2Z0dddU.js";import{A as St,a as At}from"./wallet-cards-xX4QZik7.js";import{G as wt,C as Nt,X as Dt,Y as Ct}from"./gh-chart-B2aWYkGg.js";import{T as Ve,a as $e,K as ue,d as Y,e as Tt,b as me}from"./tabs-CjNdfW0y.js";import{g as _t}from"./audience-CJHVR7kD.js";import{S as te,B as kt}from"./sort-button-Dv8vjh13.js";import{S as Pt,C as Q,g as Ot,c as Mt,b as Rt}from"./url-helpers-mt6MBIi0.js";import{e as le,c as K,f as F,g as Et,a as Ye,b as ze,d as H}from"./table-D30IXfUP.js";import{g as Se}from"./currency-fEUUCkj0.js";import{g as Bt}from"./source-utils-B1S3ZHA2.js";import{a as It,b as Ft,u as Lt,k as Kt}from"./stats-C5ad0fgQ.js";import{u as Gt,a as Vt}from"./tiers-BaXK0JoI.js";import{C as be,a as _e,b as ke,f as Pe,c as ge,j as $t}from"./pagemenu-CkzsZrHC.js";import{h as ne,F as Yt,T as zt,b as he,r as Ae,H as ae,L as ie,o as X,c as Ht,S as Ut,A as Wt,I as qt,i as Me,d as Qt,J as Z,u as He,e as Xt,K as Jt,G as Zt,m as fe,l as ea,n as ta,M as aa,N as pe,O as Re,g as sa,s as ra,C as Ue,a as We,v as na,B as Ee}from"./chart-BAQCVPCH.js";import{S as qe,a as Qe,b as Xe,c as Je,f as we}from"./select-C7aNW8QS.js";import{P as ia,a as oa}from"./PolarAngleAxis-DALH8FDm.js";import{n as la,o as ca,l as da}from"./lucide-react-ClQ3Iy7l.js";import{u as ua}from"./use-growth-stats-Bg0nE0WG.js";import"./message-square-text-Dd1XS5-H.js";import"./sprout-BwLQTzMf.js";import"./index-DKAlEWM4.js";import"./_baseAssignValue-D_UsvJRN.js";import"./a-large-small-DVyx4GMu.js";import"./at-sign-CGNkBrZS.js";import"./copy-CNsHZEFR.js";import"./hash-j3sh-UI3.js";import"./inbox-1cUdr8Mm.js";import"./list-filter-DPE4Xj2T.js";import"./minus-CyEc3BE5.js";import"./tags-PGeGAafJ.js";import"./square-YF1YE9ex.js";import"./user-round-check-BLc3L-ei.js";import"./repeat-B-SL0yPM.js";import"./reply-BdCPoUQ9.js";import"./trash-D7ZWrnDq.js";var xe;function re(s){"@babel/helpers - typeof";return re=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(a){return typeof a}:function(a){return a&&typeof Symbol=="function"&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},re(s)}function ee(){return ee=Object.assign?Object.assign.bind():function(s){for(var a=1;a<arguments.length;a++){var n=arguments[a];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(s[t]=n[t])}return s},ee.apply(this,arguments)}function Be(s,a){var n=Object.keys(s);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(s);a&&(t=t.filter(function(r){return Object.getOwnPropertyDescriptor(s,r).enumerable})),n.push.apply(n,t)}return n}function R(s){for(var a=1;a<arguments.length;a++){var n=arguments[a]!=null?arguments[a]:{};a%2?Be(Object(n),!0).forEach(function(t){L(s,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(n)):Be(Object(n)).forEach(function(t){Object.defineProperty(s,t,Object.getOwnPropertyDescriptor(n,t))})}return s}function ma(s,a){if(!(s instanceof a))throw new TypeError("Cannot call a class as a function")}function Ie(s,a){for(var n=0;n<a.length;n++){var t=a[n];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(s,et(t.key),t)}}function pa(s,a,n){return a&&Ie(s.prototype,a),n&&Ie(s,n),Object.defineProperty(s,"prototype",{writable:!1}),s}function ha(s,a,n){return a=ve(a),fa(s,Ze()?Reflect.construct(a,n||[],ve(s).constructor):a.apply(s,n))}function fa(s,a){if(a&&(re(a)==="object"||typeof a=="function"))return a;if(a!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return xa(s)}function xa(s){if(s===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s}function Ze(){try{var s=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Ze=function(){return!!s})()}function ve(s){return ve=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},ve(s)}function ba(s,a){if(typeof a!="function"&&a!==null)throw new TypeError("Super expression must either be null or a function");s.prototype=Object.create(a&&a.prototype,{constructor:{value:s,writable:!0,configurable:!0}}),Object.defineProperty(s,"prototype",{writable:!1}),a&&Ne(s,a)}function Ne(s,a){return Ne=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,r){return t.__proto__=r,t},Ne(s,a)}function L(s,a,n){return a=et(a),a in s?Object.defineProperty(s,a,{value:n,enumerable:!0,configurable:!0,writable:!0}):s[a]=n,s}function et(s){var a=ga(s,"string");return re(a)=="symbol"?a:a+""}function ga(s,a){if(re(s)!="object"||!s)return s;var n=s[Symbol.toPrimitive];if(n!==void 0){var t=n.call(s,a);if(re(t)!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(s)}var G=(function(s){function a(n){var t;return ma(this,a),t=ha(this,a,[n]),L(t,"pieRef",null),L(t,"sectorRefs",[]),L(t,"id",Jt("recharts-pie-")),L(t,"handleAnimationEnd",function(){var r=t.props.onAnimationEnd;t.setState({isAnimationFinished:!0}),ne(r)&&r()}),L(t,"handleAnimationStart",function(){var r=t.props.onAnimationStart;t.setState({isAnimationFinished:!1}),ne(r)&&r()}),t.state={isAnimationFinished:!n.isAnimationActive,prevIsAnimationActive:n.isAnimationActive,prevAnimationId:n.animationId,sectorToFocus:0},t}return ba(a,s),pa(a,[{key:"isActiveIndex",value:function(t){var r=this.props.activeIndex;return Array.isArray(r)?r.indexOf(t)!==-1:t===r}},{key:"hasActiveIndex",value:function(){var t=this.props.activeIndex;return Array.isArray(t)?t.length!==0:t||t===0}},{key:"renderLabels",value:function(t){var r=this.props.isAnimationActive;if(r&&!this.state.isAnimationFinished)return null;var l=this.props,i=l.label,f=l.labelLine,g=l.dataKey,c=l.valueKey,o=he(this.props,!1),j=he(i,!1),A=he(f,!1),x=i&&i.offsetRadius||20,w=t.map(function(m,b){var N=(m.startAngle+m.endAngle)/2,p=Ae(m.cx,m.cy,m.outerRadius+x,N),h=R(R(R(R({},o),m),{},{stroke:"none"},j),{},{index:b,textAnchor:a.getTextAnchor(p.x,m.cx)},p),u=R(R(R(R({},o),m),{},{fill:"none",stroke:m.fill},A),{},{index:b,points:[Ae(m.cx,m.cy,m.outerRadius,N),p]}),v=g;return ae(g)&&ae(c)?v="value":ae(g)&&(v=c),I.createElement(ie,{key:"label-".concat(m.startAngle,"-").concat(m.endAngle,"-").concat(m.midAngle,"-").concat(b)},f&&a.renderLabelLineItem(f,u,"line"),a.renderLabelItem(i,h,X(m,v)))});return I.createElement(ie,{className:"recharts-pie-labels"},w)}},{key:"renderSectorsStatically",value:function(t){var r=this,l=this.props,i=l.activeShape,f=l.blendStroke,g=l.inactiveShape;return t.map(function(c,o){if(c?.startAngle===0&&c?.endAngle===0&&t.length!==1)return null;var j=r.isActiveIndex(o),A=g&&r.hasActiveIndex()?g:null,x=j?i:A,w=R(R({},c),{},{stroke:f?c.fill:c.stroke,tabIndex:-1});return I.createElement(ie,ee({ref:function(b){b&&!r.sectorRefs.includes(b)&&r.sectorRefs.push(b)},tabIndex:-1,className:"recharts-pie-sector"},Ht(r.props,c,o),{key:"sector-".concat(c?.startAngle,"-").concat(c?.endAngle,"-").concat(c.midAngle,"-").concat(o)}),I.createElement(Ut,ee({option:x,isActive:j,shapeType:"sector"},w)))})}},{key:"renderSectorsWithAnimation",value:function(){var t=this,r=this.props,l=r.sectors,i=r.isAnimationActive,f=r.animationBegin,g=r.animationDuration,c=r.animationEasing,o=r.animationId,j=this.state,A=j.prevSectors,x=j.prevIsAnimationActive;return I.createElement(Wt,{begin:f,duration:g,isActive:i,easing:c,from:{t:0},to:{t:1},key:"pie-".concat(o,"-").concat(x),onAnimationStart:this.handleAnimationStart,onAnimationEnd:this.handleAnimationEnd},function(w){var m=w.t,b=[],N=l&&l[0],p=N.startAngle;return l.forEach(function(h,u){var v=A&&A[u],C=u>0?qt(h,"paddingAngle",0):0;if(v){var S=Me(v.endAngle-v.startAngle,h.endAngle-h.startAngle),d=R(R({},h),{},{startAngle:p+C,endAngle:p+S(m)+C});b.push(d),p=d.endAngle}else{var k=h.endAngle,y=h.startAngle,D=Me(0,k-y),O=D(m),M=R(R({},h),{},{startAngle:p+C,endAngle:p+O+C});b.push(M),p=M.endAngle}}),I.createElement(ie,null,t.renderSectorsStatically(b))})}},{key:"attachKeyboardHandlers",value:function(t){var r=this;t.onkeydown=function(l){if(!l.altKey)switch(l.key){case"ArrowLeft":{var i=++r.state.sectorToFocus%r.sectorRefs.length;r.sectorRefs[i].focus(),r.setState({sectorToFocus:i});break}case"ArrowRight":{var f=--r.state.sectorToFocus<0?r.sectorRefs.length-1:r.state.sectorToFocus%r.sectorRefs.length;r.sectorRefs[f].focus(),r.setState({sectorToFocus:f});break}case"Escape":{r.sectorRefs[r.state.sectorToFocus].blur(),r.setState({sectorToFocus:0});break}}}}},{key:"renderSectors",value:function(){var t=this.props,r=t.sectors,l=t.isAnimationActive,i=this.state.prevSectors;return l&&r&&r.length&&(!i||!Qt(i,r))?this.renderSectorsWithAnimation():this.renderSectorsStatically(r)}},{key:"componentDidMount",value:function(){this.pieRef&&this.attachKeyboardHandlers(this.pieRef)}},{key:"render",value:function(){var t=this,r=this.props,l=r.hide,i=r.sectors,f=r.className,g=r.label,c=r.cx,o=r.cy,j=r.innerRadius,A=r.outerRadius,x=r.isAnimationActive,w=this.state.isAnimationFinished;if(l||!i||!i.length||!Z(c)||!Z(o)||!Z(j)||!Z(A))return null;var m=ye("recharts-pie",f);return I.createElement(ie,{tabIndex:this.props.rootTabIndex,className:m,ref:function(N){t.pieRef=N}},this.renderSectors(),g&&this.renderLabels(i),He.renderCallByParent(this.props,null,!1),(!x||w)&&Xt.renderCallByParent(this.props,i,!1))}}],[{key:"getDerivedStateFromProps",value:function(t,r){return r.prevIsAnimationActive!==t.isAnimationActive?{prevIsAnimationActive:t.isAnimationActive,prevAnimationId:t.animationId,curSectors:t.sectors,prevSectors:[],isAnimationFinished:!0}:t.isAnimationActive&&t.animationId!==r.prevAnimationId?{prevAnimationId:t.animationId,curSectors:t.sectors,prevSectors:r.curSectors,isAnimationFinished:!0}:t.sectors!==r.curSectors?{curSectors:t.sectors,isAnimationFinished:!0}:null}},{key:"getTextAnchor",value:function(t,r){return t>r?"start":t<r?"end":"middle"}},{key:"renderLabelLineItem",value:function(t,r,l){if(I.isValidElement(t))return I.cloneElement(t,r);if(ne(t))return t(r);var i=ye("recharts-pie-label-line",typeof t!="boolean"?t.className:"");return I.createElement(Yt,ee({},r,{key:l,type:"linear",className:i}))}},{key:"renderLabelItem",value:function(t,r,l){if(I.isValidElement(t))return I.cloneElement(t,r);var i=l;if(ne(t)&&(i=t(r),I.isValidElement(i)))return i;var f=ye("recharts-pie-label-text",typeof t!="boolean"&&!ne(t)?t.className:"");return I.createElement(zt,ee({},r,{alignmentBaseline:"middle",className:f}),i)}}])})(P.PureComponent);xe=G;L(G,"displayName","Pie");L(G,"defaultProps",{stroke:"#fff",fill:"#808080",legendType:"rect",cx:"50%",cy:"50%",startAngle:0,endAngle:360,innerRadius:0,outerRadius:"80%",paddingAngle:0,labelLine:!0,hide:!1,minAngle:0,isAnimationActive:!Zt.isSsr,animationBegin:400,animationDuration:1500,animationEasing:"ease",nameKey:"name",blendStroke:!1,rootTabIndex:0});L(G,"parseDeltaAngle",function(s,a){var n=fe(a-s),t=Math.min(Math.abs(a-s),360);return n*t});L(G,"getRealPieData",function(s){var a=s.data,n=s.children,t=he(s,!1),r=ea(n,ta);return a&&a.length?a.map(function(l,i){return R(R(R({payload:l},t),l),r&&r[i]&&r[i].props)}):r&&r.length?r.map(function(l){return R(R({},t),l.props)}):[]});L(G,"parseCoordinateOfPie",function(s,a){var n=a.top,t=a.left,r=a.width,l=a.height,i=aa(r,l),f=t+pe(s.cx,r,r/2),g=n+pe(s.cy,l,l/2),c=pe(s.innerRadius,i,0),o=pe(s.outerRadius,i,i*.8),j=s.maxRadius||Math.sqrt(r*r+l*l)/2;return{cx:f,cy:g,innerRadius:c,outerRadius:o,maxRadius:j}});L(G,"getComposedData",function(s){var a=s.item,n=s.offset,t=a.type.defaultProps!==void 0?R(R({},a.type.defaultProps),a.props):a.props,r=xe.getRealPieData(t);if(!r||!r.length)return null;var l=t.cornerRadius,i=t.startAngle,f=t.endAngle,g=t.paddingAngle,c=t.dataKey,o=t.nameKey,j=t.valueKey,A=t.tooltipType,x=Math.abs(t.minAngle),w=xe.parseCoordinateOfPie(t,n),m=xe.parseDeltaAngle(i,f),b=Math.abs(m),N=c;ae(c)&&ae(j)?(Re(!1,`Use "dataKey" to specify the value of pie,
|
|
2
2
|
the props "valueKey" will be deprecated in 1.1.0`),N="value"):ae(c)&&(Re(!1,`Use "dataKey" to specify the value of pie,
|
|
3
|
-
the props "valueKey" will be deprecated in 1.1.0`),N=j);var p=r.filter(function(d){return X(d,N,0)!==0}).length,h=(b>=360?p:p-1)*g,u=b-p*x-h,v=r.reduce(function(d,k){var y=X(k,N,0);return d+(Z(y)?y:0)},0),C;if(v>0){var S;C=r.map(function(d,k){var y=X(d,N,0),D=X(d,o,k),O=(Z(y)?y:0)/v,M;k?M=S.endAngle+fe(m)*g*(y!==0?1:0):M=i;var _=M+fe(m)*((y!==0?x:0)+O*u),E=(M+_)/2,V=(w.innerRadius+w.outerRadius)/2,q=[{name:D,value:y,payload:d,dataKey:N,type:A}],st=Ae(w.cx,w.cy,V,E);return S=R(R(R({percent:O,cornerRadius:l,name:D,tooltipPayload:q,midAngle:E,middleRadius:V,tooltipPosition:st},d),w),{},{value:X(d,N),startAngle:M,endAngle:_,payload:d,paddingAngle:fe(m)*g}),S})}return R(R({},w),{},{sectors:C,data:r})});var va=sa({chartName:"PieChart",GraphicalChild:G,validateTooltipEventTypes:["item"],defaultTooltipEventType:"item",legendContent:"children",axisComponents:[{axisType:"angleAxis",AxisComp:ia},{axisType:"radiusAxis",AxisComp:oa}],formatAxisMap:ra,defaultProps:{layout:"centric",startAngle:0,endAngle:360,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"}});const tt=({className:s})=>{const a=De();return e.jsx(ce,{actions:e.jsx(Ce,{variant:"outline",onClick:()=>a("/settings/analytics",{crossApp:!0}),children:"Open settings"}),className:s,description:"Enable member source tracking in settings to see which content drives member growth.",title:"Member sources have been disabled",children:e.jsx(St,{})})},ja=s=>s==="total-members"||s==="free-members"||s==="paid-members"||s==="mrr",ya=({active:s,payload:a,range:n,color:t,showBreakdown:r})=>{if(!s||!a?.length)return null;const l=a[0].payload,{date:i,formattedValue:f,label:g,comped:c}=l,o=l.value-(c||0);return e.jsxs("div",{className:"min-w-[200px] rounded-lg border bg-background px-3 py-2 shadow-lg",children:[i&&e.jsx("div",{className:"mb-1 text-sm text-foreground",children:z(i,n||0)}),e.jsxs("div",{className:"flex flex-col gap-1",children:[r&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("div",{className:"flex grow items-center justify-between gap-5",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"Paid subscriptions"}),e.jsx("div",{className:"font-mono text-xs",children:T(o)})]})}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("div",{className:"flex grow items-center justify-between gap-5",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"Complimentary"}),e.jsx("div",{className:"font-mono text-xs",children:c!==void 0&&c>0?T(c):"0"})]})}),e.jsx(lt,{})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"inline-block size-2 rounded-full opacity-50",style:{backgroundColor:t||"hsl(var(--chart-purple))"}}),e.jsxs("div",{className:"flex grow items-center justify-between gap-5",children:[g&&e.jsx("div",{className:"text-sm text-muted-foreground",children:g}),e.jsx("div",{className:"font-mono font-medium",children:f})]})]})]})]})},Sa=({chartData:s,totals:a,initialTab:n,currencySymbol:t,isLoading:r,onTabChange:l})=>{const i=ja(n)?n:"total-members",[f,g]=P.useState(i),{range:c}=Te(),{appSettings:o}=je(),j=De(),[A]=Ke();P.useEffect(()=>{g(i)},[i]);const x=S=>{g(S);const d=new URLSearchParams(A);d.set("tab",S),j(`?${d.toString()}`,{replace:!0}),l&&l(S)},{totalMembers:w,freeMembers:m,paidMembers:b,mrr:N,percentChanges:p,directions:h}=a,u=P.useMemo(()=>{if(!s||s.length===0)return[];let S=[],d="value";switch(f){case"free-members":d="free";break;case"paid-members":d="paid";break;case"mrr":{d="mrr";break}default:d="value"}S=oe(s,c,d,"exact");let k=[];switch(f){case"free-members":k=S.map(y=>({...y,value:y.free,formattedValue:T(y.free),label:"Free members"}));break;case"paid-members":k=S.map(y=>({...y,value:y.paid,formattedValue:T(y.paid),label:"Paid members",comped:y.comped,paid_subscribed:y.paid_subscribed}));break;case"mrr":k=S.map(y=>({...y,value:J(y.mrr),formattedValue:`${t}${T(J(y.mrr))}`,label:"MRR"}));break;default:k=S.map(y=>{const D=y.free+y.paid;return{...y,value:D,formattedValue:T(D),label:"Total members"}})}return k},[f,s,c,t]),v={"total-members":{color:"hsl(var(--chart-darkblue))"},"free-members":{color:"hsl(var(--chart-blue))"},"paid-members":{color:"hsl(var(--chart-purple))"},mrr:{color:"hsl(var(--chart-teal))"}};return r?e.jsx("div",{className:"-mb-6 flex h-[calc(16vw+132px)] w-full items-start justify-center",children:e.jsx(rt,{})}):e.jsxs(Ve,{defaultValue:i,variant:"kpis",children:[e.jsxs($e,{className:`-mx-6 ${o?.paidMembersEnabled?"hidden grid-cols-4 lg:!visible lg:!grid":"grid grid-cols-4"}`,children:[e.jsx(ue,{className:o?.paidMembersEnabled?"":"cursor-auto after:hidden",value:"total-members",onClick:()=>{o?.paidMembersEnabled&&x("total-members")},children:e.jsx(Y,{color:"hsl(var(--chart-darkblue))",diffDirection:c===$.allTime.value?"hidden":h.total,diffValue:p.total,label:"Total members",value:T(w)})}),o?.paidMembersEnabled&&e.jsxs(e.Fragment,{children:[e.jsx(ue,{value:"free-members",onClick:()=>{x("free-members")},children:e.jsx(Y,{color:"hsl(var(--chart-blue))",diffDirection:c===$.allTime.value?"hidden":h.free,diffValue:p.free,label:"Free members",value:T(m)})}),e.jsx(ue,{value:"paid-members",onClick:()=>{x("paid-members")},children:e.jsx(Y,{color:"hsl(var(--chart-purple))",diffDirection:c===$.allTime.value?"hidden":h.paid,diffValue:p.paid,label:"Paid members",value:T(b)})}),e.jsx(ue,{value:"mrr",onClick:()=>{x("mrr")},children:e.jsx(Y,{color:"hsl(var(--chart-teal))",diffDirection:c===$.allTime.value?"hidden":h.mrr,diffValue:p.mrr,label:"MRR",value:`${t}${T(J(N))}`})})]})]}),o?.paidMembersEnabled&&e.jsxs(nt,{children:[e.jsx(it,{className:"lg:hidden",asChild:!0,children:e.jsxs(Tt,{children:[f==="total-members"&&e.jsx(Y,{color:"hsl(var(--chart-darkblue))",diffDirection:c===$.allTime.value?"hidden":h.total,diffValue:p.total,label:"Total members",value:T(w)}),f==="free-members"&&e.jsx(Y,{color:"hsl(var(--chart-blue))",diffDirection:c===$.allTime.value?"hidden":h.free,diffValue:p.free,label:"Free members",value:T(m)}),f==="paid-members"&&e.jsx(Y,{color:"hsl(var(--chart-purple))",diffDirection:c===$.allTime.value?"hidden":h.paid,diffValue:p.paid,label:"Paid members",value:T(b)}),f==="mrr"&&e.jsx(Y,{color:"hsl(var(--chart-teal))",diffDirection:c===$.allTime.value?"hidden":h.mrr,diffValue:p.mrr,label:"MRR",value:`${t}${T(J(N))}`})]})}),e.jsxs(ot,{align:"end",className:"w-56",children:[e.jsx(de,{onClick:()=>x("total-members"),children:"Total members"}),e.jsx(de,{onClick:()=>x("free-members"),children:"Free members"}),e.jsx(de,{onClick:()=>x("paid-members"),children:"Paid members"}),e.jsx(de,{onClick:()=>x("mrr"),children:"MRR"})]})]}),e.jsx("div",{className:"my-4 [&_.recharts-cartesian-axis-tick-value]:fill-gray-500",children:e.jsx(wt,{className:"-mb-3 h-[16vw] max-h-[320px] w-full min-h-[180px]",color:v[f].color,data:u,dataFormatter:f==="mrr"?S=>`${t}${T(S)}`:T,id:f,range:c,tooltipContent:f==="paid-members"?e.jsx(ya,{color:v["paid-members"].color,range:c,showBreakdown:!0}):void 0})})]})},Aa=(s,a="signups desc",n=50)=>{const{startDate:t,endDate:r,timezone:l}=se(s),i={date_from:W(t),date_to:W(r),member_status:_t(ct),order:a,limit:n.toString()};return l&&(i.timezone=l),Gt({searchParams:i})},Fe=({data:s,currencySymbol:a,limit:n,defaultSourceIconUrl:t})=>{const r=n?s.slice(0,n):s,{appSettings:l}=je();return e.jsx(le,{children:r.map(i=>e.jsxs(K,{className:"last:border-none",children:[e.jsx(F,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Pt,{defaultSourceIconUrl:t,displayName:i.displayName,iconSrc:i.iconSrc}),i.linkUrl?e.jsx("a",{className:"hover:underline",href:i.linkUrl,rel:"noreferrer",target:"_blank",children:i.displayName}):e.jsx("span",{children:i.displayName})]})}),e.jsxs(F,{className:"text-right font-mono text-sm",children:["+",T(i.free_members)]}),l?.paidMembersEnabled&&e.jsxs(e.Fragment,{children:[e.jsxs(F,{className:"text-right font-mono text-sm",children:["+",T(i.paid_members)]}),e.jsxs(F,{className:"text-right font-mono text-sm",children:["+",a,T(J(i.mrr))]})]})]},i.source))})},wa=({range:s,limit:a=20,showViewAll:n=!1,sortBy:t,setSortBy:r})=>{const{data:l}=Te(),{data:i}=It(),{appSettings:f}=je(),[g,c]=P.useState("free_members desc"),o=t||g,j=r||c,A=o.replace("free_members","signups").replace("paid_members","paid_conversions"),{data:x,isLoading:w}=Aa(s,A,a),m=l?.url,b="https://www.google.com/s2/favicons?domain=ghost.org&sz=64",N=I.useMemo(()=>{if(i?.stats&&i?.meta?.totals){const v=i.meta.totals;let C=v[0];if(!C)return Se("usd");for(const S of v)S.mrr>C.mrr&&(C=S);return Se(C.currency)}return Se("usd")},[i]),p=I.useMemo(()=>x?.stats?x.stats.map(v=>{const C=v.source||"Direct",{domain:S}=Bt(C,m),d=S?`https://www.faviconextractor.com/favicon/${S}?larger=true`:b,k=S&&C!=="Direct"?`https://${S}`:void 0;return{source:C,free_members:v.signups,paid_members:v.paid_conversions,mrr:v.mrr,iconSrc:d,displayName:C,linkUrl:k}}):[],[x,m]),h="Top sources",u=`Where did your growth come from ${U(s)}`;return f?.analytics.membersTrackSources?w?e.jsx(le,{children:e.jsx(K,{className:"last:border-none",children:e.jsx(F,{className:"border-none py-2",colSpan:1,children:e.jsx(Ge,{containerClassName:"space-y-2",count:5,maxWidth:75,randomize:!0})})})}):e.jsxs(e.Fragment,{children:[p.length>0?e.jsx(Fe,{currencySymbol:N,data:p,defaultSourceIconUrl:b,limit:a}):e.jsx(le,{children:e.jsx(K,{className:"last:border-none",children:e.jsx(F,{className:"border-none py-12 group-hover:!bg-transparent",colSpan:f?.paidMembersEnabled?4:2,children:e.jsx(ce,{description:"Try adjusting your date range to see more data.",title:`No conversions ${U(s)}`,children:e.jsx(dt,{strokeWidth:1.5})})})})}),n&&p.length>a&&e.jsx(Et,{className:"border-none bg-transparent hover:!bg-transparent",children:e.jsx(K,{children:e.jsx(F,{className:"border-none bg-transparent px-0 pb-0 hover:!bg-transparent",colSpan:4,children:e.jsxs(ut,{children:[e.jsx(mt,{asChild:!0,children:e.jsxs(Ce,{variant:"outline",children:["View all ",e.jsx(At,{})]})}),e.jsxs(pt,{className:"overflow-y-auto pt-0 sm:max-w-[600px]",children:[e.jsxs(ht,{className:"sticky top-0 z-40 -mx-6 bg-background/60 p-6 backdrop-blur",children:[e.jsx(ft,{children:h}),e.jsx(xt,{children:u})]}),e.jsx("div",{className:"group/datalist",children:e.jsxs(Ye,{children:[e.jsx(ze,{children:e.jsxs(K,{children:[e.jsx(H,{children:"Source"}),e.jsx(H,{className:"w-[110px] text-right",children:e.jsx(te,{activeSortBy:o,setSortBy:j,sortBy:"free_members desc",children:"Free members"})}),f?.paidMembersEnabled&&e.jsxs(e.Fragment,{children:[e.jsx(H,{className:"w-[110px] text-right",children:e.jsx(te,{activeSortBy:o,setSortBy:j,sortBy:"paid_members desc",children:"Paid members"})}),e.jsx(H,{className:"w-[110px] text-right",children:e.jsx(te,{activeSortBy:o,setSortBy:j,sortBy:"mrr desc",children:"MRR impact"})})]})]})}),e.jsx(Fe,{currencySymbol:N,data:p,defaultSourceIconUrl:b})]})})]})]})})})})]}):e.jsx(le,{children:e.jsx(K,{className:"last:border-none",children:e.jsx(F,{className:"border-none py-12 group-hover:!bg-transparent",colSpan:f?.paidMembersEnabled?4:2,children:e.jsx(tt,{})})})})},Na=({active:s,payload:a})=>{if(s&&a&&a.length){const n=a[0];return e.jsx("div",{className:"rounded-lg border bg-background p-2 shadow-sm",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"size-2 rounded-full opacity-50",style:{backgroundColor:n.payload.color}}),e.jsx("span",{className:"font-medium",children:n.name}),e.jsx("span",{className:"font-mono",children:T(n.value)})]})})}return null},Da=({isLoading:s,range:a})=>{const{data:n}=Ft(),{data:t}=Lt({searchParams:{date_from:W(se(a).startDate)}}),{data:{tiers:r=[]}={}}=Vt(),[l,i]=P.useState("billing-period"),{startDate:f,endDate:g}=P.useMemo(()=>se(a),[a]),c=P.useMemo(()=>W(f),[f]),o=P.useMemo(()=>W(g),[g]),j=P.useMemo(()=>r.filter(u=>u.type==="paid"&&u.active).map(u=>({id:u.id,name:u.name})),[r]),A=P.useMemo(()=>{if(!t?.stats||t.stats.length===0)return 0;const u=t.stats,v=B(c),C=B(o),S=u.filter(O=>{const M=B(O.date);return M.isSameOrAfter(v)&&M.isSameOrBefore(C)});if(S.length===0)return 0;const d=[...S].sort((O,M)=>new Date(O.date).getTime()-new Date(M.date).getTime()),k=d[0].comped,D=d[d.length-1].comped-k;return D>0?D:0},[t,c,o]),x=P.useMemo(()=>{if(!n?.stats)return[];const u=B(c),v=B(o),C=n.stats.filter(d=>{const k=B(d.date);return k.isSameOrAfter(u)&&k.isSameOrBefore(v)}).reduce((d,k)=>{const y=k.cadence;return d[y]||(d[y]=0),d[y]+=k.signups,d},{});return A>0&&(C.complimentary=A),Object.entries(C).map(([d,k],y)=>{let D=d,O="url(#gradientPurple)",M="hsl(var(--chart-purple))";return d==="month"?(D="Monthly",O="url(#gradientPurple)",M="hsl(var(--chart-purple))"):d==="year"?(D="Annual",O="url(#gradientTeal)",M="hsl(var(--chart-teal))"):d==="complimentary"&&(D="Complimentary",O="url(#gradientBlue)",M="hsl(var(--chart-blue))"),{id:`cadence-${y}`,name:D,count:k,fill:O,color:M}})},[n,c,o,A]),w=P.useMemo(()=>{if(!n?.stats||j.length===0)return[];const u=B(c),v=B(o),C=n.stats.filter(D=>{const O=B(D.date);return O.isSameOrAfter(u)&&O.isSameOrBefore(v)}).reduce((D,O)=>{const M=O.tier;return D[M]||(D[M]=0),D[M]+=O.signups,D},{}),S=[{gradient:"url(#gradientPurple)",solid:"hsl(var(--chart-purple))"},{gradient:"url(#gradientTeal)",solid:"hsl(var(--chart-teal))"},{gradient:"url(#gradientBlue)",solid:"hsl(var(--chart-blue))"},{gradient:"url(#gradientRose)",solid:"hsl(var(--chart-rose))"},{gradient:"url(#gradientOrange)",solid:"hsl(var(--chart-orange))"},{gradient:"url(#gradientGreen)",solid:"hsl(var(--chart-green))"},{gradient:"url(#gradientAmber)",solid:"hsl(var(--chart-amber))"},{gradient:"url(#gradientYellow)",solid:"hsl(var(--chart-yellow))"},{gradient:"url(#gradientDarkblue)",solid:"hsl(var(--chart-darkblue))"},{gradient:"url(#gradientGray)",solid:"hsl(var(--chart-darkgray))"}];return[...j.map(D=>{const O=C[D.id]||0;return{id:D.id,name:D.name,count:O}})].sort((D,O)=>O.count-D.count).map((D,O)=>{const M=O%S.length;return{...D,fill:S[M].gradient,color:S[M].solid}})},[n,j,c,o]),m=l==="billing-period"?x:w,b=P.useMemo(()=>m.reduce((u,v)=>u+v.count,0),[m]),N=P.useMemo(()=>{const u={count:{label:"Subscriptions"}};return m.forEach(v=>{u[v.id]={label:v.name,color:v.color}}),u},[m]),p=P.useMemo(()=>b===0?[]:m.map(u=>({label:u.name,count:u.count,percentage:u.count/b*100,color:u.color})),[m,b]);if(s||!n?.stats)return null;const h=m.length>0&&b>0;return e.jsxs(be,{children:[e.jsx(_e,{children:e.jsxs("div",{className:"flex items-start justify-between gap-1.5",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(ke,{children:"Paid subscription breakdown"}),e.jsxs(Pe,{children:["New paid subscriptions ",U(a)]})]}),j.length>1&&e.jsx("div",{children:e.jsxs(qe,{value:l,onValueChange:u=>i(u),children:[e.jsx(Qe,{className:"w-full",children:e.jsx(Xe,{})}),e.jsxs(Je,{align:"end",children:[e.jsx(we,{value:"billing-period",children:"Billing period"}),e.jsx(we,{value:"tiers",children:"Tiers"})]})]})})]})}),e.jsx(ge,{children:h?e.jsxs(e.Fragment,{children:[e.jsx(Ue,{className:"mx-auto aspect-square h-[250px] min-h-[250px] w-full",config:N,children:e.jsxs(va,{children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"gradientPurple",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"hsl(var(--chart-purple))",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"hsl(var(--chart-purple))",stopOpacity:.6})]}),e.jsxs("linearGradient",{id:"gradientTeal",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"hsl(var(--chart-teal))",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"hsl(var(--chart-teal))",stopOpacity:.6})]}),e.jsxs("linearGradient",{id:"gradientRose",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"hsl(var(--chart-rose))",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"hsl(var(--chart-rose))",stopOpacity:.6})]}),e.jsxs("linearGradient",{id:"gradientBlue",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"hsl(var(--chart-blue))",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"hsl(var(--chart-blue))",stopOpacity:.6})]}),e.jsxs("linearGradient",{id:"gradientOrange",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"hsl(var(--chart-orange))",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"hsl(var(--chart-orange))",stopOpacity:.6})]}),e.jsxs("linearGradient",{id:"gradientGreen",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"hsl(var(--chart-green))",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"hsl(var(--chart-green))",stopOpacity:.6})]}),e.jsxs("linearGradient",{id:"gradientAmber",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"hsl(var(--chart-amber))",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"hsl(var(--chart-amber))",stopOpacity:.6})]}),e.jsxs("linearGradient",{id:"gradientYellow",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"hsl(var(--chart-yellow))",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"hsl(var(--chart-yellow))",stopOpacity:.6})]}),e.jsxs("linearGradient",{id:"gradientDarkblue",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"hsl(var(--chart-darkblue))",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"hsl(var(--chart-darkblue))",stopOpacity:.6})]}),e.jsxs("linearGradient",{id:"gradientGray",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"hsl(var(--chart-darkgray))",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"hsl(var(--chart-darkgray))",stopOpacity:.6})]})]}),e.jsx(We,{content:e.jsx(Na,{}),cursor:!1}),e.jsx(G,{animationBegin:0,animationDuration:1e3,data:m,dataKey:"count",innerRadius:70,nameKey:"name",strokeWidth:5,children:e.jsx(He,{content:({viewBox:u})=>{if(u&&"cx"in u&&"cy"in u)return e.jsxs("text",{dominantBaseline:"middle",textAnchor:"middle",x:u.cx,y:u.cy,children:[e.jsx("tspan",{className:"fill-foreground text-2xl font-semibold tracking-tight",x:u.cx,y:u.cy,children:T(b)}),e.jsx("tspan",{className:"fill-muted-foreground",x:u.cx,y:(u.cy||0)+20,children:"Total"})]})}})})]})}),p.length>0&&e.jsx("div",{className:"mt-4 flex flex-wrap items-center justify-center gap-x-6 gap-y-1 text-sm text-muted-foreground",children:p.map(u=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"size-2 rounded-full opacity-50",style:{backgroundColor:u.color}}),e.jsx("span",{className:"max-w-[150px] truncate whitespace-nowrap",title:u.label,children:u.label}),e.jsxs("span",{className:"font-medium text-foreground",children:[Math.round(Number(u.percentage)||0),"%"]})]},u.label))})]}):e.jsx("div",{className:"py-12",children:e.jsx(ce,{description:`No new paid subscriptions ${U(a)}.`,title:"No new subscribers",children:e.jsx(la,{strokeWidth:1.5})})})})]})},Ca=(s,a,n)=>{if(a===1){const o=B().format("YYYY-MM-DD"),j=s.find(A=>A.date===o);return[{date:o,signups:j?.signups||0,cancellations:j?.cancellations||0}]}const{startDate:t,endDate:r}=se(a),l=B(r).diff(B(t),"days"),i=bt(a,l,"sum",n),f=new Map(s.map(o=>[o.date,o])),g=[],c=new Set;if(i==="monthly"){const o=B(t).startOf("month"),j=B(r).startOf("month");for(;o.isSameOrBefore(j);){const A=o.format("YYYY-MM-DD");if(!c.has(A)){c.add(A);const x=f.get(A);x?g.push(x):g.push({date:A,signups:0,cancellations:0})}o.add(1,"month")}}else if(i==="weekly"){const o=B(t).startOf("week"),j=B(r).startOf("week");for(;o.isSameOrBefore(j);){const A=o.format("YYYY-MM-DD");if(!c.has(A)){c.add(A);const x=f.get(A);x?g.push(x):g.push({date:A,signups:0,cancellations:0})}o.add(1,"week")}}else{const o=B(t),j=B(r);for(;o.isSameOrBefore(j);){const A=o.format("YYYY-MM-DD"),x=f.get(A);x?g.push(x):g.push({date:A,signups:0,cancellations:0}),o.add(1,"day")}}return g},at=s=>{if(s===-1){const{startDate:a,endDate:n}=se(s);return B(n).diff(B(a),"days")}return s},Ta=s=>{const a=at(s);return a<30?["daily"]:a>=91?["weekly","monthly"]:["daily","weekly"]},Le=s=>{const a=at(s);return a<30?"daily":a>=91?"monthly":"weekly"},_a=({subscriptionData:s,memberData:a,range:n,isLoading:t})=>{const[r,l]=P.useState(()=>Le(n));P.useEffect(()=>{l(Le(n))},[n]);const i=P.useMemo(()=>Ta(n),[n]),f=P.useMemo(()=>{switch(r){case"daily":return"none";case"weekly":return"weekly";case"monthly":return"monthly"}},[r]),g=P.useMemo(()=>{if(s&&s.length>0){if(n===1){const h=B().format("YYYY-MM-DD"),u=s.find(v=>v.date===h);return[{date:z(h,n),rawDate:h,new:u?.signups||0,cancelled:-(u?.cancellations||0)}]}const x=oe(s,n,"signups","sum",f),w=oe(s,n,"cancellations","sum",f),m=new Map(w.map(h=>[h.date,h])),b=x.map(h=>({date:h.date,signups:h.signups||0,cancellations:m.get(h.date)?.cancellations||0})),N=new Set(b.map(h=>h.date));return w.forEach(h=>{N.has(h.date)||b.push({date:h.date,signups:0,cancellations:h.cancellations||0})}),b.sort((h,u)=>new Date(h.date).getTime()-new Date(u.date).getTime()),Ca(b,n,f).map(h=>{let u=n;return r==="weekly"&&n<91?u=91:r==="monthly"&&n<365&&(u=365),{date:z(h.date,u),rawDate:h.date,new:h.signups||0,cancelled:-(h.cancellations||0)}})}else{if(!a||a.length===0)return[];if(n===1){const p=B().format("YYYY-MM-DD"),h=a.find(u=>u.date===p);return[{date:z(p,n),rawDate:p,new:h?.paid_subscribed||0,cancelled:-(h?.paid_canceled||0)}]}const x=oe(a,n,"paid_subscribed","sum",f),w=oe(a,n,"paid_canceled","sum",f),m=new Map(w.map(p=>[p.date,p])),b=x.map(p=>({date:p.date,paid_subscribed:p.paid_subscribed||0,paid_canceled:m.get(p.date)?.paid_canceled||0})),N=new Set(b.map(p=>p.date));return w.forEach(p=>{N.has(p.date)||b.push({date:p.date,paid_subscribed:0,paid_canceled:p.paid_canceled||0})}),b.sort((p,h)=>new Date(p.date).getTime()-new Date(h.date).getTime()),b.map(p=>{let h=n;return r==="weekly"&&n<91?h=91:r==="monthly"&&n<365&&(h=365),{date:z(p.date,h),rawDate:p.date,new:p.paid_subscribed||0,cancelled:-(p.paid_canceled||0)}})}},[a,s,n,f,r]),c={new:{label:"New",color:"hsl(var(--chart-teal))"},cancelled:{label:"Cancelled",color:"hsl(var(--chart-rose))"}},o=P.useMemo(()=>{const x=g.reduce((m,b)=>m+b.new,0),w=g.reduce((m,b)=>m+Math.abs(b.cancelled),0);return{new:x,cancelled:w}},[g]);if(t)return null;const j=g.length>0&&(o.new>0||o.cancelled>0),A=x=>x.charAt(0).toUpperCase()+x.slice(1);return e.jsxs(be,{"data-testid":"paid-members-change-card",children:[e.jsx(_e,{children:e.jsxs("div",{className:"flex items-start justify-between gap-1.5",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(ke,{children:"Paid subscriptions"}),e.jsxs(Pe,{children:["New and cancelled paid subscriptions ",U(n)]})]}),i.length>1&&e.jsx("div",{children:e.jsxs(qe,{value:r,onValueChange:x=>l(x),children:[e.jsx(Qe,{className:"w-[110px]",children:e.jsx(Xe,{})}),e.jsx(Je,{align:"end",children:i.map(x=>e.jsx(we,{value:x,children:A(x)},x))})]})})]})}),e.jsx(ge,{children:j?e.jsxs("div",{children:[e.jsx(Ue,{className:"aspect-auto h-[200px] w-full md:h-[220px] xl:h-[260px]",config:c,children:e.jsxs(kt,{data:g,stackOffset:"sign",children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"tealGradient",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"var(--color-new)",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"var(--color-new)",stopOpacity:.6})]})}),e.jsx("defs",{children:e.jsxs("linearGradient",{id:"roseGradient",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"var(--color-cancelled)",stopOpacity:.6}),e.jsx("stop",{offset:"100%",stopColor:"var(--color-cancelled)",stopOpacity:.8})]})}),e.jsx(Nt,{stroke:"hsl(var(--border))",vertical:!1}),e.jsx(Dt,{axisLine:!1,dataKey:"date",tickFormatter:()=>"",tickLine:!1,tickMargin:10}),e.jsx(Ct,{axisLine:!1,tickFormatter:x=>x<0?T(x*-1):T(x),tickLine:!1}),e.jsx(We,{content:e.jsx(na,{className:"!min-w-[120px] px-3 py-2",formatter:(x,w,m,b)=>{const N=Number(x);let p="0";N===0?p="0":p=N<0?T(N*-1):T(N);const h=Number(m?.payload?.new||0),u=Number(m?.payload?.cancelled||0),v=h+u,C=v===0?"0":v>0?`+${T(v)}`:T(v);let S=m?.payload?.date;return m?.payload?.rawDate&&(r==="monthly"?S=z(m.payload.rawDate,366):r==="weekly"?S=z(m.payload.rawDate,91):S=z(m.payload.rawDate,30)),e.jsxs("div",{className:"flex w-full flex-col",children:[b===0&&e.jsx("div",{className:"mb-1 text-sm font-medium text-foreground",children:S}),e.jsxs("div",{className:"flex w-full items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"size-2 shrink-0 rounded-full bg-[var(--color-bg)] opacity-50",style:{"--color-bg":`var(--color-${w})`}}),e.jsx("span",{className:"text-sm text-muted-foreground",children:c[w]?.label||w})]}),e.jsx("div",{className:"ml-auto flex items-baseline gap-0.5 font-mono font-medium tabular-nums text-foreground",children:p})]}),b===1&&e.jsxs("div",{className:"mt-1 flex w-full items-center justify-between gap-4 border-t pt-1",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Net change"}),e.jsx("div",{className:"ml-auto flex items-baseline gap-0.5 font-mono font-medium tabular-nums text-foreground",children:C})]})]})},hideLabel:!0}),cursor:!1,isAnimationActive:!1,position:{y:10}}),e.jsx(Ee,{activeBar:{fillOpacity:1},dataKey:"new",fill:"url(#tealGradient)",fillOpacity:.75,maxBarSize:32,minPointSize:3,radius:[4,4,0,0],stackId:"a"}),e.jsx(Ee,{activeBar:{fillOpacity:1},dataKey:"cancelled",fill:"url(#roseGradient)",fillOpacity:.75,maxBarSize:32,radius:[4,4,0,0],stackId:"a"})]})}),e.jsxs("div",{className:"mt-3 flex items-center justify-center gap-6 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"size-2 rounded-full opacity-50",style:{backgroundColor:c.new.color}}),e.jsx("span",{children:"New"}),e.jsx("span",{className:"font-medium text-foreground",children:T(o.new)})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"size-2 rounded-full opacity-50",style:{backgroundColor:c.cancelled.color}}),e.jsx("span",{children:"Cancelled"}),e.jsx("span",{className:"font-medium text-foreground",children:T(o.cancelled)})]})]})]}):e.jsx("div",{className:"py-12",children:e.jsx(ce,{description:`No paid subscription changes ${U(n)}.`,title:"No paid member changes",children:e.jsx(ca,{strokeWidth:1.5})})})})]})},ka=(s,a,n)=>{const t=s??30,r=a??"mrr desc",{startDate:l,endDate:i}=P.useMemo(()=>se(t),[t]),f=P.useMemo(()=>{const o={date_from:W(l),date_to:W(i),order:r};return n==="posts"?o.post_type="post":n==="pages"&&(o.post_type="page"),o},[l,i,r,n]),g=Object.fromEntries(Object.entries(f).filter(([,o])=>o!==void 0));return Kt({searchParams:g})},ps=()=>{const{range:s,site:a,settings:n}=Te(),t=String(n.find(d=>d.key==="timezone")?.value||"Etc/UTC"),r=De(),[l,i]=P.useState("free_members desc"),[f,g]=P.useState(Q.POSTS_AND_PAGES),[c]=Ke(),{appSettings:o}=je(),j=c.get("tab")||"total-members",[A,x]=P.useState(j);P.useEffect(()=>{j!==A&&x(j)},[j]);const{isLoading:w,chartData:m,totals:b,currencySymbol:N,subscriptionData:p}=ua(s),{data:h,isLoading:u}=ka(s,l,f),v=P.useMemo(()=>{const k=(h?.stats||[]).reduce((_,E)=>{const V=E.post_id||(E.title&&E.title.trim()!==""?E.title:E.attribution_url);if(!V)return _;if(!_.has(V))_.set(V,E);else{const q=_.get(V);q.free_members+=E.free_members,q.paid_members+=E.paid_members,q.mrr+=E.mrr,_.set(V,q)}return _},new Map),y=Array.from(k.values()),D=y.reduce((_,E)=>_+E.free_members,0),O=y.reduce((_,E)=>_+E.paid_members,0),M=y.reduce((_,E)=>_+E.mrr,0);return y.map(_=>{let E=0;return l.includes("free_members")&&D>0?E=_.free_members/D:l.includes("paid_members")&&O>0?E=_.paid_members/O:l.includes("mrr")&&M>0&&(E=_.mrr/M),{title:_.title||_.attribution_url,post_id:_.post_id,attribution_url:_.attribution_url,attribution_type:_.attribution_type,attribution_id:_.attribution_id,free_members:_.free_members,paid_members:_.paid_members,mrr:_.mrr,percentage:E,published_at:_.published_at,url_exists:_.url_exists??!0}})},[h,l]),C=w,S=w||u;return e.jsxs(gt,{children:[e.jsx(vt,{children:e.jsx($t,{children:e.jsx(jt,{})})}),e.jsxs(yt,{data:C?void 0:m,isLoading:!1,loadingComponent:e.jsx(e.Fragment,{}),children:[e.jsx(be,{"data-testid":"total-members-card",children:e.jsx(ge,{children:e.jsx(Sa,{chartData:m,currencySymbol:N,initialTab:j,isLoading:C,totals:b,onTabChange:x})})}),o?.paidMembersEnabled&&A==="paid-members"&&e.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-2 xl:grid-cols-[2fr_minmax(460px,1fr)]",children:[e.jsx(_a,{isLoading:C,memberData:m,range:s,subscriptionData:p}),e.jsx(Da,{isLoading:C,range:s})]}),e.jsxs(be,{className:"w-full overflow-x-auto","data-testid":"top-content-card",children:[e.jsxs(_e,{children:[e.jsx(ke,{children:Ot(f)}),e.jsx(Pe,{children:Mt(f,s,U)})]}),e.jsx(ge,{children:e.jsxs(Ye,{children:[e.jsx(ze,{children:e.jsxs(K,{className:"[&>th]:h-auto [&>th]:pb-2 [&>th]:pt-0",children:[e.jsx(H,{className:"min-w-[320px] pl-0",children:e.jsx(Ve,{defaultValue:f,variant:"button-sm",onValueChange:d=>{g(d)},children:e.jsxs($e,{children:[e.jsx(me,{value:Q.POSTS_AND_PAGES,children:"Posts & pages"}),e.jsx(me,{value:Q.POSTS,children:"Posts"}),e.jsx(me,{value:Q.PAGES,children:"Pages"}),e.jsx(me,{value:Q.SOURCES,children:"Sources"})]})})}),e.jsx(H,{className:"w-[140px] text-right",children:o?.paidMembersEnabled?e.jsx(te,{activeSortBy:l,setSortBy:i,sortBy:"free_members desc",children:"Free members"}):e.jsx(e.Fragment,{children:"Free members"})}),o?.paidMembersEnabled&&e.jsxs(e.Fragment,{children:[e.jsx(H,{className:"w-[140px] text-right",children:e.jsx(te,{activeSortBy:l,setSortBy:i,sortBy:"paid_members desc",children:"Paid members"})}),e.jsx(H,{className:"w-[140px] text-right",children:e.jsx(te,{activeSortBy:l,setSortBy:i,sortBy:"mrr desc",children:"MRR impact"})})]})]})}),f===Q.SOURCES?e.jsx(wa,{limit:20,range:s,setSortBy:d=>i(d),showViewAll:!0,sortBy:l}):e.jsx(le,{children:S?e.jsx(K,{className:"last:border-none",children:e.jsx(F,{className:"border-none py-2",colSpan:1,children:e.jsx(Ge,{containerClassName:"space-y-2",count:5,maxWidth:75,randomize:!0})})}):o?.analytics.membersTrackSources?v.length>0?v.map((d,k)=>e.jsxs(K,{className:"last:border-none",children:[e.jsx(F,{children:e.jsxs("div",{className:"group/link inline-flex flex-col items-start gap-px",children:[d.post_id&&d.attribution_type==="post"?e.jsx(Ce,{className:"h-auto whitespace-normal p-0 text-left font-medium leading-tight hover:!underline",title:"View post analytics",variant:"link",onClick:Rt(d.attribution_url,d.post_id,a.url||"",r,d.attribution_type),children:d.title}):e.jsx("span",{className:"font-medium",children:d.title}),d.published_at&&Oe&&new Date(d.published_at).getTime()>0&&e.jsxs("span",{className:"text-muted-foreground",children:["Published on ",Oe(d.published_at,t)]})]})}),e.jsxs(F,{className:"text-right font-mono text-sm",children:[d.free_members>0&&"+",T(d.free_members)]}),o?.paidMembersEnabled&&e.jsxs(e.Fragment,{children:[e.jsxs(F,{className:"text-right font-mono text-sm",children:[d.paid_members>0&&"+",T(d.paid_members)]}),e.jsxs(F,{className:"text-right font-mono text-sm",children:[d.mrr>0&&"+",N,T(J(d.mrr))]})]})]},`${f}-${d.post_id||`${d.title}-${k}`}`)):e.jsx(K,{className:"border-none",children:e.jsx(F,{className:"py-12 group-hover:!bg-transparent",colSpan:o?.paidMembersEnabled?4:2,children:e.jsx(ce,{description:"Try adjusting your date range to see more data.",title:`No conversions ${U(s)}`,children:e.jsx(da,{strokeWidth:1.5})})})}):e.jsx(K,{className:"last:border-none",children:e.jsx(F,{className:"border-none py-12 group-hover:!bg-transparent",colSpan:o?.paidMembersEnabled?4:2,children:e.jsx(tt,{})})})})]})})]})]})]})};export{ps as default};
|
|
3
|
+
the props "valueKey" will be deprecated in 1.1.0`),N=j);var p=r.filter(function(d){return X(d,N,0)!==0}).length,h=(b>=360?p:p-1)*g,u=b-p*x-h,v=r.reduce(function(d,k){var y=X(k,N,0);return d+(Z(y)?y:0)},0),C;if(v>0){var S;C=r.map(function(d,k){var y=X(d,N,0),D=X(d,o,k),O=(Z(y)?y:0)/v,M;k?M=S.endAngle+fe(m)*g*(y!==0?1:0):M=i;var _=M+fe(m)*((y!==0?x:0)+O*u),E=(M+_)/2,V=(w.innerRadius+w.outerRadius)/2,q=[{name:D,value:y,payload:d,dataKey:N,type:A}],st=Ae(w.cx,w.cy,V,E);return S=R(R(R({percent:O,cornerRadius:l,name:D,tooltipPayload:q,midAngle:E,middleRadius:V,tooltipPosition:st},d),w),{},{value:X(d,N),startAngle:M,endAngle:_,payload:d,paddingAngle:fe(m)*g}),S})}return R(R({},w),{},{sectors:C,data:r})});var va=sa({chartName:"PieChart",GraphicalChild:G,validateTooltipEventTypes:["item"],defaultTooltipEventType:"item",legendContent:"children",axisComponents:[{axisType:"angleAxis",AxisComp:ia},{axisType:"radiusAxis",AxisComp:oa}],formatAxisMap:ra,defaultProps:{layout:"centric",startAngle:0,endAngle:360,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"}});const tt=({className:s})=>{const a=De();return e.jsx(ce,{actions:e.jsx(Ce,{variant:"outline",onClick:()=>a("/settings/analytics",{crossApp:!0}),children:"Open settings"}),className:s,description:"Enable member source tracking in settings to see which content drives member growth.",title:"Member sources have been disabled",children:e.jsx(St,{})})},ja=s=>s==="total-members"||s==="free-members"||s==="paid-members"||s==="mrr",ya=({active:s,payload:a,range:n,color:t,showBreakdown:r})=>{if(!s||!a?.length)return null;const l=a[0].payload,{date:i,formattedValue:f,label:g,comped:c}=l,o=l.value-(c||0);return e.jsxs("div",{className:"min-w-[200px] rounded-lg border bg-background px-3 py-2 shadow-lg",children:[i&&e.jsx("div",{className:"mb-1 text-sm text-foreground",children:z(i,n||0)}),e.jsxs("div",{className:"flex flex-col gap-1",children:[r&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("div",{className:"flex grow items-center justify-between gap-5",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"Paid subscriptions"}),e.jsx("div",{className:"font-mono text-xs",children:T(o)})]})}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("div",{className:"flex grow items-center justify-between gap-5",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"Complimentary"}),e.jsx("div",{className:"font-mono text-xs",children:c!==void 0&&c>0?T(c):"0"})]})}),e.jsx(lt,{})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"inline-block size-2 rounded-full opacity-50",style:{backgroundColor:t||"hsl(var(--chart-purple))"}}),e.jsxs("div",{className:"flex grow items-center justify-between gap-5",children:[g&&e.jsx("div",{className:"text-sm text-muted-foreground",children:g}),e.jsx("div",{className:"font-mono font-medium",children:f})]})]})]})]})},Sa=({chartData:s,totals:a,initialTab:n,currencySymbol:t,isLoading:r,onTabChange:l})=>{const i=ja(n)?n:"total-members",[f,g]=P.useState(i),{range:c}=Te(),{appSettings:o}=je(),j=De(),[A]=Ke();P.useEffect(()=>{g(i)},[i]);const x=S=>{g(S);const d=new URLSearchParams(A);d.set("tab",S),j(`?${d.toString()}`,{replace:!0}),l&&l(S)},{totalMembers:w,freeMembers:m,paidMembers:b,mrr:N,percentChanges:p,directions:h}=a,u=P.useMemo(()=>{if(!s||s.length===0)return[];let S=[],d="value";switch(f){case"free-members":d="free";break;case"paid-members":d="paid";break;case"mrr":{d="mrr";break}default:d="value"}S=oe(s,c,d,"exact");let k=[];switch(f){case"free-members":k=S.map(y=>({...y,value:y.free,formattedValue:T(y.free),label:"Free members"}));break;case"paid-members":k=S.map(y=>({...y,value:y.paid,formattedValue:T(y.paid),label:"Paid members",comped:y.comped,paid_subscribed:y.paid_subscribed}));break;case"mrr":k=S.map(y=>({...y,value:J(y.mrr),formattedValue:`${t}${T(J(y.mrr))}`,label:"MRR"}));break;default:k=S.map(y=>{const D=y.free+y.paid;return{...y,value:D,formattedValue:T(D),label:"Total members"}})}return k},[f,s,c,t]),v={"total-members":{color:"hsl(var(--chart-darkblue))"},"free-members":{color:"hsl(var(--chart-blue))"},"paid-members":{color:"hsl(var(--chart-purple))"},mrr:{color:"hsl(var(--chart-teal))"}};return r?e.jsx("div",{className:"-mb-6 flex h-[calc(16vw+132px)] w-full items-start justify-center",children:e.jsx(rt,{})}):e.jsxs(Ve,{defaultValue:i,variant:"kpis",children:[e.jsxs($e,{className:`-mx-6 ${o?.paidMembersEnabled?"hidden grid-cols-4 lg:!visible lg:!grid":"grid grid-cols-4"}`,children:[e.jsx(ue,{className:o?.paidMembersEnabled?"":"cursor-auto after:hidden",value:"total-members",onClick:()=>{o?.paidMembersEnabled&&x("total-members")},children:e.jsx(Y,{color:"hsl(var(--chart-darkblue))",diffDirection:c===$.allTime.value?"hidden":h.total,diffValue:p.total,label:"Total members",value:T(w)})}),o?.paidMembersEnabled&&e.jsxs(e.Fragment,{children:[e.jsx(ue,{value:"free-members",onClick:()=>{x("free-members")},children:e.jsx(Y,{color:"hsl(var(--chart-blue))",diffDirection:c===$.allTime.value?"hidden":h.free,diffValue:p.free,label:"Free members",value:T(m)})}),e.jsx(ue,{value:"paid-members",onClick:()=>{x("paid-members")},children:e.jsx(Y,{color:"hsl(var(--chart-purple))",diffDirection:c===$.allTime.value?"hidden":h.paid,diffValue:p.paid,label:"Paid members",value:T(b)})}),e.jsx(ue,{value:"mrr",onClick:()=>{x("mrr")},children:e.jsx(Y,{color:"hsl(var(--chart-teal))",diffDirection:c===$.allTime.value?"hidden":h.mrr,diffValue:p.mrr,label:"MRR",value:`${t}${T(J(N))}`})})]})]}),o?.paidMembersEnabled&&e.jsxs(nt,{children:[e.jsx(it,{className:"lg:hidden",asChild:!0,children:e.jsxs(Tt,{children:[f==="total-members"&&e.jsx(Y,{color:"hsl(var(--chart-darkblue))",diffDirection:c===$.allTime.value?"hidden":h.total,diffValue:p.total,label:"Total members",value:T(w)}),f==="free-members"&&e.jsx(Y,{color:"hsl(var(--chart-blue))",diffDirection:c===$.allTime.value?"hidden":h.free,diffValue:p.free,label:"Free members",value:T(m)}),f==="paid-members"&&e.jsx(Y,{color:"hsl(var(--chart-purple))",diffDirection:c===$.allTime.value?"hidden":h.paid,diffValue:p.paid,label:"Paid members",value:T(b)}),f==="mrr"&&e.jsx(Y,{color:"hsl(var(--chart-teal))",diffDirection:c===$.allTime.value?"hidden":h.mrr,diffValue:p.mrr,label:"MRR",value:`${t}${T(J(N))}`})]})}),e.jsxs(ot,{align:"end",className:"w-56",children:[e.jsx(de,{onClick:()=>x("total-members"),children:"Total members"}),e.jsx(de,{onClick:()=>x("free-members"),children:"Free members"}),e.jsx(de,{onClick:()=>x("paid-members"),children:"Paid members"}),e.jsx(de,{onClick:()=>x("mrr"),children:"MRR"})]})]}),e.jsx("div",{className:"my-4 [&_.recharts-cartesian-axis-tick-value]:fill-gray-500",children:e.jsx(wt,{className:"-mb-3 h-[16vw] max-h-[320px] w-full min-h-[180px]",color:v[f].color,data:u,dataFormatter:f==="mrr"?S=>`${t}${T(S)}`:T,id:f,range:c,tooltipContent:f==="paid-members"?e.jsx(ya,{color:v["paid-members"].color,range:c,showBreakdown:!0}):void 0})})]})},Aa=(s,a="signups desc",n=50)=>{const{startDate:t,endDate:r,timezone:l}=se(s),i={date_from:W(t),date_to:W(r),member_status:_t(ct),order:a,limit:n.toString()};return l&&(i.timezone=l),Gt({searchParams:i})},Fe=({data:s,currencySymbol:a,limit:n,defaultSourceIconUrl:t})=>{const r=n?s.slice(0,n):s,{appSettings:l}=je();return e.jsx(le,{children:r.map(i=>e.jsxs(K,{className:"last:border-none",children:[e.jsx(F,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Pt,{defaultSourceIconUrl:t,displayName:i.displayName,iconSrc:i.iconSrc}),i.linkUrl?e.jsx("a",{className:"hover:underline",href:i.linkUrl,rel:"noreferrer",target:"_blank",children:i.displayName}):e.jsx("span",{children:i.displayName})]})}),e.jsxs(F,{className:"text-right font-mono text-sm",children:["+",T(i.free_members)]}),l?.paidMembersEnabled&&e.jsxs(e.Fragment,{children:[e.jsxs(F,{className:"text-right font-mono text-sm",children:["+",T(i.paid_members)]}),e.jsxs(F,{className:"text-right font-mono text-sm",children:["+",a,T(J(i.mrr))]})]})]},i.source))})},wa=({range:s,limit:a=20,showViewAll:n=!1,sortBy:t,setSortBy:r})=>{const{data:l}=Te(),{data:i}=It(),{appSettings:f}=je(),[g,c]=P.useState("free_members desc"),o=t||g,j=r||c,A=o.replace("free_members","signups").replace("paid_members","paid_conversions"),{data:x,isLoading:w}=Aa(s,A,a),m=l?.url,b="https://www.google.com/s2/favicons?domain=ghost.org&sz=64",N=I.useMemo(()=>{if(i?.stats&&i?.meta?.totals){const v=i.meta.totals;let C=v[0];if(!C)return Se("usd");for(const S of v)S.mrr>C.mrr&&(C=S);return Se(C.currency)}return Se("usd")},[i]),p=I.useMemo(()=>x?.stats?x.stats.map(v=>{const C=v.source||"Direct",{domain:S}=Bt(C,m),d=S?`https://www.faviconextractor.com/favicon/${S}?larger=true`:b,k=S&&C!=="Direct"?`https://${S}`:void 0;return{source:C,free_members:v.signups,paid_members:v.paid_conversions,mrr:v.mrr,iconSrc:d,displayName:C,linkUrl:k}}):[],[x,m]),h="Top sources",u=`Where did your growth come from ${U(s)}`;return f?.analytics.membersTrackSources?w?e.jsx(le,{children:e.jsx(K,{className:"last:border-none",children:e.jsx(F,{className:"border-none py-2",colSpan:1,children:e.jsx(Ge,{containerClassName:"space-y-2",count:5,maxWidth:75,randomize:!0})})})}):e.jsxs(e.Fragment,{children:[p.length>0?e.jsx(Fe,{currencySymbol:N,data:p,defaultSourceIconUrl:b,limit:a}):e.jsx(le,{children:e.jsx(K,{className:"last:border-none",children:e.jsx(F,{className:"border-none py-12 group-hover:!bg-transparent",colSpan:f?.paidMembersEnabled?4:2,children:e.jsx(ce,{description:"Try adjusting your date range to see more data.",title:`No conversions ${U(s)}`,children:e.jsx(dt,{strokeWidth:1.5})})})})}),n&&p.length>a&&e.jsx(Et,{className:"border-none bg-transparent hover:!bg-transparent",children:e.jsx(K,{children:e.jsx(F,{className:"border-none bg-transparent px-0 pb-0 hover:!bg-transparent",colSpan:4,children:e.jsxs(ut,{children:[e.jsx(mt,{asChild:!0,children:e.jsxs(Ce,{variant:"outline",children:["View all ",e.jsx(At,{})]})}),e.jsxs(pt,{className:"overflow-y-auto pt-0 sm:max-w-[600px]",children:[e.jsxs(ht,{className:"sticky top-0 z-40 -mx-6 bg-background/60 p-6 backdrop-blur",children:[e.jsx(ft,{children:h}),e.jsx(xt,{children:u})]}),e.jsx("div",{className:"group/datalist",children:e.jsxs(Ye,{children:[e.jsx(ze,{children:e.jsxs(K,{children:[e.jsx(H,{children:"Source"}),e.jsx(H,{className:"w-[110px] text-right",children:e.jsx(te,{activeSortBy:o,setSortBy:j,sortBy:"free_members desc",children:"Free members"})}),f?.paidMembersEnabled&&e.jsxs(e.Fragment,{children:[e.jsx(H,{className:"w-[110px] text-right",children:e.jsx(te,{activeSortBy:o,setSortBy:j,sortBy:"paid_members desc",children:"Paid members"})}),e.jsx(H,{className:"w-[110px] text-right",children:e.jsx(te,{activeSortBy:o,setSortBy:j,sortBy:"mrr desc",children:"MRR impact"})})]})]})}),e.jsx(Fe,{currencySymbol:N,data:p,defaultSourceIconUrl:b})]})})]})]})})})})]}):e.jsx(le,{children:e.jsx(K,{className:"last:border-none",children:e.jsx(F,{className:"border-none py-12 group-hover:!bg-transparent",colSpan:f?.paidMembersEnabled?4:2,children:e.jsx(tt,{})})})})},Na=({active:s,payload:a})=>{if(s&&a&&a.length){const n=a[0];return e.jsx("div",{className:"rounded-lg border bg-background p-2 shadow-sm",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"size-2 rounded-full opacity-50",style:{backgroundColor:n.payload.color}}),e.jsx("span",{className:"font-medium",children:n.name}),e.jsx("span",{className:"font-mono",children:T(n.value)})]})})}return null},Da=({isLoading:s,range:a})=>{const{data:n}=Ft(),{data:t}=Lt({searchParams:{date_from:W(se(a).startDate)}}),{data:{tiers:r=[]}={}}=Vt(),[l,i]=P.useState("billing-period"),{startDate:f,endDate:g}=P.useMemo(()=>se(a),[a]),c=P.useMemo(()=>W(f),[f]),o=P.useMemo(()=>W(g),[g]),j=P.useMemo(()=>r.filter(u=>u.type==="paid"&&u.active).map(u=>({id:u.id,name:u.name})),[r]),A=P.useMemo(()=>{if(!t?.stats||t.stats.length===0)return 0;const u=t.stats,v=B(c),C=B(o),S=u.filter(O=>{const M=B(O.date);return M.isSameOrAfter(v)&&M.isSameOrBefore(C)});if(S.length===0)return 0;const d=[...S].sort((O,M)=>new Date(O.date).getTime()-new Date(M.date).getTime()),k=d[0].comped,D=d[d.length-1].comped-k;return D>0?D:0},[t,c,o]),x=P.useMemo(()=>{if(!n?.stats)return[];const u=B(c),v=B(o),C=n.stats.filter(d=>{const k=B(d.date);return k.isSameOrAfter(u)&&k.isSameOrBefore(v)}).reduce((d,k)=>{const y=k.cadence;return d[y]||(d[y]=0),d[y]+=k.signups,d},{});return A>0&&(C.complimentary=A),Object.entries(C).map(([d,k],y)=>{let D=d,O="url(#gradientPurple)",M="hsl(var(--chart-purple))";return d==="month"?(D="Monthly",O="url(#gradientPurple)",M="hsl(var(--chart-purple))"):d==="year"?(D="Annual",O="url(#gradientTeal)",M="hsl(var(--chart-teal))"):d==="complimentary"&&(D="Complimentary",O="url(#gradientBlue)",M="hsl(var(--chart-blue))"),{id:`cadence-${y}`,name:D,count:k,fill:O,color:M}})},[n,c,o,A]),w=P.useMemo(()=>{if(!n?.stats||j.length===0)return[];const u=B(c),v=B(o),C=n.stats.filter(D=>{const O=B(D.date);return O.isSameOrAfter(u)&&O.isSameOrBefore(v)}).reduce((D,O)=>{const M=O.tier;return D[M]||(D[M]=0),D[M]+=O.signups,D},{}),S=[{gradient:"url(#gradientPurple)",solid:"hsl(var(--chart-purple))"},{gradient:"url(#gradientTeal)",solid:"hsl(var(--chart-teal))"},{gradient:"url(#gradientBlue)",solid:"hsl(var(--chart-blue))"},{gradient:"url(#gradientRose)",solid:"hsl(var(--chart-rose))"},{gradient:"url(#gradientOrange)",solid:"hsl(var(--chart-orange))"},{gradient:"url(#gradientGreen)",solid:"hsl(var(--chart-green))"},{gradient:"url(#gradientAmber)",solid:"hsl(var(--chart-amber))"},{gradient:"url(#gradientYellow)",solid:"hsl(var(--chart-yellow))"},{gradient:"url(#gradientDarkblue)",solid:"hsl(var(--chart-darkblue))"},{gradient:"url(#gradientGray)",solid:"hsl(var(--chart-darkgray))"}];return[...j.map(D=>{const O=C[D.id]||0;return{id:D.id,name:D.name,count:O}})].sort((D,O)=>O.count-D.count).map((D,O)=>{const M=O%S.length;return{...D,fill:S[M].gradient,color:S[M].solid}})},[n,j,c,o]),m=l==="billing-period"?x:w,b=P.useMemo(()=>m.reduce((u,v)=>u+v.count,0),[m]),N=P.useMemo(()=>{const u={count:{label:"Subscriptions"}};return m.forEach(v=>{u[v.id]={label:v.name,color:v.color}}),u},[m]),p=P.useMemo(()=>b===0?[]:m.map(u=>({label:u.name,count:u.count,percentage:u.count/b*100,color:u.color})),[m,b]);if(s||!n?.stats)return null;const h=m.length>0&&b>0;return e.jsxs(be,{children:[e.jsx(_e,{children:e.jsxs("div",{className:"flex items-start justify-between gap-1.5",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(ke,{children:"Paid subscription breakdown"}),e.jsxs(Pe,{children:["New paid subscriptions ",U(a)]})]}),j.length>1&&e.jsx("div",{children:e.jsxs(qe,{value:l,onValueChange:u=>i(u),children:[e.jsx(Qe,{className:"w-full",children:e.jsx(Xe,{})}),e.jsxs(Je,{align:"end",children:[e.jsx(we,{value:"billing-period",children:"Billing period"}),e.jsx(we,{value:"tiers",children:"Tiers"})]})]})})]})}),e.jsx(ge,{children:h?e.jsxs(e.Fragment,{children:[e.jsx(Ue,{className:"mx-auto aspect-square h-[250px] min-h-[250px] w-full",config:N,children:e.jsxs(va,{children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"gradientPurple",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"hsl(var(--chart-purple))",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"hsl(var(--chart-purple))",stopOpacity:.6})]}),e.jsxs("linearGradient",{id:"gradientTeal",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"hsl(var(--chart-teal))",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"hsl(var(--chart-teal))",stopOpacity:.6})]}),e.jsxs("linearGradient",{id:"gradientRose",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"hsl(var(--chart-rose))",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"hsl(var(--chart-rose))",stopOpacity:.6})]}),e.jsxs("linearGradient",{id:"gradientBlue",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"hsl(var(--chart-blue))",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"hsl(var(--chart-blue))",stopOpacity:.6})]}),e.jsxs("linearGradient",{id:"gradientOrange",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"hsl(var(--chart-orange))",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"hsl(var(--chart-orange))",stopOpacity:.6})]}),e.jsxs("linearGradient",{id:"gradientGreen",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"hsl(var(--chart-green))",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"hsl(var(--chart-green))",stopOpacity:.6})]}),e.jsxs("linearGradient",{id:"gradientAmber",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"hsl(var(--chart-amber))",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"hsl(var(--chart-amber))",stopOpacity:.6})]}),e.jsxs("linearGradient",{id:"gradientYellow",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"hsl(var(--chart-yellow))",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"hsl(var(--chart-yellow))",stopOpacity:.6})]}),e.jsxs("linearGradient",{id:"gradientDarkblue",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"hsl(var(--chart-darkblue))",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"hsl(var(--chart-darkblue))",stopOpacity:.6})]}),e.jsxs("linearGradient",{id:"gradientGray",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"hsl(var(--chart-darkgray))",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"hsl(var(--chart-darkgray))",stopOpacity:.6})]})]}),e.jsx(We,{content:e.jsx(Na,{}),cursor:!1}),e.jsx(G,{animationBegin:0,animationDuration:1e3,data:m,dataKey:"count",innerRadius:70,nameKey:"name",strokeWidth:5,children:e.jsx(He,{content:({viewBox:u})=>{if(u&&"cx"in u&&"cy"in u)return e.jsxs("text",{dominantBaseline:"middle",textAnchor:"middle",x:u.cx,y:u.cy,children:[e.jsx("tspan",{className:"fill-foreground text-2xl font-semibold tracking-tight",x:u.cx,y:u.cy,children:T(b)}),e.jsx("tspan",{className:"fill-muted-foreground",x:u.cx,y:(u.cy||0)+20,children:"Total"})]})}})})]})}),p.length>0&&e.jsx("div",{className:"mt-4 flex flex-wrap items-center justify-center gap-x-6 gap-y-1 text-sm text-muted-foreground",children:p.map(u=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"size-2 rounded-full opacity-50",style:{backgroundColor:u.color}}),e.jsx("span",{className:"max-w-[150px] truncate whitespace-nowrap",title:u.label,children:u.label}),e.jsxs("span",{className:"font-medium text-foreground",children:[Math.round(Number(u.percentage)||0),"%"]})]},u.label))})]}):e.jsx("div",{className:"py-12",children:e.jsx(ce,{description:`No new paid subscriptions ${U(a)}.`,title:"No new subscribers",children:e.jsx(la,{strokeWidth:1.5})})})})]})},Ca=(s,a,n)=>{if(a===1){const o=B().format("YYYY-MM-DD"),j=s.find(A=>A.date===o);return[{date:o,signups:j?.signups||0,cancellations:j?.cancellations||0}]}const{startDate:t,endDate:r}=se(a),l=B(r).diff(B(t),"days"),i=bt(a,l,"sum",n),f=new Map(s.map(o=>[o.date,o])),g=[],c=new Set;if(i==="monthly"){const o=B(t).startOf("month"),j=B(r).startOf("month");for(;o.isSameOrBefore(j);){const A=o.format("YYYY-MM-DD");if(!c.has(A)){c.add(A);const x=f.get(A);x?g.push(x):g.push({date:A,signups:0,cancellations:0})}o.add(1,"month")}}else if(i==="weekly"){const o=B(t).startOf("week"),j=B(r).startOf("week");for(;o.isSameOrBefore(j);){const A=o.format("YYYY-MM-DD");if(!c.has(A)){c.add(A);const x=f.get(A);x?g.push(x):g.push({date:A,signups:0,cancellations:0})}o.add(1,"week")}}else{const o=B(t),j=B(r);for(;o.isSameOrBefore(j);){const A=o.format("YYYY-MM-DD"),x=f.get(A);x?g.push(x):g.push({date:A,signups:0,cancellations:0}),o.add(1,"day")}}return g},at=s=>{if(s===-1){const{startDate:a,endDate:n}=se(s);return B(n).diff(B(a),"days")}return s},Ta=s=>{const a=at(s);return a<30?["daily"]:a>=91?["weekly","monthly"]:["daily","weekly"]},Le=s=>{const a=at(s);return a<30?"daily":a>=91?"monthly":"weekly"},_a=({subscriptionData:s,memberData:a,range:n,isLoading:t})=>{const[r,l]=P.useState(()=>Le(n));P.useEffect(()=>{l(Le(n))},[n]);const i=P.useMemo(()=>Ta(n),[n]),f=P.useMemo(()=>{switch(r){case"daily":return"none";case"weekly":return"weekly";case"monthly":return"monthly"}},[r]),g=P.useMemo(()=>{if(s&&s.length>0){if(n===1){const h=B().format("YYYY-MM-DD"),u=s.find(v=>v.date===h);return[{date:z(h,n),rawDate:h,new:u?.signups||0,cancelled:-(u?.cancellations||0)}]}const x=oe(s,n,"signups","sum",f),w=oe(s,n,"cancellations","sum",f),m=new Map(w.map(h=>[h.date,h])),b=x.map(h=>({date:h.date,signups:h.signups||0,cancellations:m.get(h.date)?.cancellations||0})),N=new Set(b.map(h=>h.date));return w.forEach(h=>{N.has(h.date)||b.push({date:h.date,signups:0,cancellations:h.cancellations||0})}),b.sort((h,u)=>new Date(h.date).getTime()-new Date(u.date).getTime()),Ca(b,n,f).map(h=>{let u=n;return r==="weekly"&&n<91?u=91:r==="monthly"&&n<365&&(u=365),{date:z(h.date,u),rawDate:h.date,new:h.signups||0,cancelled:-(h.cancellations||0)}})}else{if(!a||a.length===0)return[];if(n===1){const p=B().format("YYYY-MM-DD"),h=a.find(u=>u.date===p);return[{date:z(p,n),rawDate:p,new:h?.paid_subscribed||0,cancelled:-(h?.paid_canceled||0)}]}const x=oe(a,n,"paid_subscribed","sum",f),w=oe(a,n,"paid_canceled","sum",f),m=new Map(w.map(p=>[p.date,p])),b=x.map(p=>({date:p.date,paid_subscribed:p.paid_subscribed||0,paid_canceled:m.get(p.date)?.paid_canceled||0})),N=new Set(b.map(p=>p.date));return w.forEach(p=>{N.has(p.date)||b.push({date:p.date,paid_subscribed:0,paid_canceled:p.paid_canceled||0})}),b.sort((p,h)=>new Date(p.date).getTime()-new Date(h.date).getTime()),b.map(p=>{let h=n;return r==="weekly"&&n<91?h=91:r==="monthly"&&n<365&&(h=365),{date:z(p.date,h),rawDate:p.date,new:p.paid_subscribed||0,cancelled:-(p.paid_canceled||0)}})}},[a,s,n,f,r]),c={new:{label:"New",color:"hsl(var(--chart-teal))"},cancelled:{label:"Cancelled",color:"hsl(var(--chart-rose))"}},o=P.useMemo(()=>{const x=g.reduce((m,b)=>m+b.new,0),w=g.reduce((m,b)=>m+Math.abs(b.cancelled),0);return{new:x,cancelled:w}},[g]);if(t)return null;const j=g.length>0&&(o.new>0||o.cancelled>0),A=x=>x.charAt(0).toUpperCase()+x.slice(1);return e.jsxs(be,{"data-testid":"paid-members-change-card",children:[e.jsx(_e,{children:e.jsxs("div",{className:"flex items-start justify-between gap-1.5",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(ke,{children:"Paid subscriptions"}),e.jsxs(Pe,{children:["New and cancelled paid subscriptions ",U(n)]})]}),i.length>1&&e.jsx("div",{children:e.jsxs(qe,{value:r,onValueChange:x=>l(x),children:[e.jsx(Qe,{className:"w-[110px]",children:e.jsx(Xe,{})}),e.jsx(Je,{align:"end",children:i.map(x=>e.jsx(we,{value:x,children:A(x)},x))})]})})]})}),e.jsx(ge,{children:j?e.jsxs("div",{children:[e.jsx(Ue,{className:"aspect-auto h-[200px] w-full md:h-[220px] xl:h-[260px]",config:c,children:e.jsxs(kt,{data:g,stackOffset:"sign",children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"tealGradient",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"var(--color-new)",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"var(--color-new)",stopOpacity:.6})]})}),e.jsx("defs",{children:e.jsxs("linearGradient",{id:"roseGradient",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"var(--color-cancelled)",stopOpacity:.6}),e.jsx("stop",{offset:"100%",stopColor:"var(--color-cancelled)",stopOpacity:.8})]})}),e.jsx(Nt,{stroke:"hsl(var(--border))",vertical:!1}),e.jsx(Dt,{axisLine:!1,dataKey:"date",tickFormatter:()=>"",tickLine:!1,tickMargin:10}),e.jsx(Ct,{axisLine:!1,tickFormatter:x=>x<0?T(x*-1):T(x),tickLine:!1}),e.jsx(We,{content:e.jsx(na,{className:"!min-w-[120px] px-3 py-2",formatter:(x,w,m,b)=>{const N=Number(x);let p="0";N===0?p="0":p=N<0?T(N*-1):T(N);const h=Number(m?.payload?.new||0),u=Number(m?.payload?.cancelled||0),v=h+u,C=v===0?"0":v>0?`+${T(v)}`:T(v);let S=m?.payload?.date;return m?.payload?.rawDate&&(r==="monthly"?S=z(m.payload.rawDate,366):r==="weekly"?S=z(m.payload.rawDate,91):S=z(m.payload.rawDate,30)),e.jsxs("div",{className:"flex w-full flex-col",children:[b===0&&e.jsx("div",{className:"mb-1 text-sm font-medium text-foreground",children:S}),e.jsxs("div",{className:"flex w-full items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"size-2 shrink-0 rounded-full bg-[var(--color-bg)] opacity-50",style:{"--color-bg":`var(--color-${w})`}}),e.jsx("span",{className:"text-sm text-muted-foreground",children:c[w]?.label||w})]}),e.jsx("div",{className:"ml-auto flex items-baseline gap-0.5 font-mono font-medium tabular-nums text-foreground",children:p})]}),b===1&&e.jsxs("div",{className:"mt-1 flex w-full items-center justify-between gap-4 border-t pt-1",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Net change"}),e.jsx("div",{className:"ml-auto flex items-baseline gap-0.5 font-mono font-medium tabular-nums text-foreground",children:C})]})]})},hideLabel:!0}),cursor:!1,isAnimationActive:!1,position:{y:10}}),e.jsx(Ee,{activeBar:{fillOpacity:1},dataKey:"new",fill:"url(#tealGradient)",fillOpacity:.75,maxBarSize:32,minPointSize:3,radius:[4,4,0,0],stackId:"a"}),e.jsx(Ee,{activeBar:{fillOpacity:1},dataKey:"cancelled",fill:"url(#roseGradient)",fillOpacity:.75,maxBarSize:32,radius:[4,4,0,0],stackId:"a"})]})}),e.jsxs("div",{className:"mt-3 flex items-center justify-center gap-6 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"size-2 rounded-full opacity-50",style:{backgroundColor:c.new.color}}),e.jsx("span",{children:"New"}),e.jsx("span",{className:"font-medium text-foreground",children:T(o.new)})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"size-2 rounded-full opacity-50",style:{backgroundColor:c.cancelled.color}}),e.jsx("span",{children:"Cancelled"}),e.jsx("span",{className:"font-medium text-foreground",children:T(o.cancelled)})]})]})]}):e.jsx("div",{className:"py-12",children:e.jsx(ce,{description:`No paid subscription changes ${U(n)}.`,title:"No paid member changes",children:e.jsx(ca,{strokeWidth:1.5})})})})]})},ka=(s,a,n)=>{const t=s??30,r=a??"mrr desc",{startDate:l,endDate:i}=P.useMemo(()=>se(t),[t]),f=P.useMemo(()=>{const o={date_from:W(l),date_to:W(i),order:r};return n==="posts"?o.post_type="post":n==="pages"&&(o.post_type="page"),o},[l,i,r,n]),g=Object.fromEntries(Object.entries(f).filter(([,o])=>o!==void 0));return Kt({searchParams:g})},hs=()=>{const{range:s,site:a,settings:n}=Te(),t=String(n.find(d=>d.key==="timezone")?.value||"Etc/UTC"),r=De(),[l,i]=P.useState("free_members desc"),[f,g]=P.useState(Q.POSTS_AND_PAGES),[c]=Ke(),{appSettings:o}=je(),j=c.get("tab")||"total-members",[A,x]=P.useState(j);P.useEffect(()=>{j!==A&&x(j)},[j]);const{isLoading:w,chartData:m,totals:b,currencySymbol:N,subscriptionData:p}=ua(s),{data:h,isLoading:u}=ka(s,l,f),v=P.useMemo(()=>{const k=(h?.stats||[]).reduce((_,E)=>{const V=E.post_id||(E.title&&E.title.trim()!==""?E.title:E.attribution_url);if(!V)return _;if(!_.has(V))_.set(V,E);else{const q=_.get(V);q.free_members+=E.free_members,q.paid_members+=E.paid_members,q.mrr+=E.mrr,_.set(V,q)}return _},new Map),y=Array.from(k.values()),D=y.reduce((_,E)=>_+E.free_members,0),O=y.reduce((_,E)=>_+E.paid_members,0),M=y.reduce((_,E)=>_+E.mrr,0);return y.map(_=>{let E=0;return l.includes("free_members")&&D>0?E=_.free_members/D:l.includes("paid_members")&&O>0?E=_.paid_members/O:l.includes("mrr")&&M>0&&(E=_.mrr/M),{title:_.title||_.attribution_url,post_id:_.post_id,attribution_url:_.attribution_url,attribution_type:_.attribution_type,attribution_id:_.attribution_id,free_members:_.free_members,paid_members:_.paid_members,mrr:_.mrr,percentage:E,published_at:_.published_at,url_exists:_.url_exists??!0}})},[h,l]),C=w,S=w||u;return e.jsxs(gt,{children:[e.jsx(vt,{children:e.jsx($t,{children:e.jsx(jt,{})})}),e.jsxs(yt,{data:C?void 0:m,isLoading:!1,loadingComponent:e.jsx(e.Fragment,{}),children:[e.jsx(be,{"data-testid":"total-members-card",children:e.jsx(ge,{children:e.jsx(Sa,{chartData:m,currencySymbol:N,initialTab:j,isLoading:C,totals:b,onTabChange:x})})}),o?.paidMembersEnabled&&A==="paid-members"&&e.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-2 xl:grid-cols-[2fr_minmax(460px,1fr)]",children:[e.jsx(_a,{isLoading:C,memberData:m,range:s,subscriptionData:p}),e.jsx(Da,{isLoading:C,range:s})]}),e.jsxs(be,{className:"w-full overflow-x-auto","data-testid":"top-content-card",children:[e.jsxs(_e,{children:[e.jsx(ke,{children:Ot(f)}),e.jsx(Pe,{children:Mt(f,s,U)})]}),e.jsx(ge,{children:e.jsxs(Ye,{children:[e.jsx(ze,{children:e.jsxs(K,{className:"[&>th]:h-auto [&>th]:pb-2 [&>th]:pt-0",children:[e.jsx(H,{className:"min-w-[320px] pl-0",children:e.jsx(Ve,{defaultValue:f,variant:"button-sm",onValueChange:d=>{g(d)},children:e.jsxs($e,{children:[e.jsx(me,{value:Q.POSTS_AND_PAGES,children:"Posts & pages"}),e.jsx(me,{value:Q.POSTS,children:"Posts"}),e.jsx(me,{value:Q.PAGES,children:"Pages"}),e.jsx(me,{value:Q.SOURCES,children:"Sources"})]})})}),e.jsx(H,{className:"w-[140px] text-right",children:o?.paidMembersEnabled?e.jsx(te,{activeSortBy:l,setSortBy:i,sortBy:"free_members desc",children:"Free members"}):e.jsx(e.Fragment,{children:"Free members"})}),o?.paidMembersEnabled&&e.jsxs(e.Fragment,{children:[e.jsx(H,{className:"w-[140px] text-right",children:e.jsx(te,{activeSortBy:l,setSortBy:i,sortBy:"paid_members desc",children:"Paid members"})}),e.jsx(H,{className:"w-[140px] text-right",children:e.jsx(te,{activeSortBy:l,setSortBy:i,sortBy:"mrr desc",children:"MRR impact"})})]})]})}),f===Q.SOURCES?e.jsx(wa,{limit:20,range:s,setSortBy:d=>i(d),showViewAll:!0,sortBy:l}):e.jsx(le,{children:S?e.jsx(K,{className:"last:border-none",children:e.jsx(F,{className:"border-none py-2",colSpan:1,children:e.jsx(Ge,{containerClassName:"space-y-2",count:5,maxWidth:75,randomize:!0})})}):o?.analytics.membersTrackSources?v.length>0?v.map((d,k)=>e.jsxs(K,{className:"last:border-none",children:[e.jsx(F,{children:e.jsxs("div",{className:"group/link inline-flex flex-col items-start gap-px",children:[d.post_id&&d.attribution_type==="post"?e.jsx(Ce,{className:"h-auto whitespace-normal p-0 text-left font-medium leading-tight hover:!underline",title:"View post analytics",variant:"link",onClick:Rt(d.attribution_url,d.post_id,a.url||"",r,d.attribution_type),children:d.title}):e.jsx("span",{className:"font-medium",children:d.title}),d.published_at&&Oe&&new Date(d.published_at).getTime()>0&&e.jsxs("span",{className:"text-muted-foreground",children:["Published on ",Oe(d.published_at,t)]})]})}),e.jsxs(F,{className:"text-right font-mono text-sm",children:[d.free_members>0&&"+",T(d.free_members)]}),o?.paidMembersEnabled&&e.jsxs(e.Fragment,{children:[e.jsxs(F,{className:"text-right font-mono text-sm",children:[d.paid_members>0&&"+",T(d.paid_members)]}),e.jsxs(F,{className:"text-right font-mono text-sm",children:[d.mrr>0&&"+",N,T(J(d.mrr))]})]})]},`${f}-${d.post_id||`${d.title}-${k}`}`)):e.jsx(K,{className:"border-none",children:e.jsx(F,{className:"py-12 group-hover:!bg-transparent",colSpan:o?.paidMembersEnabled?4:2,children:e.jsx(ce,{description:"Try adjusting your date range to see more data.",title:`No conversions ${U(s)}`,children:e.jsx(da,{strokeWidth:1.5})})})}):e.jsx(K,{className:"last:border-none",children:e.jsx(F,{className:"border-none py-12 group-hover:!bg-transparent",colSpan:o?.paidMembersEnabled?4:2,children:e.jsx(tt,{})})})})]})})]})]})]})};export{hs as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as c}from"./index-CMTzNTew.js";const z=(n,t)=>n==null?t:t==null?n:Math.max(n,t),C=new WeakMap,ut={onUpdate(n,t,e){if(C.set(e,void 0),!e.computedTrend)return;const i=t.integer.concat(t.fraction).filter(o=>o.type==="integer"||o.type==="fraction"),s=n.integer.concat(n.fraction).filter(o=>o.type==="integer"||o.type==="fraction"),r=i.find(o=>!s.find(l=>l.pos===o.pos&&l.value===o.value)),a=s.find(o=>!i.find(l=>o.pos===l.pos&&o.value===l.value));C.set(e,z(r?.pos,a?.pos))},getDelta(n,t,e){const i=n-t,s=C.get(e.flow);if(!i&&s!=null&&s>=e.pos)return e.length*e.flow.computedTrend}},y=(n,t,e)=>{const i=document.createElement(n),[s,r]=Array.isArray(t)?[void 0,t]:[t,e];return s&&Object.assign(i,s),r?.forEach(a=>i.appendChild(a)),i},J=(n,t)=>{var e;return t==="left"?n.offsetLeft:(((e=n.offsetParent instanceof HTMLElement?n.offsetParent:null)==null?void 0:e.offsetWidth)??0)-n.offsetWidth-n.offsetLeft},G=n=>n.offsetWidth>0&&n.offsetHeight>0,Y=(n,t)=>{!customElements.get(n)&&customElements.define(n,t)};function Z(n,t,{reverse:e=!1}={}){const i=n.length;for(let s=e?i-1:0;e?s>=0:s<i;e?s--:s++)t(n[s],s)}function q(n,t,e,i){const s=t.formatToParts(n);e&&s.unshift({type:"prefix",value:e}),i&&s.push({type:"suffix",value:i});const r=[],a=[],o=[],l=[],u={},p=d=>`${d}:${u[d]=(u[d]??-1)+1}`;let f="",m=!1,g=!1;for(const d of s){f+=d.value;const h=d.type==="minusSign"||d.type==="plusSign"?"sign":d.type;h==="integer"?(m=!0,a.push(...d.value.split("").map(A=>({type:h,value:parseInt(A)})))):h==="group"?a.push({type:h,value:d.value}):h==="decimal"?(g=!0,o.push({type:h,value:d.value,key:p(h)})):h==="fraction"?o.push(...d.value.split("").map(A=>({type:h,value:parseInt(A),key:p(h),pos:-1-u[h]}))):(m||g?l:r).push({type:h,value:d.value,key:p(h)})}const M=[];for(let d=a.length-1;d>=0;d--){const h=a[d];M.unshift(h.type==="integer"?{...h,key:p(h.type),pos:u[h.type]}:{...h,key:p(h.type)})}return{pre:r,integer:M,fraction:o,post:l,valueAsString:f,value:typeof n=="string"?parseFloat(n):n}}const Q=String.raw,K=(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0})(),tt=typeof CSS<"u"&&CSS.supports&&CSS.supports("line-height","mod(1,1)"),w=typeof matchMedia<"u"?matchMedia("(prefers-reduced-motion: reduce)"):null,E="--_number-flow-d-opacity",U="--_number-flow-d-width",R="--_number-flow-dx",k="--_number-flow-d",et=(()=>{try{return CSS.registerProperty({name:E,syntax:"<number>",inherits:!1,initialValue:"0"}),CSS.registerProperty({name:R,syntax:"<length>",inherits:!0,initialValue:"0px"}),CSS.registerProperty({name:U,syntax:"<number>",inherits:!1,initialValue:"0"}),CSS.registerProperty({name:k,syntax:"<number>",inherits:!0,initialValue:"0"}),!0}catch{return!1}})(),it="var(--number-flow-char-height, 1em)",v="var(--number-flow-mask-height, 0.25em)",N=`calc(${v} / 2)`,$="var(--number-flow-mask-width, 0.5em)",_=`calc(${$} / var(--scale-x))`,b="#000 0, transparent 71%",P=Q`:host{display:inline-block;direction:ltr;white-space:nowrap;isolation:isolate;line-height:${it} !important}.number,.number__inner{display:inline-block;transform-origin:left top}:host([data-will-change]) :is(.number,.number__inner,.section,.digit,.digit__num,.symbol){will-change:transform}.number{--scale-x:calc(1 + var(${U}) / var(--width));transform:translateX(var(${R})) scaleX(var(--scale-x));margin:0 calc(-1 * ${$});position:relative;-webkit-mask-image:linear-gradient(to right,transparent 0,#000 ${_},#000 calc(100% - ${_}),transparent ),linear-gradient(to bottom,transparent 0,#000 ${v},#000 calc(100% - ${v}),transparent 100% ),radial-gradient(at bottom right,${b}),radial-gradient(at bottom left,${b}),radial-gradient(at top left,${b}),radial-gradient(at top right,${b});-webkit-mask-size:100% calc(100% - ${v} * 2),calc(100% - ${_} * 2) 100%,${_} ${v},${_} ${v},${_} ${v},${_} ${v};-webkit-mask-position:center,center,top left,top right,bottom right,bottom left;-webkit-mask-repeat:no-repeat}.number__inner{padding:${N} ${$};transform:scaleX(calc(1 / var(--scale-x))) translateX(calc(-1 * var(${R})))}:host > :not(.number){z-index:5}.section,.symbol{display:inline-block;position:relative;isolation:isolate}.section::after{content:'\200b';display:inline-block}.section--justify-left{transform-origin:center left}.section--justify-right{transform-origin:center right}.section > [inert],.symbol > [inert]{margin:0 !important;position:absolute !important;z-index:-1}.digit{display:inline-block;position:relative;--c:var(--current) + var(${k})}.digit__num,.number .section::after{padding:${N} 0}.digit__num{display:inline-block;--offset-raw:mod(var(--length) + var(--n) - mod(var(--c),var(--length)),var(--length));--offset:calc( var(--offset-raw) - var(--length) * round(down,var(--offset-raw) / (var(--length) / 2),1) );--y:clamp(-100%,var(--offset) * 100%,100%);transform:translateY(var(--y))}.digit__num[inert]{position:absolute;top:0;left:50%;transform:translateX(-50%) translateY(var(--y))}.digit:not(.is-spinning) .digit__num[inert]{display:none}.symbol__value{display:inline-block;mix-blend-mode:plus-lighter;white-space:pre}.section--justify-left .symbol > [inert]{left:0}.section--justify-right .symbol > [inert]{right:0}.animate-presence{opacity:calc(1 + var(${E}))}`,st=HTMLElement,B=tt&&K&&et;let S;class I extends st{constructor(){super(),this.created=!1,this.batched=!1;const{animated:t,...e}=this.constructor.defaultProps;this._animated=this.computedAnimated=t,Object.assign(this,e)}get animated(){return this._animated}set animated(t){var e;this.animated!==t&&(this._animated=t,(e=this.shadowRoot)==null||e.getAnimations().forEach(i=>i.finish()))}set data(t){var e;if(t==null)return;const{pre:i,integer:s,fraction:r,post:a,value:o}=t;if(this.created){const l=this._data;this._data=t,this.computedTrend=typeof this.trend=="function"?this.trend(l.value,o):this.trend,this.computedAnimated=B&&this._animated&&(!this.respectMotionPreference||!(w!=null&&w.matches))&&G(this),(e=this.plugins)==null||e.forEach(u=>{var p;return(p=u.onUpdate)==null?void 0:p.call(u,t,l,this)}),this.batched||this.willUpdate(),this._pre.update(i),this._num.update({integer:s,fraction:r}),this._post.update(a),this.batched||this.didUpdate()}else{this._data=t,this.attachShadow({mode:"open"});try{this._internals??(this._internals=this.attachInternals()),this._internals.role="img"}catch{}if(typeof CSSStyleSheet<"u"&&this.shadowRoot.adoptedStyleSheets)S||(S=new CSSStyleSheet,S.replaceSync(P)),this.shadowRoot.adoptedStyleSheets=[S];else{const l=document.createElement("style");l.textContent=P,this.shadowRoot.appendChild(l)}this._pre=new F(this,i,{justify:"right",part:"left"}),this.shadowRoot.appendChild(this._pre.el),this._num=new nt(this,s,r),this.shadowRoot.appendChild(this._num.el),this._post=new F(this,a,{justify:"left",part:"right"}),this.shadowRoot.appendChild(this._post.el),this.created=!0}try{this._internals.ariaLabel=t.valueAsString}catch{}}willUpdate(){this._pre.willUpdate(),this._num.willUpdate(),this._post.willUpdate()}didUpdate(){if(!this.computedAnimated)return;this._abortAnimationsFinish?this._abortAnimationsFinish.abort():this.dispatchEvent(new Event("animationsstart")),this._pre.didUpdate(),this._num.didUpdate(),this._post.didUpdate();const t=new AbortController;Promise.all(this.shadowRoot.getAnimations().map(e=>e.finished)).then(()=>{t.signal.aborted||(this.dispatchEvent(new Event("animationsfinish")),this._abortAnimationsFinish=void 0)}),this._abortAnimationsFinish=t}}I.defaultProps={transformTiming:{duration:900,easing:"linear(0,.005,.019,.039,.066,.096,.129,.165,.202,.24,.278,.316,.354,.39,.426,.461,.494,.526,.557,.586,.614,.64,.665,.689,.711,.731,.751,.769,.786,.802,.817,.831,.844,.856,.867,.877,.887,.896,.904,.912,.919,.925,.931,.937,.942,.947,.951,.955,.959,.962,.965,.968,.971,.973,.976,.978,.98,.981,.983,.984,.986,.987,.988,.989,.99,.991,.992,.992,.993,.994,.994,.995,.995,.996,.996,.9963,.9967,.9969,.9972,.9975,.9977,.9979,.9981,.9982,.9984,.9985,.9987,.9988,.9989,1)"},spinTiming:void 0,opacityTiming:{duration:450,easing:"ease-out"},animated:!0,trend:(n,t)=>Math.sign(t-n),respectMotionPreference:!0,plugins:void 0,digits:void 0};class nt{constructor(t,e,i,{className:s,...r}={}){this.flow=t,this._integer=new L(t,e,{justify:"right",part:"integer"}),this._fraction=new L(t,i,{justify:"left",part:"fraction"}),this._inner=y("span",{className:"number__inner"},[this._integer.el,this._fraction.el]),this.el=y("span",{...r,part:"number",className:`number ${s??""}`},[this._inner])}willUpdate(){this._prevWidth=this.el.offsetWidth,this._prevLeft=this.el.getBoundingClientRect().left,this._integer.willUpdate(),this._fraction.willUpdate()}update({integer:t,fraction:e}){this._integer.update(t),this._fraction.update(e)}didUpdate(){const t=this.el.getBoundingClientRect();this._integer.didUpdate(),this._fraction.didUpdate();const e=this._prevLeft-t.left,i=this.el.offsetWidth,s=this._prevWidth-i;this.el.style.setProperty("--width",String(i)),this.el.animate({[R]:[`${e}px`,"0px"],[U]:[s,0]},{...this.flow.transformTiming,composite:"accumulate"})}}class D{constructor(t,e,{justify:i,className:s,...r},a){this.flow=t,this.children=new Map,this.onCharRemove=l=>()=>{this.children.delete(l)},this.justify=i;const o=e.map(l=>this.addChar(l).el);this.el=y("span",{...r,className:`section section--justify-${i} ${s??""}`},a?a(o):o)}addChar(t,{startDigitsAtZero:e=!1,...i}={}){const s=t.type==="integer"||t.type==="fraction"?new X(this,t.type,e?0:t.value,t.pos,{...i,onRemove:this.onCharRemove(t.key)}):new at(this,t.type,t.value,{...i,onRemove:this.onCharRemove(t.key)});return this.children.set(t.key,s),s}unpop(t){t.el.removeAttribute("inert"),t.el.style.top="",t.el.style[this.justify]=""}pop(t){t.forEach(e=>{e.el.style.top=`${e.el.offsetTop}px`,e.el.style[this.justify]=`${J(e.el,this.justify)}px`}),t.forEach(e=>{e.el.setAttribute("inert",""),e.present=!1})}addNewAndUpdateExisting(t){const e=new Map,i=new Map,s=this.justify==="left",r=s?"prepend":"append";if(Z(t,a=>{let o;this.children.has(a.key)?(o=this.children.get(a.key),i.set(a,o),this.unpop(o),o.present=!0):(o=this.addChar(a,{startDigitsAtZero:!0,animateIn:!0}),e.set(a,o)),this.el[r](o.el)},{reverse:s}),this.flow.computedAnimated){const a=this.el.getBoundingClientRect();e.forEach(o=>{o.willUpdate(a)})}e.forEach((a,o)=>{a.update(o.value)}),i.forEach((a,o)=>{a.update(o.value)})}willUpdate(){const t=this.el.getBoundingClientRect();this._prevOffset=t[this.justify],this.children.forEach(e=>e.willUpdate(t))}didUpdate(){const t=this.el.getBoundingClientRect();this.children.forEach(s=>s.didUpdate(t));const e=t[this.justify],i=this._prevOffset-e;i&&this.children.size&&this.el.animate({transform:[`translateX(${i}px)`,"none"]},{...this.flow.transformTiming,composite:"accumulate"})}}class L extends D{update(t){const e=new Map;this.children.forEach((i,s)=>{t.find(r=>r.key===s)||e.set(s,i),this.unpop(i)}),this.addNewAndUpdateExisting(t),e.forEach(i=>{i instanceof X&&i.update(0)}),this.pop(e)}}class F extends D{update(t){const e=new Map;this.children.forEach((i,s)=>{t.find(r=>r.key===s)||e.set(s,i)}),this.pop(e),this.addNewAndUpdateExisting(t)}}class x{constructor(t,e,{onRemove:i,animateIn:s=!1}={}){this.flow=t,this.el=e,this._present=!0,this._remove=()=>{var r;this.el.remove(),(r=this._onRemove)==null||r.call(this)},this.el.classList.add("animate-presence"),this.flow.computedAnimated&&s&&this.el.animate({[E]:[-.9999,0]},{...this.flow.opacityTiming,composite:"accumulate"}),this._onRemove=i}get present(){return this._present}set present(t){if(this._present!==t){if(this._present=t,t?this.el.removeAttribute("inert"):this.el.setAttribute("inert",""),!this.flow.computedAnimated){t||this._remove();return}this.el.style.setProperty("--_number-flow-d-opacity",t?"0":"-.999"),this.el.animate({[E]:t?[-.9999,0]:[.999,0]},{...this.flow.opacityTiming,composite:"accumulate"}),t?this.flow.removeEventListener("animationsfinish",this._remove):this.flow.addEventListener("animationsfinish",this._remove,{once:!0})}}}class W extends x{constructor(t,e,i,s){super(t.flow,i,s),this.section=t,this.value=e,this.el=i}}class X extends W{constructor(t,e,i,s,r){var a,o;const l=(((o=(a=t.flow.digits)==null?void 0:a[s])==null?void 0:o.max)??9)+1,u=Array.from({length:l}).map((f,m)=>{const g=y("span",{className:"digit__num"},[document.createTextNode(String(m))]);return m!==i&&g.setAttribute("inert",""),g.style.setProperty("--n",String(m)),g}),p=y("span",{part:`digit ${e}-digit`,className:"digit"},u);p.style.setProperty("--current",String(i)),p.style.setProperty("--length",String(l)),super(t,i,p,r),this.pos=s,this._onAnimationsFinish=()=>{this.el.classList.remove("is-spinning")},this._numbers=u,this.length=l}willUpdate(t){const e=this.el.getBoundingClientRect();this._prevValue=this.value;const i=e[this.section.justify]-t[this.section.justify],s=e.width/2;this._prevCenter=this.section.justify==="left"?i+s:i-s}update(t){this.el.style.setProperty("--current",String(t)),this._numbers.forEach((e,i)=>i===t?e.removeAttribute("inert"):e.setAttribute("inert","")),this.value=t}didUpdate(t){const e=this.el.getBoundingClientRect(),i=e[this.section.justify]-t[this.section.justify],s=e.width/2,r=this.section.justify==="left"?i+s:i-s,a=this._prevCenter-r;a&&this.el.animate({transform:[`translateX(${a}px)`,"none"]},{...this.flow.transformTiming,composite:"accumulate"});const o=this.getDelta();o&&(this.el.classList.add("is-spinning"),this.el.animate({[k]:[-o,0]},{...this.flow.spinTiming??this.flow.transformTiming,composite:"accumulate"}),this.flow.addEventListener("animationsfinish",this._onAnimationsFinish,{once:!0}))}getDelta(){var t;if(this.flow.plugins)for(const s of this.flow.plugins){const r=(t=s.getDelta)==null?void 0:t.call(s,this.value,this._prevValue,this);if(r!=null)return r}const e=this.value-this._prevValue,i=this.flow.computedTrend||Math.sign(e);return i<0&&this.value>this._prevValue?this.value-this.length-this._prevValue:i>0&&this.value<this._prevValue?this.length-this._prevValue+this.value:e}}class at extends W{constructor(t,e,i,s){const r=y("span",{className:"symbol__value",textContent:i});super(t,i,y("span",{part:`symbol ${e}`,className:"symbol"},[r]),s),this.type=e,this._children=new Map,this._onChildRemove=a=>()=>{this._children.delete(a)},this._children.set(i,new x(this.flow,r,{onRemove:this._onChildRemove(i)}))}willUpdate(t){if(this.type==="decimal")return;const e=this.el.getBoundingClientRect();this._prevOffset=e[this.section.justify]-t[this.section.justify]}update(t){if(this.value!==t){const e=this._children.get(this.value);e&&(e.present=!1);const i=this._children.get(t);if(i)i.present=!0;else{const s=y("span",{className:"symbol__value",textContent:t});this.el.appendChild(s),this._children.set(t,new x(this.flow,s,{animateIn:!0,onRemove:this._onChildRemove(t)}))}}this.value=t}didUpdate(t){if(this.type==="decimal")return;const e=this.el.getBoundingClientRect()[this.section.justify]-t[this.section.justify],i=this._prevOffset-e;i&&this.el.animate({transform:[`translateX(${i}px)`,"none"]},{...this.flow.transformTiming,composite:"accumulate"})}}const rt=parseInt(c.version.match(/^(\d+)\./)?.[1]),j=rt>=19,ot=["data","digits"];class T extends I{attributeChangedCallback(t,e,i){this[t]=JSON.parse(i)}}T.observedAttributes=j?[]:ot;Y("number-flow-react",T);const lt={},O=j?n=>n:JSON.stringify;function V(n){const{transformTiming:t,spinTiming:e,opacityTiming:i,animated:s,respectMotionPreference:r,trend:a,plugins:o,...l}=n;return[{transformTiming:t,spinTiming:e,opacityTiming:i,animated:s,respectMotionPreference:r,trend:a,plugins:o},l]}class ht extends c.Component{updateProperties(t){if(!this.el)return;this.el.batched=!this.props.isolate;const[e]=V(this.props);Object.entries(e).forEach(([i,s])=>{this.el[i]=s??T.defaultProps[i]}),t?.onAnimationsStart&&this.el.removeEventListener("animationsstart",t.onAnimationsStart),this.props.onAnimationsStart&&this.el.addEventListener("animationsstart",this.props.onAnimationsStart),t?.onAnimationsFinish&&this.el.removeEventListener("animationsfinish",t.onAnimationsFinish),this.props.onAnimationsFinish&&this.el.addEventListener("animationsfinish",this.props.onAnimationsFinish)}componentDidMount(){this.updateProperties(),j&&this.el&&(this.el.digits=this.props.digits,this.el.data=this.props.data)}getSnapshotBeforeUpdate(t){if(this.updateProperties(t),t.data!==this.props.data){if(this.props.group)return this.props.group.willUpdate(),()=>this.props.group?.didUpdate();if(!this.props.isolate)return this.el?.willUpdate(),()=>this.el?.didUpdate()}return null}componentDidUpdate(t,e,i){i?.()}handleRef(t){this.props.innerRef&&(this.props.innerRef.current=t),this.el=t}render(){const[t,{innerRef:e,className:i,data:s,willChange:r,isolate:a,group:o,digits:l,onAnimationsStart:u,onAnimationsFinish:p,...f}]=V(this.props);return c.createElement("number-flow-react",{ref:this.handleRef,"data-will-change":r?"":void 0,class:i,...f,dangerouslySetInnerHTML:{__html:""},suppressHydrationWarning:!0,digits:O(l),data:O(s)})}constructor(t){super(t),this.handleRef=this.handleRef.bind(this)}}const ft=c.forwardRef(function({value:t,locales:e,format:i,prefix:s,suffix:r,...a},o){c.useImperativeHandle(o,()=>l.current,[]);const l=c.useRef(),u=c.useContext(H);u?.useRegister(l);const p=c.useMemo(()=>e?JSON.stringify(e):"",[e]),f=c.useMemo(()=>i?JSON.stringify(i):"",[i]),m=c.useMemo(()=>{const g=lt[`${p}:${f}`]??=new Intl.NumberFormat(e,i);return q(t,g,s,r)},[t,p,f,s,r]);return c.createElement(ht,{...a,group:u,data:m,innerRef:l})}),H=c.createContext(void 0);function mt({children:n}){const t=c.useRef(new Set),e=c.useRef(!1),i=c.useRef(new WeakMap),s=c.useMemo(()=>({useRegister(r){c.useEffect(()=>(t.current.add(r),()=>{t.current.delete(r)}),[])},willUpdate(){e.current||(e.current=!0,t.current.forEach(r=>{const a=r.current;!a||!a.created||(a.willUpdate(),i.current.set(a,!0))}))},didUpdate(){t.current.forEach(r=>{const a=r.current;!a||!i.current.get(a)||(a.didUpdate(),i.current.delete(a))}),e.current=!1}}),[]);return c.createElement(H.Provider,{value:s},n)}const ct=()=>c.useSyncExternalStore(()=>()=>{},()=>B,()=>!1),dt=()=>c.useSyncExternalStore(n=>(w?.addEventListener("change",n),()=>w?.removeEventListener("change",n)),()=>w.matches,()=>!1);function gt({respectMotionPreference:n=!0}={}){const t=ct(),e=dt();return t&&(!n||!e)}export{T as NumberFlowElement,mt as NumberFlowGroup,ut as continuous,ft as default,gt as useCanAnimate,ct as useIsSupported,dt as usePrefersReducedMotion};
|
|
1
|
+
import{r as c}from"./index-B8G0f0hb.js";const z=(n,t)=>n==null?t:t==null?n:Math.max(n,t),C=new WeakMap,ut={onUpdate(n,t,e){if(C.set(e,void 0),!e.computedTrend)return;const i=t.integer.concat(t.fraction).filter(o=>o.type==="integer"||o.type==="fraction"),s=n.integer.concat(n.fraction).filter(o=>o.type==="integer"||o.type==="fraction"),r=i.find(o=>!s.find(l=>l.pos===o.pos&&l.value===o.value)),a=s.find(o=>!i.find(l=>o.pos===l.pos&&o.value===l.value));C.set(e,z(r?.pos,a?.pos))},getDelta(n,t,e){const i=n-t,s=C.get(e.flow);if(!i&&s!=null&&s>=e.pos)return e.length*e.flow.computedTrend}},y=(n,t,e)=>{const i=document.createElement(n),[s,r]=Array.isArray(t)?[void 0,t]:[t,e];return s&&Object.assign(i,s),r?.forEach(a=>i.appendChild(a)),i},J=(n,t)=>{var e;return t==="left"?n.offsetLeft:(((e=n.offsetParent instanceof HTMLElement?n.offsetParent:null)==null?void 0:e.offsetWidth)??0)-n.offsetWidth-n.offsetLeft},G=n=>n.offsetWidth>0&&n.offsetHeight>0,Y=(n,t)=>{!customElements.get(n)&&customElements.define(n,t)};function Z(n,t,{reverse:e=!1}={}){const i=n.length;for(let s=e?i-1:0;e?s>=0:s<i;e?s--:s++)t(n[s],s)}function q(n,t,e,i){const s=t.formatToParts(n);e&&s.unshift({type:"prefix",value:e}),i&&s.push({type:"suffix",value:i});const r=[],a=[],o=[],l=[],u={},p=d=>`${d}:${u[d]=(u[d]??-1)+1}`;let f="",m=!1,g=!1;for(const d of s){f+=d.value;const h=d.type==="minusSign"||d.type==="plusSign"?"sign":d.type;h==="integer"?(m=!0,a.push(...d.value.split("").map(A=>({type:h,value:parseInt(A)})))):h==="group"?a.push({type:h,value:d.value}):h==="decimal"?(g=!0,o.push({type:h,value:d.value,key:p(h)})):h==="fraction"?o.push(...d.value.split("").map(A=>({type:h,value:parseInt(A),key:p(h),pos:-1-u[h]}))):(m||g?l:r).push({type:h,value:d.value,key:p(h)})}const M=[];for(let d=a.length-1;d>=0;d--){const h=a[d];M.unshift(h.type==="integer"?{...h,key:p(h.type),pos:u[h.type]}:{...h,key:p(h.type)})}return{pre:r,integer:M,fraction:o,post:l,valueAsString:f,value:typeof n=="string"?parseFloat(n):n}}const Q=String.raw,K=(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0})(),tt=typeof CSS<"u"&&CSS.supports&&CSS.supports("line-height","mod(1,1)"),w=typeof matchMedia<"u"?matchMedia("(prefers-reduced-motion: reduce)"):null,E="--_number-flow-d-opacity",U="--_number-flow-d-width",R="--_number-flow-dx",k="--_number-flow-d",et=(()=>{try{return CSS.registerProperty({name:E,syntax:"<number>",inherits:!1,initialValue:"0"}),CSS.registerProperty({name:R,syntax:"<length>",inherits:!0,initialValue:"0px"}),CSS.registerProperty({name:U,syntax:"<number>",inherits:!1,initialValue:"0"}),CSS.registerProperty({name:k,syntax:"<number>",inherits:!0,initialValue:"0"}),!0}catch{return!1}})(),it="var(--number-flow-char-height, 1em)",v="var(--number-flow-mask-height, 0.25em)",N=`calc(${v} / 2)`,$="var(--number-flow-mask-width, 0.5em)",_=`calc(${$} / var(--scale-x))`,b="#000 0, transparent 71%",P=Q`:host{display:inline-block;direction:ltr;white-space:nowrap;isolation:isolate;line-height:${it} !important}.number,.number__inner{display:inline-block;transform-origin:left top}:host([data-will-change]) :is(.number,.number__inner,.section,.digit,.digit__num,.symbol){will-change:transform}.number{--scale-x:calc(1 + var(${U}) / var(--width));transform:translateX(var(${R})) scaleX(var(--scale-x));margin:0 calc(-1 * ${$});position:relative;-webkit-mask-image:linear-gradient(to right,transparent 0,#000 ${_},#000 calc(100% - ${_}),transparent ),linear-gradient(to bottom,transparent 0,#000 ${v},#000 calc(100% - ${v}),transparent 100% ),radial-gradient(at bottom right,${b}),radial-gradient(at bottom left,${b}),radial-gradient(at top left,${b}),radial-gradient(at top right,${b});-webkit-mask-size:100% calc(100% - ${v} * 2),calc(100% - ${_} * 2) 100%,${_} ${v},${_} ${v},${_} ${v},${_} ${v};-webkit-mask-position:center,center,top left,top right,bottom right,bottom left;-webkit-mask-repeat:no-repeat}.number__inner{padding:${N} ${$};transform:scaleX(calc(1 / var(--scale-x))) translateX(calc(-1 * var(${R})))}:host > :not(.number){z-index:5}.section,.symbol{display:inline-block;position:relative;isolation:isolate}.section::after{content:'\200b';display:inline-block}.section--justify-left{transform-origin:center left}.section--justify-right{transform-origin:center right}.section > [inert],.symbol > [inert]{margin:0 !important;position:absolute !important;z-index:-1}.digit{display:inline-block;position:relative;--c:var(--current) + var(${k})}.digit__num,.number .section::after{padding:${N} 0}.digit__num{display:inline-block;--offset-raw:mod(var(--length) + var(--n) - mod(var(--c),var(--length)),var(--length));--offset:calc( var(--offset-raw) - var(--length) * round(down,var(--offset-raw) / (var(--length) / 2),1) );--y:clamp(-100%,var(--offset) * 100%,100%);transform:translateY(var(--y))}.digit__num[inert]{position:absolute;top:0;left:50%;transform:translateX(-50%) translateY(var(--y))}.digit:not(.is-spinning) .digit__num[inert]{display:none}.symbol__value{display:inline-block;mix-blend-mode:plus-lighter;white-space:pre}.section--justify-left .symbol > [inert]{left:0}.section--justify-right .symbol > [inert]{right:0}.animate-presence{opacity:calc(1 + var(${E}))}`,st=HTMLElement,B=tt&&K&&et;let S;class I extends st{constructor(){super(),this.created=!1,this.batched=!1;const{animated:t,...e}=this.constructor.defaultProps;this._animated=this.computedAnimated=t,Object.assign(this,e)}get animated(){return this._animated}set animated(t){var e;this.animated!==t&&(this._animated=t,(e=this.shadowRoot)==null||e.getAnimations().forEach(i=>i.finish()))}set data(t){var e;if(t==null)return;const{pre:i,integer:s,fraction:r,post:a,value:o}=t;if(this.created){const l=this._data;this._data=t,this.computedTrend=typeof this.trend=="function"?this.trend(l.value,o):this.trend,this.computedAnimated=B&&this._animated&&(!this.respectMotionPreference||!(w!=null&&w.matches))&&G(this),(e=this.plugins)==null||e.forEach(u=>{var p;return(p=u.onUpdate)==null?void 0:p.call(u,t,l,this)}),this.batched||this.willUpdate(),this._pre.update(i),this._num.update({integer:s,fraction:r}),this._post.update(a),this.batched||this.didUpdate()}else{this._data=t,this.attachShadow({mode:"open"});try{this._internals??(this._internals=this.attachInternals()),this._internals.role="img"}catch{}if(typeof CSSStyleSheet<"u"&&this.shadowRoot.adoptedStyleSheets)S||(S=new CSSStyleSheet,S.replaceSync(P)),this.shadowRoot.adoptedStyleSheets=[S];else{const l=document.createElement("style");l.textContent=P,this.shadowRoot.appendChild(l)}this._pre=new F(this,i,{justify:"right",part:"left"}),this.shadowRoot.appendChild(this._pre.el),this._num=new nt(this,s,r),this.shadowRoot.appendChild(this._num.el),this._post=new F(this,a,{justify:"left",part:"right"}),this.shadowRoot.appendChild(this._post.el),this.created=!0}try{this._internals.ariaLabel=t.valueAsString}catch{}}willUpdate(){this._pre.willUpdate(),this._num.willUpdate(),this._post.willUpdate()}didUpdate(){if(!this.computedAnimated)return;this._abortAnimationsFinish?this._abortAnimationsFinish.abort():this.dispatchEvent(new Event("animationsstart")),this._pre.didUpdate(),this._num.didUpdate(),this._post.didUpdate();const t=new AbortController;Promise.all(this.shadowRoot.getAnimations().map(e=>e.finished)).then(()=>{t.signal.aborted||(this.dispatchEvent(new Event("animationsfinish")),this._abortAnimationsFinish=void 0)}),this._abortAnimationsFinish=t}}I.defaultProps={transformTiming:{duration:900,easing:"linear(0,.005,.019,.039,.066,.096,.129,.165,.202,.24,.278,.316,.354,.39,.426,.461,.494,.526,.557,.586,.614,.64,.665,.689,.711,.731,.751,.769,.786,.802,.817,.831,.844,.856,.867,.877,.887,.896,.904,.912,.919,.925,.931,.937,.942,.947,.951,.955,.959,.962,.965,.968,.971,.973,.976,.978,.98,.981,.983,.984,.986,.987,.988,.989,.99,.991,.992,.992,.993,.994,.994,.995,.995,.996,.996,.9963,.9967,.9969,.9972,.9975,.9977,.9979,.9981,.9982,.9984,.9985,.9987,.9988,.9989,1)"},spinTiming:void 0,opacityTiming:{duration:450,easing:"ease-out"},animated:!0,trend:(n,t)=>Math.sign(t-n),respectMotionPreference:!0,plugins:void 0,digits:void 0};class nt{constructor(t,e,i,{className:s,...r}={}){this.flow=t,this._integer=new L(t,e,{justify:"right",part:"integer"}),this._fraction=new L(t,i,{justify:"left",part:"fraction"}),this._inner=y("span",{className:"number__inner"},[this._integer.el,this._fraction.el]),this.el=y("span",{...r,part:"number",className:`number ${s??""}`},[this._inner])}willUpdate(){this._prevWidth=this.el.offsetWidth,this._prevLeft=this.el.getBoundingClientRect().left,this._integer.willUpdate(),this._fraction.willUpdate()}update({integer:t,fraction:e}){this._integer.update(t),this._fraction.update(e)}didUpdate(){const t=this.el.getBoundingClientRect();this._integer.didUpdate(),this._fraction.didUpdate();const e=this._prevLeft-t.left,i=this.el.offsetWidth,s=this._prevWidth-i;this.el.style.setProperty("--width",String(i)),this.el.animate({[R]:[`${e}px`,"0px"],[U]:[s,0]},{...this.flow.transformTiming,composite:"accumulate"})}}class D{constructor(t,e,{justify:i,className:s,...r},a){this.flow=t,this.children=new Map,this.onCharRemove=l=>()=>{this.children.delete(l)},this.justify=i;const o=e.map(l=>this.addChar(l).el);this.el=y("span",{...r,className:`section section--justify-${i} ${s??""}`},a?a(o):o)}addChar(t,{startDigitsAtZero:e=!1,...i}={}){const s=t.type==="integer"||t.type==="fraction"?new X(this,t.type,e?0:t.value,t.pos,{...i,onRemove:this.onCharRemove(t.key)}):new at(this,t.type,t.value,{...i,onRemove:this.onCharRemove(t.key)});return this.children.set(t.key,s),s}unpop(t){t.el.removeAttribute("inert"),t.el.style.top="",t.el.style[this.justify]=""}pop(t){t.forEach(e=>{e.el.style.top=`${e.el.offsetTop}px`,e.el.style[this.justify]=`${J(e.el,this.justify)}px`}),t.forEach(e=>{e.el.setAttribute("inert",""),e.present=!1})}addNewAndUpdateExisting(t){const e=new Map,i=new Map,s=this.justify==="left",r=s?"prepend":"append";if(Z(t,a=>{let o;this.children.has(a.key)?(o=this.children.get(a.key),i.set(a,o),this.unpop(o),o.present=!0):(o=this.addChar(a,{startDigitsAtZero:!0,animateIn:!0}),e.set(a,o)),this.el[r](o.el)},{reverse:s}),this.flow.computedAnimated){const a=this.el.getBoundingClientRect();e.forEach(o=>{o.willUpdate(a)})}e.forEach((a,o)=>{a.update(o.value)}),i.forEach((a,o)=>{a.update(o.value)})}willUpdate(){const t=this.el.getBoundingClientRect();this._prevOffset=t[this.justify],this.children.forEach(e=>e.willUpdate(t))}didUpdate(){const t=this.el.getBoundingClientRect();this.children.forEach(s=>s.didUpdate(t));const e=t[this.justify],i=this._prevOffset-e;i&&this.children.size&&this.el.animate({transform:[`translateX(${i}px)`,"none"]},{...this.flow.transformTiming,composite:"accumulate"})}}class L extends D{update(t){const e=new Map;this.children.forEach((i,s)=>{t.find(r=>r.key===s)||e.set(s,i),this.unpop(i)}),this.addNewAndUpdateExisting(t),e.forEach(i=>{i instanceof X&&i.update(0)}),this.pop(e)}}class F extends D{update(t){const e=new Map;this.children.forEach((i,s)=>{t.find(r=>r.key===s)||e.set(s,i)}),this.pop(e),this.addNewAndUpdateExisting(t)}}class x{constructor(t,e,{onRemove:i,animateIn:s=!1}={}){this.flow=t,this.el=e,this._present=!0,this._remove=()=>{var r;this.el.remove(),(r=this._onRemove)==null||r.call(this)},this.el.classList.add("animate-presence"),this.flow.computedAnimated&&s&&this.el.animate({[E]:[-.9999,0]},{...this.flow.opacityTiming,composite:"accumulate"}),this._onRemove=i}get present(){return this._present}set present(t){if(this._present!==t){if(this._present=t,t?this.el.removeAttribute("inert"):this.el.setAttribute("inert",""),!this.flow.computedAnimated){t||this._remove();return}this.el.style.setProperty("--_number-flow-d-opacity",t?"0":"-.999"),this.el.animate({[E]:t?[-.9999,0]:[.999,0]},{...this.flow.opacityTiming,composite:"accumulate"}),t?this.flow.removeEventListener("animationsfinish",this._remove):this.flow.addEventListener("animationsfinish",this._remove,{once:!0})}}}class W extends x{constructor(t,e,i,s){super(t.flow,i,s),this.section=t,this.value=e,this.el=i}}class X extends W{constructor(t,e,i,s,r){var a,o;const l=(((o=(a=t.flow.digits)==null?void 0:a[s])==null?void 0:o.max)??9)+1,u=Array.from({length:l}).map((f,m)=>{const g=y("span",{className:"digit__num"},[document.createTextNode(String(m))]);return m!==i&&g.setAttribute("inert",""),g.style.setProperty("--n",String(m)),g}),p=y("span",{part:`digit ${e}-digit`,className:"digit"},u);p.style.setProperty("--current",String(i)),p.style.setProperty("--length",String(l)),super(t,i,p,r),this.pos=s,this._onAnimationsFinish=()=>{this.el.classList.remove("is-spinning")},this._numbers=u,this.length=l}willUpdate(t){const e=this.el.getBoundingClientRect();this._prevValue=this.value;const i=e[this.section.justify]-t[this.section.justify],s=e.width/2;this._prevCenter=this.section.justify==="left"?i+s:i-s}update(t){this.el.style.setProperty("--current",String(t)),this._numbers.forEach((e,i)=>i===t?e.removeAttribute("inert"):e.setAttribute("inert","")),this.value=t}didUpdate(t){const e=this.el.getBoundingClientRect(),i=e[this.section.justify]-t[this.section.justify],s=e.width/2,r=this.section.justify==="left"?i+s:i-s,a=this._prevCenter-r;a&&this.el.animate({transform:[`translateX(${a}px)`,"none"]},{...this.flow.transformTiming,composite:"accumulate"});const o=this.getDelta();o&&(this.el.classList.add("is-spinning"),this.el.animate({[k]:[-o,0]},{...this.flow.spinTiming??this.flow.transformTiming,composite:"accumulate"}),this.flow.addEventListener("animationsfinish",this._onAnimationsFinish,{once:!0}))}getDelta(){var t;if(this.flow.plugins)for(const s of this.flow.plugins){const r=(t=s.getDelta)==null?void 0:t.call(s,this.value,this._prevValue,this);if(r!=null)return r}const e=this.value-this._prevValue,i=this.flow.computedTrend||Math.sign(e);return i<0&&this.value>this._prevValue?this.value-this.length-this._prevValue:i>0&&this.value<this._prevValue?this.length-this._prevValue+this.value:e}}class at extends W{constructor(t,e,i,s){const r=y("span",{className:"symbol__value",textContent:i});super(t,i,y("span",{part:`symbol ${e}`,className:"symbol"},[r]),s),this.type=e,this._children=new Map,this._onChildRemove=a=>()=>{this._children.delete(a)},this._children.set(i,new x(this.flow,r,{onRemove:this._onChildRemove(i)}))}willUpdate(t){if(this.type==="decimal")return;const e=this.el.getBoundingClientRect();this._prevOffset=e[this.section.justify]-t[this.section.justify]}update(t){if(this.value!==t){const e=this._children.get(this.value);e&&(e.present=!1);const i=this._children.get(t);if(i)i.present=!0;else{const s=y("span",{className:"symbol__value",textContent:t});this.el.appendChild(s),this._children.set(t,new x(this.flow,s,{animateIn:!0,onRemove:this._onChildRemove(t)}))}}this.value=t}didUpdate(t){if(this.type==="decimal")return;const e=this.el.getBoundingClientRect()[this.section.justify]-t[this.section.justify],i=this._prevOffset-e;i&&this.el.animate({transform:[`translateX(${i}px)`,"none"]},{...this.flow.transformTiming,composite:"accumulate"})}}const rt=parseInt(c.version.match(/^(\d+)\./)?.[1]),j=rt>=19,ot=["data","digits"];class T extends I{attributeChangedCallback(t,e,i){this[t]=JSON.parse(i)}}T.observedAttributes=j?[]:ot;Y("number-flow-react",T);const lt={},O=j?n=>n:JSON.stringify;function V(n){const{transformTiming:t,spinTiming:e,opacityTiming:i,animated:s,respectMotionPreference:r,trend:a,plugins:o,...l}=n;return[{transformTiming:t,spinTiming:e,opacityTiming:i,animated:s,respectMotionPreference:r,trend:a,plugins:o},l]}class ht extends c.Component{updateProperties(t){if(!this.el)return;this.el.batched=!this.props.isolate;const[e]=V(this.props);Object.entries(e).forEach(([i,s])=>{this.el[i]=s??T.defaultProps[i]}),t?.onAnimationsStart&&this.el.removeEventListener("animationsstart",t.onAnimationsStart),this.props.onAnimationsStart&&this.el.addEventListener("animationsstart",this.props.onAnimationsStart),t?.onAnimationsFinish&&this.el.removeEventListener("animationsfinish",t.onAnimationsFinish),this.props.onAnimationsFinish&&this.el.addEventListener("animationsfinish",this.props.onAnimationsFinish)}componentDidMount(){this.updateProperties(),j&&this.el&&(this.el.digits=this.props.digits,this.el.data=this.props.data)}getSnapshotBeforeUpdate(t){if(this.updateProperties(t),t.data!==this.props.data){if(this.props.group)return this.props.group.willUpdate(),()=>this.props.group?.didUpdate();if(!this.props.isolate)return this.el?.willUpdate(),()=>this.el?.didUpdate()}return null}componentDidUpdate(t,e,i){i?.()}handleRef(t){this.props.innerRef&&(this.props.innerRef.current=t),this.el=t}render(){const[t,{innerRef:e,className:i,data:s,willChange:r,isolate:a,group:o,digits:l,onAnimationsStart:u,onAnimationsFinish:p,...f}]=V(this.props);return c.createElement("number-flow-react",{ref:this.handleRef,"data-will-change":r?"":void 0,class:i,...f,dangerouslySetInnerHTML:{__html:""},suppressHydrationWarning:!0,digits:O(l),data:O(s)})}constructor(t){super(t),this.handleRef=this.handleRef.bind(this)}}const ft=c.forwardRef(function({value:t,locales:e,format:i,prefix:s,suffix:r,...a},o){c.useImperativeHandle(o,()=>l.current,[]);const l=c.useRef(),u=c.useContext(H);u?.useRegister(l);const p=c.useMemo(()=>e?JSON.stringify(e):"",[e]),f=c.useMemo(()=>i?JSON.stringify(i):"",[i]),m=c.useMemo(()=>{const g=lt[`${p}:${f}`]??=new Intl.NumberFormat(e,i);return q(t,g,s,r)},[t,p,f,s,r]);return c.createElement(ht,{...a,group:u,data:m,innerRef:l})}),H=c.createContext(void 0);function mt({children:n}){const t=c.useRef(new Set),e=c.useRef(!1),i=c.useRef(new WeakMap),s=c.useMemo(()=>({useRegister(r){c.useEffect(()=>(t.current.add(r),()=>{t.current.delete(r)}),[])},willUpdate(){e.current||(e.current=!0,t.current.forEach(r=>{const a=r.current;!a||!a.created||(a.willUpdate(),i.current.set(a,!0))}))},didUpdate(){t.current.forEach(r=>{const a=r.current;!a||!i.current.get(a)||(a.didUpdate(),i.current.delete(a))}),e.current=!1}}),[]);return c.createElement(H.Provider,{value:s},n)}const ct=()=>c.useSyncExternalStore(()=>()=>{},()=>B,()=>!1),dt=()=>c.useSyncExternalStore(n=>(w?.addEventListener("change",n),()=>w?.removeEventListener("change",n)),()=>w.matches,()=>!1);function gt({respectMotionPreference:n=!0}={}){const t=ct(),e=dt();return t&&(!n||!e)}export{T as NumberFlowElement,mt as NumberFlowGroup,ut as continuous,ft as default,gt as useCanAnimate,ct as useIsSupported,dt as usePrefersReducedMotion};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{e as R,r as F,aB as uR,aC as ine,aD as fR}from"./index-
|
|
1
|
+
import{e as R,r as F,aB as uR,aC as ine,aD as fR}from"./index-B8G0f0hb.js";var Kd={},rne=Object.defineProperty,one=(t,e,n)=>e in t?rne(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,we=(t,e,n)=>one(t,typeof e!="symbol"?e+"":e,n);(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="bfe81679-99e3-4b92-baf2-93d0d8b7ea9d",t._sentryDebugIdIdentifier="sentry-dbid-bfe81679-99e3-4b92-baf2-93d0d8b7ea9d")}catch{}})();var nn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function qo(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function vk(t){if(t.__esModule)return t;var e=t.default;if(typeof e=="function"){var n=function i(){return this instanceof i?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach(function(i){var r=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(n,i,r.get?r:{enumerable:!0,get:function(){return t[i]}})}),n}var hR={exports:{}},bk={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as a,y as o,B as s}from"./index-
|
|
1
|
+
import{j as a,y as o,B as s}from"./index-B8G0f0hb.js";const i=({children:e,className:r,...t})=>a.jsx("div",{className:o("flex flex-col",r),...t,children:e}),l=({children:e,className:r,...t})=>a.jsx("div",{className:o("[&_svg]:size-4 flex items-center gap-1.5 text-base h-[22px] font-medium transition-all",r,t.onClick&&"hover:cursor-pointer hover:text-black dark:hover:text-white"),...t,children:e}),d=({children:e,className:r,...t})=>a.jsx("div",{className:o("text-[26px] mt-0.5 tracking-tighter leading-none text-foreground font-semibold",r),...t,children:e}),c=({children:e,className:r,...t})=>a.jsx(s,{className:o("absolute right-4 top-4 z-50 hidden translate-x-10 text-black dark:text-white/80 dark:hover:text-white opacity-0 transition-all duration-200 group-hover:translate-x-0 group-hover:opacity-100 md:!visible md:!block",r),size:"sm",variant:"outline",...t,children:e}),x=({children:e,className:r,...t})=>a.jsx("div",{className:o("group relative isolate flex flex-col border-r border-border last:border-none items-start gap-2 px-6 py-5 transition-all text-muted-foreground",t.onClick?"hover:bg-accent/50 hover:text-foreground cursor-pointer":"cursor-auto",r),...t,children:e});export{x as K,l as a,i as b,d as c,c as d};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as N,j as s,by as w,bz as T,B as y,bA as D,bB as C,bC as L,bD as S,aS as E,bE as I,aj as u,ai as g,bF as H,bG as $,r as G,aW as O,bH as q,ap as F,bI as W,bJ as k}from"./index-
|
|
1
|
+
import{e as N,j as s,by as w,bz as T,B as y,bA as D,bB as C,bC as L,bD as S,aS as E,bE as I,aj as u,ai as g,bF as H,bG as $,r as G,aW as O,bH as q,ap as F,bI as W,bJ as k}from"./index-B8G0f0hb.js";import{S as K}from"./source-icon-DTz4isLK.js";import{p as J,e as U}from"./source-utils-B1S3ZHA2.js";import{C as M,a as Q,b as X,f as Y,c as P,g as Z}from"./pagemenu-CkzsZrHC.js";import{D as ss,h as es,i as V,a as as,b as ts,c as rs,d as is,e as ls,f as ns,g as cs}from"./data-list-Dn5MkmyD.js";import{S as os,u as ds}from"./post-analytics-context-BLkup0Xh.js";import{A as hs}from"./lucide-react-ClQ3Iy7l.js";import{a as ms}from"./wallet-cards-xX4QZik7.js";import{G as us}from"./gh-chart-B2aWYkGg.js";import{T as xs,a as ps,K as _,d as x,e as vs}from"./tabs-CjNdfW0y.js";const js=i=>{const a=Object.values(os).find(l=>l.value===i);return a?["Last 7 days","Last 30 days","Last 90 days","Last 12 months"].includes(a.name)?`in the ${a.name.toLowerCase()}`:a.name==="All time"?"(all time)":a.name.toLowerCase():""},R="https://www.google.com/s2/favicons?domain=ghost.org&sz=64",p=({dataTableHeader:i,data:a,defaultSourceIconUrl:l=R,onSourceClick:o})=>s.jsxs(ss,{children:[i&&s.jsxs(es,{children:[s.jsx(V,{children:"Source"}),s.jsx(V,{children:"Visitors"})]}),s.jsx(as,{children:a?.map(e=>{const r=!!o,c=e.source?e.source.toLowerCase().replace(/[^a-z0-9]/g,"-"):"direct";return s.jsxs(ts,{className:`group/row ${r?"cursor-pointer":""}`,"data-testid":`source-row-${c}`,onClick:r?()=>o(e.source):void 0,children:[s.jsx(rs,{style:{width:`${e.percentage?Math.round(e.percentage*100):0}%`}}),s.jsx(is,{className:"group-hover/datalist:max-w-[calc(100%-140px)]",children:s.jsx("div",{className:"flex items-center space-x-4 overflow-hidden",children:s.jsx("div",{className:"truncate font-medium",children:e.linkUrl&&!o?s.jsxs("a",{className:"group/link flex items-center gap-2",href:e.linkUrl,rel:"noreferrer",target:"_blank",children:[s.jsx(K,{defaultSourceIconUrl:l,displayName:e.displayName,iconSrc:e.iconSrc}),s.jsx("span",{className:"group-hover/link:underline",children:e.displayName})]}):s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx(K,{defaultSourceIconUrl:l,displayName:e.displayName,iconSrc:e.iconSrc}),s.jsx("span",{children:e.displayName})]})})})}),s.jsxs(ls,{children:[s.jsx(ns,{children:u(e.visits)}),s.jsx(cs,{children:g(e.percentage||0)})]})]},e.source)})})]}),ks=({data:i,range:a=30,totalVisitors:l=0,siteUrl:o,siteIcon:e,defaultSourceIconUrl:r=R,tableOnly:c=!1,topSourcesLimit:n=10,onSourceClick:t})=>{const{isPostLoading:h}=ds(),m=N.useMemo(()=>J({data:i,mode:"visits",siteUrl:o,siteIcon:e,defaultSourceIconUrl:r}),[i,o,e,r]),d=N.useMemo(()=>U({processedData:m,totalVisitors:l,mode:"visits"}),[m,l]),f=d.slice(0,n),v="Top sources",j=`How readers found this post ${a&&` ${js(a)}`}`;if(c){const z=d.slice(0,n),B=d.length>n;return s.jsxs("div",{children:[s.jsx(p,{data:z,dataTableHeader:!1,defaultSourceIconUrl:r,range:a,onSourceClick:t}),B&&s.jsx("div",{className:"mt-4",children:s.jsxs(w,{children:[s.jsx(T,{asChild:!0,children:s.jsxs(y,{className:"w-full",size:"sm",variant:"outline",children:["View all (",d.length,") ",s.jsx(hs,{size:14})]})}),s.jsxs(D,{className:"overflow-y-auto pt-0 sm:max-w-[600px]",children:[s.jsxs(C,{className:"sticky top-0 z-40 -mx-6 bg-background/60 p-6 backdrop-blur",children:[s.jsx(L,{children:v}),s.jsx(S,{children:j})]}),s.jsx("div",{className:"group/datalist",children:s.jsx(p,{data:d,dataTableHeader:!0,defaultSourceIconUrl:r,range:a,onSourceClick:t})})]})]})})]})}const A=h;return s.jsxs(M,{className:"group/datalist","data-testid":"top-sources-card",children:[s.jsxs("div",{className:"flex items-center justify-between p-6",children:[s.jsxs(Q,{className:"p-0",children:[s.jsx(X,{children:v}),s.jsx(Y,{children:j})]}),s.jsx(E,{className:"mr-2",children:"Visitors"})]}),s.jsxs(P,{className:"overflow-hidden",children:[s.jsx("div",{className:"h-[1px] w-full bg-border"}),A?s.jsx(I,{lines:5}):f.length>0?s.jsx(p,{data:f,dataTableHeader:!1,defaultSourceIconUrl:r,range:a,onSourceClick:t}):s.jsx("div",{className:"py-20 text-center text-sm text-gray-700",children:"No sources data available."})]}),d.length>10&&s.jsx(Z,{children:s.jsxs(w,{children:[s.jsx(T,{asChild:!0,children:s.jsxs(y,{variant:"outline",children:["View all ",s.jsx(ms,{})]})}),s.jsxs(D,{className:"overflow-y-auto pt-0 sm:max-w-[600px]",children:[s.jsxs(C,{className:"sticky top-0 z-40 -mx-6 bg-background/60 p-6 backdrop-blur",children:[s.jsx(L,{children:v}),s.jsx(S,{children:j})]}),s.jsx("div",{className:"group/datalist",children:s.jsx(p,{data:d,dataTableHeader:!0,defaultSourceIconUrl:r,range:a,onSourceClick:t})})]})]})})]})},bs=i=>{if(!i?.length)return{visits:"0",views:"0",bounceRate:"0%",duration:"0s"};const a=n=>{const t=Number(n);return isNaN(t)?0:t},l=i.reduce((n,t)=>n+a(t.visits),0),o=i.reduce((n,t)=>n+a(t.pageviews),0),e=n=>l===0?0:i.reduce((t,h)=>{const m=a(h[n]),d=a(h.visits);return t+m*d/l},0),r=e("bounce_rate"),c=e("avg_session_sec");return{visits:u(l),views:u(o),bounceRate:g(r),duration:H(c)}},b={visits:{dataKey:"visits",label:"Visitors",color:"hsl(var(--chart-blue))",formatter:u},views:{dataKey:"pageviews",label:"Pageviews",color:"hsl(var(--chart-teal))",formatter:u},"bounce-rate":{dataKey:"bounce_rate",label:"Bounce rate",color:"hsl(var(--chart-purple))",formatter:g},duration:{dataKey:"avg_session_sec",label:"Time on page",color:"hsl(var(--chart-orange))",formatter:H}},Ks=({data:i,range:a})=>{const[l]=$(),o=l.get("tab")||"visits",[e,r]=G.useState(o),c=b[e],n=O(i||[],a,c.dataKey,"sum")?.map(h=>{const m=Number(h[c.dataKey]);return{date:String(h.date),value:m,formattedValue:c.formatter(m),label:c.label}}),t=bs(i);return s.jsx(M,{children:s.jsx(P,{children:s.jsxs(xs,{defaultValue:e,variant:"kpis",children:[s.jsxs(ps,{className:"-mx-6 hidden grid-cols-2 md:!visible md:!grid",children:[s.jsx(_,{value:"visits",onClick:()=>{r("visits")},children:s.jsx(x,{color:b.visits.color,label:"Unique visitors",value:t.visits})}),s.jsx(_,{value:"views",onClick:()=>{r("views")},children:s.jsx(x,{color:b.views.color,label:"Total views",value:t.views})})]}),s.jsxs(q,{children:[s.jsx(F,{className:"md:hidden",asChild:!0,children:s.jsxs(vs,{children:[e==="visits"&&s.jsx(x,{color:"hsl(var(--chart-blue))",label:"Unique visitors",value:t.visits}),e==="views"&&s.jsx(x,{color:"hsl(var(--chart-teal))",label:"Total views",value:t.views})]})}),s.jsxs(W,{align:"end",className:"w-56",children:[s.jsx(k,{onClick:()=>r("visits"),children:"Unique visitors"}),s.jsx(k,{onClick:()=>r("views"),children:"Total views"})]})]}),s.jsx("div",{className:"my-4 [&_.recharts-cartesian-axis-tick-value]:fill-gray-500",children:s.jsx(us,{className:"-mb-3 aspect-auto h-[16vw] max-h-[320px] min-h-[180px] w-full",color:c.color,data:n,id:c.dataKey,range:a,showHours:!0,syncId:"overview-charts"})})]})})})};export{b as K,ks as S,Ks as a,js as b,bs as g};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as i,bT as E,j as p,bU as x,y as R,an as S}from"./index-
|
|
1
|
+
import{r as i,bT as E,j as p,bU as x,y as R,an as S}from"./index-B8G0f0hb.js";var v=Symbol.for("react.lazy"),u=E[" use ".trim().toString()];function C(e){return typeof e=="object"&&e!==null&&"then"in e}function y(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===v&&"_payload"in e&&C(e._payload)}function w(e){const t=h(e),r=i.forwardRef((o,n)=>{let{children:a,...s}=o;y(a)&&typeof u=="function"&&(a=u(a._payload));const l=i.Children.toArray(a),f=l.find(N);if(f){const c=f.props.children,g=l.map(d=>d===f?i.Children.count(c)>1?i.Children.only(null):i.isValidElement(c)?c.props.children:null:d);return p.jsx(t,{...s,ref:n,children:i.isValidElement(c)?i.cloneElement(c,void 0,g):null})}return p.jsx(t,{...s,ref:n,children:a})});return r.displayName=`${e}.Slot`,r}function h(e){const t=i.forwardRef((r,o)=>{let{children:n,...a}=r;if(y(n)&&typeof u=="function"&&(n=u(n._payload)),i.isValidElement(n)){const s=_(n),l=P(a,n.props);return n.type!==i.Fragment&&(l.ref=o?x(o,s):s),i.cloneElement(n,l)}return i.Children.count(n)>1?i.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var j=Symbol("radix.slottable");function N(e){return i.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===j}function P(e,t){const r={...t};for(const o in t){const n=e[o],a=t[o];/^on[A-Z]/.test(o)?n&&a?r[o]=(...l)=>{const f=a(...l);return n(...l),f}:n&&(r[o]=n):o==="style"?r[o]={...n,...a}:o==="className"&&(r[o]=[n,a].filter(Boolean).join(" "))}return{...e,...r}}function _(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var L=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],$=L.reduce((e,t)=>{const r=w(`Primitive.${t}`),o=i.forwardRef((n,a)=>{const{asChild:s,...l}=n,f=s?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),p.jsx(f,{...l,ref:a})});return o.displayName=`Primitive.${t}`,{...e,[t]:o}},{}),A="Label",m=i.forwardRef((e,t)=>p.jsx($.label,{...e,ref:t,onMouseDown:r=>{r.target.closest("button, input, select, textarea")||(e.onMouseDown?.(r),!r.defaultPrevented&&r.detail>1&&r.preventDefault())}}));m.displayName=A;var b=m;const D=S("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),V=i.forwardRef(({className:e,...t},r)=>p.jsx(b,{ref:r,className:R(D(),e),...t}));V.displayName=b.displayName;export{V as L};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as A,aH as Q,r as ht,j as o,y as yt,ai as gt,ac as bt,ad as vt}from"./index-CMTzNTew.js";import{S as At,b as J,c as X,A as xt,i as K,L as N,d as Ot,e as st,m as V,h as Y,G as jt,j as St,k as Pt,l as kt,n as Rt,t as Ct,o as Et,p as Z,q as _t,r as wt,g as Dt,s as Tt,C as Nt,u as It,a as zt,v as Bt}from"./chart-mYz3IJwm.js";import{P as ct,a as lt}from"./PolarAngleAxis-Dod0DwfL.js";function w(t){"@babel/helpers - typeof";return w=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},w(t)}function U(){return U=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var a=arguments[e];for(var r in a)Object.prototype.hasOwnProperty.call(a,r)&&(t[r]=a[r])}return t},U.apply(this,arguments)}function tt(t,e){var a=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),a.push.apply(a,r)}return a}function F(t){for(var e=1;e<arguments.length;e++){var a=arguments[e]!=null?arguments[e]:{};e%2?tt(Object(a),!0).forEach(function(r){Lt(t,r,a[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(a)):tt(Object(a)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(a,r))})}return t}function Lt(t,e,a){return e=Mt(e),e in t?Object.defineProperty(t,e,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[e]=a,t}function Mt(t){var e=$t(t,"string");return w(e)=="symbol"?e:e+""}function $t(t,e){if(w(t)!="object"||!t)return t;var a=t[Symbol.toPrimitive];if(a!==void 0){var r=a.call(t,e);if(w(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function et(t){return typeof t=="string"?parseInt(t,10):t}function Wt(t,e){var a="".concat(e.cx||t.cx),r=Number(a),n="".concat(e.cy||t.cy),i=Number(n);return F(F(F({},e),t),{},{cx:r,cy:i})}function rt(t){return A.createElement(At,U({shapeType:"sector",propTransformer:Wt},t))}var Gt=["shape","activeShape","activeIndex","cornerRadius"],Kt=["value","background"];function C(t){"@babel/helpers - typeof";return C=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},C(t)}function I(){return I=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var a=arguments[e];for(var r in a)Object.prototype.hasOwnProperty.call(a,r)&&(t[r]=a[r])}return t},I.apply(this,arguments)}function at(t,e){var a=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),a.push.apply(a,r)}return a}function u(t){for(var e=1;e<arguments.length;e++){var a=arguments[e]!=null?arguments[e]:{};e%2?at(Object(a),!0).forEach(function(r){j(t,r,a[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(a)):at(Object(a)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(a,r))})}return t}function nt(t,e){if(t==null)return{};var a=Ft(t,e),r,n;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n<i.length;n++)r=i[n],!(e.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(t,r)&&(a[r]=t[r])}return a}function Ft(t,e){if(t==null)return{};var a={};for(var r in t)if(Object.prototype.hasOwnProperty.call(t,r)){if(e.indexOf(r)>=0)continue;a[r]=t[r]}return a}function Vt(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function it(t,e){for(var a=0;a<e.length;a++){var r=e[a];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,pt(r.key),r)}}function Ut(t,e,a){return e&&it(t.prototype,e),a&&it(t,a),Object.defineProperty(t,"prototype",{writable:!1}),t}function qt(t,e,a){return e=z(e),Ht(t,ut()?Reflect.construct(e,a||[],z(t).constructor):e.apply(t,a))}function Ht(t,e){if(e&&(C(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Qt(t)}function Qt(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function ut(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(ut=function(){return!!t})()}function z(t){return z=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(a){return a.__proto__||Object.getPrototypeOf(a)},z(t)}function Jt(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&q(t,e)}function q(t,e){return q=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,n){return r.__proto__=n,r},q(t,e)}function j(t,e,a){return e=pt(e),e in t?Object.defineProperty(t,e,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[e]=a,t}function pt(t){var e=Xt(t,"string");return C(e)=="symbol"?e:e+""}function Xt(t,e){if(C(t)!="object"||!t)return t;var a=t[Symbol.toPrimitive];if(a!==void 0){var r=a.call(t,e);if(C(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}var D=(function(t){function e(){var a;Vt(this,e);for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];return a=qt(this,e,[].concat(n)),j(a,"state",{isAnimationFinished:!1}),j(a,"handleAnimationEnd",function(){var s=a.props.onAnimationEnd;a.setState({isAnimationFinished:!0}),Y(s)&&s()}),j(a,"handleAnimationStart",function(){var s=a.props.onAnimationStart;a.setState({isAnimationFinished:!1}),Y(s)&&s()}),a}return Jt(e,t),Ut(e,[{key:"getDeltaAngle",value:function(){var r=this.props,n=r.startAngle,i=r.endAngle,s=V(i-n),p=Math.min(Math.abs(i-n),360);return s*p}},{key:"renderSectorsStatically",value:function(r){var n=this,i=this.props,s=i.shape,p=i.activeShape,d=i.activeIndex,l=i.cornerRadius,c=nt(i,Gt),y=J(c,!1);return r.map(function(g,f){var v=f===d,m=u(u(u(u({},y),{},{cornerRadius:et(l)},g),X(n.props,g,f)),{},{className:"recharts-radial-bar-sector ".concat(g.className),forceCornerRadius:c.forceCornerRadius,cornerIsExternal:c.cornerIsExternal,isActive:v,option:v?p:s});return A.createElement(rt,I({},m,{key:"sector-".concat(f)}))})}},{key:"renderSectorsWithAnimation",value:function(){var r=this,n=this.props,i=n.data,s=n.isAnimationActive,p=n.animationBegin,d=n.animationDuration,l=n.animationEasing,c=n.animationId,y=this.state.prevData;return A.createElement(xt,{begin:p,duration:d,isActive:s,easing:l,from:{t:0},to:{t:1},key:"radialBar-".concat(c),onAnimationStart:this.handleAnimationStart,onAnimationEnd:this.handleAnimationEnd},function(g){var f=g.t,v=i.map(function(m,E){var S=y&&y[E];if(S){var B=K(S.startAngle,m.startAngle),b=K(S.endAngle,m.endAngle);return u(u({},m),{},{startAngle:B(f),endAngle:b(f)})}var T=m.endAngle,L=m.startAngle,M=K(L,T);return u(u({},m),{},{endAngle:M(f)})});return A.createElement(N,null,r.renderSectorsStatically(v))})}},{key:"renderSectors",value:function(){var r=this.props,n=r.data,i=r.isAnimationActive,s=this.state.prevData;return i&&n&&n.length&&(!s||!Ot(s,n))?this.renderSectorsWithAnimation():this.renderSectorsStatically(n)}},{key:"renderBackground",value:function(r){var n=this,i=this.props.cornerRadius,s=J(this.props.background,!1);return r.map(function(p,d){p.value;var l=p.background,c=nt(p,Kt);if(!l)return null;var y=u(u(u(u(u({cornerRadius:et(i)},c),{},{fill:"#eee"},l),s),X(n.props,p,d)),{},{index:d,className:Q("recharts-radial-bar-background-sector",s?.className),option:l,isActive:!1});return A.createElement(rt,I({},y,{key:"sector-".concat(d)}))})}},{key:"render",value:function(){var r=this.props,n=r.hide,i=r.data,s=r.className,p=r.background,d=r.isAnimationActive;if(n||!i||!i.length)return null;var l=this.state.isAnimationFinished,c=Q("recharts-area",s);return A.createElement(N,{className:c},p&&A.createElement(N,{className:"recharts-radial-bar-background"},this.renderBackground(i)),A.createElement(N,{className:"recharts-radial-bar-sectors"},this.renderSectors()),(!d||l)&&st.renderCallByParent(u({},this.props),i))}}],[{key:"getDerivedStateFromProps",value:function(r,n){return r.animationId!==n.prevAnimationId?{prevAnimationId:r.animationId,curData:r.data,prevData:n.curData}:r.data!==n.curData?{curData:r.data}:null}}])})(ht.PureComponent);j(D,"displayName","RadialBar");j(D,"defaultProps",{angleAxisId:0,radiusAxisId:0,minPointSize:0,hide:!1,legendType:"rect",data:[],isAnimationActive:!jt.isSsr,animationBegin:0,animationDuration:1500,animationEasing:"ease",forceCornerRadius:!1,cornerIsExternal:!1});j(D,"getComposedData",function(t){var e=t.item,a=t.props,r=t.radiusAxis,n=t.radiusAxisTicks,i=t.angleAxis,s=t.angleAxisTicks,p=t.displayedData,d=t.dataKey,l=t.stackedData,c=t.barPosition,y=t.bandSize,g=t.dataStartIndex,f=St(c,e);if(!f)return null;var v=i.cx,m=i.cy,E=a.layout,S=e.props,B=S.children,b=S.minPointSize,T=E==="radial"?i:r,L=l?T.scale.domain():null,M=Pt({numericAxis:T}),$=kt(B,Rt),dt=p.map(function(P,_){var h,x,O,k,R,H;if(l?h=Ct(l[g+_],L):(h=Et(P,d),Array.isArray(h)||(h=[M,h])),E==="radial"){x=Z({axis:r,ticks:n,bandSize:y,offset:f.offset,entry:P,index:_}),R=i.scale(h[1]),k=i.scale(h[0]),O=x+f.size;var W=R-k;if(Math.abs(b)>0&&Math.abs(W)<Math.abs(b)){var ft=V(W||b)*(Math.abs(b)-Math.abs(W));R+=ft}H={background:{cx:v,cy:m,innerRadius:x,outerRadius:O,startAngle:a.startAngle,endAngle:a.endAngle}}}else{x=r.scale(h[0]),O=r.scale(h[1]),k=Z({axis:i,ticks:s,bandSize:y,offset:f.offset,entry:P,index:_}),R=k+f.size;var G=O-x;if(Math.abs(b)>0&&Math.abs(G)<Math.abs(b)){var mt=V(G||b)*(Math.abs(b)-Math.abs(G));O+=mt}}return u(u(u(u({},P),H),{},{payload:P,value:l?h:h[1],cx:v,cy:m,innerRadius:x,outerRadius:O,startAngle:k,endAngle:R},$&&$[_]&&$[_].props),{},{tooltipPayload:[_t(e,P)],tooltipPosition:wt(v,m,(x+O)/2,(k+R)/2)})});return{data:dt,layout:E}});var Yt=Dt({chartName:"RadialBarChart",GraphicalChild:D,legendContent:"children",defaultTooltipEventType:"axis",validateTooltipEventTypes:["axis","item"],axisComponents:[{axisType:"angleAxis",AxisComp:ct},{axisType:"radiusAxis",AxisComp:lt}],formatAxisMap:Tt,defaultProps:{layout:"radial",startAngle:0,endAngle:360,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"}});const re=({config:t,data:e,percentageValue:a,percentageLabel:r,className:n,tooltip:i=!0,size:s="responsive"})=>{const d=(()=>{switch(s){case"sm":return{barWidth:28,innerRadiusStart:e.length>1?42:56,fontSize:{percentage:"1.2rem",label:"0.8rem"}};case"md":return{barWidth:36,innerRadiusStart:e.length>1?60:72,fontSize:{percentage:"1.4rem",label:"0.9rem"}};case"lg":return{barWidth:46,innerRadiusStart:e.length>1?72:94,fontSize:{percentage:"1.6rem",label:"1rem"}};case"responsive":default:return{barWidth:46,innerRadiusStart:e.length>1?72:94,fontSize:{percentage:"1.6rem",label:"1rem"}}}})(),l={innerRadius:d.innerRadiusStart,outerRadius:d.innerRadiusStart+d.barWidth,startAngle:90,endAngle:-270};return o.jsx(Nt,{className:yt("mx-auto",n),config:t,children:o.jsxs(Yt,{data:e,endAngle:l.endAngle,innerRadius:l.innerRadius,outerRadius:l.outerRadius,startAngle:l.startAngle,children:[o.jsxs("defs",{children:[o.jsxs("radialGradient",{cx:"30%",cy:"30%",id:"gradientPurple",r:"70%",children:[o.jsx("stop",{offset:"0%",stopColor:"hsl(var(--chart-purple))",stopOpacity:.5}),o.jsx("stop",{offset:"100%",stopColor:"hsl(var(--chart-purple))",stopOpacity:1})]}),o.jsxs("radialGradient",{cx:"30%",cy:"30%",id:"gradientBlue",r:"70%",children:[o.jsx("stop",{offset:"0%",stopColor:"hsl(var(--chart-blue))",stopOpacity:.5}),o.jsx("stop",{offset:"100%",stopColor:"hsl(var(--chart-blue))",stopOpacity:1})]}),o.jsxs("radialGradient",{cx:"30%",cy:"30%",id:"gradientTeal",r:"70%",children:[o.jsx("stop",{offset:"0%",stopColor:"hsl(var(--chart-teal))",stopOpacity:.5}),o.jsx("stop",{offset:"100%",stopColor:"hsl(var(--chart-teal))",stopOpacity:1})]}),o.jsxs("radialGradient",{cx:"30%",cy:"30%",id:"gradientGray",r:"70%",children:[o.jsx("stop",{offset:"0%",stopColor:"hsl(var(--chart-gray))",stopOpacity:.5}),o.jsx("stop",{offset:"100%",stopColor:"hsl(var(--chart-gray))",stopOpacity:1})]})]}),o.jsx(ct,{angleAxisId:0,domain:[0,1],tick:!1,type:"number"}),o.jsx(D,{cornerRadius:10,dataKey:"value",minPointSize:-2,background:!0,children:e.length>1&&o.jsx(st,{className:"fill-black opacity-60",dataKey:"datatype",fontSize:11,position:"insideStart"})}),o.jsx(lt,{axisLine:!1,tick:!1,tickLine:!1,children:o.jsx(It,{content:({viewBox:c})=>{if(c&&"cx"in c&&"cy"in c)return o.jsxs("text",{dominantBaseline:"middle",textAnchor:"middle",x:c.cx,y:c.cy,children:[a&&o.jsx("tspan",{className:"fill-foreground text-[1.6rem] font-semibold tracking-tight",x:c.cx,y:(c.cy||0)-6,children:a}),r&&o.jsx("tspan",{className:"fill-muted-foreground font-medium",x:c.cx,y:(c.cy||0)+14,children:r})]})}})}),i&&o.jsx(zt,{content:o.jsx(Bt,{formatter:(c,y,g)=>o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("div",{className:"size-2 rounded-full opacity-50",style:{backgroundColor:g.payload?.color}}),o.jsx("div",{className:"text-xs text-muted-foreground",children:g.payload?.datatype}),o.jsx("div",{className:"ml-3 font-mono text-xs",children:gt(c)})]}),nameKey:"datatype",hideLabel:!0}),cursor:!1,isAnimationActive:!1})]})})},ot=(t,e=!1)=>{try{const a=["ref","attribution_id","attribution_type"],r=new URL(t);for(const i of a)r.searchParams.delete(i);return e?(r.host+(r.pathname==="/"&&!r.search?"":r.pathname)+(r.search?r.search:"")+(r.hash?r.hash:"")).replace(/^www\./,""):r.toString()}catch{return t}},ae=(t,e)=>t.find(a=>a.link.link_id===e),ne=t=>{const r=(t?.links.map(n=>({link:n.link,count:n.count?.clicks||0}))||[]).map(n=>({...n,link:{...n.link,originalTo:n.link.to,to:ot(n.link.to,!1),title:ot(n.link.to,!0)}})).reduce((n,i)=>(n[i.link.title]?(n[i.link.title].count||(n[i.link.title].count=0),n[i.link.title].count+=i.count??0):n[i.link.title]=i,n),{});return Object.values(r).sort((n,i)=>{const s=n.count||0;return(i.count||0)-s})},ie=bt({dataType:"LinkResponseType",path:"/links/"}),oe=vt({method:"PUT",path:()=>"/links/bulk/",body:({editedUrl:t})=>({bulk:{action:"updateLink",meta:{link:{to:t}}}}),searchParams:({originalUrl:t,postId:e})=>({filter:`post_id:'${e}'+to:'${t}'`})});export{re as N,oe as a,ot as c,ae as g,ne as p,ie as u};
|
|
1
|
+
import{e as A,aH as Q,r as ht,j as o,y as yt,ai as gt,ac as bt,ad as vt}from"./index-B8G0f0hb.js";import{S as At,b as J,c as X,A as xt,i as K,L as N,d as Ot,e as st,m as V,h as Y,G as jt,j as St,k as Pt,l as kt,n as Rt,t as Ct,o as Et,p as Z,q as _t,r as wt,g as Dt,s as Tt,C as Nt,u as It,a as zt,v as Bt}from"./chart-BAQCVPCH.js";import{P as ct,a as lt}from"./PolarAngleAxis-DALH8FDm.js";function w(t){"@babel/helpers - typeof";return w=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},w(t)}function U(){return U=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var a=arguments[e];for(var r in a)Object.prototype.hasOwnProperty.call(a,r)&&(t[r]=a[r])}return t},U.apply(this,arguments)}function tt(t,e){var a=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),a.push.apply(a,r)}return a}function F(t){for(var e=1;e<arguments.length;e++){var a=arguments[e]!=null?arguments[e]:{};e%2?tt(Object(a),!0).forEach(function(r){Lt(t,r,a[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(a)):tt(Object(a)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(a,r))})}return t}function Lt(t,e,a){return e=Mt(e),e in t?Object.defineProperty(t,e,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[e]=a,t}function Mt(t){var e=$t(t,"string");return w(e)=="symbol"?e:e+""}function $t(t,e){if(w(t)!="object"||!t)return t;var a=t[Symbol.toPrimitive];if(a!==void 0){var r=a.call(t,e);if(w(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function et(t){return typeof t=="string"?parseInt(t,10):t}function Wt(t,e){var a="".concat(e.cx||t.cx),r=Number(a),n="".concat(e.cy||t.cy),i=Number(n);return F(F(F({},e),t),{},{cx:r,cy:i})}function rt(t){return A.createElement(At,U({shapeType:"sector",propTransformer:Wt},t))}var Gt=["shape","activeShape","activeIndex","cornerRadius"],Kt=["value","background"];function C(t){"@babel/helpers - typeof";return C=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},C(t)}function I(){return I=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var a=arguments[e];for(var r in a)Object.prototype.hasOwnProperty.call(a,r)&&(t[r]=a[r])}return t},I.apply(this,arguments)}function at(t,e){var a=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),a.push.apply(a,r)}return a}function u(t){for(var e=1;e<arguments.length;e++){var a=arguments[e]!=null?arguments[e]:{};e%2?at(Object(a),!0).forEach(function(r){j(t,r,a[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(a)):at(Object(a)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(a,r))})}return t}function nt(t,e){if(t==null)return{};var a=Ft(t,e),r,n;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n<i.length;n++)r=i[n],!(e.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(t,r)&&(a[r]=t[r])}return a}function Ft(t,e){if(t==null)return{};var a={};for(var r in t)if(Object.prototype.hasOwnProperty.call(t,r)){if(e.indexOf(r)>=0)continue;a[r]=t[r]}return a}function Vt(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function it(t,e){for(var a=0;a<e.length;a++){var r=e[a];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,pt(r.key),r)}}function Ut(t,e,a){return e&&it(t.prototype,e),a&&it(t,a),Object.defineProperty(t,"prototype",{writable:!1}),t}function qt(t,e,a){return e=z(e),Ht(t,ut()?Reflect.construct(e,a||[],z(t).constructor):e.apply(t,a))}function Ht(t,e){if(e&&(C(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Qt(t)}function Qt(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function ut(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(ut=function(){return!!t})()}function z(t){return z=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(a){return a.__proto__||Object.getPrototypeOf(a)},z(t)}function Jt(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&q(t,e)}function q(t,e){return q=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,n){return r.__proto__=n,r},q(t,e)}function j(t,e,a){return e=pt(e),e in t?Object.defineProperty(t,e,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[e]=a,t}function pt(t){var e=Xt(t,"string");return C(e)=="symbol"?e:e+""}function Xt(t,e){if(C(t)!="object"||!t)return t;var a=t[Symbol.toPrimitive];if(a!==void 0){var r=a.call(t,e);if(C(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}var D=(function(t){function e(){var a;Vt(this,e);for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];return a=qt(this,e,[].concat(n)),j(a,"state",{isAnimationFinished:!1}),j(a,"handleAnimationEnd",function(){var s=a.props.onAnimationEnd;a.setState({isAnimationFinished:!0}),Y(s)&&s()}),j(a,"handleAnimationStart",function(){var s=a.props.onAnimationStart;a.setState({isAnimationFinished:!1}),Y(s)&&s()}),a}return Jt(e,t),Ut(e,[{key:"getDeltaAngle",value:function(){var r=this.props,n=r.startAngle,i=r.endAngle,s=V(i-n),p=Math.min(Math.abs(i-n),360);return s*p}},{key:"renderSectorsStatically",value:function(r){var n=this,i=this.props,s=i.shape,p=i.activeShape,d=i.activeIndex,l=i.cornerRadius,c=nt(i,Gt),y=J(c,!1);return r.map(function(g,f){var v=f===d,m=u(u(u(u({},y),{},{cornerRadius:et(l)},g),X(n.props,g,f)),{},{className:"recharts-radial-bar-sector ".concat(g.className),forceCornerRadius:c.forceCornerRadius,cornerIsExternal:c.cornerIsExternal,isActive:v,option:v?p:s});return A.createElement(rt,I({},m,{key:"sector-".concat(f)}))})}},{key:"renderSectorsWithAnimation",value:function(){var r=this,n=this.props,i=n.data,s=n.isAnimationActive,p=n.animationBegin,d=n.animationDuration,l=n.animationEasing,c=n.animationId,y=this.state.prevData;return A.createElement(xt,{begin:p,duration:d,isActive:s,easing:l,from:{t:0},to:{t:1},key:"radialBar-".concat(c),onAnimationStart:this.handleAnimationStart,onAnimationEnd:this.handleAnimationEnd},function(g){var f=g.t,v=i.map(function(m,E){var S=y&&y[E];if(S){var B=K(S.startAngle,m.startAngle),b=K(S.endAngle,m.endAngle);return u(u({},m),{},{startAngle:B(f),endAngle:b(f)})}var T=m.endAngle,L=m.startAngle,M=K(L,T);return u(u({},m),{},{endAngle:M(f)})});return A.createElement(N,null,r.renderSectorsStatically(v))})}},{key:"renderSectors",value:function(){var r=this.props,n=r.data,i=r.isAnimationActive,s=this.state.prevData;return i&&n&&n.length&&(!s||!Ot(s,n))?this.renderSectorsWithAnimation():this.renderSectorsStatically(n)}},{key:"renderBackground",value:function(r){var n=this,i=this.props.cornerRadius,s=J(this.props.background,!1);return r.map(function(p,d){p.value;var l=p.background,c=nt(p,Kt);if(!l)return null;var y=u(u(u(u(u({cornerRadius:et(i)},c),{},{fill:"#eee"},l),s),X(n.props,p,d)),{},{index:d,className:Q("recharts-radial-bar-background-sector",s?.className),option:l,isActive:!1});return A.createElement(rt,I({},y,{key:"sector-".concat(d)}))})}},{key:"render",value:function(){var r=this.props,n=r.hide,i=r.data,s=r.className,p=r.background,d=r.isAnimationActive;if(n||!i||!i.length)return null;var l=this.state.isAnimationFinished,c=Q("recharts-area",s);return A.createElement(N,{className:c},p&&A.createElement(N,{className:"recharts-radial-bar-background"},this.renderBackground(i)),A.createElement(N,{className:"recharts-radial-bar-sectors"},this.renderSectors()),(!d||l)&&st.renderCallByParent(u({},this.props),i))}}],[{key:"getDerivedStateFromProps",value:function(r,n){return r.animationId!==n.prevAnimationId?{prevAnimationId:r.animationId,curData:r.data,prevData:n.curData}:r.data!==n.curData?{curData:r.data}:null}}])})(ht.PureComponent);j(D,"displayName","RadialBar");j(D,"defaultProps",{angleAxisId:0,radiusAxisId:0,minPointSize:0,hide:!1,legendType:"rect",data:[],isAnimationActive:!jt.isSsr,animationBegin:0,animationDuration:1500,animationEasing:"ease",forceCornerRadius:!1,cornerIsExternal:!1});j(D,"getComposedData",function(t){var e=t.item,a=t.props,r=t.radiusAxis,n=t.radiusAxisTicks,i=t.angleAxis,s=t.angleAxisTicks,p=t.displayedData,d=t.dataKey,l=t.stackedData,c=t.barPosition,y=t.bandSize,g=t.dataStartIndex,f=St(c,e);if(!f)return null;var v=i.cx,m=i.cy,E=a.layout,S=e.props,B=S.children,b=S.minPointSize,T=E==="radial"?i:r,L=l?T.scale.domain():null,M=Pt({numericAxis:T}),$=kt(B,Rt),dt=p.map(function(P,_){var h,x,O,k,R,H;if(l?h=Ct(l[g+_],L):(h=Et(P,d),Array.isArray(h)||(h=[M,h])),E==="radial"){x=Z({axis:r,ticks:n,bandSize:y,offset:f.offset,entry:P,index:_}),R=i.scale(h[1]),k=i.scale(h[0]),O=x+f.size;var W=R-k;if(Math.abs(b)>0&&Math.abs(W)<Math.abs(b)){var ft=V(W||b)*(Math.abs(b)-Math.abs(W));R+=ft}H={background:{cx:v,cy:m,innerRadius:x,outerRadius:O,startAngle:a.startAngle,endAngle:a.endAngle}}}else{x=r.scale(h[0]),O=r.scale(h[1]),k=Z({axis:i,ticks:s,bandSize:y,offset:f.offset,entry:P,index:_}),R=k+f.size;var G=O-x;if(Math.abs(b)>0&&Math.abs(G)<Math.abs(b)){var mt=V(G||b)*(Math.abs(b)-Math.abs(G));O+=mt}}return u(u(u(u({},P),H),{},{payload:P,value:l?h:h[1],cx:v,cy:m,innerRadius:x,outerRadius:O,startAngle:k,endAngle:R},$&&$[_]&&$[_].props),{},{tooltipPayload:[_t(e,P)],tooltipPosition:wt(v,m,(x+O)/2,(k+R)/2)})});return{data:dt,layout:E}});var Yt=Dt({chartName:"RadialBarChart",GraphicalChild:D,legendContent:"children",defaultTooltipEventType:"axis",validateTooltipEventTypes:["axis","item"],axisComponents:[{axisType:"angleAxis",AxisComp:ct},{axisType:"radiusAxis",AxisComp:lt}],formatAxisMap:Tt,defaultProps:{layout:"radial",startAngle:0,endAngle:360,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"}});const re=({config:t,data:e,percentageValue:a,percentageLabel:r,className:n,tooltip:i=!0,size:s="responsive"})=>{const d=(()=>{switch(s){case"sm":return{barWidth:28,innerRadiusStart:e.length>1?42:56,fontSize:{percentage:"1.2rem",label:"0.8rem"}};case"md":return{barWidth:36,innerRadiusStart:e.length>1?60:72,fontSize:{percentage:"1.4rem",label:"0.9rem"}};case"lg":return{barWidth:46,innerRadiusStart:e.length>1?72:94,fontSize:{percentage:"1.6rem",label:"1rem"}};case"responsive":default:return{barWidth:46,innerRadiusStart:e.length>1?72:94,fontSize:{percentage:"1.6rem",label:"1rem"}}}})(),l={innerRadius:d.innerRadiusStart,outerRadius:d.innerRadiusStart+d.barWidth,startAngle:90,endAngle:-270};return o.jsx(Nt,{className:yt("mx-auto",n),config:t,children:o.jsxs(Yt,{data:e,endAngle:l.endAngle,innerRadius:l.innerRadius,outerRadius:l.outerRadius,startAngle:l.startAngle,children:[o.jsxs("defs",{children:[o.jsxs("radialGradient",{cx:"30%",cy:"30%",id:"gradientPurple",r:"70%",children:[o.jsx("stop",{offset:"0%",stopColor:"hsl(var(--chart-purple))",stopOpacity:.5}),o.jsx("stop",{offset:"100%",stopColor:"hsl(var(--chart-purple))",stopOpacity:1})]}),o.jsxs("radialGradient",{cx:"30%",cy:"30%",id:"gradientBlue",r:"70%",children:[o.jsx("stop",{offset:"0%",stopColor:"hsl(var(--chart-blue))",stopOpacity:.5}),o.jsx("stop",{offset:"100%",stopColor:"hsl(var(--chart-blue))",stopOpacity:1})]}),o.jsxs("radialGradient",{cx:"30%",cy:"30%",id:"gradientTeal",r:"70%",children:[o.jsx("stop",{offset:"0%",stopColor:"hsl(var(--chart-teal))",stopOpacity:.5}),o.jsx("stop",{offset:"100%",stopColor:"hsl(var(--chart-teal))",stopOpacity:1})]}),o.jsxs("radialGradient",{cx:"30%",cy:"30%",id:"gradientGray",r:"70%",children:[o.jsx("stop",{offset:"0%",stopColor:"hsl(var(--chart-gray))",stopOpacity:.5}),o.jsx("stop",{offset:"100%",stopColor:"hsl(var(--chart-gray))",stopOpacity:1})]})]}),o.jsx(ct,{angleAxisId:0,domain:[0,1],tick:!1,type:"number"}),o.jsx(D,{cornerRadius:10,dataKey:"value",minPointSize:-2,background:!0,children:e.length>1&&o.jsx(st,{className:"fill-black opacity-60",dataKey:"datatype",fontSize:11,position:"insideStart"})}),o.jsx(lt,{axisLine:!1,tick:!1,tickLine:!1,children:o.jsx(It,{content:({viewBox:c})=>{if(c&&"cx"in c&&"cy"in c)return o.jsxs("text",{dominantBaseline:"middle",textAnchor:"middle",x:c.cx,y:c.cy,children:[a&&o.jsx("tspan",{className:"fill-foreground text-[1.6rem] font-semibold tracking-tight",x:c.cx,y:(c.cy||0)-6,children:a}),r&&o.jsx("tspan",{className:"fill-muted-foreground font-medium",x:c.cx,y:(c.cy||0)+14,children:r})]})}})}),i&&o.jsx(zt,{content:o.jsx(Bt,{formatter:(c,y,g)=>o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("div",{className:"size-2 rounded-full opacity-50",style:{backgroundColor:g.payload?.color}}),o.jsx("div",{className:"text-xs text-muted-foreground",children:g.payload?.datatype}),o.jsx("div",{className:"ml-3 font-mono text-xs",children:gt(c)})]}),nameKey:"datatype",hideLabel:!0}),cursor:!1,isAnimationActive:!1})]})})},ot=(t,e=!1)=>{try{const a=["ref","attribution_id","attribution_type"],r=new URL(t);for(const i of a)r.searchParams.delete(i);return e?(r.host+(r.pathname==="/"&&!r.search?"":r.pathname)+(r.search?r.search:"")+(r.hash?r.hash:"")).replace(/^www\./,""):r.toString()}catch{return t}},ae=(t,e)=>t.find(a=>a.link.link_id===e),ne=t=>{const r=(t?.links.map(n=>({link:n.link,count:n.count?.clicks||0}))||[]).map(n=>({...n,link:{...n.link,originalTo:n.link.to,to:ot(n.link.to,!1),title:ot(n.link.to,!0)}})).reduce((n,i)=>(n[i.link.title]?(n[i.link.title].count||(n[i.link.title].count=0),n[i.link.title].count+=i.count??0):n[i.link.title]=i,n),{});return Object.values(r).sort((n,i)=>{const s=n.count||0;return(i.count||0)-s})},ie=bt({dataType:"LinkResponseType",path:"/links/"}),oe=vt({method:"PUT",path:()=>"/links/bulk/",body:({editedUrl:t})=>({bulk:{action:"updateLink",meta:{link:{to:t}}}}),searchParams:({originalUrl:t,postId:e})=>({filter:`post_id:'${e}'+to:'${t}'`})});export{re as N,oe as a,ot as c,ae as g,ne as p,ie as u};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{aA as t}from"./index-B8G0f0hb.js";/**
|
|
2
|
+
* @license lucide-react v0.553.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const e=[["path",{d:"M2 5h20",key:"1fs1ex"}],["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M9 19h6",key:"456am0"}]],o=t("list-filter",e);export{o as L};
|