<commit_before>define('tinymce.media.ui.Dialog', [
	'global!tinymce.util.Delay',
	'tinymce.media.core.HtmlToData',
	'tinymce.media.core.UpdateHtml',
	'tinymce.media.core.Service',
	'tinymce.media.core.Size',
	'global!tinymce.util.Tools',
	'global!tinymce.Env'
], function (Delay, HtmlToData, UpdateHtml, Service, Size, Tools, Env) {
	var embedChange = (Env.ie && Env.ie <= 8) ? 'onChange' : 'onInput';

	var handleError = function (editor) {
		return function (error) {
			var errorMessage = error && error.msg ?
				'Media embed handler error: ' + error.msg :
				'Media embed handler threw unknown error.';
			editor.notificationManager.open({type: 'error', text: errorMessage});
		};
	};

	var getData = function (editor) {
		var element = editor.selection.getNode();
		var dataEmbed = element.getAttribute('data-ephox-embed-iri');

		if (dataEmbed) {
			return {
				source1: dataEmbed,
				'data-ephox-embed-iri': dataEmbed,
				width: Size.getMaxWidth(element),
				height: Size.getMaxHeight(element)
			};
		}

		return element.getAttribute('data-mce-object') ?
			HtmlToData.htmlToData(editor.settings.media_scripts, editor.serializer.serialize(element, {selection: true})) :
			{};
	};

	var getSource = function (editor) {
		var elm = editor.selection.getNode();

		if (elm.getAttribute('data-mce-object') || elm.getAttribute('data-ephox-embed-iri')) {
			return editor.selection.getContent();
		}
	};

	var addEmbedHtml = function (win, editor) {
		return function (response) {
			var html = response.html;
			win.find('#embed').value(html);
			var data = Tools.extend(HtmlToData.htmlToData(editor.settings.media_scripts, html), {source1: response.url});
			win.fromJSON(data);
			updateSize(win);
		};
	};

	var selectPlaceholder = function (editor, beforeObjects) {
		var i;
		var y;
		var afterObjects = editor.dom.select('img[data-mce-object]');

		// Find new image placeholder so we can select it
		for (i = 0; i < beforeObjects.length; i++) {
			for (y = afterObjects.length - 1; y >= 0; y--) {
				if (beforeObjects[i] === afterObjects[y]) {
					afterObjects.splice(y, 1);<commit_msg>TINY-854: nullcheck embed in addEmbedHtml<commit_after>define('tinymce.media.ui.Dialog', [
	'global!tinymce.util.Delay',
	'tinymce.media.core.HtmlToData',
	'tinymce.media.core.UpdateHtml',
	'tinymce.media.core.Service',
	'tinymce.media.core.Size',
	'global!tinymce.util.Tools',
	'global!tinymce.Env'
], function (Delay, HtmlToData, UpdateHtml, Service, Size, Tools, Env) {
	var embedChange = (Env.ie && Env.ie <= 8) ? 'onChange' : 'onInput';

	var handleError = function (editor) {
		return function (error) {
			var errorMessage = error && error.msg ?
				'Media embed handler error: ' + error.msg :
				'Media embed handler threw unknown error.';
			editor.notificationManager.open({type: 'error', text: errorMessage});
		};
	};

	var getData = function (editor) {
		var element = editor.selection.getNode();
		var dataEmbed = element.getAttribute('data-ephox-embed-iri');

		if (dataEmbed) {
			return {
				source1: dataEmbed,
				'data-ephox-embed-iri': dataEmbed,
				width: Size.getMaxWidth(element),
				height: Size.getMaxHeight(element)
			};
		}

		return element.getAttribute('data-mce-object') ?
			HtmlToData.htmlToData(editor.settings.media_scripts, editor.serializer.serialize(element, {selection: true})) :
			{};
	};

	var getSource = function (editor) {
		var elm = editor.selection.getNode();

		if (elm.getAttribute('data-mce-object') || elm.getAttribute('data-ephox-embed-iri')) {
			return editor.selection.getContent();
		}
	};

	var addEmbedHtml = function (win, editor) {
		return function (response) {
			var html = response.html;
			var embed = win.find('#embed')[0];
			var data = Tools.extend(HtmlToData.htmlToData(editor.settings.media_scripts, html), {source1: response.url});
			win.fromJSON(data);

			if (embed) {
				embed.value(html);
				updateSize(win);
			}
		};
	};

	var selectPlaceholder = function (editor, beforeObjects) {
		var i;
		var y;
		var afterObjects = editor.dom.select('img[data-mce-object]');

		// Find new image placeholder so we can select it
		for (i = 0; i < beforeObjects.length; i++) {
			for (y = afterObjects.length - 1; y >= 0; y--) {
				if (beforeObjects[i] === afterObjects[y]) {
					afterObjects.splice(y, 1);
{'fraction_non_alphanumeric': 0.15775962660443407, 'fraction_numerical': 0.004200700116686115, 'mean_word_length': 4.018735362997658, 'pattern_counts': {'":': 0, '<': 7, '<?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': '4739685', 'n_tokens_mistral': 1635, 'n_tokens_neox': 1450, 'n_words': 302}