var Loop=window.Loop||{},wysihtml5,Base,templates;Loop.viewModels=Loop.viewModels||{};Loop.viewModels.Brick=function(n){function y(n){Array.isArray(n)?n.length===0?t(Loop.Enum.BrickDataStatus.LoadedWithoutContent):t(Loop.Enum.BrickDataStatus.LoadedWithContent):n?t(Loop.Enum.BrickDataStatus.LoadedWithContent):t(Loop.Enum.BrickDataStatus.LoadedWithoutContent)}function p(n,r,u,f,e){return e=e!==undefined?e:!0,i(""),v.loadStatus={url:n.url(),callback:r},Loop.Core.Ajax.loadData({endpoint:n,successCallback:function(n){typeof r=="function"&&r(n)},errorCallback:function(n,r){e&&t(Loop.Enum.BrickDataStatus.LoadedWithErrors);i(r);typeof u=="function"&&u(n,r)},preventModalOnError:!1,timeout:f,withCredentials:n?n.withCredentials:!1})}function w(n,i,r,u){Loop.Core.Ajax.deleteData({endpoint:n,inputData:i,successCallback:function(n){typeof r=="function"&&r(n)},errorCallback:function(n,i){typeof u=="function"&&(t(Loop.Enum.BrickDataStatus.LoadedWithErrors),u(n,i))},withCredentials:n?n.withCredentials:!1})}function b(n,r,u,f,e){Loop.Core.Ajax.createData({endpoint:n,inputData:r,successCallback:function(n){typeof u=="function"&&u(n)},errorCallback:function(n,r){t(Loop.Enum.BrickDataStatus.LoadedWithErrors);e!==!0&&i(r);typeof f=="function"&&f(n,r)},withCredentials:n?n.withCredentials:!1})}function k(n,r,u,f,e){Loop.Core.Ajax.updateData({endpoint:n,inputData:r,successCallback:function(n){typeof u=="function"&&u(n)},errorCallback:function(n,r){t(Loop.Enum.BrickDataStatus.LoadedWithErrors);e!==!0&&i(r);typeof f=="function"&&f(n,r)},withCredentials:n?n.withCredentials:!1})}var t=ko.observable(Loop.Enum.BrickDataStatus.NotInitialized),f=ko.observable(Loop.Enum.BrickDataStatus.NotInitialized),e=ko.observable(Loop.Enum.BrickDataStatus.NotInitialized),u=Loop.Configuration.profile.ProfileUserId,o=Loop.Configuration.LoggedUserId,r=ko.observable(!1),i=ko.observable(),s=ko.observable(!1),h=ko.observable(!1),c=ko.observable(),l=ko.observable(!1),a=ko.observable(!0),v=this;return n=n||"brick-generic",t.subscribe(function(n){f(n)},this,"beforeChange"),u===o&&u!==undefined&&r(!0),{updateStatusByContent:y,loadData:p,updateData:k,createData:b,deleteData:w,userID:u,ownProfile:r,status:t,previousStatus:f,isDataLoaded:ko.computed(function(){return!(t()===Loop.Enum.BrickDataStatus.NotInitialized||t()===Loop.Enum.BrickDataStatus.Loading)},this),hasContent:ko.computed(function(){return t()===Loop.Enum.BrickDataStatus.LoadedWithContent},this),noContent:ko.computed(function(){return t()===Loop.Enum.BrickDataStatus.LoadedWithoutContent},this),noContentOwnProfile:ko.computed(function(){return t()===Loop.Enum.BrickDataStatus.LoadedWithoutContent&&r()},this),noContentOtherProfile:ko.computed(function(){return t()===Loop.Enum.BrickDataStatus.LoadedWithoutContent&&!r()},this),errorMessage:i,isVisible:s,isDisabled:h,bodyTemplate:c,showNoContentOtherProfile:!0,showErrorMessages:!0,isInSideBar:l,disableOnEdit:a,elementId:n,dataTestId:n,brickLoadedCallback:undefined,brickVisibleStatus:e,allowEmptyCase:!0}};Loop=window.Loop||{};Loop.viewModels=Loop.viewModels||{};Loop.viewModels.BrickConfig=function(n){var t=this;return t.viewModel=n.viewModel,t.alternative=n.alternative,t.templateId=n.templateId,t.templateName=n.templateName,t.sizes=n.sizes,t.id=n.id||"",t.dataTestId=n.dataTestId,t.initParams=n.initParams,t.hideDOM=n.hideDOM||!1,t.initCalled=!1,n.dataTestId||(t.dataTestId=t.templateId),t.templateId=t.templateId+"_"+Math.floor((Math.random()+1)*1e4),t};Loop=window.Loop||{};Loop.viewModels=Loop.viewModels||{};Loop.viewModels.BrickDispatcher=function(){function u(n){var t=null;if(n.rowsLayout&&n.columnsLayout){t=new Error("rowsLayout and columnsLayout cannot be present together to be able to render bricks");t.name="brickDispatcherError:mixedLayouts";throw t;}if(!n.rowsLayout&&!n.columnsLayout){t=new Error("rowsLayout or columnsLayout must be present to be able to render bricks");t.name="brickDispatcherError:layoutNotPresent";throw t;}}function r(n){var t=[];return n.xs&&t.push("col-xs-"+n.xs),n.sm&&t.push("col-sm-"+n.sm),n.md&&t.push("col-md-"+n.md),n.lg&&t.push("col-lg-"+n.lg),t.join(" ").trim()}function f(n){var t="#back-burner > #"+n.templateId;return n.hideDOM&&$(t).length>0}function e(n,t,i){var u="",f=[],e="";n.sizes&&f.push(r(n.sizes));f.length>0&&(e="class='"+f.join(" ")+"'");u="<div "+e+' id="'+n.templateId+'" data-bind="template: { name: \''+n.templateName+"', data: viewModel";t&&n.viewModel.reloadAfterRender?u=u+", afterRender:function(element,data){data.reloadAfterRender(element,data)}":!t&&n.viewModel.afterRender&&(u=u+", afterRender:function(element,data){data.afterRender(element,data)}");u=u+' }" data-test-id="'+n.dataTestId+'"><\/div>';$("#"+i).append(u)}function t(n,i,r){var u,o,s=!1;n.viewModel.templateId=n.templateId;s=f(n);n.dispatcherAlreadyLoaded||(n.dispatcherAlreadyLoaded=!1);s?$("#"+n.templateId).appendTo("#"+r):e(n,n.dispatcherAlreadyLoaded,r);n.alternative&&(t(n.alternative,!1,r),n.viewModel.brick.statusSubscription||(n.viewModel.brick.statusSubscription=n.viewModel.brick.status.subscribe(function(t){t===Loop.Enum.BrickDataStatus.NotAvailable&&(n.alternative.viewModel.init(n.alternative.initParams),n.alternative.initCalled=!0)})));u=n.viewModel.brick.status();o=n.viewModel.brick.previousStatus();u!==Loop.Enum.BrickDataStatus.NotAvailable&&o!==Loop.Enum.BrickDataStatus.RunningInBackground&&(u===Loop.Enum.BrickDataStatus.Hidden?(n.viewModel.reload&&n.viewModel.reload(n.initParams),n.viewModel.brick.status(o)):u===Loop.Enum.BrickDataStatus.ReadyToReload?n.viewModel.reload&&n.viewModel.reload(n.initParams):u!==Loop.Enum.BrickDataStatus.RunningInBackground&&(n.initCalled||(n.viewModel.init(n.initParams),n.initCalled=!0)));s?n.dispatcherAlreadyLoaded&&n.viewModel.reloadAfterRender&&n.viewModel.reloadAfterRender():ko.applyBindings(n,document.getElementById(n.templateId));n.dispatcherAlreadyLoaded=!0}function i(n){n.viewModel.brick.status()!==Loop.Enum.BrickDataStatus.NotAvailable&&n.viewModel.brick.status()!==Loop.Enum.BrickDataStatus.NotInitialized&&n.viewModel.brick.status(Loop.Enum.BrickDataStatus.Hidden);n.hideDOM?$("#"+n.templateId).appendTo("#back-burner"):$("#"+n.templateId).remove();n.alternative&&i(n.alternative);n.viewModel.onHideBrick&&n.viewModel.onHideBrick()}var n=this;n.loadConfiguration=function(t){n.bricksConfig=t};n.loadAllBricks=function(){$("#tab-pane").html("");n.bricksConfig.forEach(function(n,i){if(u(n),n.columnsLayout){var f="divPlaceHolderRowColumn_"+i;$("#tab-pane").append("<div class='row' id='"+f+"'><\/div>");n.columnsLayout.forEach(function(n,u){var e="divPlaceHolderColumn_"+i+"_"+u,o=r(n.columnSizes);$("#"+f).append("<div id='"+e+"' class='"+o+"'><\/div>");n.bricks.forEach(function(n){t(n,!0,e)})})}else n.rowsLayout&&n.rowsLayout.forEach(function(n,r){var u="divPlaceHolderRow_"+i+"_"+r;$("#tab-pane").append("<div id='"+u+"' class='row'><\/div>");n.bricks.forEach(function(n){if(n.sizes)t(n,!0,u);else throw"[brickDispatcher] brick config must include sizes object to be rendered in a row layout";})})});n.alreadyLoaded=!0};n.hideAllBricks=function(){n.bricksConfig.forEach(function(n){n.columnsLayout?n.columnsLayout.forEach(function(n){n.bricks.forEach(function(n){i(n)})}):n.rowsLayout&&n.rowsLayout.forEach(function(n){n.bricks.forEach(function(n){i(n)})})})};n.alreadyLoaded=!1};Loop=window.Loop||{};Loop.viewControls=Loop.viewControls||{};Loop.viewControls.EditForm=function(n,t,i,r,u,f){function y(n){e.dataBackup=jQuery.extend(!0,{},ko.toJS(n))}function p(n,t){o=t;e.dataItem=n;e.dataIndex=parseInt(o.attr("data-index"),10);e.divID=e.getEditItemDivID();var i=$('<div id="'+e.divID+'">'+l+"<\/div>");i.appendTo(t);typeof u=="function"&&u();e.dataItem&&e.dataItem.isEditing(!1);ko.applyBindings(e,$("#"+e.divID)[0]);e.dataItem&&e.dataItem.isEditing(!0)}function w(){return e.dataItem.IsNew?$("#"+v).attr("id"):o.attr("id")}function a(){o=null;e.dataItem=null;e.dataBackup=null;e.dataIndex=-1;e.resetButtons();s=null;c=null}var e=this,l=null,o=null,v=null,s=null,c=null,h=null;e.dataBackup=null;e.divID=null;n&&(l=$("#"+n).html());e.setDataItem=function(n,t,i){n&&t&&(Loop.Common.DeactivateAllIcons(t.attr("id"),n),y(n),p(n,t));h=i};e.saveItem=function(n,i){h=null;s=$(i.target);s.prop("disabled",!0);typeof t=="function"&&t(n.dataItem,n.dataIndex)};e.cancelEdition=function(){h=null;typeof i=="function"&&i(e.dataBackup,e.dataIndex);e.disposeForm()};e.disposeForm=function(){var n;typeof r=="function"&&r();Loop.Common.ActivateAllIcons();o&&(n=w());a()};e.getEditItemDivID=function(){return o?o.attr("id")+"_EM":null};e.deleteItem=function(n,t){h=null;c=$(t.target);c.prop("disabled",!0);typeof f=="function"&&f(n.dataItem,n.dataIndex)};e.resetButtons=function(n,t){n=n||!1;s&&(s.text("Save"),n&&s.removeAttr("disabled"));c&&n&&c.removeAttr("disabled");t&&(h=t)};e.trackingData=function(){return{actionReferral:h}};a()};Loop=window.Loop||{};Loop.viewModels=Loop.viewModels||{};Loop.viewModels.partials=Loop.viewModels.partials||{};Loop.viewModels.partials.BriefBioEditor=function(n){function u(n){var r=n,i;return n&&(i=t.toMarkdown(n),i||t.setText(""),r=i),r}var i=new Loop.markdownControl.toMD,r=n,t=this;t.control=null;t.stylesheets=["/Content/v5/fonts/font.css","/Content/v5/css/rich-text-editor.css"];t.start=function(n,i){t.control?(t.control.enable(),typeof n=="function"&&n(),t.setText(i),t.resize()):(t.control=new wysihtml5.Editor(r,{toolbar:"toolbar",stylesheets:t.stylesheets,parserRules:Loop.markdownControl.parserRules,sync:!0,useLineBreaks:!1,cleanUp:!0,autoLink:!1}).on("load",function(){setTimeout(function(){$(t.control.composer.iframe).autoResize&&$(t.control.composer.iframe).autoResize();typeof n=="function"&&n()},1e3)}),t.setText(i),t.control.enable())};t.getHTMLFromEditor=function(){var n=t.control.getValue();return t.control.parse(n)};t.getMarkdownFromEditor=function(){return u(t.getHTMLFromEditor())};t.toMarkdown=function(n){return i.toMD(n)};t.resize=function(){var n=$(t.control.composer.iframe);n.trigger("resize")};t.disableControl=function(){t.control.disable()};t.setText=function(n){t.control.setValue(n)}};Loop=window.Loop||{};Loop.controls=Loop.controls||{};Loop.controls.Menu=function(n,t){function r(n,t,r,u){var f=this,e=n;f.trackingData=function(){return{actionReferral:"cog-menu"}};f.getID=function(){return e};f.optionText=t;f.dataTrack=u!==undefined?u:null;f.optionClick=function(){typeof r=="function"&&r();i.menuVisible(!1)}}var i=this,u=n;i.getID=function(){return u};i.getButtonID=function(){return"btn-"+u};i.options=ko.observableArray(t&&t.hasOwnProperty("length")?t:[]);i.visible=ko.observable(!1);i.menuVisible=ko.observable(!1);i.addOption=function(n,t,u,f){var e=new r(n,t,u,f);i.options.push(e)};i.insertOptionAt=function(n,t,u,f,e){var o=new r(t,u,f,e);i.options.splice(n,0,o)};i.replaceOptionAt=function(n,t,u,f,e){var o=new r(t,u,f,e);i.options.splice(n,1,o)};i.removeOption=function(n){i.options.splice(n,1)};i.showMenu=function(){i.menuVisible(!0)};i.toggleMenu=function(){i.menuVisible(!i.menuVisible())};$(document).on("click",function(n){i.visible()&&($(n.target).closest("#"+i.getID()).length||i.menuVisible(!1))})};Loop=window.Loop||{};Loop.controls=Loop.controls||{};Loop.controls.userPool=function(n,t,i){var r=this;r.options=$.extend({},{visibleUsers:5,endpointLimit:50},i||{});r.brick=n;r.endpoint=t},function(){(function(n){var t;return t=function(){function t(t){this.$iframe=n(t);this.$body=this.findBody();this.addBodyStyles();this.setupEvents();this.adjustHeight()}return t.prototype.addBodyStyles=function(){return this.$body.css("overflow","hidden"),this.$body.css("min-height",0)},t.prototype.setupEvents=function(){var n=this;return this.$body.on("keyup keydown paste change focus",function(){return n.adjustHeight()})},t.prototype.adjustHeight=function(){return this.$iframe.css("min-height",this.$body.height()+this.extraBottomSpacing())},t.prototype.extraBottomSpacing=function(){return parseInt(this.$body.css("line-height"),10)||this.estimateLineHeight()},t.prototype.estimateLineHeight=function(){return parseInt(this.$body.css("font-size"),10)*1.14},t.prototype.findBody=function(){return this.$iframe.contents().find("body")},t}(),n.fn.wysihtml5SizeMatters=function(){return this.each(function(){var i;return i=n.data(this,"wysihtml5SizeMatters"),i?void 0:n.data(this,"wysihtml5SizeMatters",new t(this))})}})($)}.call(this);Loop=window.Loop||{};Loop.markdownControl=Loop.markdownControl||{};Loop.markdownControl.parserRules={classes:{"wysiwyg-clear-both":1,"wysiwyg-clear-left":1,"wysiwyg-clear-right":1,"wysiwyg-color-aqua":1,"wysiwyg-color-black":1,"wysiwyg-color-blue":1,"wysiwyg-color-fuchsia":1,"wysiwyg-color-gray":1,"wysiwyg-color-green":1,"wysiwyg-color-lime":1,"wysiwyg-color-maroon":1,"wysiwyg-color-navy":1,"wysiwyg-color-olive":1,"wysiwyg-color-purple":1,"wysiwyg-color-red":1,"wysiwyg-color-silver":1,"wysiwyg-color-teal":1,"wysiwyg-color-white":1,"wysiwyg-color-yellow":1,"wysiwyg-float-left":1,"wysiwyg-float-right":1,"wysiwyg-font-size-large":1,"wysiwyg-font-size-larger":1,"wysiwyg-font-size-medium":1,"wysiwyg-font-size-small":1,"wysiwyg-font-size-smaller":1,"wysiwyg-font-size-x-large":1,"wysiwyg-font-size-x-small":1,"wysiwyg-font-size-xx-large":1,"wysiwyg-font-size-xx-small":1,"wysiwyg-text-align-center":1,"wysiwyg-text-align-justify":1,"wysiwyg-text-align-left":1,"wysiwyg-text-align-right":1},tags:{p:{},div:{rename_tag:"p"},tr:{rename_tag:"p"},strike:{remove:1},form:{remove:1},rt:{rename_tag:"p"},code:{rename_tag:"span"},acronym:{rename_tag:"span"},br:{add_class:{clear:"clear_br"}},details:{rename_tag:"p"},em:{rename_tag:"i"},title:{remove:1},multicol:{remove:1},figure:{remove:1},xmp:{remove:1},small:{rename_tag:"span"},area:{remove:1},time:{rename_tag:"span"},dir:{remove:1},bdi:{rename_tag:"span"},command:{remove:1},ul:{rename_tag:"p"},progress:{remove:1},dfn:{rename_tag:"p"},iframe:{remove:1},figcaption:{remove:1},a:{check_attributes:{href:"url"},set_attributes:{rel:"nofollow",target:"_blank"}},img:{remove:1},rb:{remove:1},footer:{rename_tag:"p"},noframes:{remove:1},abbr:{rename_tag:"span"},u:{rename_tag:"span"},bgsound:{remove:1},sup:{rename_tag:"span"},address:{rename_tag:"p"},basefont:{remove:1},nav:{remove:1},h1:{rename_tag:"p"},h2:{rename_tag:"p"},h3:{rename_tag:"p"},h4:{rename_tag:"p"},h5:{rename_tag:"p"},h6:{rename_tag:"p"},head:{remove:1},tbody:{rename_tag:"span"},dd:{rename_tag:"p"},s:{rename_tag:"span"},li:{rename_tag:"p"},td:{rename_tag:"span"},object:{remove:1},option:{remove:1},select:{remove:1},i:{},track:{remove:1},wbr:{remove:1},fieldset:{remove:1},big:{rename_tag:"span"},button:{remove:1},noscript:{remove:1},svg:{remove:1},input:{remove:1},table:{rename_tag:"p"},keygen:{remove:1},meta:{remove:1},map:{remove:1},isindex:{remove:1},mark:{rename_tag:"span"},caption:{rename_tag:"p"},tfoot:{rename_tag:"p"},base:{remove:1},video:{remove:1},strong:{},canvas:{remove:1},output:{remove:1},marquee:{remove:1},b:{rename_tag:"strong"},q:{remove:1},applet:{remove:1},span:{},rp:{remove:1},spacer:{remove:1},source:{remove:1},aside:{rename_tag:"p"},frame:{remove:1},section:{rename_tag:"p"},body:{rename_tag:"span"},ol:{rename_tag:"p"},nobr:{rename_tag:"span"},html:{remove:"1"},summary:{rename_tag:"p"},"var":{rename_tag:"p"},del:{remove:1},blockquote:{rename_tag:"p"},style:{remove:1},device:{remove:1},meter:{rename_tag:"p"},textarea:{rename_tag:"p"},embed:{remove:1},hgroup:{remove:1},font:{rename_tag:"span"},tt:{rename_tag:"p"},noembed:{remove:1},thead:{rename_tag:"p"},blink:{rename_tag:"p"},plaintext:{rename_tag:"p"},xml:{remove:1},param:{remove:1},th:{rename_tag:"span"},legend:{rename_tag:"p"},hr:{remove:1},label:{rename_tag:"span"},dl:{remove:1},kbd:{rename_tag:"span"},listing:{remove:1},dt:{rename_tag:"p"},nextid:{remove:1},pre:{rename_tag:"p"},center:{rename_tag:"span"},audio:{remove:1},datalist:{rename_tag:"p"},samp:{rename_tag:"p"},col:{remove:1},article:{rename_tag:"p"},cite:{rename_tag:"span"},link:{remove:1},script:{remove:1},bdo:{rename_tag:"p"},menu:{rename_tag:"p"},colgroup:{remove:1},ruby:{remove:1},ins:{rename_tag:"span"},sub:{rename_tag:"span"},comment:{remove:1},frameset:{remove:1},optgroup:{remove:1},header:{rename_tag:"p"}}};Loop=window.Loop||{};Loop.markdownControl=Loop.markdownControl||{};Loop.markdownControl.toMD=function(){"use strict";function n(n){this.originalNode=n;this.nodeType=null;this.elementType="html";this.text="";this.childNodes=[];this.level=""}function i(n){return n.replace(/((\n)(\s*)(\n))/g,t)}function r(n){var t=n;return t&&(t=n.replace(/(\*\*)(\*\*)([^\*]?)(\*\*)(\*\*)/g,"**$3**"),t=t.replace(/(\n|^)(\ {4,})(.*)/g,"$1$3")),t}function u(t){function s(t){var i=new n(t),r=null;i.parse("",this.config);r=i.render(this.config);u+=r}var o=$.parseHTML(t),u="",f=null,e=null;return o.forEach(s,this),f=r(u),e=i(f),e||""}var t="\n\n";return n.prototype.parse=function(t,i){this.nodeType=this.originalNode.nodeName.toUpperCase();this.level=t;i[this.nodeType]!==undefined&&(this.elementType=i[this.nodeType].drawAs||"html");var r=[].slice.call(this.originalNode.childNodes);r.forEach(function(r){var u=new n(r);u.parse(t+"    ",i);this.childNodes.push(u)},this)},n.prototype.render=function(n){function i(n,t,i,r,u){u=u||!1;var f=n.replace(t,i);return u&&console.log("["+r+"]\n"+f+"\n[/"+r+"]"),f}function r(n){var r="(^)",u="(\r\n|\n)",f="(\\*|\\+|-)",e="(^\\s*)",o="(\\r\\n\\s*|\\n\\s*)",l=new RegExp(e+f,"g"),a=new RegExp(o+f,"g"),s="(\\d+)\\.(\\s+)",v=new RegExp(e+s,"g"),y=new RegExp(o+s,"g"),h="(\\s{4,}|\\t+)",p=new RegExp(r+h,"g"),w=new RegExp(u+h,"g"),c="(\\*|-)(\\s?)",b=new RegExp(r+c,"g"),k=new RegExp(u+c,"g"),t=i(n,/(\*{1,2})(.+?)(\*{1,2})/g,"\\$1$2\\$3","emphasis (*)");return t=i(t,/(_{1,2})(.+?)(_{1,2})/g,"\\$1$2\\$3","emphasis (_)"),t=i(t,a,"$1\\$2","list (line)"),t=i(t,l,"$1\\$2","list (^)"),t=i(t,v,"$1$2\\.$3","numbered list (^)"),t=i(t,y,"$1$2\\.$3","numbered list (line)"),t=i(t,/^>/g,"&gt;","quote (^)"),t=i(t,/(\r\n|\n)>/g,"$1&gt;","quote (line)"),t=i(t,b,"$1\\$2$3","rules (^)"),t=i(t,k,"$1\\$2$3","rules (line)"),t=i(t,/\[(.+?)\]\((.+?)\)/g,"\\[$1]\\($2\\)","normal link"),t=i(t,/\[(.*?)\](\s*?)\[(.*?)\]/g,"\\[$1]$2\\[$3]","reference link"),t=i(t,/\[(.*?)\]:/g,"\\[$1]:","id link"),t=i(t,/(\r\n|\n)(={3,})(\r\n|\n)/g,"$1\\$2$3","heading (=)"),t=i(t,/(\r\n|\n)(-{3,})(\r\n|\n)/g,"$1\\$2$3","heading (-)"),t=i(t,/^(#+)/g,"\\$1","heading (#)"),t=i(t,/(\r\n|\n)(#+)/g,"$1\\$2","heading (^#)"),t=i(t,/`/g,"\\`","code (`)"),t=i(t,p,"$1","code block (^)"),t=i(t,w,"$1","code block"),t.replace("&gt;","\\>")}function f(n){n=r(n);var i=n.match(/_/g),t;return i&&i.length%2==1&&(t=n.lastIndexOf("_"),n=n.substring(0,t)+"\\"+n.substring(t)),n}function e(n,i){var u="",e=/^(\*\*)(.*?)(\*\*)/;if(n.originalNode.nodeName.toUpperCase()==="#TEXT"&&(u=n.originalNode.textContent),u&&(u=r(u)),i)switch(n.elementType){case"text":u=i;break;case"link":n.originalNode.href&&(u="["+i+"]("+f(n.originalNode.href)+")");break;case"paragraph":u=t+i+t;break;case"italics":u="_"+i+"_";break;case"strong":u=e.test(i)?"**"+i.replace(e,"$2")+"**":"**"+i+"**";break;case"remove":u="";break;default:u="<"+n.nodeType+">"+u+i+"<\/"+n.nodeType+">"}return u}function u(n){var i="",t=0;if(n.childNodes.length>0)for(t=0;t<n.childNodes.length;t++)i+=u(n.childNodes[t]);return e(n,i)}var o=function(t){t.render(n)};return u(this)},{toMD:u,config:{"#TEXT":{drawAs:"text"},A:{drawAs:"link"},ABBR:{drawAs:"text"},B:{drawAs:"strong"},BIG:{drawAs:"text"},BLOCKQUOTE:{drawAs:"paragraph"},BR:{drawAs:"paragraph"},CENTER:{drawAs:"text"},CITE:{drawAs:"paragraph"},CODE:{drawAs:"text"},DD:{drawAs:"paragraph"},DEL:{drawAs:"text"},DIV:{drawAs:"paragraph"},DL:{drawAs:"text"},DT:{drawAs:"paragraph"},EM:{drawAs:"italics"},FORM:{drawAs:"paragraph"},H1:{drawAs:"paragraph"},H2:{drawAs:"paragraph"},H3:{drawAs:"paragraph"},H4:{drawAs:"paragraph"},H5:{drawAs:"paragraph"},H6:{drawAs:"paragraph"},I:{drawAs:"italics"},LABEL:{drawAs:"text"},LI:{drawAs:"paragraph"},OL:{drawAs:"text"},P:{drawAs:"paragraph"},PRE:{drawAs:"paragraph"},Q:{drawAs:"text"},SCRIPT:{drawAs:"remove"},SMALL:{drawAs:"text"},SPAN:{drawAs:"text"},STRONG:{drawAs:"strong"},SUB:{drawAs:"text"},SUP:{drawAs:"text"},TABLE:{drawAs:"remove"},TT:{drawAs:"text"},UL:{drawAs:"text"}}}};wysihtml5={version:"0.4.0pre",commands:{},dom:{},quirks:{},toolbar:{},lang:{},selection:{},views:{},INVISIBLE_SPACE:"﻿",EMPTY_FUNCTION:function(){},ELEMENT_NODE:1,TEXT_NODE:3,BACKSPACE_KEY:8,ENTER_KEY:13,ESCAPE_KEY:27,SPACE_KEY:32,DELETE_KEY:46};window.rangy=function(){function t(n,t){var i=typeof n[t];return i==k||!!(i==p&&n[t])||i=="unknown"}function f(n,t){return!!(typeof n[t]==p&&n[t])}function w(n,t){return typeof n[t]!=r}function s(n){return function(t,i){for(var r=i.length;r--;)if(!n(t,i[r]))return!1;return!0}}function b(n){return n&&h(n,tt)&&c(n,nt)}function i(t){window.alert("Rangy not supported in your browser. Reason: "+t);n.initialized=!0;n.supported=!1}function rt(t){var i="Rangy warning: "+t;n.config.alertOnWarn?window.alert(i):typeof console!=r&&typeof window.console.log!=r&&window.console.log(i)}function v(){var r,u,e,o,v,s,y;if(!n.initialized)for(u=!1,e=!1,t(document,"createRange")&&(r=document.createRange(),h(r,g)&&c(r,d)&&(u=!0),r.detach()),o=f(document,"body")?document.body:document.getElementsByTagName("body")[0],o&&t(o,"createTextRange")&&(r=o.createTextRange(),b(r)&&(e=!0)),u||e||i("Neither Range nor TextRange are implemented"),n.initialized=!0,n.features={implementsDomRange:u,implementsTextRange:e},v=a.concat(l),s=0,y=v.length;s<y;++s)try{v[s](n)}catch(p){f(window,"console")&&t(window.console,"log")&&window.console.log("Init listener threw an exception. Continuing.",p)}}function ut(n){n=n||window;v();for(var t=0,i=e.length;t<i;++t)e[t](n)}function u(n){this.name=n;this.initialized=!1;this.supported=!1}var p="object",k="function",r="undefined",d=["startContainer","startOffset","endContainer","endOffset","collapsed","commonAncestorContainer","START_TO_START","START_TO_END","END_TO_START","END_TO_END"],g=["setStart","setStartBefore","setStartAfter","setEnd","setEndBefore","setEndAfter","collapse","selectNode","selectNodeContents","compareBoundaryPoints","deleteContents","extractContents","cloneContents","insertNode","surroundContents","cloneRange","toString","detach"],nt=["boundingHeight","boundingLeft","boundingTop","boundingWidth","htmlText","text"],tt=["collapse","compareEndPoints","duplicate","getBookmark","moveToBookmark","moveToElementText","parentElement","pasteHTML","select","setEndPoint","getBoundingClientRect"],h=s(t),it=s(f),c=s(w),n={version:"1.2.2",initialized:!1,supported:!0,util:{isHostMethod:t,isHostObject:f,isHostProperty:w,areHostMethods:h,areHostObjects:it,areHostProperties:c,isTextRange:b},features:{},modules:{},config:{alertOnWarn:!1,preferTextRange:!1}},l,a,e,y,o;if(n.fail=i,n.warn=rt,{}.hasOwnProperty?n.util.extend=function(n,t){for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i])}:i("hasOwnProperty not supported"),l=[],a=[],n.init=v,n.addInitListener=function(t){n.initialized?t(n):l.push(t)},e=[],n.addCreateMissingNativeApiListener=function(n){e.push(n)},n.createMissingNativeApi=ut,u.prototype.fail=function(n){this.initialized=!0;this.supported=!1;throw new Error("Module '"+this.name+"' failed to load: "+n);},u.prototype.warn=function(t){n.warn("Module "+this.name+": "+t)},u.prototype.createError=function(n){return new Error("Error in Rangy "+this.name+" module: "+n)},n.createModule=function(t,i){var r=new u(t);n.modules[t]=r;a.push(function(n){i(n,r);r.initialized=!0;r.supported=!0})},n.requireModules=function(t){for(var f=0,e=t.length,i,r;f<e;++f){if(r=t[f],i=n.modules[r],!i||!(i instanceof u))throw new Error("Module '"+r+"' not found");if(!i.supported)throw new Error("Module '"+r+"' not supported");}},y=!1,o=function(){y||(y=!0,n.initialized||v())},typeof window==r){i("No window found");return}if(typeof document==r){i("No document found");return}return t(document,"addEventListener")&&document.addEventListener("DOMContentLoaded",o,!1),t(window,"addEventListener")?window.addEventListener("load",o,!1):t(window,"attachEvent")?window.attachEvent("onload",o):i("Window does not have required addEventListener or attachEvent method"),n}();rangy.createModule("DomUtil",function(n,t){function b(n){var t;return typeof n.namespaceURI==i||(t=n.namespaceURI)===null||t=="http://www.w3.org/1999/xhtml"}function k(n){var t=n.parentNode;return t.nodeType==1?t:null}function h(n){for(var t=0;n=n.previousSibling;)t++;return t}function d(n){var t;return c(n)?n.length:(t=n.childNodes)?t.length:0}function a(n,t){for(var r=[],i=n;i;i=i.parentNode)r.push(i);for(i=t;i;i=i.parentNode)if(s(r,i))return i;return null}function g(n,t,i){for(var r=i?t:t.parentNode;r;){if(r===n)return!0;r=r.parentNode}return!1}function f(n,t,i){for(var u,r=i?n:n.parentNode;r;){if(u=r.parentNode,u===t)return r;r=u}return null}function c(n){var t=n.nodeType;return t==3||t==4||t==8}function v(n,t){var i=t.nextSibling,r=t.parentNode;return i?r.insertBefore(n,i):r.appendChild(n),n}function nt(n,t){var i=n.cloneNode(!1);return i.deleteData(0,t),n.deleteData(t,n.length-t),v(i,n),i}function e(n){if(n.nodeType==9)return n;if(typeof n.ownerDocument!=i)return n.ownerDocument;if(typeof n.document!=i)return n.document;if(n.parentNode)return e(n.parentNode);throw new Error("getDocument: no document found for node");}function tt(n){var t=e(n);if(typeof t.defaultView!=i)return t.defaultView;if(typeof t.parentWindow!=i)return t.parentWindow;throw new Error("Cannot get a window object for node");}function it(n){if(typeof n.contentDocument!=i)return n.contentDocument;if(typeof n.contentWindow!=i)return n.contentWindow.document;throw new Error("getIframeWindow: No Document object found for iframe element");}function rt(n){if(typeof n.contentWindow!=i)return n.contentWindow;if(typeof n.contentDocument!=i)return n.contentDocument.defaultView;throw new Error("getIframeWindow: No Window object found for iframe element");}function ut(n){return r.isHostObject(n,"body")?n.body:n.getElementsByTagName("body")[0]}function ft(n){for(var t;t=n.parentNode;)n=t;return n}function et(n,t,i,r){var o,u,s,c,e;if(n==i)return t===r?0:t<r?-1:1;if(o=f(i,n,!0))return t<=h(o)?-1:1;if(o=f(n,i,!0))return h(o)<r?-1:1;if(u=a(n,i),s=n===u?u:f(n,u,!0),c=i===u?u:f(i,u,!0),s===c)throw new Error("comparePoints got to case 4 and childA and childB are the same!");else{for(e=u.firstChild;e;){if(e===s)return-1;if(e===c)return 1;e=e.nextSibling}throw new Error("Should not be here!");}}function ot(n){for(var t=e(n).createDocumentFragment(),i;i=n.firstChild;)t.appendChild(i);return t}function y(n){if(!n)return"[No node]";if(c(n))return'"'+n.data+'"';if(n.nodeType==1){var t=n.id?' id="'+n.id+'"':"";return"<"+n.nodeName+t+">["+n.childNodes.length+"]"}return n.nodeName}function p(n){this.root=n;this._next=n}function st(n){return new p(n)}function w(n,t){this.node=n;this.offset=t}function l(n){this.code=this[n];this.codeName=n;this.message="DOMException: "+this.codeName}var i="undefined",r=n.util,u,o,s;r.areHostMethods(document,["createDocumentFragment","createElement","createTextNode"])||t.fail("document missing a Node creation method");r.isHostMethod(document,"getElementsByTagName")||t.fail("document missing getElementsByTagName method");u=document.createElement("div");r.areHostMethods(u,["insertBefore","appendChild","cloneNode"]||!r.areHostObjects(u,["previousSibling","nextSibling","childNodes","parentNode"]))||t.fail("Incomplete Element implementation");r.isHostProperty(u,"innerHTML")||t.fail("Element is missing innerHTML property");o=document.createTextNode("test");r.areHostMethods(o,["splitText","deleteData","insertData","appendData","cloneNode"]||!r.areHostObjects(u,["previousSibling","nextSibling","childNodes","parentNode"])||!r.areHostProperties(o,["data"]))||t.fail("Incomplete Text Node implementation");s=function(n,t){for(var i=n.length;i--;)if(n[i]===t)return!0;return!1};p.prototype={_current:null,hasNext:function(){return!!this._next},next:function(){var n=this._current=this._next,t,i;if(this._current)if(t=n.firstChild,t)this._next=t;else{for(i=null;n!==this.root&&!(i=n.nextSibling);)n=n.parentNode;this._next=i}return this._current},detach:function(){this._current=this._next=this.root=null}};w.prototype={equals:function(n){return this.node===n.node&this.offset==n.offset},inspect:function(){return"[DomPosition("+y(this.node)+":"+this.offset+")]"}};l.prototype={INDEX_SIZE_ERR:1,HIERARCHY_REQUEST_ERR:3,WRONG_DOCUMENT_ERR:4,NO_MODIFICATION_ALLOWED_ERR:7,NOT_FOUND_ERR:8,NOT_SUPPORTED_ERR:9,INVALID_STATE_ERR:11};l.prototype.toString=function(){return this.message};n.dom={arrayContains:s,isHtmlNamespace:b,parentElement:k,getNodeIndex:h,getNodeLength:d,getCommonAncestor:a,isAncestorOf:g,getClosestAncestorIn:f,isCharacterDataNode:c,insertAfter:v,splitDataNode:nt,getDocument:e,getWindow:tt,getIframeWindow:rt,getIframeDocument:it,getBody:ut,getRootContainer:ft,comparePoints:et,inspectNode:y,fragmentFromNodeChildren:ot,createIterator:st,DomPosition:w};n.DOMException=l});rangy.createModule("DomRange",function(n){function c(n,i){return n.nodeType!=3&&(t.isAncestorOf(n,i.startContainer,!0)||t.isAncestorOf(n,i.endContainer,!0))}function r(n){return t.getDocument(n.startContainer)}function ot(n,t,i){var u=n._listeners[t],r,f;if(u)for(r=0,f=u.length;r<f;++r)u[r].call(n,{target:n,args:i})}function st(n){return new et(n.parentNode,t.getNodeIndex(n))}function b(n){return new et(n.parentNode,t.getNodeIndex(n)+1)}function ht(n,i,r){var u=n.nodeType==11?n.firstChild:n;return t.isCharacterDataNode(i)?r==i.length?t.insertAfter(n,i):i.parentNode.insertBefore(n,r==0?i:t.splitDataNode(i,r)):r>=i.childNodes.length?i.appendChild(n):i.insertBefore(n,i.childNodes[r]),u}function ct(n){for(var i,t,e=r(n.range).createDocumentFragment(),u;t=n.next();){if(i=n.isPartiallySelectedSubtree(),t=t.cloneNode(!i),i&&(u=n.getSubtreeIterator(),t.appendChild(ct(u)),u.detach(!0)),t.nodeType==10)throw new f("HIERARCHY_REQUEST_ERR");e.appendChild(t)}return e}function y(n,i,r){var e,o,u,f;for(r=r||{stop:!1};u=n.next();)if(n.isPartiallySelectedSubtree()){if(i(u)===!1){r.stop=!0;return}if(f=n.getSubtreeIterator(),y(f,i,r),f.detach(!0),r.stop)return}else for(e=t.createIterator(u);o=e.next();)if(i(o)===!1){r.stop=!0;return}}function lt(n){for(var t;n.next();)n.isPartiallySelectedSubtree()?(t=n.getSubtreeIterator(),lt(t),t.detach(!0)):n.remove()}function at(n){for(var t,u=r(n.range).createDocumentFragment(),i;t=n.next();){if(n.isPartiallySelectedSubtree()?(t=t.cloneNode(!1),i=n.getSubtreeIterator(),t.appendChild(at(i)),i.detach(!0)):n.remove(),t.nodeType==10)throw new f("HIERARCHY_REQUEST_ERR");u.appendChild(t)}return u}function vt(n,t,i){var u=!!(t&&t.length),f,e=!!i,r;return u&&(f=new RegExp("^("+t.join("|")+")$")),r=[],y(new o(n,!1),function(n){(!u||f.test(n.nodeType))&&(!e||i(n))&&r.push(n)}),r}function yt(n){var i=typeof n.getName=="undefined"?"Range":n.getName();return"["+i+"("+t.inspectNode(n.startContainer)+":"+n.startOffset+", "+t.inspectNode(n.endContainer)+":"+n.endOffset+")]"}function o(n,i){if(this.range=n,this.clonePartiallySelectedTextNodes=i,!n.collapsed){this.sc=n.startContainer;this.so=n.startOffset;this.ec=n.endContainer;this.eo=n.endOffset;var r=n.commonAncestorContainer;this.sc===this.ec&&t.isCharacterDataNode(this.sc)?(this.isSingleCharacterDataNode=!0,this._first=this._last=this._next=this.sc):(this._first=this._next=this.sc===r&&!t.isCharacterDataNode(this.sc)?this.sc.childNodes[this.so]:t.getClosestAncestorIn(this.sc,r,!0),this._last=this.ec===r&&!t.isCharacterDataNode(this.ec)?this.ec.childNodes[this.eo-1]:t.getClosestAncestorIn(this.ec,r,!0))}}function s(n){this.code=this[n];this.codeName=n;this.message="RangeException: "+this.codeName}function pt(n,t,i){this.nodes=vt(n,t,i);this._next=this.nodes[0];this._position=0}function k(n){return function(i,r){for(var f,u=r?i:i.parentNode;u;){if(f=u.nodeType,t.arrayContains(n,f))return u;u=u.parentNode}return null}}function a(n,t){if(vi(n,t))throw new s("INVALID_NODE_TYPE_ERR");}function e(n){if(!n.startContainer)throw new f("INVALID_STATE_ERR");}function v(n,i){if(!t.arrayContains(i,n.nodeType))throw new s("INVALID_NODE_TYPE_ERR");}function g(n,i){if(i<0||i>(t.isCharacterDataNode(n)?n.length:n.childNodes.length))throw new f("INDEX_SIZE_ERR");}function nt(n,t){if(d(n,!0)!==d(t,!0))throw new f("WRONG_DOCUMENT_ERR");}function h(n){if(ai(n,!0))throw new f("NO_MODIFICATION_ALLOWED_ERR");}function p(n,t){if(!n)throw new f(t);}function kt(n){return!t.arrayContains(bt,n.nodeType)&&!d(n,!0)}function dt(n,i){return i<=(t.isCharacterDataNode(n)?n.length:n.childNodes.length)}function i(n){if(e(n),kt(n.startContainer)||kt(n.endContainer)||!dt(n.startContainer,n.startOffset)||!dt(n.endContainer,n.endOffset))throw new Error("Range error: Range is no longer valid after DOM mutation ("+n.inspect()+")");}function ft(){}function ui(n){n.START_TO_START=rt;n.START_TO_END=gt;n.END_TO_END=pi;n.END_TO_START=ni;n.NODE_BEFORE=ti;n.NODE_AFTER=ii;n.NODE_BEFORE_AND_AFTER=ri;n.NODE_INSIDE=ut}function fi(n){ui(n);ui(n.prototype)}function ei(n,r){return function(){var a;i(this);var u=this.startContainer,e=this.startOffset,c=this.commonAncestorContainer,f=new o(this,!0),l,s;return u!==c&&(l=t.getClosestAncestorIn(u,c,!0),s=b(l),u=s.node,e=s.offset),y(f,h),f.reset(),a=n(f),f.detach(),r(this,u,e,u,e),a}}function oi(r,u,f){function s(n,t){return function(i){e(this);v(i,wt);v(l(i),bt);var r=(n?st:b)(i);(t?y:p)(this,r.node,r.offset)}}function y(n,i,r){var f=n.endContainer,e=n.endOffset;(i!==n.startContainer||r!==n.startOffset)&&((l(i)!=l(f)||t.comparePoints(i,r,f,e)==1)&&(f=i,e=r),u(n,i,r,f,e))}function p(n,i,r){var f=n.startContainer,e=n.startOffset;(i!==n.endContainer||r!==n.endOffset)&&((l(i)!=l(f)||t.comparePoints(i,r,f,e)==-1)&&(f=i,e=r),u(n,f,e,i,r))}function w(n,t,i){(t!==n.startContainer||i!==n.startOffset||t!==n.endContainer||i!==n.endOffset)&&u(n,t,i,t,i)}r.prototype=new ft;n.util.extend(r.prototype,{setStart:function(n,t){e(this);a(n,!0);g(n,t);y(this,n,t)},setEnd:function(n,t){e(this);a(n,!0);g(n,t);p(this,n,t)},setStartBefore:s(!0,!0),setStartAfter:s(!1,!0),setEndBefore:s(!0,!1),setEndAfter:s(!1,!1),collapse:function(n){i(this);n?u(this,this.startContainer,this.startOffset,this.startContainer,this.startOffset):u(this,this.endContainer,this.endOffset,this.endContainer,this.endOffset)},selectNodeContents:function(n){e(this);a(n,!0);u(this,n,0,n,t.getNodeLength(n))},selectNode:function(n){e(this);a(n,!1);v(n,wt);var t=st(n),i=b(n);u(this,t.node,t.offset,i.node,i.offset)},extractContents:ei(at,u),deleteContents:ei(lt,u),canSurroundContents:function(){i(this);h(this.startContainer);h(this.endContainer);var n=new o(this,!0),t=n._first&&c(n._first,this)||n._last&&c(n._last,this);return n.detach(),!t},detach:function(){f(this)},splitBoundaries:function(){i(this);var n=this.startContainer,e=this.startOffset,r=this.endContainer,f=this.endOffset,o=n===r;t.isCharacterDataNode(r)&&f>0&&f<r.length&&t.splitDataNode(r,f);t.isCharacterDataNode(n)&&e>0&&e<n.length&&(n=t.splitDataNode(n,e),o?(f-=e,r=n):r==n.parentNode&&f>=t.getNodeIndex(n)&&f++,e=0);u(this,n,e,r,f)},normalizeBoundaries:function(){var o,s;i(this);var f=this.startContainer,e=this.startOffset,n=this.endContainer,r=this.endOffset,h=function(t){var i=t.nextSibling;i&&i.nodeType==t.nodeType&&(n=t,r=t.length,t.appendData(i.data),i.parentNode.removeChild(i))},c=function(i){var u=i.previousSibling,s,o;u&&u.nodeType==i.nodeType&&(f=i,s=i.length,e=u.length,i.insertData(0,u.data),u.parentNode.removeChild(u),f==n?(r+=e,n=f):n==i.parentNode&&(o=t.getNodeIndex(i),r==o?(n=i,r=s):r>o&&r--))},l=!0;t.isCharacterDataNode(n)?n.length==r&&h(n):(r>0&&(o=n.childNodes[r-1],o&&t.isCharacterDataNode(o)&&h(o)),l=!this.collapsed);l?t.isCharacterDataNode(f)?e==0&&c(f):e<f.childNodes.length&&(s=f.childNodes[e],s&&t.isCharacterDataNode(s)&&c(s)):(f=n,e=r);u(this,f,e,n,r)},collapseToPoint:function(n,t){e(this);a(n,!0);g(n,t);w(this,n,t)}});fi(r)}function si(n){n.collapsed=n.startContainer===n.endContainer&&n.startOffset===n.endOffset;n.commonAncestorContainer=n.collapsed?n.startContainer:t.getCommonAncestor(n.startContainer,n.endContainer)}function hi(n,t,i,r,u){var f=n.startContainer!==t||n.startOffset!==i,e=n.endContainer!==r||n.endOffset!==u;n.startContainer=t;n.startOffset=i;n.endContainer=r;n.endOffset=u;si(n);ot(n,"boundarychange",{startMoved:f,endMoved:e})}function wi(n){e(n);n.startContainer=n.startOffset=n.endContainer=n.endOffset=null;n.collapsed=n.commonAncestorContainer=null;ot(n,"detach",null);n._listeners=null}function u(n){this.startContainer=n;this.startOffset=0;this.endContainer=n;this.endOffset=0;this._listeners={boundarychange:[],detach:[]};si(this)}var tt,w;n.requireModules(["DomUtil"]);var t=n.dom,et=t.DomPosition,f=n.DOMException;o.prototype={_current:null,_next:null,_first:null,_last:null,isSingleCharacterDataNode:!1,reset:function(){this._current=null;this._next=this._first},hasNext:function(){return!!this._next},next:function(){var n=this._current=this._next;return n&&(this._next=n!==this._last?n.nextSibling:null,t.isCharacterDataNode(n)&&this.clonePartiallySelectedTextNodes&&(n===this.ec&&(n=n.cloneNode(!0)).deleteData(this.eo,n.length-this.eo),this._current===this.sc&&(n=n.cloneNode(!0)).deleteData(0,this.so))),n},remove:function(){var n=this._current,i,r;t.isCharacterDataNode(n)&&(n===this.sc||n===this.ec)?(i=n===this.sc?this.so:0,r=n===this.ec?this.eo:n.length,i!=r&&n.deleteData(i,r-i)):n.parentNode&&n.parentNode.removeChild(n)},isPartiallySelectedSubtree:function(){var n=this._current;return c(n,this.range)},getSubtreeIterator:function(){var n;if(this.isSingleCharacterDataNode)n=this.range.cloneRange(),n.collapse();else{n=new u(r(this.range));var i=this._current,f=i,e=0,s=i,h=t.getNodeLength(i);t.isAncestorOf(i,this.sc,!0)&&(f=this.sc,e=this.so);t.isAncestorOf(i,this.ec,!0)&&(s=this.ec,h=this.eo);hi(n,f,e,s,h)}return new o(n,this.clonePartiallySelectedTextNodes)},detach:function(n){n&&this.range.detach();this.range=this._current=this._next=this._first=this._last=this.sc=this.so=this.ec=this.eo=null}};s.prototype={BAD_BOUNDARYPOINTS_ERR:1,INVALID_NODE_TYPE_ERR:2};s.prototype.toString=function(){return this.message};pt.prototype={_current:null,hasNext:function(){return!!this._next},next:function(){return this._current=this._next,this._next=this.nodes[++this._position],this._current},detach:function(){this._current=this._next=this.nodes=null}};var wt=[1,3,4,5,7,8,10],bt=[2,9,11],ci=[1,3,4,5,7,8,10,11],li=[1,3,4,5,7,8];var l=t.getRootContainer,d=k([9,11]),ai=k([5,6,10,12]),vi=k([6,10,12]);tt=document.createElement("style");w=!1;try{tt.innerHTML="<b>x<\/b>";w=tt.firstChild.nodeType==3}catch(bi){}n.features.htmlParsingConforms=w;var yi=w?function(n){var r=this.startContainer,u=t.getDocument(r),i;if(!r)throw new f("INVALID_STATE_ERR");return i=null,r.nodeType==1?i=r:t.isCharacterDataNode(r)&&(i=t.parentElement(r)),i=i===null||i.nodeName=="HTML"&&t.isHtmlNamespace(t.getDocument(i).documentElement)&&t.isHtmlNamespace(i)?u.createElement("body"):i.cloneNode(!1),i.innerHTML=n,t.fragmentFromNodeChildren(i)}:function(n){e(this);var u=r(this),i=u.createElement("body");return i.innerHTML=n,t.fragmentFromNodeChildren(i)},it=["startContainer","startOffset","endContainer","endOffset","collapsed","commonAncestorContainer"],rt=0,gt=1,pi=2,ni=3,ti=0,ii=1,ri=2,ut=3;ft.prototype={attachListener:function(n,t){this._listeners[n].push(t)},compareBoundaryPoints:function(n,r){i(this);nt(this.startContainer,r.startContainer);var u,f,e,o,s=n==ni||n==rt?"start":"end",h=n==gt||n==rt?"start":"end";return u=this[s+"Container"],f=this[s+"Offset"],e=r[h+"Container"],o=r[h+"Offset"],t.comparePoints(u,f,e,o)},insertNode:function(n){if(i(this),v(n,ci),h(this.startContainer),t.isAncestorOf(n,this.startContainer,!0))throw new f("HIERARCHY_REQUEST_ERR");var r=ht(n,this.startContainer,this.startOffset);this.setStartBefore(r)},cloneContents:function(){var n,u,f;return i(this),this.collapsed?r(this).createDocumentFragment():this.startContainer===this.endContainer&&t.isCharacterDataNode(this.startContainer)?(n=this.startContainer.cloneNode(!0),n.data=n.data.slice(this.startOffset,this.endOffset),u=r(this).createDocumentFragment(),u.appendChild(n),u):(f=new o(this,!0),n=ct(f),f.detach(),n)},canSurroundContents:function(){i(this);h(this.startContainer);h(this.endContainer);var n=new o(this,!0),t=n._first&&c(n._first,this)||n._last&&c(n._last,this);return n.detach(),!t},surroundContents:function(n){if(v(n,li),!this.canSurroundContents())throw new s("BAD_BOUNDARYPOINTS_ERR");var t=this.extractContents();if(n.hasChildNodes())while(n.lastChild)n.removeChild(n.lastChild);ht(n,this.startContainer,this.startOffset);n.appendChild(t);this.selectNode(n)},cloneRange:function(){i(this);for(var t=new u(r(this)),f=it.length,n;f--;)n=it[f],t[n]=this[n];return t},toString:function(){var n,r,u;return i(this),n=this.startContainer,n===this.endContainer&&t.isCharacterDataNode(n)?n.nodeType==3||n.nodeType==4?n.data.slice(this.startOffset,this.endOffset):"":(r=[],u=new o(this,!0),y(u,function(n){(n.nodeType==3||n.nodeType==4)&&r.push(n.data)}),u.detach(),r.join(""))},compareNode:function(n){var r,u,o,e;if(i(this),r=n.parentNode,u=t.getNodeIndex(n),!r)throw new f("NOT_FOUND_ERR");return o=this.comparePoint(r,u),e=this.comparePoint(r,u+1),o<0?e>0?ri:ti:e>0?ii:ut},comparePoint:function(n,r){return(i(this),p(n,"HIERARCHY_REQUEST_ERR"),nt(n,this.startContainer),t.comparePoints(n,r,this.startContainer,this.startOffset)<0)?-1:t.comparePoints(n,r,this.endContainer,this.endOffset)>0?1:0},createContextualFragment:yi,toHtml:function(){i(this);var n=r(this).createElement("div");return n.appendChild(this.cloneContents()),n.innerHTML},intersectsNode:function(n,u){var f,e,o,s;return(i(this),p(n,"NOT_FOUND_ERR"),t.getDocument(n)!==r(this))?!1:(f=n.parentNode,e=t.getNodeIndex(n),p(f,"NOT_FOUND_ERR"),o=t.comparePoints(f,e,this.endContainer,this.endOffset),s=t.comparePoints(f,e+1,this.startContainer,this.startOffset),u?o<=0&&s>=0:o<0&&s>0)},isPointInRange:function(n,r){return i(this),p(n,"HIERARCHY_REQUEST_ERR"),nt(n,this.startContainer),t.comparePoints(n,r,this.startContainer,this.startOffset)>=0&&t.comparePoints(n,r,this.endContainer,this.endOffset)<=0},intersectsRange:function(n,u){if(i(this),r(n)!=r(this))throw new f("WRONG_DOCUMENT_ERR");var e=t.comparePoints(this.startContainer,this.startOffset,n.endContainer,n.endOffset),o=t.comparePoints(this.endContainer,this.endOffset,n.startContainer,n.startOffset);return u?e<=0&&o>=0:e<0&&o>0},intersection:function(n){if(this.intersectsRange(n)){var r=t.comparePoints(this.startContainer,this.startOffset,n.startContainer,n.startOffset),u=t.comparePoints(this.endContainer,this.endOffset,n.endContainer,n.endOffset),i=this.cloneRange();return r==-1&&i.setStart(n.startContainer,n.startOffset),u==1&&i.setEnd(n.endContainer,n.endOffset),i}return null},union:function(n){if(this.intersectsRange(n,!0)){var i=this.cloneRange();return t.comparePoints(n.startContainer,n.startOffset,this.startContainer,this.startOffset)==-1&&i.setStart(n.startContainer,n.startOffset),t.comparePoints(n.endContainer,n.endOffset,this.endContainer,this.endOffset)==1&&i.setEnd(n.endContainer,n.endOffset),i}throw new s("Ranges do not intersect");},containsNode:function(n,t){return t?this.intersectsNode(n,!1):this.compareNode(n)==ut},containsNodeContents:function(n){return this.comparePoint(n,0)>=0&&this.comparePoint(n,t.getNodeLength(n))<=0},containsRange:function(n){return this.intersection(n).equals(n)},containsNodeText:function(n){var t=this.cloneRange(),i,r,u;return t.selectNode(n),i=t.getNodes([3]),i.length>0?(t.setStart(i[0],0),r=i.pop(),t.setEnd(r,r.length),u=this.containsRange(t),t.detach(),u):this.containsNodeContents(n)},createNodeIterator:function(n,t){return i(this),new pt(this,n,t)},getNodes:function(n,t){return i(this),vt(this,n,t)},getDocument:function(){return r(this)},collapseBefore:function(n){e(this);this.setEndBefore(n);this.collapse(!1)},collapseAfter:function(n){e(this);this.setStartAfter(n);this.collapse(!0)},getName:function(){return"DomRange"},equals:function(n){return u.rangesEqual(this,n)},inspect:function(){return yt(this)}};oi(u,hi,wi);n.rangePrototype=ft.prototype;u.rangeProperties=it;u.RangeIterator=o;u.copyComparisonConstants=fi;u.createPrototypeRange=oi;u.inspect=yt;u.getRangeDocument=r;u.rangesEqual=function(n,t){return n.startContainer===t.startContainer&&n.startOffset===t.startOffset&&n.endContainer===t.endContainer&&n.endOffset===t.endOffset};n.DomRange=u;n.RangeException=s});rangy.createModule("WrappedRange",function(n){function s(n){var e=n.parentElement(),i=n.duplicate(),r,f,u;return i.collapse(!0),r=i.parentElement(),i=n.duplicate(),i.collapse(!1),f=i.parentElement(),u=r==f?r:t.getCommonAncestor(r,f),u==e?u:t.getCommonAncestor(e,u)}function h(n){return n.compareEndPoints("StartToEnd",n)==0}function f(n,i,u,f){var s=n.duplicate(),o,e,y,w,c,a,p,l,v,h,b;if(s.collapse(u),o=s.parentElement(),t.isAncestorOf(i,o,!0)||(o=i),!o.canHaveHTML)return new r(o.parentNode,t.getNodeIndex(o));e=t.getDocument(o).createElement("span");w=u?"StartToStart":"StartToEnd";do o.insertBefore(e,e.previousSibling),s.moveToElementText(e);while((y=s.compareEndPoints(w,n))>0&&e.previousSibling);if(l=e.nextSibling,y==-1&&l&&t.isCharacterDataNode(l)){if(s.setEndPoint(u?"EndToStart":"EndToEnd",n),/[\r\n]/.test(l.data))for(h=s.duplicate(),b=h.text.replace(/\r\n/g,"\r").length,v=h.moveStart("character",b);(y=h.compareEndPoints("StartToEnd",h))==-1;)v++,h.moveStart("character",1);else v=s.text.length;p=new r(l,v)}else c=(f||!u)&&e.previousSibling,a=(f||u)&&e.nextSibling,p=a&&t.isCharacterDataNode(a)?new r(a,0):c&&t.isCharacterDataNode(c)?new r(c,c.length):new r(o,t.getNodeIndex(e));return e.parentNode.removeChild(e),p}function e(n,i){var u,f,o=n.offset,h=t.getDocument(n.node),r,s,e=h.body.createTextRange(),c=t.isCharacterDataNode(n.node);return c?(u=n.node,f=u.parentNode):(s=n.node.childNodes,u=o<s.length?s[o]:null,f=n.node),r=h.createElement("span"),r.innerHTML="&#feff;",u?f.insertBefore(r,u):f.appendChild(r),e.moveToElementText(r),e.collapse(!i),f.removeChild(r),c&&e[i?"moveStart":"moveEnd"]("character",o),e}var o;n.requireModules(["DomUtil","DomRange"]);var i,t=n.dom,r=t.DomPosition,u=n.DomRange;!n.features.implementsDomRange||n.features.implementsTextRange&&n.config.preferTextRange?n.features.implementsTextRange&&(i=function(n){this.textRange=n;this.refresh()},i.prototype=new u(document),i.prototype.refresh=function(){var n,t,i=s(this.textRange);h(this.textRange)?t=n=f(this.textRange,i,!0,!0):(n=f(this.textRange,i,!0,!1),t=f(this.textRange,i,!1,!1));this.setStart(n.node,n.offset);this.setEnd(t.node,t.offset)},u.copyComparisonConstants(i),o=function(){return this}(),typeof o.Range=="undefined"&&(o.Range=i),n.createNativeRange=function(n){return n=n||document,n.body.createTextRange()}):(function(){function o(n){for(var i=c.length,t;i--;)t=c[i],n[t]=n.nativeRange[t]}function a(n,t,i,r,u){var f=n.startContainer!==t||n.startOffset!=i,e=n.endContainer!==r||n.endOffset!=u;(f||e)&&(n.setEnd(r,u),n.setStart(t,i))}function v(n){n.nativeRange.detach();n.detached=!0;for(var t=c.length,i;t--;)i=c[t],n[i]=null}var r,c=u.rangeProperties,l,h,e,f,s;i=function(n){if(!n)throw new Error("Range must be specified");this.nativeRange=n;o(this)};u.createPrototypeRange(i,a,v);r=i.prototype;r.selectNode=function(n){this.nativeRange.selectNode(n);o(this)};r.deleteContents=function(){this.nativeRange.deleteContents();o(this)};r.extractContents=function(){var n=this.nativeRange.extractContents();return o(this),n};r.cloneContents=function(){return this.nativeRange.cloneContents()};r.surroundContents=function(n){this.nativeRange.surroundContents(n);o(this)};r.collapse=function(n){this.nativeRange.collapse(n);o(this)};r.cloneRange=function(){return new i(this.nativeRange.cloneRange())};r.refresh=function(){o(this)};r.toString=function(){return this.nativeRange.toString()};e=document.createTextNode("test");t.getBody(document).appendChild(e);f=document.createRange();f.setStart(e,0);f.setEnd(e,0);try{f.setStart(e,1);l=!0;r.setStart=function(n,t){this.nativeRange.setStart(n,t);o(this)};r.setEnd=function(n,t){this.nativeRange.setEnd(n,t);o(this)};h=function(n){return function(t){this.nativeRange[n](t);o(this)}}}catch(y){l=!1;r.setStart=function(n,t){try{this.nativeRange.setStart(n,t)}catch(i){this.nativeRange.setEnd(n,t);this.nativeRange.setStart(n,t)}o(this)};r.setEnd=function(n,t){try{this.nativeRange.setEnd(n,t)}catch(i){this.nativeRange.setStart(n,t);this.nativeRange.setEnd(n,t)}o(this)};h=function(n,t){return function(i){try{this.nativeRange[n](i)}catch(r){this.nativeRange[t](i);this.nativeRange[n](i)}o(this)}}}r.setStartBefore=h("setStartBefore","setEndBefore");r.setStartAfter=h("setStartAfter","setEndAfter");r.setEndBefore=h("setEndBefore","setStartBefore");r.setEndAfter=h("setEndAfter","setStartAfter");f.selectNodeContents(e);r.selectNodeContents=f.startContainer==e&&f.endContainer==e&&f.startOffset==0&&f.endOffset==e.length?function(n){this.nativeRange.selectNodeContents(n);o(this)}:function(n){this.setStart(n,0);this.setEnd(n,u.getEndOffset(n))};f.selectNodeContents(e);f.setEnd(e,3);s=document.createRange();s.selectNodeContents(e);s.setEnd(e,4);s.setStart(e,2);r.compareBoundaryPoints=f.compareBoundaryPoints(f.START_TO_END,s)==-1&f.compareBoundaryPoints(f.END_TO_START,s)==1?function(n,t){return t=t.nativeRange||t,n==t.START_TO_END?n=t.END_TO_START:n==t.END_TO_START&&(n=t.START_TO_END),this.nativeRange.compareBoundaryPoints(n,t)}:function(n,t){return this.nativeRange.compareBoundaryPoints(n,t.nativeRange||t)};n.util.isHostMethod(f,"createContextualFragment")&&(r.createContextualFragment=function(n){return this.nativeRange.createContextualFragment(n)});t.getBody(document).removeChild(e);f.detach();s.detach()}(),n.createNativeRange=function(n){return n=n||document,n.createRange()});n.features.implementsTextRange&&(i.rangeToTextRange=function(n){if(n.collapsed)return e(new r(n.startContainer,n.startOffset),!0);var u=e(new r(n.startContainer,n.startOffset),!0),f=e(new r(n.endContainer,n.endOffset),!1),i=t.getDocument(n.startContainer).body.createTextRange();return i.setEndPoint("StartToStart",u),i.setEndPoint("EndToEnd",f),i});i.prototype.getName=function(){return"WrappedRange"};n.WrappedRange=i;n.createRange=function(t){return t=t||document,new i(n.createNativeRange(t))};n.createRangyRange=function(n){return n=n||document,new u(n)};n.createIframeRange=function(i){return n.createRange(t.getIframeDocument(i))};n.createIframeRangyRange=function(i){return n.createRangyRange(t.getIframeDocument(i))};n.addCreateMissingNativeApiListener(function(t){var i=t.document;typeof i.createRange=="undefined"&&(i.createRange=function(){return n.createRange(this)});i=t=null})});rangy.createModule("WrappedSelection",function(n,t){function ri(n){return(n||window).getSelection()}function yt(n){return(n||window).document.selection}function p(n,t,i){var r=i?"end":"start",u=i?"start":"end";n.anchorNode=t[r+"Container"];n.anchorOffset=t[r+"Offset"];n.focusNode=t[u+"Container"];n.focusOffset=t[u+"Offset"]}function ui(n){var t=n.nativeSelection;n.anchorNode=t.anchorNode;n.anchorOffset=t.anchorOffset;n.focusNode=t.focusNode;n.focusOffset=t.focusOffset}function s(n){n.anchorNode=n.focusNode=null;n.anchorOffset=n.focusOffset=0;n.rangeCount=0;n.isCollapsed=!0;n._ranges.length=0}function st(t){var i;return t instanceof h?(i=t._selectionNativeRange,i||(i=n.createNativeRange(r.getDocument(t.startContainer)),i.setEnd(t.endContainer,t.endOffset),i.setStart(t.startContainer,t.startOffset),t._selectionNativeRange=i,t.attachListener("detach",function(){this._selectionNativeRange=null}))):t instanceof k?i=t.nativeRange:n.features.implementsDomRange&&t instanceof r.getWindow(t.startContainer).Range&&(i=t),i}function fi(n){if(!n.length||n[0].nodeType!=1)return!1;for(var t=1,i=n.length;t<i;++t)if(!r.isAncestorOf(n[0],n[t]))return!1;return!0}function ht(n){var t=n.getNodes();if(!fi(t))throw new Error("getSingleElementFromRange: range "+n.inspect()+" did not consist of a single element");return t[0]}function kt(n){return!!n&&typeof n.text!="undefined"}function dt(n,t){var i=new k(t);n._ranges=[i];p(n,i,!1);n.rangeCount=1;n.isCollapsed=i.collapsed}function w(t){var i,f,e,u;if(t._ranges.length=0,t.docSelection.type=="None")s(t);else if(i=t.docSelection.createRange(),kt(i))dt(t,i);else{for(t.rangeCount=i.length,e=r.getDocument(i.item(0)),u=0;u<t.rangeCount;++u)f=n.createRange(e),f.selectNode(i.item(u)),t._ranges.push(f);t.isCollapsed=t.rangeCount==1&&t._ranges[0].collapsed;p(t,t._ranges[t.rangeCount-1],!1)}}function gt(n,t){for(var i=n.docSelection.createRange(),e=ht(t),o=r.getDocument(i.item(0)),u=r.getBody(o).createControlRange(),f=0,s=i.length;f<s;++f)u.add(i.item(f));try{u.add(e)}catch(h){throw new Error("addRange(): Element within the specified Range could not be added to control selection (does it have layout?)");}u.select();w(n)}function rt(n,t,i){this.nativeSelection=n;this.docSelection=t;this._ranges=[];this.win=i;this.refresh()}function ni(n,t){for(var e=r.getDocument(t[0].startContainer),u=r.getBody(e).createControlRange(),i=0,f;i<rangeCount;++i){f=ht(t[i]);try{u.add(f)}catch(o){throw new Error("setRanges(): Element within the one of the specified Ranges could not be added to control selection (does it have layout?)");}}u.select();w(n)}function ti(n,t){if(n.anchorNode&&r.getDocument(n.anchorNode)!==r.getDocument(t))throw new d("WRONG_DOCUMENT_ERR");}function ii(n){var i=[],u=new vt(n.anchorNode,n.anchorOffset),f=new vt(n.focusNode,n.focusOffset),e=typeof n.getName=="function"?n.getName():"Selection",t,r;if(typeof n.rangeCount!="undefined")for(t=0,r=n.rangeCount;t<r;++t)i[t]=h.inspect(n.getRangeAt(t));return"["+e+"(Ranges: "+i.join(", ")+")(anchor: "+u.inspect()+", focus: "+f.inspect()+"]"}var nt,et,tt,ot,e,bt,it,i,ct,ut,lt,b;n.requireModules(["DomUtil","DomRange","WrappedRange"]);n.config.checkSelectionRanges=!0;var at="boolean",ft="_rangySelection",r=n.dom,f=n.util,h=n.DomRange,k=n.WrappedRange,d=n.DOMException,vt=r.DomPosition,l,g,o="Control";var pt=n.util.isHostMethod(window,"getSelection"),a=n.util.isHostObject(document,"selection"),v=a&&(!pt||n.config.preferTextRange);v?(l=yt,n.isSelectionValid=function(n){var t=(n||window).document,i=t.selection;return i.type!="None"||r.getDocument(i.createRange().parentElement())==t}):pt?(l=ri,n.isSelectionValid=function(){return!0}):t.fail("Neither document.selection or window.getSelection() detected.");n.getNativeSelection=l;var u=l(),wt=n.createNativeRange(document),y=r.getBody(document),c=f.areHostObjects(u,["anchorNode","focusNode"]&&f.areHostProperties(u,["anchorOffset","focusOffset"]));if(n.features.selectionHasAnchorAndFocus=c,nt=f.isHostMethod(u,"extend"),n.features.selectionHasExtend=nt,et=typeof u.rangeCount=="number",n.features.selectionHasRangeCount=et,tt=!1,ot=!0,f.areHostMethods(u,["addRange","getRangeAt","removeAllRanges"])&&typeof u.rangeCount=="number"&&n.features.implementsDomRange&&function(){var u=document.createElement("iframe"),o=decodeURI("%3Chtml%3E%3Chead%3E%3C/head%3E%3Cbody%3E12%3C/body%3E%3C/html%3E"),t,f;y.appendChild(u);t=r.getIframeDocument(u);t.open();t.write(o);t.close();var i=r.getIframeWindow(u).getSelection(),s=t.documentElement,h=s.lastChild,e=h.firstChild,n=t.createRange();n.setStart(e,1);n.collapse(!0);i.addRange(n);ot=i.rangeCount==1;i.removeAllRanges();f=n.cloneRange();n.setStart(e,0);f.setEnd(e,2);i.addRange(n);i.addRange(f);tt=i.rangeCount==2;n.detach();f.detach();y.removeChild(u)}(),n.features.selectionSupportsMultipleRanges=tt,n.features.collapsedNonEditableSelectionsSupported=ot,e=!1,y&&f.isHostMethod(y,"createControlRange")&&(bt=y.createControlRange(),f.areHostProperties(bt,["item","add"])&&(e=!0)),n.features.implementsControlRange=e,g=c?function(n){return n.anchorNode===n.focusNode&&n.anchorOffset===n.focusOffset}:function(n){return n.rangeCount?n.getRangeAt(n.rangeCount-1).collapsed:!1},f.isHostMethod(u,"getRangeAt")?it=function(n,t){try{return n.getRangeAt(t)}catch(i){return null}}:c&&(it=function(t){var u=r.getDocument(t.anchorNode),i=n.createRange(u);return i.setStart(t.anchorNode,t.anchorOffset),i.setEnd(t.focusNode,t.focusOffset),i.collapsed!==this.isCollapsed&&(i.setStart(t.focusNode,t.focusOffset),i.setEnd(t.anchorNode,t.anchorOffset)),i}),n.getSelection=function(n){n=n||window;var t=n[ft],i=l(n),r=a?yt(n):null;return t?(t.nativeSelection=i,t.docSelection=r,t.refresh(n)):(t=new rt(i,r,n),n[ft]=t),t},n.getIframeSelection=function(t){return n.getSelection(r.getIframeWindow(t))},i=rt.prototype,!v&&c&&f.areHostMethods(u,["removeAllRanges","addRange"]))i.removeAllRanges=function(){this.nativeSelection.removeAllRanges();s(this)},ct=function(t,i){var u=h.getRangeDocument(i),r=n.createRange(u);r.collapseToPoint(i.endContainer,i.endOffset);t.nativeSelection.addRange(st(r));t.nativeSelection.extend(i.startContainer,i.startOffset);t.refresh()},i.addRange=et?function(t,i){var u,r;e&&a&&this.docSelection.type==o?gt(this,t):i&&nt?ct(this,t):(tt?u=this.rangeCount:(this.removeAllRanges(),u=0),this.nativeSelection.addRange(st(t)),this.rangeCount=this.nativeSelection.rangeCount,this.rangeCount==u+1?(n.config.checkSelectionRanges&&(r=it(this.nativeSelection,this.rangeCount-1),r&&!h.rangesEqual(r,t)&&(t=new k(r))),this._ranges[this.rangeCount-1]=t,p(this,t,b(this.nativeSelection)),this.isCollapsed=g(this)):this.refresh())}:function(n,t){t&&nt?ct(this,n):(this.nativeSelection.addRange(st(n)),this.refresh())},i.setRanges=function(n){if(e&&n.length>1)ni(this,n);else{this.removeAllRanges();for(var t=0,i=n.length;t<i;++t)this.addRange(n[t])}};else if(f.isHostMethod(u,"empty")&&f.isHostMethod(wt,"select")&&e&&v)i.removeAllRanges=function(){var n,t,i;try{this.docSelection.empty();this.docSelection.type!="None"&&(this.anchorNode?n=r.getDocument(this.anchorNode):this.docSelection.type==o&&(t=this.docSelection.createRange(),t.length&&(n=r.getDocument(t.item(0)).body.createTextRange())),n&&(i=n.body.createTextRange(),i.select(),this.docSelection.empty()))}catch(u){}s(this)},i.addRange=function(n){this.docSelection.type==o?gt(this,n):(k.rangeToTextRange(n).select(),this._ranges[0]=n,this.rangeCount=1,this.isCollapsed=this._ranges[0].collapsed,p(this,n,!1))},i.setRanges=function(n){this.removeAllRanges();var t=n.length;t>1?ni(this,n):t&&this.addRange(n[0])};else return t.fail("No means of selecting a Range or TextRange was found"),!1;if(i.getRangeAt=function(n){if(n<0||n>=this.rangeCount)throw new d("INDEX_SIZE_ERR");else return this._ranges[n]},v)ut=function(t){var i;n.isSelectionValid(t.win)?i=t.docSelection.createRange():(i=r.getBody(t.win.document).createTextRange(),i.collapse(!0));t.docSelection.type==o?w(t):kt(i)?dt(t,i):s(t)};else if(f.isHostMethod(u,"getRangeAt")&&typeof u.rangeCount=="number")ut=function(t){if(e&&a&&t.docSelection.type==o)w(t);else if(t._ranges.length=t.rangeCount=t.nativeSelection?t.nativeSelection.rangeCount:0,t.rangeCount){for(var i=0,r=t.rangeCount;i<r;++i)t._ranges[i]=new n.WrappedRange(t.nativeSelection.getRangeAt(i));p(t,t._ranges[t.rangeCount-1],b(t.nativeSelection));t.isCollapsed=g(t)}else s(t)};else if(c&&typeof u.isCollapsed==at&&typeof wt.collapsed==at&&n.features.implementsDomRange)ut=function(n){var t,i=n.nativeSelection;i.anchorNode?(t=it(i,0),n._ranges=[t],n.rangeCount=1,ui(n),n.isCollapsed=g(n)):s(n)};else return t.fail("No means of obtaining a Range or TextRange from the user's selection was found"),!1;i.refresh=function(n){var i=n?this._ranges.slice(0):null,t;if(ut(this),n){if(t=i.length,t!=this._ranges.length)return!1;while(t--)if(!h.rangesEqual(i[t],this._ranges[t]))return!1;return!0}};lt=function(n,t){var r=n.getAllRanges(),u=!1,i,f;for(n.removeAllRanges(),i=0,f=r.length;i<f;++i)u||t!==r[i]?n.addRange(r[i]):u=!0;n.rangeCount||s(n)};i.removeRange=e?function(n){var t,s;if(this.docSelection.type==o){var i=this.docSelection.createRange(),h=ht(n),c=r.getDocument(i.item(0)),u=r.getBody(c).createControlRange(),f,e=!1;for(t=0,s=i.length;t<s;++t)f=i.item(t),f!==h||e?u.add(i.item(t)):e=!0;u.select();w(this)}else lt(this,n)}:function(n){lt(this,n)};!v&&c&&n.features.implementsDomRange?(b=function(n){var t=!1;return n.anchorNode&&(t=r.comparePoints(n.anchorNode,n.anchorOffset,n.focusNode,n.focusOffset)==1),t},i.isBackwards=function(){return b(this)}):b=i.isBackwards=function(){return!1};i.toString=function(){for(var t=[],n=0,i=this.rangeCount;n<i;++n)t[n]=""+this._ranges[n];return t.join("")};i.collapse=function(t,i){ti(this,t);var u=n.createRange(r.getDocument(t));u.collapseToPoint(t,i);this.removeAllRanges();this.addRange(u);this.isCollapsed=!0};i.collapseToStart=function(){if(this.rangeCount){var n=this._ranges[0];this.collapse(n.startContainer,n.startOffset)}else throw new d("INVALID_STATE_ERR");};i.collapseToEnd=function(){if(this.rangeCount){var n=this._ranges[this.rangeCount-1];this.collapse(n.endContainer,n.endOffset)}else throw new d("INVALID_STATE_ERR");};i.selectAllChildren=function(t){ti(this,t);var i=n.createRange(r.getDocument(t));i.selectNodeContents(t);this.removeAllRanges();this.addRange(i)};i.deleteFromDocument=function(){var n,t,i,r,u;if(e&&a&&this.docSelection.type==o){for(n=this.docSelection.createRange();n.length;)t=n.item(0),n.remove(t),t.parentNode.removeChild(t);this.refresh()}else if(this.rangeCount){for(i=this.getAllRanges(),this.removeAllRanges(),r=0,u=i.length;r<u;++r)i[r].deleteContents();this.addRange(i[u-1])}};i.getAllRanges=function(){return this._ranges.slice(0)};i.setSingleRange=function(n){this.setRanges([n])};i.containsNode=function(n,t){for(var i=0,r=this._ranges.length;i<r;++i)if(this._ranges[i].containsNode(n,t))return!0;return!1};i.toHtml=function(){var i="",t,n,r;if(this.rangeCount){for(t=h.getRangeDocument(this._ranges[0]).createElement("div"),n=0,r=this._ranges.length;n<r;++n)t.appendChild(this._ranges[n].cloneContents());i=t.innerHTML}return i};i.getName=function(){return"WrappedSelection"};i.inspect=function(){return ii(this)};i.detach=function(){this.win[ft]=null;this.win=this.anchorNode=this.focusNode=null};rt.inspect=ii;n.Selection=rt;n.selectionPrototype=i;n.addCreateMissingNativeApiListener(function(t){typeof t.getSelection=="undefined"&&(t.getSelection=function(){return n.getSelection(this)});t=null})});Base=function(){};Base.extend=function(n,t){var u=Base.prototype.extend,r,f,i;return Base._prototyping=!0,r=new this,u.call(r,n),r.base=function(){},delete Base._prototyping,f=r.constructor,i=r.constructor=function(){if(!Base._prototyping)if(this._constructing||this.constructor==i)this._constructing=!0,f.apply(this,arguments),delete this._constructing;else if(arguments[0]!=null)return(arguments[0].extend||u).call(arguments[0],r)},i.ancestor=this,i.extend=this.extend,i.forEach=this.forEach,i.implement=this.implement,i.prototype=r,i.toString=this.toString,i.valueOf=function(n){return n=="object"?i:f.valueOf()},u.call(i,t),typeof i.init=="function"&&i.init(),i};Base.prototype={extend:function(n,t){var r,f,u,i;if(arguments.length>1)r=this[n],r&&typeof t=="function"&&(!r.valueOf||r.valueOf()!=t.valueOf())&&/\bbase\b/.test(t)&&(f=t.valueOf(),t=function(){var t=this.base||Base.prototype.base,n;return this.base=r,n=f.apply(this,arguments),this.base=t,n},t.valueOf=function(n){return n=="object"?t:f},t.toString=Base.toString),this[n]=t;else if(n){u=Base.prototype.extend;Base._prototyping||typeof this=="function"||(u=this.extend||u);for(var e={toSource:null},o=["constructor","toString","valueOf"],s=Base._prototyping?0:1;i=o[s++];)n[i]!=e[i]&&u.call(this,i,n[i]);for(i in n)e[i]||u.call(this,i,n[i])}return this}};Base=Base.extend({constructor:function(){this.extend(arguments[0])}},{ancestor:Object,version:"1.1",forEach:function(n,t,i){for(var r in n)this.prototype[r]===undefined&&t.call(i,n[r],r,n)},implement:function(){for(var n=0;n<arguments.length;n++)typeof arguments[n]=="function"?arguments[n](this.prototype):this.prototype.extend(arguments[n]);return this},toString:function(){return String(this.valueOf())}});wysihtml5.browser=function(){function o(n){return+(/ipad|iphone|ipod/.test(n)&&n.match(/ os (\d+).+? like mac os x/)||[,0])[1]}function s(n){return+(n.match(/android (\d+)/)||[,0])[1]}var t=navigator.userAgent,i=document.createElement("div"),n=t.indexOf("MSIE")!==-1&&t.indexOf("Opera")===-1,r=t.indexOf("Gecko")!==-1&&t.indexOf("KHTML")===-1,f=t.indexOf("AppleWebKit/")!==-1,e=t.indexOf("Chrome/")!==-1,u=t.indexOf("Opera/")!==-1;return{USER_AGENT:t,supported:function(){var n=this.USER_AGENT.toLowerCase(),t="contentEditable"in i,r=document.execCommand&&document.queryCommandSupported&&document.queryCommandState,u=document.querySelector&&document.querySelectorAll,f=this.isIos()&&o(n)<5||this.isAndroid()&&s(n)<4||n.indexOf("opera mobi")!==-1||n.indexOf("hpwos/")!==-1;return t&&r&&u&&!f},isTouchDevice:function(){return this.supportsEvent("touchmove")},isIos:function(){return/ipad|iphone|ipod/i.test(this.USER_AGENT)},isAndroid:function(){return this.USER_AGENT.indexOf("Android")!==-1},supportsSandboxedIframes:function(){return n},throwsMixedContentWarningWhenIframeSrcIsEmpty:function(){return!("querySelector"in document)},displaysCaretInEmptyContentEditableCorrectly:function(){return n},hasCurrentStyleProperty:function(){return"currentStyle"in i},hasHistoryIssue:function(){return r},insertsLineBreaksOnReturn:function(){return r},supportsPlaceholderAttributeOn:function(n){return"placeholder"in n},supportsEvent:function(n){return"on"+n in i||function(){return i.setAttribute("on"+n,"return;"),typeof i["on"+n]=="function"}()},supportsEventsInIframeCorrectly:function(){return!u},supportsHTML5Tags:function(n){var t=n.createElement("div"),i="<article>foo<\/article>";return t.innerHTML=i,t.innerHTML.toLowerCase()===i},supportsCommand:function(){var t={formatBlock:n,insertUnorderedList:n||f,insertOrderedList:n||f},i={insertHTML:r};return function(n,r){var u=t[r];if(!u){try{return n.queryCommandSupported(r)}catch(f){}try{return n.queryCommandEnabled(r)}catch(e){return!!i[r]}}return!1}}(),doesAutoLinkingInContentEditable:function(){return n},canDisableAutoLinking:function(){return this.supportsCommand(document,"AutoUrlDetect")},clearsContentEditableCorrectly:function(){return r||u||f},supportsGetAttributeCorrectly:function(){var n=document.createElement("td");return n.getAttribute("rowspan")!="1"},canSelectImagesInContentEditable:function(){return r||n||u},autoScrollsToCaret:function(){return!f},autoClosesUnclosedTags:function(){var r=i.cloneNode(!1),n,t;return r.innerHTML="<p><div><\/div>",t=r.innerHTML.toLowerCase(),n=t==="<p><\/p><div><\/div>"||t==="<p><div><\/div><\/p>",this.autoClosesUnclosedTags=function(){return n},n},supportsNativeGetElementsByClassName:function(){return String(document.getElementsByClassName).indexOf("[native code]")!==-1},supportsSelectionModify:function(){return"getSelection"in window&&"modify"in window.getSelection()},needsSpaceAfterLineBreak:function(){return u},supportsSpeechApiOn:function(n){var i=t.match(/Chrome\/(\d+)/)||[,0];return i[1]>=11&&("onwebkitspeechchange"in n||"speech"in n)},crashesWhenDefineProperty:function(t){return n&&(t==="XMLHttpRequest"||t==="XDomainRequest")},doesAsyncFocus:function(){return n},hasProblemsSettingCaretAfterImg:function(){return n},hasUndoInContextMenu:function(){return r||e||u},hasInsertNodeIssue:function(){return u},hasIframeFocusIssue:function(){return n}}}();wysihtml5.lang.array=function(n){return{contains:function(t){if(n.indexOf)return n.indexOf(t)!==-1;for(var i=0,r=n.length;i<r;i++)if(n[i]===t)return!0;return!1},without:function(t){t=wysihtml5.lang.array(t);for(var r=[],i=0,u=n.length;i<u;i++)t.contains(n[i])||r.push(n[i]);return r},get:function(){for(var t=0,r=n.length,i=[];t<r;t++)i.push(n[t]);return i}}};wysihtml5.lang.Dispatcher=Base.extend({on:function(n,t){return this.events=this.events||{},this.events[n]=this.events[n]||[],this.events[n].push(t),this},off:function(n,t){this.events=this.events||{};var i=0,r,u;if(n){for(r=this.events[n]||[],u=[];i<r.length;i++)r[i]!==t&&t&&u.push(r[i]);this.events[n]=u}else this.events={};return this},fire:function(n,t){this.events=this.events||{};for(var r=this.events[n]||[],i=0;i<r.length;i++)r[i].call(this,t);return this},observe:function(){return this.on.apply(this,arguments)},stopObserving:function(){return this.off.apply(this,arguments)}});wysihtml5.lang.object=function(n){return{merge:function(t){for(var i in t)n[i]=t[i];return this},get:function(){return n},clone:function(){var t={};for(var i in n)t[i]=n[i];return t},isArray:function(){return Object.prototype.toString.call(n)==="[object Array]"}}},function(){var n=/^\s+/,t=/\s+$/;wysihtml5.lang.string=function(i){return i=String(i),{trim:function(){return i.replace(n,"").replace(t,"")},interpolate:function(n){for(var t in n)i=this.replace("#{"+t+"}").by(n[t]);return i},replace:function(n){return{by:function(t){return i.split(n).join(t)}}}}}}(),function(n){function o(n){return l(n)?n:(n===n.ownerDocument.documentElement&&(n=n.ownerDocument.body),f(n))}function s(n){return n.replace(t,function(n,t){var i=(t.match(r)||[])[1]||"",s=e[i],f,o;return t=t.replace(r,""),t.split(s).length>t.split(i).length&&(t=t+i,i=""),f=t,o=t,t.length>u&&(o=o.substr(0,u)+"..."),f.substr(0,4)==="www."&&(f="http://"+f),'<a href="'+f+'">'+o+"<\/a>"+i})}function h(n){var t=n._wysihtml5_tempElement;return t||(t=n._wysihtml5_tempElement=n.createElement("div")),t}function c(n){var i=n.parentNode,t=h(i.ownerDocument);for(t.innerHTML="<span><\/span>"+s(n.data),t.removeChild(t.firstChild);t.firstChild;)i.insertBefore(t.firstChild,n);i.removeChild(n)}function l(n){for(var t;n.parentNode;){if(n=n.parentNode,t=n.nodeName,i.contains(t))return!0;if(t==="body")return!1}return!1}function f(r){if(!i.contains(r.nodeName)){if(r.nodeType===n.TEXT_NODE&&r.data.match(t)){c(r);return}for(var e=n.lang.array(r.childNodes).get(),o=e.length,u=0;u<o;u++)f(e[u]);return r}}var i=n.lang.array(["CODE","PRE","A","SCRIPT","HEAD","TITLE","STYLE"]),t=/((https?:\/\/|www\.)[^\s<]{3,})/gi,r=/([^\w\/\-](,?))$/i,u=100,e={")":"(","]":"[","}":"{"};n.dom.autoLink=o;n.dom.autoLink.URL_REG_EXP=t}(wysihtml5),function(n){var t=n.dom;t.addClass=function(n,i){var r=n.classList;if(r)return r.add(i);t.hasClass(n,i)||(n.className+=" "+i)};t.removeClass=function(n,t){var i=n.classList;if(i)return i.remove(t);n.className=n.className.replace(new RegExp("(^|\\s+)"+t+"(\\s+|$)")," ")};t.hasClass=function(n,t){var r=n.classList,i;return r?r.contains(t):(i=n.className,i.length>0&&(i==t||new RegExp("(^|\\s)"+t+"(\\s|$)").test(i)))}}(wysihtml5);wysihtml5.dom.contains=function(){var n=document.documentElement;return n.contains?function(n,t){return t.nodeType!==wysihtml5.ELEMENT_NODE&&(t=t.parentNode),n!==t&&n.contains(t)}:n.compareDocumentPosition?function(n,t){return!!(n.compareDocumentPosition(t)&16)}:void 0}();wysihtml5.dom.convertToList=function(){function n(n,t){var i=n.createElement("li");return t.appendChild(i),i}function t(n,t){return n.createElement(t)}function i(i,r){if(i.nodeName==="UL"||i.nodeName==="OL"||i.nodeName==="MENU")return i;for(var c=i.ownerDocument,o=t(c,r),a=i.querySelectorAll("br"),w=a.length,l,v,s,e,h,y,p,u,f=0;f<w;f++)for(e=a[f];(h=e.parentNode)&&h!==i&&h.lastChild===e;){if(wysihtml5.dom.getStyle("display").from(h)==="block"){h.removeChild(e);break}wysihtml5.dom.insert(e).after(e.parentNode)}for(l=wysihtml5.lang.array(i.childNodes).get(),v=l.length,f=0;f<v;f++){if(u=u||n(c,o),s=l[f],y=wysihtml5.dom.getStyle("display").from(s)==="block",p=s.nodeName==="BR",y){u=u.firstChild?n(c,o):u;u.appendChild(s);u=null;continue}if(p){u=u.firstChild?null:u;continue}u.appendChild(s)}return l.length===0&&n(c,o),i.parentNode.replaceChild(o,i),o}return i}();wysihtml5.dom.copyAttributes=function(n){return{from:function(t){return{to:function(i){for(var r,u=0,f=n.length;u<f;u++)r=n[u],typeof t[r]!="undefined"&&t[r]!==""&&(i[r]=t[r]);return{andTo:arguments.callee}}}}}},function(n){var t=["-webkit-box-sizing","-moz-box-sizing","-ms-box-sizing","box-sizing"],i=function(t){return r(t)?parseInt(n.getStyle("width").from(t),10)<t.offsetWidth:!1},r=function(i){for(var r=0,u=t.length;r<u;r++)if(n.getStyle(t[r]).from(i)==="border-box")return t[r]};n.copyStyles=function(r){return{from:function(u){i(u)&&(r=wysihtml5.lang.array(r).without(t));for(var o="",s=r.length,f=0,e;f<s;f++)e=r[f],o+=e+":"+n.getStyle(e).from(u)+";";return{to:function(t){n.setStyles(o).on(t);return{andTo:arguments.callee}}}}}}}(wysihtml5.dom),function(n){n.dom.delegate=function(t,i,r,u){return n.dom.observe(t,r,function(r){for(var f=r.target,e=n.lang.array(t.querySelectorAll(i));f&&f!==t;){if(e.contains(f)){u.call(f,r);break}f=f.parentNode}})}}(wysihtml5);wysihtml5.dom.getAsDom=function(){var t=function(n,t){var i=t.createElement("div");i.style.display="none";t.body.appendChild(i);try{i.innerHTML=n}catch(r){}return t.body.removeChild(i),i},i=function(t){if(!t._wysihtml5_supportsHTML5Tags){for(var i=0,r=n.length;i<r;i++)t.createElement(n[i]);t._wysihtml5_supportsHTML5Tags=!0}},n=["abbr","article","aside","audio","bdi","canvas","command","datalist","details","figcaption","figure","footer","header","hgroup","keygen","mark","meter","nav","output","progress","rp","rt","ruby","svg","section","source","summary","time","track","video","wbr"];return function(n,r){r=r||document;var u;return typeof n=="object"&&n.nodeType?(u=r.createElement("div"),u.appendChild(n)):wysihtml5.browser.supportsHTML5Tags(r)?(u=r.createElement("div"),u.innerHTML=n):(i(r),u=t(n,r)),u}}();wysihtml5.dom.getParentElement=function(){function n(n,t){return!t||!t.length?!0:typeof t=="string"?n===t:wysihtml5.lang.array(t).contains(n)}function t(n){return n.nodeType===wysihtml5.ELEMENT_NODE}function i(n,t,i){var r=(n.className||"").match(i)||[];return t?r[r.length-1]===t:!!r.length}function r(t,i,r){while(r--&&t&&t.nodeName!=="BODY"){if(n(t.nodeName,i))return t;t=t.parentNode}return null}function u(r,u,f,e,o){while(o--&&r&&r.nodeName!=="BODY"){if(t(r)&&n(r.nodeName,u)&&i(r,f,e))return r;r=r.parentNode}return null}return function(n,t,i){return i=i||50,t.className||t.classRegExp?u(n,t.nodeName,t.className,t.classRegExp,i):r(n,t.nodeName,i)}}();wysihtml5.dom.getStyle=function(){function i(n){return n.replace(t,function(n){return n.charAt(1).toUpperCase()})}var n={float:"styleFloat"in document.createElement("div").style?"styleFloat":"cssFloat"},t=/\-[a-z]/g;return function(t){return{from:function(r){var f,e,l,a;if(r.nodeType===wysihtml5.ELEMENT_NODE){var o=r.ownerDocument,s=n[t]||i(t),u=r.style,h=r.currentStyle,c=u[s];if(c)return c;if(h)try{return h[s]}catch(v){}return f=o.defaultView||o.parentWindow,e=(t==="height"||t==="width")&&r.nodeName==="TEXTAREA",f.getComputedStyle?(e&&(l=u.overflow,u.overflow="hidden"),a=f.getComputedStyle(r,null).getPropertyValue(t),e&&(u.overflow=l||""),a):void 0}}}}}();wysihtml5.dom.hasElementWithTagName=function(){function i(n){return n._wysihtml5_identifier||(n._wysihtml5_identifier=t++)}var n={},t=1;return function(t,r){var f=i(t)+":"+r,u=n[f];return u||(u=n[f]=t.getElementsByTagName(r)),u.length>0}}(),function(n){function r(n){return n._wysihtml5_identifier||(n._wysihtml5_identifier=i++)}var t={},i=1;n.dom.hasElementWithClassName=function(i,u){if(!n.browser.supportsNativeGetElementsByClassName())return!!i.querySelector("."+u);var e=r(i)+":"+u,f=t[e];return f||(f=t[e]=i.getElementsByClassName(u)),f.length>0}}(wysihtml5);wysihtml5.dom.insert=function(n){return{after:function(t){t.parentNode.insertBefore(n,t.nextSibling)},before:function(t){t.parentNode.insertBefore(n,t)},into:function(t){t.appendChild(n)}}};wysihtml5.dom.insertCSS=function(n){return n=n.join("\n"),{into:function(t){var i=t.createElement("style"),r,u;if(i.type="text/css",i.styleSheet?i.styleSheet.cssText=n:i.appendChild(t.createTextNode(n)),r=t.querySelector("head link"),r){r.parentNode.insertBefore(i,r);return}u=t.querySelector("head");u&&u.appendChild(i)}}};wysihtml5.dom.observe=function(n,t,i){t=typeof t=="string"?[t]:t;for(var r,u,f=0,e=t.length;f<e;f++)u=t[f],n.addEventListener?n.addEventListener(u,i,!1):(r=function(t){"target"in t||(t.target=t.srcElement);t.preventDefault=t.preventDefault||function(){this.returnValue=!1};t.stopPropagation=t.stopPropagation||function(){this.cancelBubble=!0};i.call(n,t)},n.attachEvent("on"+u,r));return{stop:function(){for(var u,f=0,e=t.length;f<e;f++)u=t[f],n.removeEventListener?n.removeEventListener(u,i,!1):n.detachEvent("on"+u,r)}}};wysihtml5.dom.parse=function(){function o(t,r,u,f){wysihtml5.lang.object(n).merge(e).merge(r).get();u=u||t.ownerDocument||document;for(var c=u.createDocumentFragment(),l=typeof t=="string",s,h,o=l?wysihtml5.dom.getAsDom(t,u):t;o.firstChild;)h=o.firstChild,o.removeChild(h),s=i(h,f),s&&c.appendChild(s);return o.innerHTML="",o.appendChild(c),l?wysihtml5.quirks.getCorrectInnerHTML(o):o}function i(n,r){var c=n.nodeType,s=n.childNodes,l=s.length,h=u[c],e=0,f,o;if(f=h&&h(n),!f)return null;for(e=0;e<l;e++)o=i(s[e],r),o&&f.appendChild(o);return r&&f.childNodes.length<=1&&f.nodeName.toLowerCase()===t&&!f.attributes.length?f.firstChild:f}function s(i){var r,f,o=n.tags,u=i.nodeName.toLowerCase(),e=i.scopeName;if(i._wysihtml5||(i._wysihtml5=1,i.className==="wysihtml5-temp"))return null;if(e&&e!="HTML"&&(u=e+":"+u),"outerHTML"in i&&(wysihtml5.browser.autoClosesUnclosedTags()||i.nodeName!=="P"||i.outerHTML.slice(-4).toLowerCase()==="<\/p>"||(u="div")),u in o){if(r=o[u],!r||r.remove)return null;r=typeof r=="string"?{rename_tag:r}:r}else if(i.firstChild)r={rename_tag:t};else return null;return f=i.ownerDocument.createElement(r.rename_tag||u),h(i,f,r),i=null,f}function h(t,i,u){var e={},tt=u.set_class,a=u.add_class,it=u.set_attributes,p=u.check_attributes,rt=n.classes,w=0,s=[],b=[],l=[],k=[],ut,d,h,g,o,nt,c;if(it&&(e=wysihtml5.lang.object(it).clone()),p)for(o in p)(c=v[p[o]],c)&&(nt=c(r(t,o)),typeof nt=="string"&&(e[o]=nt));if(tt&&s.push(tt),a)for(o in a)(c=y[a[o]],c)&&(g=c(r(t,o)),typeof g=="string"&&s.push(g));for(rt["_wysihtml5-temp-placeholder"]=1,k=t.getAttribute("class"),k&&(s=s.concat(k.split(f))),ut=s.length;w<ut;w++)h=s[w],rt[h]&&b.push(h);for(d=b.length;d--;)h=b[d],wysihtml5.lang.array(l).contains(h)||l.unshift(h);l.length&&(e["class"]=l.join(" "));for(o in e)try{i.setAttribute(o,e[o])}catch(ft){}e.src&&(typeof e.width!="undefined"&&i.setAttribute("width",e.width),typeof e.height!="undefined"&&i.setAttribute("height",e.height))}function r(n,t){var i,r,u;return t=t.toLowerCase(),i=n.nodeName,i=="IMG"&&t=="src"&&l(n)===!0?n.src:c&&"outerHTML"in n?(r=n.outerHTML.toLowerCase(),u=r.indexOf(" "+t+"=")!=-1,u?n.getAttribute(t):null):n.getAttribute(t)}function l(n){try{return n.complete&&!n.mozMatchesSelector(":-moz-broken")}catch(t){if(n.complete&&n.readyState==="complete")return!0}}function a(n){return n.ownerDocument.createTextNode(n.data)}var u={"1":s,"3":a},t="span",f=/\s+/,e={tags:{},classes:{}},n={},c=!wysihtml5.browser.supportsGetAttributeCorrectly(),v={url:function(){var n=/^https?:\/\//i;return function(t){return!t||!t.match(n)?null:t.replace(n,function(n){return n.toLowerCase()})}}(),src:function(){var n=/^(\/|https?:\/\/)/i;return function(t){return!t||!t.match(n)?null:t.replace(n,function(n){return n.toLowerCase()})}}(),href:function(){var n=/^(\/|https?:\/\/|mailto:)/i;return function(t){return!t||!t.match(n)?null:t.replace(n,function(n){return n.toLowerCase()})}}(),alt:function(){var n=/[^ a-z0-9_\-]/gi;return function(t){return t?t.replace(n,""):""}}(),numbers:function(){var n=/\D/g;return function(t){return t=(t||"").replace(n,""),t||null}}()},y={align_img:function(){var n={left:"wysiwyg-float-left",right:"wysiwyg-float-right"};return function(t){return n[String(t).toLowerCase()]}}(),align_text:function(){var n={left:"wysiwyg-text-align-left",right:"wysiwyg-text-align-right",center:"wysiwyg-text-align-center",justify:"wysiwyg-text-align-justify"};return function(t){return n[String(t).toLowerCase()]}}(),clear_br:function(){var n={left:"wysiwyg-clear-left",right:"wysiwyg-clear-right",both:"wysiwyg-clear-both",all:"wysiwyg-clear-both"};return function(t){return n[String(t).toLowerCase()]}}(),size_font:function(){var n={"1":"wysiwyg-font-size-xx-small","2":"wysiwyg-font-size-small","3":"wysiwyg-font-size-medium","4":"wysiwyg-font-size-large","5":"wysiwyg-font-size-x-large","6":"wysiwyg-font-size-xx-large","7":"wysiwyg-font-size-xx-large","-":"wysiwyg-font-size-smaller","+":"wysiwyg-font-size-larger"};return function(t){return n[String(t).charAt(0)]}}()};return o}();wysihtml5.dom.removeEmptyTextNodes=function(n){for(var t,r=wysihtml5.lang.array(n.childNodes).get(),u=r.length,i=0;i<u;i++)t=r[i],t.nodeType===wysihtml5.TEXT_NODE&&t.data===""&&t.parentNode.removeChild(t)};wysihtml5.dom.renameElement=function(n,t){for(var i=n.ownerDocument.createElement(t),r;r=n.firstChild;)i.appendChild(r);return wysihtml5.dom.copyAttributes(["align","className"]).from(n).to(i),n.parentNode.replaceChild(i,n),i};wysihtml5.dom.replaceWithChildNodes=function(n){if(n.parentNode){if(!n.firstChild){n.parentNode.removeChild(n);return}for(var t=n.ownerDocument.createDocumentFragment();n.firstChild;)t.appendChild(n.firstChild);n.parentNode.replaceChild(t,n);n=t=null}},function(n){function t(t){return n.getStyle("display").from(t)==="block"}function r(n){return n.nodeName==="BR"}function i(n){var t=n.ownerDocument.createElement("br");n.appendChild(t)}function u(n,u){if(n.nodeName.match(/^(MENU|UL|OL)$/)){var h=n.ownerDocument,o=h.createDocumentFragment(),c=n.previousElementSibling||n.previousSibling,e,l,a,v,s,f;if(u)for(c&&!t(c)&&i(o);f=n.firstElementChild||n.firstChild;){for(l=f.lastChild;e=f.firstChild;)a=e===l,v=a&&!t(e)&&!r(e),o.appendChild(e),v&&i(o);f.parentNode.removeChild(f)}else while(f=n.firstElementChild||n.firstChild){if(f.querySelector&&f.querySelector("div, p, ul, ol, menu, blockquote, h1, h2, h3, h4, h5, h6"))while(e=f.firstChild)o.appendChild(e);else{for(s=h.createElement("p");e=f.firstChild;)s.appendChild(e);o.appendChild(s)}f.parentNode.removeChild(f)}n.parentNode.replaceChild(o,n)}}n.resolveList=u}(wysihtml5.dom),function(n){var t=document,i=["parent","top","opener","frameElement","frames","localStorage","globalStorage","sessionStorage","indexedDB"],r=["open","close","openDialog","showModalDialog","alert","confirm","prompt","openDatabase","postMessage","XMLHttpRequest","XDomainRequest"],u=["referrer","write","open","close"];n.dom.Sandbox=Base.extend({constructor:function(t,i){this.callback=t||n.EMPTY_FUNCTION;this.config=n.lang.object({}).merge(i).get();this.iframe=this._createIframe()},insertInto:function(n){typeof n=="string"&&(n=t.getElementById(n));n.appendChild(this.iframe)},getIframe:function(){return this.iframe},getWindow:function(){this._readyError()},getDocument:function(){this._readyError()},destroy:function(){var n=this.getIframe();n.parentNode.removeChild(n)},_readyError:function(){throw new Error("wysihtml5.Sandbox: Sandbox iframe isn't loaded yet");},_createIframe:function(){var r=this,i=t.createElement("iframe");i.className="wysihtml5-sandbox";n.dom.setAttributes({security:"restricted",allowtransparency:"true",frameborder:0,width:0,height:0,marginwidth:0,marginheight:0}).on(i);return n.browser.throwsMixedContentWarningWhenIframeSrcIsEmpty()&&(i.src="javascript:'<html><\/html>'"),i.onload=function(){i.onreadystatechange=i.onload=null;r._onLoadIframe(i)},i.onreadystatechange=function(){/loaded|complete/.test(i.readyState)&&(i.onreadystatechange=i.onload=null,r._onLoadIframe(i))},i},_onLoadIframe:function(f){var e,o;if(n.dom.contains(t.documentElement,f)){var c=this,h=f.contentWindow,s=f.contentWindow.document,l=t.characterSet||t.charset||"utf-8",a=this._getHtml({charset:l,stylesheets:this.config.stylesheets});if(s.open("text/html","replace"),s.write(a),s.close(),this.getWindow=function(){return f.contentWindow},this.getDocument=function(){return f.contentWindow.document},h.onerror=function(n,t,i){throw new Error("wysihtml5.Sandbox: "+n,t,i);},!n.browser.supportsSandboxedIframes()){for(e=0,o=i.length;e<o;e++)this._unset(h,i[e]);for(e=0,o=r.length;e<o;e++)this._unset(h,r[e],n.EMPTY_FUNCTION);for(e=0,o=u.length;e<o;e++)this._unset(s,u[e]);this._unset(s,"cookie","",!0)}this.loaded=!0;setTimeout(function(){c.callback(c)},0)}},_getHtml:function(t){var i=t.stylesheets,u="",r=0,f;if(i=typeof i=="string"?[i]:i,i)for(f=i.length;r<f;r++)u+='<link rel="stylesheet" href="'+i[r]+'">';return t.stylesheets=u,n.lang.string('<!DOCTYPE html><html><head><meta charset="#{charset}">#{stylesheets}<\/head><body><\/body><\/html>').interpolate(t)},_unset:function(t,i,r,u){try{t[i]=r}catch(e){}try{t.__defineGetter__(i,function(){return r})}catch(e){}if(u)try{t.__defineSetter__(i,function(){})}catch(e){}if(!n.browser.crashesWhenDefineProperty(i))try{var f={get:function(){return r}};u&&(f.set=function(){});Object.defineProperty(t,i,f)}catch(e){}}})}(wysihtml5),function(){var n={className:"class"};wysihtml5.dom.setAttributes=function(t){return{on:function(i){for(var r in t)i.setAttribute(n[r]||r,t[r])}}}}();wysihtml5.dom.setStyles=function(n){return{on:function(t){var r=t.style,i;if(typeof n=="string"){r.cssText+=";"+n;return}for(i in n)i==="float"?(r.cssFloat=n[i],r.styleFloat=n[i]):r[i]=n[i]}}},function(n){n.simulatePlaceholder=function(t,i,r){var e="placeholder",u=function(){i.hasPlaceholderSet()&&i.clear();i.placeholderSet=!1;n.removeClass(i.element,e)},f=function(){i.isEmpty()&&(i.placeholderSet=!0,i.setValue(r),n.addClass(i.element,e))};t.on("set_placeholder",f).on("unset_placeholder",u).on("focus:composer",u).on("paste:composer",u).on("blur:composer",f);f()}}(wysihtml5.dom),function(n){var t=document.documentElement;"textContent"in t?(n.setTextContent=function(n,t){n.textContent=t},n.getTextContent=function(n){return n.textContent}):"innerText"in t?(n.setTextContent=function(n,t){n.innerText=t},n.getTextContent=function(n){return n.innerText}):(n.setTextContent=function(n,t){n.nodeValue=t},n.getTextContent=function(n){return n.nodeValue})}(wysihtml5.dom);wysihtml5.quirks.cleanPastedHTML=function(){function t(t,i,r){i=i||n;r=r||t.ownerDocument||document;var u,s=typeof t=="string",h,f,c,e,o=0;u=s?wysihtml5.dom.getAsDom(t,r):t;for(e in i)for(f=u.querySelectorAll(e),h=i[e],c=f.length;o<c;o++)h(f[o]);return f=t=i=null,s?u.innerHTML:u}var n={"a u":wysihtml5.dom.replaceWithChildNodes};return t}();wysihtml5.quirks.ensureProperClearing=function(){var n=function(){var n=this;setTimeout(function(){var t=n.innerHTML.toLowerCase();(t=="<p>&nbsp;<\/p>"||t=="<p>&nbsp;<\/p><p>&nbsp;<\/p>")&&(n.innerHTML="")},0)};return function(t){wysihtml5.dom.observe(t.element,["cut","keydown"],n)}}(),function(n){var t="%7E";n.quirks.getCorrectInnerHTML=function(i){var r=i.innerHTML,f,e,o,s,u;if(r.indexOf(t)===-1)return r;for(f=i.querySelectorAll("[href*='~'], [src*='~']"),u=0,s=f.length;u<s;u++)e=f[u].href||f[u].src,o=n.lang.string(e).replace("~").by(t),r=n.lang.string(r).replace(o).by(e);return r}}(wysihtml5),function(n){var t="wysihtml5-quirks-redraw";n.quirks.redraw=function(i){n.dom.addClass(i,t);n.dom.removeClass(i,t);try{var r=i.ownerDocument;r.execCommand("italic",!1,null);r.execCommand("italic",!1,null)}catch(u){}}}(wysihtml5),function(n){function i(n){var t=0;if(n.parentNode)do t+=n.offsetTop||0,n=n.offsetParent;while(n);return t}var t=n.dom;n.Selection=Base.extend({constructor:function(n){window.rangy.init();this.editor=n;this.composer=n.composer;this.doc=this.composer.doc},getBookmark:function(){var n=this.getRange();return n&&n.cloneRange()},setBookmark:function(n){n&&this.setSelection(n)},setBefore:function(n){var t=rangy.createRange(this.doc);return t.setStartBefore(n),t.setEndBefore(n),this.setSelection(t)},setAfter:function(n){var t=rangy.createRange(this.doc);return t.setStartAfter(n),t.setEndAfter(n),this.setSelection(t)},selectNode:function(i,r){var u=rangy.createRange(this.doc),e=i.nodeType===n.ELEMENT_NODE,f="canHaveHTML"in i?i.canHaveHTML:i.nodeName!=="IMG",s=e?i.innerHTML:i.data,o=s===""||s===n.INVISIBLE_SPACE,h=t.getStyle("display").from(i),c=h==="block"||h==="list-item";if(o&&e&&f&&!r)try{i.innerHTML=n.INVISIBLE_SPACE}catch(l){}f?u.selectNodeContents(i):u.selectNode(i);f&&o&&e?u.collapse(c):f&&o&&(u.setStartAfter(i),u.setEndAfter(i));this.setSelection(u)},getSelectedNode:function(n){var i,t;return n&&this.doc.selection&&this.doc.selection.type==="Control"&&(t=this.doc.selection.createRange(),t&&t.length)?t.item(0):(i=this.getSelection(this.doc),i.focusNode===i.anchorNode?i.focusNode:(t=this.getRange(this.doc),t?t.commonAncestorContainer:this.doc.body))},executeAndRestore:function(i,r){var u=this.doc.body,v=r&&u.scrollTop,y=r&&u.scrollLeft,c="_wysihtml5-temp-placeholder",l='<span class="'+c+'">'+n.INVISIBLE_SPACE+"<\/span>",o=this.getRange(this.doc),f,s,h,a,e;if(!o){i(u,u);return}n.browser.hasInsertNodeIssue()?this.doc.execCommand("insertHTML",!1,l):(a=o.createContextualFragment(l),o.insertNode(a));try{i(o.startContainer,o.endContainer)}catch(p){setTimeout(function(){throw p;},0)}f=this.doc.querySelector("."+c);f?(e=rangy.createRange(this.doc),h=f.nextSibling,n.browser.hasInsertNodeIssue()&&h&&h.nodeName==="BR"?(s=this.doc.createTextNode(n.INVISIBLE_SPACE),t.insert(s).after(f),e.setStartBefore(s),e.setEndBefore(s)):(e.selectNode(f),e.deleteContents()),this.setSelection(e)):u.focus();r&&(u.scrollTop=v,u.scrollLeft=y);try{f.parentNode.removeChild(f)}catch(w){}},executeAndRestoreSimple:function(n){var t=this.getRange(),o=this.doc.body,r,e,u,f,i;if(!t){n(o,o);return}f=t.getNodes([3]);e=f[0]||t.startContainer;u=f[f.length-1]||t.endContainer;i={collapsed:t.collapsed,startContainer:e,startOffset:e===t.startContainer?t.startOffset:0,endContainer:u,endOffset:u===t.endContainer?t.endOffset:u.length};try{n(t.startContainer,t.endContainer)}catch(s){setTimeout(function(){throw s;},0)}r=rangy.createRange(this.doc);try{r.setStart(i.startContainer,i.startOffset)}catch(h){}try{r.setEnd(i.endContainer,i.endOffset)}catch(c){}try{this.setSelection(r)}catch(l){}},set:function(n,t){var i=rangy.createRange(this.doc);i.setStart(n,t||0);this.setSelection(i)},insertHTML:function(n){var r=rangy.createRange(this.doc),t=r.createContextualFragment(n),i=t.lastChild;this.insertNode(t);i&&this.setAfter(i)},insertNode:function(n){var t=this.getRange();t&&t.insertNode(n)},surround:function(n){var t=this.getRange();if(t)try{t.surroundContents(n);this.selectNode(n)}catch(i){n.appendChild(t.extractContents());t.insertNode(n)}},scrollIntoView:function(){var t=this.doc,f=t.documentElement.scrollHeight>t.documentElement.offsetHeight,r=t._wysihtml5ScrollIntoViewElement=t._wysihtml5ScrollIntoViewElement||function(){var i=t.createElement("span");return i.innerHTML=n.INVISIBLE_SPACE,i}(),u;f&&(this.insertNode(r),u=i(r),r.parentNode.removeChild(r),u>=t.body.scrollTop+t.documentElement.offsetHeight-5&&(t.body.scrollTop=u))},selectLine:function(){n.browser.supportsSelectionModify()?this._selectLine_W3C():this.doc.selection&&this._selectLine_MSIE()},_selectLine_W3C:function(){var t=this.doc.defaultView,n=t.getSelection();n.modify("extend","left","lineboundary");n.modify("extend","right","lineboundary")},_selectLine_MSIE:function(){var n=this.doc.selection.createRange(),t=n.boundingTop,e=this.doc.body.scrollWidth,o,f,i,r,u;if(n.moveToPoint){for(t===0&&(i=this.doc.createElement("span"),this.insertNode(i),t=i.offsetTop,i.parentNode.removeChild(i)),t+=1,r=-10;r<e;r+=2)try{n.moveToPoint(r,t);break}catch(s){}for(o=t,f=this.doc.selection.createRange(),u=e;u>=0;u--)try{f.moveToPoint(u,o);break}catch(h){}n.setEndPoint("EndToEnd",f);n.select()}},getText:function(){var n=this.getSelection();return n?n.toString():""},getNodes:function(n,t){var i=this.getRange();return i?i.getNodes([n],t):[]},getRange:function(){var n=this.getSelection();return n&&n.rangeCount&&n.getRangeAt(0)},getSelection:function(){return rangy.getSelection(this.doc.defaultView||this.doc.parentWindow)},setSelection:function(n){var t=this.doc.defaultView||this.doc.parentWindow,i=rangy.getSelection(t);return i.setSingleRange(n)}})}(wysihtml5),function(n,t){function h(n,t,i){if(!n.className)return!1;var r=n.className.match(i)||[];return r[r.length-1]===t}function c(n,t,i){n.className?(f(n,i),n.className+=" "+t):n.className=t}function f(n,t){n.className&&(n.className=n.className.replace(t,""))}function l(n,t){return n.className.replace(u," ")==t.className.replace(u," ")}function a(n){for(var t=n.parentNode;n.firstChild;)t.insertBefore(n.firstChild,n);t.removeChild(n)}function v(n,t){if(n.attributes.length!=t.attributes.length)return!1;for(var r=0,e=n.attributes.length,i,u,f;r<e;++r)if(i=n.attributes[r],f=i.name,f!="class"&&((u=t.attributes.getNamedItem(f),i.specified!=u.specified)||i.specified&&i.nodeValue!==u.nodeValue))return!1;return!0}function e(n,i){return t.dom.isCharacterDataNode(n)?i==0?!!n.previousSibling:i==n.length?!!n.nextSibling:!0:i>0&&i<n.childNodes.length}function i(n,r,u){var f,e;if(t.dom.isCharacterDataNode(r)&&(u==0?(u=t.dom.getNodeIndex(r),r=r.parentNode):u==r.length?(u=t.dom.getNodeIndex(r)+1,r=r.parentNode):f=t.dom.splitDataNode(r,u)),!f){for(f=r.cloneNode(!1),f.id&&f.removeAttribute("id");e=r.childNodes[u];)f.appendChild(e);t.dom.insertAfter(f,r)}return r==n?f:i(n,f.parentNode,t.dom.getNodeIndex(f))}function r(t){this.isElementMerge=t.nodeType==n.ELEMENT_NODE;this.firstTextNode=this.isElementMerge?t.lastChild:t;this.textNodes=[this.firstTextNode]}function o(n,t,i,r){this.tagNames=n||[s];this.cssClass=t||"";this.similarClassRegExp=i;this.normalize=r;this.applyToAnyTagName=!1}var s="span",u=/\s+/g;r.prototype={doMerge:function(){for(var r=[],i,n,u,t=0,f=this.textNodes.length;t<f;++t)i=this.textNodes[t],n=i.parentNode,r[t]=i.data,t&&(n.removeChild(i),n.hasChildNodes()||n.parentNode.removeChild(n));return this.firstTextNode.data=u=r.join(""),u},getLength:function(){for(var n=this.textNodes.length,t=0;n--;)t+=this.textNodes[n].length;return t},toString:function(){for(var t=[],n=0,i=this.textNodes.length;n<i;++n)t[n]="'"+this.textNodes[n].data+"'";return"[Merge("+t.join(",")+")]"}};o.prototype={getAncestorWithClass:function(i){for(var r;i;){if(r=this.cssClass?h(i,this.cssClass,this.similarClassRegExp):!0,i.nodeType==n.ELEMENT_NODE&&t.dom.arrayContains(this.tagNames,i.tagName.toLowerCase())&&r)return i;i=i.parentNode}return!1},postApply:function(n,t){for(var l,a=n[0],f=n[n.length-1],e=[],i,s=a,v=f,y=0,p=f.length,o,h,u=0,c=n.length;u<c;++u)o=n[u],h=this.getAdjacentMergeableTextNode(o.parentNode,!1),h?(i||(i=new r(h),e.push(i)),i.textNodes.push(o),o===a&&(s=i.firstTextNode,y=s.length),o===f&&(v=i.firstTextNode,p=i.getLength())):i=null;if(l=this.getAdjacentMergeableTextNode(f.parentNode,!0),l&&(i||(i=new r(f),e.push(i)),i.textNodes.push(l)),e.length){for(u=0,c=e.length;u<c;++u)e[u].doMerge();t.setStart(s,y);t.setEnd(v,p)}},getAdjacentMergeableTextNode:function(t,i){var u=t.nodeType==n.TEXT_NODE,e=u?t.parentNode:t,r,f=i?"nextSibling":"previousSibling";if(u){if(r=t[f],r&&r.nodeType==n.TEXT_NODE)return r}else if(r=e[f],r&&this.areElementsMergeable(t,r))return r[i?"firstChild":"lastChild"];return null},areElementsMergeable:function(n,i){return t.dom.arrayContains(this.tagNames,(n.tagName||"").toLowerCase())&&t.dom.arrayContains(this.tagNames,(i.tagName||"").toLowerCase())&&l(n,i)&&v(n,i)},createContainer:function(n){var t=n.createElement(this.tagNames[0]);return this.cssClass&&(t.className=this.cssClass),t},applyToTextNode:function(n){var i=n.parentNode,r;i.childNodes.length==1&&t.dom.arrayContains(this.tagNames,i.tagName.toLowerCase())?this.cssClass&&c(i,this.cssClass,this.similarClassRegExp):(r=this.createContainer(t.dom.getDocument(n)),n.parentNode.insertBefore(r,n),r.appendChild(n))},isRemovable:function(i){return t.dom.arrayContains(this.tagNames,i.tagName.toLowerCase())&&n.lang.string(i.className).trim()==this.cssClass},undoToTextNode:function(n,t,r){if(!t.containsNode(r)){var u=t.cloneRange();u.selectNode(r);u.isPointInRange(t.endContainer,t.endOffset)&&e(t.endContainer,t.endOffset)&&(i(r,t.endContainer,t.endOffset),t.setEndAfter(r));u.isPointInRange(t.startContainer,t.startOffset)&&e(t.startContainer,t.startOffset)&&(r=i(r,t.startContainer,t.startOffset))}this.similarClassRegExp&&f(r,this.similarClassRegExp);this.isRemovable(r)&&a(r)},applyToRange:function(t){var i=t.getNodes([n.TEXT_NODE]),f,r,u,e;if(!i.length)try{f=this.createContainer(t.endContainer.ownerDocument);t.surroundContents(f);this.selectNode(t,f);return}catch(o){}if(t.splitBoundaries(),i=t.getNodes([n.TEXT_NODE]),i.length){for(u=0,e=i.length;u<e;++u)r=i[u],this.getAncestorWithClass(r)||this.applyToTextNode(r);t.setStart(i[0],0);r=i[i.length-1];t.setEnd(r,r.length);this.normalize&&this.postApply(i,t)}},undoToRange:function(t){var i=t.getNodes([n.TEXT_NODE]),r,e,s,u,f,o;for(i.length?(t.splitBoundaries(),i=t.getNodes([n.TEXT_NODE])):(s=t.endContainer.ownerDocument,u=s.createTextNode(n.INVISIBLE_SPACE),t.insertNode(u),t.selectNode(u),i=[u]),f=0,o=i.length;f<o;++f)r=i[f],e=this.getAncestorWithClass(r),e&&this.undoToTextNode(r,t,e);o==1?this.selectNode(t,i[0]):(t.setStart(i[0],0),r=i[i.length-1],t.setEnd(r,r.length),this.normalize&&this.postApply(i,t))},selectNode:function(t,i){var r=i.nodeType===n.ELEMENT_NODE,e="canHaveHTML"in i?i.canHaveHTML:!0,f=r?i.innerHTML:i.data,u=f===""||f===n.INVISIBLE_SPACE;if(u&&r&&e)try{i.innerHTML=n.INVISIBLE_SPACE}catch(o){}t.selectNodeContents(i);u&&r?t.collapse(!1):u&&(t.setStartAfter(i),t.setEndAfter(i))},getTextSelectedByRange:function(n,t){var i=t.cloneRange(),r,u;return i.selectNodeContents(n),r=i.intersection(t),u=r?r.toString():"",i.detach(),u},isAppliedToRange:function(t){var f=[],i,u=t.getNodes([n.TEXT_NODE]),r,e,o;if(!u.length)return i=this.getAncestorWithClass(t.startContainer),i?[i]:!1;for(r=0,e=u.length;r<e;++r)if(o=this.getTextSelectedByRange(u[r],t),i=this.getAncestorWithClass(u[r]),o==""||i)f.push(i);else return!1;return f},toggleRange:function(n){this.isAppliedToRange(n)?this.undoToRange(n):this.applyToRange(n)}};n.selection.HTMLApplier=o}(wysihtml5,rangy);wysihtml5.Commands=Base.extend({constructor:function(n){this.editor=n;this.composer=n.composer;this.doc=this.composer.doc},support:function(n){return wysihtml5.browser.supportsCommand(this.doc,n)},exec:function(n,t){var i=wysihtml5.commands[n],u=wysihtml5.lang.array(arguments).get(),f=i&&i.exec,r=null;if(this.editor.fire("beforecommand:composer"),f)u.unshift(this.composer),r=f.apply(i,u);else try{r=this.doc.execCommand(n,!1,t)}catch(e){}return this.editor.fire("aftercommand:composer"),r},state:function(n){var t=wysihtml5.commands[n],i=wysihtml5.lang.array(arguments).get(),r=t&&t.state;if(r)return i.unshift(this.composer),r.apply(t,i);try{return this.doc.queryCommandState(n)}catch(u){return!1}}});wysihtml5.commands.bold={exec:function(n,t){return wysihtml5.commands.formatInline.exec(n,t,"b")},state:function(n,t){return wysihtml5.commands.formatInline.state(n,t,"b")}},function(n){function u(n,i){for(var o=i.length,u=0,r,f,e;u<o;u++)r=i[u],f=t.getParentElement(r,{nodeName:"code"}),e=t.getTextContent(r),e.match(t.autoLink.URL_REG_EXP)&&!f?f=t.renameElement(r,"code"):t.replaceWithChildNodes(r)}function f(u,f){var y=u.doc,p="_wysihtml5-temp-"+ +new Date,o=0,s,h,e,w,b,c,l,a,v;for(n.commands.formatInline.exec(u,r,i,p,/non-matching-class/g),h=y.querySelectorAll(i+"."+p),s=h.length;o<s;o++){e=h[o];e.removeAttribute("class");for(v in f)e.setAttribute(v,f[v])}c=e;s===1&&(l=t.getTextContent(e),w=!!e.querySelector("*"),b=l===""||l===n.INVISIBLE_SPACE,!w&&b&&(t.setTextContent(e,f.text||e.href),a=y.createTextNode(" "),u.selection.setAfter(e),t.insert(a).after(e),c=a));u.selection.setAfter(c)}var r,i="A",t=n.dom;n.commands.createLink={exec:function(n,t,i){var r=this.state(n,t);r?n.selection.executeAndRestore(function(){u(n,r)}):(i=typeof i=="object"?i:{href:i},f(n,i))},state:function(t,i){return n.commands.formatInline.state(t,i,"A")}}}(wysihtml5),function(n){var i,t=/wysiwyg-font-size-[0-9a-z\-]+/g;n.commands.fontSize={exec:function(i,r,u){return n.commands.formatInline.exec(i,r,"span","wysiwyg-font-size-"+u,t)},state:function(i,r,u){return n.commands.formatInline.state(i,r,"span","wysiwyg-font-size-"+u,t)},value:function(){return i}}}(wysihtml5),function(n){var t=/wysiwyg-color-[0-9a-z]+/g;n.commands.foreColor={exec:function(i,r,u){return n.commands.formatInline.exec(i,r,"span","wysiwyg-color-"+u,t)},state:function(i,r,u){return n.commands.formatInline.state(i,r,"span","wysiwyg-color-"+u,t)}}}(wysihtml5),function(n){function h(n,t,i){n.className?(u(n,i),n.className+=" "+t):n.className=t}function u(n,t){n.className=n.className.replace(t,"")}function f(t){return t.nodeType===n.TEXT_NODE&&!n.lang.string(t.data).trim()}function e(n){for(var t=n.previousSibling;t&&f(t);)t=t.previousSibling;return t}function o(n){for(var t=n.nextSibling;t&&f(t);)t=t.nextSibling;return t}function c(n){var i=n.ownerDocument,t=o(n),r=e(n);t&&!s(t)&&n.parentNode.insertBefore(i.createElement("br"),t);r&&!s(r)&&n.parentNode.insertBefore(i.createElement("br"),n)}function l(n){var t=o(n),r=e(n);t&&i(t)&&t.parentNode.removeChild(t);r&&i(r)&&r.parentNode.removeChild(r)}function a(n){var t=n.lastChild;t&&i(t)&&t.parentNode.removeChild(t)}function i(n){return n.nodeName==="BR"}function s(n){return i(n)?!0:t.getStyle("display").from(n)==="block"?!0:!1}function v(i,r,u,f){if(f)var e=t.observe(i,"DOMNodeInserted",function(i){var r=i.target,u;r.nodeType===n.ELEMENT_NODE&&(u=t.getStyle("display").from(r),u.substr(0,6)!=="inline"&&(r.className+=" "+f))});i.execCommand(r,!1,u);e&&e.stop()}function y(t,i){t.selection.selectLine();t.selection.surround(i);l(i);a(i);t.selection.selectNode(i,n.browser.displaysCaretInEmptyContentEditableCorrectly())}function p(t){return!!n.lang.string(t.className).trim()}var t=n.dom,r=["H1","H2","H3","H4","H5","H6","P","BLOCKQUOTE","DIV"];n.commands.formatBlock={exec:function(i,f,e,o,s){var w=i.doc,l=this.state(i,f,e,o,s),b=i.config.useLineBreaks,a=b?"DIV":"P",k;if(e=typeof e=="string"?e.toUpperCase():e,l){i.selection.executeAndRestoreSimple(function(){s&&u(l,s);var n=p(l);!n&&(b||e==="P")?(c(l),t.replaceWithChildNodes(l)):t.renameElement(l,e==="P"?"DIV":a)});return}if((e===null||n.lang.array(r).contains(e))&&(k=i.selection.getSelectedNode(),l=t.getParentElement(k,{nodeName:r}),l)){i.selection.executeAndRestore(function(){e&&(l=t.renameElement(l,e));o&&h(l,o,s)});return}if(i.commands.support(f)){v(w,f,e||a,o);return}l=w.createElement(e||a);o&&(l.className=o);y(i,l)},state:function(n,i,r,u,f){r=typeof r=="string"?r.toUpperCase():r;var e=n.selection.getSelectedNode();return t.getParentElement(e,{nodeName:r,className:u,classRegExp:f})}}}(wysihtml5),function(n){function u(n){var t=i[n];return t?[n.toLowerCase(),t.toLowerCase()]:[n.toLowerCase()]}function r(i,r,f){var e=i+":"+r;return t[e]||(t[e]=new n.selection.HTMLApplier(u(i),r,f,!0)),t[e]}var i={strong:"b",em:"i",b:"strong",i:"em"},t={};n.commands.formatInline={exec:function(n,t,i,u,f){var e=n.selection.getRange();if(!e)return!1;r(i,u,f).toggleRange(e);n.selection.setSelection(e)},state:function(t,u,f,e,o){var s=t.doc,c=i[f]||f,h;return!n.dom.hasElementWithTagName(s,f)&&!n.dom.hasElementWithTagName(s,c)?!1:e&&!n.dom.hasElementWithClassName(s,e)?!1:(h=t.selection.getRange(),!h)?!1:r(f,e,o).isAppliedToRange(h)}}}(wysihtml5);wysihtml5.commands.insertHTML={exec:function(n,t,i){n.commands.support(t)?n.doc.execCommand(t,!1,i):n.selection.insertHTML(i)},state:function(){return!1}},function(n){var t="IMG";n.commands.insertImage={exec:function(i,r,u){u=typeof u=="object"?u:{src:u};var h=i.doc,f=this.state(i),s,o,e;if(f){i.selection.setBefore(f);e=f.parentNode;e.removeChild(f);n.dom.removeEmptyTextNodes(e);e.nodeName!=="A"||e.firstChild||(i.selection.setAfter(e),e.parentNode.removeChild(e));n.quirks.redraw(i.element);return}f=h.createElement(t);for(o in u)o==="className"&&(o="class"),f.setAttribute(o,u[o]);i.selection.insertNode(f);n.browser.hasProblemsSettingCaretAfterImg()?(s=h.createTextNode(n.INVISIBLE_SPACE),i.selection.insertNode(s),i.selection.setAfter(s)):i.selection.setAfter(f)},state:function(i){var e=i.doc,r,u,f;return n.dom.hasElementWithTagName(e,t)?(r=i.selection.getSelectedNode(),!r)?!1:r.nodeName===t?r:r.nodeType!==n.ELEMENT_NODE?!1:(u=i.selection.getText(),u=n.lang.string(u).trim(),u)?!1:(f=i.selection.getNodes(n.ELEMENT_NODE,function(n){return n.nodeName==="IMG"}),f.length!==1)?!1:f[0]:!1}}}(wysihtml5),function(n){var t="<br>"+(n.browser.needsSpaceAfterLineBreak()?" ":"");n.commands.insertLineBreak={exec:function(i,r){i.commands.support(r)?(i.doc.execCommand(r,!1,null),n.browser.autoScrollsToCaret()||i.selection.scrollIntoView()):i.commands.exec("insertHTML",t)},state:function(){return!1}}}(wysihtml5);wysihtml5.commands.insertOrderedList={exec:function(n,t){var f=n.doc,e=n.selection.getSelectedNode(),i=wysihtml5.dom.getParentElement(e,{nodeName:"OL"}),u=wysihtml5.dom.getParentElement(e,{nodeName:"UL"}),o="_wysihtml5-temp-"+(new Date).getTime(),s,r;if(!i&&!u&&n.commands.support(t)){f.execCommand(t,!1,null);return}i?n.selection.executeAndRestore(function(){wysihtml5.dom.resolveList(i,n.config.useLineBreaks)}):u?n.selection.executeAndRestore(function(){wysihtml5.dom.renameElement(u,"ol")}):(n.commands.exec("formatBlock","div",o),r=f.querySelector("."+o),s=r.innerHTML===""||r.innerHTML===wysihtml5.INVISIBLE_SPACE||r.innerHTML==="<br>",n.selection.executeAndRestore(function(){i=wysihtml5.dom.convertToList(r,"ol")}),s&&n.selection.selectNode(i.querySelector("li"),!0))},state:function(n){var t=n.selection.getSelectedNode();return wysihtml5.dom.getParentElement(t,{nodeName:"OL"})}};wysihtml5.commands.insertUnorderedList={exec:function(n,t){var f=n.doc,e=n.selection.getSelectedNode(),i=wysihtml5.dom.getParentElement(e,{nodeName:"UL"}),u=wysihtml5.dom.getParentElement(e,{nodeName:"OL"}),o="_wysihtml5-temp-"+(new Date).getTime(),s,r;if(!i&&!u&&n.commands.support(t)){f.execCommand(t,!1,null);return}i?n.selection.executeAndRestore(function(){wysihtml5.dom.resolveList(i,n.config.useLineBreaks)}):u?n.selection.executeAndRestore(function(){wysihtml5.dom.renameElement(u,"ul")}):(n.commands.exec("formatBlock","div",o),r=f.querySelector("."+o),s=r.innerHTML===""||r.innerHTML===wysihtml5.INVISIBLE_SPACE||r.innerHTML==="<br>",n.selection.executeAndRestore(function(){i=wysihtml5.dom.convertToList(r,"ul")}),s&&n.selection.selectNode(i.querySelector("li"),!0))},state:function(n){var t=n.selection.getSelectedNode();return wysihtml5.dom.getParentElement(t,{nodeName:"UL"})}};wysihtml5.commands.italic={exec:function(n,t){return wysihtml5.commands.formatInline.exec(n,t,"i")},state:function(n,t){return wysihtml5.commands.formatInline.state(n,t,"i")}},function(n){var t="wysiwyg-text-align-center",i=/wysiwyg-text-align-[0-9a-z]+/g;n.commands.justifyCenter={exec:function(r){return n.commands.formatBlock.exec(r,"formatBlock",null,t,i)},state:function(r){return n.commands.formatBlock.state(r,"formatBlock",null,t,i)}}}(wysihtml5),function(n){var t="wysiwyg-text-align-left",i=/wysiwyg-text-align-[0-9a-z]+/g;n.commands.justifyLeft={exec:function(r){return n.commands.formatBlock.exec(r,"formatBlock",null,t,i)},state:function(r){return n.commands.formatBlock.state(r,"formatBlock",null,t,i)}}}(wysihtml5),function(n){var t="wysiwyg-text-align-right",i=/wysiwyg-text-align-[0-9a-z]+/g;n.commands.justifyRight={exec:function(r){return n.commands.formatBlock.exec(r,"formatBlock",null,t,i)},state:function(r){return n.commands.formatBlock.state(r,"formatBlock",null,t,i)}}}(wysihtml5),function(n){var t="wysiwyg-text-align-justify",i=/wysiwyg-text-align-[0-9a-z]+/g;n.commands.justifyFull={exec:function(r){return n.commands.formatBlock.exec(r,"formatBlock",null,t,i)},state:function(r){return n.commands.formatBlock.state(r,"formatBlock",null,t,i)}}}(wysihtml5);wysihtml5.commands.redo={exec:function(n){return n.undoManager.redo()},state:function(){return!1}};wysihtml5.commands.underline={exec:function(n,t){return wysihtml5.commands.formatInline.exec(n,t,"u")},state:function(n,t){return wysihtml5.commands.formatInline.state(n,t,"u")}};wysihtml5.commands.undo={exec:function(n){return n.undoManager.undo()},state:function(){return!1}},function(n){function l(n){for(var t;t=n.querySelector("._wysihtml5-temp");)t.parentNode.removeChild(t)}var u=90,f=89,e=8,o=46,s=25,i="data-wysihtml5-selection-node",t="data-wysihtml5-selection-offset",h='<span id="_wysihtml5-undo" class="_wysihtml5-temp">'+n.INVISIBLE_SPACE+"<\/span>",c='<span id="_wysihtml5-redo" class="_wysihtml5-temp">'+n.INVISIBLE_SPACE+"<\/span>",r=n.dom;n.UndoManager=n.lang.Dispatcher.extend({constructor:function(n){this.editor=n;this.composer=n.composer;this.element=this.composer.element;this.position=0;this.historyStr=[];this.historyDom=[];this.transact();this._observe()},_observe:function(){var t=this,i=this.composer.sandbox.getDocument(),a,v,y,s;r.observe(this.element,"keydown",function(n){if(!n.altKey&&(n.ctrlKey||n.metaKey)){var i=n.keyCode,r=i===u&&!n.shiftKey,e=i===u&&n.shiftKey||i===f;r?(t.undo(),n.preventDefault()):e&&(t.redo(),n.preventDefault())}});r.observe(this.element,"keydown",function(n){var i=n.keyCode;i!==a&&(a=i,(i===e||i===o)&&t.transact())});n.browser.hasUndoInContextMenu()&&(s=function(){l(i);clearInterval(v)},r.observe(this.element,"contextmenu",function(){s();t.composer.selection.executeAndRestoreSimple(function(){t.element.lastChild&&t.composer.selection.setAfter(t.element.lastChild);i.execCommand("insertHTML",!1,h);i.execCommand("insertHTML",!1,c);i.execCommand("undo",!1,null)});v=setInterval(function(){i.getElementById("_wysihtml5-redo")?(s(),t.redo()):i.getElementById("_wysihtml5-undo")||(s(),t.undo())},400);y||(y=!0,r.observe(document,"mousedown",s),r.observe(i,["mousedown","paste","cut","copy"],s))}));this.editor.on("newword:composer",function(){t.transact()}).on("beforecommand:composer",function(){t.transact()})},transact:function(){var l=this.historyStr[this.position-1],f=this.composer.getValue(),o,c;if(f!==l){o=this.historyStr.length=this.historyDom.length=this.position;o>s&&(this.historyStr.shift(),this.historyDom.shift(),this.position--);this.position++;var h=this.composer.selection.getRange(),u=h.startContainer||this.element,a=h.startOffset||0,r,e;u.nodeType===n.ELEMENT_NODE?r=u:(r=u.parentNode,e=this.getChildNodeIndex(r,u));r.setAttribute(t,a);typeof e!="undefined"&&r.setAttribute(i,e);c=this.element.cloneNode(!!f);this.historyDom.push(c);this.historyStr.push(f);r.removeAttribute(t);r.removeAttribute(i)}},undo:function(){(this.transact(),this.undoPossible())&&(this.set(this.historyDom[--this.position-1]),this.editor.fire("undo:composer"))},redo:function(){this.redoPossible()&&(this.set(this.historyDom[++this.position-1]),this.editor.fire("redo:composer"))},undoPossible:function(){return this.position>1},redoPossible:function(){return this.position<this.historyStr.length},set:function(n){var e,r,u;this.element.innerHTML="";for(var f=0,o=n.childNodes,s=n.childNodes.length;f<s;f++)this.element.appendChild(o[f].cloneNode(!0));n.hasAttribute(t)?(e=n.getAttribute(t),u=n.getAttribute(i),r=this.element):(r=this.element.querySelector("["+t+"]")||this.element,e=r.getAttribute(t),u=r.getAttribute(i),r.removeAttribute(t),r.removeAttribute(i));u!==null&&(r=this.getChildNodeByIndex(r,+u));this.composer.selection.set(r,e)},getChildNodeIndex:function(n,t){for(var i=0,r=n.childNodes,u=r.length;i<u;i++)if(r[i]===t)return i},getChildNodeByIndex:function(n,t){return n.childNodes[t]}})}(wysihtml5);wysihtml5.views.View=Base.extend({constructor:function(n,t,i){this.parent=n;this.element=t;this.config=i;this._observeViewChange()},_observeViewChange:function(){var n=this;this.parent.on("beforeload",function(){n.parent.on("change_view",function(t){t===n.name?(n.parent.currentView=n,n.show(),setTimeout(function(){n.focus()},0)):n.hide()})})},focus:function(){if(this.element.ownerDocument.querySelector(":focus")!==this.element)try{this.element.focus()}catch(n){}},hide:function(){this.element.style.display="none"},show:function(){this.element.style.display=""},disable:function(){this.element.setAttribute("disabled","disabled")},enable:function(){this.element.removeAttribute("disabled")}}),function(n){var t=n.dom,i=n.browser;n.views.Composer=n.views.View.extend({name:"composer",CARET_HACK:"<br>",constructor:function(n,t,i){this.base(n,t,i);this.textarea=this.parent.textarea;this._initSandbox()},clear:function(){this.element.innerHTML=i.displaysCaretInEmptyContentEditableCorrectly()?"":this.CARET_HACK},getValue:function(t){var i=this.isEmpty()?"":n.quirks.getCorrectInnerHTML(this.element);return t&&(i=this.parent.parse(i)),n.lang.string(i).replace(n.INVISIBLE_SPACE).by("")},setValue:function(n,t){t&&(n=this.parent.parse(n));try{this.element.innerHTML=n}catch(i){this.element.innerText=n}},show:function(){this.iframe.style.display=this._displayStyle||"";this.textarea.element.disabled||(this.disable(),this.enable())},hide:function(){this._displayStyle=t.getStyle("display").from(this.iframe);this._displayStyle==="none"&&(this._displayStyle=null);this.iframe.style.display="none"},disable:function(){this.parent.fire("disable:composer");this.element.removeAttribute("contentEditable")},enable:function(){this.parent.fire("enable:composer");this.element.setAttribute("contentEditable","true")},focus:function(t){n.browser.doesAsyncFocus()&&this.hasPlaceholderSet()&&this.clear();this.base();var i=this.element.lastChild;t&&i&&(i.nodeName==="BR"?this.selection.setBefore(this.element.lastChild):this.selection.setAfter(this.element.lastChild))},getTextContent:function(){return t.getTextContent(this.element)},hasPlaceholderSet:function(){return this.getTextContent()==this.textarea.element.getAttribute("placeholder")&&this.placeholderSet},isEmpty:function(){var n=this.element.innerHTML.toLowerCase();return n===""||n==="<br>"||n==="<p><\/p>"||n==="<p><br><\/p>"||this.hasPlaceholderSet()},_initSandbox:function(){var r=this,i,n;this.sandbox=new t.Sandbox(function(){r._create()},{stylesheets:this.config.stylesheets});this.iframe=this.sandbox.getIframe();i=this.textarea.element;t.insert(this.iframe).after(i);i.form&&(n=document.createElement("input"),n.type="hidden",n.name="_wysihtml5_mode",n.value=1,t.insert(n).after(i))},_create:function(){var f=this,r,u;this.doc=this.sandbox.getDocument();this.element=this.doc.body;this.textarea=this.parent.textarea;this.element.innerHTML=this.textarea.getValue(!0);this.selection=new n.Selection(this.parent);this.commands=new n.Commands(this.parent);t.copyAttributes(["className","spellcheck","title","lang","dir","accessKey"]).from(this.textarea.element).to(this.element);t.addClass(this.element,this.config.composerClassName);this.config.style&&this.style();this.observe();r=this.config.name;r&&(t.addClass(this.element,r),t.addClass(this.iframe,r));this.enable();this.textarea.element.disabled&&this.disable();u=typeof this.config.placeholder=="string"?this.config.placeholder:this.textarea.element.getAttribute("placeholder");u&&t.simulatePlaceholder(this.parent,this,u);this.commands.exec("styleWithCSS",!1);this._initAutoLinking();this._initObjectResizing();this._initUndoManager();this._initLineBreaking();(this.textarea.element.hasAttribute("autofocus")||document.querySelector(":focus")==this.textarea.element)&&!i.isIos()&&setTimeout(function(){f.focus(!0)},100);i.clearsContentEditableCorrectly()||n.quirks.ensureProperClearing(this);this.initSync&&this.config.sync&&this.initSync();this.textarea.hide();this.parent.fire("beforeload").fire("load")},_initAutoLinking:function(){var r=this,u=i.canDisableAutoLinking(),f=i.doesAutoLinkingInContentEditable();if(u&&this.commands.exec("autoUrlDetect",!1),this.config.autoLink){if(!f||f&&u){this.parent.on("newword:composer",function(){t.getTextContent(r.element).match(t.autoLink.URL_REG_EXP)&&r.selection.executeAndRestore(function(n,i){t.autoLink(i.parentNode)})});t.observe(this.element,"blur",function(){t.autoLink(r.element)})}var o=this.sandbox.getDocument().getElementsByTagName("a"),s=t.autoLink.URL_REG_EXP,e=function(i){var r=n.lang.string(t.getTextContent(i)).trim();return r.substr(0,4)==="www."&&(r="http://"+r),r};t.observe(this.element,"keydown",function(n){if(o.length){var f=r.selection.getSelectedNode(n.target.ownerDocument),i=t.getParentElement(f,{nodeName:"A"},4),u;i&&(u=e(i),setTimeout(function(){var n=e(i);n!==u&&n.match(s)&&i.setAttribute("href",n)},0))}})}},_initObjectResizing:function(){if(this.commands.exec("enableObjectResizing",!0),i.supportsEvent("resizeend")){var r=["width","height"],f=r.length,u=this.element;t.observe(u,"resizeend",function(t){var e=t.target||t.srcElement,o=e.style,s=0,i;if(e.nodeName==="IMG"){for(;s<f;s++)i=r[s],o[i]&&(e.setAttribute(i,parseInt(o[i],10)),o[i]="");n.quirks.redraw(u)}})}},_initUndoManager:function(){this.undoManager=new n.UndoManager(this.parent)},_initLineBreaking:function(){function u(n){var i=t.getParentElement(n,{nodeName:["P","DIV"]},2);i&&r.selection.executeAndRestore(function(){r.config.useLineBreaks?t.replaceWithChildNodes(i):i.nodeName!=="P"&&t.renameElement(i,"p")})}var r=this,f=["LI","P","H1","H2","H3","H4","H5","H6"],e=["UL","OL","MENU"];this.config.useLineBreaks||t.observe(this.element,["focus","keydown"],function(){if(r.isEmpty()){var n=r.doc.createElement("P");r.element.innerHTML="";r.element.appendChild(n);i.displaysCaretInEmptyContentEditableCorrectly()?r.selection.selectNode(n,!0):(n.innerHTML="<br>",r.selection.setBefore(n.firstChild))}});t.observe(this.doc,"keydown",function(i){var o=i.keyCode,s;if(!i.shiftKey&&(o===n.ENTER_KEY||o===n.BACKSPACE_KEY)){if(s=t.getParentElement(r.selection.getSelectedNode(),{nodeName:f},4),s){setTimeout(function(){var i=r.selection.getSelectedNode(),f;if(s.nodeName==="LI"){if(!i)return;f=t.getParentElement(i,{nodeName:e},2);f||u(i)}o===n.ENTER_KEY&&s.nodeName.match(/^H[1-6]$/)&&u(i)},0);return}r.config.useLineBreaks&&o===n.ENTER_KEY&&!n.browser.insertsLineBreaksOnReturn()&&(r.commands.exec("insertLineBreak"),i.preventDefault())}})}})}(wysihtml5),function(n){var t=n.dom,r=document,e=window,f=r.createElement("div"),i=["background-color","color","cursor","font-family","font-size","font-style","font-variant","font-weight","line-height","letter-spacing","text-align","text-decoration","text-indent","text-rendering","word-break","word-wrap","word-spacing"],u=["background-color","border-collapse","border-bottom-color","border-bottom-style","border-bottom-width","border-left-color","border-left-style","border-left-width","border-right-color","border-right-style","border-right-width","border-top-color","border-top-style","border-top-width","clear","display","float","margin-bottom","margin-left","margin-right","margin-top","outline-color","outline-offset","outline-width","outline-style","padding-left","padding-right","padding-top","padding-bottom","position","top","left","right","bottom","z-index","vertical-align","text-align","-webkit-box-sizing","-moz-box-sizing","-ms-box-sizing","box-sizing","-webkit-box-shadow","-moz-box-shadow","-ms-box-shadow","box-shadow","-webkit-border-top-right-radius","-moz-border-radius-topright","border-top-right-radius","-webkit-border-bottom-right-radius","-moz-border-radius-bottomright","border-bottom-right-radius","-webkit-border-bottom-left-radius","-moz-border-radius-bottomleft","border-bottom-left-radius","-webkit-border-top-left-radius","-moz-border-radius-topleft","border-top-left-radius","width","height"],o=["html                 { height: 100%; }","body                 { height: 100%; padding: 1px 0 0 0; margin: -1px 0 0 0; }","body > p:first-child { margin-top: 0; }","._wysihtml5-temp     { display: none; }",n.browser.isGecko?"body.placeholder { color: graytext !important; }":"body.placeholder { color: #a9a9a9 !important; }","img:-moz-broken      { -moz-force-broken-image-icon: 1; height: 24px; width: 24px; }"],s=function(n){if(n.setActive)try{n.setActive()}catch(s){}else{var i=n.style,u=r.documentElement.scrollTop||r.body.scrollTop,f=r.documentElement.scrollLeft||r.body.scrollLeft,o={position:i.position,top:i.top,left:i.left,WebkitUserSelect:i.WebkitUserSelect};t.setStyles({position:"absolute",top:"-99999px",left:"-99999px",WebkitUserSelect:"none"}).on(n);n.focus();t.setStyles(o).on(n);e.scrollTo&&e.scrollTo(f,u)}};n.views.Composer.prototype.style=function(){var h=this,l=r.querySelector(":focus"),e=this.textarea.element,a=e.hasAttribute("placeholder"),p=a&&e.getAttribute("placeholder"),v=e.style.display,w=e.disabled,y,c;this.focusStylesHost=f.cloneNode(!1);this.blurStylesHost=f.cloneNode(!1);this.disabledStylesHost=f.cloneNode(!1);a&&e.removeAttribute("placeholder");e===l&&e.blur();e.disabled=!1;e.style.display=y="none";(e.getAttribute("rows")&&t.getStyle("height").from(e)==="auto"||e.getAttribute("cols")&&t.getStyle("width").from(e)==="auto")&&(e.style.display=y=v);t.copyStyles(u).from(e).to(this.iframe).andTo(this.blurStylesHost);t.copyStyles(i).from(e).to(this.element).andTo(this.blurStylesHost);t.insertCSS(o).into(this.element.ownerDocument);e.disabled=!0;t.copyStyles(u).from(e).to(this.disabledStylesHost);t.copyStyles(i).from(e).to(this.disabledStylesHost);e.disabled=w;e.style.display=v;s(e);e.style.display=y;t.copyStyles(u).from(e).to(this.focusStylesHost);t.copyStyles(i).from(e).to(this.focusStylesHost);e.style.display=v;t.copyStyles(["display"]).from(e).to(this.iframe);c=n.lang.array(u).without(["display"]);l?l.focus():e.blur();a&&e.setAttribute("placeholder",p);this.parent.on("focus:composer",function(){t.copyStyles(c).from(h.focusStylesHost).to(h.iframe);t.copyStyles(i).from(h.focusStylesHost).to(h.element)});this.parent.on("blur:composer",function(){t.copyStyles(c).from(h.blurStylesHost).to(h.iframe);t.copyStyles(i).from(h.blurStylesHost).to(h.element)});return this.parent.observe("disable:composer",function(){t.copyStyles(c).from(h.disabledStylesHost).to(h.iframe);t.copyStyles(i).from(h.disabledStylesHost).to(h.element)}),this.parent.observe("enable:composer",function(){t.copyStyles(c).from(h.blurStylesHost).to(h.iframe);t.copyStyles(i).from(h.blurStylesHost).to(h.element)}),this}}(wysihtml5),function(n){var t=n.dom,i=n.browser,r={"66":"bold","73":"italic","85":"underline"};n.views.Composer.prototype.observe=function(){var u=this,o=this.getValue(),s=this.sandbox.getIframe(),f=this.element,h=i.supportsEventsInIframeCorrectly()?f:this.sandbox.getWindow(),e,c;t.observe(s,"DOMNodeRemoved",function(){clearInterval(e);u.parent.fire("destroy:composer")});e=setInterval(function(){t.contains(document.documentElement,s)||(clearInterval(e),u.parent.fire("destroy:composer"))},250);t.observe(h,"focus",function(){u.parent.fire("focus").fire("focus:composer");setTimeout(function(){o=u.getValue()},0)});t.observe(h,"blur",function(){o!==u.getValue()&&u.parent.fire("change").fire("change:composer");u.parent.fire("blur").fire("blur:composer")});t.observe(f,"dragenter",function(){u.parent.fire("unset_placeholder")});t.observe(f,["drop","paste"],function(){setTimeout(function(){u.parent.fire("paste").fire("paste:composer")},0)});t.observe(f,"keyup",function(t){var i=t.keyCode;(i===n.SPACE_KEY||i===n.ENTER_KEY)&&u.parent.fire("newword:composer")});this.parent.on("paste:composer",function(){setTimeout(function(){u.parent.fire("newword:composer")},0)});i.canSelectImagesInContentEditable()||t.observe(f,"mousedown",function(n){var t=n.target;t.nodeName==="IMG"&&(u.selection.selectNode(t),n.preventDefault())});i.hasHistoryIssue()&&i.supportsSelectionModify()&&t.observe(f,"keydown",function(n){if(n.metaKey||n.ctrlKey){var t=n.keyCode,r=f.ownerDocument.defaultView,i=r.getSelection();(t===37||t===39)&&(t===37&&(i.modify("extend","left","lineboundary"),n.shiftKey||i.collapseToStart()),t===39&&(i.modify("extend","right","lineboundary"),n.shiftKey||i.collapseToEnd()),n.preventDefault())}});t.observe(f,"keydown",function(n){var i=n.keyCode,t=r[i];(n.ctrlKey||n.metaKey)&&!n.altKey&&t&&(u.commands.exec(t),n.preventDefault())});t.observe(f,"keydown",function(t){var r=u.selection.getSelectedNode(!0),e=t.keyCode,i;r&&r.nodeName==="IMG"&&(e===n.BACKSPACE_KEY||e===n.DELETE_KEY)&&(i=r.parentNode,i.removeChild(r),i.nodeName!=="A"||i.firstChild||i.parentNode.removeChild(i),setTimeout(function(){n.quirks.redraw(f)},0),t.preventDefault())});i.hasIframeFocusIssue()&&(t.observe(this.iframe,"focus",function(){setTimeout(function(){u.doc.querySelector(":focus")!==u.element&&u.focus()},0)}),t.observe(this.element,"blur",function(){setTimeout(function(){u.selection.getSelection().removeAllRanges()},0)}));c={IMG:"Image: ",A:"Link: "};t.observe(f,"mouseover",function(n){var t=n.target,i=t.nodeName,r,u;(i==="A"||i==="IMG")&&(u=t.hasAttribute("title"),u||(r=c[i]+(t.getAttribute("href")||t.getAttribute("src")),t.setAttribute("title",r)))})}}(wysihtml5),function(n){var t=400;n.views.Synchronizer=Base.extend({constructor:function(n,t,i){this.editor=n;this.textarea=t;this.composer=i;this._observe()},fromComposerToTextarea:function(t){this.textarea.setValue(n.lang.string(this.composer.getValue()).trim(),t)},fromTextareaToComposer:function(n){var t=this.textarea.getValue();t?this.composer.setValue(t,n):(this.composer.clear(),this.editor.fire("set_placeholder"))},sync:function(n){this.editor.currentView.name==="textarea"?this.fromTextareaToComposer(n):this.fromComposerToTextarea(n)},_observe:function(){var r,i=this,u=this.textarea.element.form,f=function(){r=setInterval(function(){i.fromComposerToTextarea()},t)},e=function(){clearInterval(r);r=null};f();u&&(n.dom.observe(u,"submit",function(){i.sync(!0)}),n.dom.observe(u,"reset",function(){setTimeout(function(){i.fromTextareaToComposer()},0)}));this.editor.on("change_view",function(n){n!=="composer"||r?n==="textarea"&&(i.fromComposerToTextarea(!0),e()):(i.fromTextareaToComposer(!0),f())});this.editor.on("destroy:composer",e)}})}(wysihtml5);wysihtml5.views.Textarea=wysihtml5.views.View.extend({name:"textarea",constructor:function(n,t,i){this.base(n,t,i);this._observe()},clear:function(){this.element.value=""},getValue:function(n){var t=this.isEmpty()?"":this.element.value;return n&&(t=this.parent.parse(t)),t},setValue:function(n,t){t&&(n=this.parent.parse(n));this.element.value=n},hasPlaceholderSet:function(){var t=wysihtml5.browser.supportsPlaceholderAttributeOn(this.element),i=this.element.getAttribute("placeholder")||null,n=this.element.value,r=!n;return t&&r||n===i},isEmpty:function(){return!wysihtml5.lang.string(this.element.value).trim()||this.hasPlaceholderSet()},_observe:function(){var t=this.element,n=this.parent,i={focusin:"focus",focusout:"blur"},r=wysihtml5.browser.supportsEvent("focusin")?["focusin","focusout","change"]:["focus","blur","change"];n.on("beforeload",function(){wysihtml5.dom.observe(t,r,function(t){var r=i[t.type]||t.type;n.fire(r).fire(r+":textarea")});wysihtml5.dom.observe(t,["paste","drop"],function(){setTimeout(function(){n.fire("paste").fire("paste:textarea")},0)})})}}),function(n){var t=n.dom,i="wysihtml5-command-dialog-opened",r="input, select, textarea",u="[data-wysihtml5-dialog-field]",f="data-wysihtml5-dialog-field";n.toolbar.Dialog=n.lang.Dispatcher.extend({constructor:function(n,t){this.link=n;this.container=t},_observe:function(){var u,f;if(!this._observed){u=this;f=function(n){var t=u._serialize();t==u.elementToChange?u.fire("edit",t):u.fire("save",t);u.hide();n.preventDefault();n.stopPropagation()};t.observe(u.link,"click",function(){t.hasClass(u.link,i)&&setTimeout(function(){u.hide()},0)});t.observe(this.container,"keydown",function(t){var i=t.keyCode;i===n.ENTER_KEY&&f(t);i===n.ESCAPE_KEY&&u.hide()});t.delegate(this.container,"[data-wysihtml5-dialog-action=save]","click",f);t.delegate(this.container,"[data-wysihtml5-dialog-action=cancel]","click",function(n){u.fire("cancel");u.hide();n.preventDefault();n.stopPropagation()});for(var o=this.container.querySelectorAll(r),e=0,s=o.length,h=function(){clearInterval(u.interval)};e<s;e++)t.observe(o[e],"change",h);this._observed=!0}},_serialize:function(){for(var i=this.elementToChange||{},t=this.container.querySelectorAll(u),r=t.length,n=0;n<r;n++)i[t[n].getAttribute(f)]=t[n].value;return i},_interpolate:function(n){for(var t,r,e,s=document.querySelector(":focus"),o=this.container.querySelectorAll(u),h=o.length,i=0;i<h;i++)(t=o[i],t!==s)&&(n&&t.type==="hidden"||(r=t.getAttribute(f),e=this.elementToChange?this.elementToChange[r]||"":t.defaultValue,t.value=e))},show:function(n){if(!t.hasClass(this.link,i)){var f=this,u=this.container.querySelector(r);if(this.elementToChange=n,this._observe(),this._interpolate(),n&&(this.interval=setInterval(function(){f._interpolate(!0)},500)),t.addClass(this.link,i),this.container.style.display="",this.fire("show"),u&&!n)try{u.focus()}catch(e){}}},hide:function(){clearInterval(this.interval);this.elementToChange=null;t.removeClass(this.link,i);this.container.style.display="none";this.fire("hide")}})}(wysihtml5),function(n){var t=n.dom,u={position:"relative"},i={left:0,margin:0,opacity:0,overflow:"hidden",padding:0,position:"absolute",top:0,zIndex:1},f={cursor:"inherit",fontSize:"50px",height:"50px",marginTop:"-25px",outline:0,padding:0,position:"absolute",right:"-4px",top:"50%"},r={"x-webkit-speech":"",speech:""};n.toolbar.Speech=function(e,o){var s=document.createElement("input"),c,h,l;if(!n.browser.supportsSpeechApiOn(s)){o.style.display="none";return}c=e.editor.textarea.element.getAttribute("lang");c&&(r.lang=c);h=document.createElement("div");n.lang.object(i).merge({width:o.offsetWidth+"px",height:o.offsetHeight+"px"});t.insert(s).into(h);t.insert(h).into(o);t.setStyles(f).on(s);t.setAttributes(r).on(s);t.setStyles(i).on(h);t.setStyles(u).on(o);l="onwebkitspeechchange"in s?"webkitspeechchange":"speechchange";t.observe(s,l,function(){e.execCommand("insertText",s.value);s.value=""});t.observe(s,"click",function(n){t.hasClass(o,"wysihtml5-command-disabled")&&n.preventDefault();n.stopPropagation()})}}(wysihtml5),function(n){var r="wysihtml5-command-disabled",u="wysihtml5-commands-disabled",i="wysihtml5-command-active",f="wysihtml5-action-active",t=n.dom;n.toolbar.Toolbar=Base.extend({constructor:function(t,i){this.editor=t;this.container=typeof i=="string"?document.getElementById(i):i;this.composer=t.composer;this._getLinks("command");this._getLinks("action");this._observe();this.show();for(var u=this.container.querySelectorAll("[data-wysihtml5-command=insertSpeech]"),f=u.length,r=0;r<f;r++)new n.toolbar.Speech(this,u[r])},_getLinks:function(t){for(var e=this[t+"Links"]=n.lang.array(this.container.querySelectorAll("[data-wysihtml5-"+t+"]")).get(),h=e.length,u=0,c=this[t+"Mapping"]={},i,o,r,f,s;u<h;u++)i=e[u],r=i.getAttribute("data-wysihtml5-"+t),f=i.getAttribute("data-wysihtml5-"+t+"-value"),o=this.container.querySelector("[data-wysihtml5-"+t+"-group='"+r+"']"),s=this._getDialog(i,r),c[r+":"+f]={link:i,group:o,name:r,value:f,dialog:s,state:!1}},_getDialog:function(t,i){var r=this,u=this.container.querySelector("[data-wysihtml5-dialog='"+i+"']"),f,e;if(u){f=new n.toolbar.Dialog(t,u);f.on("show",function(){e=r.composer.selection.getBookmark();r.editor.fire("show:dialog",{command:i,dialogContainer:u,commandLink:t})});f.on("save",function(n){e&&r.composer.selection.setBookmark(e);r._execCommand(i,n);r.editor.fire("save:dialog",{command:i,dialogContainer:u,commandLink:t})});f.on("cancel",function(){r.editor.focus(!1);r.editor.fire("cancel:dialog",{command:i,dialogContainer:u,commandLink:t})})}return f},execCommand:function(n,t){if(!this.commandsDisabled){var i=this.commandMapping[n+":"+t];i&&i.dialog&&!i.state?i.dialog.show():this._execCommand(n,t)}},_execCommand:function(n,t){this.editor.focus(!1);this.composer.commands.exec(n,t);this._updateLinkStates()},execAction:function(n){var t=this.editor;n==="change_view"&&(t.currentView===t.textarea?t.fire("change_view","composer"):t.fire("change_view","textarea"))},_observe:function(){for(var n=this,r=this.editor,i=this.container,e=this.commandLinks.concat(this.actionLinks),o=e.length,f=0;f<o;f++)t.setAttributes({href:"javascript:;",unselectable:"on"}).on(e[f]);t.delegate(i,"[data-wysihtml5-command], [data-wysihtml5-action]","mousedown",function(n){n.preventDefault()});t.delegate(i,"[data-wysihtml5-command]","click",function(t){var i=this,r=i.getAttribute("data-wysihtml5-command"),u=i.getAttribute("data-wysihtml5-command-value");n.execCommand(r,u);t.preventDefault()});t.delegate(i,"[data-wysihtml5-action]","click",function(t){var i=this.getAttribute("data-wysihtml5-action");n.execAction(i);t.preventDefault()});r.on("focus:composer",function(){n.bookmark=null;clearInterval(n.interval);n.interval=setInterval(function(){n._updateLinkStates()},500)});r.on("blur:composer",function(){clearInterval(n.interval)});r.on("destroy:composer",function(){clearInterval(n.interval)});r.on("change_view",function(r){setTimeout(function(){n.commandsDisabled=r!=="composer";n._updateLinkStates();n.commandsDisabled?t.addClass(i,u):t.removeClass(i,u)},0)})},_updateLinkStates:function(){var h=this.commandMapping,c=this.actionMapping,s,e,o,u;for(s in h)(u=h[s],this.commandsDisabled?(e=!1,t.removeClass(u.link,i),u.group&&t.removeClass(u.group,i),u.dialog&&u.dialog.hide()):(e=this.composer.commands.state(u.name,u.value),n.lang.object(e).isArray()&&(e=e.length===1?e[0]:!0),t.removeClass(u.link,r),u.group&&t.removeClass(u.group,r)),u.state!==e)&&(u.state=e,e?(t.addClass(u.link,i),u.group&&t.addClass(u.group,i),u.dialog&&(typeof e=="object"?u.dialog.show(e):u.dialog.hide())):(t.removeClass(u.link,i),u.group&&t.removeClass(u.group,i),u.dialog&&u.dialog.hide()));for(s in c)o=c[s],o.name==="change_view"&&(o.state=this.editor.currentView===this.editor.textarea,o.state?t.addClass(o.link,f):t.removeClass(o.link,f))},show:function(){this.container.style.display=""},hide:function(){this.container.style.display="none"}})}(wysihtml5),function(n){var t,i={name:t,style:!0,toolbar:t,autoLink:!0,parserRules:{tags:{br:{},span:{},div:{},p:{}},classes:{}},parser:n.dom.parse,composerClassName:"wysihtml5-editor",bodyClassName:"wysihtml5-supported",useLineBreaks:!0,stylesheets:[],placeholderText:t,supportTouchDevices:!0};n.Editor=n.lang.Dispatcher.extend({constructor:function(t,r){if(this.textareaElement=typeof t=="string"?document.getElementById(t):t,this.config=n.lang.object({}).merge(i).merge(r).get(),this.textarea=new n.views.Textarea(this,this.textareaElement,this.config),this.currentView=this.textarea,this._isCompatible=n.browser.supported(),!this._isCompatible||!this.config.supportTouchDevices&&n.browser.isTouchDevice()){var u=this;setTimeout(function(){u.fire("beforeload").fire("load")},0);return}n.dom.addClass(document.body,this.config.bodyClassName);this.composer=new n.views.Composer(this,this.textareaElement,this.config);this.currentView=this.composer;typeof this.config.parser=="function"&&this._initParser();this.on("beforeload",function(){this.synchronizer=new n.views.Synchronizer(this,this.textarea,this.composer);this.config.toolbar&&(this.toolbar=new n.toolbar.Toolbar(this,this.config.toolbar))});try{}catch(f){}},isCompatible:function(){return this._isCompatible},clear:function(){return this.currentView.clear(),this},getValue:function(n){return this.currentView.getValue(n)},setValue:function(n,t){return(this.fire("unset_placeholder"),!n)?this.clear():(this.currentView.setValue(n,t),this)},focus:function(n){return this.currentView.focus(n),this},disable:function(){return this.currentView.disable(),this},enable:function(){return this.currentView.enable(),this},isEmpty:function(){return this.currentView.isEmpty()},hasPlaceholderSet:function(){return this.currentView.hasPlaceholderSet()},parse:function(t){var i=this.config.parser(t,this.config.parserRules,this.composer.sandbox.getDocument(),!0);return typeof t=="object"&&n.quirks.redraw(t),i},_initParser:function(){this.on("paste:composer",function(){var t=this;t.composer.selection.executeAndRestore(function(){n.quirks.cleanPastedHTML(t.composer.element);t.parse(t.composer.element)},!0)})}})}(wysihtml5),function(){function n(n,t){return function(){return n.apply(t,arguments)}}var t,i;t=function(){function t(t){var i=this;this.el=t;this.resetHeight=n(this.resetHeight,this);this.adjustHeight=n(this.adjustHeight,this);this.watchForChanges=n(this.watchForChanges,this);this.makeTestContainer=n(this.makeTestContainer,this);this.preventScrollBars=n(this.preventScrollBars,this);this.sourceContents=n(this.sourceContents,this);this.source=n(this.source,this);this.$el=$(this.el).css({resize:"none"});this.heightLimit=this.$el.data("autoresize-limit");this.$source=this.source();this.originalHeight=this.$el.height();this.$testContainer=this.makeTestContainer();this.preventScrollBars();setTimeout(function(){i.adjustHeight();i.watchForChanges()},1)}return t.prototype.resizeBy=0,t.install=function(n){if(!$(n).is("[data-autoresize]"))return $(n).attr("data-autoresize",!0),new this(n)},t.prototype.source=function(){return this.$el},t.prototype.sourceContents=function(){return this.$source.val()},t.prototype.preventScrollBars=function(){return this.$source.css("overflow","hidden")},t.prototype.makeTestContainer=function(){var t,i,r,n,u;for(t=$("<div>").css({position:"absolute",left:-9999,top:0,"word-wrap":"break-word"}).addClass("wysihtml5-temp"),i=["fontSize","fontFamily","fontWeight","letterSpacing","lineHeight","textDecoration","padding","margin"],n=0,u=i.length;n<u;n++)r=i[n],t.css(r,this.$source.css(r));return t.insertBefore(this.$el)},t.prototype.watchForChanges=function(){var n=this;this.$source.bind("keyup keydown paste change focus",_.throttle(function(){return n.adjustHeight()},$.support.touch?300:5));this.$el.bind("resize",function(){return n.adjustHeight()});this.$el.closest("form").bind("reset",function(){return n.resetHeight()})},t.prototype.adjustHeight=function(){var i,n,u,t,r;return this.$testContainer.width(this.$source.width()),r=this.$testContainer.html("X").height(),this.$testContainer.html(this.sourceContents()),t=parseInt(this.$el.data("rows")||this.$el.attr("rows"))||!1,u=t===1?1:this.resizeBy*r,i=t?r*t+1:this.originalHeight,n=this.$testContainer.height()+u,this.heightLimit&&n>this.heightLimit&&(n=this.heightLimit),n<i&&(n=i),n=Math.round(n),this.$el.css("min-height",n)},t.prototype.resetHeight=function(){return this.$el.css("min-height",this.originalHeight)},t}();i=function(t){function i(){this.preventScrollBars=n(this.preventScrollBars,this);this.sourceContents=n(this.sourceContents,this);this.source=n(this.source,this);i.__super__.constructor.apply(this,arguments)}function r(n,t){function r(){this.constructor=n}for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(n[i]=t[i]);return r.prototype=t.prototype,n.prototype=new r,n.__super__=t.prototype,n}return r(i,t),i.prototype.source=function(){return this.$el.contents().find("body")},i.prototype.sourceContents=function(){return this.$source.html()},i.prototype.preventScrollBars=function(){return this.$source.parent("html").css({overflow:"hidden"})},i}(t);$.fn.autoResize=function(){return this.each(function(){this.tagName.toLowerCase()==="iframe"?i.install(this):t.install(this)})}}();Frontiers=window.Frontiers||{};Frontiers.Orchis=Frontiers.Orchis||{};Frontiers.Orchis.Constants=Frontiers.Orchis.Constants||{};Frontiers.Orchis.Constants.Endpoints={MyOrcid:function(n,t){var i=Frontiers.Orchis.Common.Configuration.OrchisApiBaseUrl()+"/users/"+n+"/orcid";return t!==null&&t!==""&&(i=i+"?restartUrl="+t),i},RemoveOrcID:function(n){return Frontiers.Orchis.Common.Configuration.OrchisApiBaseUrl()+"/users/"+n+"/link"}};templates=[];templates.push('<script id="default-orcidLink-plugin-template" type="text/html"><div  id="connect-orcid-link" class="orcid"><i class="icon"><\/i><span>${orcidText}<\/span><\/div><label id="orcid-toolbox" class="orcid-toolbox"><span id ="edit-link"><i class="icon-pencil"><\/i><\/span><span id ="remove-link" style="display:none"><i class="icon-cross"><\/i><\/span><\/label><\/script> ');$(document).ready(function(){templates.forEach(function(n){$("body").append(n)})});Frontiers=window.Frontiers||{};Frontiers.Orchis=Frontiers.Orchis||{};Frontiers.Orchis.Plugins=Frontiers.Orchis.Plugins||{};Frontiers.Orchis.Plugins.OrcidLink=function(n){function it(n,t,i){r!==null?Frontiers.Orchis.Common.Ajax.deleteData({withCredentials:!0,endpoint:Frontiers.Orchis.Constants.Endpoints.RemoveOrcID(n),successCallback:function(){orcidData=null;t()},errorCallback:function(n,t){if(typeof Frontiers.Orchis.Common.Configuration.onOrchisApiFailed=="function")Frontiers.Orchis.Common.Configuration.onOrchisApiFailed(n,t);i()}}):i("An OrcId doesn't exists linked to your profile. Unable to remove a unexisting bound Orcid")}function w(){h.showPluginContainer(!0)}function s(n){n!==null&&n.data==="OrcidAuthenticationWindowClosed"&&(window.removeEventListener?window.removeEventListener("message",s):window.detachEvent("message",s),b())}function b(){u=null;o=!0;f.render()}function rt(n){if(Frontiers.Orchis.Common.Navigator.isIE())var t=window.setInterval(function(){n.closed&&(s({data:"OrcidAuthenticationWindowClosed"}),window.clearInterval(t))},500);else window.addEventListener?window.addEventListener("message",s,!1):window.attachEvent("message",s)}function k(){var n,f;t.pluginContainer=$(i);u==="Success"?r!==null&&(f=Frontiers.Orchis.Common.Configuration.OrcidBaseUrl()+r,n=$(y.orcidLink.replace("${orcidText}",r)),t.pluginContainer.append(n),t.edit=$("#edit-link"),t.link=$(i+" #connect-orcid-link"),t.link.attr("target","_blank"),t.edit.attr("target","_blank"),t.link.click(function(){window.open(f)}),Loop.Core.Configuration.loggedUserId==e&&(t.removeLink=$(i+" #remove-link"),t.removeLink.click(function(){var n=null,t={id:"remove-orcid-confirmation",title:"Remove Orcid account Confirmation",message:"Are you sure you want to remove this permanently?",confirmButtonText:"Remove",cancelButtonText:"Cancel",confirmAction:function(){it(e,function(){b();n.close()},function(t){var i=Loop.constants.UIMessages.genericLoadingErrorInModalWithoutRefresh;t!==undefined&&(i=t);n.error(i)})},cancelAction:function(){}};n=Loop.Core.Modals.showConfirmCancelModal(t)}),t.removeLink.show()),t.edit.hide(),t.link.css("cursor","pointer")):u==="Redirect"&&(n=$(y.orcidLink.replace("${orcidLink}","").replace("${orcidText}","Add your ORCID and synchronise your publications")),t.pluginContainer.append(n),t.link=$(i+" #connect-orcid-link"),t.edit=$(i+" #edit-link"),t.edit.click(function(){var n=window.open(p,"_blank","status=0, toolbar=0, location=0, menubar=0, scrollbars=1, directories=0, resizable=1");rt(n)}),t.link.css("cursor","default"),t.removeLink=$(i+" #remove-link"),t.removeLink.hide());w()}function ut(){t.pluginContainer=$(i);t.link=$(i+" #connect-orcid-link");r=null;w()}function d(n){u=n.result;u==="Success"?r=n.originalValue:u==="Redirect"&&(r=null,p=n.redirectUrl);o?k():typeof l=="function"&&l()}function g(){r=null;o?ut():typeof a=="function"&&a()}function ft(){y.orcidLink=$("#default-orcidLink-plugin-template").html();nt=Frontiers.Orchis.Common.Configuration.generateUUID();var t=jQuery.extend(!0,{},tt,n);if(i="#"+t.elementId,c=t.restartUrl,e=t.userId,o=t.autoRender,l=t.onOrcidLoaded,a=t.onOrcidFailed,Frontiers.Orchis.Common.Configuration.OrchisApiBaseUrl(t.orchisApiBaseUrl),i==="#"&&o)throw new Error("The plugin should have an elementId if it will be autoRendered");else Frontiers.Orchis.Common.Configuration.GetOrcid(e,c,d,g)}var f=this,nt="",r=null,tt={elementId:"",restartUrl:null,userId:null,autoRender:!0,onOrcidLoaded:null,onOrcidFailed:null},i="",c=null,e=null,o=!0,l=null,a=null,p=null,u=null,v={},h={},t={pluginContainer:null,link:null,edit:null},y={orcidLink:null};f.hide=function(){h.showPluginContainer(!1)};f.show=function(){h.showPluginContainer(!0)};f.orcid=function(){return r};f.render=function(n){n&&(i="#"+n,t.pluginContainer=$(i));t.pluginContainer&&t.pluginContainer.empty();u!==null?k():Frontiers.Orchis.Common.Configuration.GetOrcid(e,c,d,g)};v={showPlugin:!0};h={showPluginContainer:function(n){return typeof n=="boolean"&&(v.showPlugin=n,n?t.pluginContainer.show():t.pluginContainer.hide()),v.showPlugin}};ft()};Frontiers.Orchis.Common=Frontiers.Orchis.Common||{};Frontiers.Orchis.Common.Ajax=function(){function t(n,t){var u=!0,i;return $("html").hasClass("ie9")&&(u=!1),i={type:n.verb,url:n.endpoint,async:t,timeout:n.timeout,tryCount:0,retryLimit:3,crossDomain:u,dataType:"json",contentType:"application/json; charset=utf-8",cache:!r,data:n.inputData,success:function(t){typeof n.successCallback=="function"&&n.successCallback(t)},error:function(t,i,r){this.tryCount+=1;t.status===0&&t.statusText==="timeout"?this.tryCount<=this.retryLimit-1&&n.verb==="GET"?$.ajax(this):n.errorCallback(t.status,i,r):n.errorCallback(t.status,i,r)}},t&&(i.xhrFields={withCredentials:n.withCredentials}),$.ajax(i)}function i(n,t){var r=[],i=[];if(n.endpoint||r.push("endpoint"),n.verb||(n.verb=t),n.withCredentials||(n.withCredentials=!1),r.length>0)throw new Error("Missing required fields: "+r.join(","));if(typeof n.endpoint!="string"&&i.push("endpoint"),typeof n.verb!="string"&&i.push("verb"),typeof n.withCredentials!="boolean"&&i.push("withCredentials"),i.length>0)throw new Error("Wrong field types: "+i.join(","));isNaN(n.timeout)&&(n.timeout=15e3)}$.support.cors=!0;var r=!0,n={endpoint:null,verb:null,inputData:null,timeout:15e3,successCallback:null,errorCallback:null};return{forceNoCache:function(n){r=n},loadData:function(r){return r=jQuery.extend(!0,{},n,r),i(r,"GET"),t(r,!0)},loadDataSync:function(r){r=jQuery.extend(!0,{},n,r);i(r,"GET");t(r,!1)},updateData:function(r){r=jQuery.extend(!0,{},n,r);i(r,"PUT");t(r,!0)},createData:function(r){r=jQuery.extend(!0,{},n,r);i(r,"POST");t(r,!0)},deleteData:function(r){return r=jQuery.extend(!0,{},n,r),i(r,"DELETE"),t(r,"DELETE",!0)}}}();Frontiers=window.Frontiers||{};Frontiers.Orchis=Frontiers.Orchis||{};Frontiers.Orchis.Common=Frontiers.Orchis.Common||{};Frontiers.Orchis.Common.Configuration=function(){function u(){if(t===""&&(t=f()),t.indexOf("frontiers")===-1)throw new Error("Frontiers.Orchis.Common.Configuration.FrontiersDomain() has an invalid value.");}function f(){return/\.(.*)/.exec(document.location.hostname)[1]}function n(){return Math.floor((1+Math.random())*65536).toString(16).substring(1)}var t="",i=null,r=null;return{generateUUID:function(){return n()+n()+"-"+n()+"-"+n()+"-"+n()+"-"+n()+n()+n()},FrontiersDomain:function(n){return typeof n=="string"&&(n=n.trim().toLowerCase(),n.substring(n.length-1)==="/"&&(n=n.substring(0,n.length-1)),t=n),t},OrchisApiBaseUrl:function(n){if(n===undefined)return r;r=n},OrcidBaseUrl:function(){return u(),t.indexOf("frontiersin.org")>=0?"http://orcid.org/":"http://sandbox.orcid.org/"},GetOrcid:function(n,t,r,u){i===null?Frontiers.Orchis.Common.Ajax.loadData({withCredentials:!0,endpoint:Frontiers.Orchis.Constants.Endpoints.MyOrcid(n,t),successCallback:r,errorCallback:function(n,t){if(i=null,typeof Frontiers.Orchis.Common.Configuration.onOrchisApiFailed=="function")Frontiers.Orchis.Common.Configuration.onOrchisApiFailed(n,t);u()}}):r(i)},GetOrchisApiStatus:function(){var n;return Frontiers.Orchis.Common.Configuration.GetOrcid("",function(){n="good"},function(){n="error"}),n},onOrchisApiFailed:null}}();Frontiers.Orchis.Common=Frontiers.Orchis.Common||{};Frontiers.Orchis.Common.Navigator=function(){return{isIE:function(){var n;return window.navigator.appName==="Microsoft Internet Explorer"?(ua=window.navigator.userAgent,re=new RegExp("MSIE ([0-9]{1,}[.0-9]{0,})"),re.exec(ua)!==null&&(n=parseFloat(RegExp.$1))):window.navigator.appName==="Netscape"&&(ua=window.navigator.userAgent,re=new RegExp("Trident/.*rv:([0-9]{1,}[.0-9]{0,})"),re.exec(ua)!==null&&(n=parseFloat(RegExp.$1))),n>-1}}}();Loop=window.Loop||{};Loop.viewModels=Loop.viewModels||{};Loop.viewModels.searchPeople=function(){function u(){r();var t=$.trim(n.searchTerm())||"";if(t.length<3){n.info("Please, type at least 3 characters to search.");return}n.isLoading(!0);Loop.Core.Ajax.createData({endpoint:Loop.Core.EndpointRepository.getEndpoint(i),inputData:JSON.stringify({search:t,top:10}),successCallback:function(n){var t=n.Items.map(function(n){return n.Affiliation=n.Affiliation.replace(/,/g,", "),n});o(t)},errorCallback:function(){n.isError(!0);n.isLoading(!1)},preventModalOnError:!0,loginRequired:!1})}function f(){e();r()}function e(){n.searchTerm("")}function r(){n.isError(!1);n.info("");n.searchPeopleResults.removeAll()}function o(t){n.isLoading(!1);r();n.searchPeopleResults(t);t.length||n.info("Sorry, your search didn't match any results. Please try again")}var n=this,t=-1,i="SearchPeople";n.searchPeopleResults=ko.observableArray();n.searchTerm=ko.observable("");n.isActive=ko.observable(!1);n.isLoading=ko.observable(!1);n.isError=ko.observable(!1);n.isVisible=ko.observable(!1);n.info=ko.observable("");n.keyupEvent=function(){clearTimeout(t);t=setTimeout(function(){t=null;u()},300)};n.activate=function(){n.isActive(!0);$("#people-suggestions-plugin").focus()};n.deactivate=function(){n.isActive(!1);f();$("#people-suggestions-plugin").blur()};n.navigateToSearchResult=function(n){var t=new URL(n.ProfileUrl);t.host=window.location.host;t.searchParams.set("utm_source","searchPeople");typeof dataLayer!="undefined"&&dataLayer.push({event:"searchPeople_resultClicked",searchResult:n});window.location=t.toString()};n.init=function(){if(Loop.Configuration.features.EnableSearchPeople){Loop.Core.EndpointRepository.getEndpoint(i)||Loop.Core.EndpointRepository.addEndpoint({type:Loop.Core.Constants.EndpointType.PUBLIC,key:i,url:function(){return Loop.Configuration.urls.ApiBaseUrl+"/people/search"}});$(document).click(function(t){t.target.closest(".nav-search")||n.deactivate()});var t=document.getElementById("searchPeople");ko.applyBindings(n,t);n.isVisible(!0)}}}