Liferay.Loader.define("dynamic-data-mapping-form-field-type$liferay-ckeditor@4.21.0-liferay.10/ckeditor/plugins/codemirror/dialogs/codemirrordialog", ['module', 'exports', 'require'], function (module, exports, require) {
  var define = undefined;
  var global = window;
  {
    CKEDITOR.dialog.add("codemirrordialog", function (e) {
      var g = CKEDITOR.document.getWindow(),
          f = g.getViewPaneSize(),
          h = .7 * f.height,
          f = .9 * f.width,
          k = /alert\((.*?)\)/,
          l = /innerHTML\s*=\s*.*?/,
          m = /<\?[\s\S]*?\?>/g,
          n = /<%[\s\S]*?%>/g,
          p = /(<asp:[^]+>[\s|\S]*?<\/asp:[^]+>)|(<asp:[^]+\/>)/gi,
          q = /<[^>]+?(\s+\bon\w+=(?:'[^']*'|"[^"]*"|[^'"\s>]+))*\s*\/?>/gi,
          r = /(\s+\bon\w+=(?:'[^']*'|"[^"]*"|[^'"\s>]+))/gi;e.window || (e.window = g);return { _createCodeMirrorEditor: function () {
          var a = this.dialog,
              c = a.getSize(),
              b = a.getContentElement("main", "data").getInputElement().$,
              b = this.codeMirrorEditor = CodeMirror.fromTextArea(b, { lineNumbers: !0, lineWrapping: !0, mode: "text/html" }),
              c = c.width / 2 - 40,
              d = this._getTabPanel(),
              e = this._getTabPanelPadding(),
              d = d.getSize("height") - (e.bottom + e.top);b.setSize(c, d);d = a.getParentEditor();b.setValue(d.getData());a = a.getContentElement("main", "preview").getElement();a.setSize("width", c);this._createContentIframe(a);b.on("change", this._handleCodeMirrorChange.bind(this));
        }, _createContentIframe: function (a) {
          this.dialog.getParentEditor();
          var c = this._getTabPanel(),
              b = this._getTabPanelPadding(),
              c = c.getSize("height") - (b.bottom + b.top),
              b = new CKEDITOR.dom.element("iframe");b.on("load", this._handleIframeLoaded.bind(this));a.append(b);b.setAttribute("frameborder", 0);b.setStyles({ height: c + "px", width: "99%" });return b;
        }, _handleCodeMirrorChange: function () {
          var a = this.codeMirrorEditor.getValue(),
              a = this._sanitizeHTML(a),
              c = this.dialog.getContentElement("main", "preview").getElement().findOne("iframe");c && c.$ && (c.$.contentDocument.body.innerHTML = a);
        },
        _handleIframeLoaded: function (a) {
          var c = this.codeMirrorEditor.getValue();a = a.sender;a.addClass("cke_wysiwyg_frame");a.addClass("cke_reset");var b = a.$.contentDocument.body;b.innerHTML = c;var d = a.$.contentDocument,
              f = d.head,
              c = e.config.contentsCss;Array.isArray(c) ? c.forEach(function (a) {
            var b = d.createElement("link");b.setAttribute("href", a);b.setAttribute("rel", "stylesheet");f.appendChild(b);
          }) : (b = d.createElement("link"), b.setAttribute("href", c), b.setAttribute("rel", "stylesheet"), f.appendChild(b));c = e.config.contentsLangDirection;
          b = d.documentElement;b.setAttribute("dir", c);b.setAttribute("lang", e.config.defaultLanguage);b = d.body;b.classList.add("cke_editable");b.classList.add("cke_editable_themed");b.classList.add("cke_contents_" + c);b.setAttribute("contenteditable", !1);b.setAttribute("spellcheck", !1);b.style.background = "#fff";return a;
        }, _getTabPanel: function () {
          return this.dialog.getContentElement("main").getElement().getAscendant(function (a) {
            return "div" === a.getName() && "tabpanel" === a.getAttribute("role");
          });
        }, _getTabPanelPadding: function () {
          var a = this._getTabPanel().getParent();return { bottom: parseInt(a.getComputedStyle("padding-bottom"), 10) || 0, top: parseInt(a.getComputedStyle("padding-top"), 10) || 0 };
        }, _sanitizeHTML: function (a) {
          return a.replace(q, function (a) {
            return a.replace(r, "");
          }).replace(k, "").replace(l, "").replace(m, "").replace(n, "").replace(p, "");
        }, contents: [{ id: "main", elements: [{ align: "top", children: [{ id: "data", type: "textarea" }, { html: '\x3cdiv class\x3d"code_preview"\x3e\x26nbsp;\x3c/div\x3e', id: "preview", type: "html" }], type: "hbox" }] }], height: h,
        title: e.lang.codemirror.source, width: f, onLoad: function () {
          this.definition._createCodeMirrorEditor();
        }, onOk: function () {
          var a = this.definition,
              c = this.getParentEditor(),
              a = a.codeMirrorEditor.getValue(),
              b = c.getData();a !== b && c.setData(a);c.setMode("wysiwyg");
        }, onShow: function () {
          var a = this.definition.codeMirrorEditor,
              c = this.getParentEditor(),
              b = c.getData();a && a.getValue() !== b && a.setValue(b);c.balloonToolbars && c.balloonToolbars.hide();
        } };
    });
  }
});
//# sourceMappingURL=codemirrordialog.js.map