11 | (function(l,u){typeof exports=="object"&&typeof module=="object"?module.exports=u(require("d3-delaunay"),require("d3-polygon"),require("d3-brush"),require("d3-selection")):typeof define=="function"&&define.amd?define("bb",["d3-delaunay","d3-polygon","d3-brush","d3-selection"],u):typeof exports=="object"?exports.bb=u(require("d3-delaunay"),require("d3-polygon"),require("d3-brush"),require("d3-selection")):(l.bb=l.bb||{},l.bb.plugin=l.bb.plugin||{},l.bb.plugin.textoverlap=u(l.d3,l.d3,l.d3,l.d3))})(this,function(w,l,u,C){return function(){"use strict";var D={853:function(e){e.exports=u},348:function(e){e.exports=w},263:function(e){e.exports=l},747:function(e){e.exports=C}},O={};function a(e){var n=O[e];if(n!==void 0)return n.exports;var t=O[e]={exports:{}};return D[e](t,t.exports,a),t.exports}(function(){a.d=function(e,n){for(var t in n)a.o(n,t)&&!a.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:n[t]})}})(),function(){a.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)}}();var p={};a.d(p,{default:function(){return oe}});var q=a(348),P=a(263),fe=a(853),de=a(747);function R(){return typeof globalThis=="object"&&globalThis!==null&&globalThis.Object===Object&&globalThis||typeof global=="object"&&global!==null&&global.Object===Object&&global||typeof self=="object"&&self!==null&&self.Object===Object&&self||Function("return this")()}function F(e){const n=typeof(e==null?void 0:e.requestAnimationFrame)=="function"&&typeof(e==null?void 0:e.cancelAnimationFrame)=="function",t=typeof(e==null?void 0:e.requestIdleCallback)=="function"&&typeof(e==null?void 0:e.cancelIdleCallback)=="function",o=i=>setTimeout(i,1),r=i=>clearTimeout(i);return[n?e.requestAnimationFrame:o,n?e.cancelAnimationFrame:r,t?e.requestIdleCallback:o,t?e.cancelIdleCallback:r]}const h=R(),S=h==null?void 0:h.document,[pe,he,be,me]=F(h);var I=Object.defineProperty,E=Object.getOwnPropertySymbols,B=Object.prototype.hasOwnProperty,N=Object.prototype.propertyIsEnumerable,M=(e,n,t)=>n in e?I(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,T=(e,n)=>{for(var t in n||(n={}))B.call(n,t)&&M(e,t,n[t]);if(E)for(var t of E(n))N.call(n,t)&&M(e,t,n[t]);return e};const _e=e=>e||e===0,V=e=>typeof e=="function",b=e=>typeof e=="string",_=e=>typeof e=="number",U=e=>typeof e=="undefined",j=e=>typeof e!="undefined",ge=e=>typeof e=="boolean",ye=e=>Math.ceil(e/10)*10,ve=e=>Math.ceil(e)+.5,xe=e=>e[1]-e[0],g=e=>typeof e=="object",X=e=>U(e)||e===null||b(e)&&e.length===0||g(e)&&!(e instanceof Date)&&Object.keys(e).length===0||_(e)&&isNaN(e),Y=e=>!X(e),y=e=>Array.isArray(e),m=e=>e&&!(e!=null&&e.nodeType)&&g(e)&&!y(e);function we(e,n,t){return j(e[n])?e[n]:t}function Oe(e,n){let t=!1;return Object.keys(e).forEach(o=>e[o]===n&&(t=!0)),t}function Pe(e,n,...t){const o=V(e);return o&&e.call(n,...t),o}function Ee(e,n){let t=0;const o=function(...r){!--t&&n.apply(this,...r)};"duration"in e?e.each(()=>++t).on("end",o):(++t,e.call(o))}function Me(e){return b(e)?e.replace(/<(script|img)?/ig,"<").replace(/(script)?>/ig,">"):e}function Te(e,n,t=[-1,1],o=!1){if(!(!e||!b(n)))if(n.indexOf(`
|
13 | `),s=o?i.length-1:1;e.html(""),i.forEach((c,f)=>{e.append("tspan").attr("x",0).attr("dy",`${f===0?t[0]*s:t[1]}em`).text(c)})}}}function L(e){const{x:n,y:t,width:o,height:r}=e.getBBox();return[{x:n,y:t+r},{x:n,y:t},{x:n+o,y:t},{x:n+o,y:t+r}]}function je(e){const{width:n,height:t}=e.getBoundingClientRect(),o=L(e),r=o[0].x,i=Math.min(o[0].y,o[1].y);return{x:r,y:i,width:n,height:t}}function $e(e,n){var t;const o=e&&((t=e.touches||e.sourceEvent&&e.sourceEvent.touches)==null?void 0:t[0]);let r=[0,0];try{r=d3Pointer(o||e,n)}catch(i){}return r.map(i=>isNaN(i)?0:i)}function z(e){const{event:n,$el:t}=e,o=t.subchart.main||t.main;let r;return n&&n.type==="brush"?r=n.selection:o&&(r=o.select(".bb-brush").node())&&(r=d3BrushSelection(r)),r}function Ae(e){return!("rect"in e)||"rect"in e&&e.hasAttribute("width")&&e.rect.width!==+e.getAttribute("width")?e.rect=e.getBoundingClientRect():e.rect}function Ce(e=!0,n=0,t=1e4){const o=window.crypto||window.msCrypto,r=o?n+o.getRandomValues(new Uint32Array(1))[0]%(t-n+1):Math.floor(Math.random()*(t-n)+n);return e?String(r):r}function $(e,n,t,o,r){if(t>o)return-1;const i=Math.floor((t+o)/2);let{x:s,w:c=0}=e[i];return r&&(s=e[i].y,c=e[i].h),n>=s&&n<=s+c?i:n<s?$(e,n,t,i-1,r):$(e,n,i+1,o,r)}function De(e){const n=z(e);return n?n[0]===n[1]:!0}function qe(...e){const n=t=>{if(m(t)&&t.constructor){const o=new t.constructor;for(const r in t)o[r]=n(t[r]);return o}return t};return e.map(t=>n(t)).reduce((t,o)=>T(T({},t),o))}function k(e={},n){y(n)&&n.forEach(t=>k(e,t));for(const t in n)/^\d+$/.test(t)||t in e||(e[t]=n[t]);return e}const Re=e=>e.charAt(0).toUpperCase()+e.slice(1);function Fe(e,n="-"){return e.split(n).map((t,o)=>o?t.charAt(0).toUpperCase()+t.slice(1).toLowerCase():t.toLowerCase()).join("")}const G=e=>[].slice.call(e);function Se(e,n,t){const{rootSelector:o="",sheet:r}=e,s=`${o} ${(c=>c.replace(/\s?(bb-)/g,".$1").replace(/\.+/g,"."))(n)} {${t.join(";")}}`;return r[r.insertRule?"insertRule":"addRule"](s,r.cssRules.length)}function Ie(e){let n=[];return e.forEach(t=>{var o;try{t.cssRules&&t.cssRules.length&&(n=n.concat(G(t.cssRules)))}catch(r){(o=window.console)==null||o.warn(`Error while reading rules from ${t.href}: ${r.toString()}`)}}),n}function Be(e){var n,t,o,r,i,s;return{x:((t=(n=window.pageXOffset)!=null?n:window.scrollX)!=null?t:0)+((o=e.scrollLeft)!=null?o:0),y:((i=(r=window.pageYOffset)!=null?r:window.scrollY)!=null?i:0)+((s=e.scrollTop)!=null?s:0)}}function Ne(e,n=0,t=0,o=!0){const r=new DOMPoint(n,t),i=e.getScreenCTM(),s=r.matrixTransform(o?i==null?void 0:i.inverse():i);if(o===!1){const c=e.getBoundingClientRect();s.x-=c.x,s.y-=c.y}return s}function Ve(e){const n=e?e.transform:null,t=n&&n.baseVal;return t&&t.numberOfItems?t.getItem(0).matrix:{a:0,b:0,c:0,d:0,e:0,f:0}}function Ue(e){const n=e[0]instanceof Date,t=(n?e.map(Number):e).filter((o,r,i)=>i.indexOf(o)===r);return n?t.map(o=>new Date(o)):t}function Xe(e){return e&&e.length?e.reduce((n,t)=>n.concat(t)):[]}function v(e,...n){if(!n.length||n.length===1&&!n[0])return e;const t=n.shift();return m(e)&&m(t)&&Object.keys(t).forEach(o=>{const r=t[o];m(r)?(!e[o]&&(e[o]={}),e[o]=v(e[o],r)):e[o]=y(r)?r.concat():r}),v(e,...n)}function H(e,n=!0){let t;return e[0]instanceof Date?t=n?(o,r)=>o-r:(o,r)=>r-o:n&&!e.every(isNaN)?t=(o,r)=>o-r:n||(t=(o,r)=>o>r&&-1||o<r&&1||o===r&&0),e.concat().sort(t)}function Ye(e,n){let t=n.filter(o=>Y(o));return t.length?_(t[0])?t=Math[e](...t):t[0]instanceof Date&&(t=H(t,e==="min")[0]):t=void 0,t}const Le=(e,n,t=1)=>{const o=[],r=Math.max(0,Math.ceil((n-e)/t))|0;for(let i=e;i<r;i++)o.push(e+i*t);return o},ze={mouse:(()=>{const e=()=>({bubbles:!1,cancelable:!1,screenX:0,screenY:0,clientX:0,clientY:0});try{return new MouseEvent("t"),(n,t,o=e())=>{n.dispatchEvent(new MouseEvent(t,o))}}catch(n){return(t,o,r=e())=>{const i=S.createEvent("MouseEvent");i.initMouseEvent(o,r.bubbles,r.cancelable,h,0,r.screenX,r.screenY,r.clientX,r.clientY,!1,!1,!1,!1,0,null),t.dispatchEvent(i)}}})(),touch:(e,n,t)=>{const o=new Touch(v({identifier:Date.now(),target:e,radiusX:2.5,radiusY:2.5,rotationAngle:10,force:.5},t));e.dispatchEvent(new TouchEvent(n,{cancelable:!0,bubbles:!0,shiftKey:!0,touches:[o],targetTouches:[],changedTouches:[o]}))}};function ke(e,n){let t=e;for(const o in n)t=t.replace(new RegExp(`{=${o}}`,"g"),n[o]);return t}function Ge(e){var n;let t;if(e instanceof Date)t=e;else if(b(e)){const{config:o,format:r}=this;t=(n=r.dataTime(o.data_xFormat)(e))!=null?n:new Date(e)}else _(e)&&!isNaN(e)&&(t=new Date(+e));return(!t||isNaN(+t))&&console&&console.error&&console.error(`Failed to parse x '${e}' to Date object`),t}function He(e){const n=e.attr("viewBox");return n?/(\d+(\.\d+)?){3}/.test(n):!1}function Ke(e,n,t=!1){const o=!!e.node;let r=!1;for(const[i,s]of Object.entries(n))if(r=o?e.style(i)===s:e.style[i]===s,t===!1&&r)break;return r}function We(){var e,n;return((e=document)==null?void 0:e.hidden)===!1||((n=document)==null?void 0:n.visibilityState)==="visible"}function Je(e,n){const{DocumentTouch:t,matchMedia:o,navigator:r}=window,i=o==null?void 0:o("(pointer:coarse)").matches;let s=!1;if(n)if(r&&"maxTouchPoints"in r)s=r.maxTouchPoints>0;else if("ontouchmove"in window||t&&document instanceof t)s=!0;else if(i)s=!0;else{const f=r.userAgent;s=/\b(BlackBerry|webOS|iPhone|IEMobile)\b/i.test(f)||/\b(Android|Windows Phone|iPad|iPod)\b/i.test(f)}return e&&!i&&(o==null?void 0:o("(pointer:fine)").matches)&&"mouse"||s&&"touch"||"mouse"}function K(e,n){n()===!1?requestAnimationFrame(()=>K(e,n)):e()}function W(e){const n=this.config;let t,o,r;const i=()=>{const s=o.shift();if(s&&t&&g(t)&&s in t)return t=t[s],i();if(!s)return t};Object.keys(n).forEach(s=>{t=e,o=s.split("_"),r=i(),j(r)&&(n[s]=r)}),this.api&&(this.state.orgConfig=e)}var J=Object.defineProperty,Q=(e,n,t)=>n in e?J(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,x=(e,n,t)=>Q(e,typeof n!="symbol"?n+"":n,t);class A{constructor(n={}){x(this,"$$"),x(this,"options"),this.options=n}$beforeInit(){}$init(){}$afterInit(){}$redraw(){}$willDestroy(){Object.keys(this).forEach(n=>{this[n]=null,delete this[n]})}}x(A,"version","3.14.2");class Z{constructor(){return{selector:void 0,extent:1,area:0}}}var ee=Object.defineProperty,te=(e,n,t)=>n in e?ee(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,ne=(e,n,t)=>te(e,typeof n!="symbol"?n+"":n,t);class oe extends A{constructor(n){return super(n),ne(this,"config"),this.config=new Z,this}$init(){W.call(this,this.options)}$redraw(){const{$$:{$el:n},config:{selector:t}}=this,o=t?n.main.selectAll(t):n.text;!o.empty()&&this.preventLabelOverlap(o)}generateVoronoi(n){const{$$:t}=this,{scale:o}=t,[r,i]=["x","y"].map(s=>o[s].domain());return[r[1],i[0]]=[i[0],r[1]],q.Delaunay.from(n).voronoi([...r,...i])}preventLabelOverlap(n){const{extent:t,area:o}=this.config,r=n.data().map(c=>[c.index,c.value]),i=this.generateVoronoi(r);let s=0;n.each(function(){const c=i.cellPolygon(s);if(c&&this){const[f,re]=r[s],[ie,se]=(0,P.polygonCentroid)(c),ce=Math.abs((0,P.polygonArea)(c)),d=Math.round(Math.atan2(se-re,ie-f)/Math.PI*2),le=t*(d===0?1:-1),ae=d===-1?-t:t+5,ue=Math.abs(d)===1?"middle":d===0?"start":"end";this.style.display=ce<o?"none":"",this.setAttribute("text-anchor",ue),this.setAttribute("dy",`0.${d===1?71:35}em`),this.setAttribute("transform",`translate(${le}, ${ae})`)}s++})}}return p=p.default,p}()});
|