@justifi/webcomponents 6.15.0-rc.2 → 6.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/cjs/{Analytics-COhunq0p.js → Analytics-BjZHa0wt.js} +4 -4
- package/dist/cjs/{Api-Do6SaltY.js → Api-us3AxMRC.js} +1 -1
- package/dist/cjs/{Business-oBifyXkW.js → Business-CNaz-VLa.js} +5 -1
- package/dist/cjs/{Plaid-D85oV9FN.js → Plaid-BcOAKDaU.js} +1 -1
- package/dist/cjs/additional-questions-form-step_15.cjs.entry.js +13 -13
- package/dist/cjs/additional-questions_4.cjs.entry.js +3 -3
- package/dist/cjs/bank-account-billing-form-simple_4.cjs.entry.js +4 -4
- package/dist/cjs/bank-account-document-form-inputs.cjs.entry.js +2 -2
- package/dist/cjs/bank-account-form.cjs.entry.js +4 -4
- package/dist/cjs/{business-form-options-CnlrfbQ6.js → business-form-options-BHBs_yiK.js} +1 -1
- package/dist/cjs/{business-identity-schema-hpDJFnB4.js → business-identity-schema-XiCLzxWM.js} +3 -3
- package/dist/cjs/{business.service-72YETCdB.js → business.service-_Sl3vWmu.js} +3 -3
- package/dist/cjs/card-form.cjs.entry.js +4 -4
- package/dist/cjs/{check-pkg-version-BxGoSXGD.js → check-pkg-version-CjJab8fX.js} +1 -1
- package/dist/cjs/{checkout-actions-BRQFQ6n-.js → checkout-actions-CQyGpVPe.js} +2 -2
- package/dist/cjs/{checkout.service-CPsXfx0Z.js → checkout.service-B_qymeqJ.js} +3 -3
- package/dist/cjs/{country-config-C1bWmF8P.js → country-config-DQQujh5h.js} +1 -1
- package/dist/cjs/dispute-notification_2.cjs.entry.js +8 -8
- package/dist/cjs/{event-types-UHzCC7Ga.js → event-types-DmY59QXs.js} +3 -3
- package/dist/cjs/form-address-fields_3.cjs.entry.js +2 -2
- package/dist/cjs/form-alert_3.cjs.entry.js +1 -1
- package/dist/cjs/form-control-number_2.cjs.entry.js +4 -4
- package/dist/cjs/{get-business-BpaRbn5S.js → get-business-BVxtiSDs.js} +3 -3
- package/dist/cjs/{get-payment-details-Cmg8gWvo.js → get-payment-details-DR1GgpyX.js} +3 -3
- package/dist/cjs/{get-subaccounts-Bp7DOmM_.js → get-subaccounts-BMY2bOFj.js} +4 -4
- package/dist/cjs/{input-handlers-_51J5q7J.js → input-handlers-v9h_2Ysi.js} +1 -1
- package/dist/cjs/justifi-apple-pay_12.cjs.entry.js +17 -11
- package/dist/cjs/justifi-bank-account-billing-form-simple.cjs.entry.js +6 -6
- package/dist/cjs/justifi-bank-account-form.cjs.entry.js +6 -6
- package/dist/cjs/justifi-business-details.cjs.entry.js +9 -9
- package/dist/cjs/justifi-business-form.cjs.entry.js +13 -13
- package/dist/cjs/justifi-card-form.cjs.entry.js +6 -6
- package/dist/cjs/justifi-checkout-qr-code.cjs.entry.js +6 -6
- package/dist/cjs/justifi-checkout.cjs.entry.js +6 -6
- package/dist/cjs/justifi-checkouts-list-filters.cjs.entry.js +6 -4
- package/dist/cjs/justifi-checkouts-list.cjs.entry.js +11 -11
- package/dist/cjs/justifi-dispute-management.cjs.entry.js +8 -8
- package/dist/cjs/justifi-gross-payment-chart.cjs.entry.js +33 -20
- package/dist/cjs/justifi-order-terminals.cjs.entry.js +10 -10
- package/dist/cjs/justifi-payment-details.cjs.entry.js +9 -9
- package/dist/cjs/justifi-payment-provisioning.cjs.entry.js +9 -9
- package/dist/cjs/justifi-payment-transactions-list.cjs.entry.js +8 -8
- package/dist/cjs/justifi-payments-list.cjs.entry.js +8 -8
- package/dist/cjs/justifi-payout-details.cjs.entry.js +9 -9
- package/dist/cjs/justifi-payout-transactions-list.cjs.entry.js +8 -8
- package/dist/cjs/justifi-payouts-list-filters.cjs.entry.js +2 -2
- package/dist/cjs/justifi-payouts-list.cjs.entry.js +10 -10
- package/dist/cjs/justifi-qr-terminal.cjs.entry.js +9 -9
- package/dist/cjs/justifi-refund-payment.cjs.entry.js +9 -9
- package/dist/cjs/justifi-season-interruption-insurance.cjs.entry.js +7 -7
- package/dist/cjs/justifi-terminal-orders-list-filters.cjs.entry.js +2 -2
- package/dist/cjs/justifi-terminal-orders-list.cjs.entry.js +7 -7
- package/dist/cjs/justifi-terminals-list-filters.cjs.entry.js +2 -2
- package/dist/cjs/justifi-terminals-list.cjs.entry.js +9 -9
- package/dist/cjs/{package-G3Vs7Jx5.js → package-30T__1wH.js} +1 -1
- package/dist/cjs/{payment-provisioning-actions-DDooZhhk.js → payment-provisioning-actions-SVp7B8pR.js} +2 -2
- package/dist/cjs/payment-provisioning-form-buttons_2.cjs.entry.js +1 -1
- package/dist/cjs/{payment.service-CVwTrHEL.js → payment.service-DRXVT-uB.js} +3 -3
- package/dist/cjs/{payout.service-CL3VR0hN.js → payout.service-CuQ-mXKB.js} +3 -3
- package/dist/cjs/{payouts-status-1IUtW-UQ.js → payouts-status-BvHeuy9v.js} +2 -2
- package/dist/cjs/{plaid.service-Cukg5wuY.js → plaid.service-B58nzlUE.js} +3 -3
- package/dist/cjs/{schema-validations-DehT309E.js → schema-validations-sjRvL4KO.js} +5 -4
- package/dist/cjs/{terminal.service-C0KG7BqL.js → terminal.service-CmtSEgTc.js} +3 -3
- package/dist/cjs/{utils-CBriZzRC.js → utils-BScgWJC5.js} +1 -1
- package/dist/collection/api/Business.js +2 -0
- package/dist/collection/api/Checkout.js +1 -1
- package/dist/collection/components/business-forms/schemas/schema-helpers.js +2 -1
- package/dist/collection/components/business-forms/utils/helpers.js +3 -1
- package/dist/collection/components/checkouts-list/checkouts-list-filters.js +4 -2
- package/dist/collection/components/checkouts-list/justifi-checkouts-list.js +3 -3
- package/dist/collection/components/modular-checkout/sub-components/justifi-apple-pay.js +7 -1
- package/dist/docs.json +2 -2
- package/dist/esm/{Analytics-3WmRTICF.js → Analytics-BtMYbHD0.js} +4 -4
- package/dist/esm/{Api-83B3f28Q.js → Api-nVK-rgbk.js} +1 -1
- package/dist/esm/{Business-DaDqgDrb.js → Business-CTtGaVYs.js} +5 -1
- package/dist/esm/{Plaid-BP3xNxQF.js → Plaid-CRcTLeaz.js} +1 -1
- package/dist/esm/additional-questions-form-step_15.entry.js +13 -13
- package/dist/esm/additional-questions_4.entry.js +3 -3
- package/dist/esm/bank-account-billing-form-simple_4.entry.js +4 -4
- package/dist/esm/bank-account-document-form-inputs.entry.js +2 -2
- package/dist/esm/bank-account-form.entry.js +4 -4
- package/dist/esm/{business-form-options-BxVQL9ar.js → business-form-options-DLRkVtee.js} +1 -1
- package/dist/esm/{business-identity-schema-BkmRlnQo.js → business-identity-schema-BP61Unwf.js} +3 -3
- package/dist/esm/{business.service-CTqiKKy5.js → business.service-Cq7H5w1T.js} +3 -3
- package/dist/esm/card-form.entry.js +4 -4
- package/dist/esm/{check-pkg-version-CmFl6VLH.js → check-pkg-version-BW9zgceK.js} +1 -1
- package/dist/esm/{checkout-actions-0ftD0elo.js → checkout-actions-CWnrb317.js} +2 -2
- package/dist/esm/{checkout.service-wjFjBxIB.js → checkout.service-JA7oTq5d.js} +3 -3
- package/dist/esm/{country-config-CJwnhkdq.js → country-config-F5YwgHgR.js} +1 -1
- package/dist/esm/dispute-notification_2.entry.js +8 -8
- package/dist/esm/{event-types-cqQHLwCy.js → event-types-Dsf8IwD6.js} +3 -3
- package/dist/esm/form-address-fields_3.entry.js +2 -2
- package/dist/esm/form-alert_3.entry.js +1 -1
- package/dist/esm/form-control-number_2.entry.js +4 -4
- package/dist/esm/{get-business-BLCT-zfN.js → get-business-IZpxKRZM.js} +3 -3
- package/dist/esm/{get-payment-details-BokzuPGl.js → get-payment-details-DSI41Pq5.js} +3 -3
- package/dist/esm/{get-subaccounts-ClGG-LRZ.js → get-subaccounts-B-S2TGRa.js} +4 -4
- package/dist/esm/{input-handlers-Dfuc6aDW.js → input-handlers-Dm8jO-BT.js} +1 -1
- package/dist/esm/justifi-apple-pay_12.entry.js +17 -11
- package/dist/esm/justifi-bank-account-billing-form-simple.entry.js +6 -6
- package/dist/esm/justifi-bank-account-form.entry.js +6 -6
- package/dist/esm/justifi-business-details.entry.js +9 -9
- package/dist/esm/justifi-business-form.entry.js +13 -13
- package/dist/esm/justifi-card-form.entry.js +6 -6
- package/dist/esm/justifi-checkout-qr-code.entry.js +6 -6
- package/dist/esm/justifi-checkout.entry.js +6 -6
- package/dist/esm/justifi-checkouts-list-filters.entry.js +6 -4
- package/dist/esm/justifi-checkouts-list.entry.js +11 -11
- package/dist/esm/justifi-dispute-management.entry.js +8 -8
- package/dist/esm/justifi-gross-payment-chart.entry.js +33 -20
- package/dist/esm/justifi-order-terminals.entry.js +10 -10
- package/dist/esm/justifi-payment-details.entry.js +9 -9
- package/dist/esm/justifi-payment-provisioning.entry.js +9 -9
- package/dist/esm/justifi-payment-transactions-list.entry.js +8 -8
- package/dist/esm/justifi-payments-list.entry.js +8 -8
- package/dist/esm/justifi-payout-details.entry.js +9 -9
- package/dist/esm/justifi-payout-transactions-list.entry.js +8 -8
- package/dist/esm/justifi-payouts-list-filters.entry.js +2 -2
- package/dist/esm/justifi-payouts-list.entry.js +10 -10
- package/dist/esm/justifi-qr-terminal.entry.js +9 -9
- package/dist/esm/justifi-refund-payment.entry.js +9 -9
- package/dist/esm/justifi-season-interruption-insurance.entry.js +7 -7
- package/dist/esm/justifi-terminal-orders-list-filters.entry.js +2 -2
- package/dist/esm/justifi-terminal-orders-list.entry.js +7 -7
- package/dist/esm/justifi-terminals-list-filters.entry.js +2 -2
- package/dist/esm/justifi-terminals-list.entry.js +9 -9
- package/dist/esm/{package-CAVi_ne1.js → package-BC9n8nB2.js} +1 -1
- package/dist/esm/{payment-provisioning-actions-VRIPjnAQ.js → payment-provisioning-actions-VtleD509.js} +2 -2
- package/dist/esm/payment-provisioning-form-buttons_2.entry.js +1 -1
- package/dist/esm/{payment.service-D7uv5vym.js → payment.service-B42sKlQE.js} +3 -3
- package/dist/esm/{payout.service-BoSyqft1.js → payout.service-BIoAgNJJ.js} +3 -3
- package/dist/esm/{payouts-status-CaiC5qpn.js → payouts-status-CnIf4XDi.js} +2 -2
- package/dist/esm/{plaid.service-DufQkxDk.js → plaid.service-C6Ltk2ef.js} +3 -3
- package/dist/esm/{schema-validations-8dbMCACI.js → schema-validations-De7Qe0VU.js} +5 -4
- package/dist/esm/{terminal.service-BM2aebB6.js → terminal.service-DV3qIwBy.js} +3 -3
- package/dist/esm/{utils-YUOJKtjO.js → utils-DaPywmTI.js} +1 -1
- package/dist/module/Business.js +5 -1
- package/dist/module/Plaid.js +1 -1
- package/dist/module/justifi-apple-pay2.js +7 -1
- package/dist/module/justifi-checkouts-list-filters.js +4 -2
- package/dist/module/justifi-checkouts-list.js +2 -2
- package/dist/module/justifi-gross-payment-chart.js +26 -13
- package/dist/module/package.js +1 -1
- package/dist/module/schema-validations.js +2 -1
- package/dist/types/api/Business.d.ts +2 -0
- package/dist/types/api/Checkout.d.ts +7 -7
- package/dist/types/components/checkouts-list/justifi-checkouts-list.d.ts +1 -1
- package/dist/types/components/modular-checkout/sub-components/justifi-apple-pay.d.ts +1 -0
- package/dist/types/components.d.ts +1 -1
- package/dist/webcomponents/p-065b854f.entry.js +1 -0
- package/dist/webcomponents/{p-b98ea26a.entry.js → p-082f912c.entry.js} +1 -1
- package/dist/webcomponents/{p-5c89dcdf.entry.js → p-0cd689f4.entry.js} +1 -1
- package/dist/webcomponents/{p-6eb65d23.entry.js → p-0e9351c4.entry.js} +1 -1
- package/dist/webcomponents/p-0f7e3515.entry.js +20 -0
- package/dist/webcomponents/{p-f3682c72.entry.js → p-13814028.entry.js} +1 -1
- package/dist/webcomponents/{p-bf3866b3.entry.js → p-16261d8a.entry.js} +1 -1
- package/dist/webcomponents/p-19cabdaf.entry.js +1 -0
- package/dist/webcomponents/{p-cb1cc88e.entry.js → p-1cfa634a.entry.js} +1 -1
- package/dist/webcomponents/p-2ef913b8.entry.js +1 -0
- package/dist/webcomponents/{p-25f70d5f.entry.js → p-3a1f8c5b.entry.js} +1 -1
- package/dist/webcomponents/{p-0aa96018.entry.js → p-429046e1.entry.js} +1 -1
- package/dist/webcomponents/{p-4cad48c1.entry.js → p-44ff4f2c.entry.js} +1 -1
- package/dist/webcomponents/{p-68e88747.entry.js → p-4740601b.entry.js} +1 -1
- package/dist/webcomponents/{p-50c2b8f0.entry.js → p-59b95eae.entry.js} +1 -1
- package/dist/webcomponents/{p-1cdbe8c1.entry.js → p-5c889829.entry.js} +1 -1
- package/dist/webcomponents/p-6c7fca1a.entry.js +1 -0
- package/dist/webcomponents/{p-5dcb1713.entry.js → p-735d397e.entry.js} +1 -1
- package/dist/webcomponents/p-8432cb42.entry.js +1 -0
- package/dist/webcomponents/{p-f5358a80.entry.js → p-88a44a02.entry.js} +1 -1
- package/dist/webcomponents/{p-f9f0cb1f.entry.js → p-89f0c2aa.entry.js} +1 -1
- package/dist/webcomponents/p-9b43b90d.entry.js +1 -0
- package/dist/webcomponents/p-9db15fac.entry.js +1 -0
- package/dist/webcomponents/{p-b23dfa13.entry.js → p-9eb00966.entry.js} +1 -1
- package/dist/webcomponents/p-BAvoKtN2.js +1 -0
- package/dist/webcomponents/p-BC9n8nB2.js +1 -0
- package/dist/webcomponents/p-BDtSw_d-.js +1 -0
- package/dist/webcomponents/{p-CIpBEUtx.js → p-B_2zgnvM.js} +1 -1
- package/dist/webcomponents/{p-CLq3Og7o.js → p-BhpaUYtS.js} +1 -1
- package/dist/webcomponents/{p-nbKvRcwU.js → p-BjjKkMO1.js} +1 -1
- package/dist/webcomponents/p-BmaQUnqv.js +1 -0
- package/dist/webcomponents/{p-DZQBPUfH.js → p-Bxc0NRj8.js} +1 -1
- package/dist/webcomponents/p-C60AkJ6a.js +1 -0
- package/dist/webcomponents/{p-vIQBTQmc.js → p-C6Jq8YDT.js} +1 -1
- package/dist/webcomponents/p-C9p1gWAC.js +1 -0
- package/dist/webcomponents/p-CTtGaVYs.js +1 -0
- package/dist/webcomponents/p-CgOgijHy.js +1 -0
- package/dist/webcomponents/{p-OReJ-ZQb.js → p-CtlBL-X6.js} +1 -1
- package/dist/webcomponents/p-D694H6co.js +1 -0
- package/dist/webcomponents/p-D7fNBSlC.js +1 -0
- package/dist/webcomponents/p-D7nyPi2Q.js +1 -0
- package/dist/webcomponents/p-DC2djVls.js +1 -0
- package/dist/webcomponents/{p-B0DHIvEj.js → p-DQmijfCN.js} +1 -1
- package/dist/webcomponents/p-Dqxyi-uK.js +1 -0
- package/dist/webcomponents/{p-BEL8sLz6.js → p-_MjmE9YT.js} +1 -1
- package/dist/webcomponents/{p-c3818a5a.entry.js → p-a10beb26.entry.js} +1 -1
- package/dist/webcomponents/{p-7002286e.entry.js → p-a71cc8e2.entry.js} +1 -1
- package/dist/webcomponents/{p-ced6f6f1.entry.js → p-a7c594d1.entry.js} +1 -1
- package/dist/webcomponents/{p-6931a1f2.entry.js → p-a8d25057.entry.js} +1 -1
- package/dist/webcomponents/{p-ee7fe3a8.entry.js → p-b9ba7c95.entry.js} +1 -1
- package/dist/webcomponents/{p-5842d4e8.entry.js → p-c385f10d.entry.js} +1 -1
- package/dist/webcomponents/p-c55fdbbf.entry.js +1 -0
- package/dist/webcomponents/{p-eb31024f.entry.js → p-cec7164e.entry.js} +1 -1
- package/dist/webcomponents/p-d3544e86.entry.js +1 -0
- package/dist/webcomponents/{p-9e9a2546.entry.js → p-de047614.entry.js} +1 -1
- package/dist/webcomponents/{p-c5424fda.entry.js → p-f2b3c7d5.entry.js} +1 -1
- package/dist/webcomponents/{p-e55216fb.entry.js → p-f39889f2.entry.js} +1 -1
- package/dist/webcomponents/{p-6c94218c.entry.js → p-f40fa614.entry.js} +1 -1
- package/dist/webcomponents/{p-5d7b3d71.entry.js → p-f5cb6a26.entry.js} +1 -1
- package/dist/webcomponents/{p-fdd087d4.entry.js → p-f9f310dc.entry.js} +1 -1
- package/dist/webcomponents/p-iA-Amt2z.js +1 -0
- package/dist/webcomponents/p-pueOrhXO.js +1 -0
- package/dist/webcomponents/{p-CJEetAx7.js → p-rFpPIJgu.js} +1 -1
- package/dist/webcomponents/{p-CawcnSoV.js → p-riZDHN5-.js} +1 -1
- package/dist/webcomponents/webcomponents.esm.js +1 -1
- package/package.json +15 -17
- package/dist/webcomponents/p-27igUlku.js +0 -1
- package/dist/webcomponents/p-3642e189.entry.js +0 -1
- package/dist/webcomponents/p-5f8c30b6.entry.js +0 -1
- package/dist/webcomponents/p-74575a99.entry.js +0 -1
- package/dist/webcomponents/p-7c405573.entry.js +0 -1
- package/dist/webcomponents/p-825a7ee6.entry.js +0 -1
- package/dist/webcomponents/p-909a9828.entry.js +0 -20
- package/dist/webcomponents/p-955c06d3.entry.js +0 -1
- package/dist/webcomponents/p-BAKuMxC9.js +0 -1
- package/dist/webcomponents/p-BSxXlu9H.js +0 -1
- package/dist/webcomponents/p-CAVi_ne1.js +0 -1
- package/dist/webcomponents/p-CXsRwohv.js +0 -1
- package/dist/webcomponents/p-CbyGKcz_.js +0 -1
- package/dist/webcomponents/p-Cy2N3vAg.js +0 -1
- package/dist/webcomponents/p-CyOXIqHo.js +0 -1
- package/dist/webcomponents/p-D6uhYbLo.js +0 -1
- package/dist/webcomponents/p-DN7VhlTn.js +0 -1
- package/dist/webcomponents/p-DNuxxP2B.js +0 -1
- package/dist/webcomponents/p-D_84NsmN.js +0 -1
- package/dist/webcomponents/p-DaDqgDrb.js +0 -1
- package/dist/webcomponents/p-Do9dxNjh.js +0 -1
- package/dist/webcomponents/p-PdwJswAy.js +0 -1
- package/dist/webcomponents/p-ca13117d.entry.js +0 -1
- package/dist/webcomponents/p-d59676ea.entry.js +0 -1
- package/dist/webcomponents/p-d98bc829.entry.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as t,c as e,h as i,H as s,g as a}from"./p-CV0Pyo1O.js";import{A as n}from"./p-vIQBTQmc.js";import{A as o,r,s as l,t as h,u as c,v as d,w as u,C as p,b as y,c as m,I as v,x as f,y as g,z as b}from"./p-D6uhYbLo.js";import{S as M}from"./p-05AWudQe.js";import"./p-CZfYo5-1.js";import{S as w}from"./p-eBK-iWrz.js";import{c as k,o as P,a as j,g as C,b as T}from"./p-Fpaf7CLD.js";import{t as A,r as E}from"./p-Bu7gdOaV.js";import{f as I}from"./p-Ds_P-dB8.js";import{w as N,c as D}from"./p-B4vLfYnZ.js";import{H as S}from"./p-CZk3i5Tu.js";import{H as O,b as L,h as x,i as z}from"./p-x2oNTAWh.js";import{H as _}from"./p-BAB1lPu0.js";import{J as R}from"./p-nbKvRcwU.js";import{c as U}from"./p-BEL8sLz6.js";import"./p-HXpYMWUU.js";import"./p-CLHwhyvu.js";import"./p-DaDqgDrb.js";import{m as B,a as Y}from"./p-CXsRwohv.js";import{C as F}from"./p-27igUlku.js";import{P as V}from"./p-DN7VhlTn.js";import{P as Q,a as H,b as W}from"./p-DEx8fQeW.js";import{C as Z}from"./p-ZpPDShvP.js";import"./p-CAVi_ne1.js";import"./p-DgTOxu8x.js";import"./p-CLq3Og7o.js";const G=class{constructor(i){t(this,i),this.radioClick=e(this,"radio-click",7),this.checked=!1,this.hidden=!1}render(){return i(M,{key:"02955940079320bd9c6bf94e239545385ac36458"},i("radio-list-item",{key:"fc6b98e456e4326b843b2b3248b7327436767cf4",name:this.name,value:this.value,label:this.label,checked:this.checked,hidden:this.hidden,class:this.class,"onRadio-click":t=>this.radioClick.emit(t.detail)}))}};var q;!function(t){t.UNAVAILABLE="UNAVAILABLE",t.SESSION_ERROR="SESSION_ERROR",t.MERCHANT_VALIDATION_ERROR="MERCHANT_VALIDATION_ERROR",t.PAYMENT_PROCESSING_ERROR="PAYMENT_PROCESSING_ERROR",t.USER_CANCELLED="USER_CANCELLED"}(q||(q={}));class J{constructor(){this.api=n()}initialize(t){if(this.applePayConfig=new o(t),!this.applePayConfig.isValid)throw new Error("Invalid Apple Pay configuration provided")}async validateMerchant(t,e){try{return await this.api.post({endpoint:"apple_pay/merchant_session",authToken:t,headers:{"Sub-Account":e},body:{domain:window.location.hostname,display_name:this.applePayConfig.displayName}})}catch(t){throw console.error("Backend validation failed:",t),new Error("Merchant validation failed")}}async processPayment(t,e,i){const s=await this.api.post({endpoint:"apple_pay/process_token",authToken:t,body:i,headers:{"Sub-Account":e}});return{success:s.id&&!!s.data.token,data:s}}isAvailable(){return r.isApplePaySupported()&&r.canMakePayments()}async canMakePaymentsWithActiveCard(){if(!this.applePayConfig)throw new Error("Apple Pay not initialized. Call initialize() first.");return await r.canMakePaymentsWithActiveCard(this.applePayConfig.merchantIdentifier)}async startPaymentSession(t,e,i){if(!this.applePayConfig)throw console.error("[ApplePayService] Missing applePayConfig. Did you call initialize()?"),new Error("Apple Pay not initialized. Call initialize() first.");const s=new l(t);if(!s.isValid){const t=[];throw s.countryCode||t.push("countryCode"),s.currencyCode||t.push("currencyCode"),s.merchantCapabilities&&0!==s.merchantCapabilities.length||t.push("merchantCapabilities"),s.supportedNetworks&&0!==s.supportedNetworks.length||t.push("supportedNetworks"),s.total&&s.total.label&&s.total.amount||t.push("total"),console.error("[ApplePayService] Payment request is invalid. Missing/invalid:",t),new Error("Invalid payment request provided")}return this.currentPaymentRequest=s,new Promise(((t,a)=>{try{if("undefined"==typeof window||!("ApplePaySession"in window))return console.error("[ApplePayService] ApplePaySession not available on window"),a({success:!1,error:{code:q.UNAVAILABLE,message:"ApplePaySession API is not available in this environment"}});this.currentSession=new window.ApplePaySession(3,s),this.setupSessionEventHandlers(t,a,e,i),this.currentSession.begin()}catch(t){console.error("[ApplePayService] Exception while starting session:",t),a({success:!1,error:{code:q.SESSION_ERROR,message:t instanceof Error?t.message:"Failed to start Apple Pay session"}})}}))}abortPaymentSession(){this.currentSession&&(this.currentSession.abort(),this.currentSession=void 0,this.currentPaymentRequest=void 0)}setupSessionEventHandlers(t,e,i,s){this.currentSession&&this.applePayConfig&&this.currentPaymentRequest?(this.currentSession.onvalidatemerchant=async()=>{try{if(!i)throw console.error("[ApplePayService] Missing authToken for merchant validation"),new Error("Authentication token not provided.");const t=await this.validateMerchant(i,s);try{this.currentSession.completeMerchantValidation(t)}catch(t){throw console.error("Error calling completeMerchantValidation:",t),t}}catch(t){console.error("=== MERCHANT VALIDATION ERROR ==="),console.error("Error during merchant validation:",t),t&&t.stack&&console.error("Error stack:",t.stack),this.currentSession.abort(),e({success:!1,error:{code:q.MERCHANT_VALIDATION_ERROR,message:t instanceof Error?t.message:"Merchant validation failed"}})}},this.currentSession.onpaymentauthorized=async a=>{try{const n=a.payment,o=Object.assign(Object.assign({},n.token),{product_details:{name:this.currentPaymentRequest.total.label,price:r.parseAmount(this.currentPaymentRequest.total.amount),description:this.currentPaymentRequest.total.label}}),l=await this.processPayment(i,s,o);l.success?(this.currentSession.completePayment({status:h.STATUS_SUCCESS}),t({success:!0,token:n.token,paymentMethodId:l.data.id})):(console.error("PSP reported payment failure:",l.data),this.currentSession.completePayment({status:h.STATUS_FAILURE}),e({success:!1,error:{code:q.PAYMENT_PROCESSING_ERROR,message:"Payment processing failed"}}))}catch(t){console.error("=== PAYMENT PROCESSING ERROR ==="),console.error("Error processing payment:",t),t&&t.stack&&console.error("Error stack:",t.stack),this.currentSession.completePayment({status:h.STATUS_FAILURE}),e({success:!1,error:{code:q.PAYMENT_PROCESSING_ERROR,message:t instanceof Error?t.message:"Payment processing failed"}})}finally{this.currentSession=void 0,this.currentPaymentRequest=void 0}},this.currentSession.onpaymentmethodselected=()=>{const t={newTotal:this.currentPaymentRequest.total,newLineItems:this.currentPaymentRequest.lineItems||[]};try{this.currentSession.completePaymentMethodSelection(t)}catch(t){console.error("Error completing payment method selection:",t),this.currentSession.abort()}},this.currentSession.onshippingmethodselected=()=>{this.currentSession.completeShippingMethodSelection({status:h.STATUS_SUCCESS,newTotal:this.currentPaymentRequest.total,newLineItems:this.currentPaymentRequest.lineItems||[]})},this.currentSession.oncancel=t=>{if(t.sessionError)switch(console.error(t.sessionError),t.sessionError.code){case"unknown":console.error("Unknown error - likely merchant validation issue"),console.error("This usually means:"),console.error("1. Merchant certificate is invalid or expired"),console.error("2. Merchant identifier mismatch"),console.error("3. Backend validation endpoint issues");break;case"invalidMerchantSession":console.error("Invalid merchant session provided"),console.error("Check that the merchant session from backend is valid");break;case"userCancel":console.error("User cancelled the payment");break;default:console.error("Other error code:",t.sessionError.code)}this.currentSession=void 0,this.currentPaymentRequest=void 0,e({success:!1,error:{code:q.USER_CANCELLED,message:"User cancelled the Apple Pay session"}})},"onerror"in this.currentSession&&(this.currentSession.onerror=t=>{console.error("=== APPLE PAY SESSION ERROR ==="),console.error("Session error:",t),this.currentSession=void 0,this.currentPaymentRequest=void 0,e({success:!1,error:{code:q.SESSION_ERROR,message:"Apple Pay session error occurred"}})})):console.error("[ApplePayService] setupSessionEventHandlers called without required state",{hasSession:Boolean(this.currentSession),hasConfig:Boolean(this.applePayConfig),hasPaymentRequest:Boolean(this.currentPaymentRequest)})}static createPaymentRequest(t,e,i="US",s="USD"){return{countryCode:i,currencyCode:s,merchantCapabilities:r.getDefaultMerchantCapabilities(),supportedNetworks:r.getDefaultSupportedNetworks(),total:r.createLineItem(e,t)}}getApplePayConfig(){return this.applePayConfig}}const K=t=>{const{isLoading:e}=t;return e?i("div",{class:"container-fluid p-0"},i("div",{class:"row mb-3"},i("div",{class:"col-12 align-content-center"},i(w,{height:"44px",width:"100%",styles:{borderRadius:"8px"}})))):null},$=t=>i("div",{class:"apple-pay-button-container"},i("button",Object.assign({class:(()=>{let e="apple-pay-button";switch(t.buttonStyle){case c.WHITE:e+=" apple-pay-button-white";break;case c.WHITE_OUTLINE:e+=" apple-pay-button-white-outline";break;default:e+=" apple-pay-button-black"}switch(t.buttonType){case d.BUY:e+=" apple-pay-button-type-buy";break;case d.DONATE:e+=" apple-pay-button-type-donate";break;default:e+=" apple-pay-button-type-plain"}return(t.disabled||t.isProcessing||!t.isAvailable)&&(e+=" disabled"),e})(),style:{width:t.width,height:t.height},onClick:()=>{!t.disabled&&!t.isProcessing&&t.isAvailable&&t.clickHandler&&t.clickHandler()},disabled:t.disabled||t.isProcessing||!t.isAvailable,"aria-label":"Pay with Apple Pay",type:"button"},t),t.isProcessing&&i("div",{class:"processing-overlay"},i("div",{class:"spinner"}),i("span",null,"Processing..."))),i("style",null,"\n .apple-pay-button-container {\n display: block;\n position: relative;\n width: 100%;\n }\n\n /* Apple Pay CSS classes - these are the official Apple Pay button styles */\n .apple-pay-button {\n display: inline-block;\n -webkit-appearance: -apple-pay-button;\n -apple-pay-button-type: plain; /* default */\n -apple-pay-button-style: black; /* default */\n border-radius: 8px;\n cursor: pointer;\n border: none;\n outline: none;\n transition: opacity 0.2s ease;\n position: relative;\n }\n\n /* Button styles */\n .apple-pay-button.apple-pay-button-black {\n -apple-pay-button-style: black;\n }\n\n .apple-pay-button.apple-pay-button-white {\n -apple-pay-button-style: white;\n }\n\n .apple-pay-button.apple-pay-button-white-outline {\n -apple-pay-button-style: white-outline;\n }\n\n /* Button types */\n .apple-pay-button.apple-pay-button-type-plain {\n -apple-pay-button-type: plain;\n }\n\n .apple-pay-button.apple-pay-button-type-buy {\n -apple-pay-button-type: buy;\n }\n\n .apple-pay-button.apple-pay-button-type-donate {\n -apple-pay-button-type: donate;\n }\n\n /* Hover and disabled states */\n .apple-pay-button:hover:not(.disabled) {\n opacity: 0.9;\n }\n\n .apple-pay-button.disabled {\n opacity: 0.5;\n cursor: not-allowed;\n }\n\n /* Processing overlay */\n .processing-overlay {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 8px;\n background: rgba(0, 0, 0, 0.8);\n color: white;\n border-radius: 8px;\n font-size: 14px;\n font-weight: 500;\n }\n\n .spinner {\n width: 16px;\n height: 16px;\n border: 2px solid rgba(255, 255, 255, 0.3);\n border-top: 2px solid #fff;\n border-radius: 50%;\n animation: spin 1s linear infinite;\n }\n\n @keyframes spin {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n }\n\n /* Responsive design */\n @media (max-width: 480px) {\n .apple-pay-button {\n width: 100% !important;\n min-width: 200px;\n }\n }\n ")),X=class{constructor(i){t(this,i),this.applePayStarted=e(this,"applePayStarted",7),this.applePayCompleted=e(this,"applePayCompleted",7),this.applePayCancelled=e(this,"applePayCancelled",7),this.applePayError=e(this,"applePayError",7),this.sdkLoaded=!1,this.countryCode="US",this.merchantIdentifier="merchant.com.staging-justifi.checkout-dev",this.merchantDisplayName="JustiFi Checkout",this.initiativeContext="dev-checkout.justifi-staging.com",this.buttonType=d.PLAIN,this.buttonStyle=c.BLACK,this.disabled=!1,this.width="100%",this.height="48px",this.isLoading=!0,this.isProcessing=!1,this.isAvailable=!1,this.canMakePayments=!1,this.isConfigValid=!0,this.error=null,this.handleApplePayClick=async()=>{var t,e,i;if(!this.isProcessing&&!this.disabled&&this.isAvailable)try{this.isProcessing=!0,this.error=null,this.applePayStarted.emit();const i={countryCode:this.countryCode,currencyCode:k.paymentCurrency,merchantCapabilities:[u.SUPPORTS_3DS,u.SUPPORTS_CREDIT,u.SUPPORTS_DEBIT],supportedNetworks:r.getDefaultSupportedNetworks(),total:r.createLineItem(k.paymentDescription,k.paymentAmount)},s=await this.applePayService.startPaymentSession(i,k.authToken,k.accountId);s.success?this.applePayCompleted.emit({success:!0,token:s.token,paymentMethodId:s.paymentMethodId}):(this.applePayCompleted.emit({success:!1,error:s.error}),this.applePayError.emit({error:(null===(t=s.error)||void 0===t?void 0:t.message)||"Payment failed",code:(null===(e=s.error)||void 0===e?void 0:e.code)||X.ErrorCode.PAYMENT_FAILED}))}catch(t){if((null===(i=null==t?void 0:t.error)||void 0===i?void 0:i.code)===q.USER_CANCELLED)this.applePayCancelled.emit();else{const e=t instanceof Error?t.message:"Payment failed";this.error=e,this.applePayError.emit({error:e,code:X.ErrorCode.PAYMENT_FAILED}),this.applePayCompleted.emit({success:!1,error:e})}}finally{this.isProcessing=!1}}}componentWillLoad(){this.isAvailable=r.isApplePaySupported(),this.isAvailable?k.checkoutLoaded?this.loadApplePaySDK():P("checkoutLoaded",(t=>{t&&this.loadApplePaySDK()})):this.isLoading=!1}loadApplePaySDK(){if(this.sdkLoaded)return;this.sdkLoaded=!0;const t=document.createElement("script");t.src="https://applepay.cdn-apple.com/jsapi/1.latest/apple-pay-sdk.js",t.async=!0,t.onload=()=>this.initializeApplePay(),document.head.appendChild(t)}async initializeApplePay(){try{if(this.isLoading=!0,this.error=null,this.isConfigValid=!0,!(Boolean(k.paymentAmount)&&Boolean(k.paymentCurrency)&&Boolean(k.authToken)))return this.error="Missing required Apple Pay configuration",this.isConfigValid=!1,this.applePayError.emit({error:this.error,code:X.ErrorCode.CONFIG_ERROR}),void(this.isLoading=!1);if(this.isAvailable=r.isApplePaySupported(),this.canMakePayments=r.canMakePayments(),!this.isAvailable)return this.error="Apple Pay is not supported on this device",this.applePayError.emit({error:this.error,code:X.ErrorCode.NOT_SUPPORTED}),void(this.isLoading=!1);if(!this.canMakePayments)return this.error="Apple Pay is not available",this.applePayError.emit({error:this.error,code:X.ErrorCode.NOT_AVAILABLE}),void(this.isLoading=!1);const t={merchantIdentifier:this.merchantIdentifier,displayName:this.merchantDisplayName,initiative:"web",initiativeContext:this.initiativeContext,buttonType:this.buttonType,buttonStyle:this.buttonStyle};this.applePayService=new J,this.applePayService.initialize(t),await this.applePayService.canMakePaymentsWithActiveCard()||console.warn("No Apple Pay cards available, but continuing...")}catch(t){this.error=t instanceof Error?t.message:"Failed to initialize Apple Pay",this.applePayError.emit({error:this.error,code:X.ErrorCode.INITIALIZATION_ERROR})}finally{this.isLoading=!1}}async isSupported(){return this.isAvailable&&this.canMakePayments}async getPaymentMethods(){return this.isAvailable?r.getDefaultSupportedNetworks():[]}async abort(){var t;null===(t=this.applePayService)||void 0===t||t.abortPaymentSession(),this.isProcessing=!1,this.applePayCancelled.emit()}render(){if(!k.applePayEnabled)return null;if(!this.isAvailable)return null;const t=!this.isLoading&&this.isAvailable&&this.canMakePayments&&this.isConfigValid;return i(M,null,i("div",{class:"apple-pay-container"},i(K,{isLoading:this.isLoading}),t&&i($,{buttonType:this.buttonType,buttonStyle:this.buttonStyle,disabled:this.disabled,isProcessing:this.isProcessing,isAvailable:this.isAvailable,clickHandler:this.handleApplePayClick,width:this.width,height:this.height})),i("style",null,"\n .apple-pay-container {\n width: 100%;\n }\n "))}};X.ErrorCode={CONFIG_ERROR:"CONFIG_ERROR",NOT_SUPPORTED:"NOT_SUPPORTED",NOT_AVAILABLE:"NOT_AVAILABLE",INITIALIZATION_ERROR:"INITIALIZATION_ERROR",PAYMENT_FAILED:"PAYMENT_FAILED"};const tt=class{constructor(e){t(this,e),this.variant="primary",this.type="button"}render(){return i(M,{key:"1e09a302d064e2e4a860dc4efd9eb9693d4d0055"},i("internal-button",{key:"9ce7819853789c44860de43f26632c62415ebdb5",text:this.text,variant:this.variant,isLoading:this.isLoading,clickHandler:this.clickHandler,type:this.type,disabled:this.disabled,class:this.class,customStyle:this.customStyle,hidden:this.hidden}))}},et=class{constructor(e){t(this,e)}render(){return i(M,{key:"7d3447ff4daa9bf4f603ca381027b3f43cfcc6a1"},i("section",{key:"1c8189ccde6dc986ad2d4c74da2dd10cacfc1c36"},i("div",{key:"45e6d5f47d8a92e0bd4a7bfa427630a96f049b4a"},i("div",{key:"9900b5fd770cd59b00803c3614216c16a803da41",part:A},null==k?void 0:k.paymentDescription),i("div",{key:"16cec140ef6912533a80b1f6341fcc9cb341b478"},i("span",{key:"f8883538c99a524017bb102bfd8cfaea7062e650",part:A},"Total")," ",i("span",{key:"11baa64630a60c56cedfa53548c107ec3fe3c0f5",part:A},I(+(null==k?void 0:k.totalAmount)))))))}},it=t=>{const{isLoading:e}=t;return e?i("div",{class:"container-fluid p-0"},i("div",{class:"row mb-3"},i("div",{class:"col-12 align-content-center"},i(w,{height:"44px",width:"100%",styles:{borderRadius:"8px"}})))):null};var st;!function(t){t.initialize="justifi.googlePay.initialize",t.ready="justifi.googlePay.ready",t.sdkLoaded="justifi.googlePay.sdkLoaded",t.initializeResult="justifi.googlePay.initializeResult",t.error="justifi.googlePay.error",t.buttonClicked="justifi.googlePay.buttonClicked",t.startPayment="justifi.googlePay.startPayment",t.paymentSuccess="justifi.googlePay.paymentSuccess",t.paymentCanceled="justifi.googlePay.paymentCanceled",t.paymentError="justifi.googlePay.paymentError"}(st||(st={}));const at=class{constructor(i){t(this,i),this.googlePayStarted=e(this,"googlePayStarted",7),this.googlePayCompleted=e(this,"googlePayCompleted",7),this.googlePayCancelled=e(this,"googlePayCancelled",7),this.merchantDisplayName="JustiFi Checkout",this.useNativePaymentRequest=!1,this.iframeReady=!1,this.sdkLoaded=!1,this.isReadyToPay=!1,this.handleMessage=t=>{if(t.origin!==this.iframeOrigin)return;const{eventType:e,data:i}=t.data||{};switch(e){case st.ready:this.iframeReady=!0;break;case st.sdkLoaded:this.sdkLoaded=!0,this.sendInitialize();break;case st.initializeResult:this.isReadyToPay=i.isReadyToPay,i.error&&console.error("Init error:",i.error);break;case st.error:console.error("Google Pay error:",i);break;case st.buttonClicked:this.googlePayStarted.emit(),this.sendStartPayment();break;case st.paymentSuccess:this.googlePayCompleted.emit({success:!0,paymentMethodId:i.paymentMethodId,cardNetwork:i.cardNetwork,cardDetails:i.cardDetails});break;case st.paymentCanceled:this.googlePayCancelled.emit();break;case st.paymentError:this.googlePayCompleted.emit({success:!1,error:{code:i.code,message:i.message}})}}}async componentWillLoad(){await N(),this.iframeOrigin=D.iframeOrigin}componentDidLoad(){window.addEventListener("message",this.handleMessage)}disconnectedCallback(){window.removeEventListener("message",this.handleMessage)}googlePayEnvironment(){return void 0!==this.environment?this.environment:"test"===k.checkoutMode?"TEST":"PRODUCTION"}sendInitialize(){var t;if(!(null===(t=this.iframeElement)||void 0===t?void 0:t.contentWindow))return;const e={environment:this.googlePayEnvironment(),gatewayMerchantId:k.accountId,merchantName:this.merchantDisplayName,authToken:k.authToken,accountId:k.accountId,useNativePaymentRequest:this.useNativePaymentRequest};this.iframeElement.contentWindow.postMessage({eventType:st.initialize,data:e},this.iframeOrigin)}sendStartPayment(){var t;if(!(null===(t=this.iframeElement)||void 0===t?void 0:t.contentWindow))return;const e={totalPrice:String(k.paymentAmount/100),totalPriceStatus:"FINAL",currencyCode:k.paymentCurrency||"USD"};this.iframeElement.contentWindow.postMessage({eventType:st.startPayment,data:e},this.iframeOrigin)}render(){return k.checkoutLoaded?k.googlePayEnabled?i(s,null,i(it,{isLoading:!this.isReadyToPay}),i("iframe",{ref:t=>this.iframeElement=t,src:`${this.iframeOrigin}/v2/googlePay`,allow:"payment",style:{border:"none",width:"100%",height:"48px",display:this.isReadyToPay?"block":"none"}})):(console.warn("Google Pay is not enabled for this checkout"),null):null}},nt=class{constructor(e){t(this,e),this.levels={h1:S,h2:O,h3:_},this.level="h1"}render(){return i(M,{key:"1843adabddf7d439036f8ce6f55627b7ca3e4a9f"},i(this.levels[this.level],{key:"b16e5624ce7e092cc8c144a7cdfd9cb6afdf7a83",text:this.text,class:this.class}))}},ot=class{constructor(i){t(this,i),this.errorEvent=e(this,"error-event",7),this.submitEvent=e(this,"submit-event",7),this.checkoutChangedEvent=e(this,"checkout-changed",7),this.plaidService=new V,this.handlePaypalStarted=()=>{k.isWalletProcessing=!0},this.handlePaypalCompleted=t=>{const{success:e,paymentMethodId:i,fundingSource:s}=t.detail||{};k.isWalletProcessing=!1,e&&i?(k.paymentToken=i,k.selectedPaymentMethod={type:"venmo"===s?Q.VENMO:Q.PAYPAL},this.submitCheckout()):this.errorEvent.emit({message:"Paypal payment failed",errorCode:y.TOKENIZE_ERROR,severity:p.ERROR})},this.handlePaypalCancelled=()=>{k.isWalletProcessing=!1,k.paymentToken=void 0,k.selectedPaymentMethod=void 0},this.handlePaypalError=t=>{k.isWalletProcessing=!1;const{error:e,code:i}=t.detail||{};this.errorEvent.emit({message:e||"Paypal error occurred",errorCode:`PAYPAL_${i}`,severity:p.ERROR})},this.handleApplePayStarted=()=>{k.isWalletProcessing=!0},this.handleGooglePayStarted=()=>{k.isWalletProcessing=!0},this.handleGooglePayCompleted=t=>{const{success:e,paymentMethodId:i,error:s}=t.detail||{};e&&i?(k.isWalletProcessing=!1,k.paymentToken=i,k.selectedPaymentMethod={type:Q.GOOGLE_PAY},this.submitCheckout()):(k.isWalletProcessing=!1,this.errorEvent.emit({message:s&&s.message||"Google Pay payment failed",errorCode:y.TOKENIZE_ERROR,severity:p.ERROR}))},this.handleGooglePayCancelled=()=>{k.isWalletProcessing=!1,k.paymentToken=void 0,k.selectedPaymentMethod=void 0},this.handleApplePayCompleted=t=>{const{success:e,token:i,paymentMethodId:s,error:a}=t.detail;e&&i?(k.isWalletProcessing=!1,k.paymentToken=s,k.selectedPaymentMethod={type:Q.APPLE_PAY},this.submitCheckout()):(k.isWalletProcessing=!1,console.error("Apple Pay completed but failed:",a),this.errorEvent.emit({message:(null==a?void 0:a.message)||"Apple Pay payment failed",errorCode:y.TOKENIZE_ERROR,severity:p.ERROR}))},this.handleApplePayError=t=>{k.isWalletProcessing=!1;const{error:e,code:i}=t.detail;console.error("Apple Pay error:",e),this.errorEvent.emit({message:e||"Apple Pay error occurred",errorCode:`APPLE_PAY_${i}`,severity:p.ERROR})},this.handleApplePayCancelled=()=>{k.isWalletProcessing=!1,k.paymentToken=void 0,k.selectedPaymentMethod=void 0}}connectedCallback(){var t;this.observer=new MutationObserver((()=>{this.queryFormRefs(),this.setupApplePayListeners(),this.setupGooglePayListeners(),this.setupPaypalListeners()})),this.observer.observe(this.hostEl,{childList:!0,subtree:!0}),k.checkoutId=this.checkoutId;const e={authToken:this.authToken,checkoutId:this.checkoutId,service:new F};this.getCheckout=B(e),this.completeCheckout=Y(e),null===(t=this.unsubscribeCheckoutChanges)||void 0===t||t.call(this),this.unsubscribeCheckoutChanges=j((()=>{this.emitCheckoutChanged()}))}componentWillLoad(){this.analytics=new R(this),U(),k.authToken=this.authToken,this.fetchCheckout(),L("set",(t=>{const e=z[t];void 0!==e&&x(t,e)&&this.fetchCheckout()}))}componentDidLoad(){this.queryFormRefs(),this.setupApplePayListeners(),this.setupGooglePayListeners(),this.setupPaypalListeners()}disconnectedCallback(){var t,e;null===(t=this.unsubscribeCheckoutChanges)||void 0===t||t.call(this),this.unsubscribeCheckoutChanges=void 0,null===(e=this.observer)||void 0===e||e.disconnect(),this.removeApplePayListeners(),this.removeGooglePayListeners(),this.removePaypalListeners()}fetchCheckout(){this.authToken&&this.checkoutId?this.getCheckout&&this.getCheckout({onSuccess:({checkout:t})=>{this.updateStore(t),t.status!==v.completed?t.status!==v.expired||this.errorEvent.emit({message:m.CHECKOUT_EXPIRED,errorCode:y.CHECKOUT_EXPIRED,severity:p.ERROR}):this.errorEvent.emit({message:m.CHECKOUT_ALREADY_COMPLETED,errorCode:y.CHECKOUT_ALREADY_COMPLETED,severity:p.ERROR})},onError:t=>{this.errorEvent.emit({message:t.message,errorCode:t.code,severity:t.severity})}}):this.errorEvent.emit({message:m.NOT_AUTHENTICATED,errorCode:y.NOT_AUTHENTICATED,severity:p.ERROR})}updateStore(t){var e,i,s,a,n,o,r,l,h,c,d,u,p,y,m;k.accountId=t.account_id;const v=null!=t.mode?String(t.mode).toLowerCase():"";k.checkoutMode="test"===v?"test":"live"===v?"live":null;const f=t.payment_methods.map((t=>new H(t))),g=Boolean(null===(e=t.payment_settings)||void 0===e?void 0:e.ach_payments);k.paymentMethods=f.filter((t=>t.type!==Q.SAVED_BANK_ACCOUNT||g)),k.paymentMethodGroupId=t.payment_method_group_id,k.paymentDescription=t.payment_description,k.totalAmount=t.total_amount,k.paymentAmount=t.payment_amount,k.bnplEnabled=t.payment_settings.bnpl_payments,k.insuranceEnabled=null!==(i=t.payment_settings.insurance_payments)&&void 0!==i&&i,k.bankAccountVerification=null===(s=t.payment_settings)||void 0===s?void 0:s.bank_account_verification,k.applePayEnabled=null!==(n=null===(a=t.payment_settings)||void 0===a?void 0:a.apple_payments)&&void 0!==n&&n,k.googlePayEnabled=null!==(r=null===(o=t.payment_settings)||void 0===o?void 0:o.google_payments)&&void 0!==r&&r,k.paypalEnabled=null!==(h=null===(l=t.payment_settings)||void 0===l?void 0:l.paypal_payments)&&void 0!==h&&h,k.paypalProviderClientId=null!==(d=null===(c=t.paypal)||void 0===c?void 0:c.provider_client_id)&&void 0!==d?d:"",k.achPaymentsEnabled=g,k.bnplProviderClientId=null===(u=null==t?void 0:t.bnpl)||void 0===u?void 0:u.provider_client_id,k.bnplProviderMode=null===(p=null==t?void 0:t.bnpl)||void 0===p?void 0:p.provider_mode,k.bnplProviderApiVersion=null===(y=null==t?void 0:t.bnpl)||void 0===y?void 0:y.provider_api_version,k.bnplProviderCheckoutUrl=null===(m=null==t?void 0:t.bnpl)||void 0===m?void 0:m.provider_checkout_url,k.paymentCurrency=(t.payment_currency||k.paymentCurrency).toUpperCase(),k.checkoutLoaded=!0}emitCheckoutChanged(){const t={availablePaymentMethodTypes:C(),selectedPaymentMethod:k.selectedPaymentMethod,savedPaymentMethods:k.paymentMethods};this.checkoutChangedEvent.emit(t)}queryFormRefs(){if(this.billingFormRef=this.hostEl.querySelector("justifi-billing-form, justifi-bank-account-billing-form-simple, justifi-card-billing-form-simple, justifi-billing-form-full, justifi-tokenize-payment-method"),this.applePayRef=this.hostEl.querySelector("justifi-apple-pay"),this.googlePayRef=this.hostEl.querySelector("justifi-google-pay"),this.paypalRef=this.hostEl.querySelector("justifi-paypal"),this.paymentMethodFormRef=this.hostEl.querySelector("justifi-card-form, justifi-bank-account-form, justifi-tokenize-payment-method"),!k.selectedPaymentMethod&&this.paymentMethodFormRef){const t=this.paymentMethodFormRef.tagName.toLowerCase();"justifi-card-form"===t?k.selectedPaymentMethod={type:Q.NEW_CARD}:"justifi-bank-account-form"!==t||k.checkoutLoaded&&!k.achPaymentsEnabled||(k.selectedPaymentMethod={type:Q.NEW_BANK_ACCOUNT})}this.insuranceFormRef=this.hostEl.querySelector("justifi-season-interruption-insurance")}setupApplePayListeners(){this.applePayRef&&(this.applePayRef.addEventListener("applePayStarted",this.handleApplePayStarted),this.applePayRef.addEventListener("applePayCompleted",this.handleApplePayCompleted),this.applePayRef.addEventListener("applePayError",this.handleApplePayError),this.applePayRef.addEventListener("applePayCancelled",this.handleApplePayCancelled))}removeApplePayListeners(){this.applePayRef&&(this.applePayRef.removeEventListener("applePayStarted",this.handleApplePayStarted),this.applePayRef.removeEventListener("applePayCompleted",this.handleApplePayCompleted),this.applePayRef.removeEventListener("applePayError",this.handleApplePayError),this.applePayRef.removeEventListener("applePayCancelled",this.handleApplePayCancelled))}setupGooglePayListeners(){this.googlePayRef&&(this.googlePayRef.addEventListener("googlePayStarted",this.handleGooglePayStarted),this.googlePayRef.addEventListener("googlePayCompleted",this.handleGooglePayCompleted),this.googlePayRef.addEventListener("googlePayCancelled",this.handleGooglePayCancelled))}removeGooglePayListeners(){this.googlePayRef&&(this.googlePayRef.removeEventListener("googlePayStarted",this.handleGooglePayStarted),this.googlePayRef.removeEventListener("googlePayCompleted",this.handleGooglePayCompleted),this.googlePayRef.removeEventListener("googlePayCancelled",this.handleGooglePayCancelled))}setupPaypalListeners(){this.paypalRef&&(this.paypalRef.addEventListener("paypalStarted",this.handlePaypalStarted),this.paypalRef.addEventListener("paypalCompleted",this.handlePaypalCompleted),this.paypalRef.addEventListener("paypalCancelled",this.handlePaypalCancelled),this.paypalRef.addEventListener("paypalError",this.handlePaypalError))}removePaypalListeners(){this.paypalRef&&(this.paypalRef.removeEventListener("paypalStarted",this.handlePaypalStarted),this.paypalRef.removeEventListener("paypalCompleted",this.handlePaypalCompleted),this.paypalRef.removeEventListener("paypalCancelled",this.handlePaypalCancelled),this.paypalRef.removeEventListener("paypalError",this.handlePaypalError))}async tokenizePaymentMethod(t){var e,i,s;const a=null!==(i=await(null===(e=this.billingFormRef)||void 0===e?void 0:e.getValues()))&&void 0!==i?i:{},n=Object.assign(Object.assign({},t),a),o=Object.assign({accountId:k.accountId,payment_method_group_id:void 0},n);k.savePaymentMethod&&(o.payment_method_group_id=k.paymentMethodGroupId);const r=await(null===(s=this.paymentMethodFormRef)||void 0===s?void 0:s.tokenize({clientId:this.authToken,paymentMethodMetadata:o,account:k.accountId}));return r.error?r:(k.paymentToken=r.id,r.id)}async fillBillingForm(t){k.billingFormFields=t}async setSelectedPaymentMethod(t){k.selectedPaymentMethod=t,k.paymentToken=t.id||void 0}async validate(){var t,e;const i=[];k.insuranceEnabled&&this.insuranceFormRef&&i.push(this.insuranceFormRef.validate());const s=(null===(t=k.selectedPaymentMethod)||void 0===t?void 0:t.type)===Q.NEW_CARD,a=(null===(e=k.selectedPaymentMethod)||void 0===e?void 0:e.type)===Q.NEW_BANK_ACCOUNT;if((s||a)&&(this.paymentMethodFormRef&&i.push(this.paymentMethodFormRef.validate()),this.billingFormRef&&i.push(this.billingFormRef.validate())),0===i.length)return!0;try{return!!(await Promise.all(i)).every((t=>"boolean"==typeof t?t:!1!==(null==t?void 0:t.isValid)))||(this.errorEvent.emit({message:"Validation error",errorCode:y.VALIDATION_ERROR,severity:p.ERROR}),!1)}catch(t){return!1}}async submitCheckout(t){var e,i,s,a,n,o,r,l;if(k.isSubmitting)return;k.isSubmitting=!0;const h=await this.validate();if(!k.selectedPaymentMethod)return k.isSubmitting=!1,void this.errorEvent.emit({message:"No payment method selected.",errorCode:y.VALIDATION_ERROR,severity:p.ERROR});const c=(null===(e=k.selectedPaymentMethod)||void 0===e?void 0:e.type)===Q.NEW_CARD,d=(null===(i=k.selectedPaymentMethod)||void 0===i?void 0:i.type)===Q.NEW_BANK_ACCOUNT,u=(null===(s=k.selectedPaymentMethod)||void 0===s?void 0:s.type)===Q.PLAID;if(c||d){const e=await this.tokenizePaymentMethod(t);if(null==e?void 0:e.error)return k.isSubmitting=!1,void this.errorEvent.emit({message:e.error.message,errorCode:y.TOKENIZE_ERROR,severity:p.ERROR})}if(u&&!k.paymentToken){const t=k.plaidPublicToken,e=k.plaidLinkTokenId;if(!t)return k.isSubmitting=!1,void this.errorEvent.emit({message:"Missing Plaid public token. Please connect your bank.",errorCode:y.TOKENIZE_ERROR,severity:p.ERROR});try{const i=await this.plaidService.tokenizeBankAccount(k.authToken,k.accountId,t,e||void 0,k.savePaymentMethod?k.paymentMethodGroupId:void 0);if(null==i?void 0:i.error)return k.isSubmitting=!1,void this.errorEvent.emit({message:"string"==typeof i.error?i.error:i.error.message||"Failed to tokenize bank account",errorCode:y.TOKENIZE_ERROR,severity:p.ERROR});const s=null==i?void 0:i.data,n=(null===(a=null==s?void 0:s.bank_account)||void 0===a?void 0:a.token)||(null==s?void 0:s.token)||(null==s?void 0:s.id);k.paymentToken=n}catch(t){return k.isSubmitting=!1,void this.errorEvent.emit({message:(null==t?void 0:t.message)||"Plaid exchange error",errorCode:y.TOKENIZE_ERROR,severity:p.ERROR})}}if(!h)return k.isSubmitting=!1,void this.errorEvent.emit({message:"Please fill in all required fields.",errorCode:y.VALIDATION_ERROR,severity:p.ERROR});const m=(null===(n=k.selectedPaymentMethod)||void 0===n?void 0:n.type)===Q.SEZZLE;if(m){const t=this.hostEl.querySelector("justifi-sezzle-payment-method"),e=await(null==t?void 0:t.resolvePaymentMethod({isValid:h}));if("success"!==(null===(o=null==e?void 0:e.bnpl)||void 0===o?void 0:o.status))return k.isSubmitting=!1,void this.errorEvent.emit({message:(null===(r=null==e?void 0:e.error)||void 0===r?void 0:r.message)||"Sezzle checkout was not completed.",errorCode:y.TOKENIZE_ERROR,severity:p.ERROR})}if(!m&&!k.paymentToken)return k.isSubmitting=!1,void this.errorEvent.emit({message:"Payment token not found.",errorCode:y.TOKENIZE_ERROR,severity:p.ERROR});const v={payment_mode:(t=>{switch(t){case Q.NEW_CARD:case Q.SAVED_CARD:case Q.NEW_BANK_ACCOUNT:case Q.SAVED_BANK_ACCOUNT:case Q.PLAID:return W.ECOM;case Q.SEZZLE:return W.BNPL;case Q.APPLE_PAY:return W.APPLE_PAY;case Q.GOOGLE_PAY:return W.GOOGLE_PAY;case Q.PAYPAL:return W.PAYPAL;case Q.VENMO:return W.VENMO;default:return}})(null===(l=k.selectedPaymentMethod)||void 0===l?void 0:l.type),payment_token:m?void 0:k.paymentToken};if(this.preCompleteHook){const t=T();try{await new Promise(((e,i)=>{this.preCompleteHook(t,(()=>e()),(()=>i()))}))}catch(t){return k.isSubmitting=!1,void console.log("Checkout cancelled by preCompleteHook",t)}}this.completeCheckout({payment:v,onSuccess:({checkout:t})=>{k.isSubmitting=!1,this.submitEvent.emit({checkout:t,message:"Checkout completed successfully"})},onError:t=>{k.isSubmitting=!1,this.errorEvent.emit({message:t.message,errorCode:y.COMPLETE_CHECKOUT_ERROR,severity:p.ERROR})}})}render(){return i(s,{key:"127bf2aea6758c7d91e33f252a3db4bc27b066ff"})}get hostEl(){return a(this)}},rt=n();class lt{async createPaypalOrder(t,e,i,s){return rt.post({endpoint:`checkouts/${e}/paypal/orders`,body:{funding_source:i},authToken:t,signal:s})}}const ht="paypal-script",ct=["paypal-payments","venmo-payments"],dt="PAYMENT_FAILED",ut="shown",pt=(t,e)=>{t&&(e?t.classList.add(ut):t.classList.remove(ut))},yt=class{constructor(i){t(this,i),this.paypalStarted=e(this,"paypalStarted",7),this.paypalCompleted=e(this,"paypalCompleted",7),this.paypalCancelled=e(this,"paypalCancelled",7),this.paypalError=e(this,"paypalError",7),this.paypalService=new lt,this.paypalEligible=!1,this.venmoEligible=!1,this.startSession=async(t,e)=>{if(!t)return;this.pendingOrderId=void 0,this.paypalStarted.emit({fundingSource:e});let i=!1;const s=this.createOrder(e).then((t=>({orderId:t.provider_order_id}))).catch((t=>{throw i=!0,this.emitError((null==t?void 0:t.message)||"Could not create the Paypal order","ORDER_ERROR"),t}));s.catch((()=>{}));try{await t.start({presentationMode:"auto"},s)}catch(t){if(i)return;this.emitError((null==t?void 0:t.message)||"Paypal payment failed",dt)}}}componentDidLoad(){k.checkoutLoaded?this.initializePaypal():P("checkoutLoaded",(t=>{t&&this.initializePaypal()}))}componentDidRender(){this.applyVisibility()}get currencyCode(){return(k.paymentCurrency||"USD").toUpperCase()}get showPaypal(){return!!k.paypalEnabled&&this.paypalEligible}get showVenmo(){return!!k.paypalEnabled&&this.venmoEligible&&"USD"===this.currencyCode}applyVisibility(){const{showPaypal:t,showVenmo:e}=this;pt(this.buttonsEl,t||e),pt(this.paypalButtonEl,t),pt(this.venmoButtonEl,e)}emitError(t,e){this.paypalError.emit({error:t,code:e})}loadPaypalScript(){const t=window.paypal;return t?Promise.resolve(t):new Promise(((t,e)=>{let i=document.head.querySelector(`script[data-test-id="${ht}"]`);i||(i=document.createElement("script"),i.src="test"===k.checkoutMode?"https://www.sandbox.paypal.com/web-sdk/v6/core":"https://www.paypal.com/web-sdk/v6/core",i.async=!0,i.setAttribute("data-test-id",ht),document.head.appendChild(i)),i.addEventListener("load",(()=>{const i=window.paypal;i?t(i):e(new Error("Paypal script loaded but window.paypal is undefined"))})),i.addEventListener("error",(()=>e(new Error("Error loading Paypal script"))))}))}metadataId(){return Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15)}async initializePaypal(){const t=k.paypalProviderClientId;if(!t)return this.paypalEligible=!1,this.venmoEligible=!1,this.applyVisibility(),void this.emitError("Missing Paypal client id","CONFIG_ERROR");try{const e=await this.loadPaypalScript();this.sdkInstance=await e.createInstance({clientId:t,components:ct,pageType:"checkout",metadataId:this.metadataId()});const i=await this.sdkInstance.findEligibleMethods({currencyCode:this.currencyCode});this.paypalEligible=i.isEligible("paypal"),this.venmoEligible=i.isEligible("venmo"),this.paypalEligible&&(this.paypalSession=this.sdkInstance.createPayPalOneTimePaymentSession(this.sessionOptions("paypal"))),this.venmoEligible&&(this.venmoSession=this.sdkInstance.createVenmoOneTimePaymentSession(this.sessionOptions("venmo"))),this.applyVisibility()}catch(t){this.paypalEligible=!1,this.venmoEligible=!1,this.applyVisibility(),this.emitError((null==t?void 0:t.message)||"Error initializing Paypal","INITIALIZATION_ERROR")}}sessionOptions(t){return{onApprove:()=>this.paypalCompleted.emit({success:!0,paymentMethodId:this.pendingOrderId,fundingSource:t}),onCancel:()=>this.paypalCancelled.emit({fundingSource:t}),onError:t=>this.emitError((null==t?void 0:t.message)||"Paypal payment failed",dt)}}async createOrder(t){const e=await this.paypalService.createPaypalOrder(k.authToken,k.checkoutId,t);if(null==e?void 0:e.error)throw new Error(("string"==typeof e.error?e.error:e.error.message)||"Could not create the Paypal order");const i=null==e?void 0:e.data;if(!(null==i?void 0:i.provider_order_id))throw new Error("Paypal order is missing a provider order id");return this.pendingOrderId=i.id,i}render(){return i(M,{key:"05c771ae41d3b21da7046e70c7d0e03efc296a0c"},i("div",{key:"8e7a14372ce29b4da284efadb43c27d0c059607e",class:"paypal-buttons",ref:t=>this.buttonsEl=t},i("paypal-button",{key:"aa7fa82c96ca4d41872f445a01e72a18f6f5920a",type:"pay",ref:t=>this.paypalButtonEl=t,onClick:()=>this.startSession(this.paypalSession,"paypal")}),i("venmo-button",{key:"2cb068aa82460068548f133607cebec096028a41",type:"pay",ref:t=>this.venmoButtonEl=t,onClick:()=>this.startSession(this.venmoSession,"venmo")})),i("style",{key:"159cc68f682ed79a9a83be7d1b4c88127f8a2623"},"\n .paypal-buttons {\n display: none;\n gap: 8px;\n width: 100%;\n }\n .paypal-buttons.shown {\n display: flex;\n }\n .paypal-buttons > * {\n display: none;\n flex: 1 1 0;\n min-width: 0;\n }\n .paypal-buttons > .shown {\n display: block;\n }\n "))}},mt=class{constructor(i){t(this,i),this.paymentMethodOptionSelected=e(this,"paymentMethodOptionSelected",7),this.plaidError=e(this,"plaidError",7),this.plaidErrorRecovered=e(this,"plaidErrorRecovered",7),this.isAuthenticating=!1,this.publicToken=null,this.linkToken=null,this.linkTokenId=null,this.error=null,this.plaidLink=null,this.isSelected=!1,this.retryCount=0,this.isRetrying=!1,this.sdkLoaded=!1,this.plaidService=new V,this.maxRetries=3,this.retryDelay=2e3,this.timeoutId=null,this.abortController=null,this.hasLoggedDisabledWarning=!1,this.hasLoggedAchPaymentsDisabledWarning=!1,this.waitForStoreAndInitialize=()=>{k.authToken&&k.accountId&&k.checkoutId?this.initializePlaidLink():setTimeout((()=>{this.waitForStoreAndInitialize()}),100)},this.initializePlaidLink=async()=>{try{if(void 0===window.Plaid)return void this.handleError({code:b.PLAID_SDK_LOAD_FAILED,message:g[b.PLAID_SDK_LOAD_FAILED],severity:f[b.PLAID_SDK_LOAD_FAILED],retryable:!0,userAction:"Refresh the page and try again"});if(await this.getLinkToken(),!this.linkToken)return void this.handleError({code:b.PLAID_LINK_TOKEN_FAILED,message:g[b.PLAID_LINK_TOKEN_FAILED],severity:f[b.PLAID_LINK_TOKEN_FAILED],retryable:!0,userAction:"Click to try again"});const t=window.Plaid;this.plaidLink=t.create({token:this.linkToken,onSuccess:this.handlePlaidSuccess,onExit:this.handlePlaidExit,onEvent:this.handlePlaidEvent,onLoad:this.handlePlaidLoad})}catch(t){this.handleError({code:b.PLAID_LINK_INIT_FAILED,message:g[b.PLAID_LINK_INIT_FAILED],severity:f[b.PLAID_LINK_INIT_FAILED],originalError:t,retryable:!0,userAction:"Click to try again"})}},this.getLinkToken=async()=>{var t,e,i,s,a;try{if(!k.authToken||!k.accountId)return void this.handleError({code:b.PLAID_LINK_TOKEN_FAILED,message:"Missing authentication. Please refresh the page and try again.",severity:p.ERROR,retryable:!1,userAction:"Refresh the page"});this.abortController=new AbortController,this.timeoutId=setTimeout((()=>{var t;null===(t=this.abortController)||void 0===t||t.abort()}),3e4);const e=await this.plaidService.getLinkToken(k.authToken,k.accountId,k.checkoutId,this.abortController.signal);if(this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=null),e.error)throw new Error("string"==typeof e.error?e.error:e.error.message||"Failed to get link token");this.linkToken=e.data.link_token,this.linkTokenId=(null==e?void 0:e.id)||(null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.id)||null,this.linkTokenId&&(k.plaidLinkTokenId=this.linkTokenId)}catch(t){this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=null);let n=b.PLAID_LINK_TOKEN_FAILED,o=g[n],r=!0;"AbortError"===t.name?(n=b.PLAID_TIMEOUT,o=g[n],r=!0):(null===(e=t.message)||void 0===e?void 0:e.includes("network"))||(null===(i=t.message)||void 0===i?void 0:i.includes("fetch"))?(n=b.PLAID_NETWORK_ERROR,o=g[n],r=!0):((null===(s=t.message)||void 0===s?void 0:s.includes("401"))||(null===(a=t.message)||void 0===a?void 0:a.includes("unauthorized")))&&(n=b.PLAID_INVALID_CREDENTIALS,o="Authentication failed. Please refresh the page and try again.",r=!1),this.handleError({code:n,message:o,severity:f[n],originalError:t,retryable:r,userAction:r?"Click to try again":"Refresh the page"})}},this.mapApiErrorToPlaidError=t=>{if("string"==typeof t){if(t.includes("rate_limit"))return b.PLAID_RATE_LIMITED;if(t.includes("maintenance"))return b.PLAID_MAINTENANCE;if(t.includes("not_authenticated"))return b.PLAID_INVALID_CREDENTIALS}if(null==t?void 0:t.code)switch(t.code){case"rate_limited":return b.PLAID_RATE_LIMITED;case"maintenance":return b.PLAID_MAINTENANCE;case"not_authenticated":return b.PLAID_INVALID_CREDENTIALS;default:return b.PLAID_LINK_TOKEN_FAILED}return b.PLAID_LINK_TOKEN_FAILED},this.openPlaidLink=()=>{this.plaidLink&&this.linkToken&&(this.isAuthenticating=!0,this.clearError(),this.plaidLink.open())},this.handlePlaidSuccess=t=>{this.publicToken=t,this.isAuthenticating=!1,this.clearError(),this.retryCount=0,this.isSelected||(this.isSelected=!0,k.selectedPaymentMethod={type:Q.PLAID}),this.plaidErrorRecovered.emit({code:"plaid-success",message:"Bank account connected successfully",severity:p.INFO}),k.plaidPublicToken=t},this.handlePlaidExit=t=>{this.isAuthenticating=!1,t&&this.handlePlaidError(t)},this.handlePlaidEvent=(t,e)=>{switch(t){case"OPEN":this.isAuthenticating=!0;break;case"CLOSE":this.isAuthenticating=!1;break;case"ERROR":this.handlePlaidError(e)}},this.handlePlaidLoad=()=>{},this.handlePlaidError=t=>{let e=b.PLAID_AUTHENTICATION_FAILED,i=g[e],s=!0,a="Click to try again";if(t.error_code)switch(t.error_code){case"INVALID_CREDENTIALS":e=b.PLAID_INVALID_CREDENTIALS,i=g[e],s=!0;break;case"ITEM_LOGIN_REQUIRED":e=b.PLAID_INVALID_CREDENTIALS,i="Your bank requires re-authentication. Please try again.",s=!0;break;case"ITEM_LOCKED":e=b.PLAID_ACCOUNT_LOCKED,i=g[e],s=!1,a="Contact your bank";break;case"INSTITUTION_NOT_RESPONDING":e=b.PLAID_MAINTENANCE,i=g[e],s=!0;break;case"RATE_LIMIT_EXCEEDED":e=b.PLAID_RATE_LIMITED,i=g[e],s=!0;break;case"INVALID_REQUEST":e=b.PLAID_AUTHENTICATION_FAILED,i="Invalid request. Please try again.",s=!0;break;case"PLAID_ERROR":e=b.PLAID_AUTHENTICATION_FAILED,i=t.error_message||"Bank authentication failed. Please try again.",s=!0;break;default:t.error_message&&(i=t.error_message)}if(t.error_message){const n=t.error_message.toLowerCase();n.includes("not supported")||n.includes("unsupported")?(e=b.PLAID_BANK_NOT_SUPPORTED,i=g[e],s=!1,a="Try a different payment method"):(n.includes("expired")||n.includes("timeout"))&&(e=b.PLAID_TOKEN_EXPIRED,i=g[e],s=!0)}this.handleError({code:e,message:i,severity:f[e],originalError:t,retryable:s,userAction:a}),this.isAuthenticating=!1},this.handleError=t=>{this.error=t,this.plaidError.emit({code:t.code,message:t.message,severity:t.severity,data:{originalError:t.originalError,retryable:t.retryable,userAction:t.userAction,retryCount:this.retryCount}}),console.error("Plaid error:",t),t.retryable&&this.retryCount<this.maxRetries&&this.scheduleRetry()},this.scheduleRetry=()=>{this.isRetrying||(this.isRetrying=!0,this.retryCount++,setTimeout((()=>{this.isRetrying=!1,this.clearError(),this.waitForStoreAndInitialize()}),this.retryDelay*this.retryCount))},this.clearError=()=>{this.error&&(this.error=null,this.retryCount=0)},this.syncWithStore=()=>{var t;const e=(null===(t=k.selectedPaymentMethod)||void 0===t?void 0:t.type)===Q.PLAID;this.isSelected!==e&&(this.isSelected=e)}}onSelectionChange(t){var e;t&&(null===(e=k.selectedPaymentMethod)||void 0===e?void 0:e.type)!==Q.PLAID&&(k.selectedPaymentMethod={type:Q.PLAID}),!t||!this.plaidLink||this.publicToken||this.isAuthenticating||this.error||this.openPlaidLink()}componentWillLoad(){var t;this.isSelected=(null===(t=k.selectedPaymentMethod)||void 0===t?void 0:t.type)===Q.PLAID,!0===k.bankAccountVerification&&(k.checkoutLoaded?k.achPaymentsEnabled&&this.loadPlaidSDK():P("checkoutLoaded",(t=>{t&&!0===k.bankAccountVerification&&k.achPaymentsEnabled&&this.loadPlaidSDK()})))}loadPlaidSDK(){if(this.sdkLoaded)return;this.sdkLoaded=!0;const t=document.createElement("script");t.src="https://cdn.plaid.com/link/v2/stable/link-initialize.js",t.async=!0,t.onload=()=>this.initializePlaidLink(),t.onerror=()=>{this.handleError({code:b.PLAID_SDK_LOAD_FAILED,message:g[b.PLAID_SDK_LOAD_FAILED],severity:f[b.PLAID_SDK_LOAD_FAILED],retryable:!0,userAction:"Refresh the page and try again"})},document.head.appendChild(t)}async resolvePaymentMethod(){return this.publicToken?{token:this.publicToken,data:{type:"bank_account",plaid_public_token:this.publicToken}}:{validationError:!0}}async getPaymentToken(){return k.paymentToken}async handleSelectionClick(){if(this.isSelected=!0,k.selectedPaymentMethod={type:Q.PLAID},this.error)return this.clearError(),void this.waitForStoreAndInitialize();!this.plaidLink||this.publicToken||this.isAuthenticating||this.openPlaidLink()}async setSelected(t){this.isSelected=t,t&&(k.selectedPaymentMethod={type:Q.PLAID})}async isCurrentlySelected(){return this.isSelected}async deselect(){this.isSelected=!1}async reset(){this.publicToken=null,this.clearError(),this.isAuthenticating=!1,this.linkToken=null,this.plaidLink=null,this.retryCount=0,this.isRetrying=!1,this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=null),this.abortController&&(this.abortController.abort(),this.abortController=null)}async isReadyForAuthentication(){return!(!this.plaidLink||!this.linkToken||this.isAuthenticating)}async retry(){this.error&&this.error.retryable&&(this.clearError(),this.waitForStoreAndInitialize())}async getErrorInfo(){return this.error}componentDidLoad(){const t=P("selectedPaymentMethod",this.syncWithStore);this.unsubscribeFromStore=t}disconnectedCallback(){this.unsubscribeFromStore&&this.unsubscribeFromStore(),this.timeoutId&&clearTimeout(this.timeoutId),this.abortController&&this.abortController.abort()}render(){if(k.checkoutLoaded&&!k.achPaymentsEnabled)return this.hasLoggedAchPaymentsDisabledWarning||(console.warn("[JustifiPlaidPaymentMethod] ACH payments are disabled for this checkout. Component will not render."),this.hasLoggedAchPaymentsDisabledWarning=!0),null;if(!0!==k.bankAccountVerification)return this.hasLoggedDisabledWarning||(console.warn("[JustifiPlaidPaymentMethod] bank_account_verification is disabled. Component will not render."),this.hasLoggedDisabledWarning=!0),null;const t=i("img",{class:"plaid-logo-img",src:"data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjQ4IiB2aWV3Qm94PSIwIDAgMjggMjkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgY2xhc3M9ImNzcy0xcmRhajhtIj48ZyBmaWxsPSIjMTExIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxwYXRoIGQ9Ik0yNS43NjI5IDI2LjI2MjhMMjggMTcuNTMwOUwyNC45NjkxIDE0LjUwMDFMMjcuOTk5OSAxMS40NjkxTDI1Ljc2MjggMi43MzcwNkwxNy4wMzA5IDAuNUwxNC4wMDAxIDMuNTMxTDEwLjk2OSAwLjUwMDE0TDIuMjM3MDYgMi43MzczNEwwIDExLjQ2OTFMMy4wMzEyOCAxNC40OTk5TDAuMDAwMTQgMTcuNTMxTDIuMjM3MiAyNi4yNjI5TDEwLjk2OTEgMjguNUwxNC4wMDAxIDI1LjQ2OUwxNy4wMzEgMjguNDk5OUwyNS43NjI5IDI2LjI2MjhaTTE1LjczMjEgMjMuNzM3MUwxOC42MTg2IDIwLjg1MDVMMjIuMjkxMiAyNC41MjMzTDE3LjY5NTYgMjUuNzAwN0wxNS43MzIxIDIzLjczNzFaTTExLjExMzYgOS44ODE1NEwxNC4wMDAzIDYuOTk1MDJMMTYuODg2OCA5Ljg4MTRMMTQuMDAwMSAxMi43Njc5TDExLjExMzYgOS44ODE1NFpNMTIuMjY4MiAxNC41TDkuMzgxNTQgMTcuMzg2NUw2LjQ5NTAyIDE0LjVMOS4zODE1NCAxMS42MTM1TDEyLjI2ODIgMTQuNVpNMTguNjE4NyAxMS42MTMzTDIxLjUwNTMgMTQuNUwxOC42MTg2IDE3LjM4NjVMMTUuNzMyMSAxNC41TDE4LjYxODcgMTEuNjEzM1pNMTYuODg2NyAxOS4xMTg2TDE0LjAwMDEgMjIuMDA1MUwxMS4xMTM1IDE5LjExODVMMTQuMDAwMSAxNi4yMzE5TDE2Ljg4NjcgMTkuMTE4NlpNMTAuMzA0NCAyNS43MDA3TDUuNzA4NjQgMjQuNTIzM0w5LjM4MTU0IDIwLjg1MDRMMTIuMjY4MiAyMy43MzcxTDEwLjMwNDQgMjUuNzAwN1pNNC43NjMwOCAxNi4yMzE5TDcuNjQ5NiAxOS4xMTg1TDMuOTc2NyAyMi43OTE0TDIuNzk5MyAxOC4xOTU3TDQuNzYzMDggMTYuMjMxOVpNMy45NzY3IDYuMjA4MzZMNy42NDk3NCA5Ljg4MTRMNC43NjMwOCAxMi43NjgxTDIuNzk5MyAxMC44MDQxTDMuOTc2NyA2LjIwODM2Wk0xMi4yNjgzIDUuMjYyOTRMOS4zODE2OCA4LjE0OTZMNS43MDg5MiA0LjQ3NjdMMTAuMzA0NyAzLjI5OTNMMTIuMjY4MyA1LjI2Mjk0Wk0xNy42OTU5IDMuMjk5M0wyMi4yOTE1IDQuNDc2N0wxOC42MTg2IDguMTQ5NDZMMTUuNzMyMSA1LjI2Mjk0TDE3LjY5NTkgMy4yOTkzWk0yMy4yMzcyIDEyLjc2ODFMMjAuMzUwNSA5Ljg4MTRMMjQuMDIzMyA2LjIwODc4TDI1LjIwMDcgMTAuODA0NkwyMy4yMzcyIDEyLjc2ODFaTTI0LjAyMzMgMjIuNzkxNEwyMC4zNTA1IDE5LjExODZMMjMuMjM3MiAxNi4yMzIxTDI1LjIwMDcgMTguMTk1N0wyNC4wMjMzIDIyLjc5MTRaIj48L3BhdGg+PC9nPjwvc3ZnPgo=",alt:"Plaid",title:"Plaid",style:{display:"inline",width:"20px",height:"20px",marginLeft:"5px",marginTop:"-2px"}});return i(M,{class:"payment-method"},i("div",{title:"Pay with Plaid"},i("div",{onClick:t=>{t.preventDefault(),this.handleSelectionClick()}},"Pay with Bank Account ",t," "),(()=>this.error?i("div",{class:(this.error.severity===p.ERROR?"text-danger":this.error.severity===p.WARNING?"text-warning":"text-info")+" mt-2"},i("small",null,this.error.message),i("br",null),i("small",{class:"text-muted"},this.error.userAction,this.error.retryable&&this.retryCount<this.maxRetries&&i("span",null," • Auto-retry in progress..."))):null)(),(()=>this.error?null:this.isAuthenticating?i("div",{class:"text-info mt-2"},i("small",null,"Connecting to your bank...")):this.publicToken?i("div",{class:"text-success mt-2"},i("small",null,"✓ Bank account connected successfully")):!this.isSelected||this.publicToken||this.error||this.isAuthenticating?null:i("div",{class:"text-muted mt-2"},i("small",null,"Click to connect your bank account")))()))}static get watchers(){return{isSelected:["onSelectionChange"]}}},vt=class{constructor(e){t(this,e),this.onPaymentMethodOptionClick=t=>e=>{e.preventDefault(),k.selectedPaymentMethod={id:t.id,type:t.type},k.paymentToken=t.id},this.isAllowedPaymentMethod=t=>!(t===Q.SAVED_CARD&&k.disableCreditCard||t===Q.SAVED_BANK_ACCOUNT&&k.disableBankAccount)}componentWillLoad(){k.checkoutLoaded&&(k.paymentMethods.length||console.warn("No saved payment methods available."),k.disablePaymentMethodGroup&&console.warn("Payment method group is disabled."))}render(){return k.disablePaymentMethodGroup?null:i(M,null,i("div",{class:"saved-payment-methods"},k.paymentMethods.length?k.paymentMethods.filter((t=>this.isAllowedPaymentMethod(t.type))).map((t=>i("div",{class:"radio-list-item p-3",part:E,onClick:this.onPaymentMethodOptionClick(t)},i("form-control-radio",{name:"paymentMethodType",value:null==t?void 0:t.id,checked:k.paymentToken===(null==t?void 0:t.id),label:`${Z[null==t?void 0:t.brand]||""} *${null==t?void 0:t.acct_last_four}`})))):null))}},ft=class{constructor(i){t(this,i),this.paymentMethodOptionSelected=e(this,"paymentMethodOptionSelected",7),this.paymentMethodOptionId=Q.SEZZLE,this.initializeSezzleCheckout=()=>{const t=Number(k.paymentAmount),e=new(0,window.Checkout)({mode:"popup",publicKey:k.bnplProviderClientId,apiMode:k.bnplProviderMode,apiVersion:k.bnplProviderApiVersion});e.sezzleButtonElement=this.sezzleButtonRef,e.init({onClick:function(t){t.preventDefault(),e.startCheckout({checkout_url:k.bnplProviderCheckoutUrl})},onComplete:t=>{var e;return null===(e=this.resolveSezzlePromise)||void 0===e?void 0:e.call(this,{bnpl:t.data})},onCancel:t=>{var e;return null===(e=this.resolveSezzlePromise)||void 0===e?void 0:e.call(this,{bnpl:t.data})},onFailure:t=>{var e;return null===(e=this.resolveSezzlePromise)||void 0===e?void 0:e.call(this,{bnpl:t.data})}}),this.sezzleCheckout=e,this.installmentPlan=this.sezzleCheckout.getInstallmentPlan(t)}}componentDidRender(){this.scriptRef&&(this.scriptRef.onload=()=>{this.sezzleButtonRef=document.createElement("button"),this.initializeSezzleCheckout()})}async resolvePaymentMethod(t){if(!t.isValid)return{validationError:!0};if(!this.sezzleButtonRef)return{error:{code:"sezzle_not_ready",message:"Sezzle is not ready yet. Please try again.",decline_code:""}};const e=new Promise((t=>{this.resolveSezzlePromise=t}));return this.sezzleButtonRef.click(),e}async handleSelectionClick(){k.selectedPaymentMethod={type:Q.SEZZLE},this.paymentMethodOptionSelected.emit(this.paymentMethodOptionId)}render(){var t,e;return k.bnplEnabled?i(M,{class:"payment-method"},i("script",{src:"https://checkout-sdk.sezzle.com/checkout.min.js",async:!0,ref:t=>this.scriptRef=t}),i("div",null,i("div",null,"Buy now, pay later with ",i("img",{class:"sezzle-smart-button-logo-img",src:"https://media.sezzle.com/branding/2.0/Sezzle_Logo_FullColor.svg",alt:"Sezzle",style:{display:"inline",width:"80px",marginLeft:"5px",marginTop:"-5px"}})),this.installmentPlan&&i("small",null,i("span",null,null===(t=this.installmentPlan)||void 0===t?void 0:t.installments.length)," ",i("span",null,this.installmentPlan.schedule," payments of")," ",i("span",{class:"fw-bold"},I(null===(e=this.installmentPlan)||void 0===e?void 0:e.installments[0].amountInCents))))):(console.warn("justifi-sezzle-payment-method: BNPL is not enabled for this account."),null)}},gt={[Q.NEW_BANK_ACCOUNT]:"New bank account",[Q.NEW_CARD]:"New credit or debit card"},bt="Payment form not ready",Mt="Validation error",wt=class{constructor(i){t(this,i),this.errorEvent=e(this,"error-event",7),this.submitEvent=e(this,"submit-event",7),this.computedHideSubmitButton=!1,this.isLoading=!1,this.submitButtonText="Submit"}paymentMethodsChanged(){this.setDefaultSelectedPaymentMethod()}connectedCallback(){this.setDefaultSelectedPaymentMethod(),this.setComputedHideSubmitButton()}disconnectedCallback(){var t;null===(t=this.analytics)||void 0===t||t.cleanup(),this.unsubscribeFromStore&&this.unsubscribeFromStore()}componentWillLoad(){U(),this.analytics=new R(this)}handleRadioClick(t){this.selectedPaymentMethod=t.detail,k.selectedPaymentMethod={type:t.detail}}async tokenizePaymentMethod(t){null==t||t.preventDefault(),this.validateRequiredProps(),this.isLoading=!0;try{if(!(await this.validate()).isValid)return this.errorEvent.emit({errorCode:y.TOKENIZE_ERROR,message:Mt}),void(this.isLoading=!1);const t=await this.resolvePaymentMethod({isValid:!0});return t.error&&this.emitError({errorCode:t.error.code,message:t.error.message}),this.submitEvent.emit({response:t}),t}catch(t){const e=this.createErrorResponse(y.TOKENIZE_ERROR,t.message);return this.emitError({errorCode:y.TOKENIZE_ERROR,message:t.message}),this.submitEvent.emit({response:e}),e}finally{this.isLoading=!1}}async fillBillingForm(t){k.billingFormFields=t}async validate(){if(!this.areFormsReady())return{isValid:!1,errors:{general:bt}};const[t,e]=await Promise.all([this.billingFormRef.validate(),this.paymentMethodFormRef.validate()]);return{isValid:t.isValid&&e.isValid,errors:Object.assign(Object.assign({},t.errors),e.errors)}}async getValues(){return this.billingFormRef.getValues()}async tokenize(){try{const t=await this.billingFormRef.getValues(),e={clientId:this.authToken||k.authToken,account:this.accountId||k.accountId,paymentMethodMetadata:this.buildPaymentMethodMetadata(t)};return await this.paymentMethodFormRef.tokenize(e)}catch(t){return t}}validateRequiredProps(){this.authToken||k.authToken||this.emitError({errorCode:y.TOKENIZE_ERROR,message:"Auth token is required when using the tokenize-payment-method component not slotted in justifi-modular-checkout"}),this.accountId||k.accountId||this.emitError({errorCode:y.TOKENIZE_ERROR,message:"Account ID is required when using the tokenize-payment-method component not slotted in justifi-modular-checkout"})}setDefaultSelectedPaymentMethod(){this.selectedPaymentMethod||(this.disableCreditCard?this.disableBankAccount||k.checkoutLoaded&&!k.achPaymentsEnabled||(this.selectedPaymentMethod=Q.NEW_BANK_ACCOUNT,k.selectedPaymentMethod={type:Q.NEW_BANK_ACCOUNT}):(this.selectedPaymentMethod=Q.NEW_CARD,k.selectedPaymentMethod={type:Q.NEW_CARD}))}setComputedHideSubmitButton(){if(void 0!==this.hideSubmitButton)return void(this.computedHideSubmitButton=this.hideSubmitButton);const t=this.isSlottedWithinModularCheckout();this.computedHideSubmitButton=t}isSlottedWithinModularCheckout(){var t;let e=null===(t=this.host)||void 0===t?void 0:t.parentElement;for(;e;){if("JUSTIFI-MODULAR-CHECKOUT"===e.tagName)return!0;e=e.parentElement}return!1}get availablePaymentMethods(){const t=[],e=!k.checkoutLoaded||k.achPaymentsEnabled;return this.disableCreditCard||t.push(Q.NEW_CARD),!this.disableBankAccount&&e&&t.push(Q.NEW_BANK_ACCOUNT),t}areFormsReady(){return!(!this.billingFormRef||!this.paymentMethodFormRef)}emitError(t){this.errorEvent.emit(Object.assign(Object.assign({},t),{severity:p.ERROR}))}createErrorResponse(t,e){return{error:{code:t,message:e,decline_code:void 0}}}async resolvePaymentMethod(t){if(!this.areFormsReady())return this.createErrorResponse("form_not_ready",bt);try{const e=await this.validate();if(!e.isValid||!t.isValid){const t=Object.values(e.errors)[0]||Mt;return{validationError:!0,error:{code:"validation_error",message:String(t),decline_code:void 0}}}return await this.performTokenization()}catch(t){return{error:t}}}async performTokenization(){var t,e;const i=await this.tokenize();if(i.error)return{error:i.error};const s=i.data;return{token:(null===(t=s.card)||void 0===t?void 0:t.token)||(null===(e=s.bank_account)||void 0===e?void 0:e.token),data:s}}buildPaymentMethodMetadata(t){return this.shouldSavePaymentMethod?Object.assign(Object.assign({},t),{payment_method_group_id:this.paymentMethodGroupID}):Object.assign({},t)}get paymentMethodGroupID(){return this.paymentMethodGroupId||k.paymentMethodGroupId}get shouldSavePaymentMethod(){return!(!this.paymentMethodGroupId&&!k.savePaymentMethod)}get shouldHideRadioInput(){return this.disableCreditCard||this.disableBankAccount}renderPaymentMethodOption(t){const e=this.selectedPaymentMethod===t&&void 0===k.selectedPaymentMethod.id;return i("div",{class:"payment-method"},i("radio-list-item",{name:"paymentMethodType",value:t,checked:e,label:gt[t],hidden:this.shouldHideRadioInput}),e&&this.renderSelectedPaymentMethodForm(t))}renderSelectedPaymentMethodForm(t){return i("div",{class:"mt-4 pb-4"},this.renderPaymentMethodForm(t),i("div",{class:"mt-4"},i("billing-form",{ref:t=>{t&&(this.billingFormRef=t)},hideCardBillingForm:this.hideCardBillingForm,hideBankAccountBillingForm:this.hideBankAccountBillingForm,paymentMethodType:t})),i("div",{class:"mt-4"},i("save-new-payment-method",{hidden:!this.paymentMethodGroupID,label:this.savePaymentMethodLabel})))}renderPaymentMethodForm(t){return i(t===Q.NEW_CARD?"card-form":"bank-account-form",{ref:t=>{t&&(this.paymentMethodFormRef=t)}})}render(){return i(M,{key:"16a5a47febb09295c95f141ddc96a849e530c477"},i("form",{key:"e1ac3ac80435b32cb0a742198d814778bffd635c"},i("fieldset",{key:"68d0f984d3e66a6abc794e8b2086e27f26ecc809"},i("div",{key:"b1759ec1b9c94a976da992947b06da6d8f48f553",class:"row gy-3"},i("div",{key:"bc1ef82406d3da36c5d4d97b1a10259de87fdd09",class:"col-12"},this.availablePaymentMethods.map((t=>this.renderPaymentMethodOption(t)))),i("div",{key:"ed26f2908aa90daba5ab320a668369566b9dacfa",class:"col-12"},i("internal-button",{key:"094cdacb592825374ad33dd80a05091747bfec4b",text:this.submitButtonText,variant:"primary",type:"submit",clickHandler:t=>this.tokenizePaymentMethod(t),isLoading:this.isLoading,"data-testid":"submit-button",hidden:this.computedHideSubmitButton}))))))}get host(){return a(this)}static get watchers(){return{disableCreditCard:["paymentMethodsChanged"],disableBankAccount:["paymentMethodsChanged"]}}};export{X as justifi_apple_pay,tt as justifi_button,et as justifi_checkout_summary,at as justifi_google_pay,nt as justifi_header,ot as justifi_modular_checkout,yt as justifi_paypal,mt as justifi_plaid_payment_method,G as justifi_radio_list_item,vt as justifi_saved_payment_methods,ft as justifi_sezzle_payment_method,wt as justifi_tokenize_payment_method}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as t,h as o}from"./p-CV0Pyo1O.js";import{J as r}from"./p-nbKvRcwU.js";import{c as s}from"./p-BEL8sLz6.js";import{w as a}from"./p-B4vLfYnZ.js";import{S as p}from"./p-05AWudQe.js";import"./p-CZfYo5-1.js";import"./p-CAVi_ne1.js";import"./p-vIQBTQmc.js";import"./p-Ds_P-dB8.js";import"./p-HXpYMWUU.js";import"./p-D6uhYbLo.js";import"./p-CLHwhyvu.js";import"./p-DaDqgDrb.js";import"./p-DgTOxu8x.js";const i=class{constructor(o){t(this,o)}async componentWillLoad(){await a(),s(),this.analytics=new r(this)}disconnectedCallback(){var t;null===(t=this.analytics)||void 0===t||t.cleanup()}async validate(){return this.cardFormElement.validate()}async tokenize({clientId:t,paymentMethodMetadata:o,account:r}){return this.cardFormElement.tokenize({clientId:t,paymentMethodMetadata:o,account:r})}render(){return o(p,{key:"4fa9ff677d40a6733c33d34135fe85e52392f8b0"},o("card-form",{key:"3fe97adcb966b78dc28d5902409671e88525ca41",ref:t=>this.cardFormElement=t}))}};export{i as justifi_card_form}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import{r as t,c as i,h as e}from"./p-CV0Pyo1O.js";import{A as s}from"./p-vIQBTQmc.js";import{C as n,b as r}from"./p-D6uhYbLo.js";import"./p-CLHwhyvu.js";import"./p-DaDqgDrb.js";import{g as o,a as h}from"./p-CLq3Og7o.js";import{E as a}from"./p-Bh6Q8AqQ.js";import{J as c}from"./p-nbKvRcwU.js";import{c as l}from"./p-BEL8sLz6.js";import{f as u,o as f}from"./p-Ds_P-dB8.js";import{S as d}from"./p-MPer3Rw7.js";import{S as b}from"./p-05AWudQe.js";import"./p-CZfYo5-1.js";import"./p-B4vLfYnZ.js";import"./p-DgTOxu8x.js";import"./p-CAVi_ne1.js";import"./p-Bu7gdOaV.js";import"./p-HXpYMWUU.js";
|
|
2
|
-
/*!
|
|
3
|
-
* @kurkle/color v0.3.4
|
|
4
|
-
* https://github.com/kurkle/color#readme
|
|
5
|
-
* (c) 2024 Jukka Kurkela
|
|
6
|
-
* Released under the MIT License
|
|
7
|
-
*/function p(t){return t+.5|0}const g=(t,i,e)=>Math.max(Math.min(t,e),i);function m(t){return g(p(2.55*t),0,255)}function v(t){return g(p(255*t),0,255)}function x(t){return g(p(t/2.55)/100,0,1)}function y(t){return g(p(100*t),0,100)}const M={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,A:10,B:11,C:12,D:13,E:14,F:15,a:10,b:11,c:12,d:13,e:14,f:15},w=[..."0123456789ABCDEF"],_=t=>w[15&t],k=t=>w[(240&t)>>4]+w[15&t],O=t=>(240&t)>>4==(15&t);const S=/^(hsla?|hwb|hsv)\(\s*([-+.e\d]+)(?:deg)?[\s,]+([-+.e\d]+)%[\s,]+([-+.e\d]+)%(?:[\s,]+([-+.e\d]+)(%)?)?\s*\)$/;function A(t,i,e){const s=i*Math.min(e,1-e),n=(i,n=(i+t/30)%12)=>e-s*Math.max(Math.min(n-3,9-n,1),-1);return[n(0),n(8),n(4)]}function D(t,i,e){const s=(s,n=(s+t/60)%6)=>e-e*i*Math.max(Math.min(n,4-n,1),0);return[s(5),s(3),s(1)]}function j(t,i,e){const s=A(t,1,.5);let n;for(i+e>1&&(n=1/(i+e),i*=n,e*=n),n=0;n<3;n++)s[n]*=1-i-e,s[n]+=i;return s}function C(t){const i=t.r/255,e=t.g/255,s=t.b/255,n=Math.max(i,e,s),r=Math.min(i,e,s),o=(n+r)/2;let h,a,c;return n!==r&&(c=n-r,a=o>.5?c/(2-n-r):c/(n+r),h=function(t,i,e,s,n){return t===n?(i-e)/s+(i<e?6:0):i===n?(e-t)/s+2:(t-i)/s+4}(i,e,s,c,n),h=60*h+.5),[0|h,a||0,o]}function R(t,i,e,s){return(Array.isArray(i)?t(i[0],i[1],i[2]):t(i,e,s)).map(v)}function E(t,i,e){return R(A,t,i,e)}function L(t){return(t%360+360)%360}const P={x:"dark",Z:"light",Y:"re",X:"blu",W:"gr",V:"medium",U:"slate",A:"ee",T:"ol",S:"or",B:"ra",C:"lateg",D:"ights",R:"in",Q:"turquois",E:"hi",P:"ro",O:"al",N:"le",M:"de",L:"yello",F:"en",K:"ch",G:"arks",H:"ea",I:"ightg",J:"wh"},T={OiceXe:"f0f8ff",antiquewEte:"faebd7",aqua:"ffff",aquamarRe:"7fffd4",azuY:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"0",blanKedOmond:"ffebcd",Xe:"ff",XeviTet:"8a2be2",bPwn:"a52a2a",burlywood:"deb887",caMtXe:"5f9ea0",KartYuse:"7fff00",KocTate:"d2691e",cSO:"ff7f50",cSnflowerXe:"6495ed",cSnsilk:"fff8dc",crimson:"dc143c",cyan:"ffff",xXe:"8b",xcyan:"8b8b",xgTMnPd:"b8860b",xWay:"a9a9a9",xgYF:"6400",xgYy:"a9a9a9",xkhaki:"bdb76b",xmagFta:"8b008b",xTivegYF:"556b2f",xSange:"ff8c00",xScEd:"9932cc",xYd:"8b0000",xsOmon:"e9967a",xsHgYF:"8fbc8f",xUXe:"483d8b",xUWay:"2f4f4f",xUgYy:"2f4f4f",xQe:"ced1",xviTet:"9400d3",dAppRk:"ff1493",dApskyXe:"bfff",dimWay:"696969",dimgYy:"696969",dodgerXe:"1e90ff",fiYbrick:"b22222",flSOwEte:"fffaf0",foYstWAn:"228b22",fuKsia:"ff00ff",gaRsbSo:"dcdcdc",ghostwEte:"f8f8ff",gTd:"ffd700",gTMnPd:"daa520",Way:"808080",gYF:"8000",gYFLw:"adff2f",gYy:"808080",honeyMw:"f0fff0",hotpRk:"ff69b4",RdianYd:"cd5c5c",Rdigo:"4b0082",ivSy:"fffff0",khaki:"f0e68c",lavFMr:"e6e6fa",lavFMrXsh:"fff0f5",lawngYF:"7cfc00",NmoncEffon:"fffacd",ZXe:"add8e6",ZcSO:"f08080",Zcyan:"e0ffff",ZgTMnPdLw:"fafad2",ZWay:"d3d3d3",ZgYF:"90ee90",ZgYy:"d3d3d3",ZpRk:"ffb6c1",ZsOmon:"ffa07a",ZsHgYF:"20b2aa",ZskyXe:"87cefa",ZUWay:"778899",ZUgYy:"778899",ZstAlXe:"b0c4de",ZLw:"ffffe0",lime:"ff00",limegYF:"32cd32",lRF:"faf0e6",magFta:"ff00ff",maPon:"800000",VaquamarRe:"66cdaa",VXe:"cd",VScEd:"ba55d3",VpurpN:"9370db",VsHgYF:"3cb371",VUXe:"7b68ee",VsprRggYF:"fa9a",VQe:"48d1cc",VviTetYd:"c71585",midnightXe:"191970",mRtcYam:"f5fffa",mistyPse:"ffe4e1",moccasR:"ffe4b5",navajowEte:"ffdead",navy:"80",Tdlace:"fdf5e6",Tive:"808000",TivedBb:"6b8e23",Sange:"ffa500",SangeYd:"ff4500",ScEd:"da70d6",pOegTMnPd:"eee8aa",pOegYF:"98fb98",pOeQe:"afeeee",pOeviTetYd:"db7093",papayawEp:"ffefd5",pHKpuff:"ffdab9",peru:"cd853f",pRk:"ffc0cb",plum:"dda0dd",powMrXe:"b0e0e6",purpN:"800080",YbeccapurpN:"663399",Yd:"ff0000",Psybrown:"bc8f8f",PyOXe:"4169e1",saddNbPwn:"8b4513",sOmon:"fa8072",sandybPwn:"f4a460",sHgYF:"2e8b57",sHshell:"fff5ee",siFna:"a0522d",silver:"c0c0c0",skyXe:"87ceeb",UXe:"6a5acd",UWay:"708090",UgYy:"708090",snow:"fffafa",sprRggYF:"ff7f",stAlXe:"4682b4",tan:"d2b48c",teO:"8080",tEstN:"d8bfd8",tomato:"ff6347",Qe:"40e0d0",viTet:"ee82ee",JHt:"f5deb3",wEte:"ffffff",wEtesmoke:"f5f5f5",Lw:"ffff00",LwgYF:"9acd32"};let I;const F=/^rgba?\(\s*([-+.\d]+)(%)?[\s,]+([-+.e\d]+)(%)?[\s,]+([-+.e\d]+)(%)?(?:[\s,/]+([-+.e\d]+)(%)?)?\s*\)$/,B=t=>t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055,W=t=>t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4);function N(t,i,e){if(t){let s=C(t);s[i]=Math.max(0,Math.min(s[i]+s[i]*e,0===i?360:1)),s=E(s),t.r=s[0],t.g=s[1],t.b=s[2]}}function z(t,i){return t?Object.assign(i||{},t):t}function H(t){var i={r:0,g:0,b:0,a:255};return Array.isArray(t)?t.length>=3&&(i={r:t[0],g:t[1],b:t[2],a:255},t.length>3&&(i.a=v(t[3]))):(i=z(t,{r:0,g:0,b:0,a:1})).a=v(i.a),i}function $(t){return"r"===t.charAt(0)?function(t){const i=F.exec(t);let e,s,n,r=255;if(i){if(i[7]!==e){const t=+i[7];r=i[8]?m(t):g(255*t,0,255)}return e=+i[1],s=+i[3],n=+i[5],e=255&(i[2]?m(e):g(e,0,255)),s=255&(i[4]?m(s):g(s,0,255)),n=255&(i[6]?m(n):g(n,0,255)),{r:e,g:s,b:n,a:r}}}(t):function(t){const i=S.exec(t);let e,s=255;if(!i)return;i[5]!==e&&(s=i[6]?m(+i[5]):v(+i[5]));const n=L(+i[2]),r=+i[3]/100,o=+i[4]/100;return e="hwb"===i[1]?function(t,i,e){return R(j,t,i,e)}(n,r,o):"hsv"===i[1]?function(t,i,e){return R(D,t,i,e)}(n,r,o):E(n,r,o),{r:e[0],g:e[1],b:e[2],a:s}}(t)}class Y{constructor(t){if(t instanceof Y)return t;const i=typeof t;let e;var s,n,r;"object"===i?e=H(t):"string"===i&&(r=(s=t).length,"#"===s[0]&&(4===r||5===r?n={r:255&17*M[s[1]],g:255&17*M[s[2]],b:255&17*M[s[3]],a:5===r?17*M[s[4]]:255}:7!==r&&9!==r||(n={r:M[s[1]]<<4|M[s[2]],g:M[s[3]]<<4|M[s[4]],b:M[s[5]]<<4|M[s[6]],a:9===r?M[s[7]]<<4|M[s[8]]:255})),e=n||function(t){I||(I=function(){const t={},i=Object.keys(T),e=Object.keys(P);let s,n,r,o,h;for(s=0;s<i.length;s++){for(o=h=i[s],n=0;n<e.length;n++)r=e[n],h=h.replace(r,P[r]);r=parseInt(T[o],16),t[h]=[r>>16&255,r>>8&255,255&r]}return t}(),I.transparent=[0,0,0,0]);const i=I[t.toLowerCase()];return i&&{r:i[0],g:i[1],b:i[2],a:4===i.length?i[3]:255}}(t)||$(t)),this._rgb=e,this._valid=!!e}get valid(){return this._valid}get rgb(){var t=z(this._rgb);return t&&(t.a=x(t.a)),t}set rgb(t){this._rgb=H(t)}rgbString(){return this._valid?(t=this._rgb)&&(t.a<255?`rgba(${t.r}, ${t.g}, ${t.b}, ${x(t.a)})`:`rgb(${t.r}, ${t.g}, ${t.b})`):void 0;var t}hexString(){return this._valid?(i=(t=>O(t.r)&&O(t.g)&&O(t.b)&&O(t.a))(t=this._rgb)?_:k,t?"#"+i(t.r)+i(t.g)+i(t.b)+((t,i)=>t<255?i(t):"")(t.a,i):void 0):void 0;var t,i}hslString(){return this._valid?function(t){if(!t)return;const i=C(t),e=i[0],s=y(i[1]),n=y(i[2]);return t.a<255?`hsla(${e}, ${s}%, ${n}%, ${x(t.a)})`:`hsl(${e}, ${s}%, ${n}%)`}(this._rgb):void 0}mix(t,i){if(t){const e=this.rgb,s=t.rgb;let n;const r=i===n?.5:i,o=2*r-1,h=e.a-s.a,a=((o*h==-1?o:(o+h)/(1+o*h))+1)/2;n=1-a,e.r=255&a*e.r+n*s.r+.5,e.g=255&a*e.g+n*s.g+.5,e.b=255&a*e.b+n*s.b+.5,e.a=r*e.a+(1-r)*s.a,this.rgb=e}return this}interpolate(t,i){return t&&(this._rgb=function(t,i,e){const s=W(x(t.r)),n=W(x(t.g)),r=W(x(t.b));return{r:v(B(s+e*(W(x(i.r))-s))),g:v(B(n+e*(W(x(i.g))-n))),b:v(B(r+e*(W(x(i.b))-r))),a:t.a+e*(i.a-t.a)}}(this._rgb,t._rgb,i)),this}clone(){return new Y(this.rgb)}alpha(t){return this._rgb.a=v(t),this}clearer(t){return this._rgb.a*=1-t,this}greyscale(){const t=this._rgb,i=p(.3*t.r+.59*t.g+.11*t.b);return t.r=t.g=t.b=i,this}opaquer(t){return this._rgb.a*=1+t,this}negate(){const t=this._rgb;return t.r=255-t.r,t.g=255-t.g,t.b=255-t.b,this}lighten(t){return N(this._rgb,2,t),this}darken(t){return N(this._rgb,2,-t),this}saturate(t){return N(this._rgb,1,t),this}desaturate(t){return N(this._rgb,1,-t),this}rotate(t){return function(t,i){var e=C(t);e[0]=L(e[0]+i),e=E(e),t.r=e[0],t.g=e[1],t.b=e[2]}(this._rgb,t),this}}
|
|
8
|
-
/*!
|
|
9
|
-
* Chart.js v4.5.1
|
|
10
|
-
* https://www.chartjs.org
|
|
11
|
-
* (c) 2025 Chart.js Contributors
|
|
12
|
-
* Released under the MIT License
|
|
13
|
-
*/function V(){}const X=(()=>{let t=0;return()=>t++})();function U(t){return null==t}function Z(t){if(Array.isArray&&Array.isArray(t))return!0;const i=Object.prototype.toString.call(t);return"[object"===i.slice(0,7)&&"Array]"===i.slice(-6)}function K(t){return null!==t&&"[object Object]"===Object.prototype.toString.call(t)}function Q(t){return("number"==typeof t||t instanceof Number)&&isFinite(+t)}function q(t,i){return Q(t)?t:i}function G(t,i){return void 0===t?i:t}const J=(t,i)=>"string"==typeof t&&t.endsWith("%")?parseFloat(t)/100*i:+t;function tt(t,i,e){if(t&&"function"==typeof t.call)return t.apply(e,i)}function it(t,i,e){let s,n,r;if(Z(t))for(n=t.length,s=0;s<n;s++)i.call(e,t[s],s);else if(K(t))for(r=Object.keys(t),n=r.length,s=0;s<n;s++)i.call(e,t[r[s]],r[s])}function et(t,i){let e,s,n,r;if(!t||!i||t.length!==i.length)return!1;for(e=0,s=t.length;e<s;++e)if(n=t[e],r=i[e],n.datasetIndex!==r.datasetIndex||n.index!==r.index)return!1;return!0}function st(t){if(Z(t))return t.map(st);if(K(t)){const i=Object.create(null),e=Object.keys(t),s=e.length;let n=0;for(;n<s;++n)i[e[n]]=st(t[e[n]]);return i}return t}function nt(t){return-1===["__proto__","prototype","constructor"].indexOf(t)}function rt(t,i,e,s){if(!nt(t))return;const n=i[t],r=e[t];K(n)&&K(r)?ot(n,r,s):i[t]=st(r)}function ot(t,i,e){const s=Z(i)?i:[i],n=s.length;if(!K(t))return t;const r=(e=e||{}).merger||rt;let o;for(let i=0;i<n;++i){if(o=s[i],!K(o))continue;const n=Object.keys(o);for(let i=0,s=n.length;i<s;++i)r(n[i],t,o,e)}return t}function ht(t,i){return ot(t,i,{merger:at})}function at(t,i,e){if(!nt(t))return;const s=i[t],n=e[t];K(s)&&K(n)?ht(s,n):Object.prototype.hasOwnProperty.call(i,t)||(i[t]=st(n))}const ct={"":t=>t,x:t=>t.x,y:t=>t.y};function lt(t,i){const e=ct[i]||(ct[i]=function(t){const i=function(t){const i=t.split("."),e=[];let s="";for(const t of i)s+=t,s.endsWith("\\")?s=s.slice(0,-1)+".":(e.push(s),s="");return e}(t);return t=>{for(const e of i){if(""===e)break;t=t&&t[e]}return t}}(i));return e(t)}function ut(t){return t.charAt(0).toUpperCase()+t.slice(1)}const ft=t=>void 0!==t,dt=t=>"function"==typeof t,bt=(t,i)=>{if(t.size!==i.size)return!1;for(const e of t)if(!i.has(e))return!1;return!0},pt=Math.PI,gt=2*pt,mt=Number.POSITIVE_INFINITY,vt=pt/180,xt=pt/2,yt=pt/4,Mt=2*pt/3,wt=Math.log10,_t=Math.sign;function kt(t,i,e){return Math.abs(t-i)<e}function Ot(t){const i=Math.round(t);t=kt(t,i,t/1e3)?i:t;const e=Math.pow(10,Math.floor(wt(t))),s=t/e;return(s<=1?1:s<=2?2:s<=5?5:10)*e}function St(t){return!function(t){return"symbol"==typeof t||"object"==typeof t&&null!==t&&!(Symbol.toPrimitive in t||"toString"in t||"valueOf"in t)}(t)&&!isNaN(parseFloat(t))&&isFinite(t)}function At(t){return t*(pt/180)}function Dt(t){if(!Q(t))return;let i=1,e=0;for(;Math.round(t*i)/i!==t;)i*=10,e++;return e}function jt(t){return(t%gt+gt)%gt}function Ct(t,i,e,s){const n=jt(t),r=jt(i),o=jt(e),h=jt(r-n),a=jt(o-n),c=jt(n-r),l=jt(n-o);return n===r||n===o||s&&r===o||h>a&&c<l}function Rt(t,i,e){return Math.max(i,Math.min(e,t))}function Et(t,i,e,s=1e-6){return t>=Math.min(i,e)-s&&t<=Math.max(i,e)+s}function Lt(t,i,e){e=e||(e=>t[e]<i);let s,n=t.length-1,r=0;for(;n-r>1;)s=r+n>>1,e(s)?r=s:n=s;return{lo:r,hi:n}}const Pt=(t,i,e,s)=>Lt(t,e,s?s=>{const n=t[s][i];return n<e||n===e&&t[s+1][i]===e}:s=>t[s][i]<e),Tt=(t,i,e)=>Lt(t,e,(s=>t[s][i]>=e)),It=["push","pop","shift","splice","unshift"];function Ft(t,i){const e=t._chartjs;if(!e)return;const s=e.listeners,n=s.indexOf(i);-1!==n&&s.splice(n,1),s.length>0||(It.forEach((i=>{delete t[i]})),delete t._chartjs)}const Bt="undefined"==typeof window?function(t){return t()}:window.requestAnimationFrame;function Wt(t,i){let e=[],s=!1;return function(...n){e=n,s||(s=!0,Bt.call(window,(()=>{s=!1,t.apply(i,e)})))}}const Nt=t=>"start"===t?"left":"end"===t?"right":"center",zt=(t,i,e)=>"start"===t?i:"end"===t?e:(i+e)/2,Ht=t=>0===t||1===t,$t=(t,i,e)=>-Math.pow(2,10*(t-=1))*Math.sin((t-i)*gt/e),Yt=(t,i,e)=>Math.pow(2,-10*t)*Math.sin((t-i)*gt/e)+1,Vt={linear:t=>t,easeInQuad:t=>t*t,easeOutQuad:t=>-t*(t-2),easeInOutQuad:t=>(t/=.5)<1?.5*t*t:-.5*(--t*(t-2)-1),easeInCubic:t=>t*t*t,easeOutCubic:t=>(t-=1)*t*t+1,easeInOutCubic:t=>(t/=.5)<1?.5*t*t*t:.5*((t-=2)*t*t+2),easeInQuart:t=>t*t*t*t,easeOutQuart:t=>-((t-=1)*t*t*t-1),easeInOutQuart:t=>(t/=.5)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2),easeInQuint:t=>t*t*t*t*t,easeOutQuint:t=>(t-=1)*t*t*t*t+1,easeInOutQuint:t=>(t/=.5)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2),easeInSine:t=>1-Math.cos(t*xt),easeOutSine:t=>Math.sin(t*xt),easeInOutSine:t=>-.5*(Math.cos(pt*t)-1),easeInExpo:t=>0===t?0:Math.pow(2,10*(t-1)),easeOutExpo:t=>1===t?1:1-Math.pow(2,-10*t),easeInOutExpo:t=>Ht(t)?t:t<.5?.5*Math.pow(2,10*(2*t-1)):.5*(2-Math.pow(2,-10*(2*t-1))),easeInCirc:t=>t>=1?t:-(Math.sqrt(1-t*t)-1),easeOutCirc:t=>Math.sqrt(1-(t-=1)*t),easeInOutCirc:t=>(t/=.5)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1),easeInElastic:t=>Ht(t)?t:$t(t,.075,.3),easeOutElastic:t=>Ht(t)?t:Yt(t,.075,.3),easeInOutElastic(t){const i=.1125;return Ht(t)?t:t<.5?.5*$t(2*t,i,.45):.5+.5*Yt(2*t-1,i,.45)},easeInBack(t){const i=1.70158;return t*t*((i+1)*t-i)},easeOutBack(t){const i=1.70158;return(t-=1)*t*((i+1)*t+i)+1},easeInOutBack(t){let i=1.70158;return(t/=.5)<1?t*t*((1+(i*=1.525))*t-i)*.5:.5*((t-=2)*t*((1+(i*=1.525))*t+i)+2)},easeInBounce:t=>1-Vt.easeOutBounce(1-t),easeOutBounce(t){const i=7.5625,e=2.75;return t<1/e?i*t*t:t<2/e?i*(t-=1.5/e)*t+.75:t<2.5/e?i*(t-=2.25/e)*t+.9375:i*(t-=2.625/e)*t+.984375},easeInOutBounce:t=>t<.5?.5*Vt.easeInBounce(2*t):.5*Vt.easeOutBounce(2*t-1)+.5};function Xt(t){if(t&&"object"==typeof t){const i=t.toString();return"[object CanvasPattern]"===i||"[object CanvasGradient]"===i}return!1}function Ut(t){return Xt(t)?t:new Y(t)}function Zt(t){return Xt(t)?t:new Y(t).saturate(.5).darken(.1).hexString()}const Kt=["x","y","borderWidth","radius","tension"],Qt=["color","borderColor","backgroundColor"],qt=new Map;function Gt(t,i,e){return function(t,i){i=i||{};const e=t+JSON.stringify(i);let s=qt.get(e);return s||(s=new Intl.NumberFormat(t,i),qt.set(e,s)),s}(i,e).format(t)}var Jt={formatters:{values:t=>Z(t)?t:""+t,numeric(t,i,e){if(0===t)return"0";const s=this.chart.options.locale;let n,r=t;if(e.length>1){const i=Math.max(Math.abs(e[0].value),Math.abs(e[e.length-1].value));(i<1e-4||i>1e15)&&(n="scientific"),r=function(t,i){let e=i.length>3?i[2].value-i[1].value:i[1].value-i[0].value;return Math.abs(e)>=1&&t!==Math.floor(t)&&(e=t-Math.floor(t)),e}(t,e)}const o=wt(Math.abs(r)),h=isNaN(o)?1:Math.max(Math.min(-1*Math.floor(o),20),0),a={notation:n,minimumFractionDigits:h,maximumFractionDigits:h};return Object.assign(a,this.options.ticks.format),Gt(t,s,a)}}};const ti=Object.create(null),ii=Object.create(null);function ei(t,i){if(!i)return t;const e=i.split(".");for(let i=0,s=e.length;i<s;++i){const s=e[i];t=t[s]||(t[s]=Object.create(null))}return t}function si(t,i,e){return"string"==typeof i?ot(ei(t,i),e):ot(ei(t,""),i)}class ni{constructor(t,i){this.animation=void 0,this.backgroundColor="rgba(0,0,0,0.1)",this.borderColor="rgba(0,0,0,0.1)",this.color="#666",this.datasets={},this.devicePixelRatio=t=>t.chart.platform.getDevicePixelRatio(),this.elements={},this.events=["mousemove","mouseout","click","touchstart","touchmove"],this.font={family:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",size:12,style:"normal",lineHeight:1.2,weight:null},this.hover={},this.hoverBackgroundColor=(t,i)=>Zt(i.backgroundColor),this.hoverBorderColor=(t,i)=>Zt(i.borderColor),this.hoverColor=(t,i)=>Zt(i.color),this.indexAxis="x",this.interaction={mode:"nearest",intersect:!0,includeInvisible:!1},this.maintainAspectRatio=!0,this.onHover=null,this.onClick=null,this.parsing=!0,this.plugins={},this.responsive=!0,this.scale=void 0,this.scales={},this.showLine=!0,this.drawActiveElementsOnTop=!0,this.describe(t),this.apply(i)}set(t,i){return si(this,t,i)}get(t){return ei(this,t)}describe(t,i){return si(ii,t,i)}override(t,i){return si(ti,t,i)}route(t,i,e,s){const n=ei(this,t),r=ei(this,e),o="_"+i;Object.defineProperties(n,{[o]:{value:n[i],writable:!0},[i]:{enumerable:!0,get(){const t=this[o],i=r[s];return K(t)?Object.assign({},i,t):G(t,i)},set(t){this[o]=t}}})}apply(t){t.forEach((t=>t(this)))}}var ri=new ni({_scriptable:t=>!t.startsWith("on"),_indexable:t=>"events"!==t,hover:{_fallback:"interaction"},interaction:{_scriptable:!1,_indexable:!1}},[function(t){t.set("animation",{delay:void 0,duration:1e3,easing:"easeOutQuart",fn:void 0,from:void 0,loop:void 0,to:void 0,type:void 0}),t.describe("animation",{_fallback:!1,_indexable:!1,_scriptable:t=>"onProgress"!==t&&"onComplete"!==t&&"fn"!==t}),t.set("animations",{colors:{type:"color",properties:Qt},numbers:{type:"number",properties:Kt}}),t.describe("animations",{_fallback:"animation"}),t.set("transitions",{active:{animation:{duration:400}},resize:{animation:{duration:0}},show:{animations:{colors:{from:"transparent"},visible:{type:"boolean",duration:0}}},hide:{animations:{colors:{to:"transparent"},visible:{type:"boolean",easing:"linear",fn:t=>0|t}}}})},function(t){t.set("layout",{autoPadding:!0,padding:{top:0,right:0,bottom:0,left:0}})},function(t){t.set("scale",{display:!0,offset:!1,reverse:!1,beginAtZero:!1,bounds:"ticks",clip:!0,grace:0,grid:{display:!0,lineWidth:1,drawOnChartArea:!0,drawTicks:!0,tickLength:8,tickWidth:(t,i)=>i.lineWidth,tickColor:(t,i)=>i.color,offset:!1},border:{display:!0,dash:[],dashOffset:0,width:1},title:{display:!1,text:"",padding:{top:4,bottom:4}},ticks:{minRotation:0,maxRotation:50,mirror:!1,textStrokeWidth:0,textStrokeColor:"",padding:3,display:!0,autoSkip:!0,autoSkipPadding:3,labelOffset:0,callback:Jt.formatters.values,minor:{},major:{},align:"center",crossAlign:"near",showLabelBackdrop:!1,backdropColor:"rgba(255, 255, 255, 0.75)",backdropPadding:2}}),t.route("scale.ticks","color","","color"),t.route("scale.grid","color","","borderColor"),t.route("scale.border","color","","borderColor"),t.route("scale.title","color","","color"),t.describe("scale",{_fallback:!1,_scriptable:t=>!t.startsWith("before")&&!t.startsWith("after")&&"callback"!==t&&"parser"!==t,_indexable:t=>"borderDash"!==t&&"tickBorderDash"!==t&&"dash"!==t}),t.describe("scales",{_fallback:"scale"}),t.describe("scale.ticks",{_scriptable:t=>"backdropPadding"!==t&&"callback"!==t,_indexable:t=>"backdropPadding"!==t})}]);function oi(t,i,e,s,n){let r=i[n];return r||(r=i[n]=t.measureText(n).width,e.push(n)),r>s&&(s=r),s}function hi(t,i,e){const s=t.currentDevicePixelRatio,n=0!==e?Math.max(e/2,.5):0;return Math.round((i-n)*s)/s+n}function ai(t,i){(i||t)&&((i=i||t.getContext("2d")).save(),i.resetTransform(),i.clearRect(0,0,t.width,t.height),i.restore())}function ci(t,i,e,s){li(t,i,e,s,null)}function li(t,i,e,s,n){let r,o,h,a,c,l,u,f;const d=i.pointStyle,b=i.rotation,p=i.radius;let g=(b||0)*vt;if(d&&"object"==typeof d&&(r=d.toString(),"[object HTMLImageElement]"===r||"[object HTMLCanvasElement]"===r))return t.save(),t.translate(e,s),t.rotate(g),t.drawImage(d,-d.width/2,-d.height/2,d.width,d.height),void t.restore();if(!(isNaN(p)||p<=0)){switch(t.beginPath(),d){default:n?t.ellipse(e,s,n/2,p,0,0,gt):t.arc(e,s,p,0,gt),t.closePath();break;case"triangle":l=n?n/2:p,t.moveTo(e+Math.sin(g)*l,s-Math.cos(g)*p),g+=Mt,t.lineTo(e+Math.sin(g)*l,s-Math.cos(g)*p),g+=Mt,t.lineTo(e+Math.sin(g)*l,s-Math.cos(g)*p),t.closePath();break;case"rectRounded":c=.516*p,a=p-c,o=Math.cos(g+yt)*a,u=Math.cos(g+yt)*(n?n/2-c:a),h=Math.sin(g+yt)*a,f=Math.sin(g+yt)*(n?n/2-c:a),t.arc(e-u,s-h,c,g-pt,g-xt),t.arc(e+f,s-o,c,g-xt,g),t.arc(e+u,s+h,c,g,g+xt),t.arc(e-f,s+o,c,g+xt,g+pt),t.closePath();break;case"rect":if(!b){a=Math.SQRT1_2*p,l=n?n/2:a,t.rect(e-l,s-a,2*l,2*a);break}g+=yt;case"rectRot":u=Math.cos(g)*(n?n/2:p),o=Math.cos(g)*p,h=Math.sin(g)*p,f=Math.sin(g)*(n?n/2:p),t.moveTo(e-u,s-h),t.lineTo(e+f,s-o),t.lineTo(e+u,s+h),t.lineTo(e-f,s+o),t.closePath();break;case"crossRot":g+=yt;case"cross":u=Math.cos(g)*(n?n/2:p),o=Math.cos(g)*p,h=Math.sin(g)*p,f=Math.sin(g)*(n?n/2:p),t.moveTo(e-u,s-h),t.lineTo(e+u,s+h),t.moveTo(e+f,s-o),t.lineTo(e-f,s+o);break;case"star":u=Math.cos(g)*(n?n/2:p),o=Math.cos(g)*p,h=Math.sin(g)*p,f=Math.sin(g)*(n?n/2:p),t.moveTo(e-u,s-h),t.lineTo(e+u,s+h),t.moveTo(e+f,s-o),t.lineTo(e-f,s+o),g+=yt,u=Math.cos(g)*(n?n/2:p),o=Math.cos(g)*p,h=Math.sin(g)*p,f=Math.sin(g)*(n?n/2:p),t.moveTo(e-u,s-h),t.lineTo(e+u,s+h),t.moveTo(e+f,s-o),t.lineTo(e-f,s+o);break;case"line":o=n?n/2:Math.cos(g)*p,h=Math.sin(g)*p,t.moveTo(e-o,s-h),t.lineTo(e+o,s+h);break;case"dash":t.moveTo(e,s),t.lineTo(e+Math.cos(g)*(n?n/2:p),s+Math.sin(g)*p);break;case!1:t.closePath()}t.fill(),i.borderWidth>0&&t.stroke()}}function ui(t,i,e){return e=e||.5,!i||t&&t.x>i.left-e&&t.x<i.right+e&&t.y>i.top-e&&t.y<i.bottom+e}function fi(t,i){t.save(),t.beginPath(),t.rect(i.left,i.top,i.right-i.left,i.bottom-i.top),t.clip()}function di(t){t.restore()}function bi(t,i,e,s,n){if(n.strikethrough||n.underline){const r=t.measureText(s),o=i-r.actualBoundingBoxLeft,h=i+r.actualBoundingBoxRight,a=e+r.actualBoundingBoxDescent,c=n.strikethrough?(e-r.actualBoundingBoxAscent+a)/2:a;t.strokeStyle=t.fillStyle,t.beginPath(),t.lineWidth=n.decorationWidth||2,t.moveTo(o,c),t.lineTo(h,c),t.stroke()}}function pi(t,i){const e=t.fillStyle;t.fillStyle=i.color,t.fillRect(i.left,i.top,i.width,i.height),t.fillStyle=e}function gi(t,i,e,s,n,r={}){const o=Z(i)?i:[i],h=r.strokeWidth>0&&""!==r.strokeColor;let a,c;for(t.save(),t.font=n.string,function(t,i){i.translation&&t.translate(i.translation[0],i.translation[1]),U(i.rotation)||t.rotate(i.rotation),i.color&&(t.fillStyle=i.color),i.textAlign&&(t.textAlign=i.textAlign),i.textBaseline&&(t.textBaseline=i.textBaseline)}(t,r),a=0;a<o.length;++a)c=o[a],r.backdrop&&pi(t,r.backdrop),h&&(r.strokeColor&&(t.strokeStyle=r.strokeColor),U(r.strokeWidth)||(t.lineWidth=r.strokeWidth),t.strokeText(c,e,s,r.maxWidth)),t.fillText(c,e,s,r.maxWidth),bi(t,e,s,c,r),s+=Number(n.lineHeight);t.restore()}function mi(t,i){const{x:e,y:s,w:n,h:r,radius:o}=i;t.arc(e+o.topLeft,s+o.topLeft,o.topLeft,1.5*pt,pt,!0),t.lineTo(e,s+r-o.bottomLeft),t.arc(e+o.bottomLeft,s+r-o.bottomLeft,o.bottomLeft,pt,xt,!0),t.lineTo(e+n-o.bottomRight,s+r),t.arc(e+n-o.bottomRight,s+r-o.bottomRight,o.bottomRight,xt,0,!0),t.lineTo(e+n,s+o.topRight),t.arc(e+n-o.topRight,s+o.topRight,o.topRight,0,-xt,!0),t.lineTo(e+o.topLeft,s)}const vi=/^(normal|(\d+(?:\.\d+)?)(px|em|%)?)$/,xi=/^(normal|italic|initial|inherit|unset|(oblique( -?[0-9]?[0-9]deg)?))$/;function yi(t,i){const e=(""+t).match(vi);if(!e||"normal"===e[1])return 1.2*i;switch(t=+e[2],e[3]){case"px":return t;case"%":t/=100}return i*t}function Mi(t,i){const e={},s=K(i),n=s?Object.keys(i):i,r=K(t)?s?e=>G(t[e],t[i[e]]):i=>t[i]:()=>t;for(const t of n)e[t]=+r(t)||0;return e}function wi(t){return Mi(t,{top:"y",right:"x",bottom:"y",left:"x"})}function _i(t){return Mi(t,["topLeft","topRight","bottomLeft","bottomRight"])}function ki(t){const i=wi(t);return i.width=i.left+i.right,i.height=i.top+i.bottom,i}function Oi(t,i){let e=G((t=t||{}).size,(i=i||ri.font).size);"string"==typeof e&&(e=parseInt(e,10));let s=G(t.style,i.style);s&&!(""+s).match(xi)&&(console.warn('Invalid font style specified: "'+s+'"'),s=void 0);const n={family:G(t.family,i.family),lineHeight:yi(G(t.lineHeight,i.lineHeight),e),size:e,style:s,weight:G(t.weight,i.weight),string:""};return n.string=function(t){return!t||U(t.size)||U(t.family)?null:(t.style?t.style+" ":"")+(t.weight?t.weight+" ":"")+t.size+"px "+t.family}(n),n}function Si(t){let i,e,s;for(i=0,e=t.length;i<e;++i)if(s=t[i],void 0!==s&&void 0!==s)return s}function Ai(t,i){return Object.assign(Object.create(t),i)}function Di(t,i=[""],e,s,n=()=>t[0]){const r=e||t;void 0===s&&(s=Wi("_fallback",t));const o={[Symbol.toStringTag]:"Object",_cacheable:!0,_scopes:t,_rootScopes:r,_fallback:s,_getTarget:n,override:e=>Di([e,...t],i,r,s)};return new Proxy(o,{deleteProperty:(i,e)=>(delete i[e],delete i._keys,delete t[0][e],!0),get:(e,s)=>Li(e,s,(()=>function(t,i,e,s){let n;for(const r of i)if(n=Wi(Ri(r,t),e),void 0!==n)return Ei(t,n)?Fi(e,s,t,n):n}(s,i,t,e))),getOwnPropertyDescriptor:(t,i)=>Reflect.getOwnPropertyDescriptor(t._scopes[0],i),getPrototypeOf:()=>Reflect.getPrototypeOf(t[0]),has:(t,i)=>Ni(t).includes(i),ownKeys:t=>Ni(t),set(t,i,e){const s=t._storage||(t._storage=n());return t[i]=s[i]=e,delete t._keys,!0}})}function ji(t,i,e,s){const n={_cacheable:!1,_proxy:t,_context:i,_subProxy:e,_stack:new Set,_descriptors:Ci(t,s),setContext:i=>ji(t,i,e,s),override:n=>ji(t.override(n),i,e,s)};return new Proxy(n,{deleteProperty:(i,e)=>(delete i[e],delete t[e],!0),get:(t,i,e)=>Li(t,i,(()=>function(t,i,e){const{_proxy:s,_context:n,_subProxy:r,_descriptors:o}=t;let h=s[i];return dt(h)&&o.isScriptable(i)&&(h=function(t,i,e,s){const{_proxy:n,_context:r,_subProxy:o,_stack:h}=e;if(h.has(t))throw new Error("Recursion detected: "+Array.from(h).join("->")+"->"+t);h.add(t);let a=i(r,o||s);return h.delete(t),Ei(t,a)&&(a=Fi(n._scopes,n,t,a)),a}(i,h,t,e)),Z(h)&&h.length&&(h=function(t,i,e,s){const{_proxy:n,_context:r,_subProxy:o,_descriptors:h}=e;if(void 0!==r.index&&s(t))return i[r.index%i.length];if(K(i[0])){const e=i,s=n._scopes.filter((t=>t!==e));i=[];for(const a of e){const e=Fi(s,n,t,a);i.push(ji(e,r,o&&o[t],h))}}return i}(i,h,t,o.isIndexable)),Ei(i,h)&&(h=ji(h,n,r&&r[i],o)),h}(t,i,e))),getOwnPropertyDescriptor:(i,e)=>i._descriptors.allKeys?Reflect.has(t,e)?{enumerable:!0,configurable:!0}:void 0:Reflect.getOwnPropertyDescriptor(t,e),getPrototypeOf:()=>Reflect.getPrototypeOf(t),has:(i,e)=>Reflect.has(t,e),ownKeys:()=>Reflect.ownKeys(t),set:(i,e,s)=>(t[e]=s,delete i[e],!0)})}function Ci(t,i={scriptable:!0,indexable:!0}){const{_scriptable:e=i.scriptable,_indexable:s=i.indexable,_allKeys:n=i.allKeys}=t;return{allKeys:n,scriptable:e,indexable:s,isScriptable:dt(e)?e:()=>e,isIndexable:dt(s)?s:()=>s}}const Ri=(t,i)=>t?t+ut(i):i,Ei=(t,i)=>K(i)&&"adapters"!==t&&(null===Object.getPrototypeOf(i)||i.constructor===Object);function Li(t,i,e){if(Object.prototype.hasOwnProperty.call(t,i)||"constructor"===i)return t[i];const s=e();return t[i]=s,s}function Pi(t,i,e){return dt(t)?t(i,e):t}const Ti=(t,i)=>!0===t?i:"string"==typeof t?lt(i,t):void 0;function Ii(t,i,e,s,n){for(const r of i){const i=Ti(e,r);if(i){t.add(i);const r=Pi(i._fallback,e,n);if(void 0!==r&&r!==e&&r!==s)return r}else if(!1===i&&void 0!==s&&e!==s)return null}return!1}function Fi(t,i,e,s){const n=i._rootScopes,r=Pi(i._fallback,e,s),o=[...t,...n],h=new Set;h.add(s);let a=Bi(h,o,e,r||e,s);return null!==a&&(void 0===r||r===e||(a=Bi(h,o,r,a,s),null!==a))&&Di(Array.from(h),[""],n,r,(()=>function(t,i,e){const s=t._getTarget();i in s||(s[i]={});const n=s[i];return Z(n)&&K(e)?e:n||{}}(i,e,s)))}function Bi(t,i,e,s,n){for(;e;)e=Ii(t,i,e,s,n);return e}function Wi(t,i){for(const e of i){if(!e)continue;const i=e[t];if(void 0!==i)return i}}function Ni(t){let i=t._keys;return i||(i=t._keys=function(t){const i=new Set;for(const e of t)for(const t of Object.keys(e).filter((t=>!t.startsWith("_"))))i.add(t);return Array.from(i)}(t._scopes)),i}function zi(t,i,e,s){const{iScale:n}=t,{key:r="r"}=this._parsing,o=new Array(s);let h,a,c,l;for(h=0,a=s;h<a;++h)c=h+e,l=i[c],o[h]={r:n.parse(lt(l,r),c)};return o}function Hi(){return"undefined"!=typeof window&&"undefined"!=typeof document}function $i(t){let i=t.parentNode;return i&&"[object ShadowRoot]"===i.toString()&&(i=i.host),i}function Yi(t,i,e){let s;return"string"==typeof t?(s=parseInt(t,10),-1!==t.indexOf("%")&&(s=s/100*i.parentNode[e])):s=t,s}const Vi=t=>t.ownerDocument.defaultView.getComputedStyle(t,null),Xi=["top","right","bottom","left"];function Ui(t,i,e){const s={};e=e?"-"+e:"";for(let n=0;n<4;n++){const r=Xi[n];s[r]=parseFloat(t[i+"-"+r+e])||0}return s.width=s.left+s.right,s.height=s.top+s.bottom,s}function Zi(t,i){if("native"in t)return t;const{canvas:e,currentDevicePixelRatio:s}=i,n=Vi(e),r="border-box"===n.boxSizing,o=Ui(n,"padding"),h=Ui(n,"border","width"),{x:a,y:c,box:l}=function(t,i){const e=t.touches,s=e&&e.length?e[0]:t,{offsetX:n,offsetY:r}=s;let o,h,a=!1;if(((t,i,e)=>(t>0||i>0)&&(!e||!e.shadowRoot))(n,r,t.target))o=n,h=r;else{const t=i.getBoundingClientRect();o=s.clientX-t.left,h=s.clientY-t.top,a=!0}return{x:o,y:h,box:a}}(t,e),u=o.left+(l&&h.left),f=o.top+(l&&h.top);let{width:d,height:b}=i;return r&&(d-=o.width+h.width,b-=o.height+h.height),{x:Math.round((a-u)/d*e.width/s),y:Math.round((c-f)/b*e.height/s)}}const Ki=t=>Math.round(10*t)/10;function Qi(t,i,e){const s=i||1,n=Ki(t.height*s),r=Ki(t.width*s);t.height=Ki(t.height),t.width=Ki(t.width);const o=t.canvas;return o.style&&(e||!o.style.height&&!o.style.width)&&(o.style.height=`${t.height}px`,o.style.width=`${t.width}px`),(t.currentDevicePixelRatio!==s||o.height!==n||o.width!==r)&&(t.currentDevicePixelRatio=s,o.height=n,o.width=r,t.ctx.setTransform(s,0,0,s,0,0),!0)}const qi=function(){let t=!1;try{const i={get passive(){return t=!0,!1}};Hi()&&(window.addEventListener("test",null,i),window.removeEventListener("test",null,i))}catch(t){}return t}();function Gi(t,i){const e=function(t,i){return Vi(t).getPropertyValue(i)}(t,i),s=e&&e.match(/^(\d+)(\.\d+)?px$/);return s?+s[1]:void 0}function Ji(t,i,e){return t?function(t,i){return{x:e=>t+t+i-e,setWidth(t){i=t},textAlign:t=>"center"===t?t:"right"===t?"left":"right",xPlus:(t,i)=>t-i,leftForLtr:(t,i)=>t-i}}(i,e):{x:t=>t,setWidth(t){},textAlign:t=>t,xPlus:(t,i)=>t+i,leftForLtr:t=>t}}function te(t,i){let e,s;"ltr"!==i&&"rtl"!==i||(e=t.canvas.style,s=[e.getPropertyValue("direction"),e.getPropertyPriority("direction")],e.setProperty("direction",i,"important"),t.prevTextDirection=s)}function ie(t,i){void 0!==i&&(delete t.prevTextDirection,t.canvas.style.setProperty("direction",i[0],i[1]))}function ee(t,i,e){return t.options.clip?t[e]:i[e]}
|
|
14
|
-
/*!
|
|
15
|
-
* Chart.js v4.5.1
|
|
16
|
-
* https://www.chartjs.org
|
|
17
|
-
* (c) 2025 Chart.js Contributors
|
|
18
|
-
* Released under the MIT License
|
|
19
|
-
*/
|
|
20
|
-
class se{constructor(){this._request=null,this._charts=new Map,this._running=!1,this._lastDate=void 0}_notify(t,i,e,s){const n=i.duration;i.listeners[s].forEach((s=>s({chart:t,initial:i.initial,numSteps:n,currentStep:Math.min(e-i.start,n)})))}_refresh(){this._request||(this._running=!0,this._request=Bt.call(window,(()=>{this._update(),this._request=null,this._running&&this._refresh()})))}_update(t=Date.now()){let i=0;this._charts.forEach(((e,s)=>{if(!e.running||!e.items.length)return;const n=e.items;let r,o=n.length-1,h=!1;for(;o>=0;--o)r=n[o],r._active?(r._total>e.duration&&(e.duration=r._total),r.tick(t),h=!0):(n[o]=n[n.length-1],n.pop());h&&(s.draw(),this._notify(s,e,t,"progress")),n.length||(e.running=!1,this._notify(s,e,t,"complete"),e.initial=!1),i+=n.length})),this._lastDate=t,0===i&&(this._running=!1)}_getAnims(t){const i=this._charts;let e=i.get(t);return e||(e={running:!1,initial:!0,items:[],listeners:{complete:[],progress:[]}},i.set(t,e)),e}listen(t,i,e){this._getAnims(t).listeners[i].push(e)}add(t,i){i&&i.length&&this._getAnims(t).items.push(...i)}has(t){return this._getAnims(t).items.length>0}start(t){const i=this._charts.get(t);i&&(i.running=!0,i.start=Date.now(),i.duration=i.items.reduce(((t,i)=>Math.max(t,i._duration)),0),this._refresh())}running(t){if(!this._running)return!1;const i=this._charts.get(t);return!!(i&&i.running&&i.items.length)}stop(t){const i=this._charts.get(t);if(!i||!i.items.length)return;const e=i.items;let s=e.length-1;for(;s>=0;--s)e[s].cancel();i.items=[],this._notify(t,i,Date.now(),"complete")}remove(t){return this._charts.delete(t)}}var ne=new se;const re="transparent",oe={boolean:(t,i,e)=>e>.5?i:t,color(t,i,e){const s=Ut(t||re),n=s.valid&&Ut(i||re);return n&&n.valid?n.mix(s,e).hexString():i},number:(t,i,e)=>t+(i-t)*e};class he{constructor(t,i,e,s){const n=i[e];s=Si([t.to,s,n,t.from]);const r=Si([t.from,n,s]);this._active=!0,this._fn=t.fn||oe[t.type||typeof r],this._easing=Vt[t.easing]||Vt.linear,this._start=Math.floor(Date.now()+(t.delay||0)),this._duration=this._total=Math.floor(t.duration),this._loop=!!t.loop,this._target=i,this._prop=e,this._from=r,this._to=s,this._promises=void 0}active(){return this._active}update(t,i,e){if(this._active){this._notify(!1);const s=this._target[this._prop],n=e-this._start,r=this._duration-n;this._start=e,this._duration=Math.floor(Math.max(r,t.duration)),this._total+=n,this._loop=!!t.loop,this._to=Si([t.to,i,s,t.from]),this._from=Si([t.from,s,i])}}cancel(){this._active&&(this.tick(Date.now()),this._active=!1,this._notify(!1))}tick(t){const i=t-this._start,e=this._duration,s=this._prop,n=this._from,r=this._loop,o=this._to;let h;if(this._active=n!==o&&(r||i<e),!this._active)return this._target[s]=o,void this._notify(!0);i<0?this._target[s]=n:(h=i/e%2,h=r&&h>1?2-h:h,h=this._easing(Math.min(1,Math.max(0,h))),this._target[s]=this._fn(n,o,h))}wait(){const t=this._promises||(this._promises=[]);return new Promise(((i,e)=>{t.push({res:i,rej:e})}))}_notify(t){const i=t?"res":"rej",e=this._promises||[];for(let t=0;t<e.length;t++)e[t][i]()}}class ae{constructor(t,i){this._chart=t,this._properties=new Map,this.configure(i)}configure(t){if(!K(t))return;const i=Object.keys(ri.animation),e=this._properties;Object.getOwnPropertyNames(t).forEach((s=>{const n=t[s];if(!K(n))return;const r={};for(const t of i)r[t]=n[t];(Z(n.properties)&&n.properties||[s]).forEach((t=>{t!==s&&e.has(t)||e.set(t,r)}))}))}_animateOptions(t,i){const e=i.options,s=function(t,i){if(!i)return;let e=t.options;if(e)return e.$shared&&(t.options=e=Object.assign({},e,{$shared:!1,$animations:{}})),e;t.options=i}(t,e);if(!s)return[];const n=this._createAnimations(s,e);return e.$shared&&function(t,i){const e=[],s=Object.keys(i);for(let i=0;i<s.length;i++){const n=t[s[i]];n&&n.active()&&e.push(n.wait())}return Promise.all(e)}(t.options.$animations,e).then((()=>{t.options=e}),(()=>{})),n}_createAnimations(t,i){const e=this._properties,s=[],n=t.$animations||(t.$animations={}),r=Object.keys(i),o=Date.now();let h;for(h=r.length-1;h>=0;--h){const a=r[h];if("$"===a.charAt(0))continue;if("options"===a){s.push(...this._animateOptions(t,i));continue}const c=i[a];let l=n[a];const u=e.get(a);if(l){if(u&&l.active()){l.update(u,c,o);continue}l.cancel()}u&&u.duration?(n[a]=l=new he(u,t,a,c),s.push(l)):t[a]=c}return s}update(t,i){if(0===this._properties.size)return void Object.assign(t,i);const e=this._createAnimations(t,i);return e.length?(ne.add(this._chart,e),!0):void 0}}function ce(t,i){const e=t&&t.options||{},s=e.reverse,n=void 0===e.min?i:0,r=void 0===e.max?i:0;return{start:s?r:n,end:s?n:r}}function le(t,i){const e=[],s=t._getSortedDatasetMetas(i);let n,r;for(n=0,r=s.length;n<r;++n)e.push(s[n].index);return e}function ue(t,i,e,s={}){const n=t.keys,r="single"===s.mode;let o,h,a,c;if(null===i)return;let l=!1;for(o=0,h=n.length;o<h;++o){if(a=+n[o],a===e){if(l=!0,s.all)continue;break}c=t.values[a],Q(c)&&(r||0===i||_t(i)===_t(c))&&(i+=c)}return l||s.all?i:0}function fe(t,i){const e=t&&t.options.stacked;return e||void 0===e&&void 0!==i.stack}function de(t,i,e){const s=t[i]||(t[i]={});return s[e]||(s[e]={})}function be(t,i,e,s){for(const n of i.getMatchingVisibleMetas(s).reverse()){const i=t[n.index];if(e&&i>0||!e&&i<0)return n.index}return null}function pe(t,i){const{chart:e,_cachedMeta:s}=t,n=e._stacks||(e._stacks={}),{iScale:r,vScale:o,index:h}=s,a=r.axis,c=o.axis,l=function(t,i,e){return`${t.id}.${i.id}.${e.stack||e.type}`}(r,o,s),u=i.length;let f;for(let t=0;t<u;++t){const e=i[t],{[a]:r,[c]:u}=e;f=(e._stacks||(e._stacks={}))[c]=de(n,l,r),f[h]=u,f._top=be(f,o,!0,s.type),f._bottom=be(f,o,!1,s.type),(f._visualValues||(f._visualValues={}))[h]=u}}function ge(t,i){const e=t.scales;return Object.keys(e).filter((t=>e[t].axis===i)).shift()}function me(t,i){const e=t.controller.index,s=t.vScale&&t.vScale.axis;if(s){i=i||t._parsed;for(const t of i){const i=t._stacks;if(!i||void 0===i[s]||void 0===i[s][e])return;delete i[s][e],void 0!==i[s]._visualValues&&void 0!==i[s]._visualValues[e]&&delete i[s]._visualValues[e]}}}const ve=t=>"reset"===t||"none"===t,xe=(t,i)=>i?t:Object.assign({},t);class ye{static defaults={};static datasetElementType=null;static dataElementType=null;constructor(t,i){this.chart=t,this._ctx=t.ctx,this.index=i,this._cachedDataOpts={},this._cachedMeta=this.getMeta(),this._type=this._cachedMeta.type,this.options=void 0,this._parsing=!1,this._data=void 0,this._objectData=void 0,this._sharedOptions=void 0,this._drawStart=void 0,this._drawCount=void 0,this.enableOptionSharing=!1,this.supportsDecimation=!1,this.$context=void 0,this._syncList=[],this.datasetElementType=new.target.datasetElementType,this.dataElementType=new.target.dataElementType,this.initialize()}initialize(){const t=this._cachedMeta;this.configure(),this.linkScales(),t._stacked=fe(t.vScale,t),this.addElements(),this.options.fill&&!this.chart.isPluginEnabled("filler")&&console.warn("Tried to use the 'fill' option without the 'Filler' plugin enabled. Please import and register the 'Filler' plugin and make sure it is not disabled in the options")}updateIndex(t){this.index!==t&&me(this._cachedMeta),this.index=t}linkScales(){const t=this.chart,i=this._cachedMeta,e=this.getDataset(),s=(t,i,e,s)=>"x"===t?i:"r"===t?s:e,n=i.xAxisID=G(e.xAxisID,ge(t,"x")),r=i.yAxisID=G(e.yAxisID,ge(t,"y")),o=i.rAxisID=G(e.rAxisID,ge(t,"r")),h=i.indexAxis,a=i.iAxisID=s(h,n,r,o),c=i.vAxisID=s(h,r,n,o);i.xScale=this.getScaleForId(n),i.yScale=this.getScaleForId(r),i.rScale=this.getScaleForId(o),i.iScale=this.getScaleForId(a),i.vScale=this.getScaleForId(c)}getDataset(){return this.chart.data.datasets[this.index]}getMeta(){return this.chart.getDatasetMeta(this.index)}getScaleForId(t){return this.chart.scales[t]}_getOtherScale(t){const i=this._cachedMeta;return t===i.iScale?i.vScale:i.iScale}reset(){this._update("reset")}_destroy(){const t=this._cachedMeta;this._data&&Ft(this._data,this),t._stacked&&me(t)}_dataCheck(){const t=this.getDataset(),i=t.data||(t.data=[]),e=this._data;if(K(i))this._data=function(t,i){const{iScale:e,vScale:s}=i,n="x"===e.axis?"x":"y",r="x"===s.axis?"x":"y",o=Object.keys(t),h=new Array(o.length);let a,c,l;for(a=0,c=o.length;a<c;++a)l=o[a],h[a]={[n]:l,[r]:t[l]};return h}(i,this._cachedMeta);else if(e!==i){if(e){Ft(e,this);const t=this._cachedMeta;me(t),t._parsed=[]}i&&Object.isExtensible(i)&&((s=i)._chartjs?s._chartjs.listeners.push(this):(Object.defineProperty(s,"_chartjs",{configurable:!0,enumerable:!1,value:{listeners:[this]}}),It.forEach((t=>{const i="_onData"+ut(t),e=s[t];Object.defineProperty(s,t,{configurable:!0,enumerable:!1,value(...t){const n=e.apply(this,t);return s._chartjs.listeners.forEach((e=>{"function"==typeof e[i]&&e[i](...t)})),n}})})))),this._syncList=[],this._data=i}var s}addElements(){const t=this._cachedMeta;this._dataCheck(),this.datasetElementType&&(t.dataset=new this.datasetElementType)}buildOrUpdateElements(t){const i=this._cachedMeta,e=this.getDataset();let s=!1;this._dataCheck();const n=i._stacked;i._stacked=fe(i.vScale,i),i.stack!==e.stack&&(s=!0,me(i),i.stack=e.stack),this._resyncElements(t),(s||n!==i._stacked)&&(pe(this,i._parsed),i._stacked=fe(i.vScale,i))}configure(){const t=this.chart.config,i=t.datasetScopeKeys(this._type),e=t.getOptionScopes(this.getDataset(),i,!0);this.options=t.createResolver(e,this.getContext()),this._parsing=this.options.parsing,this._cachedDataOpts={}}parse(t,i){const{_cachedMeta:e,_data:s}=this,{iScale:n,_stacked:r}=e,o=n.axis;let h,a,c,l=0===t&&i===s.length||e._sorted,u=t>0&&e._parsed[t-1];if(!1===this._parsing)e._parsed=s,e._sorted=!0,c=s;else{c=Z(s[t])?this.parseArrayData(e,s,t,i):K(s[t])?this.parseObjectData(e,s,t,i):this.parsePrimitiveData(e,s,t,i);const n=()=>null===a[o]||u&&a[o]<u[o];for(h=0;h<i;++h)e._parsed[h+t]=a=c[h],l&&(n()&&(l=!1),u=a);e._sorted=l}r&&pe(this,c)}parsePrimitiveData(t,i,e,s){const{iScale:n,vScale:r}=t,o=n.axis,h=r.axis,a=n.getLabels(),c=n===r,l=new Array(s);let u,f,d;for(u=0,f=s;u<f;++u)d=u+e,l[u]={[o]:c||n.parse(a[d],d),[h]:r.parse(i[d],d)};return l}parseArrayData(t,i,e,s){const{xScale:n,yScale:r}=t,o=new Array(s);let h,a,c,l;for(h=0,a=s;h<a;++h)c=h+e,l=i[c],o[h]={x:n.parse(l[0],c),y:r.parse(l[1],c)};return o}parseObjectData(t,i,e,s){const{xScale:n,yScale:r}=t,{xAxisKey:o="x",yAxisKey:h="y"}=this._parsing,a=new Array(s);let c,l,u,f;for(c=0,l=s;c<l;++c)u=c+e,f=i[u],a[c]={x:n.parse(lt(f,o),u),y:r.parse(lt(f,h),u)};return a}getParsed(t){return this._cachedMeta._parsed[t]}getDataElement(t){return this._cachedMeta.data[t]}applyStack(t,i,e){const s=this._cachedMeta,n=i[t.axis];return ue({keys:le(this.chart,!0),values:i._stacks[t.axis]._visualValues},n,s.index,{mode:e})}updateRangeFromParsed(t,i,e,s){const n=e[i.axis];let r=null===n?NaN:n;const o=s&&e._stacks[i.axis];s&&o&&(s.values=o,r=ue(s,n,this._cachedMeta.index)),t.min=Math.min(t.min,r),t.max=Math.max(t.max,r)}getMinMax(t,i){const e=this._cachedMeta,s=e._parsed,n=e._sorted&&t===e.iScale,r=s.length,o=this._getOtherScale(t),h=((t,i)=>t&&!i.hidden&&i._stacked&&{keys:le(this.chart,!0),values:null})(i,e),a={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY},{min:c,max:l}=function(t){const{min:i,max:e,minDefined:s,maxDefined:n}=t.getUserBounds();return{min:s?i:Number.NEGATIVE_INFINITY,max:n?e:Number.POSITIVE_INFINITY}}(o);let u,f;function d(){f=s[u];const i=f[o.axis];return!Q(f[t.axis])||c>i||l<i}for(u=0;u<r&&(d()||(this.updateRangeFromParsed(a,t,f,h),!n));++u);if(n)for(u=r-1;u>=0;--u)if(!d()){this.updateRangeFromParsed(a,t,f,h);break}return a}getAllParsedValues(t){const i=this._cachedMeta._parsed,e=[];let s,n,r;for(s=0,n=i.length;s<n;++s)r=i[s][t.axis],Q(r)&&e.push(r);return e}getMaxOverflow(){return!1}getLabelAndValue(t){const i=this._cachedMeta,e=i.iScale,s=i.vScale,n=this.getParsed(t);return{label:e?""+e.getLabelForValue(n[e.axis]):"",value:s?""+s.getLabelForValue(n[s.axis]):""}}_update(t){const i=this._cachedMeta;this.update(t||"default"),i._clip=function(t){let i,e,s,n;return K(t)?(i=t.top,e=t.right,s=t.bottom,n=t.left):i=e=s=n=t,{top:i,right:e,bottom:s,left:n,disabled:!1===t}}(G(this.options.clip,function(t,i,e){if(!1===e)return!1;const s=ce(t,e),n=ce(i,e);return{top:n.end,right:s.end,bottom:n.start,left:s.start}}(i.xScale,i.yScale,this.getMaxOverflow())))}update(t){}draw(){const t=this._ctx,i=this._cachedMeta,e=i.data||[],s=this.chart.chartArea,n=[],r=this._drawStart||0,o=this._drawCount||e.length-r,h=this.options.drawActiveElementsOnTop;let a;for(i.dataset&&i.dataset.draw(t,s,r,o),a=r;a<r+o;++a){const i=e[a];i.hidden||(i.active&&h?n.push(i):i.draw(t,s))}for(a=0;a<n.length;++a)n[a].draw(t,s)}getStyle(t,i){const e=i?"active":"default";return void 0===t&&this._cachedMeta.dataset?this.resolveDatasetElementOptions(e):this.resolveDataElementOptions(t||0,e)}getContext(t,i,e){const s=this.getDataset();let n;if(t>=0&&t<this._cachedMeta.data.length){const i=this._cachedMeta.data[t];n=i.$context||(i.$context=function(t,i,e){return Ai(t,{active:!1,dataIndex:i,parsed:void 0,raw:void 0,element:e,index:i,mode:"default",type:"data"})}(this.getContext(),t,i)),n.parsed=this.getParsed(t),n.raw=s.data[t],n.index=n.dataIndex=t}else n=this.$context||(this.$context=function(t,i){return Ai(t,{active:!1,dataset:void 0,datasetIndex:i,index:i,mode:"default",type:"dataset"})}(this.chart.getContext(),this.index)),n.dataset=s,n.index=n.datasetIndex=this.index;return n.active=!!i,n.mode=e,n}resolveDatasetElementOptions(t){return this._resolveElementOptions(this.datasetElementType.id,t)}resolveDataElementOptions(t,i){return this._resolveElementOptions(this.dataElementType.id,i,t)}_resolveElementOptions(t,i="default",e){const s="active"===i,n=this._cachedDataOpts,r=t+"-"+i,o=n[r],h=this.enableOptionSharing&&ft(e);if(o)return xe(o,h);const a=this.chart.config,c=a.datasetElementScopeKeys(this._type,t),l=s?[`${t}Hover`,"hover",t,""]:[t,""],u=a.getOptionScopes(this.getDataset(),c),f=Object.keys(ri.elements[t]),d=a.resolveNamedOptions(u,f,(()=>this.getContext(e,s,i)),l);return d.$shared&&(d.$shared=h,n[r]=Object.freeze(xe(d,h))),d}_resolveAnimations(t,i,e){const s=this.chart,n=this._cachedDataOpts,r=`animation-${i}`,o=n[r];if(o)return o;let h;if(!1!==s.options.animation){const s=this.chart.config,n=s.datasetAnimationScopeKeys(this._type,i),r=s.getOptionScopes(this.getDataset(),n);h=s.createResolver(r,this.getContext(t,e,i))}const a=new ae(s,h&&h.animations);return h&&h._cacheable&&(n[r]=Object.freeze(a)),a}getSharedOptions(t){if(t.$shared)return this._sharedOptions||(this._sharedOptions=Object.assign({},t))}includeOptions(t,i){return!i||ve(t)||this.chart._animationsDisabled}_getSharedOptions(t,i){const e=this.resolveDataElementOptions(t,i),s=this._sharedOptions,n=this.getSharedOptions(e),r=this.includeOptions(i,n)||n!==s;return this.updateSharedOptions(n,i,e),{sharedOptions:n,includeOptions:r}}updateElement(t,i,e,s){ve(s)?Object.assign(t,e):this._resolveAnimations(i,s).update(t,e)}updateSharedOptions(t,i,e){t&&!ve(i)&&this._resolveAnimations(void 0,i).update(t,e)}_setStyle(t,i,e,s){t.active=s;const n=this.getStyle(i,s);this._resolveAnimations(i,e,s).update(t,{options:!s&&this.getSharedOptions(n)||n})}removeHoverStyle(t,i,e){this._setStyle(t,e,"active",!1)}setHoverStyle(t,i,e){this._setStyle(t,e,"active",!0)}_removeDatasetHoverStyle(){const t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",!1)}_setDatasetHoverStyle(){const t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",!0)}_resyncElements(t){const i=this._data,e=this._cachedMeta.data;for(const[t,i,e]of this._syncList)this[t](i,e);this._syncList=[];const s=e.length,n=i.length,r=Math.min(n,s);r&&this.parse(0,r),n>s?this._insertElements(s,n-s,t):n<s&&this._removeElements(n,s-n)}_insertElements(t,i,e=!0){const s=this._cachedMeta,n=s.data,r=t+i;let o;const h=t=>{for(t.length+=i,o=t.length-1;o>=r;o--)t[o]=t[o-i]};for(h(n),o=t;o<r;++o)n[o]=new this.dataElementType;this._parsing&&h(s._parsed),this.parse(t,i),e&&this.updateElements(n,t,i,"reset")}updateElements(t,i,e,s){}_removeElements(t,i){const e=this._cachedMeta;if(this._parsing){const s=e._parsed.splice(t,i);e._stacked&&me(e,s)}e.data.splice(t,i)}_sync(t){if(this._parsing)this._syncList.push(t);else{const[i,e,s]=t;this[i](e,s)}this.chart._dataChanges.push([this.index,...t])}_onDataPush(){const t=arguments.length;this._sync(["_insertElements",this.getDataset().data.length-t,t])}_onDataPop(){this._sync(["_removeElements",this._cachedMeta.data.length-1,1])}_onDataShift(){this._sync(["_removeElements",0,1])}_onDataSplice(t,i){i&&this._sync(["_removeElements",t,i]);const e=arguments.length-2;e&&this._sync(["_insertElements",t,e])}_onDataUnshift(){this._sync(["_insertElements",0,arguments.length])}}function Me(t,i,e,s){return Z(t)?function(t,i,e,s){const n=e.parse(t[0],s),r=e.parse(t[1],s),o=Math.min(n,r),h=Math.max(n,r);let a=o,c=h;Math.abs(o)>Math.abs(h)&&(a=h,c=o),i[e.axis]=c,i._custom={barStart:a,barEnd:c,start:n,end:r,min:o,max:h}}(t,i,e,s):i[e.axis]=e.parse(t,s),i}function we(t,i,e,s){const n=t.iScale,r=t.vScale,o=n.getLabels(),h=n===r,a=[];let c,l,u,f;for(c=e,l=e+s;c<l;++c)f=i[c],u={},u[n.axis]=h||n.parse(o[c],c),a.push(Me(f,u,r,c));return a}function _e(t){return t&&void 0!==t.barStart&&void 0!==t.barEnd}function ke(t,i,e,s){let n=i.borderSkipped;const r={};if(!n)return void(t.borderSkipped=r);if(!0===n)return void(t.borderSkipped={top:!0,right:!0,bottom:!0,left:!0});const{start:o,end:h,reverse:a,top:c,bottom:l}=function(t){let i,e,s,n,r;return t.horizontal?(i=t.base>t.x,e="left",s="right"):(i=t.base<t.y,e="bottom",s="top"),i?(n="end",r="start"):(n="start",r="end"),{start:e,end:s,reverse:i,top:n,bottom:r}}(t);"middle"===n&&e&&(t.enableBorderRadius=!0,(e._top||0)===s?n=c:(e._bottom||0)===s?n=l:(r[Oe(l,o,h,a)]=!0,n=c)),r[Oe(n,o,h,a)]=!0,t.borderSkipped=r}function Oe(t,i,e,s){var n,r,o;return s?(o=e,t=Se(t=(n=t)===(r=i)?o:n===o?r:n,e,i)):t=Se(t,i,e),t}function Se(t,i,e){return"start"===t?i:"end"===t?e:t}function Ae(t,{inflateAmount:i},e){t.inflateAmount="auto"===i?1===e?.33:0:i}class De extends ye{static id="doughnut";static defaults={datasetElementType:!1,dataElementType:"arc",animation:{animateRotate:!0,animateScale:!1},animations:{numbers:{type:"number",properties:["circumference","endAngle","innerRadius","outerRadius","startAngle","x","y","offset","borderWidth","spacing"]}},cutout:"50%",rotation:0,circumference:360,radius:"100%",spacing:0,indexAxis:"r"};static descriptors={_scriptable:t=>"spacing"!==t,_indexable:t=>"spacing"!==t&&!t.startsWith("borderDash")&&!t.startsWith("hoverBorderDash")};static overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(t){const i=t.data,{labels:{pointStyle:e,textAlign:s,color:n,useBorderRadius:r,borderRadius:o}}=t.legend.options;return i.labels.length&&i.datasets.length?i.labels.map(((i,h)=>{const a=t.getDatasetMeta(0).controller.getStyle(h);return{text:i,fillStyle:a.backgroundColor,fontColor:n,hidden:!t.getDataVisibility(h),lineDash:a.borderDash,lineDashOffset:a.borderDashOffset,lineJoin:a.borderJoinStyle,lineWidth:a.borderWidth,strokeStyle:a.borderColor,textAlign:s,pointStyle:e,borderRadius:r&&(o||a.borderRadius),index:h}})):[]}},onClick(t,i,e){e.chart.toggleDataVisibility(i.index),e.chart.update()}}}};constructor(t,i){super(t,i),this.enableOptionSharing=!0,this.innerRadius=void 0,this.outerRadius=void 0,this.offsetX=void 0,this.offsetY=void 0}linkScales(){}parse(t,i){const e=this.getDataset().data,s=this._cachedMeta;if(!1===this._parsing)s._parsed=e;else{let n,r,o=t=>+e[t];if(K(e[t])){const{key:t="value"}=this._parsing;o=i=>+lt(e[i],t)}for(n=t,r=t+i;n<r;++n)s._parsed[n]=o(n)}}_getRotation(){return At(this.options.rotation-90)}_getCircumference(){return At(this.options.circumference)}_getRotationExtents(){let t=gt,i=-gt;for(let e=0;e<this.chart.data.datasets.length;++e)if(this.chart.isDatasetVisible(e)&&this.chart.getDatasetMeta(e).type===this._type){const s=this.chart.getDatasetMeta(e).controller,n=s._getRotation(),r=s._getCircumference();t=Math.min(t,n),i=Math.max(i,n+r)}return{rotation:t,circumference:i-t}}update(t){const i=this.chart,{chartArea:e}=i,s=this._cachedMeta,n=s.data,r=this.getMaxBorderWidth()+this.getMaxOffset(n)+this.options.spacing,o=Math.max((Math.min(e.width,e.height)-r)/2,0),h=Math.min((c=o,"string"==typeof(a=this.options.cutout)&&a.endsWith("%")?parseFloat(a)/100:+a/c),1);var a,c;const l=this._getRingWeight(this.index),{circumference:u,rotation:f}=this._getRotationExtents(),{ratioX:d,ratioY:b,offsetX:p,offsetY:g}=function(t,i,e){let s=1,n=1,r=0,o=0;if(i<gt){const h=t,a=h+i,c=Math.cos(h),l=Math.sin(h),u=Math.cos(a),f=Math.sin(a),d=(t,i,s)=>Ct(t,h,a,!0)?1:Math.max(i,i*e,s,s*e),b=(t,i,s)=>Ct(t,h,a,!0)?-1:Math.min(i,i*e,s,s*e),p=d(0,c,u),g=d(xt,l,f),m=b(pt,c,u),v=b(pt+xt,l,f);s=(p-m)/2,n=(g-v)/2,r=-(p+m)/2,o=-(g+v)/2}return{ratioX:s,ratioY:n,offsetX:r,offsetY:o}}(f,u,h),m=Math.max(Math.min((e.width-r)/d,(e.height-r)/b)/2,0),v=J(this.options.radius,m),x=(v-Math.max(v*h,0))/this._getVisibleDatasetWeightTotal();this.offsetX=p*v,this.offsetY=g*v,s.total=this.calculateTotal(),this.outerRadius=v-x*this._getRingWeightOffset(this.index),this.innerRadius=Math.max(this.outerRadius-x*l,0),this.updateElements(n,0,n.length,t)}_circumference(t,i){const e=this.options,s=this._cachedMeta,n=this._getCircumference();return i&&e.animation.animateRotate||!this.chart.getDataVisibility(t)||null===s._parsed[t]||s.data[t].hidden?0:this.calculateCircumference(s._parsed[t]*n/gt)}updateElements(t,i,e,s){const n="reset"===s,r=this.chart,o=r.chartArea,h=(o.left+o.right)/2,a=(o.top+o.bottom)/2,c=n&&r.options.animation.animateScale,l=c?0:this.innerRadius,u=c?0:this.outerRadius,{sharedOptions:f,includeOptions:d}=this._getSharedOptions(i,s);let b,p=this._getRotation();for(b=0;b<i;++b)p+=this._circumference(b,n);for(b=i;b<i+e;++b){const i=this._circumference(b,n),e=t[b],r={x:h+this.offsetX,y:a+this.offsetY,startAngle:p,endAngle:p+i,circumference:i,outerRadius:u,innerRadius:l};d&&(r.options=f||this.resolveDataElementOptions(b,e.active?"active":s)),p+=i,this.updateElement(e,b,r,s)}}calculateTotal(){const t=this._cachedMeta,i=t.data;let e,s=0;for(e=0;e<i.length;e++){const n=t._parsed[e];null===n||isNaN(n)||!this.chart.getDataVisibility(e)||i[e].hidden||(s+=Math.abs(n))}return s}calculateCircumference(t){const i=this._cachedMeta.total;return i>0&&!isNaN(t)?gt*(Math.abs(t)/i):0}getLabelAndValue(t){const i=this.chart,e=i.data.labels||[],s=Gt(this._cachedMeta._parsed[t],i.options.locale);return{label:e[t]||"",value:s}}getMaxBorderWidth(t){let i=0;const e=this.chart;let s,n,r,o,h;if(!t)for(s=0,n=e.data.datasets.length;s<n;++s)if(e.isDatasetVisible(s)){r=e.getDatasetMeta(s),t=r.data,o=r.controller;break}if(!t)return 0;for(s=0,n=t.length;s<n;++s)h=o.resolveDataElementOptions(s),"inner"!==h.borderAlign&&(i=Math.max(i,h.borderWidth||0,h.hoverBorderWidth||0));return i}getMaxOffset(t){let i=0;for(let e=0,s=t.length;e<s;++e){const t=this.resolveDataElementOptions(e);i=Math.max(i,t.offset||0,t.hoverOffset||0)}return i}_getRingWeightOffset(t){let i=0;for(let e=0;e<t;++e)this.chart.isDatasetVisible(e)&&(i+=this._getRingWeight(e));return i}_getRingWeight(t){return Math.max(G(this.chart.data.datasets[t].weight,1),0)}_getVisibleDatasetWeightTotal(){return this._getRingWeightOffset(this.chart.data.datasets.length)||1}}class je extends ye{static id="polarArea";static defaults={dataElementType:"arc",animation:{animateRotate:!0,animateScale:!0},animations:{numbers:{type:"number",properties:["x","y","startAngle","endAngle","innerRadius","outerRadius"]}},indexAxis:"r",startAngle:0};static overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(t){const i=t.data;if(i.labels.length&&i.datasets.length){const{labels:{pointStyle:e,color:s}}=t.legend.options;return i.labels.map(((i,n)=>{const r=t.getDatasetMeta(0).controller.getStyle(n);return{text:i,fillStyle:r.backgroundColor,strokeStyle:r.borderColor,fontColor:s,lineWidth:r.borderWidth,pointStyle:e,hidden:!t.getDataVisibility(n),index:n}}))}return[]}},onClick(t,i,e){e.chart.toggleDataVisibility(i.index),e.chart.update()}}},scales:{r:{type:"radialLinear",angleLines:{display:!1},beginAtZero:!0,grid:{circular:!0},pointLabels:{display:!1},startAngle:0}}};constructor(t,i){super(t,i),this.innerRadius=void 0,this.outerRadius=void 0}getLabelAndValue(t){const i=this.chart,e=i.data.labels||[],s=Gt(this._cachedMeta._parsed[t].r,i.options.locale);return{label:e[t]||"",value:s}}parseObjectData(t,i,e,s){return zi.bind(this)(t,i,e,s)}update(t){const i=this._cachedMeta.data;this._updateRadius(),this.updateElements(i,0,i.length,t)}getMinMax(){const t={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY};return this._cachedMeta.data.forEach(((i,e)=>{const s=this.getParsed(e).r;!isNaN(s)&&this.chart.getDataVisibility(e)&&(s<t.min&&(t.min=s),s>t.max&&(t.max=s))})),t}_updateRadius(){const t=this.chart,i=t.chartArea,e=t.options,s=Math.min(i.right-i.left,i.bottom-i.top),n=Math.max(s/2,0),r=(n-Math.max(e.cutoutPercentage?n/100*e.cutoutPercentage:1,0))/t.getVisibleDatasetCount();this.outerRadius=n-r*this.index,this.innerRadius=this.outerRadius-r}updateElements(t,i,e,s){const n="reset"===s,r=this.chart,o=r.options.animation,h=this._cachedMeta.rScale,a=h.xCenter,c=h.yCenter,l=h.getIndexAngle(0)-.5*pt;let u,f=l;const d=360/this.countVisibleElements();for(u=0;u<i;++u)f+=this._computeAngle(u,s,d);for(u=i;u<i+e;u++){const i=t[u];let e=f,b=f+this._computeAngle(u,s,d),p=r.getDataVisibility(u)?h.getDistanceFromCenterForValue(this.getParsed(u).r):0;f=b,n&&(o.animateScale&&(p=0),o.animateRotate&&(e=b=l));const g={x:a,y:c,innerRadius:0,outerRadius:p,startAngle:e,endAngle:b,options:this.resolveDataElementOptions(u,i.active?"active":s)};this.updateElement(i,u,g,s)}}countVisibleElements(){let t=0;return this._cachedMeta.data.forEach(((i,e)=>{!isNaN(this.getParsed(e).r)&&this.chart.getDataVisibility(e)&&t++})),t}_computeAngle(t,i,e){return this.chart.getDataVisibility(t)?At(this.resolveDataElementOptions(t,i).angle||e):0}}function Ce(t,i,e,s){const{controller:n,data:r,_sorted:o}=t,h=n._cachedMeta.iScale,a=t.dataset&&t.dataset.options?t.dataset.options.spanGaps:null;if(h&&i===h.axis&&"r"!==i&&o&&r.length){const o=h._reversePixels?Tt:Pt;if(!s){const s=o(r,i,e);if(a){const{vScale:i}=n._cachedMeta,{_parsed:e}=t,r=e.slice(0,s.lo+1).reverse().findIndex((t=>!U(t[i.axis])));s.lo-=Math.max(0,r);const o=e.slice(s.hi).findIndex((t=>!U(t[i.axis])));s.hi+=Math.max(0,o)}return s}if(n._sharedOptions){const t=r[0],s="function"==typeof t.getRange&&t.getRange(i);if(s){const t=o(r,i,e-s),n=o(r,i,e+s);return{lo:t.lo,hi:n.hi}}}}return{lo:0,hi:r.length-1}}function Re(t,i,e,s,n){const r=t.getSortedVisibleDatasetMetas(),o=e[i];for(let t=0,e=r.length;t<e;++t){const{index:e,data:h}=r[t],{lo:a,hi:c}=Ce(r[t],i,o,n);for(let t=a;t<=c;++t){const i=h[t];i.skip||s(i,e,t)}}}function Ee(t,i,e,s,n){const r=[];return n||t.isPointInArea(i)?(Re(t,e,i,(function(e,o,h){(n||ui(e,t.chartArea,0))&&e.inRange(i.x,i.y,s)&&r.push({element:e,datasetIndex:o,index:h})}),!0),r):r}function Le(t,i,e,s,n,r){return r||t.isPointInArea(i)?"r"!==e||s?function(t,i,e,s,n,r){let o=[];const h=function(t){const i=-1!==t.indexOf("x"),e=-1!==t.indexOf("y");return function(t,s){const n=i?Math.abs(t.x-s.x):0,r=e?Math.abs(t.y-s.y):0;return Math.sqrt(Math.pow(n,2)+Math.pow(r,2))}}(e);let a=Number.POSITIVE_INFINITY;return Re(t,e,i,(function(e,c,l){const u=e.inRange(i.x,i.y,n);if(s&&!u)return;const f=e.getCenterPoint(n);if(!r&&!t.isPointInArea(f)&&!u)return;const d=h(i,f);d<a?(o=[{element:e,datasetIndex:c,index:l}],a=d):d===a&&o.push({element:e,datasetIndex:c,index:l})})),o}(t,i,e,s,n,r):function(t,i,e,s){let n=[];return Re(t,e,i,(function(t,e,r){const{startAngle:o,endAngle:h}=t.getProps(["startAngle","endAngle"],s),{angle:a}=function(t,i){const e=i.x-t.x,s=i.y-t.y,n=Math.sqrt(e*e+s*s);let r=Math.atan2(s,e);return r<-.5*pt&&(r+=gt),{angle:r,distance:n}}(t,{x:i.x,y:i.y});Ct(a,o,h)&&n.push({element:t,datasetIndex:e,index:r})})),n}(t,i,e,n):[]}function Pe(t,i,e,s,n){const r=[],o="x"===e?"inXRange":"inYRange";let h=!1;return Re(t,e,i,((t,s,a)=>{t[o]&&t[o](i[e],n)&&(r.push({element:t,datasetIndex:s,index:a}),h=h||t.inRange(i.x,i.y,n))})),s&&!h?[]:r}var Te={modes:{index(t,i,e,s){const n=Zi(i,t),r=e.axis||"x",o=e.includeInvisible||!1,h=e.intersect?Ee(t,n,r,s,o):Le(t,n,r,!1,s,o),a=[];return h.length?(t.getSortedVisibleDatasetMetas().forEach((t=>{const i=h[0].index,e=t.data[i];e&&!e.skip&&a.push({element:e,datasetIndex:t.index,index:i})})),a):[]},dataset(t,i,e,s){const n=Zi(i,t),r=e.axis||"xy",o=e.includeInvisible||!1;let h=e.intersect?Ee(t,n,r,s,o):Le(t,n,r,!1,s,o);if(h.length>0){const i=h[0].datasetIndex,e=t.getDatasetMeta(i).data;h=[];for(let t=0;t<e.length;++t)h.push({element:e[t],datasetIndex:i,index:t})}return h},point:(t,i,e,s)=>Ee(t,Zi(i,t),e.axis||"xy",s,e.includeInvisible||!1),nearest:(t,i,e,s)=>Le(t,Zi(i,t),e.axis||"xy",e.intersect,s,e.includeInvisible||!1),x:(t,i,e,s)=>Pe(t,Zi(i,t),"x",e.intersect,s),y:(t,i,e,s)=>Pe(t,Zi(i,t),"y",e.intersect,s)}};const Ie=["left","top","right","bottom"];function Fe(t,i){return t.filter((t=>t.pos===i))}function Be(t,i){return t.filter((t=>-1===Ie.indexOf(t.pos)&&t.box.axis===i))}function We(t,i){return t.sort(((t,e)=>{const s=i?e:t,n=i?t:e;return s.weight===n.weight?s.index-n.index:s.weight-n.weight}))}function Ne(t,i,e,s){return Math.max(t[e],i[e])+Math.max(t[s],i[s])}function ze(t,i){t.top=Math.max(t.top,i.top),t.left=Math.max(t.left,i.left),t.bottom=Math.max(t.bottom,i.bottom),t.right=Math.max(t.right,i.right)}function He(t,i,e,s){const{pos:n,box:r}=e,o=t.maxPadding;if(!K(n)){e.size&&(t[n]-=e.size);const i=s[e.stack]||{size:0,count:1};i.size=Math.max(i.size,e.horizontal?r.height:r.width),e.size=i.size/i.count,t[n]+=e.size}r.getPadding&&ze(o,r.getPadding());const h=Math.max(0,i.outerWidth-Ne(o,t,"left","right")),a=Math.max(0,i.outerHeight-Ne(o,t,"top","bottom")),c=h!==t.w,l=a!==t.h;return t.w=h,t.h=a,e.horizontal?{same:c,other:l}:{same:l,other:c}}function $e(t,i){const e=i.maxPadding;return function(t){const s={left:0,top:0,right:0,bottom:0};return t.forEach((t=>{s[t]=Math.max(i[t],e[t])})),s}(t?["left","right"]:["top","bottom"])}function Ye(t,i,e,s){const n=[];let r,o,h,a,c,l;for(r=0,o=t.length,c=0;r<o;++r){h=t[r],a=h.box,a.update(h.width||i.w,h.height||i.h,$e(h.horizontal,i));const{same:o,other:u}=He(i,e,h,s);c|=o&&n.length,l=l||u,a.fullSize||n.push(h)}return c&&Ye(n,i,e,s)||l}function Ve(t,i,e,s,n){t.top=e,t.left=i,t.right=i+s,t.bottom=e+n,t.width=s,t.height=n}function Xe(t,i,e,s){const n=e.padding;let{x:r,y:o}=i;for(const h of t){const t=h.box,a=s[h.stack]||{placed:0,weight:1},c=h.stackWeight/a.weight||1;if(h.horizontal){const s=i.w*c,r=a.size||t.height;ft(a.start)&&(o=a.start),t.fullSize?Ve(t,n.left,o,e.outerWidth-n.right-n.left,r):Ve(t,i.left+a.placed,o,s,r),a.start=o,a.placed+=s,o=t.bottom}else{const s=i.h*c,o=a.size||t.width;ft(a.start)&&(r=a.start),t.fullSize?Ve(t,r,n.top,o,e.outerHeight-n.bottom-n.top):Ve(t,r,i.top+a.placed,o,s),a.start=r,a.placed+=s,r=t.right}}i.x=r,i.y=o}var Ue={addBox(t,i){t.boxes||(t.boxes=[]),i.fullSize=i.fullSize||!1,i.position=i.position||"top",i.weight=i.weight||0,i._layers=i._layers||function(){return[{z:0,draw(t){i.draw(t)}}]},t.boxes.push(i)},removeBox(t,i){const e=t.boxes?t.boxes.indexOf(i):-1;-1!==e&&t.boxes.splice(e,1)},configure(t,i,e){i.fullSize=e.fullSize,i.position=e.position,i.weight=e.weight},update(t,i,e,s){if(!t)return;const n=ki(t.options.layout.padding),r=Math.max(i-n.width,0),o=Math.max(e-n.height,0),h=function(t){const i=function(t){const i=[];let e,s,n,r,o,h;for(e=0,s=(t||[]).length;e<s;++e)n=t[e],({position:r,options:{stack:o,stackWeight:h=1}}=n),i.push({index:e,box:n,pos:r,horizontal:n.isHorizontal(),weight:n.weight,stack:o&&r+o,stackWeight:h});return i}(t),e=We(i.filter((t=>t.box.fullSize)),!0),s=We(Fe(i,"left"),!0),n=We(Fe(i,"right")),r=We(Fe(i,"top"),!0),o=We(Fe(i,"bottom")),h=Be(i,"x"),a=Be(i,"y");return{fullSize:e,leftAndTop:s.concat(r),rightAndBottom:n.concat(a).concat(o).concat(h),chartArea:Fe(i,"chartArea"),vertical:s.concat(n).concat(a),horizontal:r.concat(o).concat(h)}}(t.boxes),a=h.vertical,c=h.horizontal;it(t.boxes,(t=>{"function"==typeof t.beforeLayout&&t.beforeLayout()}));const l=a.reduce(((t,i)=>i.box.options&&!1===i.box.options.display?t:t+1),0)||1,u=Object.freeze({outerWidth:i,outerHeight:e,padding:n,availableWidth:r,availableHeight:o,vBoxMaxWidth:r/2/l,hBoxMaxHeight:o/2}),f=Object.assign({},n);ze(f,ki(s));const d=Object.assign({maxPadding:f,w:r,h:o,x:n.left,y:n.top},n),b=function(t,i){const e=function(t){const i={};for(const e of t){const{stack:t,pos:s,stackWeight:n}=e;if(!t||!Ie.includes(s))continue;const r=i[t]||(i[t]={count:0,placed:0,weight:0,size:0});r.count++,r.weight+=n}return i}(t),{vBoxMaxWidth:s,hBoxMaxHeight:n}=i;let r,o,h;for(r=0,o=t.length;r<o;++r){h=t[r];const{fullSize:o}=h.box,a=e[h.stack],c=a&&h.stackWeight/a.weight;h.horizontal?(h.width=c?c*s:o&&i.availableWidth,h.height=n):(h.width=s,h.height=c?c*n:o&&i.availableHeight)}return e}(a.concat(c),u);Ye(h.fullSize,d,u,b),Ye(a,d,u,b),Ye(c,d,u,b)&&Ye(a,d,u,b),function(t){const i=t.maxPadding;function e(e){const s=Math.max(i[e]-t[e],0);return t[e]+=s,s}t.y+=e("top"),t.x+=e("left"),e("right"),e("bottom")}(d),Xe(h.leftAndTop,d,u,b),d.x+=d.w,d.y+=d.h,Xe(h.rightAndBottom,d,u,b),t.chartArea={left:d.left,top:d.top,right:d.left+d.w,bottom:d.top+d.h,height:d.h,width:d.w},it(h.chartArea,(i=>{const e=i.box;Object.assign(e,t.chartArea),e.update(d.w,d.h,{left:0,top:0,right:0,bottom:0})}))}};class Ze{acquireContext(t,i){}releaseContext(t){return!1}addEventListener(t,i,e){}removeEventListener(t,i,e){}getDevicePixelRatio(){return 1}getMaximumSize(t,i,e,s){return i=Math.max(0,i||t.width),e=e||t.height,{width:i,height:Math.max(0,s?Math.floor(i/s):e)}}isAttached(t){return!0}updateConfig(t){}}class Ke extends Ze{acquireContext(t){return t&&t.getContext&&t.getContext("2d")||null}updateConfig(t){t.options.animation=!1}}const Qe="$chartjs",qe={touchstart:"mousedown",touchmove:"mousemove",touchend:"mouseup",pointerenter:"mouseenter",pointerdown:"mousedown",pointermove:"mousemove",pointerup:"mouseup",pointerleave:"mouseout",pointerout:"mouseout"},Ge=t=>null===t||""===t,Je=!!qi&&{passive:!0};function ts(t,i,e){t&&t.canvas&&t.canvas.removeEventListener(i,e,Je)}function is(t,i){for(const e of t)if(e===i||e.contains(i))return!0}function es(t,i,e){const s=t.canvas,n=new MutationObserver((t=>{let i=!1;for(const e of t)i=i||is(e.addedNodes,s),i=i&&!is(e.removedNodes,s);i&&e()}));return n.observe(document,{childList:!0,subtree:!0}),n}function ss(t,i,e){const s=t.canvas,n=new MutationObserver((t=>{let i=!1;for(const e of t)i=i||is(e.removedNodes,s),i=i&&!is(e.addedNodes,s);i&&e()}));return n.observe(document,{childList:!0,subtree:!0}),n}const ns=new Map;let rs=0;function os(){const t=window.devicePixelRatio;t!==rs&&(rs=t,ns.forEach(((i,e)=>{e.currentDevicePixelRatio!==t&&i()})))}function hs(t,i,e){const s=t.canvas,n=s&&$i(s);if(!n)return;const r=Wt(((t,i)=>{const s=n.clientWidth;e(t,i),s<n.clientWidth&&e()}),window),o=new ResizeObserver((t=>{const i=t[0],e=i.contentRect.width,s=i.contentRect.height;0===e&&0===s||r(e,s)}));return o.observe(n),function(t,i){ns.size||window.addEventListener("resize",os),ns.set(t,i)}(t,r),o}function as(t,i,e){e&&e.disconnect(),"resize"===i&&function(t){ns.delete(t),ns.size||window.removeEventListener("resize",os)}(t)}function cs(t,i,e){const s=t.canvas,n=Wt((i=>{null!==t.ctx&&e(function(t,i){const e=qe[t.type]||t.type,{x:s,y:n}=Zi(t,i);return{type:e,chart:i,native:t,x:void 0!==s?s:null,y:void 0!==n?n:null}}(i,t))}),t);return function(t,i,e){t&&t.addEventListener(i,e,Je)}(s,i,n),n}class ls extends Ze{acquireContext(t,i){const e=t&&t.getContext&&t.getContext("2d");return e&&e.canvas===t?(function(t,i){const e=t.style,s=t.getAttribute("height"),n=t.getAttribute("width");if(t[Qe]={initial:{height:s,width:n,style:{display:e.display,height:e.height,width:e.width}}},e.display=e.display||"block",e.boxSizing=e.boxSizing||"border-box",Ge(n)){const i=Gi(t,"width");void 0!==i&&(t.width=i)}if(Ge(s))if(""===t.style.height)t.height=t.width/(i||2);else{const i=Gi(t,"height");void 0!==i&&(t.height=i)}}(t,i),e):null}releaseContext(t){const i=t.canvas;if(!i[Qe])return!1;const e=i[Qe].initial;["height","width"].forEach((t=>{const s=e[t];U(s)?i.removeAttribute(t):i.setAttribute(t,s)}));const s=e.style||{};return Object.keys(s).forEach((t=>{i.style[t]=s[t]})),i.width=i.width,delete i[Qe],!0}addEventListener(t,i,e){this.removeEventListener(t,i),(t.$proxies||(t.$proxies={}))[i]=({attach:es,detach:ss,resize:hs}[i]||cs)(t,i,e)}removeEventListener(t,i){const e=t.$proxies||(t.$proxies={}),s=e[i];s&&(({attach:as,detach:as,resize:as}[i]||ts)(t,i,s),e[i]=void 0)}getDevicePixelRatio(){return window.devicePixelRatio}getMaximumSize(t,i,e,s){return function(t,i,e,s){const n=Vi(t),r=Ui(n,"margin"),o=Yi(n.maxWidth,t,"clientWidth")||mt,h=Yi(n.maxHeight,t,"clientHeight")||mt,a=function(t,i,e){let s,n;if(void 0===i||void 0===e){const r=t&&$i(t);if(r){const t=r.getBoundingClientRect(),o=Vi(r),h=Ui(o,"border","width"),a=Ui(o,"padding");i=t.width-a.width-h.width,e=t.height-a.height-h.height,s=Yi(o.maxWidth,r,"clientWidth"),n=Yi(o.maxHeight,r,"clientHeight")}else i=t.clientWidth,e=t.clientHeight}return{width:i,height:e,maxWidth:s||mt,maxHeight:n||mt}}(t,i,e);let{width:c,height:l}=a;if("content-box"===n.boxSizing){const t=Ui(n,"border","width"),i=Ui(n,"padding");c-=i.width+t.width,l-=i.height+t.height}return c=Math.max(0,c-r.width),l=Math.max(0,s?c/s:l-r.height),c=Ki(Math.min(c,o,a.maxWidth)),l=Ki(Math.min(l,h,a.maxHeight)),c&&!l&&(l=Ki(c/2)),(void 0!==i||void 0!==e)&&s&&a.height&&l>a.height&&(l=a.height,c=Ki(Math.floor(l*s))),{width:c,height:l}}(t,i,e,s)}isAttached(t){const i=t&&$i(t);return!(!i||!i.isConnected)}}class us{static defaults={};static defaultRoutes=void 0;x;y;active=!1;options;$animations;tooltipPosition(t){const{x:i,y:e}=this.getProps(["x","y"],t);return{x:i,y:e}}hasValue(){return St(this.x)&&St(this.y)}getProps(t,i){const e=this.$animations;if(!i||!e)return this;const s={};return t.forEach((t=>{s[t]=e[t]&&e[t].active()?e[t]._to:this[t]})),s}}function fs(t,i,e,s,n){const r=G(s,0),o=Math.min(G(n,t.length),t.length);let h,a,c,l=0;for(e=Math.ceil(e),n&&(h=n-s,e=h/Math.floor(h/e)),c=r;c<0;)l++,c=Math.round(r+l*e);for(a=Math.max(r,0);a<o;a++)a===c&&(i.push(t[a]),l++,c=Math.round(r+l*e))}const ds=(t,i,e)=>"top"===i||"left"===i?t[i]+e:t[i]-e,bs=(t,i)=>Math.min(i||t,t);function ps(t,i){const e=[],s=t.length/i,n=t.length;let r=0;for(;r<n;r+=s)e.push(t[Math.floor(r)]);return e}function gs(t,i,e){const s=t.ticks.length,n=Math.min(i,s-1),r=t._startPixel,o=t._endPixel,h=1e-6;let a,c=t.getPixelForTick(n);if(!(e&&(a=1===s?Math.max(c-r,o-c):0===i?(t.getPixelForTick(1)-c)/2:(c-t.getPixelForTick(n-1))/2,c+=n<i?a:-a,c<r-h||c>o+h)))return c}function ms(t){return t.drawTicks?t.tickLength:0}function vs(t,i){if(!t.display)return 0;const e=Oi(t.font,i),s=ki(t.padding);return(Z(t.text)?t.text.length:1)*e.lineHeight+s.height}function xs(t,i,e){let s=Nt(t);return(e&&"right"!==i||!e&&"right"===i)&&(s=(t=>"left"===t?"right":"right"===t?"left":t)(s)),s}class ys extends us{constructor(t){super(),this.id=t.id,this.type=t.type,this.options=void 0,this.ctx=t.ctx,this.chart=t.chart,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this._margins={left:0,right:0,top:0,bottom:0},this.maxWidth=void 0,this.maxHeight=void 0,this.paddingTop=void 0,this.paddingBottom=void 0,this.paddingLeft=void 0,this.paddingRight=void 0,this.axis=void 0,this.labelRotation=void 0,this.min=void 0,this.max=void 0,this._range=void 0,this.ticks=[],this._gridLineItems=null,this._labelItems=null,this._labelSizes=null,this._length=0,this._maxLength=0,this._longestTextCache={},this._startPixel=void 0,this._endPixel=void 0,this._reversePixels=!1,this._userMax=void 0,this._userMin=void 0,this._suggestedMax=void 0,this._suggestedMin=void 0,this._ticksLength=0,this._borderValue=0,this._cache={},this._dataLimitsCached=!1,this.$context=void 0}init(t){this.options=t.setContext(this.getContext()),this.axis=t.axis,this._userMin=this.parse(t.min),this._userMax=this.parse(t.max),this._suggestedMin=this.parse(t.suggestedMin),this._suggestedMax=this.parse(t.suggestedMax)}parse(t,i){return t}getUserBounds(){let{_userMin:t,_userMax:i,_suggestedMin:e,_suggestedMax:s}=this;return t=q(t,Number.POSITIVE_INFINITY),i=q(i,Number.NEGATIVE_INFINITY),e=q(e,Number.POSITIVE_INFINITY),s=q(s,Number.NEGATIVE_INFINITY),{min:q(t,e),max:q(i,s),minDefined:Q(t),maxDefined:Q(i)}}getMinMax(t){let i,{min:e,max:s,minDefined:n,maxDefined:r}=this.getUserBounds();if(n&&r)return{min:e,max:s};const o=this.getMatchingVisibleMetas();for(let h=0,a=o.length;h<a;++h)i=o[h].controller.getMinMax(this,t),n||(e=Math.min(e,i.min)),r||(s=Math.max(s,i.max));return e=r&&e>s?s:e,s=n&&e>s?e:s,{min:q(e,q(s,e)),max:q(s,q(e,s))}}getPadding(){return{left:this.paddingLeft||0,top:this.paddingTop||0,right:this.paddingRight||0,bottom:this.paddingBottom||0}}getTicks(){return this.ticks}getLabels(){const t=this.chart.data;return this.options.labels||(this.isHorizontal()?t.xLabels:t.yLabels)||t.labels||[]}getLabelItems(t=this.chart.chartArea){return this._labelItems||(this._labelItems=this._computeLabelItems(t))}beforeLayout(){this._cache={},this._dataLimitsCached=!1}beforeUpdate(){tt(this.options.beforeUpdate,[this])}update(t,i,e){const{beginAtZero:s,grace:n,ticks:r}=this.options,o=r.sampleSize;this.beforeUpdate(),this.maxWidth=t,this.maxHeight=i,this._margins=e=Object.assign({left:0,right:0,top:0,bottom:0},e),this.ticks=null,this._labelSizes=null,this._gridLineItems=null,this._labelItems=null,this.beforeSetDimensions(),this.setDimensions(),this.afterSetDimensions(),this._maxLength=this.isHorizontal()?this.width+e.left+e.right:this.height+e.top+e.bottom,this._dataLimitsCached||(this.beforeDataLimits(),this.determineDataLimits(),this.afterDataLimits(),this._range=function(t,i,e){const{min:s,max:n}=t,r=J(i,(n-s)/2),o=(t,i)=>e&&0===t?0:t+i;return{min:o(s,-Math.abs(r)),max:o(n,r)}}(this,n,s),this._dataLimitsCached=!0),this.beforeBuildTicks(),this.ticks=this.buildTicks()||[],this.afterBuildTicks();const h=o<this.ticks.length;this._convertTicksToLabels(h?ps(this.ticks,o):this.ticks),this.configure(),this.beforeCalculateLabelRotation(),this.calculateLabelRotation(),this.afterCalculateLabelRotation(),r.display&&(r.autoSkip||"auto"===r.source)&&(this.ticks=function(t,i){const e=t.options.ticks,s=function(t){const i=t.options.offset,e=t._tickSize();return Math.floor(Math.min(t._length/e+(i?0:1),t._maxLength/e))}(t),n=Math.min(e.maxTicksLimit||s,s),r=e.major.enabled?function(t){const i=[];let e,s;for(e=0,s=t.length;e<s;e++)t[e].major&&i.push(e);return i}(i):[],o=r.length,h=r[0],a=r[o-1],c=[];if(o>n)return function(t,i,e,s){let n,r=0,o=e[0];for(s=Math.ceil(s),n=0;n<t.length;n++)n===o&&(i.push(t[n]),r++,o=e[r*s])}(i,c,r,o/n),c;const l=function(t,i,e){const s=function(t){const i=t.length;let e,s;if(i<2)return!1;for(s=t[0],e=1;e<i;++e)if(t[e]-t[e-1]!==s)return!1;return s}(t),n=i.length/e;if(!s)return Math.max(n,1);const r=function(t){const i=[],e=Math.sqrt(t);let s;for(s=1;s<e;s++)t%s==0&&(i.push(s),i.push(t/s));return e===(0|e)&&i.push(e),i.sort(((t,i)=>t-i)).pop(),i}(s);for(let t=0,i=r.length-1;t<i;t++){const i=r[t];if(i>n)return i}return Math.max(n,1)}(r,i,n);if(o>0){let t,e;const s=o>1?Math.round((a-h)/(o-1)):null;for(fs(i,c,l,U(s)?0:h-s,h),t=0,e=o-1;t<e;t++)fs(i,c,l,r[t],r[t+1]);return fs(i,c,l,a,U(s)?i.length:a+s),c}return fs(i,c,l),c}(this,this.ticks),this._labelSizes=null,this.afterAutoSkip()),h&&this._convertTicksToLabels(this.ticks),this.beforeFit(),this.fit(),this.afterFit(),this.afterUpdate()}configure(){let t,i,e=this.options.reverse;this.isHorizontal()?(t=this.left,i=this.right):(t=this.top,i=this.bottom,e=!e),this._startPixel=t,this._endPixel=i,this._reversePixels=e,this._length=i-t,this._alignToPixels=this.options.alignToPixels}afterUpdate(){tt(this.options.afterUpdate,[this])}beforeSetDimensions(){tt(this.options.beforeSetDimensions,[this])}setDimensions(){this.isHorizontal()?(this.width=this.maxWidth,this.left=0,this.right=this.width):(this.height=this.maxHeight,this.top=0,this.bottom=this.height),this.paddingLeft=0,this.paddingTop=0,this.paddingRight=0,this.paddingBottom=0}afterSetDimensions(){tt(this.options.afterSetDimensions,[this])}_callHooks(t){this.chart.notifyPlugins(t,this.getContext()),tt(this.options[t],[this])}beforeDataLimits(){this._callHooks("beforeDataLimits")}determineDataLimits(){}afterDataLimits(){this._callHooks("afterDataLimits")}beforeBuildTicks(){this._callHooks("beforeBuildTicks")}buildTicks(){return[]}afterBuildTicks(){this._callHooks("afterBuildTicks")}beforeTickToLabelConversion(){tt(this.options.beforeTickToLabelConversion,[this])}generateTickLabels(t){const i=this.options.ticks;let e,s,n;for(e=0,s=t.length;e<s;e++)n=t[e],n.label=tt(i.callback,[n.value,e,t],this)}afterTickToLabelConversion(){tt(this.options.afterTickToLabelConversion,[this])}beforeCalculateLabelRotation(){tt(this.options.beforeCalculateLabelRotation,[this])}calculateLabelRotation(){const t=this.options,i=t.ticks,e=bs(this.ticks.length,t.ticks.maxTicksLimit),s=i.minRotation||0,n=i.maxRotation;let r,o,h,a=s;if(!this._isVisible()||!i.display||s>=n||e<=1||!this.isHorizontal())return void(this.labelRotation=s);const c=this._getLabelSizes(),l=c.widest.width,u=c.highest.height,f=Rt(this.chart.width-l,0,this.maxWidth);r=t.offset?this.maxWidth/e:f/(e-1),l+6>r&&(r=f/(e-(t.offset?.5:1)),o=this.maxHeight-ms(t.grid)-i.padding-vs(t.title,this.chart.options.font),h=Math.sqrt(l*l+u*u),a=Math.min(Math.asin(Rt((c.highest.height+6)/r,-1,1)),Math.asin(Rt(o/h,-1,1))-Math.asin(Rt(u/h,-1,1)))*(180/pt),a=Math.max(s,Math.min(n,a))),this.labelRotation=a}afterCalculateLabelRotation(){tt(this.options.afterCalculateLabelRotation,[this])}afterAutoSkip(){}beforeFit(){tt(this.options.beforeFit,[this])}fit(){const t={width:0,height:0},{chart:i,options:{ticks:e,title:s,grid:n}}=this,r=this._isVisible(),o=this.isHorizontal();if(r){const r=vs(s,i.options.font);if(o?(t.width=this.maxWidth,t.height=ms(n)+r):(t.height=this.maxHeight,t.width=ms(n)+r),e.display&&this.ticks.length){const{first:i,last:s,widest:n,highest:r}=this._getLabelSizes(),h=2*e.padding,a=At(this.labelRotation),c=Math.cos(a),l=Math.sin(a);o?t.height=Math.min(this.maxHeight,t.height+(e.mirror?0:l*n.width+c*r.height)+h):t.width=Math.min(this.maxWidth,t.width+(e.mirror?0:c*n.width+l*r.height)+h),this._calculatePadding(i,s,l,c)}}this._handleMargins(),o?(this.width=this._length=i.width-this._margins.left-this._margins.right,this.height=t.height):(this.width=t.width,this.height=this._length=i.height-this._margins.top-this._margins.bottom)}_calculatePadding(t,i,e,s){const{ticks:{align:n,padding:r},position:o}=this.options,h=0!==this.labelRotation,a="top"!==o&&"x"===this.axis;if(this.isHorizontal()){const o=this.getPixelForTick(0)-this.left,c=this.right-this.getPixelForTick(this.ticks.length-1);let l=0,u=0;h?a?(l=s*t.width,u=e*i.height):(l=e*t.height,u=s*i.width):"start"===n?u=i.width:"end"===n?l=t.width:"inner"!==n&&(l=t.width/2,u=i.width/2),this.paddingLeft=Math.max((l-o+r)*this.width/(this.width-o),0),this.paddingRight=Math.max((u-c+r)*this.width/(this.width-c),0)}else{let e=i.height/2,s=t.height/2;"start"===n?(e=0,s=t.height):"end"===n&&(e=i.height,s=0),this.paddingTop=e+r,this.paddingBottom=s+r}}_handleMargins(){this._margins&&(this._margins.left=Math.max(this.paddingLeft,this._margins.left),this._margins.top=Math.max(this.paddingTop,this._margins.top),this._margins.right=Math.max(this.paddingRight,this._margins.right),this._margins.bottom=Math.max(this.paddingBottom,this._margins.bottom))}afterFit(){tt(this.options.afterFit,[this])}isHorizontal(){const{axis:t,position:i}=this.options;return"top"===i||"bottom"===i||"x"===t}isFullSize(){return this.options.fullSize}_convertTicksToLabels(t){let i,e;for(this.beforeTickToLabelConversion(),this.generateTickLabels(t),i=0,e=t.length;i<e;i++)U(t[i].label)&&(t.splice(i,1),e--,i--);this.afterTickToLabelConversion()}_getLabelSizes(){let t=this._labelSizes;if(!t){const i=this.options.ticks.sampleSize;let e=this.ticks;i<e.length&&(e=ps(e,i)),this._labelSizes=t=this._computeLabelSizes(e,e.length,this.options.ticks.maxTicksLimit)}return t}_computeLabelSizes(t,i,e){const{ctx:s,_longestTextCache:n}=this,r=[],o=[],h=Math.floor(i/bs(i,e));let a,c,l,u,f,d,b,p,g,m,v,x=0,y=0;for(a=0;a<i;a+=h){if(u=t[a].label,f=this._resolveTickFontOptions(a),s.font=d=f.string,b=n[d]=n[d]||{data:{},gc:[]},p=f.lineHeight,g=m=0,U(u)||Z(u)){if(Z(u))for(c=0,l=u.length;c<l;++c)v=u[c],U(v)||Z(v)||(g=oi(s,b.data,b.gc,g,v),m+=p)}else g=oi(s,b.data,b.gc,g,u),m=p;r.push(g),o.push(m),x=Math.max(g,x),y=Math.max(m,y)}!function(t,i){it(t,(t=>{const e=t.gc,s=e.length/2;let n;if(s>i){for(n=0;n<s;++n)delete t.data[e[n]];e.splice(0,s)}}))}(n,i);const M=r.indexOf(x),w=o.indexOf(y),_=t=>({width:r[t]||0,height:o[t]||0});return{first:_(0),last:_(i-1),widest:_(M),highest:_(w),widths:r,heights:o}}getLabelForValue(t){return t}getPixelForValue(t,i){return NaN}getValueForPixel(t){}getPixelForTick(t){const i=this.ticks;return t<0||t>i.length-1?null:this.getPixelForValue(i[t].value)}getPixelForDecimal(t){this._reversePixels&&(t=1-t);const i=this._startPixel+t*this._length;return Rt(this._alignToPixels?hi(this.chart,i,0):i,-32768,32767)}getDecimalForPixel(t){const i=(t-this._startPixel)/this._length;return this._reversePixels?1-i:i}getBasePixel(){return this.getPixelForValue(this.getBaseValue())}getBaseValue(){const{min:t,max:i}=this;return t<0&&i<0?i:t>0&&i>0?t:0}getContext(t){const i=this.ticks||[];if(t>=0&&t<i.length){const e=i[t];return e.$context||(e.$context=function(t,i,e){return Ai(t,{tick:e,index:i,type:"tick"})}(this.getContext(),t,e))}return this.$context||(this.$context=Ai(this.chart.getContext(),{scale:this,type:"scale"}))}_tickSize(){const t=this.options.ticks,i=At(this.labelRotation),e=Math.abs(Math.cos(i)),s=Math.abs(Math.sin(i)),n=this._getLabelSizes(),r=t.autoSkipPadding||0,o=n?n.widest.width+r:0,h=n?n.highest.height+r:0;return this.isHorizontal()?h*e>o*s?o/e:h/s:h*s<o*e?h/e:o/s}_isVisible(){const t=this.options.display;return"auto"!==t?!!t:this.getMatchingVisibleMetas().length>0}_computeGridLineItems(t){const i=this.axis,e=this.chart,s=this.options,{grid:n,position:r,border:o}=s,h=n.offset,a=this.isHorizontal(),c=this.ticks.length+(h?1:0),l=ms(n),u=[],f=o.setContext(this.getContext()),d=f.display?f.width:0,b=d/2,p=function(t){return hi(e,t,d)};let g,m,v,x,y,M,w,_,k,O,S,A;if("top"===r)g=p(this.bottom),M=this.bottom-l,_=g-b,O=p(t.top)+b,A=t.bottom;else if("bottom"===r)g=p(this.top),O=t.top,A=p(t.bottom)-b,M=g+b,_=this.top+l;else if("left"===r)g=p(this.right),y=this.right-l,w=g-b,k=p(t.left)+b,S=t.right;else if("right"===r)g=p(this.left),k=t.left,S=p(t.right)-b,y=g+b,w=this.left+l;else if("x"===i){if("center"===r)g=p((t.top+t.bottom)/2+.5);else if(K(r)){const t=Object.keys(r)[0];g=p(this.chart.scales[t].getPixelForValue(r[t]))}O=t.top,A=t.bottom,M=g+b,_=M+l}else if("y"===i){if("center"===r)g=p((t.left+t.right)/2);else if(K(r)){const t=Object.keys(r)[0];g=p(this.chart.scales[t].getPixelForValue(r[t]))}y=g-b,w=y-l,k=t.left,S=t.right}const D=G(s.ticks.maxTicksLimit,c),j=Math.max(1,Math.ceil(c/D));for(m=0;m<c;m+=j){const t=this.getContext(m),i=n.setContext(t),s=o.setContext(t),r=i.lineWidth,c=i.color,l=s.dash||[],f=s.dashOffset,d=i.tickWidth,b=i.tickColor,p=i.tickBorderDash||[],g=i.tickBorderDashOffset;v=gs(this,m,h),void 0!==v&&(x=hi(e,v,r),a?y=w=k=S=x:M=_=O=A=x,u.push({tx1:y,ty1:M,tx2:w,ty2:_,x1:k,y1:O,x2:S,y2:A,width:r,color:c,borderDash:l,borderDashOffset:f,tickWidth:d,tickColor:b,tickBorderDash:p,tickBorderDashOffset:g}))}return this._ticksLength=c,this._borderValue=g,u}_computeLabelItems(t){const i=this.axis,e=this.options,{position:s,ticks:n}=e,r=this.isHorizontal(),o=this.ticks,{align:h,crossAlign:a,padding:c,mirror:l}=n,u=ms(e.grid),f=u+c,d=l?-c:f,b=-At(this.labelRotation),p=[];let g,m,v,x,y,M,w,_,k,O,S,A,D="middle";if("top"===s)M=this.bottom-d,w=this._getXAxisLabelAlignment();else if("bottom"===s)M=this.top+d,w=this._getXAxisLabelAlignment();else if("left"===s){const t=this._getYAxisLabelAlignment(u);w=t.textAlign,y=t.x}else if("right"===s){const t=this._getYAxisLabelAlignment(u);w=t.textAlign,y=t.x}else if("x"===i){if("center"===s)M=(t.top+t.bottom)/2+f;else if(K(s)){const t=Object.keys(s)[0];M=this.chart.scales[t].getPixelForValue(s[t])+f}w=this._getXAxisLabelAlignment()}else if("y"===i){if("center"===s)y=(t.left+t.right)/2-f;else if(K(s)){const t=Object.keys(s)[0];y=this.chart.scales[t].getPixelForValue(s[t])}w=this._getYAxisLabelAlignment(u).textAlign}"y"===i&&("start"===h?D="top":"end"===h&&(D="bottom"));const j=this._getLabelSizes();for(g=0,m=o.length;g<m;++g){v=o[g],x=v.label;const t=n.setContext(this.getContext(g));_=this.getPixelForTick(g)+n.labelOffset,k=this._resolveTickFontOptions(g),O=k.lineHeight,S=Z(x)?x.length:1;const i=S/2,e=t.color,h=t.textStrokeColor,c=t.textStrokeWidth;let u,f=w;if(r?(y=_,"inner"===w&&(f=g===m-1?this.options.reverse?"left":"right":0===g?this.options.reverse?"right":"left":"center"),A="top"===s?"near"===a||0!==b?-S*O+O/2:"center"===a?-j.highest.height/2-i*O+O:O/2-j.highest.height:"near"===a||0!==b?O/2:"center"===a?j.highest.height/2-i*O:j.highest.height-S*O,l&&(A*=-1),0===b||t.showLabelBackdrop||(y+=O/2*Math.sin(b))):(M=_,A=(1-S)*O/2),t.showLabelBackdrop){const i=ki(t.backdropPadding),e=j.heights[g],s=j.widths[g];let n=A-i.top,r=0-i.left;switch(D){case"middle":n-=e/2;break;case"bottom":n-=e}switch(w){case"center":r-=s/2;break;case"right":r-=s;break;case"inner":g===m-1?r-=s:g>0&&(r-=s/2)}u={left:r,top:n,width:s+i.width,height:e+i.height,color:t.backdropColor}}p.push({label:x,font:k,textOffset:A,options:{rotation:b,color:e,strokeColor:h,strokeWidth:c,textAlign:f,textBaseline:D,translation:[y,M],backdrop:u}})}return p}_getXAxisLabelAlignment(){const{position:t,ticks:i}=this.options;if(-At(this.labelRotation))return"top"===t?"left":"right";let e="center";return"start"===i.align?e="left":"end"===i.align?e="right":"inner"===i.align&&(e="inner"),e}_getYAxisLabelAlignment(t){const{position:i,ticks:{crossAlign:e,mirror:s,padding:n}}=this.options,r=t+n,o=this._getLabelSizes().widest.width;let h,a;return"left"===i?s?(a=this.right+n,"near"===e?h="left":"center"===e?(h="center",a+=o/2):(h="right",a+=o)):(a=this.right-r,"near"===e?h="right":"center"===e?(h="center",a-=o/2):(h="left",a=this.left)):"right"===i?s?(a=this.left+n,"near"===e?h="right":"center"===e?(h="center",a-=o/2):(h="left",a-=o)):(a=this.left+r,"near"===e?h="left":"center"===e?(h="center",a+=o/2):(h="right",a=this.right)):h="right",{textAlign:h,x:a}}_computeLabelArea(){if(this.options.ticks.mirror)return;const t=this.chart,i=this.options.position;return"left"===i||"right"===i?{top:0,left:this.left,bottom:t.height,right:this.right}:"top"===i||"bottom"===i?{top:this.top,left:0,bottom:this.bottom,right:t.width}:void 0}drawBackground(){const{ctx:t,options:{backgroundColor:i},left:e,top:s,width:n,height:r}=this;i&&(t.save(),t.fillStyle=i,t.fillRect(e,s,n,r),t.restore())}getLineWidthForValue(t){const i=this.options.grid;if(!this._isVisible()||!i.display)return 0;const e=this.ticks.findIndex((i=>i.value===t));return e>=0?i.setContext(this.getContext(e)).lineWidth:0}drawGrid(t){const i=this.options.grid,e=this.ctx,s=this._gridLineItems||(this._gridLineItems=this._computeGridLineItems(t));let n,r;const o=(t,i,s)=>{s.width&&s.color&&(e.save(),e.lineWidth=s.width,e.strokeStyle=s.color,e.setLineDash(s.borderDash||[]),e.lineDashOffset=s.borderDashOffset,e.beginPath(),e.moveTo(t.x,t.y),e.lineTo(i.x,i.y),e.stroke(),e.restore())};if(i.display)for(n=0,r=s.length;n<r;++n){const t=s[n];i.drawOnChartArea&&o({x:t.x1,y:t.y1},{x:t.x2,y:t.y2},t),i.drawTicks&&o({x:t.tx1,y:t.ty1},{x:t.tx2,y:t.ty2},{color:t.tickColor,width:t.tickWidth,borderDash:t.tickBorderDash,borderDashOffset:t.tickBorderDashOffset})}}drawBorder(){const{chart:t,ctx:i,options:{border:e,grid:s}}=this,n=e.setContext(this.getContext()),r=e.display?n.width:0;if(!r)return;const o=s.setContext(this.getContext(0)).lineWidth,h=this._borderValue;let a,c,l,u;this.isHorizontal()?(a=hi(t,this.left,r)-r/2,c=hi(t,this.right,o)+o/2,l=u=h):(l=hi(t,this.top,r)-r/2,u=hi(t,this.bottom,o)+o/2,a=c=h),i.save(),i.lineWidth=n.width,i.strokeStyle=n.color,i.beginPath(),i.moveTo(a,l),i.lineTo(c,u),i.stroke(),i.restore()}drawLabels(t){if(!this.options.ticks.display)return;const i=this.ctx,e=this._computeLabelArea();e&&fi(i,e);const s=this.getLabelItems(t);for(const t of s)gi(i,t.label,0,t.textOffset,t.font,t.options);e&&di(i)}drawTitle(){const{ctx:t,options:{position:i,title:e,reverse:s}}=this;if(!e.display)return;const n=Oi(e.font),r=ki(e.padding),o=e.align;let h=n.lineHeight/2;"bottom"===i||"center"===i||K(i)?(h+=r.bottom,Z(e.text)&&(h+=n.lineHeight*(e.text.length-1))):h+=r.top;const{titleX:a,titleY:c,maxWidth:l,rotation:u}=function(t,i,e,s){const{top:n,left:r,bottom:o,right:h,chart:a}=t,{chartArea:c,scales:l}=a;let u,f,d,b=0;const p=o-n,g=h-r;if(t.isHorizontal()){if(f=zt(s,r,h),K(e)){const t=Object.keys(e)[0];d=l[t].getPixelForValue(e[t])+p-i}else d="center"===e?(c.bottom+c.top)/2+p-i:ds(t,e,i);u=h-r}else{if(K(e)){const t=Object.keys(e)[0];f=l[t].getPixelForValue(e[t])-g+i}else f="center"===e?(c.left+c.right)/2-g+i:ds(t,e,i);d=zt(s,o,n),b="left"===e?-xt:xt}return{titleX:f,titleY:d,maxWidth:u,rotation:b}}(this,h,i,o);gi(t,e.text,0,0,n,{color:e.color,maxWidth:l,rotation:u,textAlign:xs(o,i,s),textBaseline:"middle",translation:[a,c]})}draw(t){this._isVisible()&&(this.drawBackground(),this.drawGrid(t),this.drawBorder(),this.drawTitle(),this.drawLabels(t))}_layers(){const t=this.options,i=t.ticks&&t.ticks.z||0,e=G(t.grid&&t.grid.z,-1),s=G(t.border&&t.border.z,0);return this._isVisible()&&this.draw===ys.prototype.draw?[{z:e,draw:t=>{this.drawBackground(),this.drawGrid(t),this.drawTitle()}},{z:s,draw:()=>{this.drawBorder()}},{z:i,draw:t=>{this.drawLabels(t)}}]:[{z:i,draw:t=>{this.draw(t)}}]}getMatchingVisibleMetas(t){const i=this.chart.getSortedVisibleDatasetMetas(),e=this.axis+"AxisID",s=[];let n,r;for(n=0,r=i.length;n<r;++n){const r=i[n];r[e]!==this.id||t&&r.type!==t||s.push(r)}return s}_resolveTickFontOptions(t){return Oi(this.options.ticks.setContext(this.getContext(t)).font)}_maxDigits(){const t=this._resolveTickFontOptions(0).lineHeight;return(this.isHorizontal()?this.width:this.height)/t}}class Ms{constructor(t,i,e){this.type=t,this.scope=i,this.override=e,this.items=Object.create(null)}isForType(t){return Object.prototype.isPrototypeOf.call(this.type.prototype,t.prototype)}register(t){const i=Object.getPrototypeOf(t);let e;(function(t){return"id"in t&&"defaults"in t})(i)&&(e=this.register(i));const s=this.items,n=t.id,r=this.scope+"."+n;if(!n)throw new Error("class does not have id: "+t);return n in s||(s[n]=t,function(t,i,e){const s=ot(Object.create(null),[e?ri.get(e):{},ri.get(i),t.defaults]);ri.set(i,s),t.defaultRoutes&&function(t,i){Object.keys(i).forEach((e=>{const s=e.split("."),n=s.pop(),r=[t].concat(s).join("."),o=i[e].split("."),h=o.pop(),a=o.join(".");ri.route(r,n,a,h)}))}(i,t.defaultRoutes),t.descriptors&&ri.describe(i,t.descriptors)}(t,r,e),this.override&&ri.override(t.id,t.overrides)),r}get(t){return this.items[t]}unregister(t){const i=this.items,e=t.id,s=this.scope;e in i&&delete i[e],s&&e in ri[s]&&(delete ri[s][e],this.override&&delete ti[e])}}class ws{constructor(){this.controllers=new Ms(ye,"datasets",!0),this.elements=new Ms(us,"elements"),this.plugins=new Ms(Object,"plugins"),this.scales=new Ms(ys,"scales"),this._typedRegistries=[this.controllers,this.scales,this.elements]}add(...t){this._each("register",t)}remove(...t){this._each("unregister",t)}addControllers(...t){this._each("register",t,this.controllers)}addElements(...t){this._each("register",t,this.elements)}addPlugins(...t){this._each("register",t,this.plugins)}addScales(...t){this._each("register",t,this.scales)}getController(t){return this._get(t,this.controllers,"controller")}getElement(t){return this._get(t,this.elements,"element")}getPlugin(t){return this._get(t,this.plugins,"plugin")}getScale(t){return this._get(t,this.scales,"scale")}removeControllers(...t){this._each("unregister",t,this.controllers)}removeElements(...t){this._each("unregister",t,this.elements)}removePlugins(...t){this._each("unregister",t,this.plugins)}removeScales(...t){this._each("unregister",t,this.scales)}_each(t,i,e){[...i].forEach((i=>{const s=e||this._getRegistryForType(i);e||s.isForType(i)||s===this.plugins&&i.id?this._exec(t,s,i):it(i,(i=>{const s=e||this._getRegistryForType(i);this._exec(t,s,i)}))}))}_exec(t,i,e){const s=ut(t);tt(e["before"+s],[],e),i[t](e),tt(e["after"+s],[],e)}_getRegistryForType(t){for(let i=0;i<this._typedRegistries.length;i++){const e=this._typedRegistries[i];if(e.isForType(t))return e}return this.plugins}_get(t,i,e){const s=i.get(t);if(void 0===s)throw new Error('"'+t+'" is not a registered '+e+".");return s}}var _s=new ws;class ks{constructor(){this._init=void 0}notify(t,i,e,s){if("beforeInit"===i&&(this._init=this._createDescriptors(t,!0),this._notify(this._init,t,"install")),void 0===this._init)return;const n=s?this._descriptors(t).filter(s):this._descriptors(t),r=this._notify(n,t,i,e);return"afterDestroy"===i&&(this._notify(n,t,"stop"),this._notify(this._init,t,"uninstall"),this._init=void 0),r}_notify(t,i,e,s){s=s||{};for(const n of t){const t=n.plugin;if(!1===tt(t[e],[i,s,n.options],t)&&s.cancelable)return!1}return!0}invalidate(){U(this._cache)||(this._oldCache=this._cache,this._cache=void 0)}_descriptors(t){if(this._cache)return this._cache;const i=this._cache=this._createDescriptors(t);return this._notifyStateChanges(t),i}_createDescriptors(t,i){const e=t&&t.config,s=G(e.options&&e.options.plugins,{}),n=function(t){const i={},e=[],s=Object.keys(_s.plugins.items);for(let t=0;t<s.length;t++)e.push(_s.getPlugin(s[t]));const n=t.plugins||[];for(let t=0;t<n.length;t++){const s=n[t];-1===e.indexOf(s)&&(e.push(s),i[s.id]=!0)}return{plugins:e,localIds:i}}(e);return!1!==s||i?function(t,{plugins:i,localIds:e},s,n){const r=[],o=t.getContext();for(const h of i){const i=h.id,a=Os(s[i],n);null!==a&&r.push({plugin:h,options:Ss(t.config,{plugin:h,local:e[i]},a,o)})}return r}(t,n,s,i):[]}_notifyStateChanges(t){const i=this._oldCache||[],e=this._cache,s=(t,i)=>t.filter((t=>!i.some((i=>t.plugin.id===i.plugin.id))));this._notify(s(i,e),t,"stop"),this._notify(s(e,i),t,"start")}}function Os(t,i){return i||!1!==t?!0===t?{}:t:null}function Ss(t,{plugin:i,local:e},s,n){const r=t.pluginScopeKeys(i),o=t.getOptionScopes(s,r);return e&&i.defaults&&o.push(i.defaults),t.createResolver(o,n,[""],{scriptable:!1,indexable:!1,allKeys:!0})}function As(t,i){return((i.datasets||{})[t]||{}).indexAxis||i.indexAxis||(ri.datasets[t]||{}).indexAxis||"x"}function Ds(t){if("x"===t||"y"===t||"r"===t)return t}function js(t,...i){if(Ds(t))return t;for(const s of i){const i=s.axis||("top"===(e=s.position)||"bottom"===e?"x":"left"===e||"right"===e?"y":void 0)||t.length>1&&Ds(t[0].toLowerCase());if(i)return i}var e;throw new Error(`Cannot determine type of '${t}' axis. Please provide 'axis' or 'position' option.`)}function Cs(t,i,e){if(e[i+"AxisID"]===t)return{axis:i}}function Rs(t){const i=t.options||(t.options={});i.plugins=G(i.plugins,{}),i.scales=function(t,i){const e=ti[t.type]||{scales:{}},s=i.scales||{},n=As(t.type,i),r=Object.create(null);return Object.keys(s).forEach((i=>{const o=s[i];if(!K(o))return console.error(`Invalid scale configuration for scale: ${i}`);if(o._proxy)return console.warn(`Ignoring resolver passed as options for scale: ${i}`);const h=js(i,o,function(t,i){if(i.data&&i.data.datasets){const e=i.data.datasets.filter((i=>i.xAxisID===t||i.yAxisID===t));if(e.length)return Cs(t,"x",e[0])||Cs(t,"y",e[0])}return{}}(i,t),ri.scales[o.type]),a=function(t,i){return t===i?"_index_":"_value_"}(h,n),c=e.scales||{};r[i]=ht(Object.create(null),[{axis:h},o,c[h],c[a]])})),t.data.datasets.forEach((e=>{const n=e.type||t.type,o=e.indexAxis||As(n,i),h=(ti[n]||{}).scales||{};Object.keys(h).forEach((t=>{const i=function(t,i){let e=t;return"_index_"===t?e=i:"_value_"===t&&(e="x"===i?"y":"x"),e}(t,o),n=e[i+"AxisID"]||i;r[n]=r[n]||Object.create(null),ht(r[n],[{axis:i},s[n],h[t]])}))})),Object.keys(r).forEach((t=>{const i=r[t];ht(i,[ri.scales[i.type],ri.scale])})),r}(t,i)}function Es(t){return(t=t||{}).datasets=t.datasets||[],t.labels=t.labels||[],t}const Ls=new Map,Ps=new Set;function Ts(t,i){let e=Ls.get(t);return e||(e=i(),Ls.set(t,e),Ps.add(e)),e}const Is=(t,i,e)=>{const s=lt(i,e);void 0!==s&&t.add(s)};class Fs{constructor(t){this._config=function(t){return(t=t||{}).data=Es(t.data),Rs(t),t}(t),this._scopeCache=new Map,this._resolverCache=new Map}get platform(){return this._config.platform}get type(){return this._config.type}set type(t){this._config.type=t}get data(){return this._config.data}set data(t){this._config.data=Es(t)}get options(){return this._config.options}set options(t){this._config.options=t}get plugins(){return this._config.plugins}update(){const t=this._config;this.clearCache(),Rs(t)}clearCache(){this._scopeCache.clear(),this._resolverCache.clear()}datasetScopeKeys(t){return Ts(t,(()=>[[`datasets.${t}`,""]]))}datasetAnimationScopeKeys(t,i){return Ts(`${t}.transition.${i}`,(()=>[[`datasets.${t}.transitions.${i}`,`transitions.${i}`],[`datasets.${t}`,""]]))}datasetElementScopeKeys(t,i){return Ts(`${t}-${i}`,(()=>[[`datasets.${t}.elements.${i}`,`datasets.${t}`,`elements.${i}`,""]]))}pluginScopeKeys(t){const i=t.id;return Ts(`${this.type}-plugin-${i}`,(()=>[[`plugins.${i}`,...t.additionalOptionScopes||[]]]))}_cachedScopes(t,i){const e=this._scopeCache;let s=e.get(t);return s&&!i||(s=new Map,e.set(t,s)),s}getOptionScopes(t,i,e){const{options:s,type:n}=this,r=this._cachedScopes(t,e),o=r.get(i);if(o)return o;const h=new Set;i.forEach((i=>{t&&(h.add(t),i.forEach((i=>Is(h,t,i)))),i.forEach((t=>Is(h,s,t))),i.forEach((t=>Is(h,ti[n]||{},t))),i.forEach((t=>Is(h,ri,t))),i.forEach((t=>Is(h,ii,t)))}));const a=Array.from(h);return 0===a.length&&a.push(Object.create(null)),Ps.has(i)&&r.set(i,a),a}chartOptionScopes(){const{options:t,type:i}=this;return[t,ti[i]||{},ri.datasets[i]||{},{type:i},ri,ii]}resolveNamedOptions(t,i,e,s=[""]){const n={$shared:!0},{resolver:r,subPrefixes:o}=Bs(this._resolverCache,t,s);let h=r;(function(t,i){const{isScriptable:e,isIndexable:s}=Ci(t);for(const n of i){const i=e(n),r=s(n),o=(r||i)&&t[n];if(i&&(dt(o)||Ws(o))||r&&Z(o))return!0}return!1})(r,i)&&(n.$shared=!1,h=ji(r,e=dt(e)?e():e,this.createResolver(t,e,o)));for(const t of i)n[t]=h[t];return n}createResolver(t,i,e=[""],s){const{resolver:n}=Bs(this._resolverCache,t,e);return K(i)?ji(n,i,void 0,s):n}}function Bs(t,i,e){let s=t.get(i);s||(s=new Map,t.set(i,s));const n=e.join();let r=s.get(n);return r||(r={resolver:Di(i,e),subPrefixes:e.filter((t=>!t.toLowerCase().includes("hover")))},s.set(n,r)),r}const Ws=t=>K(t)&&Object.getOwnPropertyNames(t).some((i=>dt(t[i]))),Ns=["top","bottom","left","right","chartArea"];function zs(t,i){return"top"===t||"bottom"===t||-1===Ns.indexOf(t)&&"x"===i}function Hs(t,i){return function(e,s){return e[t]===s[t]?e[i]-s[i]:e[t]-s[t]}}function $s(t){const i=t.chart,e=i.options.animation;i.notifyPlugins("afterRender"),tt(e&&e.onComplete,[t],i)}function Ys(t){const i=t.chart,e=i.options.animation;tt(e&&e.onProgress,[t],i)}function Vs(t){return Hi()&&"string"==typeof t?t=document.getElementById(t):t&&t.length&&(t=t[0]),t&&t.canvas&&(t=t.canvas),t}const Xs={},Us=t=>{const i=Vs(t);return Object.values(Xs).filter((t=>t.canvas===i)).pop()};function Zs(t,i,e){const s=Object.keys(t);for(const n of s){const s=+n;if(s>=i){const r=t[n];delete t[n],(e>0||s>i)&&(t[s+e]=r)}}}class Ks{static defaults=ri;static instances=Xs;static overrides=ti;static registry=_s;static version="4.5.1";static getChart=Us;static register(...t){_s.add(...t),Qs()}static unregister(...t){_s.remove(...t),Qs()}constructor(t,i){const e=this.config=new Fs(i),s=Vs(t),n=Us(s);if(n)throw new Error("Canvas is already in use. Chart with ID '"+n.id+"' must be destroyed before the canvas with ID '"+n.canvas.id+"' can be reused.");const r=e.createResolver(e.chartOptionScopes(),this.getContext());this.platform=new(e.platform||function(t){return!Hi()||"undefined"!=typeof OffscreenCanvas&&t instanceof OffscreenCanvas?Ke:ls}(s)),this.platform.updateConfig(e);const o=this.platform.acquireContext(s,r.aspectRatio),h=o&&o.canvas,a=h&&h.height,c=h&&h.width;this.id=X(),this.ctx=o,this.canvas=h,this.width=c,this.height=a,this._options=r,this._aspectRatio=this.aspectRatio,this._layers=[],this._metasets=[],this._stacks=void 0,this.boxes=[],this.currentDevicePixelRatio=void 0,this.chartArea=void 0,this._active=[],this._lastEvent=void 0,this._listeners={},this._responsiveListeners=void 0,this._sortedMetasets=[],this.scales={},this._plugins=new ks,this.$proxies={},this._hiddenIndices={},this.attached=!1,this._animationsDisabled=void 0,this.$context=void 0,this._doResize=function(t,i){let e;return function(...s){return i?(clearTimeout(e),e=setTimeout(t,i,s)):t.apply(this,s),i}}((t=>this.update(t)),r.resizeDelay||0),this._dataChanges=[],Xs[this.id]=this,o&&h?(ne.listen(this,"complete",$s),ne.listen(this,"progress",Ys),this._initialize(),this.attached&&this.update()):console.error("Failed to create chart: can't acquire context from the given item")}get aspectRatio(){const{options:{aspectRatio:t,maintainAspectRatio:i},width:e,height:s,_aspectRatio:n}=this;return U(t)?i&&n?n:s?e/s:null:t}get data(){return this.config.data}set data(t){this.config.data=t}get options(){return this._options}set options(t){this.config.options=t}get registry(){return _s}_initialize(){return this.notifyPlugins("beforeInit"),this.options.responsive?this.resize():Qi(this,this.options.devicePixelRatio),this.bindEvents(),this.notifyPlugins("afterInit"),this}clear(){return ai(this.canvas,this.ctx),this}stop(){return ne.stop(this),this}resize(t,i){ne.running(this)?this._resizeBeforeDraw={width:t,height:i}:this._resize(t,i)}_resize(t,i){const e=this.options,s=this.platform.getMaximumSize(this.canvas,t,i,e.maintainAspectRatio&&this.aspectRatio),n=e.devicePixelRatio||this.platform.getDevicePixelRatio(),r=this.width?"resize":"attach";this.width=s.width,this.height=s.height,this._aspectRatio=this.aspectRatio,Qi(this,n,!0)&&(this.notifyPlugins("resize",{size:s}),tt(e.onResize,[this,s],this),this.attached&&this._doResize(r)&&this.render())}ensureScalesHaveIDs(){it(this.options.scales||{},((t,i)=>{t.id=i}))}buildOrUpdateScales(){const t=this.options,i=t.scales,e=this.scales,s=Object.keys(e).reduce(((t,i)=>(t[i]=!1,t)),{});let n=[];i&&(n=n.concat(Object.keys(i).map((t=>{const e=i[t],s=js(t,e),n="r"===s,r="x"===s;return{options:e,dposition:n?"chartArea":r?"bottom":"left",dtype:n?"radialLinear":r?"category":"linear"}})))),it(n,(i=>{const n=i.options,r=n.id,o=js(r,n),h=G(n.type,i.dtype);void 0!==n.position&&zs(n.position,o)===zs(i.dposition)||(n.position=i.dposition),s[r]=!0;let a=null;r in e&&e[r].type===h?a=e[r]:(a=new(_s.getScale(h))({id:r,type:h,ctx:this.ctx,chart:this}),e[a.id]=a),a.init(n,t)})),it(s,((t,i)=>{t||delete e[i]})),it(e,(t=>{Ue.configure(this,t,t.options),Ue.addBox(this,t)}))}_updateMetasets(){const t=this._metasets,i=this.data.datasets.length,e=t.length;if(t.sort(((t,i)=>t.index-i.index)),e>i){for(let t=i;t<e;++t)this._destroyDatasetMeta(t);t.splice(i,e-i)}this._sortedMetasets=t.slice(0).sort(Hs("order","index"))}_removeUnreferencedMetasets(){const{_metasets:t,data:{datasets:i}}=this;t.length>i.length&&delete this._stacks,t.forEach(((t,e)=>{0===i.filter((i=>i===t._dataset)).length&&this._destroyDatasetMeta(e)}))}buildOrUpdateControllers(){const t=[],i=this.data.datasets;let e,s;for(this._removeUnreferencedMetasets(),e=0,s=i.length;e<s;e++){const s=i[e];let n=this.getDatasetMeta(e);const r=s.type||this.config.type;if(n.type&&n.type!==r&&(this._destroyDatasetMeta(e),n=this.getDatasetMeta(e)),n.type=r,n.indexAxis=s.indexAxis||As(r,this.options),n.order=s.order||0,n.index=e,n.label=""+s.label,n.visible=this.isDatasetVisible(e),n.controller)n.controller.updateIndex(e),n.controller.linkScales();else{const i=_s.getController(r),{datasetElementType:s,dataElementType:o}=ri.datasets[r];Object.assign(i,{dataElementType:_s.getElement(o),datasetElementType:s&&_s.getElement(s)}),n.controller=new i(this,e),t.push(n.controller)}}return this._updateMetasets(),t}_resetElements(){it(this.data.datasets,((t,i)=>{this.getDatasetMeta(i).controller.reset()}),this)}reset(){this._resetElements(),this.notifyPlugins("reset")}update(t){const i=this.config;i.update();const e=this._options=i.createResolver(i.chartOptionScopes(),this.getContext()),s=this._animationsDisabled=!e.animation;if(this._updateScales(),this._checkEventBindings(),this._updateHiddenIndices(),this._plugins.invalidate(),!1===this.notifyPlugins("beforeUpdate",{mode:t,cancelable:!0}))return;const n=this.buildOrUpdateControllers();this.notifyPlugins("beforeElementsUpdate");let r=0;for(let t=0,i=this.data.datasets.length;t<i;t++){const{controller:i}=this.getDatasetMeta(t),e=!s&&-1===n.indexOf(i);i.buildOrUpdateElements(e),r=Math.max(+i.getMaxOverflow(),r)}r=this._minPadding=e.layout.autoPadding?r:0,this._updateLayout(r),s||it(n,(t=>{t.reset()})),this._updateDatasets(t),this.notifyPlugins("afterUpdate",{mode:t}),this._layers.sort(Hs("z","_idx"));const{_active:o,_lastEvent:h}=this;h?this._eventHandler(h,!0):o.length&&this._updateHoverStyles(o,o,!0),this.render()}_updateScales(){it(this.scales,(t=>{Ue.removeBox(this,t)})),this.ensureScalesHaveIDs(),this.buildOrUpdateScales()}_checkEventBindings(){const t=this.options,i=new Set(Object.keys(this._listeners)),e=new Set(t.events);bt(i,e)&&!!this._responsiveListeners===t.responsive||(this.unbindEvents(),this.bindEvents())}_updateHiddenIndices(){const{_hiddenIndices:t}=this,i=this._getUniformDataChanges()||[];for(const{method:e,start:s,count:n}of i)Zs(t,s,"_removeElements"===e?-n:n)}_getUniformDataChanges(){const t=this._dataChanges;if(!t||!t.length)return;this._dataChanges=[];const i=this.data.datasets.length,e=i=>new Set(t.filter((t=>t[0]===i)).map(((t,i)=>i+","+t.splice(1).join(",")))),s=e(0);for(let t=1;t<i;t++)if(!bt(s,e(t)))return;return Array.from(s).map((t=>t.split(","))).map((t=>({method:t[1],start:+t[2],count:+t[3]})))}_updateLayout(t){if(!1===this.notifyPlugins("beforeLayout",{cancelable:!0}))return;Ue.update(this,this.width,this.height,t);const i=this.chartArea,e=i.width<=0||i.height<=0;this._layers=[],it(this.boxes,(t=>{e&&"chartArea"===t.position||(t.configure&&t.configure(),this._layers.push(...t._layers()))}),this),this._layers.forEach(((t,i)=>{t._idx=i})),this.notifyPlugins("afterLayout")}_updateDatasets(t){if(!1!==this.notifyPlugins("beforeDatasetsUpdate",{mode:t,cancelable:!0})){for(let t=0,i=this.data.datasets.length;t<i;++t)this.getDatasetMeta(t).controller.configure();for(let i=0,e=this.data.datasets.length;i<e;++i)this._updateDataset(i,dt(t)?t({datasetIndex:i}):t);this.notifyPlugins("afterDatasetsUpdate",{mode:t})}}_updateDataset(t,i){const e=this.getDatasetMeta(t),s={meta:e,index:t,mode:i,cancelable:!0};!1!==this.notifyPlugins("beforeDatasetUpdate",s)&&(e.controller._update(i),s.cancelable=!1,this.notifyPlugins("afterDatasetUpdate",s))}render(){!1!==this.notifyPlugins("beforeRender",{cancelable:!0})&&(ne.has(this)?this.attached&&!ne.running(this)&&ne.start(this):(this.draw(),$s({chart:this})))}draw(){let t;if(this._resizeBeforeDraw){const{width:t,height:i}=this._resizeBeforeDraw;this._resizeBeforeDraw=null,this._resize(t,i)}if(this.clear(),this.width<=0||this.height<=0)return;if(!1===this.notifyPlugins("beforeDraw",{cancelable:!0}))return;const i=this._layers;for(t=0;t<i.length&&i[t].z<=0;++t)i[t].draw(this.chartArea);for(this._drawDatasets();t<i.length;++t)i[t].draw(this.chartArea);this.notifyPlugins("afterDraw")}_getSortedDatasetMetas(t){const i=this._sortedMetasets,e=[];let s,n;for(s=0,n=i.length;s<n;++s){const n=i[s];t&&!n.visible||e.push(n)}return e}getSortedVisibleDatasetMetas(){return this._getSortedDatasetMetas(!0)}_drawDatasets(){if(!1===this.notifyPlugins("beforeDatasetsDraw",{cancelable:!0}))return;const t=this.getSortedVisibleDatasetMetas();for(let i=t.length-1;i>=0;--i)this._drawDataset(t[i]);this.notifyPlugins("afterDatasetsDraw")}_drawDataset(t){const i=this.ctx,e={meta:t,index:t.index,cancelable:!0},s=function(t,i){const e=i._clip;if(e.disabled)return!1;const s=function(t,i){const{xScale:e,yScale:s}=t;return e&&s?{left:ee(e,i,"left"),right:ee(e,i,"right"),top:ee(s,i,"top"),bottom:ee(s,i,"bottom")}:i}(i,t.chartArea);return{left:!1===e.left?0:s.left-(!0===e.left?0:e.left),right:!1===e.right?t.width:s.right+(!0===e.right?0:e.right),top:!1===e.top?0:s.top-(!0===e.top?0:e.top),bottom:!1===e.bottom?t.height:s.bottom+(!0===e.bottom?0:e.bottom)}}(this,t);!1!==this.notifyPlugins("beforeDatasetDraw",e)&&(s&&fi(i,s),t.controller.draw(),s&&di(i),e.cancelable=!1,this.notifyPlugins("afterDatasetDraw",e))}isPointInArea(t){return ui(t,this.chartArea,this._minPadding)}getElementsAtEventForMode(t,i,e,s){const n=Te.modes[i];return"function"==typeof n?n(this,t,e,s):[]}getDatasetMeta(t){const i=this.data.datasets[t],e=this._metasets;let s=e.filter((t=>t&&t._dataset===i)).pop();return s||(s={type:null,data:[],dataset:null,controller:null,hidden:null,xAxisID:null,yAxisID:null,order:i&&i.order||0,index:t,_dataset:i,_parsed:[],_sorted:!1},e.push(s)),s}getContext(){return this.$context||(this.$context=Ai(null,{chart:this,type:"chart"}))}getVisibleDatasetCount(){return this.getSortedVisibleDatasetMetas().length}isDatasetVisible(t){const i=this.data.datasets[t];if(!i)return!1;const e=this.getDatasetMeta(t);return"boolean"==typeof e.hidden?!e.hidden:!i.hidden}setDatasetVisibility(t,i){this.getDatasetMeta(t).hidden=!i}toggleDataVisibility(t){this._hiddenIndices[t]=!this._hiddenIndices[t]}getDataVisibility(t){return!this._hiddenIndices[t]}_updateVisibility(t,i,e){const s=e?"show":"hide",n=this.getDatasetMeta(t),r=n.controller._resolveAnimations(void 0,s);ft(i)?(n.data[i].hidden=!e,this.update()):(this.setDatasetVisibility(t,e),r.update(n,{visible:e}),this.update((i=>i.datasetIndex===t?s:void 0)))}hide(t,i){this._updateVisibility(t,i,!1)}show(t,i){this._updateVisibility(t,i,!0)}_destroyDatasetMeta(t){const i=this._metasets[t];i&&i.controller&&i.controller._destroy(),delete this._metasets[t]}_stop(){let t,i;for(this.stop(),ne.remove(this),t=0,i=this.data.datasets.length;t<i;++t)this._destroyDatasetMeta(t)}destroy(){this.notifyPlugins("beforeDestroy");const{canvas:t,ctx:i}=this;this._stop(),this.config.clearCache(),t&&(this.unbindEvents(),ai(t,i),this.platform.releaseContext(i),this.canvas=null,this.ctx=null),delete Xs[this.id],this.notifyPlugins("afterDestroy")}toBase64Image(...t){return this.canvas.toDataURL(...t)}bindEvents(){this.bindUserEvents(),this.options.responsive?this.bindResponsiveEvents():this.attached=!0}bindUserEvents(){const t=this._listeners,i=this.platform,e=(e,s)=>{i.addEventListener(this,e,s),t[e]=s},s=(t,i,e)=>{t.offsetX=i,t.offsetY=e,this._eventHandler(t)};it(this.options.events,(t=>e(t,s)))}bindResponsiveEvents(){this._responsiveListeners||(this._responsiveListeners={});const t=this._responsiveListeners,i=this.platform,e=(e,s)=>{i.addEventListener(this,e,s),t[e]=s},s=(e,s)=>{t[e]&&(i.removeEventListener(this,e,s),delete t[e])},n=(t,i)=>{this.canvas&&this.resize(t,i)};let r;const o=()=>{s("attach",o),this.attached=!0,this.resize(),e("resize",n),e("detach",r)};r=()=>{this.attached=!1,s("resize",n),this._stop(),this._resize(0,0),e("attach",o)},i.isAttached(this.canvas)?o():r()}unbindEvents(){it(this._listeners,((t,i)=>{this.platform.removeEventListener(this,i,t)})),this._listeners={},it(this._responsiveListeners,((t,i)=>{this.platform.removeEventListener(this,i,t)})),this._responsiveListeners=void 0}updateHoverStyle(t,i,e){const s=e?"set":"remove";let n,r,o,h;for("dataset"===i&&(n=this.getDatasetMeta(t[0].datasetIndex),n.controller["_"+s+"DatasetHoverStyle"]()),o=0,h=t.length;o<h;++o){r=t[o];const i=r&&this.getDatasetMeta(r.datasetIndex).controller;i&&i[s+"HoverStyle"](r.element,r.datasetIndex,r.index)}}getActiveElements(){return this._active||[]}setActiveElements(t){const i=this._active||[],e=t.map((({datasetIndex:t,index:i})=>{const e=this.getDatasetMeta(t);if(!e)throw new Error("No dataset found at index "+t);return{datasetIndex:t,element:e.data[i],index:i}}));!et(e,i)&&(this._active=e,this._lastEvent=null,this._updateHoverStyles(e,i))}notifyPlugins(t,i,e){return this._plugins.notify(this,t,i,e)}isPluginEnabled(t){return 1===this._plugins._cache.filter((i=>i.plugin.id===t)).length}_updateHoverStyles(t,i,e){const s=this.options.hover,n=(t,i)=>t.filter((t=>!i.some((i=>t.datasetIndex===i.datasetIndex&&t.index===i.index)))),r=n(i,t),o=e?t:n(t,i);r.length&&this.updateHoverStyle(r,s.mode,!1),o.length&&s.mode&&this.updateHoverStyle(o,s.mode,!0)}_eventHandler(t,i){const e={event:t,replay:i,cancelable:!0,inChartArea:this.isPointInArea(t)},s=i=>(i.options.events||this.options.events).includes(t.native.type);if(!1===this.notifyPlugins("beforeEvent",e,s))return;const n=this._handleEvent(t,i,e.inChartArea);return e.cancelable=!1,this.notifyPlugins("afterEvent",e,s),(n||e.changed)&&this.render(),this}_handleEvent(t,i,e){const{_active:s=[],options:n}=this,r=this._getActiveElements(t,s,e,i),o=function(t){return"mouseup"===t.type||"click"===t.type||"contextmenu"===t.type}(t),h=function(t,i,e,s){return e&&"mouseout"!==t.type?s?i:t:null}(t,this._lastEvent,e,o);e&&(this._lastEvent=null,tt(n.onHover,[t,r,this],this),o&&tt(n.onClick,[t,r,this],this));const a=!et(r,s);return(a||i)&&(this._active=r,this._updateHoverStyles(r,s,i)),this._lastEvent=h,a}_getActiveElements(t,i,e,s){if("mouseout"===t.type)return[];if(!e)return i;const n=this.options.hover;return this.getElementsAtEventForMode(t,n.mode,n,s)}}function Qs(){return it(Ks.instances,(t=>t._plugins.invalidate()))}function qs(t,i){const{x:e,y:s,base:n,width:r,height:o}=t.getProps(["x","y","base","width","height"],i);let h,a,c,l,u;return t.horizontal?(u=o/2,h=Math.min(e,n),a=Math.max(e,n),c=s-u,l=s+u):(u=r/2,h=e-u,a=e+u,c=Math.min(s,n),l=Math.max(s,n)),{left:h,top:c,right:a,bottom:l}}function Gs(t,i,e,s){return t?0:Rt(i,e,s)}function Js(t,i,e,s){const n=null===i,r=null===e,o=t&&!(n&&r)&&qs(t,s);return o&&(n||Et(i,o.left,o.right))&&(r||Et(e,o.top,o.bottom))}function tn(t,i){t.rect(i.x,i.y,i.w,i.h)}function en(t,i,e={}){const s=t.x!==e.x?-i:0,n=t.y!==e.y?-i:0;return{x:t.x+s,y:t.y+n,w:t.w+((t.x+t.w!==e.x+e.w?i:0)-s),h:t.h+((t.y+t.h!==e.y+e.h?i:0)-n),radius:t.radius}}const sn=["rgb(54, 162, 235)","rgb(255, 99, 132)","rgb(255, 159, 64)","rgb(255, 205, 86)","rgb(75, 192, 192)","rgb(153, 102, 255)","rgb(201, 203, 207)"],nn=sn.map((t=>t.replace("rgb(","rgba(").replace(")",", 0.5)")));function rn(t){return sn[t%sn.length]}function on(t){return nn[t%nn.length]}function hn(t){let i;for(i in t)if(t[i].borderColor||t[i].backgroundColor)return!0;return!1}var an={id:"colors",defaults:{enabled:!0,forceOverride:!1},beforeLayout(t,i,e){if(!e.enabled)return;const{data:{datasets:s},options:n}=t.config,{elements:r}=n,o=hn(s)||(h=n)&&(h.borderColor||h.backgroundColor)||r&&hn(r)||"rgba(0,0,0,0.1)"!==ri.borderColor||"rgba(0,0,0,0.1)"!==ri.backgroundColor;var h;if(!e.forceOverride&&o)return;const a=function(t){let i=0;return(e,s)=>{const n=t.getDatasetMeta(s).controller;n instanceof De?i=function(t,i){return t.backgroundColor=t.data.map((()=>rn(i++))),i}(e,i):n instanceof je?i=function(t,i){return t.backgroundColor=t.data.map((()=>on(i++))),i}(e,i):n&&(i=function(t,i){return t.borderColor=rn(i),t.backgroundColor=on(i),++i}(e,i))}}(t);s.forEach(a)}};const cn=(t,i)=>{let{boxHeight:e=i,boxWidth:s=i}=t;return t.usePointStyle&&(e=Math.min(e,i),s=t.pointStyleWidth||Math.min(s,i)),{boxWidth:s,boxHeight:e,itemHeight:Math.max(i,e)}};class ln extends us{constructor(t){super(),this._added=!1,this.legendHitBoxes=[],this._hoveredItem=null,this.doughnutMode=!1,this.chart=t.chart,this.options=t.options,this.ctx=t.ctx,this.legendItems=void 0,this.columnSizes=void 0,this.lineWidths=void 0,this.maxHeight=void 0,this.maxWidth=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.height=void 0,this.width=void 0,this._margins=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(t,i,e){this.maxWidth=t,this.maxHeight=i,this._margins=e,this.setDimensions(),this.buildLabels(),this.fit()}setDimensions(){this.isHorizontal()?(this.width=this.maxWidth,this.left=this._margins.left,this.right=this.width):(this.height=this.maxHeight,this.top=this._margins.top,this.bottom=this.height)}buildLabels(){const t=this.options.labels||{};let i=tt(t.generateLabels,[this.chart],this)||[];t.filter&&(i=i.filter((i=>t.filter(i,this.chart.data)))),t.sort&&(i=i.sort(((i,e)=>t.sort(i,e,this.chart.data)))),this.options.reverse&&i.reverse(),this.legendItems=i}fit(){const{options:t,ctx:i}=this;if(!t.display)return void(this.width=this.height=0);const e=t.labels,s=Oi(e.font),n=s.size,r=this._computeTitleHeight(),{boxWidth:o,itemHeight:h}=cn(e,n);let a,c;i.font=s.string,this.isHorizontal()?(a=this.maxWidth,c=this._fitRows(r,n,o,h)+10):(c=this.maxHeight,a=this._fitCols(r,s,o,h)+10),this.width=Math.min(a,t.maxWidth||this.maxWidth),this.height=Math.min(c,t.maxHeight||this.maxHeight)}_fitRows(t,i,e,s){const{ctx:n,maxWidth:r,options:{labels:{padding:o}}}=this,h=this.legendHitBoxes=[],a=this.lineWidths=[0],c=s+o;let l=t;n.textAlign="left",n.textBaseline="middle";let u=-1,f=-c;return this.legendItems.forEach(((t,d)=>{const b=e+i/2+n.measureText(t.text).width;(0===d||a[a.length-1]+b+2*o>r)&&(l+=c,a[a.length-(d>0?0:1)]=0,f+=c,u++),h[d]={left:0,top:f,row:u,width:b,height:s},a[a.length-1]+=b+o})),l}_fitCols(t,i,e,s){const{ctx:n,maxHeight:r,options:{labels:{padding:o}}}=this,h=this.legendHitBoxes=[],a=this.columnSizes=[],c=r-t;let l=o,u=0,f=0,d=0,b=0;return this.legendItems.forEach(((t,r)=>{const{itemWidth:p,itemHeight:g}=function(t,i,e,s,n){const r=function(t,i,e,s){let n=t.text;return n&&"string"!=typeof n&&(n=n.reduce(((t,i)=>t.length>i.length?t:i))),i+e.size/2+s.measureText(n).width}(s,t,i,e),o=function(t,i,e){let s=t;return"string"!=typeof i.text&&(s=un(i,e)),s}(n,s,i.lineHeight);return{itemWidth:r,itemHeight:o}}(e,i,n,t,s);r>0&&f+g+2*o>c&&(l+=u+o,a.push({width:u,height:f}),d+=u+o,b++,u=f=0),h[r]={left:d,top:f,col:b,width:p,height:g},u=Math.max(u,p),f+=g+o})),l+=u,a.push({width:u,height:f}),l}adjustHitBoxes(){if(!this.options.display)return;const t=this._computeTitleHeight(),{legendHitBoxes:i,options:{align:e,labels:{padding:s},rtl:n}}=this,r=Ji(n,this.left,this.width);if(this.isHorizontal()){let n=0,o=zt(e,this.left+s,this.right-this.lineWidths[n]);for(const h of i)n!==h.row&&(n=h.row,o=zt(e,this.left+s,this.right-this.lineWidths[n])),h.top+=this.top+t+s,h.left=r.leftForLtr(r.x(o),h.width),o+=h.width+s}else{let n=0,o=zt(e,this.top+t+s,this.bottom-this.columnSizes[n].height);for(const h of i)h.col!==n&&(n=h.col,o=zt(e,this.top+t+s,this.bottom-this.columnSizes[n].height)),h.top=o,h.left+=this.left+s,h.left=r.leftForLtr(r.x(h.left),h.width),o+=h.height+s}}isHorizontal(){return"top"===this.options.position||"bottom"===this.options.position}draw(){if(this.options.display){const t=this.ctx;fi(t,this),this._draw(),di(t)}}_draw(){const{options:t,columnSizes:i,lineWidths:e,ctx:s}=this,{align:n,labels:r}=t,o=ri.color,h=Ji(t.rtl,this.left,this.width),a=Oi(r.font),{padding:c}=r,l=a.size,u=l/2;let f;this.drawTitle(),s.textAlign=h.textAlign("left"),s.textBaseline="middle",s.lineWidth=.5,s.font=a.string;const{boxWidth:d,boxHeight:b,itemHeight:p}=cn(r,l),g=this.isHorizontal(),m=this._computeTitleHeight();f=g?{x:zt(n,this.left+c,this.right-e[0]),y:this.top+c+m,line:0}:{x:this.left+c,y:zt(n,this.top+m+c,this.bottom-i[0].height),line:0},te(this.ctx,t.textDirection);const v=p+c;this.legendItems.forEach(((x,y)=>{s.strokeStyle=x.fontColor,s.fillStyle=x.fontColor;const M=s.measureText(x.text).width,w=h.textAlign(x.textAlign||(x.textAlign=r.textAlign)),_=d+u+M;let k=f.x,O=f.y;h.setWidth(this.width),g?y>0&&k+_+c>this.right&&(O=f.y+=v,f.line++,k=f.x=zt(n,this.left+c,this.right-e[f.line])):y>0&&O+v>this.bottom&&(k=f.x=k+i[f.line].width+c,f.line++,O=f.y=zt(n,this.top+m+c,this.bottom-i[f.line].height)),function(t,i,e){if(isNaN(d)||d<=0||isNaN(b)||b<0)return;s.save();const n=G(e.lineWidth,1);if(s.fillStyle=G(e.fillStyle,o),s.lineCap=G(e.lineCap,"butt"),s.lineDashOffset=G(e.lineDashOffset,0),s.lineJoin=G(e.lineJoin,"miter"),s.lineWidth=n,s.strokeStyle=G(e.strokeStyle,o),s.setLineDash(G(e.lineDash,[])),r.usePointStyle){const o={radius:b*Math.SQRT2/2,pointStyle:e.pointStyle,rotation:e.rotation,borderWidth:n},a=h.xPlus(t,d/2);li(s,o,a,i+u,r.pointStyleWidth&&d)}else{const r=i+Math.max((l-b)/2,0),o=h.leftForLtr(t,d),a=_i(e.borderRadius);s.beginPath(),Object.values(a).some((t=>0!==t))?mi(s,{x:o,y:r,w:d,h:b,radius:a}):s.rect(o,r,d,b),s.fill(),0!==n&&s.stroke()}s.restore()}(h.x(k),O,x),k=((t,i,e,s)=>t===(s?"left":"right")?e:"center"===t?(i+e)/2:i)(w,k+d+u,g?k+_:this.right,t.rtl),function(t,i,e){gi(s,e.text,t,i+p/2,a,{strikethrough:e.hidden,textAlign:h.textAlign(e.textAlign)})}(h.x(k),O,x),g?f.x+=_+c:f.y+="string"!=typeof x.text?un(x,a.lineHeight)+c:v})),ie(this.ctx,t.textDirection)}drawTitle(){const t=this.options,i=t.title,e=Oi(i.font),s=ki(i.padding);if(!i.display)return;const n=Ji(t.rtl,this.left,this.width),r=this.ctx,o=i.position,h=s.top+e.size/2;let a,c=this.left,l=this.width;if(this.isHorizontal())l=Math.max(...this.lineWidths),a=this.top+h,c=zt(t.align,c,this.right-l);else{const i=this.columnSizes.reduce(((t,i)=>Math.max(t,i.height)),0);a=h+zt(t.align,this.top,this.bottom-i-t.labels.padding-this._computeTitleHeight())}const u=zt(o,c,c+l);r.textAlign=n.textAlign(Nt(o)),r.textBaseline="middle",r.strokeStyle=i.color,r.fillStyle=i.color,r.font=e.string,gi(r,i.text,u,a,e)}_computeTitleHeight(){const t=this.options.title,i=Oi(t.font),e=ki(t.padding);return t.display?i.lineHeight+e.height:0}_getLegendItemAt(t,i){let e,s,n;if(Et(t,this.left,this.right)&&Et(i,this.top,this.bottom))for(n=this.legendHitBoxes,e=0;e<n.length;++e)if(s=n[e],Et(t,s.left,s.left+s.width)&&Et(i,s.top,s.top+s.height))return this.legendItems[e];return null}handleEvent(t){const i=this.options;if(!function(t,i){return!("mousemove"!==t&&"mouseout"!==t||!i.onHover&&!i.onLeave)||!(!i.onClick||"click"!==t&&"mouseup"!==t)}(t.type,i))return;const e=this._getLegendItemAt(t.x,t.y);if("mousemove"===t.type||"mouseout"===t.type){const r=this._hoveredItem,o=(n=e,null!==(s=r)&&null!==n&&s.datasetIndex===n.datasetIndex&&s.index===n.index);r&&!o&&tt(i.onLeave,[t,r,this],this),this._hoveredItem=e,e&&!o&&tt(i.onHover,[t,e,this],this)}else e&&tt(i.onClick,[t,e,this],this);var s,n}}function un(t,i){return i*(t.text?t.text.length:0)}var fn={id:"legend",_element:ln,start(t,i,e){const s=t.legend=new ln({ctx:t.ctx,options:e,chart:t});Ue.configure(t,s,e),Ue.addBox(t,s)},stop(t){Ue.removeBox(t,t.legend),delete t.legend},beforeUpdate(t,i,e){const s=t.legend;Ue.configure(t,s,e),s.options=e},afterUpdate(t){const i=t.legend;i.buildLabels(),i.adjustHitBoxes()},afterEvent(t,i){i.replay||t.legend.handleEvent(i.event)},defaults:{display:!0,position:"top",align:"center",fullSize:!0,reverse:!1,weight:1e3,onClick(t,i,e){const s=i.datasetIndex,n=e.chart;n.isDatasetVisible(s)?(n.hide(s),i.hidden=!0):(n.show(s),i.hidden=!1)},onHover:null,onLeave:null,labels:{color:t=>t.chart.options.color,boxWidth:40,padding:10,generateLabels(t){const i=t.data.datasets,{labels:{usePointStyle:e,pointStyle:s,textAlign:n,color:r,useBorderRadius:o,borderRadius:h}}=t.legend.options;return t._getSortedDatasetMetas().map((t=>{const a=t.controller.getStyle(e?0:void 0),c=ki(a.borderWidth);return{text:i[t.index].label,fillStyle:a.backgroundColor,fontColor:r,hidden:!t.visible,lineCap:a.borderCapStyle,lineDash:a.borderDash,lineDashOffset:a.borderDashOffset,lineJoin:a.borderJoinStyle,lineWidth:(c.width+c.height)/4,strokeStyle:a.borderColor,pointStyle:s||a.pointStyle,rotation:a.rotation,textAlign:n||a.textAlign,borderRadius:o&&(h||a.borderRadius),datasetIndex:t.index}}),this)}},title:{color:t=>t.chart.options.color,display:!1,position:"center",text:""}},descriptors:{_scriptable:t=>!t.startsWith("on"),labels:{_scriptable:t=>!["generateLabels","filter","sort"].includes(t)}}};class dn extends us{constructor(t){super(),this.chart=t.chart,this.options=t.options,this.ctx=t.ctx,this._padding=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(t,i){const e=this.options;if(this.left=0,this.top=0,!e.display)return void(this.width=this.height=this.right=this.bottom=0);this.width=this.right=t,this.height=this.bottom=i;const s=Z(e.text)?e.text.length:1;this._padding=ki(e.padding);const n=s*Oi(e.font).lineHeight+this._padding.height;this.isHorizontal()?this.height=n:this.width=n}isHorizontal(){const t=this.options.position;return"top"===t||"bottom"===t}_drawArgs(t){const{top:i,left:e,bottom:s,right:n,options:r}=this,o=r.align;let h,a,c,l=0;return this.isHorizontal()?(a=zt(o,e,n),c=i+t,h=n-e):("left"===r.position?(a=e+t,c=zt(o,s,i),l=-.5*pt):(a=n-t,c=zt(o,i,s),l=.5*pt),h=s-i),{titleX:a,titleY:c,maxWidth:h,rotation:l}}draw(){const t=this.ctx,i=this.options;if(!i.display)return;const e=Oi(i.font),s=e.lineHeight/2+this._padding.top,{titleX:n,titleY:r,maxWidth:o,rotation:h}=this._drawArgs(s);gi(t,i.text,0,0,e,{color:i.color,maxWidth:o,rotation:h,textAlign:Nt(i.align),textBaseline:"middle",translation:[n,r]})}}var bn={id:"title",_element:dn,start(t,i,e){!function(t,i){const e=new dn({ctx:t.ctx,options:i,chart:t});Ue.configure(t,e,i),Ue.addBox(t,e),t.titleBlock=e}(t,e)},stop(t){Ue.removeBox(t,t.titleBlock),delete t.titleBlock},beforeUpdate(t,i,e){const s=t.titleBlock;Ue.configure(t,s,e),s.options=e},defaults:{align:"center",display:!1,font:{weight:"bold"},fullSize:!0,padding:10,position:"top",text:"",weight:2e3},defaultRoutes:{color:"color"},descriptors:{_scriptable:!0,_indexable:!1}};const pn={average(t){if(!t.length)return!1;let i,e,s=new Set,n=0,r=0;for(i=0,e=t.length;i<e;++i){const e=t[i].element;if(e&&e.hasValue()){const t=e.tooltipPosition();s.add(t.x),n+=t.y,++r}}return 0!==r&&0!==s.size&&{x:[...s].reduce(((t,i)=>t+i))/s.size,y:n/r}},nearest(t,i){if(!t.length)return!1;let e,s,n,r=i.x,o=i.y,h=Number.POSITIVE_INFINITY;for(e=0,s=t.length;e<s;++e){const s=t[e].element;if(s&&s.hasValue()){const t=(a=i,c=s.getCenterPoint(),Math.sqrt(Math.pow(c.x-a.x,2)+Math.pow(c.y-a.y,2)));t<h&&(h=t,n=s)}}var a,c;if(n){const t=n.tooltipPosition();r=t.x,o=t.y}return{x:r,y:o}}};function gn(t,i){return i&&(Z(i)?Array.prototype.push.apply(t,i):t.push(i)),t}function mn(t){return("string"==typeof t||t instanceof String)&&t.indexOf("\n")>-1?t.split("\n"):t}function vn(t,i){const{element:e,datasetIndex:s,index:n}=i,r=t.getDatasetMeta(s).controller,{label:o,value:h}=r.getLabelAndValue(n);return{chart:t,label:o,parsed:r.getParsed(n),raw:t.data.datasets[s].data[n],formattedValue:h,dataset:r.getDataset(),dataIndex:n,datasetIndex:s,element:e}}function xn(t,i){const e=t.chart.ctx,{body:s,footer:n,title:r}=t,{boxWidth:o,boxHeight:h}=i,a=Oi(i.bodyFont),c=Oi(i.titleFont),l=Oi(i.footerFont),u=r.length,f=n.length,d=s.length,b=ki(i.padding);let p=b.height,g=0,m=s.reduce(((t,i)=>t+i.before.length+i.lines.length+i.after.length),0);m+=t.beforeBody.length+t.afterBody.length,u&&(p+=u*c.lineHeight+(u-1)*i.titleSpacing+i.titleMarginBottom),m&&(p+=d*(i.displayColors?Math.max(h,a.lineHeight):a.lineHeight)+(m-d)*a.lineHeight+(m-1)*i.bodySpacing),f&&(p+=i.footerMarginTop+f*l.lineHeight+(f-1)*i.footerSpacing);let v=0;const x=function(t){g=Math.max(g,e.measureText(t).width+v)};return e.save(),e.font=c.string,it(t.title,x),e.font=a.string,it(t.beforeBody.concat(t.afterBody),x),v=i.displayColors?o+2+i.boxPadding:0,it(s,(t=>{it(t.before,x),it(t.lines,x),it(t.after,x)})),v=0,e.font=l.string,it(t.footer,x),e.restore(),g+=b.width,{width:g,height:p}}function yn(t,i,e,s){const{x:n,width:r}=e,{width:o,chartArea:{left:h,right:a}}=t;let c="center";return"center"===s?c=n<=(h+a)/2?"left":"right":n<=r/2?c="left":n>=o-r/2&&(c="right"),function(t,i,e,s){const{x:n,width:r}=s,o=e.caretSize+e.caretPadding;return"left"===t&&n+r+o>i.width||"right"===t&&n-r-o<0||void 0}(c,t,i,e)&&(c="center"),c}function Mn(t,i,e){const s=e.yAlign||i.yAlign||function(t,i){const{y:e,height:s}=i;return e<s/2?"top":e>t.height-s/2?"bottom":"center"}(t,e);return{xAlign:e.xAlign||i.xAlign||yn(t,i,e,s),yAlign:s}}function wn(t,i,e,s){const{caretSize:n,caretPadding:r,cornerRadius:o}=t,{xAlign:h,yAlign:a}=e,c=n+r,{topLeft:l,topRight:u,bottomLeft:f,bottomRight:d}=_i(o);let b=function(t,i){let{x:e,width:s}=t;return"right"===i?e-=s:"center"===i&&(e-=s/2),e}(i,h);const p=function(t,i,e){let{y:s,height:n}=t;return"top"===i?s+=e:s-="bottom"===i?n+e:n/2,s}(i,a,c);return"center"===a?"left"===h?b+=c:"right"===h&&(b-=c):"left"===h?b-=Math.max(l,f)+n:"right"===h&&(b+=Math.max(u,d)+n),{x:Rt(b,0,s.width-i.width),y:Rt(p,0,s.height-i.height)}}function _n(t,i,e){const s=ki(e.padding);return"center"===i?t.x+t.width/2:"right"===i?t.x+t.width-s.right:t.x+s.left}function kn(t){return gn([],mn(t))}function On(t,i){const e=i&&i.dataset&&i.dataset.tooltip&&i.dataset.tooltip.callbacks;return e?t.override(e):t}const Sn={beforeTitle:V,title(t){if(t.length>0){const i=t[0],e=i.chart.data.labels,s=e?e.length:0;if(this&&this.options&&"dataset"===this.options.mode)return i.dataset.label||"";if(i.label)return i.label;if(s>0&&i.dataIndex<s)return e[i.dataIndex]}return""},afterTitle:V,beforeBody:V,beforeLabel:V,label(t){if(this&&this.options&&"dataset"===this.options.mode)return t.label+": "+t.formattedValue||t.formattedValue;let i=t.dataset.label||"";i&&(i+=": ");const e=t.formattedValue;return U(e)||(i+=e),i},labelColor(t){const i=t.chart.getDatasetMeta(t.datasetIndex).controller.getStyle(t.dataIndex);return{borderColor:i.borderColor,backgroundColor:i.backgroundColor,borderWidth:i.borderWidth,borderDash:i.borderDash,borderDashOffset:i.borderDashOffset,borderRadius:0}},labelTextColor(){return this.options.bodyColor},labelPointStyle(t){const i=t.chart.getDatasetMeta(t.datasetIndex).controller.getStyle(t.dataIndex);return{pointStyle:i.pointStyle,rotation:i.rotation}},afterLabel:V,afterBody:V,beforeFooter:V,footer:V,afterFooter:V};function An(t,i,e,s){const n=t[i].call(e,s);return void 0===n?Sn[i].call(e,s):n}class Dn extends us{static positioners=pn;constructor(t){super(),this.opacity=0,this._active=[],this._eventPosition=void 0,this._size=void 0,this._cachedAnimations=void 0,this._tooltipItems=[],this.$animations=void 0,this.$context=void 0,this.chart=t.chart,this.options=t.options,this.dataPoints=void 0,this.title=void 0,this.beforeBody=void 0,this.body=void 0,this.afterBody=void 0,this.footer=void 0,this.xAlign=void 0,this.yAlign=void 0,this.x=void 0,this.y=void 0,this.height=void 0,this.width=void 0,this.caretX=void 0,this.caretY=void 0,this.labelColors=void 0,this.labelPointStyles=void 0,this.labelTextColors=void 0}initialize(t){this.options=t,this._cachedAnimations=void 0,this.$context=void 0}_resolveAnimations(){const t=this._cachedAnimations;if(t)return t;const i=this.chart,e=this.options.setContext(this.getContext()),s=e.enabled&&i.options.animation&&e.animations,n=new ae(this.chart,s);return s._cacheable&&(this._cachedAnimations=Object.freeze(n)),n}getContext(){return this.$context||(this.$context=Ai(this.chart.getContext(),{tooltip:this,tooltipItems:this._tooltipItems,type:"tooltip"}))}getTitle(t,i){const{callbacks:e}=i,s=An(e,"beforeTitle",this,t),n=An(e,"title",this,t),r=An(e,"afterTitle",this,t);let o=[];return o=gn(o,mn(s)),o=gn(o,mn(n)),o=gn(o,mn(r)),o}getBeforeBody(t,i){return kn(An(i.callbacks,"beforeBody",this,t))}getBody(t,i){const{callbacks:e}=i,s=[];return it(t,(t=>{const i={before:[],lines:[],after:[]},n=On(e,t);gn(i.before,mn(An(n,"beforeLabel",this,t))),gn(i.lines,An(n,"label",this,t)),gn(i.after,mn(An(n,"afterLabel",this,t))),s.push(i)})),s}getAfterBody(t,i){return kn(An(i.callbacks,"afterBody",this,t))}getFooter(t,i){const{callbacks:e}=i,s=An(e,"beforeFooter",this,t),n=An(e,"footer",this,t),r=An(e,"afterFooter",this,t);let o=[];return o=gn(o,mn(s)),o=gn(o,mn(n)),o=gn(o,mn(r)),o}_createItems(t){const i=this._active,e=this.chart.data,s=[],n=[],r=[];let o,h,a=[];for(o=0,h=i.length;o<h;++o)a.push(vn(this.chart,i[o]));return t.filter&&(a=a.filter(((i,s,n)=>t.filter(i,s,n,e)))),t.itemSort&&(a=a.sort(((i,s)=>t.itemSort(i,s,e)))),it(a,(i=>{const e=On(t.callbacks,i);s.push(An(e,"labelColor",this,i)),n.push(An(e,"labelPointStyle",this,i)),r.push(An(e,"labelTextColor",this,i))})),this.labelColors=s,this.labelPointStyles=n,this.labelTextColors=r,this.dataPoints=a,a}update(t,i){const e=this.options.setContext(this.getContext()),s=this._active;let n,r=[];if(s.length){const t=pn[e.position].call(this,s,this._eventPosition);r=this._createItems(e),this.title=this.getTitle(r,e),this.beforeBody=this.getBeforeBody(r,e),this.body=this.getBody(r,e),this.afterBody=this.getAfterBody(r,e),this.footer=this.getFooter(r,e);const i=this._size=xn(this,e),o=Object.assign({},t,i),h=Mn(this.chart,e,o),a=wn(e,o,h,this.chart);this.xAlign=h.xAlign,this.yAlign=h.yAlign,n={opacity:1,x:a.x,y:a.y,width:i.width,height:i.height,caretX:t.x,caretY:t.y}}else 0!==this.opacity&&(n={opacity:0});this._tooltipItems=r,this.$context=void 0,n&&this._resolveAnimations().update(this,n),t&&e.external&&e.external.call(this,{chart:this.chart,tooltip:this,replay:i})}drawCaret(t,i,e,s){const n=this.getCaretPosition(t,e,s);i.lineTo(n.x1,n.y1),i.lineTo(n.x2,n.y2),i.lineTo(n.x3,n.y3)}getCaretPosition(t,i,e){const{xAlign:s,yAlign:n}=this,{caretSize:r,cornerRadius:o}=e,{topLeft:h,topRight:a,bottomLeft:c,bottomRight:l}=_i(o),{x:u,y:f}=t,{width:d,height:b}=i;let p,g,m,v,x,y;return"center"===n?(x=f+b/2,"left"===s?(p=u,g=p-r,v=x+r,y=x-r):(p=u+d,g=p+r,v=x-r,y=x+r),m=p):(g="left"===s?u+Math.max(h,c)+r:"right"===s?u+d-Math.max(a,l)-r:this.caretX,"top"===n?(v=f,x=v-r,p=g-r,m=g+r):(v=f+b,x=v+r,p=g+r,m=g-r),y=v),{x1:p,x2:g,x3:m,y1:v,y2:x,y3:y}}drawTitle(t,i,e){const s=this.title,n=s.length;let r,o,h;if(n){const a=Ji(e.rtl,this.x,this.width);for(t.x=_n(this,e.titleAlign,e),i.textAlign=a.textAlign(e.titleAlign),i.textBaseline="middle",r=Oi(e.titleFont),o=e.titleSpacing,i.fillStyle=e.titleColor,i.font=r.string,h=0;h<n;++h)i.fillText(s[h],a.x(t.x),t.y+r.lineHeight/2),t.y+=r.lineHeight+o,h+1===n&&(t.y+=e.titleMarginBottom-o)}}_drawColorBox(t,i,e,s,n){const r=this.labelColors[e],o=this.labelPointStyles[e],{boxHeight:h,boxWidth:a}=n,c=Oi(n.bodyFont),l=_n(this,"left",n),u=s.x(l),f=i.y+(h<c.lineHeight?(c.lineHeight-h)/2:0);if(n.usePointStyle){const i={radius:Math.min(a,h)/2,pointStyle:o.pointStyle,rotation:o.rotation,borderWidth:1},e=s.leftForLtr(u,a)+a/2,c=f+h/2;t.strokeStyle=n.multiKeyBackground,t.fillStyle=n.multiKeyBackground,ci(t,i,e,c),t.strokeStyle=r.borderColor,t.fillStyle=r.backgroundColor,ci(t,i,e,c)}else{t.lineWidth=K(r.borderWidth)?Math.max(...Object.values(r.borderWidth)):r.borderWidth||1,t.strokeStyle=r.borderColor,t.setLineDash(r.borderDash||[]),t.lineDashOffset=r.borderDashOffset||0;const i=s.leftForLtr(u,a),e=s.leftForLtr(s.xPlus(u,1),a-2),o=_i(r.borderRadius);Object.values(o).some((t=>0!==t))?(t.beginPath(),t.fillStyle=n.multiKeyBackground,mi(t,{x:i,y:f,w:a,h,radius:o}),t.fill(),t.stroke(),t.fillStyle=r.backgroundColor,t.beginPath(),mi(t,{x:e,y:f+1,w:a-2,h:h-2,radius:o}),t.fill()):(t.fillStyle=n.multiKeyBackground,t.fillRect(i,f,a,h),t.strokeRect(i,f,a,h),t.fillStyle=r.backgroundColor,t.fillRect(e,f+1,a-2,h-2))}t.fillStyle=this.labelTextColors[e]}drawBody(t,i,e){const{body:s}=this,{bodySpacing:n,bodyAlign:r,displayColors:o,boxHeight:h,boxWidth:a,boxPadding:c}=e,l=Oi(e.bodyFont);let u=l.lineHeight,f=0;const d=Ji(e.rtl,this.x,this.width),b=function(e){i.fillText(e,d.x(t.x+f),t.y+u/2),t.y+=u+n},p=d.textAlign(r);let g,m,v,x,y,M,w;for(i.textAlign=r,i.textBaseline="middle",i.font=l.string,t.x=_n(this,p,e),i.fillStyle=e.bodyColor,it(this.beforeBody,b),f=o&&"right"!==p?"center"===r?a/2+c:a+2+c:0,x=0,M=s.length;x<M;++x){for(g=s[x],m=this.labelTextColors[x],i.fillStyle=m,it(g.before,b),v=g.lines,o&&v.length&&(this._drawColorBox(i,t,x,d,e),u=Math.max(l.lineHeight,h)),y=0,w=v.length;y<w;++y)b(v[y]),u=l.lineHeight;it(g.after,b)}f=0,u=l.lineHeight,it(this.afterBody,b),t.y-=n}drawFooter(t,i,e){const s=this.footer,n=s.length;let r,o;if(n){const h=Ji(e.rtl,this.x,this.width);for(t.x=_n(this,e.footerAlign,e),t.y+=e.footerMarginTop,i.textAlign=h.textAlign(e.footerAlign),i.textBaseline="middle",r=Oi(e.footerFont),i.fillStyle=e.footerColor,i.font=r.string,o=0;o<n;++o)i.fillText(s[o],h.x(t.x),t.y+r.lineHeight/2),t.y+=r.lineHeight+e.footerSpacing}}drawBackground(t,i,e,s){const{xAlign:n,yAlign:r}=this,{x:o,y:h}=t,{width:a,height:c}=e,{topLeft:l,topRight:u,bottomLeft:f,bottomRight:d}=_i(s.cornerRadius);i.fillStyle=s.backgroundColor,i.strokeStyle=s.borderColor,i.lineWidth=s.borderWidth,i.beginPath(),i.moveTo(o+l,h),"top"===r&&this.drawCaret(t,i,e,s),i.lineTo(o+a-u,h),i.quadraticCurveTo(o+a,h,o+a,h+u),"center"===r&&"right"===n&&this.drawCaret(t,i,e,s),i.lineTo(o+a,h+c-d),i.quadraticCurveTo(o+a,h+c,o+a-d,h+c),"bottom"===r&&this.drawCaret(t,i,e,s),i.lineTo(o+f,h+c),i.quadraticCurveTo(o,h+c,o,h+c-f),"center"===r&&"left"===n&&this.drawCaret(t,i,e,s),i.lineTo(o,h+l),i.quadraticCurveTo(o,h,o+l,h),i.closePath(),i.fill(),s.borderWidth>0&&i.stroke()}_updateAnimationTarget(t){const i=this.chart,e=this.$animations,s=e&&e.x,n=e&&e.y;if(s||n){const e=pn[t.position].call(this,this._active,this._eventPosition);if(!e)return;const r=this._size=xn(this,t),o=Object.assign({},e,this._size),h=Mn(i,t,o),a=wn(t,o,h,i);s._to===a.x&&n._to===a.y||(this.xAlign=h.xAlign,this.yAlign=h.yAlign,this.width=r.width,this.height=r.height,this.caretX=e.x,this.caretY=e.y,this._resolveAnimations().update(this,a))}}_willRender(){return!!this.opacity}draw(t){const i=this.options.setContext(this.getContext());let e=this.opacity;if(!e)return;this._updateAnimationTarget(i);const s={width:this.width,height:this.height},n={x:this.x,y:this.y};e=Math.abs(e)<.001?0:e;const r=ki(i.padding);i.enabled&&(this.title.length||this.beforeBody.length||this.body.length||this.afterBody.length||this.footer.length)&&(t.save(),t.globalAlpha=e,this.drawBackground(n,t,s,i),te(t,i.textDirection),n.y+=r.top,this.drawTitle(n,t,i),this.drawBody(n,t,i),this.drawFooter(n,t,i),ie(t,i.textDirection),t.restore())}getActiveElements(){return this._active||[]}setActiveElements(t,i){const e=this._active,s=t.map((({datasetIndex:t,index:i})=>{const e=this.chart.getDatasetMeta(t);if(!e)throw new Error("Cannot find a dataset at index "+t);return{datasetIndex:t,element:e.data[i],index:i}})),n=!et(e,s),r=this._positionChanged(s,i);(n||r)&&(this._active=s,this._eventPosition=i,this._ignoreReplayEvents=!0,this.update(!0))}handleEvent(t,i,e=!0){if(i&&this._ignoreReplayEvents)return!1;this._ignoreReplayEvents=!1;const s=this.options,n=this._active||[],r=this._getActiveElements(t,n,i,e),o=this._positionChanged(r,t),h=i||!et(r,n)||o;return h&&(this._active=r,(s.enabled||s.external)&&(this._eventPosition={x:t.x,y:t.y},this.update(!0,i))),h}_getActiveElements(t,i,e,s){const n=this.options;if("mouseout"===t.type)return[];if(!s)return i.filter((t=>this.chart.data.datasets[t.datasetIndex]&&void 0!==this.chart.getDatasetMeta(t.datasetIndex).controller.getParsed(t.index)));const r=this.chart.getElementsAtEventForMode(t,n.mode,n,e);return n.reverse&&r.reverse(),r}_positionChanged(t,i){const{caretX:e,caretY:s,options:n}=this,r=pn[n.position].call(this,t,i);return!1!==r&&(e!==r.x||s!==r.y)}}var jn={id:"tooltip",_element:Dn,positioners:pn,afterInit(t,i,e){e&&(t.tooltip=new Dn({chart:t,options:e}))},beforeUpdate(t,i,e){t.tooltip&&t.tooltip.initialize(e)},reset(t,i,e){t.tooltip&&t.tooltip.initialize(e)},afterDraw(t){const i=t.tooltip;if(i&&i._willRender()){const e={tooltip:i};if(!1===t.notifyPlugins("beforeTooltipDraw",{...e,cancelable:!0}))return;i.draw(t.ctx),t.notifyPlugins("afterTooltipDraw",e)}},afterEvent(t,i){t.tooltip&&t.tooltip.handleEvent(i.event,i.replay,i.inChartArea)&&(i.changed=!0)},defaults:{enabled:!0,external:null,position:"average",backgroundColor:"rgba(0,0,0,0.8)",titleColor:"#fff",titleFont:{weight:"bold"},titleSpacing:2,titleMarginBottom:6,titleAlign:"left",bodyColor:"#fff",bodySpacing:2,bodyFont:{},bodyAlign:"left",footerColor:"#fff",footerSpacing:2,footerMarginTop:6,footerFont:{weight:"bold"},footerAlign:"left",padding:6,caretPadding:2,caretSize:5,cornerRadius:6,boxHeight:(t,i)=>i.bodyFont.size,boxWidth:(t,i)=>i.bodyFont.size,multiKeyBackground:"#fff",displayColors:!0,boxPadding:0,borderColor:"rgba(0,0,0,0)",borderWidth:0,animation:{duration:400,easing:"easeOutQuart"},animations:{numbers:{type:"number",properties:["x","y","width","height","caretX","caretY"]},opacity:{easing:"linear",duration:200}},callbacks:Sn},defaultRoutes:{bodyFont:"font",footerFont:"font",titleFont:"font"},descriptors:{_scriptable:t=>"filter"!==t&&"itemSort"!==t&&"external"!==t,_indexable:!1,callbacks:{_scriptable:!1,_indexable:!1},animation:{_fallback:!1},animations:{_fallback:"animation"}},additionalOptionScopes:["interaction"]};function Cn(t){const i=this.getLabels();return t>=0&&t<i.length?i[t]:t}function Rn(t,i,{horizontal:e,minRotation:s}){const n=At(s),r=(e?Math.sin(n):Math.cos(n))||.001;return Math.min(i/r,.75*i*(""+t).length)}class En extends ys{constructor(t){super(t),this.start=void 0,this.end=void 0,this._startValue=void 0,this._endValue=void 0,this._valueRange=0}parse(t,i){return U(t)||("number"==typeof t||t instanceof Number)&&!isFinite(+t)?null:+t}handleTickRangeOptions(){const{beginAtZero:t}=this.options,{minDefined:i,maxDefined:e}=this.getUserBounds();let{min:s,max:n}=this;const r=t=>s=i?s:t,o=t=>n=e?n:t;if(t){const t=_t(s),i=_t(n);t<0&&i<0?o(0):t>0&&i>0&&r(0)}if(s===n){let i=0===n?1:Math.abs(.05*n);o(n+i),t||r(s-i)}this.min=s,this.max=n}getTickLimit(){const t=this.options.ticks;let i,{maxTicksLimit:e,stepSize:s}=t;return s?(i=Math.ceil(this.max/s)-Math.floor(this.min/s)+1,i>1e3&&(console.warn(`scales.${this.id}.ticks.stepSize: ${s} would result generating up to ${i} ticks. Limiting to 1000.`),i=1e3)):(i=this.computeTickLimit(),e=e||11),e&&(i=Math.min(e,i)),i}computeTickLimit(){return Number.POSITIVE_INFINITY}buildTicks(){const t=this.options,i=t.ticks;let e=this.getTickLimit();e=Math.max(2,e);const s=function(t,i){const e=[],{bounds:s,step:n,min:r,max:o,precision:h,count:a,maxTicks:c,maxDigits:l,includeBounds:u}=t,f=n||1,d=c-1,{min:b,max:p}=i,g=!U(r),m=!U(o),v=!U(a),x=(p-b)/(l+1);let y,M,w,_,k=Ot((p-b)/d/f)*f;if(k<1e-14&&!g&&!m)return[{value:b},{value:p}];_=Math.ceil(p/k)-Math.floor(b/k),_>d&&(k=Ot(_*k/d/f)*f),U(h)||(y=Math.pow(10,h),k=Math.ceil(k*y)/y),"ticks"===s?(M=Math.floor(b/k)*k,w=Math.ceil(p/k)*k):(M=b,w=p),g&&m&&n&&function(t,i){const e=Math.round(t);return e-i<=t&&e+i>=t}((o-r)/n,k/1e3)?(_=Math.round(Math.min((o-r)/k,c)),k=(o-r)/_,M=r,w=o):v?(M=g?r:M,w=m?o:w,_=a-1,k=(w-M)/_):(_=(w-M)/k,_=kt(_,Math.round(_),k/1e3)?Math.round(_):Math.ceil(_));const O=Math.max(Dt(k),Dt(M));y=Math.pow(10,U(h)?O:h),M=Math.round(M*y)/y,w=Math.round(w*y)/y;let S=0;for(g&&(u&&M!==r?(e.push({value:r}),M<r&&S++,kt(Math.round((M+S*k)*y)/y,r,Rn(r,x,t))&&S++):M<r&&S++);S<_;++S){const t=Math.round((M+S*k)*y)/y;if(m&&t>o)break;e.push({value:t})}return m&&u&&w!==o?e.length&&kt(e[e.length-1].value,o,Rn(o,x,t))?e[e.length-1].value=o:e.push({value:o}):m&&w!==o||e.push({value:w}),e}({maxTicks:e,bounds:t.bounds,min:t.min,max:t.max,precision:i.precision,step:i.stepSize,count:i.count,maxDigits:this._maxDigits(),horizontal:this.isHorizontal(),minRotation:i.minRotation||0,includeBounds:!1!==i.includeBounds},this._range||this);return"ticks"===t.bounds&&function(t,i){let e,s,n;for(e=0,s=t.length;e<s;e++)n=t[e].value,isNaN(n)||(i.min=Math.min(i.min,n),i.max=Math.max(i.max,n))}(s,this),t.reverse?(s.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),s}configure(){const t=this.ticks;let i=this.min,e=this.max;if(super.configure(),this.options.offset&&t.length){const s=(e-i)/Math.max(t.length-1,1)/2;i-=s,e+=s}this._startValue=i,this._endValue=e,this._valueRange=e-i}getLabelForValue(t){return Gt(t,this.chart.options.locale,this.options.ticks.format)}}const Ln=s();class Pn{async fetchGrossVolumeChartData(t,i){return Ln.get({endpoint:`account/${t}/reports/gross_volume`,authToken:i})}}Ks.register(an,class extends ye{static id="bar";static defaults={datasetElementType:!1,dataElementType:"bar",categoryPercentage:.8,barPercentage:.9,grouped:!0,animations:{numbers:{type:"number",properties:["x","y","base","width","height"]}}};static overrides={scales:{_index_:{type:"category",offset:!0,grid:{offset:!0}},_value_:{type:"linear",beginAtZero:!0}}};parsePrimitiveData(t,i,e,s){return we(t,i,e,s)}parseArrayData(t,i,e,s){return we(t,i,e,s)}parseObjectData(t,i,e,s){const{iScale:n,vScale:r}=t,{xAxisKey:o="x",yAxisKey:h="y"}=this._parsing,a="x"===n.axis?o:h,c="x"===r.axis?o:h,l=[];let u,f,d,b;for(u=e,f=e+s;u<f;++u)b=i[u],d={},d[n.axis]=n.parse(lt(b,a),u),l.push(Me(lt(b,c),d,r,u));return l}updateRangeFromParsed(t,i,e,s){super.updateRangeFromParsed(t,i,e,s);const n=e._custom;n&&i===this._cachedMeta.vScale&&(t.min=Math.min(t.min,n.min),t.max=Math.max(t.max,n.max))}getMaxOverflow(){return 0}getLabelAndValue(t){const i=this._cachedMeta,{iScale:e,vScale:s}=i,n=this.getParsed(t),r=n._custom,o=_e(r)?"["+r.start+", "+r.end+"]":""+s.getLabelForValue(n[s.axis]);return{label:""+e.getLabelForValue(n[e.axis]),value:o}}initialize(){this.enableOptionSharing=!0,super.initialize(),this._cachedMeta.stack=this.getDataset().stack}update(t){const i=this._cachedMeta;this.updateElements(i.data,0,i.data.length,t)}updateElements(t,i,e,s){const n="reset"===s,{index:r,_cachedMeta:{vScale:o}}=this,h=o.getBasePixel(),a=o.isHorizontal(),c=this._getRuler(),{sharedOptions:l,includeOptions:u}=this._getSharedOptions(i,s);for(let f=i;f<i+e;f++){const i=this.getParsed(f),e=n||U(i[o.axis])?{base:h,head:h}:this._calculateBarValuePixels(f),d=this._calculateBarIndexPixels(f,c),b=(i._stacks||{})[o.axis],p={horizontal:a,base:e.base,enableBorderRadius:!b||_e(i._custom)||r===b._top||r===b._bottom,x:a?e.head:d.center,y:a?d.center:e.head,height:a?d.size:Math.abs(e.size),width:a?Math.abs(e.size):d.size};u&&(p.options=l||this.resolveDataElementOptions(f,t[f].active?"active":s));const g=p.options||t[f].options;ke(p,g,b,r),Ae(p,g,c.ratio),this.updateElement(t[f],f,p,s)}}_getStacks(t,i){const{iScale:e}=this._cachedMeta,s=e.getMatchingVisibleMetas(this._type).filter((t=>t.controller.options.grouped)),n=e.options.stacked,r=[],o=this._cachedMeta.controller.getParsed(i),h=o&&o[e.axis],a=t=>{const i=t._parsed.find((t=>t[e.axis]===h)),s=i&&i[t.vScale.axis];if(U(s)||isNaN(s))return!0};for(const e of s)if((void 0===i||!a(e))&&((!1===n||-1===r.indexOf(e.stack)||void 0===n&&void 0===e.stack)&&r.push(e.stack),e.index===t))break;return r.length||r.push(void 0),r}_getStackCount(t){return this._getStacks(void 0,t).length}_getAxisCount(){return this._getAxis().length}getFirstScaleIdForIndexAxis(){const t=this.chart.scales,i=this.chart.options.indexAxis;return Object.keys(t).filter((e=>t[e].axis===i)).shift()}_getAxis(){const t={},i=this.getFirstScaleIdForIndexAxis();for(const e of this.chart.data.datasets)t[G("x"===this.chart.options.indexAxis?e.xAxisID:e.yAxisID,i)]=!0;return Object.keys(t)}_getStackIndex(t,i,e){const s=this._getStacks(t,e),n=void 0!==i?s.indexOf(i):-1;return-1===n?s.length-1:n}_getRuler(){const t=this.options,i=this._cachedMeta,e=i.iScale,s=[];let n,r;for(n=0,r=i.data.length;n<r;++n)s.push(e.getPixelForValue(this.getParsed(n)[e.axis],n));const o=t.barThickness,h=o||function(t){const i=t.iScale,e=function(t,i){if(!t._cache.$bar){const e=t.getMatchingVisibleMetas(i);let s=[];for(let i=0,n=e.length;i<n;i++)s=s.concat(e[i].controller.getAllParsedValues(t));t._cache.$bar=function(t){const i=new Set(t);return i.size===t.length?t:Array.from(i)}(s.sort(((t,i)=>t-i)))}return t._cache.$bar}(i,t.type);let s,n,r,o,h=i._length;const a=()=>{32767!==r&&-32768!==r&&(ft(o)&&(h=Math.min(h,Math.abs(r-o)||h)),o=r)};for(s=0,n=e.length;s<n;++s)r=i.getPixelForValue(e[s]),a();for(o=void 0,s=0,n=i.ticks.length;s<n;++s)r=i.getPixelForTick(s),a();return h}(i);return{min:h,pixels:s,start:e._startPixel,end:e._endPixel,stackCount:this._getStackCount(),scale:e,grouped:t.grouped,ratio:o?1:t.categoryPercentage*t.barPercentage}}_calculateBarValuePixels(t){const{_cachedMeta:{vScale:i,_stacked:e,index:s},options:{base:n,minBarLength:r}}=this,o=n||0,h=this.getParsed(t),a=h._custom,c=_e(a);let l,u,f=h[i.axis],d=0,b=e?this.applyStack(i,h,e):f;b!==f&&(d=b-f,b=f),c&&(f=a.barStart,b=a.barEnd-a.barStart,0!==f&&_t(f)!==_t(a.barEnd)&&(d=0),d+=f);const p=U(n)||c?d:n;let g=i.getPixelForValue(p);if(l=this.chart.getDataVisibility(t)?i.getPixelForValue(d+b):g,u=l-g,Math.abs(u)<r){u=function(t,i,e){return 0!==t?_t(t):(i.isHorizontal()?1:-1)*(i.min>=e?1:-1)}(u,i,o)*r,f===o&&(g-=u/2);const t=i.getPixelForDecimal(0),n=i.getPixelForDecimal(1),a=Math.min(t,n),d=Math.max(t,n);g=Math.max(Math.min(g,d),a),l=g+u,e&&!c&&(h._stacks[i.axis]._visualValues[s]=i.getValueForPixel(l)-i.getValueForPixel(g))}if(g===i.getPixelForValue(o)){const t=_t(u)*i.getLineWidthForValue(o)/2;g+=t,u-=t}return{size:u,base:g,head:l,center:l+u/2}}_calculateBarIndexPixels(t,i){const e=i.scale,s=this.options,n=s.skipNull,r=G(s.maxBarThickness,1/0);let o,h;const a=this._getAxisCount();if(i.grouped){const e=n?this._getStackCount(t):i.stackCount,c="flex"===s.barThickness?function(t,i,e,s){const n=i.pixels,r=n[t];let o=t>0?n[t-1]:null,h=t<n.length-1?n[t+1]:null;const a=e.categoryPercentage;null===o&&(o=r-(null===h?i.end-i.start:h-r)),null===h&&(h=r+r-o);const c=r-(r-Math.min(o,h))/2*a;return{chunk:Math.abs(h-o)/2*a/s,ratio:e.barPercentage,start:c}}(t,i,s,e*a):function(t,i,e,s){const n=e.barThickness;let r,o;return U(n)?(r=i.min*e.categoryPercentage,o=e.barPercentage):(r=n*s,o=1),{chunk:r/s,ratio:o,start:i.pixels[t]-r/2}}(t,i,s,e*a),l="x"===this.chart.options.indexAxis?this.getDataset().xAxisID:this.getDataset().yAxisID,u=this._getAxis().indexOf(G(l,this.getFirstScaleIdForIndexAxis())),f=this._getStackIndex(this.index,this._cachedMeta.stack,n?t:void 0)+u;o=c.start+c.chunk*f+c.chunk/2,h=Math.min(r,c.chunk*c.ratio)}else o=e.getPixelForValue(this.getParsed(t)[e.axis],t),h=Math.min(r,i.min*i.ratio);return{base:o-h/2,head:o+h/2,center:o,size:h}}draw(){const t=this._cachedMeta,i=t.vScale,e=t.data,s=e.length;let n=0;for(;n<s;++n)null===this.getParsed(n)[i.axis]||e[n].hidden||e[n].draw(this._ctx)}},class extends us{static id="bar";static defaults={borderSkipped:"start",borderWidth:0,borderRadius:0,inflateAmount:"auto",pointStyle:void 0};static defaultRoutes={backgroundColor:"backgroundColor",borderColor:"borderColor"};constructor(t){super(),this.options=void 0,this.horizontal=void 0,this.base=void 0,this.width=void 0,this.height=void 0,this.inflateAmount=void 0,t&&Object.assign(this,t)}draw(t){const{inflateAmount:i,options:{borderColor:e,backgroundColor:s}}=this,{inner:n,outer:r}=function(t){const i=qs(t),e=i.right-i.left,s=i.bottom-i.top,n=function(t,i,e){const s=t.borderSkipped,n=wi(t.options.borderWidth);return{t:Gs(s.top,n.top,0,e),r:Gs(s.right,n.right,0,i),b:Gs(s.bottom,n.bottom,0,e),l:Gs(s.left,n.left,0,i)}}(t,e/2,s/2),r=function(t,i,e){const{enableBorderRadius:s}=t.getProps(["enableBorderRadius"]),n=t.options.borderRadius,r=_i(n),o=Math.min(i,e),h=t.borderSkipped,a=s||K(n);return{topLeft:Gs(!a||h.top||h.left,r.topLeft,0,o),topRight:Gs(!a||h.top||h.right,r.topRight,0,o),bottomLeft:Gs(!a||h.bottom||h.left,r.bottomLeft,0,o),bottomRight:Gs(!a||h.bottom||h.right,r.bottomRight,0,o)}}(t,e/2,s/2);return{outer:{x:i.left,y:i.top,w:e,h:s,radius:r},inner:{x:i.left+n.l,y:i.top+n.t,w:e-n.l-n.r,h:s-n.t-n.b,radius:{topLeft:Math.max(0,r.topLeft-Math.max(n.t,n.l)),topRight:Math.max(0,r.topRight-Math.max(n.t,n.r)),bottomLeft:Math.max(0,r.bottomLeft-Math.max(n.b,n.l)),bottomRight:Math.max(0,r.bottomRight-Math.max(n.b,n.r))}}}}(this),o=(h=r.radius).topLeft||h.topRight||h.bottomLeft||h.bottomRight?mi:tn;var h;t.save(),r.w===n.w&&r.h===n.h||(t.beginPath(),o(t,en(r,i,n)),t.clip(),o(t,en(n,-i,r)),t.fillStyle=e,t.fill("evenodd")),t.beginPath(),o(t,en(n,i)),t.fillStyle=s,t.fill(),t.restore()}inRange(t,i,e){return Js(this,t,i,e)}inXRange(t,i){return Js(this,t,null,i)}inYRange(t,i){return Js(this,null,t,i)}getCenterPoint(t){const{x:i,y:e,base:s,horizontal:n}=this.getProps(["x","y","base","horizontal"],t);return{x:n?(i+s)/2:i,y:n?e:(e+s)/2}}getRange(t){return"x"===t?this.width/2:this.height/2}},class extends ys{static id="category";static defaults={ticks:{callback:Cn}};constructor(t){super(t),this._startValue=void 0,this._valueRange=0,this._addedLabels=[]}init(t){const i=this._addedLabels;if(i.length){const t=this.getLabels();for(const{index:e,label:s}of i)t[e]===s&&t.splice(e,1);this._addedLabels=[]}super.init(t)}parse(t,i){if(U(t))return null;const e=this.getLabels();return((t,i)=>null===t?null:Rt(Math.round(t),0,i))(i=isFinite(i)&&e[i]===t?i:function(t,i,e,s){const n=t.indexOf(i);return-1===n?((t,i,e,s)=>("string"==typeof i?(e=t.push(i)-1,s.unshift({index:e,label:i})):isNaN(i)&&(e=null),e))(t,i,e,s):n!==t.lastIndexOf(i)?e:n}(e,t,G(i,t),this._addedLabels),e.length-1)}determineDataLimits(){const{minDefined:t,maxDefined:i}=this.getUserBounds();let{min:e,max:s}=this.getMinMax(!0);"ticks"===this.options.bounds&&(t||(e=0),i||(s=this.getLabels().length-1)),this.min=e,this.max=s}buildTicks(){const t=this.min,i=this.max,e=this.options.offset,s=[];let n=this.getLabels();n=0===t&&i===n.length-1?n:n.slice(t,i+1),this._valueRange=Math.max(n.length-(e?0:1),1),this._startValue=this.min-(e?.5:0);for(let e=t;e<=i;e++)s.push({value:e});return s}getLabelForValue(t){return Cn.call(this,t)}configure(){super.configure(),this.isHorizontal()||(this._reversePixels=!this._reversePixels)}getPixelForValue(t){return"number"!=typeof t&&(t=this.parse(t)),null===t?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getPixelForTick(t){const i=this.ticks;return t<0||t>i.length-1?null:this.getPixelForValue(i[t].value)}getValueForPixel(t){return Math.round(this._startValue+this.getDecimalForPixel(t)*this._valueRange)}getBasePixel(){return this.bottom}},class extends En{static id="linear";static defaults={ticks:{callback:Jt.formatters.numeric}};determineDataLimits(){const{min:t,max:i}=this.getMinMax(!0);this.min=Q(t)?t:0,this.max=Q(i)?i:1,this.handleTickRangeOptions()}computeTickLimit(){const t=this.isHorizontal(),i=t?this.width:this.height,e=At(this.options.ticks.minRotation),s=(t?Math.sin(e):Math.cos(e))||.001,n=this._resolveTickFontOptions(0);return Math.ceil(i/Math.min(40,n.lineHeight/s))}getPixelForValue(t){return null===t?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getValueForPixel(t){return this._startValue+this.getDecimalForPixel(t)*this._valueRange}},fn,jn,bn);const Tn=class{constructor(e){t(this,e),this.errorEvent=i(this,"error-event",7),this.loading=!0,this.errorMessage="",this.wrapperErrorMessage=null}componentWillLoad(){l(),this.analytics=new c(this),this.initializeGetGrossPayment()}componentDidLoad(){this.getGrossPayment&&this.fetchData()}disconnectedCallback(){var t;null===(t=this.analytics)||void 0===t||t.cleanup(),this.chart&&this.chart.destroy()}authPropChanged(){this.initializeGetGrossPayment(),this.getGrossPayment&&this.fetchData()}grossVolumeReportChanged(t){t&&(this.chart?this.updateChartData(t):this.initChart(t))}initializeGetGrossPayment(){this.accountId&&this.authToken?(this.wrapperErrorMessage=null,this.errorMessage="",this.getGrossPayment=(({id:t,authToken:i,service:e})=>async({onSuccess:s,onError:r})=>{var a;try{const c=await e.fetchGrossVolumeChartData(t,i);c.error?r({error:h(c.error),code:o(null===(a=c.error)||void 0===a?void 0:a.code),severity:n.ERROR}):s(c.data)}catch(t){const i=o(null==t?void 0:t.code);r({error:h(t),code:i,severity:n.ERROR})}})({id:this.accountId,authToken:this.authToken,service:new Pn})):(this.getGrossPayment=void 0,this.wrapperErrorMessage="Account ID and Auth Token are required",this.errorEvent.emit({errorCode:r.MISSING_PROPS,message:this.wrapperErrorMessage,severity:n.ERROR}))}async fetchData(){this.loading=!0,this.getGrossPayment({onSuccess:t=>{this.loading=!1,this.grossVolumeReport=t},onError:({error:t,code:i,severity:e})=>{this.loading=!1,this.errorMessage=t,this.errorEvent.emit({errorCode:i,message:t,severity:e})}})}initChart(t){const{dates:i,total:e}=t,s=i.reverse(),n=((t,i,e)=>({type:"bar",options:{plugins:{legend:{display:!1},title:{display:!0,text:["Trailing 30 Days","Gross Payments",u(t)],position:"top",align:"start"},tooltip:{displayColors:!1,intersect:!1,callbacks:{label:t=>{const s=t.dataIndex;return[f(i[s].date,e),u(i[s].value)]}}}},scales:{x:{grid:{drawOnChartArea:!1,drawTicks:!1},ticks:{callback:t=>{if(0===t||t===i.length-1)return f(i[t].date,e)}}},y:{display:!1}}},data:{labels:i.map((()=>"")),datasets:[{label:"Gross Volume by Date",data:i.map((t=>t.value))}]}}))(e,s,s[i.length-1].date);this.chart=new Ks(this.chartRef.getContext("2d"),n)}updateChartData(t){const i=t.dates.map((t=>t.value));this.chart.data.datasets.forEach((t=>{t.data=i})),this.chart.update()}render(){return this.wrapperErrorMessage?e(b,null,a(this.wrapperErrorMessage)):e(b,null,this.loading&&e(d,null),this.errorMessage?a(this.errorMessage):e("canvas",{id:"chart",ref:t=>this.chartRef=t}))}static get watchers(){return{accountId:["authPropChanged"],authToken:["authPropChanged"],grossVolumeReport:["grossVolumeReportChanged"]}}};export{Tn as justifi_gross_payment_chart}
|