varconsole,util=require("util"),assert=require("assert"),now=require("date-now"),slice=Array.prototype.slice,times={};console="undefined"!=typeofglobal&&global.console?global.console:"undefined"!=typeofwindow&&window.console?window.console:{};for(varfunctions=[[log,"log"],[info,"info"],[warn,"warn"],[error,"error"],[time,"time"],[timeEnd,"timeEnd"],[trace,"trace"],[dir,"dir"],[consoleAssert,"assert"]],i=0;i<functions.length;i++){vartuple=functions[i],f=tuple[0],name=tuple[1];console[name]||(console[name]=f)}functionlog(){}functioninfo(){console.log.apply(console,arguments)}functionwarn(){console.log.apply(console,arguments)}functionerror(){console.warn.apply(console,arguments)}functiontime(o){times[o]=now()}functiontimeEnd(o){vare=times[o];if(!e)thrownewError("No such label: "+o);varn=now()-e;console.log(o+": "+n+"ms")}functiontrace(){varo=newError;o.name="Trace",o.message=util.format.apply(null,arguments),console.error(o.stack)}functiondir(o){console.log(util.inspect(o)+"\n")}functionconsoleAssert(o){if(!o){vare=slice.call(arguments,1);assert.ok(!1,util.format.apply(null,e))}}module.exports=console;
!function(e){"use strict";varr=function(e,r){vart=newError(e+" at character "+r);throwt.index=r,t.description=e,t},t={"-":!0,"!":!0,"~":!0,"+":!0},n={"||":1,"&&":2,"|":3,"^":4,"&":5,"==":6,"!=":6,"===":6,"!==":6,"<":7,">":7,"<=":7,">=":7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":10,"/":10,"%":10},o=function(e){varr,t=0;for(varnine)(r=n.length)>t&&e.hasOwnProperty(n)&&(t=r);returnt},i=o(t),a=o(n),u={true:!0,false:!1,null:null},s=function(e){returnn[e]||0},p=function(e,r,t){return{type:"||"===e||"&&"===e?"LogicalExpression":"BinaryExpression",operator:e,left:r,right:t}},f=function(e){returne>=48&&e<=57},c=function(e){return36===e||95===e||e>=65&&e<=90||e>=97&&e<=122||e>=128&&!n[String.fromCharCode(e)]},l=function(e){return36===e||95===e||e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57||e>=128&&!n[String.fromCharCode(e)]},h=function(e){for(varo,h,d=0,v=e.charAt,x=e.charCodeAt,y=function(r){returnv.call(e,r)},m=function(r){returnx.call(e,r)},g=e.length,b=function(){for(vare=m(d);32===e||9===e||10===e||13===e;)e=m(++d)},E=function(){vare,t,n=w();returnb(),63!==m(d)?n:(d++,(e=E())||r("Expected expression",d),b(),58===m(d)?(d++,(t=E())||r("Expected expression",d),{type:"ConditionalExpression",test:n,consequent:e,alternate:t}):voidr("Expected :",d))},C=function(){b();for(varr=e.substr(d,a),t=r.length;t>0;){if(n.hasOwnProperty(r)&&(!c(m(d))||d+r.length<e.length&&!l(m(d+r.length))))returnd+=t,r;r=r.substr(0,--t)}return!1},w=function(){vare,t,n,o,i,a,u,f;if(a=O(),!(t=C()))returna;for(i={value:t,prec:s(t)},(u=O())||r("Expected expression after "+t,d),o=[a,i,u];(t=C())&&0!==(n=s(t));){for(i={value:t,prec:n};o.length>2&&n<=o[o.length-2].prec;)u=o.pop(),t=o.pop().value,a=o.pop(),e=p(t,a,u),o.push(e);(e=O())||r("Expected expression after "+t,d),o.push(i,e)}for(e=o[f=o.length-1];f>1;)e=p(o[f-1].value,o[f-2],e),f-=2;returne},O=function(){varr,n,o;if(b(),r=m(d),f(r)||46===r)returnU();if(39===r||34===r)returnk();if(91===r)returnS();for(o=(n=e.substr(d,i)).length;o>0;){if(t.hasOwnProperty(n)&&(!c(m(d))||d+n.length<e.length&&!l(m(d+n.length))))returnd+=o,{type:"UnaryExpression",operator:n,argument:O(),prefix:!0};n=n.substr(0,--o)}return!(!c(r)&&40!==r)&&A()},U=function(){for(vare,t,n="";f(m(d));)n+=y(d++);if(46===m(d))for(n+=y(d++);f(m(d));)n+=y(d++);if("e"===(e=y(d))||"E"===e){for(n+=y(d++),"+"!==(e=y(d))&&"-"!==e||(n+=y(d++));f(m(d));)n+=y(d++);f(m(d-1))||r("Expected exponent ("+n+y(d)+")",d)}returnt=m(d),c(t)?r("Variable names cannot start with a number ("+n+y(d)+")",d):46===t&&r("Unexpected period",d),{type:"Literal",value:parseFloat(n),raw:n}},k=function(){for(vare,t="",n=y(d++),o=!1;d<g;){if((e=y(d++))===n){o=!0;break}if("\\"===e)switch(e=y(d++)){case"n":t+="\n";break;case"r":t+="\r";break;case"t":t+="\t";break;case"b":t+="\b";break;case"f":t+="\f";break;case"v":t+="\v";break;default:t+=e}elset+=e}returno||r('Unclosed quote after "'+t+'"',d),{type:"Literal",value:t,raw:n+t+n}},L=function(){vart,n=m(d),o=d;for(c(n)?d++:r("Unexpected "+y(d),d);d<g&&(n=m(d),l(n));)d++;returnt=e.slice(o,d),u.hasOwnProperty(t)?{type:"Literal",value:u[t],raw:t}:"this"===t?{type:"ThisExpression"}:{type:"Identifier",name:t}},j=function(e){for(vart,n,o=[],i=!1;d<g;){if(b(),(t=m(d))===e){i=!0,d++;break}44===t?d++:((n=E())&&"Compound"!==n.type||r("Expected comma",d),o.push(n))}returni||r("Expected "+String.fromCharCode(e),d),o},A=function(){vare,t;for(t=40===(e=m(d))?P():L(),b(),e=m(d);46===e||91===e||40===e;)d++,46===e?(b(),t={type:"MemberExpression",computed:!1,object:t,property:L()}):91===e?(t={type:"MemberExpression",computed:!0,object:t,property:E()},b(),93!==(e=m(d))&&r("Unclosed [",d),d++):40===e&&(t={type:"CallExpression",arguments:j(41),callee:t}),b(),e=m(d);returnt},P=function(){d++;vare=E();if(b(),41===m(d))returnd++,e;r("Unclosed (",d)},S=function(){returnd++,{type:"ArrayExpression",elements:j(93)}},B=[];d<g;)59===(o=m(d))||44===o?d++:(h=E())?B.push(h):d<g&&r('Unexpected "'+y(d)+'"',d);return1===B.length?B[0]:{type:"Compound",body:B}};if(h.version="0.3.4",h.toString=function(){return"JavaScriptExpressionParser(JSE
!function(e){"function"==typeofrequire&&"object"==typeofexports&&"object"==typeofmodule?e("undefined"!=typeofwindow?window.ko:"undefined"!=typeofglobal?global.ko:null):"function"==typeofdefine&&define.amd?define(["knockout"],e):e(window.ko)}(function(e){e.subscribable.fn.watch=function(t,a,n,o){varr=typeoft;return"boolean"===r||"undefined"===r?e.watch(this,{enabled:!1!==t}):"function"!==r||e.isSubscribable(t)?e.watch(t,a,n,o||this):e.watch(this,a||{},t,o||this),this},e.watch=function(t,a,n,o){functionr(l,c,f,u,s,b){if(l&&0!==a.depth&&(-1===a.depth||f.length<(a.depth||1))){if(a.watchedOnly&&!l.watchable&&l!=t)return;if(!1!==a.enabled&&!0!==a.enabled||(l.watchable=a.enabled),!1===l.watchable)return;!0===a.seal&&(l.watchable=!1);vard=typeofl;if("object"===d||"function"===d){if(l._watcher===o)return;if(a.hide&&e.utils.arrayIndexOf(a.hide,l)>-1)return;varh=[].concat(f,c&&c!==t?c:[]);if("function"!==d){if("[object Object]"===Object.prototype.toString.call(l))e.utils.objectForEach(l,function(t,n){if(n=a.getter?a.getter.call(o,h,l,t):n){if(a.wrap){vari=Object.prototype.toString.call(n);"[object Function]"!==i&&"[object Object]"!==i&&(a.beforeWrap&&!1===a.beforeWrap.call(o,h,l,n)||(n=l[t]="[object Array]"===i?e.observableArray(n):e.observable(n)))}a.unloop&&(n._watcher=u?void0:o);varc=r(n,s?null:l,h,u,null,t);a.tagFields&&void0===n._fieldName&&(c||"parentsOnly"!==a.tagFields&&"function"==typeofn||"object"==typeofn)&&(n._fieldName=t)}});elseif(!0!==a.hideArrays)for(varp=0;p<l.length;p++)r(l[p],s?null:l,h,u);return!0}if("function"==typeofl.notifySubscribers&&n){if(!0===a.enabled&&!1===l.watchable)return;if(u||!a.beforeWatch||!1!==a.beforeWatch.call(o,h,l,b)){vary="function"==typeofl.pop;if(u?i(l):function(t,i,l,c){i?t.subscribe(function(i){varf;!1===a.splitArrayChanges&&void0!==(f=n.call(o,l,t,i))&&o(f),e.utils.arrayForEach(i,function(e){if(!1!==a.splitArrayChanges){vari=n.call(o,l,t,e);void0!==i&&o(i)}e.moved||(!1===a.async?r(e.value,c?null:t,l,"deleted"===e.status):setTimeout(function(){r(e.value,c?null:t,l,"deleted"===e.status)}))})},void0,"arrayChange")._watcher=o:(t.subscribe(function(){if(!1!==t.watchable){vare=n.call(o,l,t);void0!==e&&o(e),a.mutable&&"object"==typeoft()&&(!1===a.async?r(t(),c?null:t,l,!1,!0):setTimeout(function(){r(t(),c?null:t,l,!1,!0)}))}},null,"change")._watcher=o,(a.oldValues>0||a.mutable)&&(t.subscribe(function(e){if(a.oldValues>0){varn=t.oldValues?t.oldValues:t.oldValues=[];for(n.unshift(e);n.length>a.oldValues;)n.pop()}a.mutable&&"object"==typeofe&&r(e,c?null:t,l,!0,!0)},null,"beforeChange")._watcher=o))}(l,y,h,s),y)returnr(l(),s?null:l,h,u,!0),!0;if(!0!==a.hideWrappedValues)returnr(l(),s?null:l,h,u,!0)}}}}}functioni(e){vart=e[l];if(!t)throw"Subscriptions field (."+l+") not defined for observable child "+(e._fieldName||"");if(t.change)for(n=t.change.length-1;n>=0;n--)t.change[n]._watcher===o&&t.change[n].dispose();if(t.beforeChange&&(a.mutable||a.oldValues>0))for(n=t.beforeChange.length-1;n>=0;n--)t.beforeChange[n]._watcher===o&&t.beforeChange[n].dispose();if(t.arrayChange)for(varn=t.arrayChange.length-1;n>=0;n--)t.arrayChange[n]._watcher===o&&t.arrayChange[n].dispose()}varl;switch("function"==typeofa&&(o=o||n,n=a,a={}),o=o||this,"function"==typeofe.subscription||e.version){case!0:l="_subscriptions";break;case"3.0.0":l="F";break;case"3.1.0":l="H";break;case"3.2.0":l="M";break;case"3.3.0":l="G";break;case"3.4.0":case"3.4.1":l="K";break;case"3.4.2":l="F";break;case"3.5.0-beta":l="S";break;default:throw"Unsupported Knockout version. Only v3.0.0 to v3.5.0-beta are supported when minified. Current version is "+e.version}return"function"!=typeoft||e.isSubscribable(t)?(r(t,null,[]),{dispose:function(){r(t,null,[],!0)}}):e.computed(t,n,a)}}),window.foo="1.4.0";
varcachedSetTimeout,cachedClearTimeout,process=module.exports={};functiondefaultSetTimout(){thrownewError("setTimeout has not been defined")}functiondefaultClearTimeout(){thrownewError("clearTimeout has not been defined")}functionrunTimeout(e){if(cachedSetTimeout===setTimeout)returnsetTimeout(e,0);if((cachedSetTimeout===defaultSetTimout||!cachedSetTimeout)&&setTimeout)returncachedSetTimeout=setTimeout,setTimeout(e,0);try{returncachedSetTimeout(e,0)}catch(t){try{returncachedSetTimeout.call(null,e,0)}catch(t){returncachedSetTimeout.call(this,e,0)}}}functionrunClearTimeout(e){if(cachedClearTimeout===clearTimeout)returnclearTimeout(e);if((cachedClearTimeout===defaultClearTimeout||!cachedClearTimeout)&&clearTimeout)returncachedClearTimeout=clearTimeout,clearTimeout(e);try{returncachedClearTimeout(e)}catch(t){try{returncachedClearTimeout.call(null,e)}catch(t){returncachedClearTimeout.call(this,e)}}}!function(){try{cachedSetTimeout="function"==typeofsetTimeout?setTimeout:defaultSetTimout}catch(e){cachedSetTimeout=defaultSetTimout}try{cachedClearTimeout="function"==typeofclearTimeout?clearTimeout:defaultClearTimeout}catch(e){cachedClearTimeout=defaultClearTimeout}}();varcurrentQueue,queue=[],draining=!1,queueIndex=-1;functioncleanUpNextTick(){draining&¤tQueue&&(draining=!1,currentQueue.length?queue=currentQueue.concat(queue):queueIndex=-1,queue.length&&drainQueue())}functiondrainQueue(){if(!draining){vare=runTimeout(cleanUpNextTick);draining=!0;for(vart=queue.length;t;){for(currentQueue=queue,queue=[];++queueIndex<t;)currentQueue&¤tQueue[queueIndex].run();queueIndex=-1,t=queue.length}currentQueue=null,draining=!1,runClearTimeout(e)}}functionItem(e,t){this.fun=e,this.array=t}functionnoop(){}process.nextTick=function(e){vart=newArray(arguments.length-1);if(arguments.length>1)for(varr=1;r<arguments.length;r++)t[r-1]=arguments[r];queue.push(newItem(e,t)),1!==queue.length||draining||runTimeout(drainQueue)},Item.prototype.run=function(){this.fun.apply(null,this.array)},process.title="browser",process.browser=!0,process.env={},process.argv=[],process.version="",process.versions={},process.on=noop,process.addListener=noop,process.once=noop,process.off=noop,process.removeListener=noop,process.removeAllListeners=noop,process.emit=noop,process.prependListener=noop,process.prependOnceListener=noop,process.listeners=function(e){return[]},process.binding=function(e){thrownewError("process.binding is not supported")},process.cwd=function(){return"/"},process.chdir=function(e){thrownewError("process.chdir is not supported")},process.umask=function(){return0};
},{}],23:[function(require,module,exports){
"use strict";varescapeRe=/([-.*+?^${}()|[\]\/\\])/g,unescapeRe=/\\/g,escape=function(e){return(e+"").replace(escapeRe,"\\$1")},unescape=function(e){return(e+"").replace(unescapeRe,"")},slickRe=RegExp("^(?:\\s*(,)\\s*|\\s*(<combinator>+)\\s*|(\\s+)|(<unicode>+|\\*)|\\#(<unicode>+)|\\.(<unicode>+)|\\[\\s*(<unicode1>+)(?:\\s*([*^$!~|]?=)(?:\\s*(?:([\"']?)(.*?)\\9)))?\\s*\\](?!\\])|(:+)(<unicode>+)(?:\\((?:(?:([\"'])([^\\13]*)\\13)|((?:\\([^)]+\\)|[^()]*)+))\\))?)".replace(/<combinator>/,"["+escape(">+~`!@$%^&={}\\;</")+"]").replace(/<unicode>/g,"(?:[\\w\\u00a1-\\uFFFF-]|\\\\[^\\s0-9a-f])").replace(/<unicode1>/g,"(?:[:\\w\\u00a1-\\uFFFF-]|\\\\[^\\s0-9a-f])")),Part=function(e){this.combinator=e||" ",this.tag="*"};Part.prototype.toString=function(){if(!this.raw){vare,s,t="";if(t+=this.tag||"*",this.id&&(t+="#"+this.id),this.classes&&(t+="."+this.classList.join(".")),this.attributes)for(e=0;s=this.attributes[e++];)t+="["+s.name+(s.operator?s.operator+'"'+s.value+'"':"")+"]";if(this.pseudos)for(e=0;s=this.pseudos[e++];)t+=":"+s.name,s.value&&(t+="("+s.value+")");this.raw=t}returnthis.raw};varExpression=function(){this.length=0};Expression.prototype.toString=function(){if(!this.raw){for(vare,s="",t=0;e=this[t++];)1!==t&&(s+=" ")," "!==e.combinator&&(s+=e.combinator+" "),s+=e;this.raw=s}returnthis.raw};varreplacer=function(e,s,t,a,r,i,n,c,u,o,p,l,h,f,g,d){varv,w;if((s||!this.length)&&(v=this[this.length++]=newExpression,s))return"";if(v||(v=this[this.length-1]),(t||a||!v.length)&&(w=v[v.length++]=newPart(t)),w||(w=v[v.length-1]),r)w.tag=unescape(r);elseif(i)w.id=unescape(i);elseif(n){varm=unescape(n),b=w.classes||(w.classes={});if(!b[m]){b[m]=escape(n);varx=w.classList||(w.classList=[]);x.push(m),x.sort()}}elseh?(d=d||g,(w.pseudos||(w.pseudos=[])).push({type:1==l.length?"class":"element",name:unescape(h),escapedName:escape(h),value:d?unescape(d):null,escapedValue:d?escape(d):null})):c&&(p=p?escape(p):null,(w.attributes||(w.attributes=[])).push({operator:u,name:unescape(c),escapedName:escape(c),value:p?unescape(p):null,escapedValue:p?escape(p):null}));return""},Expressions=function(e){this.length=0;for(vars,t=this,a=e;e;){if((s=e.replace(slickRe,function(){returnreplacer.apply(t,arguments)}))===e)thrownewError(a+" is an invalid expression");e=s}};Expressions.prototype.toString=function(){if(!this.raw){for(vare,s=[],t=0;e=this[t++];)s.push(e);this.raw=s.join(", ")}returnthis.raw};varcache={},parse=function(e){returnnull==e?null:(e=(""+e).replace(/^\s+|\s+$/g,""),cache[e]||(cache[e]=newExpressions(e)))};module.exports=parse;
"use strict";vartemplateLoader=require("./template-loader.js"),console=require("console-browserify"),ko="undefined"!=typeofwindow?window.ko:"undefined"!=typeofglobal?global.ko:null,$="undefined"!=typeofwindow?window.jQuery:"undefined"!=typeofglobal?global.jQuery:null;require("./ko-bindings.js");varperformanceAwareCaller=require("./timed-call.js").timedCall,addUndoStackExtensionMaker=require("./undomanager/undomain.js"),colorPlugin=require("./ext/color.js"),utilPlugin=require("./ext/util.js"),inlinerPlugin=require("./ext/inliner.js"),localStorageLoader=require("./ext/localstorage.js");if(void0===ko)throw"Cannot find knockout.js library!";if(void0===$)throw"Cannot find jquery library!";function_canonicalize(e){vari=global.document.createElement("div");returni.innerHTML="<a></a>",i.firstChild.href=e,i.innerHTML=i.innerHTML,i.firstChild.href}function_appendUrlParameters(e,i){varn=-1==e.indexOf("?")?"?":"&",a=e;for(vartini)i.hasOwnProperty(t)&&(a+=n+t+"="+encodeURIComponent(i[t]),n="&");returna}varapplyBindingOptions=function(e,i){i.bindingHandlers.wysiwygSrc.convertedUrl=function(i,n,a,t){varo=e.imgProcessorBackend?e.imgProcessorBackend:"./upload",r=o.match(/^(https?:\/\/[^\/]*\/).*$/),l=i.match(/^(https?:\/\/[^\/]*\/).*$/);if(null===r||null!==l&&r[1]==l[1])returno.indexOf("?"),_appendUrlParameters(o,{src:i,method:n,params:a+","+t});console.log("Cannot apply backend image resizing to non-local resources ",i,n,a,t,r,l);vard={method:n,width:a};returnnull!==t&&(d.height=t),_appendUrlParameters(i,d)},i.bindingHandlers.wysiwygSrc.placeholderUrl=function(i,n,a){return_appendUrlParameters(e.imgProcessorBackend?e.imgProcessorBackend:"./upload",{method:"placeholder",params:i+","+n})},e&&e.tinymceConfig&&(i.bindingHandlers.wysiwyg.standardOptions=e.tinymceConfig),e&&e.tinymceConfigFull&&(i.bindingHandlers.wysiwyg.fullOptions=e.tinymceConfigFull)},start=function(e,i,n,a,t){templateLoader.fixPageEvents();varo=[function(i){e&&e.strings&&(i.t=function(n,a){vart=e.strings[n];returnvoid0===t&&(console.warn("Missing translation string for",n,": using default string"),t=n),i.tt(t,a)})},addUndoStackExtensionMaker(performanceAwareCaller),colorPlugin,utilPlugin,inlinerPlugin];if(void0!==t)for(varr=0;r<t.length;r++)o.push(t[r]);o.push(function(i){varn={messages:{unknownError:i.t("Unknown error"),uploadedBytes:i.t("Uploaded bytes exceed file size"),maxNumberOfFiles:i.t("Maximum number of files exceeded"),acceptFileTypes:i.t("File type not allowed"),maxFileSize:i.t("File is too large"),minFileSize:i.t("File is too small"),post_max_size:i.t("The uploaded file exceeds the post_max_size directive in php.ini"),max_file_size:i.t("File is too big"),min_file_size:i.t("File is too small"),accept_file_types:i.t("Filetype not allowed"),max_number_of_files:i.t("Maximum number of files exceeded"),max_width:i.t("Image exceeds maximum width"),min_width:i.t("Image requires a minimum width"),max_height:i.t("Image exceeds maximum height"),min_height:i.t("Image requires a minimum height"),abort:i.t("File upload aborted"),image_resize:i.t("Failed to resize image"),generic:i.t("Unexpected upload error")}};e&&e.fileuploadConfig&&(n=$.extend(!0,n,e.fileuploadConfig)),ko.bindingHandlers.fileupload.extendOptions=n});varl=e.fileuploadConfig?e.fileuploadConfig.url:"/upload/";applyBindingOptions(e,ko),$("\x3c!-- ko template: 'main' --\x3e\x3c!-- /ko --\x3e").appendTo(global.document.body),void0===i&&void0!==n&&(i=n.template),templateLoader.load(performanceAwareCaller,i,n,a,o,l)},initFromLocalStorage=function(e,i,n){try{vara=localStorageLoader(i,e.emailProcessorBackend),t=void0!==n?n:[];t.push(a.extension);varo=_canonicalize(a.metadata.template);start(e,o,a.metadata,a.model,t)}catch(e){console.error("TODO not found ",i,e)}},init=function(e,i){varn=global.location.hash?global.location.href.split("#")[1]:void0;if(e&&(e.template||e.data))if(e.data){vara="string"==typeofa?JSON.parse(e.data):e.data;start(e,void0,a.metadata,a.content,i)}elsestart(e,e.template,void0,void0,i);elseif(n&&7==n.length)initFromLocalStorage(e,n,i);else{if(!n)re
"use strict";varko="undefined"!=typeofwindow?window.ko:"undefined"!=typeofglobal?global.ko:null,console=require("console-browserify");ko.bindingHandlers.withProperties={init:function(e,n,o,t,l){vara=l.createChildContext(l.$rawData,null,function(e){ko.utils.extend(e,n())});returnko.applyBindingsToDescendants(a,e),{controlsDescendantBindings:!0}}},ko.virtualElements.allowedBindings.withProperties=!0,ko.bindingHandlers.log={init:function(e,n,o,t,l){console.log("log",n())}},ko.bindingHandlers.block={templateExists:function(e){return!!global.document.getElementById(e)},_chooseTemplate:function(e,n,o,t){varl=n+"-"+o;if(ko.bindingHandlers.block.templateExists(l))returnl;if(null!=t)returnko.bindingHandlers.block._chooseTemplate(e,n,t);vara=e?"array":"object-"+o;if(ko.bindingHandlers.block.templateExists(a))returna;throw"cannot find template for "+l+"/"+a},_displayMode:function(e,n){varo=void0!==e.type?ko.utils.unwrapObservable(e.type):"notablock-"+typeofe,t=void0!==e.splice,l=n.templateMode?n.templateMode:"show";returnko.bindingHandlers.block._chooseTemplate(t,o,l,n.templateModeFallback)},_makeTemplateValueAccessor:function(e,n){returnfunction(){varo,t,l=e(),a=ko.utils.peekObservable(l);if(!a||"object"!=typeofa.data&&"function"!=typeofa.data)o=l;elseif(o=a.data,void0!==a.template){vari=ko.utils.unwrapObservable(a.template),r=n.templateMode?n.templateMode:"show";t=ko.bindingHandlers.block._chooseTemplate(!1,i,r,n.templateModeFallback)}vars=ko.utils.unwrapObservable(o);if(ko.isObservable(s)&&console.log("doubleObservable",s),void0===t)if(void0===o)t="empty";elsetry{t=ko.bindingHandlers.block._displayMode(s,n)}catch(e){throwconsole.log(e,s,n.$data,n.templateMode),e}return{name:t,data:o,templateEngine:ko.nativeTemplateEngine.instance}}},init:function(e,n,o,t,l){void0===n()&&console.log("found a null block: check ending commas in arrays defs in IE");vara=ko.bindingHandlers.block._makeTemplateValueAccessor(n,l);returnko.bindingHandlers.template.init(e,a)},update:function(e,n,o,t,l){vara=ko.bindingHandlers.block._makeTemplateValueAccessor(n,l);returnko.bindingHandlers.template.update(e,a,o,t,l)}},ko.expressionRewriting.bindingRewriteValidators.block=!1,ko.virtualElements.allowedBindings.block=!0;
"use strict";var$="undefined"!=typeofwindow?window.jQuery:"undefined"!=typeofglobal?global.jQuery:null,ko="undefined"!=typeofwindow?window.ko:"undefined"!=typeofglobal?global.ko:null,console=require("console-browserify");ko.bindingHandlers.fudroppable={init:function(e,i){varo=i()||{},r={},l=function(e,i,o,r,l,a){e[i]?global.clearTimeout(e[i]):(void0!==r&&o.classList.add(r),ko.isWriteableObservable(l)&&!l()&&l(!0));vars=function(){e[i]=null,void0!==r&&o.classList.remove(r),ko.isWriteableObservable(l)&&l()&&l(!1)};"dragleave"==a.type?s():e[i]=global.setTimeout(s,500)};(o.active||o.activeClass)&&ko.utils.registerEventHandler(global,"dragover",l.bind(void0,r,"activeTimeout",e,o.activeClass,o.active)),o.hoverClass&&ko.utils.registerEventHandler(e,"dragover dragenter dragleave",l.bind(void0,r,"hoverTimeout",e,o.hoverClass,void0))}},ko.bindingHandlers.fileupload={extendOptions:{},remoteFilePreprocessor:function(e){returne},init:function(e,i){ko.utils.domNodeDisposal.addDisposeCallback(e,function(){$(e).fileupload("destroy")}),!("WebkitAppearance"inglobal.document.documentElement.style)||"webkitNbspMode"inglobal.document.documentElement.style||"StyleMedia"inglobal?$(e).attr("title",""):$(e).attr("title"," ")},update:function(e,i){varo=i()||{},r=$(e),l=r.parents(".uploadzone"),a=o.data;o.data=void0;vars=o.canvasPreview;ko.utils.extend(o,{url:"/upload/",dataType:"json",dropZone:l.find(".mo-uploadzone")[0],autoUpload:!0,acceptFileTypes:/(\.|\/)(gif|jpe?g|png)$/i,maxFileSize:1048576,disableImageResize:/Android(?!.*Chrome)|Opera/.test(global.navigator.userAgent),previewMaxWidth:200,previewMaxHeight:200,previewCrop:!1,replaceFileInput:!1,messages:{unknownError:"Unknown error",uploadedBytes:"Uploaded bytes exceed file size",maxNumberOfFiles:"Maximum number of files exceeded",acceptFileTypes:"File type not allowed",maxFileSize:"File is too large",minFileSize:"File is too small",post_max_size:"The uploaded file exceeds the post_max_size directive in php.ini",max_file_size:"File is too big",min_file_size:"File is too small",accept_file_types:"Filetype not allowed",max_number_of_files:"Maximum number of files exceeded",max_width:"Image exceeds maximum width",min_width:"Image requires a minimum width",max_height:"Image exceeds maximum height",min_height:"Image requires a minimum height",abort:"File upload aborted",image_resize:"Failed to resize image",generic:"Unexpected upload error"}}),ko.utils.extend(o,ko.bindingHandlers.fileupload.extendOptions);varn=0,t="",d=function(){0==--n&&(a&&a(t),t="",s&&(l.find("img").show(),l.find("canvas").remove()),l.removeClass("uploading"),l.find(".progress-bar").css("width",0))},u=function(e){if("object"==typeofo.messages&&null!==o.messages){vari=e.match(/^([^ ]+)(.*)$/);if(i&&void0!==o.messages[i[1]])returno.messages[i[1]]+i[2]}returne};r.fileupload(o);for(varp=["fileuploadadd","fileuploadprocessalways","fileuploadprogressall","fileuploaddone","fileuploadfail"],f=function(e,i){if("fileuploadadd"==e.type&&n++,"fileuploadfail"==e.type&&(console.log("fileuploadfail",e,i),o.onerror&&(""===i.errorThrown&&"error"==i.textStatus?o.onerror(u("generic")):o.onerror(u("generic ("+i.errorThrown+")"))),d()),"fileuploaddone"==e.type)if(void0!==i.result.files[0].url){if(o.onfile)for(varr=0;r<i.result.files.length;r++)i.result.files[r]=ko.bindingHandlers.fileupload.remoteFilePreprocessor(i.result.files[r]),o.onfile(i.result.files[r]);if(""===t&&(t=i.result.files[0].url),s){vara=newImage;a.onload=d,a.onerror=d,a.src=i.result.files[0].url}elsed()}elsevoid0!==i.result.files[0].error?(console.log("remote error",e,i),o.onerror&&o.onerror(u(i.result.files[0].error)),d()):(console.log("unexpected error",e,i),o.onerror&&o.onerror(u("generic (Unexpected Error retrieving uploaded file)")),d());if("fileuploadprocessalways"==e.type){varp=i.index,f=i.files[p];if(f.preview&&0===p&&0===l.find("canvas").length){if(s){varm=$(f.preview).css("width","100%");l.find("img").hide(),l.prepend(m)}l.addClass("uploading"),l.find(".progress-bar").css("width",0)}f.error&&(o.onerror&&o.onerror(u(f.error)),d())}if("f
"use strict";varconsole=require("console-browserify"),checkModel=function(e,o,t,n,l){vari,f,r,a=0;if(void0===l&&(l=!1),void0!==o&&"function"==typeofo.splice)for(i={},f=0;f<o.length;f++)i[o[f].type]=o[f];elsei=o;for(varpine)if(e.hasOwnProperty(p))if(r=void0!==n?n+"."+p:p,t.hasOwnProperty(p))if(typeoft[p]!=typeofe[p])null!==t[p]&&null!==e[p]&&("string"==typeoft[p]?String(e[p])!=e[p]&&(console.log("TODO Different type 1 ",r,typeoft[p],typeofe[p],t[p],e[p]),a=Math.max(a,2)):"number"==typeoft[p]?Number(e[p])!=e[p]&&(console.log("TODO Different type 2 ",r,typeoft[p],typeofe[p],t[p],e[p]),a=Math.max(a,2)):(console.log("TODO Different type 3 ",r,typeoft[p],typeofe[p],t[p],e[p]),a=Math.max(a,2)));elseif("object"==typeofe[p])if(null!==e[p])if(void0!==e[p].splice){if(e[p].length>0)if(t[p].length>0){varc=0;for(f=0;f<t[p].length;f++)if("string"==typeoft[p][f].type){for(;c<e[p].length&&e[p][c].type!==t[p][f].type;)console.log("ignoring ",r,e[p][c].type," block type in reference not found in model"),c++;if(c>=e[p].length){console.log("WARN cannot find ",r,t[p][f].type," block in reference"),a=Math.max(a,2);break}a=Math.max(a,checkModel(e[p][c],void0,t[p][f],r+"["+f+"."+t[p][f].type+"]"))}}elsefor(f=0;f<e[p].length;f++)"string"!=typeofe[p][f].type?(console.log("TODO found an object with no type",r,e[p][f]),a=Math.max(a,2)):i.hasOwnProperty(e[p][f].type)?a=Math.max(a,checkModel(i[e[p][f].type],i,e[p][f],r+"["+f+"."+e[p][f].type+"]")):(console.warn("TODO the model uses a block type not defined by the template. REMOVING IT!!",r,e[p][f]),e[p].splice(f,1),f--,a=Math.max(a,2))}elsenull===t[p]?l?(console.log("WARN Null object in model ",r,"instead of",e[p],"deleting it"),a=Math.max(a,2),deletee[p]):(console.log("INFO Null object in model ",r,"instead of",e[p],"cloning it from the reference"),a=Math.max(a,1),t[p]=e[p]):a=Math.max(a,checkModel(e[p],i,t[p],r,l));elsenull!==t[p]&&(console.log("TODO Null in reference but not null in model",r,t[p]),a=Math.max(a,2));else"string"!=typeofe[p]&&"boolean"!=typeofe[p]&&"number"!=typeofe[p]&&(console.log("TODO unsupported type",r,typeofe[p]),a=Math.max(a,2));elsel?(console.warn("WARN Property ",r,"found in model is not defined by template: removing it!"),a=Math.max(a,2),deletee[p]):(console.log("INFO Property ",r,"missing in model, cloning from reference!"),a=Math.max(a,1),t[p]=e[p]);returnl||(a=Math.max(a,checkModel(t,o,e,void0!==n?n+"!R":"!R",!0))),a};module.exports=checkModel;
"use strict";varconverterUtils=require("./utils.js"),cssParse=require("mensch/lib/parser.js"),console=require("console-browserify"),domutils=require("./domutils.js"),_declarationValueLookup=function(e,t,r){for(varl=e.length-1;l>=0;l--)if("property"==e[l].type&&e[l].name==t)return_declarationValueUrlPrefixer(e[l].value,r);returnnull},_propToCamelCase=function(e){returne.replace(/-([a-z])/g,function(e,t,r,l){returnt.toUpperCase()})},_declarationValueUrlPrefixer=function(e,t){returne.match(/url\(.*\)/)?e.replace(/(url\()([^\)]*)(\))/g,function(e,r,l,i){varn=l.trim(),o=l.trim().charAt(0);"'"==o||'"'==o?n=n.substr(1,n.length-2):o="";vara=t(n);returnnull!==a?r+o+a+o+i:e}):e},elaborateDeclarations=function(e,t,r,l,i,n,o){vara="object"==typeofn&&null!==n?n:{},u=null,s=0;void0===t&&(t=cssParse("#{\n"+e+"}",{comments:!0,position:!0}).stylesheet.rules[0].declarations,s=1);for(vard=t.length-1;d>=0;d--)if("property"==t[d].type)if(!0===o&&"display"==t[d].name&&"none"==t[d].value)null===u&&(u=e),u=converterUtils.removeStyle(u,t[d].position.start,t[d].position.end,s,0,0,"");else{varv=t[d].name.match(/^-ko-(bind-|attr-)?([a-z0-9-]*?)(-if|-ifnot)?$/);if(null!==v){null===u&&void0!==e&&(u=e);varc,f,m,p="attr-"==v[1],y="bind-"==v[1],h=v[2],b="-if"==v[3]||"-ifnot"==v[3];if(b){if(c=t[d].name.substr(0,t[d].name.length-v[3].length),null===_declarationValueLookup(t,c,r))throw"Unable to find declaration "+c+" for "+t[d].name}else{if((p||y)&&void0===i&&void0!==e)throw"Attributes and bind declarations are only allowed in inline styles!";varS,g=!0;if(p?(m=domutils.getAttribute(i,h),g=!1,S="virtualAttr"):y?(S=null,"text"==h?void0!==i?m=domutils.getInnerText(i):g=!1:"html"==h&&void0!==i?m=domutils.getInnerHtml(i):g=!1):((g=void0!==e)&&(m=_declarationValueLookup(t,h,r)),S="virtualStyle"),g&&null===m)throwconsole.error("Cannot find default value for",t[d].name,t),"Cannot find default value for "+t[d].name+": "+t[d].value+" in "+i+" ("+typeofe+"/"+h+")";varw=m,U=y||p?-1!=h.indexOf("-")?"'"+h+"'":h:_propToCamelCase(h);try{f=converterUtils.expressionBinding(t[d].value,l,w)}catch(e){throwconsole.error("Model ensure path failed",e.stack,"name",t[d].name,"value",t[d].value,"default",m,"element",i),e}null!==S&&void0===a[S]&&(a[S]={}),"virtualAttr"==S&&"href"==U&&(S=null,U="wysiwygHref",null!=i&&domutils.removeAttribute(i,"href"));varx=_declarationValueLookup(t,t[d].name+"-if",r),A=!1;if(null===x)x=_declarationValueLookup(t,t[d].name+"-ifnot",r),A=!0;elseif(null!==_declarationValueLookup(t,t[d].name+"-ifnot",r))throw"Unexpected error: cannot use both -if and -ifnot property conditions";if(null!==x)try{f=(A?"!":"")+"("+converterUtils.conditionBinding(x,l)+") ? "+f+" : null"}catch(e){throwconsole.error("Unable to deal with -ko style binding condition",x,t[d].name),e}null!==S?a[S][U]=f:a[U]=f}if(null!==u)try{if(null!=i)u=converterUtils.removeStyle(u,t[d].position.start,t[d].position.end,s,0,0,"");else{var_="";b||(_=h+": \x3c!-- ko text: "+f+" --\x3e"+m+"\x3c!-- /ko --\x3e"),u=converterUtils.removeStyle(u,t[d].position.start,t[d].position.end,s,0,0,_)}}catch(e){throwconsole.warn("Remove style failed",e,"name",t[d]),e}}else{vark=_declarationValueUrlPrefixer(t[d].value,r);if(k!=t[d].value&&(null===u&&void0!==e&&(u=e),null!==u))try{u=converterUtils.removeStyle(u,t[d].position.start,t[d].position.end,s,0,0,t[d].name+": "+k)}catch(e){throwconsole.log("Remove style failed replacing url",e,"name",t[d]),e}varC=_propToCamelCase(t[d].name),V="virtualAttrStyle",P=void0!==a.virtualStyle?a.virtualStyle[C]:void0,j=" ";void0===a[V]&&(a[V]="''",j=""),void0!==P?(a[V]="'"+t[d].name+": '+("+P+")+';"+j+"'+"+a[V],deletea.virtualStyle[C]):a[V]="'"+t[d].name+": "+converterUtils.addSlashes(k)+";"+j+"'+"+a[V]}}if(null!=i){for(varzina.virtualStyle)if(a.virtualStyle.hasOwnProperty(z))throwconsole.log("Unexpected virtualStyle binding after conversion to virtualAttr.style",z,a.virtualStyle[z],e),"Unexpected virtualStyle binding after conversion to virtualAttr.style for "+z;deletea.virtualStyle;varL=domutils.getAttribute(i,"data-bind"),q=(null!==L
"use strict";varobjExtend=require("./domutils.js").objExtend,console=require("console-browserify"),_valueSet=function(e,t,o,l){varr=o.indexOf(".");if(-1==r)if(void0===t[o])console.log("Undefined prop "+o+" while setting value "+l+" in model._valueSet");elseif(null===t[o])"object"==typeofl&&null!==l&&void0===l.push&&console.log("nullpropobjectvalue",o,l),t[o]=l;elseif("object"==typeoft[o]&&"function"==typeoft[o].push){varn;if("string"==typeofl){vari=l.match(/^\[(.*)\]$/);if(null===i)throw"Unexpected default value for array property "+o+": "+l;n=i[1].split(",")}else{if("object"!=typeofl||void0===l.push)throw"Unexpected default value for array property "+o+": "+l+" typeof "+typeofl;n=l}for(vara=[],d=0;d<n.length;d++)"@"==n[d].substr(0,1)?a.push(_generateModel(e,n[d].substr(1))):n[d].length>0&&a.push(n[d]);t[o]=a}else"string"==typeoft[o]||"boolean"==typeoft[o]?t[o]=l:"object"==typeoft[o]&&null!==t[o]&&void0!==t[o]._widget?("object"==typeofl&&null!==l&&console.log("objectvalue",o,t[o]._widget,l),t[o]=l):console.log("setting",typeoft[o],t[o],o,l);else{varf=o.substr(0,r);_valueSet(e,t[f],o.substr(r+1),l)}},_modelCreateOrUpdateBlockDef=function(e,t,o,l){if(void0!==e[t]&&e[t]._initialized&&!e[t]._writeable)throwconsole.log("_modelCreateOrUpdateBlockDef",e,t,o,l),"Trying to alter non writeable model: "+t+" / "+o;if(void0===e[t]&&(e[t]={_writeable:!0},void0===l&&(l={}),void0===l.category&&void0===e[t]._category&&(t.match(/(^t|.T)heme$/)||t.match(/(^s|.S)tyle$/)||t.match(/(^c|.C)olor$/)||t.match(/(^r|.R)adius$/)?l.category="style":l.category="content")),void0!==l){if(void0!==l.name&&(e[t]._name=l.name),void0!==l.themeOverride&&(e[t]._themeOverride=l.themeOverride),void0!==l.globalStyle){e[t]._globalStyle=l.globalStyle;varr=l.globalStyle.replace(/^(\$theme|_theme_)\./,""),n=r.indexOf("."),i=-1!=n?r.substr(0,n):r;_modelCreateOrUpdateBlockDef(e,"theme",i),(void0===e[t]._themeOverride||e[t]._themeOverride)&&_modelCreateOrUpdateBlockDef(e,t,"customStyle=false")}void0!==l.contextName&&(e[t]._context=l.contextName,"block"==l.contextName&&void0===e[t]._globalStyle&&(e[t]._globalStyle="_theme_.bodyTheme",_modelCreateOrUpdateBlockDef(e,"theme","bodyTheme"),(void0===e[t]._themeOverride||e[t]._themeOverride)&&_modelCreateOrUpdateBlockDef(e,t,"customStyle=false"))),void0!==l.extend&&(e[t].type=l.extend)}for(varainl)l.hasOwnProperty(a)&&void0!==l[a]&&-1==["name","extend","contextName","globalStyle","themeOverride"].indexOf(a)&&(e[t]["_"+a]=l[a]);void0!==o&&o.length>0&&(e[t]._props=void0!==e[t]._props&&e[t]._props.length>0?e[t]._props+" "+o:o)},_removePrefix=function(e){vart=e.match(/^[^A-Z]+([A-Z])(.*)$/);returnnull!==t?t[1].toLowerCase()+t[2]:null},_generateModelFromDef=function(e,t){varo={};for(varline)if(!l.match(/^_.*/)&&e.hasOwnProperty(l)){varr=e[l];if("object"==typeofr&&null!==r&&void0!==r._complex&&r._complex)o[l]=_generateModelFromDef(r,t);elseif("type"==l)o[l]=r;else{if("object"!=typeofr)throwconsole.error("Unexpected model def",l,r,e),"Unexpected model def ["+l+"]="+r;o[l]=null}}if(void0!==e._defaultValues){varn=e._defaultValues;for(variinn)n.hasOwnProperty(i)&&_valueSet(t,o,i,n[i])}returno},_generateModel=function(e,t){varo=_getModelDef(e,t,!1,!0);return_generateModelFromDef(o,e)},_getDef=function(e,t){return_getModelDef(e,t,!1,!0)},_getModelDef=function(e,t,o,l){if(void0===e[t]){if(-1!=t.indexOf(" "))returnnull;varr=_removePrefix(t);returnnull!==r?_getModelDef(e,r,o,l):null}varn=e[t];if("object"!=typeofn)throw"Block definition must be an object: found "+n+" for "+t;if(void0===n._initialized){if(void0===n.type&&(-1==t.indexOf(" ")?n.type=t:n.type=t.substr(t.indexOf(" ")+1)),n.type!=t&&void0===n._widget){vari=_getModelDef(e,n.type,!0);n=objExtend(i,n),e[t]=n}elsevoid0===n._widget&&void0===n._props&&n._complex;n._writeable=!0,n._initialized=!0}if(void0!==n._props){vara=n._props;if((a=a.split(" ")).length>0&&void0===n._writeable)throwconsole.error("Altering a non writable object ",t,a,n),"Altering a non writable object: "+t+" def: "+a;void0===n._processe
"use strict";varcssParse=require("mensch/lib/parser.js"),console=require("console-browserify"),converterUtils=require("./utils.js"),elaborateDeclarations=require("./declarations.js"),_removeOptionalQuotes=function(e){return"'"!=e[0]&&'"'!=e[0]||e[e.length-1]!=e[0]?e:e.substr(1,e.length-2).replace(/\\([\s\S])/gm,"$1")},_processStyleSheetRules_processBlockDef=function(e,t){for(varo,s,r,l=0;l<t.length;l++)if("rule"==t[l].type){for(varn=t[l].selectors,i=!1,a=!1,c=0;c<n.length;c++)n[c].match(/:preview$/)?a=!0:i=!0;if(a&&i)throwconsole.log("cannot mix selectors type (:preview and declarations) in @supports -ko-blockdefs ",n),"Cannot mix selectors type (:preview and declarations) in @supports -ko-blockdefs";if(!a&&!i)throwconsole.log("cannot find known selectors in @supports -ko-blockdefs ",n),"Cannot find known selectors in @supports -ko-blockdefs";if(i){o="",s={},r=t[l].declarations;for(varp,u=0;u<r.length;u++)"property"==r[u].type&&(p=_removeOptionalQuotes(r[u].value),"label"==r[u].name?s.name=p:"context"==r[u].name?s.contextName=p:"properties"==r[u].name?o=p:"theme"==r[u].name?s.globalStyle="_theme_."+p:"themeOverride"==r[u].name?s.themeOverride="true"==String(p).toLowerCase():s[r[u].name]=p);for(vard=0;d<n.length;d++)e(n[d],o,s)}if(a)for(varf=0;f<n.length;f++)e(n[f].substr(0,n[f].indexOf(":")),void0,{previewBindings:t[l].declarations})}},processStylesheetRules=function(e,t,o,s,r,l,n,i){vara,c=e,p=null;if(void0===t){varu=cssParse(e,{comments:!0,position:!0});if("stylesheet"!=u.type||void0===u.stylesheet)throwconsole.log("unable to process styleSheet",u),"Unable to parse stylesheet";t=u.stylesheet.rules}for(vard=t.length-1;d>=0;d--){if("supports"==t[d].type&&"-ko-blockdefs"==t[d].name)_processStyleSheetRules_processBlockDef(s,t[d].rules),c=converterUtils.removeStyle(c,t[d].position.start,p,0,0,0,"");elseif("media"==t[d].type||"supports"==t[d].type)c=processStylesheetRules(c,t[d].rules,o,s,r,l,n,i);elseif("comment"==t[d].type);elseif("rule"==t[d].type){for(varf=t[d].selectors,h="",m=null,v=0;v<f.length;v++){h.length>0&&(h+=", ");vary=f[v].match(/\[data-ko-block=([^ ]*)\]/);if(null!==y){if(null!==m&&m!=y[1])throw"Found multiple block-match attribute selectors: cannot translate it ("+m+" vs "+y[1]+")";m=y[1]}h+="\x3c!-- ko text: templateMode =='wysiwyg' ? '#main-wysiwyg-area ' : '' --\x3e\x3c!-- /ko --\x3e"+f[v]}if(m){vark="\x3c!-- ko foreach: $root.findObjectsOfType($data, '"+m+"') --\x3e",x=p,g=" ";t[d].declarations.length>0&&(t[d].declarations[0].position.start.line!=t[d].position.end.line&&(g="\n"+newArray(t[d].position.start.col).join(" ")),x=t[d].declarations[t[d].declarations.length-1].position.end),null===x?c+=g+"\x3c!-- /ko --\x3e":c=x==p?converterUtils.removeStyle(c,x,p,0,0,0,g+"\x3c!-- /ko --\x3e"):converterUtils.removeStyle(c,x,p,0,0,0,g+"}"+g+"\x3c!-- /ko --\x3e"),h=k+g+h.replace(newRegExp("\\[data-ko-block="+m+"\\]","g"),"\x3c!-- ko text: '#'+id() --\x3e"+m+"\x3c!-- /ko --\x3e"),s(m,"",{contextName:"block"})}varb=m||i;a=o.bind(this,b,"");varw=elaborateDeclarations(c,t[d].declarations,l,a);null!==w&&(c=w),c=converterUtils.removeStyle(c,t[d].position.start,t[d].position.end,0,0,0,h)}elseconsole.log("Unknown rule type",t[d].type,"while parsing <style> rules");p=t[d].position.start}returnc};module.exports=processStylesheetRules;
"use strict";varconsole=require("console-browserify"),jsep=require("jsep");jsep.addBinaryOp("or",1),jsep.addBinaryOp("and",2),jsep.addBinaryOp("eq",6),jsep.addBinaryOp("neq",6),jsep.addBinaryOp("lt",7),jsep.addBinaryOp("lte",7),jsep.addBinaryOp("gt",7),jsep.addBinaryOp("gte",7);varaddSlashes=function(e){returne.replace(/[\\"'\r\n\t\v\f\b]/g,"\\$&").replace(/\u0000/g,"\\0")},removeStyle=function(e,r,n,t,o,i,a){for(vars=e.split("\n"),p=o,l=i,u=1+t;u<r.line;u++)p+=s[u-1-t].length+1;if(p+=r.col,null!==n){for(vard=1+t;d<n.line;d++)l+=s[d-1-t].length+1;l+=n.col}elsel+=e.length+1;returne.substr(0,p-1)+a+e.substr(l-1)},expressionGenerator=function(e,r,n){returnfunctione(r,n,t,o){if(void0===t&&(t=!0),void0!==o&&"Identifier"!==r.type&&"MemberExpression"!==r.type&&"function"==typeofconsole.debug&&console.debug("Cannot apply default value to variable when using expressions"),"BinaryExpression"===r.type||"LogicalExpression"===r.type)return"("+e(r.left,n,t)+" "+function(e){switch(e){case"or":return"||";case"and":return"&&";case"lt":return"<";case"lte":return"<=";case"gt":return">";case"gte":return">=";case"eq":return"==";case"neq":return"!=";default:returne}}(r.operator)+" "+e(r.right,n,t)+")";if("CallExpression"===r.type){vari=r.arguments.map(function(r){returne(r,n,t)});returne(r.callee,n,t)+"("+i.join(", ")+")"}if("UnaryExpression"===r.type)returnr.operator+e(r.argument,n,t);if("MemberExpression"==r.type&&r.computed)throw"Unexpected computed member expression";if("MemberExpression"!=r.type||r.computed){if("Literal"===r.type)returnr.raw;if("Identifier"===r.type){vara=r.name;returnt?n(a,o)+"()":a}if("ConditionalExpression"===r.type)return"("+e(r.test,n,t)+" ? "+e(r.consequent,n,t)+" : "+e(r.alternate,n,t)+")";throw"Compound"===r.type?"Syntax error in expression: operator expected after "+e(r.body[0],n,!1):"Found an unsupported expression type: "+r.type}vars=e(r.object,n,!1)+"."+e(r.property,n,!1);returnt&&"Math"!==r.object.name&&"Color"!==r.object.name&&"Util"!==r.object.name?n(s,o)+"()":s}(e,r,void0,n)},expressionBinding=function(e,r,n){vart;if(null!=n){varo=e.trim().replace(/@\[([^\]]+)\]|@([a-zA-Z0-9\._]+)\b/g,"###var###");if("###var###"==(o=o.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")))t=[null,n];elseif(o="^"+o.replace(/###var###/g,"(.+)")+"$",!(t=n.trim().match(newRegExp(o))))throwconsole.log("Cannot find matches",t,"for",n,e,o,e),"Cannot find default value for "+e+" in "+n}try{vari=0,a="'"+e.replace(/@\[([^\]]+)\]|@([a-zA-Z0-9\._]+)\b|(')/g,function(e,n,o,a){if(a)return"\\"+a;i++;vars,p=n||o;if(t&&(void0!==t[i]?s=t[i].trim():console.log("ABZZZ Cannot find default value for",p,"in",t,"as",i)),n){varl=jsep(n);return"'+"+expressionGenerator(l,r,s)+"+'"}return"'+"+r(p,s)+"()+'"})+"'";returna=a.replace(/(^|[^\\])''\+/g,"$1").replace(/\+''/g,""),0===i&&"false"!==a&&"true"!==a&&console.error("Unexpected expression with no valid @variable references",e),a}catch(r){throw"Exception parsing expression "+e+" "+r}},conditionBinding=function(e,r){varn=jsep(e);returnexpressionGenerator(n,r)};module.exports={addSlashes:addSlashes,removeStyle:removeStyle,conditionBinding:conditionBinding,expressionBinding:expressionBinding};
"use strict";varko="undefined"!=typeofwindow?window.ko:"undefined"!=typeofglobal?global.ko:null,console=require("console-browserify");functionwrap(e){vart=typeofe;if("object"===t&&(e?e.constructor==Date?t="date":"[object Array]"==Object.prototype.toString.call(e)&&(t="array"):t="null"),"array"==t){varn=ko.observableArray();if(!e||0===e.length)returnn;for(varo=0,r=e.length;o<r;++o)n.push(wrap(e[o]));returnn}if("object"==t){vara={};for(variine){varl=e[i];a[i]=wrap(l)}returnko.observable(a)}if("function"==t)returne;vars=ko.observable();returns(e),s}var_getOptionsObjectKeys=function(e){for(vart=e.split("|"),n=[],o=0;o<t.length;o++){varr=t[o].split("=");n.push(r[0].trim())}returnn},_makeComputed=function(e,t,n,o,r,a){returnko.computed({read:function(){varn=e();if(null===n){vari=ko.utils.unwrapObservable(o);returnvoid0===i||"custom"==i?ko.utils.unwrapObservable(t):a[i][r]}returnn},write:function(i){varl,s=ko.utils.unwrapObservable(o);if(l=void0===s||"custom"==s?ko.utils.peekObservable(t):a[s][r],n)e(i==l?null:i);else{varu=ko.utils.peekObservable(e);i==l&&null===u||e(i)}}})},_nextVariantFunction=function(e,t,n){for(varo=e.utils.unwrapObservable(t),r=0;r<n.length&&e.utils.peekObservable(n[r])!=o;r++);r==n.length&&(console.warn("Didn't find a variant!",t,o,n),r=n.length-1);vara=r+1;a==n.length&&(a=0),t(e.utils.peekObservable(n[a]))},_getVariants=function(e){vart=e._variant;if("object"!=typeofe[t]||void0===e[t]._widget||"string"!=typeofe[t]._options&&"boolean"!==e[t]._widget)throwconsole.error("Unexpected variant declaration",t,e[t]),"Unexpected variant declaration: cannot find property "+t+" or its _options string and it is not a boolean";return"string"==typeofe[t]._options?_getOptionsObjectKeys(e[t]._options):[!0,!1]},_makeComputedFunction=function(e,t,n,o,r,a,i){if(void0===e){if(void0===o.utils.unwrapObservable(i).type)throwconsole.log("TODO ERROR Found a non-typed def ",e,i),"Found a non-typed def "+e;varl=o.utils.unwrapObservable(o.utils.unwrapObservable(i).type);"object"!=typeof(e=t[l])&&console.log("TODO ERROR Found a non-object def ",e,"for",l)}void0===r&&void0!==a&&a&&(r=i);vars="$root.content().",u=e._globalStyles;if(void0!==u)for(varpinu)if(u.hasOwnProperty(p)){varb,c,v,d="$root.content().theme().scheme";if(u[p].substr(0,s.length)!=s)throw"UNEXPECTED globalStyle path ("+u[p]+") outside selfPath ("+s+")";v=u[p].substr(s.length),c=r,d.substr(0,s.length)==s?b=d.substr(s.length):(console.log("IS THIS CORRECT?",d,s),b=d);for(varf=c,h=v.split("()."),_="",g=!0,k=0;k<h.length;k++)c=o.utils.unwrapObservable(c)[h[k]],g?"theme"==h[k]&&(g=!1):(_.length>0&&(_+="."),_+=h[k]);for(varw=b.split("()."),m=0;m<w.length;m++)f=o.utils.unwrapObservable(f)[w[m]];for(varO=p.split("."),y=i,R=0;R<O.length;R++)y=o.utils.unwrapObservable(y)[O[R]];if(!o.isObservable(y))throw"Unexpected non observable target "+p+"/"+_;y._defaultComputed=_makeComputed(y,c,!0,f,_,n)}if(void0!==e._variant){for(varF=e._variant.split("."),S=i,j=o.utils.unwrapObservable(i),C=0;C<F.length;C++)S=o.utils.unwrapObservable(S)[F[C]];if(void0!==S._defaultComputed&&(console.log("Found variant on a style property: beware variants should be only used on content properties because they don't match the theme fallback behaviour",e._variant),S=S._defaultComputed),void0===S)throwconsole.log("ERROR looking for variant target",e._variant,i),"ERROR looking for variant target "+e._variant;j._nextVariant=_nextVariantFunction.bind(S,o,S,_getVariants(e))}for(varxine)if(e.hasOwnProperty(x)){varP=e[x];if("object"==typeofP&&null!==P&&void0!==P._context&&"block"==P._context){varB=r[x](),E=_makeComputedFunction(t[x],t,n,o,r,a,B);i[x](E)}elseif("object"==typeofP&&null!==P&&"blocks"==P.type){for(varD,I,T,A=r[x](),V=A.blocks(),U=0;U<V.length;U++)D=o.utils.unwrapObservable(V[U]),I=o.utils.unwrapObservable(D.type),T=_makeComputedFunction(t[I],t,n,o,r,a,D),V[U](T);varW=A.blocks;_augmentBlocksObservable(W,_blockInstrumentFunction.bind(A,void0,t,n,o,void0,r,a)),r[x]._wrap=_makeBlocksWrap.bind(r[x],W._instrumentBlock),r[x]._unwrap=_unw
"use strict";varconsole=require("console-browserify"),ko="undefined"!=typeofwindow?window.ko:"undefined"!=typeofglobal?global.ko:null,$="undefined"!=typeofwindow?window.jQuery:"undefined"!=typeofglobal?global.jQuery:null,lsLoader=function(e,t){vara=global.localStorage.getItem("metadata-"+e);if(null!==a){varo,l=global.localStorage.getItem("template-"+e);null!==l&&(o=JSON.parse(l));varn=JSON.parse(a);return{metadata:n,model:o,extension:lsCommandPluginFactory(n,t)}}throw"Cannot find stored data for "+e},lsCommandPluginFactory=function(e,t){returnfunction(e,a,o){varl={name:"Save",enabled:ko.observable(!0),execute:function(){l.enabled(!1),o.metadata.changed=Date.now(),void0===o.metadata.key&&(console.warn("Unable to find key in metadata object...",o.metadata),o.metadata.key=e),global.localStorage.setItem("metadata-"+e,o.exportMetadata()),global.localStorage.setItem("template-"+e,o.exportJSON()),l.enabled(!0)}},n={name:"Test",enabled:ko.observable(!0)},r={name:"Download",enabled:ko.observable(!0)};n.execute=function(){n.enabled(!1);varl=global.localStorage.getItem("testemail");if(null!==l&&"null"!=l||(l=o.t("Insert here the recipient email address")),"function"!=typeofglobal.prompt)global.alert(o.t("This feature is not supported by your browser")),n.enabled(!0);elseif(null!=(l=global.prompt(o.t("Test email address"),l))&&l.match(/@/)){global.localStorage.setItem("testemail",l);varr=t||"/dl/",d=$.post(r,{action:"email",rcpt:l,subject:"[test] "+e+" - "+a,html:o.exportHTML()},null,"html");d.fail(function(){console.log("fail",arguments),o.notifier.error(o.t("Unexpected error talking to server: contact us!"))}),d.success(function(){console.log("success",arguments),o.notifier.success(o.t("Test email sent..."))}),d.always(function(){n.enabled(!0)})}elseglobal.alert(o.t("Invalid email address")),n.enabled(!0)},r.execute=function(){r.enabled(!1),o.notifier.info(o.t("Downloading...")),o.exportHTMLtoTextarea("#downloadHtmlTextarea");vare=t||"/dl/";global.document.getElementById("downloadForm").setAttribute("action",e),global.document.getElementById("downloadForm").submit(),r.enabled(!0)},o.save=l,o.test=n,o.download=r}.bind(void0,e.key,e.name)};module.exports=lsLoader;
"use strict";var$="undefined"!=typeofwindow?window.jQuery:"undefined"!=typeofglobal?global.jQuery:null,ko="undefined"!=typeofwindow?window.ko:"undefined"!=typeofglobal?global.ko:null,kojqui="undefined"!=typeofwindow?window.kojqui:"undefined"!=typeofglobal?global.kojqui:null,templateConverter=require("./converter/main.js"),console=require("console-browserify"),initializeViewmodel=require("./viewmodel.js"),templateSystem=require("./bindings/choose-template.js");if(!$.ui.version.match(/^1\.11\..*$/))throw"Usupported jQuery UI version detected: "+$.ui.version+" (we only support 1.11.*)";varpluginsCall=function(e,t,n,o){vari,a,r,d,l;l=[],void0!==o&&o?(i=e.length-1,a=0,r=-1):(i=0,a=e.length-1,r=1);for(vars=i;s!=a+r;s+=r)void0!==e[s][t]&&void0!==(d=e[s][t].apply(e[s],n))&&l.push(d);returnl},origDisposeCallback=ko.utils.domNodeDisposal.addDisposeCallback;ko.utils.domNodeDisposal.addDisposeCallback=function(e,t){origDisposeCallback(e,function(e){try{t(e)}catch(e){"function"==typeofconsole.debug&&console.debug("Caught unexpected dispose callback exception",e)}})};varbindingPluginMaker=function(e){return{viewModel:function(t){try{e("applyBindings",ko.applyBindings.bind(void0,t))}catch(e){throwconsole.warn(e,e.stack),e}},dispose:function(){try{e("unapplyBindings",ko.cleanNode.bind(this,global.document.body))}catch(e){throwconsole.warn(e,e.stack),e}}}},templateCreator=function(e,t,n,o){vari=n;for(void0!==n&&void0!==o&&("object"==typeoft&&"replacedhtml"==t.tagName.toLowerCase()||(i+="-"+o));null==i||e.exists(i);)i="anonymous-"+Math.floor(1e5*Math.random()+1);if("object"==typeoft&&"replacedhtml"==t.tagName.toLowerCase()){vara=$(t),r=$("replacedhead",a),d=$("replacedbody",a);e.adder(i+"-head",r.html()||""),e.adder(i+"-show",d.html()||""),e.adder(i+"-preview",a.html()),e.adder(i+"-wysiwyg",a.html()),r.children().detach(),r.html("\x3c!-- ko block: content --\x3e\x3c!-- /ko --\x3e"),r.before("\x3c!-- ko withProperties: { templateMode: 'head' } --\x3e"),r.after("\x3c!-- /ko --\x3e"),d.html("\x3c!-- ko block: content --\x3e\x3c!-- /ko --\x3e"),e.adder(i+"-iframe",a[0].outerHTML)}else"object"==typeoft?e.adder(i,t.outerHTML):e.adder(i,t);returni};function_viewModelPluginInstance(e){vart;return{viewModel:function(n){t=e(n)},init:function(){void0!==t&&void0!==t.init&&t.init()},dispose:function(){void0!==t&&void0!==t.dispose&&t.dispose()}}}var_templateUrlConverter=function(e,t){returnt.match(/^[^\/]*:/)||t.match(/^\//)||t.match(/^\[/)||t.match(/^#?$/)?null:e+t},templateLoader=function(e,t,n,o,i,a){varr="string"==typeoft?t:n.template,d="./",l=r.lastIndexOf("/");-1!=l&&(d=r.substr(0,l+1));vars,c=_templateUrlConverter.bind(void0,d);s=void0===n?{template:r,name:"No name",created:Date.now()}:n,$.get(r,function(t){templateCompiler(e,c,"template",t,o,s,i,a).init()})},templateCompiler=function(e,t,n,o,i,a,r,d){varl=o.match(/^([\S\s]*)([<]html[^>]*>[\S\s]*<\/html>)([\S\s]*)$/i);if(null===l)throw"Unable to find <html> opening and closing tags in the template";vars=l[1],c={"<html":0,"<head":0,"<body":0,"</html":0,"</body":0,"</head":0},u=l[2].replace(/(<\/?)(html|head|body)([^>]*>)/gi,function(e,t,n,o){returnc[(t+n).toLowerCase()]+=1,t+"replaced"+n+o});for(varminc)if(c.hasOwnProperty(m)&&1!=c[m]){if(0===c[m])throw"ERROR: missing mandatory element "+m+">";if(c[m]>1)throw"ERROR: multiple element "+m+"> occourences are not supported (found "+c[m]+" occourences)"}varp=l[3],b=[],h=[];if(void0!==r)for(varv=0;v<r.length;v++)"function"==typeofr[v]?h.push(_viewModelPluginInstance(r[v])):h.push(r[v]);varg=[],f={adder:function(e,t){if("string"!=typeoft)throw"Template system: cannot create new template "+e;varn=t.match(/(data)?-ko-[^ =:]*/g);n&&console.error("ERROR: found unexpected -ko- attribute in compiled template",e,", you probably mispelled it:",n),templateSystem.addTemplate(e,t),g.push(e)},exists:function(e){returnvoid0!==templateSystem.getTemplateContent(e)},dispose:function(){for(vare=g.length-1;e>=0;e--)templateSystem.removeTemplate(g[e])}};ko.bindingHandlers.block.templateExists=f.exists;for(vary=temp
"use strict";varko="undefined"!=typeofwindow?window.ko:"undefined"!=typeofglobal?global.ko:null,reactor=require("ko-reactor/dist/ko-reactor.min.js"),console=require("console-browserify"),undoManager=function(e,o){varn,t=ko.observableArray(),i=ko.observableArray(),r=0,d=0,l={levels:100,undoLabel:"undo (#COUNT#)",redoLabel:"redo (#COUNT#)"};o="object"==typeofo?ko.utils.extend(l,o):l;varu=function(e){1==r?a(e,i):2==r?a(e,t):0==r&&(a(e,t),i.removeAll())},a=function(e,t){if(t().length>0){vari=(d=e,void0!==(r=t()[t().length-1]).mergedAction?r.mergedAction(d):null);if(null!==i)returnvoid(t()[t().length-1]=i)}varr,d;t().length>=o.levels&&t.shift(),n=t,t.push(e)},c=function(e,o,t){return{name:ko.computed(function(){returnko.utils.unwrapObservable(e).replace(/#COUNT#/,t().length)}),enabled:ko.computed(function(){return0!==t().length}),execute:function(){vare=t.pop();if(e){vari=r;r=o;varl=d;d=3,e(),s(n),d=l,r=i}return!0}}},s=function(e){if(void0===e)throw"Unexpected operation: stack cleaner called with undefined stack";e().length>0&&void0!==e()[e().length-1].mergedAction&&deletee()[e().length-1].mergedAction},f=function(e,o){varn=function(e,o){e(),o()}.bind(void0,e,o);returnvoid0!==e.mergedAction&&(n.mergedAction=e.mergedAction),n},m=function(e,o,n){if(void0!==o)e(o);else{if(!n)throw"Unexpected condition: no item and no child.oldValues!";if("deleted"==n.status)e.splice(n.index,0,n.value);else{if("added"!=n.status)throw"Unsupported item.status: "+n.status;e.splice(n.index,1)}}},v=function(e,o,n,t,i){returne.bind(void0,n,t,i)},g=("function"==typeofreactor?reactor:ko.watch)(e,{depth:-1,oldValues:1,mutable:!0,tagFields:!0},function(e,o,n){vart=void0!==o.oldValues?o.oldValues[0]:void0,i=v(m,e,o,t,n);1!=d&&(3==d?void0!==i&&(i.mergedAction=function(e){returnvoid0!==e.mergeMe&&e.mergeMe?f(e,this):null},i.mergeMe=!0):void0!==i&&(o.oldValues&&2==d&&(i.mergedAction=function(e,o,n){return"object"==typeofn.mergeableAction&&e==n.mergeableAction.child?this:null}.bind(i,o,n),i.mergeableAction={child:o,item:n}),n&&"deleted"==n.status?i.mergedAction=function(e,o,n){return"object"==typeofn.mergeableMove&&o.value==n.mergeableMove.item.value?f(n,this):null}.bind(i,o,n):n&&"added"==n.status?i.mergeableMove={child:o,item:n}:n&&console.warn("Unsupported item.status",n.status)),void0!==i&&u(i))},{});return{push:u,undoCommand:c(o.undoLabel,1,t),redoCommand:c(o.redoLabel,2,i),reset:function(){t.removeAll(),i.removeAll()},setModeOnce:function(){d=2,s(t)},setModeMerge:function(){d=3,s(t)},setModeNormal:function(){d=0,s(t)},setModeIgnore:function(){d=1,s(t)},setUndoActionMaker:function(e){v=e},dispose:function(){g.dispose()}}};module.exports=undoManager;
"use strict";varlistener,watchEnabled,ko="undefined"!=typeofwindow?window.ko:"undefined"!=typeofglobal?global.ko:null,console=require("console-browserify"),_reference=function(e,n){for(vart,o,r=0,a=e;r<n.length;)switch(n.charAt(r)){case"(":")"==n.charAt(r+1)&&(a=a()),r+=2;break;case"[":o=n.indexOf("]",r),a=a[n.substring(r+1,o)],r=o+1;break;case".":-1==(t=n.indexOf("(",r))&&(t=n.length),-1==(o=n.indexOf("[",r))&&(o=n.length),o=Math.min(t,o),a=a[n.substring(r+1,o)],r=o}returna},_getPath=function(e,n){for(vart,o="",r=0;r<=e.length;r++)if(t=r<e.length?e[r]:n,ko.isObservable(t)&&(o+="()"),void0!==t._fieldName)o+="."+t._fieldName;else{if(!(r>0&&"function"==typeofe[r-1].pop))throwconsole.error("Unexpected parent with no _fieldName and no parent array",r,e),"Unexpected parent with no _fieldName and no parent array";vara=ko.isObservable(e[r-1])?ko.utils.peekObservable(e[r-1]):e[r-1],i=ko.utils.arrayIndexOf(a,t);if(-1==i)throwconsole.error("Unexpected object not found in parent array",a,t,r,e.length,ko.toJS(a),ko.utils.unwrapObservable(t)),"Unexpected object not found in parent array";o+="["+i+"]"}returno},makeDereferencedUndoAction=function(e,n,t,o,r){e(_reference(n,t),o,r)},_setListener=function(e){listener=e},makeUndoActionDereferenced=function(e,n,t,o,r,a){try{vari=_getPath(t,o);if("object"!=typeofr&&"function"!=typeofr||(r=ko.toJS(r)),void0===a||"object"!=typeofa.value&&"function"!=typeofa.value||(a=ko.toJS(a)),void0!==listener)try{listener(i,o,r,a)}catch(e){console.log("Undoserializer ignoring exception in listener callback")}returnmakeDereferencedUndoAction.bind(void0,n,e,i,r,a)}catch(e){console.error("Exception processing undo",e,t,o,a)}},_watchEnabled=function(e){if(void0===e)returnwatchEnabled;watchEnabled=e};module.exports={dereference:_getPath,reference:_reference,makeUndoAction:makeUndoActionDereferenced,setListener:_setListener,watchEnabled:_watchEnabled};
"use strict";var$="undefined"!=typeofwindow?window.jQuery:"undefined"!=typeofglobal?global.jQuery:null,ko="undefined"!=typeofwindow?window.ko:"undefined"!=typeofglobal?global.ko:null,console=require("console-browserify"),performanceAwareCaller=require("./timed-call.js").timedCall,toastr=require("toastr");functioninitializeEditor(e,o,t,l){varr={galleryRecent:ko.observableArray([]).extend({paging:16}),galleryRemote:ko.observableArray([]).extend({paging:16}),selectedBlock:ko.observable(null),selectedItem:ko.observable(null),selectedTool:ko.observable(0),selectedImageTab:ko.observable(0),dragging:ko.observable(!1),draggingImage:ko.observable(!1),galleryLoaded:ko.observable(!1),showPreviewFrame:ko.observable(!1),previewMode:ko.observable("mobile"),showToolbox:ko.observable(!0),showTheme:ko.observable(!1),showGallery:ko.observable(!1),debug:ko.observable(!1),contentListeners:ko.observable(0),logoPath:"rs/img/mosaico32.png",logoUrl:".",logoAlt:"mosaico"};returnr.content=e,r.blockDefs=o,r.notifier=toastr,r.tt=function(e,o){if(void0!==o)for(vartino)o.hasOwnProperty(t)&&(e=e.replace(newRegExp("__"+t+"__","g"),o[t]));returne},r.t=r.tt,r.ut=function(e,o){returno},r.templatePath=t,r.remoteUrlProcessor=function(e){returne},r.remoteFileProcessor=function(e){returnvoid0!==e.url&&(e.url=r.remoteUrlProcessor(e.url)),void0!==e.thumbnailUrl&&(e.thumbnailUrl=r.remoteUrlProcessor(e.thumbnailUrl)),e},r.loadGallery=function(){r.galleryLoaded("loading");vare=l||"/upload/";$.getJSON(e,function(e){for(varo=0;o<e.files.length;o++)e.files[o]=r.remoteFileProcessor(e.files[o]);r.galleryLoaded(e.files.length),r.galleryRemote(e.files.reverse())}).fail(function(){r.galleryLoaded(!1),r.notifier.error(r.t("Unexpected error listing files"))})},r.fileToImage=function(e,o,t){returne.url},r.removeBlock=function(e,o){ko.utils.unwrapObservable(r.selectedBlock)==ko.utils.unwrapObservable(e)&&r.selectBlock(null,!0);vart=o.blocks.remove(e);returnr.notifier.info(r.t("Block removed: use undo button to restore it...")),t},r.duplicateBlock=function(e,o){vart=ko.utils.unwrapObservable(e),l=ko.toJS(ko.utils.unwrapObservable(o.blocks)[t]);void0!==l.id&&(l.id=""),o.blocks.splice(t+1,0,l)},r.moveBlock=function(e,o,t){varl=ko.utils.unwrapObservable(e),n=ko.utils.unwrapObservable(o.blocks);if(t&&l>0||!t&&l<n.length-1){vara=l+(t?-1:1),i=n[a];r.startMultiple(),o.blocks.splice(a,1),o.blocks.splice(l,0,i),r.stopMultiple()}},r.loadDefaultBlocks=function(){vare=ko.toJS(r.content().mainBlocks);e.blocks=[];for(varo=ko.utils.unwrapObservable(r.blockDefs),t=0;t<o.length;t++){varl=ko.toJS(o[t]);l.id="block_"+t,e.blocks.push(l)}performanceAwareCaller("setMainBlocks",r.content().mainBlocks._wrap.bind(r.content().mainBlocks,e))},r.addImage=function(e){varo=$("#main-wysiwyg-area .selectable-img.selecteditem");return1==o.length&&"object"==typeofe&&void0!==e.url&&(ko.contextFor(o[0])._src(e.url),!0)},r.addBlock=function(e,o){vart,l,n=r.selectedBlock();if(null!==n)for(vara=r.content().mainBlocks().blocks().length-1;a>=0;a--)if(r.content().mainBlocks().blocks()[a]()==n){t=a;break}void0!==t?(l=t+1,r.content().mainBlocks().blocks.splice(l,0,e),r.notifier.info(r.t("New block added after the selected one (__pos__)",{pos:l}))):(r.content().mainBlocks().blocks.push(e),l=r.content().mainBlocks().blocks().length-1,r.notifier.info(r.t("New block added at the model bottom (__pos__)",{pos:l})));vari=r.content().mainBlocks().blocks()[l]();returnr.selectBlock(i,!0),!1},r.findObjectsOfType=function(e,o){vart=[],l=ko.utils.unwrapObservable(e);for(varrinl)if(l.hasOwnProperty(r)){varn=ko.utils.unwrapObservable(l[r]);if(r.match(/Blocks$/))for(vara=ko.utils.unwrapObservable(n.blocks),i=0;i<a.length;i++){varc=ko.utils.unwrapObservable(a[i]);null!==o&&ko.utils.unwrapObservable(c.type)!=o||t.push(c)}else"object"==typeofn&&null!==n&&(null!==o&&ko.utils.unwrapObservable(n.type)!=o||t.push(n))}returnt},r.placeholderHelper={element:function(e){return$(e[0].outerHTML).removeClass("ui-draggable").addClass("sortable-placeholder").css("display","block").css("position","rela