UNPKG

@asyncapi/studio

Version:

One place that allows you to develop an AsyncAPI document, validate it, convert it to the latest version, preview the documentation and visualize the events flow.

23 lines (20 loc) 40.7 kB
"use strict";exports.id=6170,exports.ids=[6170],exports.modules={36170:(t,e,n)=>{n.d(e,{diagram:()=>tg});var s,i=n(51892),r=n(63951),l=n(51635),a=n(17605),o=n(25329),h=n(13177),c=n(30248);let u=(t,e)=>(0,c.Z)(t,"a",-e);var f=n(12470),y=n(34436);function d(t,e){let n=function(t){let e=[];for(let n=0;n<t.length;++n)for(let s=n+1;s<t.length;++s)for(let i of m(t[n],t[s]))i.parentIndex=[n,s],e.push(i);return e}(t),s=n.filter(e=>t.every(t=>g(e,t)<t.radius+1e-10)),i=0,r=0,l=[];if(s.length>1){let e=b(s);for(let t=0;t<s.length;++t){let n=s[t];n.angle=Math.atan2(n.x-e.x,n.y-e.y)}s.sort((t,e)=>e.angle-t.angle);let n=s[s.length-1];for(let e=0;e<s.length;++e){let a=s[e];r+=(n.x+a.x)*(a.y-n.y);let o={x:(a.x+n.x)/2,y:(a.y+n.y)/2},h=null;for(let e=0;e<a.parentIndex.length;++e)if(n.parentIndex.includes(a.parentIndex[e])){let s=t[a.parentIndex[e]],i=Math.atan2(a.x-s.x,a.y-s.y),r=Math.atan2(n.x-s.x,n.y-s.y),l=r-i;l<0&&(l+=2*Math.PI);let c=r-l/2,u=g(o,{x:s.x+s.radius*Math.sin(c),y:s.y+s.radius*Math.cos(c)});u>2*s.radius&&(u=2*s.radius),(null==h||h.width>u)&&(h={circle:s,width:u,p1:a,p2:n,large:u>s.radius,sweep:!0})}null!=h&&(l.push(h),i+=x(h.circle.radius,h.width),n=a)}}else{let e=t[0];for(let n=1;n<t.length;++n)t[n].radius<e.radius&&(e=t[n]);let n=!1;for(let s=0;s<t.length;++s)if(g(t[s],e)>Math.abs(e.radius-t[s].radius)){n=!0;break}n?i=r=0:(i=e.radius*e.radius*Math.PI,l.push({circle:e,p1:{x:e.x,y:e.y+e.radius},p2:{x:e.x-1e-10,y:e.y+e.radius},width:2*e.radius,large:!0,sweep:!0}))}return r/=2,e&&(e.area=i+r,e.arcArea=i,e.polygonArea=r,e.arcs=l,e.innerPoints=s,e.intersectionPoints=n),i+r}function x(t,e){return t*t*Math.acos(1-e/t)-(t-e)*Math.sqrt(e*(2*t-e))}function g(t,e){return Math.sqrt((t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y))}function p(t,e,n){return n>=t+e?0:n<=Math.abs(t-e)?Math.PI*Math.min(t,e)*Math.min(t,e):x(t,t-(n*n-e*e+t*t)/(2*n))+x(e,e-(n*n-t*t+e*e)/(2*n))}function m(t,e){let n=g(t,e),s=t.radius,i=e.radius;if(n>=s+i||n<=Math.abs(s-i))return[];let r=(s*s-i*i+n*n)/(2*n),l=Math.sqrt(s*s-r*r),a=t.x+r*(e.x-t.x)/n,o=t.y+r*(e.y-t.y)/n,h=-(e.y-t.y)*(l/n),c=-(e.x-t.x)*(l/n);return[{x:a+h,y:o-c},{x:a-h,y:o+c}]}function b(t){let e={x:0,y:0};for(let n of t)e.x+=n.x,e.y+=n.y;return e.x/=t.length,e.y/=t.length,e}function v(t){let e=Array(t);for(let n=0;n<t;++n)e[n]=0;return e}function I(t,e){return v(t).map(()=>v(e))}function M(t,e){let n=0;for(let s=0;s<t.length;++s)n+=t[s]*e[s];return n}function k(t){return Math.sqrt(M(t,t))}function _(t,e,n){for(let s=0;s<e.length;++s)t[s]=e[s]*n}function w(t,e,n,s,i){for(let r=0;r<t.length;++r)t[r]=e*n[r]+s*i[r]}function E(t,e,n){let s;let i=(n=n||{}).maxIterations||200*e.length,r=n.nonZeroDelta||1.05,l=n.zeroDelta||.001,a=n.minErrorDelta||1e-6,o=n.minErrorDelta||1e-5,h=void 0!==n.rho?n.rho:1,c=void 0!==n.chi?n.chi:2,u=void 0!==n.psi?n.psi:-.5,f=void 0!==n.sigma?n.sigma:.5,y=e.length,d=Array(y+1);d[0]=e,d[0].fx=t(e),d[0].id=0;for(let n=0;n<y;++n){let s=e.slice();s[n]=s[n]?s[n]*r:l,d[n+1]=s,d[n+1].fx=t(s),d[n+1].id=n+1}function x(t){for(let e=0;e<t.length;e++)d[y][e]=t[e];d[y].fx=t.fx}let g=(t,e)=>t.fx-e.fx,p=e.slice(),m=e.slice(),b=e.slice(),v=e.slice();for(let e=0;e<i;++e){if(d.sort(g),n.history){let t=d.map(t=>{let e=t.slice();return e.fx=t.fx,e.id=t.id,e});t.sort((t,e)=>t.id-e.id),n.history.push({x:d[0].slice(),fx:d[0].fx,simplex:t})}s=0;for(let t=0;t<y;++t)s=Math.max(s,Math.abs(d[0][t]-d[1][t]));if(Math.abs(d[0].fx-d[y].fx)<a&&s<o)break;for(let t=0;t<y;++t){p[t]=0;for(let e=0;e<y;++e)p[t]+=d[e][t];p[t]/=y}let e=d[y];if(w(m,1+h,p,-h,e),m.fx=t(m),m.fx<d[0].fx)w(v,1+c,p,-c,e),v.fx=t(v),x(v.fx<m.fx?v:m);else if(m.fx>=d[y-1].fx){let n=!1;if(m.fx>e.fx?(w(b,1+u,p,-u,e),b.fx=t(b),b.fx<e.fx?x(b):n=!0):(w(b,1-u*h,p,u*h,e),b.fx=t(b),b.fx<m.fx?x(b):n=!0),n){if(f>=1)break;for(let e=1;e<d.length;++e)w(d[e],1-f,d[0],f,d[e]),d[e].fx=t(d[e])}}else x(m)}return d.sort(g),{fx:d[0].fx,x:d[0]}}function S(t,e={}){e.maxIterations=e.maxIterations||500;let n=e.initialLayout||z,s=e.lossFunction||A,i=function(t,e={}){let n=e.distinct,s=t.map(t=>Object.assign({},t));function i(t){return t.join(";")}if(n){let t=new Map;for(let e of s)for(let n=0;n<e.sets.length;n++){let s=String(e.sets[n]);t.set(s,e.size+(t.get(s)||0));for(let i=n+1;i<e.sets.length;i++){let n=String(e.sets[i]),r=`${s};${n}`,l=`${n};${s}`;t.set(r,e.size+(t.get(r)||0)),t.set(l,e.size+(t.get(l)||0))}}for(let e of s)e.sets.length<3&&(e.size=t.get(i(e.sets)))}let r=[],l=new Set;for(let t of s)if(1===t.sets.length)r.push(t.sets[0]);else if(2===t.sets.length){let e=t.sets[0],n=t.sets[1];l.add(i(t.sets)),l.add(i([n,e]))}r.sort((t,e)=>t===e?0:t<e?-1:1);for(let t=0;t<r.length;++t){let e=r[t];for(let n=t+1;n<r.length;++n){let t=r[n];l.has(i([e,t]))||s.push({sets:[e,t],size:0})}}return s}(t,e),r=n(i,e),l=Object.keys(r),a=[];for(let t of l)a.push(r[t].x),a.push(r[t].y);let o=E(t=>{let e={};for(let n=0;n<l.length;++n){let s=l[n];e[s]={x:t[2*n],y:t[2*n+1],radius:r[s].radius}}return s(e,i)},a,e).x;for(let t=0;t<l.length;++t){let e=l[t];r[e].x=o[2*t],r[e].y=o[2*t+1]}return r}function T(t,e,n){return Math.min(t,e)*Math.min(t,e)*Math.PI<=n+1e-10?Math.abs(t-e):function(t,e,n,s){let i=(s=s||{}).maxIterations||100,r=s.tolerance||1e-10,l=t(e),a=t(n),o=n-e;if(l*a>0)throw"Initial bisect points must have opposite signs";if(0===l)return e;if(0===a)return n;for(let n=0;n<i;++n){let n=e+(o/=2),s=t(n);if(s*l>=0&&(e=n),Math.abs(o)<r||0===s)return n}return e+o}(s=>p(t,e,s)-n,0,t+e)}function z(t,e={}){let n=function(t,e){let n=e&&e.lossFunction?e.lossFunction:A,s={},i={};for(let e of t)if(1===e.sets.length){let t=e.sets[0];s[t]={x:1e10,y:1e10,rowid:s.length,size:e.size,radius:Math.sqrt(e.size/Math.PI)},i[t]=[]}for(let e of t=t.filter(t=>2===t.sets.length)){let t=null!=e.weight?e.weight:1,n=e.sets[0],r=e.sets[1];e.size+1e-10>=Math.min(s[n].size,s[r].size)&&(t=0),i[n].push({set:r,size:e.size,weight:t}),i[r].push({set:n,size:e.size,weight:t})}let r=[];function l(t,e){return e.size-t.size}Object.keys(i).forEach(t=>{let e=0;for(let n=0;n<i[t].length;++n)e+=i[t][n].size*i[t][n].weight;r.push({set:t,size:e})}),r.sort(l);let a={};function o(t){return t.set in a}function h(t,e){s[e].x=t.x,s[e].y=t.y,a[e]=!0}h({x:0,y:0},r[0].set);for(let e=1;e<r.length;++e){let a=r[e].set,u=i[a].filter(o),f=s[a];if(u.sort(l),0===u.length)throw"ERROR: missing pairwise overlap information";let y=[];for(var c=0;c<u.length;++c){let t=s[u[c].set],e=T(f.radius,t.radius,u[c].size);y.push({x:t.x+e,y:t.y}),y.push({x:t.x-e,y:t.y}),y.push({y:t.y+e,x:t.x}),y.push({y:t.y-e,x:t.x});for(let n=c+1;n<u.length;++n){let i=s[u[n].set],r=T(f.radius,i.radius,u[n].size),l=m({x:t.x,y:t.y,radius:e},{x:i.x,y:i.y,radius:r});y.push(...l)}}let d=1e50,x=y[0];for(let e of y){s[a].x=e.x,s[a].y=e.y;let i=n(s,t);i<d&&(d=i,x=e)}h(x,a)}return s}(t,e),s=e.lossFunction||A;if(t.length>=8){let i=function(t,e={}){let n=e.restarts||10,s=[],i={};for(let e of t)1===e.sets.length&&(i[e.sets[0]]=s.length,s.push(e));let{distances:r,constraints:l}=function(t,e,n){let s=I(e.length,e.length),i=I(e.length,e.length);return t.filter(t=>2===t.sets.length).forEach(t=>{let r=n[t.sets[0]],l=n[t.sets[1]],a=T(Math.sqrt(e[r].size/Math.PI),Math.sqrt(e[l].size/Math.PI),t.size);s[r][l]=s[l][r]=a;let o=0;t.size+1e-10>=Math.min(e[r].size,e[l].size)?o=1:t.size<=1e-10&&(o=-1),i[r][l]=i[l][r]=o}),{distances:s,constraints:i}}(t,s,i),a=k(r.map(k))/r.length;r=r.map(t=>t.map(t=>t/a));let o=(t,e)=>(function(t,e,n,s){for(let t=0;t<e.length;++t)e[t]=0;let i=0;for(let r=0;r<n.length;++r){let l=t[2*r],a=t[2*r+1];for(let o=r+1;o<n.length;++o){let h=t[2*o],c=t[2*o+1],u=n[r][o],f=s[r][o],y=(h-l)*(h-l)+(c-a)*(c-a),d=Math.sqrt(y),x=y-u*u;f>0&&d<=u||f<0&&d>=u||(i+=2*x*x,e[2*r]+=4*x*(l-h),e[2*r+1]+=4*x*(a-c),e[2*o]+=4*x*(h-l),e[2*o+1]+=4*x*(c-a))}}return i})(t,e,r,l),h=null;for(let t=0;t<n;++t){let t=function(t,e,n){let s,i,r,l={x:e.slice(),fx:0,fxprime:e.slice()},a={x:e.slice(),fx:0,fxprime:e.slice()},o=e.slice(),h=1;r=(n=n||{}).maxIterations||20*e.length,l.fx=t(l.x,l.fxprime),_(s=l.fxprime.slice(),l.fxprime,-1);for(let e=0;e<r;++e){if(h=function(t,e,n,s,i,r,l){let a=n.fx,o=M(n.fxprime,e),h=a,c=a,u=o,f=0;function y(c,f,y){for(let d=0;d<16;++d)if(i=(c+f)/2,w(s.x,1,n.x,i,e),h=s.fx=t(s.x,s.fxprime),u=M(s.fxprime,e),h>a+r*i*o||h>=y)f=i;else{if(Math.abs(u)<=-l*o)return i;u*(f-c)>=0&&(f=c),c=i,y=h}return 0}i=i||1,r=r||1e-6,l=l||.1;for(let d=0;d<10;++d){if(w(s.x,1,n.x,i,e),h=s.fx=t(s.x,s.fxprime),u=M(s.fxprime,e),h>a+r*i*o||d&&h>=c)return y(f,i,c);if(Math.abs(u)<=-l*o)break;if(u>=0)return y(i,f,h);c=h,f=i,i*=2}return i}(t,s,l,a,h),n.history&&n.history.push({x:l.x.slice(),fx:l.fx,fxprime:l.fxprime.slice(),alpha:h}),h){w(o,1,a.fxprime,-1,l.fxprime);let t=M(l.fxprime,l.fxprime);w(s,Math.max(0,M(o,a.fxprime)/t),s,-1,a.fxprime),i=l,l=a,a=i}else _(s,l.fxprime,-1);if(1e-5>=k(l.fxprime))break}return n.history&&n.history.push({x:l.x.slice(),fx:l.fx,fxprime:l.fxprime.slice(),alpha:h}),l}(o,v(2*r.length).map(Math.random),e);(!h||t.fx<h.fx)&&(h=t)}let c=h.x,u={};for(let t=0;t<s.length;++t){let e=s[t];u[e.sets[0]]={x:c[2*t]*a,y:c[2*t+1]*a,radius:Math.sqrt(e.size/Math.PI)}}if(e.history)for(let t of e.history)_(t.x,a);return u}(t,e);s(i,t)+1e-8<s(n,t)&&(n=i)}return n}function A(t,e){let n=0;for(let s of e){let e;if(1!==s.sets.length){if(2===s.sets.length){let n=t[s.sets[0]],i=t[s.sets[1]];e=p(n.radius,i.radius,g(n,i))}else e=d(s.sets.map(e=>t[e]));n+=(null!=s.weight?s.weight:1)*(e-s.size)*(e-s.size)}}return n}function W(t,e){let n=0;for(let s of e){let e;if(1===s.sets.length)continue;if(2===s.sets.length){let n=t[s.sets[0]],i=t[s.sets[1]];e=p(n.radius,i.radius,g(n,i))}else e=d(s.sets.map(e=>t[e]));let i=null!=s.weight?s.weight:1,r=Math.log((e+1)/(s.size+1));n+=i*r*r}return n}function R(t){let e=e=>({max:t.reduce((t,n)=>Math.max(t,n[e]+n.radius),Number.NEGATIVE_INFINITY),min:t.reduce((t,n)=>Math.min(t,n[e]-n.radius),Number.POSITIVE_INFINITY)});return{xRange:e("x"),yRange:e("y")}}function N(t,e,n){null==e&&(e=Math.PI/2);let s=F(t).map(t=>Object.assign({},t)),i=function(t){function e(t){return t.parent!==t&&(t.parent=e(t.parent)),t.parent}t.forEach(t=>{t.parent=t});for(let n=0;n<t.length;++n)for(let s=n+1;s<t.length;++s){let i=t[n].radius+t[s].radius;g(t[n],t[s])+1e-10<i&&function(t,n){let s=e(t),i=e(n);s.parent=i}(t[s],t[n])}let n=new Map;for(let s=0;s<t.length;++s){let i=e(t[s]).parent.setid;n.has(i)||n.set(i,[]),n.get(i).push(t[s])}return t.forEach(t=>{delete t.parent}),Array.from(n.values())}(s);for(let t of i){!function(t,e,n){if(null==n?t.sort((t,e)=>e.radius-t.radius):t.sort(n),t.length>0){let e=t[0].x,n=t[0].y;for(let s of t)s.x-=e,s.y-=n}if(2===t.length&&g(t[0],t[1])<Math.abs(t[1].radius-t[0].radius)&&(t[1].x=t[0].x+t[0].radius-t[1].radius-1e-10,t[1].y=t[0].y),t.length>1){let n=Math.atan2(t[1].x,t[1].y)-e,s=Math.cos(n),i=Math.sin(n);for(let e of t){let t=e.x,n=e.y;e.x=s*t-i*n,e.y=i*t+s*n}}if(t.length>2){let n=Math.atan2(t[2].x,t[2].y)-e;for(;n<0;)n+=2*Math.PI;for(;n>2*Math.PI;)n-=2*Math.PI;if(n>Math.PI){let e=t[1].y/(1e-10+t[1].x);for(let n of t){var s=(n.x+e*n.y)/(1+e*e);n.x=2*s-n.x,n.y=2*s*e-n.y}}}}(t,e,n);let s=R(t);t.size=(s.xRange.max-s.xRange.min)*(s.yRange.max-s.yRange.min),t.bounds=s}i.sort((t,e)=>e.size-t.size);let r=(s=i[0]).bounds,l=(r.xRange.max-r.xRange.min)/50;function a(t,e,n){let i,a;if(!t)return;let o=t.bounds;if(e)i=r.xRange.max-o.xRange.min+l;else{i=r.xRange.max-o.xRange.max;let t=(o.xRange.max-o.xRange.min)/2-(r.xRange.max-r.xRange.min)/2;t<0&&(i+=t)}if(n)a=r.yRange.max-o.yRange.min+l;else{a=r.yRange.max-o.yRange.max;let t=(o.yRange.max-o.yRange.min)/2-(r.yRange.max-r.yRange.min)/2;t<0&&(a+=t)}for(let e of t)e.x+=i,e.y+=a,s.push(e)}let o=1;for(;o<i.length;)a(i[o],!0,!1),a(i[o+1],!1,!0),a(i[o+2],!0,!0),o+=3,r=R(s);return O(s)}function $(t,e,n,s,i){let r,l;let a=F(t);e-=2*s,n-=2*s;let{xRange:o,yRange:h}=R(a);if(o.max===o.min||h.max===h.min)return console.log("not scaling solution: zero size detected"),t;if(i){let t=2*Math.sqrt(i/Math.PI);r=e/t,l=n/t}else r=e/(o.max-o.min),l=n/(h.max-h.min);let c=Math.min(l,r),u=(e-(o.max-o.min)*c)/2,f=(n-(h.max-h.min)*c)/2;return O(a.map(t=>({radius:c*t.radius,x:s+u+(t.x-o.min)*c,y:s+f+(t.y-h.min)*c,setid:t.setid})))}function O(t){let e={};for(let n of t)e[n.setid]=n;return e}function F(t){return Object.keys(t).map(e=>Object.assign(t[e],{setid:e}))}function D(t,e){return function(n){let s=this,i=t[n.sets[0]].radius||50,r=e(n)||"",l=r.split(/\s+/).reverse(),a=(r.length+l.length)/3,o=l.pop(),h=[o],c=0;s.textContent=null;let u=[];function f(t){let e=s.ownerDocument.createElementNS(s.namespaceURI,"tspan");return e.textContent=t,u.push(e),s.append(e),e}let y=f(o);for(;o=l.pop();){h.push(o);let t=h.join(" ");y.textContent=t,t.length>a&&y.getComputedTextLength()>i&&(h.pop(),y.textContent=h.join(" "),h=[o],y=f(o),c++)}let d=.35-1.1*c/2,x=s.getAttribute("x"),g=s.getAttribute("y");u.forEach((t,e)=>{t.setAttribute("x",x),t.setAttribute("y",g),t.setAttribute("dy",`${d+1.1*e}em`)})}}function C(t,e,n){let s=e[0].radius-g(e[0],t);for(let n=1;n<e.length;++n){let i=e[n].radius-g(e[n],t);i<=s&&(s=i)}for(let e=0;e<n.length;++e){let i=g(n[e],t)-n[e].radius;i<=s&&(s=i)}return s}function P(t,e,n){let s={},i=function(t){let e={},n=Object.keys(t);for(let t of n)e[t]=[];for(let s=0;s<n.length;s++){let i=n[s],r=t[i];for(let l=s+1;l<n.length;++l){let s=n[l],a=t[s],o=g(r,a);o+a.radius<=r.radius+1e-10?e[s].push(i):o+r.radius<=a.radius+1e-10&&e[i].push(s)}}return e}(t);for(let r=0;r<e.length;++r){let l=e[r].sets,a={},o={};for(let t=0;t<l.length;++t){a[l[t]]=!0;let e=i[l[t]];for(let t=0;t<e.length;++t)o[e[t]]=!0}let h=[],c=[];for(let e in t)e in a?h.push(t[e]):e in o||c.push(t[e]);let u=function t(e,n,s){let i=[];for(let t of e)i.push({x:t.x,y:t.y}),i.push({x:t.x+t.radius/2,y:t.y}),i.push({x:t.x-t.radius/2,y:t.y}),i.push({x:t.x,y:t.y+t.radius/2}),i.push({x:t.x,y:t.y-t.radius/2});let r=i[0],l=C(i[0],e,n);for(let t=1;t<i.length;++t){let s=C(i[t],e,n);s>=l&&(r=i[t],l=s)}let a=E(t=>-1*C({x:t[0],y:t[1]},e,n),[r.x,r.y],{maxIterations:500,minErrorDelta:1e-10}).x,o={x:s?0:a[0],y:a[1]},h=!0;for(let t of e)if(g(o,t)>t.radius){h=!1;break}for(let t of n)if(g(o,t)<t.radius){h=!1;break}if(h)return o;if(1==e.length)return{x:e[0].x,y:e[0].y};let c={};return(d(e,c),0===c.arcs.length)?{x:0,y:-1e3,disjoint:!0}:1==c.arcs.length?{x:c.arcs[0].circle.x,y:c.arcs[0].circle.y}:n.length?t(e,[]):b(c.arcs.map(t=>t.p1))}(h,c,n);s[l]=u,u.disjoint&&e[r].size>0&&console.log("WARNING: area "+l+" not represented on screen")}return s}function j(t){if(0===t.length)return[];let e={};return d(t,e),e.arcs}function L(t,e){if(0===t.length)return"M 0 0";let n=Math.pow(10,e||0),s=null!=e?t=>Math.round(t*n)/n:t=>t;if(1==t.length){let e=t[0].circle;return function(t,e,n){let s=[];return s.push("\nM",t,e),s.push("\nm",-n,0),s.push("\na",n,n,0,1,0,2*n,0),s.push("\na",n,n,0,1,0,-(2*n),0),s.join(" ")}(s(e.x),s(e.y),s(e.radius))}let i=["\nM",s(t[0].p2.x),s(t[0].p2.y)];for(let e of t){let t=s(e.circle.radius);i.push("\nA",t,t,0,e.large?1:0,e.sweep?1:0,s(e.p1.x),s(e.p1.y))}return i.join(" ")}var q=n(28646),U=function(){var t=(0,a.eW)(function(t,e,n,s){for(n=n||{},s=t.length;s--;n[t[s]]=e);return n},"o"),e=[5,8],n=[7,8,11,12,17,19,22,24],s=[1,17],i=[1,18],r=[7,8,11,12,14,15,16,17,19,20,21,22,24,27],l=[1,31],o=[1,39],h=[7,8,11,12,17,19,22,24,27],c=[1,57],u=[1,56],f=[1,58],y=[1,59],d=[1,60],x=[7,8,11,12,16,17,19,20,22,24,27,31,32,33],g={trace:(0,a.eW)(function(){},"trace"),yy:{},symbols_:{error:2,start:3,optNewlines:4,VENN:5,document:6,EOF:7,NEWLINE:8,line:9,statement:10,TITLE:11,SET:12,identifier:13,BRACKET_LABEL:14,COLON:15,NUMERIC:16,UNION:17,identifierList:18,TEXT:19,IDENTIFIER:20,STRING:21,INDENT_TEXT:22,indentedTextTail:23,STYLE:24,stylesOpt:25,styleField:26,COMMA:27,styleValue:28,valueTokens:29,valueToken:30,HEXCOLOR:31,RGBCOLOR:32,RGBACOLOR:33,$accept:0,$end:1},terminals_:{2:"error",5:"VENN",7:"EOF",8:"NEWLINE",11:"TITLE",12:"SET",14:"BRACKET_LABEL",15:"COLON",16:"NUMERIC",17:"UNION",19:"TEXT",20:"IDENTIFIER",21:"STRING",22:"INDENT_TEXT",24:"STYLE",27:"COMMA",31:"HEXCOLOR",32:"RGBCOLOR",33:"RGBACOLOR"},productions_:[0,[3,4],[4,0],[4,2],[6,0],[6,2],[9,1],[9,1],[10,1],[10,2],[10,3],[10,4],[10,5],[10,2],[10,3],[10,4],[10,5],[10,3],[10,3],[10,3],[10,4],[10,4],[10,2],[10,3],[23,1],[23,1],[23,1],[23,2],[23,2],[25,1],[25,3],[26,3],[28,1],[28,1],[29,1],[29,2],[30,1],[30,1],[30,1],[30,1],[30,1],[18,1],[18,3],[13,1],[13,1]],performAction:(0,a.eW)(function(t,e,n,s,i,r,l){var a=r.length-1;switch(i){case 1:return r[a-1];case 2:case 3:case 4:case 6:this.$=[];break;case 5:case 35:r[a-1].push(r[a]),this.$=r[a-1];break;case 7:case 22:case 32:case 36:case 37:case 38:case 39:case 40:case 43:case 44:this.$=r[a];break;case 8:s.setDiagramTitle(r[a].substr(6)),this.$=r[a].substr(6);break;case 9:s.addSubsetData([r[a]],void 0,void 0),s.setIndentMode&&s.setIndentMode(!0);break;case 10:s.addSubsetData([r[a-1]],r[a],void 0),s.setIndentMode&&s.setIndentMode(!0);break;case 11:s.addSubsetData([r[a-2]],void 0,parseFloat(r[a])),s.setIndentMode&&s.setIndentMode(!0);break;case 12:s.addSubsetData([r[a-3]],r[a-2],parseFloat(r[a])),s.setIndentMode&&s.setIndentMode(!0);break;case 13:if(r[a].length<2)throw Error("union requires multiple identifiers");s.validateUnionIdentifiers&&s.validateUnionIdentifiers(r[a]),s.addSubsetData(r[a],void 0,void 0),s.setIndentMode&&s.setIndentMode(!0);break;case 14:if(r[a-1].length<2)throw Error("union requires multiple identifiers");s.validateUnionIdentifiers&&s.validateUnionIdentifiers(r[a-1]),s.addSubsetData(r[a-1],r[a],void 0),s.setIndentMode&&s.setIndentMode(!0);break;case 15:if(r[a-2].length<2)throw Error("union requires multiple identifiers");s.validateUnionIdentifiers&&s.validateUnionIdentifiers(r[a-2]),s.addSubsetData(r[a-2],void 0,parseFloat(r[a])),s.setIndentMode&&s.setIndentMode(!0);break;case 16:if(r[a-3].length<2)throw Error("union requires multiple identifiers");s.validateUnionIdentifiers&&s.validateUnionIdentifiers(r[a-3]),s.addSubsetData(r[a-3],r[a-2],parseFloat(r[a])),s.setIndentMode&&s.setIndentMode(!0);break;case 17:case 18:case 19:s.addTextData(r[a-1],r[a],void 0);break;case 20:case 21:s.addTextData(r[a-2],r[a-1],r[a]);break;case 23:s.addStyleData(r[a-1],r[a]);break;case 24:case 25:case 26:var o=s.getCurrentSets();if(!o)throw Error("text requires set");s.addTextData(o,r[a],void 0);break;case 27:case 28:var o=s.getCurrentSets();if(!o)throw Error("text requires set");s.addTextData(o,r[a-1],r[a]);break;case 29:case 41:case 34:this.$=[r[a]];break;case 30:case 42:this.$=[...r[a-2],r[a]];break;case 31:this.$=[r[a-2],r[a]];break;case 33:this.$=r[a].join(" ")}},"anonymous"),table:[t(e,[2,2],{3:1,4:2}),{1:[3]},{5:[1,3],8:[1,4]},t(n,[2,4],{6:5}),t(e,[2,3]),{7:[1,6],8:[1,8],9:7,10:9,11:[1,10],12:[1,11],17:[1,12],19:[1,13],22:[1,14],24:[1,15]},{1:[2,1]},t(n,[2,5]),t(n,[2,6]),t(n,[2,7]),t(n,[2,8]),{13:16,20:s,21:i},{13:20,18:19,20:s,21:i},{13:20,18:21,20:s,21:i},{16:[1,25],20:[1,23],21:[1,24],23:22},{13:20,18:26,20:s,21:i},t(n,[2,9],{14:[1,27],15:[1,28]}),t(r,[2,43]),t(r,[2,44]),t(n,[2,13],{14:[1,29],15:[1,30],27:l}),t(r,[2,41]),{16:[1,34],20:[1,32],21:[1,33],27:l},t(n,[2,22]),t(n,[2,24],{14:[1,35]}),t(n,[2,25],{14:[1,36]}),t(n,[2,26]),{20:o,25:37,26:38,27:l},t(n,[2,10],{15:[1,40]}),{16:[1,41]},t(n,[2,14],{15:[1,42]}),{16:[1,43]},{13:44,20:s,21:i},t(n,[2,17],{14:[1,45]}),t(n,[2,18],{14:[1,46]}),t(n,[2,19]),t(n,[2,27]),t(n,[2,28]),t(n,[2,23],{27:[1,47]}),t(h,[2,29]),{15:[1,48]},{16:[1,49]},t(n,[2,11]),{16:[1,50]},t(n,[2,15]),t(r,[2,42]),t(n,[2,20]),t(n,[2,21]),{20:o,26:51},{16:c,20:u,21:[1,53],28:52,29:54,30:55,31:f,32:y,33:d},t(n,[2,12]),t(n,[2,16]),t(h,[2,30]),t(h,[2,31]),t(h,[2,32]),t(h,[2,33],{30:61,16:c,20:u,31:f,32:y,33:d}),t(x,[2,34]),t(x,[2,36]),t(x,[2,37]),t(x,[2,38]),t(x,[2,39]),t(x,[2,40]),t(x,[2,35])],defaultActions:{6:[2,1]},parseError:(0,a.eW)(function(t,e){if(e.recoverable)this.trace(t);else{var n=Error(t);throw n.hash=e,n}},"parseError"),parse:(0,a.eW)(function(t){var e=this,n=[0],s=[],i=[null],r=[],l=this.table,o="",h=0,c=0,u=0,f=r.slice.call(arguments,1),y=Object.create(this.lexer),d={yy:{}};for(var x in this.yy)Object.prototype.hasOwnProperty.call(this.yy,x)&&(d.yy[x]=this.yy[x]);y.setInput(t,d.yy),d.yy.lexer=y,d.yy.parser=this,void 0===y.yylloc&&(y.yylloc={});var g=y.yylloc;r.push(g);var p=y.options&&y.options.ranges;function m(){var t;return"number"!=typeof(t=s.pop()||y.lex()||1)&&(t instanceof Array&&(t=(s=t).pop()),t=e.symbols_[t]||t),t}"function"==typeof d.yy.parseError?this.parseError=d.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError,(0,a.eW)(function(t){n.length=n.length-2*t,i.length=i.length-t,r.length=r.length-t},"popStack"),(0,a.eW)(m,"lex");for(var b,v,I,M,k,_,w,E,S,T={};;){if(I=n[n.length-1],this.defaultActions[I]?M=this.defaultActions[I]:(null==b&&(b=m()),M=l[I]&&l[I][b]),void 0===M||!M.length||!M[0]){var z="";for(_ in S=[],l[I])this.terminals_[_]&&_>2&&S.push("'"+this.terminals_[_]+"'");z=y.showPosition?"Parse error on line "+(h+1)+":\n"+y.showPosition()+"\nExpecting "+S.join(", ")+", got '"+(this.terminals_[b]||b)+"'":"Parse error on line "+(h+1)+": Unexpected "+(1==b?"end of input":"'"+(this.terminals_[b]||b)+"'"),this.parseError(z,{text:y.match,token:this.terminals_[b]||b,line:y.yylineno,loc:g,expected:S})}if(M[0]instanceof Array&&M.length>1)throw Error("Parse Error: multiple actions possible at state: "+I+", token: "+b);switch(M[0]){case 1:n.push(b),i.push(y.yytext),r.push(y.yylloc),n.push(M[1]),b=null,v?(b=v,v=null):(c=y.yyleng,o=y.yytext,h=y.yylineno,g=y.yylloc,u>0&&u--);break;case 2:if(w=this.productions_[M[1]][1],T.$=i[i.length-w],T._$={first_line:r[r.length-(w||1)].first_line,last_line:r[r.length-1].last_line,first_column:r[r.length-(w||1)].first_column,last_column:r[r.length-1].last_column},p&&(T._$.range=[r[r.length-(w||1)].range[0],r[r.length-1].range[1]]),void 0!==(k=this.performAction.apply(T,[o,c,h,d.yy,M[1],i,r].concat(f))))return k;w&&(n=n.slice(0,-1*w*2),i=i.slice(0,-1*w),r=r.slice(0,-1*w)),n.push(this.productions_[M[1]][0]),i.push(T.$),r.push(T._$),E=l[n[n.length-2]][n[n.length-1]],n.push(E);break;case 3:return!0}}return!0},"parse")},p={EOF:1,parseError:(0,a.eW)(function(t,e){if(this.yy.parser)this.yy.parser.parseError(t,e);else throw Error(t)},"parseError"),setInput:(0,a.eW)(function(t,e){return this.yy=e||this.yy||{},this._input=t,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},"setInput"),input:(0,a.eW)(function(){var t=this._input[0];return this.yytext+=t,this.yyleng++,this.offset++,this.match+=t,this.matched+=t,t.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),t},"input"),unput:(0,a.eW)(function(t){var e=t.length,n=t.split(/(?:\r\n?|\n)/g);this._input=t+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-e),this.offset-=e;var s=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),n.length-1&&(this.yylineno-=n.length-1);var i=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:n?(n.length===s.length?this.yylloc.first_column:0)+s[s.length-n.length].length-n[0].length:this.yylloc.first_column-e},this.options.ranges&&(this.yylloc.range=[i[0],i[0]+this.yyleng-e]),this.yyleng=this.yytext.length,this},"unput"),more:(0,a.eW)(function(){return this._more=!0,this},"more"),reject:(0,a.eW)(function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},"reject"),less:(0,a.eW)(function(t){this.unput(this.match.slice(t))},"less"),pastInput:(0,a.eW)(function(){var t=this.matched.substr(0,this.matched.length-this.match.length);return(t.length>20?"...":"")+t.substr(-20).replace(/\n/g,"")},"pastInput"),upcomingInput:(0,a.eW)(function(){var t=this.match;return t.length<20&&(t+=this._input.substr(0,20-t.length)),(t.substr(0,20)+(t.length>20?"...":"")).replace(/\n/g,"")},"upcomingInput"),showPosition:(0,a.eW)(function(){var t=this.pastInput(),e=Array(t.length+1).join("-");return t+this.upcomingInput()+"\n"+e+"^"},"showPosition"),test_match:(0,a.eW)(function(t,e){var n,s,i;if(this.options.backtrack_lexer&&(i={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(i.yylloc.range=this.yylloc.range.slice(0))),(s=t[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=s.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:s?s[s.length-1].length-s[s.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+t[0].length},this.yytext+=t[0],this.match+=t[0],this.matches=t,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(t[0].length),this.matched+=t[0],n=this.performAction.call(this,this.yy,this,e,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),n)return n;if(this._backtrack)for(var r in i)this[r]=i[r];return!1},"test_match"),next:(0,a.eW)(function(){if(this.done)return this.EOF;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var t,e,n,s,i=this._currentRules(),r=0;r<i.length;r++)if((n=this._input.match(this.rules[i[r]]))&&(!e||n[0].length>e[0].length)){if(e=n,s=r,this.options.backtrack_lexer){if(!1!==(t=this.test_match(n,i[r])))return t;if(!this._backtrack)return!1;e=!1;continue}if(!this.options.flex)break}return e?!1!==(t=this.test_match(e,i[s]))&&t:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},"next"),lex:(0,a.eW)(function(){return this.next()||this.lex()},"lex"),begin:(0,a.eW)(function(t){this.conditionStack.push(t)},"begin"),popState:(0,a.eW)(function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},"popState"),_currentRules:(0,a.eW)(function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},"_currentRules"),topState:(0,a.eW)(function(t){return(t=this.conditionStack.length-1-Math.abs(t||0))>=0?this.conditionStack[t]:"INITIAL"},"topState"),pushState:(0,a.eW)(function(t){this.begin(t)},"pushState"),stateStackSize:(0,a.eW)(function(){return this.conditionStack.length},"stateStackSize"),options:{"case-insensitive":!0},performAction:(0,a.eW)(function(t,e,n,s){switch(n){case 0:case 1:case 2:case 4:case 7:case 8:break;case 3:if(t.getIndentMode&&t.getIndentMode())return t.consumeIndentText=!0,this.begin("INITIAL"),22;break;case 5:t.setIndentMode&&t.setIndentMode(!1),this.begin("INITIAL"),this.unput(e.yytext);break;case 6:return this.begin("bol"),8;case 9:return 7;case 10:return 11;case 11:return 5;case 12:return 12;case 13:return 17;case 14:if(!t.consumeIndentText)return 19;t.consumeIndentText=!1;break;case 15:return 24;case 16:return e.yytext=e.yytext.slice(2,-2),14;case 17:return e.yytext=e.yytext.slice(1,-1).trim(),14;case 18:return 16;case 19:return 31;case 20:return 33;case 21:return 32;case 22:return 20;case 23:return 21;case 24:return 27;case 25:return 15}},"anonymous"),rules:[/^(?:%%(?!\{)[^\n]*)/i,/^(?:[^\}]%%[^\n]*)/i,/^(?:[ \t]+(?=[\n\r]))/i,/^(?:[ \t]+(?=text\b))/i,/^(?:[ \t]+)/i,/^(?:[^ \t\n\r])/i,/^(?:[\n\r]+)/i,/^(?:%%[^\n]*)/i,/^(?:[ \t]+)/i,/^(?:$)/i,/^(?:title\s[^#\n;]+)/i,/^(?:venn-beta\b)/i,/^(?:set\b)/i,/^(?:union\b)/i,/^(?:text\b)/i,/^(?:style\b)/i,/^(?:\["[^\"]*"\])/i,/^(?:\[[^\]\"]+\])/i,/^(?:[+-]?(\d+(\.\d+)?|\.\d+))/i,/^(?:#[0-9a-fA-F]{3,8})/i,/^(?:rgba\(\s*[0-9.]+\s*[,]\s*[0-9.]+\s*[,]\s*[0-9.]+\s*[,]\s*[0-9.]+\s*\))/i,/^(?:rgb\(\s*[0-9.]+\s*[,]\s*[0-9.]+\s*[,]\s*[0-9.]+\s*\))/i,/^(?:[A-Za-z_][A-Za-z0-9\-_]*)/i,/^(?:"[^\"]*")/i,/^(?:,)/i,/^(?::)/i],conditions:{bol:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25],inclusive:!0},INITIAL:{rules:[0,1,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25],inclusive:!0}}};function m(){this.yy={}}return g.lexer=p,(0,a.eW)(m,"Parser"),m.prototype=g,g.Parser=m,new m}();U.parser=U;var B=[],G=[],Z=[],Y=new Set,V=!1,X=(0,a.eW)((t,e,n)=>{let i=tn(t).sort(),r=n??10/Math.pow(t.length,2);s=i,1===i.length&&Y.add(i[0]),B.push({sets:i,size:r,label:e?H(e):void 0})},"addSubsetData"),K=(0,a.eW)(()=>B,"getSubsetData"),H=(0,a.eW)(t=>{let e=t.trim();return e.length>=2&&e.startsWith('"')&&e.endsWith('"')?e.slice(1,-1):e},"normalizeText"),J=(0,a.eW)(t=>t?H(t):t,"normalizeStyleValue"),Q=(0,a.eW)((t,e,n)=>{let s=H(e);G.push({sets:tn(t).sort(),id:s,label:n?H(n):void 0})},"addTextData"),tt=(0,a.eW)((t,e)=>{let n=tn(t).sort(),s={};for(let[t,n]of e)s[t]=J(n)??n;Z.push({targets:n,styles:s})},"addStyleData"),te=(0,a.eW)(()=>Z,"getStyleData"),tn=(0,a.eW)(t=>t.map(t=>H(t)),"normalizeIdentifierList"),ts=(0,a.eW)(t=>{let e=tn(t).filter(t=>!Y.has(t));if(e.length>0)throw Error(`unknown set identifier: ${e.join(", ")}`)},"validateUnionIdentifiers"),ti=(0,a.eW)(()=>G,"getTextData"),tr=(0,a.eW)(()=>s,"getCurrentSets"),tl=(0,a.eW)(()=>V,"getIndentMode"),ta=(0,a.eW)(t=>{V=t},"setIndentMode"),to=l.vZ.venn;function th(){return(0,r.Rb)(to,(0,l.iE)().venn)}(0,a.eW)(th,"getConfig");var tc={getConfig:th,clear:(0,a.eW)(()=>{(0,l.ZH)(),B.length=0,G.length=0,Z.length=0,Y.clear(),s=void 0,V=!1},"customClear"),setAccTitle:l.GN,getAccTitle:l.eu,setDiagramTitle:l.g2,getDiagramTitle:l.Kr,getAccDescription:l.Mx,setAccDescription:l.U$,addSubsetData:X,getSubsetData:K,addTextData:Q,addStyleData:tt,validateUnionIdentifiers:ts,getTextData:ti,getStyleData:te,getCurrentSets:tr,getIndentMode:tl,setIndentMode:ta},tu=(0,a.eW)(t=>` .venn-title { font-size: 32px; fill: ${t.vennTitleTextColor}; font-family: ${t.fontFamily}; } .venn-circle text { font-size: 48px; font-family: ${t.fontFamily}; } .venn-intersection text { font-size: 48px; fill: ${t.vennSetTextColor}; font-family: ${t.fontFamily}; } .venn-text-node { font-family: ${t.fontFamily}; color: ${t.vennSetTextColor}; } `,"getStyles");function tf(t){let e=new Map;for(let n of t){let t=n.targets.join("|"),s=e.get(t);s?Object.assign(s,n.styles):e.set(t,{...n.styles})}return e}(0,a.eW)(tf,"buildStyleByKey");var ty=(0,a.eW)((t,e,n,s)=>{let r=s.db,a=r.getConfig?.(),{themeVariables:c,look:d,handDrawnSeed:x}=(0,l.iE)(),g="handDrawn"===d,p=[c.venn1,c.venn2,c.venn3,c.venn4,c.venn5,c.venn6,c.venn7,c.venn8].filter(Boolean),m=r.getDiagramTitle?.(),b=r.getSubsetData(),v=r.getTextData(),I=tf(r.getStyleData()),M=a?.width??800,k=a?.height??450,_=M/1600,w=m?48*_:0,E=c.primaryTextColor??c.textColor,T=(0,i.P)(e);T.attr("viewBox",`0 0 ${M} ${k}`),m&&T.append("text").text(m).attr("class","venn-title").attr("font-size",`${32*_}px`).attr("text-anchor","middle").attr("dominant-baseline","middle").attr("x","50%").attr("y",32*_).style("fill",c.vennTitleTextColor||c.titleColor);let z=(0,o.Ys)(document.createElement("div")),R=(function(t={}){let e=!1,n=600,s=350,i=15,r=1e3,l=Math.PI/2,a=!0,o=null,h=!0,c=!0,u=null,f=null,y=!1,d=null,x=!!t&&!!t.symmetricalTextCentre&&t.symmetricalTextCentre,g={},p=t&&t.colourScheme?t.colourScheme:t&&t.colorScheme?t.colorScheme:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],m=0,b=function(t){if(t in g)return g[t];var e=g[t]=p[m];return(m+=1)>=p.length&&(m=0),e},v=S,I=A;function M(g){let p=g.datum(),m=new Set;p.forEach(t=>{0==t.size&&1==t.sets.length&&m.add(t.sets[0])});let M={},k={};if((p=p.filter(t=>!t.sets.some(t=>m.has(t)))).length>0){let t=v(p,{lossFunction:I,distinct:y});a&&(t=N(t,l,f)),k=P(M=$(t,n,s,i,o),p,x)}let _={};function w(t){return t.sets in _?_[t.sets]:1==t.sets.length?""+t.sets[0]:void 0}p.forEach(t=>{t.label&&(_[t.sets]=t.label)}),g.selectAll("svg").data([M]).enter().append("svg");let E=g.select("svg");e?E.attr("viewBox",`0 0 ${n} ${s}`):E.attr("width",n).attr("height",s);let S={},T=!1;function z(t){return e=>{var i,r;return i=t.sets.map(t=>{let i=S[t],r=M[t];return i||(i={x:n/2,y:s/2,radius:1}),r||(r={x:n/2,y:s/2,radius:1}),{x:i.x*(1-e)+r.x*e,y:i.y*(1-e)+r.y*e,radius:i.radius*(1-e)+r.radius*e}}),r=d,L(j(i),r)}}E.selectAll(".venn-area path").each(function(t){let e=this.getAttribute("d");1==t.sets.length&&e&&!y&&(T=!0,S[t.sets[0]]=function(t){let e=t.split(" ");return{x:Number.parseFloat(e[1]),y:Number.parseFloat(e[2]),radius:-Number.parseFloat(e[4])}}(e))});let A=E.selectAll(".venn-area").data(p,t=>t.sets),W=A.enter().append("g").attr("class",t=>`venn-area venn-${1==t.sets.length?"circle":"intersection"}${t.colour||t.color?" venn-coloured":""}`).attr("data-venn-sets",t=>t.sets.join("_")),R=W.append("path"),O=W.append("text").attr("class","label").text(t=>w(t)).attr("text-anchor","middle").attr("dy",".35em").attr("x",n/2).attr("y",s/2);function F(t){return"function"==typeof t.transition?t.transition("venn").duration(r):t}c&&(R.style("fill-opacity","0").filter(t=>1==t.sets.length).style("fill",t=>t.colour?t.colour:t.color?t.color:b(t.sets)).style("fill-opacity",".25"),O.style("fill",e=>e.colour||e.color?"#FFF":t.textFill?t.textFill:1==e.sets.length?b(e.sets):"#444"));let C=g;T&&"function"==typeof C.transition?(C=F(g)).selectAll("path").attrTween("d",z):C.selectAll("path").attr("d",t=>L(j(t.sets.map(t=>M[t])),void 0),d);let q=C.selectAll("text").filter(t=>t.sets in k).text(t=>w(t)).attr("x",t=>Math.floor(k[t.sets].x)).attr("y",t=>Math.floor(k[t.sets].y));h&&(T?"on"in q?q.on("end",D(M,w)):q.each("end",D(M,w)):q.each(D(M,w)));let U=F(A.exit()).remove();"function"==typeof A.transition&&U.selectAll("path").attrTween("d",z);let B=U.selectAll("text").attr("x",n/2).attr("y",s/2);return null!==u&&(O.style("font-size","0px"),q.style("font-size",u),B.style("font-size","0px")),{circles:M,textCentres:k,nodes:A,enter:W,update:C,exit:U}}return M.wrap=function(t){return arguments.length?(h=t,M):h},M.useViewBox=function(){return e=!0,M},M.width=function(t){return arguments.length?(n=t,M):n},M.height=function(t){return arguments.length?(s=t,M):s},M.padding=function(t){return arguments.length?(i=t,M):i},M.distinct=function(t){return arguments.length?(y=t,M):y},M.colours=function(t){return arguments.length?(b=t,M):b},M.colors=function(t){return arguments.length?(b=t,M):b},M.fontSize=function(t){return arguments.length?(u=t,M):u},M.round=function(t){return arguments.length?(d=t,M):d},M.duration=function(t){return arguments.length?(r=t,M):r},M.layoutFunction=function(t){return arguments.length?(v=t,M):v},M.normalize=function(t){return arguments.length?(a=t,M):a},M.scaleToFit=function(t){return arguments.length?(o=t,M):o},M.styled=function(t){return arguments.length?(c=t,M):c},M.orientation=function(t){return arguments.length?(l=t,M):l},M.orientationOrder=function(t){return arguments.length?(f=t,M):f},M.lossFunction=function(t){return arguments.length?(I="default"===t?A:"logRatio"===t?W:t,M):I},M})().width(M).height(k-w);z.datum(b).call(R);let O=g?q.Z.svg(z.select("svg").node()):void 0,F=function(t,e={}){let{lossFunction:n,layoutFunction:s=S,normalize:i=!0,orientation:r=Math.PI/2,orientationOrder:l,width:a=600,height:o=350,padding:h=15,scaleToFit:c=!1,symmetricalTextCentre:u=!1,distinct:f,round:y=2}=e,d=s(t,{lossFunction:"default"!==n&&n?"logRatio"===n?W:n:A,distinct:f});i&&(d=N(d,r,l));let x=$(d,a,o,h,c),g=P(x,t,u),p=new Map(Object.keys(x).map(t=>[t,{set:t,x:x[t].x,y:x[t].y,radius:x[t].radius}])),m=t.map(t=>{let e=t.sets.map(t=>p.get(t)),n=j(e),s=L(n,y);return{circles:e,arcs:n,path:s,area:t,has:new Set(t.sets)}});return m.map(({circles:t,arcs:e,path:n,area:s})=>({data:s,text:g[s.sets],circles:t,arcs:e,path:n,distinctPath:n+function(t){let e="";for(let n of m)n.has.size>t.length&&t.every(t=>n.has.has(t))&&(e+=" "+n.path);return e}(s.sets)}))}(b,{width:M,height:k-w,padding:a?.padding??15}),C=new Map;for(let t of F){let e=td([...t.data.sets].sort());C.set(e,t)}v.length>0&&tx(a,C,z,v,_,I);let U=(0,h.Z)(c.background||"#f4f4f4");z.selectAll(".venn-circle").each(function(t,e){let n=(0,o.Ys)(this),s=td([...t.sets].sort()),i=I.get(s),r=i?.fill||p[e%p.length]||c.primaryColor;n.classed(`venn-set-${e%8}`,!0);let l=i?.["fill-opacity"]??.1,a=i?.stroke||r,h=i?.["stroke-width"]||`${5*_}`;if(g&&O){let t=C.get(s);if(t&&t.circles.length>0){let s=t.circles[0],i=O.circle(s.x,s.y,2*s.radius,{roughness:.7,seed:x,fill:u(r,.7),fillStyle:"hachure",fillWeight:2,hachureGap:8,hachureAngle:-41+60*e,stroke:a,strokeWidth:parseFloat(String(h))});n.select("path").remove(),n.node()?.insertBefore(i,n.select("text").node())}}else n.select("path").style("fill",r).style("fill-opacity",l).style("stroke",a).style("stroke-width",h).style("stroke-opacity",.95);let d=i?.color||(U?(0,f.Z)(r,30):(0,y.Z)(r,30));n.select("text").style("font-size",`${48*_}px`).style("fill",d)}),g&&O?z.selectAll(".venn-intersection").each(function(t){let e=(0,o.Ys)(this),n=td([...t.sets].sort()),s=I.get(n),i=s?.fill;if(i){let t=e.select("path"),n=t.attr("d");if(n){let e=O.path(n,{roughness:.7,seed:x,fill:u(i,.3),fillStyle:"cross-hatch",fillWeight:2,hachureGap:6,hachureAngle:60,stroke:"none"}),s=t.node();s?.parentNode?.insertBefore(e,s),t.remove()}}else e.select("path").style("fill-opacity",0);e.select("text").style("font-size",`${48*_}px`).style("fill",s?.color??c.vennSetTextColor??E)}):(z.selectAll(".venn-intersection text").style("font-size",`${48*_}px`).style("fill",t=>{let e=td([...t.sets].sort());return I.get(e)?.color??c.vennSetTextColor??E}),z.selectAll(".venn-intersection path").style("fill-opacity",t=>{let e=td([...t.sets].sort());return I.get(e)?.fill?1:0}).style("fill",t=>{let e=td([...t.sets].sort());return I.get(e)?.fill??"transparent"}));let B=T.append("g").attr("transform",`translate(0, ${w})`),G=z.select("svg").node();if(G&&"childNodes"in G)for(let t of[...G.childNodes])B.node()?.appendChild(t);(0,l.v2)(T,k,M,a?.useMaxWidth??!0)},"draw");function td(t){return t.join("|")}function tx(t,e,n,s,i,r){let l=t?.useDebugLayout??!1,a=n.select("svg").append("g").attr("class","venn-text-nodes"),o=new Map;for(let t of s){let e=td(t.sets),n=o.get(e);n?n.push(t):o.set(e,[t])}for(let[t,n]of o.entries()){let s=e.get(t);if(!s?.text)continue;let o=s.text.x,h=s.text.y,c=Math.min(...s.circles.map(t=>t.radius)),u=Math.min(...s.circles.map(t=>t.radius-Math.hypot(o-t.x,h-t.y))),f=Number.isFinite(u)?Math.max(0,u):0;0===f&&Number.isFinite(c)&&(f=.6*c);let y=a.append("g").attr("class","venn-text-area").attr("font-size",`${40*i}px`);l&&y.append("circle").attr("class","venn-text-debug-circle").attr("cx",o).attr("cy",h).attr("r",f).attr("fill","none").attr("stroke","purple").attr("stroke-width",1.5*i).attr("stroke-dasharray",`${6*i} ${4*i}`);let d=Math.max(80*i,1.9*f),x=Math.max(60*i,1.9*f),g=(s.data.label&&s.data.label.length>0?Math.min(32*i,.25*f):0)+(n.length<=2?30*i:0),p=o-d/2,m=h-x/2+g,b=Math.max(1,Math.ceil(Math.sqrt(n.length))),v=Math.max(1,Math.ceil(n.length/b)),I=d/b,M=x/v;for(let[t,e]of n.entries()){let n=t%b,s=Math.floor(t/b),a=p+I*(n+.5),o=m+M*(s+.5);l&&y.append("rect").attr("class","venn-text-debug-cell").attr("x",p+I*n).attr("y",m+M*s).attr("width",I).attr("height",M).attr("fill","none").attr("stroke","teal").attr("stroke-width",1*i).attr("stroke-dasharray",`${4*i} ${3*i}`);let h=.9*I,c=.9*M,u=y.append("foreignObject").attr("class","venn-text-node-fo").attr("width",h).attr("height",c).attr("x",a-h/2).attr("y",o-c/2).attr("overflow","visible"),f=r.get(e.id)?.color,d=u.append("xhtml:span").attr("class","venn-text-node").style("display","flex").style("width","100%").style("height","100%").style("white-space","normal").style("align-items","center").style("justify-content","center").style("text-align","center").style("overflow-wrap","normal").style("word-break","normal").text(e.label??e.id);f&&d.style("color",f)}}}(0,a.eW)(td,"stableSetsKey"),(0,a.eW)(tx,"renderTextNodes");var tg={parser:U,db:tc,renderer:{draw:ty},styles:tu}}};