<commit_before>(function() {
	packages = {

		// Lazily construct the package hierarchy from class starts.
		root : function(classes) {
			var map = {};

			function find(start, data) {
				var node = map[start], i;
				if (!node) {
					node = map[start] = data || {
						start : start,
						children : []
					};
					if (start.length) {
						node.parent = find(start.substring(0, i = start.lastIndexOf(".")));
						node.parent.children.push(node);
						node.key = start.substring(i + 1);
					}
				}
				return node;
			}

			classes.forEach(function(d) {
				find(d.start, d);
			});

			return map[""];
		},

		// Return a list of ends for the given array of nodes.
		ends : function(nodes) {
			var map = {}, ends = [];

			// Compute a map from start to node.
			nodes.forEach(function(d) {
				map[d.start] = d;
			});

			// For each import, construct a link from the source to target node.
			nodes.forEach(function(d) {
				if (d.ends)
					d.ends.forEach(function(i) {
						ends.push({
							source : map[d.start],
							target : map[i]
						});
					});
			});

			return ends;
		}

	};
})();

// select items
var bar_items = [];
var brush;
var brush_obj;
var axis_x_label;
var axis_x_line;
var svg ;
var grid_x;
var grid_y;
var range_y;

// select params
var svg_h = 150;
var svg_padding_left = 50;   // y-axis
var svg_padding_right = 10;
var svg_padding_top = 10;
var svg_padding_bottom = 50; // x-axis
var bar_padding = 0;
var plot_h = svg_h - svg_padding_top - svg_padding_bottom;
var dataset_length = 0;

// resize timer
var timer = false;
window.addEventListener('resize', function() {
	if (timer !== false) {
		clearTimeout(timer);
	}
	timer = setTimeout(function() {
		draw_select_resize();
	}, 200);
});

function draw_select_resize() {
	// update width
	var svg_w = parseInt(d3.select("body").style("width"), 10) - 200;
	var plot_w = svg_w - svg_padding_left - svg_padding_right;

	svg
		.style("width", svg_w + 'px')
	;

	
	if (plot_w / dataset_length > 3) {
		bar_padding = 1;
	}
	else {
		bar_padding = 0;
	}
	
	// bar// bar
	svg.selectAll("rect")
		.attr("x", function(d, i) {
			return svg_padding_left + i * plot_w / dataset_length;
		})
		.attr("width", function(d, i) {
			return plot_w / dataset_length - bar_padding;
		})
		;

	// brush
	var brush_schale = d3.scale.linear().range([ svg_padding_left, svg_padding_left + plot_w ]);

	brush_obj.remove();
	brush = d3.svg.brush()
		.x(brush_schale)
		.on("brush", function() {
			brushed(brush.extent());
		})
		;
	
	brush_obj=svg.append("g")
		.attr("class", "x brush")
		.call(brush)
		.selectAll("rect")
		.attr("y", svg_padding_top)
		.attr("height", plot_h)
		;
	
	// x-label
	axis_x_label
		.attr('transform', function(d, i)  {
			var x = svg_padding_left + (i * plot_w) / dataset_length + (plot_w / dataset_length / 2);
			var y = svg_padding_top + plot_h + 5;
	    	return 'translate(' + x + ', ' + y + ') rotate(-90)';
	    })
		;
	axis_x_line
		.attr("x2", svg_padding_left + plot_w)
		;

	// grid
	grid_y.remove();
	grid_x.remove();
	
	var range_x = d3.range(svg_padding_left, svg_padding_left + plot_w, plot_w / dataset_length * 20);

	grid_y = svg.selectAll("line.y")
		.data(range_y)
		.enter()
		.append("line")
		.attr("x1", svg_padding_left).attr("y1", function(d,i){return d; })
		.attr("x2", svg_padding_left + plot_w).attr("y2", function(d,i){return d ;})

	grid_x = svg.selectAll("line.x")
		.data(range_x)
		.enter()
		.append("line")
		.attr("x1", function(d,i){return d;}).attr("y1", svg_padding_top)
		.attr("x2", function(d,i){return d;}).attr("y2", svg_padding_top + plot_h);
	
	svg.selectAll("line")
		.attr("stroke", "lightgray")
		.attr("shape-rendering", "crispEdges")
		.style("stroke-opacity", 0.5);
	
}

function draw_select()
{
	var svg_w = parseInt(d3.select("body").style("width"), 10) - 200;
	var plot_w = svg_w - svg_padding_left - svg_padding_right;

	var selects = bundle_data_sv.get_select();
	var dataset = [];
	var max = 0;
	bar_items = [];
	for (var i = 0; i < selects.length; i++) {
		dataset.push(selects[i].value);
		if (max < selects[i].value) {
			max = selects[i].value;
		}
		// start, end, items
		var w = 1 / selects.length;
		var start = i * w;
		var end = start + w;
		bar_items.push([start, end, selects[i].item])
		
	}
	svg = d3.select("#selector")
		.append("svg")
		.attr("width", svg_w)
		.attr("height", svg_h);
	

	if (plot_w / dataset.length > 3) {
		bar_padding = 1;
	}
	else {
		bar_padding = 0;
	}
	dataset_length = dataset.length;


	
	// bar
	svg.selectAll("rect")
		.data(dataset)
		.enter()
		.append("rect")
		.attr("x", function(d, i) {
			return svg_padding_left + i * (plot_w / dataset.length);
		})
		.attr("y", function(d) {
			return svg_padding_top + plot_h - (d * plot_h / max);
		})
		.attr("width", plot_w / dataset.length - bar_padding)
		.attr("height", function(d) {
			return (d * plot_h / max);
		})
		.style("fill", style_sv_thumb.bar_select_color)
/*		.on("mouseover", function(d, i) {
			// remove last tooltip data
			d3.select("#tooltip").selectAll("p#text").remove();
			
			// add text to tooltip
			d3.select("#tooltip").append("p").attr("id",  "text").text("items");
			d3.select("#tooltip").append("p").attr("id",  "text").text(d + ";" + selects[i].key + ";" + list_to_string(selects[i].item));
		
			//Show the tooltip
			d3.select("#tooltip").classed("hidden", false);
			
			//Get this bar's x/y values, then argument for the tooltip
			var rect = document.getElementById("selector").getBoundingClientRect();
			var xPosition = parseFloat(rect.left) + window.pageXOffset + 10;
			var yPosition = parseFloat(rect.top) + window.pageYOffset + 10;

			//Update the tooltip position and value
			d3.select("#tooltip")
				.style("left", xPosition + "px")
				.style("top", yPosition + "px")
			;
	   })
	   .on("mouseout", function() {
			//Hide the tooltip
			d3.select("#tooltip").classed("hidden", true);
		})*/
		;
	
	// brush
	var brush_schale = d3.scale.linear().range([ svg_padding_left, svg_padding_left + plot_w ]);
	brush = d3.svg.brush()
		.x(brush_schale)
		.on("brush", function() {
			brushed(brush.extent());
		})
		;
	
	brush_obj=svg.append("g")
		.attr("class", "x brush")
		.call(brush)
		.selectAll("rect")
		.attr("y", svg_padding_top)
		.attr("height", plot_h)
		;
	
	// x-label
	axis_x_label = svg.selectAll("text")
		.data(dataset)
		.enter()
		.append("text")
		.text(function(d, i) {
			var unit = Math.pow(10,(String(bundle_data_sv.node_size).length -1));
			var pos = Math.floor(Number(selects[i].key.substr(-4)) * bundle_data_sv.node_size / unit);
			if (selects[i].key.substr(-4) == "0000") {
				var chrs = key_to_values(style_sv_detail.arc_label_text, selects[i].key.substr(5, 2));
				//return "chr" + chrs + ":" + pos;
				return "chr" + chrs;
			}
			//if (selects[i].key.substr(-1) == "9") {
			//	var chrs = key_to_values(style_sv_detail.arc_label_text, selects[i].key.substr(5, 2));
			//	return pos;
			//}
			return "";
		})
		.attr("text-anchor", "end")
		.attr('transform', function(d, i)  {
			var x = svg_padding_left + (i * plot_w) / dataset.length + (plot_w / dataset.length / 2);
			var y = svg_padding_top + plot_h + 5;
	    	return 'translate(' + x + ', ' + y + ') rotate(-90)';
	    })
		.attr("font-family", "sans-serif")
		.attr("font-size", "10px")
	;
	axis_x_line = svg.append("line")
		.attr("x1", svg_padding_left)
		.attr("y1", svg_padding_top + plot_h + 3)
		.attr("x2", svg_padding_left + plot_w)
		.attr("y2", svg_padding_top + plot_h + 3)
		.attr("class", "axis")
		;

	// y-axis
	var y_scale = d3.scale.linear()
	.domain([0, max])   // original
	.range([plot_h, 0]) // target
	;
	
	svg.append("g")
	.attr("class", "axis")
	.attr("transform", "translate(" + (svg_padding_left-3) + ", " + (svg_padding_top) + ")")
	.call(
		d3.svg.axis()
		.scale(y_scale)
		.orient("left")
		.ticks(2)
//		.tickValues([1,3,5,7,9])
//		.tickFormat(d3.format("d"))
	)
	;
	
	// grid
	var range_x = d3.range(svg_padding_left, svg_padding_left + plot_w, plot_w / dataset.length * 20);
	range_y = d3.range(svg_padding_top, svg_padding_top + plot_h, plot_h / max * max/2);

	grid_y = svg.selectAll("line.y")
		.data(range_y)
		.enter()
		.append("line")
		.attr("x1", svg_padding_left).attr("y1", function(d,i){return d; })
		.attr("x2", svg_padding_left + plot_w).attr("y2", function(d,i){return d ;})

	grid_x = svg.selectAll("line.x")
		.data(range_x)
		.enter()
		.append("line")
		.attr("x1", function(d,i){return d;}).attr("y1", svg_padding_top)
		.attr("x2", function(d,i){return d;}).attr("y2", svg_padding_top + plot_h);

	svg.selectAll("line")
		.attr("stroke", "lightgray")
		.attr("shape-rendering", "crispEdges")
		.style("stroke-opacity", 0.5);

}

function brushed(data) {
	
	if ((data[0] < 0) ||  (data[1] < 0)) {
		thumb_select_clear();
		return;
	}
	
	var hide = false;
	if (d3.select('input[name="q2"]:checked')[0][0].value == "hide") {
		hide = true;
	}
	// data is range [0,1]
	// to item
	
	// search selected item
	var match = []
	for (var i=0 ; i < bar_items.length; i++) {
		if (bar_items[i][1] < data[0]) {continue;}
		if (bar_items[i][0] > data[1]) {continue;}
		
		for (var j=0; j < bar_items[i][2].length; j++) {
			match.push(bar_items[i][2][j]);
		}
	}
	
	// remove duplicate
	var sort = match.filter(function (x, i, self) {
              return self.indexOf(x) === i;
        });

	// ID to index
	for (var j=0; j<bundle_data_sv.index_ID.length; j++) {
		var find = false;
		for (var i=0 ; i < sort.length; i++) {
			if (bundle_data_sv.index_ID[j] == sort[i]) {
				find = true;
				break;
			}
		}
		
		// view
		if (find == true) {<commit_msg>temporary<commit_after>(function() {
	packages = {

		// Lazily construct the package hierarchy from class starts.
		root : function(classes) {
			var map = {};

			function find(start, data) {
				var node = map[start], i;
				if (!node) {
					node = map[start] = data || {
						start : start,
						children : []
					};
					if (start.length) {
						node.parent = find(start.substring(0, i = start.lastIndexOf(".")));
						node.parent.children.push(node);
						node.key = start.substring(i + 1);
					}
				}
				return node;
			}

			classes.forEach(function(d) {
				find(d.start, d);
			});

			return map[""];
		},

		// Return a list of ends for the given array of nodes.
		ends : function(nodes) {
			var map = {}, ends = [];

			// Compute a map from start to node.
			nodes.forEach(function(d) {
				map[d.start] = d;
			});

			// For each import, construct a link from the source to target node.
			nodes.forEach(function(d) {
				if (d.ends)
					d.ends.forEach(function(i) {
						ends.push({
							source : map[d.start],
							target : map[i]
						});
					});
			});

			return ends;
		}

	};
})();

// select items
var bar_items = [];
var brush;
var brush_obj;
var axis_x_label;
var axis_x_line;
var svg ;
var grid_x;
var grid_y;
var range_y;

// select params
var svg_h = 150;
var svg_padding_left = 50;   // y-axis
var svg_padding_right = 10;
var svg_padding_top = 10;
var svg_padding_bottom = 50; // x-axis
var bar_padding = 0;
var plot_h = svg_h - svg_padding_top - svg_padding_bottom;
var dataset_length = 0;

// resize timer
var timer = false;
window.addEventListener('resize', function() {
	if (timer !== false) {
		clearTimeout(timer);
	}
	timer = setTimeout(function() {
		draw_select_resize();
	}, 200);
});

function draw_select_resize() {
	// update width
	var svg_w = parseInt(d3.select("body").style("width"), 10) - 200;
	var plot_w = svg_w - svg_padding_left - svg_padding_right;

	svg
		.style("width", svg_w + 'px')
	;

	
	if (plot_w / dataset_length > 3) {
		bar_padding = 1;
	}
	else {
		bar_padding = 0;
	}
	
	// bar// bar
	svg.selectAll("rect")
		.attr("x", function(d, i) {
			return svg_padding_left + i * plot_w / dataset_length;
		})
		.attr("width", function(d, i) {
			return plot_w / dataset_length - bar_padding;
		})
		;

	// brush
	var brush_schale = d3.scale.linear().range([ svg_padding_left, svg_padding_left + plot_w ]);

	brush_obj.remove();
	brush = d3.svg.brush()
		.x(brush_schale)
		.on("brush", function() {
			brushed(brush.extent());
		})
		;
	
	brush_obj=svg.append("g")
		.attr("class", "x brush")
		.call(brush)
		.selectAll("rect")
		.attr("y", svg_padding_top)
		.attr("height", plot_h)
		;
	
	// x-label
	axis_x_label
		.attr('transform', function(d, i)  {
			var x = svg_padding_left + (i * plot_w) / dataset_length + (plot_w / dataset_length / 2);
			var y = svg_padding_top + plot_h + 5;
	    	return 'translate(' + x + ', ' + y + ') rotate(-90)';
	    })
		;
	axis_x_line
		.attr("x2", svg_padding_left + plot_w)
		;

	// grid
	grid_y.remove();
	grid_x.remove();
	
	var range_x = d3.range(svg_padding_left, svg_padding_left + plot_w, plot_w / dataset_length * 20);

	grid_y = svg.selectAll("line.y")
		.data(range_y)
		.enter()
		.append("line")
		.attr("x1", svg_padding_left).attr("y1", function(d,i){return d; })
		.attr("x2", svg_padding_left + plot_w).attr("y2", function(d,i){return d ;})

	grid_x = svg.selectAll("line.x")
		.data(range_x)
		.enter()
		.append("line")
		.attr("x1", function(d,i){return d;}).attr("y1", svg_padding_top)
		.attr("x2", function(d,i){return d;}).attr("y2", svg_padding_top + plot_h);
	
	svg.selectAll("line")
		.attr("stroke", "lightgray")
		.attr("shape-rendering", "crispEdges")
		.style("stroke-opacity", 0.5);
	
}

function draw_select()
{
	var svg_w = parseInt(d3.select("body").style("width"), 10) - 200;
	var plot_w = svg_w - svg_padding_left - svg_padding_right;

	var selects = bundle_data_sv.get_select();
	var dataset = [];
	var max = 0;
	bar_items = [];
	for (var i = 0; i < selects.length; i++) {
		dataset.push(selects[i].value);
		if (max < selects[i].value) {
			max = selects[i].value;
		}
		// start, end, items
		var w = 1 / selects.length;
		var start = i * w;
		var end = start + w;
		bar_items.push([start, end, selects[i].item])
		
	}
	svg = d3.select("#selector")
		.append("svg")
		.attr("width", svg_w)
		.attr("height", svg_h);
	

	if (plot_w / dataset.length > 3) {
		bar_padding = 1;
	}
	else {
		bar_padding = 0;
	}
	dataset_length = dataset.length;


	
	// bar
	svg.selectAll("rect")
		.data(dataset)
		.enter()
		.append("rect")
		.attr("x", function(d, i) {
			return svg_padding_left + i * (plot_w / dataset.length);
		})
		.attr("y", function(d) {
			return svg_padding_top + plot_h - (d * plot_h / max);
		})
		.attr("width", plot_w / dataset.length - bar_padding)
		.attr("height", function(d) {
			return (d * plot_h / max);
		})
		.style("fill", style_sv_thumb.bar_select_color)
/*		.on("mouseover", function(d, i) {
			// remove last tooltip data
			d3.select("#tooltip").selectAll("p#text").remove();
			
			// add text to tooltip
			d3.select("#tooltip").append("p").attr("id",  "text").text("items");
			d3.select("#tooltip").append("p").attr("id",  "text").text(d + ";" + selects[i].key + ";" + list_to_string(selects[i].item));
		
			//Show the tooltip
			d3.select("#tooltip").classed("hidden", false);
			
			//Get this bar's x/y values, then argument for the tooltip
			var rect = document.getElementById("selector").getBoundingClientRect();
			var xPosition = parseFloat(rect.left) + window.pageXOffset + 10;
			var yPosition = parseFloat(rect.top) + window.pageYOffset + 10;

			//Update the tooltip position and value
			d3.select("#tooltip")
				.style("left", xPosition + "px")
				.style("top", yPosition + "px")
			;
	   })
	   .on("mouseout", function() {
			//Hide the tooltip
			d3.select("#tooltip").classed("hidden", true);
		})*/
		;
	
	// brush
	var brush_schale = d3.scale.linear().range([ svg_padding_left, svg_padding_left + plot_w ]);
	brush = d3.svg.brush()
		.x(brush_schale)
		.on("brush", function() {
			brushed(brush.extent());
		})
		;
	
	brush_obj=svg.append("g")
		.attr("class", "x brush")
		.call(brush)
		.selectAll("rect")
		.attr("y", svg_padding_top)
		.attr("height", plot_h)
		;
	
	// x-label
	axis_x_label = svg.selectAll("text")
		.data(dataset)
		.enter()
		.append("text")
		.text(function(d, i) {
			var unit = Math.pow(10,(String(bundle_data_sv.node_size).length -1));
			var pos = Math.floor(Number(selects[i].key.substr(-4)) * bundle_data_sv.node_size / unit);
			if (selects[i].key.substr(-4) == "0000") {
				var chrs = key_to_values(style_sv_detail.arc_label_text, selects[i].key.substr(5, 2));
				//return "chr" + chrs + ":" + pos;
				return "chr" + chrs;
			}
			//if (selects[i].key.substr(-1) == "9") {
			//	var chrs = key_to_values(style_sv_detail.arc_label_text, selects[i].key.substr(5, 2));
			//	return pos;
			//}
			return "";
		})
		.attr("text-anchor", "end")
		.attr('transform', function(d, i)  {
			var x = svg_padding_left + (i * plot_w) / dataset.length + (plot_w / dataset.length / 2);
			var y = svg_padding_top + plot_h + 5;
	    	return 'translate(' + x + ', ' + y + ') rotate(-90)';
	    })
		.attr("font-family", "sans-serif")
		.attr("font-size", "10px")
	;
	axis_x_line = svg.append("line")
		.attr("x1", svg_padding_left)
		.attr("y1", svg_padding_top + plot_h + 3)
		.attr("x2", svg_padding_left + plot_w)
		.attr("y2", svg_padding_top + plot_h + 3)
		.attr("class", "axis")
		;

	// y-axis
	var y_scale = d3.scale.linear()
	.domain([0, max])   // original
	.range([plot_h, 0]) // target
	;
	
	svg.append("g")
	.attr("class", "axis")
	.attr("transform", "translate(" + (svg_padding_left-3) + ", " + (svg_padding_top) + ")")
	.call(
		d3.svg.axis()
		.scale(y_scale)
		.orient("left")
		.ticks(2)
//		.tickValues([1,3,5,7,9])
//		.tickFormat(d3.format("d"))
	)
	;
	
	// grid
	var range_x = d3.range(svg_padding_left, svg_padding_left + plot_w, plot_w / dataset.length * 20);
	range_y = d3.range(svg_padding_top, svg_padding_top + plot_h, plot_h / max * max/2);

	grid_y = svg.selectAll("line.y")
		.data(range_y)
		.enter()
		.append("line")
		.attr("x1", svg_padding_left).attr("y1", function(d,i){return d; })
		.attr("x2", svg_padding_left + plot_w).attr("y2", function(d,i){return d ;})

	grid_x = svg.selectAll("line.x")
		.data(range_x)
		.enter()
		.append("line")
		.attr("x1", function(d,i){return d;}).attr("y1", svg_padding_top)
		.attr("x2", function(d,i){return d;}).attr("y2", svg_padding_top + plot_h);

	svg.selectAll("line")
		.attr("stroke", "lightgray")
		.attr("shape-rendering", "crispEdges")
		.style("stroke-opacity", 0.5);

}

function brushed(data) {
	
	if ((data[0] < 0) ||  (data[1] < 0)) {
		thumb_select_clear();
		return;
	}
	
	var hide = false;
//	if (d3.select('input[name="q2"]:checked')[0][0].value == "hide") {
//		hide = true;
//	}
	// data is range [0,1]
	// to item
	
	// search selected item
	var match = []
	for (var i=0 ; i < bar_items.length; i++) {
		if (bar_items[i][1] < data[0]) {continue;}
		if (bar_items[i][0] > data[1]) {continue;}
		
		for (var j=0; j < bar_items[i][2].length; j++) {
			match.push(bar_items[i][2][j]);
		}
	}
	
	// remove duplicate
	var sort = match.filter(function (x, i, self) {
              return self.indexOf(x) === i;
        });

	// ID to index
	for (var j=0; j<bundle_data_sv.index_ID.length; j++) {
		var find = false;
		for (var i=0 ; i < sort.length; i++) {
			if (bundle_data_sv.index_ID[j] == sort[i]) {
				find = true;
				break;
			}
		}
		
		// view
		if (find == true) {
{'fraction_non_alphanumeric': 0.1935618293572247, 'fraction_numerical': 0.015209917699760392, 'mean_word_length': 3.220488019344911, 'pattern_counts': {'":': 2, '<': 21, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7281328', 'n_tokens_mistral': 8617, 'n_tokens_neox': 7589, 'n_words': 1490}