text: /* Do not modify this file directly. It is compiled from other files. */
  /* global grunionEditorView, tinyMCE, QTags, wp */
  !function(t,e,n){if(e.mce=e.mce||{},void 0!==e.mce.views){e.mce.grunion_wp_view_renderer={shortcode_string:"contact-form",template:e.template("grunion-contact-form"),field_templates:{email:e.template("grunion-field-email"),telephone:e.template("grunion-field-telephone"),textarea:e.template("grunion-field-textarea"),radio:e.template("grunion-field-radio"),checkbox:e.template("grunion-field-checkbox"),"checkbox-multiple":e.template("grunion-field-checkbox-multiple"),select:e.template("grunion-field-select"),date:e.template("grunion-field-date"),text:e.template("grunion-field-text"),name:e.template("grunion-field-text"),url:e.template("grunion-field-url")},edit_template:e.template("grunion-field-edit"),editor_inline:e.template("grunion-editor-inline"),editor_option:e.template("grunion-field-edit-option"),getContent:function(){var t,i,o=this.shortcode.content,r=0,c="";for(o||(o=n.default_form);t=e.shortcode.next("contact-field",o,r);)r=t.index+t.content.length,i=t.shortcode.attrs.named,i.type&&this.field_templates[i.type]||(i.type="text"),i.required&&(i.required=n.labels.required_field_text),i.options&&"string"==typeof i.options&&(i.options=i.options.split(",")),c+=this.field_templates[i.type](i);var s={body:c,submit_button_text:n.labels.submit_button_text};return this.template(s)},edit:function(i,o){var r,c,s=e.shortcode.next(this.shortcode_string,i),l=s.shortcode,a=t(tinyMCE.activeEditor.getDoc()),d=a.find(".wpview.wpview-wrap").filter(function(){return t(this).attr("data-mce-selected")}),f=t('<iframe scrolling="no" class="inline-edit-contact-form" />'),u=0,h="";for(l.content||(l.content=n.default_form);c=e.shortcode.next("contact-field",l.content,u);)u=c.index+c.content.length,r=c.shortcode.attrs.named,r.options&&"string"==typeof r.options&&(r.options=r.options.split(",")),h+=this.edit_template(r);f.on("checkheight",function(){var t=this.contentDocument?this.contentDocument:this.contentWindow.document;this.style.height="10px",this.style.height=5+t.body.scrollHeight+"px",tinyMCE.activeEditor.execCommand("wpAutoResize")}),f.on("load",function(){var i=1===window.isRtl?n.inline_editing_style_rtl:n.inline_editing_style,r=t('<link rel="stylesheet" href="'+i+'" />'),c=t('<link rel="stylesheet" href="'+n.dashicons_css_url+'" />');r.on("load",function(){f.contents().find("body").css("visibility","visible"),f.trigger("checkheight")}),f.contents().find("head").append(r).append(c),f.contents().find("body").html(e.mce.grunion_wp_view_renderer.editor_inline({to:l.attrs.named.to,subject:l.attrs.named.subject,fields:h})).css("visibility","hidden"),f.contents().find("input:first").focus(),setTimeout(function(){f.trigger("checkheight")},250),setTimeout(function(){f.trigger("checkheight")},500);var s=f.contents().find(".grunion-fields"),a=f.contents().find(".grunion-controls");s.sortable(),s.on("change select","select[name=type]",function(){t(this).closest(".grunion-field-edit")[0].className="card is-compact grunion-field-edit grunion-field-"+t(this).val(),f.trigger("checkheight")}),s.on("click",".delete-option",function(e){e.preventDefault(),t(this).closest("li").remove(),f.trigger("checkheight")}),s.on("click",".add-option",function(n){var i=t(e.mce.grunion_wp_view_renderer.editor_option());n.preventDefault(),t(this).closest("li").before(i),f.trigger("checkheight"),i.find("input:first").focus()}),s.on("click",".delete-field",function(e){e.preventDefault(),t(this).closest(".card").remove(),f.trigger("checkheight")}),a.find("input[name=submit]").on("click",function(){var n=l;n.type="closed",n.attrs={},n.content="",s.children().each(function(){var i={tag:"contact-field",type:"single",attrs:{label:t(this).find("input[name=label]").val(),type:t(this).find("select[name=type]").val()}},o=[];t(this).find("input[name=required]:checked").length&&(i.attrs.required="1"),t(this).find("input[name=option]").each(function(){t(this).val()&&o.push(t(this).val())}),o.length&&(i.attrs.options=o.join(",")),n.content+=e.shortcode.string(i)}),f.contents().find("input[name=to]").val()&&(n.attrs.to=f.contents().find("input[name=to]").val()),f.contents().find("input[name=subject]").val()&&(n.attrs.subject=f.contents().find("input[name=subject]").val()),o(e.shortcode.string(n))}),a.find("input[name=cancel]").on("click",function(){o(e.shortcode.string(l))}),a.find("input[name=add-field]").on("click",function(){var n=t(e.mce.grunion_wp_view_renderer.edit_template({}));s.append(n),s.sortable("refresh"),f.trigger("checkheight"),n.find("input:first").focus()})}),d.html(f)}},e.mce.views.register("contact-form",e.mce.grunion_wp_view_renderer),QTags.addButton("grunion_shortcode",n.labels.quicktags_label,function(){QTags.insertContent("[contact-form]"+n.default_form+"[/contact-form]")});var i=t("#wp-content-wrap");t("#insert-jetpack-contact-form").on("click",function(t){t.preventDefault(),i.hasClass("tmce-active")?tinyMCE.execCommand("grunion_add_form"):i.hasClass("html-active")?QTags.insertContent("[contact-form]"+n.default_form+"[/contact-form]"):window.console.error("Neither TinyMCE nor QuickTags is active. Unable to insert form.")})}}(jQuery,wp,grunionEditorView);