text: tinymce.PluginManager.add("media", function (e, t) {
      function n(e) {
          return-1 != e.indexOf(".mp3") ? "audio/mpeg" : -1 != e.indexOf(".wav") ? "audio/wav" : -1 != e.indexOf(".mp4") ? "video/mp4" : -1 != e.indexOf(".webm") ? "video/webm" : -1 != e.indexOf(".ogg") ? "video/ogg" : -1 != e.indexOf(".swf") ? "application/x-shockwave-flash" : ""
      }
  
      function i() {
          function t(e) {
              var t, r, a, o;
              t = n.find("#width")[0], r = n.find("#height")[0], a = t.value(), o = r.value(), n.find("#constrain")[0].checked() && i && c && a && o && (e.control == t ? (o = Math.round(a / i * o), r.value(o)) : (a = Math.round(o / c * a), t.value(a))), i = a, c = o
          }
  
          var n, i, c, l;
          l = s(e.selection.getNode()), i = l.width, c = l.height, n = e.windowManager.open({title: "Insert/edit video", data: l, bodyType: "tabpanel", body: [
              {title: "General", type: "form", onShowTab: function () {
                  this.fromJSON(o(this.next().find("#embed").value()))
              }, items: [
                  {name: "source1", type: "filepicker", filetype: "media", size: 40, autofocus: !0, label: "Source"},
                  {name: "source2", type: "filepicker", filetype: "media", size: 40, label: "Alternative source"},
                  {name: "poster", type: "filepicker", filetype: "image", size: 40, label: "Poster"},
                  {type: "container", label: "Dimensions", layout: "flex", direction: "row", align: "center", spacing: 5, items: [
                      {name: "width", type: "textbox", maxLength: 3, size: 3, onchange: t},
                      {type: "label", text: "x"},
                      {name: "height", type: "textbox", maxLength: 3, size: 3, onchange: t},
                      {name: "constrain", type: "checkbox", checked: !0, text: "Constrain proportions"}
                  ]}
              ]},
              {title: "Embed", type: "panel", layout: "flex", direction: "column", align: "stretch", padding: 10, spacing: 10, onShowTab: function () {
                  this.find("#embed").value(a(this.parent().toJSON()))
              }, items: [
                  {type: "label", text: "Paste your embed code below:"},
                  {type: "textbox", flex: 1, name: "embed", value: r(), multiline: !0, label: "Source"}
              ]}
          ], onSubmit: function () {
              e.insertContent(a(this.toJSON()))
          }})
      }
  
      function r() {
          var t = e.selection.getNode();
          return t.getAttribute("data-mce-object") ? e.selection.getContent() : void 0
      }
  
      function a(i) {
          var r = "";
          return i.source1 || (tinymce.extend(i, o(i.embed)), i.source1) ? (i.source1 = e.convertURL(i.source1, "source"), i.source2 = e.convertURL(i.source2, "source"), i.source1mime = n(i.source1), i.source2mime = n(i.source2), i.poster = e.convertURL(i.poster, "poster"), i.flashPlayerUrl = e.convertURL(t + "/moxieplayer.swf", "movie"), i.embed ? r = c(i.embed, i, !0) : (tinymce.each(l, function (e) {
              var t, n, r;
              if (t = e.regex.exec(i.source1)) {
                  for (r = e.url, n = 0; t[n]; n++)r = r.replace("$" + n, function () {
                      return t[n]
                  });
                  i.source1 = r, i.type = e.type, i.width = e.w, i.height = e.h
              }
          }), i.width = i.width || 300, i.height = i.height || 150, tinymce.each(i, function (t, n) {
              i[n] = e.dom.encode(t)
          }), "iframe" == i.type ? r += '<iframe src="' + i.source1 + '" width="' + i.width + '" height="' + i.height + '"></iframe>' : "application/x-shockwave-flash" == i.source1mime ? (r += '<object data="' + i.source1 + '" width="' + i.width + '" height="' + i.height + '" type="application/x-shockwave-flash">', i.poster && (r += '<img src="' + i.poster + '" width="' + i.width + '" height="' + i.height + '" />'), r += "</object>") : -1 != i.source1mime.indexOf("audio") ? e.settings.audio_template_callback ? r = e.settings.audio_template_callback(i) : r += '<audio controls="controls" src="' + i.source1 + '">' + (i.source2 ? '\n<source src="' + i.source2 + '"' + (i.source2mime ? ' type="' + i.source2mime + '"' : "") + " />\n" : "") + "</audio>" : r = e.settings.video_template_callback ? e.settings.video_template_callback(i) : '<video width="' + i.width + '" height="' + i.height + '"' + (i.poster ? ' poster="' + i.poster + '"' : "") + ' controls="controls">\n' + '<source src="' + i.source1 + '"' + (i.source1mime ? ' type="' + i.source1mime + '"' : "") + " />\n" + (i.source2 ? '<source src="' + i.source2 + '"' + (i.source2mime ? ' type="' + i.source2mime + '"' : "") + " />\n" : "") + "</video>"), r) : ""
      }
  
      function o(e) {
          var t = {};
          return new tinymce.html.SaxParser({validate: !1, special: "script,noscript", start: function (e, n) {
              t.source1 || "param" != e || (t.source1 = n.map.movie), ("iframe" == e || "object" == e || "embed" == e || "video" == e || "audio" == e) && (t = tinymce.extend(n.map, t)), "source" == e && (t.source1 ? t.source2 || (t.source2 = n.map.src) : t.source1 = n.map.src), "img" != e || t.poster || (t.poster = n.map.src)
          }}).parse(e), t.source1 = t.source1 || t.src || t.data, t.source2 = t.source2 || "", t.poster = t.poster || "", t
      }
  
      function s(t) {
          return t.getAttribute("data-mce-object") ? o(e.serializer.serialize(t, {selection: !0})) : {}
      }
  
      function c(e, t, n) {
          function i(e, t) {
              var n, i, r, a;
              for (n in t)if (r = "" + t[n], e.map[n])for (i = e.length; i--;)a = e[i], a.name == n && (r ? (e.map[n] = r, a.value = r) : (delete e.map[n], e.splice(i, 1))); else r && (e.push({name: n, value: r}), e.map[n] = r)
          }
  
          var r, a = new tinymce.html.Writer, o = 0;
          return new tinymce.html.SaxParser({validate: !1, special: "script,noscript", comment: function (e) {
              a.comment(e)
          }, cdata: function (e) {
              a.cdata(e)
          }, text: function (e, t) {
              a.text(e, t)
          }, start: function (e, s, c) {
              switch (e) {
                  case"video":
                  case"object":
                  case"img":
                  case"iframe":
                      i(s, {width: t.width, height: t.height})
              }
              if (n)switch (e) {
                  case"video":
                      i(s, {poster: t.poster, src: ""}), t.source2 && i(s, {src: ""});
                      break;
                  case"iframe":
                      i(s, {src: t.source1});
                      break;
                  case"source":
                      if (o++, 2 >= o && (i(s, {src: t["source" + o], type: t["source" + o + "mime"]}), !t["source" + o]))return;
                      break;
                  case"img":
                      if (!t.poster)return;
                      r = !0
              }
              a.start(e, s, c)
          }, end: function (e) {
              if ("video" == e && n)for (var s = 1; 2 >= s; s++)if (t["source" + s]) {
                  var c = [];
                  c.map = {}, s > o && (i(c, {src: t["source" + s], type: t["source" + s + "mime"]}), a.start("source", c, !0))
              }
              if (t.poster && "object" == e && n && !r) {
                  var l = [];
                  l.map = {}, i(l, {src: t.poster, width: t.width, height: t.height}), a.start("img", l, !0)
              }
              a.end(e)
          }}, new tinymce.html.Schema({})).parse(e), a.getContent()
      }
  
      var l = [
          {regex: /youtu\.be\/([a-z1-9.-_]+)/, type: "iframe", w: 425, h: 350, url: "http://www.youtube.com/embed/$1"},
          {regex: /youtube\.com(.+)v=([^&]+)/, type: "iframe", w: 425, h: 350, url: "http://www.youtube.com/embed/$2"},
          {regex: /vimeo\.com\/([0-9]+)/, type: "iframe", w: 425, h: 350, url: "http://player.vimeo.com/video/$1?title=0&byline=0&portrait=0&color=8dc7dc"},
          {regex: /maps\.google\.([a-z]{2,3})\/maps\/(.+)msid=(.+)/, type: "iframe", w: 425, h: 350, url: 'http://maps.google.com/maps/ms?msid=$2&output=embed"'}
      ];
      e.on("ResolveName", function (e) {
          var t;
          1 == e.target.nodeType && (t = e.target.getAttribute("data-mce-object")) && (e.name = t)
      }), e.on("preInit", function () {
          var t = e.schema.getSpecialElements();
          tinymce.each("video audio iframe object".split(" "), function (e) {
              t[e] = new RegExp("</" + e + "[^>]*>", "gi")
          }), e.schema.addValidElements("object[id|style|width|height|classid|codebase|*],embed[id|style|width|height|type|src|*],video[*],audio[*]");
          var n = e.schema.getBoolAttrs();
          tinymce.each("webkitallowfullscreen mozallowfullscreen allowfullscreen".split(" "), function (e) {
              n[e] = {}
          }), e.parser.addNodeFilter("iframe,video,audio,object,embed", function (t, n) {
              for (var i, r, a, o, s, c, l, d = t.length; d--;) {
                  for (r = t[d], a = new tinymce.html.Node("img", 1), a.shortEnded = !0, c = r.attributes, i = c.length; i--;)o = c[i].name, s = c[i].value, "width" !== o && "height" !== o && "style" !== o && (("data" == o || "src" == o) && (s = e.convertURL(s, o)), a.attr("data-mce-p-" + o, s));
                  l = r.firstChild && r.firstChild.value, l && (a.attr("data-mce-html", escape(l)), a.firstChild = null), a.attr({width: r.attr("width") || "300", height: r.attr("height") || ("audio" == n ? "30" : "150"), style: r.attr("style"), src: tinymce.Env.transparentSrc, "data-mce-object": n, "class": "mce-object mce-object-" + n}), r.replace(a)
              }
          }), e.serializer.addAttributeFilter("data-mce-object", function (e, t) {
              for (var n, i, r, a, o, s, c = e.length; c--;) {
                  for (n = e[c], i = new tinymce.html.Node(n.attr(t), 1), "audio" != n.attr(t) && i.attr({width: n.attr("width"), height: n.attr("height")}), i.attr({style: n.attr("style")}), a = n.attributes, r = a.length; r--;) {
                      var l = a[r].name;
                      0 === l.indexOf("data-mce-p-") && i.attr(l.substr(11), a[r].value)
                  }
                  o = n.attr("data-mce-html"), o && (s = new tinymce.html.Node("#text", 3), s.raw = !0, s.value = unescape(o), i.append(s)), n.replace(i)
              }
          })
      }), e.on("ObjectSelected", function (e) {
          "audio" == e.target.getAttribute("data-mce-object") && e.preventDefault()
      }), e.on("objectResized", function (e) {
          var t, n = e.target;
          n.getAttribute("data-mce-object") && (t = n.getAttribute("data-mce-html"), t && (t = unescape(t), n.setAttribute("data-mce-html", escape(c(t, {width: e.width, height: e.height})))))
      }), e.addButton("media", {tooltip: "Insert/edit video", onclick: i, stateSelector: "img[data-mce-object=video]"}), e.addMenuItem("media", {icon: "media", text: "Insert video", onclick: i, context: "insert", prependToContext: !0})
  });