!function(t,a){"object"==typeof exports&&"object"==typeof module?module.exports=a():"function"==typeof define&&define.amd?define([],a):"object"==typeof exports?exports.ChartjsPluginStacked100=a():t.ChartjsPluginStacked100=a()}(self,(()=>(()=>{"use strict";var t={d:(a,n)=>{for(var e in n)t.o(n,e)&&!t.o(a,e)&&Object.defineProperty(a,e,{enumerable:!0,get:n[e]})},o:(t,a)=>Object.prototype.hasOwnProperty.call(t,a),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},a={};t.r(a),t.d(a,{default:()=>f});var n=function(t,a,n){if(n||2===arguments.length)for(var e,r=0,o=a.length;r<o;r++)!e&&r in a||(e||(e=Array.prototype.slice.call(a,0,r)),e[r]=a[r]);return t.concat(e||Array.prototype.slice.call(a))},e=function(t,a){return"object"==typeof(n=t)&&n?a?t.x:t.y:t;var n},r=function(t){t.originalData=t.datasets.map((function(t){return a=t.data,n([],a,!0);var a}))},o=function(){return o=Object.assign||function(t){for(var a,n=1,e=arguments.length;n<e;n++)for(var r in a=arguments[n])Object.prototype.hasOwnProperty.call(a,r)&&(t[r]=a[r]);return t},o.apply(this,arguments)},i=function(t,a,n){if(n||2===arguments.length)for(var e,r=0,o=a.length;r<o;r++)!e&&r in a||(e||(e=Array.prototype.slice.call(a,0,r)),e[r]=a[r]);return t.concat(e||Array.prototype.slice.call(a))},c=Symbol(),u=function(t,a,n,r,o){var u=function(t,a,n,r){var o,u=(null==t?void 0:t.reduce((function(t,a){var n,e=(null===(n=null==a?void 0:a.data)||void 0===n?void 0:n.length)||0;return e>t?e:t}),0))||0,l=null===(o=null==t?void 0:t[0])||void 0===o?void 0:o.stack,d=i([],new Array(u),!0).map((function(o,i){return t.reduce((function(t,o,u){var d=o.stack||c;t[d]||(t[d]=0);var f=Math.abs(e(o.data[i],n)||0)*a[u];return r&&!l?t[d]<f&&(t[d]=f):t[d]+=f,t}),{})}));return l&&r?d.map((function(t){var a=Math.max.apply(Math,Object.values(t));return Object.keys(t).forEach((function(n){return t[n]=a})),t})):d}(null==t?void 0:t.datasets,a,n,o);return t.datasets.map((function(t){return t.data.map((function(a,o){var i=u[o][t.stack||c],l=e(a,n);return l&&i?function(t,a){var n=Math.pow(10,a);return Math.round(100*t*n)/n}(l/i,r):0}))}))},l=function(t,a){t&&t.forEach((function(t,n){a[n].data=t}))},d=function(t){return"y"===t.options.indexAxis};const f={id:"stacked100",beforeInit:function(t,a,n){if(n.enable){var r=n.replaceTooltipLabel,i=void 0===r||r,c=n.fixNegativeScale,u=void 0===c||c,l=n.individual,f=void 0!==l&&l,s=d(t),p=s?"x":"y",v=t.data.datasets.some((function(t){return t.data.some((function(t){return(e(t,s)||0)<0}))}));["x","y"].forEach((function(a){var n=a===p?function(t,a){var n={max:100};return t?a?o({min:-100},n):n:o({min:0},n)}(v,u):{},e=o(o({stacked:!f},n),t.options.scales[a]);t.options.scales[a]=e})),i&&(t.options.plugins.tooltip.callbacks.label=function(t){return function(a){var n=a.chart.data,r=a.datasetIndex,o=a.dataIndex,i=n.datasets[r].label||"",c=n.originalData[r][o],u=n.calculatedData[r][o],l=e(c,t);return"".concat(i,": ").concat(u,"% (").concat(l,")")}}(s))}},beforeUpdate:function(t,a,n){if(n.enable){var e=t.data;r(e);var o=e.datasets.map((function(a,n){var e,r;return(null!==(r=null===(e=t.getDatasetMeta(n))||void 0===e?void 0:e.hidden)&&void 0!==r?r:a.hidden)?0:1})),i=function(t){if(!("precision"in t))return 1;if("number"!=typeof t.precision)return 1;var a=Math.floor(t.precision);return a<0||a>16?1:a}(n);e.calculatedData=u(e,o,d(t),i,n.individual),l(e.calculatedData,e.datasets)}},afterUpdate:function(t,a,n){if(n.enable){var e=t.data;l(e.originalData,e.datasets)}}};return a})()));