text:
function attachEvent(element,name,f){
 f=Function.closure(element,f);if(element.addEventListener){
 element.addEventListener(name,f,false);}else if(element.attachEvent){
 element.attachEvent("on"+name,f);}else{
 element["on"+name]=f;}
 element[name]=f;}
Function.closure=function(parent,f){
 return function(){ return f.apply(parent,arguments);};};
Object.keys=function(object){
 var a=[];for(var k in object)a.push(k);return a;};
Object.values=function(object){
 var a=[];for(var k in object)a.push(object[k]);return a;};
Array.sum=function(array){
 for(var i=0,sum=0;i < array.length;sum+=array[i++]){};return sum;};
Array.index=function(array,v){
 for(var i=0;i < array.length;i++){ if(array[i]===v)return i;}
 return-1;};
Array.choice=function(array){
 return array[Math.round(Math.random()*(array.length-1))];};
Array.unique=function(array){
 var a=array.slice();for(var i=a.length-1;i > 0;--i){
 var v=a[i];for(var j=i-1;j >=0;--j){
 if(a[j]===v)a.splice(j,1);i--;}
 }
 return a;};
var choice=Array.choice;
Math.degrees=function(radians){
 return radians*180/Math.PI;};
Math.radians=function(degrees){
 return degrees/180*Math.PI;};
Math.coordinates=function(x,y,distance,angle){
 return[x+distance*Math.cos(Math.radians(angle)),
 y+distance*Math.sin(Math.radians(angle))];};
var __MOUSE__={
 x: 0,
 y: 0,
 _x0: 0,
 _y0: 0,
 dx: 0,
 dy: 0,
 pressed: false,
 dragged: false,
 relative: function(element){
 var dx=0;var dy=0;if(element.offsetParent){
 do{
 dx+=element.offsetLeft;dy+=element.offsetTop;}while(element=element.offsetParent);}
 return{
 x: __MOUSE__.x-dx,
 y: __MOUSE__.y-dy
 }
 }
};
attachEvent(document,"mousemove",function(e){
 __MOUSE__.x=e.pageX ||(e.clientX+(document.documentElement.scrollLeft || document.body.scrollLeft));__MOUSE__.y=e.pageY ||(e.clientY+(document.documentElement.scrollTop || document.body.scrollTop));if(__MOUSE__.pressed){
 __MOUSE__.dragged=true;__MOUSE__.dx=__MOUSE__.x-__MOUSE__._x0;__MOUSE__.dy=__MOUSE__.y-__MOUSE__._y0;}
});
attachEvent(document,"mousedown",function(e){
 __MOUSE__.pressed=true;__MOUSE__._x0=__MOUSE__.x;__MOUSE__._y0=__MOUSE__.y;});
attachEvent(document,"mouseup",function(e){
 __MOUSE__.pressed=false;__MOUSE__.dragged=false;__MOUSE__.dx=0;__MOUSE__.dy=0;});
function _unselectable(element){
 if(element){
 element.onselectstart=function(){ return false;};element.unselectable="on";element.style.MozUserSelect="none";element.style.cursor="default";}
}
(function(){
 var initialized=false;var has_super=/xyz/.test(function(){ xyz;})?/\b_super\b/:/.*/;this.Class=function(){};Class.extend=function(properties){
 var _super=this.prototype;initialized=true;var p=new this();
 initialized=false;
 for(var k in properties){
 p[k]=typeof properties[k]=="function"
 && typeof _super[k]=="function"
 && has_super.test(properties[k])?(function(k,f){ return function(){
 var s,r;s=this._super;
 this._super=_super[k];r=f.apply(this,arguments);
 this._super=s;return r;};
 })(k,properties[k]): properties[k];}
 function Class(){
 if(!initialized && this.init){
 this.init.apply(this,arguments);}
 }
 Class.constructor=Class;Class.prototype=p;
 Class.extend=arguments.callee;return Class;};})();
function _parseRGBA(clr){
 if(clr && clr.rgba && clr._get){
 return clr._get();}
 if(clr instanceof Array){
 var r=Math.round(clr[0]*255);var g=Math.round(clr[1]*255);var b=Math.round(clr[2]*255);return "rgba("+r+","+g+","+b+","+clr[3]+")";
 }
 if(clr===null){
 return "rgba(0,0,0,0)";}
 return clr;}
var _GRAPH_FILL1=null;var _GRAPH_FILL2=null;function _ctx_graph_fillStyle(clr,ctx){
 clr=_parseRGBA(clr);if(clr===undefined){
 if(_ctx && _ctx.state && _ctx.state.fill !==undefined){
 clr=_parseRGBA(_ctx.state.fill);}else{
 clr="rgba(0,0,0,0)";}
 }
 if(_GRAPH_FILL1 !=clr || _GRAPH_FILL2 !=ctx.fillStyle){
 _GRAPH_FILL1=ctx.fillStyle=clr;_GRAPH_FILL2=ctx.fillStyle;}
}
var _GRAPH_STROKE1=null;var _GRAPH_STROKE2=null;function _ctx_graph_strokeStyle(clr,ctx){
 clr=_parseRGBA(clr);if(clr===undefined){
 if(_ctx && _ctx.state && _ctx.state.stroke !==undefined){
 clr=_parseRGBA(_ctx.state.stroke);}else{
 clr="rgba(0,0,0,1)";}
 }
 if(_GRAPH_STROKE1 !=clr || _GRAPH_STROKE2 !=ctx.strokeStyle){
 _GRAPH_STROKE1=ctx.strokeStyle=clr;_GRAPH_STROKE2=ctx.strokeStyle;}
}
function _ctx_graph_lineWidth(w1,w2,ctx){
 if(w1===undefined){
 w1=_ctx && _ctx.state && _ctx.state.strokewidth || 1.0;}
 ctx.lineWidth=w1+w2 || 0;}
var Node=Class.extend({
 init: function(id,a){
 if(a===undefined)a={};if(a.x===undefined)a.x=0;if(a.y===undefined)a.y=0;if(a.radius===undefined)a.radius=5;if(a.fixed===undefined)a.fixed=false;
 this.graph=null;this.links=new NodeLinks();this.id=id;this.x=0;
 this.y=0;
 this._x=a.x;this._y=a.y;this._vx=0;this._vy=0;this.radius=a.radius;this.fixed=a.fixed;this.fill=a.fill;this.stroke=a.stroke;this.strokewidth=a.strokewidth;this.weight=a.weight || 0;this.centrality=a.centrality || 0;this.degree=a.degree || 0;this.text=null;if(a.text !=false){
 var div=document.createElement('div');var txt=((a.label || id)+"").replace("\\\"","\"");txt=txt.replace("<","<");txt=txt.replace(">",">");div.innerHTML=(a.href)? ''+txt+"" : txt;div.className=(a.css)?("node-label "+a.css): "node-label";div.style.fontFamily=(a.font)? a.font : "";div.style.fontSize=(a.fontsize)? a.fontsize+"px" : "";div.style.fontWeight=(a.fontweight)? a.fontweight : "";
 div.style.color=(typeof(a.text)=="string")? a.text : "";this.text=div;_unselectable(div);}
 },
 edges: function(){
 var a=[];for(var i=0;i < this.graph.edges.length;i++){
 var e=this.graph.edges[i];if(e.node1==this || e.node2==this){
 a.push(e);}
 }
 return a;},
 flatten: function(depth,traversable,_visited){
 if(depth===undefined)depth=1;if(traversable===undefined)traversable=function(node,edge){ return true;};_visited=_visited ||{};_visited[this.id]=[this,depth];if(depth >=1){
 for(var i=0;i < this.links.length;i++){
 var n=this.links[i];if(!_visited[n.id]|| _visited[n.id][1]< depth-1){
 if(traversable(this,this.links.edges[n.id])){
 n.flatten(depth-1,traversable,_visited);}
 }
 }
 }
 var a=Object.values(_visited);
 for(var i=0;i ((weighted==true)?-1:weighted)){
 var w=this.centrality*35;_ctx_graph_fillStyle("rgba(0,0,0,0.075)",ctx);ctx.beginPath();ctx.arc(this.x,this.y,this.radius+w,0,Math.PI*2,true);ctx.closePath();ctx.fill();}
 _ctx_graph_lineWidth(this.strokewidth,0,ctx);_ctx_graph_strokeStyle(this.stroke,ctx);_ctx_graph_fillStyle(this.fill,ctx);ctx.beginPath();ctx.arc(this.x,this.y,this.radius,0,Math.PI*2,true);ctx.closePath();ctx.fill();ctx.stroke();
 if(this.text){
 this.text.style.display="inline";this.text.style.position="absolute";this.text.style.left=Math.round(this.x+this.radius/2+this.graph.canvas.width/2)+"px";this.text.style.top=Math.round(this.y+this.radius/2+this.graph.canvas.height/2)+"px";}
 },
 contains: function(x,y){
 return Math.abs(this.x-x)< this.radius*2 &&
 Math.abs(this.y-y)< this.radius*2
 }
});
var NodeLinks=Class.extend({
 init: function(){
 this.edges={};this.length=0;},
 append: function(node,edge){
 if(!this.edges[node.id]){
 this[this.length]=node;
 this.length+=1;}
 this.edges[node.id]=edge;},
 remove: function(node){
 var i=Array.index(this,node);if(i >=0){
 for(var j=i;j < this.length;j++)this[j]=this[j+1];this.length-=1;delete this.edges[node.id];}
 },
 edge: function(node){
 return this.edges[(node instanceof Node)? node.id : node]|| null;}
});
var Edge=Class.extend({
 init: function(node1,node2,a){
 if(a===undefined)a={};if(a.weight===undefined)a.weight=0.0;if(a.length===undefined)a.length=1.0;if(a.type===undefined)a.type=null;
 this.node1=node1;this.node2=node2;this.weight=a.weight;this.length=a.length;this.type=a.type;this.stroke=a.stroke;this.strokewidth=a.strokewidth;},
 draw: function(weighted,directed){
 var w=weighted && this.weight || 0;var ctx=this.node1.graph._ctx;_ctx_graph_lineWidth(this.strokewidth,w,ctx);_ctx_graph_strokeStyle(this.stroke,ctx);ctx.beginPath();ctx.moveTo(this.node1.x,this.node1.y);ctx.lineTo(this.node2.x,this.node2.y);ctx.stroke();if(directed){
 this.drawArrow(this.strokewidth);}
 },
 drawArrow: function(strokewidth){
 var s=(strokewidth !==undefined)? strokewidth : _ctx && _ctx.state && _ctx.state.strokewidth || 1;var x0=this.node1.x;var y0=this.node1.y;var x1=this.node2.x;var y1=this.node2.y;
 var a=Math.degrees(Math.atan2(y1-y0,x1-x0));
 var d=Math.sqrt(Math.pow(x1-x0,2)+Math.pow(y1-y0,2));var r=Math.max(s*4,8);var p1=Math.coordinates(x0,y0,d-this.node2.radius-1,a);var p2=Math.coordinates(p1[0],p1[1],-r,a-20);var p3=Math.coordinates(p1[0],p1[1],-r,a+20);var ctx=this.node1.graph._ctx;_ctx_graph_fillStyle(ctx.strokeStyle,ctx);ctx.beginPath();ctx.moveTo(p1[0],p1[1]);ctx.lineTo(p2[0],p2[1]);ctx.lineTo(p3[0],p3[1]);ctx.fill();}
});
var SHADOW=0.0;
var SPRING="spring";
var EIGENVECTOR="eigenvector";var BETWEENNESS="betweenness";
var WEIGHT="weight"
var CENTRALITY="centrality"
var Graph=Class.extend({
 init: function(canvas,distance,layout){
 if(distance===undefined)distance=10;if(layout===undefined)layout=SPRING;this.canvas=canvas;_unselectable(canvas);this._ctx=this.canvas? this.canvas.getContext("2d"): null;this.nodeset={};this.nodes=[];this.edges=[];this.root=null;this.mouse=__MOUSE__;this.distance=distance;this.layout=(layout==SPRING)? new GraphSpringLayout(this):
 new GraphLayout(this);},
 $: function(id){
 return this.nodeset[id];},
 append: function(base,a){
 if(base==Node)
 return this.add_node(a.id,a);if(base==Edge)
 return this.add_edge(a.id1,a.id2,a);},
 addNode: function(id,a){
 var n=a && a._super || Node;n=(id instanceof Node)? id :(this.nodeset[id])? this.nodeset[id]: new n(id,a);if(a && a.root)this.root=n;if(!this.nodeset[n.id]){
 this.nodes.push(n);this.nodeset[n.id]=n;n.graph=this;if(n.text && this.canvas && this.canvas.parentNode){
 this.canvas.parentNode.appendChild(n.text);}
 }
 return n;},
 addEdge: function(id1,id2,a){
 var n1=this.addNode(id1);var n2=this.addNode(id2);
 var e1=n1.links.edge(n2)
 if(e1 && e1.node1==n1 && e1.node2==n2){
 return e1;
 }
 e2=a && a._super || Edge;e2=new e2(n1,n2,a);this.edges.push(e2);
 n1.links.append(n2,edge=e2)
 n2.links.append(n1,edge=e1||e2)
 return e2;},
 remove: function(x){
 if(x instanceof Node && this.nodeset[x.id]){
 delete this.nodeset[x.id];this.nodes.splice(Array.index(this.nodes,x),1);x.graph=null;
 var a=[];for(var i=0;i < this.edges.length;i++){
 var e=this.edges[i];if(x==e.node1 || x==e.node2){
 if(x==e.node2)e.node1.links.remove(x);if(x==e.node1)e.node2.links.remove(x);}else{
 a.push(e);}
 }
 this.edges=a;
 if(x.text)x.text.parentNode.removeChild(x.text);}
 if(x instanceof Edge){
 this.edges.splice(Array.index(this.edges,x),1);}
 },
 node: function(id){
 if(id instanceof Node && id.graph==this)return id;return this.nodeset[id]|| null;},
 edge: function(id1,id2){
 if(id1 instanceof Node && id1.graph==this)id1=id1.id;if(id2 instanceof Node && id2.graph==this)id2=id2.id;return(this.nodeset[id1]&& this.nodeset[id2])? this.nodeset[id1].links.edge(id2): null;},
 paths: function(node1,node2,length,path){
 if(length===undefined)length=4;if(path===undefined)path=[];if(!(node1 instanceof Node))node1=this.nodeset(node1);if(!(node2 instanceof Node))node2=this.nodeset(node2);var p=[];var P=Graph.paths(this,node1.id,node2.id,length,path,true);for(var i=0;i < P.length;i++){
 var n=[];for(var j=0;j < P[i].length;j++){
 n.push(this.nodeset[P[i][j]]);}
 p.push(n);}
 return p;},
 shortestPath: function(node1,node2,a){
 if(!(node1 instanceof Node))node1=this.nodeset[node1];if(!(node2 instanceof Node))node2=this.nodeset[node2];try{
 var p=Graph.dijkstraShortestPath(this,node1.id,node2.id,a);var n=[];for(var i=0;i < p.length;i++){
 n.push(this.nodeset[p[i]]);}
 return n;}catch(e){
 return null;}
 },
 shortestPaths: function(node,a){
 if(!(node instanceof Node))node=this.nodeset[node];var p={};var P=Graph.dijkstraShortestPaths(this,node.id,a);for(var id in P){
 if(P[id]){
 var n=[];for(var i=0;i < P[id].length;i++){
 n.push(this.nodeset[P[id][i]]);}
 p[this.nodeset[id]]=n;}else{
 p[this.nodeset[id]]=null;}
 }
 },
 eigenvectorCentrality: function(graph,a){
 var ec=Graph.eigenvectorCentrality(this,a);var r={};for(var id in ec){
 var n=this.nodeset[id];n.weight=ec[id];r[n]=n.weight;}
 return r;},
 betweennessCentrality: function(graph,a){
 var bc=Graph.brandesBetweennessCentrality(this,a);var r={};for(var id in bc){
 var n=this.nodeset[id];n.centrality=bc[id];r[n]=n.centrality;}
 return r;},
 degreeCentrality: function(graph){
 var r={};for(var i=0;i < this.nodes.length;i++){
 var n=this.nodes[i];n.degree=n.links.length/this.nodes.length;r[n]=n.degree;}
 return r;},
 sorted: function(order,threshold){
 if(order===undefined)order=WEIGHT;if(threshold===undefined)threshold=0.0;var a=[];for(var i=0;i < this.nodes.length;i++){
 if(this.nodes[i][order]>=threshold){
 a.push([this.nodes[i][order],this.nodes[i]]);}
 }
 a=a.sort();a=a.reverse();for(var i=0;i < a.length;i++){
 a[i]=a[i][1];}
 return a;},
 prune: function(depth){
 if(depth===undefined)depth=0;var m={};for(i=0;i<this.nodes.length;i++){
 m[this.nodes[i].id]=0;}
 for(i=0;i<this.edges.length;i++){
 m[this.edges[i].node1.id]+=1;m[this.edges[i].node2.id]+=1;}
 for(id in m){
 if(m[id]<=depth){
 this.remove(this.nodeset[id]);}
 }
 },
 fringe: function(depth){
 if(depth===undefined)depth=0;var u=[];for(var i=0;i < this.nodes.length;i++){
 if(this.nodes[i].links.length==1){
 u.push.apply(u,this.nodes[i].flatten(depth));}
 }
 return Array.unique(u);},
 density: function(){
 return 2.0*this.edges.length/(this.nodes.length*(this.nodes.length-1));},
 split: function(){
 return Graph.partition(this);},
 update: function(iterations,weight,limit){
 if(iterations===undefined)iterations=2;for(var i=0;i < iterations;i++){
 this.layout.update(weight,limit);}
 },
 draw: function(weighted,directed){
 this._ctx.save();this._ctx.translate(this.canvas.width/2,this.canvas.height/2);for(var i=0;i < this.edges.length;i++){
 this.edges[i].draw(weighted,directed);}
 for(var i=0;i < this.nodes.length;i++){
 this.nodes[i].draw(weighted);}
 this._ctx.restore();},
 drag: function(mouse){
 var pt=null;if(mouse.pressed){
 pt=mouse.relative && mouse.relative(this.canvas)||{x: mouse.x,y: mouse.y};pt.x-=this.canvas.width/2;
 pt.y-=this.canvas.height/2;}
 if(mouse.pressed && !mouse.dragged){
 this.dragged=this.nodeAt(pt.x,pt.y);}
 if(!mouse.pressed){
 this.dragged=null;}
 if(this.dragged){
 this.dragged._x=pt.x/this.distance;this.dragged._y=pt.y/this.distance;this.layout.iterations=0;this._i=0;}
 },
 loop: function(a){
 if(a===undefined)a={};if(a.frames===undefined)a.frames=500;if(a.fps===undefined)a.fps=30;if(a.ipf===undefined)a.ipf=2;this._i=0;this._frames=a.frames;this._animation=setInterval(function(g){
 if(g._i < g._frames){
 g._ctx.clearRect(0,0,g.canvas.width,g.canvas.height);if(SHADOW){
 g._ctx.shadowColor="rgba(0,0,0,"+SHADOW+")";g._ctx.shadowBlur=8;g._ctx.shadowOffsetX=6;g._ctx.shadowOffsetY=6;}
 g.update(a.ipf);g.draw(a.weighted,a.directed);g._i+=1;}
 g.drag(g.mouse);},1000/a.fps,this);},
 stop: function(){
 clearInterval(this._animation);this._animation=null;},
 nodeAt: function(x,y){
 for(var i=0;i < this.nodes.length;i++){
 var n=this.nodes[i];if(n.contains(x,y)){
 return n;}
 }
 },
 _addNodeCopy: function(n,a){
 var args={
 radius: n.radius,
 fill: n.fill,
 stroke: n.stroke,
 strokewidth: n.strokewidth,
 text: n.text? n.text.style.color || true : false,
 font: n.text? n.text.style.fontFamily || null : null,
 fontsize: n.text? parseInt(n.text.style.fontSize)|| null : null,
 fontweight: n.text? n.text.style.fontWeight || null : null,
 css: n.text? n.text.className || null : null,
 root: a && a.root || false
 };var a=n.text? n.text.getElementsByTagName("a"): null;if(a && a.length > 0)args.href=a[0].href || null;this.addNode(n.id,args);},
 _addEdgeCopy: function(e,a){
 if(!((a && a["node1"]|| e.node1).id in this.nodeset)||
 !((a && a["node2"]|| e.node2).id in this.nodeset)){
 return;}
 this.addEdge(
 a && a["node1"]|| this.nodeset[e.node1.id],
 a && a["node2"]|| this.nodeset[e.node2.id],{
 weight: e.weight,
 length: e.length,
 type: e.type,
 stroke: e.stroke,
 strokewidth: e.strokewidth
 }
 );},
 copy: function(canvas,nodes){
 if(nodes===undefined)nodes=this.nodes;var g=new Graph(canvas,this.distance,null);g.layout=this.layout.copy(g);for(var i=0;i < nodes.length;i++){
 var n=nodes[i];if(!(n instanceof Node))n=this.nodeset[n];g._addNodeCopy(n,{root:this.root==n});}
 for(var i=0;i < this.edges.length;i++){
 var e=this.edges[i];g._addEdgeCopy(e);}
 return g;},
 clear: function(){
 if(this.canvas && this._ctx){
 this._ctx.clearRect(0,0,this.canvas.width,this.canvas.height);}
 for(var i=0;i < this.nodes.length;i++){
 var n=this.nodes[i];if(n.text && n.text.parentNode){
 n.text.parentNode.removeChild(n.text);n.text=null;}
 }
 this.nodeset={};this.nodes=[];this.edges=[];this.root=null;this.layout=null;this.canvas=null;}
});
GraphLayout=Class.extend({
 init: function(graph){
 this.graph=graph;this.iterations=0;},
 update: function(){
 this.iterations+=1;},
 reset: function(){
 this.iterations=0;for(var i=0;i < this.graph.nodes.length;i++){
 var n=this.graph.nodes[i];n._x=0;n._y=0;n._vx=0;n._vy=0;}
 },
 bounds: function(){
 var min={'x':+Infinity,'y':+Infinity}
 var max={'x':-Infinity,'y':-Infinity}
 for(var i=0;i < this.graph.nodes.length;i++){
 var n=this.graph.nodes[i];if(n._x < min.x)min.x=n._x;if(n._y < min.y)min.y=n._y;if(n._x > max.x)max.x=n._x;if(n._y > max.y)max.y=n._y;}
 return[min.x,min.y,max.x-min.x,max.y-min.y];},
 copy: function(graph){
 return new GraphLayout(graph);}
});
GraphSpringLayout=GraphLayout.extend({
 init: function(graph){
 this._super(graph);this.k=4.0;
 this.force=0.01;
 this.repulsion=50;
 },
 _distance: function(node1,node2){
 var dx=node2._x-node1._x;var dy=node2._y-node1._y;var d2=dx*dx+dy*dy;if(d2 < 0.01){
 dx=Math.random()*0.1+0.1;dy=Math.random()*0.1+0.1;d2=dx*dx+dy*dy;}
 return[dx,dy,Math.sqrt(d2),d2];},
 _repulse: function(node1,node2){
 var a=this._distance(node1,node2);dx=a[0];dy=a[1];d=a[2];d2=a[3];if(d < this.repulsion){
 var f=Math.pow(this.k,2)/d2;node2._vx+=f*dx;node2._vy+=f*dy;node1._vx-=f*dx;node1._vy-=f*dy;}
 },
 _attract: function(node1,node2,weight,length){
 var a=this._distance(node1,node2);dx=a[0];dy=a[1];d=a[2];d2=a[3];var d=Math.min(d,this.repulsion);var f=(d2-Math.pow(this.k,2))/this.k*length;f*=weight*0.5+1;f/=d;node2._vx-=f*dx;node2._vy-=f*dy;node1._vx+=f*dx;node1._vy+=f*dy;},
 update: function(weight,limit){
 if(weight===undefined)weight=10.0;if(limit===undefined)limit=0.5;
 this._super();
 for(var i=0;i < this.graph.nodes.length;i++){
 var n1=this.graph.nodes[i];for(var j=i+1;j < this.graph.nodes.length;j++){
 var n2=this.graph.nodes[j];this._repulse(n1,n2);}
 }
 for(var i=0;i < this.graph.edges.length;i++){
 var e=this.graph.edges[i];this._attract(e.node1,e.node2,weight*e.weight,1.0/(e.length||0.01));}
 for(var i=0;i < this.graph.nodes.length;i++){
 var n=this.graph.nodes[i];if(!n.fixed){
 n._x+=Math.max(-limit,Math.min(this.force*n._vx,limit));n._y+=Math.max(-limit,Math.min(this.force*n._vy,limit));n.x=n._x*n.graph.distance;n.y=n._y*n.graph.distance;}
 n._vx=0;n._vy=0;}
 },
 copy: function(graph){
 var g=new GraphSpringLayout(graph);g.k=this.k;g.force=this.force;g.repulsion=this.repulsion;return g;}
});
Graph.depthFirstSearch=function(node,a){
 if(a===undefined)a={};if(a.visit===undefined)a.visit=function(node){ return false;};if(a.traversable===undefined)a.traversable=function(node,edge){ return true;};var stop=visit(node);a._visited=a._visited ||{};a._visited[node.id]=true;for(var i=0;i < node.links.length;i++){
 var n=node.links[i];if(stop)return true;if(a.traversable(node,node.links.edge(n)==false))continue;if(!a._visited[n.id]){
 stop=Graph.depthFirstSearch(n,a);}
 }
 return stop;};
dfs=Graph.depthFirstSearch;
Graph.breadthFirstSearch=function(node,a){
 if(a===undefined)a={};if(a.visit===undefined)a.visit=function(node){ return false;};if(a.traversable===undefined)a.traversable=function(node,edge){ return true;};
 var q=[node];var _visited={};while(q.length > 0){
 node=q.splice(0,1)[0];if(!_visited[node.id]){
 if(a.visit(node))
 return true;for(var i=0;i < node.links.length;i++){
 var n=node.links[i];if(a.traversable(node,node.links.edge(n))!=false)q.push(n);}
 _visited[node.id]=true;}
 }
 return false;};
bfs=Graph.breadthFirstSearch;
Graph.paths=function(graph,id1,id2,length,path,_root){
 if(path.length >=length){
 return[];}
 if(!(id1 in graph.nodeset)){
 return[];}
 if(id1==id2){
 path=path.slice();path.push(id1);return[path];}
 path=path.slice();path.push(id1);var p=[];var n=graph.nodeset[id1].links;for(var i=0;i < n.length;i++){
 if(Array.index(path,n[i].id)< 0){
 p=p.push.apply(Graph.paths(graph,n[i].id,id2,length,path,false));}
 }
 if(_root !=false)p.sort(function(a,b){ return a.length-b.length;});return p;};
function edges(path){
 if(path && path.length > 1){
 var e=[];for(var i=0;i < path.length-1;i++){
 e.push(path[i].links.edge(path[i+1]));}
 return e;}
 return[];};
var Heap=Class.extend({
 init: function(){
 this.k=[];this.w=[];this.length=0;},
 push: function(key,weight){
 var i=0;while(i <=this.w.length && weight <(this.w[i]||Infinity))i++;this.k.splice(i,0,key);this.w.splice(i,0,weight);this.length+=1;return true;
 },
 pop: function(){
 this.length-=1;this.w.pop();return this.k.pop();}
});
Graph.adjacency=function(graph,a){
 if(a===undefined)a={};if(a.directed===undefined)a.directed=false;if(a.reversed===undefined)a.reversed=false;if(a.stochastic===undefined)a.stochastic=false;var map={};for(var i=0;i < graph.nodes.length;i++){
 map[graph.nodes[i].id]={};}
 for(var i=0;i < graph.edges.length;i++){
 var e=graph.edges[i];var id1=e[(a.reversed)?"node2":"node1"].id;var id2=e[(a.reversed)?"node1":"node2"].id;map[id1][id2]=1.0-e.weight*0.5;if(a.heuristic){
 map[id1][id2]+=a.heuristic(id1,id2);}
 if(!a.directed){
 map[id2][id1]=map[id1][id2];}
 }
 if(a.stochastic){
 for(var id1 in map){
 var n=Array.sum(Object.values(map[id1]));for(var id2 in map[id1]){
 map[id1][id2]/=n;}
 }
 }
 return map;};
Graph.dijkstraShortestPath=function(graph,id1,id2,a){
 function flatten(array){
 var a=[];for(var i=0;i < array.length;i++){
(array[i]instanceof Array)? a=a.concat(flatten(array[i])): a.push(array[i]);}
 return a;}
 var G=Graph.adjacency(graph,a);var q=new Heap();q.push([0,id1,[]],0);var visited={};for(;;){
 var x=q.pop();cost=x[0];n1=x[1];path=x[2];visited[n1]=true;if(n1==id2){
 var r=flatten(path);r.reverse();
 r.push(n1);return r;}
 var path=[n1,path];for(var n2 in G[n1]){
 if(!visited[n2]){
 q.push([cost+G[n1][n2],n2,path],cost+G[n1][n2]);}
 }
 }
};
Graph.dijkstraShortestPaths=function(graph,id,a){
 var W=Graph.adjacency(graph,a);var Q=new Heap();
 var D={};
 var P={};
 P[id]=[id];var seen={id: 0};Q.push([0,id],0);while(Q.length){
 var q=Q.pop();dist=q[0];v=q[1];if(v in D)continue;D[v]=dist;for(var w in W[v]){
 var vw_dist=D[v]+W[v][w];if(!(w in D)&&(!(w in seen)|| vw_dist < seen[w])){
 seen[w]=vw_dist;Q.push([vw_dist,w],vw_dist);P[w]=P[v].slice();P[w].push(w);}
 }
 }
 for(var n in graph.nodeset){
 if(!(n in P))P[n]=null;}
 return P;};
Graph.brandesBetweennessCentrality=function(graph,a){
 if(a===undefined)a={};if(a.normalized===undefined)a.normalized=true;if(a.directed===undefined)a.directed=false;var W=Graph.adjacency(graph,a);var b={};for(var n in graph.nodeset)b[n]=0.0;for(var id in graph.nodeset){
 var Q=new Heap();
 var D={};
 var P={};
 for(var n in graph.nodeset)P[n]=[];var seen={id: 0};Q.push([0,id,id],0);var S=[];var E={};for(var n in graph.nodeset)E[n]=0;
 E[id]=1.0;while(Q.length){
 var q=Q.pop();dist=q[0];pred=q[1];v=q[2];if(v in D)continue;D[v]=dist;S.push(v);E[v]+=E[pred];for(var w in W[v]){
 var vw_dist=D[v]+W[v][w];if(!(w in D)&&(!(w in seen)|| vw_dist < seen[w])){
 seen[w]=vw_dist;Q.push([vw_dist,v,w],vw_dist);P[w]=[v];E[w]=0.0;}else if(vw_dist==seen[w]){
 P[w].push(v);E[w]=E[w]+E[v];}
 }
 }
 var d={};for(var v in graph.nodeset)d[v]=0;while(S.length){
 var w=S.pop();for(var i=0;i < P[w].length;i++){
 v=P[w][i];d[v]+=(1+d[w])*E[v]/E[w];}
 if(w !=id){
 b[w]+=d[w];}
 }
 }
 var m=a.normalized? Math.max.apply(Math,Object.values(b))|| 1 : 1;for(var id in b)b[id]=b[id]/m;return b;};
Graph.eigenvectorCentrality=function(graph,a){
 if(a===undefined)a={};if(a.normalized===undefined)a.normalized=true;if(a.reversed===undefined)a.reversed=true;if(a.rating===undefined)a.rating={};if(a.iterations===undefined)a.iterations=100;if(a.tolerance===undefined)a.tolerance=0.0001;function normalize(vector){
 var w=1.0/(Array.sum(Object.values(vector))|| 1);for(var node in vector){
 vector[node]*=w;}
 }
 var G=Graph.adjacency(graph,a);var v={};for(var n in graph.nodeset)v[n]=Math.random();normalize(v);
 for(var i=0;i < a.iterations;i++){
 var v0=v
 var v={};for(var k in v0)v[k]=0;for(var n1 in v){
 for(var n2 in G[n1]){
 v[n1]+=0.01+v0[n2]*G[n1][n2]*(a.rating[n]? a.rating[n]: 1);}
 }
 normalize(v);var e=0;for(var n in v)e+=Math.abs(v[n]-v0[n]);
 if(e < graph.nodes.length*a.tolerance){
 var m=a.normalized? Math.max.apply(Math,Object.values(v))|| 1 : 1;for(var id in v)v[id]/=m;return v;}
 }
 if(window.console){
 console.warn("node weight is 0 because Graph.eigenvectorCentrality()did not converge.");}
 var x={};for(var n in graph.nodeset)x[n]=0;return x;};
Array.union=function(a,b){
 return Array.unique(a.concat(b));};
Array.intersection=function(a,b){
 var r=[],m={},i;for(i=0;i < b.length;i++)m[b[i]]=true;for(i=0;i < a.length;i++){
 if(a[i]in m)r.push(a[i]);
 }
 return r;};
Array.difference=function(a,b){
 var r=[],m={},i;for(i=0;i < b.length;i++)m[b[i]]=true;for(i=0;i < a.length;i++){
 if(!(a[i]in m))r.push(a[i]);}
 return r;};
Graph.partition=function(graph){
 var g=[];for(var i=0;i < graph.nodes.length;i++){
 var n=graph.nodes[i];n=n.flatten();var d={};for(var j=0;j < n.length;j++)d[n[j].id]=true;g.push(Object.keys(d));}
 for(var i=g.length-1;i >=0;i--){
 for(var j=g.length-1;j >=i+1;j--){
 if(g[i].length > 0 && g[j].length > 0 && Array.intersection(g[i],g[j]).length > 0){
 g[i]=Array.union(g[i],g[j]);g[j]=[];}
 }
 }
 for(var i=g.length-1;i >=0;i--){
 if(g[i].length==0)g.splice(i,1);}
 for(var i=0;i < g.length;i++){
 var n=[];for(var j=0;j < g[i].length;j++)n[j]=graph.nodeset[g[i][j]];g[i]=graph.copy(graph.canvas,nodes=n);}
 g.sort(function(a,b){ return b.length-a.length;});return g;};
Graph.isClique=function(graph){
 return(graph.density()==1.0);};
Graph.clique=function(graph,id){
 if(id instanceof Node){
 id=id.id;}
 var a=[id];for(var i=0;i < graph.nodes.length;i++){
 var n=graph.nodes[i];var b=true;for(var j=0;j < a.length;j++){
 if(n.id !=a[i].id && graph.edge(n.id,a[i].id)==null){
 b=false;break;}
 }
 if(b && n.id !=a[i].id){
 a.push(n.id);}
 return a;}
};
Graph.cliques=function(graph,threshold){
 if(threshold===undefined)threshold=3;var a=[];for(var i=0;i < graph.nodes.length;i++){
 var n=graph.nodes[i];var c=Graph.clique(graph,n.id);if(c.length >=threshold){
 c.sort();if(Array.index(a,c)< 0){
 a.push(c);}
 }
 }
};
Graph.unlink=function(graph,node1,node2){
 if(!(node1 instanceof Node))node1=graph.nodeset[node1];if(!(node2 instanceof Node))node2=graph.nodeset[node2];var e=graph.edges.slice();for(var i=0;i < e.length;i++){
 if((node1==e[i].node1 || node1==e[i].node2)&&
(node2==e[i].node1 || node2==e[i].node2 || node2===undefined)){
 graph.edges.splice(Array.index(graph.edges,e[i]),1);}
 try{
 node1.links.remove(Array.index(node1.links,node2),1);node2.links.remove(Array.index(node2.links,node1),1);}catch(x){
 }
 }
};
Graph.redirect=function(graph,node1,node2){
 if(!(node1 instanceof Node))node1=graph.nodeset[node1];if(!(node2 instanceof Node))node2=graph.nodeset[node2];for(var i=0;i < graph.edges.length;i++){
 var e=graph.edges[i];if(node1==e.node1 || node1==e.node2){
 if(e.node1==node1 && e.node2 !=node2){
 graph._addEdgeCopy(e,node2,e.node2);}
 if(e.node2==node1 && e.node1 !=node2){
 graph._addEdgeCopy(e,e.node1,node2);}
 }
 }
 Graph.unlink(graph,node1);};
Graph.cut=function(graph,node){
 if(!(node instanceof Node))node=graph.nodeset[node];for(var i=0;i < graph.edges.length;i++){
 var e=graph.edges[i];if(node==e.node1 || node==e.node2){
 for(var j=0;j < node.links.length;j++){
 var n=node.links[j];if(e.node1==node && e.node2 !=n){
 graph._addEdgeCopy(e,n,e.node2);}
 if(e.node2==node && e.node1 !=n){
 graph._addEdgeCopy(e,e.node1,n);}
 }
 }
 }
 Graph.unlink(graph,node);};
Graph.insert=function(graph,node,a,b){
 if(!(node instanceof Node))node=graph.nodeset[node];if(!(a instanceof Node))a=graph.nodeset[a];if(!(b instanceof Node))b=graph.nodeset[b];for(var i=0;i < graph.edges.length;i++){
 var e=graph.edges[i];if(e.node1==a && e.node2==b){
 graph._addEdgeCopy(e,a,node);graph._addEdgeCopy(e,node,b);}
 if(e.node1==b && e.node2==a){
 grapg._addEdgeCopy(e,b,node);graph._addEdgeCopy(e,node,a);}
 }
 Graph.unlink(graph,a,b);};


text:
id: contexts
title: Contexts
---

redpajama_set_name: RedPajamaGithub


text:
#include "core/svg/graphics/filters/SVGFilterBuilder.h"

#include "core/css/CSSPrimitiveValue.h"
#include "core/css/CSSPrimitiveValueMappings.h"
#include "core/css/StylePropertySet.h"
#include "core/dom/ElementTraversal.h"
#include "core/layout/LayoutObject.h"
#include "core/svg/SVGFilterElement.h"
#include "core/svg/SVGFilterPrimitiveStandardAttributes.h"
#include "platform/graphics/filters/Filter.h"
#include "platform/graphics/filters/PaintFilterEffect.h"
#include "platform/graphics/filters/SourceAlpha.h"
#include "platform/graphics/filters/SourceGraphic.h"

namespace blink {

namespace {

class FilterInputKeywords {
 public:
  static const AtomicString& getSourceGraphic() {
    DEFINE_STATIC_LOCAL(const AtomicString, s_sourceGraphicName,
                        ("SourceGraphic"));
    return s_sourceGraphicName;
  }

  static const AtomicString& sourceAlpha() {
    DEFINE_STATIC_LOCAL(const AtomicString, s_sourceAlphaName, ("SourceAlpha"));
    return s_sourceAlphaName;
  }

  static const AtomicString& fillPaint() {
    DEFINE_STATIC_LOCAL(const AtomicString, s_fillPaintName, ("FillPaint"));
    return s_fillPaintName;
  }

  static const AtomicString& strokePaint() {
    DEFINE_STATIC_LOCAL(const AtomicString, s_strokePaintName, ("StrokePaint"));
    return s_strokePaintName;
  }
};

}  // namespace

SVGFilterGraphNodeMap::SVGFilterGraphNodeMap() {}

void SVGFilterGraphNodeMap::addBuiltinEffect(FilterEffect* effect) {
  m_effectReferences.add(effect, FilterEffectSet());
}

void SVGFilterGraphNodeMap::addPrimitive(LayoutObject* object,
                                         FilterEffect* effect) {
  // The effect must be a newly created filter effect.
  ASSERT(!m_effectReferences.contains(effect));
  ASSERT(!object || !m_effectRenderer.contains(object));
  m_effectReferences.add(effect, FilterEffectSet());

  unsigned numberOfInputEffects = effect->inputEffects().size();

  // Add references from the inputs of this effect to the effect itself, to
  // allow determining what effects needs to be invalidated when a certain
  // effect changes.
  for (unsigned i = 0; i < numberOfInputEffects; ++i)
    effectReferences(effect->inputEffect(i)).add(effect);

  // If object is null, that means the element isn't attached for some
  // reason, which in turn mean that certain types of invalidation will not
  // work (the LayoutObject -> FilterEffect mapping will not be defined).
  if (object)
    m_effectRenderer.add(object, effect);
}

void SVGFilterGraphNodeMap::invalidateDependentEffects(FilterEffect* effect) {
  if (!effect->hasImageFilter())
    return;

  effect->clearResult();

  FilterEffectSet& effectReferences = this->effectReferences(effect);
  for (FilterEffect* effectReference : effectReferences)
    invalidateDependentEffects(effectReference);
}

DEFINE_TRACE(SVGFilterGraphNodeMap) {
  visitor->trace(m_effectRenderer);
  visitor->trace(m_effectReferences);
}

SVGFilterBuilder::SVGFilterBuilder(FilterEffect* sourceGraphic,
                                   SVGFilterGraphNodeMap* nodeMap,
                                   const SkPaint* fillPaint,
                                   const SkPaint* strokePaint)
    : m_nodeMap(nodeMap) {
  FilterEffect* sourceGraphicRef = sourceGraphic;
  m_builtinEffects.add(FilterInputKeywords::getSourceGraphic(),
                       sourceGraphicRef);
  m_builtinEffects.add(FilterInputKeywords::sourceAlpha(),
                       SourceAlpha::create(sourceGraphicRef));
  if (fillPaint)
    m_builtinEffects.add(
        FilterInputKeywords::fillPaint(),
        PaintFilterEffect::create(sourceGraphicRef->getFilter(), *fillPaint));
  if (strokePaint)
    m_builtinEffects.add(
        FilterInputKeywords::strokePaint(),
        PaintFilterEffect::create(sourceGraphicRef->getFilter(), *strokePaint));
  addBuiltinEffects();
}

void SVGFilterBuilder::addBuiltinEffects() {
  if (!m_nodeMap)
    return;
  for (const auto& entry : m_builtinEffects)
    m_nodeMap->addBuiltinEffect(entry.value.get());
}

// Returns the color-interpolation-filters property of the element.
static EColorInterpolation colorInterpolationForElement(
    SVGElement& element,
    EColorInterpolation parentColorInterpolation) {
  if (const LayoutObject* layoutObject = element.layoutObject())
    return layoutObject->styleRef().svgStyle().colorInterpolationFilters();

  // No layout has been performed, try to determine the property value
  // "manually" (used by external SVG files.)
  if (const StylePropertySet* propertySet =
          element.presentationAttributeStyle()) {
    const CSSValue* cssValue =
        propertySet->getPropertyCSSValue(CSSPropertyColorInterpolationFilters);
    if (cssValue && cssValue->isIdentifierValue()) {
      return toCSSIdentifierValue(*cssValue).convertTo<EColorInterpolation>();
    }
  }
  // 'auto' is the default (per Filter Effects), but since the property is
  // inherited, propagate the parent's value.
  return parentColorInterpolation;
}

ColorSpace SVGFilterBuilder::resolveColorSpace(
    EColorInterpolation colorInterpolation) {
  return colorInterpolation == CI_LINEARRGB ? ColorSpaceLinearRGB
                                            : ColorSpaceDeviceRGB;
}

void SVGFilterBuilder::buildGraph(Filter* filter,
                                  SVGFilterElement& filterElement,
                                  const FloatRect& referenceBox) {
  EColorInterpolation filterColorInterpolation =
      colorInterpolationForElement(filterElement, CI_AUTO);
  SVGUnitTypes::SVGUnitType primitiveUnits =
      filterElement.primitiveUnits()->currentValue()->enumValue();

  for (SVGElement* element = Traversal<SVGElement>::firstChild(filterElement);
       element; element = Traversal<SVGElement>::nextSibling(*element)) {
    if (!element->isFilterEffect())
      continue;

    SVGFilterPrimitiveStandardAttributes* effectElement =
        static_cast<SVGFilterPrimitiveStandardAttributes*>(element);
    FilterEffect* effect = effectElement->build(this, filter);
    if (!effect)
      continue;

    if (m_nodeMap)
      m_nodeMap->addPrimitive(effectElement->layoutObject(), effect);

    effectElement->setStandardAttributes(effect, primitiveUnits, referenceBox);
    EColorInterpolation colorInterpolation =
        colorInterpolationForElement(*effectElement, filterColorInterpolation);
    effect->setOperatingColorSpace(resolveColorSpace(colorInterpolation));
    if (effectElement->taintsOrigin(effect->inputsTaintOrigin()))
      effect->setOriginTainted();

    add(AtomicString(effectElement->result()->currentValue()->value()), effect);
  }
}

void SVGFilterBuilder::add(const AtomicString& id, FilterEffect* effect) {
  if (id.isEmpty()) {
    m_lastEffect = effect;
    return;
  }

  if (m_builtinEffects.contains(id))
    return;

  m_lastEffect = effect;
  m_namedEffects.set(id, m_lastEffect);
}

FilterEffect* SVGFilterBuilder::getEffectById(const AtomicString& id) const {
  if (!id.isEmpty()) {
    if (FilterEffect* builtinEffect = m_builtinEffects.get(id))
      return builtinEffect;

    if (FilterEffect* namedEffect = m_namedEffects.get(id))
      return namedEffect;
  }

  if (m_lastEffect)
    return m_lastEffect.get();

  return m_builtinEffects.get(FilterInputKeywords::getSourceGraphic());
}

}  // namespace blink


text:
package com.google.android.libraries.mobiledatadownload.downloader;

import static com.google.android.libraries.mobiledatadownload.internal.MddConstants.INLINE_FILE_URL_SCHEME;
import static com.google.common.base.Preconditions.checkArgument;

import android.net.Uri;
import android.util.Pair;
import com.google.auto.value.AutoValue;
import com.google.common.base.Optional;
import com.google.common.collect.ImmutableList;
import javax.annotation.concurrent.Immutable;

/** Request to download a file. */
@Immutable
@AutoValue
public abstract class DownloadRequest {

  // Default value for Traffic Tag if not set by clients.
  // MDD will not tag the traffic if the TrafficTag is not set to a valid value (>0).
  private static final int UNSPECIFIED_TRAFFIC_TAG = -1;

  DownloadRequest() {}

  /** The File Uri to download the file at. */
  public abstract Uri fileUri();

  /** The url to download the file from. */
  public abstract String urlToDownload();

  /**
   * Conditions under which this file should be downloaded.
   *
   *
These conditions relate to the type of network that should be used when downloading and must
   * be provided when performing a network download.
   *
   *
When performing in-memory downloads (using the "inlinefile" url scheme), this will not be
   * used.
   */
  public abstract DownloadConstraints downloadConstraints();

  /**
   * Traffic tag used for this request.
   *
   *
If not set, it will take the default value of UNSPECIFIED_TRAFFIC_TAG and MDD will not tag
   * the traffic.
   */
  public abstract int trafficTag();

  /** The extra HTTP headers for this request. */
  public abstract ImmutableList<Pair<String, String>> extraHttpHeaders();

  /**
   * Parameters for inline file downloads.
   *
   *
An instance of {@link InlineDownloadParams} must be included in the request to support
   * in-memory downloads (see <internal> for more info on the "inlinefile" url scheme).
   *
   *
Implementations of {@link FileDownloader} that support downloading from an inline file
   * should ensure that 1) the "inlinefile" url scheme is used and 2) an {@link
   * InlineDownloadParams} is provided.
   */
  public abstract Optional<InlineDownloadParams> inlineDownloadParamsOptional();

  public static Builder newBuilder() {
    return new AutoValue_DownloadRequest.Builder()
        .setTrafficTag(UNSPECIFIED_TRAFFIC_TAG)
        .setExtraHttpHeaders(ImmutableList.of());
  }

  /** Builder for {@link DownloadRequest}. */
  @AutoValue.Builder
  public abstract static class Builder {
    Builder() {}

    /** Sets the on-device destination uri of the file. */
    public abstract Builder setFileUri(Uri fileUri);

    /** Sets the url from where file content should be downloaded. */
    public abstract Builder setUrlToDownload(String urlToDownload);

    /**
     * Sets the network constraints that should be used for the download.
     *
     *
Only required when performing network downloads. If performing an in-memory download, this
     * is not required.
     */
    public abstract Builder setDownloadConstraints(DownloadConstraints downloadConstraints);

    /** Sets the traffic tag for this request. */
    public abstract Builder setTrafficTag(int trafficTag);

    /** Sets the extra HTTP headers for this request. */
    public abstract Builder setExtraHttpHeaders(
        ImmutableList<Pair<String, String>> extraHttpHeaders);

    /**
     * Sets the parameters for an inline file download.
     *
     *
Only required when performing an in-memory download (using an "inlinefile" url scheme). If
     * performing a network download, this is not required.
     */
    public abstract Builder setInlineDownloadParamsOptional(
        InlineDownloadParams inlineDownloadParams);

    /** Builds a {@link DownloadRequest} and checks for correct data. */
    public final DownloadRequest build() {
      // Ensure that inlinefile: requests include InlineDownloadParams
      if (urlToDownload().startsWith(INLINE_FILE_URL_SCHEME)) {
        checkArgument(
            inlineDownloadParamsOptional().isPresent(),
            "InlineDownloadParams must be set when using inlinefile: scheme");

        // inline file request doesn't require download constraints, so set to NONE.
        setDownloadConstraints(DownloadConstraints.NONE);
      }

      return autoBuild();
    }

    /** Tells AutoValue to generate an automated builder used in {@link #build} */
    abstract DownloadRequest autoBuild();

    abstract String urlToDownload();

    abstract Optional<InlineDownloadParams> inlineDownloadParamsOptional();
  }
}


text:
<resources>

    <style name="AppTheme" parent="@style/Theme.AppCompat.NoActionBar">
        <item name="colorPrimary">#3F52B6</item>
        <item name="colorPrimaryDark">#3F52B6</item>
        <item name="colorAccent">#FF4183</item>
    </style>

    <style name="ToolbarStyle" parent="Widget.AppCompat.Toolbar">
        <item name="android:background">#3F52B6</item>
        <item name="popupTheme">@style/ThemeOverlay.AppCompat.Light</item>
        <item name="theme">@style/ToolbarTheme</item>
    </style>

    <style name="ToolbarTheme" parent="ThemeOverlay.AppCompat.ActionBar">

    </style>

</resources>


text:
var colors = require('colors');
var express = require('express');
var bodyParser = require('body-parser');
var http = require('http');
var fs = require('fs');
var path = require('path');
var neo4j = require('neo4j-driver');
var jwt = require('jsonwebtoken');
var config = require('dotenv').config();
var multipart = require('connect-multiparty');

// Connect to Neo4j
exports.driver = neo4j.driver(
    "bolt://" + process.env.NEO4J_HOST + ":" + process.env.NEO4J_PORT,
    neo4j.auth.basic( process.env.NEO4J_USERNAME, process.env.NEO4J_PASSWORD),
    // { connectionTimeout: 3000 },
)

exports.driver.verifyConnectivity()
    .then(function(result) {
        console.log(colors.green(new Date() + " Neo4j is running on port " + process.env.NEO4J_PORT));
    })
    .catch(function(err) {
        console.error(colors.red(new Date() + " Neo4j could not be accessed:\n" + JSON.stringify(err)));
    });

// Load certificates
if (process.env.NODE_ENV === "production") {
    var privateKey = fs.readFileSync('ssl/server.key', 'utf8');
    var certificate = fs.readFileSync('ssl/server.crt', 'utf8');

    var credentials = {
        key: privateKey,
        cert: certificate
    };
}

// Server settings
var app = express();
app.use(bodyParser.json({
    limit: 52428800 // 50MB
}));
app.use(bodyParser.urlencoded({
    extended: false,
    limit: 52428800 // 50MB
}));

// Set folder for static files
app.use(express.static(__dirname + '/public', {
    redirect: true
}));

// Allow CORS, disable caching for API
app.use(function(req, res, next) {
    res.header("Access-Control-Allow-Origin", "*");
    res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
    res.header("Cache-Control", "no-store");
    next();
});

app.use(multipart({
    uploadDir: config.tmp
}));

// Authentication
exports.isAuthenticated = function isAuthenticated(req, res, next) {
    if (req.headers.authorization) {
        var token = req.headers.authorization.substring(7);

        // Verify token
        jwt.verify(token, process.env.JWT_SECRET, function(err, decoded) {
            if(err){
                res.status(401).send("Authentication failed!");
            } else {
                // Authorization
                if(decoded.username === process.env.ADMIN_USERNAME && decoded.iss === process.env.SERVER_URL){
                    return next();
                } else {
                    res.status(401).send("Authentication failed!");
                }
            }
        });
    } else {
        res.status(401).send("Authentication failed!");
    }
};

// API endpoint
var prefix = '/api';

// Load API routes
app.use(prefix, require('./routes/reset'));
app.use(prefix, require('./routes/login'));
app.use(prefix, require('./routes/scenarios'));
app.use(prefix, require('./routes/locations'));
app.use(prefix, require('./routes/videos'));
app.use(prefix, require('./routes/overlays'));
app.use(prefix, require('./routes/relationships'));
app.use(prefix, require('./routes/search'));
app.use(prefix, require('./routes/handlers'));

var cms = require('./routes/cms');
app.use(cms);

// Resolve path after refreshing inside app
app.get('/', function(req, res, next) {
    res.sendFile(path.resolve('public/index.html'));
});
app.get('/creator/*', function(req, res, next) {
    res.sendFile(path.resolve('public/creator/index.html'));
});
app.get('/cms/*', function(req, res, next) {
    res.sendFile(path.resolve('public/cms/index.html'));
});
app.get('/viewer/*', function(req, res, next) {
    res.sendFile(path.resolve('public/viewer/index.html'));
});
app.get('/remote/*', function(req, res, next) {
    res.sendFile(path.resolve('public/remote/index.html'));
});

// Start Webserver
var httpServer = http.createServer(app);
httpServer.listen(Number(process.env.HTTP_PORT), function() {
    console.log(colors.green(new Date() + " HTTP-Server is listening at port " + process.env.HTTP_PORT));
});
if(process.env.NODE_ENV === "production") {
    var httpsServer = https.createServer(credentials, app);
    httpsServer.listen(Number(process.env.HTTPS_PORT), function() {
        console.log(colors.green(new Date() + " HTTPS-Server is listening at port " + process.env.HTTPS_PORT));
    });
}

// Start websocket server
var io = require('socket.io')(httpServer);
exports.io = io;
require('./controllers/sockets.js').sockets;
console.log(colors.green(new Date() + " Websocket-Server is listening at port " + process.env.HTTP_PORT));


text:
package ru.appmanager;

import org.apache.http.NameValuePair;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.client.LaxRedirectStrategy;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;

import javax.swing.*;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import static java.awt.SystemColor.info;

public class HttpSession {
    private CloseableHttpClient httpclient;
    private ApplicationManager app;

    public HttpSession(ApplicationManager app){
        this.app = app;
        //создание новой сесси для работы по протоколу http. объект, который будет отправлять запросы на сервер
        httpclient = HttpClients.custom().setRedirectStrategy(new LaxRedirectStrategy()).build();
    }

    public boolean login(String username, String password) throws IOException {
        HttpPost post = new HttpPost(app.getProperty("web.baseUrl") + "/login.php"); //создание post запроса
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("username", username));
        params.add(new BasicNameValuePair("password", password));
        params.add(new BasicNameValuePair("secure_session", "on"));
        params.add(new BasicNameValuePair("return", "index.php"));
        post.setEntity(new UrlEncodedFormEntity(params)); //устанавливаем параметры запроса post
        CloseableHttpResponse response = httpclient.execute(post); //отправка запроса
        String body = getTextFrom(response); //получаем текст ответа от сервера
        return body.contains(String.format("%s",username)); //проверка, действительно ли зашел пользователь
    }

    private String getTextFrom(CloseableHttpResponse response) throws IOException {
        try{
            return EntityUtils.toString(response.getEntity());
        } finally {
            response.close();
        }

    }

    //метод для проверки, какой пользователь сейчас залогинен
    public boolean isLoggedInAs(String username) throws IOException {
        HttpGet get =  new HttpGet(app.getProperty("web.baseUrl") + "/index.php");
        CloseableHttpResponse response = httpclient.execute(get);
        String body = getTextFrom(response);
        return body.contains(String.format("%s",username));

    }
}


text:
/**
 *
 * \file libmini_event.c
 * @brief Build in default eventloop extension that uses select.
 *
 */

/*
 * Copyright (c) 2013, NLnet Labs, Verisign, Inc.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 * * Redistributions of source code must retain the above copyright
 *   notice, this list of conditions and the following disclaimer.
 * * Redistributions in binary form must reproduce the above copyright
 *   notice, this list of conditions and the following disclaimer in the
 *   documentation and/or other materials provided with the distribution.
 * * Neither the names of the copyright holders nor the
 *   names of its contributors may be used to endorse or promote products
 *   derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#include "extension/libmini_event.h"
#include "context.h"
#include "util-internal.h"
#if defined(SCHED_DEBUG) && SCHED_DEBUG
#include <inttypes.h>
#endif

static void
getdns_mini_event_cleanup(getdns_eventloop *loop)
{
	getdns_mini_event *ext = (getdns_mini_event *)loop;
	getdns_event_base_free(ext->base);
}

void
getdns_mini_event_destroy(getdns_mini_event *ext)
{
	assert(ext);
	ext->loop.vmt->cleanup(&ext->loop);
	GETDNS_FREE(ext->mf, ext);
}

void getdns_handle_timeouts(struct getdns_event_base* base,
    struct timeval* now, struct timeval* wait);
int getdns_handle_select(struct getdns_event_base* base, struct timeval* wait);

static int
getdns_mini_event_settime(getdns_mini_event *ext)
{
	if (gettimeofday(&ext->time_tv, NULL) < 0)
		return -1;
	ext->time_secs = (time_t)ext->time_tv.tv_sec;
	return 0;
}

static void
getdns_mini_event_run(getdns_eventloop *loop)
{
	getdns_mini_event *ext = (getdns_mini_event *)loop;
	struct timeval wait;

	if (ext->n_events == 0 || getdns_mini_event_settime(ext) < 0)
		return;

	do {
		(void) getdns_handle_timeouts(ext->base, &ext->time_tv, &wait);

		if (!ext->n_events)
			break;

		if (getdns_handle_select(ext->base, &wait))
			break;

	} while (ext->n_events);
}

static void
getdns_mini_event_run_once(getdns_eventloop *loop, int blocking)
{
	static struct timeval immediately = { 0, 0 };
	getdns_mini_event *ext = (getdns_mini_event *)loop;
	struct timeval wait;

	if (blocking) {
		if (getdns_mini_event_settime(ext) < 0)
			return;
		getdns_handle_timeouts(ext->base, &ext->time_tv, &wait);
		if (getdns_handle_select(ext->base, &wait) < 0)
			return;

	} else if (getdns_handle_select(ext->base, &immediately) < 0)
		return;

	getdns_handle_timeouts(ext->base, &ext->time_tv, &wait);
}

static getdns_return_t
getdns_mini_event_clear(getdns_eventloop *loop, getdns_eventloop_event *el_ev)
{
	getdns_return_t r = GETDNS_RETURN_GOOD;
	getdns_mini_event *ext = (getdns_mini_event *)loop;

	assert(el_ev->ev);
	DEBUG_SCHED("1. getdns_mini_event_clear(loop: %p, el_ev: %p[userarg: %p, r: %p, w: %p, t: %p, ev: %p]); n_events: %d, times: %d\n", loop, el_ev, el_ev->userarg, el_ev->read_cb, el_ev->write_cb, el_ev->timeout_cb, el_ev->ev, (int)ext->n_events, (int)ext->base->times->count);

	if (getdns_event_del(el_ev->ev) != 0)
		r = GETDNS_RETURN_GENERIC_ERROR;

	GETDNS_FREE(ext->mf, el_ev->ev);
	el_ev->ev = NULL;

	ext->n_events--;
	DEBUG_SCHED("2. %d <- getdns_mini_event_clear(loop: %p, el_ev: %p[userarg: %p, r: %p, w: %p, t: %p, ev: %p]); n_events: %d, times: %d\n", r, loop, el_ev, el_ev->userarg, el_ev->read_cb, el_ev->write_cb, el_ev->timeout_cb, el_ev->ev, (int)ext->n_events, (int)ext->base->times->count);

	return r;
}

static void
getdns_mini_event_callback(int fd, short bits, void *arg)
{
	getdns_eventloop_event *el_ev = (getdns_eventloop_event *)arg;
	DEBUG_SCHED("1. getdns_mini_event_callback(fd: %d, bits: %d, el_ev: %p[userarg: %p, r: %p, w: %p, t: %p, ev: %p])\n", fd, (int)bits, el_ev, el_ev->userarg, el_ev->read_cb, el_ev->write_cb, el_ev->timeout_cb, el_ev->ev);
	if (bits & EV_READ) {
		assert(el_ev->read_cb);
		el_ev->read_cb(el_ev->userarg);
	} else if (bits & EV_WRITE) {
		assert(el_ev->write_cb);
		el_ev->write_cb(el_ev->userarg);
	} else if (bits & EV_TIMEOUT) {
		assert(el_ev->timeout_cb);
		el_ev->timeout_cb(el_ev->userarg);
	} else
		assert(ASSERT_UNREACHABLE);
}

static getdns_return_t
getdns_mini_event_schedule(getdns_eventloop *loop,
    int fd, uint64_t timeout, getdns_eventloop_event *el_ev)
{
	getdns_mini_event *ext = (getdns_mini_event *)loop;
	struct getdns_event *my_ev;
	struct timeval tv = { timeout / 1000, (timeout % 1000) * 1000 };

	assert(el_ev);
	assert(!(el_ev->read_cb || el_ev->write_cb) || fd >= 0);
	assert(  el_ev->read_cb || el_ev->write_cb  || el_ev->timeout_cb);

	if (!(my_ev = GETDNS_MALLOC(ext->mf, struct getdns_event)))
		return GETDNS_RETURN_MEMORY_ERROR;

	el_ev->ev = my_ev;
	DEBUG_SCHED("1. getdns_mini_event_schedule(loop: %p, fd: %d, timeout: %"PRId64", el_ev: %p[userarg: %p, r: %p, w: %p, t: %p, ev: %p]); n_events: %d\n", loop, fd, timeout, el_ev, el_ev->userarg, el_ev->read_cb, el_ev->write_cb, el_ev->timeout_cb, el_ev->ev, (int)ext->n_events);
	getdns_event_set(my_ev, fd, (
	    (el_ev->read_cb ? EV_READ|EV_PERSIST : 0) |
	    (el_ev->write_cb ? EV_WRITE|EV_PERSIST : 0) |
	    (el_ev->timeout_cb ? EV_TIMEOUT : 0)),
	    getdns_mini_event_callback, el_ev);

	if (getdns_mini_event_settime(ext))
		goto error;

	(void) getdns_event_base_set(ext->base, my_ev);
	if (getdns_event_add(my_ev, el_ev->timeout_cb ? &tv : NULL))
		goto error;

	ext->n_events++;
	DEBUG_SCHED("2. getdns_mini_event_schedule(loop: %p, fd: %d, timeout: %"PRId64", el_ev: %p[userarg: %p, r: %p, w: %p, t: %p, ev: %p]); n_events: %d\n", loop, fd, timeout, el_ev, el_ev->userarg, el_ev->read_cb, el_ev->write_cb, el_ev->timeout_cb, el_ev->ev, (int)ext->n_events);

	return GETDNS_RETURN_GOOD;
error:
	GETDNS_FREE(ext->mf, my_ev);
	el_ev->ev = NULL;

	DEBUG_SCHED("3. getdns_mini_event_schedule(loop: %p, fd: %d, timeout: %"PRId64", el_ev: %p[userarg: %p, r: %p, w: %p, t: %p, ev: %p]); n_events: %d\n", loop, fd, timeout, el_ev, el_ev->userarg, el_ev->read_cb, el_ev->write_cb, el_ev->timeout_cb, el_ev->ev, (int)ext->n_events);
	return GETDNS_RETURN_GENERIC_ERROR;
}

getdns_return_t
getdns_mini_event_init(getdns_context *context, getdns_mini_event *ext)
{
	static getdns_eventloop_vmt getdns_mini_event_vmt = {
		getdns_mini_event_cleanup,
		getdns_mini_event_schedule,
		getdns_mini_event_clear,
		getdns_mini_event_run,
		getdns_mini_event_run_once
	};

	if (!context)
		return GETDNS_RETURN_BAD_CONTEXT;
	if (!ext)
		return GETDNS_RETURN_INVALID_PARAMETER;

	ext->n_events = 0;
	ext->loop.vmt = &getdns_mini_event_vmt;
	ext->base = getdns_event_init(&ext->time_secs, &ext->time_tv);
	if (!ext->base)
		return GETDNS_RETURN_MEMORY_ERROR;

	ext->mf = context->mf;
	return GETDNS_RETURN_GOOD;
}

getdns_return_t
getdns_mini_event_create(getdns_context *context, getdns_mini_event **ext)
{
	if (!context) return GETDNS_RETURN_BAD_CONTEXT;
	if (!ext)     return GETDNS_RETURN_INVALID_PARAMETER;

	*ext = GETDNS_MALLOC(context->mf, getdns_mini_event);
	return getdns_mini_event_init(context, *ext);
}


text:
namespace SimTKIpopt
{
  class RegisteredOptions;

  void RegisterOptions_Interfaces(const SmartPtr<RegisteredOptions>& roptions);

} // namespace Ipopt

#endif


text:
package org.mongodb.morphia.mapping.cache;

import org.mongodb.morphia.Key;

/**
 * A primarily internal class used by MorphiaIterator to track entities loaded from mongo to prevent multiple loads of objects when keys
 * are
 * seen multiple times in a query result.
 */
public interface EntityCache {
    /**
     * Looks for a Key in the cache
     *
     * @param k the Key to search for
     * @return true if the Key is found
     */
    Boolean exists(Key<?> k);

    /**
     * Clears the cache
     */
    void flush();

    /**
     * Returns the entity for a Key
     *
     * @param k   the Key to search for
     * @param <T> the type of the entity
     * @return the entity
     */
    <T> T getEntity(Key<T> k);

    /**
     * Returns a proxy for the entity for a Key
     *
     * @param k   the Key to search for
     * @param <T> the type of the entity
     * @return the proxy
     */
    <T> T getProxy(Key<T> k);

    /**
     * Notifies the cache of the existence of a Key
     *
     * @param k      the Key
     * @param exists true if the Key represents an existing entity
     */
    void notifyExists(Key<?> k, boolean exists);

    /**
     * Adds an entity to the cache
     *
     * @param k   the Key of the entity
     * @param t   the entity
     * @param <T> the type of the entity
     */
    <T> void putEntity(Key<T> k, T t);

    /**
     * Adds a proxy to the cache
     *
     * @param k   the Key of the entity
     * @param t   the proxy
     * @param <T> the type of the entity
     */
    <T> void putProxy(Key<T> k, T t);

    /**
     * @return the stats for this cache
     */
    EntityCacheStatistics stats();
}


text:
import Vector4 from "../../math/vector4";
import * as MathUtil from "../../math/util";

class Material {
  constructor(name) {
    this.name = name;

    this.castShadow = true;

    this.ambient = {
      color: (color) => { this.ambient._color = new Vector4(color.r, color.g, color.b, color.a); return this; }, _color: new Vector4(0.0, 0.0, 0.0, 0.0),
      intensity: (intensity) => { this.ambient._intensity = intensity; return this; }, _intensity: 0.0,
      occlusion: {
        map: (map) => { this.ambient.occlusion._map = map; return this; }, _map: null,
        intensity: (intensity) => { this.ambient.occlusion._intensity = MathUtil.clamp(intensity, 0.0, 2.0); return this; }, _intensity: 0.0
      }
    };

    this.diffuse = {
      color: (color) => { this.diffuse._color = new Vector4(color.r, color.g, color.b, color.a); return this; }, _color: new Vector4(0.25, 0.25, 0.25, 1.0),
      intensity: (intensity) => { this.diffuse._intensity = MathUtil.clamp(intensity, 0.0, 2.0); return this; }, _intensity: 1.0,
      map: (map) => { this.diffuse._map = map; return this; }, _map: null,
    };

    this.specular = {
      color: (color) => { this.specular._color = new Vector4(color.r, color.g, color.b, color.a); return this; }, _color: new Vector4(0.2, 0.4, 0.7, 1.0),
      intensity: (intensity) => { this.specular._intensity = MathUtil.clamp(intensity, 0.0, 2.0); return this; }, _intensity: 1.0,
      hardness: (hardness) => { this.specular._hardness = MathUtil.clamp(hardness, 0.0, 64.0); return this; }, _hardness: 1,
      map: (map) => { this.specular._map = map; return this; }, _map: null,
    };

    this.bump = {
      normal: {
        map: (map) => { this.bump.normal._map = map; return this; }, _map: null
      },
      height: {
        map: (map) => { this.bump.height._map = map; return this; }, _map: null,
        scale: (scale) => { this.specular._scale = scale; return this; }, _scale: 1.0
      }
    };

    this.environment = {
      color: (color) => { this.environment._color = new Vector4(color.r, color.g, color.b, color.a); return this; }, _color: new Vector4(0.0, 0.0, 0.0, 0.0),
      intensity: (intensity) => { this.environment._intensity = MathUtil.clamp(intensity, 0.0, 2.0); return this; }, _intensity: 0.0,
      map: (map) => { this.environment._map = map; return this; }, _map: null
    };

    this.detail = {
      color: (color) => { this.detail._color = new Vector4(color.r, color.g, color.b, color.a); return this; }, _color: new Vector4(0.0, 0.0, 0.0, 0.0),
      intensity: (intensity) => { this.detail._intensity = MathUtil.clamp(intensity, 0.0, 2.0); return this; }, _intensity: 0.0,
      map: (map) => { this.detail._map = map; return this; }, _map: null
    };

    this.glow = {
      color: (color) => { this.glow._color = new Vector4(color.r, color.g, color.b, color.a); return this; }, _color: new Vector4(0.0, 0.0, 0.0, 0.0),
      intensity: (intensity) => { this.glow._intensity = MathUtil.clamp(intensity, 0.0, 2.0); return this; }, _intensity: 0.0,
      map: (map) => { this.glow._map = map; return this; }, _map: null
    };
  }

  bind(shader) {
    let
      //s = Renderer.boundShader;
      s = shader;

    // bind vec4 props
    s.links.vec4("uAmbientColor", this.ambient._color);
    s.links.vec4("uDiffuseColor", this.diffuse._color);
    s.links.vec4("uSpecularColor", this.specular._color);
    s.links.vec4("uEnvironmentColor", this.environment._color);
    s.links.vec4("uDetailColor", this.detail._color);
    s.links.vec4("uGlowColor", this.glow._color);

    // bind packed props
    s.links.vec4("uFloatChannel[0]", new Vector4(
      this.ambient.occlusion._intensity,
      this.diffuse._intensity,
      this.specular._intensity,
      this.specular._hardness
    ));
    s.links.vec4("uFloatChannel[1]", new Vector4(
      this.bump.height._scale,
      this.environment._intensity,
      this.detail._intensity,
      this.glow._intensity
    ));

    // bind samplers
    let flags = [0,0,0,0,0,0,0,0];
    if(this.ambient.occlusion._map) {
      s.texture2D(0, this.ambient.occlusion._map); flags[0] = 1;
      s.links.sampler2D("uAmbientOcclusionMap", 0);
    }
    if(this.diffuse._map) {
      s.texture2D(1, this.diffuse._map); flags[1] = 1;
      s.links.sampler2D("uDiffuseMap", 1);
    }
    if(this.specular._map) {
      s.texture2D(2, this.specular._map); flags[2] = 1;
      s.links.sampler2D("uSpecularMap", 2);
    }
    if(this.bump.normal._map) {
      s.texture2D(3, this.bump.normal._map); flags[3] = 1;
      s.links.sampler2D("uNormalMap", 3);
    }
    if(this.bump.height._map) {
      s.texture2D(4, this.bump.height._map); flags[4] = 1;
      s.links.sampler2D("uHeightMap", 4);
    }
    if(this.environment._map) {
      s.textureCube(5, this.environment._map); flags[5] = 1;
      s.links.samplerCube("uEnvironmentMap", 5);
    }
    if(this.detail._map) {
      s.texture2D(6, this.detail._map); flags[6] = 1;
      s.links.sampler2D("uDetailMap", 6);
    }
    if(this.glow._map) {
      s.texture2D(7, this.glow._map); flags[7] = 1;
      s.links.sampler2D("uGlowMap", 7);
    }

    // bind flags
    s.links.ivec4("uIntChannel[0]", new Vector4(...flags.slice(0,4)));
    s.links.ivec4("uIntChannel[1]", new Vector4(...flags.slice(4,8)));
  }
}

export default Material;


text:
using System;

namespace StoryCLM.SDK.Content
{
    public class StoryMediafile : StorySimpleModelBase
    {
        internal StoryMediafile() { }

        public string FileName { get; set; }

        public string Title { get; set; }

        public string BlobId { get; set; }

        public int FileSize { get; set; }

        public string MIMEType { get; set; }

        public DateTime Created { get; set; }

        public DateTime Updated { get; set; }

        public string SAS { get; set; }

        public bool IsAvailableForSharing { get; set; }
    }
}


text:
package org.kie.workbench.common.dmn.backend.definition.v1_1;

import org.kie.dmn.model.api.RuleAnnotation;
import org.kie.workbench.common.dmn.api.definition.model.RuleAnnotationClauseText;
import org.kie.workbench.common.dmn.api.property.dmn.Text;

public class RuleAnnotationClauseTextConverter {

    public static RuleAnnotationClauseText wbFromDMN(final RuleAnnotation ruleAnnotation) {
        if (ruleAnnotation == null) {
            return null;
        }
        final RuleAnnotationClauseText text = new RuleAnnotationClauseText();
        text.setText(new Text(ruleAnnotation.getText()));
        return text;
    }

    public static RuleAnnotation dmnFromWB(final RuleAnnotationClauseText wb) {
        if (wb == null) {
            return null;
        }
        final RuleAnnotation ruleAnnotation = new org.kie.dmn.model.v1_2.TRuleAnnotation();
        ruleAnnotation.setText(wb.getText().getValue());
        return ruleAnnotation;
    }
}


text:
namespace ash {

class PartialScreenshotControllerTest : public test::AshTestBase {
 public:
  PartialScreenshotControllerTest() {}
  ~PartialScreenshotControllerTest() override {}

 protected:
  PartialScreenshotController* partial_screenshot_controller() {
    return Shell::GetInstance()->partial_screenshot_controller();
  }

  bool TestIfMouseWarpsAt(const gfx::Point& point_in_screen) {
    return test::DisplayManagerTestApi::TestIfMouseWarpsAt(GetEventGenerator(),
                                                           point_in_screen);
  }

  void StartPartialScreenshotSession() {
    partial_screenshot_controller()->StartPartialScreenshotSession(
        GetScreenshotDelegate());
  }

  void Cancel() { partial_screenshot_controller()->Cancel(); }

  bool IsActive() {
    return partial_screenshot_controller()->screenshot_delegate_ != nullptr;
  }

  const gfx::Point& GetStartPosition() const {
    return Shell::GetInstance()
        ->partial_screenshot_controller()
        ->start_position_;
  }

 private:
  DISALLOW_COPY_AND_ASSIGN(PartialScreenshotControllerTest);
};

TEST_F(PartialScreenshotControllerTest, BasicMouse) {
  StartPartialScreenshotSession();
  test::TestScreenshotDelegate* test_delegate = GetScreenshotDelegate();
  ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow());

  generator.MoveMouseTo(100, 100);
  generator.PressLeftButton();
  EXPECT_EQ("100,100", GetStartPosition().ToString());
  EXPECT_EQ(0, test_delegate->handle_take_partial_screenshot_count());

  generator.MoveMouseTo(200, 200);
  EXPECT_EQ(0, test_delegate->handle_take_partial_screenshot_count());

  generator.ReleaseLeftButton();
  EXPECT_EQ("100,100 100x100", GetScreenshotDelegate()->last_rect().ToString());
  EXPECT_EQ(1, GetScreenshotDelegate()->handle_take_partial_screenshot_count());

  RunAllPendingInMessageLoop();
  EXPECT_FALSE(IsActive());
}

// Starting the screenshot session while mouse is pressed, releasing the mouse
// without moving it used to cause a crash. Make sure this doesn't happen again.
// crbug.com/581432.
TEST_F(PartialScreenshotControllerTest, StartSessionWhileMousePressed) {
  ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow());
  test::TestScreenshotDelegate* test_delegate = GetScreenshotDelegate();

  generator.MoveMouseTo(100, 100);
  generator.PressLeftButton();

  // The following used to cause a crash. Now it should remain in the
  // screenshot session.
  StartPartialScreenshotSession();
  generator.ReleaseLeftButton();
  EXPECT_EQ(0, test_delegate->handle_take_partial_screenshot_count());
  EXPECT_TRUE(IsActive());

  // Pressing again, moving, and releasing should take a screenshot.
  generator.PressLeftButton();
  generator.MoveMouseTo(200, 200);
  generator.ReleaseLeftButton();
  EXPECT_EQ(1, test_delegate->handle_take_partial_screenshot_count());
  EXPECT_FALSE(IsActive());

  // Starting the screenshot session while mouse is pressed, moving the mouse
  // and releasing should take a screenshot normally.
  generator.MoveMouseTo(100, 100);
  generator.PressLeftButton();
  StartPartialScreenshotSession();
  generator.MoveMouseTo(150, 150);
  generator.MoveMouseTo(200, 200);
  EXPECT_TRUE(IsActive());
  generator.ReleaseLeftButton();
  EXPECT_EQ(2, test_delegate->handle_take_partial_screenshot_count());
  EXPECT_FALSE(IsActive());
}

TEST_F(PartialScreenshotControllerTest, JustClick) {
  StartPartialScreenshotSession();
  test::TestScreenshotDelegate* test_delegate = GetScreenshotDelegate();
  ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow());

  generator.MoveMouseTo(100, 100);

  // No moves, just clicking at the same position.
  generator.ClickLeftButton();
  EXPECT_EQ(0, test_delegate->handle_take_partial_screenshot_count());

  RunAllPendingInMessageLoop();
  EXPECT_FALSE(IsActive());
}

TEST_F(PartialScreenshotControllerTest, BasicTouch) {
  StartPartialScreenshotSession();
  test::TestScreenshotDelegate* test_delegate = GetScreenshotDelegate();
  ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow());

  generator.set_current_location(gfx::Point(100, 100));
  generator.PressTouch();
  EXPECT_EQ(0, test_delegate->handle_take_partial_screenshot_count());
  EXPECT_EQ("100,100", GetStartPosition().ToString());

  generator.MoveTouch(gfx::Point(200, 200));
  EXPECT_EQ(0, test_delegate->handle_take_partial_screenshot_count());

  generator.ReleaseTouch();
  EXPECT_EQ("100,100 100x100", GetScreenshotDelegate()->last_rect().ToString());
  EXPECT_EQ(1, GetScreenshotDelegate()->handle_take_partial_screenshot_count());

  RunAllPendingInMessageLoop();
  EXPECT_FALSE(IsActive());
}

TEST_F(PartialScreenshotControllerTest, TwoFingerTouch) {
  StartPartialScreenshotSession();
  test::TestScreenshotDelegate* test_delegate = GetScreenshotDelegate();
  ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow());

  generator.set_current_location(gfx::Point(100, 100));
  generator.PressTouch();
  EXPECT_EQ(0, test_delegate->handle_take_partial_screenshot_count());
  EXPECT_EQ("100,100", GetStartPosition().ToString());

  generator.set_current_location(gfx::Point(200, 200));
  generator.PressTouchId(1);
  EXPECT_EQ("100,100 100x100", GetScreenshotDelegate()->last_rect().ToString());
  EXPECT_EQ(1, GetScreenshotDelegate()->handle_take_partial_screenshot_count());

  RunAllPendingInMessageLoop();
  EXPECT_FALSE(IsActive());
}

TEST_F(PartialScreenshotControllerTest, MultipleDisplays) {
  if (!SupportsMultipleDisplays())
    return;

  StartPartialScreenshotSession();
  EXPECT_TRUE(IsActive());
  UpdateDisplay("400x400,500x500");
  RunAllPendingInMessageLoop();
  EXPECT_FALSE(IsActive());

  StartPartialScreenshotSession();
  EXPECT_TRUE(IsActive());
  UpdateDisplay("400x400");
  RunAllPendingInMessageLoop();
  EXPECT_FALSE(IsActive());
}

// Make sure PartialScreenshotController doesn't allow taking screenshot
// across multiple monitors
// cursor. See http://crbug.com/462229
#if defined(OS_CHROMEOS)
TEST_F(PartialScreenshotControllerTest, MouseWarpTest) {
  if (!SupportsMultipleDisplays())
    return;

  // Create two displays.
  Shell* shell = Shell::GetInstance();
  UpdateDisplay("500x500,500x500");
  EXPECT_EQ(2U, shell->display_manager()->GetNumDisplays());

  StartPartialScreenshotSession();
  EXPECT_FALSE(TestIfMouseWarpsAt(gfx::Point(499, 11)));
  EXPECT_EQ("499,11",
            aura::Env::GetInstance()->last_mouse_location().ToString());

  Cancel();
  EXPECT_TRUE(TestIfMouseWarpsAt(gfx::Point(499, 11)));
  EXPECT_EQ("501,11",
            aura::Env::GetInstance()->last_mouse_location().ToString());
}

TEST_F(PartialScreenshotControllerTest, VisibilityTest) {
  aura::client::CursorClient* client = Shell::GetInstance()->cursor_manager();

  GetEventGenerator().PressKey(ui::VKEY_A, 0);
  GetEventGenerator().ReleaseKey(ui::VKEY_A, 0);

  EXPECT_FALSE(client->IsCursorVisible());

  StartPartialScreenshotSession();
  EXPECT_TRUE(IsActive());
  EXPECT_TRUE(client->IsCursorVisible());

  Cancel();
  EXPECT_TRUE(client->IsCursorVisible());
}

// Make sure PartialScreenshotController doesn't prevent handling of large
// cursor. See http://crbug.com/459214
TEST_F(PartialScreenshotControllerTest, LargeCursor) {
  Shell::GetInstance()->cursor_manager()->SetCursorSet(ui::CURSOR_SET_LARGE);
  Shell::GetInstance()
      ->window_tree_host_manager()
      ->cursor_window_controller()
      ->SetCursorCompositingEnabled(true);

  // Large cursor is represented as cursor window.
  test::MirrorWindowTestApi test_api;
  ASSERT_NE(nullptr, test_api.GetCursorWindow());

  ui::test::EventGenerator event_generator(Shell::GetPrimaryRootWindow());
  gfx::Point cursor_location;
  event_generator.MoveMouseTo(cursor_location);
  EXPECT_EQ(cursor_location.ToString(),
            test_api.GetCursorLocation().ToString());

  StartPartialScreenshotSession();
  EXPECT_TRUE(IsActive());

  cursor_location += gfx::Vector2d(1, 1);
  event_generator.MoveMouseTo(cursor_location);
  EXPECT_EQ(cursor_location.ToString(),
            test_api.GetCursorLocation().ToString());

  event_generator.PressLeftButton();
  cursor_location += gfx::Vector2d(5, 5);
  event_generator.MoveMouseTo(cursor_location);
  EXPECT_EQ(cursor_location.ToString(),
            test_api.GetCursorLocation().ToString());

  event_generator.ReleaseLeftButton();

  EXPECT_EQ(1, GetScreenshotDelegate()->handle_take_partial_screenshot_count());
  EXPECT_EQ("1,1 5x5", GetScreenshotDelegate()->last_rect().ToString());
  RunAllPendingInMessageLoop();
  EXPECT_FALSE(IsActive());
}
#endif

}  // namespace ash


text:
package org.elasticsearch.repositories;

import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.UUIDs;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.snapshots.SnapshotId;
import org.elasticsearch.snapshots.SnapshotState;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * A class that represents the data in a repository, as captured in the
 * repository's index blob.
 */
public final class RepositoryData {

    /**
     * The generation value indicating the repository has no index generational files.
     */
    public static final long EMPTY_REPO_GEN = -1L;
    /**
     * An instance initialized for an empty repository.
     */
    public static final RepositoryData EMPTY = new RepositoryData(EMPTY_REPO_GEN,
        Collections.emptyMap(), Collections.emptyMap(), Collections.emptyMap(), Collections.emptyList());

    /**
     * The generational id of the index file from which the repository data was read.
     */
    private final long genId;
    /**
     * The ids of the snapshots in the repository.
     */
    private final Map<String, SnapshotId> snapshotIds;
    /**
     * The states of each snapshot in the repository.
     */
    private final Map<String, SnapshotState> snapshotStates;
    /**
     * The indices found in the repository across all snapshots, as a name to {@link IndexId} mapping
     */
    private final Map<String, IndexId> indices;
    /**
     * The snapshots that each index belongs to.
     */
    private final Map<IndexId, Set<SnapshotId>> indexSnapshots;
    /**
     * The snapshots that are no longer compatible with the current cluster ES version.
     */
    private final List<SnapshotId> incompatibleSnapshotIds;

    public RepositoryData(long genId,
                          Map<String, SnapshotId> snapshotIds,
                          Map<String, SnapshotState> snapshotStates,
                          Map<IndexId, Set<SnapshotId>> indexSnapshots,
                          List<SnapshotId> incompatibleSnapshotIds) {
        this.genId = genId;
        this.snapshotIds = Collections.unmodifiableMap(snapshotIds);
        this.snapshotStates = Collections.unmodifiableMap(snapshotStates);
        this.indices = Collections.unmodifiableMap(indexSnapshots.keySet().stream()
            .collect(Collectors.toMap(IndexId::getName, Function.identity())));
        this.indexSnapshots = Collections.unmodifiableMap(indexSnapshots);
        this.incompatibleSnapshotIds = Collections.unmodifiableList(incompatibleSnapshotIds);
    }

    protected RepositoryData copy() {
        return new RepositoryData(genId, snapshotIds, snapshotStates, indexSnapshots, incompatibleSnapshotIds);
    }

    /**
     * Gets the generational index file id from which this instance was read.
     */
    public long getGenId() {
        return genId;
    }

    /**
     * Returns an unmodifiable collection of the snapshot ids.
     */
    public Collection<SnapshotId> getSnapshotIds() {
        return Collections.unmodifiableCollection(snapshotIds.values());
    }

    /**
     * Returns an immutable collection of the snapshot ids in the repository that are incompatible with the
     * current ES version.
     */
    public Collection<SnapshotId> getIncompatibleSnapshotIds() {
        return incompatibleSnapshotIds;
    }

    /**
     * Returns an immutable collection of all the snapshot ids in the repository, both active and
     * incompatible snapshots.
     */
    public Collection<SnapshotId> getAllSnapshotIds() {
        List<SnapshotId> allSnapshotIds = new ArrayList<>(snapshotIds.size() + incompatibleSnapshotIds.size());
        allSnapshotIds.addAll(snapshotIds.values());
        allSnapshotIds.addAll(incompatibleSnapshotIds);
        return Collections.unmodifiableList(allSnapshotIds);
    }

    /**
     * Returns the {@link SnapshotState} for the given snapshot.  Returns {@code null} if
     * there is no state for the snapshot.
     */
    @Nullable
    public SnapshotState getSnapshotState(final SnapshotId snapshotId) {
        return snapshotStates.get(snapshotId.getUUID());
    }

    /**
     * Returns an unmodifiable map of the index names to {@link IndexId} in the repository.
     */
    public Map<String, IndexId> getIndices() {
        return indices;
    }

    /**
     * Add a snapshot and its indices to the repository; returns a new instance.  If the snapshot
     * already exists in the repository data, this method throws an IllegalArgumentException.
     */
    public RepositoryData addSnapshot(final SnapshotId snapshotId,
                                      final SnapshotState snapshotState,
                                      final List<IndexId> snapshottedIndices) {
        if (snapshotIds.containsKey(snapshotId.getUUID())) {
            // if the snapshot id already exists in the repository data, it means an old master
            // that is blocked from the cluster is trying to finalize a snapshot concurrently with
            // the new master, so we make the operation idempotent
            return this;
        }
        Map<String, SnapshotId> snapshots = new HashMap<>(snapshotIds);
        snapshots.put(snapshotId.getUUID(), snapshotId);
        Map<String, SnapshotState> newSnapshotStates = new HashMap<>(snapshotStates);
        newSnapshotStates.put(snapshotId.getUUID(), snapshotState);
        Map<IndexId, Set<SnapshotId>> allIndexSnapshots = new HashMap<>(indexSnapshots);
        for (final IndexId indexId : snapshottedIndices) {
            if (allIndexSnapshots.containsKey(indexId)) {
                Set<SnapshotId> ids = allIndexSnapshots.get(indexId);
                if (ids == null) {
                    ids = new LinkedHashSet<>();
                    allIndexSnapshots.put(indexId, ids);
                }
                ids.add(snapshotId);
            } else {
                Set<SnapshotId> ids = new LinkedHashSet<>();
                ids.add(snapshotId);
                allIndexSnapshots.put(indexId, ids);
            }
        }
        return new RepositoryData(genId, snapshots, newSnapshotStates, allIndexSnapshots, incompatibleSnapshotIds);
    }

    /**
     * Remove a snapshot and remove any indices that no longer exist in the repository due to the deletion of the snapshot.
     */
    public RepositoryData removeSnapshot(final SnapshotId snapshotId) {
        Map<String, SnapshotId> newSnapshotIds = snapshotIds.values().stream()
            .filter(id -> snapshotId.equals(id) == false)
            .collect(Collectors.toMap(SnapshotId::getUUID, Function.identity()));
        Map<String, SnapshotState> newSnapshotStates = new HashMap<>(snapshotStates);
        newSnapshotStates.remove(snapshotId.getUUID());
        Map<IndexId, Set<SnapshotId>> indexSnapshots = new HashMap<>();
        for (final IndexId indexId : indices.values()) {
            Set<SnapshotId> set;
            Set<SnapshotId> snapshotIds = this.indexSnapshots.get(indexId);
            assert snapshotIds != null;
            if (snapshotIds.contains(snapshotId)) {
                if (snapshotIds.size() == 1) {
                    // removing the snapshot will mean no more snapshots
                    // have this index, so just skip over it
                    continue;
                }
                set = new LinkedHashSet<>(snapshotIds);
                set.remove(snapshotId);
            } else {
                set = snapshotIds;
            }
            indexSnapshots.put(indexId, set);
        }

        return new RepositoryData(genId, newSnapshotIds, newSnapshotStates, indexSnapshots, incompatibleSnapshotIds);
    }

    /**
     * Returns an immutable collection of the snapshot ids for the snapshots that contain the given index.
     */
    public Set<SnapshotId> getSnapshots(final IndexId indexId) {
        Set<SnapshotId> snapshotIds = indexSnapshots.get(indexId);
        if (snapshotIds == null) {
            throw new IllegalArgumentException("unknown snapshot index " + indexId);
        }
        return snapshotIds;
    }

    /**
     * Initializes the indices in the repository metadata; returns a new instance.
     */
    public RepositoryData initIndices(final Map<IndexId, Set<SnapshotId>> indexSnapshots) {
        return new RepositoryData(genId, snapshotIds, snapshotStates, indexSnapshots, incompatibleSnapshotIds);
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null || getClass() != obj.getClass()) {
            return false;
        }
        @SuppressWarnings("unchecked") RepositoryData that = (RepositoryData) obj;
        return snapshotIds.equals(that.snapshotIds)
                   && snapshotStates.equals(that.snapshotStates)
                   && indices.equals(that.indices)
                   && indexSnapshots.equals(that.indexSnapshots)
                   && incompatibleSnapshotIds.equals(that.incompatibleSnapshotIds);
    }

    @Override
    public int hashCode() {
        return Objects.hash(snapshotIds, snapshotStates, indices, indexSnapshots, incompatibleSnapshotIds);
    }

    /**
     * Resolve the index name to the index id specific to the repository,
     * throwing an exception if the index could not be resolved.
     */
    public IndexId resolveIndexId(final String indexName) {
        if (indices.containsKey(indexName)) {
            return indices.get(indexName);
        } else {
            // on repositories created before 5.0, there was no indices information in the index
            // blob, so if the repository hasn't been updated with new snapshots, no new index blob
            // would have been written, so we only have old snapshots without the index information.
            // in this case, the index id is just the index name
            return new IndexId(indexName, indexName);
        }
    }

    /**
     * Resolve the given index names to index ids.
     */
    public List<IndexId> resolveIndices(final List<String> indices) {
        List<IndexId> resolvedIndices = new ArrayList<>(indices.size());
        for (final String indexName : indices) {
            resolvedIndices.add(resolveIndexId(indexName));
        }
        return resolvedIndices;
    }

    /**
     * Resolve the given index names to index ids, creating new index ids for
     * new indices in the repository.
     */
    public List<IndexId> resolveNewIndices(final List<String> indicesToResolve) {
        List<IndexId> snapshotIndices = new ArrayList<>();
        for (String index : indicesToResolve) {
            final IndexId indexId;
            if (indices.containsKey(index)) {
                indexId = indices.get(index);
            } else {
                indexId = new IndexId(index, UUIDs.randomBase64UUID());
            }
            snapshotIndices.add(indexId);
        }
        return snapshotIndices;
    }

    private static final String SNAPSHOTS = "snapshots";
    private static final String INCOMPATIBLE_SNAPSHOTS = "incompatible-snapshots";
    private static final String INDICES = "indices";
    private static final String INDEX_ID = "id";
    private static final String NAME = "name";
    private static final String UUID = "uuid";
    private static final String STATE = "state";

    /**
     * Writes the snapshots metadata and the related indices metadata to x-content, omitting the
     * incompatible snapshots.
     */
    public XContentBuilder snapshotsToXContent(final XContentBuilder builder, final ToXContent.Params params) throws IOException {
        builder.startObject();
        // write the snapshots list
        builder.startArray(SNAPSHOTS);
        for (final SnapshotId snapshot : getSnapshotIds()) {
            builder.startObject();
            builder.field(NAME, snapshot.getName());
            builder.field(UUID, snapshot.getUUID());
            if (snapshotStates.containsKey(snapshot.getUUID())) {
                builder.field(STATE, snapshotStates.get(snapshot.getUUID()).value());
            }
            builder.endObject();
        }
        builder.endArray();
        // write the indices map
        builder.startObject(INDICES);
        for (final IndexId indexId : getIndices().values()) {
            builder.startObject(indexId.getName());
            builder.field(INDEX_ID, indexId.getId());
            builder.startArray(SNAPSHOTS);
            Set<SnapshotId> snapshotIds = indexSnapshots.get(indexId);
            assert snapshotIds != null;
            for (final SnapshotId snapshotId : snapshotIds) {
                builder.value(snapshotId.getUUID());
            }
            builder.endArray();
            builder.endObject();
        }
        builder.endObject();
        builder.endObject();
        return builder;
    }

    /**
     * Reads an instance of {@link RepositoryData} from x-content, loading the snapshots and indices metadata.
     */
    public static RepositoryData snapshotsFromXContent(final XContentParser parser, long genId) throws IOException {
        Map<String, SnapshotId> snapshots = new HashMap<>();
        Map<String, SnapshotState> snapshotStates = new HashMap<>();
        Map<IndexId, Set<SnapshotId>> indexSnapshots = new HashMap<>();
        if (parser.nextToken() == XContentParser.Token.START_OBJECT) {
            while (parser.nextToken() == XContentParser.Token.FIELD_NAME) {
                String field = parser.currentName();
                if (SNAPSHOTS.equals(field)) {
                    if (parser.nextToken() == XContentParser.Token.START_ARRAY) {
                        while (parser.nextToken() != XContentParser.Token.END_ARRAY) {
                            final SnapshotId snapshotId;
                            // the new format from 5.0 which contains the snapshot name and uuid
                            if (parser.currentToken() == XContentParser.Token.START_OBJECT) {
                                String name = null;
                                String uuid = null;
                                SnapshotState state = null;
                                while (parser.nextToken() != XContentParser.Token.END_OBJECT) {
                                    String currentFieldName = parser.currentName();
                                    parser.nextToken();
                                    if (NAME.equals(currentFieldName)) {
                                        name = parser.text();
                                    } else if (UUID.equals(currentFieldName)) {
                                        uuid = parser.text();
                                    } else if (STATE.equals(currentFieldName)) {
                                        state = SnapshotState.fromValue(parser.numberValue().byteValue());
                                    }
                                }
                                snapshotId = new SnapshotId(name, uuid);
                                if (state != null) {
                                    snapshotStates.put(uuid, state);
                                }
                            } else {
                                // the old format pre 5.0 that only contains the snapshot name, use the name as the uuid too
                                final String name = parser.text();
                                snapshotId = new SnapshotId(name, name);
                            }
                            snapshots.put(snapshotId.getUUID(), snapshotId);
                        }
                    } else {
                        throw new ElasticsearchParseException("expected array for [" + field + "]");
                    }
                } else if (INDICES.equals(field)) {
                    if (parser.nextToken() != XContentParser.Token.START_OBJECT) {
                        throw new ElasticsearchParseException("start object expected [indices]");
                    }
                    while (parser.nextToken() != XContentParser.Token.END_OBJECT) {
                        String indexName = parser.currentName();
                        String indexId = null;
                        Set<SnapshotId> snapshotIds = new LinkedHashSet<>();
                        if (parser.nextToken() != XContentParser.Token.START_OBJECT) {
                            throw new ElasticsearchParseException("start object expected index[" + indexName + "]");
                        }
                        while (parser.nextToken() != XContentParser.Token.END_OBJECT) {
                            String indexMetaFieldName = parser.currentName();
                            parser.nextToken();
                            if (INDEX_ID.equals(indexMetaFieldName)) {
                                indexId = parser.text();
                            } else if (SNAPSHOTS.equals(indexMetaFieldName)) {
                                if (parser.currentToken() != XContentParser.Token.START_ARRAY) {
                                    throw new ElasticsearchParseException("start array expected [snapshots]");
                                }
                                while (parser.nextToken() != XContentParser.Token.END_ARRAY) {
                                    String uuid = null;
                                    // the old format pre 5.4.1 which contains the snapshot name and uuid
                                    if (parser.currentToken() == XContentParser.Token.START_OBJECT) {
                                        while (parser.nextToken() != XContentParser.Token.END_OBJECT) {
                                            String currentFieldName = parser.currentName();
                                            parser.nextToken();
                                            if (UUID.equals(currentFieldName)) {
                                                uuid = parser.text();
                                            }
                                        }
                                    } else {
                                        // the new format post 5.4.1 that only contains the snapshot uuid,
                                        // since we already have the name/uuid combo in the snapshots array
                                        uuid = parser.text();
                                    }
                                    snapshotIds.add(snapshots.get(uuid));
                                }
                            }
                        }
                        assert indexId != null;
                        indexSnapshots.put(new IndexId(indexName, indexId), snapshotIds);
                    }
                } else {
                    throw new ElasticsearchParseException("unknown field name  [" + field + "]");
                }
            }
        } else {
            throw new ElasticsearchParseException("start object expected");
        }
        return new RepositoryData(genId, snapshots, snapshotStates, indexSnapshots, Collections.emptyList());
    }

    /**
     * Writes the incompatible snapshot ids to x-content.
     */
    public XContentBuilder incompatibleSnapshotsToXContent(final XContentBuilder builder, final ToXContent.Params params)
        throws IOException {

        builder.startObject();
        // write the incompatible snapshots list
        builder.startArray(INCOMPATIBLE_SNAPSHOTS);
        for (final SnapshotId snapshot : getIncompatibleSnapshotIds()) {
            snapshot.toXContent(builder, params);
        }
        builder.endArray();
        builder.endObject();
        return builder;
    }

    /**
     * Reads the incompatible snapshot ids from x-content, loading them into a new instance of {@link RepositoryData}
     * that is created from the invoking instance, plus the incompatible snapshots that are read from x-content.
     */
    public RepositoryData incompatibleSnapshotsFromXContent(final XContentParser parser) throws IOException {
        List<SnapshotId> incompatibleSnapshotIds = new ArrayList<>();
        if (parser.nextToken() == XContentParser.Token.START_OBJECT) {
            while (parser.nextToken() == XContentParser.Token.FIELD_NAME) {
                String currentFieldName = parser.currentName();
                if (INCOMPATIBLE_SNAPSHOTS.equals(currentFieldName)) {
                    if (parser.nextToken() == XContentParser.Token.START_ARRAY) {
                        while (parser.nextToken() != XContentParser.Token.END_ARRAY) {
                            incompatibleSnapshotIds.add(SnapshotId.fromXContent(parser));
                        }
                    } else {
                        throw new ElasticsearchParseException("expected array for [" + currentFieldName + "]");
                    }
                } else {
                    throw new ElasticsearchParseException("unknown field name  [" + currentFieldName + "]");
                }
            }
        } else {
            throw new ElasticsearchParseException("start object expected");
        }
        return new RepositoryData(this.genId, this.snapshotIds, this.snapshotStates, this.indexSnapshots, incompatibleSnapshotIds);
    }

}


text:
<!doctype html>

	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

	<link rel="stylesheet" href="css/bootstrap.css">
	<link rel="stylesheet" href="css/selectize.bootstrap4.css">
	<title>Selectize Bootstrap 4</title>

	Selectize Bs4 Example
	<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">

	</button>

			<form>

                                       select 1

						<select class="form-control single-select" id="passenger">
							<option>1</option>
							<option>2</option>
							<option>3</option>
							<option>4</option>
						</select>

                                        select 2

						<select class="form-control single-select" id="baggage">
							<option>1</option>
							<option>2</option>
							<option>3</option>
							<option>4</option>
						</select>

          Form-control-sm
          <select class="form-control form-control-sm single-select" id="baggage">
							<option>1</option>
							<option>2</option>
							<option>3</option>
							<option>4</option>
						</select>

          Default
          <select class="form-control single-select" id="baggage">
							<option>1</option>
							<option>2</option>
							<option>3</option>
							<option>4</option>
						</select>

			</form>