UNPKG

@davidyaha/graphql-birdseye

Version:
327 lines 82.5 kB
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});function _interopDefault(e){return e&&"object"==typeof e&&"default"in e?e["default"]:e}var React=require("react"),React__default=_interopDefault(React),ReactDOM=require("react-dom"),definition=require("graphql/type/definition"),buildClientSchema=require("graphql/utilities/buildClientSchema"),PropTypes=_interopDefault(require("prop-types")),extendStatics=function(e,t){return extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},extendStatics(e,t)};function __extends(e,t){function n(){this.constructor=e}extendStatics(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var __assign=function(){return __assign=Object.assign||function(e){for(var t,r=1,o=arguments.length;r<o;r++)for(var n in t=arguments[r],t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},__assign.apply(this,arguments)};function __rest(n,r){var e={};for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&0>r.indexOf(t)&&(e[t]=n[t]);if(null!=n&&"function"==typeof Object.getOwnPropertySymbols)for(var o=0,t=Object.getOwnPropertySymbols(n);o<t.length;o++)0>r.indexOf(t[o])&&(e[t[o]]=n[t[o]]);return e}function __awaiter(e,t,n,r){return new(n||(n=Promise))(function(o,i){function a(e){try{d(r.next(e))}catch(t){i(t)}}function s(e){try{d(r["throw"](e))}catch(t){i(t)}}function d(e){e.done?o(e.value):new n(function(t){t(e.value)}).then(a,s)}d((r=r.apply(e,t||[])).next())})}function __generator(e,n){function r(e){return function(t){return o([e,t])}}function o(t){if(i)throw new TypeError("Generator is already executing.");for(;p;)try{if(i=1,a&&(s=2&t[0]?a["return"]:t[0]?a["throw"]||((s=a["return"])&&s.call(a),0):a.next)&&!(s=s.call(a,t[1])).done)return s;switch((a=0,s)&&(t=[2&t[0],s.value]),t[0]){case 0:case 1:s=t;break;case 4:return p.label++,{value:t[1],done:!1};case 5:p.label++,a=t[1],t=[0];continue;case 7:t=p.ops.pop(),p.trys.pop();continue;default:if((s=p.trys,!(s=0<s.length&&s[s.length-1]))&&(6===t[0]||2===t[0])){p=0;continue}if(3===t[0]&&(!s||t[1]>s[0]&&t[1]<s[3])){p.label=t[1];break}if(6===t[0]&&p.label<s[1]){p.label=s[1],s=t;break}if(s&&p.label<s[2]){p.label=s[2],p.ops.push(t);break}s[2]&&p.ops.pop(),p.trys.pop();continue;}t=n.call(e,p)}catch(n){t=[6,n],a=0}finally{i=s=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}var i,a,s,d,p={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return d={next:r(0),throw:r(1),return:r(2)},"function"==typeof Symbol&&(d[Symbol.iterator]=function(){return this}),d}var colors={primary:"#548f9e",background:"#212C32",white:"#ffffff",line:{active:"#8F9599",inactive:"#31424B"}},nodeStyles={gap:15,container:{fill:"#31424B",rx:15},header:{height:36,label:{"font-size":18,"text-anchor":"middle",fill:"#ffffff"},container:{fill:"transparent"// colors.primary, // stroke: colors.primary }},divider:{height:1,stroke:colors.background,fill:colors.background},row:{height:26,fieldNameLabel:{fill:"#f6f8fa","font-weight":"lighter"},fieldTypeLabel:{fill:"#959da5",weight:"lighter"},body:{fill:"transparent",stroke:"transparent",height:25,cursor:"pointer"}}},defaultTheme=__assign({colors:colors},nodeStyles,{line:{stroke:colors.line.inactive,fill:"transparent",strokeWidth:4,strokeLinejoin:"round",targetMarker:{type:"path",d:"M 10 -5 0 0 10 5 z"}}});function injectCustomRouter(e){var t=Math.round,n=Math.abs,r=Math.floor,o=e.g;e.routers.manhattan=function(e,o,i,a){// HELPER CLASSES // // Map of obstacles // Helper structure to identify whether a point lies inside an obstacle. function s(e){this.map={},this.options=e,this.mapGridSize=100}// Sorted Set // Set of items sorted by given value. function d(){this.items=[],this.hash={},this.values={},this.OPEN=1,this.CLOSE=2}// HELPERS // // return source bbox function p(e,t){// expand by padding box return t&&t.paddingBox?e.sourceBBox.clone().moveAndExpand(t.paddingBox):e.sourceBBox.clone()}// return target bbox function l(e,t){// expand by padding box return t&&t.paddingBox?e.targetBBox.clone().moveAndExpand(t.paddingBox):e.targetBBox.clone()}// return source anchor function c(e,t){if(e.sourceAnchor)return e.sourceAnchor;// fallback: center of bbox var n=p(e,t);return n.center()}// return target anchor function h(e,t){if(e.targetAnchor)return e.targetAnchor;// fallback: center of bbox var n=l(e,t);return n.center();// default }// returns a direction index from start point to end point // corrects for grid deformation between start and end function m(t,n,o,i,a){var s=360/o,d=t.theta(u(t,n,i,a)),p=e.normalizeAngle(d+s/2);return s*r(p/s)}// helper function for getDirectionAngle() // corrects for grid deformation // (if a point is one grid steps away from another in both dimensions, // it is considered to be 45 degrees away, even if the real angle is different) // this causes visible angle discrepancies if `opt.step` is much larger than `paper.gridSize` function u(t,n,r,o){var i=o.step,a=n.x-t.x,s=n.y-t.y,d=a/r.x,p=s/r.y;return new e.Point(t.x+d*i,t.y+p*i)}// return the change in direction between two direction angles function g(e,t){var r=n(e-t);return 180<r?360-r:r}// fix direction offsets according to current grid function _(e,t,n){var r=n.step;a.toArray(n.directions).forEach(function(e){e.gridOffsetX=e.offsetX/r*t.x,e.gridOffsetY=e.offsetY/r*t.y})}// get grid size in x and y dimensions, adapted to source and target positions function f(e,t,n){return{source:t.clone(),x:y(n.x-t.x,e),y:y(n.y-t.y,e)}}// helper function for getGrid() function y(e,r){// return step if diff = 0 if(!e)return r;var o=n(e),i=t(o/r);// return absDiff if less than one step apart if(!i)return o;// otherwise, return corrected step return r+(o-i*r)/i}// return a clone of point snapped to grid function b(t,n){var r=n.source,o=e.snapToGrid(t.x-r.x,n.x)+r.x,i=e.snapToGrid(t.y-r.y,n.y)+r.y;return new e.Point(o,i)}// round the point to opt.precision function v(e,t){return e?e.round(t.precision):e}// return a string representing the point // string is rounded to nearest int in both dimensions function x(e){return e.clone().round().toString()}// return a normalized vector from given point // used to determine the direction of a difference of two points function L(t){return new e.Point(0===t.x?0:n(t.x)/t.x,0===t.y?0:n(t.y)/t.y)}// PATHFINDING // // reconstructs a route by concatenating points with their parents function k(e,t,n,r,o,i){for(var a,s=[],d=L(o.difference(n)),p=x(n),l=e[p];l;){a=v(t[p],i);var c=L(a.difference(v(l.clone(),i)));c.equals(d)||(s.unshift(a),d=c),p=x(l),l=e[p]}var h=v(t[p],i),m=L(h.difference(r));return m.equals(d)||s.unshift(h),s}// heuristic method to determine the distance between two points function w(e,t){for(var n,r=1/0,o=0,a=t.length;o<a;o++)n=e.manhattanDistance(t[o]),n<r&&(r=n);return r}// find points around the bbox taking given directions into account // lines are drawn from anchor in given directions, intersections recorded // if anchor is outside bbox, only those directions that intersect get a rect point // the anchor itself is returned as rect point (representing some directions) // (since those directions are unobstructed by the bbox) function O(t,r,o,s,d){var p=d.directionMap,l=v(b(t,s),d),c=v(b(r.center(),s),d),h=l.difference(c),m=a.isObject(p)?Object.keys(p):[],u=a.toArray(o),g=m.reduce(function(o,a){if(u.includes(a)){for(var c,m=p[a],g=new e.Point(l.x+m.x*(n(h.x)+r.width),l.y+m.y*(n(h.y)+r.height)),_=new e.Line(t,g),f=_.intersect(r)||[],y=f.length,x=null,L=0;L<y;L++){var k=f[L],w=l.squaredDistance(k);(void 0===c||w>c)&&(c=w,x=b(k,s))}var O=v(x,d);// if an intersection was found in this direction, it is our rectPoint O&&(r.containsPoint(O)&&v(O.offset(m.x*s.x,m.y*s.y),d),o.push(O))}return o},[]);return r.containsPoint(l)||g.push(l),g}// finds the route between two points/rectangles (`from`, `to`) implementing A* algorithm // rectangles get rect points assigned by getRectPoints() function P(t,r,o,s){// Get grid for this route. var p,l;p=t instanceof e.Rect?c(this,s).clone():t.clone(),l=r instanceof e.Rect?h(this,s).clone():r.clone();var u,y,L,P,E=f(s.step,p,l);// Get pathfinding points. // Check that there is an accessible route point on both sides. // Otherwise, use fallbackRoute(). if(t instanceof e.Rect?(u=v(b(p,E),s),L=O(u,t,s.startDirections,E,s)):(u=v(b(p,E),s),L=[u]),r instanceof e.Rect?(y=v(b(l,E),s),P=O(l,r,s.endDirections,E,s)):(y=v(b(l,E),s),P=[y]),L=L.filter(o.isPointAccessible,o),P=P.filter(o.isPointAccessible,o),0<L.length&&0<P.length){// The set of tentative points to be evaluated, initially containing the start points. // Rounded to nearest integer for simplicity. for(var T=new d,S={},M={},A={},B=0,z=L.length;B<z;B++){var n=L[B],j=x(n);T.add(j,w(n,P)),S[j]=n,A[j]=0}var C,R,Z=s.previousDirectionAngle,F=void 0===Z,G=s.directions;// undefined for first route _(G,E,s);for(var N=G.length,X=a.toArray(P).reduce(function(e,t){var n=x(t);return e.push(n),e},[]),I=s.maximumLoops;!T.isEmpty()&&0<I;){// remove current from the open list var H,D=T.pop(),Y=S[D],K=M[D],q=A[D],W=Y.equals(u);// beginning of path, source anchor or `from` point // check if we reached any endpoint if(H=void 0===K?F?W?// beginning of path, start rect point null:m(u,Y,N,E,s):Z:m(K,Y,N,E,s),0<=X.indexOf(D))return s.previousDirectionAngle=H,k(M,S,Y,u,y,s);// go over all possible directions and find neighbors for(B=0;B<N;B++){C=G[B];var U=C.angle;// if the direction changed rapidly, don't use this point // any direction is allowed for starting points if(R=g(H,U),F&&W||!(R>s.maxAllowedDirectionChange)){var Q=Y.clone().offset(C.gridOffsetX,C.gridOffsetY),J=x(Q);// Closed points from the openSet were already evaluated. if(!T.isClose(J)&&o.isPointAccessible(Q)){// We can only enter end points at an acceptable angle. if(0<=X.indexOf(J)){v(Q,s);// remove rounding errors var V=Q.equals(y);// (is target anchor or `to` point) = can be entered in any direction if(!V){var $=m(Q,y,N,E,s),ee=g(U,$);if(ee>s.maxAllowedDirectionChange)continue}}// The current direction is ok. var te=C.cost,ne=W?0:s.penalties[R],re=q+te+ne;(!T.isOpen(J)||re<A[J])&&(S[J]=Q,M[J]=Y,A[J]=re,T.add(J,re+w(Q,P)))}}}I--}}// no route found (`to` point either wasn't accessible or finding route took // way too much calculation) return s.fallbackRoute.call(this,u,y,s)}// resolve some of the options function E(t){t.directions=a.result(t,"directions"),t.penalties=a.result(t,"penalties"),t.paddingBox=a.result(t,"paddingBox"),a.toArray(t.directions).forEach(function(t){var n=new e.Point(0,0),r=new e.Point(t.offsetX,t.offsetY);t.angle=e.normalizeAngle(n.theta(r))})}// initialization of the route finding function T(t,n,r){E(n),r.options.perpendicular=!!n.perpendicular;// the origin of first route's grid, does not need snapping // find a route by concatenating all partial routes (routes need to pass through vertices) // source -> vertex[1] -> ... -> vertex[n] -> target for(var o=p(r,n),d=l(r,n),h=c(r,n),m=new s(n).build(r.paper.model,r.model),u=a.toArray(t).map(e.Point),g=[],_=h,f=0,y=u.length;f<=y;f++){var b=null,v=x||o,x=u[f];if(!x){x=d;// If the target is a point (i.e. it's not an element), we // should use dragging route instead of main routing method if it has been provided. var L=!r.model.get("source").id||!r.model.get("target").id;if(L&&a.isFunction(n.draggingRoute)){// Make sure we are passing points only (not rects). var k=v===o?h:v,w=x.origin();b=n.draggingRoute.call(r,k,w,n)}}// if partial route has not been calculated yet use the main routing method to find one if(b=b||P.call(r,v,x,m,n),null===b)// the partial route cannot be found return n.fallbackRouter(t,n,r);var O=b[0];// remove the first point if the previous partial route had the same point as last O&&O.equals(_)&&b.shift(),_=b[b.length-1]||_,Array.prototype.push.apply(g,b)}return g}// public function var S={// size of the step to find a route (the grid of the manhattan pathfinder) step:10,// the number of route finding loops that cause the router to abort // returns fallback route instead maximumLoops:9e4,// the number of decimal places to round floating point coordinates precision:10,// maximum change of direction maxAllowedDirectionChange:90,// should the router use perpendicular linkView option? // does not connect anchor of element but rather a point close-by that is orthogonal // this looks much better perpendicular:!1,// should the source and/or target not be considered as obstacles? excludeEnds:[],// should certain types of elements not be considered as obstacles? excludeTypes:["basic.Text"],// possible starting directions from an element startDirections:["top","right","bottom","left"],// possible ending directions to an element endDirections:["top","right","bottom","left"],// specify the directions used above and what they mean directionMap:{top:{x:0,y:-1},right:{x:1,y:0},bottom:{x:0,y:1},left:{x:-1,y:0}},// cost of an orthogonal step cost:function(){return this.step},// an array of directions to find next points on the route // different from start/end directions directions:function(){var e=this.step,t=this.cost();return[{offsetX:e,offsetY:0,cost:t},{offsetX:0,offsetY:e,cost:t},{offsetX:-e,offsetY:0,cost:t},{offsetX:0,offsetY:-e,cost:t}]},// a penalty received for direction change penalties:function(){return{0:0,45:this.step/2,90:this.step/2}},// padding applied on the element bounding boxes paddingBox:function(){var e=this.step;return{x:-e,y:-e,width:2*e,height:2*e}},// a router to use when the manhattan router fails // (one of the partial routes returns null) fallbackRouter:function(e,t,n){if(!a.isFunction(i.routers.orthogonal))throw new Error("Manhattan requires the orthogonal router as default fallback.");return i.routers.orthogonal(e,a.assign({},S,t),n)},/* Deprecated */ // a simple route used in situations when main routing method fails // (exceed max number of loop iterations, inaccessible) fallbackRoute:function(){return null;// null result will trigger the fallbackRouter // left for reference: /*// Find an orthogonal route ignoring obstacles. var point = ((opt.previousDirAngle || 0) % 180 === 0) ? new g.Point(from.x, to.y) : new g.Point(to.x, from.y); return [point];*/},// if a function is provided, it's used to route the link while dragging an end // i.e. function(from, to, opt) { return []; } draggingRoute:null};return s.prototype.build=function(e,t){var n=this.options,r=a.toArray(n.excludeEnds).reduce(function(n,r){var o=t.get(r);if(o){var i=e.getCell(o.id);i&&n.push(i)}return n},[]),o=[],i=e.getCell(t.get("source").id);// source or target element could be excluded from set of obstacles i&&(o=a.union(o,i.getAncestors().map(function(e){return e.id})));var s=e.getCell(t.get("target").id);s&&(o=a.union(o,s.getAncestors().map(function(e){return e.id})));// Builds a map of all elements for quicker obstacle queries (i.e. is a point contained // in any obstacle?) (a simplified grid search). // The paper is divided into smaller cells, where each holds information about which // elements belong to it. When we query whether a point lies inside an obstacle we // don't need to go through all obstacles, we check only those in a particular cell. var d=this.mapGridSize;return e.getElements().reduce(function(e,t){var i=a.toArray(n.excludeTypes).includes(t.get("type")),s=r.find(function(e){return e.id===t.id}),p=o.includes(t.id);if(!(i||s||p))for(var l=t.getBBox().moveAndExpand(n.paddingBox),c=l.origin().snapToGrid(d),h=l.corner().snapToGrid(d),m=c.x;m<=h.x;m+=d)for(var u,g=c.y;g<=h.y;g+=d)u=m+"@"+g,e[u]=e[u]||[],e[u].push(l);return e},this.map),this},s.prototype.isPointAccessible=function(e){var t=e.clone().snapToGrid(this.mapGridSize).toString();return a.toArray(this.map[t]).every(function(t){return!t.containsPoint(e)})},d.prototype.add=function(e,t){this.hash[e]?this.items.splice(this.items.indexOf(e),1):this.hash[e]=this.OPEN,this.values[e]=t;var n=i.util.sortedIndex(this.items,e,function(e){return this.values[e]}.bind(this));this.items.splice(n,0,e)},d.prototype.remove=function(e){this.hash[e]=this.CLOSE},d.prototype.isOpen=function(e){return this.hash[e]===this.OPEN},d.prototype.isClose=function(e){return this.hash[e]===this.CLOSE},d.prototype.isEmpty=function(){return 0===this.items.length},d.prototype.pop=function(){var e=this.items.shift();return this.remove(e),e},function(e,t,n){return T(e,a.assign({},S,t),n)}}(o,null,e,e.util),e.routers.metro=function(t){var n=Math.ceil,i={maxAllowedDirectionChange:45,// cost of a diagonal step diagonalCost:function(){var e=this.step;return n(Math.sqrt(e*e<<1))},// an array of directions to find next points on the route // different from start/end directions directions:function(){var e=this.step,t=this.cost(),n=this.diagonalCost();return[{offsetX:e,offsetY:0,cost:t},{offsetX:e,offsetY:e,cost:n},{offsetX:0,offsetY:e,cost:t},{offsetX:-e,offsetY:e,cost:n},{offsetX:-e,offsetY:0,cost:t},{offsetX:-e,offsetY:-e,cost:n},{offsetX:0,offsetY:-e,cost:t},{offsetX:e,offsetY:-e,cost:n}]},// a simple route used in situations when main routing method fails // (exceed max number of loop iterations, inaccessible) fallbackRoute:function(e,i,s){// Find a route which breaks by 45 degrees ignoring all obstacles. var d=e.theta(i),p=[],l={x:i.x,y:e.y},c={x:e.x,y:i.y};if(90<d%180){var h=l;l=c,c=h}var t=45>d%90?l:c,m=new o.Line(e,t),u=90*n(d/90),g=o.Point.fromPolar(m.squaredLength(),o.toRad(u+135),t),_=new o.Line(i,g),f=m.intersection(_),y=f?f:i,v=f?y:e,x=360/s.directions.length,L=v.theta(i),k=o.normalizeAngle(L+x/2),w=x*r(k/x);return s.previousDirectionAngle=w,y&&p.push(y.round()),p.push(i),p}};// public function return function(n,r,o){if(!t.isFunction(e.routers.manhattan))throw new Error("Metro requires the manhattan router.");return e.routers.manhattan(n,t.assign({},i,r),o)}}(e.util)}var injectCustomShapes=function(e,t){var n=Math.max;e.dia.FastPaper=e.dia.Paper.extend({sortViews:function(){}}),e.shapes.devs.Model.define("devs.Type",{size:{width:300,height:"auto"},attrs:{".container":__assign({},t.container,{"ref-width":"100%","ref-height":t.header.height+2*t.gap+5,"ref-height-2":"100%"}),".label":__assign({},t.header.label,{x:0,y:15}),".header":__assign({},t.header.container,{"ref-width":"100%"}),".divider":__assign({"ref-width":"1","ref-width-2":"100%",y:t.header.height},t.divider),".joint-port":{y:t.row.height}},ports:{groups:{out:{position:{name:"right",args:{dy:t.header.height+t.gap}},attrs:{".port-label":__assign({},t.row.fieldTypeLabel),".port-body":__assign({},t.row.body,{y:-t.row.height/2}),".port-body-highlighter":{rx:5,fill:"transparent",cursor:"pointer"}},label:{position:{name:"left",args:{y:0}}}},in:{position:{name:"left",args:{dy:t.header.height+t.gap}},attrs:{".port-label":t.row.fieldNameLabel,".port-body":__assign({},t.row.body,{y:-t.row.height/2}),".port-body-highlighter":{rx:5,fill:"transparent",cursor:"pointer"}},label:{position:{name:"right",args:{y:0}}}}}}},{markup:"<rect class=\"container\"/><rect class=\"header\"/><text class=\"label\"/><rect class=\"divider\" />",portMarkup:"<rect class=\"port-body\"/>",portLabelMarkup:"<text class=\"port-label\"/>",initialize:function(){e.shapes.basic.Generic.prototype.initialize.apply(this,arguments),this.on("change:inPorts change:outPorts",this.updatePortItems,this),this.updatePortItems()},updatePortItems:function(t,n,r){// Make sure all ports are unique. var o=e.util.uniq(this.get("inPorts")),i=e.util.difference(e.util.uniq(this.get("outPorts")),o),a=this.createPortItems("in",o),s=this.createPortItems("out",i);this.prop("ports/items",s.concat(a),e.util.assign({rewrite:!0},r)),this._setSize()},_setSize:function(){var e=n(this.get("inPorts").length,this.get("outPorts").length),r=this.get("size"),o=r.height,i=r.width;r.height&&"auto"!==r.height||(o=e*t.row.height+t.header.height+t.gap);var a=n.apply(Math,this.get("inPorts").map(function(e){return e.length})),s=n.apply(Math,this.get("outPorts").map(function(e){return e.label.length}));i=n(i,10*(a+s)+20),this.set("attrs/.container/height",o),this.set("size",__assign({},r,{height:o,width:i}))},createPortItem:function(e,n){return this._setSize(),{id:"object"==typeof n?n.id:n,group:e,attrs:{".port-label":{text:"object"==typeof n?n.label:n},".port-body":{width:this.get("size").width,x:"out"===e?-this.get("size").width:0},".port-body-highlighter":{width:this.get("size").width-20,x:"out"===e?-this.get("size").width+10:10,height:t.row.height,y:-t.row.height/2}}}},createPortItems:function(t,n){return e.util.toArray(n).map(this.createPortItem.bind(this,t))},_addGroupPort:function(e,t,n){var r=this.get(t);return this.set(t,Array.isArray(r)?r.concat(e):[e],n)},addOutPort:function(e,t){return this._addGroupPort(e,"outPorts",t)},addInPort:function(e,t){return this._addGroupPort(e,"inPorts",t)},_removeGroupPort:function(t,n,r){return this.set(n,e.util.without(this.get(n),t),r)},removeOutPort:function(e,t){return this._removeGroupPort(e,"outPorts",t)},removeInPort:function(e,t){return this._removeGroupPort(e,"inPorts",t)},_changeGroup:function(t,n,r){return this.prop("ports/groups/"+t,e.util.isObject(n)?n:{},r)},changeInGroup:function(e,t){return this._changeGroup("in",e,t)},changeOutGroup:function(e,t){return this._changeGroup("out",e,t)},transitionAsync:function(){for(var e=this,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return new Promise(function(n){e.transition.apply(e,t),e.on("transition:end",function(){n()})})},transitionOpacity:function(t,n){var r=n.delay,o=void 0===r?0:r,i=n.duration,a=void 0===i?100:i;return this.transitionAsync("attrs/./opacity",t,{delay:o,duration:a,timingFunction:e.util.timing.cubic,valueFunction:e.util.interpolate.number})},transitionPosition:function(t,n){var r=n.delay,o=void 0===r?0:r,i=n.duration,a=void 0===i?100:i;return Promise.all([this.transitionAsync("position/x",t.x,{delay:o,duration:a,timingFunction:e.util.timing.cubic,valueFunction:e.util.interpolate.number}),this.transitionAsync("position/y",t.y,{delay:o,duration:a,timingFunction:e.util.timing.cubic,valueFunction:e.util.interpolate.number})])}}),e.dia.Link.define("devs.Link",{attrs:{line:__assign({},t.line,{connection:!0}),wrapper:{connection:!0,strokeWidth:2,strokeLinejoin:"round"}}},{markup:[{tagName:"path",selector:"wrapper",attributes:{fill:"none",cursor:"pointer",stroke:"transparent"}},{tagName:"path",selector:"line",attributes:{fill:"none","pointer-events":"none"}}],transitionAsync:function(){for(var e=this,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return new Promise(function(n){e.transition.apply(e,t),e.on("transition:end",function(){n()})})},transitionColor:function(e,t){var n=t.delay,r=t.duration;return this.prop("attrs/line/stroke",e// , { // delay: 0, // duration: duration, // timingFunction: joint.util.timing.cubic, // valueFunction: joint.util.interpolate.hexColor // } )},transitionOpacity:function(e,t){var n=t.delay,r=t.duration;return this.prop("attrs/line/opacity",e// , { // delay: delay, // duration: duration, // timingFunction: joint.util.timing.cubic, // valueFunction: joint.util.interpolate.number // } )}})},baseEntities=["Boolean","Int","String","Float","ID"],filteredTypes=["DateTime"];function getNestedType(e){return Object.keys(e).includes("name")?e:getNestedType(e.ofType)}function getFieldLabel(e){return"GraphQLList"===e.constructor.name?"["+getFieldLabel(e.ofType)+"]":"GraphQLNonNull"===e.constructor.name?""+getFieldLabel(e.ofType):""+e.name}function isBaseEntity(e){return e.name.startsWith("__")||-1<baseEntities.indexOf(e.name)||["GraphQLEnumType","GraphQLInputObjectType","GraphQLScalarType"].includes(e.constructor.name)||"Mutation"===e.name}function isFilteredEntity(e){return-1<filteredTypes.indexOf(e.name)}function isRelatedType(e,t){var n=e.getFields(),r=Object.keys(n).find(function(e){var r=getNestedType(n[e].type);return r.name===t.name})||!1;return r}var joint=require("jointjs"),svgPanZoom=require("svg-pan-zoom"),animate=require("@f/animate"),TRANSITION_DURATION=500,JointJS=/** @class */function(){var t=Math.max;function e(e){this.activeType="root",this.animation=!0,this.maxZoom=20,this.eventMap={},this.cachedCells={},this.cachedLinks={},this.mounted=!1;var t=e.theme,n=void 0===t?defaultTheme:t;injectCustomShapes(joint,n),injectCustomRouter(joint),this.theme=n}return e.prototype.init=function(e,t,n){return __awaiter(this,void 0,void 0,function(){var r=this;return __generator(this,function(o){switch(o.label){case 0:return this.typeMap=n,this.graph=new joint.dia.Graph,this.paper=new joint.dia.FastPaper({el:e,model:this.graph,width:t.width,height:t.height,background:{color:this.theme.colors.background},gridSize:1,async:!0,defaultRouter:{name:"metro",args:{endDirection:["top","bottom"],paddingBox:200,step:100}},defaultConnector:{name:"rounded",args:{radius:200}},interactive:{linkMove:!1,elementMove:!1},validateMagnet:function(){return!1}}),[4/*yield*/,this.renderElements({animate:!1})];case 1:return o.sent(),this.bindInteractionEvents(),this.paper.on("render:done",function(){r.paper.options.async=!1,r.resizeToFit({animate:!1}),r.mounted=!0}),[2/*return*/];}})})},e.prototype.destroy=function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(){return this.paper.cancelRenderViews(),this.paper.clearGrid(),this.graph.clear(),this.paper.remove(),delete this.graph,delete this.paper,delete this.panZoom,[2/*return*/]})})},e.prototype.bindInteractionEvents=function(){var e=this;// show link tools this.paper.on("link:mouseover",function(t){var n=e.graph.getLinks();n.map(function(n){n===t.model||(n.transitionColor(e.theme.colors.line.inactive,{duration:TRANSITION_DURATION/2}),n.toBack())}),t.model.transitionColor(e.theme.colors.line.active,{duration:TRANSITION_DURATION/2}),t.model.toFront({deep:!0}),t.showTools()}),this.paper.on("element:magnet:pointerclick",function(e,t,n,r,o){t.stopPropagation(),console.log(e,t,n,r,o)}),this.paper.on("cell:mouseover",function(t,n){if(!t.model.isElement())return null;t.model.toFront({deep:!0});// return; var r=e.getHoveredPort(t,n);if(t.model.getPorts().map(function(e){t.model.portProp(e.id,"attrs/.port-body/fill","transparent")}),!r)return e.highlightLinks({cell:t.model});var o=r.link;return o?e.highlightLinks({links:[o]}):e.highlightLinks({cell:t.model})}),this.paper.on("blank:mouseover cell:mouseover",function(){e.paper.hideTools()}),this.paper.on("link:pointerclick",function(t){var n=t.model.attributes.target.id;e.setActiveType(n)}),this.paper.on("cell:pointerclick",function(t){var n=t.model.id;e.setActiveType(n)})},e.prototype.get=function(e){return this[e]},e.prototype.on=function(e,t){this.eventMap[e]=t},e.prototype.startLoading=function(){return __awaiter(this,void 0,void 0,function(){var e;return __generator(this,function(t){switch(t.label){case 0:return e=this.eventMap["loading:start"],e?[4/*yield*/,e()]:[3/*break*/,2];case 1:return[2/*return*/,t.sent()];case 2:return[2/*return*/];}})})},e.prototype.stopLoading=function(){return __awaiter(this,void 0,void 0,function(){var e;return __generator(this,function(t){switch(t.label){case 0:return e=this.eventMap["loading:stop"],e?[4/*yield*/,e()]:[3/*break*/,2];case 1:return[2/*return*/,t.sent()];case 2:return[2/*return*/];}})})},e.prototype.enableAnimation=function(){this.animation=!0},e.prototype.disableAnimation=function(){this.animation=!1},e.prototype.setTypeMap=function(e){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(t){switch(t.label){case 0:return this.typeMap=e,delete this.cachedCells,this.cachedLinks,this.cachedCells={},this.cachedLinks={},[4/*yield*/,this.renderElements({typeMap:e,animate:!1})];case 1:return t.sent(),[2/*return*/];}})})},e.prototype.setActiveType=function(e){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(t){switch(t.label){case 0:return this.graph.getCell(e).isElement()&&this.activeType!==e?(this.activeType=e,[4/*yield*/,this.renderElements()]):[3/*break*/,2];case 1:t.sent(),t.label=2;case 2:return[2/*return*/];}})})},e.prototype.setSize=function(e,t){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(){return this.paper.setDimensions(e,t),this.panZoom&&this.panZoom.resize(),[2/*return*/]})})},e.prototype.renderElements=function(e){return __awaiter(this,void 0,void 0,function(){var t,n,r,o,i,a,s,d,p;return __generator(this,function(l){switch(l.label){case 0:return[4/*yield*/,this.startLoading()];case 1:return l.sent(),t=new joint.dia.Graph().fromJSON(this.graph.toJSON()),n=e||{},r=n.typeMap,o=void 0===r?this.typeMap:r,i=n.activeType,a=void 0===i?this.activeType:i,s=n.animate,d=void 0===s?this.animation:s,p=this.getToRenderTypes(o,a),[4/*yield*/,Promise.all([this.removeUnusedElements(p,t),this.addNewElements(p,t)])];case 2:return l.sent(),[4/*yield*/,this.layoutGraph({animate:d,newGraph:t})];case 3:return l.sent(),[4/*yield*/,this.stopLoading()];case 4:return l.sent(),[2/*return*/];}})})},e.prototype.getToRenderTypes=function(e,t){return void 0===e&&(e=this.typeMap),void 0===t&&(t=this.activeType),Object.keys(e).filter(function(n){var r=e[n];return!(isFilteredEntity(r)||isBaseEntity(r))&&("root"===t?"Query"===r.name||"Mutation"===r.name||e.Query&&isRelatedType(e.Query,r)||e.Mutation&&isRelatedType(e.Mutation,r):t===r.name||!!("GraphQLObjectType"===r.constructor.name||r instanceof definition.GraphQLObjectType)&&(isRelatedType(r,e[t])||isRelatedType(e[t],r)))}).map(function(t){return e[t]})},e.prototype.removeUnusedElements=function(e,t){return void 0===t&&(t=this.graph),__awaiter(this,void 0,void 0,function(){var n,r;return __generator(this,function(){return n=t.getElements(),r=n.filter(function(t){return!e.find(function(e){return e.name===t.id})}).map(function(e){return[e].concat(t.getConnectedLinks(e))}),t.removeCells.apply(t,[].concat.apply([],r)),[2/*return*/]})})},e.prototype.addNewElements=function(e,t){return void 0===t&&(t=this.graph),__awaiter(this,void 0,void 0,function(){function n(e,t,n){return e.name+"_"+t.name+"_"+n.name}var r,o,i,a,s=this;return __generator(this,function(){return r=t.getElements(),o=e.filter(function(e){return!r.find(function(t){return t.id===e.name})}),i=o.map(function(e){var r=e.getFields();return s.createNode({id:e.name,position:(t.getBBox()||s.paper.getContentBBox()).topLeft(),attrs:{".label":{text:e.name}},inPorts:Object.keys(r),outPorts:Object.keys(r).map(function(t){var o=r[t],i=getNestedType(o.type),a=n(e,o,i),s=getFieldLabel(o.type);return s&&"undefined"!==s||(s=getFieldLabel(i)),{id:a,label:s}})})}),a=e.map(function(t){var n=t.getFields(),r=Object.keys(n),o=r.reduce(function(t,r){var o=n[r],i=getNestedType(o.type);return-1<e.findIndex(function(e){return e.name===i.name})&&(t[i.name]=(t[i.name]||[]).concat([o])),t},{});return Object.keys(o).map(function(e){return s.createLink(t.name,e)})}),t.addCells(i.concat([].concat.apply([],a))),[2/*return*/]})})},e.prototype.layoutGraph=function(e){return __awaiter(this,void 0,void 0,function(){var t,n,r,o,i,a,s=this;return __generator(this,function(d){switch(d.label){case 0:return t=e||{},n=t.animate,r=void 0===n||n,o=t.newGraph,i=void 0===o?this.graph:o,a=i.getElements().reduce(function(e,t){return e[t.attributes.id]=t.position(),e},{}),joint.layout.DirectedGraph.layout(i,{nodeSep:200,rankSep:500,rankDir:"LR"}),this.graph.fromJSON(i.toJSON()),[4/*yield*/,Promise.all([this.mounted&&this.resizeToFit()].concat(this.graph.getElements().map(function(e){return __awaiter(s,void 0,void 0,function(){var t,n,o,i=this;return __generator(this,function(s){switch(s.label){case 0:return r?(t=a[e.attributes.id],n=e.position(),e.position(t.x,t.y),o=this.graph.getConnectedLinks(e),this.graph.removeLinks(e),[4/*yield*/,e.transitionPosition(n,{duration:TRANSITION_DURATION})]):[2/*return*/];case 1:return s.sent(),o.map(function(e){return __awaiter(i,void 0,void 0,function(){return __generator(this,function(){return e.addTo(this.graph),[2/*return*/]})})}),[2/*return*/];}})})})))];case 1:return d.sent(),this.graph.resetCells(this.graph.getCells()),[2/*return*/];}})})},e.prototype.createNode=function(e){var t=this.cachedCells[e.id];if(t)return t;var n=new joint.shapes.devs.Type(e);return this.cachedCells[e.id]=n,n},e.prototype.createLink=function(e,t){var n=e+"_"+t,r=this.cachedLinks[n];if(r)return r;var o=new joint.shapes.devs.Link;return o.source({id:e,anchor:{name:"top",args:{dy:5}}}),o.target({id:t,anchor:{name:"top",args:{dy:this.theme.row.height-5,dx:10}}}),this.cachedLinks[n]=o,o},e.prototype.addTools=function(e){var t=new joint.dia.ToolsView({tools:[new joint.linkTools.TargetArrowhead]});e.findView(this.paper).addTools(t)},e.prototype.getHoveredPort=function(e,t){if(!e.model.isElement())return null;var n=e.findAttribute("port",t.target);return n?{id:n,link:this.graph.getLinks(e).find(function(e){return e.isLink()&&e.attributes.source.port===n})}:null},e.prototype.highlightLinks=function(e){var t=this,n=e.cell,r=e.links,o=r;n&&(o=this.graph.getConnectedLinks(n)),this.graph.getLinks().map(function(e){e.transitionColor(t.theme.colors.line.inactive,{duration:TRANSITION_DURATION}),e.toBack()}),o.map(function(e){e.transitionColor(t.theme.colors.line.active,{duration:TRANSITION_DURATION}),e.toFront({deep:!0})})},e.prototype.resizeToFit=function(e){return __awaiter(this,void 0,void 0,function(){var t,n,r=this;return __generator(this,function(){return t=(e||{}).animate,n=void 0===t||t,this.panZoom||(this.panZoom=svgPanZoom("#"+this.paper.svg.id,{fit:!0,controlIconsEnabled:!0,maxZoom:this.maxZoom,panEnabled:!1}),this.paper.on("blank:pointerdown",function(){r.panZoom.enablePan()}),this.paper.on("cell:pointerup blank:pointerup",function(){r.panZoom.disablePan()}),this.paper.on("resize",function(){r.panZoom.reset()})),this.panZoom.updateBBox(),n&&this.focusBBox(this.paper.getContentBBox()),[2/*return*/]})})},e.prototype.focusBBox=function(e){var n=e,r=this.panZoom.getPan();n.y=r.y,n.x=r.x;var o=this.panZoom.getSizes();r.x+=o.width/2-n.width/2,r.y+=o.height/2-n.height/2;var i=1.2*t(n.height/o.height,n.width/o.width),a=this.panZoom.getZoom()/i,s=.6*this.maxZoom;a>s&&(a=s);var d=r.x-n.x+0,p=r.y-n.y+0;// this.offsetLeft; this.animatePanAndZoom(d,p,a)},e.prototype.animatePanAndZoom=function(e,t,n){var r=this,o=this.panZoom.getPan(),i={x:e,y:t};animate(o,i,function(e){if(r.panZoom.pan({x:e.x,y:e.y}),e===i){var t=r.panZoom.getZoom();animate({zoom:t},{zoom:n},function(e){r.panZoom.zoom(e.zoom)})}})},e}(),MapShim=function(){/** * Returns index in provided array that matches the specified key. * * @param {Array<Array>} arr * @param {*} key * @returns {number} */function e(e,t){var n=-1;return e.some(function(e,r){return e[0]===t&&(n=r,!0)}),n}return"undefined"==typeof Map?/** @class */function(){function t(){this.__entries__=[]}return Object.defineProperty(t.prototype,"size",{/** * @returns {boolean} */get:function(){return this.__entries__.length},enumerable:!0,configurable:!0}),t.prototype.get=function(t){var n=e(this.__entries__,t),r=this.__entries__[n];return r&&r[1]},t.prototype.set=function(t,n){var r=e(this.__entries__,t);~r?this.__entries__[r][1]=n:this.__entries__.push([t,n])},t.prototype.delete=function(t){var n=this.__entries__,r=e(n,t);~r&&n.splice(r,1)},t.prototype.has=function(t){return!!~e(this.__entries__,t)},t.prototype.clear=function(){this.__entries__.splice(0)},t.prototype.forEach=function(e,t){void 0===t&&(t=null);for(var n,r=0,o=this.__entries__;r<o.length;r++)n=o[r],e.call(t,n[1],n[0])},t}():Map}(),isBrowser="undefined"!=typeof window&&"undefined"!=typeof document&&window.document===document,global$1=function(){return"undefined"!=typeof global&&global.Math===Math?global:"undefined"!=typeof self&&self.Math===Math?self:"undefined"!=typeof window&&window.Math===Math?window:Function("return this")();// eslint-disable-next-line no-new-func }(),requestAnimationFrame$1=function(){return"function"==typeof requestAnimationFrame?requestAnimationFrame.bind(global$1):function(e){return setTimeout(function(){return e(Date.now())},1e3/60)}}(),trailingTimeout=2;/** * Creates a wrapper function which ensures that provided callback will be * invoked only once during the specified delay period. * * @param {Function} callback - Function to be invoked after the delay period. * @param {number} delay - Delay after which to invoke callback. * @returns {Function} */function throttle(e,t){/** * Invokes the original callback function and schedules new invocation if * the "proxy" was called during current request. * * @returns {void} */function n(){i&&(i=!1,e()),a&&o()}/** * Callback invoked after the specified delay. It will further postpone * invocation of the original function delegating it to the * requestAnimationFrame. * * @returns {void} */function r(){requestAnimationFrame$1(n)}/** * Schedules invocation of the original function. * * @returns {void} */function o(){var e=Date.now();if(i){// Reject immediately following calls. if(e-s<trailingTimeout)return;// Schedule new call to be in invoked when the pending one is resolved. // This is important for "transitions" which never actually start // immediately so there is a chance that we might miss one if change // happens amids the pending invocation. a=!0}else i=!0,a=!1,setTimeout(r,t);s=e}var i=!1,a=!1,s=0;return o}// Minimum delay before invoking the update of observers. var REFRESH_DELAY=20,transitionKeys=["top","right","bottom","left","width","height","size","weight"],mutationObserverSupported="undefined"!=typeof MutationObserver,ResizeObserverController=/** @class */function(){/** * Creates a new instance of ResizeObserverController. * * @private */function e(){this.connected_=!1,this.mutationEventsAdded_=!1,this.mutationsObserver_=null,this.observers_=[],this.onTransitionEnd_=this.onTransitionEnd_.bind(this),this.refresh=throttle(this.refresh.bind(this),REFRESH_DELAY)}/** * Adds observer to observers list. * * @param {ResizeObserverSPI} observer - Observer to be added. * @returns {void} */return e.prototype.addObserver=function(e){~this.observers_.indexOf(e)||this.observers_.push(e),this.connected_||this.connect_()},e.prototype.removeObserver=function(e){var t=this.observers_,n=t.indexOf(e);~n&&t.splice(n,1),!t.length&&this.connected_&&this.disconnect_()},e.prototype.refresh=function(){var e=this.updateObservers_();// Continue running updates if changes have been detected as there might // be future ones caused by CSS transitions. e&&this.refresh()},e.prototype.updateObservers_=function(){// Collect observers that have active observations. var e=this.observers_.filter(function(e){return e.gatherActive(),e.hasActive()});// Deliver notifications in a separate cycle in order to avoid any // collisions between observers, e.g. when multiple instances of // ResizeObserver are tracking the same element and the callback of one // of them changes content dimensions of the observed target. Sometimes // this may result in notifications being blocked for the rest of observers. return e.forEach(function(e){return e.broadcastActive()}),0<e.length},e.prototype.connect_=function(){!isBrowser||this.connected_||(// Subscription to the "Transitionend" event is used as a workaround for // delayed transitions. This way it's possible to capture at least the // final state of an element. document.addEventListener("transitionend",this.onTransitionEnd_),window.addEventListener("resize",this.refresh),mutationObserverSupported?(this.mutationsObserver_=new MutationObserver(this.refresh),this.mutationsObserver_.observe(document,{attributes:!0,childList:!0,characterData:!0,subtree:!0})):(document.addEventListener("DOMSubtreeModified",this.refresh),this.mutationEventsAdded_=!0),this.connected_=!0)},e.prototype.disconnect_=function(){isBrowser&&this.connected_&&(document.removeEventListener("transitionend",this.onTransitionEnd_),window.removeEventListener("resize",this.refresh),this.mutationsObserver_&&this.mutationsObserver_.disconnect(),this.mutationEventsAdded_&&document.removeEventListener("DOMSubtreeModified",this.refresh),this.mutationsObserver_=null,this.mutationEventsAdded_=!1,this.connected_=!1)},e.prototype.onTransitionEnd_=function(e){var t=e.propertyName,n=void 0===t?"":t,r=transitionKeys.some(function(e){return!!~n.indexOf(e)});// Detect whether transition may affect dimensions of an element. r&&this.refresh()},e.getInstance=function(){return this.instance_||(this.instance_=new e),this.instance_},e.instance_=null,e}(),defineConfigurable=function(e,t){for(var n,r=0,o=Object.keys(t);r<o.length;r++)n=o[r],Object.defineProperty(e,n,{value:t[n],enumerable:!1,writable:!1,configurable:!0});return e},getWindowOf=function(e){// Assume that the element is an instance of Node, which means that it // has the "ownerDocument" property from which we can retrieve a // corresponding global object. var t=e&&e.ownerDocument&&e.ownerDocument.defaultView;// Return the local global object if it's not possible extract one from // provided element. return t||global$1},emptyRect=createRectInit(0,0,0,0);// A list of substrings of CSS properties used to find transition events that // might affect dimensions of observed elements. /** * Converts provided string to a number. * * @param {number|string} value * @returns {number} */function toFloat(e){return parseFloat(e)||0}/** * Extracts borders size from provided styles. * * @param {CSSStyleDeclaration} styles * @param {...string} positions - Borders positions (top, right, ...) * @returns {number} */function getBordersSize(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return t.reduce(function(t,n){var r=e["border-"+n+"-width"];return t+toFloat(r)},0)}/** * Extracts paddings sizes from provided styles. * * @param {CSSStyleDeclaration} styles * @returns {Object} Paddings box. */function getPaddings(e){for(var t=["top","right","bottom","left"],n={},r=0,o=t;r<o.length;r++){var i=o[r],a=e["padding-"+i];n[i]=toFloat(a)}return n}/** * Calculates content rectangle of provided SVG element. * * @param {SVGGraphicsElement} target - Element content rectangle of which needs * to be calculated. * @returns {DOMRectInit} */function getSVGContentRect(e){var t=e.getBBox();return createRectInit(0,0,t.width,t.height)}/** * Calculates content rectangle of provided HTMLElement. * * @param {HTMLElement} target - Element for which to calculate the content rectangle. * @returns {DOMRectInit} */function getHTMLElementContentRect(e){var t=Math.round,n=Math.abs,r=e.clientWidth,o=e.clientHeight;// By this condition we can catch all non-replaced inline, hidden and // detached elements. Though elements with width & height properties less // than 0.5 will be discarded as well. // // Without it we would need to implement separate methods for each of // those cases and it's not possible to perform a precise and performance // effective test for hidden elements. E.g. even jQuery's ':visible' filter // gives wrong results for elements with width & height less than 0.5. if(!r&&!o)return emptyRect;var i=getWindowOf(e).getComputedStyle(e),a=getPaddings(i),s=a.left+a.right,d=a.top+a.bottom,p=toFloat(i.width),l=toFloat(i.height);// Following steps can't be applied to the document's root element as its // client[Width/Height] properties represent viewport area of the window. // Besides, it's as well not necessary as the <html> itself neither has // rendered scroll bars nor it can be clipped. if("border-box"===i.boxSizing&&(t(p+s)!==r&&(p-=getBordersSize(i,"left","right")+s),t(l+d)!==o&&(l-=getBordersSize(i,"top","bottom")+d)),!isDocumentElement(e)){// In some browsers (only in Firefox, actually) CSS width & height // include scroll bars size which can be removed at this step as scroll // bars are the only difference between rounded dimensions + paddings // and "client" properties, though that is not always true in Chrome. var c=t(p+s)-r,h=t(l+d)-o;1!==n(c)&&(p-=c),1!==n(h)&&(l-=h)}return createRectInit(a.left,a.top,p,l)}/** * Checks whether provided element is an instance of the SVGGraphicsElement. * * @param {Element} target - Element to be checked. * @returns {boolean} */var isSVGGraphicsElement=function(){// Some browsers, namely IE and Edge, don't have the SVGGraphicsElement // interface. return"undefined"==typeof SVGGraphicsElement?function(e){return e instanceof getWindowOf(e).SVGElement&&"function"==typeof e.getBBox}:function(e){return e instanceof getWindowOf(e).SVGGraphicsElement};// If it's so, then check that element is at least an instance of the // SVGElement and that it has the "getBBox" method. // eslint-disable-next-line no-extra-parens }();/** * Checks whether provided element is a document element (<html>). * * @param {Element} target - Element to be checked. * @returns {boolean} */function isDocumentElement(e){return e===getWindowOf(e).document.documentElement}/** * Calculates an appropriate content rectangle for provided html or svg element. * * @param {Element} target - Element content rectangle of which needs to be calculated. * @returns {DOMRectInit} */function getContentRect(e){return isBrowser?isSVGGraphicsElement(e)?getSVGContentRect(e):getHTMLElementContentRect(e):emptyRect}/** * Creates rectangle with an interface of the DOMRectReadOnly. * Spec: https://drafts.fxtf.org/geometry/#domrectreadonly * * @param {DOMRectInit} rectInit - Object with rectangle's x/y coordinates and dimensions. * @returns {DOMRectReadOnly} */function createReadOnlyRect(e){var t=e.x,n=e.y,r=e.width,o=e.height,i="undefined"==typeof DOMRectReadOnly?Object:DOMRectReadOnly,a=Object.create(i.prototype);// If DOMRectReadOnly is available use it as a prototype for the rectangle. return defineConfigurable(a,{x:t,y:n,width:r,height:o,top:n,right:t+r,bottom:o+n,left:t}),a}/** * Creates DOMRectInit object based on the provided dimensions and the x/y coordinates. * Spec: https://drafts.fxtf.org/geometry/#dictdef-domrectinit * * @param {number} x - X coordinate. * @param {number} y - Y coordinate. * @param {number} width - Rectangle's width. * @param {number} height - Rectangle's height. * @returns {DOMRectInit} */function createRectInit(e,t,n,r){return{x:e,y:t,width:n,height:r}}/** * Class that is responsible for computations of the content rectangle of * provided DOM element and for keeping track of it's changes. */var ResizeObservation=/** @class */function(){/** * Creates an instance of ResizeObservation. * * @param {Element} target - Element to be observed. */function e(e){this.broadcastWidth=0,this.broadcastHeight=0,this.contentRect_=createRectInit(0,0,0,0),this.target=e}/** * Updates content rectangle and tells whether it's width or height properties * have changed since the last broadcast. * * @returns {boolean} */return e.prototype.isActive=function(){var e=getContentRect(this.target);return this.contentRect_=e,e.width!==this.broadcastWidth||e.height!==this.broadcastHeight},e.prototype.broadcastRect=function(){var e=this.contentRect_;return this.broadcastWidth=e.width,this.broadcastHeight=e.height,e},e}(),ResizeObserverEntry=/** @class */function(){/** * Creates an instance of ResizeObserverEntry. * * @param {Element} target - Element that is being observed. * @param {DOMRectInit} rectInit - Data of the element's content rectangle. */return function(e,t){var n=createReadOnlyRect(t);// According to the specification following properties are not writable // and are also not enumerable in the native implementation. // // Property accessors are not being used as they'd require to define a // private WeakMap storage which may cause memory leaks in browsers that // don't support this type of collections. defineConfigurable(this,{target:e,contentRect:n})}}(),ResizeObserverSPI=/** @class */function(){/** * Creates a new instance of ResizeObserver. * * @param {ResizeObserverCallback} callback - Callback function that is invoked * when one of the observed elements changes it's content dimensions. * @param {ResizeObserverController} controller - Controller instance which * is responsible for the updates of observer. * @param {ResizeObserver} callbackCtx - Reference to the public * ResizeObserver instance which will be passed to callback function. */function e(e,t,n){if(this.activeObservations_=[],this.observations_=new MapShim,"function"!=typeof e)throw new TypeError("The callback provided as parameter 1 is not a function.");this.callback_=e,this.controller_=t,this.callbackCtx_=n}/** * Starts observing provided element. * * @param {Element} target - Element to be observed. * @returns {void} */return e.prototype.observe=function(e){if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");// Do nothing if current environment doesn't have the Element interface. if("undefined"!=typeof Element&&Element instanceof Object){if(!(e instanceof getWindowOf(e).Element))throw new TypeError("parameter 1 is not of type \"Element\".");var t=this.observations_;// Do nothing if element is already being observed. t.has(e)||(// Force the update of observations. t.set(e,new ResizeObservation(e)),this.controller_.addObserver(this),this.controller_.refresh())}},e.prototype.unobserve=function(e){if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");// Do nothing if current environment doesn't have the Element interface. if("undefined"!=typeof Element&&Element instanceof Object){if(!(e instanceof getWindowOf(e).Element))throw new TypeError("parameter 1 is not of type \"Element\".");var t=this.observations_;// Do nothing if element is not being observed. t.has(e)&&(t.delete(