From 5b5df75eaf043ad8b9b5b87f7dedf541a002cf9b Mon Sep 17 00:00:00 2001 From: Rico Sonntag Date: Mon, 13 Dec 2021 16:08:24 +0100 Subject: [PATCH] Fixes #18: NAME without "//" is misalinged and breaks the layout --- resources/js/descendants-chart.min.js | 2 +- resources/js/modules/tree.js | 17 +++++++++++++++++ src/Traits/IndividualTrait.php | 15 ++++++++------- src/Traits/ModuleCustomTrait.php | 5 ----- 4 files changed, 26 insertions(+), 13 deletions(-) diff --git a/resources/js/descendants-chart.min.js b/resources/js/descendants-chart.min.js index 7b0134d..6ddaf6b 100644 --- a/resources/js/descendants-chart.min.js +++ b/resources/js/descendants-chart.min.js @@ -1 +1 @@ -var t,e;t=this,e=function(t){var e="http://www.w3.org/1999/xhtml",n={svg:"http://www.w3.org/2000/svg",xhtml:e,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function r(t){var e=t+="",r=e.indexOf(":");return r>=0&&"xmlns"!==(e=t.slice(0,r))&&(t=t.slice(r+1)),n.hasOwnProperty(e)?{space:n[e],local:t}:t}function i(t){return function(){var n=this.ownerDocument,r=this.namespaceURI;return r===e&&n.documentElement.namespaceURI===e?n.createElement(t):n.createElementNS(r,t)}}function o(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function a(t){var e=r(t);return(e.local?o:i)(e)}function s(){}function u(t){return null==t?s:function(){return this.querySelector(t)}}function h(t){return null==t?[]:Array.isArray(t)?t:Array.from(t)}function l(){return[]}function c(t){return null==t?l:function(){return this.querySelectorAll(t)}}function f(t){return function(){return this.matches(t)}}function d(t){return function(e){return e.matches(t)}}var p=Array.prototype.find;function g(){return this.firstElementChild}var m=Array.prototype.filter;function _(){return Array.from(this.children)}function v(t){return new Array(t.length)}function y(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}function w(t){return function(){return t}}function x(t,e,n,r,i,o){for(var a,s=0,u=e.length,h=o.length;se?1:t>=e?0:NaN}function M(t){return function(){this.removeAttribute(t)}}function A(t){return function(){this.removeAttributeNS(t.space,t.local)}}function E(t,e){return function(){this.setAttribute(t,e)}}function S(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function P(t,e){return function(){var n=e.apply(this,arguments);null==n?this.removeAttribute(t):this.setAttribute(t,n)}}function R(t,e){return function(){var n=e.apply(this,arguments);null==n?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,n)}}function T(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function C(t){return function(){this.style.removeProperty(t)}}function X(t,e,n){return function(){this.style.setProperty(t,e,n)}}function Y(t,e,n){return function(){var r=e.apply(this,arguments);null==r?this.style.removeProperty(t):this.style.setProperty(t,r,n)}}function W(t,e){return t.style.getPropertyValue(e)||T(t).getComputedStyle(t,null).getPropertyValue(e)}function L(t){return function(){delete this[t]}}function H(t,e){return function(){this[t]=e}}function B(t,e){return function(){var n=e.apply(this,arguments);null==n?delete this[t]:this[t]=n}}function I(t){return t.trim().split(/^|\s+/)}function D(t){return t.classList||new O(t)}function O(t){this._node=t,this._names=I(t.getAttribute("class")||"")}function V(t,e){for(var n=D(t),r=-1,i=e.length;++r=0&&(e=t.slice(n+1),t=t.slice(0,n)),{type:t,name:e}}))}function st(t){return function(){var e=this.__on;if(e){for(var n,r=0,i=-1,o=e.length;r=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};var ft=[null];function dt(t,e){this._groups=t,this._parents=e}function pt(){return new dt([[document.documentElement]],ft)}function gt(t){return"string"==typeof t?new dt([[document.querySelector(t)]],[document.documentElement]):new dt([[t]],ft)}function mt(t,e){if(t=function(t){let e;for(;e=t.sourceEvent;)t=e;return t}(t),void 0===e&&(e=t.currentTarget),e){var n=e.ownerSVGElement||e;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=t.clientX,r.y=t.clientY,[(r=r.matrixTransform(e.getScreenCTM().inverse())).x,r.y]}if(e.getBoundingClientRect){var i=e.getBoundingClientRect();return[t.clientX-i.left-e.clientLeft,t.clientY-i.top-e.clientTop]}}return[t.pageX,t.pageY]}dt.prototype=pt.prototype={constructor:dt,select:function(t){"function"!=typeof t&&(t=u(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i=M&&(M=z+1);!(y=m[M])&&++M=0;)(r=i[o])&&(a&&4^r.compareDocumentPosition(a)&&a.parentNode.insertBefore(r,a),a=r);return this},sort:function(t){function e(e,n){return e&&n?t(e.__data__,n.__data__):!e-!n}t||(t=z);for(var n=this._groups,r=n.length,i=new Array(r),o=0;o1?this.each((null==e?C:"function"==typeof e?Y:X)(t,e,null==n?"":n)):W(this.node(),t)},property:function(t,e){return arguments.length>1?this.each((null==e?L:"function"==typeof e?B:H)(t,e)):this.node()[t]},classed:function(t,e){var n=I(t+"");if(arguments.length<2){for(var r=D(this.node()),i=-1,o=n.length;++i{}};function vt(){for(var t,e=0,n=arguments.length,r={};e=0&&(n=t.slice(r+1),t=t.slice(0,r)),t&&!e.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:n}}))}function xt(t,e){for(var n,r=0,i=t.length;r0)for(var n,r,i=new Array(n),o=0;o=0&&e._call.call(void 0,t),e=e._next;--zt}()}finally{zt=0,function(){for(var t,e,n=kt,r=1/0;n;)n._call?(r>n._time&&(r=n._time),t=n,n=n._next):(e=n._next,n._next=null,n=t?t._next=e:kt=e);Nt=t,Bt(r)}(),St=0}}function Ht(){var t=Rt.now(),e=t-Et;e>1e3&&(Pt-=e,Et=t)}function Bt(t){zt||(Mt&&(Mt=clearTimeout(Mt)),t-St>24?(t<1/0&&(Mt=setTimeout(Lt,t-Rt.now()-Pt)),At&&(At=clearInterval(At))):(At||(Et=Rt.now(),At=setInterval(Ht,1e3)),zt=1,Tt(Lt)))}function It(t,e,n){var r=new Yt;return e=null==e?0:+e,r.restart((n=>{r.stop(),t(n+e)}),e,n),r}Yt.prototype=Wt.prototype={constructor:Yt,restart:function(t,e,n){if("function"!=typeof t)throw new TypeError("callback is not a function");n=(null==n?Ct():+n)+(null==e?0:+e),this._next||Nt===this||(Nt?Nt._next=this:kt=this,Nt=this),this._call=t,this._time=n,Bt()},stop:function(){this._call&&(this._call=null,this._time=1/0,Bt())}};var Dt=vt("start","end","cancel","interrupt"),Ot=[];function Vt(t,e,n,r,i,o){var a=t.__transition;if(a){if(n in a)return}else t.__transition={};!function(t,e,n){var r,i=t.__transition;function o(t){n.state=1,n.timer.restart(a,n.delay,n.time),n.delay<=t&&a(t-n.delay)}function a(o){var h,l,c,f;if(1!==n.state)return u();for(h in i)if((f=i[h]).name===n.name){if(3===f.state)return It(a);4===f.state?(f.state=6,f.timer.stop(),f.on.call("interrupt",t,t.__data__,f.index,f.group),delete i[h]):+h0)throw new Error("too late; already scheduled");return n}function Ut(t,e){var n=jt(t,e);if(n.state>3)throw new Error("too late; already running");return n}function jt(t,e){var n=t.__transition;if(!n||!(n=n[e]))throw new Error("transition not found");return n}function Gt(t,e){var n,r,i,o=t.__transition,a=!0;if(o){for(i in e=null==e?null:e+"",o)(n=o[i]).name===e?(r=n.state>2&&n.state<5,n.state=6,n.timer.stop(),n.on.call(r?"interrupt":"cancel",t,t.__data__,n.index,n.group),delete o[i]):a=!1;a&&delete t.__transition}}function Ft(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function $t(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function Kt(){}var Qt=.7,Jt=1/Qt,Zt="\\s*([+-]?\\d+)\\s*",te="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)\\s*",ee="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)%\\s*",ne=/^#([0-9a-f]{3,8})$/,re=new RegExp("^rgb\\("+[Zt,Zt,Zt]+"\\)$"),ie=new RegExp("^rgb\\("+[ee,ee,ee]+"\\)$"),oe=new RegExp("^rgba\\("+[Zt,Zt,Zt,te]+"\\)$"),ae=new RegExp("^rgba\\("+[ee,ee,ee,te]+"\\)$"),se=new RegExp("^hsl\\("+[te,ee,ee]+"\\)$"),ue=new RegExp("^hsla\\("+[te,ee,ee,te]+"\\)$"),he={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};function le(){return this.rgb().formatHex()}function ce(){return this.rgb().formatRgb()}function fe(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=ne.exec(t))?(n=e[1].length,e=parseInt(e[1],16),6===n?de(e):3===n?new _e(e>>8&15|e>>4&240,e>>4&15|240&e,(15&e)<<4|15&e,1):8===n?pe(e>>24&255,e>>16&255,e>>8&255,(255&e)/255):4===n?pe(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|240&e,((15&e)<<4|15&e)/255):null):(e=re.exec(t))?new _e(e[1],e[2],e[3],1):(e=ie.exec(t))?new _e(255*e[1]/100,255*e[2]/100,255*e[3]/100,1):(e=oe.exec(t))?pe(e[1],e[2],e[3],e[4]):(e=ae.exec(t))?pe(255*e[1]/100,255*e[2]/100,255*e[3]/100,e[4]):(e=se.exec(t))?xe(e[1],e[2]/100,e[3]/100,1):(e=ue.exec(t))?xe(e[1],e[2]/100,e[3]/100,e[4]):he.hasOwnProperty(t)?de(he[t]):"transparent"===t?new _e(NaN,NaN,NaN,0):null}function de(t){return new _e(t>>16&255,t>>8&255,255&t,1)}function pe(t,e,n,r){return r<=0&&(t=e=n=NaN),new _e(t,e,n,r)}function ge(t){return t instanceof Kt||(t=fe(t)),t?new _e((t=t.rgb()).r,t.g,t.b,t.opacity):new _e}function me(t,e,n,r){return 1===arguments.length?ge(t):new _e(t,e,n,null==r?1:r)}function _e(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}function ve(){return"#"+we(this.r)+we(this.g)+we(this.b)}function ye(){var t=this.opacity;return(1===(t=isNaN(t)?1:Math.max(0,Math.min(1,t)))?"rgb(":"rgba(")+Math.max(0,Math.min(255,Math.round(this.r)||0))+", "+Math.max(0,Math.min(255,Math.round(this.g)||0))+", "+Math.max(0,Math.min(255,Math.round(this.b)||0))+(1===t?")":", "+t+")")}function we(t){return((t=Math.max(0,Math.min(255,Math.round(t)||0)))<16?"0":"")+t.toString(16)}function xe(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new ke(t,e,n,r)}function be(t){if(t instanceof ke)return new ke(t.h,t.s,t.l,t.opacity);if(t instanceof Kt||(t=fe(t)),!t)return new ke;if(t instanceof ke)return t;var e=(t=t.rgb()).r/255,n=t.g/255,r=t.b/255,i=Math.min(e,n,r),o=Math.max(e,n,r),a=NaN,s=o-i,u=(o+i)/2;return s?(a=e===o?(n-r)/s+6*(n0&&u<1?0:a,new ke(a,s,u,t.opacity)}function ke(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}function Ne(t,e,n){return 255*(t<60?e+(n-e)*t/60:t<180?n:t<240?e+(n-e)*(240-t)/60:e)}Ft(Kt,fe,{copy:function(t){return Object.assign(new this.constructor,this,t)},displayable:function(){return this.rgb().displayable()},hex:le,formatHex:le,formatHsl:function(){return be(this).formatHsl()},formatRgb:ce,toString:ce}),Ft(_e,me,$t(Kt,{brighter:function(t){return t=null==t?Jt:Math.pow(Jt,t),new _e(this.r*t,this.g*t,this.b*t,this.opacity)},darker:function(t){return t=null==t?Qt:Math.pow(Qt,t),new _e(this.r*t,this.g*t,this.b*t,this.opacity)},rgb:function(){return this},displayable:function(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:ve,formatHex:ve,formatRgb:ye,toString:ye})),Ft(ke,(function(t,e,n,r){return 1===arguments.length?be(t):new ke(t,e,n,null==r?1:r)}),$t(Kt,{brighter:function(t){return t=null==t?Jt:Math.pow(Jt,t),new ke(this.h,this.s,this.l*t,this.opacity)},darker:function(t){return t=null==t?Qt:Math.pow(Qt,t),new ke(this.h,this.s,this.l*t,this.opacity)},rgb:function(){var t=this.h%360+360*(this.h<0),e=isNaN(t)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*e,i=2*n-r;return new _e(Ne(t>=240?t-240:t+120,i,r),Ne(t,i,r),Ne(t<120?t+240:t-120,i,r),this.opacity)},displayable:function(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl:function(){var t=this.opacity;return(1===(t=isNaN(t)?1:Math.max(0,Math.min(1,t)))?"hsl(":"hsla(")+(this.h||0)+", "+100*(this.s||0)+"%, "+100*(this.l||0)+"%"+(1===t?")":", "+t+")")}}));var ze=t=>()=>t;function Me(t){return 1==(t=+t)?Ae:function(e,n){return n-e?function(t,e,n){return t=Math.pow(t,n),e=Math.pow(e,n)-t,n=1/n,function(r){return Math.pow(t+r*e,n)}}(e,n,t):ze(isNaN(e)?n:e)}}function Ae(t,e){var n=e-t;return n?function(t,e){return function(n){return t+n*e}}(t,n):ze(isNaN(t)?e:t)}var Ee=function t(e){var n=Me(e);function r(t,e){var r=n((t=me(t)).r,(e=me(e)).r),i=n(t.g,e.g),o=n(t.b,e.b),a=Ae(t.opacity,e.opacity);return function(e){return t.r=r(e),t.g=i(e),t.b=o(e),t.opacity=a(e),t+""}}return r.gamma=t,r}(1);function Se(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}var Pe=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Re=new RegExp(Pe.source,"g");function Te(t,e){var n,r,i,o=Pe.lastIndex=Re.lastIndex=0,a=-1,s=[],u=[];for(t+="",e+="";(n=Pe.exec(t))&&(r=Re.exec(e));)(i=r.index)>o&&(i=e.slice(o,i),s[a]?s[a]+=i:s[++a]=i),(n=n[0])===(r=r[0])?s[a]?s[a]+=r:s[++a]=r:(s[++a]=null,u.push({i:a,x:Se(n,r)})),o=Re.lastIndex;return o180?e+=360:e-t>180&&(t+=360),o.push({i:n.push(i(n)+"rotate(",null,r)-2,x:Se(t,e)})):e&&n.push(i(n)+"rotate("+e+r)}(o.rotate,a.rotate,s,u),function(t,e,n,o){t!==e?o.push({i:n.push(i(n)+"skewX(",null,r)-2,x:Se(t,e)}):e&&n.push(i(n)+"skewX("+e+r)}(o.skewX,a.skewX,s,u),function(t,e,n,r,o,a){if(t!==n||e!==r){var s=o.push(i(o)+"scale(",null,",",null,")");a.push({i:s-4,x:Se(t,n)},{i:s-2,x:Se(e,r)})}else 1===n&&1===r||o.push(i(o)+"scale("+n+","+r+")")}(o.scaleX,o.scaleY,a.scaleX,a.scaleY,s,u),o=a=null,function(t){for(var e,n=-1,r=u.length;++n=0&&(t=t.slice(0,e)),!t||"start"===t}))}(e)?qt:Ut;return function(){var a=o(this,t),s=a.on;s!==r&&(i=(r=s).copy()).on(e,n),a.on=i}}var hn=pt.prototype.constructor;function ln(t){return function(){this.style.removeProperty(t)}}function cn(t,e,n){return function(r){this.style.setProperty(t,e.call(this,r),n)}}function fn(t,e,n){var r,i;function o(){var o=e.apply(this,arguments);return o!==i&&(r=(i=o)&&cn(t,o,n)),r}return o._value=e,o}function dn(t){return function(e){this.textContent=t.call(this,e)}}function pn(t){var e,n;function r(){var r=t.apply(this,arguments);return r!==n&&(e=(n=r)&&dn(r)),e}return r._value=t,r}var gn=0;function mn(t,e,n,r){this._groups=t,this._parents=e,this._name=n,this._id=r}function _n(){return++gn}var vn=pt.prototype;mn.prototype={constructor:mn,select:function(t){var e=this._name,n=this._id;"function"!=typeof t&&(t=u(t));for(var r=this._groups,i=r.length,o=new Array(i),a=0;a()=>t;function Mn(t,{sourceEvent:e,target:n,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function An(t,e,n){this.k=t,this.x=e,this.y=n}An.prototype={constructor:An,scale:function(t){return 1===t?this:new An(this.k*t,this.x,this.y)},translate:function(t,e){return 0===t&0===e?this:new An(this.k,this.x+this.k*t,this.y+this.k*e)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var En=new An(1,0,0);function Sn(t){for(;!t.__zoom;)if(!(t=t.parentNode))return En;return t.__zoom}function Pn(t){t.stopImmediatePropagation()}function Rn(t){t.preventDefault(),t.stopImmediatePropagation()}function Tn(t){return!(t.ctrlKey&&"wheel"!==t.type||t.button)}function Cn(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t).hasAttribute("viewBox")?[[(t=t.viewBox.baseVal).x,t.y],[t.x+t.width,t.y+t.height]]:[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]:[[0,0],[t.clientWidth,t.clientHeight]]}function Xn(){return this.__zoom||En}function Yn(t){return-t.deltaY*(1===t.deltaMode?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function Wn(){return navigator.maxTouchPoints||"ontouchstart"in this}function Ln(t,e,n){var r=t.invertX(e[0][0])-n[0][0],i=t.invertX(e[1][0])-n[1][0],o=t.invertY(e[0][1])-n[0][1],a=t.invertY(e[1][1])-n[1][1];return t.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),a>o?(o+a)/2:Math.min(0,o)||Math.max(0,a))}function Hn(t){var e=0,n=t.children,r=n&&n.length;if(r)for(;--r>=0;)e+=n[r].value;else e=1;t.value=e}function Bn(t,e){t instanceof Map?(t=[void 0,t],void 0===e&&(e=Dn)):void 0===e&&(e=In);for(var n,r,i,o,a,s=new qn(t),u=[s];n=u.pop();)if((i=e(n.data))&&(a=(i=Array.from(i)).length))for(n.children=i,o=a-1;o>=0;--o)u.push(r=i[o]=new qn(i[o])),r.parent=n,r.depth=n.depth+1;return s.eachBefore(Vn)}function In(t){return t.children}function Dn(t){return Array.isArray(t)?t[1]:null}function On(t){void 0!==t.data.value&&(t.value=t.data.value),t.data=t.data.data}function Vn(t){var e=0;do{t.height=e}while((t=t.parent)&&t.height<++e)}function qn(t){this.data=t,this.depth=this.height=0,this.parent=null}function Un(t,e){return t.parent===e.parent?1:2}function jn(t){var e=t.children;return e?e[0]:t.t}function Gn(t){var e=t.children;return e?e[e.length-1]:t.t}function Fn(t,e,n){var r=n/(e.i-t.i);e.c-=r,e.s+=n,t.c+=r,e.z+=n,e.m+=n}function $n(t,e,n){return t.a.parent===e.parent?t.a:n}function Kn(t,e){this._=t,this.parent=null,this.children=null,this.A=null,this.a=this,this.z=0,this.m=0,this.c=0,this.s=0,this.t=null,this.i=e}function Qn(){var t=Un,e=1,n=1,r=null;function i(i){var u=function(t){for(var e,n,r,i,o,a=new Kn(t,0),s=[a];e=s.pop();)if(r=e._.children)for(e.children=new Array(o=r.length),i=o-1;i>=0;--i)s.push(n=e.children[i]=new Kn(r[i],i)),n.parent=e;return(a.parent=new Kn(null,0)).children=[a],a}(i);if(u.eachAfter(o),u.parent.m=-u.z,u.eachBefore(a),r)i.eachBefore(s);else{var h=i,l=i,c=i;i.eachBefore((function(t){t.xl.x&&(l=t),t.depth>c.depth&&(c=t)}));var f=h===l?1:t(h,l)/2,d=f-h.x,p=e/(l.x+f+d),g=n/(c.depth||1);i.eachBefore((function(t){t.x=(t.x+d)*p,t.y=t.depth*g}))}return i}function o(e){var n=e.children,r=e.parent.children,i=e.i?r[e.i-1]:null;if(n){!function(t){for(var e,n=0,r=0,i=t.children,o=i.length;--o>=0;)(e=i[o]).z+=n,e.m+=n,n+=e.s+(r+=e.c)}(e);var o=(n[0].z+n[n.length-1].z)/2;i?(e.z=i.z+t(e._,i._),e.m=e.z-o):e.z=o}else i&&(e.z=i.z+t(e._,i._));e.parent.A=function(e,n,r){if(n){for(var i,o=e,a=e,s=n,u=o.parent.children[0],h=o.m,l=a.m,c=s.m,f=u.m;s=Gn(s),o=jn(o),s&&o;)u=jn(u),(a=Gn(a)).a=e,(i=s.z+c-o.z-h+t(s._,o._))>0&&(Fn($n(s,e,r),e,i),h+=i,l+=i),c+=s.m,h+=o.m,f+=u.m,l+=a.m;s&&!Gn(a)&&(a.t=s,a.m+=c-l),o&&!jn(u)&&(u.t=o,u.m+=h-f,r=e)}return r}(e,i,e.parent.A||r[0])}function a(t){t._.x=t.z+t.parent.m,t.m+=t.parent.m}function s(t){t.x*=e,t.y=t.depth*n}return i.separation=function(e){return arguments.length?(t=e,i):t},i.size=function(t){return arguments.length?(r=!1,e=+t[0],n=+t[1],i):r?null:[e,n]},i.nodeSize=function(t){return arguments.length?(r=!0,e=+t[0],n=+t[1],i):r?[e,n]:null},i}function Jn(t){if(!t.ok)throw new Error(t.status+" "+t.statusText);return t.text()}Sn.prototype=An.prototype,qn.prototype=Bn.prototype={constructor:qn,count:function(){return this.eachAfter(Hn)},each:function(t,e){let n=-1;for(const r of this)t.call(e,r,++n,this);return this},eachAfter:function(t,e){for(var n,r,i,o=this,a=[o],s=[],u=-1;o=a.pop();)if(s.push(o),n=o.children)for(r=0,i=n.length;r=0;--r)o.push(n[r]);return this},find:function(t,e){let n=-1;for(const r of this)if(t.call(e,r,++n,this))return r},sum:function(t){return this.eachAfter((function(e){for(var n=+t(e.data)||0,r=e.children,i=r&&r.length;--i>=0;)n+=r[i].value;e.value=n}))},sort:function(t){return this.eachBefore((function(e){e.children&&e.children.sort(t)}))},path:function(t){for(var e=this,n=function(t,e){if(t===e)return t;var n=t.ancestors(),r=e.ancestors(),i=null;for(t=n.pop(),e=r.pop();t===e;)i=t,t=n.pop(),e=r.pop();return i}(e,t),r=[e];e!==n;)e=e.parent,r.push(e);for(var i=r.length;t!==n;)r.splice(i,0,t),t=t.parent;return r},ancestors:function(){for(var t=this,e=[t];t=t.parent;)e.push(t);return e},descendants:function(){return Array.from(this)},leaves:function(){var t=[];return this.eachBefore((function(e){e.children||t.push(e)})),t},links:function(){var t=this,e=[];return t.each((function(n){n!==t&&e.push({source:n.parent,target:n})})),e},copy:function(){return Bn(this).eachBefore(On)},[Symbol.iterator]:function*(){var t,e,n,r,i=this,o=[i];do{for(t=o.reverse(),o=[];i=t.pop();)if(yield i,e=i.children)for(n=0,r=e.length;n1+(t?Math.max(...t.map(e)):0);e(t);let n=Bn(t,(t=>t.children));const r=Qn().nodeSize([this.nodeWidth,this.nodeHeight]).separation((t=>this.separation));this._root=n,this._nodes=r(n)}get nodes(){return this._nodes}get root(){return this._root}createEmptyNode(t,e){return{id:0,xref:"",url:"",updateUrl:"",generation:t,name:"",firstNames:[],lastNames:[],preferredName:"",alternativeNames:[],isAltRtl:!1,sex:e,timespan:"",color:this._configuration.defaultColor,colors:[[],[]]}}}class lr{constructor(t,e,n){this._svg=t,this._configuration=e,this._hierarchy=n,this._hierarchy.root.x0=0,this._hierarchy.root.y0=0,this._orientation=this._configuration.orientation,this.draw(this._hierarchy.root)}draw(t){let e=this._hierarchy.nodes.descendants(),n=this._hierarchy.nodes.links();e.forEach((t=>{this._orientation.norm(t)})),this.drawLinks(n,t),this.drawNodes(e,t),e.forEach((t=>{t.x0=t.x,t.y0=t.y}))}drawNodes(t,e){let n=0,r=this;this._svg.defs.get().append("clipPath").attr("id","clip-rect").append("rect").attr("rx",r._orientation.imageCornerRadius()).attr("ry",r._orientation.imageCornerRadius()).attr("x",r._orientation.imageX()).attr("y",r._orientation.imageY()).attr("width",r._orientation.imageWidth()).attr("height",r._orientation.imageHeight()),this._svg.visual.transition().duration(this._configuration.duration);let i=this._svg.visual.selectAll("g.person").data(t,(t=>t.id||(t.id=++n))).enter().append("g").attr("class","person").attr("transform",(t=>"translate("+this._orientation.x(t)+","+this._orientation.y(t)+")"));i.append("rect").attr("class",(t=>"F"===t.data.sex?"female":"M"===t.data.sex?"male":"unknown")).attr("rx",this._orientation.cornerRadius()).attr("ry",this._orientation.cornerRadius()).attr("x",-this._orientation.boxWidth/2).attr("y",-this._orientation.boxHeight/2).attr("width",this._orientation.boxWidth).attr("height",this._orientation.boxHeight).attr("fill-opacity",.5).attr("fill",(t=>t.data.color)),i.filter((t=>""!==t.data.xref)).each((function(t){let e=gt(this);e.append("title").text((t=>t.data.name));let n=e.append("g").attr("class","image");n.append("rect").attr("rx",r._orientation.imageCornerRadius()).attr("ry",r._orientation.imageCornerRadius()).attr("x",r._orientation.imageX()).attr("y",r._orientation.imageY()).attr("width",r._orientation.imageWidth()).attr("height",r._orientation.imageHeight()).attr("fill","rgb(255, 255, 255)");let i=n.append("image").attr("x",r._orientation.imageX()).attr("y",r._orientation.imageY()).attr("width",r._orientation.imageWidth()).attr("height",r._orientation.imageHeight()).attr("clip-path","url(#clip-rect)");(function(t,e){return fetch(t,e).then((t=>t.blob())).then((t=>new Promise(((e,n)=>{const r=new FileReader;r.onloadend=()=>e(r.result),r.onerror=n,r.readAsDataURL(t)}))))})(r.getImageToLoad(t)).then((t=>i.attr("xlink:href",t))).catch((t=>{console.error(t)})),n.append("rect").attr("rx",r._orientation.imageCornerRadius()).attr("ry",r._orientation.imageCornerRadius()).attr("x",r._orientation.imageX()).attr("y",r._orientation.imageY()).attr("width",r._orientation.imageWidth()).attr("height",r._orientation.imageHeight()).attr("fill","none").attr("stroke","rgb(200, 200, 200)").attr("stroke-width",1.5),r.addNames(e,t),r.addDates(e,t)}))}togglePerson(t,e){e.children?(e._children=e.children,e.children=null):(e.children=e._children,e._children=null),this.draw(e)}collapse(t){t.children&&(t._children=t.children,t._children.forEach((t=>this.collapse(t))),t.children=null)}addFirstNames(t,e){let n=0;for(let r of e.data.firstNames){let i=t.append("tspan").text(r);r===e.data.preferredName&&i.attr("class","preferred"),0!==n&&i.attr("dx","0.25em"),++n}}addLastNames(t,e,n=0){let r=0;for(let i of e.data.lastNames){let e=t.append("tspan").attr("class","lastName").text(i);0!==r&&e.attr("dx","0.25em"),0!==n&&e.attr("dx",n+"em"),++r}}truncateNames(t,e=!1){let n=this._orientation.textWidth();this.truncateListOfNames(t.selectAll("tspan:not(.preferred):not(.lastName)"),t,n,e),t.selectAll("tspan.preferred").each(this.truncateText(t,n,e)),t.selectAll("tspan.lastName").each(this.truncateText(t,n,e))}truncateListOfNames(t,e,n,r){t.size()&&t.nodes().reverse().forEach((t=>{gt(t).each(this.truncateText(e,n,r))}))}truncateText(t,e,n=!1){let r=this;return function(){let i=r.getTextLength(t),o=gt(this),a=o.text();i>e&&(n?o.text(""):a.length>1&&o.text(a.slice(0,1)+"."))}}getTextLength(t){let e=0;return t.selectAll("tspan").each((function(){e+=this.getComputedTextLength()})),e}addNames(t,e){let n=t.append("g").attr("class","name");if(this._orientation._splittNames){let t=n.append("text").attr("text-anchor","middle").attr("alignment-baseline","central").attr("dy",this._orientation.textY()),r=n.append("text").attr("text-anchor","middle").attr("alignment-baseline","central").attr("dy",this._orientation.textY()+20);this.addFirstNames(t,e),this.addLastNames(r,e),this.truncateNames(t),this.truncateNames(r)}else{let t=n.append("text").attr("text-anchor","start").attr("dx",this._orientation.textX()).attr("dy",this._orientation.textY());this.addFirstNames(t,e),this.addLastNames(t,e,.25),this.truncateNames(t)}}addDates(t,e){let n=t.append("g").attr("class","table");if(this._orientation._splittNames)return void n.append("text").attr("class","date").attr("text-anchor","middle").attr("alignment-baseline","central").attr("dy",this._orientation.textY()+50).append("tspan").text(e.data.timespan);let r=n.append("text").attr("class","date").attr("text-anchor","middle").attr("dominant-baseline","middle").attr("x",this._orientation.textX()).attr("y",this._orientation.textY()+15);if(e.data.birth&&r.append("tspan").text("★").attr("x",this._orientation.textX()+5).attr("dy",this._orientation.textY()+20),e.data.death){let t=r.append("tspan").text("†");e.data.birth?t.attr("x",this._orientation.textX()+5).attr("dy",this._orientation.textY()+35):t.attr("x",this._orientation.textX()+5).attr("dy",this._orientation.textY()+20)}let i=n.append("text").attr("class","date").attr("text-anchor","start").attr("dominant-baseline","middle").attr("x",this._orientation.textX()).attr("y",this._orientation.textY()+20);if(e.data.birth&&i.append("tspan").text(e.data.birth).attr("x",this._orientation.textX()+15).attr("dy",this._orientation.textY()+15),e.data.death){let t=i.append("tspan").text(e.data.death);e.data.birth?t.attr("x",this._orientation.textX()+15).attr("dy",this._orientation.textY()+35):t.attr("x",this._orientation.textX()+15).attr("dy",this._orientation.textY()+15)}}getImageToLoad(t){return t.data.thumbnail?t.data.thumbnail:""}drawLinks(t,e){this._svg.visual.selectAll("path.link").data(t,(t=>t.target.id)).enter().append("path").classed("link",!0).attr("d",(t=>this._orientation.elbow(t)))}}class cr{constructor(t){this._element=t.append("div").attr("class","overlay").style("opacity",1e-6)}show(t,e=0,n=null){this._element.select("p").remove(),this._element.append("p").attr("class","tooltip").text(t),this._element.transition().duration(e).style("opacity",1).on("end",(()=>{"function"==typeof n&&n()}))}hide(t=0,e=0){this._element.transition().delay(t).duration(e).style("opacity",1e-6)}get(){return this._element}}class fr{constructor(t){this._element=t.append("defs")}get(){return this._element}}class dr{constructor(t){this._zoom=null,this._parent=t,this.init()}init(){this._zoom=function(){var t,e,n,r=Tn,i=Cn,o=Ln,a=Yn,s=Wn,u=[0,1/0],h=[[-1/0,-1/0],[1/0,1/0]],l=250,c=De,f=vt("start","zoom","end"),d=500,p=0,g=10;function m(t){t.property("__zoom",Xn).on("wheel.zoom",k,{passive:!1}).on("mousedown.zoom",N).on("dblclick.zoom",z).filter(s).on("touchstart.zoom",M).on("touchmove.zoom",A).on("touchend.zoom touchcancel.zoom",E).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function _(t,e){return(e=Math.max(u[0],Math.min(u[1],e)))===t.k?t:new An(e,t.x,t.y)}function v(t,e,n){var r=e[0]-n[0]*t.k,i=e[1]-n[1]*t.k;return r===t.x&&i===t.y?t:new An(t.k,r,i)}function y(t){return[(+t[0][0]+ +t[1][0])/2,(+t[0][1]+ +t[1][1])/2]}function w(t,e,n,r){t.on("start.zoom",(function(){x(this,arguments).event(r).start()})).on("interrupt.zoom end.zoom",(function(){x(this,arguments).event(r).end()})).tween("zoom",(function(){var t=this,o=arguments,a=x(t,o).event(r),s=i.apply(t,o),u=null==n?y(s):"function"==typeof n?n.apply(t,o):n,h=Math.max(s[1][0]-s[0][0],s[1][1]-s[0][1]),l=t.__zoom,f="function"==typeof e?e.apply(t,o):e,d=c(l.invert(u).concat(h/l.k),f.invert(u).concat(h/f.k));return function(t){if(1===t)t=f;else{var e=d(t),n=h/e[2];t=new An(n,u[0]-e[0]*n,u[1]-e[1]*n)}a.zoom(null,t)}}))}function x(t,e,n){return!n&&t.__zooming||new b(t,e)}function b(t,e){this.that=t,this.args=e,this.active=0,this.sourceEvent=null,this.extent=i.apply(t,e),this.taps=0}function k(t,...e){if(r.apply(this,arguments)){var n=x(this,e).event(t),i=this.__zoom,s=Math.max(u[0],Math.min(u[1],i.k*Math.pow(2,a.apply(this,arguments)))),l=mt(t);if(n.wheel)n.mouse[0][0]===l[0]&&n.mouse[0][1]===l[1]||(n.mouse[1]=i.invert(n.mouse[0]=l)),clearTimeout(n.wheel);else{if(i.k===s)return;n.mouse=[l,i.invert(l)],Gt(this),n.start()}Rn(t),n.wheel=setTimeout(c,150),n.zoom("mouse",o(v(_(i,s),n.mouse[0],n.mouse[1]),n.extent,h))}function c(){n.wheel=null,n.end()}}function N(t,...e){if(!n&&r.apply(this,arguments)){var i=t.currentTarget,a=x(this,e,!0).event(t),s=gt(t.view).on("mousemove.zoom",f,!0).on("mouseup.zoom",d,!0),u=mt(t,i),l=t.clientX,c=t.clientY;kn(t.view),Pn(t),a.mouse=[u,this.__zoom.invert(u)],Gt(this),a.start()}function f(t){if(Rn(t),!a.moved){var e=t.clientX-l,n=t.clientY-c;a.moved=e*e+n*n>p}a.event(t).zoom("mouse",o(v(a.that.__zoom,a.mouse[0]=mt(t,i),a.mouse[1]),a.extent,h))}function d(t){s.on("mousemove.zoom mouseup.zoom",null),Nn(t.view,a.moved),Rn(t),a.event(t).end()}}function z(t,...e){if(r.apply(this,arguments)){var n=this.__zoom,a=mt(t.changedTouches?t.changedTouches[0]:t,this),s=n.invert(a),u=n.k*(t.shiftKey?.5:2),c=o(v(_(n,u),a,s),i.apply(this,e),h);Rn(t),l>0?gt(this).transition().duration(l).call(w,c,a,t):gt(this).call(m.transform,c,a,t)}}function M(n,...i){if(r.apply(this,arguments)){var o,a,s,u,h=n.touches,l=h.length,c=x(this,i,n.changedTouches.length===l).event(n);for(Pn(n),a=0;a{t.sourceEvent&&"touchmove"===t.sourceEvent.type&&t.sourceEvent.touches.length<2||this._parent.attr("transform",t.transform)})),this._zoom.wheelDelta((t=>-t.deltaY*(1===t.deltaMode?.05:t.deltaMode?1:.002))),this._zoom.filter((t=>{if("wheel"===t.type){if(!t.ctrlKey)return!1;var e=Sn(this);if(e.k){if(e.k<=.1&&t.deltaY>0)return t.preventDefault(),!1;if(e.k>=20&&t.deltaY<0)return t.preventDefault(),!1}return!0}return t.button||"touchmove"!==t.type?!(t.ctrlKey&&"wheel"!==t.type||t.button):2===t.touches.length}))}get(){return this._zoom}}class pr{triggerDownload(t,e){let n=new MouseEvent("click",{view:window,bubbles:!1,cancelable:!0}),r=document.createElement("a");r.setAttribute("download",e),r.setAttribute("href",t),r.setAttribute("target","_blank"),r.dispatchEvent(n)}}class gr extends pr{copyStylesInline(t,e){return new Promise((n=>{let r=["svg","g","text","textPath"];for(let n=0;n{let i=(new XMLSerializer).serializeToString(t),o=window.URL||window.webkitURL||window,a=new Blob([i],{type:"image/svg+xml;charset=utf-8"}),s=o.createObjectURL(a),u=new Image;u.onload=()=>{let t=this.createCanvas(e,n),i=t.getContext("2d");i.fillStyle="rgb(255,255,255)",i.fillRect(0,0,t.width,t.height),i.drawImage(u,0,0),o.revokeObjectURL(s);let a=t.toDataURL("image/png").replace("image/png","image/octet-stream");r(a)},u.src=s}))}cloneSvg(t){return new Promise((e=>{e(t.cloneNode(!0))}))}svgToImage(t,e){this.cloneSvg(t.get().node()).then((n=>{this.copyStylesInline(t.get().node(),n);const r=this.calculateViewBox(t.get().node()),i=r[2],o=r[3];n.setAttribute("width",i),n.setAttribute("height",o),n.setAttribute("viewBox",r),this.convertToDataUrl(n,i,o).then((t=>this.triggerDownload(t,e))).catch((()=>{console.log("Failed to save chart as PNG image")}))}))}}class mr extends pr{copyStylesInline(t,e){return new Promise((n=>{(function(t,e){return fetch(t,e).then(Jn)})(t).then((t=>{t=t.replace(/#webtrees-descendants-chart-container /g,"");let r=document.createElementNS("http://www.w3.org/2000/svg","style");r.appendChild(document.createTextNode(t)),e.prepend(r),n(e)}))}))}convertToObjectUrl(t){return new Promise((e=>{let n=(new XMLSerializer).serializeToString(t),r=window.URL||window.webkitURL||window,i=new Blob([n],{type:"image/svg+xml;charset=utf-8"}),o=r.createObjectURL(i),a=new Image;a.onload=()=>{e(o)},a.src=o}))}cloneSvg(t){return new Promise((e=>{e(t.cloneNode(!0))}))}svgToImage(t,e,n){this.cloneSvg(t.get().node()).then((t=>this.copyStylesInline(e,t))).then((t=>this.convertToObjectUrl(t))).then((t=>this.triggerDownload(t,n))).catch((()=>{console.log("Failed to save chart as SVG image")}))}}class _r{constructor(){this._exportClass=null}setExportClass(t){switch(t){case"png":this._exportClass=gr;break;case"svg":this._exportClass=mr}}createExport(t){switch(this.setExportClass(t),t){case"png":case"svg":return new this._exportClass}}}class vr{constructor(t,e){this._element=t.append("svg"),this._defs=new fr(this._element),this._visual=null,this._zoom=null,this._configuration=e,this.init()}init(){this._element.attr("width","100%").attr("height","100%").attr("text-rendering","geometricPrecision").attr("text-anchor","middle").attr("xmlns:xlink","https://www.w3.org/1999/xlink")}initEvents(t){this._element.on("contextmenu",(t=>t.preventDefault())).on("wheel",(e=>{e.ctrlKey||t.show(this._configuration.labels.zoom,300,(()=>{t.hide(700,800)}))})).on("touchend",(e=>{e.touches.length<2&&t.hide(0,800)})).on("touchmove",(e=>{e.touches.length>=2?t.hide():t.show(this._configuration.labels.move)})).on("click",(t=>this.doStopPropagation(t)),!0),this._configuration.rtl&&this._element.classed("rtl",!0),this._visual=this._element.append("g"),this._zoom=new dr(this._visual),this._element.call(this._zoom.get())}doStopPropagation(t){t.defaultPrevented&&t.stopPropagation()}export(t){return(new _r).createExport(t)}get defs(){return this._defs}get zoom(){return this._zoom}get visual(){return this._visual}get(){return this._element}}class yr{constructor(t,e){this._configuration=e,this._parent=t,this._hierarchy=new hr(this._configuration),this._data={}}get svg(){return this._svg}updateViewBox(){let t=this._svg.visual.node().getBBox(),e=this._parent.node().getBoundingClientRect(),n=Math.max(e.width,t.width),r=Math.max(e.height,t.height,300),i=(n-t.width)/2,o=(r-t.height)/2,a=Math.ceil(t.x-i-10),s=Math.ceil(t.y-o-10);n=Math.ceil(n+20),r=Math.ceil(r+20),this._svg.get().attr("viewBox",[a,s,n,r])}get data(){return this._data}set data(t){this._data=t,this._hierarchy.init(this._data)}draw(){this._parent.html(""),this._svg=new vr(this._parent,this._configuration),this._overlay=new cr(this._parent),this._svg.initEvents(this._overlay),new lr(this._svg,this._configuration,this._hierarchy),this.bindClickEventListener(),this.updateViewBox()}bindClickEventListener(){var t=this;this._svg.visual.selectAll("g.person").filter((t=>""!==t.data.xref)).each((function(e){gt(this).on("click",(function(){t.personClick(e.data)}))}))}personClick(t){1===t.generation?this.redirectToIndividual(t.url):this.update(t.updateUrl)}redirectToIndividual(t){window.location=t}update(t){window.location=t}}t.DescendantsChart=class{constructor(t,e){this._selector=t,this._parent=gt(this._selector),this._configuration=new ur(e.labels,e.generations,e.defaultColor,e.fontColor,e.treeLayout,e.rtl),this._chart=new yr(this._parent,this._configuration),this.init()}init(){gt("#centerButton").on("click",(()=>this.center())),gt("#exportPNG").on("click",(()=>this.exportPNG())),gt("#exportSVG").on("click",(()=>this.exportSVG()))}center(){this._chart.svg.get().transition().duration(750).call(this._chart.svg.zoom.get().transform,En)}get configuration(){return this._configuration}set cssFile(t){this._cssFile=t}update(t){this._chart.update(t)}draw(t){this._chart.data=t,this._chart.draw()}exportPNG(){this._chart.svg.export("png").svgToImage(this._chart.svg,"descendants-chart.png")}exportSVG(){this._chart.svg.export("svg").svgToImage(this._chart.svg,this._cssFile,"descendants-chart.svg")}},Object.defineProperty(t,"__esModule",{value:!0})},"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).WebtreesDescendantsChart={}); +var t,e;t=this,e=function(t){var e="http://www.w3.org/1999/xhtml",n={svg:"http://www.w3.org/2000/svg",xhtml:e,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function r(t){var e=t+="",r=e.indexOf(":");return r>=0&&"xmlns"!==(e=t.slice(0,r))&&(t=t.slice(r+1)),n.hasOwnProperty(e)?{space:n[e],local:t}:t}function i(t){return function(){var n=this.ownerDocument,r=this.namespaceURI;return r===e&&n.documentElement.namespaceURI===e?n.createElement(t):n.createElementNS(r,t)}}function o(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function a(t){var e=r(t);return(e.local?o:i)(e)}function s(){}function u(t){return null==t?s:function(){return this.querySelector(t)}}function h(t){return null==t?[]:Array.isArray(t)?t:Array.from(t)}function l(){return[]}function c(t){return null==t?l:function(){return this.querySelectorAll(t)}}function f(t){return function(){return this.matches(t)}}function d(t){return function(e){return e.matches(t)}}var p=Array.prototype.find;function g(){return this.firstElementChild}var m=Array.prototype.filter;function _(){return Array.from(this.children)}function v(t){return new Array(t.length)}function y(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}function w(t){return function(){return t}}function x(t,e,n,r,i,o){for(var a,s=0,u=e.length,h=o.length;se?1:t>=e?0:NaN}function M(t){return function(){this.removeAttribute(t)}}function A(t){return function(){this.removeAttributeNS(t.space,t.local)}}function E(t,e){return function(){this.setAttribute(t,e)}}function S(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function P(t,e){return function(){var n=e.apply(this,arguments);null==n?this.removeAttribute(t):this.setAttribute(t,n)}}function R(t,e){return function(){var n=e.apply(this,arguments);null==n?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,n)}}function T(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function C(t){return function(){this.style.removeProperty(t)}}function X(t,e,n){return function(){this.style.setProperty(t,e,n)}}function Y(t,e,n){return function(){var r=e.apply(this,arguments);null==r?this.style.removeProperty(t):this.style.setProperty(t,r,n)}}function W(t,e){return t.style.getPropertyValue(e)||T(t).getComputedStyle(t,null).getPropertyValue(e)}function L(t){return function(){delete this[t]}}function H(t,e){return function(){this[t]=e}}function B(t,e){return function(){var n=e.apply(this,arguments);null==n?delete this[t]:this[t]=n}}function I(t){return t.trim().split(/^|\s+/)}function D(t){return t.classList||new O(t)}function O(t){this._node=t,this._names=I(t.getAttribute("class")||"")}function V(t,e){for(var n=D(t),r=-1,i=e.length;++r=0&&(e=t.slice(n+1),t=t.slice(0,n)),{type:t,name:e}}))}function st(t){return function(){var e=this.__on;if(e){for(var n,r=0,i=-1,o=e.length;r=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};var ft=[null];function dt(t,e){this._groups=t,this._parents=e}function pt(){return new dt([[document.documentElement]],ft)}function gt(t){return"string"==typeof t?new dt([[document.querySelector(t)]],[document.documentElement]):new dt([[t]],ft)}function mt(t,e){if(t=function(t){let e;for(;e=t.sourceEvent;)t=e;return t}(t),void 0===e&&(e=t.currentTarget),e){var n=e.ownerSVGElement||e;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=t.clientX,r.y=t.clientY,[(r=r.matrixTransform(e.getScreenCTM().inverse())).x,r.y]}if(e.getBoundingClientRect){var i=e.getBoundingClientRect();return[t.clientX-i.left-e.clientLeft,t.clientY-i.top-e.clientTop]}}return[t.pageX,t.pageY]}dt.prototype=pt.prototype={constructor:dt,select:function(t){"function"!=typeof t&&(t=u(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i=M&&(M=z+1);!(y=m[M])&&++M=0;)(r=i[o])&&(a&&4^r.compareDocumentPosition(a)&&a.parentNode.insertBefore(r,a),a=r);return this},sort:function(t){function e(e,n){return e&&n?t(e.__data__,n.__data__):!e-!n}t||(t=z);for(var n=this._groups,r=n.length,i=new Array(r),o=0;o1?this.each((null==e?C:"function"==typeof e?Y:X)(t,e,null==n?"":n)):W(this.node(),t)},property:function(t,e){return arguments.length>1?this.each((null==e?L:"function"==typeof e?B:H)(t,e)):this.node()[t]},classed:function(t,e){var n=I(t+"");if(arguments.length<2){for(var r=D(this.node()),i=-1,o=n.length;++i{}};function vt(){for(var t,e=0,n=arguments.length,r={};e=0&&(n=t.slice(r+1),t=t.slice(0,r)),t&&!e.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:n}}))}function xt(t,e){for(var n,r=0,i=t.length;r0)for(var n,r,i=new Array(n),o=0;o=0&&e._call.call(void 0,t),e=e._next;--zt}()}finally{zt=0,function(){for(var t,e,n=kt,r=1/0;n;)n._call?(r>n._time&&(r=n._time),t=n,n=n._next):(e=n._next,n._next=null,n=t?t._next=e:kt=e);Nt=t,Bt(r)}(),St=0}}function Ht(){var t=Rt.now(),e=t-Et;e>1e3&&(Pt-=e,Et=t)}function Bt(t){zt||(Mt&&(Mt=clearTimeout(Mt)),t-St>24?(t<1/0&&(Mt=setTimeout(Lt,t-Rt.now()-Pt)),At&&(At=clearInterval(At))):(At||(Et=Rt.now(),At=setInterval(Ht,1e3)),zt=1,Tt(Lt)))}function It(t,e,n){var r=new Yt;return e=null==e?0:+e,r.restart((n=>{r.stop(),t(n+e)}),e,n),r}Yt.prototype=Wt.prototype={constructor:Yt,restart:function(t,e,n){if("function"!=typeof t)throw new TypeError("callback is not a function");n=(null==n?Ct():+n)+(null==e?0:+e),this._next||Nt===this||(Nt?Nt._next=this:kt=this,Nt=this),this._call=t,this._time=n,Bt()},stop:function(){this._call&&(this._call=null,this._time=1/0,Bt())}};var Dt=vt("start","end","cancel","interrupt"),Ot=[];function Vt(t,e,n,r,i,o){var a=t.__transition;if(a){if(n in a)return}else t.__transition={};!function(t,e,n){var r,i=t.__transition;function o(t){n.state=1,n.timer.restart(a,n.delay,n.time),n.delay<=t&&a(t-n.delay)}function a(o){var h,l,c,f;if(1!==n.state)return u();for(h in i)if((f=i[h]).name===n.name){if(3===f.state)return It(a);4===f.state?(f.state=6,f.timer.stop(),f.on.call("interrupt",t,t.__data__,f.index,f.group),delete i[h]):+h0)throw new Error("too late; already scheduled");return n}function Ut(t,e){var n=jt(t,e);if(n.state>3)throw new Error("too late; already running");return n}function jt(t,e){var n=t.__transition;if(!n||!(n=n[e]))throw new Error("transition not found");return n}function Gt(t,e){var n,r,i,o=t.__transition,a=!0;if(o){for(i in e=null==e?null:e+"",o)(n=o[i]).name===e?(r=n.state>2&&n.state<5,n.state=6,n.timer.stop(),n.on.call(r?"interrupt":"cancel",t,t.__data__,n.index,n.group),delete o[i]):a=!1;a&&delete t.__transition}}function Ft(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function $t(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function Kt(){}var Qt=.7,Jt=1/Qt,Zt="\\s*([+-]?\\d+)\\s*",te="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)\\s*",ee="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)%\\s*",ne=/^#([0-9a-f]{3,8})$/,re=new RegExp("^rgb\\("+[Zt,Zt,Zt]+"\\)$"),ie=new RegExp("^rgb\\("+[ee,ee,ee]+"\\)$"),oe=new RegExp("^rgba\\("+[Zt,Zt,Zt,te]+"\\)$"),ae=new RegExp("^rgba\\("+[ee,ee,ee,te]+"\\)$"),se=new RegExp("^hsl\\("+[te,ee,ee]+"\\)$"),ue=new RegExp("^hsla\\("+[te,ee,ee,te]+"\\)$"),he={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};function le(){return this.rgb().formatHex()}function ce(){return this.rgb().formatRgb()}function fe(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=ne.exec(t))?(n=e[1].length,e=parseInt(e[1],16),6===n?de(e):3===n?new _e(e>>8&15|e>>4&240,e>>4&15|240&e,(15&e)<<4|15&e,1):8===n?pe(e>>24&255,e>>16&255,e>>8&255,(255&e)/255):4===n?pe(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|240&e,((15&e)<<4|15&e)/255):null):(e=re.exec(t))?new _e(e[1],e[2],e[3],1):(e=ie.exec(t))?new _e(255*e[1]/100,255*e[2]/100,255*e[3]/100,1):(e=oe.exec(t))?pe(e[1],e[2],e[3],e[4]):(e=ae.exec(t))?pe(255*e[1]/100,255*e[2]/100,255*e[3]/100,e[4]):(e=se.exec(t))?xe(e[1],e[2]/100,e[3]/100,1):(e=ue.exec(t))?xe(e[1],e[2]/100,e[3]/100,e[4]):he.hasOwnProperty(t)?de(he[t]):"transparent"===t?new _e(NaN,NaN,NaN,0):null}function de(t){return new _e(t>>16&255,t>>8&255,255&t,1)}function pe(t,e,n,r){return r<=0&&(t=e=n=NaN),new _e(t,e,n,r)}function ge(t){return t instanceof Kt||(t=fe(t)),t?new _e((t=t.rgb()).r,t.g,t.b,t.opacity):new _e}function me(t,e,n,r){return 1===arguments.length?ge(t):new _e(t,e,n,null==r?1:r)}function _e(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}function ve(){return"#"+we(this.r)+we(this.g)+we(this.b)}function ye(){var t=this.opacity;return(1===(t=isNaN(t)?1:Math.max(0,Math.min(1,t)))?"rgb(":"rgba(")+Math.max(0,Math.min(255,Math.round(this.r)||0))+", "+Math.max(0,Math.min(255,Math.round(this.g)||0))+", "+Math.max(0,Math.min(255,Math.round(this.b)||0))+(1===t?")":", "+t+")")}function we(t){return((t=Math.max(0,Math.min(255,Math.round(t)||0)))<16?"0":"")+t.toString(16)}function xe(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new ke(t,e,n,r)}function be(t){if(t instanceof ke)return new ke(t.h,t.s,t.l,t.opacity);if(t instanceof Kt||(t=fe(t)),!t)return new ke;if(t instanceof ke)return t;var e=(t=t.rgb()).r/255,n=t.g/255,r=t.b/255,i=Math.min(e,n,r),o=Math.max(e,n,r),a=NaN,s=o-i,u=(o+i)/2;return s?(a=e===o?(n-r)/s+6*(n0&&u<1?0:a,new ke(a,s,u,t.opacity)}function ke(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}function Ne(t,e,n){return 255*(t<60?e+(n-e)*t/60:t<180?n:t<240?e+(n-e)*(240-t)/60:e)}Ft(Kt,fe,{copy:function(t){return Object.assign(new this.constructor,this,t)},displayable:function(){return this.rgb().displayable()},hex:le,formatHex:le,formatHsl:function(){return be(this).formatHsl()},formatRgb:ce,toString:ce}),Ft(_e,me,$t(Kt,{brighter:function(t){return t=null==t?Jt:Math.pow(Jt,t),new _e(this.r*t,this.g*t,this.b*t,this.opacity)},darker:function(t){return t=null==t?Qt:Math.pow(Qt,t),new _e(this.r*t,this.g*t,this.b*t,this.opacity)},rgb:function(){return this},displayable:function(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:ve,formatHex:ve,formatRgb:ye,toString:ye})),Ft(ke,(function(t,e,n,r){return 1===arguments.length?be(t):new ke(t,e,n,null==r?1:r)}),$t(Kt,{brighter:function(t){return t=null==t?Jt:Math.pow(Jt,t),new ke(this.h,this.s,this.l*t,this.opacity)},darker:function(t){return t=null==t?Qt:Math.pow(Qt,t),new ke(this.h,this.s,this.l*t,this.opacity)},rgb:function(){var t=this.h%360+360*(this.h<0),e=isNaN(t)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*e,i=2*n-r;return new _e(Ne(t>=240?t-240:t+120,i,r),Ne(t,i,r),Ne(t<120?t+240:t-120,i,r),this.opacity)},displayable:function(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl:function(){var t=this.opacity;return(1===(t=isNaN(t)?1:Math.max(0,Math.min(1,t)))?"hsl(":"hsla(")+(this.h||0)+", "+100*(this.s||0)+"%, "+100*(this.l||0)+"%"+(1===t?")":", "+t+")")}}));var ze=t=>()=>t;function Me(t){return 1==(t=+t)?Ae:function(e,n){return n-e?function(t,e,n){return t=Math.pow(t,n),e=Math.pow(e,n)-t,n=1/n,function(r){return Math.pow(t+r*e,n)}}(e,n,t):ze(isNaN(e)?n:e)}}function Ae(t,e){var n=e-t;return n?function(t,e){return function(n){return t+n*e}}(t,n):ze(isNaN(t)?e:t)}var Ee=function t(e){var n=Me(e);function r(t,e){var r=n((t=me(t)).r,(e=me(e)).r),i=n(t.g,e.g),o=n(t.b,e.b),a=Ae(t.opacity,e.opacity);return function(e){return t.r=r(e),t.g=i(e),t.b=o(e),t.opacity=a(e),t+""}}return r.gamma=t,r}(1);function Se(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}var Pe=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Re=new RegExp(Pe.source,"g");function Te(t,e){var n,r,i,o=Pe.lastIndex=Re.lastIndex=0,a=-1,s=[],u=[];for(t+="",e+="";(n=Pe.exec(t))&&(r=Re.exec(e));)(i=r.index)>o&&(i=e.slice(o,i),s[a]?s[a]+=i:s[++a]=i),(n=n[0])===(r=r[0])?s[a]?s[a]+=r:s[++a]=r:(s[++a]=null,u.push({i:a,x:Se(n,r)})),o=Re.lastIndex;return o180?e+=360:e-t>180&&(t+=360),o.push({i:n.push(i(n)+"rotate(",null,r)-2,x:Se(t,e)})):e&&n.push(i(n)+"rotate("+e+r)}(o.rotate,a.rotate,s,u),function(t,e,n,o){t!==e?o.push({i:n.push(i(n)+"skewX(",null,r)-2,x:Se(t,e)}):e&&n.push(i(n)+"skewX("+e+r)}(o.skewX,a.skewX,s,u),function(t,e,n,r,o,a){if(t!==n||e!==r){var s=o.push(i(o)+"scale(",null,",",null,")");a.push({i:s-4,x:Se(t,n)},{i:s-2,x:Se(e,r)})}else 1===n&&1===r||o.push(i(o)+"scale("+n+","+r+")")}(o.scaleX,o.scaleY,a.scaleX,a.scaleY,s,u),o=a=null,function(t){for(var e,n=-1,r=u.length;++n=0&&(t=t.slice(0,e)),!t||"start"===t}))}(e)?qt:Ut;return function(){var a=o(this,t),s=a.on;s!==r&&(i=(r=s).copy()).on(e,n),a.on=i}}var hn=pt.prototype.constructor;function ln(t){return function(){this.style.removeProperty(t)}}function cn(t,e,n){return function(r){this.style.setProperty(t,e.call(this,r),n)}}function fn(t,e,n){var r,i;function o(){var o=e.apply(this,arguments);return o!==i&&(r=(i=o)&&cn(t,o,n)),r}return o._value=e,o}function dn(t){return function(e){this.textContent=t.call(this,e)}}function pn(t){var e,n;function r(){var r=t.apply(this,arguments);return r!==n&&(e=(n=r)&&dn(r)),e}return r._value=t,r}var gn=0;function mn(t,e,n,r){this._groups=t,this._parents=e,this._name=n,this._id=r}function _n(){return++gn}var vn=pt.prototype;mn.prototype={constructor:mn,select:function(t){var e=this._name,n=this._id;"function"!=typeof t&&(t=u(t));for(var r=this._groups,i=r.length,o=new Array(i),a=0;a()=>t;function Mn(t,{sourceEvent:e,target:n,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function An(t,e,n){this.k=t,this.x=e,this.y=n}An.prototype={constructor:An,scale:function(t){return 1===t?this:new An(this.k*t,this.x,this.y)},translate:function(t,e){return 0===t&0===e?this:new An(this.k,this.x+this.k*t,this.y+this.k*e)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var En=new An(1,0,0);function Sn(t){for(;!t.__zoom;)if(!(t=t.parentNode))return En;return t.__zoom}function Pn(t){t.stopImmediatePropagation()}function Rn(t){t.preventDefault(),t.stopImmediatePropagation()}function Tn(t){return!(t.ctrlKey&&"wheel"!==t.type||t.button)}function Cn(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t).hasAttribute("viewBox")?[[(t=t.viewBox.baseVal).x,t.y],[t.x+t.width,t.y+t.height]]:[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]:[[0,0],[t.clientWidth,t.clientHeight]]}function Xn(){return this.__zoom||En}function Yn(t){return-t.deltaY*(1===t.deltaMode?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function Wn(){return navigator.maxTouchPoints||"ontouchstart"in this}function Ln(t,e,n){var r=t.invertX(e[0][0])-n[0][0],i=t.invertX(e[1][0])-n[1][0],o=t.invertY(e[0][1])-n[0][1],a=t.invertY(e[1][1])-n[1][1];return t.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),a>o?(o+a)/2:Math.min(0,o)||Math.max(0,a))}function Hn(t){var e=0,n=t.children,r=n&&n.length;if(r)for(;--r>=0;)e+=n[r].value;else e=1;t.value=e}function Bn(t,e){t instanceof Map?(t=[void 0,t],void 0===e&&(e=Dn)):void 0===e&&(e=In);for(var n,r,i,o,a,s=new qn(t),u=[s];n=u.pop();)if((i=e(n.data))&&(a=(i=Array.from(i)).length))for(n.children=i,o=a-1;o>=0;--o)u.push(r=i[o]=new qn(i[o])),r.parent=n,r.depth=n.depth+1;return s.eachBefore(Vn)}function In(t){return t.children}function Dn(t){return Array.isArray(t)?t[1]:null}function On(t){void 0!==t.data.value&&(t.value=t.data.value),t.data=t.data.data}function Vn(t){var e=0;do{t.height=e}while((t=t.parent)&&t.height<++e)}function qn(t){this.data=t,this.depth=this.height=0,this.parent=null}function Un(t,e){return t.parent===e.parent?1:2}function jn(t){var e=t.children;return e?e[0]:t.t}function Gn(t){var e=t.children;return e?e[e.length-1]:t.t}function Fn(t,e,n){var r=n/(e.i-t.i);e.c-=r,e.s+=n,t.c+=r,e.z+=n,e.m+=n}function $n(t,e,n){return t.a.parent===e.parent?t.a:n}function Kn(t,e){this._=t,this.parent=null,this.children=null,this.A=null,this.a=this,this.z=0,this.m=0,this.c=0,this.s=0,this.t=null,this.i=e}function Qn(){var t=Un,e=1,n=1,r=null;function i(i){var u=function(t){for(var e,n,r,i,o,a=new Kn(t,0),s=[a];e=s.pop();)if(r=e._.children)for(e.children=new Array(o=r.length),i=o-1;i>=0;--i)s.push(n=e.children[i]=new Kn(r[i],i)),n.parent=e;return(a.parent=new Kn(null,0)).children=[a],a}(i);if(u.eachAfter(o),u.parent.m=-u.z,u.eachBefore(a),r)i.eachBefore(s);else{var h=i,l=i,c=i;i.eachBefore((function(t){t.xl.x&&(l=t),t.depth>c.depth&&(c=t)}));var f=h===l?1:t(h,l)/2,d=f-h.x,p=e/(l.x+f+d),g=n/(c.depth||1);i.eachBefore((function(t){t.x=(t.x+d)*p,t.y=t.depth*g}))}return i}function o(e){var n=e.children,r=e.parent.children,i=e.i?r[e.i-1]:null;if(n){!function(t){for(var e,n=0,r=0,i=t.children,o=i.length;--o>=0;)(e=i[o]).z+=n,e.m+=n,n+=e.s+(r+=e.c)}(e);var o=(n[0].z+n[n.length-1].z)/2;i?(e.z=i.z+t(e._,i._),e.m=e.z-o):e.z=o}else i&&(e.z=i.z+t(e._,i._));e.parent.A=function(e,n,r){if(n){for(var i,o=e,a=e,s=n,u=o.parent.children[0],h=o.m,l=a.m,c=s.m,f=u.m;s=Gn(s),o=jn(o),s&&o;)u=jn(u),(a=Gn(a)).a=e,(i=s.z+c-o.z-h+t(s._,o._))>0&&(Fn($n(s,e,r),e,i),h+=i,l+=i),c+=s.m,h+=o.m,f+=u.m,l+=a.m;s&&!Gn(a)&&(a.t=s,a.m+=c-l),o&&!jn(u)&&(u.t=o,u.m+=h-f,r=e)}return r}(e,i,e.parent.A||r[0])}function a(t){t._.x=t.z+t.parent.m,t.m+=t.parent.m}function s(t){t.x*=e,t.y=t.depth*n}return i.separation=function(e){return arguments.length?(t=e,i):t},i.size=function(t){return arguments.length?(r=!1,e=+t[0],n=+t[1],i):r?null:[e,n]},i.nodeSize=function(t){return arguments.length?(r=!0,e=+t[0],n=+t[1],i):r?[e,n]:null},i}function Jn(t){if(!t.ok)throw new Error(t.status+" "+t.statusText);return t.text()}Sn.prototype=An.prototype,qn.prototype=Bn.prototype={constructor:qn,count:function(){return this.eachAfter(Hn)},each:function(t,e){let n=-1;for(const r of this)t.call(e,r,++n,this);return this},eachAfter:function(t,e){for(var n,r,i,o=this,a=[o],s=[],u=-1;o=a.pop();)if(s.push(o),n=o.children)for(r=0,i=n.length;r=0;--r)o.push(n[r]);return this},find:function(t,e){let n=-1;for(const r of this)if(t.call(e,r,++n,this))return r},sum:function(t){return this.eachAfter((function(e){for(var n=+t(e.data)||0,r=e.children,i=r&&r.length;--i>=0;)n+=r[i].value;e.value=n}))},sort:function(t){return this.eachBefore((function(e){e.children&&e.children.sort(t)}))},path:function(t){for(var e=this,n=function(t,e){if(t===e)return t;var n=t.ancestors(),r=e.ancestors(),i=null;for(t=n.pop(),e=r.pop();t===e;)i=t,t=n.pop(),e=r.pop();return i}(e,t),r=[e];e!==n;)e=e.parent,r.push(e);for(var i=r.length;t!==n;)r.splice(i,0,t),t=t.parent;return r},ancestors:function(){for(var t=this,e=[t];t=t.parent;)e.push(t);return e},descendants:function(){return Array.from(this)},leaves:function(){var t=[];return this.eachBefore((function(e){e.children||t.push(e)})),t},links:function(){var t=this,e=[];return t.each((function(n){n!==t&&e.push({source:n.parent,target:n})})),e},copy:function(){return Bn(this).eachBefore(On)},[Symbol.iterator]:function*(){var t,e,n,r,i=this,o=[i];do{for(t=o.reverse(),o=[];i=t.pop();)if(yield i,e=i.children)for(n=0,r=e.length;n1+(t?Math.max(...t.map(e)):0);e(t);let n=Bn(t,(t=>t.children));const r=Qn().nodeSize([this.nodeWidth,this.nodeHeight]).separation((t=>this.separation));this._root=n,this._nodes=r(n)}get nodes(){return this._nodes}get root(){return this._root}createEmptyNode(t,e){return{id:0,xref:"",url:"",updateUrl:"",generation:t,name:"",firstNames:[],lastNames:[],preferredName:"",alternativeNames:[],isAltRtl:!1,sex:e,timespan:"",color:this._configuration.defaultColor,colors:[[],[]]}}}class lr{constructor(t,e,n){this._svg=t,this._configuration=e,this._hierarchy=n,this._hierarchy.root.x0=0,this._hierarchy.root.y0=0,this._orientation=this._configuration.orientation,this.draw(this._hierarchy.root)}draw(t){let e=this._hierarchy.nodes.descendants(),n=this._hierarchy.nodes.links();e.forEach((t=>{this._orientation.norm(t)})),this.drawLinks(n,t),this.drawNodes(e,t),e.forEach((t=>{t.x0=t.x,t.y0=t.y}))}drawNodes(t,e){let n=0,r=this;this._svg.defs.get().append("clipPath").attr("id","clip-rect").append("rect").attr("rx",r._orientation.imageCornerRadius()).attr("ry",r._orientation.imageCornerRadius()).attr("x",r._orientation.imageX()).attr("y",r._orientation.imageY()).attr("width",r._orientation.imageWidth()).attr("height",r._orientation.imageHeight()),this._svg.visual.transition().duration(this._configuration.duration);let i=this._svg.visual.selectAll("g.person").data(t,(t=>t.id||(t.id=++n))).enter().append("g").attr("class","person").attr("transform",(t=>"translate("+this._orientation.x(t)+","+this._orientation.y(t)+")"));i.append("rect").attr("class",(t=>"F"===t.data.sex?"female":"M"===t.data.sex?"male":"unknown")).attr("rx",this._orientation.cornerRadius()).attr("ry",this._orientation.cornerRadius()).attr("x",-this._orientation.boxWidth/2).attr("y",-this._orientation.boxHeight/2).attr("width",this._orientation.boxWidth).attr("height",this._orientation.boxHeight).attr("fill-opacity",.5).attr("fill",(t=>t.data.color)),i.filter((t=>""!==t.data.xref)).each((function(t){let e=gt(this);e.append("title").text((t=>t.data.name));let n=e.append("g").attr("class","image");n.append("rect").attr("rx",r._orientation.imageCornerRadius()).attr("ry",r._orientation.imageCornerRadius()).attr("x",r._orientation.imageX()).attr("y",r._orientation.imageY()).attr("width",r._orientation.imageWidth()).attr("height",r._orientation.imageHeight()).attr("fill","rgb(255, 255, 255)");let i=n.append("image").attr("x",r._orientation.imageX()).attr("y",r._orientation.imageY()).attr("width",r._orientation.imageWidth()).attr("height",r._orientation.imageHeight()).attr("clip-path","url(#clip-rect)");(function(t,e){return fetch(t,e).then((t=>t.blob())).then((t=>new Promise(((e,n)=>{const r=new FileReader;r.onloadend=()=>e(r.result),r.onerror=n,r.readAsDataURL(t)}))))})(r.getImageToLoad(t)).then((t=>i.attr("xlink:href",t))).catch((t=>{console.error(t)})),n.append("rect").attr("rx",r._orientation.imageCornerRadius()).attr("ry",r._orientation.imageCornerRadius()).attr("x",r._orientation.imageX()).attr("y",r._orientation.imageY()).attr("width",r._orientation.imageWidth()).attr("height",r._orientation.imageHeight()).attr("fill","none").attr("stroke","rgb(200, 200, 200)").attr("stroke-width",1.5),r.addNames(e,t),r.addDates(e,t)}))}togglePerson(t,e){e.children?(e._children=e.children,e.children=null):(e.children=e._children,e._children=null),this.draw(e)}collapse(t){t.children&&(t._children=t.children,t._children.forEach((t=>this.collapse(t))),t.children=null)}addFirstNames(t,e){let n=0;for(let r of e.data.firstNames){let i=t.append("tspan").text(r);r===e.data.preferredName&&i.attr("class","preferred"),0!==n&&i.attr("dx","0.25em"),++n}}addLastNames(t,e,n=0){let r=0;for(let i of e.data.lastNames){let e=t.append("tspan").attr("class","lastName").text(i);0!==r&&e.attr("dx","0.25em"),0!==n&&e.attr("dx",n+"em"),++r}}truncateNames(t,e=!1){let n=this._orientation.textWidth();this.truncateListOfNames(t.selectAll("tspan:not(.preferred):not(.lastName)"),t,n,e),t.selectAll("tspan.preferred").each(this.truncateText(t,n,e)),t.selectAll("tspan.lastName").each(this.truncateText(t,n,e))}truncateListOfNames(t,e,n,r){t.size()&&t.nodes().reverse().forEach((t=>{gt(t).each(this.truncateText(e,n,r))}))}truncateText(t,e,n=!1){let r=this;return function(){let i=r.getTextLength(t),o=gt(this),a=o.text();i>e&&(n?o.text(""):a.length>1&&o.text(a.slice(0,1)+"."))}}getTextLength(t){let e=0;return t.selectAll("tspan").each((function(){e+=this.getComputedTextLength()})),e}addNames(t,e){let n=t.append("g").attr("class","name");if(this._orientation._splittNames){let t=n.append("text").attr("text-anchor","middle").attr("alignment-baseline","central").attr("dy",this._orientation.textY()),r=n.append("text").attr("text-anchor","middle").attr("alignment-baseline","central").attr("dy",this._orientation.textY()+20);this.addFirstNames(t,e),this.addLastNames(r,e),e.data.firstNames.length||e.data.lastNames.length||t.append("tspan").text(e.data.name),this.truncateNames(t),this.truncateNames(r)}else{let t=n.append("text").attr("text-anchor","start").attr("dx",this._orientation.textX()).attr("dy",this._orientation.textY());this.addFirstNames(t,e),this.addLastNames(t,e,.25),e.data.firstNames.length||e.data.lastNames.length||t.append("tspan").text(e.data.name),this.truncateNames(t)}}addDates(t,e){let n=t.append("g").attr("class","table");if(this._orientation._splittNames)return void n.append("text").attr("class","date").attr("text-anchor","middle").attr("alignment-baseline","central").attr("dy",this._orientation.textY()+50).append("tspan").text(e.data.timespan);let r=n.append("text").attr("class","date").attr("text-anchor","middle").attr("dominant-baseline","middle").attr("x",this._orientation.textX()).attr("y",this._orientation.textY()+15);if(e.data.birth&&r.append("tspan").text("★").attr("x",this._orientation.textX()+5).attr("dy",this._orientation.textY()+20),e.data.death){let t=r.append("tspan").text("†");e.data.birth?t.attr("x",this._orientation.textX()+5).attr("dy",this._orientation.textY()+35):t.attr("x",this._orientation.textX()+5).attr("dy",this._orientation.textY()+20)}let i=n.append("text").attr("class","date").attr("text-anchor","start").attr("dominant-baseline","middle").attr("x",this._orientation.textX()).attr("y",this._orientation.textY()+20);if(e.data.birth&&i.append("tspan").text(e.data.birth).attr("x",this._orientation.textX()+15).attr("dy",this._orientation.textY()+15),e.data.death){let t=i.append("tspan").text(e.data.death);e.data.birth?t.attr("x",this._orientation.textX()+15).attr("dy",this._orientation.textY()+35):t.attr("x",this._orientation.textX()+15).attr("dy",this._orientation.textY()+15)}}getImageToLoad(t){return t.data.thumbnail?t.data.thumbnail:""}drawLinks(t,e){this._svg.visual.selectAll("path.link").data(t,(t=>t.target.id)).enter().append("path").classed("link",!0).attr("d",(t=>this._orientation.elbow(t)))}}class cr{constructor(t){this._element=t.append("div").attr("class","overlay").style("opacity",1e-6)}show(t,e=0,n=null){this._element.select("p").remove(),this._element.append("p").attr("class","tooltip").text(t),this._element.transition().duration(e).style("opacity",1).on("end",(()=>{"function"==typeof n&&n()}))}hide(t=0,e=0){this._element.transition().delay(t).duration(e).style("opacity",1e-6)}get(){return this._element}}class fr{constructor(t){this._element=t.append("defs")}get(){return this._element}}class dr{constructor(t){this._zoom=null,this._parent=t,this.init()}init(){this._zoom=function(){var t,e,n,r=Tn,i=Cn,o=Ln,a=Yn,s=Wn,u=[0,1/0],h=[[-1/0,-1/0],[1/0,1/0]],l=250,c=De,f=vt("start","zoom","end"),d=500,p=0,g=10;function m(t){t.property("__zoom",Xn).on("wheel.zoom",k,{passive:!1}).on("mousedown.zoom",N).on("dblclick.zoom",z).filter(s).on("touchstart.zoom",M).on("touchmove.zoom",A).on("touchend.zoom touchcancel.zoom",E).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function _(t,e){return(e=Math.max(u[0],Math.min(u[1],e)))===t.k?t:new An(e,t.x,t.y)}function v(t,e,n){var r=e[0]-n[0]*t.k,i=e[1]-n[1]*t.k;return r===t.x&&i===t.y?t:new An(t.k,r,i)}function y(t){return[(+t[0][0]+ +t[1][0])/2,(+t[0][1]+ +t[1][1])/2]}function w(t,e,n,r){t.on("start.zoom",(function(){x(this,arguments).event(r).start()})).on("interrupt.zoom end.zoom",(function(){x(this,arguments).event(r).end()})).tween("zoom",(function(){var t=this,o=arguments,a=x(t,o).event(r),s=i.apply(t,o),u=null==n?y(s):"function"==typeof n?n.apply(t,o):n,h=Math.max(s[1][0]-s[0][0],s[1][1]-s[0][1]),l=t.__zoom,f="function"==typeof e?e.apply(t,o):e,d=c(l.invert(u).concat(h/l.k),f.invert(u).concat(h/f.k));return function(t){if(1===t)t=f;else{var e=d(t),n=h/e[2];t=new An(n,u[0]-e[0]*n,u[1]-e[1]*n)}a.zoom(null,t)}}))}function x(t,e,n){return!n&&t.__zooming||new b(t,e)}function b(t,e){this.that=t,this.args=e,this.active=0,this.sourceEvent=null,this.extent=i.apply(t,e),this.taps=0}function k(t,...e){if(r.apply(this,arguments)){var n=x(this,e).event(t),i=this.__zoom,s=Math.max(u[0],Math.min(u[1],i.k*Math.pow(2,a.apply(this,arguments)))),l=mt(t);if(n.wheel)n.mouse[0][0]===l[0]&&n.mouse[0][1]===l[1]||(n.mouse[1]=i.invert(n.mouse[0]=l)),clearTimeout(n.wheel);else{if(i.k===s)return;n.mouse=[l,i.invert(l)],Gt(this),n.start()}Rn(t),n.wheel=setTimeout(c,150),n.zoom("mouse",o(v(_(i,s),n.mouse[0],n.mouse[1]),n.extent,h))}function c(){n.wheel=null,n.end()}}function N(t,...e){if(!n&&r.apply(this,arguments)){var i=t.currentTarget,a=x(this,e,!0).event(t),s=gt(t.view).on("mousemove.zoom",f,!0).on("mouseup.zoom",d,!0),u=mt(t,i),l=t.clientX,c=t.clientY;kn(t.view),Pn(t),a.mouse=[u,this.__zoom.invert(u)],Gt(this),a.start()}function f(t){if(Rn(t),!a.moved){var e=t.clientX-l,n=t.clientY-c;a.moved=e*e+n*n>p}a.event(t).zoom("mouse",o(v(a.that.__zoom,a.mouse[0]=mt(t,i),a.mouse[1]),a.extent,h))}function d(t){s.on("mousemove.zoom mouseup.zoom",null),Nn(t.view,a.moved),Rn(t),a.event(t).end()}}function z(t,...e){if(r.apply(this,arguments)){var n=this.__zoom,a=mt(t.changedTouches?t.changedTouches[0]:t,this),s=n.invert(a),u=n.k*(t.shiftKey?.5:2),c=o(v(_(n,u),a,s),i.apply(this,e),h);Rn(t),l>0?gt(this).transition().duration(l).call(w,c,a,t):gt(this).call(m.transform,c,a,t)}}function M(n,...i){if(r.apply(this,arguments)){var o,a,s,u,h=n.touches,l=h.length,c=x(this,i,n.changedTouches.length===l).event(n);for(Pn(n),a=0;a{t.sourceEvent&&"touchmove"===t.sourceEvent.type&&t.sourceEvent.touches.length<2||this._parent.attr("transform",t.transform)})),this._zoom.wheelDelta((t=>-t.deltaY*(1===t.deltaMode?.05:t.deltaMode?1:.002))),this._zoom.filter((t=>{if("wheel"===t.type){if(!t.ctrlKey)return!1;var e=Sn(this);if(e.k){if(e.k<=.1&&t.deltaY>0)return t.preventDefault(),!1;if(e.k>=20&&t.deltaY<0)return t.preventDefault(),!1}return!0}return t.button||"touchmove"!==t.type?!(t.ctrlKey&&"wheel"!==t.type||t.button):2===t.touches.length}))}get(){return this._zoom}}class pr{triggerDownload(t,e){let n=new MouseEvent("click",{view:window,bubbles:!1,cancelable:!0}),r=document.createElement("a");r.setAttribute("download",e),r.setAttribute("href",t),r.setAttribute("target","_blank"),r.dispatchEvent(n)}}class gr extends pr{copyStylesInline(t,e){return new Promise((n=>{let r=["svg","g","text","textPath"];for(let n=0;n{let i=(new XMLSerializer).serializeToString(t),o=window.URL||window.webkitURL||window,a=new Blob([i],{type:"image/svg+xml;charset=utf-8"}),s=o.createObjectURL(a),u=new Image;u.onload=()=>{let t=this.createCanvas(e,n),i=t.getContext("2d");i.fillStyle="rgb(255,255,255)",i.fillRect(0,0,t.width,t.height),i.drawImage(u,0,0),o.revokeObjectURL(s);let a=t.toDataURL("image/png").replace("image/png","image/octet-stream");r(a)},u.src=s}))}cloneSvg(t){return new Promise((e=>{e(t.cloneNode(!0))}))}svgToImage(t,e){this.cloneSvg(t.get().node()).then((n=>{this.copyStylesInline(t.get().node(),n);const r=this.calculateViewBox(t.get().node()),i=r[2],o=r[3];n.setAttribute("width",i),n.setAttribute("height",o),n.setAttribute("viewBox",r),this.convertToDataUrl(n,i,o).then((t=>this.triggerDownload(t,e))).catch((()=>{console.log("Failed to save chart as PNG image")}))}))}}class mr extends pr{copyStylesInline(t,e){return new Promise((n=>{(function(t,e){return fetch(t,e).then(Jn)})(t).then((t=>{t=t.replace(/#webtrees-descendants-chart-container /g,"");let r=document.createElementNS("http://www.w3.org/2000/svg","style");r.appendChild(document.createTextNode(t)),e.prepend(r),n(e)}))}))}convertToObjectUrl(t){return new Promise((e=>{let n=(new XMLSerializer).serializeToString(t),r=window.URL||window.webkitURL||window,i=new Blob([n],{type:"image/svg+xml;charset=utf-8"}),o=r.createObjectURL(i),a=new Image;a.onload=()=>{e(o)},a.src=o}))}cloneSvg(t){return new Promise((e=>{e(t.cloneNode(!0))}))}svgToImage(t,e,n){this.cloneSvg(t.get().node()).then((t=>this.copyStylesInline(e,t))).then((t=>this.convertToObjectUrl(t))).then((t=>this.triggerDownload(t,n))).catch((()=>{console.log("Failed to save chart as SVG image")}))}}class _r{constructor(){this._exportClass=null}setExportClass(t){switch(t){case"png":this._exportClass=gr;break;case"svg":this._exportClass=mr}}createExport(t){switch(this.setExportClass(t),t){case"png":case"svg":return new this._exportClass}}}class vr{constructor(t,e){this._element=t.append("svg"),this._defs=new fr(this._element),this._visual=null,this._zoom=null,this._configuration=e,this.init()}init(){this._element.attr("width","100%").attr("height","100%").attr("text-rendering","geometricPrecision").attr("text-anchor","middle").attr("xmlns:xlink","https://www.w3.org/1999/xlink")}initEvents(t){this._element.on("contextmenu",(t=>t.preventDefault())).on("wheel",(e=>{e.ctrlKey||t.show(this._configuration.labels.zoom,300,(()=>{t.hide(700,800)}))})).on("touchend",(e=>{e.touches.length<2&&t.hide(0,800)})).on("touchmove",(e=>{e.touches.length>=2?t.hide():t.show(this._configuration.labels.move)})).on("click",(t=>this.doStopPropagation(t)),!0),this._configuration.rtl&&this._element.classed("rtl",!0),this._visual=this._element.append("g"),this._zoom=new dr(this._visual),this._element.call(this._zoom.get())}doStopPropagation(t){t.defaultPrevented&&t.stopPropagation()}export(t){return(new _r).createExport(t)}get defs(){return this._defs}get zoom(){return this._zoom}get visual(){return this._visual}get(){return this._element}}class yr{constructor(t,e){this._configuration=e,this._parent=t,this._hierarchy=new hr(this._configuration),this._data={}}get svg(){return this._svg}updateViewBox(){let t=this._svg.visual.node().getBBox(),e=this._parent.node().getBoundingClientRect(),n=Math.max(e.width,t.width),r=Math.max(e.height,t.height,300),i=(n-t.width)/2,o=(r-t.height)/2,a=Math.ceil(t.x-i-10),s=Math.ceil(t.y-o-10);n=Math.ceil(n+20),r=Math.ceil(r+20),this._svg.get().attr("viewBox",[a,s,n,r])}get data(){return this._data}set data(t){this._data=t,this._hierarchy.init(this._data)}draw(){this._parent.html(""),this._svg=new vr(this._parent,this._configuration),this._overlay=new cr(this._parent),this._svg.initEvents(this._overlay),new lr(this._svg,this._configuration,this._hierarchy),this.bindClickEventListener(),this.updateViewBox()}bindClickEventListener(){var t=this;this._svg.visual.selectAll("g.person").filter((t=>""!==t.data.xref)).each((function(e){gt(this).on("click",(function(){t.personClick(e.data)}))}))}personClick(t){1===t.generation?this.redirectToIndividual(t.url):this.update(t.updateUrl)}redirectToIndividual(t){window.location=t}update(t){window.location=t}}t.DescendantsChart=class{constructor(t,e){this._selector=t,this._parent=gt(this._selector),this._configuration=new ur(e.labels,e.generations,e.defaultColor,e.fontColor,e.treeLayout,e.rtl),this._chart=new yr(this._parent,this._configuration),this.init()}init(){gt("#centerButton").on("click",(()=>this.center())),gt("#exportPNG").on("click",(()=>this.exportPNG())),gt("#exportSVG").on("click",(()=>this.exportSVG()))}center(){this._chart.svg.get().transition().duration(750).call(this._chart.svg.zoom.get().transform,En)}get configuration(){return this._configuration}set cssFile(t){this._cssFile=t}update(t){this._chart.update(t)}draw(t){this._chart.data=t,this._chart.draw()}exportPNG(){this._chart.svg.export("png").svgToImage(this._chart.svg,"descendants-chart.png")}exportSVG(){this._chart.svg.export("svg").svgToImage(this._chart.svg,this._cssFile,"descendants-chart.svg")}},Object.defineProperty(t,"__esModule",{value:!0})},"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).WebtreesDescendantsChart={}); diff --git a/resources/js/modules/tree.js b/resources/js/modules/tree.js index b71bf50..f66324e 100644 --- a/resources/js/modules/tree.js +++ b/resources/js/modules/tree.js @@ -628,6 +628,14 @@ export default class Tree this.addFirstNames(text1, datum); this.addLastNames(text2, datum); + if (!datum.data.firstNames.length + && !datum.data.lastNames.length + ) { + // If both first and last names are empty, add the full name as alternative + text1.append("tspan") + .text(datum.data.name); + } + this.truncateNames(text1); this.truncateNames(text2); @@ -640,6 +648,15 @@ export default class Tree this.addFirstNames(text1, datum); this.addLastNames(text1, datum, 0.25); + + if (!datum.data.firstNames.length + && !datum.data.lastNames.length + ) { + // If both first and last names are empty, add the full name as alternative + text1.append("tspan") + .text(datum.data.name); + } + this.truncateNames(text1); } } diff --git a/src/Traits/IndividualTrait.php b/src/Traits/IndividualTrait.php index 2247a7c..191be78 100644 --- a/src/Traits/IndividualTrait.php +++ b/src/Traits/IndividualTrait.php @@ -28,29 +28,30 @@ trait IndividualTrait * * @var string */ - private $xpathFirstNames = '//text()[following::span[@class="SURN"]][normalize-space()]'; + private $xpathFirstNames + = '//span[@class="NAME"]//text()[parent::*[not(@class="wt-nickname")]][following::span[@class="SURN"]]'; /** - * The XPath identifier to extract the last name parts. + * The XPath identifier to extract the last name parts (surname + surname suffix). * * @var string */ private $xpathLastNames - = '//text()[parent::*[not(@class="wt-nickname")]][not(following::span[@class="SURN"])][normalize-space()]'; + = '//span[@class="NAME"]//span[@class="SURN"]/text()|//span[@class="SURN"]/following::text()'; /** - * The XPath identifier to extract the nick name part. + * The XPath identifier to extract the nickname part. * * @var string */ - private $xpathNickname = '//q[@class="wt-nickname"]'; + private $xpathNickname = '//span[@class="NAME"]//q[@class="wt-nickname"]/text()'; /** * The XPath identifier to extract the starred name part. * * @var string */ - private $xpathPreferredName = '//span[@class="starredname"]'; + private $xpathPreferredName = '//span[@class="NAME"]//span[@class="starredname"]/text()'; /** * The XPath identifier to extract the alternative name parts. @@ -65,7 +66,7 @@ trait IndividualTrait * @param Individual $individual The current individual * @param int $generation The generation the person belongs to * - * @return array + * @return array|bool|int|string> */ private function getIndividualData(Individual $individual, int $generation): array { diff --git a/src/Traits/ModuleCustomTrait.php b/src/Traits/ModuleCustomTrait.php index 8700446..3ed95aa 100644 --- a/src/Traits/ModuleCustomTrait.php +++ b/src/Traits/ModuleCustomTrait.php @@ -40,11 +40,6 @@ public function customModuleLatestVersionUrl(): string return self::CUSTOM_LATEST_VERSION; } - /** - * Fetch the latest version of this module. - * - * @return string - */ public function customModuleLatestVersion(): string { // No update URL provided.