<commit_before>/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

// VERSION 3.0.17

this.mainSidebar = {
	main: true,
	twin: false,
	_loaded: false,
	get loaded () { return this._loaded; },
	set loaded (v) {
		this._loaded = v;
		dispatch(this.box, { type: 'LoadedSidebar', cancelable: false, detail: v });
		return v;
	},
	autoHideInit: false,
	initialShowings: new Set(),
	contentFocused: false,
	get command () { return this.box && this.box.getAttribute('sidebarcommand'); },
	set command (v) { return setAttribute(this.box, 'sidebarcommand', v); },
	get isSocial () { return isSocial && !this.box || this.box.getAttribute('origin') || (typeof(Social) != 'undefined' && isAncestor(Social.browser, this.box)); },
	get isOpen () {
		if(this.isSocial) { return true; }

		if(!this.command
		|| !$(this.command)
		|| $(this.command).localName != 'broadcaster'
		|| $(this.command).getAttribute('sidebarurl') != this.box.getAttribute('src')
		|| this.box.getAttribute('src') != this.sidebar.getAttribute('src')) {
			return false;
		}
		return true;
	},
	get focused () {
		return	this.sidebar && this.sidebar.contentWindow
			&& (document.commandDispatcher.focusedWindow == this.sidebar.contentWindow.content || document.commandDispatcher.focusedWindow == this.sidebar.contentWindow);
	},
	get closed () { return !this.box || this.box.hidden || this.box.collapsed; },
	get label () { return Strings.get('buttons', (Prefs.twinSidebar) ? 'buttonMainLabel' : 'buttonlabel'); },
	get splitter () { return $('sidebar-splitter'); },
	get header () { return $('sidebar-header'); },
	get box () { return $('sidebar-box'); },
	get resizeBox () { return $(objName+'-resizebox'); },
	get resizer () { return $(objName+'-resizer'); },
	get sidebar () { return $('sidebar'); },
	get titleNode () { return $('sidebar-title'); },
	get title () { return this.titleNode.value; },
	// both .value and setAttribute to fix a bug where the title wouldn't show sometimes when starting firefox with the sidebar closed
	set title (v) { this.titleNode.value = v; setAttribute(this.titleNode, 'value', v); return v; },
	get titleButton () { return Prefs.showheadertitle && Prefs.titleButton; },
	get docker () { return $(objName+'-dock_button'); },
	toolbarId: objName+'-Toolbar',
	get toolbar () { return $(this.toolbarId); },
	get stack () { return $(objName+'-stackSidebar'); },
	buttonId: objName+'-button',
	get button () { return $(this.buttonId); },
	get close () { return this.header ? $$('toolbarbutton.close-icon', this.header)[0] : null; },
	get width () {
		if(this.box) {
			let width = this.box.getAttribute('width');
			if(!width || width == '0' || width == 'NaN') {
				width = (!width) ? 300 : Math.max(this.box.boxObject.width, Prefs.minSidebarWidth) || 300;
				this.box.setAttribute('width', width);
				document.persist(this.box.id, 'width');
			}
			return parseInt(width);
		}
		return null;
	},
	reUnload: function() {
		if(this.box.collapsed) {
			SidebarUI.close(this);
		}
	},
	_state: null,
	get state () {
		if(!this._state) {
			this.noPersist();

			var data = SessionStore.getWindowValue(window, objName+'.mainSidebar');

			// if this window doesn't have it's own state, use the state from the opener
			if(!data && window.opener && !window.opener.closed
			&& (!PrivateBrowsing.isPrivate(window) == PrivateBrowsing.isPrivate(window.opener) || Prefs.keepPrivate)) {
				data = SessionStore.getWindowValue(window.opener, objName+'.mainSidebar');
			}

			// fallback to a global pref value so the sidebar is rarely reset when it's not supposed to
			if(!data && (!PrivateBrowsing.inPrivateBrowsing || Prefs.keepPrivate)) {
				data = Prefs.lastStateMain;
			}

			if(data) {
				this._state = JSON.parse(data);
			} else {
				this._state = {
					command: objName+"-viewBlankSidebar",
					closed: true
				};
				this.saveState();
			}
		}

		return this._state;
	},
	set state (v) {
		this._state.command = v;
		this._state.closed = this.closed;
		this.saveState();
	},
	stateForceClosed: function(v) {
		this.state;
		this._state.closed = v;
		this.saveState();
	},
	stateForceCommand: function(v) {
		this.state;
		this._state.command = v;
		this.saveState();
	},
	saveState: function() {
		var stringified = JSON.stringify(this._state);
		if(!PrivateBrowsing.inPrivateBrowsing || Prefs.keepPrivate) {
			Prefs.lastStateMain = stringified;
		}
		return SessionStore.setWindowValue(window, objName+'.mainSidebar', stringified);
	},
	stateReset: function() {
		this._state = null;
		if(!PrivateBrowsing.inPrivateBrowsing || Prefs.keepPrivate) {
			Prefs.reset('lastStateMain');
		}
		SessionStore.deleteWindowValue(window, objName+'.mainSidebar');
	},
	noPersist: function() {
		// the native SidebarUI persists the attributes of sidebar-box,
		// which can cause the sidebar to open after restarting firefox when it's not supposed to
		if(Services.xulStore.hasValue(document.documentURI, 'sidebar-box', 'src')) {
			Services.xulStore.removeValue(document.documentURI, 'sidebar-box', 'src');
		}
		if(Services.xulStore.hasValue(document.documentURI, 'sidebar-box', 'sidebarcommand')) {
			Services.xulStore.removeValue(document.documentURI, 'sidebar-box', 'sidebarcommand');
		}
	},
	get keyset () { return mainKey; },
	get keysetPanel () { return Prefs.mainKeysetPanel; },
	get above () { return Prefs.renderabove; },
	get autoHide () { return Prefs.autoHide; },
	get autoClose () { return Prefs.autoClose; },
	get useSwitch () { return Prefs.useSwitch; },
	needSwitch: new Set(),
	get isSwitchNeeded () {
		return (this.needSwitch.size > 0);
	},
	get switcher () { return $(objName+'-switch'); },
	toggleSwitcher: function() {
		if(!this.switcher) { return; }
		this.switcher.collapsed = !(this.useSwitch || (this.above && this.autoHide && !this.closed) || this.isSwitchNeeded);
	},
	get goURI () { return $(objName+'-viewURISidebar'); },
	get goURIButton () { return $(objName+'-uri_sidebar_button'); }
};

this.twinSidebar = {
	main: false,
	twin: true,
	_loaded: false,
	get loaded () { return this._loaded; },
	set loaded (v) {
		this._loaded = v;
		dispatch(this.box, { type: 'LoadedSidebar', cancelable: false, detail: v });
		return v;
	},
	autoHideInit: false,
	initialShowings: new Set(),
	contentFocused: false,
	get command () { return this.box && this.box.getAttribute('sidebarcommand'); },
	set command (v) { return setAttribute(this.box, 'sidebarcommand', v); },
	get isSocial () { return isSocial && !this.box || this.box.getAttribute('origin') || (typeof(Social) != 'undefined' && isAncestor(Social.browser, this.box)); },
	get isOpen () {
		if(this.isSocial) { return true; }

		if(!this.command
		|| !$(this.command)
		|| $(this.command).localName != 'broadcaster'
		|| $(this.command).getAttribute('sidebarurl') != this.box.getAttribute('src')
		|| this.box.getAttribute('src') != this.sidebar.getAttribute('src')) {
			return false;
		}
		return true;
	},
	get focused () {
		return	this.sidebar && this.sidebar.contentWindow
			&& (document.commandDispatcher.focusedWindow == this.sidebar.contentWindow.content || document.commandDispatcher.focusedWindow == this.sidebar.contentWindow);
	},
	get closed () { return !this.box || this.box.hidden || this.box.collapsed; },
	get label () { return Strings.get('buttons', 'buttonTwinLabel'); },
	get splitter () { return $(objName+'-sidebar-splitter-twin'); },<commit_msg>#137 small fix for previous commit<commit_after>/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

// VERSION 3.0.18

this.mainSidebar = {
	main: true,
	twin: false,
	_loaded: false,
	get loaded () { return this._loaded; },
	set loaded (v) {
		this._loaded = v;
		dispatch(this.box, { type: 'LoadedSidebar', cancelable: false, detail: v });
		return v;
	},
	autoHideInit: false,
	initialShowings: new Set(),
	contentFocused: false,
	get command () { return this.box && this.box.getAttribute('sidebarcommand'); },
	set command (v) { return setAttribute(this.box, 'sidebarcommand', v); },
	get isSocial () { return isSocial && (!this.box || this.box.getAttribute('origin') || (typeof(Social) != 'undefined' && isAncestor(Social.browser, this.box))); },
	get isOpen () {
		if(this.isSocial) { return true; }

		if(!this.command
		|| !$(this.command)
		|| $(this.command).localName != 'broadcaster'
		|| $(this.command).getAttribute('sidebarurl') != this.box.getAttribute('src')
		|| this.box.getAttribute('src') != this.sidebar.getAttribute('src')) {
			return false;
		}
		return true;
	},
	get focused () {
		return	this.sidebar && this.sidebar.contentWindow
			&& (document.commandDispatcher.focusedWindow == this.sidebar.contentWindow.content || document.commandDispatcher.focusedWindow == this.sidebar.contentWindow);
	},
	get closed () { return !this.box || this.box.hidden || this.box.collapsed; },
	get label () { return Strings.get('buttons', (Prefs.twinSidebar) ? 'buttonMainLabel' : 'buttonlabel'); },
	get splitter () { return $('sidebar-splitter'); },
	get header () { return $('sidebar-header'); },
	get box () { return $('sidebar-box'); },
	get resizeBox () { return $(objName+'-resizebox'); },
	get resizer () { return $(objName+'-resizer'); },
	get sidebar () { return $('sidebar'); },
	get titleNode () { return $('sidebar-title'); },
	get title () { return this.titleNode.value; },
	// both .value and setAttribute to fix a bug where the title wouldn't show sometimes when starting firefox with the sidebar closed
	set title (v) { this.titleNode.value = v; setAttribute(this.titleNode, 'value', v); return v; },
	get titleButton () { return Prefs.showheadertitle && Prefs.titleButton; },
	get docker () { return $(objName+'-dock_button'); },
	toolbarId: objName+'-Toolbar',
	get toolbar () { return $(this.toolbarId); },
	get stack () { return $(objName+'-stackSidebar'); },
	buttonId: objName+'-button',
	get button () { return $(this.buttonId); },
	get close () { return this.header ? $$('toolbarbutton.close-icon', this.header)[0] : null; },
	get width () {
		if(this.box) {
			let width = this.box.getAttribute('width');
			if(!width || width == '0' || width == 'NaN') {
				width = (!width) ? 300 : Math.max(this.box.boxObject.width, Prefs.minSidebarWidth) || 300;
				this.box.setAttribute('width', width);
				document.persist(this.box.id, 'width');
			}
			return parseInt(width);
		}
		return null;
	},
	reUnload: function() {
		if(this.box.collapsed) {
			SidebarUI.close(this);
		}
	},
	_state: null,
	get state () {
		if(!this._state) {
			this.noPersist();

			var data = SessionStore.getWindowValue(window, objName+'.mainSidebar');

			// if this window doesn't have it's own state, use the state from the opener
			if(!data && window.opener && !window.opener.closed
			&& (!PrivateBrowsing.isPrivate(window) == PrivateBrowsing.isPrivate(window.opener) || Prefs.keepPrivate)) {
				data = SessionStore.getWindowValue(window.opener, objName+'.mainSidebar');
			}

			// fallback to a global pref value so the sidebar is rarely reset when it's not supposed to
			if(!data && (!PrivateBrowsing.inPrivateBrowsing || Prefs.keepPrivate)) {
				data = Prefs.lastStateMain;
			}

			if(data) {
				this._state = JSON.parse(data);
			} else {
				this._state = {
					command: objName+"-viewBlankSidebar",
					closed: true
				};
				this.saveState();
			}
		}

		return this._state;
	},
	set state (v) {
		this._state.command = v;
		this._state.closed = this.closed;
		this.saveState();
	},
	stateForceClosed: function(v) {
		this.state;
		this._state.closed = v;
		this.saveState();
	},
	stateForceCommand: function(v) {
		this.state;
		this._state.command = v;
		this.saveState();
	},
	saveState: function() {
		var stringified = JSON.stringify(this._state);
		if(!PrivateBrowsing.inPrivateBrowsing || Prefs.keepPrivate) {
			Prefs.lastStateMain = stringified;
		}
		return SessionStore.setWindowValue(window, objName+'.mainSidebar', stringified);
	},
	stateReset: function() {
		this._state = null;
		if(!PrivateBrowsing.inPrivateBrowsing || Prefs.keepPrivate) {
			Prefs.reset('lastStateMain');
		}
		SessionStore.deleteWindowValue(window, objName+'.mainSidebar');
	},
	noPersist: function() {
		// the native SidebarUI persists the attributes of sidebar-box,
		// which can cause the sidebar to open after restarting firefox when it's not supposed to
		if(Services.xulStore.hasValue(document.documentURI, 'sidebar-box', 'src')) {
			Services.xulStore.removeValue(document.documentURI, 'sidebar-box', 'src');
		}
		if(Services.xulStore.hasValue(document.documentURI, 'sidebar-box', 'sidebarcommand')) {
			Services.xulStore.removeValue(document.documentURI, 'sidebar-box', 'sidebarcommand');
		}
	},
	get keyset () { return mainKey; },
	get keysetPanel () { return Prefs.mainKeysetPanel; },
	get above () { return Prefs.renderabove; },
	get autoHide () { return Prefs.autoHide; },
	get autoClose () { return Prefs.autoClose; },
	get useSwitch () { return Prefs.useSwitch; },
	needSwitch: new Set(),
	get isSwitchNeeded () {
		return (this.needSwitch.size > 0);
	},
	get switcher () { return $(objName+'-switch'); },
	toggleSwitcher: function() {
		if(!this.switcher) { return; }
		this.switcher.collapsed = !(this.useSwitch || (this.above && this.autoHide && !this.closed) || this.isSwitchNeeded);
	},
	get goURI () { return $(objName+'-viewURISidebar'); },
	get goURIButton () { return $(objName+'-uri_sidebar_button'); }
};

this.twinSidebar = {
	main: false,
	twin: true,
	_loaded: false,
	get loaded () { return this._loaded; },
	set loaded (v) {
		this._loaded = v;
		dispatch(this.box, { type: 'LoadedSidebar', cancelable: false, detail: v });
		return v;
	},
	autoHideInit: false,
	initialShowings: new Set(),
	contentFocused: false,
	get command () { return this.box && this.box.getAttribute('sidebarcommand'); },
	set command (v) { return setAttribute(this.box, 'sidebarcommand', v); },
	get isSocial () { return isSocial && (!this.box || this.box.getAttribute('origin') || (typeof(Social) != 'undefined' && isAncestor(Social.browser, this.box))); },
	get isOpen () {
		if(this.isSocial) { return true; }

		if(!this.command
		|| !$(this.command)
		|| $(this.command).localName != 'broadcaster'
		|| $(this.command).getAttribute('sidebarurl') != this.box.getAttribute('src')
		|| this.box.getAttribute('src') != this.sidebar.getAttribute('src')) {
			return false;
		}
		return true;
	},
	get focused () {
		return	this.sidebar && this.sidebar.contentWindow
			&& (document.commandDispatcher.focusedWindow == this.sidebar.contentWindow.content || document.commandDispatcher.focusedWindow == this.sidebar.contentWindow);
	},
	get closed () { return !this.box || this.box.hidden || this.box.collapsed; },
	get label () { return Strings.get('buttons', 'buttonTwinLabel'); },
	get splitter () { return $(objName+'-sidebar-splitter-twin'); },
{'fraction_non_alphanumeric': 0.16918368704677, 'fraction_numerical': 0.002461579402568026, 'mean_word_length': 4.296687808315715, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1664303', 'n_tokens_mistral': 5273, 'n_tokens_neox': 4870, 'n_words': 1103}