rdesign/frontend/node_modules/mermaid/dist/chunks/mermaid.esm.min/vennDiagram-R4MEU4WM.mjs

35 lines
42 KiB
JavaScript

import{a as Bt}from"./chunk-D4HHKWPY.mjs";import{a as Pt}from"./chunk-IWDTEBJL.mjs";import{l as jt}from"./chunk-Q3CC2MQB.mjs";import"./chunk-XBXGYYE5.mjs";import{N as Rt,Q as zt,R as Ct,S as Ot,T as Vt,U as Nt,V as Lt,W as Ft,d as Tt,e as Et,f as _t,g as ct,j as At,s as it}from"./chunk-3UWU4A3N.mjs";import{h as rt}from"./chunk-MGPAVIPZ.mjs";import"./chunk-JIN56HTB.mjs";import{a as d}from"./chunk-VELTKBKT.mjs";var ut=(function(){var t=d(function(D,x,b,k){for(b=b||{},k=D.length;k--;b[D[k]]=x);return b},"o"),n=[5,8],s=[7,8,11,12,17,19,22,24],e=[1,17],i=[1,18],r=[7,8,11,12,14,15,16,17,19,20,21,22,24,27],a=[1,31],c=[1,39],h=[7,8,11,12,17,19,22,24,27],u=[1,57],o=[1,56],p=[1,58],g=[1,59],v=[1,60],y=[7,8,11,12,16,17,19,20,22,24,27,31,32,33],S={trace:d(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:d(function(x,b,k,l,m,f,V){var I=f.length-1;switch(m){case 1:return f[I-1];case 2:case 3:case 4:this.$=[];break;case 5:f[I-1].push(f[I]),this.$=f[I-1];break;case 6:this.$=[];break;case 7:case 22:case 32:case 36:case 37:case 38:case 39:case 40:this.$=f[I];break;case 8:l.setDiagramTitle(f[I].substr(6)),this.$=f[I].substr(6);break;case 9:l.addSubsetData([f[I]],void 0,void 0),l.setIndentMode&&l.setIndentMode(!0);break;case 10:l.addSubsetData([f[I-1]],f[I],void 0),l.setIndentMode&&l.setIndentMode(!0);break;case 11:l.addSubsetData([f[I-2]],void 0,parseFloat(f[I])),l.setIndentMode&&l.setIndentMode(!0);break;case 12:l.addSubsetData([f[I-3]],f[I-2],parseFloat(f[I])),l.setIndentMode&&l.setIndentMode(!0);break;case 13:if(f[I].length<2)throw new Error("union requires multiple identifiers");l.validateUnionIdentifiers&&l.validateUnionIdentifiers(f[I]),l.addSubsetData(f[I],void 0,void 0),l.setIndentMode&&l.setIndentMode(!0);break;case 14:if(f[I-1].length<2)throw new Error("union requires multiple identifiers");l.validateUnionIdentifiers&&l.validateUnionIdentifiers(f[I-1]),l.addSubsetData(f[I-1],f[I],void 0),l.setIndentMode&&l.setIndentMode(!0);break;case 15:if(f[I-2].length<2)throw new Error("union requires multiple identifiers");l.validateUnionIdentifiers&&l.validateUnionIdentifiers(f[I-2]),l.addSubsetData(f[I-2],void 0,parseFloat(f[I])),l.setIndentMode&&l.setIndentMode(!0);break;case 16:if(f[I-3].length<2)throw new Error("union requires multiple identifiers");l.validateUnionIdentifiers&&l.validateUnionIdentifiers(f[I-3]),l.addSubsetData(f[I-3],f[I-2],parseFloat(f[I])),l.setIndentMode&&l.setIndentMode(!0);break;case 17:case 18:case 19:l.addTextData(f[I-1],f[I],void 0);break;case 20:case 21:l.addTextData(f[I-2],f[I-1],f[I]);break;case 23:l.addStyleData(f[I-1],f[I]);break;case 24:case 25:case 26:var C=l.getCurrentSets();if(!C)throw new Error("text requires set");l.addTextData(C,f[I],void 0);break;case 27:case 28:var C=l.getCurrentSets();if(!C)throw new Error("text requires set");l.addTextData(C,f[I-1],f[I]);break;case 29:case 41:this.$=[f[I]];break;case 30:case 42:this.$=[...f[I-2],f[I]];break;case 31:this.$=[f[I-2],f[I]];break;case 33:this.$=f[I].join(" ");break;case 34:this.$=[f[I]];break;case 35:f[I-1].push(f[I]),this.$=f[I-1];break;case 43:case 44:this.$=f[I];break}},"anonymous"),table:[t(n,[2,2],{3:1,4:2}),{1:[3]},{5:[1,3],8:[1,4]},t(s,[2,4],{6:5}),t(n,[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(s,[2,5]),t(s,[2,6]),t(s,[2,7]),t(s,[2,8]),{13:16,20:e,21:i},{13:20,18:19,20:e,21:i},{13:20,18:21,20:e,21:i},{16:[1,25],20:[1,23],21:[1,24],23:22},{13:20,18:26,20:e,21:i},t(s,[2,9],{14:[1,27],15:[1,28]}),t(r,[2,43]),t(r,[2,44]),t(s,[2,13],{14:[1,29],15:[1,30],27:a}),t(r,[2,41]),{16:[1,34],20:[1,32],21:[1,33],27:a},t(s,[2,22]),t(s,[2,24],{14:[1,35]}),t(s,[2,25],{14:[1,36]}),t(s,[2,26]),{20:c,25:37,26:38,27:a},t(s,[2,10],{15:[1,40]}),{16:[1,41]},t(s,[2,14],{15:[1,42]}),{16:[1,43]},{13:44,20:e,21:i},t(s,[2,17],{14:[1,45]}),t(s,[2,18],{14:[1,46]}),t(s,[2,19]),t(s,[2,27]),t(s,[2,28]),t(s,[2,23],{27:[1,47]}),t(h,[2,29]),{15:[1,48]},{16:[1,49]},t(s,[2,11]),{16:[1,50]},t(s,[2,15]),t(r,[2,42]),t(s,[2,20]),t(s,[2,21]),{20:c,26:51},{16:u,20:o,21:[1,53],28:52,29:54,30:55,31:p,32:g,33:v},t(s,[2,12]),t(s,[2,16]),t(h,[2,30]),t(h,[2,31]),t(h,[2,32]),t(h,[2,33],{30:61,16:u,20:o,31:p,32:g,33:v}),t(y,[2,34]),t(y,[2,36]),t(y,[2,37]),t(y,[2,38]),t(y,[2,39]),t(y,[2,40]),t(y,[2,35])],defaultActions:{6:[2,1]},parseError:d(function(x,b){if(b.recoverable)this.trace(x);else{var k=new Error(x);throw k.hash=b,k}},"parseError"),parse:d(function(x){var b=this,k=[0],l=[],m=[null],f=[],V=this.table,I="",C=0,G=0,F=0,T=2,R=1,z=f.slice.call(arguments,1),_=Object.create(this.lexer),O={yy:{}};for(var N in this.yy)Object.prototype.hasOwnProperty.call(this.yy,N)&&(O.yy[N]=this.yy[N]);_.setInput(x,O.yy),O.yy.lexer=_,O.yy.parser=this,typeof _.yylloc>"u"&&(_.yylloc={});var L=_.yylloc;f.push(L);var H=_.options&&_.options.ranges;typeof O.yy.parseError=="function"?this.parseError=O.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function Y(W){k.length=k.length-2*W,m.length=m.length-W,f.length=f.length-W}d(Y,"popStack");function j(){var W;return W=l.pop()||_.lex()||R,typeof W!="number"&&(W instanceof Array&&(l=W,W=l.pop()),W=b.symbols_[W]||W),W}d(j,"lex");for(var A,K,U,M,B,et,Z={},X,P,wt,st;;){if(U=k[k.length-1],this.defaultActions[U]?M=this.defaultActions[U]:((A===null||typeof A>"u")&&(A=j()),M=V[U]&&V[U][A]),typeof M>"u"||!M.length||!M[0]){var lt="";st=[];for(X in V[U])this.terminals_[X]&&X>T&&st.push("'"+this.terminals_[X]+"'");_.showPosition?lt="Parse error on line "+(C+1)+`:
`+_.showPosition()+`
Expecting `+st.join(", ")+", got '"+(this.terminals_[A]||A)+"'":lt="Parse error on line "+(C+1)+": Unexpected "+(A==R?"end of input":"'"+(this.terminals_[A]||A)+"'"),this.parseError(lt,{text:_.match,token:this.terminals_[A]||A,line:_.yylineno,loc:L,expected:st})}if(M[0]instanceof Array&&M.length>1)throw new Error("Parse Error: multiple actions possible at state: "+U+", token: "+A);switch(M[0]){case 1:k.push(A),m.push(_.yytext),f.push(_.yylloc),k.push(M[1]),A=null,K?(A=K,K=null):(G=_.yyleng,I=_.yytext,C=_.yylineno,L=_.yylloc,F>0&&F--);break;case 2:if(P=this.productions_[M[1]][1],Z.$=m[m.length-P],Z._$={first_line:f[f.length-(P||1)].first_line,last_line:f[f.length-1].last_line,first_column:f[f.length-(P||1)].first_column,last_column:f[f.length-1].last_column},H&&(Z._$.range=[f[f.length-(P||1)].range[0],f[f.length-1].range[1]]),et=this.performAction.apply(Z,[I,G,C,O.yy,M[1],m,f].concat(z)),typeof et<"u")return et;P&&(k=k.slice(0,-1*P*2),m=m.slice(0,-1*P),f=f.slice(0,-1*P)),k.push(this.productions_[M[1]][0]),m.push(Z.$),f.push(Z._$),wt=V[k[k.length-2]][k[k.length-1]],k.push(wt);break;case 3:return!0}}return!0},"parse")},E=(function(){var D={EOF:1,parseError:d(function(b,k){if(this.yy.parser)this.yy.parser.parseError(b,k);else throw new Error(b)},"parseError"),setInput:d(function(x,b){return this.yy=b||this.yy||{},this._input=x,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:d(function(){var x=this._input[0];this.yytext+=x,this.yyleng++,this.offset++,this.match+=x,this.matched+=x;var b=x.match(/(?:\r\n?|\n).*/g);return b?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),x},"input"),unput:d(function(x){var b=x.length,k=x.split(/(?:\r\n?|\n)/g);this._input=x+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-b),this.offset-=b;var l=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),k.length-1&&(this.yylineno-=k.length-1);var m=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:k?(k.length===l.length?this.yylloc.first_column:0)+l[l.length-k.length].length-k[0].length:this.yylloc.first_column-b},this.options.ranges&&(this.yylloc.range=[m[0],m[0]+this.yyleng-b]),this.yyleng=this.yytext.length,this},"unput"),more:d(function(){return this._more=!0,this},"more"),reject:d(function(){if(this.options.backtrack_lexer)this._backtrack=!0;else return 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).
`+this.showPosition(),{text:"",token:null,line:this.yylineno});return this},"reject"),less:d(function(x){this.unput(this.match.slice(x))},"less"),pastInput:d(function(){var x=this.matched.substr(0,this.matched.length-this.match.length);return(x.length>20?"...":"")+x.substr(-20).replace(/\n/g,"")},"pastInput"),upcomingInput:d(function(){var x=this.match;return x.length<20&&(x+=this._input.substr(0,20-x.length)),(x.substr(0,20)+(x.length>20?"...":"")).replace(/\n/g,"")},"upcomingInput"),showPosition:d(function(){var x=this.pastInput(),b=new Array(x.length+1).join("-");return x+this.upcomingInput()+`
`+b+"^"},"showPosition"),test_match:d(function(x,b){var k,l,m;if(this.options.backtrack_lexer&&(m={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&&(m.yylloc.range=this.yylloc.range.slice(0))),l=x[0].match(/(?:\r\n?|\n).*/g),l&&(this.yylineno+=l.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:l?l[l.length-1].length-l[l.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+x[0].length},this.yytext+=x[0],this.match+=x[0],this.matches=x,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(x[0].length),this.matched+=x[0],k=this.performAction.call(this,this.yy,this,b,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),k)return k;if(this._backtrack){for(var f in m)this[f]=m[f];return!1}return!1},"test_match"),next:d(function(){if(this.done)return this.EOF;this._input||(this.done=!0);var x,b,k,l;this._more||(this.yytext="",this.match="");for(var m=this._currentRules(),f=0;f<m.length;f++)if(k=this._input.match(this.rules[m[f]]),k&&(!b||k[0].length>b[0].length)){if(b=k,l=f,this.options.backtrack_lexer){if(x=this.test_match(k,m[f]),x!==!1)return x;if(this._backtrack){b=!1;continue}else return!1}else if(!this.options.flex)break}return b?(x=this.test_match(b,m[l]),x!==!1?x:!1):this._input===""?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+`. Unrecognized text.
`+this.showPosition(),{text:"",token:null,line:this.yylineno})},"next"),lex:d(function(){var b=this.next();return b||this.lex()},"lex"),begin:d(function(b){this.conditionStack.push(b)},"begin"),popState:d(function(){var b=this.conditionStack.length-1;return b>0?this.conditionStack.pop():this.conditionStack[0]},"popState"),_currentRules:d(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:d(function(b){return b=this.conditionStack.length-1-Math.abs(b||0),b>=0?this.conditionStack[b]:"INITIAL"},"topState"),pushState:d(function(b){this.begin(b)},"pushState"),stateStackSize:d(function(){return this.conditionStack.length},"stateStackSize"),options:{"case-insensitive":!0},performAction:d(function(b,k,l,m){var f=m;switch(l){case 0:break;case 1:break;case 2:break;case 3:if(b.getIndentMode&&b.getIndentMode())return b.consumeIndentText=!0,this.begin("INITIAL"),22;break;case 4:break;case 5:b.setIndentMode&&b.setIndentMode(!1),this.begin("INITIAL"),this.unput(k.yytext);break;case 6:return this.begin("bol"),8;break;case 7:break;case 8:break;case 9:return 7;case 10:return 11;case 11:return 5;case 12:return 12;case 13:return 17;case 14:if(b.consumeIndentText)b.consumeIndentText=!1;else return 19;break;case 15:return 24;case 16:return k.yytext=k.yytext.slice(2,-2),14;break;case 17:return k.yytext=k.yytext.slice(1,-1).trim(),14;break;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}}};return D})();S.lexer=E;function w(){this.yy={}}return d(w,"Parser"),w.prototype=S,S.Parser=w,new w})();ut.parser=ut;var qt=ut;var ft=[],ht=[],dt=[],gt=new Set,xt,yt=!1,ue=d((t,n,s)=>{let e=ot(t).sort(),i=s??10/Math.pow(t.length,2);xt=e,e.length===1&&gt.add(e[0]),ft.push({sets:e,size:i,label:n?nt(n):void 0})},"addSubsetData"),fe=d(()=>ft,"getSubsetData"),nt=d(t=>{let n=t.trim();return n.length>=2&&n.startsWith('"')&&n.endsWith('"')?n.slice(1,-1):n},"normalizeText"),he=d(t=>t&&nt(t),"normalizeStyleValue"),de=d((t,n,s)=>{let e=nt(n);ht.push({sets:ot(t).sort(),id:e,label:s?nt(s):void 0})},"addTextData"),ge=d((t,n)=>{let s=ot(t).sort(),e={};for(let[i,r]of n)e[i]=he(r)??r;dt.push({targets:s,styles:e})},"addStyleData"),xe=d(()=>dt,"getStyleData"),ot=d(t=>t.map(n=>nt(n)),"normalizeIdentifierList"),ye=d(t=>{let s=ot(t).filter(e=>!gt.has(e));if(s.length>0)throw new Error(`unknown set identifier: ${s.join(", ")}`)},"validateUnionIdentifiers"),pe=d(()=>ht,"getTextData"),me=d(()=>xt,"getCurrentSets"),be=d(()=>yt,"getIndentMode"),ve=d(t=>{yt=t},"setIndentMode"),ke=At.venn;function Me(){return jt(ke,it().venn)}d(Me,"getConfig");var Ie=d(()=>{zt(),ft.length=0,ht.length=0,dt.length=0,gt.clear(),xt=void 0,yt=!1},"customClear"),Gt={getConfig:Me,clear:Ie,setAccTitle:Ct,getAccTitle:Ot,setDiagramTitle:Lt,getDiagramTitle:Ft,getAccDescription:Nt,setAccDescription:Vt,addSubsetData:ue,getSubsetData:fe,addTextData:de,addStyleData:ge,validateUnionIdentifiers:ye,getTextData:pe,getStyleData:xe,getCurrentSets:me,getIndentMode:be,setIndentMode:ve};var Se=d(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"),Ut=Se;function at(t,n){let s=we(t),e=s.filter(c=>De(c,t)),i=0,r=0,a=[];if(e.length>1){let c=Yt(e);for(let u=0;u<e.length;++u){let o=e[u];o.angle=Math.atan2(o.x-c.x,o.y-c.y)}e.sort((u,o)=>o.angle-u.angle);let h=e[e.length-1];for(let u=0;u<e.length;++u){let o=e[u];r+=(h.x+o.x)*(o.y-h.y);let p={x:(o.x+h.x)/2,y:(o.y+h.y)/2},g=null;for(let v=0;v<o.parentIndex.length;++v)if(h.parentIndex.includes(o.parentIndex[v])){let y=t[o.parentIndex[v]],S=Math.atan2(o.x-y.x,o.y-y.y),E=Math.atan2(h.x-y.x,h.y-y.y),w=E-S;w<0&&(w+=2*Math.PI);let D=E-w/2,x=q(p,{x:y.x+y.radius*Math.sin(D),y:y.y+y.radius*Math.cos(D)});x>y.radius*2&&(x=y.radius*2),(g==null||g.width>x)&&(g={circle:y,width:x,p1:o,p2:h,large:x>y.radius,sweep:!0})}g!=null&&(a.push(g),i+=bt(g.circle.radius,g.width),h=o)}}else{let c=t[0];for(let u=1;u<t.length;++u)t[u].radius<c.radius&&(c=t[u]);let h=!1;for(let u=0;u<t.length;++u)if(q(t[u],c)>Math.abs(c.radius-t[u].radius)){h=!0;break}h?i=r=0:(i=c.radius*c.radius*Math.PI,a.push({circle:c,p1:{x:c.x,y:c.y+c.radius},p2:{x:c.x-1e-10,y:c.y+c.radius},width:c.radius*2,large:!0,sweep:!0}))}return r/=2,n&&(n.area=i+r,n.arcArea=i,n.polygonArea=r,n.arcs=a,n.innerPoints=e,n.intersectionPoints=s),i+r}d(at,"intersectionArea");function De(t,n){return n.every(s=>q(t,s)<s.radius+1e-10)}d(De,"containedInCircles");function we(t){let n=[];for(let s=0;s<t.length;++s)for(let e=s+1;e<t.length;++e){let i=Kt(t[s],t[e]);for(let r of i)r.parentIndex=[s,e],n.push(r)}return n}d(we,"getIntersectionPoints");function bt(t,n){return t*t*Math.acos(1-n/t)-(t-n)*Math.sqrt(n*(2*t-n))}d(bt,"circleArea");function q(t,n){return Math.sqrt((t.x-n.x)*(t.x-n.x)+(t.y-n.y)*(t.y-n.y))}d(q,"distance");function Dt(t,n,s){if(s>=t+n)return 0;if(s<=Math.abs(t-n))return Math.PI*Math.min(t,n)*Math.min(t,n);let e=t-(s*s-n*n+t*t)/(2*s),i=n-(s*s-t*t+n*n)/(2*s);return bt(t,e)+bt(n,i)}d(Dt,"circleOverlap");function Kt(t,n){let s=q(t,n),e=t.radius,i=n.radius;if(s>=e+i||s<=Math.abs(e-i))return[];let r=(e*e-i*i+s*s)/(2*s),a=Math.sqrt(e*e-r*r),c=t.x+r*(n.x-t.x)/s,h=t.y+r*(n.y-t.y)/s,u=-(n.y-t.y)*(a/s),o=-(n.x-t.x)*(a/s);return[{x:c+u,y:h-o},{x:c-u,y:h+o}]}d(Kt,"circleCircleIntersection");function Yt(t){let n={x:0,y:0};for(let s of t)n.x+=s.x,n.y+=s.y;return n.x/=t.length,n.y/=t.length,n}d(Yt,"getCenter");function Te(t,n,s,e){e=e||{};let i=e.maxIterations||100,r=e.tolerance||1e-10,a=t(n),c=t(s),h=s-n;if(a*c>0)throw"Initial bisect points must have opposite signs";if(a===0)return n;if(c===0)return s;for(let u=0;u<i;++u){h/=2;let o=n+h,p=t(o);if(p*a>=0&&(n=o),Math.abs(h)<r||p===0)return o}return n+h}d(Te,"bisect");function vt(t){let n=new Array(t);for(let s=0;s<t;++s)n[s]=0;return n}d(vt,"zeros");function Wt(t,n){return vt(t).map(()=>vt(n))}d(Wt,"zerosM");function $(t,n){let s=0;for(let e=0;e<t.length;++e)s+=t[e]*n[e];return s}d($,"dot");function kt(t){return Math.sqrt($(t,t))}d(kt,"norm2");function Mt(t,n,s){for(let e=0;e<n.length;++e)t[e]=n[e]*s}d(Mt,"scale");function J(t,n,s,e,i){for(let r=0;r<t.length;++r)t[r]=n*s[r]+e*i[r]}d(J,"weightedSum");function Xt(t,n,s){s=s||{};let e=s.maxIterations||n.length*200,i=s.nonZeroDelta||1.05,r=s.zeroDelta||.001,a=s.minErrorDelta||1e-6,c=s.minErrorDelta||1e-5,h=s.rho!==void 0?s.rho:1,u=s.chi!==void 0?s.chi:2,o=s.psi!==void 0?s.psi:-.5,p=s.sigma!==void 0?s.sigma:.5,g,v=n.length,y=new Array(v+1);y[0]=n,y[0].fx=t(n),y[0].id=0;for(let k=0;k<v;++k){let l=n.slice();l[k]=l[k]?l[k]*i:r,y[k+1]=l,y[k+1].fx=t(l),y[k+1].id=k+1}function S(k){for(let l=0;l<k.length;l++)y[v][l]=k[l];y[v].fx=k.fx}d(S,"updateSimplex");let E=d((k,l)=>k.fx-l.fx,"sortOrder"),w=n.slice(),D=n.slice(),x=n.slice(),b=n.slice();for(let k=0;k<e;++k){if(y.sort(E),s.history){let m=y.map(f=>{let V=f.slice();return V.fx=f.fx,V.id=f.id,V});m.sort((f,V)=>f.id-V.id),s.history.push({x:y[0].slice(),fx:y[0].fx,simplex:m})}g=0;for(let m=0;m<v;++m)g=Math.max(g,Math.abs(y[0][m]-y[1][m]));if(Math.abs(y[0].fx-y[v].fx)<a&&g<c)break;for(let m=0;m<v;++m){w[m]=0;for(let f=0;f<v;++f)w[m]+=y[f][m];w[m]/=v}let l=y[v];if(J(D,1+h,w,-h,l),D.fx=t(D),D.fx<y[0].fx)J(b,1+u,w,-u,l),b.fx=t(b),b.fx<D.fx?S(b):S(D);else if(D.fx>=y[v-1].fx){let m=!1;if(D.fx>l.fx?(J(x,1+o,w,-o,l),x.fx=t(x),x.fx<l.fx?S(x):m=!0):(J(x,1-o*h,w,o*h,l),x.fx=t(x),x.fx<D.fx?S(x):m=!0),m){if(p>=1)break;for(let f=1;f<y.length;++f)J(y[f],1-p,y[0],p,y[f]),y[f].fx=t(y[f])}}else S(D)}return y.sort(E),{fx:y[0].fx,x:y[0]}}d(Xt,"nelderMead");function Ee(t,n,s,e,i,r,a){let c=s.fx,h=$(s.fxprime,n),u=c,o=c,p=h,g=0;i=i||1,r=r||1e-6,a=a||.1;function v(y,S,E){for(let w=0;w<16;++w)if(i=(y+S)/2,J(e.x,1,s.x,i,n),u=e.fx=t(e.x,e.fxprime),p=$(e.fxprime,n),u>c+r*i*h||u>=E)S=i;else{if(Math.abs(p)<=-a*h)return i;p*(S-y)>=0&&(S=y),y=i,E=u}return 0}d(v,"zoom");for(let y=0;y<10;++y){if(J(e.x,1,s.x,i,n),u=e.fx=t(e.x,e.fxprime),p=$(e.fxprime,n),u>c+r*i*h||y&&u>=o)return v(g,i,o);if(Math.abs(p)<=-a*h)return i;if(p>=0)return v(i,g,u);o=u,g=i,i*=2}return i}d(Ee,"wolfeLineSearch");function _e(t,n,s){let e={x:n.slice(),fx:0,fxprime:n.slice()},i={x:n.slice(),fx:0,fxprime:n.slice()},r=n.slice(),a,c,h=1,u;s=s||{},u=s.maxIterations||n.length*20,e.fx=t(e.x,e.fxprime),a=e.fxprime.slice(),Mt(a,e.fxprime,-1);for(let o=0;o<u;++o){if(h=Ee(t,a,e,i,h),s.history&&s.history.push({x:e.x.slice(),fx:e.fx,fxprime:e.fxprime.slice(),alpha:h}),!h)Mt(a,e.fxprime,-1);else{J(r,1,i.fxprime,-1,e.fxprime);let p=$(e.fxprime,e.fxprime),g=Math.max(0,$(r,i.fxprime)/p);J(a,g,a,-1,i.fxprime),c=e,e=i,i=c}if(kt(e.fxprime)<=1e-5)break}return s.history&&s.history.push({x:e.x.slice(),fx:e.fx,fxprime:e.fxprime.slice(),alpha:h}),e}d(_e,"conjugateGradient");function Zt(t,n={}){n.maxIterations=n.maxIterations||500;let s=n.initialLayout||Ce,e=n.lossFunction||tt,i=Ae(t,n),r=s(i,n),a=Object.keys(r),c=[];for(let o of a)c.push(r[o].x),c.push(r[o].y);let u=Xt(o=>{let p={};for(let g=0;g<a.length;++g){let v=a[g];p[v]={x:o[2*g],y:o[2*g+1],radius:r[v].radius}}return e(p,i)},c,n).x;for(let o=0;o<a.length;++o){let p=a[o];r[p].x=u[2*o],r[p].y=u[2*o+1]}return r}d(Zt,"venn");var Jt=1e-10;function It(t,n,s){return Math.min(t,n)*Math.min(t,n)*Math.PI<=s+Jt?Math.abs(t-n):Te(e=>Dt(t,n,e)-s,0,t+n)}d(It,"distanceFromIntersectArea");function Ae(t,n={}){let s=n.distinct,e=t.map(c=>Object.assign({},c));function i(c){return c.join(";")}if(d(i,"toKey"),s){let c=new Map;for(let h of e)for(let u=0;u<h.sets.length;u++){let o=String(h.sets[u]);c.set(o,h.size+(c.get(o)||0));for(let p=u+1;p<h.sets.length;p++){let g=String(h.sets[p]),v=`${o};${g}`,y=`${g};${o}`;c.set(v,h.size+(c.get(v)||0)),c.set(y,h.size+(c.get(y)||0))}}for(let h of e)h.sets.length<3&&(h.size=c.get(i(h.sets)))}let r=[],a=new Set;for(let c of e)if(c.sets.length===1)r.push(c.sets[0]);else if(c.sets.length===2){let h=c.sets[0],u=c.sets[1];a.add(i(c.sets)),a.add(i([u,h]))}r.sort((c,h)=>c===h?0:c<h?-1:1);for(let c=0;c<r.length;++c){let h=r[c];for(let u=c+1;u<r.length;++u){let o=r[u];a.has(i([h,o]))||e.push({sets:[h,o],size:0})}}return e}d(Ae,"addMissingAreas");function Re(t,n,s){let e=Wt(n.length,n.length),i=Wt(n.length,n.length);return t.filter(r=>r.sets.length===2).forEach(r=>{let a=s[r.sets[0]],c=s[r.sets[1]],h=Math.sqrt(n[a].size/Math.PI),u=Math.sqrt(n[c].size/Math.PI),o=It(h,u,r.size);e[a][c]=e[c][a]=o;let p=0;r.size+1e-10>=Math.min(n[a].size,n[c].size)?p=1:r.size<=1e-10&&(p=-1),i[a][c]=i[c][a]=p}),{distances:e,constraints:i}}d(Re,"getDistanceMatrices");function ze(t,n,s,e){for(let r=0;r<n.length;++r)n[r]=0;let i=0;for(let r=0;r<s.length;++r){let a=t[2*r],c=t[2*r+1];for(let h=r+1;h<s.length;++h){let u=t[2*h],o=t[2*h+1],p=s[r][h],g=e[r][h],v=(u-a)*(u-a)+(o-c)*(o-c),y=Math.sqrt(v),S=v-p*p;g>0&&y<=p||g<0&&y>=p||(i+=2*S*S,n[2*r]+=4*S*(a-u),n[2*r+1]+=4*S*(c-o),n[2*h]+=4*S*(u-a),n[2*h+1]+=4*S*(o-c))}}return i}d(ze,"constrainedMDSGradient");function Ce(t,n={}){let s=Ve(t,n),e=n.lossFunction||tt;if(t.length>=8){let i=Oe(t,n),r=e(i,t),a=e(s,t);r+1e-8<a&&(s=i)}return s}d(Ce,"bestInitialLayout");function Oe(t,n={}){let s=n.restarts||10,e=[],i={};for(let g of t)g.sets.length===1&&(i[g.sets[0]]=e.length,e.push(g));let{distances:r,constraints:a}=Re(t,e,i),c=kt(r.map(kt))/r.length;r=r.map(g=>g.map(v=>v/c));let h=d((g,v)=>ze(g,v,r,a),"obj"),u=null;for(let g=0;g<s;++g){let v=vt(r.length*2).map(Math.random),y=_e(h,v,n);(!u||y.fx<u.fx)&&(u=y)}let o=u.x,p={};for(let g=0;g<e.length;++g){let v=e[g];p[v.sets[0]]={x:o[2*g]*c,y:o[2*g+1]*c,radius:Math.sqrt(v.size/Math.PI)}}if(n.history)for(let g of n.history)Mt(g.x,c);return p}d(Oe,"constrainedMDSLayout");function Ve(t,n){let s=n&&n.lossFunction?n.lossFunction:tt,e={},i={};for(let p of t)if(p.sets.length===1){let g=p.sets[0];e[g]={x:1e10,y:1e10,rowid:e.length,size:p.size,radius:Math.sqrt(p.size/Math.PI)},i[g]=[]}t=t.filter(p=>p.sets.length===2);for(let p of t){let g=p.weight!=null?p.weight:1,v=p.sets[0],y=p.sets[1];p.size+Jt>=Math.min(e[v].size,e[y].size)&&(g=0),i[v].push({set:y,size:p.size,weight:g}),i[y].push({set:v,size:p.size,weight:g})}let r=[];Object.keys(i).forEach(p=>{let g=0;for(let v=0;v<i[p].length;++v)g+=i[p][v].size*i[p][v].weight;r.push({set:p,size:g})});function a(p,g){return g.size-p.size}d(a,"sortOrder"),r.sort(a);let c={};function h(p){return p.set in c}d(h,"isPositioned");function u(p,g){e[g].x=p.x,e[g].y=p.y,c[g]=!0}d(u,"positionSet"),u({x:0,y:0},r[0].set);for(let p=1;p<r.length;++p){let g=r[p].set,v=i[g].filter(h),y=e[g];if(v.sort(a),v.length===0)throw"ERROR: missing pairwise overlap information";let S=[];for(var o=0;o<v.length;++o){let D=e[v[o].set],x=It(y.radius,D.radius,v[o].size);S.push({x:D.x+x,y:D.y}),S.push({x:D.x-x,y:D.y}),S.push({y:D.y+x,x:D.x}),S.push({y:D.y-x,x:D.x});for(let b=o+1;b<v.length;++b){let k=e[v[b].set],l=It(y.radius,k.radius,v[b].size),m=Kt({x:D.x,y:D.y,radius:x},{x:k.x,y:k.y,radius:l});S.push(...m)}}let E=1e50,w=S[0];for(let D of S){e[g].x=D.x,e[g].y=D.y;let x=s(e,t);x<E&&(E=x,w=D)}u(w,g)}return e}d(Ve,"greedyLayout");function tt(t,n){let s=0;for(let e of n){if(e.sets.length===1)continue;let i;if(e.sets.length===2){let a=t[e.sets[0]],c=t[e.sets[1]];i=Dt(a.radius,c.radius,q(a,c))}else i=at(e.sets.map(a=>t[a]));let r=e.weight!=null?e.weight:1;s+=r*(i-e.size)*(i-e.size)}return s}d(tt,"lossFunction");function Qt(t,n){let s=0;for(let e of n){if(e.sets.length===1)continue;let i;if(e.sets.length===2){let c=t[e.sets[0]],h=t[e.sets[1]];i=Dt(c.radius,h.radius,q(c,h))}else i=at(e.sets.map(c=>t[c]));let r=e.weight!=null?e.weight:1,a=Math.log((i+1)/(e.size+1));s+=r*a*a}return s}d(Qt,"logRatioLossFunction");function Ne(t,n,s){if(s==null?t.sort((i,r)=>r.radius-i.radius):t.sort(s),t.length>0){let i=t[0].x,r=t[0].y;for(let a of t)a.x-=i,a.y-=r}if(t.length===2&&q(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 i=Math.atan2(t[1].x,t[1].y)-n,r=Math.cos(i),a=Math.sin(i);for(let c of t){let h=c.x,u=c.y;c.x=r*h-a*u,c.y=a*h+r*u}}if(t.length>2){let i=Math.atan2(t[2].x,t[2].y)-n;for(;i<0;)i+=2*Math.PI;for(;i>2*Math.PI;)i-=2*Math.PI;if(i>Math.PI){let r=t[1].y/(1e-10+t[1].x);for(let a of t){var e=(a.x+r*a.y)/(1+r*r);a.x=2*e-a.x,a.y=2*e*r-a.y}}}}d(Ne,"orientateCircles");function Le(t){t.forEach(i=>{i.parent=i});function n(i){return i.parent!==i&&(i.parent=n(i.parent)),i.parent}d(n,"find");function s(i,r){let a=n(i),c=n(r);a.parent=c}d(s,"union");for(let i=0;i<t.length;++i)for(let r=i+1;r<t.length;++r){let a=t[i].radius+t[r].radius;q(t[i],t[r])+1e-10<a&&s(t[r],t[i])}let e=new Map;for(let i=0;i<t.length;++i){let r=n(t[i]).parent.setid;e.has(r)||e.set(r,[]),e.get(r).push(t[i])}return t.forEach(i=>{delete i.parent}),Array.from(e.values())}d(Le,"disjointCluster");function St(t){let n=d(s=>{let e=t.reduce((r,a)=>Math.max(r,a[s]+a.radius),Number.NEGATIVE_INFINITY),i=t.reduce((r,a)=>Math.min(r,a[s]-a.radius),Number.POSITIVE_INFINITY);return{max:e,min:i}},"minMax");return{xRange:n("x"),yRange:n("y")}}d(St,"getBoundingBox");function $t(t,n,s){n==null&&(n=Math.PI/2);let e=ne(t).map(u=>Object.assign({},u)),i=Le(e);for(let u of i){Ne(u,n,s);let o=St(u);u.size=(o.xRange.max-o.xRange.min)*(o.yRange.max-o.yRange.min),u.bounds=o}i.sort((u,o)=>o.size-u.size),e=i[0];let r=e.bounds,a=(r.xRange.max-r.xRange.min)/50;function c(u,o,p){if(!u)return;let g=u.bounds,v,y;if(o)v=r.xRange.max-g.xRange.min+a;else{v=r.xRange.max-g.xRange.max;let S=(g.xRange.max-g.xRange.min)/2-(r.xRange.max-r.xRange.min)/2;S<0&&(v+=S)}if(p)y=r.yRange.max-g.yRange.min+a;else{y=r.yRange.max-g.yRange.max;let S=(g.yRange.max-g.yRange.min)/2-(r.yRange.max-r.yRange.min)/2;S<0&&(y+=S)}for(let S of u)S.x+=v,S.y+=y,e.push(S)}d(c,"addCluster");let h=1;for(;h<i.length;)c(i[h],!0,!1),c(i[h+1],!1,!0),c(i[h+2],!0,!0),h+=3,r=St(e);return ee(e)}d($t,"normalizeSolution");function te(t,n,s,e,i){let r=ne(t);n-=2*e,s-=2*e;let{xRange:a,yRange:c}=St(r);if(a.max===a.min||c.max===c.min)return console.log("not scaling solution: zero size detected"),t;let h,u;if(i){let v=Math.sqrt(i/Math.PI)*2;h=n/v,u=s/v}else h=n/(a.max-a.min),u=s/(c.max-c.min);let o=Math.min(u,h),p=(n-(a.max-a.min)*o)/2,g=(s-(c.max-c.min)*o)/2;return ee(r.map(v=>({radius:o*v.radius,x:e+p+(v.x-a.min)*o,y:e+g+(v.y-c.min)*o,setid:v.setid})))}d(te,"scaleSolution");function ee(t){let n={};for(let s of t)n[s.setid]=s;return n}d(ee,"toObjectNotation");function ne(t){return Object.keys(t).map(s=>Object.assign(t[s],{setid:s}))}d(ne,"fromObjectNotation");function se(t={}){let n=!1,s=600,e=350,i=15,r=1e3,a=Math.PI/2,c=!0,h=null,u=!0,o=!0,p=null,g=null,v=!1,y=null,S=t&&t.symmetricalTextCentre?t.symmetricalTextCentre:!1,E={},w=t&&t.colourScheme?t.colourScheme:t&&t.colorScheme?t.colorScheme:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],D=0,x=d(function(m){if(m in E)return E[m];var f=E[m]=w[D];return D+=1,D>=w.length&&(D=0),f},"colours"),b=Zt,k=tt;function l(m){let f=m.datum(),V=new Set;f.forEach(M=>{M.size==0&&M.sets.length==1&&V.add(M.sets[0])}),f=f.filter(M=>!M.sets.some(B=>V.has(B)));let I={},C={};if(f.length>0){let M=b(f,{lossFunction:k,distinct:v});c&&(M=$t(M,a,g)),I=te(M,s,e,i,h),C=re(I,f,S)}let G={};f.forEach(M=>{M.label&&(G[M.sets]=M.label)});function F(M){if(M.sets in G)return G[M.sets];if(M.sets.length==1)return""+M.sets[0]}d(F,"label"),m.selectAll("svg").data([I]).enter().append("svg");let T=m.select("svg");n?T.attr("viewBox",`0 0 ${s} ${e}`):T.attr("width",s).attr("height",e);let R={},z=!1;T.selectAll(".venn-area path").each(function(M){let B=this.getAttribute("d");M.sets.length==1&&B&&!v&&(z=!0,R[M.sets[0]]=Pe(B))});function _(M){return B=>{let et=M.sets.map(Z=>{let X=R[Z],P=I[Z];return X||(X={x:s/2,y:e/2,radius:1}),P||(P={x:s/2,y:e/2,radius:1}),{x:X.x*(1-B)+P.x*B,y:X.y*(1-B)+P.y*B,radius:X.radius*(1-B)+P.radius*B}});return Ht(et,y)}}d(_,"pathTween");let O=T.selectAll(".venn-area").data(f,M=>M.sets),N=O.enter().append("g").attr("class",M=>`venn-area venn-${M.sets.length==1?"circle":"intersection"}${M.colour||M.color?" venn-coloured":""}`).attr("data-venn-sets",M=>M.sets.join("_")),L=N.append("path"),H=N.append("text").attr("class","label").text(M=>F(M)).attr("text-anchor","middle").attr("dy",".35em").attr("x",s/2).attr("y",e/2);o&&(L.style("fill-opacity","0").filter(M=>M.sets.length==1).style("fill",M=>M.colour?M.colour:M.color?M.color:x(M.sets)).style("fill-opacity",".25"),H.style("fill",M=>M.colour||M.color?"#FFF":t.textFill?t.textFill:M.sets.length==1?x(M.sets):"#444"));function Y(M){return typeof M.transition=="function"?M.transition("venn").duration(r):M}d(Y,"asTransition");let j=m;z&&typeof j.transition=="function"?(j=Y(m),j.selectAll("path").attrTween("d",_)):j.selectAll("path").attr("d",M=>Ht(M.sets.map(B=>I[B])),y);let A=j.selectAll("text").filter(M=>M.sets in C).text(M=>F(M)).attr("x",M=>Math.floor(C[M.sets].x)).attr("y",M=>Math.floor(C[M.sets].y));u&&(z?"on"in A?A.on("end",pt(I,F)):A.each("end",pt(I,F)):A.each(pt(I,F)));let K=Y(O.exit()).remove();typeof O.transition=="function"&&K.selectAll("path").attrTween("d",_);let U=K.selectAll("text").attr("x",s/2).attr("y",e/2);return p!==null&&(H.style("font-size","0px"),A.style("font-size",p),U.style("font-size","0px")),{circles:I,textCentres:C,nodes:O,enter:N,update:j,exit:K}}return d(l,"chart"),l.wrap=function(m){return arguments.length?(u=m,l):u},l.useViewBox=function(){return n=!0,l},l.width=function(m){return arguments.length?(s=m,l):s},l.height=function(m){return arguments.length?(e=m,l):e},l.padding=function(m){return arguments.length?(i=m,l):i},l.distinct=function(m){return arguments.length?(v=m,l):v},l.colours=function(m){return arguments.length?(x=m,l):x},l.colors=function(m){return arguments.length?(x=m,l):x},l.fontSize=function(m){return arguments.length?(p=m,l):p},l.round=function(m){return arguments.length?(y=m,l):y},l.duration=function(m){return arguments.length?(r=m,l):r},l.layoutFunction=function(m){return arguments.length?(b=m,l):b},l.normalize=function(m){return arguments.length?(c=m,l):c},l.scaleToFit=function(m){return arguments.length?(h=m,l):h},l.styled=function(m){return arguments.length?(o=m,l):o},l.orientation=function(m){return arguments.length?(a=m,l):a},l.orientationOrder=function(m){return arguments.length?(g=m,l):g},l.lossFunction=function(m){return arguments.length?(k=m==="default"?tt:m==="logRatio"?Qt:m,l):k},l}d(se,"VennDiagram");function pt(t,n){return function(s){let e=this,i=t[s.sets[0]].radius||50,r=n(s)||"",a=r.split(/\s+/).reverse(),h=(r.length+a.length)/3,u=a.pop(),o=[u],p=0,g=1.1;e.textContent=null;let v=[];function y(x){let b=e.ownerDocument.createElementNS(e.namespaceURI,"tspan");return b.textContent=x,v.push(b),e.append(b),b}d(y,"append");let S=y(u);for(;u=a.pop(),!!u;){o.push(u);let x=o.join(" ");S.textContent=x,x.length>h&&S.getComputedTextLength()>i&&(o.pop(),S.textContent=o.join(" "),o=[u],S=y(u),p++)}let E=.35-p*g/2,w=e.getAttribute("x"),D=e.getAttribute("y");v.forEach((x,b)=>{x.setAttribute("x",w),x.setAttribute("y",D),x.setAttribute("dy",`${E+b*g}em`)})}}d(pt,"wrapText");function mt(t,n,s){let e=n[0].radius-q(n[0],t);for(let i=1;i<n.length;++i){let r=n[i].radius-q(n[i],t);r<=e&&(e=r)}for(let i=0;i<s.length;++i){let r=q(s[i],t)-s[i].radius;r<=e&&(e=r)}return e}d(mt,"circleMargin");function ie(t,n,s){let e=[];for(let o of t)e.push({x:o.x,y:o.y}),e.push({x:o.x+o.radius/2,y:o.y}),e.push({x:o.x-o.radius/2,y:o.y}),e.push({x:o.x,y:o.y+o.radius/2}),e.push({x:o.x,y:o.y-o.radius/2});let i=e[0],r=mt(e[0],t,n);for(let o=1;o<e.length;++o){let p=mt(e[o],t,n);p>=r&&(i=e[o],r=p)}let a=Xt(o=>-1*mt({x:o[0],y:o[1]},t,n),[i.x,i.y],{maxIterations:500,minErrorDelta:1e-10}).x,c={x:s?0:a[0],y:a[1]},h=!0;for(let o of t)if(q(c,o)>o.radius){h=!1;break}for(let o of n)if(q(c,o)<o.radius){h=!1;break}if(h)return c;if(t.length==1)return{x:t[0].x,y:t[0].y};let u={};return at(t,u),u.arcs.length===0?{x:0,y:-1e3,disjoint:!0}:u.arcs.length==1?{x:u.arcs[0].circle.x,y:u.arcs[0].circle.y}:n.length?ie(t,[]):Yt(u.arcs.map(o=>o.p1))}d(ie,"computeTextCentre");function Fe(t){let n={},s=Object.keys(t);for(let e of s)n[e]=[];for(let e=0;e<s.length;e++){let i=s[e],r=t[i];for(let a=e+1;a<s.length;++a){let c=s[a],h=t[c],u=q(r,h);u+h.radius<=r.radius+1e-10?n[c].push(i):u+r.radius<=h.radius+1e-10&&n[i].push(c)}}return n}d(Fe,"getOverlappingCircles");function re(t,n,s){let e={},i=Fe(t);for(let r=0;r<n.length;++r){let a=n[r].sets,c={},h={};for(let g=0;g<a.length;++g){c[a[g]]=!0;let v=i[a[g]];for(let y=0;y<v.length;++y)h[v[y]]=!0}let u=[],o=[];for(let g in t)g in c?u.push(t[g]):g in h||o.push(t[g]);let p=ie(u,o,s);e[a]=p,p.disjoint&&n[r].size>0&&console.log("WARNING: area "+a+" not represented on screen")}return e}d(re,"computeTextCentres");function je(t,n,s){let e=[];return e.push(`
M`,t,n),e.push(`
m`,-s,0),e.push(`
a`,s,s,0,1,0,s*2,0),e.push(`
a`,s,s,0,1,0,-s*2,0),e.join(" ")}d(je,"circlePath");function Pe(t){let n=t.split(" ");return{x:Number.parseFloat(n[1]),y:Number.parseFloat(n[2]),radius:-Number.parseFloat(n[4])}}d(Pe,"circleFromPath");function oe(t){if(t.length===0)return[];let n={};return at(t,n),n.arcs}d(oe,"intersectionAreaArcs");function ae(t,n){if(t.length===0)return"M 0 0";let s=Math.pow(10,n||0),e=n!=null?r=>Math.round(r*s)/s:r=>r;if(t.length==1){let r=t[0].circle;return je(e(r.x),e(r.y),e(r.radius))}let i=[`
M`,e(t[0].p2.x),e(t[0].p2.y)];for(let r of t){let a=e(r.circle.radius);i.push(`
A`,a,a,0,r.large?1:0,r.sweep?1:0,e(r.p1.x),e(r.p1.y))}return i.join(" ")}d(ae,"arcsToPath");function Ht(t,n){return ae(oe(t),n)}d(Ht,"intersectionAreaPath");function le(t,n={}){let{lossFunction:s,layoutFunction:e=Zt,normalize:i=!0,orientation:r=Math.PI/2,orientationOrder:a,width:c=600,height:h=350,padding:u=15,scaleToFit:o=!1,symmetricalTextCentre:p=!1,distinct:g,round:v=2}=n,y=e(t,{lossFunction:s==="default"||!s?tt:s==="logRatio"?Qt:s,distinct:g});i&&(y=$t(y,r,a));let S=te(y,c,h,u,o),E=re(S,t,p),w=new Map(Object.keys(S).map(b=>[b,{set:b,x:S[b].x,y:S[b].y,radius:S[b].radius}])),D=t.map(b=>{let k=b.sets.map(f=>w.get(f)),l=oe(k),m=ae(l,v);return{circles:k,arcs:l,path:m,area:b,has:new Set(b.sets)}});function x(b){let k="";for(let l of D)l.has.size>b.length&&b.every(m=>l.has.has(m))&&(k+=" "+l.path);return k}return d(x,"genDistinctPath"),D.map(({circles:b,arcs:k,path:l,area:m})=>({data:m,text:E[m.sets],circles:b,arcs:k,path:l,distinctPath:l+x(m.sets)}))}d(le,"layout");function qe(t){let n=new Map;for(let s of t){let e=s.targets.join("|"),i=n.get(e);i?Object.assign(i,s.styles):n.set(e,{...s.styles})}return n}d(qe,"buildStyleByKey");var Ge=d((t,n,s,e)=>{let i=e.db,r=i.getConfig?.(),{themeVariables:a,look:c,handDrawnSeed:h}=it(),u=c==="handDrawn",o=[a.venn1,a.venn2,a.venn3,a.venn4,a.venn5,a.venn6,a.venn7,a.venn8].filter(Boolean),p=i.getDiagramTitle?.(),g=i.getSubsetData(),v=i.getTextData(),y=qe(i.getStyleData()),S=r?.width??800,E=r?.height??450,D=S/1600,x=p?48*D:0,b=a.primaryTextColor??a.textColor,k=Bt(n);k.attr("viewBox",`0 0 ${S} ${E}`),p&&k.append("text").text(p).attr("class","venn-title").attr("font-size",`${32*D}px`).attr("text-anchor","middle").attr("dominant-baseline","middle").attr("x","50%").attr("y",32*D).style("fill",a.vennTitleTextColor||a.titleColor);let l=rt(document.createElement("div")),m=se().width(S).height(E-x);l.datum(g).call(m);let f=u?Pt.svg(l.select("svg").node()):void 0,V=le(g,{width:S,height:E-x,padding:r?.padding??15}),I=new Map;for(let T of V){let R=Q([...T.data.sets].sort());I.set(R,T)}v.length>0&&Ue(r,I,l,v,D,y);let C=Tt(a.background||"#f4f4f4");l.selectAll(".venn-circle").each(function(T,R){let z=rt(this),O=Q([...T.sets].sort()),N=y.get(O),L=N?.fill||o[R%o.length]||a.primaryColor;z.classed(`venn-set-${R%8}`,!0);let H=N?.["fill-opacity"]??.1,Y=N?.stroke||L,j=N?.["stroke-width"]||`${5*D}`;if(u&&f){let K=I.get(O);if(K&&K.circles.length>0){let U=K.circles[0],M=f.circle(U.x,U.y,U.radius*2,{roughness:.7,seed:h,fill:ct(L,.7),fillStyle:"hachure",fillWeight:2,hachureGap:8,hachureAngle:-41+R*60,stroke:Y,strokeWidth:parseFloat(String(j))});z.select("path").remove(),z.node()?.insertBefore(M,z.select("text").node())}}else z.select("path").style("fill",L).style("fill-opacity",H).style("stroke",Y).style("stroke-width",j).style("stroke-opacity",.95);let A=N?.color||(C?Et(L,30):_t(L,30));z.select("text").style("font-size",`${48*D}px`).style("fill",A)}),u&&f?l.selectAll(".venn-intersection").each(function(T){let R=rt(this),_=Q([...T.sets].sort()),O=y.get(_),N=O?.fill;if(N){let L=R.select("path"),H=L.attr("d");if(H){let Y=f.path(H,{roughness:.7,seed:h,fill:ct(N,.3),fillStyle:"cross-hatch",fillWeight:2,hachureGap:6,hachureAngle:60,stroke:"none"}),j=L.node();j?.parentNode?.insertBefore(Y,j),L.remove()}}else R.select("path").style("fill-opacity",0);R.select("text").style("font-size",`${48*D}px`).style("fill",O?.color??a.vennSetTextColor??b)}):(l.selectAll(".venn-intersection text").style("font-size",`${48*D}px`).style("fill",T=>{let z=Q([...T.sets].sort());return y.get(z)?.color??a.vennSetTextColor??b}),l.selectAll(".venn-intersection path").style("fill-opacity",T=>{let z=Q([...T.sets].sort());return y.get(z)?.fill?1:0}).style("fill",T=>{let z=Q([...T.sets].sort());return y.get(z)?.fill??"transparent"}));let G=k.append("g").attr("transform",`translate(0, ${x})`),F=l.select("svg").node();if(F&&"childNodes"in F)for(let T of[...F.childNodes])G.node()?.appendChild(T);Rt(k,E,S,r?.useMaxWidth??!0)},"draw");function Q(t){return t.join("|")}d(Q,"stableSetsKey");function Ue(t,n,s,e,i,r){let a=t?.useDebugLayout??!1,h=s.select("svg").append("g").attr("class","venn-text-nodes"),u=new Map;for(let o of e){let p=Q(o.sets),g=u.get(p);g?g.push(o):u.set(p,[o])}for(let[o,p]of u.entries()){let g=n.get(o);if(!g?.text)continue;let v=g.text.x,y=g.text.y,S=Math.min(...g.circles.map(T=>T.radius)),E=Math.min(...g.circles.map(T=>T.radius-Math.hypot(v-T.x,y-T.y))),w=Number.isFinite(E)?Math.max(0,E):0;w===0&&Number.isFinite(S)&&(w=S*.6);let D=h.append("g").attr("class","venn-text-area").attr("font-size",`${40*i}px`);a&&D.append("circle").attr("class","venn-text-debug-circle").attr("cx",v).attr("cy",y).attr("r",w).attr("fill","none").attr("stroke","purple").attr("stroke-width",1.5*i).attr("stroke-dasharray",`${6*i} ${4*i}`);let x=Math.max(80*i,w*2*.95),b=Math.max(60*i,w*2*.95),m=(g.data.label&&g.data.label.length>0?Math.min(32*i,w*.25):0)+(p.length<=2?30*i:0),f=v-x/2,V=y-b/2+m,I=Math.max(1,Math.ceil(Math.sqrt(p.length))),C=Math.max(1,Math.ceil(p.length/I)),G=x/I,F=b/C;for(let[T,R]of p.entries()){let z=T%I,_=Math.floor(T/I),O=f+G*(z+.5),N=V+F*(_+.5);a&&D.append("rect").attr("class","venn-text-debug-cell").attr("x",f+G*z).attr("y",V+F*_).attr("width",G).attr("height",F).attr("fill","none").attr("stroke","teal").attr("stroke-width",1*i).attr("stroke-dasharray",`${4*i} ${3*i}`);let L=G*.9,H=F*.9,Y=D.append("foreignObject").attr("class","venn-text-node-fo").attr("width",L).attr("height",H).attr("x",O-L/2).attr("y",N-H/2).attr("overflow","visible"),j=r.get(R.id)?.color,A=Y.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(R.label??R.id);j&&A.style("color",j)}}}d(Ue,"renderTextNodes");var ce={draw:Ge};var xn={parser:qt,db:Gt,renderer:ce,styles:Ut};export{xn as diagram};