(()=>{"use strict";const e=window.wp.i18n,t=e=>Math.abs(parseInt(e,10)),a=(e,t,a)=>{const n=new CustomEvent(`wpcf7${t}`,{bubbles:!0,detail:a});"string"==typeof e&&(e=document.querySelector(e)),e.dispatchEvent(n)},n=(e,t)=>{const n=new Map([["init","init"],["validation_failed","invalid"],["acceptance_missing","unaccepted"],["spam","spam"],["aborted","aborted"],["mail_sent","sent"],["mail_failed","failed"],["submitting","submitting"],["resetting","resetting"],["validating","validating"],["payment_required","payment-required"]]);n.has(t)&&(t=n.get(t)),Array.from(n.values()).includes(t)||(t=`custom-${t=(t=t.replace(/[^0-9a-z]+/i," ").trim()).replace(/\s+/,"-")}`);const r=e.getAttribute("data-status");if(e.wpcf7.status=t,e.setAttribute("data-status",t),e.classList.add(t),r&&r!==t){e.classList.remove(r);const t={contactFormId:e.wpcf7.id,pluginVersion:e.wpcf7.pluginVersion,contactFormLocale:e.wpcf7.locale,unitTag:e.wpcf7.unitTag,containerPostId:e.wpcf7.containerPost,status:e.wpcf7.status,prevStatus:r};a(e,"statuschanged",t)}return t},r=e=>{const{root:t,namespace:a="contact-form-7/v1"}=wpcf7.api;return c.reduceRight(((e,t)=>a=>t(a,e)),(e=>{let n,r,{url:c,path:o,endpoint:s,headers:i,body:l,data:p,...d}=e;"string"==typeof s&&(n=a.replace(/^\/|\/$/g,""),r=s.replace(/^\//,""),o=r?n+"/"+r:n),"string"==typeof o&&(-1!==t.indexOf("?")&&(o=o.replace("?","&")),o=o.replace(/^\//,""),c=t+o),i={Accept:"application/json, */*;q=0.1",...i},delete i["X-WP-Nonce"],p&&(l=JSON.stringify(p),i["Content-Type"]="application/json");const f={code:"fetch_error",message:"You are probably offline."},u={code:"invalid_json",message:"The response is not a valid JSON response."};return window.fetch(c||o||window.location.href,{...d,headers:i,body:l}).then((e=>Promise.resolve(e).then((e=>{if(e.status>=200&&e.status<300)return e;throw e})).then((e=>{if(204===e.status)return null;if(e&&e.json)return e.json().catch((()=>{throw u}));throw u}))),(()=>{throw f}))}))(e)},c=[];function o(e,t={}){const{target:a,scope:r=e,...c}=t;if(void 0===e.wpcf7?.schema)return;const o={...e.wpcf7.schema};if(void 0!==a){if(!e.contains(a))return;if(!a.closest(".wpcf7-form-control-wrap[data-name]"))return;if(a.closest(".novalidate"))return}const p=r.querySelectorAll(".wpcf7-form-control-wrap"),d=Array.from(p).reduce(((e,t)=>(t.closest(".novalidate")||t.querySelectorAll(":where(input, textarea, select):enabled").forEach((t=>{if(t.name)switch(t.type){case"button":case"image":case"reset":case"submit":break;case"checkbox":case"radio":t.checked&&e.append(t.name,t.value);break;case"select-multiple":for(const a of t.selectedOptions)e.append(t.name,a.value);break;case"file":for(const a of t.files)e.append(t.name,a);break;default:e.append(t.name,t.value)}})),e)),new FormData),f=e.getAttribute("data-status");Promise.resolve(n(e,"validating")).then((n=>{if(void 0!==swv){const n=swv.validate(o,d,t);for(const t of p){if(void 0===t.dataset.name)continue;const c=t.dataset.name;if(n.has(c)){const{error:t,validInputs:a}=n.get(c);i(e,c),void 0!==t&&s(e,c,t,{scope:r}),l(e,c,null!=a?a:[])}if(t.contains(a))break}}})).finally((()=>{n(e,f)}))}r.use=e=>{c.unshift(e)};const s=(e,t,a,n)=>{const{scope:r=e,...c}=null!=n?n:{},o=`${e.wpcf7?.unitTag}-ve-${t}`.replaceAll(/[^0-9a-z_-]+/gi,""),s=e.querySelector(`.wpcf7-form-control-wrap[data-name="${t}"] .wpcf7-form-control`);(()=>{const t=document.createElement("li");t.setAttribute("id",o),s&&s.id?t.insertAdjacentHTML("beforeend",`<a href="#${s.id}">${a}</a>`):t.insertAdjacentText("beforeend",a),e.wpcf7.parent.querySelector(".screen-reader-response ul").appendChild(t)})(),r.querySelectorAll(`.wpcf7-form-control-wrap[data-name="${t}"]`).forEach((e=>{const t=document.createElement("span");t.classList.add("wpcf7-not-valid-tip"),t.setAttribute("aria-hidden","true"),t.insertAdjacentText("beforeend",a),e.appendChild(t),e.querySelectorAll("[aria-invalid]").forEach((e=>{e.setAttribute("aria-invalid","true")})),e.querySelectorAll(".wpcf7-form-control").forEach((e=>{e.classList.add("wpcf7-not-valid"),e.setAttribute("aria-describedby",o),"function"==typeof e.setCustomValidity&&e.setCustomValidity(a),e.closest(".use-floating-validation-tip")&&(e.addEventListener("focus",(e=>{t.setAttribute("style","display: none")})),t.addEventListener("click",(e=>{t.setAttribute("style","display: none")})))}))}))},i=(e,t)=>{const a=`${e.wpcf7?.unitTag}-ve-${t}`.replaceAll(/[^0-9a-z_-]+/gi,"");e.wpcf7.parent.querySelector(`.screen-reader-response ul li#${a}`)?.remove(),e.querySelectorAll(`.wpcf7-form-control-wrap[data-name="${t}"]`).forEach((e=>{e.querySelector(".wpcf7-not-valid-tip")?.remove(),e.querySelectorAll("[aria-invalid]").forEach((e=>{e.setAttribute("aria-invalid","false")})),e.querySelectorAll(".wpcf7-form-control").forEach((e=>{e.removeAttribute("aria-describedby"),e.classList.remove("wpcf7-not-valid"),"function"==typeof e.setCustomValidity&&e.setCustomValidity("")}))}))},l=(e,t,a)=>{e.querySelectorAll(`[data-reflection-of="${t}"]`).forEach((e=>{if("output"===e.tagName.toLowerCase()){const t=e;0===a.length&&a.push(t.dataset.default),a.slice(0,1).forEach((e=>{e instanceof File&&(e=e.name),t.textContent=e}))}else e.querySelectorAll("output").forEach((e=>{e.hasAttribute("data-default")?0===a.length?e.removeAttribute("hidden"):e.setAttribute("hidden","hidden"):e.remove()})),a.forEach((a=>{a instanceof File&&(a=a.name);const n=document.createElement("output");n.setAttribute("name",t),n.textContent=a,e.appendChild(n)}))}))};function p(e,t={}){if(wpcf7.blocked)return d(e),void n(e,"submitting");const c=new FormData(e);t.submitter&&t.submitter.name&&c.append(t.submitter.name,t.submitter.value);const o={contactFormId:e.wpcf7.id,pluginVersion:e.wpcf7.pluginVersion,contactFormLocale:e.wpcf7.locale,unitTag:e.wpcf7.unitTag,containerPostId:e.wpcf7.containerPost,status:e.wpcf7.status,inputs:Array.from(c,(e=>{const t=e[0],a=e[1];return!t.match(/^_/)&&{name:t,value:a}})).filter((e=>!1!==e)),formData:c};r({endpoint:`contact-forms/${e.wpcf7.id}/feedback`,method:"POST",body:c,wpcf7:{endpoint:"feedback",form:e,detail:o}}).then((t=>{const r=n(e,t.status);return o.status=t.status,o.apiResponse=t,["invalid","unaccepted","spam","aborted"].includes(r)?a(e,r,o):["sent","failed"].includes(r)&&a(e,`mail${r}`,o),a(e,"submit",o),t})).then((t=>{t.posted_data_hash&&(e.querySelector('input[name="_wpcf7_posted_data_hash"]').value=t.posted_data_hash),"mail_sent"===t.status&&(e.reset(),e.wpcf7.resetOnMailSent=!0),t.invalid_fields&&t.invalid_fields.forEach((t=>{s(e,t.field,t.message)})),e.wpcf7.parent.querySelector('.screen-reader-response [role="status"]').insertAdjacentText("beforeend",t.message),e.querySelectorAll(".wpcf7-response-output").forEach((e=>{e.innerText=t.message}))})).catch((e=>console.error(e)))}r.use(((e,t)=>{if(e.wpcf7&&"feedback"===e.wpcf7.endpoint){const{form:t,detail:r}=e.wpcf7;d(t),a(t,"beforesubmit",r),n(t,"submitting")}return t(e)}));const d=e=>{e.querySelectorAll(".wpcf7-form-control-wrap").forEach((t=>{t.dataset.name&&i(e,t.dataset.name)})),e.wpcf7.parent.querySelector('.screen-reader-response [role="status"]').innerText="",e.querySelectorAll(".wpcf7-response-output").forEach((e=>{e.innerText=""}))};function f(e){const t=new FormData(e),c={contactFormId:e.wpcf7.id,pluginVersion:e.wpcf7.pluginVersion,contactFormLocale:e.wpcf7.locale,unitTag:e.wpcf7.unitTag,containerPostId:e.wpcf7.containerPost,status:e.wpcf7.status,inputs:Array.from(t,(e=>{const t=e[0],a=e[1];return!t.match(/^_/)&&{name:t,value:a}})).filter((e=>!1!==e)),formData:t};r({endpoint:`contact-forms/${e.wpcf7.id}/refill`,method:"GET",wpcf7:{endpoint:"refill",form:e,detail:c}}).then((t=>{e.wpcf7.resetOnMailSent?(delete e.wpcf7.resetOnMailSent,n(e,"mail_sent")):n(e,"init"),c.apiResponse=t,a(e,"reset",c)})).catch((e=>console.error(e)))}r.use(((e,t)=>{if(e.wpcf7&&"refill"===e.wpcf7.endpoint){const{form:t,detail:a}=e.wpcf7;d(t),n(t,"resetting")}return t(e)}));const u=(e,t)=>{for(const a in t){const n=t[a];e.querySelectorAll(`input[name="${a}"]`).forEach((e=>{e.value=""})),e.querySelectorAll(`img.wpcf7-captcha-${a.replaceAll(":","")}`).forEach((e=>{e.setAttribute("src",n)}));const r=/([0-9]+)\.(png|gif|jpeg)$/.exec(n);r&&e.querySelectorAll(`input[name="_wpcf7_captcha_challenge_${a}"]`).forEach((e=>{e.value=r[1]}))}},m=(e,t)=>{for(const a in t){const n=t[a][0],r=t[a][1];e.querySelectorAll(`.wpcf7-form-control-wrap[data-name="${a}"]`).forEach((e=>{e.querySelector(`input[name="${a}"]`).value="",e.querySelector(".wpcf7-quiz-label").textContent=n,e.querySelector(`input[name="_wpcf7_quiz_answer_${a}"]`).value=r}))}};function w(e){const a=new FormData(e);e.wpcf7={id:t(a.get("_wpcf7")),status:e.getAttribute("data-status"),pluginVersion:a.get("_wpcf7_version"),locale:a.get("_wpcf7_locale"),unitTag:a.get("_wpcf7_unit_tag"),containerPost:t(a.get("_wpcf7_container_post")),parent:e.closest(".wpcf7"),get schema(){return wpcf7.schemas.get(this.id)}},wpcf7.schemas.set(e.wpcf7.id,void 0),e.querySelectorAll(".has-spinner").forEach((e=>{e.insertAdjacentHTML("afterend",'<span class="wpcf7-spinner"></span>')})),(e=>{e.querySelectorAll(".wpcf7-exclusive-checkbox").forEach((t=>{t.addEventListener("change",(t=>{const a=t.target.getAttribute("name");e.querySelectorAll(`input[type="checkbox"][name="${a}"]`).forEach((e=>{e!==t.target&&(e.checked=!1)}))}))}))})(e),(e=>{e.querySelectorAll(".has-free-text").forEach((t=>{const a=t.querySelector("input.wpcf7-free-text"),n=t.querySelector('input[type="checkbox"], input[type="radio"]');a.disabled=!n.checked,e.addEventListener("change",(e=>{a.disabled=!n.checked,e.target===n&&n.checked&&a.focus()}))}))})(e),(e=>{e.querySelectorAll(".wpcf7-validates-as-url").forEach((e=>{e.addEventListener("change",(t=>{let a=e.value.trim();a&&!a.match(/^[a-z][a-z0-9.+-]*:/i)&&-1!==a.indexOf(".")&&(a=a.replace(/^\/+/,""),a="http://"+a),e.value=a}))}))})(e),(e=>{if(!e.querySelector(".wpcf7-acceptance")||e.classList.contains("wpcf7-acceptance-as-validation"))return;const t=()=>{let t=!0;e.querySelectorAll(".wpcf7-acceptance").forEach((e=>{if(!t||e.classList.contains("optional"))return;const a=e.querySelector('input[type="checkbox"]');(e.classList.contains("invert")&&a.checked||!e.classList.contains("invert")&&!a.checked)&&(t=!1)})),e.querySelectorAll(".wpcf7-submit").forEach((e=>{e.disabled=!t}))};t(),e.addEventListener("change",(e=>{t()})),e.addEventListener("wpcf7reset",(e=>{t()}))})(e),(e=>{const a=(e,a)=>{const n=t(e.getAttribute("data-starting-value")),r=t(e.getAttribute("data-maximum-value")),c=t(e.getAttribute("data-minimum-value")),o=e.classList.contains("down")?n-a.value.trim().length:a.value.trim().length;e.setAttribute("data-current-value",o),e.innerText=o,r&&r<a.value.length?e.classList.add("too-long"):e.classList.remove("too-long"),c&&a.value.length<c?e.classList.add("too-short"):e.classList.remove("too-short")},n=t=>{t={init:!1,...t},e.querySelectorAll(".wpcf7-character-count").forEach((n=>{const r=n.getAttribute("data-target-name"),c=e.querySelector(`[name="${r}"]`);c&&(c.value=c.defaultValue,a(n,c),t.init&&c.addEventListener("keyup",(e=>{a(n,c)})))}))};n({init:!0}),e.addEventListener("wpcf7reset",(e=>{n()}))})(e),window.addEventListener("load",(t=>{wpcf7.cached&&e.reset()})),e.addEventListener("reset",(t=>{wpcf7.reset(e)})),e.addEventListener("submit",(t=>{wpcf7.submit(e,{submitter:t.submitter}),t.preventDefault()})),e.addEventListener("wpcf7submit",(t=>{t.detail.apiResponse.captcha&&u(e,t.detail.apiResponse.captcha),t.detail.apiResponse.quiz&&m(e,t.detail.apiResponse.quiz)})),e.addEventListener("wpcf7reset",(t=>{t.detail.apiResponse.captcha&&u(e,t.detail.apiResponse.captcha),t.detail.apiResponse.quiz&&m(e,t.detail.apiResponse.quiz)})),e.addEventListener("change",(t=>{t.target.closest(".wpcf7-form-control")&&wpcf7.validate(e,{target:t.target})})),e.addEventListener("wpcf7statuschanged",(t=>{const a=t.detail.status;e.querySelectorAll(".active-on-any").forEach((e=>{e.removeAttribute("inert"),e.classList.remove("active-on-any")})),e.querySelectorAll(`.inert-on-${a}`).forEach((e=>{e.setAttribute("inert","inert"),e.classList.add("active-on-any")}))}))}document.addEventListener("DOMContentLoaded",(t=>{var a;if("undefined"!=typeof wpcf7)if(void 0!==wpcf7.api)if("function"==typeof window.fetch)if("function"==typeof window.FormData)if("function"==typeof NodeList.prototype.forEach)if("function"==typeof String.prototype.replaceAll){wpcf7={init:w,submit:p,reset:f,validate:o,schemas:new Map,...null!==(a=wpcf7)&&void 0!==a?a:{}},document.querySelectorAll("form .wpcf7[data-wpcf7-id]").forEach((t=>{const a=document.createElement("p");a.setAttribute("class","wpcf7-form-in-wrong-place");const n=document.createElement("strong");n.append((0,e.__)("Error:","contact-form-7"));const r=(0,e.__)("This contact form is placed in the wrong place.","contact-form-7");a.append(n," ",r),t.replaceWith(a)})),document.querySelectorAll(".wpcf7 > form").forEach((e=>{wpcf7.init(e),e.closest(".wpcf7").classList.replace("no-js","js")}));for(const e of wpcf7.schemas.keys())r({endpoint:`contact-forms/${e}/feedback/schema`,method:"GET"}).then((t=>{wpcf7.schemas.set(e,t)}))}else console.error("Your browser does not support String.replaceAll().");else console.error("Your browser does not support NodeList.forEach().");else console.error("Your browser does not support window.FormData().");else console.error("Your browser does not support window.fetch().");else console.error("wpcf7.api is not defined.");else console.error("wpcf7 is not defined.")}))})();
window.addComment=function(v){var I,C,h,E=v.document,b={commentReplyClass:"comment-reply-link",commentReplyTitleId:"reply-title",cancelReplyId:"cancel-comment-reply-link",commentFormId:"commentform",temporaryFormId:"wp-temp-form-div",parentIdFieldId:"comment_parent",postIdFieldId:"comment_post_ID"},e=v.MutationObserver||v.WebKitMutationObserver||v.MozMutationObserver,r="querySelector"in E&&"addEventListener"in v,n=!!E.documentElement.dataset;function t(){d(),e&&new e(o).observe(E.body,{childList:!0,subtree:!0})}function d(e){if(r&&(I=g(b.cancelReplyId),C=g(b.commentFormId),I)){I.addEventListener("touchstart",l),I.addEventListener("click",l);function t(e){if((e.metaKey||e.ctrlKey)&&13===e.keyCode&&"a"!==E.activeElement.tagName.toLowerCase())return C.removeEventListener("keydown",t),e.preventDefault(),C.submit.click(),!1}C&&C.addEventListener("keydown",t);for(var n,d=function(e){var t=b.commentReplyClass;e&&e.childNodes||(e=E);e=E.getElementsByClassName?e.getElementsByClassName(t):e.querySelectorAll("."+t);return e}(e),o=0,i=d.length;o<i;o++)(n=d[o]).addEventListener("touchstart",a),n.addEventListener("click",a)}}function l(e){var t,n,d=g(b.temporaryFormId);d&&h&&(g(b.parentIdFieldId).value="0",t=d.textContent,d.parentNode.replaceChild(h,d),this.style.display="none",n=(d=(d=g(b.commentReplyTitleId))&&d.firstChild)&&d.nextSibling,d&&d.nodeType===Node.TEXT_NODE&&t&&(n&&"A"===n.nodeName&&n.id!==b.cancelReplyId&&(n.style.display=""),d.textContent=t),e.preventDefault())}function a(e){var t=g(b.commentReplyTitleId),t=t&&t.firstChild.textContent,n=this,d=m(n,"belowelement"),o=m(n,"commentid"),i=m(n,"respondelement"),r=m(n,"postid"),n=m(n,"replyto")||t;d&&o&&i&&r&&!1===v.addComment.moveForm(d,o,i,r,n)&&e.preventDefault()}function o(e){for(var t=e.length;t--;)if(e[t].addedNodes.length)return void d()}function m(e,t){return n?e.dataset[t]:e.getAttribute("data-"+t)}function g(e){return E.getElementById(e)}return r&&"loading"!==E.readyState?t():r&&v.addEventListener("DOMContentLoaded",t,!1),{init:d,moveForm:function(e,t,n,d,o){var i,r,l,a,m,c,s,e=g(e),n=(h=g(n),g(b.parentIdFieldId)),y=g(b.postIdFieldId),p=g(b.commentReplyTitleId),u=(p=p&&p.firstChild)&&p.nextSibling;if(e&&h&&n){void 0===o&&(o=p&&p.textContent),a=h,m=b.temporaryFormId,c=g(m),s=(s=g(b.commentReplyTitleId))?s.firstChild.textContent:"",c||((c=E.createElement("div")).id=m,c.style.display="none",c.textContent=s,a.parentNode.insertBefore(c,a)),d&&y&&(y.value=d),n.value=t,I.style.display="",e.parentNode.insertBefore(h,e.nextSibling),p&&p.nodeType===Node.TEXT_NODE&&(u&&"A"===u.nodeName&&u.id!==b.cancelReplyId&&(u.style.display="none"),p.textContent=o),I.onclick=function(){return!1};try{for(var f=0;f<C.elements.length;f++)if(i=C.elements[f],r=!1,"getComputedStyle"in v?l=v.getComputedStyle(i):E.documentElement.currentStyle&&(l=i.currentStyle),(i.offsetWidth<=0&&i.offsetHeight<=0||"hidden"===l.visibility)&&(r=!0),"hidden"!==i.type&&!i.disabled&&!r){i.focus();break}}catch(e){}return!1}}}}(window);
function wpss_get_ckf(e){var t=document.cookie.split(";");for(var s in t)if(t.hasOwnProperty(s))if(-1!=t[s].indexOf(e+"="))return decodeURIComponent(t[s].split("=")[1]);return""}function wpss_set_ckf(e,t,s,n,i,_){var c=new Date;c.setTime(c.getTime()),s&&(s=1e3*s*60*60*24);var r=new Date(c.getTime()+s);document.cookie=e+"="+escape(t)+(s?";expires="+r.toGMTString():"")+(n?";path="+n:"")+(i?";domain="+i:"")+(_?";secure":"")}function wpss_init_ckf(){var e=wpss_get_ckf("JCS_INENREF"),t=wpss_get_ckf("JCS_INENTIM"),s=new Date,n=s.getTime(),i=document.referrer;e||wpss_set_ckf("JCS_INENREF",i,1/24,"/"),t||wpss_set_ckf("JCS_INENTIM",n,1/24,"/");var h=window.history.length;var p=navigator.plugins.length;var q="N:"+p.toString();var u="";for(var j=0;j<p;j++){var k=j+1;u+="["+k+"]["+navigator.plugins[j].name+"] ";}var d=q+" | "+window.btoa(u);wpss_set_ckf("_wpss_h_",h,1/24,"/");wpss_set_ckf("_wpss_p_",d,1/24,"/");}wpss_init_ckf();jQuery(document).ready(function($){$("#commentform, .comment-respond form, .comment-form").removeAttr("novalidate");var f="form[method='post']";$(f).submit(function(){$("<input>").attr("type","hidden").attr("name","WP55T3S7XJS2").attr("value","7H5W8K53HX").appendTo(f);return true;})});
!function(){var h,n=this;function p(t){return void 0!==t}function aa(){}function ba(t){t.yb=function(){return t.zf?t.zf:t.zf=new t}}function ca(t){var e=typeof t;if("object"==e){if(!t)return"null";if(t instanceof Array)return"array";if(t instanceof Object)return e;var n=Object.prototype.toString.call(t);if("[object Window]"==n)return"object";if("[object Array]"==n||"number"==typeof t.length&&"undefined"!=typeof t.splice&&"undefined"!=typeof t.propertyIsEnumerable&&!t.propertyIsEnumerable("splice"))return"array";if("[object Function]"==n||"undefined"!=typeof t.call&&"undefined"!=typeof t.propertyIsEnumerable&&!t.propertyIsEnumerable("call"))return"function"}else if("function"==e&&"undefined"==typeof t.call)return"object";return e}function da(t){return"array"==ca(t)}function ea(t){var e=ca(t);return"array"==e||"object"==e&&"number"==typeof t.length}function q(t){return"string"==typeof t}function fa(t){return"number"==typeof t}function r(t){return"function"==ca(t)}function ga(t){var e=typeof t;return"object"==e&&null!=t||"function"==e}function ha(t,e,n){return t.call.apply(t.bind,arguments)}function ia(e,n,t){if(!e)throw Error();if(2<arguments.length){var i=Array.prototype.slice.call(arguments,2);return function(){var t=Array.prototype.slice.call(arguments);return Array.prototype.unshift.apply(t,i),e.apply(n,t)}}return function(){return e.apply(n,arguments)}}function u(t,e,n){return(u=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?ha:ia).apply(null,arguments)}var ja=Date.now||function(){return+new Date};function ka(t,o){function e(){}e.prototype=o.prototype,t.ph=o.prototype,t.prototype=new e,(t.prototype.constructor=t).lh=function(t,e,n){for(var i=Array(arguments.length-2),r=2;r<arguments.length;r++)i[r-2]=arguments[r];return o.prototype[e].apply(t,i)}}function la(t){if(Error.captureStackTrace)Error.captureStackTrace(this,la);else{var e=Error().stack;e&&(this.stack=e)}t&&(this.message=String(t))}function v(t,e){for(var n in t)e.call(void 0,t[n],n,t)}function ma(t,e){var n,i={};for(n in t)i[n]=e.call(void 0,t[n],n,t);return i}function na(t,e){for(var n in t)if(!e.call(void 0,t[n],n,t))return!1;return!0}function oa(t){var e,n=0;for(e in t)n++;return n}function pa(t){for(var e in t)return e}function qa(t){var e,n=[],i=0;for(e in t)n[i++]=t[e];return n}function ra(t){var e,n=[],i=0;for(e in t)n[i++]=e;return n}function sa(t,e){for(var n in t)if(t[n]==e)return!0;return!1}function ta(t,e,n){for(var i in t)if(e.call(n,t[i],i,t))return i}function ua(t,e){var n=ta(t,e,void 0);return n&&t[n]}function va(t){for(var e in t)return!1;return!0}function wa(t){var e,n={};for(e in t)n[e]=t[e];return n}ka(la,Error),la.prototype.name="CustomError";var xa="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function ya(t,e){for(var n,i,r=1;r<arguments.length;r++){for(n in i=arguments[r])t[n]=i[n];for(var o=0;o<xa.length;o++)n=xa[o],Object.prototype.hasOwnProperty.call(i,n)&&(t[n]=i[n])}}function za(a){if(a=String(a),!/^\s*$/.test(a)&&/^[\],:{}\s\u2028\u2029]*$/.test(a.replace(/\\["\\\/bfnrtu]/g,"@").replace(/"[^"\\\n\r\u2028\u2029\x00-\x08\x0a-\x1f]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:[\s\u2028\u2029]*\[)+/g,"")))try{return eval("("+a+")")}catch(b){}throw Error("Invalid JSON string: "+a)}function Aa(){this.Vd=void 0}function Ba(t,e,n){switch(typeof e){case"string":Ca(e,n);break;case"number":n.push(isFinite(e)&&!isNaN(e)?e:"null");break;case"boolean":n.push(e);break;case"undefined":n.push("null");break;case"object":if(null==e){n.push("null");break}if(da(e)){var i=e.length;n.push("[");for(var r="",o=0;o<i;o++)n.push(r),r=e[o],Ba(t,t.Vd?t.Vd.call(e,String(o),r):r,n),r=",";n.push("]");break}for(o in n.push("{"),i="",e)Object.prototype.hasOwnProperty.call(e,o)&&("function"!=typeof(r=e[o])&&(n.push(i),Ca(o,n),n.push(":"),Ba(t,t.Vd?t.Vd.call(e,o,r):r,n),i=","));n.push("}");break;case"function":break;default:throw Error("Unknown type: "+typeof e)}}var Da={'"':'\\"',"\\":"\\\\","/":"\\/","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\x0B":"\\u000b"},Ea=/\uffff/.test("￿")?/[\\\"\x00-\x1f\x7f-\uffff]/g:/[\\\"\x00-\x1f\x7f-\xff]/g,w;function Ca(t,e){e.push('"',t.replace(Ea,function(t){if(t in Da)return Da[t];var e=t.charCodeAt(0),n="\\u";return e<16?n+="000":e<256?n+="00":e<4096&&(n+="0"),Da[t]=n+e.toString(16)}),'"')}function Fa(){return Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^ja()).toString(36)}t:{var Ga=n.navigator;if(Ga){var Ha=Ga.userAgent;if(Ha){w=Ha;break t}}w=""}function Ia(){this.Ya=-1}function Ja(){this.Ya=-1,this.Ya=64,this.P=[],this.pe=[],this.eg=[],this.Od=[],this.Od[0]=128;for(var t=1;t<this.Ya;++t)this.Od[t]=0;this.ge=this.ec=0,this.reset()}function Ka(t,e,n){n=n||0;var i=t.eg;if(q(e))for(var r=0;r<16;r++)i[r]=e.charCodeAt(n)<<24|e.charCodeAt(n+1)<<16|e.charCodeAt(n+2)<<8|e.charCodeAt(n+3),n+=4;else for(r=0;r<16;r++)i[r]=e[n]<<24|e[n+1]<<16|e[n+2]<<8|e[n+3],n+=4;for(r=16;r<80;r++){var o=i[r-3]^i[r-8]^i[r-14]^i[r-16];i[r]=4294967295&(o<<1|o>>>31)}e=t.P[0],n=t.P[1];var a,s=t.P[2],h=t.P[3],u=t.P[4];for(r=0;r<80;r++)a=r<40?r<20?(o=h^n&(s^h),1518500249):(o=n^s^h,1859775393):r<60?(o=n&s|h&(n|s),2400959708):(o=n^s^h,3395469782),o=(e<<5|e>>>27)+o+u+a+i[r]&4294967295,u=h,h=s,s=4294967295&(n<<30|n>>>2),n=e,e=o;t.P[0]=t.P[0]+e&4294967295,t.P[1]=t.P[1]+n&4294967295,t.P[2]=t.P[2]+s&4294967295,t.P[3]=t.P[3]+h&4294967295,t.P[4]=t.P[4]+u&4294967295}ka(Ja,Ia),Ja.prototype.reset=function(){this.P[0]=1732584193,this.P[1]=4023233417,this.P[2]=2562383102,this.P[3]=271733878,this.P[4]=3285377520,this.ge=this.ec=0},Ja.prototype.update=function(t,e){if(null!=t){p(e)||(e=t.length);for(var n=e-this.Ya,i=0,r=this.pe,o=this.ec;i<e;){if(0==o)for(;i<=n;)Ka(this,t,i),i+=this.Ya;if(q(t)){for(;i<e;)if(r[o]=t.charCodeAt(i),++i,++o==this.Ya){Ka(this,r),o=0;break}}else for(;i<e;)if(r[o]=t[i],++i,++o==this.Ya){Ka(this,r),o=0;break}}this.ec=o,this.ge+=e}};var x=Array.prototype,La=x.indexOf?function(t,e,n){return x.indexOf.call(t,e,n)}:function(t,e,n){if(n=null==n?0:n<0?Math.max(0,t.length+n):n,q(t))return q(e)&&1==e.length?t.indexOf(e,n):-1;for(;n<t.length;n++)if(n in t&&t[n]===e)return n;return-1},Ma=x.forEach?function(t,e,n){x.forEach.call(t,e,n)}:function(t,e,n){for(var i=t.length,r=q(t)?t.split(""):t,o=0;o<i;o++)o in r&&e.call(n,r[o],o,t)},Na=x.filter?function(t,e,n){return x.filter.call(t,e,n)}:function(t,e,n){for(var i=t.length,r=[],o=0,a=q(t)?t.split(""):t,s=0;s<i;s++)if(s in a){var h=a[s];e.call(n,h,s,t)&&(r[o++]=h)}return r},Oa=x.map?function(t,e,n){return x.map.call(t,e,n)}:function(t,e,n){for(var i=t.length,r=Array(i),o=q(t)?t.split(""):t,a=0;a<i;a++)a in o&&(r[a]=e.call(n,o[a],a,t));return r},Pa=x.reduce?function(t,e,n,i){for(var r=[],o=1,a=arguments.length;o<a;o++)r.push(arguments[o]);return i&&(r[0]=u(e,i)),x.reduce.apply(t,r)}:function(n,i,t,r){var o=t;return Ma(n,function(t,e){o=i.call(r,o,t,e,n)}),o},Qa=x.every?function(t,e,n){return x.every.call(t,e,n)}:function(t,e,n){for(var i=t.length,r=q(t)?t.split(""):t,o=0;o<i;o++)if(o in r&&!e.call(n,r[o],o,t))return!1;return!0},Ya,ab;function Ra(t,e){var n=Sa(t,e,void 0);return n<0?null:q(t)?t.charAt(n):t[n]}function Sa(t,e,n){for(var i=t.length,r=q(t)?t.split(""):t,o=0;o<i;o++)if(o in r&&e.call(n,r[o],o,t))return o;return-1}function Ta(t,e){var n=La(t,e);0<=n&&x.splice.call(t,n,1)}function Ua(t,e,n){return arguments.length<=2?x.slice.call(t,e):x.slice.call(t,e,n)}function Va(t,e){t.sort(e||Wa)}function Wa(t,e){return e<t?1:t<e?-1:0}function Xa(t){n.setTimeout(function(){throw t},0)}function Za(){var t=n.MessageChannel;if(void 0===t&&"undefined"!=typeof window&&window.postMessage&&window.addEventListener&&-1==w.indexOf("Presto")&&(t=function(){(i=document.createElement("iframe")).style.display="none",i.src="",document.documentElement.appendChild(i);var t=i.contentWindow;(i=t.document).open(),i.write(""),i.close();var e="callImmediate"+Math.random(),n="file:"==t.location.protocol?"*":t.location.protocol+"//"+t.location.host,i=u(function(t){"*"!=n&&t.origin!=n||t.data!=e||this.port1.onmessage()},this);t.addEventListener("message",i,!1),this.port1={},this.port2={postMessage:function(){t.postMessage(e,n)}}}),void 0===t||-1!=w.indexOf("Trident")||-1!=w.indexOf("MSIE"))return"undefined"!=typeof document&&"onreadystatechange"in document.createElement("script")?function(t){var e=document.createElement("script");e.onreadystatechange=function(){e.onreadystatechange=null,e.parentNode.removeChild(e),e=null,t(),t=null},document.documentElement.appendChild(e)}:function(t){n.setTimeout(t,0)};var e=new t,i={},r=i;return e.port1.onmessage=function(){if(p(i.next)){var t=(i=i.next).hb;i.hb=null,t()}},function(t){r.next={hb:t},r=r.next,e.port2.postMessage(0)}}function $a(t,e){ab||bb(),cb||(ab(),cb=!0),db.push(new eb(t,e))}function bb(){if(n.Promise&&n.Promise.resolve){var t=n.Promise.resolve();ab=function(){t.then(fb)}}else ab=function(){var t=fb;!r(n.setImmediate)||n.Window&&n.Window.prototype&&n.Window.prototype.setImmediate==n.setImmediate?(Ya=Ya||Za())(t):n.setImmediate(t)}}var cb=!1,db=[];function fb(){for(;db.length;){var t=db;db=[];for(var e=0;e<t.length;e++){var n=t[e];try{n.yg.call(n.scope)}catch(i){Xa(i)}}}cb=!1}function eb(t,e){this.yg=t,this.scope=e}[].push(function(){cb=!1,db=[]});var gb=-1!=w.indexOf("Opera")||-1!=w.indexOf("OPR"),hb=-1!=w.indexOf("Trident")||-1!=w.indexOf("MSIE"),ib=-1!=w.indexOf("Gecko")&&-1==w.toLowerCase().indexOf("webkit")&&!(-1!=w.indexOf("Trident")||-1!=w.indexOf("MSIE")),jb=-1!=w.toLowerCase().indexOf("webkit"),Gm,Fm;Fm="",gb&&n.opera?r(Fm=n.opera.version)&&Fm():(ib?Gm=/rv\:([^\);]+)(\)|;)/:hb?Gm=/\b(?:MSIE|rv)[: ]([^\);]+)(\)|;)/:jb&&(Gm=/WebKit\/(\S+)/),Gm&&(Fm=(Fm=Gm.exec(w))?Fm[1]:""),hb&&(Gm=(Gm=n.document)?Gm.documentMode:void 0)>parseFloat(Fm)&&String(Gm));var kb=null,lb=null,mb=null;function nb(t,e){if(!ea(t))throw Error("encodeByteArray takes an array as a parameter");ob();for(var n=e?lb:kb,i=[],r=0;r<t.length;r+=3){var o=t[r],a=r+1<t.length,s=a?t[r+1]:0,h=r+2<t.length,u=o>>2,c=(o=(3&o)<<4|s>>4,s=(15&s)<<2|(c=h?t[r+2]:0)>>6,63&c);h||(c=64,a||(s=64)),i.push(n[u],n[o],n[s],n[c])}return i.join("")}function ob(){if(!kb){kb={},lb={},mb={};for(var t=0;t<65;t++)kb[t]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(t),lb[t]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.".charAt(t),62<=(mb[lb[t]]=t)&&(mb["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(t)]=t)}}function pb(t,e){if(this.N=qb,this.Rf=void 0,this.Ba=this.Ha=null,this.yd=this.ye=!1,t==rb)sb(this,tb,e);else try{var n=this;t.call(e,function(t){sb(n,tb,t)},function(t){if(!(t instanceof ub))try{if(t instanceof Error)throw t;throw Error("Promise rejected.")}catch(e){}sb(n,vb,t)})}catch(i){sb(this,vb,i)}}var qb=0,tb=2,vb=3;function rb(){}function xb(t,e){if(t.N==qb)if(t.Ha){var n=t.Ha;if(n.Ba){for(var i,r=0,o=-1,a=0;(i=n.Ba[a])&&!((i=i.o)&&(r++,i==t&&(o=a),0<=o&&1<r));a++);0<=o&&(n.N==qb&&1==r?xb(n,e):(r=n.Ba.splice(o,1)[0],yb(n,r,vb,e)))}t.Ha=null}else sb(t,vb,e)}function zb(t,e){t.Ba&&t.Ba.length||t.N!=tb&&t.N!=vb||Ab(t),t.Ba||(t.Ba=[]),t.Ba.push(e)}function wb(t,o,a,s){var e={o:null,Hf:null,Jf:null};return e.o=new pb(function(i,r){e.Hf=o?function(t){try{var e=o.call(s,t);i(e)}catch(n){r(n)}}:i,e.Jf=a?function(t){try{var e=a.call(s,t);!p(e)&&t instanceof ub?r(t):i(e)}catch(n){r(n)}}:r}),zb(e.o.Ha=t,e),e.o}function sb(t,e,n){if(t.N==qb){if(t==n)e=vb,n=new TypeError("Promise cannot resolve to itself");else{var i;if(n)try{i=!!n.$goog_Thenable}catch(a){i=!1}else i=!1;if(i)return t.N=1,void n.then(t.Yf,t.Zf,t);if(ga(n))try{var o=n.then;if(r(o))return void Bb(t,n,o)}catch(s){e=vb,n=s}}t.Rf=n,t.N=e,t.Ha=null,Ab(t),e!=vb||n instanceof ub||Cb(t,n)}}function Bb(e,t,n){function i(t){r||(r=!0,e.Zf(t))}var r=!(e.N=1);try{n.call(t,function o(t){r||(r=!0,e.Yf(t))},i)}catch(a){i(a)}}function Ab(t){t.ye||(t.ye=!0,$a(t.wg,t))}function yb(t,e,n,i){if(n==tb)e.Hf(i);else{if(e.o)for(;t&&t.yd;t=t.Ha)t.yd=!1;e.Jf(i)}}function Cb(t,e){t.yd=!0,$a(function(){t.yd&&Db.call(null,e)})}pb.prototype.then=function(t,e,n){return wb(this,r(t)?t:null,r(e)?e:null,n)},pb.prototype.then=pb.prototype.then,pb.prototype.$goog_Thenable=!0,h=pb.prototype,h.gh=function(t,e){return wb(this,null,t,e)},h.cancel=function(t){this.N==qb&&$a(function(){xb(this,new ub(t))},this)},h.Yf=function(t){this.N=qb,sb(this,tb,t)},h.Zf=function(t){this.N=qb,sb(this,vb,t)},h.wg=function(){for(;this.Ba&&this.Ba.length;){var t=this.Ba;this.Ba=null;for(var e=0;e<t.length;e++)yb(this,t[e],this.N,this.Rf)}this.ye=!1};var Db=Xa;function ub(t){la.call(this,t)}ka(ub,la),ub.prototype.name="cancel";var Eb=Eb||"2.4.2";function y(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function z(t,e){if(Object.prototype.hasOwnProperty.call(t,e))return t[e]}function Fb(t,e){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e(n,t[n])}function Gb(t){var n={};return Fb(t,function(t,e){n[t]=e}),n}function Hb(t){return"object"==typeof t&&null!==t}function Ib(t){var n=[];return Fb(t,function(e,t){da(t)?Ma(t,function(t){n.push(encodeURIComponent(e)+"="+encodeURIComponent(t))}):n.push(encodeURIComponent(e)+"="+encodeURIComponent(t))}),n.length?"&"+n.join("&"):""}function Jb(t){var e={};return t=t.replace(/^\?/,"").split("&"),Ma(t,function(t){t&&(t=t.split("="),e[t[0]]=t[1])}),e}function Kb(t,e){if(!t)throw Lb(e)}function Lb(t){return Error("Firebase ("+Eb+") INTERNAL ASSERT FAILED: "+t)}var Mb=n.Promise||pb;function B(){var n=this;this.reject=this.resolve=null,this.D=new Mb(function(t,e){n.resolve=t,n.reject=e})}function C(n,i){return function(t,e){t?n.reject(t):n.resolve(e),r(i)&&(Nb(n.D),1===i.length?i(t):i(t,e))}}function Nb(t){t.then(void 0,aa)}function Ob(t){for(var e=[],n=0,i=0;i<t.length;i++){var r=t.charCodeAt(i);55296<=r&&r<=56319&&(r-=55296,Kb(++i<t.length,"Surrogate pair missing trail surrogate."),r=65536+(r<<10)+(t.charCodeAt(i)-56320)),r<128?e[n++]=r:(r<2048?e[n++]=r>>6|192:(r<65536?e[n++]=r>>12|224:(e[n++]=r>>18|240,e[n++]=r>>12&63|128),e[n++]=r>>6&63|128),e[n++]=63&r|128)}return e}function Pb(t){for(var e=0,n=0;n<t.length;n++){var i=t.charCodeAt(n);i<128?e++:i<2048?e+=2:55296<=i&&i<=56319?(e+=4,n++):e+=3}return e}function D(t,e,n,i){var r;if(i<e?r="at least "+e:n<i&&(r=0===n?"none":"no more than "+n),r)throw Error(t+" failed: Was called with "+i+(1===i?" argument.":" arguments.")+" Expects "+r+".")}function E(t,e,n){var i="";switch(e){case 1:i=n?"first":"First";break;case 2:i=n?"second":"Second";break;case 3:i=n?"third":"Third";break;case 4:i=n?"fourth":"Fourth";break;default:throw Error("errorPrefix called with argumentNumber > 4.  Need to update it?")}return t+" failed: "+i+" argument "}function F(t,e,n,i){if((!i||p(n))&&!r(n))throw Error(E(t,e,i)+"must be a valid function.")}function Qb(t,e,n){if(p(n)&&(!ga(n)||null===n))throw Error(E(t,e,!0)+"must be a valid context object.")}function Rb(t){return"undefined"!=typeof JSON&&p(JSON.parse)?JSON.parse(t):za(t)}function G(t){if("undefined"!=typeof JSON&&p(JSON.stringify))t=JSON.stringify(t);else{var e=[];Ba(new Aa,t,e),t=e.join("")}return t}function Sb(){this.Zd=H}function Tb(){}pb.prototype["catch"]=pb.prototype.gh,Sb.prototype.j=function(t){return this.Zd.S(t)},Sb.prototype.toString=function(){return this.Zd.toString()},Tb.prototype.uf=function(){return null},Tb.prototype.Ce=function(){return null};var Ub=new Tb;function Vb(t,e,n){this.bg=t,this.Oa=e,this.Nd=n}function Zb(){this.xb=[]}function $b(t,e){for(var n=null,i=0;i<e.length;i++){var r=e[i],o=r.cc();null===n||o.ea(n.cc())||(t.xb.push(n),n=null),null===n&&(n=new ac(o)),n.add(r)}n&&t.xb.push(n)}function bc(t,e,n){$b(t,n),cc(t,function(t){return t.ea(e)})}function dc(t,e,n){$b(t,n),cc(t,function(t){return t.contains(e)||e.contains(t)})}function cc(t,e){for(var n=!0,i=0;i<t.xb.length;i++){if(r=t.xb[i])if(e(r=r.cc())){for(var r=t.xb[i],o=0;o<r.xd.length;o++){var a=r.xd[o];if(null!==a){r.xd[o]=null;var s=a.Zb();ec&&fc("event: "+a.toString()),gc(s)}}t.xb[i]=null}else n=!1}n&&(t.xb=[])}function ac(t){this.ta=t,this.xd=[]}function J(t,e,n,i){this.type=t,this.Na=e,this.Za=n,this.Oe=i,this.Td=void 0}function hc(t){return new J(ic,t)}Vb.prototype.uf=function(t){var e=this.Oa.Q;return Wb(e,t)?e.j().T(t):(e=null!=this.Nd?new Xb(this.Nd,!0,!1):this.Oa.w(),this.bg.Bc(t,e))},Vb.prototype.Ce=function(t,e,n){var i=null!=this.Nd?this.Nd:Yb(this.Oa);return 0===(t=this.bg.qe(i,e,1,n,t)).length?null:t[0]},ac.prototype.add=function(t){this.xd.push(t)},ac.prototype.cc=function(){return this.ta};var ic="value";function jc(t,e,n,i){this.xe=e,this.be=n,this.Td=i,this.wd=t}function kc(t,e,n){this.xe=t,this.error=e,this.path=n}function Xb(t,e,n){this.A=t,this.ga=e,this.Yb=n}function lc(t){return t.ga}function mc(t){return t.Yb}function nc(t,e){return e.e()?t.ga&&!t.Yb:Wb(t,K(e))}function Wb(t,e){return t.ga&&!t.Yb||t.A.Fa(e)}function oc(t){this.pg=t,this.Gd=null}function pc(t,e){this.Vf={},this.hd=new oc(t),this.da=e;var n=1e4+2e4*Math.random();setTimeout(u(this.Of,this),Math.floor(n))}function qc(){this.Hc={}}function rc(t,e,n){p(n)||(n=1),y(t.Hc,e)||(t.Hc[e]=0),t.Hc[e]+=n}jc.prototype.cc=function(){var t=this.be.Mb();return"value"===this.wd?t.path:t.parent().path},jc.prototype.De=function(){return this.wd},jc.prototype.Zb=function(){return this.xe.Zb(this)},jc.prototype.toString=function(){return this.cc().toString()+":"+this.wd+":"+G(this.be.qf())},kc.prototype.cc=function(){return this.path},kc.prototype.De=function(){return"cancel"},kc.prototype.Zb=function(){return this.xe.Zb(this)},kc.prototype.toString=function(){return this.path.toString()+":cancel"},Xb.prototype.j=function(){return this.A},oc.prototype.get=function(){var t=this.pg.get(),e=wa(t);if(this.Gd)for(var n in this.Gd)e[n]-=this.Gd[n];return this.Gd=t,e},pc.prototype.Of=function(){var t,e=this.hd.get(),n={},i=!1;for(t in e)0<e[t]&&y(this.Vf,t)&&(n[t]=e[t],i=!0);i&&this.da.Ye(n),setTimeout(u(this.Of,this),Math.floor(6e5*Math.random()))},qc.prototype.get=function(){return wa(this.Hc)};var sc={},tc={};function uc(t){return t=t.toString(),sc[t]||(sc[t]=new qc),sc[t]}function vc(t,e){var n=t.toString();return tc[n]||(tc[n]=e()),tc[n]}function L(t,e){this.name=t,this.U=e}function wc(t,e){return new L(t,e)}function xc(t,e){return yc(t.name,e.name)}function zc(t,e){return yc(t,e)}function Ac(t,e,n){this.type=Bc,this.source=t,this.path=e,this.Ja=n}function Cc(t,e){this.type=Dc,this.source=t,this.path=e}function Ec(t,e){this.Pa=t,this.xa=e||Fc}function Gc(t,e){for(var n,i=t.xa,r=null;!i.e();){if(0===(n=t.Pa(e,i.key))){if(i.left.e())return r?r.key:null;for(i=i.left;!i.right.e();)i=i.right;return i.key}n<0?i=i.left:0<n&&(i=(r=i).right)}throw Error("Attempted to find predecessor key for a nonexistent key.  What gives?")}function Hc(t,e,n,i,r){for(this.Xd=r||null,this.Je=i,this.Ta=[],r=1;!t.e();)if(r=e?n(t.key,e):1,i&&(r*=-1),r<0)t=this.Je?t.left:t.right;else{if(0===r){this.Ta.push(t);break}this.Ta.push(t),t=this.Je?t.right:t.left}}function Ic(t){if(0===t.Ta.length)return null;var e,n=t.Ta.pop();if(e=t.Xd?t.Xd(n.key,n.value):{key:n.key,value:n.value},t.Je)for(n=n.left;!n.e();)t.Ta.push(n),n=n.right;else for(n=n.right;!n.e();)t.Ta.push(n),n=n.left;return e}function Jc(t){return 0===t.Ta.length?null:(e=(e=t.Ta)[e.length-1],t.Xd?t.Xd(e.key,e.value):{key:e.key,value:e.value});var e}function Kc(t,e,n,i,r){this.key=t,this.value=e,this.color=null==n||n,this.left=null!=i?i:Fc,this.right=null!=r?r:Fc}function Lc(t){return t.left.e()?t:Lc(t.left)}function Nc(t){return t.left.e()?Fc:(t.left.ha()||t.left.left.ha()||(t=Oc(t)),Mc(t=t.$(null,null,null,Nc(t.left),null)))}function Mc(t){return t.right.ha()&&!t.left.ha()&&(t=Rc(t)),t.left.ha()&&t.left.left.ha()&&(t=Pc(t)),t.left.ha()&&t.right.ha()&&(t=Qc(t)),t}function Oc(t){return(t=Qc(t)).right.left.ha()&&(t=Qc(t=Rc(t=t.$(null,null,null,null,Pc(t.right))))),t}function Rc(t){return t.right.$(null,null,t.color,t.$(null,null,!0,null,t.right.left),null)}function Pc(t){return t.left.$(null,null,t.color,null,t.$(null,null,!0,t.left.right,null))}function Qc(t){return t.$(null,null,!t.color,t.left.$(null,null,!t.left.color,null,null),t.right.$(null,null,!t.right.color,null,null))}function Sc(){}Ac.prototype.$c=function(t){return this.path.e()?new Ac(this.source,M,this.Ja.T(t)):new Ac(this.source,N(this.path),this.Ja)},Ac.prototype.toString=function(){return"Operation("+this.path+": "+this.source.toString()+" overwrite: "+this.Ja.toString()+")"},Cc.prototype.$c=function(){return this.path.e()?new Cc(this.source,M):new Cc(this.source,N(this.path))},Cc.prototype.toString=function(){return"Operation("+this.path+": "+this.source.toString()+" listen_complete)"},h=Ec.prototype,h.Sa=function(t,e){return new Ec(this.Pa,this.xa.Sa(t,e,this.Pa).$(null,null,!1,null,null))},h.remove=function(t){return new Ec(this.Pa,this.xa.remove(t,this.Pa).$(null,null,!1,null,null))},h.get=function(t){for(var e,n=this.xa;!n.e();){if(0===(e=this.Pa(t,n.key)))return n.value;e<0?n=n.left:0<e&&(n=n.right)}return null},h.e=function(){return this.xa.e()},h.count=function(){return this.xa.count()},h.Vc=function(){return this.xa.Vc()},h.jc=function(){return this.xa.jc()},h.ka=function(t){return this.xa.ka(t)},h.ac=function(t){return new Hc(this.xa,null,this.Pa,!1,t)},h.bc=function(t,e){return new Hc(this.xa,t,this.Pa,!1,e)},h.dc=function(t,e){return new Hc(this.xa,t,this.Pa,!0,e)},h.xf=function(t){return new Hc(this.xa,null,this.Pa,!0,t)},h=Kc.prototype,h.$=function(t,e,n,i,r){return new Kc(null!=t?t:this.key,null!=e?e:this.value,null!=n?n:this.color,null!=i?i:this.left,null!=r?r:this.right)},h.count=function(){return this.left.count()+1+this.right.count()},h.e=function(){return!1},h.ka=function(t){return this.left.ka(t)||t(this.key,this.value)||this.right.ka(t)},h.Vc=function(){return Lc(this).key},h.jc=function(){return this.right.e()?this.key:this.right.jc()},h.Sa=function(t,e,n){var i,r;return Mc(r=(i=n(t,(r=this).key))<0?r.$(null,null,null,r.left.Sa(t,e,n),null):0===i?r.$(null,e,null,null,null):r.$(null,null,null,null,r.right.Sa(t,e,n)))},h.remove=function(t,e){var n,i;if(e(t,(n=this).key)<0)n.left.e()||n.left.ha()||n.left.left.ha()||(n=Oc(n)),n=n.$(null,null,null,n.left.remove(t,e),null);else{if(n.left.ha()&&(n=Pc(n)),n.right.e()||n.right.ha()||n.right.left.ha()||(n=Qc(n)).left.left.ha()&&(n=Qc(n=Pc(n))),0===e(t,n.key)){if(n.right.e())return Fc;i=Lc(n.right),n=n.$(i.key,i.value,null,null,Nc(n.right))}n=n.$(null,null,null,null,n.right.remove(t,e))}return Mc(n)},h.ha=function(){return this.color},h=Sc.prototype,h.$=function(){return this},h.Sa=function(t,e){return new Kc(t,e,null)},h.remove=function(){return this},h.count=function(){return 0},h.e=function(){return!0},h.ka=function(){return!1},h.Vc=function(){return null},h.jc=function(){return null},h.ha=function(){return!1};var Fc=new Sc;function Tc(t,e){return t&&"object"==typeof t?(O(".sv"in t,"Unexpected leaf node or priority contents"),e[t[".sv"]]):t}function Uc(t,n){var i=new Vc;return Wc(t,new P(""),function(t,e){i.rc(t,Xc(e,n))}),i}function Xc(t,i){var r,e=Tc(e=t.C().J(),i);if(t.L()){var n=Tc(t.Ea(),i);return n!==t.Ea()||e!==t.C().J()?new Yc(n,Q(e)):t}return e!==(r=t).C().J()&&(r=r.ia(new Yc(e))),t.R(R,function(t,e){var n=Xc(e,i);n!==e&&(r=r.W(t,n))}),r}function Zc(){this.Ac={}}function $c(t){this.Ic=t,this.Sd="firebase:"}function ad(t){try{if("undefined"!=typeof window&&"undefined"!=typeof window[t]){var e=window[t];return e.setItem("firebase:sentinel","cache"),e.removeItem("firebase:sentinel"),new $c(e)}}catch(n){}return new Zc}Zc.prototype.set=function(t,e){null==e?delete this.Ac[t]:this.Ac[t]=e},Zc.prototype.get=function(t){return y(this.Ac,t)?this.Ac[t]:null},Zc.prototype.remove=function(t){delete this.Ac[t]},Zc.prototype.Af=!0,h=$c.prototype,h.set=function(t,e){null==e?this.Ic.removeItem(this.Sd+t):this.Ic.setItem(this.Sd+t,G(e))},h.get=function(t){return null==(t=this.Ic.getItem(this.Sd+t))?null:Rb(t)},h.remove=function(t){this.Ic.removeItem(this.Sd+t)},h.Af=!1,h.toString=function(){return this.Ic.toString()};var bd=ad("localStorage"),cd=ad("sessionStorage");function dd(t,e,n,i,r){this.host=t.toLowerCase(),this.domain=this.host.substr(this.host.indexOf(".")+1),this.ob=e,this.lc=n,this.jh=i,this.Rd=r||"",this.ab=bd.get("host:"+t)||this.host}function ed(t,e){e!==t.ab&&(t.ab=e,"s-"===t.ab.substr(0,2)&&bd.set("host:"+t.host,t.ab))}function fd(t,e,n){if(O("string"==typeof e,"typeof type must==string"),O("object"==typeof n,"typeof params must==object"),e===gd)e=(t.ob?"wss://":"ws://")+t.ab+"/.ws?";else{if(e!==hd)throw Error("Unknown connection type: "+e);e=(t.ob?"https://":"http://")+t.ab+"/.lp?"}t.host!==t.ab&&(n.ns=t.lc);var i=[];return v(n,function(t,e){i.push(e+"="+t)}),e+i.join("&")}dd.prototype.toString=function(){var t=(this.ob?"https://":"http://")+this.host;return this.Rd&&(t+="<"+this.Rd+">"),t};var id=(Ps=1,function(){return Ps++}),O=Kb,jd=Lb,Ps;function kd(t){try{var e;if("undefined"!=typeof atob)e=atob(t);else{ob();for(var n=mb,i=[],r=0;r<t.length;){var o=n[t.charAt(r++)],a=r<t.length?n[t.charAt(r)]:0,s=++r<t.length?n[t.charAt(r)]:64,h=++r<t.length?n[t.charAt(r)]:64;if(++r,null==o||null==a||null==s||null==h)throw Error();i.push(o<<2|a>>4),64!=s&&(i.push(a<<4&240|s>>2),64!=h&&i.push(s<<6&192|h))}if(i.length<8192)e=String.fromCharCode.apply(null,i);else{for(t="",n=0;n<i.length;n+=8192)t+=String.fromCharCode.apply(null,Ua(i,n,n+8192));e=t}}return e}catch(u){fc("base64Decode failed: ",u)}return null}function ld(t){var e=Ob(t);(t=new Ja).update(e);e=[];var n=8*t.ge;t.ec<56?t.update(t.Od,56-t.ec):t.update(t.Od,t.Ya-(t.ec-56));for(var i=t.Ya-1;56<=i;i--)t.pe[i]=255&n,n/=256;for(Ka(t,t.pe),i=n=0;i<5;i++)for(var r=24;0<=r;r-=8)e[n]=t.P[i]>>r&255,++n;return nb(e)}function md(t){for(var e="",n=0;n<arguments.length;n++)e=ea(arguments[n])?e+md.apply(null,arguments[n]):"object"==typeof arguments[n]?e+G(arguments[n]):e+arguments[n],e+=" ";return e}var ec=null,nd=!0;function od(t,e){Kb(!e||!0===t||!1===t,"Can't turn on custom loggers persistently."),!0===t?("undefined"!=typeof console&&("function"==typeof console.log?ec=u(console.log,console):"object"==typeof console.log&&(ec=function(t){console.log(t)})),e&&cd.set("logging_enabled",!0)):r(t)?ec=t:(ec=null,cd.remove("logging_enabled"))}function fc(t){if(!0===nd&&(nd=!1,null===ec&&!0===cd.get("logging_enabled")&&od(!0)),ec){var e=md.apply(null,arguments);ec(e)}}function pd(t){return function(){fc(t,arguments)}}function qd(t){if("undefined"!=typeof console){var e="FIREBASE INTERNAL ERROR: "+md.apply(null,arguments);"undefined"!=typeof console.error?console.error(e):console.log(e)}}function rd(t){var e=md.apply(null,arguments);throw Error("FIREBASE FATAL ERROR: "+e)}function S(t){if("undefined"!=typeof console){var e="FIREBASE WARNING: "+md.apply(null,arguments);"undefined"!=typeof console.warn?console.warn(e):console.log(e)}}function sd(t){var e="",n="",i="",r="",o=!0,a="https",s=443;if(q(t)){var h=t.indexOf("//");for(0<=h&&(a=t.substring(0,h-1),t=t.substring(h+2)),-1===(h=t.indexOf("/"))&&(h=t.length),e=t.substring(0,h),r="",t=t.substring(h).split("/"),h=0;h<t.length;h++)if(0<t[h].length){var u=t[h];try{u=decodeURIComponent(u.replace(/\+/g," "))}catch(c){}r+="/"+u}3===(t=e.split(".")).length?(n=t[1],i=t[0].toLowerCase()):2===t.length&&(n=t[0]),0<=(h=e.indexOf(":"))&&(o="https"===a||"wss"===a,s=e.substring(h+1),isFinite(s)&&(s=String(s)),s=q(s)?/^\s*-?0x/i.test(s)?parseInt(s,16):parseInt(s,10):NaN)}return{host:e,port:s,domain:n,fh:i,ob:o,scheme:a,bd:r}}function td(t){return fa(t)&&(t!=t||t==Number.POSITIVE_INFINITY||t==Number.NEGATIVE_INFINITY)}function ud(t){if("complete"===document.readyState)t();else{var e=!1,n=function(){document.body?e||(e=!0,t()):setTimeout(n,Math.floor(10))};document.addEventListener?(document.addEventListener("DOMContentLoaded",n,!1),window.addEventListener("load",n,!1)):document.attachEvent&&(document.attachEvent("onreadystatechange",function(){"complete"===document.readyState&&n()}),window.attachEvent("onload",n))}}function yc(t,e){if(t===e)return 0;if("[MIN_NAME]"===t||"[MAX_NAME]"===e)return-1;if("[MIN_NAME]"===e||"[MAX_NAME]"===t)return 1;var n=vd(t),i=vd(e);return null!==n?null!==i?0==n-i?t.length-e.length:n-i:-1:null!==i?1:t<e?-1:1}function wd(t,e){if(e&&t in e)return e[t];throw Error("Missing required key ("+t+") in object: "+G(e))}function xd(t){if("object"!=typeof t||null===t)return G(t);var e,n=[];for(e in t)n.push(e);n.sort(),e="{";for(var i=0;i<n.length;i++)0!==i&&(e+=","),e+=G(n[i]),e+=":",e+=xd(t[n[i]]);return e+"}"}function yd(t,e){if(t.length<=e)return[t];for(var n=[],i=0;i<t.length;i+=e)t<i+e?n.push(t.substring(i,t.length)):n.push(t.substring(i,i+e));return n}function zd(t,e){if(da(t))for(var n=0;n<t.length;++n)e(n,t[n]);else v(t,e)}function Ad(t){var e,n,i,r;for(O(!td(t),"Invalid JSON number"),0===t?(i=n=0,e=-Infinity==1/t?1:0):(e=t<0,i=(t=Math.abs(t))>=Math.pow(2,-1022)?(n=(i=Math.min(Math.floor(Math.log(t)/Math.LN2),1023))+1023,Math.round(t*Math.pow(2,52-i)-Math.pow(2,52))):(n=0,Math.round(t/Math.pow(2,-1074)))),r=[],t=52;t;--t)r.push(i%2?1:0),i=Math.floor(i/2);for(t=11;t;--t)r.push(n%2?1:0),n=Math.floor(n/2);for(r.push(e?1:0),r.reverse(),e=r.join(""),n="",t=0;t<64;t+=8)1===(i=parseInt(e.substr(t,8),2).toString(16)).length&&(i="0"+i),n+=i;return n.toLowerCase()}var Bd=/^-?\d{1,10}$/;function vd(t){return Bd.test(t)&&(-2147483648<=(t=Number(t))&&t<=2147483647)?t:null}function gc(t){try{t()}catch(e){setTimeout(function(){throw S("Exception was thrown by user callback.",e.stack||""),e},Math.floor(0))}}function T(t,e){if(r(t)){var n=Array.prototype.slice.call(arguments,1).slice();gc(function(){t.apply(null,n)})}}function Cd(t){var e={},n={},i={},r="";try{var o=t.split(".");e=Rb(kd(o[0])||""),n=Rb(kd(o[1])||""),r=o[2],i=n.d||{};delete n.d}catch(a){}return{mh:e,Ec:n,data:i,bh:r}}function Dd(t){return"object"==typeof(t=Cd(t).Ec)&&t.hasOwnProperty("iat")?z(t,"iat"):null}function Ed(t){var e=(t=Cd(t)).Ec;return!!t.bh&&!!e&&"object"==typeof e&&e.hasOwnProperty("iat")}function Fd(t){this.Y=t,this.g=t.n.g}function Gd(e,t,n,i){var r=[],o=[];return Ma(t,function(t){"child_changed"===t.type&&e.g.Dd(t.Oe,t.Na)&&o.push(new J("child_moved",t.Na,t.Za))}),Hd(e,r,"child_removed",t,i,n),Hd(e,r,"child_added",t,i,n),Hd(e,r,"child_moved",o,i,n),Hd(e,r,"child_changed",t,i,n),Hd(e,r,ic,t,i,n),r}function Hd(i,r,e,t,o,a){Va(t=Na(t,function(t){return t.type===e}),u(i.qg,i)),Ma(t,function(e){var n=Id(i,e,a);Ma(o,function(t){t.Qf(e.type)&&r.push(t.createEvent(n,i.Y))})})}function Id(t,e,n){return"value"!==e.type&&"child_removed"!==e.type&&(e.Td=n.wf(e.Za,e.Na,t.g)),e}function Jd(){this.ib={}}function Kd(t,e){var n=e.type,i=e.Za;O("child_added"==n||"child_changed"==n||"child_removed"==n,"Only child changes supported for tracking"),O(".priority"!==i,"Only non-priority child changes can be tracked.");var r=z(t.ib,i);if(r){var o=r.type;if("child_added"==n&&"child_removed"==o)t.ib[i]=new J("child_changed",e.Na,i,r.Na);else if("child_removed"==n&&"child_added"==o)delete t.ib[i];else if("child_removed"==n&&"child_changed"==o)t.ib[i]=new J("child_removed",r.Oe,i);else if("child_changed"==n&&"child_added"==o)t.ib[i]=new J("child_added",e.Na,i);else{if("child_changed"!=n||"child_changed"!=o)throw jd("Illegal combination of changes: "+e+" occurred after "+r);t.ib[i]=new J("child_changed",e.Na,i,r.Oe)}}else t.ib[i]=e}function Ld(t){this.g=t}function Md(t){var e;this.Fe=new Ld(t.g),this.g=t.g,e=t.oa?(e=Nd(t),t.g.Sc(Od(t),e)):t.g.Wc(),this.gd=e,t=t.ra?(e=Pd(t),t.g.Sc(Rd(t),e)):t.g.Tc(),this.Jc=t}function Sd(t){this.ua=new Md(t),this.g=t.g,O(t.la,"Only valid if limit has been set"),this.ma=t.ma,this.Nb=!Td(t)}function Ud(t,e,n,i,r,o){var a;if(t.Nb){var s=Vd(t.g);a=function(t,e){return s(e,t)}}else a=Vd(t.g);O(e.Hb()==t.ma,"");var h=new L(n,i),u=t.Nb?Wd(e,t.g):Xd(e,t.g),c=t.ua.matches(h);if(e.Fa(n)){var f=e.T(n);for(u=r.Ce(t.g,u,t.Nb);null!=u&&(u.name==n||e.Fa(u.name));)u=r.Ce(t.g,u,t.Nb);return r=null==u?1:a(u,h),c&&!i.e()&&0<=r?(null!=o&&Kd(o,new J("child_changed",i,n,f)),e.W(n,i)):(null!=o&&Kd(o,new J("child_removed",f,n)),e=e.W(n,H),null!=u&&t.ua.matches(u)?(null!=o&&Kd(o,new J("child_added",u.U,u.name)),e.W(u.name,u.U)):e)}return i.e()?e:c&&0<=a(u,h)?(null!=o&&(Kd(o,new J("child_removed",u.U,u.name)),Kd(o,new J("child_added",i,n))),e.W(n,i).W(u.name,H)):e}function Yd(t,e){this.me=t,this.og=e}function Zd(t){this.X=t}function ie(t,e,n,i,r,o){var a,s=e.Q;if(null!=i.xc(n))return e;if(n.e())O(lc(e.w()),"If change path is empty, we must have complete server data"),i=mc(e.w())?(r=Yb(e),i.Cc(r instanceof fe?r:H)):i.Aa(Yb(e)),o=t.X.ya(e.Q.j(),i,o);else{var h=K(n);if(".priority"==h)O(1==le(n),"Can't have a priority with additional path components"),o=s.j(),a=e.w().j(),o=null!=(i=i.nd(n,o,a))?t.X.ia(o,i):s.j();else{var u=N(n);o=null!=(i=Wb(s,h)?(a=e.w().j(),null!=(i=i.nd(n,s.j(),a))?s.j().T(h).H(u,i):s.j().T(h)):i.Bc(h,e.w()))?t.X.H(s.j(),h,i,u,r,o):s.j()}}return ge(e,o,s.ga||n.e(),t.X.Ra())}function ae(t,e,n,i,r,o,a,s){var h=e.w();if(a=a?t.X:t.X.$b(),n.e())i=a.ya(h.j(),i,null);else if(a.Ra()&&!h.Yb)i=h.j().H(n,i),i=a.ya(h.j(),i,null);else{var u=K(n);if(!nc(h,n)&&1<le(n))return e;var c=N(n);i=h.j().T(u).H(c,i),i=".priority"==u?a.ia(h.j(),i):a.H(h.j(),u,i,c,Ub,null)}return h=h.ga||n.e(),ie(t,e=new je(e.Q,new Xb(i,h,a.Ra())),n,r,new Vb(r,e,o),s)}function $d(t,e,n,i,r,o,a){var s=e.Q;if(r=new Vb(r,e,o),n.e())a=t.X.ya(e.Q.j(),i,a),t=ge(e,a,!0,t.X.Ra());else if(".priority"===(o=K(n)))a=t.X.ia(e.Q.j(),i),t=ge(e,a,s.ga,s.Yb);else{n=N(n);var h=s.j().T(o);if(!n.e()){var u=r.uf(o);i=null!=u?".priority"===me(n)&&u.S(n.parent()).e()?u:u.H(n,i):H}t=h.ea(i)?e:ge(e,a=t.X.H(s.j(),o,i,n,r,a),s.ga,t.X.Ra())}return t}function ce(i,r,o,t,a,s,h){var u=r;return ne(t,function(t,e){var n=o.o(t);Wb(r.Q,K(n))&&(u=$d(i,u,n,e,a,s,h))}),ne(t,function(t,e){var n=o.o(t);Wb(r.Q,K(n))||(u=$d(i,u,n,e,a,s,h))}),u}function oe(n,t){return ne(t,function(t,e){n=n.H(t,e)}),n}function de(i,r,t,e,o,a,s,h){if(r.w().j().e()&&!lc(r.w()))return r;var u=r;t=t.e()?e:pe(qe,t,e);var c=r.w().j();return t.children.ka(function(t,e){if(c.Fa(t)){var n=oe(n=r.w().j().T(t),e);u=ae(i,u,new P(t),n,o,a,s,h)}}),t.children.ka(function(t,e){var n=!Wb(r.w(),t)&&null==e.value;c.Fa(t)||n||(n=oe(n=r.w().j().T(t),e),u=ae(i,u,new P(t),n,o,a,s,h))}),u}function he(t,e,n,i,r,o,a){if(null!=r.xc(n))return e;var s=mc(e.w()),h=e.w();if(null==i.value)return u=qe,ne(i,function(t){var e=n.o(t);nc(h,e)&&(u=u.set(t,h.j().S(e)))}),de(t,e,n,u,r,o,s,a);if(n.e()&&h.ga||nc(h,n))return ae(t,e,n,h.j().S(n),r,o,s,a);if(n.e()){var u=qe;return h.j().R(re,function(t,e){u=u.set(new P(t),e)}),de(t,e,n,u,r,o,s,a)}return e}function se(){}Fd.prototype.qg=function(t,e){if(null==t.Za||null==e.Za)throw jd("Should only compare child_ events.");return this.g.compare(new L(t.Za,t.Na),new L(e.Za,e.Na))},h=Ld.prototype,h.H=function(t,e,n,i,r,o){return O(t.Mc(this.g),"A node must be indexed if only a child is updated"),(r=t.T(e)).S(i).ea(n.S(i))&&r.e()==n.e()?t:(null!=o&&(n.e()?t.Fa(e)?Kd(o,new J("child_removed",r,e)):O(t.L(),"A child remove without an old child only makes sense on a leaf node"):r.e()?Kd(o,new J("child_added",n,e)):Kd(o,new J("child_changed",n,e,r))),t.L()&&n.e()?t:t.W(e,n).pb(this.g))},h.ya=function(i,n,r){return null!=r&&(i.L()||i.R(R,function(t,e){n.Fa(t)||Kd(r,new J("child_removed",e,t))}),n.L()||n.R(R,function(t,e){if(i.Fa(t)){var n=i.T(t);n.ea(e)||Kd(r,new J("child_changed",e,t,n))}else Kd(r,new J("child_added",e,t))})),n.pb(this.g)},h.ia=function(t,e){return t.e()?H:t.ia(e)},h.Ra=function(){return!1},h.$b=function(){return this},h=Md.prototype,h.matches=function(t){return this.g.compare(this.gd,t)<=0&&this.g.compare(t,this.Jc)<=0},h.H=function(t,e,n,i,r,o){return this.matches(new L(e,n))||(n=H),this.Fe.H(t,e,n,i,r,o)},h.ya=function(t,e,n){e.L()&&(e=H);var i=(i=e.pb(this.g)).ia(H),r=this;return e.R(R,function(t,e){r.matches(new L(t,e))||(i=i.W(t,H))}),this.Fe.ya(t,i,n)},h.ia=function(t){return t},h.Ra=function(){return!0},h.$b=function(){return this.Fe},h=Sd.prototype,h.H=function(t,e,n,i,r,o){return this.ua.matches(new L(e,n))||(n=H),t.T(e).ea(n)?t:t.Hb()<this.ma?this.ua.$b().H(t,e,n,i,r,o):Ud(this,t,e,n,r,o)},h.ya=function(t,e,n){var i;if(e.L()||e.e())i=H.pb(this.g);else if(2*this.ma<e.Hb()&&e.Mc(this.g)){i=H.pb(this.g),e=this.Nb?e.dc(this.ua.Jc,this.g):e.bc(this.ua.gd,this.g);for(var r=0;0<e.Ta.length&&r<this.ma;){var o=Ic(e);if(!(this.Nb?this.g.compare(this.ua.gd,o)<=0:this.g.compare(o,this.ua.Jc)<=0))break;i=i.W(o.name,o.U),r++}}else{var a,s,h;if(i=(i=e.pb(this.g)).ia(H),this.Nb){e=i.xf(this.g),a=this.ua.Jc,s=this.ua.gd;var u=Vd(this.g);h=function(t,e){return u(e,t)}}else e=i.ac(this.g),a=this.ua.gd,s=this.ua.Jc,h=Vd(this.g);r=0;for(var c=!1;0<e.Ta.length;)o=Ic(e),!c&&h(a,o)<=0&&(c=!0),c&&r<this.ma&&h(o,s)<=0?r++:i=i.W(o.name,H)}return this.ua.$b().ya(t,i,n)},h.ia=function(t){return t},h.Ra=function(){return!0},h.$b=function(){return this.ua.$b()},Zd.prototype.gb=function(t,e,n,i){var r,o=new Jd;if(e.type===Bc)n=e.source.Ae?$d(this,t,e.path,e.Ja,n,i,o):(O(e.source.tf,"Unknown source."),r=e.source.ef||mc(t.w())&&!e.path.e(),ae(this,t,e.path,e.Ja,n,i,r,o));else if(e.type===be)n=e.source.Ae?ce(this,t,e.path,e.children,n,i,o):(O(e.source.tf,"Unknown source."),r=e.source.ef||mc(t.w()),de(this,t,e.path,e.children,n,i,r,o));else if(e.type===ee)if(e.Yd)if(e=e.path,null!=n.xc(e))n=t;else{if(r=new Vb(n,t,i),i=t.Q.j(),e.e()||".priority"===K(e))e=lc(t.w())?n.Aa(Yb(t)):(e=t.w().j(),O(e instanceof fe,"serverChildren would be complete if leaf node"),n.Cc(e)),e=this.X.ya(i,e,o);else{var a=K(e),s=n.Bc(a,t.w());null==s&&Wb(t.w(),a)&&(s=i.T(a)),(e=null!=s?this.X.H(i,a,s,N(e),r,o):t.Q.j().Fa(a)?this.X.H(i,a,H,N(e),r,o):i).e()&&lc(t.w())&&((i=n.Aa(Yb(t))).L()&&(e=this.X.ya(e,i,o)))}i=lc(t.w())||null!=n.xc(M),n=ge(t,e,i,this.X.Ra())}else n=he(this,t,e.path,e.Ub,n,i,o);else{if(e.type!==Dc)throw jd("Unknown operation type: "+e.type);i=e.path,r=(e=t.w()).j(),a=e.ga||i.e(),n=ie(this,new je(t.Q,new Xb(r,a,e.Yb)),i,n,Ub,o)}return o=qa(o.ib),(e=(i=n).Q).ga&&(r=e.j().L()||e.j().e(),a=ke(t),(0<o.length||!t.Q.ga||r&&!e.j().ea(a)||!e.j().C().ea(a.C()))&&o.push(hc(ke(i)))),new Yd(n,o)};var te={};function Vd(t){return u(t.compare,t)}function ve(t){O(!t.e()&&".priority"!==K(t),"Can't create PathIndex with empty path or .priority key"),this.gc=t}function xe(){}se.prototype.Dd=function(t,e){return 0!==this.compare(new L("[MIN_NAME]",t),new L("[MIN_NAME]",e))},se.prototype.Wc=function(){return ue},ka(ve,se),h=ve.prototype,h.Lc=function(t){return!t.S(this.gc).e()},h.compare=function(t,e){var n=t.U.S(this.gc),i=e.U.S(this.gc);return 0===(n=n.Gc(i))?yc(t.name,e.name):n},h.Sc=function(t,e){var n=Q(t);return new L(e,n=H.H(this.gc,n))},h.Tc=function(){return new L("[MAX_NAME]",H.H(this.gc,we))},h.toString=function(){return this.gc.slice().join("/")},ka(xe,se),h=xe.prototype,h.compare=function(t,e){var n=t.U.C(),i=e.U.C();return 0===(n=n.Gc(i))?yc(t.name,e.name):n},h.Lc=function(t){return!t.C().e()},h.Dd=function(t,e){return!t.C().ea(e.C())},h.Wc=function(){return ue},h.Tc=function(){return new L("[MAX_NAME]",new Yc("[PRIORITY-POST]",we))},h.Sc=function(t,e){return new L(e,new Yc("[PRIORITY-POST]",Q(t)))},h.toString=function(){return".priority"};var R=new xe;function ye(){}ka(ye,se),h=ye.prototype,h.compare=function(t,e){return yc(t.name,e.name)},h.Lc=function(){throw jd("KeyIndex.isDefinedOn not expected to be called.")},h.Dd=function(){return!1},h.Wc=function(){return ue},h.Tc=function(){return new L("[MAX_NAME]",H)},h.Sc=function(t){return O(q(t),"KeyIndex indexValue must always be a string."),new L(t,H)},h.toString=function(){return".key"};var re=new ye;function ze(){}ka(ze,se),h=ze.prototype,h.compare=function(t,e){var n=t.U.Gc(e.U);return 0===n?yc(t.name,e.name):n},h.Lc=function(){return!0},h.Dd=function(t,e){return!t.ea(e)},h.Wc=function(){return ue},h.Tc=function(){return Ae},h.Sc=function(t,e){return new L(e,Q(t))},h.toString=function(){return".value"};var Be=new ze;function Ce(){this.Xb=this.ra=this.Pb=this.oa=this.la=!1,this.ma=0,this.Rb="",this.ic=null,this.Bb="",this.fc=null,this.zb="",this.g=R}var De=new Ce;function Td(t){return""===t.Rb?t.oa:"l"===t.Rb}function Od(t){return O(t.oa,"Only valid if start has been set"),t.ic}function Nd(t){return O(t.oa,"Only valid if start has been set"),t.Pb?t.Bb:"[MIN_NAME]"}function Rd(t){return O(t.ra,"Only valid if end has been set"),t.fc}function Pd(t){return O(t.ra,"Only valid if end has been set"),t.Xb?t.zb:"[MAX_NAME]"}function Ee(t){var e=new Ce;return e.la=t.la,e.ma=t.ma,e.oa=t.oa,e.ic=t.ic,e.Pb=t.Pb,e.Bb=t.Bb,e.ra=t.ra,e.fc=t.fc,e.Xb=t.Xb,e.zb=t.zb,e.g=t.g,e}function Fe(t,e){var n=Ee(t);return n.g=e,n}function Ge(t){var e={};if(t.oa&&(e.sp=t.ic,t.Pb&&(e.sn=t.Bb)),t.ra&&(e.ep=t.fc,t.Xb&&(e.en=t.zb)),t.la){e.l=t.ma;var n=t.Rb;""===n&&(n=Td(t)?"l":"r"),e.vf=n}return t.g!==R&&(e.i=t.g.toString()),e}function He(t){return!(t.oa||t.ra||t.la)}function Ie(t){return He(t)&&t.g==R}function Je(t){var e,n={};return Ie(t)||(e=t.g===R?"$priority":t.g===Be?"$value":t.g===re?"$key":(O(t.g instanceof ve,"Unrecognized index type!"),t.g.toString()),n.orderBy=G(e),t.oa&&(n.startAt=G(t.ic),t.Pb&&(n.startAt+=","+G(t.Bb))),t.ra&&(n.endAt=G(t.fc),t.Xb&&(n.endAt+=","+G(t.zb))),t.la&&(Td(t)?n.limitToFirst=t.ma:n.limitToLast=t.ma)),n}function Ke(t,e){this.Ed=t,this.hc=e}function Le(a,s,h){return new Ke(ma(a.Ed,function(t,e){var n=z(a.hc,e);if(O(n,"Missing index implementation for "+e),t!==te)return i=t,(n=h.get(s.name))&&(i=i.remove(new L(s.name,n))),i.Sa(s,s.U);if(n.Lc(s.U)){for(var i=[],r=h.ac(wc),o=Ic(r);o;)o.name!=s.name&&i.push(o),o=Ic(r);return i.push(s),Me(i,Vd(n))}return te}),a.hc)}function Ne(t,n,i){return new Ke(ma(t.Ed,function(t){if(t===te)return t;var e=i.get(n.name);return e?t.remove(new L(n.name,e)):t}),t.hc)}h=Ce.prototype,h.Le=function(t){var e=Ee(this);return e.la=!0,e.ma=t,e.Rb="",e},h.Me=function(t){var e=Ee(this);return e.la=!0,e.ma=t,e.Rb="l",e},h.Ne=function(t){var e=Ee(this);return e.la=!0,e.ma=t,e.Rb="r",e},h.ce=function(t,e){var n=Ee(this);return n.oa=!0,p(t)||(t=null),n.ic=t,null!=e?(n.Pb=!0,n.Bb=e):(n.Pb=!1,n.Bb=""),n},h.vd=function(t,e){var n=Ee(this);return n.ra=!0,p(t)||(t=null),n.fc=t,p(e)?(n.Xb=!0,n.zb=e):(n.oh=!1,n.zb=""),n},h.toString=function(){return G(Ge(this))},Ke.prototype.get=function(t){var e=z(this.Ed,t);if(!e)throw Error("No index defined for "+t);return e===te?null:e};var Oe=new Ke({".priority":te},{".priority":R});function Yc(t,e){this.B=t,O(p(this.B)&&null!==this.B,"LeafNode shouldn't be created with null/undefined value."),this.ca=e||H,Pe(this.ca),this.Gb=null}var Qe=["object","boolean","number","string"];function fe(t,e,n){this.m=t,(this.ca=e)&&Pe(this.ca),t.e()&&O(!this.ca||this.ca.e(),"An empty node cannot have a priority"),this.Ab=n,this.Gb=null}h=Yc.prototype,h.L=function(){return!0},h.C=function(){return this.ca},h.ia=function(t){return new Yc(this.B,t)},h.T=function(t){return".priority"===t?this.ca:H},h.S=function(t){return t.e()?this:".priority"===K(t)?this.ca:H},h.Fa=function(){return!1},h.wf=function(){return null},h.W=function(t,e){return".priority"===t?this.ia(e):e.e()&&".priority"!==t?this:H.W(t,e).ia(this.ca)},h.H=function(t,e){var n=K(t);return null===n?e:e.e()&&".priority"!==n?this:(O(".priority"!==n||1===le(t),".priority must be the last token in a path"),this.W(n,H.H(N(t),e)))},h.e=function(){return!1},h.Hb=function(){return 0},h.R=function(){return!1},h.J=function(t){return t&&!this.C().e()?{".value":this.Ea(),".priority":this.C().J()}:this.Ea()},h.hash=function(){if(null===this.Gb){var t="";this.ca.e()||(t+="priority:"+Re(this.ca.J())+":");var e=typeof this.B;t=t+e+":",t="number"==e?t+Ad(this.B):t+this.B;this.Gb=ld(t)}return this.Gb},h.Ea=function(){return this.B},h.Gc=function(t){if(t===H)return 1;if(t instanceof fe)return-1;O(t.L(),"Unknown node type");var e=typeof t.B,n=typeof this.B,i=La(Qe,e),r=La(Qe,n);return O(0<=i,"Unknown leaf type: "+e),O(0<=r,"Unknown leaf type: "+n),i===r?"object"==n?0:this.B<t.B?-1:this.B===t.B?0:1:r-i},h.pb=function(){return this},h.Mc=function(){return!0},h.ea=function(t){return t===this||!!t.L()&&(this.B===t.B&&this.ca.ea(t.ca))},h.toString=function(){return G(this.J(!0))},h=fe.prototype,h.L=function(){return!1},h.C=function(){return this.ca||H},h.ia=function(t){return this.m.e()?this:new fe(this.m,t,this.Ab)},h.T=function(t){return".priority"===t?this.C():null===(t=this.m.get(t))?H:t},h.S=function(t){var e=K(t);return null===e?this:this.T(e).S(N(t))},h.Fa=function(t){return null!==this.m.get(t)},h.W=function(t,e){if(O(e,"We should always be passing snapshot nodes"),".priority"===t)return this.ia(e);var n,i,r=new L(t,e);return r=e.e()?(n=this.m.remove(t),Ne(this.Ab,r,this.m)):(n=this.m.Sa(t,e),Le(this.Ab,r,this.m)),i=n.e()?H:this.ca,new fe(n,i,r)},h.H=function(t,e){var n=K(t);if(null===n)return e;O(".priority"!==K(t)||1===le(t),".priority must be the last token in a path");var i=this.T(n).H(N(t),e);return this.W(n,i)},h.e=function(){return this.m.e()},h.Hb=function(){return this.m.count()};var Se=/^(0|[1-9]\d*)$/;function Wd(t,e){var n;return(n=(n=Te(t,e))?(n=n.Vc())&&n.name:t.m.Vc())?new L(n,t.m.get(n)):null}function Xd(t,e){var n;return(n=(n=Te(t,e))?(n=n.jc())&&n.name:t.m.jc())?new L(n,t.m.get(n)):null}function Te(t,e){return e===re?null:t.Ab.get(e.toString())}function Q(t,e){if(null===t)return H;var n=null;if("object"==typeof t&&".priority"in t?n=t[".priority"]:void 0!==e&&(n=e),O(null===n||"string"==typeof n||"number"==typeof n||"object"==typeof n&&".sv"in n,"Invalid priority type found: "+typeof n),"object"==typeof t&&".value"in t&&null!==t[".value"]&&(t=t[".value"]),"object"!=typeof t||".sv"in t)return new Yc(t,Q(n));if(t instanceof Array){var i=H,r=t;return v(r,function(t,e){if(y(r,e)&&"."!==e.substring(0,1)){var n=Q(t);!n.L()&&n.e()||(i=i.W(e,n))}}),i.ia(Q(n))}var o=[],a=!1,s=t;if(Fb(s,function(t){if("string"!=typeof t||"."!==t.substring(0,1)){var e=Q(s[t]);e.e()||(a=a||!e.C().e(),o.push(new L(t,e)))}}),0==o.length)return H;var h=Me(o,xc,function(t){return t.name},zc);if(a){var u=Me(o,Vd(R));return new fe(h,Q(n),new Ke({".priority":u},{".priority":R}))}return new fe(h,Q(n),Oe)}h=fe.prototype,h.J=function(n){if(this.e())return null;var i={},r=0,o=0,a=!0;if(this.R(R,function(t,e){i[t]=e.J(n),r++,a&&Se.test(t)?o=Math.max(o,Number(t)):a=!1}),!n&&a&&o<2*r){var t,e=[];for(t in i)e[t]=i[t];return e}return n&&!this.C().e()&&(i[".priority"]=this.C().J()),i},h.hash=function(){if(null===this.Gb){var i="";this.C().e()||(i+="priority:"+Re(this.C().J())+":"),this.R(R,function(t,e){var n=e.hash();""!==n&&(i+=":"+t+":"+n)}),this.Gb=""===i?"":ld(i)}return this.Gb},h.wf=function(t,e,n){return(n=Te(this,n))?(t=Gc(n,new L(t,e)))?t.name:null:Gc(this.m,t)},h.R=function(t,e){var n=Te(this,t);return n?n.ka(function(t){return e(t.name,t.U)}):this.m.ka(e)},h.ac=function(t){return this.bc(t.Wc(),t)},h.bc=function(t,e){if(n=Te(this,e))return n.bc(t,function(t){return t});for(var n,i=Jc(n=this.m.bc(t.name,wc));null!=i&&e.compare(i,t)<0;)Ic(n),i=Jc(n);return n},h.xf=function(t){return this.dc(t.Tc(),t)},h.dc=function(t,e){if(n=Te(this,e))return n.dc(t,function(t){return t});for(var n,i=Jc(n=this.m.dc(t.name,wc));null!=i&&0<e.compare(i,t);)Ic(n),i=Jc(n);return n},h.Gc=function(t){return this.e()?t.e()?0:-1:t.L()||t.e()?1:t===we?-1:0},h.pb=function(t){if(t===re||sa(this.Ab.hc,t.toString()))return this;var e=this.Ab,n=this.m;O(t!==re,"KeyIndex always exists and isn't meant to be added to the IndexMap.");for(var i=[],r=!1,o=Ic(n=n.ac(wc));o;)r=r||t.Lc(o.U),i.push(o),o=Ic(n);return i=r?Me(i,Vd(t)):te,r=t.toString(),(n=wa(e.hc))[r]=t,(t=wa(e.Ed))[r]=i,new fe(this.m,this.ca,new Ke(t,n))},h.Mc=function(t){return t===re||sa(this.Ab.hc,t.toString())},h.ea=function(t){if(t===this)return!0;if(t.L())return!1;if(this.C().ea(t.C())&&this.m.count()===t.m.count()){var e=this.ac(R);t=t.ac(R);for(var n=Ic(e),i=Ic(t);n&&i;){if(n.name!==i.name||!n.U.ea(i.U))return!1;n=Ic(e),i=Ic(t)}return null===n&&null===i}return!1},h.toString=function(){return G(this.J(!0))};var Ue=Math.log(2);function Ve(t){this.count=parseInt(Math.log(t+1)/Ue,10),this.nf=this.count-1,this.ng=t+1&parseInt(Array(this.count+1).join("1"),2)}function We(t){var e=!(t.ng&1<<t.nf);return t.nf--,e}function Me(h,t,u,e){h.sort(t);var n=function(t){function e(t,e){var n=s-t,i=s;s-=t;i=function o(t,e){if(0==(i=e-t))return null;if(1==i){var n=h[t];return new Kc(u?u(n):n,n.U,!1,null,null)}var i=o(t,n=parseInt(i/2,10)+t),r=o(n+1,e);n=h[n];return new Kc(u?u(n):n,n.U,!1,i,r)}(n+1,i),n=h[n],i=new Kc(u?u(n):n,n.U,e,null,i);r?r.left=i:a=i,r=i}for(var r=null,a=null,s=h.length,n=0;n<t.count;++n){var i=We(t),o=Math.pow(2,t.count-(n+1));i?e(o,!1):(e(o,!1),e(o,!0))}return a}(new Ve(h.length));return null!==n?new Ec(e||t,n):new Ec(e||t)}function Re(t){return"number"==typeof t?"number:"+Ad(t):"string:"+t}function Pe(t){if(t.L()){var e=t.J();O("string"==typeof e||"number"==typeof e||"object"==typeof e&&y(e,".sv"),"Priority must be a string or number.")}else O(t===we||t.e(),"priority of unexpected type.");O(t===we||t.C().e(),"Priority nodes can't have a priority of their own.")}var H=new fe(new Ec(zc),null,Oe);function Xe(){fe.call(this,new Ec(zc),H,Oe)}ka(Xe,fe),h=Xe.prototype,h.Gc=function(t){return t===this?0:1},h.ea=function(t){return t===this},h.C=function(){return this},h.T=function(){return H},h.e=function(){return!1};var we=new Xe,ue=new L("[MIN_NAME]",H),Ae=new L("[MAX_NAME]",we);function je(t,e){this.Q=t,this.ae=e}function ge(t,e,n,i){return new je(new Xb(e,n,i),t.ae)}function ke(t){return t.Q.ga?t.Q.j():null}function Yb(t){return t.ae.ga?t.ae.j():null}function Ye(t,e){var n=new Ld((i=(this.Y=t).n).g),i=He(i)?new Ld(i.g):i.la?new Sd(i):new Md(i);this.Nf=new Zd(i);var r=e.w(),o=e.Q,a=n.ya(H,r.j(),null),s=i.ya(H,o.j(),null);this.Oa=new je(new Xb(s,o.ga,i.Ra()),new Xb(a,r.ga,n.Ra())),this.$a=[],this.ug=new Fd(t)}function Ze(t){return t.Y}function af(t,e){var n=t.Oa.Q,i=[];return n.j().L()||n.j().R(R,function(t,e){i.push(new J("child_added",e,t))}),n.ga&&i.push(hc(n.j())),$e(t,i,n.j(),e)}function $e(t,e,n,i){return Gd(t.ug,e,n,i?[i]:t.$a)}function bf(t,e,n){this.type=be,this.source=t,this.path=e,this.children=n}function cf(t,e){this.f=pd("p:rest:"),this.G=t,this.Kb=e,this.Ca=null,this.ba={}}function df(t,e){return p(e)?"tag$"+e:(O(Ie(t.n),"should have a tag if it's not a default query."),t.path.toString())}function ef(e,t,n,i){(n=n||{}).format="export",e.Ca&&(n.auth=e.Ca);var r=(e.G.ob?"https://":"http://")+e.G.host+t+"?"+Ib(n);e.f("Sending REST request for "+r);var o=new XMLHttpRequest;o.onreadystatechange=function(){if(i&&4===o.readyState){e.f("REST Response for "+r+" received. status:",o.status,"response:",o.responseText);var t=null;if(200<=o.status&&o.status<300){try{t=Rb(o.responseText)}catch(n){S("Failed to parse JSON response for "+r+": "+o.responseText)}i(null,t)}else 401!==o.status&&404!==o.status&&S("Got unsuccessful REST response for "+r+" Status: "+o.status),i(o.status);i=null}},o.open("GET",r,!0),o.send()}function ff(t){O(da(t)&&0<t.length,"Requires a non-empty array"),this.fg=t,this.Rc={}}function gf(t,e){O(Ra(t.fg,function(t){return t===e}),"Unknown event: "+e)}je.prototype.w=function(){return this.ae},h=Ye.prototype,h.w=function(){return this.Oa.w().j()},h.kb=function(t){var e=Yb(this.Oa);return e&&(He(this.Y.n)||!t.e()&&!e.T(K(t)).e())?e.S(t):null},h.e=function(){return 0===this.$a.length},h.Tb=function(t){this.$a.push(t)},h.nb=function(t,e){var n=[];if(e){O(null==t,"A cancel should cancel all event registrations.");var i=this.Y.path;Ma(this.$a,function(t){(t=t.lf(e,i))&&n.push(t)})}if(t){for(var r=[],o=0;o<this.$a.length;++o){var a=this.$a[o];if(a.matches(t)){if(t.yf()){r=r.concat(this.$a.slice(o+1));break}}else r.push(a)}this.$a=r}else this.$a=[];return n},h.gb=function(t,e,n){t.type===be&&null!==t.source.Lb&&(O(Yb(this.Oa),"We should always have a full cache before handling merges"),O(ke(this.Oa),"Missing event cache, even though we have a server cache"));var i=this.Oa;return t=this.Nf.gb(i,t,e,n),e=this.Nf,n=t.me,O(n.Q.j().Mc(e.X.g),"Event snap not indexed"),O(n.w().j().Mc(e.X.g),"Server snap not indexed"),O(lc(t.me.w())||!lc(i.w()),"Once a server snap is complete, it should never go back"),this.Oa=t.me,$e(this,t.og,t.me.Q.j(),null)},bf.prototype.$c=function(t){return this.path.e()?(t=this.children.subtree(new P(t))).e()?null:t.value?new Ac(this.source,M,t.value):new bf(this.source,M,t):(O(K(this.path)===t,"Can't get a merge for a child not on the path of the operation"),new bf(this.source,N(this.path),this.children))},bf.prototype.toString=function(){return"Operation("+this.path+": "+this.source.toString()+" merge: "+this.children.toString()+")"},h=cf.prototype,h.Cf=function(t,e,i,r){var o=t.path.toString();this.f("Listen called for "+o+" "+t.wa());var a=df(t,i),s={};this.ba[a]=s,t=Je(t.n);var h=this;ef(this,o+".json",t,function(t,e){var n=e;404===t&&(t=n=null),null===t&&h.Kb(o,n,!1,i),z(h.ba,a)===s&&r(t?401==t?"permission_denied":"rest_error:"+t:"ok",null)})},h.$f=function(t,e){var n=df(t,e);delete this.ba[n]},h.O=function(t,e){var n=(i=Cd(this.Ca=t)).data,i=i.Ec&&i.Ec.exp;e&&e("ok",{auth:n,expires:i})},h.je=function(t){t("ok",this.Ca=null)},h.Qe=function(){},h.Gf=function(){},h.Md=function(){},h.put=function(){},h.Df=function(){},h.Ye=function(){},ff.prototype.ie=function(t,e){var n,i=(n=this.Rc[t]||[]).length;if(0<i){for(var r=Array(i),o=0;o<i;o++)r[o]=n[o];n=r}else n=[];for(i=0;i<n.length;i++)n[i].Dc.apply(n[i].Qa,Array.prototype.slice.call(arguments,1))},ff.prototype.Ib=function(t,e,n){gf(this,t),this.Rc[t]=this.Rc[t]||[],this.Rc[t].push({Dc:e,Qa:n}),(t=this.Ee(t))&&e.apply(n,t)},ff.prototype.mc=function(t,e,n){gf(this,t),t=this.Rc[t]||[];for(var i=0;i<t.length;i++)if(t[i].Dc===e&&(!n||n===t[i].Qa)){t.splice(i,1);break}};var hf=(ND=0,OD=[],function(t){var e=t===ND;ND=t;for(var n=Array(8),i=7;0<=i;i--)n[i]="-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz".charAt(t%64),t=Math.floor(t/64);if(O(0===t,"Cannot push at time==0"),t=n.join(""),e){for(i=11;0<=i&&63===OD[i];i--)OD[i]=0;OD[i]++}else for(i=0;i<12;i++)OD[i]=Math.floor(64*Math.random());for(i=0;i<12;i++)t+="-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz".charAt(OD[i]);return O(20===t.length,"nextPushId: Length should be 20."),t}),ND,OD;function jf(){if(ff.call(this,["online"]),this.oc=!0,"undefined"!=typeof window&&"undefined"!=typeof window.addEventListener){var t=this;window.addEventListener("online",function(){t.oc||(t.oc=!0,t.ie("online",!0))},!1),window.addEventListener("offline",function(){t.oc&&(t.oc=!1,t.ie("online",!1))},!1)}}function kf(){var e,t;if(ff.call(this,["visible"]),"undefined"!=typeof document&&"undefined"!=typeof document.addEventListener&&("undefined"!=typeof document.hidden?(t="visibilitychange",e="hidden"):"undefined"!=typeof document.mozHidden?(t="mozvisibilitychange",e="mozHidden"):"undefined"!=typeof document.msHidden?(t="msvisibilitychange",e="msHidden"):"undefined"!=typeof document.webkitHidden&&(t="webkitvisibilitychange",e="webkitHidden")),this.Sb=!0,t){var n=this;document.addEventListener(t,function(){var t=!document[e];t!==n.Sb&&(n.Sb=t,n.ie("visible",t))},!1)}}function P(t,e){if(1==arguments.length){this.u=t.split("/");for(var n=0,i=0;i<this.u.length;i++)0<this.u[i].length&&(this.u[n]=this.u[i],n++);this.u.length=n,this.aa=0}else this.u=t,this.aa=e}function lf(t,e){var n=K(t);if(null===n)return e;if(n===K(e))return lf(N(t),N(e));throw Error("INTERNAL ERROR: innerPath ("+e+") is not within outerPath ("+t+")")}function mf(t,e){for(var n=t.slice(),i=e.slice(),r=0;r<n.length&&r<i.length;r++){var o=yc(n[r],i[r]);if(0!==o)return o}return n.length===i.length?0:n.length<i.length?-1:1}function K(t){return t.aa>=t.u.length?null:t.u[t.aa]}function le(t){return t.u.length-t.aa}function N(t){var e=t.aa;return e<t.u.length&&e++,new P(t.u,e)}function me(t){return t.aa<t.u.length?t.u[t.u.length-1]:null}ka(jf,ff),jf.prototype.Ee=function(t){return O("online"===t,"Unknown event type: "+t),[this.oc]},ba(jf),ka(kf,ff),kf.prototype.Ee=function(t){return O("visible"===t,"Unknown event type: "+t),[this.Sb]},ba(kf),h=P.prototype,h.toString=function(){for(var t="",e=this.aa;e<this.u.length;e++)""!==this.u[e]&&(t+="/"+this.u[e]);return t||"/"},h.slice=function(t){return this.u.slice(this.aa+(t||0))},h.parent=function(){if(this.aa>=this.u.length)return null;for(var t=[],e=this.aa;e<this.u.length-1;e++)t.push(this.u[e]);return new P(t,0)},h.o=function(t){for(var e=[],n=this.aa;n<this.u.length;n++)e.push(this.u[n]);if(t instanceof P)for(n=t.aa;n<t.u.length;n++)e.push(t.u[n]);else for(t=t.split("/"),n=0;n<t.length;n++)0<t[n].length&&e.push(t[n]);return new P(e,0)},h.e=function(){return this.aa>=this.u.length},h.ea=function(t){if(le(this)!==le(t))return!1;for(var e=this.aa,n=t.aa;e<=this.u.length;e++,n++)if(this.u[e]!==t.u[n])return!1;return!0},h.contains=function(t){var e=this.aa,n=t.aa;if(le(this)>le(t))return!1;for(;e<this.u.length;){if(this.u[e]!==t.u[n])return!1;++e,++n}return!0};var M=new P("");function nf(t,e){this.Ua=t.slice(),this.Ka=Math.max(1,this.Ua.length),this.pf=e;for(var n=0;n<this.Ua.length;n++)this.Ka+=Pb(this.Ua[n]);of(this)}function of(t){if(768<t.Ka)throw Error(t.pf+"has a key path longer than 768 bytes ("+t.Ka+").");if(32<t.Ua.length)throw Error(t.pf+"path specified exceeds the maximum depth that can be written (32) or object contains a cycle "+pf(t))}function pf(t){return 0==t.Ua.length?"":"in property '"+t.Ua.join(".")+"'"}function qf(t,e){this.value=t,this.children=e||rf}nf.prototype.push=function(t){0<this.Ua.length&&(this.Ka+=1),this.Ua.push(t),this.Ka+=Pb(t),of(this)},nf.prototype.pop=function(){var t=this.Ua.pop();this.Ka-=Pb(t),0<this.Ua.length&&--this.Ka};var rf=new Ec(function(t,e){return t===e?0:t<e?-1:1});function sf(t){var n=qe;return v(t,function(t,e){n=n.set(new P(e),t)}),n}function tf(t,e,n){if(null!=t.value&&n(t.value))return{path:M,value:t.value};if(e.e())return null;var i=K(e);return null!==(t=t.children.get(i))?null!=(e=tf(t,N(e),n))?{path:new P(i).o(e.path),value:e.value}:null:null}function uf(t,e){return tf(t,e,function(){return!0})}function pe(t,e,n){if(e.e())return n;var i=K(e);return i=(e=pe(t.children.get(i)||qe,N(e),n)).e()?t.children.remove(i):t.children.Sa(i,e),new qf(t.value,i)}function vf(t,e){return wf(t,M,e)}function wf(t,n,i){var r={};return t.children.ka(function(t,e){r[t]=wf(e,n.o(t),i)}),i(n,t.value,r)}function xf(t,e,n){return yf(t,e,M,n)}function yf(t,e,n,i){var r=!!t.value&&i(n,t.value);return r||(e.e()?null:(r=K(e),(t=t.children.get(r))?yf(t,N(e),n.o(r),i):null))}function zf(t,e,n){Af(t,e,M,n)}function Af(t,e,n,i){if(e.e())return t;t.value&&i(n,t.value);var r=K(e);return(t=t.children.get(r))?Af(t,N(e),n.o(r),i):qe}function ne(t,e){Bf(t,M,e)}function Bf(t,n,i){t.children.ka(function(t,e){Bf(e,n.o(t),i)}),t.value&&i(n,t.value)}function Cf(t,n){t.children.ka(function(t,e){e.value&&n(t,e.value)})}h=qf.prototype,h.e=function(){return null===this.value&&this.children.e()},h.subtree=function(t){if(t.e())return this;var e=this.children.get(K(t));return null!==e?e.subtree(N(t)):qe},h.set=function(t,e){if(t.e())return new qf(e,this.children);var n=K(t),i=(this.children.get(n)||qe).set(N(t),e);n=this.children.Sa(n,i);return new qf(this.value,n)},h.remove=function(t){if(t.e())return this.children.e()?qe:new qf(null,this.children);var e=K(t),n=this.children.get(e);return n?(e=(t=n.remove(N(t))).e()?this.children.remove(e):this.children.Sa(e,t),null===this.value&&e.e()?qe:new qf(this.value,e)):this},h.get=function(t){if(t.e())return this.value;var e=this.children.get(K(t));return e?e.get(N(t)):null};var qe=new qf(null);function Df(t,e,n){this.type=ee,this.source=Ef,this.path=t,this.Ub=e,this.Yd=n}qf.prototype.toString=function(){var n={};return ne(this,function(t,e){n[t.toString()]=e.toString()}),G(n)},Df.prototype.$c=function(t){return this.path.e()?null!=this.Ub.value?(O(this.Ub.children.e(),"affectedTree should not have overlapping affected paths."),this):(t=this.Ub.subtree(new P(t)),new Df(M,t,this.Yd)):(O(K(this.path)===t,"operationForChild called for unrelated child."),new Df(N(this.path),this.Ub,this.Yd))},Df.prototype.toString=function(){return"Operation("+this.path+": "+this.source.toString()+" ack write revert="+this.Yd+" affectedTree="+this.Ub+")"};var Bc=0,be=1,ee=2,Dc=3;function Ff(t,e,n,i){this.Ae=t,this.tf=e,this.Lb=n,this.ef=i,O(!i||e,"Tagged queries must be from server.")}var Ef=new Ff(!0,!1,null,!1),Gf=new Ff(!1,!0,null,!1);function Hf(t){this.Z=t}Ff.prototype.toString=function(){return this.Ae?"user":this.ef?"server(queryID="+this.Lb+")":"server"};var If=new Hf(new qf(null));function Jf(t,e,n){if(e.e())return new Hf(new qf(n));if(null==(r=uf(t.Z,e)))return new Hf(t=pe(t.Z,e,new qf(n)));var i=r.path,r=r.value;return e=lf(i,e),r=r.H(e,n),new Hf(t.Z.set(i,r))}function Kf(t,n,e){var i=t;return Fb(e,function(t,e){i=Jf(i,n.o(t),e)}),i}function Lf(t,e){var n=uf(t.Z,e);return null!=n?t.Z.get(n.path).S(lf(n.path,e)):null}function Mf(t){var n=[],e=t.Z.value;return null!=e?e.L()||e.R(R,function(t,e){n.push(new L(t,e))}):t.Z.children.ka(function(t,e){null!=e.value&&n.push(new L(t,e.value))}),n}function Nf(t,e){if(e.e())return t;var n=Lf(t,e);return new Hf(null!=n?new qf(n):t.Z.subtree(e))}function Of(n,t,i){if(null!=t.value)return i.H(n,t.value);var r=null;return t.children.ka(function(t,e){".priority"===t?(O(null!==e.value,"Priority writes must always be leaf nodes"),r=e.value):i=Of(n.o(t),e,i)}),i.S(n).e()||null===r||(i=i.H(n.o(".priority"),r)),i}function Pf(){this.V=If,this.pa=[],this.Pc=-1}function Qf(t,e){for(var n=0;n<t.pa.length;n++){var i=t.pa[n];if(i.md===e)return i}return null}function Rf(n,i){return n.Ja?n.path.contains(i):!!ta(n.children,function(t,e){return n.path.o(e).contains(i)})}function Tf(t){return t.visible}function Sf(t,e,n){for(var i=If,r=0;r<t.length;++r){var o=t[r];if(e(o)){var a=o.path;if(o.Ja)n.contains(a)?i=Jf(i,a=lf(n,a),o.Ja):a.contains(n)&&(a=lf(a,n),i=Jf(i,M,o.Ja.S(a)));else{if(!o.children)throw jd("WriteRecord should have .snap or .children");n.contains(a)?i=Kf(i,a=lf(n,a),o.children):a.contains(n)&&((a=lf(a,n)).e()?i=Kf(i,M,o.children):(o=z(o.children,K(a)))&&(o=o.S(N(a)),i=Jf(i,M,o)))}}}return i}function Uf(t,e){this.Qb=t,this.Z=e}function Vf(){this.children={},this.pd=0,this.value=null}function Wf(t,e,n){this.Jd=t||"",this.Ha=e||null,this.A=n||new Vf}function Xf(t,e){for(var n,i=e instanceof P?e:new P(e),r=t;null!==(n=K(i));)r=new Wf(n,r,z(r.A.children,n)||new Vf),i=N(i);return r}function Yf(t,e){O(void 0!==e,"Cannot set value to undefined"),t.A.value=e,Zf(t)}function $f(t,e,n,i){n&&!i&&e(t),t.R(function(t){$f(t,e,!0,i)}),n&&i&&e(t)}function ag(t,e){for(var n=t.parent();null!==n&&!e(n);)n=n.parent()}function Zf(t){if(null!==t.Ha){var e=t.Ha,n=t.Jd,i=t.e(),r=y(e.A.children,n);i&&r?(delete e.A.children[n],e.A.pd--,Zf(e)):i||r||(e.A.children[n]=t.A,e.A.pd++,Zf(e))}}Hf.prototype.Ud=function(t){return t.e()?If:new Hf(t=pe(this.Z,t,qe))},Hf.prototype.e=function(){return this.Z.e()},Hf.prototype.apply=function(t){return Of(M,this.Z,t)},h=Pf.prototype,h.Ud=function(e){var t=Sa(this.pa,function(t){return t.md===e});O(0<=t,"removeWrite called with nonexistent writeId.");var n=this.pa[t];this.pa.splice(t,1);for(var i=n.visible,r=!1,o=this.pa.length-1;i&&0<=o;){var a=this.pa[o];a.visible&&(t<=o&&Rf(a,n.path)?i=!1:n.path.contains(a.path)&&(r=!0)),o--}if(i){if(r)this.V=Sf(this.pa,Tf,M),this.Pc=0<this.pa.length?this.pa[this.pa.length-1].md:-1;else if(n.Ja)this.V=this.V.Ud(n.path);else{var s=this;v(n.children,function(t,e){s.V=s.V.Ud(n.path.o(e))})}return!0}return!1},h.Aa=function(e,t,n,i){if(n||i){var r=Nf(this.V,e);return!i&&r.e()?t:i||null!=t||null!=Lf(r,M)?(r=Sf(this.pa,function(t){return(t.visible||i)&&(!n||!(0<=La(n,t.md)))&&(t.path.contains(e)||e.contains(t.path))},e),t=t||H,r.apply(t)):null}return null!=(r=Lf(this.V,e))?r:(r=Nf(this.V,e)).e()?t:null!=t||null!=Lf(r,M)?(t=t||H,r.apply(t)):null},h.Cc=function(t,e){var i=H,n=Lf(this.V,t);if(n)n.L()||n.R(R,function(t,e){i=i.W(t,e)});else if(e){var r=Nf(this.V,t);e.R(R,function(t,e){var n=Nf(r,new P(t)).apply(e);i=i.W(t,n)}),Ma(Mf(r),function(t){i=i.W(t.name,t.U)})}else r=Nf(this.V,t),Ma(Mf(r),function(t){i=i.W(t.name,t.U)});return i},h.nd=function(t,e,n,i){return O(n||i,"Either existingEventSnap or existingServerSnap must exist"),t=t.o(e),null!=Lf(this.V,t)?null:(t=Nf(this.V,t)).e()?i.S(e):t.apply(i.S(e))},h.Bc=function(t,e,n){t=t.o(e);var i=Lf(this.V,t);return null!=i?i:Wb(n,e)?Nf(this.V,t).apply(n.j().T(e)):null},h.xc=function(t){return Lf(this.V,t)},h.qe=function(t,e,n,i,r,o){var a;if(null==(a=Lf(t=Nf(this.V,t),M))){if(null==e)return[];a=t.apply(e)}if((a=a.pb(o)).e()||a.L())return[];for(e=[],t=Vd(o),o=Ic(r=r?a.dc(n,o):a.bc(n,o));o&&e.length<i;)0!==t(o,n)&&e.push(o),o=Ic(r);return e},h=Uf.prototype,h.Aa=function(t,e,n){return this.Z.Aa(this.Qb,t,e,n)},h.Cc=function(t){return this.Z.Cc(this.Qb,t)},h.nd=function(t,e,n){return this.Z.nd(this.Qb,t,e,n)},h.xc=function(t){return this.Z.xc(this.Qb.o(t))},h.qe=function(t,e,n,i,r){return this.Z.qe(this.Qb,t,e,n,i,r)},h.Bc=function(t,e){return this.Z.Bc(this.Qb,t,e)},h.o=function(t){return new Uf(this.Qb.o(t),this.Z)},h=Wf.prototype,h.Ea=function(){return this.A.value},h.clear=function(){this.A.value=null,this.A.children={},this.A.pd=0,Zf(this)},h.zd=function(){return 0<this.A.pd},h.e=function(){return null===this.Ea()&&!this.zd()},h.R=function(n){var i=this;v(this.A.children,function(t,e){n(new Wf(e,i,t))})},h.path=function(){return new P(null===this.Ha?this.Jd:this.Ha.path()+"/"+this.Jd)},h.name=function(){return this.Jd},h.parent=function(){return this.Ha};var bg=/[\[\].#$\/\u0000-\u001F\u007F]/,cg=/[\[\].#$\u0000-\u001F\u007F]/,dg=/^[a-zA-Z][a-zA-Z._\-+]+$/;function eg(t){return q(t)&&0!==t.length&&!bg.test(t)}function fg(t){return null===t||q(t)||fa(t)&&!td(t)||ga(t)&&y(t,".sv")}function gg(t,e,n,i){i&&!p(e)||hg(E(t,1,i),e,n)}function hg(n,t,i){if(i instanceof P&&(i=new nf(i,n)),!p(t))throw Error(n+"contains undefined "+pf(i));if(r(t))throw Error(n+"contains a function "+pf(i)+" with contents: "+t.toString());if(td(t))throw Error(n+"contains "+t.toString()+" "+pf(i));if(q(t)&&t.length>10485760/3&&10485760<Pb(t))throw Error(n+"contains a string greater than 10485760 utf8 bytes "+pf(i)+" ('"+t.substring(0,50)+"...')");if(ga(t)){var o=!1,a=!1;if(Fb(t,function(t,e){if(".value"===t)o=!0;else if(".priority"!==t&&".sv"!==t&&(a=!0,!eg(t)))throw Error(n+" contains an invalid key ("+t+") "+pf(i)+'.  Keys must be non-empty strings and can\'t contain ".", "#", "$", "/", "[", or "]"');i.push(t),hg(n,e,i),i.pop()}),o&&a)throw Error(n+' contains ".value" child '+pf(i)+" in addition to actual children.")}}function ig(t,e){var n,i;for(n=0;n<e.length;n++)for(var r=(i=e[n]).slice(),o=0;o<r.length;o++)if((".priority"!==r[o]||o!==r.length-1)&&!eg(r[o]))throw Error(t+"contains an invalid key ("+r[o]+") in path "+i.toString()+'. Keys must be non-empty strings and can\'t contain ".", "#", "$", "/", "[", or "]"');for(e.sort(mf),r=null,n=0;n<e.length;n++){if(i=e[n],null!==r&&r.contains(i))throw Error(t+"contains a path "+r.toString()+" that is ancestor of another path "+i.toString());r=i}}function jg(t,e,i){var r=E(t,1,!1);if(!ga(e)||da(e))throw Error(r+" must be an object containing the children to replace.");var o=[];Fb(e,function(t,e){var n=new P(t);if(hg(r,e,i.o(n)),".priority"===me(n)&&!fg(e))throw Error(r+"contains an invalid value for '"+n.toString()+"', which must be a valid Firebase priority (a string, finite number, server value, or null).");o.push(n)}),ig(r,o)}function kg(t,e,n){if(td(n))throw Error(E(t,e,!1)+"is "+n.toString()+", but must be a valid Firebase priority (a string, finite number, server value, or null).");if(!fg(n))throw Error(E(t,e,!1)+"must be a valid Firebase priority (a string, finite number, server value, or null).")}function lg(t,e,n){if(!n||p(e))switch(e){case"value":case"child_added":case"child_removed":case"child_changed":case"child_moved":break;default:throw Error(E(t,1,n)+'must be a valid event type: "value", "child_added", "child_removed", "child_changed", or "child_moved".')}}function mg(t,e){if(p(e)&&!eg(e))throw Error(E(t,2,!0)+'was an invalid key: "'+e+'".  Firebase keys must be non-empty strings and can\'t contain ".", "#", "$", "/", "[", or "]").')}function ng(t,e){if(!q(e)||0===e.length||cg.test(e))throw Error(E(t,1,!1)+'was an invalid path: "'+e+'". Paths must be non-empty strings and can\'t contain ".", "#", "$", "[", or "]"')}function og(t,e){if(".info"===K(e))throw Error(t+" failed: Can't modify data under /.info/")}function pg(t,e){if(!q(e))throw Error(E(t,1,!1)+"must be a valid credential (a string).")}function qg(t,e,n){if(!q(n))throw Error(E(t,e,!1)+"must be a valid string.")}function rg(t,e){if(qg(t,1,e),!dg.test(e))throw Error(E(t,1,!1)+"'"+e+"' is not a valid authentication provider.")}function sg(t,e,n,i){if((!i||p(n))&&(!ga(n)||null===n))throw Error(E(t,e,i)+"must be a valid object.")}function tg(t,e,n){if(!ga(e)||!y(e,n))throw Error(E(t,1,!1)+'must contain the key "'+n+'"');if(!q(z(e,n)))throw Error(E(t,1,!1)+'must contain the key "'+n+'" with type "string"')}function ug(){this.set={}}function vg(t,n){v(t.set,function(t,e){n(e,t)})}function Vc(){this.m=this.B=null}function wg(n,t){if(t.e())return n.B=null,!(n.m=null);if(null===n.B)return null===n.m||(e=K(t),t=N(t),n.m.contains(e)&&wg(n.m.get(e),t)&&n.m.remove(e),!!n.m.e()&&!(n.m=null));if(n.B.L())return!1;var e=n.B;return n.B=null,e.R(R,function(t,e){n.rc(new P(t),e)}),wg(n,t)}function Wc(t,n,i){null!==t.B?i(n,t.B):t.R(function(t,e){Wc(e,new P(n.toString()+"/"+t),i)})}h=ug.prototype,h.add=function(t,e){this.set[t]=null===e||e},h.contains=function(t){return y(this.set,t)},h.get=function(t){return this.contains(t)?this.set[t]:void 0},h.remove=function(t){delete this.set[t]},h.clear=function(){this.set={}},h.e=function(){return va(this.set)},h.count=function(){return oa(this.set)},h.keys=function(){var n=[];return v(this.set,function(t,e){n.push(e)}),n},Vc.prototype.find=function(t){if(null!=this.B)return this.B.S(t);if(t.e()||null==this.m)return null;var e=K(t);return t=N(t),this.m.contains(e)?this.m.get(e).find(t):null},Vc.prototype.rc=function(t,e){if(t.e())this.B=e,this.m=null;else if(null!==this.B)this.B=this.B.H(t,e);else{null==this.m&&(this.m=new ug);var n=K(t);this.m.contains(n)||this.m.add(n,new Vc),n=this.m.get(n),t=N(t),n.rc(t,e)}},Vc.prototype.R=function(n){null!==this.m&&vg(this.m,function(t,e){n(t,e)})};var xg="auth.firebase.com";function yg(t,e,n){this.qd=t||{},this.he=e||{},this.fb=n||{},this.qd.remember||(this.qd.remember="default")}var zg=["remember","redirectTo"];function Ag(t){var n={},i={};return Fb(t||{},function(t,e){0<=La(zg,t)?n[t]=e:i[t]=e}),new yg(n,{},i)}function Bg(t,e){this.Ue=["session",t.Rd,t.lc].join(":"),this.ee=e}function Cg(){return"undefined"!=typeof navigator&&"string"==typeof navigator.userAgent?navigator.userAgent:""}function Dg(){return"undefined"!=typeof window&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(Cg())}function Eg(){return"undefined"!=typeof location&&/^file:\//.test(location.href)}function Fg(t){var e=Cg();if(""===e)return!1;if("Microsoft Internet Explorer"===navigator.appName){if((e=e.match(/MSIE ([0-9]{1,}[\.0-9]{0,})/))&&1<e.length)return parseFloat(e[1])>=t}else if(-1<e.indexOf("Trident")&&(e=e.match(/rv:([0-9]{2,2}[\.0-9]{0,})/))&&1<e.length)return parseFloat(e[1])>=t;return!1}function Gg(){var t,e=window.opener.frames;for(t=e.length-1;0<=t;t--)try{if(e[t].location.protocol===window.location.protocol&&e[t].location.host===window.location.host&&"__winchan_relay_frame"===e[t].name)return e[t]}catch(n){}return null}function Hg(t,e,n){t.attachEvent?t.attachEvent("on"+e,n):t.addEventListener&&t.addEventListener(e,n,!1)}function Ig(t,e,n){t.detachEvent?t.detachEvent("on"+e,n):t.removeEventListener&&t.removeEventListener(e,n,!1)}function Jg(t){/^https?:\/\//.test(t)||(t=window.location.href);var e=/^(https?:\/\/[\-_a-zA-Z\.0-9:]+)/.exec(t);return e?e[1]:t}function Kg(t){var e="";try{var n=Jb(t=t.replace(/.*\?/,""));n&&y(n,"__firebase_request_key")&&(e=z(n,"__firebase_request_key"))}catch(i){}return e}function Lg(){try{var t=(t=(t=document.location.hash.replace(/&__firebase_request_key=([a-zA-z0-9]*)/,"")).replace(/\?$/,"")).replace(/^#+$/,"");document.location.hash=t}catch(e){}}function Mg(){var t=sd(xg);return t.scheme+"://"+t.host+"/v2"}function Ng(t){return Mg()+"/"+t+"/auth/channel"}function Og(t){var e=this;if(this.hb=t,this.fe="*",Fg(8)?this.Uc=this.Cd=Gg():(this.Uc=window.opener,this.Cd=window),!e.Uc)throw"Unable to find relay frame";Hg(this.Cd,"message",u(this.nc,this)),Hg(this.Cd,"message",u(this.Ff,this));try{Pg(this,{a:"ready"})}catch(n){Hg(this.Uc,"load",function(){Pg(e,{a:"ready"})})}Hg(window,"unload",u(this.Ng,this))}function Pg(t,e){e=G(e),Fg(8)?t.Uc.doPost(e,t.fe):t.Uc.postMessage(e,t.fe)}function Qg(t){this.tc=Fa()+Fa()+Fa(),this.Kf=t}Bg.prototype.set=function(t,e){if(!e){if(!this.ee.length)throw Error("fb.login.SessionManager:No storage options available!");e=this.ee[0]}e.set(this.Ue,t)},Bg.prototype.get=function(){var t=Oa(this.ee,u(this.Bg,this));return Va(t=Na(t,function(t){return null!==t}),function(t,e){return Dd(e.token)-Dd(t.token)}),0<t.length?t.shift():null},Bg.prototype.Bg=function(t){try{var e=t.get(this.Ue);if(e&&e.token)return e}catch(n){}return null},Bg.prototype.clear=function(){var e=this;Ma(this.ee,function(t){t.remove(e.Ue)})},Og.prototype.nc=function(t){var e,n=this;try{e=Rb(t.data)}catch(i){}e&&"request"===e.a&&(Ig(window,"message",this.nc),this.fe=t.origin,this.hb&&setTimeout(function(){n.hb(n.fe,e.d,function(t,e){n.mg=!e,n.hb=void 0,Pg(n,{a:"response",d:t,forceKeepWindowOpen:e})})},0))},Og.prototype.Ng=function(){try{Ig(this.Cd,"message",this.Ff)}catch(t){}this.hb&&(Pg(this,{a:"error",d:"unknown closed window"}),this.hb=void 0);try{window.close()}catch(e){}},Og.prototype.Ff=function(t){if(this.mg&&"die"===t.data)try{window.close()}catch(e){}},Qg.prototype.open=function(t,e){cd.set("redirect_request_id",this.tc),cd.set("redirect_request_id",this.tc),e.requestId=this.tc,e.redirectTo=e.redirectTo||window.location.href,t+=(/\?/.test(t)?"":"?")+Ib(e),window.location=t},Qg.isAvailable=function(){return!Eg()&&!Dg()},Qg.prototype.Fc=function(){return"redirect"};var Rg={NETWORK_ERROR:"Unable to contact the Firebase server.",SERVER_ERROR:"An unknown server error occurred.",TRANSPORT_UNAVAILABLE:"There are no login transports available for the requested method.",REQUEST_INTERRUPTED:"The browser redirected the page before the login request could complete.",USER_CANCELLED:"The user cancelled authentication."};function Sg(t){var e=Error(z(Rg,t),t);return e.code=t,e}function Tg(t){var e;(e=!t.window_features)||(e=-1!==(e=Cg()).indexOf("Fennec/")||-1!==e.indexOf("Firefox/")&&-1!==e.indexOf("Android")),e&&(t.window_features=void 0),t.window_name||(t.window_name="_blank"),this.options=t}function Ug(t){t.method||(t.method="GET"),t.headers||(t.headers={}),t.headers.content_type||(t.headers.content_type="application/json"),t.headers.content_type=t.headers.content_type.toLowerCase(),this.options=t}function Vg(t){this.tc=Fa()+Fa()+Fa(),this.Kf=t}function Wg(t){t.callback_parameter||(t.callback_parameter="callback"),this.options=t,window.__firebase_auth_jsonp=window.__firebase_auth_jsonp||{}}function Xg(i,r,o){setTimeout(function(){try{var t=document.createElement("script");t.type="text/javascript",t.id=i,t.async=!0,t.src=r,t.onerror=function(){var t=document.getElementById(i);null!==t&&t.parentNode.removeChild(t),o&&o(Sg("NETWORK_ERROR"))};var e=document.getElementsByTagName("head");(e&&0!=e.length?e[0]:document.documentElement).appendChild(t)}catch(n){o&&o(Sg("NETWORK_ERROR"))}},0)}function Yg(t,e,n,i){ff.call(this,["auth_status"]),this.G=t,this.hf=e,this.ih=n,this.Pe=i,this.wc=new Bg(t,[bd,cd]),this.qb=null,this.We=!1,Zg(this)}function Zg(n){cd.get("redirect_request_id")&&$g(n);var i=n.wc.get();i&&i.token?(ah(n,i),n.hf(i.token,function(t,e){bh(n,t,e,!1,i.token,i)},function(t,e){ch(n,"resumeSession()",t,e)})):ah(n,null)}function dh(n,i,r,o,a,s){"firebaseio-demo.com"===n.G.domain&&S("Firebase authentication is not supported on demo Firebases (*.firebaseio-demo.com). To secure your Firebase, create a production Firebase at https://www.firebase.com."),n.hf(i,function(t,e){bh(n,t,e,!0,i,r,o||{},a)},function(t,e){ch(n,"auth()",t,e,s)})}function eh(t,r){t.wc.clear(),ah(t,null),t.ih(function(t,e){if("ok"===t)T(r,null);else{var n=(t||"error").toUpperCase(),i=n;e&&(i+=": "+e),(i=Error(i)).code=n,T(r,i)}})}function bh(t,e,n,i,r,o,a,s){"ok"===e?(i&&(e=n.auth,o.auth=e,o.expires=n.expires,o.token=Ed(r)?r:"",n=null,e&&y(e,"uid")?n=z(e,"uid"):y(o,"uid")&&(n=z(o,"uid")),o.uid=n,n="custom",e&&y(e,"provider")?n=z(e,"provider"):y(o,"provider")&&(n=z(o,"provider")),o.provider=n,t.wc.clear(),Ed(r)&&(n=bd,"sessionOnly"===(a=a||{}).remember&&(n=cd),"none"!==a.remember&&t.wc.set(o,n)),ah(t,o)),T(s,null,o)):(t.wc.clear(),ah(t,null),o=t=(e||"error").toUpperCase(),n&&(o+=": "+n),(o=Error(o)).code=t,T(s,o))}function ch(t,e,n,i,r){S(e+" was canceled: "+i),t.wc.clear(),ah(t,null),(t=Error(i)).code=n.toUpperCase(),T(r,t)}function fh(t,e,n,i,r){gh(t),hh(t,[Ug,Wg],"/auth/"+e,n=new yg(i||{},{},n||{}),r)}function ih(t,e,n,i){gh(t);var r=[Tg,Vg];n=Ag(n);var o=625;"anonymous"===e||"password"===e?setTimeout(function(){T(i,Sg("TRANSPORT_UNAVAILABLE"))},0):("github"===e&&(o=1025),n.he.window_features="menubar=yes,modal=yes,alwaysRaised=yeslocation=yes,resizable=yes,scrollbars=yes,status=yes,height=625,width="+o+",top="+("object"==typeof screen?.5*(screen.height-625):0)+",left="+("object"==typeof screen?.5*(screen.width-o):0),n.he.relay_url=Ng(t.G.lc),n.he.requestWithCredential=u(t.uc,t),hh(t,r,"/auth/"+e,n,i))}function $g(t){if(n=cd.get("redirect_request_id")){var e=cd.get("redirect_client_options");cd.remove("redirect_request_id"),cd.remove("redirect_client_options");var n,i=[Ug,Wg];e=new yg(e,{},n={requestId:n,requestKey:Kg(document.location.hash)});t.We=!0,Lg(),hh(t,i,"/auth/session",e,function(){this.We=!1}.bind(t))}}function hh(n,t,e,i,r){jh(n,t,e,i,function(t,e){!t&&e&&e.token&&e.uid?dh(n,e.token,e,i.qd,function(t,e){t?T(r,t):T(r,null,e)}):T(r,t||Sg("UNKNOWN_ERROR"))})}function jh(t,e,n,i,r){0===(e=Na(e,function(t){return"function"==typeof t.isAvailable&&t.isAvailable()})).length?setTimeout(function(){T(r,Sg("TRANSPORT_UNAVAILABLE"))},0):(e=new(e.shift())(i.he),(i=Gb(i.fb)).v="js-"+Eb,i.transport=e.Fc(),i.suppress_status_codes=!0,t=Mg()+"/"+t.G.lc+n,e.open(t,i,function(t,e){if(t)T(r,t);else if(e&&e.error){var n=Error(e.error.message);n.code=e.error.code,n.details=e.error.details,T(r,n)}else T(r,null,e)}))}function ah(t,e){var n=null!==t.qb||null!==e;t.qb=e,n&&t.ie("auth_status",e),t.Pe(null!==e)}function gh(t){var e=t.G;if("firebaseio.com"!==e.domain&&"firebaseio-demo.com"!==e.domain&&"auth.firebase.com"===xg)throw Error("This custom Firebase server ('"+t.G.domain+"') does not support delegated login.")}Tg.prototype.open=function(t,e,n){function i(t){if(o&&(document.body.removeChild(o),o=void 0),c=c&&clearInterval(c),Ig(window,"message",r),Ig(window,"unload",i),u&&!t)try{u.close()}catch(e){a.postMessage("die",h)}u=a=void 0}function r(t){if(t.origin===h)try{var e=Rb(t.data);"ready"===e.a?a.postMessage(f,h):"error"===e.a?(i(!1),n&&(n(e.d),n=null)):"response"===e.a&&(i(e.forceKeepWindowOpen),n&&(n(null,e.d),n=null))}catch(r){}}var o,a,s=Fg(8);if(!this.options.relay_url)return n(Error("invalid arguments: origin of url and relay_url must match"));var h=Jg(t);if(h!==Jg(this.options.relay_url))n&&setTimeout(function(){n(Error("invalid arguments: origin of url and relay_url must match"))},0);else{s&&((o=document.createElement("iframe")).setAttribute("src",this.options.relay_url),o.style.display="none",o.setAttribute("name","__winchan_relay_frame"),document.body.appendChild(o),a=o.contentWindow),t+=(/\?/.test(t)?"":"?")+Ib(e);var u=window.open(t,this.options.window_name,this.options.window_features);a=a||u;var c=setInterval(function(){u&&u.closed&&(i(!1),n&&(n(Sg("USER_CANCELLED")),n=null))},500),f=G({a:"request",d:e});Hg(window,"unload",i),Hg(window,"message",r)}},Tg.isAvailable=function(){var t;return(t="postMessage"in window&&!Eg())&&((t=Dg()||"undefined"!=typeof navigator&&(!!Cg().match(/Windows Phone/)||!!window.Windows&&/^ms-appx:/.test(location.href)))||(t=Cg(),t="undefined"!=typeof navigator&&"undefined"!=typeof window&&!!(t.match(/(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i)||t.match(/CriOS/)||t.match(/Twitter for iPhone/)||t.match(/FBAN\/FBIOS/)||window.navigator.standalone)),t=!t),t&&!Cg().match(/PhantomJS/)},Tg.prototype.Fc=function(){return"popup"},Ug.prototype.open=function(t,e,n){function i(){n&&(n(Sg("REQUEST_INTERRUPTED")),n=null)}var r,o=new XMLHttpRequest,a=this.options.method.toUpperCase();if(Hg(window,"beforeunload",i),o.onreadystatechange=function(){if(n&&4===o.readyState){var t;if(200<=o.status&&o.status<300){try{t=Rb(o.responseText)}catch(e){}n(null,t)}else 500<=o.status&&o.status<600?n(Sg("SERVER_ERROR")):n(Sg("NETWORK_ERROR"));n=null,Ig(window,"beforeunload",i)}},"GET"===a)t+=(/\?/.test(t)?"":"?")+Ib(e),r=null;else{var s=this.options.headers.content_type;"application/json"===s&&(r=G(e)),"application/x-www-form-urlencoded"===s&&(r=Ib(e))}for(var h in o.open(a,t,!0),ya(t={"X-Requested-With":"XMLHttpRequest",Accept:"application/json;text/plain"},this.options.headers),t)o.setRequestHeader(h,t[h]);o.send(r)},Ug.isAvailable=function(){var t;return(t=!!window.XMLHttpRequest)&&(t=!((t=Cg()).match(/MSIE/)||t.match(/Trident/))||Fg(10)),t},Ug.prototype.Fc=function(){return"json"},Vg.prototype.open=function(t,e,o){function a(){o&&(o(Sg("USER_CANCELLED")),o=null)}var s,h=this,u=sd(xg);e.requestId=this.tc,e.redirectTo=u.scheme+"://"+u.host+"/blank/page.html",t+=/\?/.test(t)?"":"?",t+=Ib(e),(s=window.open(t,"_blank","location=no"))&&r(s.addEventListener)?(s.addEventListener("loadstart",function(t){var e;if(e=t&&t.url)t:{try{var n=document.createElement("a");n.href=t.url,e=n.host===u.host&&"/blank/page.html"===n.pathname;break t}catch(i){}e=!1}e&&(t=Kg(t.url),s.removeEventListener("exit",a),s.close(),t=new yg(null,null,{requestId:h.tc,requestKey:t}),h.Kf.requestWithCredential("/auth/session",t,o),o=null)}),s.addEventListener("exit",a)):o(Sg("TRANSPORT_UNAVAILABLE"))},Vg.isAvailable=function(){return Dg()},Vg.prototype.Fc=function(){return"redirect"},Wg.prototype.open=function(t,n,i){function r(){i&&(i(Sg("REQUEST_INTERRUPTED")),i=null)}var o="fn"+(new Date).getTime()+Math.floor(99999*Math.random());n[this.options.callback_parameter]="__firebase_auth_jsonp."+o,t+=(/\?/.test(t)?"":"?")+Ib(n),Hg(window,"beforeunload",r),window.__firebase_auth_jsonp[o]=function(t){i&&(i(null,t),i=null),function e(){setTimeout(function(){window.__firebase_auth_jsonp[o]=void 0,va(window.__firebase_auth_jsonp)&&(window.__firebase_auth_jsonp=void 0);try{var t=document.getElementById(o);t&&t.parentNode.removeChild(t)}catch(n){}},1),Ig(window,"beforeunload",r)}()},Xg(o,t,i)},Wg.isAvailable=function(){return"undefined"!=typeof document&&null!=document.createElement},Wg.prototype.Fc=function(){return"json"},ka(Yg,ff),h=Yg.prototype,h.Be=function(){return this.qb||null},h.ve=function(t,n){gh(this);var e=Ag(t);e.fb._method="POST",this.uc("/users",e,function(t,e){t?T(n,t):T(n,t,e)})},h.Xe=function(t,n){var i=this;gh(this);var e="/users/"+encodeURIComponent(t.email),r=Ag(t);r.fb._method="DELETE",this.uc(e,r,function(t,e){!t&&e&&e.uid&&i.qb&&i.qb.uid&&i.qb.uid===e.uid&&eh(i),T(n,t)})},h.se=function(t,e){gh(this);var n="/users/"+encodeURIComponent(t.email)+"/password",i=Ag(t);i.fb._method="PUT",i.fb.password=t.newPassword,this.uc(n,i,function(t){T(e,t)})},h.re=function(t,e){gh(this);var n="/users/"+encodeURIComponent(t.oldEmail)+"/email",i=Ag(t);i.fb._method="PUT",i.fb.email=t.newEmail,i.fb.password=t.password,this.uc(n,i,function(t){T(e,t)})},h.Ze=function(t,e){gh(this);var n="/users/"+encodeURIComponent(t.email)+"/password",i=Ag(t);i.fb._method="POST",this.uc(n,i,function(t){T(e,t)})},h.uc=function(t,e,n){jh(this,[Ug,Wg],t,e,n)},h.Ee=function(t){return O("auth_status"===t,'initial event must be of type "auth_status"'),this.We?null:[this.qb]};var gd="websocket",hd="long_polling",oh,ph;function kh(t){this.nc=t,this.Qd=[],this.Wb=0,this.te=-1,this.Jb=null}function lh(t,e,n){t.te=e,t.Jb=n,t.te<t.Wb&&(t.Jb(),t.Jb=null)}function mh(t,e,n){for(t.Qd[e]=n;t.Qd[t.Wb];){var i=t.Qd[t.Wb];delete t.Qd[t.Wb];for(var r=0;r<i.length;++r)if(i[r]){var o=t;gc(function(){o.nc(i[r])})}if(t.Wb===t.te){t.Jb&&(clearTimeout(t.Jb),t.Jb(),t.Jb=null);break}t.Wb++}}function nh(t,e,n,i){this.ue=t,this.f=pd(t),this.rb=this.sb=0,this.Xa=uc(e),this.Xf=n,this.Kc=!1,this.Fb=i,this.ld=function(t){return fd(e,hd,t)}}function rh(t,e){var n=G(e).length;t.rb+=n,rc(t.Xa,"bytes_received",n)}function qh(t,e,n,i){if(this.ld=i,this.lb=n,this.Te=new ug,this.cd=[],this.we=Math.floor(1e8*Math.random()),this.$d=!0,this.ke=id(),window["pLPCommand"+this.ke]=t,window["pRTLPCB"+this.ke]=e,(t=document.createElement("iframe")).style.display="none",!document.body)throw"Document body has not initialized. Wait to initialize Firebase until after the document is ready.";document.body.appendChild(t);try{t.contentWindow.document||fc("No IE domain setting required")}catch(r){t.src="javascript:void((function(){document.open();document.domain='"+document.domain+"';document.close();})())"}t.contentDocument?t.jb=t.contentDocument:t.contentWindow?t.jb=t.contentWindow.document:t.document&&(t.jb=t.document),this.Ga=t,t="",this.Ga.src&&"javascript:"===this.Ga.src.substr(0,11)&&(t='<script>document.domain="'+document.domain+'";<\/script>'),t="<html><body>"+t+"</body></html>";try{this.Ga.jb.open(),this.Ga.jb.write(t),this.Ga.jb.close()}catch(o){fc("frame writing exception"),o.stack&&fc(o.stack),fc(o)}}function th(t){if(t.oe&&t.$d&&t.Te.count()<(0<t.cd.length?2:1)){t.we++,(e={}).id=t.Gg,e.pw=t.Hg,e.ser=t.we;for(var e=t.ld(e),n="",i=0;0<t.cd.length&&t.cd[0].of.length+30+n.length<=1870;){var r=t.cd.shift();n=n+"&seg"+i+"="+r.Yg+"&ts"+i+"="+r.hh+"&d"+i+"="+r.of;i++}return uh(t,e+n,t.we),!0}return!1}function uh(t,e,n){function i(){t.Te.remove(n),th(t)}t.Te.add(n,1);var r=setTimeout(i,Math.floor(25e3));sh(t,e,function(){clearTimeout(r),i()})}function sh(n,i,r){setTimeout(function(){try{if(n.$d){var e=n.Ga.jb.createElement("script");e.type="text/javascript",e.async=!0,e.src=i,e.onload=e.onreadystatechange=function(){var t=e.readyState;t&&"loaded"!==t&&"complete"!==t||(e.onload=e.onreadystatechange=null,e.parentNode&&e.parentNode.removeChild(e),r())},e.onerror=function(){fc("Long-poll script failed to load: "+i),n.$d=!1,n.close()},n.Ga.jb.body.appendChild(e)}}catch(t){}},Math.floor(1))}nh.prototype.open=function(t,e){this.mf=0,this.na=e,this.Ef=new kh(t),this.Db=!1;var o=this;this.ub=setTimeout(function(){o.f("Timed out trying to connect."),o.bb(),o.ub=null},Math.floor(3e4)),ud(function(){if(!o.Db){o.Wa=new qh(function(t,e,n,i,r){if(rh(o,arguments),o.Wa)if(o.ub&&(clearTimeout(o.ub),o.ub=null),o.Kc=!0,"start"==t)o.id=e,o.Mf=n;else{if("close"!==t)throw Error("Unrecognized command received: "+t);e?(o.Wa.$d=!1,lh(o.Ef,e,function(){o.bb()})):o.bb()}},function(t,e){rh(o,arguments),mh(o.Ef,t,e)},function(){o.bb()},o.ld);var t={start:"t"};t.ser=Math.floor(1e8*Math.random()),o.Wa.ke&&(t.cb=o.Wa.ke),t.v="5",o.Xf&&(t.s=o.Xf),o.Fb&&(t.ls=o.Fb),"undefined"!=typeof location&&location.href&&-1!==location.href.indexOf("firebaseio.com")&&(t.r="f"),t=o.ld(t),o.f("Connecting via long-poll to "+t),sh(o.Wa,t,function(){})}})},nh.prototype.start=function(){var t=this.Wa,e=this.Mf;for(t.Gg=this.id,t.Hg=e,t.oe=!0;th(t););t=this.id,e=this.Mf,this.kc=document.createElement("iframe");var n={dframe:"t"};n.id=t,n.pw=e,this.kc.src=this.ld(n),this.kc.style.display="none",document.body.appendChild(this.kc)},nh.isAvailable=function(){return oh||!ph&&"undefined"!=typeof document&&null!=document.createElement&&!("object"==typeof window&&window.chrome&&window.chrome.extension&&!/^chrome/.test(window.location.href))&&!("object"==typeof Windows&&"object"==typeof Windows.kh)&&!0},h=nh.prototype,h.Hd=function(){},h.fd=function(){this.Db=!0,this.Wa&&(this.Wa.close(),this.Wa=null),this.kc&&(document.body.removeChild(this.kc),this.kc=null),this.ub&&(clearTimeout(this.ub),this.ub=null)},h.bb=function(){this.Db||(this.f("Longpoll is closing itself"),this.fd(),this.na&&(this.na(this.Kc),this.na=null))},h.close=function(){this.Db||(this.f("Longpoll is being closed."),this.fd())},h.send=function(t){t=G(t),this.sb+=t.length,rc(this.Xa,"bytes_sent",t.length),t=yd(t=nb(t=Ob(t),!0),1840);for(var e=0;e<t.length;e++){var n=this.Wa;n.cd.push({Yg:this.mf,hh:t.length,of:t[e]}),n.oe&&th(n),this.mf++}},qh.prototype.close=function(){if(this.oe=!1,this.Ga){this.Ga.jb.body.innerHTML="";var t=this;setTimeout(function(){null!==t.Ga&&(document.body.removeChild(t.Ga),t.Ga=null)},Math.floor(0))}var e=this.lb;e&&(this.lb=null,e())};var vh=null,xh;function wh(t,e,n,i){this.ue=t,this.f=pd(this.ue),this.frames=this.Nc=null,this.rb=this.sb=this.ff=0,this.Xa=uc(e),t={v:"5"},"undefined"!=typeof location&&location.href&&-1!==location.href.indexOf("firebaseio.com")&&(t.r="f"),n&&(t.s=n),i&&(t.ls=i),this.jf=fd(e,gd,t)}function zh(t,e){if(t.frames.push(e),t.frames.length==t.ff){var n=t.frames.join("");t.frames=null,n=Rb(n),t.Lg(n)}}function yh(t){clearInterval(t.Nc),t.Nc=setInterval(function(){t.La&&Ah(t,"0"),yh(t)},Math.floor(45e3))}function Ah(t,e){try{t.La.send(e)}catch(n){t.f("Exception thrown from WebSocket.send():",n.message||n.data,"Closing connection."),setTimeout(u(t.bb,t),0)}}function Bh(t){Ch(this,t)}"undefined"!=typeof MozWebSocket?vh=MozWebSocket:"undefined"!=typeof WebSocket&&(vh=WebSocket),wh.prototype.open=function(t,e){this.lb=e,this.Lg=t,this.f("Websocket connecting to "+this.jf),this.Kc=!1,bd.set("previous_websocket_failure",!0);try{this.La=new vh(this.jf)}catch(r){this.f("Error instantiating WebSocket.");var n=r.message||r.data;return n&&this.f(n),void this.bb()}var i=this;this.La.onopen=function(){i.f("Websocket connected."),i.Kc=!0},this.La.onclose=function(){i.f("Websocket connection was disconnected."),i.La=null,i.bb()},this.La.onmessage=function(t){if(null!==i.La)if(t=t.data,i.rb+=t.length,rc(i.Xa,"bytes_received",t.length),yh(i),null!==i.frames)zh(i,t);else{t:{if(O(null===i.frames,"We already have a frame buffer"),t.length<=6){var e=Number(t);if(!isNaN(e)){i.ff=e,i.frames=[],t=null;break t}}i.ff=1,i.frames=[]}null!==t&&zh(i,t)}},this.La.onerror=function(t){i.f("WebSocket error.  Closing connection."),(t=t.message||t.data)&&i.f(t),i.bb()}},wh.prototype.start=function(){},wh.isAvailable=function(){var t=!1;if("undefined"!=typeof navigator&&navigator.userAgent){var e=navigator.userAgent.match(/Android ([0-9]{0,}\.[0-9]{0,})/);e&&1<e.length&&parseFloat(e[1])<4.4&&(t=!0)}return!t&&null!==vh&&!xh},wh.responsesRequiredToBeHealthy=2,wh.healthyTimeout=3e4,h=wh.prototype,h.Hd=function(){bd.remove("previous_websocket_failure")},h.send=function(t){yh(this),t=G(t),this.sb+=t.length,rc(this.Xa,"bytes_sent",t.length),1<(t=yd(t,16384)).length&&Ah(this,String(t.length));for(var e=0;e<t.length;e++)Ah(this,t[e])},h.fd=function(){this.Db=!0,this.Nc&&(clearInterval(this.Nc),this.Nc=null),this.La&&(this.La.close(),this.La=null)},h.bb=function(){this.Db||(this.f("WebSocket is closing itself"),this.fd(),this.lb&&(this.lb(this.Kc),this.lb=null))},h.close=function(){this.Db||(this.f("WebSocket is being closed"),this.fd())};var Dh=[nh,wh];function Ch(t,e){var n=wh&&wh.isAvailable(),i=n&&!(bd.Af||!0===bd.get("previous_websocket_failure"));if(e.jh&&(n||S("wss:// URL used, but browser isn't known to support websockets.  Trying anyway."),i=!0),i)t.jd=[wh];else{var r=t.jd=[];zd(Dh,function(t,e){e&&e.isAvailable()&&r.push(e)})}}function Eh(t){if(0<t.jd.length)return t.jd[0];throw Error("No transports available")}function Fh(t,e,n,i,r,o,a){this.id=t,this.f=pd("c:"+this.id+":"),this.nc=n,this.Zc=i,this.na=r,this.Re=o,this.G=e,this.Pd=[],this.kf=0,this.Wf=new Bh(e),this.N=0,this.Fb=a,this.f("Connection created"),Gh(this)}function Gh(t){var e=Eh(t.Wf);t.K=new e("c:"+t.id+":"+t.kf++,t.G,void 0,t.Fb),t.Ve=e.responsesRequiredToBeHealthy||0;var n=Hh(t,t.K),i=Ih(t,t.K);t.kd=t.K,t.ed=t.K,t.F=null,t.Eb=!1,setTimeout(function(){t.K&&t.K.open(n,i)},Math.floor(0)),0<(e=e.healthyTimeout||0)&&(t.Bd=setTimeout(function(){t.Bd=null,t.Eb||(t.K&&102400<t.K.rb?(t.f("Connection exceeded healthy timeout but has received "+t.K.rb+" bytes.  Marking connection healthy."),t.Eb=!0,t.K.Hd()):t.K&&10240<t.K.sb?t.f("Connection exceeded healthy timeout but has sent "+t.K.sb+" bytes.  Leaving connection alive."):(t.f("Closing unhealthy connection after timeout."),t.close()))},Math.floor(e)))}function Ih(e,n){return function(t){n===e.K?(e.K=null,t||0!==e.N?1===e.N&&e.f("Realtime connection lost."):(e.f("Realtime connection failed."),"s-"===e.G.ab.substr(0,2)&&(bd.remove("host:"+e.G.host),e.G.ab=e.G.host)),e.close()):n===e.F?(e.f("Secondary connection lost."),t=e.F,e.F=null,e.kd!==t&&e.ed!==t||e.close()):e.f("closing an old connection")}}function Hh(r,o){return function(t){if(2!=r.N)if(o===r.ed){var e=wd("t",t);if(t=wd("d",t),"c"==e){if(e=wd("t",t),"d"in t)if(t=t.d,"h"===e){e=t.ts;var n=t.v,i=t.h;r.Uf=t.s,ed(r.G,i),0==r.N&&(r.K.start(),Jh(r,r.K,e),"5"!==n&&S("Protocol version mismatch detected"),(t=1<(t=r.Wf).jd.length?t.jd[1]:null)&&Kh(r,t))}else if("n"===e){for(r.f("recvd end transmission on primary"),r.ed=r.F,t=0;t<r.Pd.length;++t)r.Ld(r.Pd[t]);r.Pd=[],Lh(r)}else"s"===e?(r.f("Connection shutdown command received. Shutting down..."),r.Re&&(r.Re(t),r.Re=null),r.na=null,r.close()):"r"===e?(r.f("Reset packet received.  New host: "+t),ed(r.G,t),1===r.N?r.close():(Mh(r),Gh(r))):"e"===e?qd("Server Error: "+t):"o"===e?(r.f("got pong on primary."),Nh(r),Oh(r)):qd("Unknown control packet command: "+e)}else"d"==e&&r.Ld(t)}else if(o===r.F)if(e=wd("t",t),t=wd("d",t),"c"==e)"t"in t&&("a"===(t=t.t)?Ph(r):"r"===t?(r.f("Got a reset on secondary, closing it"),r.F.close(),r.kd!==r.F&&r.ed!==r.F||r.close()):"o"===t&&(r.f("got pong on secondary."),r.Tf--,Ph(r)));else{if("d"!=e)throw Error("Unknown protocol layer: "+e);r.Pd.push(t)}else r.f("message on old connection")}}function Lh(t){t.kd===t.F&&t.ed===t.F&&(t.f("cleaning up and promoting a connection: "+t.F.ue),t.K=t.F,t.F=null)}function Ph(t){t.Tf<=0?(t.f("Secondary connection is healthy."),t.Eb=!0,t.F.Hd(),t.F.start(),t.f("sending client ack on secondary"),t.F.send({t:"c",d:{t:"a",d:{}}}),t.f("Ending transmission on primary"),t.K.send({t:"c",d:{t:"n",d:{}}}),t.kd=t.F,Lh(t)):(t.f("sending ping on secondary."),t.F.send({t:"c",d:{t:"p",d:{}}}))}function Nh(t){t.Eb||(t.Ve--,t.Ve<=0&&(t.f("Primary connection is healthy."),t.Eb=!0,t.K.Hd()))}function Kh(t,e){t.F=new e("c:"+t.id+":"+t.kf++,t.G,t.Uf),t.Tf=e.responsesRequiredToBeHealthy||0,t.F.open(Hh(t,t.F),Ih(t,t.F)),setTimeout(function(){t.F&&(t.f("Timed out trying to upgrade."),t.F.close())},Math.floor(6e4))}function Jh(t,e,n){t.f("Realtime connection established."),t.K=e,t.N=1,t.Zc&&(t.Zc(n,t.Uf),t.Zc=null),0===t.Ve?(t.f("Primary connection is healthy."),t.Eb=!0):setTimeout(function(){Oh(t)},Math.floor(5e3))}function Oh(t){t.Eb||1!==t.N||(t.f("sending ping on primary."),Qh(t,{t:"c",d:{t:"p",d:{}}}))}function Qh(t,e){if(1!==t.N)throw"Connection is not connected";t.kd.send(e)}function Mh(t){t.f("Shutting down all connections"),t.K&&(t.K.close(),t.K=null),t.F&&(t.F.close(),t.F=null),t.Bd&&(clearTimeout(t.Bd),t.Bd=null)}function Rh(t,e,n,i){this.id=Sh++,this.f=pd("p:"+this.id+":"),this.Bf=this.Ie=!1,this.ba={},this.sa=[],this.ad=0,this.Yc=[],this.qa=!1,this.eb=1e3,this.Id=3e5,this.Kb=e,this.Xc=n,this.Se=i,this.G=t,this.wb=this.Ca=this.Ma=this.Fb=this.$e=null,this.Sb=!1,this.Wd={},this.Xg=0,this.rf=!0,this.Oc=this.Ke=null,Th(this,0),kf.yb().Ib("visible",this.Og,this),-1===t.host.indexOf("fblocal")&&jf.yb().Ib("online",this.Mg,this)}Fh.prototype.Ia=function(t){Qh(this,{t:"d",d:t})},Fh.prototype.Ld=function(t){Nh(this),this.nc(t)},Fh.prototype.close=function(){2!==this.N&&(this.f("Closing realtime connection."),this.N=2,Mh(this),this.na&&(this.na(),this.na=null))};var Sh=0,Uh=0;function Vh(r,o){var a=o.Ug,s=a.path.toString(),h=a.wa();r.f("Listen on "+s+" for "+h);var t={p:s};o.tag&&(t.q=Ge(a.n),t.t=o.tag),t.h=o.Ad(),r.Ia("q",t,function(t){var e=t.d,n=t.s;if(e&&"object"==typeof e&&y(e,"w")){var i=z(e,"w");da(i)&&0<=La(i,"no_index")&&S('Using an unspecified index. Consider adding ".indexOn": "'+a.n.g.toString()+'" at '+a.path.toString()+" to your security rules for better performance")}(r.ba[s]&&r.ba[s][h])===o&&(r.f("listen response",t),"ok"!==n&&Wh(r,s,h),o.I&&o.I(n,e))})}function Xh(n){var i=n.Ca;n.qa&&i&&n.Ia("auth",{cred:i.rg},function(t){var e=t.s;t=t.d||"error","ok"!==e&&n.Ca===i&&(n.Ca=null),i.sf?"ok"!==e&&i.od&&i.od(e,t):(i.sf=!0,i.Dc&&i.Dc(e,t))})}function Yh(t,e,n,i,r){n={p:n,d:i},t.f("onDisconnect "+e,n),t.Ia(e,n,function(t){r&&setTimeout(function(){r(t.s,t.d)},Math.floor(0))})}function Zh(t,e,n,i,r,o){i={p:n,d:i},p(o)&&(i.h=o),t.sa.push({action:e,Pf:i,I:r}),t.ad++,e=t.sa.length-1,t.qa?$h(t,e):t.f("Buffering put: "+n)}function $h(e,n){var i=e.sa[n].action,t=e.sa[n].Pf,r=e.sa[n].I;e.sa[n].Vg=e.qa,e.Ia(i,t,function(t){e.f(i+" response",t),delete e.sa[n],e.ad--,0===e.ad&&(e.sa=[]),r&&r(t.s,t.d)})}function Th(t,e){O(!t.Ma,"Scheduling a connect when we're already connected/ing?"),t.wb&&clearTimeout(t.wb),t.wb=setTimeout(function(){t.wb=null,ci(t)},Math.floor(e))}function ci(e){if(di(e)){e.f("Making a connection attempt"),e.Ke=(new Date).getTime(),e.Oc=null;var t=u(e.Ld,e),n=u(e.Zc,e),i=u(e.If,e),r=e.id+":"+Uh++;e.Ma=new Fh(r,e.G,t,n,i,function(t){S(t+" ("+e.G.toString()+")"),e.Bf=!0},e.Fb)}}function ai(t,e,n){(t=Wh(t,e,n=n?Oa(n,function(t){return xd(t)}).join("$"):"default"))&&t.I&&t.I("permission_denied")}function Wh(t,e,n){var i;return e=new P(e).toString(),p(t.ba[e])?(i=t.ba[e][n],delete t.ba[e][n],0===oa(t.ba[e])&&delete t.ba[e]):i=void 0,i}function bi(e){Xh(e),v(e.ba,function(t){v(t,function(t){Vh(e,t)})});for(var t=0;t<e.sa.length;t++)e.sa[t]&&$h(e,t);for(;e.Yc.length;)t=e.Yc.shift(),Yh(e,t.action,t.bd,t.data,t.I)}function di(t){var e;return e=jf.yb().oc,!t.Bf&&!t.Ie&&e}h=Rh.prototype,h.Ia=function(t,e,n){var i=++this.Xg;t={r:i,a:t,b:e},this.f(G(t)),O(this.qa,"sendRequest call when we're not connected not allowed."),this.Ma.Ia(t),n&&(this.Wd[i]=n)},h.Cf=function(t,e,n,i){var r=t.wa(),o=t.path.toString();this.f("Listen called for "+o+" "+r),this.ba[o]=this.ba[o]||{},O(Ie(t.n)||!He(t.n),"listen() called for non-default but complete query"),O(!this.ba[o][r],"listen() called twice for same path/queryId."),t={I:i,Ad:e,Ug:t,tag:n},this.ba[o][r]=t,this.qa&&Vh(this,t)},h.O=function(t,e,n){this.Ca={rg:t,sf:!1,Dc:e,od:n},this.f("Authenticating using credential: "+t),Xh(this),(e=40==t.length)||(e="object"==typeof(t=Cd(t).Ec)&&!0===z(t,"admin")),e&&(this.f("Admin auth credential detected.  Reducing max reconnect time."),this.Id=3e4)},h.je=function(e){this.Ca=null,this.qa&&this.Ia("unauth",{},function(t){e(t.s,t.d)})},h.$f=function(t,e){var n=t.path.toString(),i=t.wa();if(this.f("Unlisten called for "+n+" "+i),O(Ie(t.n)||!He(t.n),"unlisten() called for non-default but complete query"),Wh(this,n,i)&&this.qa){var r=Ge(t.n);this.f("Unlisten on "+n+" for "+i),n={p:n},e&&(n.q=r,n.t=e),this.Ia("n",n)}},h.Qe=function(t,e,n){this.qa?Yh(this,"o",t,e,n):this.Yc.push({bd:t,action:"o",data:e,I:n})},h.Gf=function(t,e,n){this.qa?Yh(this,"om",t,e,n):this.Yc.push({bd:t,action:"om",data:e,I:n})},h.Md=function(t,e){this.qa?Yh(this,"oc",t,null,e):this.Yc.push({bd:t,action:"oc",data:null,I:e})},h.put=function(t,e,n,i){Zh(this,"p",t,e,n,i)},h.Df=function(t,e,n,i){Zh(this,"m",t,e,n,i)},h.Ye=function(t){this.qa&&(t={c:t},this.f("reportStats",t),this.Ia("s",t,function(t){"ok"!==t.s&&this.f("reportStats","Error sending stats: "+t.d)}))},h.Ld=function(t){if("r"in t){this.f("from server: "+G(t));var e=t.r,n=this.Wd[e];n&&(delete this.Wd[e],n(t.b))}else{if("error"in t)throw"A server-side error has occurred: "+t.error;"a"in t&&(e=t.a,n=t.b,this.f("handleServerMessage",e,n),"d"===e?this.Kb(n.p,n.d,!1,n.t):"m"===e?this.Kb(n.p,n.d,!0,n.t):"c"===e?ai(this,n.p,n.q):"ac"===e?(t=n.s,e=n.d,n=this.Ca,this.Ca=null,n&&n.od&&n.od(t,e)):"sd"===e?this.$e?this.$e(n):"msg"in n&&"undefined"!=typeof console&&console.log("FIREBASE: "+n.msg.replace("\n","\nFIREBASE: ")):qd("Unrecognized action received from server: "+G(e)+"\nAre you using the latest client?"))}},h.Zc=function(t,e){if(this.f("connection ready"),this.qa=!0,this.Oc=(new Date).getTime(),this.Se({serverTimeOffset:t-(new Date).getTime()}),this.Fb=e,this.rf){var n={};n["sdk.js."+Eb.replace(/\./g,"-")]=1,Dg()?n["framework.cordova"]=1:"object"==typeof navigator&&"ReactNative"===navigator.product&&(n["framework.reactnative"]=1),this.Ye(n)}bi(this),this.rf=!1,this.Xc(!0)},h.Og=function(t){t&&!this.Sb&&this.eb===this.Id&&(this.f("Window became visible.  Reducing delay."),this.eb=1e3,this.Ma||Th(this,0)),this.Sb=t},h.Mg=function(t){t?(this.f("Browser went online."),this.eb=1e3,this.Ma||Th(this,0)):(this.f("Browser went offline.  Killing connection."),this.Ma&&this.Ma.close())},h.If=function(){this.f("data client disconnected"),this.qa=!1,this.Ma=null;for(var t=0;t<this.sa.length;t++){var e=this.sa[t];e&&"h"in e.Pf&&e.Vg&&(e.I&&e.I("disconnect"),delete this.sa[t],this.ad--)}0===this.ad&&(this.sa=[]),this.Wd={},di(this)&&(this.Sb?this.Oc&&(3e4<(new Date).getTime()-this.Oc&&(this.eb=1e3),this.Oc=null):(this.f("Window isn't visible.  Delaying reconnect."),this.eb=this.Id,this.Ke=(new Date).getTime()),t=Math.max(0,this.eb-((new Date).getTime()-this.Ke)),t*=Math.random(),this.f("Trying to reconnect in "+t+"ms"),Th(this,t),this.eb=Math.min(this.Id,1.3*this.eb)),this.Xc(!1)},h.Cb=function(){this.Ie=!0,this.Ma?this.Ma.close():(this.wb&&(clearTimeout(this.wb),this.wb=null),this.qa&&this.If())},h.vc=function(){this.Ie=!1,this.eb=1e3,this.Ma||Th(this,0)};var U={zg:function(){oh=xh=!0}};function ei(t,e){this.committed=t,this.snapshot=e}function V(t,e){this.dd=t,this.ta=e}function W(t,e,n){this.A=t,this.Y=e,this.g=n}function ii(t,e,n){this.Vb=t,this.tb=e,this.vb=n||null}function ji(t,e,n){this.ja=t,this.tb=e,this.vb=n}function ki(){this.za={}}function mi(t){return Na(qa(t.za),function(t){return!He(t.Y.n)})}function ni(t,e){if(He(e.n))return li(t);var n=e.wa();return z(t.za,n)}function li(t){return ua(t.za,function(t){return He(t.Y.n)})||null}function oi(t){this.va=qe,this.mb=new Pf,this.df={},this.qc={},this.Qc=t}function pi(t,e,n,i,r){var o=t.mb,a=r;return O(i>o.Pc,"Stacking an older write on top of newer ones"),p(a)||(a=!0),o.pa.push({path:e,Ja:n,md:i,visible:a}),a&&(o.V=Jf(o.V,e,n)),o.Pc=i,r?qi(t,new Ac(Ef,e,n)):[]}function ri(t,e,n,i){var r=t.mb;return O(i>r.Pc,"Stacking an older merge on top of newer ones"),r.pa.push({path:e,children:n,md:i,visible:!0}),r.V=Kf(r.V,e,n),r.Pc=i,n=sf(n),qi(t,new bf(Ef,e,n))}function si(t,e,n){n=n||!1;var i=Qf(t.mb,e);if(t.mb.Ud(e)){var r=qe;return null!=i.Ja?r=r.set(M,!0):Fb(i.children,function(t,e){r=r.set(new P(t),e)}),qi(t,new Df(i.path,r,n))}return[]}function ti(t,e,n){return n=sf(n),qi(t,new bf(Gf,e,n))}function ui(t,e,n,i){if(null==(i=vi(t,i)))return[];var r=wi(i);return i=r.path,r=r.Lb,e=lf(i,e),xi(t,i,n=new Ac(new Ff(!1,!0,r,!0),e,n))}function yi(t,e,n,i){if(i=vi(t,i)){var r=wi(i);return i=r.path,r=r.Lb,e=lf(i,e),n=sf(n),xi(t,i,n=new bf(new Ff(!1,!0,r,!0),e,n))}return[]}function Ci(t){return vf(t,function(t,e,n){if(e&&null!=li(e))return[li(e)];var i=[];return e&&(i=mi(e)),v(n,function(t){i=i.concat(t)}),i})}function Gi(t,e){for(var n=0;n<e.length;++n){if(!He((i=e[n]).n)){var i=zi(i),r=t.qc[i];delete t.qc[i],delete t.df["_"+r]}}}function Ei(t){return He(t.n)&&!Ie(t.n)?t.Mb():t}function Bi(t,e,n){var i=e.path,r=Fi(t,e);if(n=Di(t,n),e=t.Qc.af(Ei(e),r,n.Ad,n.I),i=t.va.subtree(i),r)O(null==li(i.value),"If we're adding a query, it shouldn't be shadowed");else for(r=vf(i,function(t,e,n){if(!t.e()&&e&&null!=li(e))return[Ze(li(e))];var i=[];return e&&(i=i.concat(Oa(mi(e),function(t){return t.Y}))),v(n,function(t){i=i.concat(t)}),i}),i=0;i<r.length;++i)n=r[i],t.Qc.de(Ei(n),Fi(t,n));return e}function Di(i,t){var r=t.Y,o=Fi(i,r);return{Ad:function(){return(t.w()||H).hash()},I:function(t){if("ok"!==t)return e="Unknown Error","too_big"===t?e="The data requested exceeds the maximum size that can be accessed with a single request.":"permission_denied"==t?e="Client doesn't have permission to access the desired data.":"unavailable"==t&&(e="The service is unavailable"),(e=Error(t+" at "+r.path.toString()+": "+e)).code=t.toUpperCase(),i.nb(r,null,e);if(o){var e=r.path;if(t=vi(i,o)){var n=wi(t);t=n.path,n=n.Lb,e=lf(t,e),e=new Cc(new Ff(!1,!0,n,!0),e),t=xi(i,t,e)}else t=[]}else t=qi(i,new Cc(Gf,r.path));return t}}}function zi(t){return t.path.toString()+"$"+t.wa()}function wi(t){var e=t.indexOf("$");return O(-1!==e&&e<t.length-1,"Bad queryKey."),{Lb:t.substr(e+1),path:new P(t.substr(0,e))}}function vi(t,e){var n=t.df,i="_"+e;return i in n?n[i]:void 0}function Fi(t,e){var n=zi(e);return z(t.qc,n)}U.forceLongPolling=U.zg,U.Ag=function(){ph=!0},U.forceWebSockets=U.Ag,U.Eg=function(){return wh.isAvailable()},U.isWebSocketsAvailable=U.Eg,U.ah=function(t,e){t.k.Va.$e=e},U.setSecurityDebugCallback=U.ah,U.bf=function(t,e){t.k.bf(e)},U.stats=U.bf,U.cf=function(t,e){t.k.cf(e)},U.statsIncrementCounter=U.cf,U.ud=function(t){return t.k.ud},U.dataUpdateCount=U.ud,U.Dg=function(t,e){t.k.He=e},U.interceptServerData=U.Dg,U.Kg=function(t){new Og(t)},U.onPopupOpen=U.Kg,U.Zg=function(t){xg=t},U.setAuthenticationServer=U.Zg,V.prototype.cancel=function(t){D("Firebase.onDisconnect().cancel",0,1,arguments.length),F("Firebase.onDisconnect().cancel",1,t,!0);var e=new B;return this.dd.Md(this.ta,C(e,t)),e.D},V.prototype.cancel=V.prototype.cancel,V.prototype.remove=function(t){D("Firebase.onDisconnect().remove",0,1,arguments.length),og("Firebase.onDisconnect().remove",this.ta),F("Firebase.onDisconnect().remove",1,t,!0);var e=new B;return fi(this.dd,this.ta,null,C(e,t)),e.D},V.prototype.remove=V.prototype.remove,V.prototype.set=function(t,e){D("Firebase.onDisconnect().set",1,2,arguments.length),og("Firebase.onDisconnect().set",this.ta),gg("Firebase.onDisconnect().set",t,this.ta,!1),F("Firebase.onDisconnect().set",2,e,!0);var n=new B;return fi(this.dd,this.ta,t,C(n,e)),n.D},V.prototype.set=V.prototype.set,V.prototype.Ob=function(t,e,n){D("Firebase.onDisconnect().setWithPriority",2,3,arguments.length),og("Firebase.onDisconnect().setWithPriority",this.ta),gg("Firebase.onDisconnect().setWithPriority",t,this.ta,!1),kg("Firebase.onDisconnect().setWithPriority",2,e),F("Firebase.onDisconnect().setWithPriority",3,n,!0);var i=new B;return gi(this.dd,this.ta,t,e,C(i,n)),i.D},V.prototype.setWithPriority=V.prototype.Ob,V.prototype.update=function(t,e){if(D("Firebase.onDisconnect().update",1,2,arguments.length),og("Firebase.onDisconnect().update",this.ta),da(t)){for(var n={},i=0;i<t.length;++i)n[""+i]=t[i];t=n,S("Passing an Array to Firebase.onDisconnect().update() is deprecated. Use set() if you want to overwrite the existing data, or an Object with integer keys if you really do want to only update some of the children.")}return jg("Firebase.onDisconnect().update",t,this.ta),F("Firebase.onDisconnect().update",2,e,!0),n=new B,hi(this.dd,this.ta,t,C(n,e)),n.D},V.prototype.update=V.prototype.update,W.prototype.J=function(){return D("Firebase.DataSnapshot.val",0,0,arguments.length),this.A.J()},W.prototype.val=W.prototype.J,W.prototype.qf=function(){return D("Firebase.DataSnapshot.exportVal",0,0,arguments.length),this.A.J(!0)},W.prototype.exportVal=W.prototype.qf,W.prototype.xg=function(){return D("Firebase.DataSnapshot.exists",0,0,arguments.length),!this.A.e()},W.prototype.exists=W.prototype.xg,W.prototype.o=function(t){D("Firebase.DataSnapshot.child",0,1,arguments.length),fa(t)&&(t=String(t)),ng("Firebase.DataSnapshot.child",t);var e=new P(t),n=this.Y.o(e);return new W(this.A.S(e),n,R)},W.prototype.child=W.prototype.o,W.prototype.Fa=function(t){D("Firebase.DataSnapshot.hasChild",1,1,arguments.length),ng("Firebase.DataSnapshot.hasChild",t);var e=new P(t);return!this.A.S(e).e()},W.prototype.hasChild=W.prototype.Fa,W.prototype.C=function(){return D("Firebase.DataSnapshot.getPriority",0,0,arguments.length),this.A.C().J()},W.prototype.getPriority=W.prototype.C,W.prototype.forEach=function(n){if(D("Firebase.DataSnapshot.forEach",1,1,arguments.length),F("Firebase.DataSnapshot.forEach",1,n,!1),this.A.L())return!1;var i=this;return!!this.A.R(this.g,function(t,e){return n(new W(e,i.Y.o(t),R))})},W.prototype.forEach=W.prototype.forEach,W.prototype.zd=function(){return D("Firebase.DataSnapshot.hasChildren",0,0,arguments.length),!this.A.L()&&!this.A.e()},W.prototype.hasChildren=W.prototype.zd,W.prototype.name=function(){return S("Firebase.DataSnapshot.name() being deprecated. Please use Firebase.DataSnapshot.key() instead."),D("Firebase.DataSnapshot.name",0,0,arguments.length),this.key()},W.prototype.name=W.prototype.name,W.prototype.key=function(){return D("Firebase.DataSnapshot.key",0,0,arguments.length),this.Y.key()},W.prototype.key=W.prototype.key,W.prototype.Hb=function(){return D("Firebase.DataSnapshot.numChildren",0,0,arguments.length),this.A.Hb()},W.prototype.numChildren=W.prototype.Hb,W.prototype.Mb=function(){return D("Firebase.DataSnapshot.ref",0,0,arguments.length),this.Y},W.prototype.ref=W.prototype.Mb,h=ii.prototype,h.Qf=function(t){return"value"===t},h.createEvent=function(t,e){var n=e.n.g;return new jc("value",this,new W(t.Na,e.Mb(),n))},h.Zb=function(t){var e=this.vb;if("cancel"===t.De()){O(this.tb,"Raising a cancel event on a listener with no cancel callback");var n=this.tb;return function(){n.call(e,t.error)}}var i=this.Vb;return function(){i.call(e,t.be)}},h.lf=function(t,e){return this.tb?new kc(this,t,e):null},h.matches=function(t){return t instanceof ii&&(!t.Vb||!this.Vb||t.Vb===this.Vb&&t.vb===this.vb)},h.yf=function(){return null!==this.Vb},h=ji.prototype,h.Qf=function(t){return("children_removed"===(t="children_added"===t?"child_added":t)?"child_removed":t)in this.ja},h.lf=function(t,e){return this.tb?new kc(this,t,e):null},h.createEvent=function(t,e){O(null!=t.Za,"Child events should have a childName.");var n=e.Mb().o(t.Za);return new jc(t.type,this,new W(t.Na,n,e.n.g),t.Td)},h.Zb=function(t){var e=this.vb;if("cancel"===t.De()){O(this.tb,"Raising a cancel event on a listener with no cancel callback");var n=this.tb;return function(){n.call(e,t.error)}}var i=this.ja[t.wd];return function(){i.call(e,t.be,t.Td)}},h.matches=function(n){if(n instanceof ji){if(!this.ja||!n.ja)return!0;if(this.vb===n.vb)if((t=oa(n.ja))===oa(this.ja)){if(1!==t)return na(this.ja,function(t,e){return n.ja[e]===t});var t=pa(n.ja),e=pa(this.ja);return!(e!==t||n.ja[t]&&this.ja[e]&&n.ja[t]!==this.ja[e])}}return!1},h.yf=function(){return null!==this.ja},h=ki.prototype,h.e=function(){return va(this.za)},h.gb=function(e,n,i){var t=e.source.Lb;if(null!==t)return t=z(this.za,t),O(null!=t,"SyncTree gave us an op for an invalid query."),t.gb(e,n,i);var r=[];return v(this.za,function(t){r=r.concat(t.gb(e,n,i))}),r},h.Tb=function(t,e,n,i,r){var o=t.wa();if(!(a=z(this.za,o))){var a,s=!1;s=!!(a=n.Aa(r?i:null))||(a=i instanceof fe?n.Cc(i):H,!1),a=new Ye(t,new je(new Xb(a,s,!1),new Xb(i,r,!1))),this.za[o]=a}return a.Tb(e),af(a,e)},h.nb=function(t,n,i){var e=t.wa(),r=[],o=[],a=null!=li(this);if("default"===e){var s=this;v(this.za,function(t,e){o=o.concat(t.nb(n,i)),t.e()&&(delete s.za[e],He(t.Y.n)||r.push(t.Y))})}else{var h=z(this.za,e);h&&(o=o.concat(h.nb(n,i)),h.e()&&(delete this.za[e],He(h.Y.n)||r.push(h.Y)))}return a&&null==li(this)&&r.push(new X(t.k,t.path)),{Wg:r,vg:o}},h.kb=function(e){var n=null;return v(this.za,function(t){n=n||t.kb(e)}),n},oi.prototype.Tb=function(t,e){var i=t.path,r=null,o=!1;zf(this.va,i,function(t,e){var n=lf(t,i);r=r||e.kb(n),o=o||null!=li(e)});var n,a=this.va.get(i);a?(o=o||null!=li(a),r=r||a.kb(M)):(a=new ki,this.va=this.va.set(i,a)),null!=r?n=!0:(n=!1,r=H,Cf(this.va.subtree(i),function(t,e){var n=e.kb(M);n&&(r=r.W(t,n))}));var s=null!=ni(a,t);if(!s&&!He(t.n)){var h=zi(t);O(!(h in this.qc),"View does not exist, but we have a tag");var u=Ai++;this.qc[h]=u,this.df["_"+u]=h}return n=a.Tb(t,e,new Uf(i,this.mb),r,n),s||o||(a=ni(a,t),n=n.concat(Bi(this,t,a))),n},oi.prototype.nb=function(t,e,n){var i=t.path,r=this.va.get(i),o=[];if(r&&("default"===t.wa()||null!=ni(r,t))){o=r.nb(t,e,n),r.e()&&(this.va=this.va.remove(i)),r=o.Wg,o=o.vg,e=-1!==Sa(r,function(t){return He(t.n)});var a=xf(this.va,i,function(t,e){return null!=li(e)});if(e&&!a&&!(i=this.va.subtree(i)).e()){i=Ci(i);for(var s=0;s<i.length;++s){var h=(u=i[s]).Y,u=Di(this,u);this.Qc.af(Ei(h),Fi(this,h),u.Ad,u.I)}}if(!a&&0<r.length&&!n)if(e)this.Qc.de(Ei(t),null);else{var c=this;Ma(r,function(t){t.wa();var e=c.qc[zi(t)];c.Qc.de(Ei(t),e)})}Gi(this,r)}return o},oi.prototype.Aa=function(i,t){var e=this.mb,n=xf(this.va,i,function(t,e){var n=lf(t,i);if(n=e.kb(n))return n});return e.Aa(i,n,t,!0)};var Ai=1;function xi(t,e,n){var i=t.va.get(e);return O(i,"Missing sync point for query tag that we're tracking"),i.gb(n,new Uf(e,t.mb),null)}function qi(t,e){return Hi(t,e,t.va,null,new Uf(M,t.mb))}function Hi(t,e,n,i,r){if(e.path.e())return Ii(t,e,n,i,r);var o=n.get(M);null==i&&null!=o&&(i=o.kb(M));var a=[],s=K(e.path),h=e.$c(s);if((n=n.children.get(s))&&h){var u=i?i.T(s):null;s=r.o(s),a=a.concat(Hi(t,h,n,u,s))}return o&&(a=a.concat(o.gb(e,r,i))),a}function Ii(o,a,t,s,h){var e=t.get(M);null==s&&null!=e&&(s=e.kb(M));var u=[];return t.children.ka(function(t,e){var n=s?s.T(t):null,i=h.o(t),r=a.$c(t);r&&(u=u.concat(Ii(o,r,e,n,i)))}),e&&(u=u.concat(e.gb(a,h,s))),u}function Ji(t,e){this.G=t,this.Xa=uc(t),this.hd=null,this.fa=new Zb,this.Kd=1,this.Va=null,e||0<=("object"==typeof window&&window.navigator&&window.navigator.userAgent||"").search(/googlebot|google webmaster tools|bingbot|yahoo! slurp|baiduspider|yandexbot|duckduckbot/i)?(this.da=new cf(this.G,u(this.Kb,this)),setTimeout(u(this.Xc,this,!0),0)):this.da=this.Va=new Rh(this.G,u(this.Kb,this),u(this.Xc,this),u(this.Se,this)),this.eh=vc(t,u(function(){return new pc(this.Xa,this.da)},this)),this.yc=new Wf,this.Ge=new Sb;var o=this;this.Fd=new oi({af:function(t,e,n,i){return e=[],(n=o.Ge.j(t.path)).e()||(e=qi(o.Fd,new Ac(Gf,t.path,n)),setTimeout(function(){i("ok")},0)),e},de:aa}),Ki(this,"connected",!1),this.na=new Vc,this.O=new Yg(t,u(this.da.O,this.da),u(this.da.je,this.da),u(this.Pe,this)),this.ud=0,this.He=null,this.M=new oi({af:function(i,t,e,r){return o.da.Cf(i,e,t,function(t,e){var n=r(t,e);dc(o.fa,i.path,n)}),[]},de:function(t,e){o.da.$f(t,e)}})}function Li(t){return t=t.Ge.j(new P(".info/serverTimeOffset")).J()||0,(new Date).getTime()+t}function Mi(t){return(t=t={timestamp:Li(t)}).timestamp=t.timestamp||(new Date).getTime(),t}function Ki(t,e,n){e=new P("/.info/"+e),n=Q(n);var i=t.Ge;i.Zd=i.Zd.H(e,n),n=qi(t.Fd,new Ac(Gf,e,n)),dc(t.fa,e,n)}function Oi(i){i.f("onDisconnectEvents");var t=Mi(i),r=[];Wc(Uc(i.na,t),M,function(t,e){r=r.concat(qi(i.M,new Ac(Gf,t,e)));var n=Qi(i,t);Ni(i,n)}),i.na=new Vc,dc(i.fa,M,r)}function fi(n,i,t,r){var o=Q(t);n.da.Qe(i.toString(),o.J(!0),function(t,e){"ok"===t&&n.na.rc(i,o),Pi(r,t,e)})}function gi(n,i,t,e,r){var o=Q(t,e);n.da.Qe(i.toString(),o.J(!0),function(t,e){"ok"===t&&n.na.rc(i,o),Pi(r,t,e)})}function hi(r,o,a,s){var t,e=!0;for(t in a)e=!1;e?(fc("onDisconnect().update() called with empty data.  Don't do anything."),Pi(s,"ok")):r.da.Gf(o.toString(),a,function(t,e){if("ok"===t)for(var n in a){var i=Q(a[n]);r.na.rc(o.o(n),i)}Pi(s,t,e)})}function Ri(t,e,n){n=".info"===K(e.path)?t.Fd.Tb(e,n):t.M.Tb(e,n),bc(t.fa,e.path,n)}function Pi(n,i,r){n&&gc(function(){if("ok"==i)n(null);else{var t=(i||"error").toUpperCase(),e=t;r&&(e+=": "+r),(e=Error(e)).code=t,n(e)}})}function Si(t,e,n,i,r){function o(){}t.f("transaction on "+e);var a=new X(t,e);if(a.Ib("value",o),n={path:e,update:n,I:i,status:null,Lf:id(),gf:r,Sf:0,le:function(){a.mc("value",o)},ne:null,Da:null,rd:null,sd:null,td:null},i=t.M.Aa(e,void 0)||H,n.rd=i,p(i=n.update(i.J()))){hg("transaction failed: Data returned ",i,n.path),n.status=1;var s=(r=Xf(t.yc,e)).Ea()||[];s.push(n),Yf(r,s),"object"==typeof i&&null!==i&&y(i,".priority")?(s=z(i,".priority"),O(fg(s),"Invalid priority returned by transaction. Priority must be a valid string, finite number, server value, or null.")):s=(t.M.Aa(e)||H).C().J(),r=Mi(t),r=Xc(i=Q(i,s),r),n.sd=i,n.td=r,n.Da=t.Kd++,n=pi(t.M,e,r,n.Da,n.gf),dc(t.fa,e,n),Ti(t)}else n.le(),n.sd=null,n.td=null,n.I&&(t=new W(n.rd,new X(t,n.path),R),n.I(null,!1,t))}function Ti(e,t){var n=t||e.yc;if(t||Ui(e,n),null!==n.Ea()){var i=Vi(e,n);O(0<i.length,"Sending zero length transaction queue"),Qa(i,function(t){return 1===t.status})&&Wi(e,n.path(),i)}else n.zd()&&n.R(function(t){Ti(e,t)})}function Wi(r,o,a){for(var t=Oa(a,function(t){return t.Da}),e=(t=e=r.M.Aa(o,t)||H,e.hash()),s=0;s<a.length;s++){var n=a[s];O(1===n.status,"tryToSendTransactionQueue_: items in queue should all be run."),n.status=2,n.Sf++;var i=lf(o,n.path);t=t.H(i,n.sd)}t=t.J(!0),r.da.put(o.toString(),t,function(t){r.f("transaction put response",{path:o.toString(),status:t});var e=[];if("ok"===t){for(t=[],s=0;s<a.length;s++){if(a[s].status=3,e=e.concat(si(r.M,a[s].Da)),a[s].I){var n=a[s].td,i=new X(r,a[s].path);t.push(u(a[s].I,null,null,!0,new W(n,i,R)))}a[s].le()}for(Ui(r,Xf(r.yc,o)),Ti(r),dc(r.fa,o,e),s=0;s<t.length;s++)gc(t[s])}else{if("datastale"===t)for(s=0;s<a.length;s++)a[s].status=4===a[s].status?5:1;else for(S("transaction at "+o.toString()+" failed: "+t),s=0;s<a.length;s++)a[s].status=5,a[s].ne=t;Ni(r,o)}},e)}function Ni(t,e){var n,i=(n=Xi(t,e)).path();return Yi(t,n=Vi(t,n),i),i}function Yi(t,e,n){if(0!==e.length){for(var i=[],r=[],o=Na(e,function(t){return 1===t.status}),a=(o=Oa(o,function(t){return t.Da}),0);a<e.length;a++){var s,h=e[a],c=lf(n,h.path),f=!1;if(O(null!==c,"rerunTransactionsUnderNode_: relativePath should not be null."),5===h.status)f=!0,s=h.ne,r=r.concat(si(t.M,h.Da,!0));else if(1===h.status)if(25<=h.Sf)f=!0,s="maxretry",r=r.concat(si(t.M,h.Da,!0));else{var l=t.M.Aa(h.path,o)||H;h.rd=l;var d=e[a].update(l.J());r=p(d)?(hg("transaction failed: Data returned ",d,h.path),c=Q(d),"object"==typeof d&&null!=d&&y(d,".priority")||(c=c.ia(l.C())),l=h.Da,d=Xc(c,d=Mi(t)),h.sd=c,h.td=d,h.Da=t.Kd++,Ta(o,l),(r=r.concat(pi(t.M,h.path,d,h.Da,h.gf))).concat(si(t.M,l,!0))):(f=!0,s="nodata",r.concat(si(t.M,h.Da,!0)))}dc(t.fa,n,r),r=[],f&&(e[a].status=3,setTimeout(e[a].le,Math.floor(0)),e[a].I&&("nodata"===s?(h=new X(t,e[a].path),i.push(u(e[a].I,null,null,!1,new W(e[a].rd,h,R)))):i.push(u(e[a].I,null,Error(s),!1,null))))}for(Ui(t,t.yc),a=0;a<i.length;a++)gc(i[a]);Ti(t)}}function Xi(t,e){for(var n,i=t.yc;null!==(n=K(e))&&null===i.Ea();)i=Xf(i,n),e=N(e);return i}function Vi(t,e){var n=[];return Zi(t,e,n),n.sort(function(t,e){return t.Lf-e.Lf}),n}function Zi(e,t,n){var i=t.Ea();if(null!==i)for(var r=0;r<i.length;r++)n.push(i[r]);t.R(function(t){Zi(e,t,n)})}function Ui(e,t){var n=t.Ea();if(n){for(var i=0,r=0;r<n.length;r++)3!==n[r].status&&(n[i]=n[r],i++);n.length=i,Yf(t,0<n.length?n:null)}t.R(function(t){Ui(e,t)})}function Qi(e,t){var n=Xi(e,t).path(),i=Xf(e.yc,t);return ag(i,function(t){$i(e,t)}),$i(e,i),$f(i,function(t){$i(e,t)}),n}function $i(t,e){var n=e.Ea();if(null!==n){for(var i=[],r=[],o=-1,a=0;a<n.length;a++)4!==n[a].status&&(2===n[a].status?(O(o===a-1,"All SENT items should be at beginning of queue."),n[o=a].status=4,n[a].ne="set"):(O(1===n[a].status,"Unexpected transaction status in abort"),n[a].le(),r=r.concat(si(t.M,n[a].Da,!0)),n[a].I&&i.push(u(n[a].I,null,Error("set"),!1,null))));for(-1===o?Yf(e,null):n.length=o+1,dc(t.fa,e.path(),r),a=0;a<i.length;a++)gc(i[a])}}function aj(){this.sc={},this.ag=!1}function Y(t,e,n,i){this.k=t,this.path=e,this.n=n,this.pc=i}function bj(t){var e=null,n=null;if(t.oa&&(e=Od(t)),t.ra&&(n=Rd(t)),t.g===re){if(t.oa){if("[MIN_NAME]"!=Nd(t))throw Error("Query: When ordering by key, you may only pass one argument to startAt(), endAt(), or equalTo().");if("string"!=typeof e)throw Error("Query: When ordering by key, the argument passed to startAt(), endAt(),or equalTo() must be a string.")}if(t.ra){if("[MAX_NAME]"!=Pd(t))throw Error("Query: When ordering by key, you may only pass one argument to startAt(), endAt(), or equalTo().");if("string"!=typeof n)throw Error("Query: When ordering by key, the argument passed to startAt(), endAt(),or equalTo() must be a string.")}}else if(t.g===R){if(null!=e&&!fg(e)||null!=n&&!fg(n))throw Error("Query: When ordering by priority, the first argument passed to startAt(), endAt(), or equalTo() must be a valid priority value (null, a number, or a string).")}else if(O(t.g instanceof ve||t.g===Be,"unknown index type."),null!=e&&"object"==typeof e||null!=n&&"object"==typeof n)throw Error("Query: First argument passed to startAt(), endAt(), or equalTo() cannot be an object.")}function cj(t){if(t.oa&&t.ra&&t.la&&(!t.la||""===t.Rb))throw Error("Query: Can't combine startAt(), endAt(), and limit(). Use limitToFirst() or limitToLast() instead.")}function dj(t,e){if(!0===t.pc)throw Error(e+": You can't combine multiple orderBy calls.")}function ej(t,e,n){var i={cancel:null,Qa:null};if(e&&n)i.cancel=e,F(t,3,i.cancel,!0),i.Qa=n,Qb(t,4,i.Qa);else if(e)if("object"==typeof e&&null!==e)i.Qa=e;else{if("function"!=typeof e)throw Error(E(t,3,!0)+" must either be a cancel callback or a context object.");i.cancel=e}return i}h=Ji.prototype,h.toString=function(){return(this.G.ob?"https://":"http://")+this.G.host},h.name=function(){return this.G.lc},h.Kb=function(t,e,n,i){this.ud++;var r=new P(t);e=this.He?this.He(t,e):e,t=[],t=i?n?(e=ma(e,function(t){return Q(t)}),yi(this.M,r,e,i)):(e=Q(e),ui(this.M,r,e,i)):n?(i=ma(e,function(t){return Q(t)}),ti(this.M,r,i)):(i=Q(e),qi(this.M,new Ac(Gf,r,i))),i=r,0<t.length&&(i=Ni(this,r)),dc(this.fa,i,t)},h.Xc=function(t){Ki(this,"connected",t),!1===t&&Oi(this)},h.Se=function(t){var n=this;zd(t,function(t,e){Ki(n,e,t)})},h.Pe=function(t){Ki(this,"authenticated",t)},h.Ob=function(i,t,e,r){this.f("set",{path:i.toString(),value:t,nh:e});var n=Mi(this),o=(n=Xc(t=Q(t,e),n),this.Kd++);n=pi(this.M,i,n,o,!0);$b(this.fa,n);var a=this;this.da.put(i.toString(),t.J(!0),function(t,e){var n="ok"===t;n||S("set at "+i+" failed: "+t),n=si(a.M,o,!n),dc(a.fa,i,n),Pi(r,t,e)}),Ni(this,n=Qi(this,i)),dc(this.fa,n,[])},h.update=function(r,t,o){this.f("update",{path:r.toString(),value:t});var i=!0,a=Mi(this),s={};if(v(t,function(t,e){i=!1;var n=Q(t);s[e]=Xc(n,a)}),i)fc("update() called with empty data.  Don't do anything."),Pi(o,"ok");else{var h=this.Kd++,e=ri(this.M,r,s,h);$b(this.fa,e);var u=this;this.da.Df(r.toString(),t,function(t,e){(n="ok"===t)||S("update at "+r+" failed: "+t);var n=si(u.M,h,!n),i=r;0<n.length&&(i=Ni(u,r)),dc(u.fa,i,n),Pi(o,t,e)}),Ni(this,t=Qi(this,r)),dc(this.fa,r,[])}},h.Md=function(n,i){var r=this;this.da.Md(n.toString(),function(t,e){"ok"===t&&wg(r.na,n),Pi(i,t,e)})},h.Cb=function(){this.Va&&this.Va.Cb()},h.vc=function(){this.Va&&this.Va.vc()},h.bf=function(t){if("undefined"!=typeof console){t=t?(this.hd||(this.hd=new oc(this.Xa)),this.hd.get()):this.Xa.get();var e,n=Pa(ra(t),function(t,e){return Math.max(e.length,t)},0);for(e in t){for(var i=t[e],r=e.length;r<n+2;r++)e+=" ";console.log(e+i)}}},h.cf=function(t){rc(this.Xa,t),this.eh.Vf[t]=!0},h.f=function(t){var e="";this.Va&&(e=this.Va.id+":"),fc(e,arguments)},aj.prototype.Cb=function(){for(var t in this.sc)this.sc[t].Cb()},aj.prototype.vc=function(){for(var t in this.sc)this.sc[t].vc()},aj.prototype.ze=function(){this.ag=!0},ba(aj),aj.prototype.interrupt=aj.prototype.Cb,aj.prototype.resume=aj.prototype.vc,h=Y.prototype,h.Mb=function(){return D("Query.ref",0,0,arguments.length),new X(this.k,this.path)},h.Ib=function(t,e,n,i){D("Query.on",2,4,arguments.length),lg("Query.on",t,!1),F("Query.on",2,e,!1);var r=ej("Query.on",n,i);if("value"===t)Ri(this.k,this,new ii(e,r.cancel||null,r.Qa||null));else{var o={};o[t]=e,Ri(this.k,this,new ji(o,r.cancel,r.Qa))}return e},h.mc=function(t,e,n){D("Query.off",0,3,arguments.length),lg("Query.off",t,!0),F("Query.off",2,e,!0),Qb("Query.off",3,n);var i=null,r=null;"value"===t?i=new ii(e||null,null,n||null):t&&(e&&((r={})[t]=e),i=new ji(r,null,n||null)),r=this.k,i=".info"===K(this.path)?r.Fd.nb(this,i):r.M.nb(this,i),bc(r.fa,this.path,i)},h.Pg=function(e,n){function i(t){a&&(a=!1,o.mc(e,i),n&&n.call(r.Qa,t),s.resolve(t))}D("Query.once",1,4,arguments.length),lg("Query.once",e,!1),F("Query.once",2,n,!0);var r=ej("Query.once",arguments[2],arguments[3]),o=this,a=!0,s=new B;return Nb(s.D),this.Ib(e,i,function(t){o.mc(e,i),r.cancel&&r.cancel.call(r.Qa,t),s.reject(t)}),s.D},h.Le=function(t){if(S("Query.limit() being deprecated. Please use Query.limitToFirst() or Query.limitToLast() instead."),D("Query.limit",1,1,arguments.length),!fa(t)||Math.floor(t)!==t||t<=0)throw Error("Query.limit: First argument must be a positive integer.");if(this.n.la)throw Error("Query.limit: Limit was already set (by another call to limit, limitToFirst, orlimitToLast.");var e=this.n.Le(t);return cj(e),new Y(this.k,this.path,e,this.pc)},h.Me=function(t){if(D("Query.limitToFirst",1,1,arguments.length),!fa(t)||Math.floor(t)!==t||t<=0)throw Error("Query.limitToFirst: First argument must be a positive integer.");if(this.n.la)throw Error("Query.limitToFirst: Limit was already set (by another call to limit, limitToFirst, or limitToLast).");return new Y(this.k,this.path,this.n.Me(t),this.pc)},h.Ne=function(t){if(D("Query.limitToLast",1,1,arguments.length),!fa(t)||Math.floor(t)!==t||t<=0)throw Error("Query.limitToLast: First argument must be a positive integer.");if(this.n.la)throw Error("Query.limitToLast: Limit was already set (by another call to limit, limitToFirst, or limitToLast).");return new Y(this.k,this.path,this.n.Ne(t),this.pc)},h.Qg=function(t){if(D("Query.orderByChild",1,1,arguments.length),"$key"===t)throw Error('Query.orderByChild: "$key" is invalid.  Use Query.orderByKey() instead.');if("$priority"===t)throw Error('Query.orderByChild: "$priority" is invalid.  Use Query.orderByPriority() instead.');if("$value"===t)throw Error('Query.orderByChild: "$value" is invalid.  Use Query.orderByValue() instead.');ng("Query.orderByChild",t),dj(this,"Query.orderByChild");var e=new P(t);if(e.e())throw Error("Query.orderByChild: cannot pass in empty path.  Use Query.orderByValue() instead.");return e=new ve(e),bj(e=Fe(this.n,e)),new Y(this.k,this.path,e,!0)},h.Rg=function(){D("Query.orderByKey",0,0,arguments.length),dj(this,"Query.orderByKey");var t=Fe(this.n,re);return bj(t),new Y(this.k,this.path,t,!0)},h.Sg=function(){D("Query.orderByPriority",0,0,arguments.length),dj(this,"Query.orderByPriority");var t=Fe(this.n,R);return bj(t),new Y(this.k,this.path,t,!0)},h.Tg=function(){D("Query.orderByValue",0,0,arguments.length),dj(this,"Query.orderByValue");var t=Fe(this.n,Be);return bj(t),new Y(this.k,this.path,t,!0)},h.ce=function(t,e){D("Query.startAt",0,2,arguments.length),gg("Query.startAt",t,this.path,!0),mg("Query.startAt",e);var n=this.n.ce(t,e);if(cj(n),bj(n),this.n.oa)throw Error("Query.startAt: Starting point was already set (by another call to startAt or equalTo).");return p(t)||(e=t=null),new Y(this.k,this.path,n,this.pc)},h.vd=function(t,e){D("Query.endAt",0,2,arguments.length),gg("Query.endAt",t,this.path,!0),mg("Query.endAt",e);var n=this.n.vd(t,e);if(cj(n),bj(n),this.n.ra)throw Error("Query.endAt: Ending point was already set (by another call to endAt or equalTo).");return new Y(this.k,this.path,n,this.pc)},h.tg=function(t,e){if(D("Query.equalTo",1,2,arguments.length),gg("Query.equalTo",t,this.path,!1),mg("Query.equalTo",e),this.n.oa)throw Error("Query.equalTo: Starting point was already set (by another call to endAt or equalTo).");if(this.n.ra)throw Error("Query.equalTo: Ending point was already set (by another call to endAt or equalTo).");return this.ce(t,e).vd(t,e)},h.toString=function(){D("Query.toString",0,0,arguments.length);for(var t=this.path,e="",n=t.aa;n<t.u.length;n++)""!==t.u[n]&&(e+="/"+encodeURIComponent(String(t.u[n])));return this.k.toString()+(e||"/")},h.wa=function(){var t=xd(Ge(this.n));return"{}"===t?"default":t},Y.prototype.ref=Y.prototype.Mb,Y.prototype.on=Y.prototype.Ib,Y.prototype.off=Y.prototype.mc,Y.prototype.once=Y.prototype.Pg,Y.prototype.limit=Y.prototype.Le,Y.prototype.limitToFirst=Y.prototype.Me,Y.prototype.limitToLast=Y.prototype.Ne,Y.prototype.orderByChild=Y.prototype.Qg,Y.prototype.orderByKey=Y.prototype.Rg,Y.prototype.orderByPriority=Y.prototype.Sg,Y.prototype.orderByValue=Y.prototype.Tg,Y.prototype.startAt=Y.prototype.ce,Y.prototype.endAt=Y.prototype.vd,Y.prototype.equalTo=Y.prototype.tg,Y.prototype.toString=Y.prototype.toString;var Z={};function X(t,e){var n,i,r;if(t instanceof Ji)n=t,i=e;else{var o;if(D("new Firebase",1,2,arguments.length),n=(i=sd(t)).fh,"firebase"===i.domain&&rd(i.host+" is no longer supported. Please use <YOUR FIREBASE>.firebaseio.com instead"),n&&"undefined"!=n||rd("Cannot parse Firebase url. Please use https://<YOUR FIREBASE>.firebaseio.com"),i.ob||"undefined"!=typeof window&&window.location&&window.location.protocol&&-1!==window.location.protocol.indexOf("https:")&&S("Insecure Firebase access from a secure page. Please use https in calls to new Firebase()."),n=new dd(i.host,i.ob,n,"ws"===i.scheme||"wss"===i.scheme),r=(i=new P(i.bd)).toString(),!(o=!q(n.host)||0===n.host.length||!eg(n.lc))&&(o=0!==r.length)&&(o=!(q(r=r&&r.replace(/^\/*\.info(\/|$)/,"/"))&&0!==r.length&&!cg.test(r))),o)throw Error(E("new Firebase",1,!1)+'must be a valid firebase URL and the path can\'t contain ".", "#", "$", "[", or "]".');if(e)if(e instanceof aj)r=e;else{if(!q(e))throw Error("Expected a valid Firebase.Context for second argument to new Firebase()");r=aj.yb(),n.Rd=e}else r=aj.yb();o=n.toString();var a=z(r.sc,o);a||(a=new Ji(n,r.ag),r.sc[o]=a),n=a}Y.call(this,n,i,De,!1),this.then=void 0,this["catch"]=void 0}Z.zc=Rh,Z.DataConnection=Z.zc,Rh.prototype.dh=function(t,e){this.Ia("q",{p:t},e)},Z.zc.prototype.simpleListen=Z.zc.prototype.dh,Rh.prototype.sg=function(t,e){this.Ia("echo",{d:t},e)},Z.zc.prototype.echo=Z.zc.prototype.sg,Rh.prototype.interrupt=Rh.prototype.Cb,Z.dg=Fh,Z.RealTimeConnection=Z.dg,Fh.prototype.sendRequest=Fh.prototype.Ia,Fh.prototype.close=Fh.prototype.close,Z.Cg=function(r){var o=Rh.prototype.put;return Rh.prototype.put=function(t,e,n,i){p(i)&&(i=r()),o.call(this,t,e,n,i)},function(){Rh.prototype.put=o}},Z.hijackHash=Z.Cg,Z.cg=dd,Z.ConnectionTarget=Z.cg,Z.wa=function(t){return t.wa()},Z.queryIdentifier=Z.wa,Z.Fg=function(t){return t.k.Va.ba},Z.listens=Z.Fg,Z.ze=function(t){t.ze()},Z.forceRestClient=Z.ze,ka(X,Y);var fj=X,gj=["Firebase"],hj=n,ij;gj[0]in hj||!hj.execScript||hj.execScript("var "+gj[0]);for(;gj.length&&(ij=gj.shift());)!gj.length&&p(fj)?hj[ij]=fj:hj=hj[ij]?hj[ij]:hj[ij]={};X.goOffline=function(){D("Firebase.goOffline",0,0,arguments.length),aj.yb().Cb()},X.goOnline=function(){D("Firebase.goOnline",0,0,arguments.length),aj.yb().vc()},X.enableLogging=od,X.ServerValue={TIMESTAMP:{".sv":"timestamp"}},X.SDK_VERSION=Eb,X.INTERNAL=U,X.Context=aj,X.TEST_ACCESS=Z,X.prototype.name=function(){return S("Firebase.name() being deprecated. Please use Firebase.key() instead."),D("Firebase.name",0,0,arguments.length),this.key()},X.prototype.name=X.prototype.name,X.prototype.key=function(){return D("Firebase.key",0,0,arguments.length),this.path.e()?null:me(this.path)},X.prototype.key=X.prototype.key,X.prototype.o=function(t){if(D("Firebase.child",1,1,arguments.length),fa(t))t=String(t);else if(!(t instanceof P))if(null===K(this.path)){var e=t;ng("Firebase.child",e=e&&e.replace(/^\/*\.info(\/|$)/,"/"))}else ng("Firebase.child",t);return new X(this.k,this.path.o(t))},X.prototype.child=X.prototype.o,X.prototype.parent=function(){D("Firebase.parent",0,0,arguments.length);var t=this.path.parent();return null===t?null:new X(this.k,t)},X.prototype.parent=X.prototype.parent,X.prototype.root=function(){D("Firebase.ref",0,0,arguments.length);for(var t=this;null!==t.parent();)t=t.parent();return t},X.prototype.root=X.prototype.root,X.prototype.set=function(t,e){D("Firebase.set",1,2,arguments.length),og("Firebase.set",this.path),gg("Firebase.set",t,this.path,!1),F("Firebase.set",2,e,!0);var n=new B;return this.k.Ob(this.path,t,null,C(n,e)),n.D},X.prototype.set=X.prototype.set,X.prototype.update=function(t,e){if(D("Firebase.update",1,2,arguments.length),og("Firebase.update",this.path),da(t)){for(var n={},i=0;i<t.length;++i)n[""+i]=t[i];t=n,S("Passing an Array to Firebase.update() is deprecated. Use set() if you want to overwrite the existing data, or an Object with integer keys if you really do want to only update some of the children.")}return jg("Firebase.update",t,this.path),F("Firebase.update",2,e,!0),n=new B,this.k.update(this.path,t,C(n,e)),n.D},X.prototype.update=X.prototype.update,X.prototype.Ob=function(t,e,n){if(D("Firebase.setWithPriority",2,3,arguments.length),og("Firebase.setWithPriority",this.path),gg("Firebase.setWithPriority",t,this.path,!1),kg("Firebase.setWithPriority",2,e),F("Firebase.setWithPriority",3,n,!0),".length"===this.key()||".keys"===this.key())throw"Firebase.setWithPriority failed: "+this.key()+" is a read-only object.";var i=new B;return this.k.Ob(this.path,t,e,C(i,n)),i.D},X.prototype.setWithPriority=X.prototype.Ob,X.prototype.remove=function(t){return D("Firebase.remove",0,1,arguments.length),og("Firebase.remove",this.path),F("Firebase.remove",1,t,!0),this.set(null,t)},X.prototype.remove=X.prototype.remove,X.prototype.transaction=function(t,i,e){if(D("Firebase.transaction",1,3,arguments.length),og("Firebase.transaction",this.path),F("Firebase.transaction",1,t,!1),F("Firebase.transaction",2,i,!0),p(e)&&"boolean"!=typeof e)throw Error(E("Firebase.transaction",3,!0)+"must be a boolean.");if(".length"===this.key()||".keys"===this.key())throw"Firebase.transaction failed: "+this.key()+" is a read-only object.";void 0===e&&(e=!0);var o=new B;return r(i)&&Nb(o.D),Si(this.k,this.path,t,function(t,e,n){t?o.reject(t):o.resolve(new ei(e,n)),r(i)&&i(t,e,n)},e),o.D},X.prototype.transaction=X.prototype.transaction,X.prototype.$g=function(t,e){D("Firebase.setPriority",1,2,arguments.length),og("Firebase.setPriority",this.path),kg("Firebase.setPriority",1,t),F("Firebase.setPriority",2,e,!0);var n=new B;return this.k.Ob(this.path.o(".priority"),t,null,C(n,e)),n.D},X.prototype.setPriority=X.prototype.$g,X.prototype.push=function(t,e){D("Firebase.push",0,2,arguments.length),og("Firebase.push",this.path),gg("Firebase.push",t,this.path,!0),F("Firebase.push",2,e,!0);var n=Li(this.k),i=hf(n);n=this.o(i);if(null!=t){var o=this,a=n.set(t,e).then(function(){return o.o(i)});n.then=u(a.then,a),n["catch"]=u(a.then,a,void 0),r(e)&&Nb(a)}return n},X.prototype.push=X.prototype.push,X.prototype.lb=function(){return og("Firebase.onDisconnect",this.path),new V(this.k,this.path)},X.prototype.onDisconnect=X.prototype.lb,X.prototype.O=function(t,e,n){S("FirebaseRef.auth() being deprecated. Please use FirebaseRef.authWithCustomToken() instead."),D("Firebase.auth",1,3,arguments.length),pg("Firebase.auth",t),F("Firebase.auth",2,e,!0),F("Firebase.auth",3,e,!0);var i=new B;return dh(this.k.O,t,{},{remember:"none"},C(i,e),n),i.D},X.prototype.auth=X.prototype.O,X.prototype.je=function(t){D("Firebase.unauth",0,1,arguments.length),F("Firebase.unauth",1,t,!0);var e=new B;return eh(this.k.O,C(e,t)),e.D},X.prototype.unauth=X.prototype.je,X.prototype.Be=function(){return D("Firebase.getAuth",0,0,arguments.length),this.k.O.Be()},X.prototype.getAuth=X.prototype.Be,X.prototype.Jg=function(t,e){D("Firebase.onAuth",1,2,arguments.length),F("Firebase.onAuth",1,t,!1),Qb("Firebase.onAuth",2,e),this.k.O.Ib("auth_status",t,e)},X.prototype.onAuth=X.prototype.Jg,X.prototype.Ig=function(t,e){D("Firebase.offAuth",1,2,arguments.length),F("Firebase.offAuth",1,t,!1),Qb("Firebase.offAuth",2,e),this.k.O.mc("auth_status",t,e)},X.prototype.offAuth=X.prototype.Ig,X.prototype.hg=function(t,e,n){D("Firebase.authWithCustomToken",1,3,arguments.length),2===arguments.length&&Hb(e)&&(n=e,e=void 0),pg("Firebase.authWithCustomToken",t),F("Firebase.authWithCustomToken",2,e,!0),sg("Firebase.authWithCustomToken",3,n,!0);var i=new B;return dh(this.k.O,t,{},n||{},C(i,e)),i.D},X.prototype.authWithCustomToken=X.prototype.hg,X.prototype.ig=function(t,e,n){D("Firebase.authWithOAuthPopup",1,3,arguments.length),2===arguments.length&&Hb(e)&&(n=e,e=void 0),rg("Firebase.authWithOAuthPopup",t),F("Firebase.authWithOAuthPopup",2,e,!0),sg("Firebase.authWithOAuthPopup",3,n,!0);var i=new B;return ih(this.k.O,t,n,C(i,e)),i.D},X.prototype.authWithOAuthPopup=X.prototype.ig,X.prototype.jg=function(t,e,n){D("Firebase.authWithOAuthRedirect",1,3,arguments.length),2===arguments.length&&Hb(e)&&(n=e,e=void 0),rg("Firebase.authWithOAuthRedirect",t),F("Firebase.authWithOAuthRedirect",2,e,!1),sg("Firebase.authWithOAuthRedirect",3,n,!0);var i=new B,r=this.k.O,o=n,a=C(i,e);gh(r);var s=[Qg];o=Ag(o);return"anonymous"===t||"firebase"===t?T(a,Sg("TRANSPORT_UNAVAILABLE")):(cd.set("redirect_client_options",o.qd),hh(r,s,"/auth/"+t,o,a)),i.D},X.prototype.authWithOAuthRedirect=X.prototype.jg,X.prototype.kg=function(t,e,n,i){D("Firebase.authWithOAuthToken",2,4,arguments.length),3===arguments.length&&Hb(n)&&(i=n,n=void 0),rg("Firebase.authWithOAuthToken",t),F("Firebase.authWithOAuthToken",3,n,!0),sg("Firebase.authWithOAuthToken",4,i,!0);var r=new B;return q(e)?(qg("Firebase.authWithOAuthToken",2,e),fh(this.k.O,t+"/token",{access_token:e},i,C(r,n))):(sg("Firebase.authWithOAuthToken",2,e,!1),fh(this.k.O,t+"/token",e,i,C(r,n))),r.D},X.prototype.authWithOAuthToken=X.prototype.kg,X.prototype.gg=function(t,e){D("Firebase.authAnonymously",0,2,arguments.length),1===arguments.length&&Hb(t)&&(e=t,t=void 0),F("Firebase.authAnonymously",1,t,!0),sg("Firebase.authAnonymously",2,e,!0);var n=new B;return fh(this.k.O,"anonymous",{},e,C(n,t)),n.D},X.prototype.authAnonymously=X.prototype.gg,X.prototype.lg=function(t,e,n){D("Firebase.authWithPassword",1,3,arguments.length),2===arguments.length&&Hb(e)&&(n=e,e=void 0),sg("Firebase.authWithPassword",1,t,!1),tg("Firebase.authWithPassword",t,"email"),tg("Firebase.authWithPassword",t,"password"),F("Firebase.authWithPassword",2,e,!0),sg("Firebase.authWithPassword",3,n,!0);var i=new B;return fh(this.k.O,"password",t,n,C(i,e)),i.D},X.prototype.authWithPassword=X.prototype.lg,X.prototype.ve=function(t,e){D("Firebase.createUser",1,2,arguments.length),sg("Firebase.createUser",1,t,!1),tg("Firebase.createUser",t,"email"),tg("Firebase.createUser",t,"password"),F("Firebase.createUser",2,e,!0);var n=new B;return this.k.O.ve(t,C(n,e)),n.D},X.prototype.createUser=X.prototype.ve,X.prototype.Xe=function(t,e){D("Firebase.removeUser",1,2,arguments.length),sg("Firebase.removeUser",1,t,!1),tg("Firebase.removeUser",t,"email"),tg("Firebase.removeUser",t,"password"),F("Firebase.removeUser",2,e,!0);var n=new B;return this.k.O.Xe(t,C(n,e)),n.D},X.prototype.removeUser=X.prototype.Xe,X.prototype.se=function(t,e){D("Firebase.changePassword",1,2,arguments.length),sg("Firebase.changePassword",1,t,!1),tg("Firebase.changePassword",t,"email"),tg("Firebase.changePassword",t,"oldPassword"),tg("Firebase.changePassword",t,"newPassword"),F("Firebase.changePassword",2,e,!0);var n=new B;return this.k.O.se(t,C(n,e)),n.D},X.prototype.changePassword=X.prototype.se,X.prototype.re=function(t,e){D("Firebase.changeEmail",1,2,arguments.length),sg("Firebase.changeEmail",1,t,!1),tg("Firebase.changeEmail",t,"oldEmail"),tg("Firebase.changeEmail",t,"newEmail"),tg("Firebase.changeEmail",t,"password"),F("Firebase.changeEmail",2,e,!0);var n=new B;return this.k.O.re(t,C(n,e)),n.D},X.prototype.changeEmail=X.prototype.re,X.prototype.Ze=function(t,e){D("Firebase.resetPassword",1,2,arguments.length),sg("Firebase.resetPassword",1,t,!1),tg("Firebase.resetPassword",t,"email"),F("Firebase.resetPassword",2,e,!0);var n=new B;return this.k.O.Ze(t,C(n,e)),n.D},X.prototype.resetPassword=X.prototype.Ze}();
!function(z){var w,e={className:"autosizejs",id:"autosizejs",append:"\n",callback:!1,resizeDelay:10,placeholder:!0},f=["fontFamily","fontSize","fontWeight","fontStyle","letterSpacing","textTransform","wordSpacing","textIndent","whiteSpace"],b=z('<textarea aria-hidden="true" tabindex="-1"/>').data("autosize",!0)[0];b.style.cssText="position:absolute; top:-999px; left:0; right:auto; bottom:auto; border:0; padding: 0; -moz-box-sizing:content-box; -webkit-box-sizing:content-box; box-sizing:content-box; word-wrap:break-word; height:0 !important; min-height:0 !important; overflow:hidden; transition:none; -webkit-transition:none; -moz-transition:none;",(b.style.lineHeight="99px")===z(b).css("lineHeight")&&f.push("lineHeight"),b.style.lineHeight="",z.fn.autosize=function(p){return this.length?(p=z.extend({},e,p||{}),b.parentNode!==document.body&&z(document.body).append(b),this.each(function(){var a,o,e,n=this,s=z(n),r=0,l=z.isFunction(p.callback),t={height:n.style.height,overflow:n.style.overflow,overflowY:n.style.overflowY,wordWrap:n.style.wordWrap,resize:n.style.resize},i=s.width(),d=s.css("resize");function c(){var o,i=window.getComputedStyle?window.getComputedStyle(n,null):null;i?(o=parseFloat(i.width),"border-box"!==i.boxSizing&&"border-box"!==i.webkitBoxSizing&&"border-box"!==i.mozBoxSizing||z.each(["paddingLeft","paddingRight","borderLeftWidth","borderRightWidth"],function(e,t){o-=parseFloat(i[t])})):o=s.width(),b.style.width=Math.max(o,0)+"px"}function h(){var e,t;w!==n?function i(){var o={};if(w=n,b.className=p.className,b.id=p.id,a=parseFloat(s.css("maxHeight")),z.each(f,function(e,t){o[t]=s.css(t)}),z(b).css(o).attr("wrap",s.attr("wrap")),c(),window.chrome){var e=n.style.width;n.style.width="0px";n.offsetWidth;n.style.width=e}}():c(),!n.value&&p.placeholder?b.value=s.attr("placeholder")||"":b.value=n.value,b.value+=p.append||"",b.style.overflowY=n.style.overflowY,t=parseFloat(n.style.height)||0,b.scrollTop=0,b.scrollTop=9e4,e=b.scrollTop,a&&a<e?(n.style.overflowY="scroll",e=a):(n.style.overflowY="hidden",e<o&&(e=o)),e+=r,.01<Math.abs(t-e)&&(n.style.height=e+"px",b.className=b.className,l&&p.callback.call(n,n),s.trigger("autosize.resized"))}function u(){clearTimeout(e),e=setTimeout(function(){var e=s.width();e!==i&&(i=e,h())},parseInt(p.resizeDelay,10))}s.data("autosize")||(s.data("autosize",!0),"border-box"!==s.css("box-sizing")&&"border-box"!==s.css("-moz-box-sizing")&&"border-box"!==s.css("-webkit-box-sizing")||(r=s.outerHeight()-s.height()),o=Math.max(parseFloat(s.css("minHeight"))-r||0,s.height()),s.css({overflow:"hidden",overflowY:"hidden",wordWrap:"break-word"}),"vertical"===d?s.css("resize","none"):"both"===d&&s.css("resize","horizontal"),"onpropertychange"in n?"oninput"in n?s.on("input.autosize keyup.autosize",h):s.on("propertychange.autosize",function(){"value"===event.propertyName&&h()}):s.on("input.autosize",h),!1!==p.resizeDelay&&z(window).on("resize.autosize",u),s.on("autosize.resize",h),s.on("autosize.resizeIncludeStyle",function(){w=null,h()}),s.on("autosize.destroy",function(){w=null,clearTimeout(e),z(window).off("resize",u),s.off("autosize").off(".autosize").css(t).removeData("autosize")}),h())})):this}}(jQuery||$);
!function(d,h,p,c){var e="plugin_ylc",t={app_id:"",render:!0,display_login:!0,user_info:{user_id:null,user_name:null,user_email:null,gravatar:null,user_type:null,avatar_type:null,avatar_image:null,current_page:null,user_ip:null},styles:{bg_color:"#009EDB",x_pos:"right",y_pos:"bottom",border_radius:"5px 5px 0 0",popup_width:370,btn_width:260,btn_height:0,btn_type:"classic",form_width:260,animation_type:"bounceIn",autoplay:!0,autoplay_delay:1e3}},l=null,s={end_chat_frontend:function(t){if(t){var e=new Date;this.trigger_premium("save_user_data",this.data.user.conversation_id,!0,e.getTime(),!0)}},premium_frontend:function(){var a=this,n=!1,i=!1,e=!1;if(d(p).on("click","#YLC_send_btn",function(t){if(n)return!1;if(ylc.gdpr&&!d("#YLC_gdpr_acceptance").is(":checked"))return a.display_ntf(a.strings.msg.field_empty,"error","#YLC_offline_ntf"),!1;a.display_ntf(a.strings.msg.sending+"...","sending ","#YLC_offline_ntf");var e=d("#YLC_popup_form").serializeArray(),i=e.length-1;return d.each(e,function(t,e){if(a.data.current_form[e.name]=e.value,!e.value)return a.display_ntf(a.strings.msg.field_empty,"error","#YLC_offline_ntf"),!1;if("email"===e.name){if(!a.validate_email(e.value))return a.display_ntf(a.strings.msg.invalid_email,"error","#YLC_offline_ntf"),!1}else if("name"===e.name&&!a.validate_username(e.value))return a.display_ntf(a.strings.msg.invalid_username,"error","#YLC_offline_ntf"),!1;if(t===i){n=!0;var s=d("#YLC_popup_form").serialize()+"&vendor_id="+ylc.active_vendor.vendor_id;a.post("ylc_ajax_offline_form",s,function(t){n=!1,t.error?a.display_ntf(t.error,"error","#YLC_offline_ntf"):t.warn?(a.display_ntf(t.warn,"success","#YLC_offline_ntf"),setTimeout(function(){a.clean_ntf(),a.minimize()},4e3)):(a.display_ntf(t.msg,"success","#YLC_offline_ntf"),setTimeout(function(){a.clean_ntf(),a.minimize()},2e3))})}}),!1}),d(p).on("mouseenter","#YLC_send_btn",function(){d(this).css("background-color",a.data.primary_hover)}),d(p).on("mouseleave","#YLC_send_btn",function(){d(this).css("background-color",a.opts.styles.bg_color)}),d(p).on("click","#YLC_good_btn, #YLC_bad_btn",function(t){if(i)return!1;i=!0,a.display_ntf(a.strings.msg.sending+"...","sending","#YLC_end_chat_ntf");var e="YLC_good_btn"===d(this).attr("id")?"good":"bad",s=d("#YLC_request_chat").is(":checked")?1:0;return a.post("ylc_ajax_chat_evaluation",{conversation_id:a.data.user.conversation_id,evaluation:e,receive_copy:s,user_email:a.data.user.user_email,chat_with:a.data.user.chat_with},function(){i=!1}),a.minimize(),!1}),d(p).on("click","#YLC_chat_request",function(t){if(e)return!1;e=!0,a.display_ntf(a.strings.msg.sending+"...","sending","#YLC_end_chat_ntf");return a.post("ylc_ajax_chat_evaluation",{conversation_id:a.data.user.conversation_id,evaluation:"",receive_copy:1,user_email:a.data.user.user_email,chat_with:a.data.user.chat_with},function(){e=!1}),a.minimize(),!1}),"round"==this.opts.styles.btn_type){var t=this.opts.styles.btn_width/2;d("#YLC_chat_btn.btn-round").css({color:this.data.primary_fg,"background-color":this.opts.styles.bg_color,width:this.opts.styles.btn_width+"px",height:this.opts.styles.btn_width+"px","-webkit-border-radius":t+"px","-moz-border-radius":t+"px","border-radius":t+"px",right:"right"===this.opts.styles.x_pos?"20px":"auto",left:"right"===this.opts.styles.x_pos?"auto":"20px",top:"top"===this.opts.styles.y_pos?"20px":"auto",bottom:"top"===this.opts.styles.y_pos?"auto":"20px"}),d("#YLC_chat_btn .chat-ico.chat").css({width:this.opts.styles.btn_width+"px"}),d("#YLC_chat_btn div").css({"line-height":this.opts.styles.btn_width+"px"})}else d("#YLC_chat_btn").css({color:this.data.primary_fg,"background-color":this.opts.styles.bg_color,width:this.opts.styles.btn_width+"px","-webkit-border-radius":this.opts.styles.border_radius,"-moz-border-radius":this.opts.styles.border_radius,"border-radius":this.opts.styles.border_radius,right:"right"===this.opts.styles.x_pos?"20px":"auto",left:"right"===this.opts.styles.x_pos?"auto":"20px",top:"top"===this.opts.styles.y_pos?"0":"auto",bottom:"top"===this.opts.styles.y_pos?"auto":"0"});d("#YLC_chat").css({"-webkit-border-radius":this.opts.styles.border_radius,"-moz-border-radius":this.opts.styles.border_radius,"border-radius":this.opts.styles.border_radius,right:"right"===this.opts.styles.x_pos?"40px":"auto",left:"right"===this.opts.styles.x_pos?"auto":"40px",top:"top"===this.opts.styles.y_pos?"0":"auto",bottom:"top"===this.opts.styles.y_pos?"auto":"0"}),d("#YLC_chat_header").css({color:this.data.primary_fg,"background-color":this.opts.styles.bg_color}),d(".chat-form-btn").css({color:this.data.primary_fg,"background-color":this.opts.styles.bg_color}),"bottom"!==this.opts.styles.y_pos&&d(".chat-body").css({"-webkit-border-radius":this.opts.styles.border_radius,"-moz-border-radius":this.opts.styles.border_radius,"border-radius":this.opts.styles.border_radius})},chat_duration:function(t,e){if(""==e||""==t)return"00:00:00";var s=.001*(e-t)>>0,i=s/60>>0,a=i/60>>0;return(a=(a%=60)<10?"0"+a:a)+":"+(i=(i%=60)<10?"0"+i:i)+":"+(s=(s%=60)<10?"0"+s:s)},save_user_data:function(r,_,a,u,l){var c=this;this.data.ref_cnv.child(r).once("value",function(t){var e=null!==t.val(),s=t.val();if(e){var o=s.user_id,i=c.trigger_premium("chat_duration",s.accepted_at,a);c.data.ref_users.child(o).once("value",function(t){var n=t.val();n.created_at=s.created_at,n.evaluation=s.evaluation,n.duration=i,n.receive_copy=s.receive_copy,n.send_email=u,c.data.ref_msgs.once("value",function(t){var e=t.val(),s=e?Object.keys(e).length:0,i=0,a={};e?d.each(e,function(t,e){i+=1,e.conversation_id===r&&(a[t]=e,_&&c.data.ref_msgs.child(t).remove()),s===i&&(n.msgs=a,c.post("ylc_ajax_save_chat",n,function(t){l&&l(t)}))}):l&&l({}),_&&(c.data.ref_users.child(o).remove(),c.data.ref_cnv.child(r).remove())})})}else l&&l({})})},set_avatar_premium:function(t,e){if("admin"!=t)return"https://www.gravatar.com/avatar/"+e.gravatar+".jpg?s=60&d="+ylc.default_user_avatar;switch(e.avatar_type){case"gravatar":return"https://www.gravatar.com/avatar/"+e.gravatar+".jpg?s=60&d="+ylc.default_admin_avatar;case"image":return e.avatar_image;default:return""!=ylc.company_avatar?ylc.company_avatar:this.data.assets_url+"/images/default-avatar-"+t+".png"}},logged_users_auth:function(){""!=this.opts.user_info.user_name&&""!=this.opts.user_info.user_email&&(d("#YLC_field_name").val(this.opts.user_info.user_name),d("#YLC_msg_name").val(this.opts.user_info.user_name),d("#YLC_field_email").val(this.opts.user_info.user_email),d("#YLC_msg_email").val(this.opts.user_info.user_email))},autoplay:function(){0<this.opts.styles.autoplay_delay&&setTimeout(function(){d("#YLC_chat_btn").click()},this.opts.styles.autoplay_delay)}};function i(){this.opts=d.extend(t,ylc.defaults),this.premium=d.extend({},s)}i.prototype={init:function(){this.data={auth:null,ref:null,is_mobile:!1,active_user_id:0,mode:"offline",logged:!1,assets_url:ylc.plugin_url,animation_delay:1e3,show_delay:ylc.show_delay,guest_prefix:"Guest-",primary_fg:null,primary_hover:null,popup_status:"close",user:{},current_form:{},online_ops:{}},this.strings=ylc.strings,this.objs={btn:null,popup:null,popup_header:null,cnv:null};var e=this;this.trigger_premium("logged_users_auth"),this.trigger_premium("premium_frontend"),/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)&&(this.data.is_mobile=!0),this.post("ylc_ajax_get_token",{},function(t){t.error||(e.data.auth_token=t.token,e.render_chat(),e.trigger_premium("autoplay"))})},auth:function(t){this.opts.app_id?(null==this.data.ref&&(this.data.ref=new Firebase("https://"+this.opts.app_id+".firebaseIO.com"),this.data.ref_conn=new Firebase("https://"+this.opts.app_id+".firebaseIO.com/.info/connected"),this.data.ref_cnv=new Firebase("https://"+this.opts.app_id+".firebaseIO.com/chat_sessions"),this.data.ref_msgs=new Firebase("https://"+this.opts.app_id+".firebaseIO.com/chat_messages"),this.data.ref_users=new Firebase("https://"+this.opts.app_id+".firebaseIO.com/chat_users")),this.opts.display_login?this.login(!1,t):this.login(!0,t)):console.error("App ID not provided")},login:function(t,_){var u=this;this.purge_firebase(),this.manage_connections(),this.data._new_user=t,this.data.auth=this.data.ref.authWithCustomToken(this.data.auth_token,function(t){t?(console.error(t.code,t.message),u.display_ntf(u.strings.msg.conn_err,"error","#YLC_login_ntf")):(u.data.logged=!0,u.data.ref_users.once("value",function(t){var e=t.val(),s=0,i=!1,a=0,n=!1,o=!1;if(null!==e){var r=Object.keys(e).length;d.each(e,function(t,e){a++,e&&("operator"==e.user_type&&"online"===e.status?u.valid_operator(e.vendor_id)&&(u.data.online_ops[e.user_id]=e):"operator"!=e.user_type&&(e.user_name!==c&&e.user_id!=u.opts.user_info.user_id&&s++,e.user_email!==c&&u.data.current_form.user_email!==c&&(e.user_email!=u.data.current_form.user_email||ylc.frontend_op_access||(e.user_ip==u.opts.user_info.user_ip?"online"===e.status&&e.user_id!=u.opts.user_info.user_id?n=!0:o=e.conversation_id:n=!0)))),n?u.display_ntf(u.strings.msg.already_logged,"error","#YLC_login_ntf"):a===r&&(u.total_online_ops()||o?"operator"==u.opts.user_info.user_type||s<ylc.max_guests||0==ylc.max_guests?(null!=l&&clearInterval(l),u.opts.display_login?u.show_login():u.show_cnv(!0)):(i=!0,u.show_offline(!0)):u.show_offline(),u.check_user(u.opts.user_info.user_id,i,o))})}else u.show_offline(),u.check_user(u.opts.user_info.user_id,!1);_&&_(i)}))})},logout:function(t){var e=this;this.data.user.user_id&&(e.data.ref_user.off(),e.data.ref_users.off(),e.data.ref_msgs.off()),d(".chat-body").hide(),d("#YLC_end_chat").show(),ylc.is_premium?e.trigger_premium("end_chat_frontend",t):(t&&e.clear_user_data(e.data.user.conversation_id),setTimeout(function(){e.be_offline(),e.minimize()},2e3)),e.objs.cnv.empty(),e.objs.popup_header.click(function(){e.minimize(),e.objs.popup_header.off("click")}),d(h).trigger("resize")},be_offline:function(){this.data.mode="offline",this.data.ref_user&&(this.data.ref_user.child("status").set("offline"),this.data.ref_user.child("last_online").set(Firebase.ServerValue.TIMESTAMP)),this.check_mode(!0)},check_mode:function(t){var e=this.data.mode;if(t)this.show_connecting(),this.data.mode="offline";else if(this.total_online_ops())"offline"===e&&(d("#YLC_cnv_reply").removeClass("chat-disabled").removeAttr("disabled"),this.clean_ntf()),this.data.mode=this.opts.display_login&&"online"!=e?"login":"online";else{switch(e){case"login":this.show_offline();break;case"online":ylc.is_premium||(this.opts.display_login?(d("#YLC_cnv_reply").addClass("chat-disabled").attr("disabled","disabled"),this.display_ntf(this.strings.msg.no_op+"!","error","#YLC_popup_ntf")):this.show_offline())}this.data.mode="offline"}},show_offline:function(t){var i=this;this.data.mode="offline",this.allow_chatbox()&&(i.objs.popup.parent().removeClass().addClass("chat-offline"),d(".chat-body").hide(),d("#YLC_offline .chat-lead").hide(),d("#YLC_offline").show(),t?(ylc.show_busy_form||d("#YLC_popup_form").hide(),d("#YLC_offline .chat-lead.op-busy").show(),null!=l&&clearInterval(l),l=setInterval(function(){i.data.ref_users.once("value",function(t){var e=t.val(),s=0;null!==e&&d.each(e,function(t,e){e&&e.user_name!==c&&"operator"!=e.user_type&&e.user_id!=i.opts.user_info.user_id&&s++}),s<ylc.max_guests&&(i.opts.display_login?i.login(!1):i.login(!0))})},3e4)):d("#YLC_offline .chat-lead.op-offline").show(),d(h).trigger("resize"))},show_connecting:function(){d(".chat-body").hide(),d("#YLC_connecting").show()},show_login:function(){var e=this;this.allow_chatbox()&&(this.opts.display_login&&this.total_online_ops()&&this.objs.popup?(this.data.mode="login",this.objs.popup.parent().removeClass().addClass("chat-login"),d(".chat-body").hide(),d("#YLC_login").show(),d(h).trigger("resize"),d("#YLC_login_btn").hover(function(){d(this).css("background-color",e.data.primary_hover)},function(){d(this).css("background-color",e.opts.styles.bg_color)}).click(function(){e.send_login_form()}),d("#YLC_login_form").keydown(function(t){13!=t.keyCode||t.shiftKey||(t.preventDefault(),e.send_login_form())})):"online"===e.data.mode?this.show_cnv():this.show_offline())},send_login_form:function(){var s=this;if(ylc.chat_gdpr&&!d("#YLC_chat_gdpr_acceptance").is(":checked"))return s.display_ntf(s.strings.msg.field_empty,"error","#YLC_login_ntf"),!1;this.display_ntf(this.strings.msg.connecting+"...","sending","#YLC_login_ntf");var t=d("#YLC_login_form").serializeArray(),i=t.length-1;d.each(t,function(t,e){if(s.data.current_form[e.name]=e.value,!e.value)return s.display_ntf(s.strings.msg.field_empty,"error","#YLC_login_ntf"),!1;if("user_email"===e.name){if(!s.validate_email(e.value))return s.display_ntf(s.strings.msg.invalid_email,"error","#YLC_login_ntf"),!1;s.data.current_form.gravatar=s.md5(e.value)}else if(!s.validate_username(e.value))return s.display_ntf(s.strings.msg.invalid_username,"error","#YLC_login_ntf"),!1;t===i&&setTimeout(function(){s.login(!0)},1e4)})},check_user:function(s,t,i){var a=this;this.data.ref_user=this.data.ref_users.child(s),t?this.data.ref_user.child("status").set("wait"):(this.data.ref_user.once("value",function(t){var e=t.val();e=e||{},a.get_user(s,e,i)}),this.data.ref_user.child("chat_with").on("value",function(t){var e=t.val();null!=e&&(a.data.user.chat_with=e)})),this.data.ref_users.on("child_removed",function(t){var e=t.val();e&&s===e.user_id&&a.logout()})},get_user:function(t,e,s,i){var a=this;if(e.user_id)this.data.user=e,this.data.ref_user.child("status").set("online"),this.data.ref_user.child("user_ip").set(a.opts.user_info.user_ip),this.data.ref_user.child("current_page").set(a.opts.user_info.current_page),this.data.ref_user.child("vendor_id").set(ylc.active_vendor.vendor_id),this.data.ref_user.child("vendor_name").set(ylc.active_vendor.vendor_name),this.data.ref_user.child("chat_with").set("free"),this.total_online_ops()?this.show_cnv():this.show_offline(),this.manage_connections(),a.listen_users(),i&&i();else if(!0===this.data._new_user){var n={user_id:t,conversation_id:this.data.ref_cnv.push({user_id:t,created_at:Firebase.ServerValue.TIMESTAMP,accepted_at:"",evaluation:"",user_type:"visitor",receive_copy:!1}).key(),last_online:"",is_mobile:this.data.is_mobile,chat_with:"free",status:"online",vendor_id:ylc.active_vendor.vendor_id,vendor_name:ylc.active_vendor.vendor_name};for(var o in this.opts.user_info)n[o]=this.opts.user_info[o];for(var r in this.data.current_form)n[r]=this.data.current_form[r];n.user_name||(n.user_email?n.user_name=n.user_email.substring(0,n.user_email.indexOf("@")):n.user_name=this.data.guest_prefix+this.random_id(1e3,5e3)),this.data.user=n,this.data.ref_user.set(n,function(t){if(!t&&(a.show_cnv(),a.manage_connections(),a.listen_users(),s))if(ylc.is_premium){var e=new Date;a.trigger_premium("save_user_data",s,!0,e.getTime(),!1)}else a.clear_user_data(s);i&&i()})}else a.listen_users()},show_cnv:function(t){var e=this;this.data.mode="online",this.allow_chatbox()&&(this.objs.popup.parent().removeClass().addClass("chat-online"),d(".chat-body").hide(),d("#YLC_chat_body").show(),this.objs.cnv=d("#YLC_cnv"),t?setTimeout(function(){d("#YLC_cnv_reply").focus().autosize({append:""}).trigger("autosize.resize")},this.data.animation_delay):d("#YLC_cnv_reply").focus().autosize({append:""}).trigger("autosize.resize"),d(h).trigger("resize"),this.listen_msgs(),d("#YLC_tool_end_chat").click(function(){e.push_msg("-- "+e.strings.msg.close_msg_user+" --"),e.data.ref_cnv.child(e.data.user.conversation_id).child("status").set("closed"),e.logout(!0)}),this.manage_reply_box())},listen_users:function(){var a=this;this.data.last_changed_id=null,this.data.ref_users.once("value",function(t){var e=t.val(),s=0;if(null!==e){var i=Object.keys(e).length;a.data.online_ops={},d.each(e,function(t,e){s+=1,e&&a.valid_operator(e.vendor_id)&&"operator"===e.user_type&&("online"===e.status?a.data.online_ops[e.user_id]=e:delete a.data.online_ops[e.user_id]),s===i&&(a.check_mode(),a.listen_new_users())})}})},listen_new_users:function(t){var s=this;this.data.ref_users.on("value",function(t){var e=t.val();d.each(e,function(t,e){s.update_user(e)})})},update_user:function(t,e){t&&!t.user_id||(t&&(t.conversation_id?("operator"===t.user_type&&("online"===t.status?this.data.online_ops[t.user_id]=t:delete this.data.online_ops[t.user_id]),this.check_mode()):this.clean_user_data(t.user_id)),this.data.last_changed_id=e)},clean_user_data:function(s){var i=this,a=this.data.ref_users.child(s);a.once("value",function(t){var e=t.val();a.remove(),e.conversation_id&&i.ref_cnv.child(e.conversation_id),i.data.ref_msgs.once("value",function(t){var e=t.val();e&&d.each(e,function(t,e){e.user_id===s&&i.data.ref_msgs.child(t).remove()})})})},set_avatar:function(t,e){return t="operator"==t?"admin":"user",ylc.is_premium?this.trigger_premium("set_avatar_premium",t,e):this.data.assets_url+"/images/default-avatar-"+t+".png"},time:function(t,e){return this.strings.time[t]&&this.strings.time[t].replace(/%d/i,Math.abs(Math.round(e)))},timeago:function(t){if(!t)return"";var e=.001*((new Date).getTime()-t)>>0,s=e/60,i=s/60,a=i/24,n=a/365;return(e<45&&this.time("seconds",e)||e<90&&this.time("minute",1)||s<45&&this.time("minutes",s)||s<90&&this.time("hour",1)||i<24&&this.time("hours",i)||i<42&&this.time("day",1)||a<30&&this.time("days",a)||a<45&&this.time("month",1)||a<365&&this.time("months",a/30)||n<1.5&&this.time("year",1)||this.time("years",n))+" "+this.strings.time.suffix},listen_msgs:function(){var a=this;this.data.ref_msgs.off(),this.data.ref_msgs.once("value",function(t){var e=t.val(),s=e?Object.keys(e).length:0,i=1;e?d.each(e,function(t,e){a.data.user.conversation_id==e.conversation_id&&(e.id=t,a.add_msg(e)),e.first_load=!0,s==i&&a.listen_new_msgs(t),i+=1}):a.listen_new_msgs()})},listen_new_msgs:function(t){var s=this,e=t?s.data.ref_msgs.startAt(null,t):s.data.ref_msgs,i=!0;t||(i=!1),e.on("child_added",function(t){var e=t.val();e.id=t.key(),s.data.user.conversation_id==e.conversation_id&&(i||s.add_msg(e)),i||s.show_popup(),i=!1})},add_msg:function(t){var e=new Date,s=new Date(t.msg_time),i=s.getHours()+":"+(s.getMinutes()<10?"0":"")+s.getMinutes(),a=this.sanitize_msg(t.msg),n=s.toDateString()==e.toDateString()?i:s.getUTCDate()+" "+this.strings.months_short[s.getUTCMonth()]+", "+i;if(this.objs.cnv.find(".chat-welc").hide(),this.objs.cnv){var o=t.user_id==this.data.user.user_id?" chat-you":"",r=s.getUTCDate()+" "+this.strings.months[s.getUTCMonth()]+" "+s.getUTCFullYear()+" "+i,_=this.set_avatar(t.user_type,{gravatar:t.gravatar,avatar_type:t.avatar_type,avatar_image:t.avatar_image});this.objs.cnv.append('<div id="YLC_msg_'+t.id+'" class="chat-cnv-line'+o+'"><div title="'+r+'" class="chat-cnv-time">'+n+'</div><div class="chat-avatar"><img src="'+_+'" /></div><div class="chat-cnv-msg"><div class="chat-cnv-author">'+t.user_name+"</div>"+a+'</div></div><div class="chat-clear"></div>').scrollTop(this.objs.cnv.prop("scrollHeight"))}},sanitize_msg:function(t){var e,s,i,a,n={"&":"&amp;","<":"&lt;",">":"&gt;"};return a=/\n/gim,e=/(\b(https?|ftp):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gim,s=/(^|[^\/])(www\.[\S]+(\b|$))/gim,i=/(([a-zA-Z0-9\-\_\.])+@[a-zA-Z\_]+?(\.[a-zA-Z]{2,6})+)/gim,t.replace(/[&<>]/g,function(t){return n[t]||t}).replace(a,"<br />").replace(e,'<a href="$1" target="_blank">$1</a>').replace(s,'$1<a href="http://$2" target="_blank">$2</a>').replace(i,'<a href="mailto:$1">$1</a>')},manage_reply_box:function(t){var s,a=this,i=!1,e=d("#YLC_cnv_reply"),n=(s=0,function(t,e){clearTimeout(s),s=setTimeout(t,e)});this.data.ref_cnv.child(this.data.user.conversation_id+"/typing").remove(),e.keydown(function(t){if(13!==t.keyCode||t.shiftKey){if(!i){switch(t.keyCode){case 17:case 18:case 16:case 9:case 8:case 224:case 17:case 91:case 93:return}a.data.ref_cnv.child(a.data.user.conversation_id+"/typing/"+a.data.user.user_id).set(a.data.user.user_name),i=!0}n(function(){a.data.ref_cnv.child(a.data.user.conversation_id+"/typing/"+a.data.user.user_id).remove(),i=!1},1300)}else{t.preventDefault();var e=d(this).val();e&&(d(this).val("").trigger("autosize.resize"),a.push_msg(e),a.data.ref_cnv.child(a.data.user.conversation_id+"/typing/"+a.data.user.user_id).remove())}}),t&&this.data.ref_cnv.child(t+"/typing").off(),this.data.ref_cnv.child(this.data.user.conversation_id+"/typing").on("value",function(t){var s=0,e=t.val(),i=e?Object.keys(e).length:0;e?d.each(e,function(t,e){null==t||t==a.data.user.user_id?(i===s&&a.clean_ntf(),s+=1):a.display_ntf(a.strings.msg.writing.replace(/%s/i,e),"typing","#YLC_popup_ntf")}):a.clean_ntf()}),this.objs.popup.find(".chat-cnv-reply").click(function(){e.focus()})},reload_cnv:function(s){this.data.ref_msgs.once("value",function(t){new Date;var e=t.val();e&&Object.keys(e).length;e&&d.each(e,function(t,e){e.conversation_id==s&&(e.old_msg=!0,1)})})},push_msg:function(t){this.data.ref_msgs.push({user_id:this.data.user.user_id,user_type:this.data.user.user_type,conversation_id:this.data.user.conversation_id,user_name:this.data.user.user_name||this.data.user.user_email,gravatar:this.data.user.gravatar,avatar_type:this.data.user.avatar_type,avatar_image:this.data.user.avatar_image,msg:t,msg_time:Firebase.ServerValue.TIMESTAMP,vendor_id:ylc.active_vendor.vendor_id,read:!1})},get_user_data:function(t,s){this.data.ref_users.child(t).once("value",function(t){var e=t.val();s(e)})},render_chat:function(){var c=this;this.data.primary_fg=this.use_white(this.opts.styles.bg_color)?"#ffffff":"#444444",this.data.primary_hover=this.shade_color(this.opts.styles.bg_color,7),this.objs.btn=d("#YLC_chat_btn"),this.objs.btn.hover(function(){if(d(this).css("background-color",c.data.primary_hover),"round"==c.opts.styles.btn_type&&ylc.button_animation){var t=d(this).css("width","auto").width();d(this).width(c.opts.styles.btn_width).animate({width:t+10},250)}},function(){d(this).css("background-color",c.opts.styles.bg_color),"round"==c.opts.styles.btn_type&&ylc.button_animation&&d(this).animate({width:c.opts.styles.btn_width},250)}),this.objs.btn.click(function(){d(this).hide(),c.show_popup(),c.auth()}),setTimeout(function(){c.show_btn()},this.data.show_delay),this.show_connecting(),this.objs.popup=d("#YLC_chat"),this.objs.popup_header=d("#YLC_chat_header"),d(p).on("hover","#YLC_send_btn",function(){d(this).css("background-color",c.data.primary_hover)},function(){d(this).css("background-color",c.opts.styles.bg_color)}),d(h).resize(function(){var t=h,e=p,s=e.documentElement,i=e.getElementsByTagName("body")[0],a=(t.innerWidth||s.clientWidth||i.clientWidth,t.innerHeight||s.clientHeight||i.clientHeight),n=c.objs.popup.height(),o=c.objs.popup_header.height(),r=parseInt(c.objs.popup.css("bottom"),10),_=n<a?"auto":a,u=n<a?"auto":a-o-r;c.objs.popup.css("height",_),d("#YLC_chat_body, #YLC_offline").css("height",u);var l=d(h).width();"round"==c.opts.styles.btn_type?c.objs.btn.css({width:c.opts.styles.btn_width+"px",left:"right"===c.opts.styles.x_pos?"auto":"20px",right:"left"===c.opts.styles.x_pos?"auto":"20px"}):480<l?c.objs.btn.css({width:c.opts.styles.btn_width+"px",left:"right"===c.opts.styles.x_pos?"auto":"40px",right:"left"===c.opts.styles.x_pos?"auto":"40px"}):c.objs.btn.css({width:"",left:"right"===c.opts.styles.x_pos?"auto":0,right:"left"===c.opts.styles.x_pos?"auto":0}),480<l?(c.objs.popup.css({left:"right"===c.opts.styles.x_pos?"auto":"40px",right:"left"===c.opts.styles.x_pos?"auto":"40px"}),d(".chat-body.chat-online").css("width",c.opts.styles.popup_width+"px"),d(".chat-body.chat-form").css("width",c.opts.styles.form_width+"px")):(c.objs.popup.css({left:"right"===c.opts.styles.x_pos?"auto":0,right:"left"===c.opts.styles.x_pos?"auto":0}),d(".chat-body").css("width",""))}).trigger("resize")},show_popup:function(){if("open"!=this.data.popup_status){var t=this;this.objs.popup.show(),this.animate(this.objs.popup,this.opts.styles.animation_type),setTimeout(function(){t.objs.popup_header.click(function(){t.be_offline(),t.minimize(),t.objs.popup_header.off("click")})},3e3),setTimeout(function(){switch(t.data.mode){case"online":d("#YLC_cnv_reply").focus(),t.objs.cnv.scrollTop(t.objs.cnv.prop("scrollHeight"));break;case"offline":case"login":d("#YLC_login_form .chat-line:first-child input").focus()}t.data.popup_status="open"},this.data.animation_delay)}},show_btn:function(t){this.allow_chatbox()&&(this.objs.btn.show(),this.objs.btn.find(".chat-title").html(t),this.animate(this.objs.btn,this.opts.styles.animation_type))},minimize:function(){this.data.popup_status="close",this.objs.popup&&(this.objs.popup.hide(),this.show_connecting()),this.objs.btn.show(),this.animate(this.objs.btn,this.opts.styles.animation_type)},manage_connections:function(){var e=this;this.data.ref_user&&this.data.ref_conn.on("value",function(t){!0===t.val()?(e.data.ref_user.child("connections").push(!0).onDisconnect().remove(),e.data.ref_user.child("status").set("online"),e.data.ref_user.child("status").onDisconnect().set("offline"),e.data.ref_user.child("last_online").onDisconnect().set(Firebase.ServerValue.TIMESTAMP),e.data.ref_cnv.child(e.data.user.conversation_id+"/typing/"+e.data.user.user_id).onDisconnect().remove()):e.show_offline()})},post:function(e,t,s){d.post(ylc.ajax_url+"?action="+e,t,s,"json").fail(function(t){return console.log(e,": ",t),!1})},trigger_premium:function(t,e,s,i,a,n,o){if(ylc.is_premium)return this.premium[t].call(this,e,s,i,a,n,o)},display_ntf:function(t,e,s){var i;switch(e){case"success":case"error":case"typing":i='<span class="ylc-icons ylc-icons-'+e+'"></span> ';break;default:i=""}d(s).removeClass().addClass("chat-ntf chat-"+e).html(i+t).fadeIn(300)},clean_ntf:function(){d(".chat-ntf").html("").hide()},clear_user_data:function(n,o){var r=this;this.data.ref_cnv.child(n).once("value",function(t){var e=t.val();if(e){var a=e.user_id;r.data.ref_msgs.once("value",function(t){var e=t.val(),s=e?Object.keys(e).length:0,i=0;e?d.each(e,function(t,e){i+=1,e.conversation_id===n&&r.data.ref_msgs.child(t).remove(),s===i&&o&&o()}):o&&o(),r.data.ref_users.child(a).remove(),r.data.ref_cnv.child(n).remove()})}})},total_online_ops:function(){return this.data.online_ops?Object.keys(this.data.online_ops).length:0},allow_chatbox:function(){return!!this.opts.render},animate:function(t,e){d(h).trigger("resize");var s="top"===this.opts.styles.y_pos?"Down":"Up";t.addClass("chat-anim chat-"+e+s),setTimeout(function(){t.removeClass("chat-anim chat-"+e+s)},this.data.animation_delay)},shade_color:function(t,e){var s=parseInt(t.slice(1),16),i=Math.round(2.55*e),a=(s>>16)+i,n=(s>>8&255)+i,o=(255&s)+i;return"#"+(16777216+65536*(a<255?a<1?0:a:255)+256*(n<255?n<1?0:n:255)+(o<255?o<1?0:o:255)).toString(16).slice(1)},use_white:function(t){t=t.substring(1);var e=parseInt(t,16);return.2126*(e>>16&255)+.7152*(e>>8&255)+.0722*(e>>0&255)<180},validate_email:function(t){return/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(t)},validate_username:function(t){return/^[\u0030-\u0039\u0041-\u005A\u0061-\u007A\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF\u0100-\u017F\u0180-\u024F\u0370-\u03FF\u0400-\u04FF\u0530-\u058F\u0590-\u05FF\u0600-\u06FF\u1100-\u11FF\u3130-\u318F\uAC00-\uD7AF\u2E80-\u2EFF\u3000-\u303F\u31C0-\u31EF\u3200-\u32FF\u3300-\u33FF\u3400-\u4DBF\u4E00-\u9FFF\uF900-\uFAFF\uFE30-\uFE4F\u3040-\u309F\u30A0-\u30FF\u31F0-\u31FF\u0020\u002D\u002E\u0040\u005F]+$/gim.test(t)},md5:function(t){function r(t,e){var s,i,a,n,o;return a=2147483648&t,n=2147483648&e,o=(1073741823&t)+(1073741823&e),(s=1073741824&t)&(i=1073741824&e)?2147483648^o^a^n:s|i?1073741824&o?3221225472^o^a^n:1073741824^o^a^n:o^a^n}function e(t,e,s,i,a,n,o){return r((t=r(t,r(r(e&s|~e&i,a),o)))<<n|t>>>32-n,e)}function s(t,e,s,i,a,n,o){return r((t=r(t,r(r(e&i|s&~i,a),o)))<<n|t>>>32-n,e)}function i(t,e,s,i,a,n,o){return r((t=r(t,r(r(e^s^i,a),o)))<<n|t>>>32-n,e)}function a(t,e,s,i,a,n,o){return r((t=r(t,r(r(s^(e|~i),a),o)))<<n|t>>>32-n,e)}function n(t){var e,s="",i="";for(e=0;e<=3;e++)s+=(i="0"+(i=t>>>8*e&255).toString(16)).substr(i.length-2,2);return s}var o,_,u,l,c,d,h,p,f;for(o=function(t){for(var e,s=t.length,i=16*(((e=s+8)-e%64)/64+1),a=Array(i-1),n=0,o=0;o<s;)n=o%4*8,a[e=(o-o%4)/4]|=t.charCodeAt(o)<<n,o++;return a[e=(o-o%4)/4]|=128<<o%4*8,a[i-2]=s<<3,a[i-1]=s>>>29,a}(t=function(t){t=t.replace(/\r\n/g,"\n");for(var e="",s=0;s<t.length;s++){var i=t.charCodeAt(s);i<128?e+=String.fromCharCode(i):(127<i&&i<2048?e+=String.fromCharCode(i>>6|192):(e+=String.fromCharCode(i>>12|224),e+=String.fromCharCode(i>>6&63|128)),e+=String.fromCharCode(63&i|128))}return e}(t)),d=1732584193,h=4023233417,p=2562383102,f=271733878,t=0;t<o.length;t+=16)h=a(h=a(h=a(h=a(h=i(h=i(h=i(h=i(h=s(h=s(h=s(h=s(h=e(h=e(h=e(h=e(u=h,p=e(l=p,f=e(c=f,d=e(_=d,h,p,f,o[t+0],7,3614090360),h,p,o[t+1],12,3905402710),d,h,o[t+2],17,606105819),f,d,o[t+3],22,3250441966),p=e(p,f=e(f,d=e(d,h,p,f,o[t+4],7,4118548399),h,p,o[t+5],12,1200080426),d,h,o[t+6],17,2821735955),f,d,o[t+7],22,4249261313),p=e(p,f=e(f,d=e(d,h,p,f,o[t+8],7,1770035416),h,p,o[t+9],12,2336552879),d,h,o[t+10],17,4294925233),f,d,o[t+11],22,2304563134),p=e(p,f=e(f,d=e(d,h,p,f,o[t+12],7,1804603682),h,p,o[t+13],12,4254626195),d,h,o[t+14],17,2792965006),f,d,o[t+15],22,1236535329),p=s(p,f=s(f,d=s(d,h,p,f,o[t+1],5,4129170786),h,p,o[t+6],9,3225465664),d,h,o[t+11],14,643717713),f,d,o[t+0],20,3921069994),p=s(p,f=s(f,d=s(d,h,p,f,o[t+5],5,3593408605),h,p,o[t+10],9,38016083),d,h,o[t+15],14,3634488961),f,d,o[t+4],20,3889429448),p=s(p,f=s(f,d=s(d,h,p,f,o[t+9],5,568446438),h,p,o[t+14],9,3275163606),d,h,o[t+3],14,4107603335),f,d,o[t+8],20,1163531501),p=s(p,f=s(f,d=s(d,h,p,f,o[t+13],5,2850285829),h,p,o[t+2],9,4243563512),d,h,o[t+7],14,1735328473),f,d,o[t+12],20,2368359562),p=i(p,f=i(f,d=i(d,h,p,f,o[t+5],4,4294588738),h,p,o[t+8],11,2272392833),d,h,o[t+11],16,1839030562),f,d,o[t+14],23,4259657740),p=i(p,f=i(f,d=i(d,h,p,f,o[t+1],4,2763975236),h,p,o[t+4],11,1272893353),d,h,o[t+7],16,4139469664),f,d,o[t+10],23,3200236656),p=i(p,f=i(f,d=i(d,h,p,f,o[t+13],4,681279174),h,p,o[t+0],11,3936430074),d,h,o[t+3],16,3572445317),f,d,o[t+6],23,76029189),p=i(p,f=i(f,d=i(d,h,p,f,o[t+9],4,3654602809),h,p,o[t+12],11,3873151461),d,h,o[t+15],16,530742520),f,d,o[t+2],23,3299628645),p=a(p,f=a(f,d=a(d,h,p,f,o[t+0],6,4096336452),h,p,o[t+7],10,1126891415),d,h,o[t+14],15,2878612391),f,d,o[t+5],21,4237533241),p=a(p,f=a(f,d=a(d,h,p,f,o[t+12],6,1700485571),h,p,o[t+3],10,2399980690),d,h,o[t+10],15,4293915773),f,d,o[t+1],21,2240044497),p=a(p,f=a(f,d=a(d,h,p,f,o[t+8],6,1873313359),h,p,o[t+15],10,4264355552),d,h,o[t+6],15,2734768916),f,d,o[t+13],21,1309151649),p=a(p,f=a(f,d=a(d,h,p,f,o[t+4],6,4149444226),h,p,o[t+11],10,3174756917),d,h,o[t+2],15,718787259),f,d,o[t+9],21,3951481745),d=r(d,_),h=r(h,u),p=r(p,l),f=r(f,c);return(n(d)+n(h)+n(p)+n(f)).toLowerCase()},random_id:function(t,e){return Math.floor(Math.random()*(e-t+1))+t},purge_firebase:function(s){var l=this;this.data.ref_users.once("value",function(t){var e=t.val(),i=0,a=[],n=[],o=[],r=s?0:3600;if(null!==e){var _=Object.keys(e).length,u=new Date;d.each(e,function(t,e){if(i++,e)if("offline"===e.status){var s=.001*(u.getTime()-e.last_online)>>0;r<=s&&("operator"!=e.user_type?null!=e.conversation_id?n.push(e.conversation_id):a.push(t):(a.push(t),o.push(e.conversation_id)))}else if("wait"===e.status)if(e.last_online===c)a.push(t);else{s=.001*(u.getTime()-e.last_online)>>0;2*r<=s&&a.push(t)}i===_&&(d.each(a,function(t,e){l.data.ref_users.child(e).remove()}),d.each(o,function(t,e){l.data.ref_cnv.child(e).remove()}),d.each(n,function(t,e){ylc.is_premium?l.trigger_premium("save_user_data",e,!0,u.getTime()):l.clear_user_data(e)}))})}})},valid_operator:function(t){return!ylc.yith_wpv_active||(!(!ylc.yith_wpv_active||ylc.active_vendor.vendor_id!==t)||!(!ylc.yith_wpv_active||"0"!==t||ylc.vendor_only_chat))}},d.fn.ylc=function(){var t;this.data(e)instanceof i||this.data(e,new i(this)),(t=this.data(e)).el=this,t.init()},d(p).ready(function(){d.post(p.location.href,function(t){if(""!==t){var e=d("<div></div>").html(t).find("#YLC");d("#YLC").html(e.html()).ylc(),d('a[href="#yith-live-chat"]').click(function(t){t.preventDefault(),d("#YLC_chat_btn").click()})}})})}(jQuery,window,document);
!function(n,t){var r,e;"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define("underscore",t):(n="undefined"!=typeof globalThis?globalThis:n||self,r=n._,(e=n._=t()).noConflict=function(){return n._=r,e})}(this,function(){var n="1.13.7",t="object"==typeof self&&self.self===self&&self||"object"==typeof global&&global.global===global&&global||Function("return this")()||{},e=Array.prototype,V=Object.prototype,F="undefined"!=typeof Symbol?Symbol.prototype:null,P=e.push,f=e.slice,s=V.toString,q=V.hasOwnProperty,r="undefined"!=typeof ArrayBuffer,u="undefined"!=typeof DataView,U=Array.isArray,W=Object.keys,z=Object.create,L=r&&ArrayBuffer.isView,$=isNaN,C=isFinite,K=!{toString:null}.propertyIsEnumerable("toString"),J=["valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"],G=Math.pow(2,53)-1;function l(u,o){return o=null==o?u.length-1:+o,function(){for(var n=Math.max(arguments.length-o,0),t=Array(n),r=0;r<n;r++)t[r]=arguments[r+o];switch(o){case 0:return u.call(this,t);case 1:return u.call(this,arguments[0],t);case 2:return u.call(this,arguments[0],arguments[1],t)}for(var e=Array(o+1),r=0;r<o;r++)e[r]=arguments[r];return e[o]=t,u.apply(this,e)}}function o(n){var t=typeof n;return"function"==t||"object"==t&&!!n}function H(n){return void 0===n}function Q(n){return!0===n||!1===n||"[object Boolean]"===s.call(n)}function i(n){var t="[object "+n+"]";return function(n){return s.call(n)===t}}var X=i("String"),Y=i("Number"),Z=i("Date"),nn=i("RegExp"),tn=i("Error"),rn=i("Symbol"),en=i("ArrayBuffer"),a=i("Function"),t=t.document&&t.document.childNodes,p=a="function"!=typeof/./&&"object"!=typeof Int8Array&&"function"!=typeof t?function(n){return"function"==typeof n||!1}:a,t=i("Object"),un=u&&(!/\[native code\]/.test(String(DataView))||t(new DataView(new ArrayBuffer(8)))),a="undefined"!=typeof Map&&t(new Map),u=i("DataView");var h=un?function(n){return null!=n&&p(n.getInt8)&&en(n.buffer)}:u,v=U||i("Array");function y(n,t){return null!=n&&q.call(n,t)}var on=i("Arguments"),an=(!function(){on(arguments)||(on=function(n){return y(n,"callee")})}(),on);function fn(n){return Y(n)&&$(n)}function cn(n){return function(){return n}}function ln(t){return function(n){n=t(n);return"number"==typeof n&&0<=n&&n<=G}}function sn(t){return function(n){return null==n?void 0:n[t]}}var d=sn("byteLength"),pn=ln(d),hn=/\[object ((I|Ui)nt(8|16|32)|Float(32|64)|Uint8Clamped|Big(I|Ui)nt64)Array\]/;var vn=r?function(n){return L?L(n)&&!h(n):pn(n)&&hn.test(s.call(n))}:cn(!1),g=sn("length");function yn(n,t){t=function(t){for(var r={},n=t.length,e=0;e<n;++e)r[t[e]]=!0;return{contains:function(n){return!0===r[n]},push:function(n){return r[n]=!0,t.push(n)}}}(t);var r=J.length,e=n.constructor,u=p(e)&&e.prototype||V,o="constructor";for(y(n,o)&&!t.contains(o)&&t.push(o);r--;)(o=J[r])in n&&n[o]!==u[o]&&!t.contains(o)&&t.push(o)}function b(n){if(!o(n))return[];if(W)return W(n);var t,r=[];for(t in n)y(n,t)&&r.push(t);return K&&yn(n,r),r}function dn(n,t){var r=b(t),e=r.length;if(null==n)return!e;for(var u=Object(n),o=0;o<e;o++){var i=r[o];if(t[i]!==u[i]||!(i in u))return!1}return!0}function m(n){return n instanceof m?n:this instanceof m?void(this._wrapped=n):new m(n)}function gn(n){return new Uint8Array(n.buffer||n,n.byteOffset||0,d(n))}m.VERSION=n,m.prototype.valueOf=m.prototype.toJSON=m.prototype.value=function(){return this._wrapped},m.prototype.toString=function(){return String(this._wrapped)};var bn="[object DataView]";function mn(n,t,r,e){var u;return n===t?0!==n||1/n==1/t:null!=n&&null!=t&&(n!=n?t!=t:("function"==(u=typeof n)||"object"==u||"object"==typeof t)&&function n(t,r,e,u){t instanceof m&&(t=t._wrapped);r instanceof m&&(r=r._wrapped);var o=s.call(t);if(o!==s.call(r))return!1;if(un&&"[object Object]"==o&&h(t)){if(!h(r))return!1;o=bn}switch(o){case"[object RegExp]":case"[object String]":return""+t==""+r;case"[object Number]":return+t!=+t?+r!=+r:0==+t?1/+t==1/r:+t==+r;case"[object Date]":case"[object Boolean]":return+t==+r;case"[object Symbol]":return F.valueOf.call(t)===F.valueOf.call(r);case"[object ArrayBuffer]":case bn:return n(gn(t),gn(r),e,u)}o="[object Array]"===o;if(!o&&vn(t)){var i=d(t);if(i!==d(r))return!1;if(t.buffer===r.buffer&&t.byteOffset===r.byteOffset)return!0;o=!0}if(!o){if("object"!=typeof t||"object"!=typeof r)return!1;var i=t.constructor,a=r.constructor;if(i!==a&&!(p(i)&&i instanceof i&&p(a)&&a instanceof a)&&"constructor"in t&&"constructor"in r)return!1}e=e||[];u=u||[];var f=e.length;for(;f--;)if(e[f]===t)return u[f]===r;e.push(t);u.push(r);if(o){if((f=t.length)!==r.length)return!1;for(;f--;)if(!mn(t[f],r[f],e,u))return!1}else{var c,l=b(t);if(f=l.length,b(r).length!==f)return!1;for(;f--;)if(c=l[f],!y(r,c)||!mn(t[c],r[c],e,u))return!1}e.pop();u.pop();return!0}(n,t,r,e))}function c(n){if(!o(n))return[];var t,r=[];for(t in n)r.push(t);return K&&yn(n,r),r}function jn(e){var u=g(e);return function(n){if(null==n)return!1;var t=c(n);if(g(t))return!1;for(var r=0;r<u;r++)if(!p(n[e[r]]))return!1;return e!==_n||!p(n[wn])}}var wn="forEach",t=["clear","delete"],u=["get","has","set"],U=t.concat(wn,u),_n=t.concat(u),r=["add"].concat(t,wn,"has"),u=a?jn(U):i("Map"),t=a?jn(_n):i("WeakMap"),U=a?jn(r):i("Set"),a=i("WeakSet");function j(n){for(var t=b(n),r=t.length,e=Array(r),u=0;u<r;u++)e[u]=n[t[u]];return e}function An(n){for(var t={},r=b(n),e=0,u=r.length;e<u;e++)t[n[r[e]]]=r[e];return t}function xn(n){var t,r=[];for(t in n)p(n[t])&&r.push(t);return r.sort()}function Sn(f,c){return function(n){var t=arguments.length;if(c&&(n=Object(n)),!(t<2||null==n))for(var r=1;r<t;r++)for(var e=arguments[r],u=f(e),o=u.length,i=0;i<o;i++){var a=u[i];c&&void 0!==n[a]||(n[a]=e[a])}return n}}var On=Sn(c),w=Sn(b),Mn=Sn(c,!0);function En(n){var t;return o(n)?z?z(n):((t=function(){}).prototype=n,n=new t,t.prototype=null,n):{}}function Bn(n){return v(n)?n:[n]}function _(n){return m.toPath(n)}function Nn(n,t){for(var r=t.length,e=0;e<r;e++){if(null==n)return;n=n[t[e]]}return r?n:void 0}function In(n,t,r){n=Nn(n,_(t));return H(n)?r:n}function Tn(n){return n}function A(t){return t=w({},t),function(n){return dn(n,t)}}function kn(t){return t=_(t),function(n){return Nn(n,t)}}function x(u,o,n){if(void 0===o)return u;switch(null==n?3:n){case 1:return function(n){return u.call(o,n)};case 3:return function(n,t,r){return u.call(o,n,t,r)};case 4:return function(n,t,r,e){return u.call(o,n,t,r,e)}}return function(){return u.apply(o,arguments)}}function Dn(n,t,r){return null==n?Tn:p(n)?x(n,t,r):(o(n)&&!v(n)?A:kn)(n)}function Rn(n,t){return Dn(n,t,1/0)}function S(n,t,r){return m.iteratee!==Rn?m.iteratee(n,t):Dn(n,t,r)}function Vn(){}function Fn(n,t){return null==t&&(t=n,n=0),n+Math.floor(Math.random()*(t-n+1))}m.toPath=Bn,m.iteratee=Rn;var O=Date.now||function(){return(new Date).getTime()};function Pn(t){function r(n){return t[n]}var n="(?:"+b(t).join("|")+")",e=RegExp(n),u=RegExp(n,"g");return function(n){return e.test(n=null==n?"":""+n)?n.replace(u,r):n}}var r={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"},qn=Pn(r),r=Pn(An(r)),Un=m.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g},Wn=/(.)^/,zn={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},Ln=/\\|'|\r|\n|\u2028|\u2029/g;function $n(n){return"\\"+zn[n]}var Cn=/^\s*(\w|\$)+\s*$/;var Kn=0;function Jn(n,t,r,e,u){return e instanceof t?(e=En(n.prototype),o(t=n.apply(e,u))?t:e):n.apply(r,u)}var M=l(function(u,o){function i(){for(var n=0,t=o.length,r=Array(t),e=0;e<t;e++)r[e]=o[e]===a?arguments[n++]:o[e];for(;n<arguments.length;)r.push(arguments[n++]);return Jn(u,i,this,this,r)}var a=M.placeholder;return i}),Gn=(M.placeholder=m,l(function(t,r,e){var u;if(p(t))return u=l(function(n){return Jn(t,u,r,this,e.concat(n))});throw new TypeError("Bind must be called on a function")})),E=ln(g);function B(n,t,r,e){if(e=e||[],t||0===t){if(t<=0)return e.concat(n)}else t=1/0;for(var u=e.length,o=0,i=g(n);o<i;o++){var a=n[o];if(E(a)&&(v(a)||an(a)))if(1<t)B(a,t-1,r,e),u=e.length;else for(var f=0,c=a.length;f<c;)e[u++]=a[f++];else r||(e[u++]=a)}return e}var Hn=l(function(n,t){var r=(t=B(t,!1,!1)).length;if(r<1)throw new Error("bindAll must be passed function names");for(;r--;){var e=t[r];n[e]=Gn(n[e],n)}return n});var Qn=l(function(n,t,r){return setTimeout(function(){return n.apply(null,r)},t)}),Xn=M(Qn,m,1);function Yn(n){return function(){return!n.apply(this,arguments)}}function Zn(n,t){var r;return function(){return 0<--n&&(r=t.apply(this,arguments)),n<=1&&(t=null),r}}var nt=M(Zn,2);function tt(n,t,r){t=S(t,r);for(var e,u=b(n),o=0,i=u.length;o<i;o++)if(t(n[e=u[o]],e,n))return e}function rt(o){return function(n,t,r){t=S(t,r);for(var e=g(n),u=0<o?0:e-1;0<=u&&u<e;u+=o)if(t(n[u],u,n))return u;return-1}}var et=rt(1),ut=rt(-1);function ot(n,t,r,e){for(var u=(r=S(r,e,1))(t),o=0,i=g(n);o<i;){var a=Math.floor((o+i)/2);r(n[a])<u?o=a+1:i=a}return o}function it(o,i,a){return function(n,t,r){var e=0,u=g(n);if("number"==typeof r)0<o?e=0<=r?r:Math.max(r+u,e):u=0<=r?Math.min(r+1,u):r+u+1;else if(a&&r&&u)return n[r=a(n,t)]===t?r:-1;if(t!=t)return 0<=(r=i(f.call(n,e,u),fn))?r+e:-1;for(r=0<o?e:u-1;0<=r&&r<u;r+=o)if(n[r]===t)return r;return-1}}var at=it(1,et,ot),ft=it(-1,ut);function ct(n,t,r){t=(E(n)?et:tt)(n,t,r);if(void 0!==t&&-1!==t)return n[t]}function N(n,t,r){if(t=x(t,r),E(n))for(u=0,o=n.length;u<o;u++)t(n[u],u,n);else for(var e=b(n),u=0,o=e.length;u<o;u++)t(n[e[u]],e[u],n);return n}function I(n,t,r){t=S(t,r);for(var e=!E(n)&&b(n),u=(e||n).length,o=Array(u),i=0;i<u;i++){var a=e?e[i]:i;o[i]=t(n[a],a,n)}return o}function lt(p){return function(n,t,r,e){var u=3<=arguments.length,o=n,i=x(t,e,4),a=r,f=!E(o)&&b(o),c=(f||o).length,l=0<p?0:c-1;for(u||(a=o[f?f[l]:l],l+=p);0<=l&&l<c;l+=p){var s=f?f[l]:l;a=i(a,o[s],s,o)}return a}}var st=lt(1),pt=lt(-1);function T(n,e,t){var u=[];return e=S(e,t),N(n,function(n,t,r){e(n,t,r)&&u.push(n)}),u}function ht(n,t,r){t=S(t,r);for(var e=!E(n)&&b(n),u=(e||n).length,o=0;o<u;o++){var i=e?e[o]:o;if(!t(n[i],i,n))return!1}return!0}function vt(n,t,r){t=S(t,r);for(var e=!E(n)&&b(n),u=(e||n).length,o=0;o<u;o++){var i=e?e[o]:o;if(t(n[i],i,n))return!0}return!1}function k(n,t,r,e){return E(n)||(n=j(n)),0<=at(n,t,r="number"==typeof r&&!e?r:0)}var yt=l(function(n,r,e){var u,o;return p(r)?o=r:(r=_(r),u=r.slice(0,-1),r=r[r.length-1]),I(n,function(n){var t=o;if(!t){if(null==(n=u&&u.length?Nn(n,u):n))return;t=n[r]}return null==t?t:t.apply(n,e)})});function dt(n,t){return I(n,kn(t))}function gt(n,e,t){var r,u,o=-1/0,i=-1/0;if(null==e||"number"==typeof e&&"object"!=typeof n[0]&&null!=n)for(var a=0,f=(n=E(n)?n:j(n)).length;a<f;a++)null!=(r=n[a])&&o<r&&(o=r);else e=S(e,t),N(n,function(n,t,r){u=e(n,t,r),(i<u||u===-1/0&&o===-1/0)&&(o=n,i=u)});return o}var bt=/[^\ud800-\udfff]|[\ud800-\udbff][\udc00-\udfff]|[\ud800-\udfff]/g;function mt(n){return n?v(n)?f.call(n):X(n)?n.match(bt):E(n)?I(n,Tn):j(n):[]}function jt(n,t,r){if(null==t||r)return(n=E(n)?n:j(n))[Fn(n.length-1)];for(var e=mt(n),r=g(e),u=(t=Math.max(Math.min(t,r),0),r-1),o=0;o<t;o++){var i=Fn(o,u),a=e[o];e[o]=e[i],e[i]=a}return e.slice(0,t)}function D(o,t){return function(r,e,n){var u=t?[[],[]]:{};return e=S(e,n),N(r,function(n,t){t=e(n,t,r);o(u,n,t)}),u}}var wt=D(function(n,t,r){y(n,r)?n[r].push(t):n[r]=[t]}),_t=D(function(n,t,r){n[r]=t}),At=D(function(n,t,r){y(n,r)?n[r]++:n[r]=1}),xt=D(function(n,t,r){n[r?0:1].push(t)},!0);function St(n,t,r){return t in r}var Ot=l(function(n,t){var r={},e=t[0];if(null!=n){p(e)?(1<t.length&&(e=x(e,t[1])),t=c(n)):(e=St,t=B(t,!1,!1),n=Object(n));for(var u=0,o=t.length;u<o;u++){var i=t[u],a=n[i];e(a,i,n)&&(r[i]=a)}}return r}),Mt=l(function(n,r){var t,e=r[0];return p(e)?(e=Yn(e),1<r.length&&(t=r[1])):(r=I(B(r,!1,!1),String),e=function(n,t){return!k(r,t)}),Ot(n,e,t)});function Et(n,t,r){return f.call(n,0,Math.max(0,n.length-(null==t||r?1:t)))}function Bt(n,t,r){return null==n||n.length<1?null==t||r?void 0:[]:null==t||r?n[0]:Et(n,n.length-t)}function R(n,t,r){return f.call(n,null==t||r?1:t)}var Nt=l(function(n,t){return t=B(t,!0,!0),T(n,function(n){return!k(t,n)})}),It=l(function(n,t){return Nt(n,t)});function Tt(n,t,r,e){Q(t)||(e=r,r=t,t=!1),null!=r&&(r=S(r,e));for(var u=[],o=[],i=0,a=g(n);i<a;i++){var f=n[i],c=r?r(f,i,n):f;t&&!r?(i&&o===c||u.push(f),o=c):r?k(o,c)||(o.push(c),u.push(f)):k(u,f)||u.push(f)}return u}var kt=l(function(n){return Tt(B(n,!0,!0))});function Dt(n){for(var t=n&&gt(n,g).length||0,r=Array(t),e=0;e<t;e++)r[e]=dt(n,e);return r}var Rt=l(Dt);function Vt(n,t){return n._chain?m(t).chain():t}function Ft(r){return N(xn(r),function(n){var t=m[n]=r[n];m.prototype[n]=function(){var n=[this._wrapped];return P.apply(n,arguments),Vt(this,t.apply(m,n))}}),m}N(["pop","push","reverse","shift","sort","splice","unshift"],function(t){var r=e[t];m.prototype[t]=function(){var n=this._wrapped;return null!=n&&(r.apply(n,arguments),"shift"!==t&&"splice"!==t||0!==n.length||delete n[0]),Vt(this,n)}}),N(["concat","join","slice"],function(n){var t=e[n];m.prototype[n]=function(){var n=this._wrapped;return Vt(this,n=null!=n?t.apply(n,arguments):n)}});n=Ft({__proto__:null,VERSION:n,restArguments:l,isObject:o,isNull:function(n){return null===n},isUndefined:H,isBoolean:Q,isElement:function(n){return!(!n||1!==n.nodeType)},isString:X,isNumber:Y,isDate:Z,isRegExp:nn,isError:tn,isSymbol:rn,isArrayBuffer:en,isDataView:h,isArray:v,isFunction:p,isArguments:an,isFinite:function(n){return!rn(n)&&C(n)&&!isNaN(parseFloat(n))},isNaN:fn,isTypedArray:vn,isEmpty:function(n){var t;return null==n||("number"==typeof(t=g(n))&&(v(n)||X(n)||an(n))?0===t:0===g(b(n)))},isMatch:dn,isEqual:function(n,t){return mn(n,t)},isMap:u,isWeakMap:t,isSet:U,isWeakSet:a,keys:b,allKeys:c,values:j,pairs:function(n){for(var t=b(n),r=t.length,e=Array(r),u=0;u<r;u++)e[u]=[t[u],n[t[u]]];return e},invert:An,functions:xn,methods:xn,extend:On,extendOwn:w,assign:w,defaults:Mn,create:function(n,t){return n=En(n),t&&w(n,t),n},clone:function(n){return o(n)?v(n)?n.slice():On({},n):n},tap:function(n,t){return t(n),n},get:In,has:function(n,t){for(var r=(t=_(t)).length,e=0;e<r;e++){var u=t[e];if(!y(n,u))return!1;n=n[u]}return!!r},mapObject:function(n,t,r){t=S(t,r);for(var e=b(n),u=e.length,o={},i=0;i<u;i++){var a=e[i];o[a]=t(n[a],a,n)}return o},identity:Tn,constant:cn,noop:Vn,toPath:Bn,property:kn,propertyOf:function(t){return null==t?Vn:function(n){return In(t,n)}},matcher:A,matches:A,times:function(n,t,r){var e=Array(Math.max(0,n));t=x(t,r,1);for(var u=0;u<n;u++)e[u]=t(u);return e},random:Fn,now:O,escape:qn,unescape:r,templateSettings:Un,template:function(o,n,t){n=Mn({},n=!n&&t?t:n,m.templateSettings);var r,t=RegExp([(n.escape||Wn).source,(n.interpolate||Wn).source,(n.evaluate||Wn).source].join("|")+"|$","g"),i=0,a="__p+='";if(o.replace(t,function(n,t,r,e,u){return a+=o.slice(i,u).replace(Ln,$n),i=u+n.length,t?a+="'+\n((__t=("+t+"))==null?'':_.escape(__t))+\n'":r?a+="'+\n((__t=("+r+"))==null?'':__t)+\n'":e&&(a+="';\n"+e+"\n__p+='"),n}),a+="';\n",t=n.variable){if(!Cn.test(t))throw new Error("variable is not a bare identifier: "+t)}else a="with(obj||{}){\n"+a+"}\n",t="obj";a="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+a+"return __p;\n";try{r=new Function(t,"_",a)}catch(n){throw n.source=a,n}function e(n){return r.call(this,n,m)}return e.source="function("+t+"){\n"+a+"}",e},result:function(n,t,r){var e=(t=_(t)).length;if(!e)return p(r)?r.call(n):r;for(var u=0;u<e;u++){var o=null==n?void 0:n[t[u]];void 0===o&&(o=r,u=e),n=p(o)?o.call(n):o}return n},uniqueId:function(n){var t=++Kn+"";return n?n+t:t},chain:function(n){return(n=m(n))._chain=!0,n},iteratee:Rn,partial:M,bind:Gn,bindAll:Hn,memoize:function(e,u){function o(n){var t=o.cache,r=""+(u?u.apply(this,arguments):n);return y(t,r)||(t[r]=e.apply(this,arguments)),t[r]}return o.cache={},o},delay:Qn,defer:Xn,throttle:function(r,e,u){function o(){l=!1===u.leading?0:O(),i=null,c=r.apply(a,f),i||(a=f=null)}function n(){var n=O(),t=(l||!1!==u.leading||(l=n),e-(n-l));return a=this,f=arguments,t<=0||e<t?(i&&(clearTimeout(i),i=null),l=n,c=r.apply(a,f),i||(a=f=null)):i||!1===u.trailing||(i=setTimeout(o,t)),c}var i,a,f,c,l=0;return u=u||{},n.cancel=function(){clearTimeout(i),l=0,i=a=f=null},n},debounce:function(t,r,e){function u(){var n=O()-i;n<r?o=setTimeout(u,r-n):(o=null,e||(f=t.apply(c,a)),o||(a=c=null))}var o,i,a,f,c,n=l(function(n){return c=this,a=n,i=O(),o||(o=setTimeout(u,r),e&&(f=t.apply(c,a))),f});return n.cancel=function(){clearTimeout(o),o=a=c=null},n},wrap:function(n,t){return M(t,n)},negate:Yn,compose:function(){var r=arguments,e=r.length-1;return function(){for(var n=e,t=r[e].apply(this,arguments);n--;)t=r[n].call(this,t);return t}},after:function(n,t){return function(){if(--n<1)return t.apply(this,arguments)}},before:Zn,once:nt,findKey:tt,findIndex:et,findLastIndex:ut,sortedIndex:ot,indexOf:at,lastIndexOf:ft,find:ct,detect:ct,findWhere:function(n,t){return ct(n,A(t))},each:N,forEach:N,map:I,collect:I,reduce:st,foldl:st,inject:st,reduceRight:pt,foldr:pt,filter:T,select:T,reject:function(n,t,r){return T(n,Yn(S(t)),r)},every:ht,all:ht,some:vt,any:vt,contains:k,includes:k,include:k,invoke:yt,pluck:dt,where:function(n,t){return T(n,A(t))},max:gt,min:function(n,e,t){var r,u,o=1/0,i=1/0;if(null==e||"number"==typeof e&&"object"!=typeof n[0]&&null!=n)for(var a=0,f=(n=E(n)?n:j(n)).length;a<f;a++)null!=(r=n[a])&&r<o&&(o=r);else e=S(e,t),N(n,function(n,t,r){((u=e(n,t,r))<i||u===1/0&&o===1/0)&&(o=n,i=u)});return o},shuffle:function(n){return jt(n,1/0)},sample:jt,sortBy:function(n,e,t){var u=0;return e=S(e,t),dt(I(n,function(n,t,r){return{value:n,index:u++,criteria:e(n,t,r)}}).sort(function(n,t){var r=n.criteria,e=t.criteria;if(r!==e){if(e<r||void 0===r)return 1;if(r<e||void 0===e)return-1}return n.index-t.index}),"value")},groupBy:wt,indexBy:_t,countBy:At,partition:xt,toArray:mt,size:function(n){return null==n?0:(E(n)?n:b(n)).length},pick:Ot,omit:Mt,first:Bt,head:Bt,take:Bt,initial:Et,last:function(n,t,r){return null==n||n.length<1?null==t||r?void 0:[]:null==t||r?n[n.length-1]:R(n,Math.max(0,n.length-t))},rest:R,tail:R,drop:R,compact:function(n){return T(n,Boolean)},flatten:function(n,t){return B(n,t,!1)},without:It,uniq:Tt,unique:Tt,union:kt,intersection:function(n){for(var t=[],r=arguments.length,e=0,u=g(n);e<u;e++){var o=n[e];if(!k(t,o)){for(var i=1;i<r&&k(arguments[i],o);i++);i===r&&t.push(o)}}return t},difference:Nt,unzip:Dt,transpose:Dt,zip:Rt,object:function(n,t){for(var r={},e=0,u=g(n);e<u;e++)t?r[n[e]]=t[e]:r[n[e][0]]=n[e][1];return r},range:function(n,t,r){null==t&&(t=n||0,n=0),r=r||(t<n?-1:1);for(var e=Math.max(Math.ceil((t-n)/r),0),u=Array(e),o=0;o<e;o++,n+=r)u[o]=n;return u},chunk:function(n,t){if(null==t||t<1)return[];for(var r=[],e=0,u=n.length;e<u;)r.push(f.call(n,e,e+=t));return r},mixin:Ft,default:m});return n._=n});
!function(n){var s="object"==typeof self&&self.self===self&&self||"object"==typeof global&&global.global===global&&global;if("function"==typeof define&&define.amd)define(["underscore","jquery","exports"],function(t,e,i){s.Backbone=n(s,i,t,e)});else if("undefined"!=typeof exports){var t,e=require("underscore");try{t=require("jquery")}catch(t){}n(s,exports,e,t)}else s.Backbone=n(s,{},s._,s.jQuery||s.Zepto||s.ender||s.$)}(function(t,h,b,e){function a(t,e,i,n,s){var r,o=0;if(i&&"object"==typeof i){void 0!==n&&"context"in s&&void 0===s.context&&(s.context=n);for(r=b.keys(i);o<r.length;o++)e=a(t,e,r[o],i[r[o]],s)}else if(i&&l.test(i))for(r=i.split(l);o<r.length;o++)e=t(e,r[o],n,s);else e=t(e,i,n,s);return e}function x(t,e,i){i=Math.min(Math.max(i,0),t.length);for(var n=Array(t.length-i),s=e.length,r=0;r<n.length;r++)n[r]=t[r+i];for(r=0;r<s;r++)t[r+i]=e[r];for(r=0;r<n.length;r++)t[r+s+i]=n[r]}function s(i,n,t,s){b.each(t,function(t,e){n[e]&&(i.prototype[e]=function(n,t,s,r){switch(t){case 1:return function(){return n[s](this[r])};case 2:return function(t){return n[s](this[r],t)};case 3:return function(t,e){return n[s](this[r],T(t,this),e)};case 4:return function(t,e,i){return n[s](this[r],T(t,this),e,i)};default:return function(){var t=u.call(arguments);return t.unshift(this[r]),n[s].apply(n,t)}}}(n,t,e,s))})}var o,i=t.Backbone,u=Array.prototype.slice,e=(h.VERSION="1.6.0",h.$=e,h.noConflict=function(){return t.Backbone=i,this},h.emulateHTTP=!1,h.emulateJSON=!1,h.Events={}),l=/\s+/,n=(e.on=function(t,e,i){return this._events=a(n,this._events||{},t,e,{context:i,ctx:this,listening:o}),o&&(((this._listeners||(this._listeners={}))[o.id]=o).interop=!1),this},e.listenTo=function(t,e,i){if(t){var n=t._listenId||(t._listenId=b.uniqueId("l")),s=this._listeningTo||(this._listeningTo={}),r=o=s[n],s=(r||(this._listenId||(this._listenId=b.uniqueId("l")),r=o=s[n]=new g(this,t)),c(t,e,i,this));if(o=void 0,s)throw s;r.interop&&r.on(e,i)}return this},function(t,e,i,n){var s,r;return i&&(e=t[e]||(t[e]=[]),s=n.context,r=n.ctx,(n=n.listening)&&n.count++,e.push({callback:i,context:s,ctx:s||r,listening:n})),t}),c=function(t,e,i,n){try{t.on(e,i,n)}catch(t){return t}},r=(e.off=function(t,e,i){return this._events&&(this._events=a(r,this._events,t,e,{context:i,listeners:this._listeners})),this},e.stopListening=function(t,e,i){var n=this._listeningTo;if(n){for(var s=t?[t._listenId]:b.keys(n),r=0;r<s.length;r++){var o=n[s[r]];if(!o)break;o.obj.off(e,i,this),o.interop&&o.off(e,i)}b.isEmpty(n)&&(this._listeningTo=void 0)}return this},function(t,e,i,n){if(t){var s,r=n.context,o=n.listeners,h=0;if(e||r||i){for(s=e?[e]:b.keys(t);h<s.length;h++){var a=t[e=s[h]];if(!a)break;for(var u=[],l=0;l<a.length;l++){var c=a[l];i&&i!==c.callback&&i!==c.callback._callback||r&&r!==c.context?u.push(c):(c=c.listening)&&c.off(e,i)}u.length?t[e]=u:delete t[e]}return t}for(s=b.keys(o);h<s.length;h++)o[s[h]].cleanup()}}),d=(e.once=function(t,e,i){var n=a(d,{},t,e,this.off.bind(this));return this.on(n,e="string"==typeof t&&null==i?void 0:e,i)},e.listenToOnce=function(t,e,i){e=a(d,{},e,i,this.stopListening.bind(this,t));return this.listenTo(t,e)},function(t,e,i,n){var s;return i&&((s=t[e]=b.once(function(){n(e,s),i.apply(this,arguments)}))._callback=i),t}),f=(e.trigger=function(t){if(this._events){for(var e=Math.max(0,arguments.length-1),i=Array(e),n=0;n<e;n++)i[n]=arguments[n+1];a(f,this._events,t,void 0,i)}return this},function(t,e,i,n){var s,r;return t&&(s=t[e],r=t.all,s&&(r=r&&r.slice()),s&&p(s,n),r)&&p(r,[e].concat(n)),t}),p=function(t,e){var i,n=-1,s=t.length,r=e[0],o=e[1],h=e[2];switch(e.length){case 0:for(;++n<s;)(i=t[n]).callback.call(i.ctx);return;case 1:for(;++n<s;)(i=t[n]).callback.call(i.ctx,r);return;case 2:for(;++n<s;)(i=t[n]).callback.call(i.ctx,r,o);return;case 3:for(;++n<s;)(i=t[n]).callback.call(i.ctx,r,o,h);return;default:for(;++n<s;)(i=t[n]).callback.apply(i.ctx,e);return}},g=function(t,e){this.id=t._listenId,this.listener=t,this.obj=e,this.interop=!0,this.count=0,this._events=void 0},v=(g.prototype.on=e.on,g.prototype.off=function(t,e){t=this.interop?(this._events=a(r,this._events,t,e,{context:void 0,listeners:void 0}),!this._events):(this.count--,0===this.count);t&&this.cleanup()},g.prototype.cleanup=function(){delete this.listener._listeningTo[this.obj._listenId],this.interop||delete this.obj._listeners[this.id]},e.bind=e.on,e.unbind=e.off,b.extend(h,e),h.Model=function(t,e){var i=t||{},n=(e=e||{},this.preinitialize.apply(this,arguments),this.cid=b.uniqueId(this.cidPrefix),this.attributes={},e.collection&&(this.collection=e.collection),e.parse&&(i=this.parse(i,e)||{}),b.result(this,"defaults")),i=b.defaults(b.extend({},n,i),n);this.set(i,e),this.changed={},this.initialize.apply(this,arguments)}),m=(b.extend(v.prototype,e,{changed:null,validationError:null,idAttribute:"id",cidPrefix:"c",preinitialize:function(){},initialize:function(){},toJSON:function(t){return b.clone(this.attributes)},sync:function(){return h.sync.apply(this,arguments)},get:function(t){return this.attributes[t]},escape:function(t){return b.escape(this.get(t))},has:function(t){return null!=this.get(t)},matches:function(t){return!!b.iteratee(t,this)(this.attributes)},set:function(t,e,i){if(null!=t){var n;if("object"==typeof t?(n=t,i=e):(n={})[t]=e,!this._validate(n,i=i||{}))return!1;var s,r,o=i.unset,t=i.silent,h=[],a=this._changing,u=(this._changing=!0,a||(this._previousAttributes=b.clone(this.attributes),this.changed={}),this.attributes),l=this.changed,c=this._previousAttributes;for(s in n)e=n[s],b.isEqual(u[s],e)||h.push(s),b.isEqual(c[s],e)?delete l[s]:l[s]=e,o?delete u[s]:u[s]=e;if(this.idAttribute in n&&(r=this.id,this.id=this.get(this.idAttribute),this.trigger("changeId",this,r,i)),!t){h.length&&(this._pending=i);for(var d=0;d<h.length;d++)this.trigger("change:"+h[d],this,u[h[d]],i)}if(!a){if(!t)for(;this._pending;)i=this._pending,this._pending=!1,this.trigger("change",this,i);this._pending=!1,this._changing=!1}}return this},unset:function(t,e){return this.set(t,void 0,b.extend({},e,{unset:!0}))},clear:function(t){var e,i={};for(e in this.attributes)i[e]=void 0;return this.set(i,b.extend({},t,{unset:!0}))},hasChanged:function(t){return null==t?!b.isEmpty(this.changed):b.has(this.changed,t)},changedAttributes:function(t){if(!t)return!!this.hasChanged()&&b.clone(this.changed);var e,i,n=this._changing?this._previousAttributes:this.attributes,s={};for(i in t){var r=t[i];b.isEqual(n[i],r)||(s[i]=r,e=!0)}return!!e&&s},previous:function(t){return null!=t&&this._previousAttributes?this._previousAttributes[t]:null},previousAttributes:function(){return b.clone(this._previousAttributes)},fetch:function(i){i=b.extend({parse:!0},i);var n=this,s=i.success;return i.success=function(t){var e=i.parse?n.parse(t,i):t;if(!n.set(e,i))return!1;s&&s.call(i.context,n,t,i),n.trigger("sync",n,t,i)},N(this,i),this.sync("read",this,i)},save:function(t,e,i){null==t||"object"==typeof t?(n=t,i=e):(n={})[t]=e;var n,s=(i=b.extend({validate:!0,parse:!0},i)).wait;if(n&&!s){if(!this.set(n,i))return!1}else if(!this._validate(n,i))return!1;var r=this,o=i.success,h=this.attributes,t=(i.success=function(t){r.attributes=h;var e=i.parse?r.parse(t,i):t;if((e=s?b.extend({},n,e):e)&&!r.set(e,i))return!1;o&&o.call(i.context,r,t,i),r.trigger("sync",r,t,i)},N(this,i),n&&s&&(this.attributes=b.extend({},h,n)),this.isNew()?"create":i.patch?"patch":"update"),e=("patch"!=t||i.attrs||(i.attrs=n),this.sync(t,this,i));return this.attributes=h,e},destroy:function(e){e=e?b.clone(e):{};function i(){n.stopListening(),n.trigger("destroy",n,n.collection,e)}var n=this,s=e.success,r=e.wait,t=!(e.success=function(t){r&&i(),s&&s.call(e.context,n,t,e),n.isNew()||n.trigger("sync",n,t,e)});return this.isNew()?b.defer(e.success):(N(this,e),t=this.sync("delete",this,e)),r||i(),t},url:function(){var t,e=b.result(this,"urlRoot")||b.result(this.collection,"url")||M();return this.isNew()?e:(t=this.get(this.idAttribute),e.replace(/[^\/]$/,"$&/")+encodeURIComponent(t))},parse:function(t,e){return t},clone:function(){return new this.constructor(this.attributes)},isNew:function(){return!this.has(this.idAttribute)},isValid:function(t){return this._validate({},b.extend({},t,{validate:!0}))},_validate:function(t,e){if(!e.validate||!this.validate)return!0;t=b.extend({},this.attributes,t);t=this.validationError=this.validate(t,e)||null;return!t||(this.trigger("invalid",this,t,b.extend(e,{validationError:t})),!1)}}),h.Collection=function(t,e){e=e||{},this.preinitialize.apply(this,arguments),e.model&&(this.model=e.model),void 0!==e.comparator&&(this.comparator=e.comparator),this._reset(),this.initialize.apply(this,arguments),t&&this.reset(t,b.extend({silent:!0},e))}),w={add:!0,remove:!0,merge:!0},_={add:!0,remove:!1},y=(b.extend(m.prototype,e,{model:v,preinitialize:function(){},initialize:function(){},toJSON:function(e){return this.map(function(t){return t.toJSON(e)})},sync:function(){return h.sync.apply(this,arguments)},add:function(t,e){return this.set(t,b.extend({merge:!1},e,_))},remove:function(t,e){e=b.extend({},e);var i=!b.isArray(t),t=(t=i?[t]:t.slice(),this._removeModels(t,e));return!e.silent&&t.length&&(e.changes={added:[],merged:[],removed:t},this.trigger("update",this,e)),i?t[0]:t},set:function(t,e){if(null!=t){(e=b.extend({},w,e)).parse&&!this._isModel(t)&&(t=this.parse(t,e)||[]);for(var i=!b.isArray(t),n=(t=i?[t]:t.slice(),e.at),s=((n=(n=null!=n?+n:n)>this.length?this.length:n)<0&&(n+=this.length+1),[]),r=[],o=[],h=[],a={},u=e.add,l=e.merge,c=e.remove,d=!1,f=this.comparator&&null==n&&!1!==e.sort,p=b.isString(this.comparator)?this.comparator:null,g=0;g<t.length;g++){var v,m=t[g],_=this.get(m);_?(l&&m!==_&&(v=this._isModel(m)?m.attributes:m,e.parse&&(v=_.parse(v,e)),_.set(v,e),o.push(_),f)&&!d&&(d=_.hasChanged(p)),a[_.cid]||(a[_.cid]=!0,s.push(_)),t[g]=_):u&&(m=t[g]=this._prepareModel(m,e))&&(r.push(m),this._addReference(m,e),a[m.cid]=!0,s.push(m))}if(c){for(g=0;g<this.length;g++)a[(m=this.models[g]).cid]||h.push(m);h.length&&this._removeModels(h,e)}var y=!1;if(s.length&&(!f&&u&&c)?(y=this.length!==s.length||b.some(this.models,function(t,e){return t!==s[e]}),this.models.length=0,x(this.models,s,0),this.length=this.models.length):r.length&&(f&&(d=!0),x(this.models,r,null==n?this.length:n),this.length=this.models.length),d&&this.sort({silent:!0}),!e.silent){for(g=0;g<r.length;g++)null!=n&&(e.index=n+g),(m=r[g]).trigger("add",m,this,e);(d||y)&&this.trigger("sort",this,e),(r.length||h.length||o.length)&&(e.changes={added:r,removed:h,merged:o},this.trigger("update",this,e))}return i?t[0]:t}},reset:function(t,e){e=e?b.clone(e):{};for(var i=0;i<this.models.length;i++)this._removeReference(this.models[i],e);return e.previousModels=this.models,this._reset(),t=this.add(t,b.extend({silent:!0},e)),e.silent||this.trigger("reset",this,e),t},push:function(t,e){return this.add(t,b.extend({at:this.length},e))},pop:function(t){var e=this.at(this.length-1);return this.remove(e,t)},unshift:function(t,e){return this.add(t,b.extend({at:0},e))},shift:function(t){var e=this.at(0);return this.remove(e,t)},slice:function(){return u.apply(this.models,arguments)},get:function(t){if(null!=t)return this._byId[t]||this._byId[this.modelId(this._isModel(t)?t.attributes:t,t.idAttribute)]||t.cid&&this._byId[t.cid]},has:function(t){return null!=this.get(t)},at:function(t){return t<0&&(t+=this.length),this.models[t]},where:function(t,e){return this[e?"find":"filter"](t)},findWhere:function(t){return this.where(t,!0)},sort:function(t){var e=this.comparator;if(!e)throw new Error("Cannot sort a set without a comparator");t=t||{};var i=e.length;return b.isFunction(e)&&(e=e.bind(this)),1===i||b.isString(e)?this.models=this.sortBy(e):this.models.sort(e),t.silent||this.trigger("sort",this,t),this},pluck:function(t){return this.map(t+"")},fetch:function(i){var n=(i=b.extend({parse:!0},i)).success,s=this;return i.success=function(t){var e=i.reset?"reset":"set";s[e](t,i),n&&n.call(i.context,s,t,i),s.trigger("sync",s,t,i)},N(this,i),this.sync("read",this,i)},create:function(t,e){var n=(e=e?b.clone(e):{}).wait;if(!(t=this._prepareModel(t,e)))return!1;n||this.add(t,e);var s=this,r=e.success;return e.success=function(t,e,i){n&&(t.off("error",s._forwardPristineError,s),s.add(t,i)),r&&r.call(i.context,t,e,i)},n&&t.once("error",this._forwardPristineError,this),t.save(null,e),t},parse:function(t,e){return t},clone:function(){return new this.constructor(this.models,{model:this.model,comparator:this.comparator})},modelId:function(t,e){return t[e||this.model.prototype.idAttribute||"id"]},values:function(){return new E(this,S)},keys:function(){return new E(this,I)},entries:function(){return new E(this,k)},_reset:function(){this.length=0,this.models=[],this._byId={}},_prepareModel:function(t,e){return this._isModel(t)?(t.collection||(t.collection=this),t):(t=((e=e?b.clone(e):{}).collection=this).model.prototype?new this.model(t,e):this.model(t,e)).validationError?(this.trigger("invalid",this,t.validationError,e),!1):t},_removeModels:function(t,e){for(var i=[],n=0;n<t.length;n++){var s,r,o=this.get(t[n]);o&&(s=this.indexOf(o),this.models.splice(s,1),this.length--,delete this._byId[o.cid],null!=(r=this.modelId(o.attributes,o.idAttribute))&&delete this._byId[r],e.silent||(e.index=s,o.trigger("remove",o,this,e)),i.push(o),this._removeReference(o,e))}return 0<t.length&&!e.silent&&delete e.index,i},_isModel:function(t){return t instanceof v},_addReference:function(t,e){this._byId[t.cid]=t;var i=this.modelId(t.attributes,t.idAttribute);null!=i&&(this._byId[i]=t),t.on("all",this._onModelEvent,this)},_removeReference:function(t,e){delete this._byId[t.cid];var i=this.modelId(t.attributes,t.idAttribute);null!=i&&delete this._byId[i],this===t.collection&&delete t.collection,t.off("all",this._onModelEvent,this)},_onModelEvent:function(t,e,i,n){if(e){if(("add"===t||"remove"===t)&&i!==this)return;var s,r;"destroy"===t&&this.remove(e,n),"changeId"===t&&(s=this.modelId(e.previousAttributes(),e.idAttribute),r=this.modelId(e.attributes,e.idAttribute),null!=s&&delete this._byId[s],null!=r)&&(this._byId[r]=e)}this.trigger.apply(this,arguments)},_forwardPristineError:function(t,e,i){this.has(t)||this._onModelEvent("error",t,e,i)}}),"function"==typeof Symbol&&Symbol.iterator),E=(y&&(m.prototype[y]=m.prototype.values),function(t,e){this._collection=t,this._kind=e,this._index=0}),S=1,I=2,k=3,y=(y&&(E.prototype[y]=function(){return this}),E.prototype.next=function(){if(this._collection){var t,e;if(this._index<this._collection.length)return t=this._collection.at(this._index),this._index++,{value:this._kind===S?t:(e=this._collection.modelId(t.attributes,t.idAttribute),this._kind===I?e:[e,t]),done:!1};this._collection=void 0}return{value:void 0,done:!0}},h.View=function(t){this.cid=b.uniqueId("view"),this.preinitialize.apply(this,arguments),b.extend(this,b.pick(t,P)),this._ensureElement(),this.initialize.apply(this,arguments)}),A=/^(\S+)\s*(.*)$/,P=["model","collection","el","id","attributes","className","tagName","events"],T=(b.extend(y.prototype,e,{tagName:"div",$:function(t){return this.$el.find(t)},preinitialize:function(){},initialize:function(){},render:function(){return this},remove:function(){return this._removeElement(),this.stopListening(),this},_removeElement:function(){this.$el.remove()},setElement:function(t){return this.undelegateEvents(),this._setElement(t),this.delegateEvents(),this},_setElement:function(t){this.$el=t instanceof h.$?t:h.$(t),this.el=this.$el[0]},delegateEvents:function(t){if(t=t||b.result(this,"events"))for(var e in this.undelegateEvents(),t){var i=t[e];(i=b.isFunction(i)?i:this[i])&&(e=e.match(A),this.delegate(e[1],e[2],i.bind(this)))}return this},delegate:function(t,e,i){return this.$el.on(t+".delegateEvents"+this.cid,e,i),this},undelegateEvents:function(){return this.$el&&this.$el.off(".delegateEvents"+this.cid),this},undelegate:function(t,e,i){return this.$el.off(t+".delegateEvents"+this.cid,e,i),this},_createElement:function(t){return document.createElement(t)},_ensureElement:function(){var t;this.el?this.setElement(b.result(this,"el")):(t=b.extend({},b.result(this,"attributes")),this.id&&(t.id=b.result(this,"id")),this.className&&(t.class=b.result(this,"className")),this.setElement(this._createElement(b.result(this,"tagName"))),this._setAttributes(t))},_setAttributes:function(t){this.$el.attr(t)}}),function(e,t){var i;return b.isFunction(e)?e:b.isObject(e)&&!t._isModel(e)?(i=b.matches(e),function(t){return i(t.attributes)}):b.isString(e)?function(t){return t.get(e)}:e}),H=(b.each([[m,{forEach:3,each:3,map:3,collect:3,reduce:0,foldl:0,inject:0,reduceRight:0,foldr:0,find:3,detect:3,filter:3,select:3,reject:3,every:3,all:3,some:3,any:3,include:3,includes:3,contains:3,invoke:0,max:3,min:3,toArray:1,size:1,first:3,head:3,take:3,initial:3,rest:3,tail:3,drop:3,last:3,without:0,difference:0,indexOf:3,shuffle:1,lastIndexOf:3,isEmpty:1,chain:1,sample:3,partition:3,groupBy:3,countBy:3,sortBy:3,indexBy:3,findIndex:3,findLastIndex:3},"models"],[v,{keys:1,values:1,pairs:1,invert:1,pick:0,omit:0,chain:1,isEmpty:1},"attributes"]],function(t){var i=t[0],e=t[1],n=t[2];i.mixin=function(t){var e=b.reduce(b.functions(t),function(t,e){return t[e]=0,t},{});s(i,t,e,n)},s(i,b,e,n)}),h.sync=function(t,e,n){var i,s=H[t],r=(b.defaults(n=n||{},{emulateHTTP:h.emulateHTTP,emulateJSON:h.emulateJSON}),{type:s,dataType:"json"}),o=(n.url||(r.url=b.result(e,"url")||M()),null!=n.data||!e||"create"!==t&&"update"!==t&&"patch"!==t||(r.contentType="application/json",r.data=JSON.stringify(n.attrs||e.toJSON(n))),n.emulateJSON&&(r.contentType="application/x-www-form-urlencoded",r.data=r.data?{model:r.data}:{}),!n.emulateHTTP||"PUT"!==s&&"DELETE"!==s&&"PATCH"!==s||(r.type="POST",n.emulateJSON&&(r.data._method=s),i=n.beforeSend,n.beforeSend=function(t){if(t.setRequestHeader("X-HTTP-Method-Override",s),i)return i.apply(this,arguments)}),"GET"===r.type||n.emulateJSON||(r.processData=!1),n.error),t=(n.error=function(t,e,i){n.textStatus=e,n.errorThrown=i,o&&o.call(n.context,t,e,i)},n.xhr=h.ajax(b.extend(r,n)));return e.trigger("request",e,t,n),t},{create:"POST",update:"PUT",patch:"PATCH",delete:"DELETE",read:"GET"}),$=(h.ajax=function(){return h.$.ajax.apply(h.$,arguments)},h.Router=function(t){t=t||{},this.preinitialize.apply(this,arguments),t.routes&&(this.routes=t.routes),this._bindRoutes(),this.initialize.apply(this,arguments)}),C=/\((.*?)\)/g,j=/(\(\?)?:\w+/g,O=/\*\w+/g,U=/[\-{}\[\]+?.,\\\^$|#\s]/g,R=(b.extend($.prototype,e,{preinitialize:function(){},initialize:function(){},route:function(e,i,n){b.isRegExp(e)||(e=this._routeToRegExp(e)),b.isFunction(i)&&(n=i,i=""),n=n||this[i];var s=this;return h.history.route(e,function(t){t=s._extractParameters(e,t);!1!==s.execute(n,t,i)&&(s.trigger.apply(s,["route:"+i].concat(t)),s.trigger("route",i,t),h.history.trigger("route",s,i,t))}),this},execute:function(t,e,i){t&&t.apply(this,e)},navigate:function(t,e){return h.history.navigate(t,e),this},_bindRoutes:function(){if(this.routes){this.routes=b.result(this,"routes");for(var t,e=b.keys(this.routes);null!=(t=e.pop());)this.route(t,this.routes[t])}},_routeToRegExp:function(t){return t=t.replace(U,"\\$&").replace(C,"(?:$1)?").replace(j,function(t,e){return e?t:"([^/?]+)"}).replace(O,"([^?]*?)"),new RegExp("^"+t+"(?:\\?([\\s\\S]*))?$")},_extractParameters:function(t,e){var i=t.exec(e).slice(1);return b.map(i,function(t,e){return e===i.length-1?t||null:t?decodeURIComponent(t):null})}}),h.History=function(){this.handlers=[],this.checkUrl=this.checkUrl.bind(this),"undefined"!=typeof window&&(this.location=window.location,this.history=window.history)}),z=/^[#\/]|\s+$/g,q=/^\/+|\/+$/g,F=/#.*$/,M=(R.started=!1,b.extend(R.prototype,e,{interval:50,atRoot:function(){return this.location.pathname.replace(/[^\/]$/,"$&/")===this.root&&!this.getSearch()},matchRoot:function(){return this.decodeFragment(this.location.pathname).slice(0,this.root.length-1)+"/"===this.root},decodeFragment:function(t){return decodeURI(t.replace(/%25/g,"%2525"))},getSearch:function(){var t=this.location.href.replace(/#.*/,"").match(/\?.+/);return t?t[0]:""},getHash:function(t){t=(t||this).location.href.match(/#(.*)$/);return t?t[1]:""},getPath:function(){var t=this.decodeFragment(this.location.pathname+this.getSearch()).slice(this.root.length-1);return"/"===t.charAt(0)?t.slice(1):t},getFragment:function(t){return(t=null==t?this._usePushState||!this._wantsHashChange?this.getPath():this.getHash():t).replace(z,"")},start:function(t){if(R.started)throw new Error("Backbone.history has already been started");if(R.started=!0,this.options=b.extend({root:"/"},this.options,t),this.root=this.options.root,this._trailingSlash=this.options.trailingSlash,this._wantsHashChange=!1!==this.options.hashChange,this._hasHashChange="onhashchange"in window&&(void 0===document.documentMode||7<document.documentMode),this._useHashChange=this._wantsHashChange&&this._hasHashChange,this._wantsPushState=!!this.options.pushState,this._hasPushState=!(!this.history||!this.history.pushState),this._usePushState=this._wantsPushState&&this._hasPushState,this.fragment=this.getFragment(),this.root=("/"+this.root+"/").replace(q,"/"),this._wantsHashChange&&this._wantsPushState){if(!this._hasPushState&&!this.atRoot())return t=this.root.slice(0,-1)||"/",this.location.replace(t+"#"+this.getPath()),!0;this._hasPushState&&this.atRoot()&&this.navigate(this.getHash(),{replace:!0})}this._hasHashChange||!this._wantsHashChange||this._usePushState||(this.iframe=document.createElement("iframe"),this.iframe.src="javascript:0",this.iframe.style.display="none",this.iframe.tabIndex=-1,(t=(t=document.body).insertBefore(this.iframe,t.firstChild).contentWindow).document.open(),t.document.close(),t.location.hash="#"+this.fragment);t=window.addEventListener||function(t,e){return attachEvent("on"+t,e)};if(this._usePushState?t("popstate",this.checkUrl,!1):this._useHashChange&&!this.iframe?t("hashchange",this.checkUrl,!1):this._wantsHashChange&&(this._checkUrlInterval=setInterval(this.checkUrl,this.interval)),!this.options.silent)return this.loadUrl()},stop:function(){var t=window.removeEventListener||function(t,e){return detachEvent("on"+t,e)};this._usePushState?t("popstate",this.checkUrl,!1):this._useHashChange&&!this.iframe&&t("hashchange",this.checkUrl,!1),this.iframe&&(document.body.removeChild(this.iframe),this.iframe=null),this._checkUrlInterval&&clearInterval(this._checkUrlInterval),R.started=!1},route:function(t,e){this.handlers.unshift({route:t,callback:e})},checkUrl:function(t){var e=this.getFragment();if((e=e===this.fragment&&this.iframe?this.getHash(this.iframe.contentWindow):e)===this.fragment)return!this.matchRoot()&&this.notfound();this.iframe&&this.navigate(e),this.loadUrl()},loadUrl:function(e){return this.matchRoot()&&(e=this.fragment=this.getFragment(e),b.some(this.handlers,function(t){if(t.route.test(e))return t.callback(e),!0}))||this.notfound()},notfound:function(){return this.trigger("notfound"),!1},navigate:function(t,e){if(!R.started)return!1;e&&!0!==e||(e={trigger:!!e}),t=this.getFragment(t||"");var i=this.root,i=(i=this._trailingSlash||""!==t&&"?"!==t.charAt(0)?i:i.slice(0,-1)||"/")+t,n=(t=t.replace(F,""),this.decodeFragment(t));if(this.fragment!==n){if(this.fragment=n,this._usePushState)this.history[e.replace?"replaceState":"pushState"]({},document.title,i);else{if(!this._wantsHashChange)return this.location.assign(i);this._updateHash(this.location,t,e.replace),this.iframe&&t!==this.getHash(this.iframe.contentWindow)&&(n=this.iframe.contentWindow,e.replace||(n.document.open(),n.document.close()),this._updateHash(n.location,t,e.replace))}return e.trigger?this.loadUrl(t):void 0}},_updateHash:function(t,e,i){i?(i=t.href.replace(/(javascript:|#).*$/,""),t.replace(i+"#"+e)):t.hash="#"+e}}),h.history=new R,v.extend=m.extend=$.extend=y.extend=R.extend=function(t,e){var i=this,n=t&&b.has(t,"constructor")?t.constructor:function(){return i.apply(this,arguments)};return b.extend(n,i,e),n.prototype=b.create(i.prototype,t),(n.prototype.constructor=n).__super__=i.prototype,n},function(){throw new Error('A "url" property or function must be specified')}),N=function(e,i){var n=i.error;i.error=function(t){n&&n.call(i.context,e,t,i),e.trigger("error",e,t,i)}};return h._debug=function(){return{root:t,_:b}},h});
(function(t,e){if("function"==typeof define&&define.amd)define(["backbone","underscore"],function(i,n){return t.Marionette=t.Mn=e(t,i,n)});else if("undefined"!=typeof exports){var i=require("backbone"),n=require("underscore");module.exports=e(t,i,n)}else t.Marionette=t.Mn=e(t,t.Backbone,t._)})(this,function(t,e,i){"use strict";(function(t,e){var i=t.ChildViewContainer;return t.ChildViewContainer=function(t,e){var i=function(t){this._views={},this._indexByModel={},this._indexByCustom={},this._updateLength(),e.each(t,this.add,this)};e.extend(i.prototype,{add:function(t,e){var i=t.cid;return this._views[i]=t,t.model&&(this._indexByModel[t.model.cid]=i),e&&(this._indexByCustom[e]=i),this._updateLength(),this},findByModel:function(t){return this.findByModelCid(t.cid)},findByModelCid:function(t){var e=this._indexByModel[t];return this.findByCid(e)},findByCustom:function(t){var e=this._indexByCustom[t];return this.findByCid(e)},findByIndex:function(t){return e.values(this._views)[t]},findByCid:function(t){return this._views[t]},remove:function(t){var i=t.cid;return t.model&&delete this._indexByModel[t.model.cid],e.any(this._indexByCustom,function(t,e){return t===i?(delete this._indexByCustom[e],!0):void 0},this),delete this._views[i],this._updateLength(),this},call:function(t){this.apply(t,e.tail(arguments))},apply:function(t,i){e.each(this._views,function(n){e.isFunction(n[t])&&n[t].apply(n,i||[])})},_updateLength:function(){this.length=e.size(this._views)}});var n=["forEach","each","map","find","detect","filter","select","reject","every","all","some","any","include","contains","invoke","toArray","first","initial","rest","last","without","isEmpty","pluck","reduce"];return e.each(n,function(t){i.prototype[t]=function(){var i=e.values(this._views),n=[i].concat(e.toArray(arguments));return e[t].apply(e,n)}}),i}(t,e),t.ChildViewContainer.VERSION="0.1.7",t.ChildViewContainer.noConflict=function(){return t.ChildViewContainer=i,this},t.ChildViewContainer})(e,i),function(t,e){var i=t.Wreqr,n=t.Wreqr={};return t.Wreqr.VERSION="1.3.3",t.Wreqr.noConflict=function(){return t.Wreqr=i,this},n.Handlers=function(t,e){var i=function(t){this.options=t,this._wreqrHandlers={},e.isFunction(this.initialize)&&this.initialize(t)};return i.extend=t.Model.extend,e.extend(i.prototype,t.Events,{setHandlers:function(t){e.each(t,function(t,i){var n=null;e.isObject(t)&&!e.isFunction(t)&&(n=t.context,t=t.callback),this.setHandler(i,t,n)},this)},setHandler:function(t,e,i){var n={callback:e,context:i};this._wreqrHandlers[t]=n,this.trigger("handler:add",t,e,i)},hasHandler:function(t){return!!this._wreqrHandlers[t]},getHandler:function(t){var e=this._wreqrHandlers[t];if(e)return function(){return e.callback.apply(e.context,arguments)}},removeHandler:function(t){delete this._wreqrHandlers[t]},removeAllHandlers:function(){this._wreqrHandlers={}}}),i}(t,e),n.CommandStorage=function(){var i=function(t){this.options=t,this._commands={},e.isFunction(this.initialize)&&this.initialize(t)};return e.extend(i.prototype,t.Events,{getCommands:function(t){var e=this._commands[t];return e||(e={command:t,instances:[]},this._commands[t]=e),e},addCommand:function(t,e){var i=this.getCommands(t);i.instances.push(e)},clearCommands:function(t){var e=this.getCommands(t);e.instances=[]}}),i}(),n.Commands=function(t,e){return t.Handlers.extend({storageType:t.CommandStorage,constructor:function(e){this.options=e||{},this._initializeStorage(this.options),this.on("handler:add",this._executeCommands,this),t.Handlers.prototype.constructor.apply(this,arguments)},execute:function(t){t=arguments[0];var i=e.rest(arguments);this.hasHandler(t)?this.getHandler(t).apply(this,i):this.storage.addCommand (t,i)},_executeCommands:function(t,i,n){var r=this.storage.getCommands(t);e.each(r.instances,function(t){i.apply(n,t)}),this.storage.clearCommands(t)},_initializeStorage:function(t){var i,n=t.storageType||this.storageType;i=e.isFunction(n)?new n:n,this.storage=i}})}(n,e),n.RequestResponse=function(t,e){return t.Handlers.extend({request:function(t){return this.hasHandler(t)?this.getHandler(t).apply(this,e.rest(arguments)):void 0}})}(n,e),n.EventAggregator=function(t,e){var i=function(){};return i.extend=t.Model.extend,e.extend(i.prototype,t.Events),i}(t,e),n.Channel=function(){var i=function(e){this.vent=new t.Wreqr.EventAggregator,this.reqres=new t.Wreqr.RequestResponse,this.commands=new t.Wreqr.Commands,this.channelName=e};return e.extend(i.prototype,{reset:function(){return this.vent.off(),this.vent.stopListening(),this.reqres.removeAllHandlers(),this.commands.removeAllHandlers(),this},connectEvents:function(t,e){return this._connect("vent",t,e),this},connectCommands:function(t,e){return this._connect("commands",t,e),this},connectRequests:function(t,e){return this._connect("reqres",t,e),this},_connect:function(t,i,n){if(i){n=n||this;var r="vent"===t?"on":"setHandler";e.each(i,function(i,s){this[t][r](s,e.bind(i,n))},this)}}}),i}(n),n.radio=function(t,e){var i=function(){this._channels={},this.vent={},this.commands={},this.reqres={},this._proxyMethods()};e.extend(i.prototype,{channel:function(t){if(!t)throw Error("Channel must receive a name");return this._getChannel(t)},_getChannel:function(e){var i=this._channels[e];return i||(i=new t.Channel(e),this._channels[e]=i),i},_proxyMethods:function(){e.each(["vent","commands","reqres"],function(t){e.each(n[t],function(e){this[t][e]=r(this,t,e)},this)},this)}});var n={vent:["on","off","trigger","once","stopListening","listenTo","listenToOnce"],commands:["execute","setHandler","setHandlers","removeHandler","removeAllHandlers"],reqres:["request","setHandler","setHandlers","removeHandler","removeAllHandlers"]},r=function(t,i,n){return function(r){var s=t._getChannel(r)[i];return s[n].apply(s,e.rest(arguments))}};return new i}(n,e),t.Wreqr}(e,i);var n=t.Marionette,r=t.Mn,s=e.Marionette={};s.VERSION="2.4.2",s.noConflict=function(){return t.Marionette=n,t.Mn=r,this},e.Marionette=s,s.Deferred=e.$.Deferred,s.extend=e.Model.extend,s.isNodeAttached=function(t){return e.$.contains(document.documentElement,t)},s.mergeOptions=function(t,e){t&&i.extend(this,i.pick(t,e))},s.getOption=function(t,e){return t&&e?t.options&&void 0!==t.options[e]?t.options[e]:t[e]:void 0},s.proxyGetOption=function(t){return s.getOption(this,t)},s._getValue=function(t,e,n){return i.isFunction(t)&&(t=n?t.apply(e,n):t.call(e)),t},s.normalizeMethods=function(t){return i.reduce(t,function(t,e,n){return i.isFunction(e)||(e=this[e]),e&&(t[n]=e),t},{},this)},s.normalizeUIString=function(t,e){return t.replace(/@ui\.[a-zA-Z_$0-9]*/g,function(t){return e[t.slice(4)]})},s.normalizeUIKeys=function(t,e){return i.reduce(t,function(t,i,n){var r=s.normalizeUIString(n,e);return t[r]=i,t},{})},s.normalizeUIValues=function(t,e,n){return i.each(t,function(r,o){i.isString(r)?t[o]=s.normalizeUIString(r,e):i.isObject(r)&&i.isArray(n)&&(i.extend(r,s.normalizeUIValues(i.pick(r,n),e)),i.each(n,function(t){var n=r[t];i.isString(n)&&(r[t]=s.normalizeUIString(n,e))}))}),t},s.actAsCollection=function(t,e){var n=["forEach","each","map","find","detect","filter","select","reject","every","all","some","any","include","contains","invoke","toArray","first","initial","rest","last","without","isEmpty","pluck"];i.each(n,function(n){t[n]=function(){var t=i.values(i.result(this,e)),r=[t].concat(i.toArray(arguments));return i[n].apply(i,r)}})};var o=s.deprecate=function(t,e){i.isObject(t)&&(t=t.prev+" is going to be removed in the future. "+"Please use "+t.next+" instead."+(t.url?" See: "+t.url:"")),void 0!==e&&e||o._cache[t]||(o._warn("Deprecation warning: "+t),o._cache[t]=!0)};o._warn="undefined"!=typeof console&&(console.warn||console.log)||function(){},o._cache={},s._triggerMethod=function(){function t(t,e,i){return i.toUpperCase()}var e=/(^|:)(\w)/gi;return function(n,r,s){var o=3>arguments.length;o&&(s=r,r=s[0]);var h,a="on"+r.replace(e,t),d=n[a];return i.isFunction(d)&&(h=d.apply(n,o?i.rest(s):s)),i.isFunction(n.trigger)&&(o+s.length>1?n.trigger.apply(n,o?s:[r].concat(i.drop(s,0))):n.trigger(r)),h}}(),s.triggerMethod=function(){return s._triggerMethod(this,arguments)},s.triggerMethodOn=function(t){var e=i.isFunction(t.triggerMethod)?t.triggerMethod:s.triggerMethod;return e.apply(t,i.rest(arguments))},s.MonitorDOMRefresh=function(t){function e(){t._isShown=!0,r()}function n(){t._isRendered=!0,r()}function r(){t._isShown&&t._isRendered&&s.isNodeAttached(t.el)&&i.isFunction(t.triggerMethod)&&t.triggerMethod("dom:refresh")}t.on({show:e,render:n})},function(t){function e(e,n,r,s){var o=s.split(/\s+/);i.each(o,function(i){var s=e[i];if(!s)throw new t.Error('Method "'+i+'" was configured as an event handler, but does not exist.');e.listenTo(n,r,s)})}function n(t,e,i,n){t.listenTo(e,i,n)}function r(t,e,n,r){var s=r.split(/\s+/);i.each(s,function(i){var r=t[i];t.stopListening(e,n,r)})}function s(t,e,i,n){t.stopListening(e,i,n)}function o(e,n,r,s,o){if(n&&r){if(!i.isObject(r))throw new t.Error({message:"Bindings must be an object or function.",url:"marionette.functions.html#marionettebindentityevents"});r=t._getValue(r,e),i.each(r,function(t,r){i.isFunction(t)?s(e,n,r,t):o(e,n,r,t)})}}t.bindEntityEvents=function(t,i,r){o(t,i,r,n,e)},t.unbindEntityEvents=function(t,e,i){o(t,e,i,s,r)},t.proxyBindEntityEvents=function(e,i){return t.bindEntityEvents(this,e,i)},t.proxyUnbindEntityEvents=function(e,i){return t.unbindEntityEvents(this,e,i)}}(s);var h=["description","fileName","lineNumber","name","message","number"];return s.Error=s.extend.call(Error,{urlRoot:"http://marionettejs.com/docs/v"+s.VERSION+"/",constructor:function(t,e){i.isObject(t)?(e=t,t=e.message):e||(e={});var n=Error.call(this,t);i.extend(this,i.pick(n,h),i.pick(e,h)),this.captureStackTrace(),e.url&&(this.url=this.urlRoot+e.url)},captureStackTrace:function(){Error.captureStackTrace&&Error.captureStackTrace(this,s.Error)},toString:function(){return this.name+": "+this.message+(this.url?" See: "+this.url:"")}}),s.Error.extend=s.extend,s.Callbacks=function(){this._deferred=s.Deferred(),this._callbacks=[]},i.extend(s.Callbacks.prototype,{add:function(t,e){var n=i.result(this._deferred,"promise");this._callbacks.push({cb:t,ctx:e}),n.then(function(i){e&&(i.context=e),t.call(i.context,i.options)})},run:function(t,e){this._deferred.resolve({options:t,context:e})},reset:function(){var t=this._callbacks;this._deferred=s.Deferred(),this._callbacks=[],i.each(t,function(t){this.add(t.cb,t.ctx)},this)}}),s.Controller=function(t){this.options=t||{},i.isFunction(this.initialize)&&this.initialize(this.options)},s.Controller.extend=s.extend,i.extend(s.Controller.prototype,e.Events,{destroy:function(){return s._triggerMethod(this,"before:destroy",arguments),s._triggerMethod(this,"destroy",arguments),this.stopListening(),this.off(),this},triggerMethod:s.triggerMethod,mergeOptions:s.mergeOptions,getOption:s.proxyGetOption}),s.Object=function(t){this.options=i.extend({},i.result(this,"options"),t),this.initialize.apply(this,arguments)},s.Object.extend=s.extend,i.extend(s.Object.prototype,e.Events,{initialize:function(){},destroy:function(){return this.triggerMethod("before:destroy"),this.triggerMethod("destroy"),this.stopListening(),this},triggerMethod:s.triggerMethod,mergeOptions:s.mergeOptions,getOption:s.proxyGetOption,bindEntityEvents:s.proxyBindEntityEvents,unbindEntityEvents:s.proxyUnbindEntityEvents}),s.Region=s.Object.extend({constructor:function(t){if(this.options=t||{},this.el=this.getOption("el"),this.el=this.el instanceof e.$?this.el[0]:this.el,!this.el)throw new s.Error({name:"NoElError",message:'An "el" must be specified for a region.'});this.$el=this.getEl(this.el),s.Object.call(this,t)},show:function(t,e){if(this._ensureElement()){this._ensureViewIsIntact(t);var n=e||{},r=t!==this.currentView,o=!!n.preventDestroy,h=!!n.forceShow,a=!!this.currentView,d=r&&!o,l=r||h;if(a&&this.triggerMethod("before:swapOut",this.currentView,this,e),this.currentView&&delete this.currentView._parent,d?this.empty():a&&l&&this.currentView.off("destroy",this.empty,this),l){t.once("destroy",this.empty,this),t.render(),t._parent=this,a&&this.triggerMethod("before:swap",t,this,e),this.triggerMethod("before:show",t,this,e),s.triggerMethodOn(t,"before:show",t,this,e),a&&this.triggerMethod("swapOut",this.currentView,this,e);var c=s.isNodeAttached(this.el),u=[],g=i.extend({triggerBeforeAttach:this.triggerBeforeAttach,triggerAttach:this.triggerAttach},n);return c&&g.triggerBeforeAttach&&(u=this._displayedViews(t),this._triggerAttach(u,"before:")),this.attachHtml(t),this.currentView=t,c&&g.triggerAttach&&(u=this._displayedViews(t),this._triggerAttach(u)),a&&this.triggerMethod("swap",t,this,e),this.triggerMethod("show",t,this,e),s.triggerMethodOn(t,"show",t,this,e),this}return this}},triggerBeforeAttach:!0,triggerAttach:!0,_triggerAttach:function(t,e){var n=(e||"")+"attach";i.each(t,function(t){s.triggerMethodOn(t,n,t,this)},this)},_displayedViews:function(t){return i.union([t],i.result(t,"_getNestedViews")||[])},_ensureElement:function(){if(i.isObject(this.el)||(this.$el=this.getEl(this.el),this.el=this.$el[0]),!this.$el||0===this.$el.length){if(this.getOption("allowMissingEl"))return!1;throw new s.Error('An "el" '+this.$el.selector+" must exist in DOM")}return!0},_ensureViewIsIntact:function(t){if(!t)throw new s.Error({name:"ViewNotValid",message:"The view passed is undefined and therefore invalid. You must pass a view instance to show."});if(t.isDestroyed)throw new s.Error({name:"ViewDestroyedError",message:'View (cid: "'+t.cid+'") has already been destroyed and cannot be used.'})},getEl:function(t){return e.$(t,s._getValue(this.options.parentEl,this))},attachHtml:function(t){this.$el.contents().detach(),this.el.appendChild(t.el)},empty:function(t){var e=this.currentView,i=s._getValue(t,"preventDestroy",this);return e?(e.off("destroy",this.empty,this),this.triggerMethod("before:empty",e),i||this._destroyView(),this.triggerMethod("empty",e),delete this.currentView,i&&this.$el.contents().detach(),this):void 0},_destroyView:function(){var t=this.currentView;t.destroy&&!t.isDestroyed?t.destroy():t.remove&&(t.remove(),t.isDestroyed=!0)},attachView:function(t){return this.currentView=t,this},hasView:function(){return!!this.currentView},reset:function(){return this.empty(),this.$el&&(this.el=this.getOption('el')),delete this.$el,this}},{buildRegion:function(t,e){if(i.isString(t))return this._buildRegionFromSelector(t,e);if(t.selector||t.el||t.regionClass)return this._buildRegionFromObject(t,e);if(i.isFunction(t))return this._buildRegionFromRegionClass(t);throw new s.Error({message:"Improper region configuration type.",url:"marionette.region.html#region-configuration-types"})},_buildRegionFromSelector:function(t,e){return new e({el:t})},_buildRegionFromObject:function(t,e){var n=t.regionClass||e,r=i.omit(t,"selector","regionClass");return t.selector&&!r.el&&(r.el=t.selector),new n(r)},_buildRegionFromRegionClass:function(t){return new t}}),s.RegionManager=s.Controller.extend({constructor:function(t){this._regions={},this.length=0,s.Controller.call(this,t),this.addRegions(this.getOption("regions"))},addRegions:function(t,e){return t=s._getValue(t,this,arguments),i.reduce(t,function(t,n,r){return i.isString(n)&&(n={selector:n}),n.selector&&(n=i.defaults({},n,e)),t[r]=this.addRegion(r,n),t},{},this)},addRegion:function(t,e){var i;return i=e instanceof s.Region?e:s.Region.buildRegion(e,s.Region),this.triggerMethod("before:add:region",t,i),i._parent=this,this._store(t,i),this.triggerMethod("add:region",t,i),i},get:function(t){return this._regions[t]},getRegions:function(){return i.clone(this._regions)},removeRegion:function(t){var e=this._regions[t];return this._remove(t,e),e},removeRegions:function(){var t=this.getRegions();return i.each(this._regions,function(t,e){this._remove(e,t)},this),t},emptyRegions:function(){var t=this.getRegions();return i.invoke(t,"empty"),t},destroy:function(){return this.removeRegions(),s.Controller.prototype.destroy.apply(this,arguments)},_store:function(t,e){this._regions[t]||this.length++,this._regions[t]=e},_remove:function(t,e){this.triggerMethod("before:remove:region",t,e),e.empty(),e.stopListening(),delete e._parent,delete this._regions[t],this.length--,this.triggerMethod("remove:region",t,e)}}),s.actAsCollection(s.RegionManager.prototype,"_regions"),s.TemplateCache=function(t){this.templateId=t},i.extend(s.TemplateCache,{templateCaches:{},get:function(t,e){var i=this.templateCaches[t];return i||(i=new s.TemplateCache(t),this.templateCaches[t]=i),i.load(e)},clear:function(){var t,e=i.toArray(arguments),n=e.length;if(n>0)for(t=0;n>t;t++)delete this.templateCaches[e[t]];else this.templateCaches={}}}),i.extend(s.TemplateCache.prototype,{load:function(t){if(this.compiledTemplate)return this.compiledTemplate;var e=this.loadTemplate(this.templateId,t);return this.compiledTemplate=this.compileTemplate(e,t),this.compiledTemplate},loadTemplate:function(t){var i=e.$(t).html();if(!i||0===i.length)throw new s.Error({name:"NoTemplateError",message:'Could not find template: "'+t+'"'});return i},compileTemplate:function(t,e){return i.template(t,e)}}),s.Renderer={render:function(t,e){if(!t)throw new s.Error({name:"TemplateNotFoundError",message:"Cannot render the template since its false, null or undefined."});var n=i.isFunction(t)?t:s.TemplateCache.get(t);return n(e)}},s.View=e.View.extend({isDestroyed:!1,constructor:function(t){i.bindAll(this,"render"),t=s._getValue(t,this),this.options=i.extend({},i.result(this,"options"),t),this._behaviors=s.Behaviors(this),e.View.call(this,this.options),s.MonitorDOMRefresh(this)},getTemplate:function(){return this.getOption("template")},serializeModel:function(t){return t.toJSON.apply(t,i.rest(arguments))},mixinTemplateHelpers:function(t){t=t||{};var e=this.getOption("templateHelpers");return e=s._getValue(e,this),i.extend(t,e)},normalizeUIKeys:function(t){var e=i.result(this,"_uiBindings");return s.normalizeUIKeys(t,e||i.result(this,"ui"))},normalizeUIValues:function(t,e){var n=i.result(this,"ui"),r=i.result(this,"_uiBindings");return s.normalizeUIValues(t,r||n,e)},configureTriggers:function(){if(this.triggers){var t=this.normalizeUIKeys(i.result(this,"triggers"));return i.reduce(t,function(t,e,i){return t[i]=this._buildViewTrigger(e),t},{},this)}},delegateEvents:function(t){return this._delegateDOMEvents(t),this.bindEntityEvents(this.model,this.getOption("modelEvents")),this.bindEntityEvents(this.collection,this.getOption("collectionEvents")),i.each(this._behaviors,function(t){t.bindEntityEvents(this.model,t.getOption("modelEvents")),t.bindEntityEvents(this.collection,t.getOption("collectionEvents"))},this),this},_delegateDOMEvents:function(t){var n=s._getValue(t||this.events,this);n=this.normalizeUIKeys(n),i.isUndefined(t)&&(this.events=n);var r={},o=i.result(this,"behaviorEvents")||{},h=this.configureTriggers(),a=i.result(this,"behaviorTriggers")||{};i.extend(r,o,n,h,a),e.View.prototype.delegateEvents.call(this,r)},undelegateEvents:function(){return e.View.prototype.undelegateEvents.apply(this,arguments),this.unbindEntityEvents(this.model,this.getOption("modelEvents")),this.unbindEntityEvents(this.collection,this.getOption("collectionEvents")),i.each(this._behaviors,function(t){t.unbindEntityEvents(this.model,t.getOption("modelEvents")),t.unbindEntityEvents(this.collection,t.getOption("collectionEvents"))},this),this},_ensureViewIsIntact:function(){if(this.isDestroyed)throw new s.Error({name:"ViewDestroyedError",message:'View (cid: "'+this.cid+'") has already been destroyed and cannot be used.'})},destroy:function(){if(this.isDestroyed)return this;var t=i.toArray(arguments);return this.triggerMethod.apply(this,["before:destroy"].concat(t)),this.isDestroyed=!0,this.triggerMethod.apply(this,["destroy"].concat(t)),this.unbindUIElements(),this.isRendered=!1,this.remove(),i.invoke(this._behaviors,"destroy",t),this},bindUIElements:function(){this._bindUIElements(),i.invoke(this._behaviors,this._bindUIElements)},_bindUIElements:function(){if(this.ui){this._uiBindings||(this._uiBindings=this.ui);var t=i.result(this,"_uiBindings");this.ui={},i.each(t,function(t,e){this.ui[e]=this.$(t)},this)}},unbindUIElements:function(){this._unbindUIElements(),i.invoke(this._behaviors,this._unbindUIElements)},_unbindUIElements:function(){this.ui&&this._uiBindings&&(i.each(this.ui,function(t,e){delete this.ui[e]},this),this.ui=this._uiBindings,delete this._uiBindings)},_buildViewTrigger:function(t){var e=i.isObject(t),n=i.defaults({},e?t:{},{preventDefault:!0,stopPropagation:!0}),r=e?n.event:t;return function(t){t&&(t.preventDefault&&n.preventDefault&&t.preventDefault(),t.stopPropagation&&n.stopPropagation&&t.stopPropagation());var e={view:this,model:this.model,collection:this.collection};this.triggerMethod(r,e)}},setElement:function(){var t=e.View.prototype.setElement.apply(this,arguments);return i.invoke(this._behaviors,"proxyViewProperties",this),t},triggerMethod:function(){var t=s._triggerMethod(this,arguments);return this._triggerEventOnBehaviors(arguments),this._triggerEventOnParentLayout(arguments[0],i.rest(arguments)),t},_triggerEventOnBehaviors:function(t){for(var e=s._triggerMethod,i=this._behaviors,n=0,r=i&&i.length;r>n;n++)e(i[n],t)},_triggerEventOnParentLayout:function(t,e){var n=this._parentLayoutView();if(n){var r=s.getOption(n,"childViewEventPrefix"),o=r+":"+t;s._triggerMethod(n,[o,this].concat(e));var h=s.getOption(n,"childEvents"),a=n.normalizeMethods(h);a&&i.isFunction(a[t])&&a[t].apply(n,[this].concat(e))}},_getImmediateChildren:function(){return[]},_getNestedViews:function(){var t=this._getImmediateChildren();return t.length?i.reduce(t,function(t,e){return e._getNestedViews?t.concat(e._getNestedViews()):t},t):t},_getAncestors:function(){for(var t=[],e=this._parent;e;)t.push(e),e=e._parent;return t},_parentLayoutView:function(){var t=this._getAncestors();return i.find(t,function(t){return t instanceof s.LayoutView})},normalizeMethods:s.normalizeMethods,mergeOptions:s.mergeOptions,getOption:s.proxyGetOption,bindEntityEvents:s.proxyBindEntityEvents,unbindEntityEvents:s.proxyUnbindEntityEvents}),s.ItemView=s.View.extend({constructor:function(){s.View.apply(this,arguments)},serializeData:function(){if(!this.model&&!this.collection)return{};var t=[this.model||this.collection];return arguments.length&&t.push.apply(t,arguments),this.model?this.serializeModel.apply(this,t):{items:this.serializeCollection.apply(this,t)}},serializeCollection:function(t){return t.toJSON.apply(t,i.rest(arguments))},render:function(){return this._ensureViewIsIntact(),this.triggerMethod("before:render",this),this._renderTemplate(),this.isRendered=!0,this.bindUIElements(),this.triggerMethod("render",this),this},_renderTemplate:function(){var t=this.getTemplate();if(t!==!1){if(!t)throw new s.Error({name:"UndefinedTemplateError",message:"Cannot render the template since it is null or undefined."});var e=this.mixinTemplateHelpers(this.serializeData()),i=s.Renderer.render(t,e,this);return this.attachElContent(i),this}},attachElContent:function(t){return this.$el.html(t),this}}),s.CollectionView=s.View.extend({childViewEventPrefix:"childview",sort:!0,constructor:function(){this.once("render",this._initialEvents),this._initChildViewStorage(),s.View.apply(this,arguments),this.on({"before:show":this._onBeforeShowCalled,show:this._onShowCalled,"before:attach":this._onBeforeAttachCalled,attach:this._onAttachCalled}),this.initRenderBuffer()},initRenderBuffer:function(){this._bufferedChildren=[]},startBuffering:function(){this.initRenderBuffer(),this.isBuffering=!0},endBuffering:function(){var t,e=this._isShown&&s.isNodeAttached(this.el);this.isBuffering=!1,this._isShown&&this._triggerMethodMany(this._bufferedChildren,this,"before:show"),e&&this._triggerBeforeAttach&&(t=this._getNestedViews(),this._triggerMethodMany(t,this,"before:attach")),this.attachBuffer(this,this._createBuffer()),e&&this._triggerAttach&&(t=this._getNestedViews(),this._triggerMethodMany(t,this,"attach")),this._isShown&&this._triggerMethodMany(this._bufferedChildren,this,"show"),this.initRenderBuffer()},_triggerMethodMany:function(t,e,n){var r=i.drop(arguments,3);i.each(t,function(t){s.triggerMethodOn.apply(t,[t,n,t,e].concat(r))})},_initialEvents:function(){this.collection&&(this.listenTo(this.collection,"add",this._onCollectionAdd),this.listenTo(this.collection,"remove",this._onCollectionRemove),this.listenTo(this.collection,"reset",this.render),this.getOption("sort")&&this.listenTo(this.collection,"sort",this._sortViews))},_onCollectionAdd:function(t,e,n){var r;if(r=void 0!==n.at?n.at:i.indexOf(this._filteredSortedModels(),t),this._shouldAddChild(t,r)){this.destroyEmptyView();var s=this.getChildView(t);this.addChild(t,s,r)}},_onCollectionRemove:function(t){var e=this.children.findByModel(t);this.removeChildView(e),this.checkEmpty()},_onBeforeShowCalled:function(){this._triggerBeforeAttach=this._triggerAttach=!1,this.children.each(function(t){s.triggerMethodOn(t,"before:show",t)})},_onShowCalled:function(){this.children.each(function(t){s.triggerMethodOn(t,"show",t)})},_onBeforeAttachCalled:function(){this._triggerBeforeAttach=!0},_onAttachCalled:function(){this._triggerAttach=!0},render:function(){return this._ensureViewIsIntact(),this.triggerMethod("before:render",this),this._renderChildren(),this.isRendered=!0,this.triggerMethod("render",this),this},reorder:function(){var t=this.children,e=this._filteredSortedModels(),n=i.find(e,function(e){return!t.findByModel(e)});if(n)this.render();else{var r=i.map(e,function(e,i){var n=t.findByModel(e);return n._index=i,n.el});this.triggerMethod("before:reorder"),this._appendReorderedChildren(r),this.triggerMethod("reorder")}},resortView:function(){s.getOption(this,"reorderOnSort")?this.reorder():this.render()},_sortViews:function(){var t=this._filteredSortedModels(),e=i.find(t,function(t,e){var i=this.children.findByModel(t);return!i||i._index!==e},this);e&&this.resortView()},_emptyViewIndex:-1,_appendReorderedChildren:function(t){this.$el.append(t)},_renderChildren:function(){this.destroyEmptyView(),this.destroyChildren({checkEmpty:!1}),this.isEmpty(this.collection)?this.showEmptyView():(this.triggerMethod("before:render:collection",this),this.startBuffering(),this.showCollection(),this.endBuffering(),this.triggerMethod("render:collection",this),this.children.isEmpty()&&this.showEmptyView())},showCollection:function(){var t,e=this._filteredSortedModels();i.each(e,function(e,i){t=this.getChildView(e),this.addChild(e,t,i)},this)},_filteredSortedModels:function(){var t,e=this.getViewComparator();return t=e?i.isString(e)||1===e.length?this.collection.sortBy(e,this):i.clone(this.collection.models).sort(i.bind(e,this)):this.collection.models,this.getOption("filter")&&(t=i.filter(t,function(t,e){return this._shouldAddChild(t,e)},this)),t},showEmptyView:function(){var t=this.getEmptyView();if(t&&!this._showingEmptyView){this.triggerMethod("before:render:empty"),this._showingEmptyView=!0;var i=new e.Model;this.addEmptyView(i,t),this.triggerMethod("render:empty")}},destroyEmptyView:function(){this._showingEmptyView&&(this.triggerMethod("before:remove:empty"),this.destroyChildren(),delete this._showingEmptyView,this.triggerMethod("remove:empty"))},getEmptyView:function(){return this.getOption("emptyView")},addEmptyView:function(t,e){var n,r=this._isShown&&!this.isBuffering&&s.isNodeAttached(this.el),o=this.getOption("emptyViewOptions")||this.getOption("childViewOptions");i.isFunction(o)&&(o=o.call(this,t,this._emptyViewIndex));var h=this.buildChildView(t,e,o);h._parent=this,this.proxyChildEvents(h),this._isShown&&s.triggerMethodOn(h,"before:show",h),this.children.add(h),r&&this._triggerBeforeAttach&&(n=[h].concat(h._getNestedViews()),h.once("render",function(){this._triggerMethodMany(n,this,"before:attach")},this)),this.renderChildView(h,this._emptyViewIndex),r&&this._triggerAttach&&(n=[h].concat(h._getNestedViews()),this._triggerMethodMany(n,this,"attach")),this._isShown&&s.triggerMethodOn(h,"show",h)},getChildView:function(){var t=this.getOption("childView");if(!t)throw new s.Error({name:"NoChildViewError",message:'A "childView" must be specified'});return t},addChild:function(t,e,i){var n=this.getOption("childViewOptions");n=s._getValue(n,this,[t,i]);var r=this.buildChildView(t,e,n);return this._updateIndices(r,!0,i),this.triggerMethod("before:add:child",r),this._addChildView(r,i),this.triggerMethod("add:child",r),r._parent=this,r},_updateIndices:function(t,e,i){this.getOption("sort")&&(e&&(t._index=i),this.children.each(function(i){i._index>=t._index&&(i._index+=e?1:-1)}))},_addChildView:function(t,e){var i,n=this._isShown&&!this.isBuffering&&s.isNodeAttached(this.el);this.proxyChildEvents(t),this._isShown&&!this.isBuffering&&s.triggerMethodOn(t,"before:show",t),this.children.add(t),n&&this._triggerBeforeAttach&&(i=[t].concat(t._getNestedViews()),t.once("render",function(){this._triggerMethodMany(i,this,"before:attach")},this)),this.renderChildView(t,e),n&&this._triggerAttach&&(i=[t].concat(t._getNestedViews()),this._triggerMethodMany(i,this,"attach")),this._isShown&&!this.isBuffering&&s.triggerMethodOn(t,"show",t)},renderChildView:function(t,e){return t.render(),this.attachHtml(this,t,e),t},buildChildView:function(t,e,n){var r=i.extend({model:t},n);return new e(r)},removeChildView:function(t){return t&&(this.triggerMethod("before:remove:child",t),t.destroy?t.destroy():t.remove&&t.remove(),delete t._parent,this.stopListening(t),this.children.remove(t),this.triggerMethod("remove:child",t),this._updateIndices(t,!1)),t},isEmpty:function(){return!this.collection||0===this.collection.length},checkEmpty:function(){this.isEmpty(this.collection)&&this.showEmptyView()},attachBuffer:function(t,e){t.$el.append(e)},_createBuffer:function(){var t=document.createDocumentFragment();return i.each(this._bufferedChildren,function(e){t.appendChild(e.el)}),t},attachHtml:function(t,e,i){t.isBuffering?t._bufferedChildren.splice(i,0,e):t._insertBefore(e,i)||t._insertAfter(e)},_insertBefore:function(t,e){var i,n=this.getOption("sort")&&this.children.length-1>e;return n&&(i=this.children.find(function(t){return t._index===e+1})),i?(i.$el.before(t.el),!0):!1},_insertAfter:function(t){this.$el.append(t.el)},_initChildViewStorage:function(){this.children=new e.ChildViewContainer},destroy:function(){return this.isDestroyed?this:(this.triggerMethod("before:destroy:collection"),this.destroyChildren({checkEmpty:!1}),this.triggerMethod("destroy:collection"),s.View.prototype.destroy.apply(this,arguments))},destroyChildren:function(t){var e=t||{},n=!0,r=this.children.map(i.identity);return i.isUndefined(e.checkEmpty)||(n=e.checkEmpty),this.children.each(this.removeChildView,this),n&&this.checkEmpty(),r},_shouldAddChild:function(t,e){var n=this.getOption("filter");return!i.isFunction(n)||n.call(this,t,e,this.collection)},proxyChildEvents:function(t){var e=this.getOption("childViewEventPrefix");this.listenTo(t,"all",function(){var n=i.toArray(arguments),r=n[0],s=this.normalizeMethods(i.result(this,"childEvents"));n[0]=e+":"+r,n.splice(1,0,t),s!==void 0&&i.isFunction(s[r])&&s[r].apply(this,n.slice(1)),this.triggerMethod.apply(this,n)})},_getImmediateChildren:function(){return i.values(this.children._views)},getViewComparator:function(){return this.getOption("viewComparator")}}),s.CompositeView=s.CollectionView.extend({constructor:function(){s.CollectionView.apply(this,arguments)},_initialEvents:function(){this.collection&&(this.listenTo(this.collection,"add",this._onCollectionAdd),this.listenTo(this.collection,"remove",this._onCollectionRemove),this.listenTo(this.collection,"reset",this._renderChildren),this.getOption("sort")&&this.listenTo(this.collection,"sort",this._sortViews))},getChildView:function(){var t=this.getOption("childView")||this.constructor;return t},serializeData:function(){var t={};return this.model&&(t=i.partial(this.serializeModel,this.model).apply(this,arguments)),t},render:function(){return this._ensureViewIsIntact(),this._isRendering=!0,this.resetChildViewContainer(),this.triggerMethod("before:render",this),this._renderTemplate(),this._renderChildren(),this._isRendering=!1,this.isRendered=!0,this.triggerMethod("render",this),this
},_renderChildren:function(){(this.isRendered||this._isRendering)&&s.CollectionView.prototype._renderChildren.call(this)},_renderTemplate:function(){var t={};t=this.serializeData(),t=this.mixinTemplateHelpers(t),this.triggerMethod("before:render:template");var e=this.getTemplate(),i=s.Renderer.render(e,t,this);this.attachElContent(i),this.bindUIElements(),this.triggerMethod("render:template")},attachElContent:function(t){return this.$el.html(t),this},attachBuffer:function(t,e){var i=this.getChildViewContainer(t);i.append(e)},_insertAfter:function(t){var e=this.getChildViewContainer(this,t);e.append(t.el)},_appendReorderedChildren:function(t){var e=this.getChildViewContainer(this);e.append(t)},getChildViewContainer:function(t){if(t.$childViewContainer)return t.$childViewContainer;var e,i=s.getOption(t,"childViewContainer");if(i){var n=s._getValue(i,t);if(e="@"===n.charAt(0)&&t.ui?t.ui[n.substr(4)]:t.$(n),0>=e.length)throw new s.Error({name:"ChildViewContainerMissingError",message:'The specified "childViewContainer" was not found: '+t.childViewContainer})}else e=t.$el;return t.$childViewContainer=e,e},resetChildViewContainer:function(){this.$childViewContainer&&(this.$childViewContainer=void 0)}}),s.LayoutView=s.ItemView.extend({regionClass:s.Region,options:{destroyImmediate:!1},childViewEventPrefix:"childview",constructor:function(t){t=t||{},this._firstRender=!0,this._initializeRegions(t),s.ItemView.call(this,t)},render:function(){return this._ensureViewIsIntact(),this._firstRender?this._firstRender=!1:this._reInitializeRegions(),s.ItemView.prototype.render.apply(this,arguments)},destroy:function(){return this.isDestroyed?this:(this.getOption("destroyImmediate")===!0&&this.$el.remove(),this.regionManager.destroy(),s.ItemView.prototype.destroy.apply(this,arguments))},showChildView:function(t,e){return this.getRegion(t).show(e)},getChildView:function(t){return this.getRegion(t).currentView},addRegion:function(t,e){var i={};return i[t]=e,this._buildRegions(i)[t]},addRegions:function(t){return this.regions=i.extend({},this.regions,t),this._buildRegions(t)},removeRegion:function(t){return delete this.regions[t],this.regionManager.removeRegion(t)},getRegion:function(t){return this.regionManager.get(t)},getRegions:function(){return this.regionManager.getRegions()},_buildRegions:function(t){var e={regionClass:this.getOption("regionClass"),parentEl:i.partial(i.result,this,"el")};return this.regionManager.addRegions(t,e)},_initializeRegions:function(t){var e;this._initRegionManager(),e=s._getValue(this.regions,this,[t])||{};var n=this.getOption.call(t,"regions");n=s._getValue(n,this,[t]),i.extend(e,n),e=this.normalizeUIValues(e,["selector","el"]),this.addRegions(e)},_reInitializeRegions:function(){this.regionManager.invoke("reset")},getRegionManager:function(){return new s.RegionManager},_initRegionManager:function(){this.regionManager=this.getRegionManager(),this.regionManager._parent=this,this.listenTo(this.regionManager,"before:add:region",function(t){this.triggerMethod("before:add:region",t)}),this.listenTo(this.regionManager,"add:region",function(t,e){this[t]=e,this.triggerMethod("add:region",t,e)}),this.listenTo(this.regionManager,"before:remove:region",function(t){this.triggerMethod("before:remove:region",t)}),this.listenTo(this.regionManager,"remove:region",function(t,e){delete this[t],this.triggerMethod("remove:region",t,e)})},_getImmediateChildren:function(){return i.chain(this.regionManager.getRegions()).pluck("currentView").compact().value()}}),s.Behavior=s.Object.extend({constructor:function(t,e){this.view=e,this.defaults=i.result(this,"defaults")||{},this.options=i.extend({},this.defaults,t),this.ui=i.extend({},i.result(e,"ui"),i.result(this,"ui")),s.Object.apply(this,arguments)},$:function(){return this.view.$.apply(this.view,arguments)},destroy:function(){return this.stopListening(),this},proxyViewProperties:function(t){this.$el=t.$el,this.el=t.el}}),s.Behaviors=function(t,e){function i(t,n){return e.isObject(t.behaviors)?(n=i.parseBehaviors(t,n||e.result(t,"behaviors")),i.wrap(t,n,e.keys(o)),n):{}}function n(t,e){this._view=t,this._behaviors=e,this._triggers={}}function r(t){return t._uiBindings||t.ui}var s=/^(\S+)\s*(.*)$/,o={behaviorTriggers:function(t,e){var i=new n(this,e);return i.buildBehaviorTriggers()},behaviorEvents:function(i,n){var o={};return e.each(n,function(i,n){var h={},a=e.clone(e.result(i,"events"))||{};a=t.normalizeUIKeys(a,r(i));var d=0;e.each(a,function(t,r){var o=r.match(s),a=o[1]+"."+[this.cid,n,d++," "].join(""),l=o[2],c=a+l,u=e.isFunction(t)?t:i[t];h[c]=e.bind(u,i)},this),o=e.extend(o,h)},this),o}};return e.extend(i,{behaviorsLookup:function(){throw new t.Error({message:"You must define where your behaviors are stored.",url:"marionette.behaviors.html#behaviorslookup"})},getBehaviorClass:function(e,n){return e.behaviorClass?e.behaviorClass:t._getValue(i.behaviorsLookup,this,[e,n])[n]},parseBehaviors:function(t,n){return e.chain(n).map(function(n,r){var s=i.getBehaviorClass(n,r),o=new s(n,t),h=i.parseBehaviors(t,e.result(o,"behaviors"));return[o].concat(h)}).flatten().value()},wrap:function(t,i,n){e.each(n,function(n){t[n]=e.partial(o[n],t[n],i)})}}),e.extend(n.prototype,{buildBehaviorTriggers:function(){return e.each(this._behaviors,this._buildTriggerHandlersForBehavior,this),this._triggers},_buildTriggerHandlersForBehavior:function(i,n){var s=e.clone(e.result(i,"triggers"))||{};s=t.normalizeUIKeys(s,r(i)),e.each(s,e.bind(this._setHandlerForBehavior,this,i,n))},_setHandlerForBehavior:function(t,e,i,n){var r=n.replace(/^\S+/,function(t){return t+"."+"behaviortriggers"+e});this._triggers[r]=this._view._buildViewTrigger(i)}}),i}(s,i),s.AppRouter=e.Router.extend({constructor:function(t){this.options=t||{},e.Router.apply(this,arguments);var i=this.getOption("appRoutes"),n=this._getController();this.processAppRoutes(n,i),this.on("route",this._processOnRoute,this)},appRoute:function(t,e){var i=this._getController();this._addAppRoute(i,t,e)},_processOnRoute:function(t,e){if(i.isFunction(this.onRoute)){var n=i.invert(this.getOption("appRoutes"))[t];this.onRoute(t,n,e)}},processAppRoutes:function(t,e){if(e){var n=i.keys(e).reverse();i.each(n,function(i){this._addAppRoute(t,i,e[i])},this)}},_getController:function(){return this.getOption("controller")},_addAppRoute:function(t,e,n){var r=t[n];if(!r)throw new s.Error('Method "'+n+'" was not found on the controller');this.route(e,n,i.bind(r,t))},mergeOptions:s.mergeOptions,getOption:s.proxyGetOption,triggerMethod:s.triggerMethod,bindEntityEvents:s.proxyBindEntityEvents,unbindEntityEvents:s.proxyUnbindEntityEvents}),s.Application=s.Object.extend({constructor:function(t){this._initializeRegions(t),this._initCallbacks=new s.Callbacks,this.submodules={},i.extend(this,t),this._initChannel(),s.Object.call(this,t)},execute:function(){this.commands.execute.apply(this.commands,arguments)},request:function(){return this.reqres.request.apply(this.reqres,arguments)},addInitializer:function(t){this._initCallbacks.add(t)},start:function(t){this.triggerMethod("before:start",t),this._initCallbacks.run(t,this),this.triggerMethod("start",t)},addRegions:function(t){return this._regionManager.addRegions(t)},emptyRegions:function(){return this._regionManager.emptyRegions()},removeRegion:function(t){return this._regionManager.removeRegion(t)},getRegion:function(t){return this._regionManager.get(t)},getRegions:function(){return this._regionManager.getRegions()},module:function(t,e){var n=s.Module.getClass(e),r=i.toArray(arguments);return r.unshift(this),n.create.apply(n,r)},getRegionManager:function(){return new s.RegionManager},_initializeRegions:function(t){var e=i.isFunction(this.regions)?this.regions(t):this.regions||{};this._initRegionManager();var n=s.getOption(t,"regions");return i.isFunction(n)&&(n=n.call(this,t)),i.extend(e,n),this.addRegions(e),this},_initRegionManager:function(){this._regionManager=this.getRegionManager(),this._regionManager._parent=this,this.listenTo(this._regionManager,"before:add:region",function(){s._triggerMethod(this,"before:add:region",arguments)}),this.listenTo(this._regionManager,"add:region",function(t,e){this[t]=e,s._triggerMethod(this,"add:region",arguments)}),this.listenTo(this._regionManager,"before:remove:region",function(){s._triggerMethod(this,"before:remove:region",arguments)}),this.listenTo(this._regionManager,"remove:region",function(t){delete this[t],s._triggerMethod(this,"remove:region",arguments)})},_initChannel:function(){this.channelName=i.result(this,"channelName")||"global",this.channel=i.result(this,"channel")||e.Wreqr.radio.channel(this.channelName),this.vent=i.result(this,"vent")||this.channel.vent,this.commands=i.result(this,"commands")||this.channel.commands,this.reqres=i.result(this,"reqres")||this.channel.reqres}}),s.Module=function(t,e,n){this.moduleName=t,this.options=i.extend({},this.options,n),this.initialize=n.initialize||this.initialize,this.submodules={},this._setupInitializersAndFinalizers(),this.app=e,i.isFunction(this.initialize)&&this.initialize(t,e,this.options)},s.Module.extend=s.extend,i.extend(s.Module.prototype,e.Events,{startWithParent:!0,initialize:function(){},addInitializer:function(t){this._initializerCallbacks.add(t)},addFinalizer:function(t){this._finalizerCallbacks.add(t)},start:function(t){this._isInitialized||(i.each(this.submodules,function(e){e.startWithParent&&e.start(t)}),this.triggerMethod("before:start",t),this._initializerCallbacks.run(t,this),this._isInitialized=!0,this.triggerMethod("start",t))},stop:function(){this._isInitialized&&(this._isInitialized=!1,this.triggerMethod("before:stop"),i.invoke(this.submodules,"stop"),this._finalizerCallbacks.run(void 0,this),this._initializerCallbacks.reset(),this._finalizerCallbacks.reset(),this.triggerMethod("stop"))},addDefinition:function(t,e){this._runModuleDefinition(t,e)},_runModuleDefinition:function(t,n){if(t){var r=i.flatten([this,this.app,e,s,e.$,i,n]);t.apply(this,r)}},_setupInitializersAndFinalizers:function(){this._initializerCallbacks=new s.Callbacks,this._finalizerCallbacks=new s.Callbacks},triggerMethod:s.triggerMethod}),i.extend(s.Module,{create:function(t,e,n){var r=t,s=i.drop(arguments,3);e=e.split(".");var o=e.length,h=[];return h[o-1]=n,i.each(e,function(e,i){var o=r;r=this._getModule(o,e,t,n),this._addModuleDefinition(o,r,h[i],s)},this),r},_getModule:function(t,e,n,r){var s=i.extend({},r),o=this.getClass(r),h=t[e];return h||(h=new o(e,n,s),t[e]=h,t.submodules[e]=h),h},getClass:function(t){var e=s.Module;return t?t.prototype instanceof e?t:t.moduleClass||e:e},_addModuleDefinition:function(t,e,i,n){var r=this._getDefine(i),s=this._getStartWithParent(i,e);r&&e.addDefinition(r,n),this._addStartWithParent(t,e,s)},_getStartWithParent:function(t,e){var n;return i.isFunction(t)&&t.prototype instanceof s.Module?(n=e.constructor.prototype.startWithParent,i.isUndefined(n)?!0:n):i.isObject(t)?(n=t.startWithParent,i.isUndefined(n)?!0:n):!0},_getDefine:function(t){return!i.isFunction(t)||t.prototype instanceof s.Module?i.isObject(t)?t.define:null:t},_addStartWithParent:function(t,e,i){e.startWithParent=e.startWithParent&&i,e.startWithParent&&!e.startWithParentIsConfigured&&(e.startWithParentIsConfigured=!0,t.addInitializer(function(t){e.startWithParent&&e.start(t)}))}}),s});
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n(require("underscore"),require("backbone")):"function"==typeof define&&define.amd?define(["underscore","backbone"],n):e.Backbone.Radio=n(e._,e.Backbone)}(this,function(e,n){"use strict";function t(e,n,t,r){var s=e[n];return t&&t!==s.callback&&t!==s.callback._callback||r&&r!==s.context?void 0:(delete e[n],!0)}function r(n,r,s,i){n||(n={});for(var a=r?[r]:e.keys(n),u=!1,o=0,c=a.length;c>o;o++)r=a[o],n[r]&&t(n,r,s,i)&&(u=!0);return u}function s(n){return c[n]||(c[n]=e.partial(u.log,n))}function i(n){return e.isFunction(n)?n:function(){return n}}var a=n.Radio,u=n.Radio={};u.VERSION="1.0.1",u.noConflict=function(){return n.Radio=a,this},u.DEBUG=!1,u._debugText=function(e,n,t){return e+(t?" on the "+t+" channel":"")+': "'+n+'"'},u.debugLog=function(e,n,t){u.DEBUG&&console&&console.warn&&console.warn(u._debugText(e,n,t))};var o=/\s+/;u._eventsApi=function(n,t,r,s){if(!r)return!1;var i={};if("object"==typeof r){for(var a in r){var u=n[t].apply(n,[a,r[a]].concat(s));o.test(a)?e.extend(i,u):i[a]=u}return i}if(o.test(r)){for(var c=r.split(o),l=0,h=c.length;h>l;l++)i[c[l]]=n[t].apply(n,[c[l]].concat(s));return i}return!1},u._callHandler=function(e,n,t){var r=t[0],s=t[1],i=t[2];switch(t.length){case 0:return e.call(n);case 1:return e.call(n,r);case 2:return e.call(n,r,s);case 3:return e.call(n,r,s,i);default:return e.apply(n,t)}};var c={};e.extend(u,{log:function(n,t){var r=e.rest(arguments,2);console.log("["+n+'] "'+t+'"',r)},tuneIn:function(e){var n=u.channel(e);return n._tunedIn=!0,n.on("all",s(e)),this},tuneOut:function(e){var n=u.channel(e);return n._tunedIn=!1,n.off("all",s(e)),delete c[e],this}}),u.Requests={request:function(n){var t=e.rest(arguments),r=u._eventsApi(this,"request",n,t);if(r)return r;var s=this.channelName,i=this._requests;if(s&&this._tunedIn&&u.log.apply(this,[s,n].concat(t)),i&&(i[n]||i["default"])){var a=i[n]||i["default"];return t=i[n]?t:arguments,u._callHandler(a.callback,a.context,t)}u.debugLog("An unhandled request was fired",n,s)},reply:function(e,n,t){return u._eventsApi(this,"reply",e,[n,t])?this:(this._requests||(this._requests={}),this._requests[e]&&u.debugLog("A request was overwritten",e,this.channelName),this._requests[e]={callback:i(n),context:t||this},this)},replyOnce:function(n,t,r){if(u._eventsApi(this,"replyOnce",n,[t,r]))return this;var s=this,a=e.once(function(){return s.stopReplying(n),i(t).apply(this,arguments)});return this.reply(n,a,r)},stopReplying:function(e,n,t){return u._eventsApi(this,"stopReplying",e)?this:(e||n||t?r(this._requests,e,n,t)||u.debugLog("Attempted to remove the unregistered request",e,this.channelName):delete this._requests,this)}},u._channels={},u.channel=function(e){if(!e)throw new Error("You must provide a name for the channel.");return u._channels[e]?u._channels[e]:u._channels[e]=new u.Channel(e)},u.Channel=function(e){this.channelName=e},e.extend(u.Channel.prototype,n.Events,u.Requests,{reset:function(){return this.off(),this.stopListening(),this.stopReplying(),this}});var l,h,f=[n.Events,u.Commands,u.Requests];e.each(f,function(n){e.each(n,function(n,t){u[t]=function(n){return h=e.rest(arguments),l=this.channel(n),l[t].apply(l,h)}})}),u.reset=function(n){var t=n?[this._channels[n]]:this._channels;e.invoke(t,"reset")};var p=u;return p});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Mexp=t()}(this,(function(){"use strict";function e(){return e=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},e.apply(this,arguments)}var t,n={0:11,1:0,2:3,3:0,4:0,5:0,6:0,7:11,8:11,9:1,10:10,11:0,12:11,13:0,14:-1};function a(e,t){for(var n=0;n<e.length;n++)e[n]+=t;return e}!function(e){e[e.FUNCTION_WITH_ONE_ARG=0]="FUNCTION_WITH_ONE_ARG",e[e.NUMBER=1]="NUMBER",e[e.BINARY_OPERATOR_HIGH_PRECENDENCE=2]="BINARY_OPERATOR_HIGH_PRECENDENCE",e[e.CONSTANT=3]="CONSTANT",e[e.OPENING_PARENTHESIS=4]="OPENING_PARENTHESIS",e[e.CLOSING_PARENTHESIS=5]="CLOSING_PARENTHESIS",e[e.DECIMAL=6]="DECIMAL",e[e.POSTFIX_FUNCTION_WITH_ONE_ARG=7]="POSTFIX_FUNCTION_WITH_ONE_ARG",e[e.FUNCTION_WITH_N_ARGS=8]="FUNCTION_WITH_N_ARGS",e[e.BINARY_OPERATOR_LOW_PRECENDENCE=9]="BINARY_OPERATOR_LOW_PRECENDENCE",e[e.BINARY_OPERATOR_PERMUTATION=10]="BINARY_OPERATOR_PERMUTATION",e[e.COMMA=11]="COMMA",e[e.EVALUATED_FUNCTION=12]="EVALUATED_FUNCTION",e[e.EVALUATED_FUNCTION_PARAMETER=13]="EVALUATED_FUNCTION_PARAMETER",e[e.SPACE=14]="SPACE"}(t||(t={}));var o={0:!0,1:!0,3:!0,4:!0,6:!0,8:!0,9:!0,12:!0,13:!0,14:!0},h={0:!0,1:!0,2:!0,3:!0,4:!0,5:!0,6:!0,7:!0,8:!0,9:!0,10:!0,11:!0,12:!0,13:!0},r={0:!0,3:!0,4:!0,8:!0,12:!0,13:!0},u={},s={0:!0,1:!0,3:!0,4:!0,6:!0,8:!0,12:!0,13:!0},p={1:!0},i=[[],["1","2","3","7","8","9","4","5","6","+","-","*","/","(",")","^","!","P","C","e","0",".",",","n"," ","&"],["pi","ln","Pi"],["sin","cos","tan","Del","int","Mod","log","pow"],["asin","acos","atan","cosh","root","tanh","sinh"],["acosh","atanh","asinh","Sigma"]];function l(e,t,n,a){for(var o=0;o<a;o++)if(e[n+o]!==t[o])return!1;return!0}function E(e){for(var a=0;a<e.length;a++){var o=e[a].token.length,h=-1;e[a].type===t.FUNCTION_WITH_N_ARGS&&void 0===e[a].numberOfArguments&&(e[a].numberOfArguments=2),i[o]=i[o]||[];for(var r=0;r<i[o].length;r++)if(e[a].token===i[o][r]){h=N(i[o][r],this.tokens);break}-1===h?(this.tokens.push(e[a]),e[a].precedence=n[e[a].type],i.length<=e[a].token.length&&(i[e[a].token.length]=[]),i[e[a].token.length].push(e[a].token)):(this.tokens[h]=e[a],e[a].precedence=n[e[a].type])}}function N(e,t){for(var n=0;n<t.length;n++)if(t[n].token===e)return n;return-1}var v=function(e,n){var E,v={value:this.math.changeSign,type:t.FUNCTION_WITH_ONE_ARG,precedence:4,show:"-"},f={value:")",show:")",type:t.CLOSING_PARENTHESIS,precedence:0},y={value:"(",type:t.OPENING_PARENTHESIS,precedence:0,show:"("},A=[y],c=[],_=e,O=o,T=0,R=u,I="";void 0!==n&&this.addToken(n);var w=function(e,t){for(var n,a,o,h=[],r=t.length,u=0;u<r;u++)if(!(u<r-1&&" "===t[u]&&" "===t[u+1])){for(n="",a=t.length-u>i.length-2?i.length-1:t.length-u;a>0;a--)if(void 0!==i[a])for(o=0;o<i[a].length;o++)l(t,i[a][o],u,a)&&(n=i[a][o],o=i[a].length,a=0);if(u+=n.length-1,""===n)throw new Error("Can't understand after "+t.slice(u));h.push(e.tokens[N(n,e.tokens)])}return h}(this,_);for(E=0;E<w.length;E++){var P=w[E];if(14!==P.type){var m,M=P.token,g=P.type,C=P.value,d=P.precedence,k=P.show,S=A[A.length-1];for(m=c.length;m--&&0===c[m];)if(-1!==[t.FUNCTION_WITH_ONE_ARG,t.BINARY_OPERATOR_HIGH_PRECENDENCE,t.CONSTANT,t.OPENING_PARENTHESIS,t.CLOSING_PARENTHESIS,t.BINARY_OPERATOR_LOW_PRECENDENCE,t.BINARY_OPERATOR_PERMUTATION,t.COMMA,t.EVALUATED_FUNCTION,t.EVALUATED_FUNCTION_PARAMETER].indexOf(g)){if(!0!==O[g])throw new Error(M+" is not allowed after "+I);A.push(f),O=h,R=s,c.pop()}if(!0!==O[g])throw new Error(M+" is not allowed after "+I);!0===R[g]&&(g=t.BINARY_OPERATOR_HIGH_PRECENDENCE,C=this.math.mul,k="&times;",d=3,E-=1);var U={value:C,type:g,precedence:d,show:k,numberOfArguments:P.numberOfArguments};if(g===t.FUNCTION_WITH_ONE_ARG)O=o,R=u,a(c,2),A.push(U),w[E+1].type!==t.OPENING_PARENTHESIS&&(A.push(y),c.push(2));else if(g===t.NUMBER)S.type===t.NUMBER?(S.value+=C,a(c,1)):A.push(U),O=h,R=r;else if(g===t.BINARY_OPERATOR_HIGH_PRECENDENCE)O=o,R=u,a(c,2),A.push(U);else if(g===t.CONSTANT)A.push(U),O=h,R=s;else if(g===t.OPENING_PARENTHESIS)a(c,1),T++,O=o,R=u,A.push(U);else if(g===t.CLOSING_PARENTHESIS){if(!T)throw new Error("Closing parenthesis are more than opening one, wait What!!!");T--,O=h,R=s,A.push(U),a(c,1)}else if(g===t.DECIMAL){if(S.hasDec)throw new Error("Two decimals are not allowed in one number");S.type!==t.NUMBER&&(S={show:"0",value:0,type:t.NUMBER,precedence:0},A.push(S)),O=p,a(c,1),R=u,S.value+=C,S.hasDec=!0}else g===t.POSTFIX_FUNCTION_WITH_ONE_ARG&&(O=h,R=s,a(c,1),A.push(U));g===t.FUNCTION_WITH_N_ARGS?(O=o,R=u,a(c,P.numberOfArguments+2),A.push(U),w[E+1].type!==t.OPENING_PARENTHESIS&&(A.push(y),c.push(P.numberOfArguments+2))):g===t.BINARY_OPERATOR_LOW_PRECENDENCE?(S.type===t.BINARY_OPERATOR_LOW_PRECENDENCE?S.value===this.math.add?(S.value=C,S.show=k,a(c,1)):S.value===this.math.sub&&"-"===k&&(S.value=this.math.add,S.show="+",a(c,1)):S.type!==t.CLOSING_PARENTHESIS&&S.type!==t.POSTFIX_FUNCTION_WITH_ONE_ARG&&S.type!==t.NUMBER&&S.type!==t.CONSTANT&&S.type!==t.EVALUATED_FUNCTION_PARAMETER?"-"===M&&(O=o,R=u,a(c,1).push(2),A.push(v),A.push(y)):(A.push(U),a(c,2)),O=o,R=u):g===t.BINARY_OPERATOR_PERMUTATION?(O=o,R=u,a(c,2),A.push(U)):g===t.COMMA?(O=o,R=u,A.push(U)):g===t.EVALUATED_FUNCTION?(O=o,R=u,a(c,6),A.push(U),w[E+1].type!==t.OPENING_PARENTHESIS&&(A.push(y),c.push(6))):g===t.EVALUATED_FUNCTION_PARAMETER&&(O=h,R=s,A.push(U)),a(c,-1),I=M}else if(E>0&&E<w.length-1&&1===w[E+1].type&&(1===w[E-1].type||6===w[E-1].type))throw new Error("Unexpected Space")}for(m=c.length;m--;)A.push(f);if(!0!==O[5])throw new Error("complete the expression");for(;T--;)A.push(f);return A.push(f),A};function f(e){for(var t,n,a,o=[],h=-1,r=-1,u=[{value:"(",type:4,precedence:0,show:"("}],s=1;s<e.length;s++)if(1===e[s].type||3===e[s].type||13===e[s].type)1===e[s].type&&(e[s].value=Number(e[s].value)),o.push(e[s]);else if(4===e[s].type)u.push(e[s]);else if(5===e[s].type)for(;4!==(null==(p=n=u.pop())?void 0:p.type);){var p;n&&o.push(n)}else if(11===e[s].type){for(;4!==(null==(i=n=u.pop())?void 0:i.type);){var i;n&&o.push(n)}u.push(n)}else{r=(t=e[s]).precedence,h=(a=u[u.length-1]).precedence;var l="Math.pow"==a.value&&"Math.pow"==t.value;if(r>h)u.push(t);else{for(;h>=r&&!l||l&&r<h;)n=u.pop(),a=u[u.length-1],n&&o.push(n),h=a.precedence,l="Math.pow"==t.value&&"Math.pow"==a.value;u.push(t)}}return o}function y(e,t){(t=t||{}).PI=Math.PI,t.E=Math.E;for(var n,a,o,h=[],r=void 0!==t.n,u=0;u<e.length;u++)if(1===e[u].type)h.push({value:e[u].value,type:1});else if(3===e[u].type)h.push({value:t[e[u].value],type:1});else if(0===e[u].type){var s=h[h.length-1];Array.isArray(s)?s.push(e[u]):s.value=e[u].value(s.value)}else if(7===e[u].type){var p=h[h.length-1];Array.isArray(p)?p.push(e[u]):p.value=e[u].value(p.value)}else if(8===e[u].type){for(var i=[],l=0;l<e[u].numberOfArguments;l++){var E=h.pop();E&&i.push(E.value)}h.push({type:1,value:e[u].value.apply(e[u],i.reverse())})}else if(10===e[u].type)n=h.pop(),a=h.pop(),Array.isArray(a)?((a=a.concat(n)).push(e[u]),h.push(a)):Array.isArray(n)?(n.unshift(a),n.push(e[u]),h.push(n)):h.push({type:1,value:e[u].value(a.value,n.value)});else if(2===e[u].type||9===e[u].type)n=h.pop(),a=h.pop(),Array.isArray(a)?((a=a.concat(n)).push(e[u]),h.push(a)):Array.isArray(n)?(n.unshift(a),n.push(e[u]),h.push(n)):h.push({type:1,value:e[u].value(a.value,n.value)});else if(12===e[u].type){n=h.pop();var N=void 0;N=!Array.isArray(n)&&n?[n]:n||[],a=h.pop(),o=h.pop(),h.push({type:1,value:e[u].value(o.value,a.value,N)})}else 13===e[u].type&&(r?h.push({value:t[e[u].value],type:3}):h.push([e[u]]));if(h.length>1)throw new Error("Uncaught Syntax error");return parseFloat(h[0].value.toFixed(15))}var A=function(){function t(){var t;this.toPostfix=f,this.addToken=E,this.lex=v,this.postfixEval=y,this.math=(t=this,{isDegree:!0,acos:function(e){return t.math.isDegree?180/Math.PI*Math.acos(e):Math.acos(e)},add:function(e,t){return e+t},asin:function(e){return t.math.isDegree?180/Math.PI*Math.asin(e):Math.asin(e)},atan:function(e){return t.math.isDegree?180/Math.PI*Math.atan(e):Math.atan(e)},acosh:function(e){return Math.log(e+Math.sqrt(e*e-1))},asinh:function(e){return Math.log(e+Math.sqrt(e*e+1))},atanh:function(e){return Math.log((1+e)/(1-e))},C:function(e,n){var a=1,o=e-n,h=n;h<o&&(h=o,o=n);for(var r=h+1;r<=e;r++)a*=r;var u=t.math.fact(o);return"NaN"===u?"NaN":a/u},changeSign:function(e){return-e},cos:function(e){return t.math.isDegree&&(e=t.math.toRadian(e)),Math.cos(e)},cosh:function(e){return(Math.pow(Math.E,e)+Math.pow(Math.E,-1*e))/2},div:function(e,t){return e/t},fact:function(e){if(e%1!=0)return"NaN";for(var t=1,n=2;n<=e;n++)t*=n;return t},inverse:function(e){return 1/e},log:function(e){return Math.log(e)/Math.log(10)},mod:function(e,t){return e%t},mul:function(e,t){return e*t},P:function(e,t){for(var n=1,a=Math.floor(e)-Math.floor(t)+1;a<=Math.floor(e);a++)n*=a;return n},Pi:function(e,n,a){for(var o=1,h=e;h<=n;h++)o*=Number(t.postfixEval(a,{n:h}));return o},pow10x:function(e){for(var t=1;e--;)t*=10;return t},sigma:function(e,n,a){for(var o=0,h=e;h<=n;h++)o+=Number(t.postfixEval(a,{n:h}));return o},sin:function(e){return t.math.isDegree&&(e=t.math.toRadian(e)),Math.sin(e)},sinh:function(e){return(Math.pow(Math.E,e)-Math.pow(Math.E,-1*e))/2},sub:function(e,t){return e-t},tan:function(e){return t.math.isDegree&&(e=t.math.toRadian(e)),Math.tan(e)},tanh:function(e){return t.math.sinh(e)/t.math.cosh(e)},toRadian:function(e){return e*Math.PI/180},and:function(e,t){return e&t}}),this.tokens=function(t){return[{token:"sin",show:"sin",type:0,value:t.math.sin},{token:"cos",show:"cos",type:0,value:t.math.cos},{token:"tan",show:"tan",type:0,value:t.math.tan},{token:"pi",show:"&pi;",type:3,value:"PI"},{token:"(",show:"(",type:4,value:"("},{token:")",show:")",type:5,value:")"},{token:"P",show:"P",type:10,value:t.math.P},{token:"C",show:"C",type:10,value:t.math.C},{token:" ",show:" ",type:14,value:" ".anchor},{token:"asin",show:"asin",type:0,value:t.math.asin},{token:"acos",show:"acos",type:0,value:t.math.acos},{token:"atan",show:"atan",type:0,value:t.math.atan},{token:"7",show:"7",type:1,value:"7"},{token:"8",show:"8",type:1,value:"8"},{token:"9",show:"9",type:1,value:"9"},{token:"int",show:"Int",type:0,value:Math.floor},{token:"cosh",show:"cosh",type:0,value:t.math.cosh},{token:"acosh",show:"acosh",type:0,value:t.math.acosh},{token:"ln",show:" ln",type:0,value:Math.log},{token:"^",show:"^",type:10,value:Math.pow},{token:"root",show:"root",type:0,value:Math.sqrt},{token:"4",show:"4",type:1,value:"4"},{token:"5",show:"5",type:1,value:"5"},{token:"6",show:"6",type:1,value:"6"},{token:"/",show:"&divide;",type:2,value:t.math.div},{token:"!",show:"!",type:7,value:t.math.fact},{token:"tanh",show:"tanh",type:0,value:t.math.tanh},{token:"atanh",show:"atanh",type:0,value:t.math.atanh},{token:"Mod",show:" Mod ",type:2,value:t.math.mod},{token:"1",show:"1",type:1,value:"1"},{token:"2",show:"2",type:1,value:"2"},{token:"3",show:"3",type:1,value:"3"},{token:"*",show:"&times;",type:2,value:t.math.mul},{token:"sinh",show:"sinh",type:0,value:t.math.sinh},{token:"asinh",show:"asinh",type:0,value:t.math.asinh},{token:"e",show:"e",type:3,value:"E"},{token:"log",show:" log",type:0,value:t.math.log},{token:"0",show:"0",type:1,value:"0"},{token:".",show:".",type:6,value:"."},{token:"+",show:"+",type:9,value:t.math.add},{token:"-",show:"-",type:9,value:t.math.sub},{token:",",show:",",type:11,value:","},{token:"Sigma",show:"&Sigma;",type:12,value:t.math.sigma},{token:"n",show:"n",type:13,value:"n"},{token:"Pi",show:"&Pi;",type:12,value:t.math.Pi},{token:"pow",show:"pow",type:8,value:Math.pow,numberOfArguments:2},{token:"&",show:"&",type:9,value:t.math.and}].map((function(t){return e({},t,{precedence:n[t.type]})}))}(this)}return t.prototype.eval=function(e,t,n){return this.postfixEval(this.toPostfix(this.lex(e,t)),n)},t}();return A.TOKEN_TYPES=t,A.tokenTypes=t,A}));
var nfRadio=Backbone.Radio;
nfRadio.channel('form').on('render:view', function(){
jQuery('.g-recaptcha').each(function(){
var callback=jQuery(this).data('callback');
var fieldID=jQuery(this).data('fieldid');
if(typeof window[ callback ]!=='function'){
window[ callback ]=function(response){
nfRadio.channel('recaptcha').request('update:response', response, fieldID);
};}});
});
var nfRecaptcha=Marionette.Object.extend({
initialize: function(){
if(0!=jQuery('.g-recaptcha').length){
this.renderCaptcha();
}
this.listenTo(nfRadio.channel('form'), 'render:view', this.renderCaptcha);
this.listenTo(nfRadio.channel('captcha'), 'reset', this.renderCaptcha);
},
renderCaptcha: function(){
jQuery('.g-recaptcha:empty').each(function(){
var opts={
fieldid: jQuery(this).data('fieldid'),
size: jQuery(this).data('size'),
theme: jQuery(this).data('theme'),
sitekey: jQuery(this).data('sitekey'),
callback: jQuery(this).data('callback')
};
var grecaptchaID=grecaptcha.render(jQuery(this)[0], opts);
if(opts.size==='invisible'){
try {
nf_reprocess_recaptcha(grecaptchaID);
setInterval(nf_reprocess_recaptcha, 110000, grecaptchaID);
} catch(e){
console.log('Notice: Error trying to execute grecaptcha.');
}}
});
}});
var nfRenderRecaptcha=function(){
new nfRecaptcha();
}
if(typeof nf_reprocess_recaptcha==='undefined'){
const nf_reprocess_recaptcha=(grecaptchaID)=> {
grecaptcha.execute(grecaptchaID);
}}
const nf_check_recaptcha_consent=()=> {
let stored_responses=[], services=[];
if(!nf_check_data_for_recaptcha_consent()){
stored_responses.push(false);
services.push("missing_cookie");
}
const response={
"consent_state": stored_responses,
"services":services
};
nfFrontEnd.nf_consent_status_response=response;
let nf_consent_status_extra_check=new CustomEvent('nf_consent_status_check', {detail: response});
document.dispatchEvent(nf_consent_status_extra_check);
return nfFrontEnd.nf_consent_status_response;
}
const nf_check_data_for_recaptcha_consent=()=> {
return nf_get_cookie_by_name("_grecaptcha")!=="";
}
const nf_get_cookie_by_name=(cname)=> {
let name=cname + "=";
let decodedCookie=decodeURIComponent(document.cookie);
let ca=decodedCookie.split(';');
for(let i=0; i <ca.length; i++){
let c=ca[i];
while (c.charAt(0)==' '){
c=c.substring(1);
}
if(c.indexOf(name)==0){
return c.substring(name.length, c.length);
}}
return "";
}
const nf_reload_after_cookie_consent=(submitFieldID, layoutView)=> {
if(typeof submitFieldID!=="undefined"&&typeof layoutView!=="undefined"){
nfRadio.channel('fields').request("remove:error", submitFieldID, "recaptcha-v3-missing");
nfRadio.channel('fields').request("remove:error", submitFieldID, "recaptcha-v3-consent");
nfRadio.channel('form').trigger('render:view', layoutView);
}}
const nf_add_reCaptcha_aria=()=> {
const nf_act_on_inserted_node=(mutationList, observer)=> {
for (const mutation of mutationList){
if(mutation.type==='childList'&&mutation.target.className==="g-recaptcha"){
let nf_recaptchaTextarea=document.getElementById("g-recaptcha-response");
if(typeof nf_recaptchaTextarea!=="undefined"){
nf_recaptchaTextarea.setAttribute("aria-hidden", "true");
nf_recaptchaTextarea.setAttribute("aria-label", "Silent reCaptcha security check");
nf_recaptchaTextarea.setAttribute("aria-readonly", "true");
observer.disconnect();
}}
}
observer.disconnect();
};
const nf_forms_listed=document.querySelectorAll(".ninja-forms-form-wrap");
if(nf_forms_listed.length > 0){
let nf_recaptcha_observers=[];
nf_forms_listed.forEach((nf_form)=> {
nf_recaptcha_observers.push({"class": new MutationObserver(nf_act_on_inserted_node), "element": nf_form});
});
if(nf_recaptcha_observers.length > 0){
nf_recaptcha_observers.forEach((object)=> {
object.class.observe(object.element,
{ childList: true, subtree: true }
);
});
}}
}
const nf_remove_noscript_tags_as_needed=()=> {
const noscripts=document.getElementsByClassName('ninja-forms-noscript-message')
for (let i=0; i < noscripts.length; i++){
noscripts[i].parentNode.removeChild(noscripts[i])
}}
jQuery(document).on('nfFormReady', ()=> {
nf_remove_noscript_tags_as_needed();
nf_add_reCaptcha_aria();
});
!function(){var e,t,i;!function(n){var r,o,a,l,s={},d={},c={},f={},u=Object.prototype.hasOwnProperty,h=[].slice,m=/\.js$/;function g(e,t){return u.call(e,t)}function p(e,t){var i,n,r,o,a,l,s,d,f,u,h,g=t&&t.split("/"),p=c.map,v=p&&p["*"]||{};if(e){for(a=(e=e.split("/")).length-1,c.nodeIdCompat&&m.test(e[a])&&(e[a]=e[a].replace(m,"")),"."===e[0].charAt(0)&&g&&(e=g.slice(0,g.length-1).concat(e)),f=0;f<e.length;f++)if("."===(h=e[f]))e.splice(f,1),f-=1;else if(".."===h){if(0===f||1===f&&".."===e[2]||".."===e[f-1])continue;f>0&&(e.splice(f-1,2),f-=2)}e=e.join("/")}if((g||v)&&p){for(f=(i=e.split("/")).length;f>0;f-=1){if(n=i.slice(0,f).join("/"),g)for(u=g.length;u>0;u-=1)if((r=p[g.slice(0,u).join("/")])&&(r=r[n])){o=r,l=f;break}if(o)break;!s&&v&&v[n]&&(s=v[n],d=f)}!o&&s&&(o=s,l=d),o&&(i.splice(0,l,o),e=i.join("/"))}return e}function v(e,t){return function(){var i=h.call(arguments,0);return"string"!=typeof i[0]&&1===i.length&&i.push(null),o.apply(n,i.concat([e,t]))}}function y(e){return function(t){s[e]=t}}function b(e){if(g(d,e)){var t=d[e];delete d[e],f[e]=!0,r.apply(n,t)}if(!g(s,e)&&!g(f,e))throw new Error("No "+e);return s[e]}function R(e){var t,i=e?e.indexOf("!"):-1;return i>-1&&(t=e.substring(0,i),e=e.substring(i+1,e.length)),[t,e]}function _(e){return e?R(e):[]}function w(e){return function(){return c&&c.config&&c.config[e]||{}}}a=function(e,t){var i,n,r=R(e),o=r[0],a=t[1];return e=r[1],o&&(i=b(o=p(o,a))),o?e=i&&i.normalize?i.normalize(e,(n=a,function(e){return p(e,n)})):p(e,a):(o=(r=R(e=p(e,a)))[0],e=r[1],o&&(i=b(o))),{f:o?o+"!"+e:e,n:e,pr:o,p:i}},l={require:function(e){return v(e)},exports:function(e){var t=s[e];return void 0!==t?t:s[e]={}},module:function(e){return{id:e,uri:"",exports:s[e],config:w(e)}}},r=function(e,t,i,r){var o,c,u,h,m,p,R,w=[],F=typeof i;if(p=_(r=r||e),"undefined"===F||"function"===F){for(t=!t.length&&i.length?["require","exports","module"]:t,m=0;m<t.length;m+=1)if("require"===(c=(h=a(t[m],p)).f))w[m]=l.require(e);else if("exports"===c)w[m]=l.exports(e),R=!0;else if("module"===c)o=w[m]=l.module(e);else if(g(s,c)||g(d,c)||g(f,c))w[m]=b(c);else{if(!h.p)throw new Error(e+" missing "+c);h.p.load(h.n,v(r,!0),y(c),{}),w[m]=s[c]}u=i?i.apply(s[e],w):void 0,e&&(o&&o.exports!==n&&o.exports!==s[e]?s[e]=o.exports:u===n&&R||(s[e]=u))}else e&&(s[e]=i)},e=t=o=function(e,t,i,s,d){if("string"==typeof e)return l[e]?l[e](t):b(a(e,_(t)).f);if(!e.splice){if((c=e).deps&&o(c.deps,c.callback),!t)return;t.splice?(e=t,t=i,i=null):e=n}return t=t||function(){},"function"==typeof i&&(i=s,s=d),s?r(n,e,t,i):setTimeout((function(){r(n,e,t,i)}),4),o},o.config=function(e){return o(e)},e._defined=s,(i=function(e,t,i){if("string"!=typeof e)throw new Error("See almond README: incorrect module build, no module name");t.splice||(i=t,t=[]),g(s,e)||g(d,e)||(d[e]=[e,t,i])}).amd={jQuery:!0}}(),i("../../../node_modules/almond/almond",(function(){})),i("models/fieldErrorModel",[],(function(){return Backbone.Model.extend({})})),i("models/fieldErrorCollection",["models/fieldErrorModel"],(function(e){return Backbone.Collection.extend({model:e})})),i("models/fieldModel",["models/fieldErrorCollection"],(function(e){return Backbone.Model.extend({defaults:{placeholder:"",value:"",label_pos:"",classes:"ninja-forms-field",reRender:!1,mirror_field:!1,confirm_field:!1,clean:!0,disabled:"",visible:!0,invalid:!1},initialize:function(){var t=this.get("type");this.set("formID",this.collection.options.formModel.get("id")),this.listenTo(nfRadio.channel("form-"+this.get("formID")),"reset",this.resetModel),this.bind("change",this.changeModel,this),this.bind("change:value",this.changeValue,this),this.set("errors",new e),"listimage"===t&&(this.get=this.listimageGet,this.set=this.listimageSet),nfRadio.channel("fields").trigger("init:model",this),nfRadio.channel(this.get("type")).trigger("init:model",this),nfRadio.channel("fields-"+this.get("type")).trigger("init:model",this),void 0!==this.get("parentType")&&nfRadio.channel(this.get("parentType")).trigger("init:model",this),this.listenTo(nfRadio.channel("form-"+this.get("formID")),"loaded",this.formLoaded),this.listenTo(nfRadio.channel("form-"+this.get("formID")),"before:submit",this.beforeSubmit)},listimageGet:function(e){return"options"===e&&(e="image_options"),Backbone.Model.prototype.get.call(this,e)},listimageSet:function(e,t){return"options"===e&&(e="image_options"),Backbone.Model.prototype.set.call(this,e,t)},changeModel:function(){nfRadio.channel("field-"+this.get("id")).trigger("change:model",this),nfRadio.channel(this.get("type")).trigger("change:model",this),nfRadio.channel("fields").trigger("change:model",this)},changeValue:function(){nfRadio.channel("field-"+this.get("id")).trigger("change:modelValue",this),nfRadio.channel(this.get("type")).trigger("change:modelValue",this),nfRadio.channel("fields").trigger("change:modelValue",this)},addWrapperClass:function(e){this.set("addWrapperClass",e)},removeWrapperClass:function(e){this.set("removeWrapperClass",e)},setInvalid:function(e){this.set("invalid",e)},formLoaded:function(){nfRadio.channel("fields").trigger("formLoaded",this),nfRadio.channel("fields-"+this.get("type")).trigger("formLoaded",this)},beforeSubmit:function(e){nfRadio.channel(this.get("type")).trigger("before:submit",this),nfRadio.channel("fields").trigger("before:submit",this)},getValue:function(){return this.get("value")}})})),i("models/fieldCollection",["models/fieldModel"],(function(e){var t=Backbone.Collection.extend({model:e,comparator:"order",initialize:function(e,t){this.options=t,this.on("reset",(function(e){nfRadio.channel("fields").trigger("reset:collection",e)}),this),nfRadio.channel("fields").reply("get:firstFieldByOrder",this.getFirstFieldByOrder)},validateFields:function(){_.each(this.models,(function(e){if("repeater"===e.get("type")){const t=nfRadio.channel("field-repeater").request("get:repeaterFieldsModelsArrayByForm",e.get("formID"));_.each(t,(function(e){e.set("clean",!1),nfRadio.channel("submit").trigger("validate:field",e)}))}else e.set("clean",!1),nfRadio.channel("submit").trigger("validate:field",e)}),this);var e=nfRadio.channel("form-"+this.models[0].get("formID")).request("get:form");_.size(e.get("fieldErrors"))>0&&nfRadio.channel("submit").request("focus:firstInvalidInput",Object.keys(e.get("fieldErrors")))},showFields:function(){this.invoke("set",{visible:!0}),this.invoke((function(){this.trigger("change:value",this)}))},hideFields:function(){this.invoke("set",{visible:!1}),this.invoke((function(){this.trigger("change:value",this)}))},getFirstFieldByOrder:function(e){let t=0;return _.each(e,(function(e){const i=nfRadio.channel("fields").request("get:field",e).get("order");t=0===t||i<t?e:t})),t}});return t})),i("models/formErrorModel",[],(function(){return Backbone.Model.extend({})})),i("models/formErrorCollection",["models/formErrorModel"],(function(e){return Backbone.Collection.extend({model:e})})),i("models/formModel",["models/fieldCollection","models/formErrorCollection"],(function(e,t){return Backbone.Model.extend({defaults:{beforeForm:"",afterForm:"",beforeFields:"",afterFields:"",wrapper_class:"",element_class:"",hp:"",fieldErrors:{},extra:{}},initialize:function(){_.each(this.get("settings"),(function(e,t){this.set(t,e)}),this),this.set("loadedFields",this.get("fields")),this.set("fields",new e(this.get("fields"),{formModel:this})),this.set("errors",new t),nfRadio.channel("form").trigger("before:filterData",this);var i=this.get("formContentData");i||(i=this.get("fieldContentsData"));var n=nfRadio.channel("formContent").request("get:loadFilters"),r=_.without(n,void 0);i=_.first(r)(i,this,this),this.set("formContentData",i),nfRadio.channel("forms").trigger("init:model",this),nfRadio.channel("form-"+this.get("id")).trigger("init:model",this),nfRadio.channel("form-"+this.get("id")).reply("get:fieldByKey",this.getFieldByKey,this),nfRadio.channel("form-"+this.get("id")).reply("add:error",this.addError,this),nfRadio.channel("form-"+this.get("id")).reply("remove:error",this.removeError,this),nfRadio.channel("form-"+this.get("id")).reply("get:extra",this.getExtra,this),nfRadio.channel("form-"+this.get("id")).reply("add:extra",this.addExtra,this),nfRadio.channel("form-"+this.get("id")).reply("remove:extra",this.removeExtra,this),nfRadio.channel("form-"+this.get("id")).reply("get:form",this.getForm,this),nfRadio.channel("form").trigger("loaded",this),nfRadio.channel("form").trigger("after:loaded",this),nfRadio.channel("form-"+this.get("id")).trigger("loaded",this)},getFieldByKey:function(e){return this.get("fields").findWhere({key:e})},addError:function(e,t){this.get("errors").add({id:e,msg:t}),nfRadio.channel("form-"+this.get("id")).trigger("add:error",this,e,t)},removeError:function(e){var t=this.get("errors"),i=t.get(e);t.remove(i),nfRadio.channel("form-"+this.get("id")).trigger("remove:error",this,e)},getExtra:function(e){var t=this.get("extra");return void 0===e?t:t[e]},addExtra:function(e,t){this.get("extra")[e]=t,nfRadio.channel("form-"+this.get("id")).trigger("add:extra",this,e,t)},removeExtra:function(e){delete this.get("extra")[e],nfRadio.channel("form-"+this.get("id")).trigger("remove:extra",this,e)},getForm:function(){return this}})})),i("models/formCollection",["models/formModel"],(function(e){return Backbone.Collection.extend({model:e})})),i("controllers/formData",["models/formModel","models/formCollection","models/fieldCollection","models/formErrorCollection"],(function(e,t,i,n){return Marionette.Object.extend({initialize:function(){this.collection=new t(nfForms),nfRadio.channel("forms").trigger("loaded",this.collection),nfRadio.channel("app").trigger("forms:loaded",this.collection),nfRadio.channel("app").reply("get:form",this.getForm,this),nfRadio.channel("app").reply("get:forms",this.getForms,this),nfRadio.channel("fields").reply("get:field",this.getField,this)},getForm:function(e){return this.collection.get(e)},getForms:function(){return this.collection},getField:function(e){var t=!1;return _.each(this.collection.models,(function(i){t||(t=i.get("fields").get(e))})),void 0===t&&-1!==String(e).indexOf(".")&&(t=nfRadio.channel("field-repeater").request("get:repeaterFieldById",e)),t}})})),i("controllers/fieldError",["models/fieldErrorModel"],(function(e){return Marionette.Object.extend({initialize:function(){nfRadio.channel("fields").reply("add:error",this.addError),nfRadio.channel("fields").reply("remove:error",this.removeError),nfRadio.channel("fields").reply("get:error",this.getError)},addError:function(e,t,i){var n=nfRadio.channel("fields").request("get:field",e);if(void 0!==n){var r=n.get("errors");r.add({id:t,msg:i}),n.set("errors",r),n.trigger("change:errors",n),n.set("clean",!1),nfRadio.channel("fields").trigger("add:error",n,t,i)}},removeError:function(e,t){var i=nfRadio.channel("fields").request("get:field",e);if(void 0!==i){var n=i.get("errors"),r=n.get(t);void 0!==r&&(n.remove(r),i.set("errors",n),i.trigger("change:errors",i),nfRadio.channel("fields").trigger("remove:error",i,t))}},getError:function(e,t){var i=nfRadio.channel("fields").request("get:field",e).get("errors").get(t);return"undefined"!=i&&i}})})),i("controllers/changeField",[],(function(){return Marionette.Object.extend({initialize:function(){nfRadio.channel("nfAdmin").reply("change:field",this.changeField),this.listenTo(nfRadio.channel("fields"),"blur:field",this.blurField)},changeField:function(e,t){var i=nfRadio.channel(t.get("type")).request("before:updateField",e,t);i=void 0!==(i=void 0!==i?i:nfRadio.channel(t.get("parentType")).request("before:updateField",e,t))?i:jQuery(e).val(),t.set("isUpdated",!1),t.set("clean",!1),nfRadio.channel("field-"+t.get("id")).trigger("change:field",e,t),nfRadio.channel(t.get("type")).trigger("change:field",e,t),nfRadio.channel("fields").trigger("change:field",e,t),nfRadio.channel("nfAdmin").request("update:field",t,i),t.get("repeaterField")&&nfRadio.channel("field-repeater").trigger("set:value")},blurField:function(e,t){t.set("clean",!1)}})})),i("controllers/changeEmail",[],(function(){var e=nfRadio.channel("email"),t=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,i="invalid-email";return Marionette.Object.extend({initialize:function(){this.listenTo(e,"change:modelValue",this.onChangeModelValue),this.listenTo(e,"keyup:field",this.emailKeyup),this.listenTo(e,"blur:field",this.onBlurField)},onChangeModelValue:function(e){var t=e.get("value"),i=e.get("id");this.emailChange(t,i)},onBlurField:function(e,t){var i=jQuery(e).val(),n=t.get("id");this.emailChange(i,n)},emailChange:function(e,n){if(0<e.length)if(t.test(e))nfRadio.channel("fields").request("remove:error",n,i);else{var r=nfRadio.channel("fields").request("get:field",n),o=nfRadio.channel("app").request("get:form",r.get("formID"));nfRadio.channel("fields").request("add:error",n,i,o.get("settings").changeEmailErrorMsg)}else nfRadio.channel("fields").request("remove:error",n,i)},emailKeyup:function(e,n,r){if(9==r)return!1;var o=jQuery(e).val(),a=n.get("id");if(0==o.length)nfRadio.channel("fields").request("remove:error",a,i);else if(t.test(o)||n.get("clean"))t.test(o)&&(nfRadio.channel("fields").request("remove:error",a,i),n.addWrapperClass("nf-pass"),n.set("clean",!1));else{var l=nfRadio.channel("fields").request("get:field",a),s=nfRadio.channel("app").request("get:form",l.get("formID"));nfRadio.channel("fields").request("add:error",a,i,s.get("settings").changeEmailErrorMsg),n.removeWrapperClass("nf-pass")}}})})),i("controllers/changeDate",[],(function(){var e=nfRadio.channel("date"),t="invalid-date";return Marionette.Object.extend({initialize:function(){this.listenTo(e,"change:modelValue",this.onChangeModelValue),this.listenTo(e,"keyup:field",this.dateKeyup),this.listenTo(e,"blur:field",this.onBlurField),this.listenTo(e,"change:extra",this.changeHoursMinutes,this)},onChangeModelValue:function(e){var t=moment.locale();moment.locale("ninja-forms"),this.dateChange(e),moment.locale(t)},onBlurField:function(e,t){var i=moment.locale();moment.locale("ninja-forms"),this.dateChange(t),moment.locale(i)},dateChange:function(e){var i=e.get("id"),n=e.get("value"),r=e.get("date_format");if("time_only"==e.get("date_mode"))return!1;if(0<n.length)if(this.isDateValid(n,r,i))nfRadio.channel("fields").request("remove:error",i,t);else{var o=nfRadio.channel("fields").request("get:field",i),a=nfRadio.channel("app").request("get:form",o.get("formID"));nfRadio.channel("fields").request("add:error",i,t,a.get("settings").changeDateErrorMsg)}else nfRadio.channel("fields").request("remove:error",i,t)},dateKeyup:function(e,i,n){if(9==n)return!1;var r=jQuery(e).val(),o=i.get("id"),a=i.get("date_format"),l=moment.locale();if(moment.locale("ninja-forms"),0==r.length)nfRadio.channel("fields").request("remove:error",o,t);else if(this.isDateValid(r,a,o)||i.get("clean"))this.isDateValid(r,a,o)&&(nfRadio.channel("fields").request("remove:error",o,t),i.addWrapperClass("nf-pass"),i.set("clean",!1));else{var s=nfRadio.channel("fields").request("get:field",o),d=nfRadio.channel("app").request("get:form",s.get("formID"));nfRadio.channel("fields").request("add:error",o,t,d.get("settings").changeDateErrorMsg),i.removeWrapperClass("nf-pass")}moment.locale(l)},changeHoursMinutes:function(e,t){let i=jQuery(e.target).closest(".nf-field-element"),n=jQuery(i).find(".hour").val(),r=jQuery(i).find(".minute").val(),o=jQuery(i).find(".ampm").val();t.set("selected_hour",n),t.set("selected_minute",r),t.set("selected_ampm",o),t.trigger("change:value",t)},isDateValid:function(e,t,i){const n=document.querySelector("[name='nf-field-"+i+"']")._flatpickr.parseDate(e,t);if(!n)return!1;const r=n.getTime();if(isNaN(r))return!1;const o=new Date(r);return document.querySelector("[name='nf-field-"+i+"']")._flatpickr.formatDate(o,t)===e}})})),i("controllers/fieldCheckbox",[],(function(){return Marionette.Object.extend({initialize:function(){this.listenTo(nfRadio.channel("checkbox"),"init:model",this.registerRenderClasses),nfRadio.channel("checkbox").reply("validate:required",this.validateRequired),nfRadio.channel("checkbox").reply("validate:modelData",this.validateModelData),nfRadio.channel("checkbox").reply("before:updateField",this.beforeUpdateField,this),nfRadio.channel("checkbox").reply("get:calcValue",this.getCalcValue,this)},beforeUpdateField:function(e,t){if(jQuery(e).prop("checked")){var i=1;jQuery(e).addClass("nf-checked"),jQuery(e).closest(".field-wrap").find('label[for="'+jQuery(e).prop("id")+'"]').addClass("nf-checked-label")}else{i=0;jQuery(e).removeClass("nf-checked"),jQuery(e).closest(".field-wrap").find('label[for="'+jQuery(e).prop("id")+'"]').removeClass("nf-checked-label")}return i},validateRequired:function(e,t){return e[0].checked},validateModelData:function(e){return 0!=e.get("value")},getCalcValue:function(e){return 1==e.get("value")?calcValue=e.get("checked_calc_value"):calcValue=e.get("unchecked_calc_value"),calcValue},registerRenderClasses:function(e){"checked"==e.get("default_value")?e.set("value",1):e.set("value",0),e.set("customClasses",this.customClasses),e.set("customLabelClasses",this.customLabelClasses),e.set("maybeChecked",this.maybeChecked)},customClasses:function(e){return 1==this.value||this.clean&&void 0!==this.default_value&&"checked"==this.default_value?e+=" nf-checked":e.replace("nf-checked",""),e},customLabelClasses:function(e){return 1==this.value||this.clean&&void 0!==this.default_value&&"checked"==this.default_value?e+=" nf-checked-label":e.replace("nf-checked-label",""),e},maybeChecked:function(){return 1==this.value||this.clean&&void 0!==this.default_value&&"checked"==this.default_value?" checked":""}})})),i("controllers/fieldCheckboxList",[],(function(){return Marionette.Object.extend({initialize:function(){this.listenTo(nfRadio.channel("listcheckbox"),"init:model",this.register),this.listenTo(nfRadio.channel("terms"),"init:model",this.register),nfRadio.channel("listcheckbox").reply("before:updateField",this.beforeUpdateField,this),nfRadio.channel("terms").reply("before:updateField",this.beforeUpdateField,this),nfRadio.channel("listcheckbox").reply("get:calcValue",this.getCalcValue,this),nfRadio.channel("terms").reply("get:calcValue",this.getCalcValue,this)},register:function(e){if(e.set("renderOptions",this.renderOptions),e.set("renderOtherText",this.renderOtherText),e.set("selected",[]),0!=e.get("options").length){var t=_.filter(e.get("options"),(function(e){return 1==e.selected}));t=_.map(t,(function(e){return e.value}))}var i=e.get("value");void 0!==i&&Array.isArray(i)?e.set("value",i):void 0!==t&&e.set("value",t)},renderOptions:function(){var e="";if(""==this.value||Array.isArray(this.value)&&0<this.value.length||0<this.value.length)var t=!0;else t=!1;if(_.each(this.options,(function(i,n){Array.isArray(this.value)&&(Array.isArray(this.value[0])&&-1!==_.indexOf(this.value[0],i.value)||_.indexOf(this.value,i.value))&&(t=!0),i.value==this.value&&(t=!0),void 0===i.visible&&(i.visible=!0),i.fieldID=this.id,i.classes=this.classes,i.index=n,i.label=void 0!==nfFrontEnd.filter_esc_status&&"true"===nfFrontEnd.filter_esc_status?_.escape(i.label):i.label;var r=!1;Array.isArray(this.value)&&0<this.value.length?-1===_.indexOf(this.value[0].split(","),i.value)&&-1===_.indexOf(this.value,i.value)||(r=!0):_.isArray(this.value)||i.value!=this.value?1==i.selected&&this.clean&&void 0===this.value&&(r=!0):r=!0,i.selected=r,i.isSelected=r,i.required=this.required,i.maybeFilterHTML=this.maybeFilterHTML;var o=nfRadio.channel("app").request("get:template","#tmpl-nf-field-listcheckbox-option");e+=o(i)}),this),1==this.show_other){"nf-other"==this.value&&(t=!1);var i={fieldID:this.id,classes:this.classes,currentValue:this.value,renderOtherText:this.renderOtherText,valueFound:t},n=nfRadio.channel("app").request("get:template","#tmpl-nf-field-listcheckbox-other");e+=n(i)}return e},renderOtherText:function(){if("nf-other"==this.currentValue||!this.valueFound){"nf-other"==this.currentValue&&(this.currentValue="");var e={fieldID:this.fieldID,classes:this.classes,currentValue:this.currentValue};return nfRadio.channel("app").request("get:template","#tmpl-nf-field-listcheckbox-other-text")(e)}},getCalcValue:function(e){var t=0,i=e.get("options");return 0!=i.length&&_.each(e.get("value"),(function(e){var n=_.find(i,(function(t){return t.value==e}));t=Number(t)+Number(n.calc)})),t},beforeUpdateField:function(e,t){var i=t.get("value")||[];"string"==typeof i&&(i=[i]);var n=jQuery(e).val();if(jQuery(e).prop("checked"))i.push(n),jQuery(e).addClass("nf-checked"),jQuery(e).parent().find('label[for="'+jQuery(e).prop("id")+'"]').addClass("nf-checked-label");else{jQuery(e).removeClass("nf-checked"),jQuery(e).parent().find('label[for="'+jQuery(e).prop("id")+'"]').removeClass("nf-checked-label");var r=i.indexOf(n);if(-1!=r)i.splice(r,1);else if(Array.isArray(i)){var o=void 0!==i[0]?i[0].split(","):[],a=o.indexOf(n);-1!==a&&o.splice(a,1),i=o.join(",")}}return _.clone(i)}})})),i("controllers/fieldImageList",[],(function(){return Marionette.Object.extend({initialize:function(){this.listenTo(nfRadio.channel("listimage"),"init:model",this.register),nfRadio.channel("listimage").reply("before:updateField",this.beforeUpdateField,this),nfRadio.channel("listimage").reply("get:calcValue",this.getCalcValue,this)},register:function(e){if(e.set("renderOptions",this.renderOptions),e.set("renderOtherText",this.renderOtherText),e.set("selected",[]),0!=e.get("image_options").length){var t=_.filter(e.get("image_options"),(function(e){return 1==e.selected}));t=_.map(t,(function(e){return e.value}))}var i=e.get("value");void 0!==i&&Array.isArray(i)?e.set("value",i):void 0!==t&&e.set("value",t)},renderOptions:function(){var e="";if(""==this.value||Array.isArray(this.value)&&0<this.value.length||0<this.value.length)var t=!0;else t=!1;1===this.allow_multi_select?(this.old_classname="list-checkbox",this.image_type="checkbox"):this.image_type="radio","horizontal"===this.list_orientation?this.flex_direction="row":this.flex_direction="column";var i=this,n=parseInt(this.num_columns)||1,r=1,o=1;if(_.each(this.image_options,(function(a,l){this.show_option_labels?a.label=void 0!==nfFrontEnd.filter_esc_status&&"true"===nfFrontEnd.filter_esc_status?_.escape(a.label):a.label:a.label="",Array.isArray(this.value)&&(Array.isArray(this.value[0])&&-1!==_.indexOf(this.value[0],a.value)||_.indexOf(this.value,a.value))&&(t=!0),a.value==this.value&&(t=!0),void 0===a.visible&&(a.visible=!0),"horizontal"===i.list_orientation&&r<=n&&(a.styles="margin:auto;grid-column: "+r+"; grid-row="+o,r===n?(r=1,o+=1):r+=1),a.image_type=i.image_type,a.fieldID=this.id,a.classes=this.classes,a.index=l;var s=!1;Array.isArray(this.value)&&0<this.value.length?-1===_.indexOf(this.value[0].split(","),a.value)&&-1===_.indexOf(this.value,a.value)||(s=!0):(_.isArray(this.value)||a.value!=this.value)&&(1!=a.selected||!this.clean||void 0!==this.value&&""!==this.value)||(s=!0),a.selected=s,a.isSelected=s,a.required=this.required,a.maybeFilterHTML=this.maybeFilterHTML;var d=nfRadio.channel("app").request("get:template","#tmpl-nf-field-listimage-option");e+=d(a)}),this),1==this.show_other){"nf-other"==this.value&&(t=!1);var a={fieldID:this.id,classes:this.classes,value:this.value,currentValue:this.value,renderOtherText:this.renderOtherText,valueFound:t},l=nfRadio.channel("app").request("get:template","#tmpl-nf-field-listimage-other");e+=l(a)}return e},renderOtherText:function(){if("nf-other"==this.currentValue||!this.valueFound){"nf-other"==this.currentValue&&(this.currentValue="");var e={fieldID:this.fieldID,classes:this.classes,currentValue:this.currentValue};return nfRadio.channel("app").request("get:template","#tmpl-nf-field-listimage-other-text")(e)}},getCalcValue:function(e){var t=0,i=e.get("options");if(0!=i.length)if(1==parseInt(e.get("allow_multi_select")))_.each(e.get("value"),(function(e){var n=_.find(i,(function(t){return t.value==e}));t+=Number(n.calc)}));else{var n=_.find(i,(function(t){return e.get("value")==t.value}));void 0!==n&&(t=n.calc)}return t},beforeUpdateField:function(e,t){if(1!==t.get("allow_multi_select")){var i=jQuery(e).val(),n=t.get("image_options");_.each(n,(function(e,t){e.value===i?(e.isSelected=!0,e.selected=!0):(e.isSelected=!1,e.selected=!1),e.isSelected?(jQuery("#nf-field-"+e.fieldID+"-"+t).addClass("nf-checked"),jQuery("#nf-label-field-"+e.fieldID+"-"+t).addClass("nf-checked-label")):(e.selected=!1,jQuery("#nf-field-"+e.fieldID+"-"+t).removeClass("nf-checked"),jQuery("#nf-label-field-"+e.fieldID+"-"+t).removeClass("nf-checked-label"))}))}else{"string"==typeof(i=t.get("value")||[])&&(i=[i]);var r=jQuery(e).val();if(jQuery(e).prop("checked"))i.push(r),jQuery(e).addClass("nf-checked"),jQuery(e).parent().find('label[for="'+jQuery(e).prop("id")+'"]').addClass("nf-checked-label");else{jQuery(e).removeClass("nf-checked"),jQuery(e).parent().find('label[for="'+jQuery(e).prop("id")+'"]').removeClass("nf-checked-label");var o=i.indexOf(r);if(-1!=o)i.splice(o,1);else if(Array.isArray(i)){var a=i[0].split(","),l=a.indexOf(r);-1!==l&&a.splice(l,1),i=a.join(",")}}}return _.clone(i)}})})),i("controllers/fieldRadio",[],(function(){return Marionette.Object.extend({initialize:function(){this.listenTo(nfRadio.channel("listradio"),"change:modelValue",this.changeModelValue),this.listenTo(nfRadio.channel("listradio"),"init:model",this.register),nfRadio.channel("listradio").reply("get:calcValue",this.getCalcValue,this),this.listenTo(nfRadio.channel("listradio"),"change:field",this.updateCheckedClass,this)},register:function(e){if(e.set("renderOptions",this.renderOptions),e.set("renderOtherText",this.renderOtherText),0!=e.get("options").length){var t=_.find(e.get("options"),(function(e){return 1==e.selected}));void 0!==t&&e.set("value",t.value)}},changeModelValue:function(e){1==e.get("show_other")&&e.trigger("reRender")},renderOptions:function(){var e="";if(""==this.value)var t=!0;else t=!1;if(_.each(this.options,(function(i,n){i.value==this.value&&(t=!0),void 0===i.visible&&(i.visible=!0),i.selected=!1,i.fieldID=this.id,i.classes=this.classes,i.currentValue=this.value,i.index=n,i.label=void 0!==nfFrontEnd.filter_esc_status&&"true"===nfFrontEnd.filter_esc_status?_.escape(i.label):i.label,i.required=this.required,this.clean&&1==this.selected||this.value==i.value?i.selected=!0:i.selected=!1,i.maybeFilterHTML=this.maybeFilterHTML;var r=nfRadio.channel("app").request("get:template","#tmpl-nf-field-listradio-option");e+=r(i)}),this),1==this.show_other){"nf-other"==this.value&&(t=!1);var i={fieldID:this.id,classes:this.classes,currentValue:this.value,renderOtherText:this.renderOtherText,valueFound:t},n=nfRadio.channel("app").request("get:template","#tmpl-nf-field-listradio-other");e+=n(i)}return e},renderOtherText:function(){if("nf-other"==this.currentValue||!this.valueFound){"nf-other"==this.currentValue&&(this.currentValue="");var e={fieldID:this.fieldID,classes:this.classes,currentValue:this.currentValue};return nfRadio.channel("app").request("get:template","#tmpl-nf-field-listradio-other-text")(e)}},getCalcValue:function(e){var t=0;if(0!=e.get("options").length){var i=_.find(e.get("options"),(function(t){return e.get("value")==t.value}));void 0!==i&&(t=i.calc)}return t},updateCheckedClass:function(e,t){jQuery('[name="'+jQuery(e).attr("name")+'"]').removeClass("nf-checked"),jQuery(e).closest("ul").find("label").removeClass("nf-checked-label"),jQuery(e).addClass("nf-checked"),jQuery(e).closest("li").find('label[for="'+jQuery(e).prop("id")+'"]').addClass("nf-checked-label")}})})),i("controllers/fieldNumber",[],(function(){return Marionette.Object.extend({initialize:function(){this.listenTo(nfRadio.channel("number"),"init:model",this.maybeMinDefault),this.listenTo(nfRadio.channel("number"),"keyup:field",this.validateMinMax)},maybeMinDefault:function(e){if(""==e.get("value")&&""==e.get("placeholder")){var t=e.get("num_min");e.set("placeholder",t)}},validateMinMax:function(e,t){var i=jQuery(e),n=parseFloat(i.val()),r=i.attr("min"),o=i.attr("max"),a=parseFloat(i.attr("step"));if(r&&n<r){var l=nfRadio.channel("fields").request("get:field",t.get("id")),s=nfRadio.channel("app").request("get:form",l.get("formID"));nfRadio.channel("fields").request("add:error",t.get("id"),"number-min",s.get("settings").fieldNumberNumMinError)}else nfRadio.channel("fields").request("remove:error",t.get("id"),"number-min");if(o&&n>o){l=nfRadio.channel("fields").request("get:field",t.get("id")),s=nfRadio.channel("app").request("get:form",l.get("formID"));nfRadio.channel("fields").request("add:error",t.get("id"),"number-max",s.get("settings").fieldNumberNumMaxError)}else nfRadio.channel("fields").request("remove:error",t.get("id"),"number-max");var d=Math.round(1e9*parseFloat(n)),c=Math.round(1e9*parseFloat(a));if(a&&n&&0!=d%c){l=nfRadio.channel("fields").request("get:field",t.get("id")),s=nfRadio.channel("app").request("get:form",l.get("formID"));nfRadio.channel("fields").request("add:error",t.get("id"),"number-step",s.get("settings").fieldNumberIncrementBy+a)}else nfRadio.channel("fields").request("remove:error",t.get("id"),"number-step")}})})),i("controllers/mirrorField",[],(function(){var e=nfRadio.channel("fields");return Marionette.Object.extend({listeningModel:"",initialize:function(){this.listenTo(e,"init:model",this.registerMirror)},registerMirror:function(e){if(e.get("mirror_field")){this.listeningModel=e;var t=e.get("mirror_field");this.listenTo(nfRadio.channel("field-"+t),"change:modelValue",this.changeValue)}},changeValue:function(e){this.listeningModel.set("value",e.get("value")),this.listeningModel.trigger("reRender")}})})),i("controllers/confirmField",[],(function(){var e=nfRadio.channel("fields"),t="confirm-mismatch";return Marionette.Object.extend({initialize:function(){this.listenTo(e,"init:model",this.registerConfirm),this.listenTo(e,"keyup:field",this.confirmKeyup)},registerConfirm:function(e){e.get("confirm_field")&&this.listenTo(nfRadio.channel("form"),"loaded",(function(t){this.registerConfirmListeners(e)}))},registerConfirmListeners:function(e){var t=nfRadio.channel("form-"+e.get("formID")).request("get:fieldByKey",e.get("confirm_field"));void 0!==t&&(t.set("confirm_with",e.get("id")),this.listenTo(nfRadio.channel("field-"+t.get("id")),"change:modelValue",this.changeValue),this.listenTo(nfRadio.channel("field-"+e.get("id")),"change:modelValue",this.changeValue))},changeValue:function(i){if(void 0===i.get("confirm_with"))var n=i,r=nfRadio.channel("form-"+i.get("formID")).request("get:fieldByKey",n.get("confirm_field"));else r=i,n=e.request("get:field",r.get("confirm_with"));r.get("id");var o=n.get("id");if(""==n.get("value")||n.get("value")==r.get("value"))nfRadio.channel("fields").request("remove:error",o,t);else{var a=nfRadio.channel("fields").request("get:field",o),l=nfRadio.channel("app").request("get:form",a.get("formID"));nfRadio.channel("fields").request("add:error",o,t,l.get("settings").confirmFieldErrorMsg)}},confirmKeyup:function(e,i,n){var r=jQuery(e).val();if(i.get("confirm_field"))var o=i,a=i.get("id"),l=nfRadio.channel("form-"+i.get("formID")).request("get:fieldByKey",o.get("confirm_field")).get("value"),s=r;else if(i.get("confirm_with"))a=(o=nfRadio.channel("fields").request("get:field",i.get("confirm_with"))).get("id"),l=s=o.get("value");if(void 0!==o)if(""==s)nfRadio.channel("fields").request("remove:error",a,t);else if(r==l)nfRadio.channel("fields").request("remove:error",a,t);else{var d=nfRadio.channel("fields").request("get:field",a),c=nfRadio.channel("app").request("get:form",d.get("formID"));nfRadio.channel("fields").request("add:error",a,t,c.get("settings").confirmFieldErrorMsg)}}})})),i("controllers/updateFieldModel",[],(function(){return Marionette.Object.extend({initialize:function(){nfRadio.channel("nfAdmin").reply("update:field",this.updateField)},updateField:function(e,t){e.get("isUpdated")||(e.set("value",t),e.set("isUpdated",!0),_.isArray(t)&&e.trigger("change:value",e))}})})),i("controllers/submitButton",["controllers/submitButton"],(function(e){return Marionette.Object.extend({bound:{},initialize:function(){this.listenTo(nfRadio.channel("submit"),"init:model",this.registerHandlers)},registerHandlers:function(e){if(void 0!==this.bound[e.get("id")])return!1;this.listenTo(nfRadio.channel("field-"+e.get("id")),"click:field",this.click,this),e.listenTo(nfRadio.channel("form-"+e.get("formID")),"before:submit",this.beforeSubmit,e),e.listenTo(nfRadio.channel("form-"+e.get("formID")),"submit:failed",this.resetLabel,e),e.listenTo(nfRadio.channel("form-"+e.get("formID")),"submit:response",this.resetLabel,e),e.listenTo(nfRadio.channel("form-"+e.get("formID")),"enable:submit",this.maybeEnable,e),e.listenTo(nfRadio.channel("form-"+e.get("formID")),"disable:submit",this.maybeDisable,e),e.listenTo(nfRadio.channel("form-"+e.get("formID")),"processingLabel",this.processingLabel,e),e.listenTo(nfRadio.channel("fields"),"add:error",this.maybeDisable,e),e.listenTo(nfRadio.channel("fields"),"remove:error",this.maybeEnable,e),this.bound[e.get("id")]=!0},click:function(e,t){var i=nfRadio.channel("app").request("get:form",t.get("formID"));_.size(i.get("fieldErrors"))>0&&nfRadio.channel("submit").request("focus:firstInvalidInput",Object.keys(i.get("fieldErrors"))),nfRadio.channel("form-"+t.get("formID")).request("submit",i)},beforeSubmit:function(){this.get("disabled")||(this.set("disabled",!0),nfRadio.channel("form-"+this.get("formID")).trigger("processingLabel",this))},maybeDisable:function(e){void 0!==e&&e.get("formID")!=this.get("formID")||(this.set("disabled",!0),this.trigger("reRender"))},maybeEnable:function(e){if(void 0!==e&&e.get("formID")!=this.get("formID"))return!1;var t=nfRadio.channel("app").request("get:form",this.get("formID"));0==_.size(t.get("fieldErrors"))&&(this.set("disabled",!1),this.trigger("reRender"))},processingLabel:function(){this.set("oldLabel",this.get("label")),this.set("label",this.get("processing_label")),this.set("disabled",!0),this.trigger("reRender")},resetLabel:function(e){void 0!==e.errors&&void 0!==e.errors.nonce&&_.size(e.errors.nonce)>0&&void 0!==e.errors.nonce.new_nonce&&void 0!==e.errors.nonce.nonce_ts||(void 0!==this.get("oldLabel")&&this.set("label",this.get("oldLabel")),this.set("disabled",!1),this.trigger("reRender"))}})})),i("controllers/submitDebug",[],(function(){return Marionette.Object.extend({initialize:function(){this.listenTo(nfRadio.channel("forms"),"submit:response",this.submitDebug)},submitDebug:function(e,t,i,n){if(void 0!==e.debug){if(void 0!==e.debug.form){var r=document.createElement("span");_.each(e.debug.form,(function(e,t){var i=document.createTextNode(e);r.appendChild(i),r.appendChild(document.createElement("br"))})),jQuery(".nf-debug-msg").html(r)}if(void 0!==e.debug.console){console.log("%c%s","","NINJA SUPPORT"),_.each(e.debug.console,(function(e,t){console.log(e)})),console.log("%c%s","","END NINJA SUPPORT")}}}})})),i("controllers/getFormErrors",[],(function(){nfRadio.channel("fields");return Marionette.Object.extend({initialize:function(e){nfRadio.channel("form").reply("get:errors",this.getFormErrors)},getFormErrors:function(e){var t=nfRadio.channel("app").request("get:form",e),i=!1;return t&&(0!==t.get("errors").length&&_.each(t.get("errors").models,(function(e){(i=i||{})[e.get("id")]=e.get("msg")})),_.each(t.get("fields").models,(function(e){"submit"!=e.get("type")&&e.get("errors").length>0&&((i=i||{})[e.get("id")]=e.get("errors"))}))),i}})})),i("controllers/validateRequired",[],(function(){return Marionette.Object.extend({initialize:function(){this.listenTo(nfRadio.channel("fields"),"blur:field",this.validateRequired),this.listenTo(nfRadio.channel("fields"),"change:field",this.validateRequired),this.listenTo(nfRadio.channel("fields"),"keyup:field",this.validateKeyup),this.listenTo(nfRadio.channel("fields"),"change:modelValue",this.validateModelData),this.listenTo(nfRadio.channel("submit"),"validate:field",this.validateModelData)},validateKeyup:function(e,t,i){if(1!=t.get("required"))return!1;t.get("clean")||this.validateRequired(e,t)},validateRequired:function(e,t){if(1!=t.get("required")||!t.get("visible"))return!1;var i=jQuery(e).val(),n=nfRadio.channel(t.get("type")).request("validate:required",e,t),r=!0,o=this.getMask(t);if(o&&i===o&&(0<t.get("errors").length||!t.get("clean"))&&(r=!1),String(i).trim()||(r=!1),void 0!==n)var a=n;else a=r;this.maybeError(a,t)},getMask:function(e){var t=e.get("mask");if(void 0!==t){switch(t){case"":break;case"currency":t=nfi18n.currencySymbol;break;case"custom":t=e.get("custom_mask");default:t=(t=(t=t.replace(/9/g,"_")).replace(/a/g,"_")).replace(/\*/g,"_")}return t}},validateModelData:function(e){if(1!=e.get("required")||!e.get("visible")||e.get("clean"))return!1;if(e.get("errors").get("required-error"))return!1;currentValue=e.get("value");var t=!0;String(currentValue).trim()||(t=!1);var i=nfRadio.channel(e.get("type")).request("validate:modelData",e);if(void 0!==i)var n=i;else n=t;this.maybeError(n,e)},maybeError:function(e,t){if(e)nfRadio.channel("fields").request("remove:error",t.get("id"),"required-error");else{var i=nfRadio.channel("form-"+t.get("formID")).request("get:form");void 0!==i&&nfRadio.channel("fields").request("add:error",t.get("id"),"required-error",i.get("settings").validateRequiredField)}}})})),i("controllers/submitError",[],(function(){return Marionette.Object.extend({initialize:function(){this.listenTo(nfRadio.channel("forms"),"submit:response",this.submitErrors),nfRadio.channel("submit").reply("focus:firstInvalidInput",this.focusFirstInvalidInput)},submitErrors:function(e,t,i,n){if(_.size(e.errors.nonce)>0&&void 0!==e.errors.nonce.new_nonce&&void 0!==e.errors.nonce.nonce_ts){nfFrontEnd.ajaxNonce=e.errors.nonce.new_nonce,nfFrontEnd.nonce_ts=e.errors.nonce.nonce_ts;var r=nfRadio.channel("app").request("get:form",n);nfRadio.channel("form-"+n).request("submit",r)}if(_.size(e.errors.fields)>0&&_.each(e.errors.fields,(function(e,t){"object"==typeof e?nfRadio.channel("fields").request("add:error",t,e.slug,e.message):nfRadio.channel("fields").request("add:error",t,"required-error",e)})),_.size(e.errors.form)>0&&_.each(e.errors.form,(function(e,t){nfRadio.channel("form-"+n).request("remove:error",t),nfRadio.channel("form-"+n).request("add:error",t,e)})),void 0!==e.errors.last&&void 0!==e.errors.last.message){var o="background: rgba(255, 207, 115, .5); color: #FFA700; display: block;";console.log("%c NINJA FORMS SUPPORT: SERVER ERROR",o),console.log(e.errors.last.message),console.log("%c END SERVER ERROR MESSAGE",o)}jQuery("#nf-form-"+n+"-cont .nf-field-container").show()},focusFirstInvalidInput:function(e){const t=nfRadio.channel("fields").request("get:firstFieldByOrder",e);null!==document.getElementById("nf-field-"+t)&&document.getElementById("nf-field-"+t).focus()}})})),i("controllers/actionRedirect",[],(function(){return Marionette.Object.extend({initialize:function(){this.listenTo(nfRadio.channel("forms"),"submit:response",this.actionRedirect)},actionRedirect:function(e){void 0!==e.data.halt&&void 0!==e.data.halt.redirect&&""!=e.data.halt.redirect&&(window.location=e.data.halt.redirect),0==_.size(e.errors)&&void 0!==e.data.actions&&void 0!==e.data.actions.redirect&&""!=e.data.actions.redirect&&(window.location=e.data.actions.redirect)}})})),i("controllers/actionSuccess",[],(function(){return Marionette.Object.extend({initialize:function(){this.listenTo(nfRadio.channel("forms"),"submit:response",this.actionSubmit)},actionSubmit:function(e){if(0==_.size(e.errors)&&void 0!==e.data.actions&&void 0!==e.data.actions.success_message&&""!=e.data.actions.success_message){var t=e.data.form_id,i=jQuery("#nf-form-"+t+"-cont .nf-response-msg");const l=e.data.actions.success_message.replace(/(<([^>]+)>)/gi,"");i.attr("tabindex","0"),i.attr("aria-live","assertive"),i.attr("aria-label",l),i.html(e.data.actions.success_message).show(),i.focus();var n=i.offset().top,r=i.offset().top+i.outerHeight(),o=jQuery(window).scrollTop()+jQuery(window).height(),a=jQuery(window).scrollTop();o>r&&a<n||jQuery("html, body").animate({scrollTop:i.offset().top-50},300)}}})})),i("controllers/fieldSelect",[],(function(){return Marionette.Object.extend({initialize:function(){this.listenTo(nfRadio.channel("fields"),"init:model",(function(e){"list"==e.get("parentType")&&this.register(e)}),this),nfRadio.channel("listselect").reply("get:calcValue",this.getCalcValue,this),nfRadio.channel("listmultiselect").reply("get:calcValue",this.getCalcValue,this)},register:function(e){if(e.set("renderOptions",this.renderOptions),e.set("renderOtherAttributes",this.renderOtherAttributes),0!=e.get("options").length){var t=e.get("value");if("listmultiselect"==e.get("type"))var i=_.filter(e.get("options"),(function(e){return 1==e.selected})),n=i=_.map(i,(function(e){return e.value}));else if("listradio"!==e.get("type")){if(void 0===(i=_.find(e.get("options"),(function(e){return 1==e.selected})))&&(i=_.first(e.get("options"))),void 0!==i&&void 0!==i.value)n=i.value;else if(void 0!==i)n=i.label}void 0!==t&&""!==t&&Array.isArray(t)?e.set("value",t):void 0!==i&&e.set("value",n)}},renderOptions:function(){var e="";return _.each(this.options,(function(t){if(_.isArray(this.value)){if("listmultiselect"===this.type&&0<this.value.length&&-1!=_.indexOf(this.value[0].split(","),t.value))var i=!0;else if(-1!=_.indexOf(this.value,t.value))i=!0}else if(_.isArray(this.value)||t.value!=this.value)if(1==t.selected&&this.clean&&void 0===this.value)i=!0;else i=!1;else var i=!0;void 0===t.visible&&(t.visible=!0),t.selected=i,t.fieldID=this.id,t.classes=this.classes,t.currentValue=this.value,t.label=void 0!==nfFrontEnd.filter_esc_status&&"true"===nfFrontEnd.filter_esc_status?_.escape(t.label):t.label,t.maybeFilterHTML=this.maybeFilterHTML;var n=nfRadio.channel("app").request("get:template","#tmpl-nf-field-listselect-option");e+=n(t)}),this),e},renderOtherAttributes:function(){var e="";"listmultiselect"==this.type&&(e=(e+=" multiple")+' size="'+(this.multi_size||5)+'"');return e},getCalcValue:function(e){var t=0,i=e.get("options");if(0!=i.length)if("listmultiselect"==e.get("type"))_.each(e.get("value"),(function(e){var n=_.find(i,(function(t){return t.value==e}));t+=Number(n.calc)}));else{var n=_.find(i,(function(t){return e.get("value")==t.value}));void 0===n&&(n=e.get("options")[0]),t=n.calc}return t}})})),i("controllers/coreSubmitResponse",[],(function(){return Marionette.Object.extend({initialize:function(){this.listenTo(nfRadio.channel("forms"),"submit:response",this.actionSubmit)},actionSubmit:function(e){var t=nfRadio.channel("app").request("get:form",e.data.form_id);if(0!=_.size(e.errors))return!1;1==e.data.settings.clear_complete&&(t.get("fields").reset(t.get("loadedFields")),1!=e.data.settings.hide_complete&&nfRadio.channel("captcha").trigger("reset")),1==e.data.settings.hide_complete&&t.trigger("hide")}})})),i("controllers/fieldProduct",[],(function(){return Marionette.Object.extend({initialize:function(){this.listenTo(nfRadio.channel("product"),"init:model",this.register),nfRadio.channel("product").reply("get:calcValue",this.getCalcValue,this)},register:function(e){e.set("renderProductQuantity",this.renderProductQuantity),e.set("renderProduct",this.renderProduct),e.set("renderOptions",this.renderOptions)},renderProduct:function(){switch(this.product_type){case"user":return nfRadio.channel("app").request("get:template","#tmpl-nf-field-textbox")(this);case"hidden":return nfRadio.channel("app").request("get:template","#tmpl-nf-field-hidden")(this);case"dropdown":return nfRadio.channel("app").request("get:template","#tmpl-nf-product-dropdown")(this);default:return nfRadio.channel("app").request("get:template","#tmpl-nf-product-single")(this)}},renderProductQuantity:function(){if(1==this.product_use_quantity)return nfRadio.channel("app").request("get:template","#tmpl-nf-product-quantity")(this)},renderOptions:function(){var e=this,t="";return _.each(this.options,(function(i){if(1==i.selected)var n=!0;else n=!1;i.selected=n,i.fieldID=e.id,i.classes=e.classes,i.currentValue=e.value;var r=nfRadio.channel("app").request("get:template","#tmpl-nf-product-"+e.product_type+"-option");t+=r(i)})),t},getCalcValue:function(e){return e.get("product_price")*e.get("value")}})})),i("controllers/fieldTotal",[],(function(){return Marionette.Object.extend({totalModel:{},productTotals:{},initialize:function(){this.listenTo(nfRadio.channel("total"),"init:model",this.register),this.listenTo(nfRadio.channel("shipping"),"init:model",this.registerShipping)},register:function(e){this.totalModel=e;var t=e.get("formID");this.listenTo(nfRadio.channel("form-"+t),"loaded",this.onFormLoaded),this.listenTo(nfRadio.channel("product"),"change:modelValue",this.onChangeProduct),this.listenTo(nfRadio.channel("quantity"),"change:modelValue",this.onChangeQuantity)},registerShipping:function(e){this.shippingCost=e.get("shipping_cost")},onFormLoaded:function(e){var t=e.get("fields").models,i={},n={};for(var r in t){var o=t[r],a=o.get("id");if("product"==o.get("type"))i[a]=o;else if("quantity"==o.get("type")){n[l=o.get("product_assignment")]=o}}for(var l in i){var s=i[l],d=Number(s.get("product_price"));n[l]?d*=n[l].get("value"):1==s.get("product_use_quantity")&&(d*=s.get("value")),this.productTotals[l]=d}this.updateTotal()},onChangeProduct:function(e){var t=e.get("id"),i=Number(e.get("product_price")),n=Number(e.get("value"))*i;this.productTotals[t]=n,this.updateTotal()},onChangeQuantity:function(e){var t=e.get("product_assignment"),i=nfRadio.channel("fields").request("get:field",t),n=Number(i.get("product_price")),r=Number(e.get("value"))*n;this.productTotals[t]=r,this.updateTotal()},updateTotal:function(){var e=0;for(var t in this.productTotals)e+=Number(this.productTotals[t]);e&&this.shippingCost&&(e+=Number(this.shippingCost)),this.totalModel.set("value",e.toFixed(2)),this.totalModel.trigger("reRender")}})})),i("controllers/fieldQuantity",[],(function(){return Marionette.Object.extend({initialize:function(){this.listenTo(nfRadio.channel("quantity"),"init:model",this.registerQuantity)},registerQuantity:function(e){var t=e.get("product_assignment"),i=nfRadio.channel("fields").request("get:field",t);i&&i.set("product_use_quantity",0)}})})),i("models/calcModel",[],(function(){return Backbone.Model.extend({initialize:function(){this.set("formID",this.collection.options.formModel.get("id")),this.set("fields",{}),nfRadio.channel("calc").trigger("init:model",this),this.on("change:value",this.changeValue,this)},changeField:function(e){nfRadio.channel("calc").trigger("change:field",this,e)},changeCalc:function(e){nfRadio.channel("calc").trigger("change:calc",this,e)},changeValue:function(){nfRadio.channel("calc").trigger("change:value",this)}})})),i("models/calcCollection",["models/calcModel"],(function(e){return Backbone.Collection.extend({model:e,comparator:"order",initialize:function(e,t){this.options=t,_.each(e,(function(e){void 0!==e.dec&&(""===e.dec.toString().trim()&&(e.dec=2),e.dec=parseInt(e.dec))})),nfRadio.channel("form-"+t.formModel.get("id")).reply("get:calc",this.getCalc,this)},getCalc:function(e){return this.findWhere({name:e})}})})),i("controllers/calculations",["models/calcCollection"],(function(e){return Marionette.Object.extend({initialize:function(){this.calcs={},this.displayFields={},this.listenTo(nfRadio.channel("form"),"loaded",this.registerCalcs),this.listenTo(nfRadio.channel("fields"),"reset:collection",this.resetCalcs),this.listenTo(nfRadio.channel("calc"),"change:field",this.changeField),this.listenTo(nfRadio.channel("calc"),"change:calc",this.changeCalc);var e=this;_.each(nfFrontEnd.use_merge_tags.calculations,(function(t){e.listenTo(nfRadio.channel("fields-"+t),"init:model",e.initDisplayField)})),this.listenTo(nfRadio.channel("calc"),"change:value",this.updateDisplayFields),this.init={}},resetCalcs:function(e){void 0!==e.options.formModel&&this.registerCalcs(e.options.formModel)},registerCalcs:function(t){var i=new e(t.get("settings").calculations,{formModel:t});this.calcs[t.get("id")]=i;var n=this;_.each(i.models,(function(e){n.init[e.get("name")]=!0,n.setupCalc(e)}))},setupCalc:function(e){var t=this,i=e.get("eq"),n=i,r=(e.get("name"),i.match(new RegExp(/{field:(.*?)}/g)));r&&(r=r.map((function(i){var r=i.replace(":calc}","").replace("}","").replace("{field:","");if(fieldModel=nfRadio.channel("form-"+e.get("formID")).request("get:fieldByKey",r),"undefined"!=typeof fieldModel){fieldModel.set("clean",!1),fieldModel.on("change:value",e.changeField,e);var o=t.getCalcValue(fieldModel);t.updateCalcFields(e,r,o),n=t.replaceKey("field",r,o,n)}})));var o=i.match(new RegExp(/{calc:(.*?)}/g));o&&(o=o.map((function(i){var r=i.replace("}","").replace("{calc:",""),o=e.collection.findWhere({name:r});if(void 0!==o){o.on("change:value",e.changeCalc,e);var a=o.get("value");n=t.replaceKey("calc",r,a,n)}}))),n=(n=n.replace(/{([a-zA-Z0-9]|:|_|-)*}/g,0)).replace(/\r?\n|\r/g,"");try{this.debug("Calculation Decoder "+n+" -> "+this.localeDecodeEquation(n)+" (Setup)");const t=new Mexp;e.set("value",Number(t.eval(this.localeDecodeEquation(n))).toFixed(e.get("dec")))}catch(e){console.log(e)}"NaN"===e.get("value")&&e.set("value","0")},updateCalcFields:function(e,t,i){var n=e.get("fields");n[t]=i,e.set("fields",n)},getCalcValue:function(e){var t=nfRadio.channel(e.get("type")).request("get:calcValue",e),i=e.get("value");void 0!==t&&(t||0===t)&&(i=t);var n=new r(nfi18n.siteLocale,nfi18n.thousands_sep,nfi18n.decimal_point),o=n.numberDecoder(i),a=n.numberEncoder(i);return t=void 0!==o&&jQuery.isNumeric(o)?a:0,e.get("visible")||(t=0),t},replaceKey:function(e,t,i,n){n=n||calcModel.get("eq"),tag="{"+e+":"+t+"}";var r=new RegExp(tag,"g");calcTag="{"+e+":"+t+":calc}";var o=new RegExp(calcTag,"g");return n=(n=n.replace(r,i)).replace(o,i)},replaceAllKeys:function(e){var t=e.get("eq"),i=this;_.each(e.get("fields"),(function(e,n){t=i.replaceKey("field",n,e,t)}));var n=t.match(new RegExp(/{calc:(.*?)}/g));return n&&_.each(n,(function(i){var n=i.replace("}","").replace("{calc:",""),r=e.collection.findWhere({name:n});if(void 0!==r){var o=new RegExp(i,"g");t=t.replace(o,r.get("value"))}})),t},changeField:function(e,t){var i=t.get("key"),n=this.getCalcValue(t);this.updateCalcFields(e,i,n);var r=this.replaceAllKeys(e);r=(r=r.replace(/{([a-zA-Z0-9]|:|_|-)*}/g,"0")).replace(/\r?\n|\r/g,"");try{this.debug("Calculation Decoder "+r+" -> "+this.localeDecodeEquation(r)+" (Change Field)");const t=new Mexp;e.set("value",Number(t.eval(this.localeDecodeEquation(r))).toFixed(e.get("dec")))}catch(e){this.debug()&&console.log(e)}"NaN"===e.get("value")&&e.set("value","0")},initDisplayField:function(e){if(e.get("default")&&"string"==typeof e.get("default")){var t=e.get("default").match(new RegExp(/{calc:(.*?)}/g));t&&_.each(t,(function(t){t=t.replace("{calc:","").replace("}","").replace(":2",""),this.displayFields[t]=this.displayFields[t]||[],this.displayFields[t].push(e)}),this)}},updateDisplayFields:function(e){var t=this;void 0!==this.displayFields[e.get("name")]&&_.each(this.displayFields[e.get("name")],(function(i){var n="",r=(n="html"===i.get("type")?i.get("value"):i.get("default")).match(new RegExp(/<span data-key="calc:(.*?)<\/span>/g));_.each(r,(function(e){var t="{"+e.replace('<span data-key="',"").replace(/">(.*?)<\/span>/,"")+"}";n=n.replace(e,t)}));var o=n.match(new RegExp(/{calc:(.*?)}/g));_.each(o,(function(e){var r=e.replace("}","").replace("{calc:","").replace(":2",""),o=t.calcs[i.get("formID")].findWhere({name:r}),a=new RegExp(e,"g"),l=o.get("value");void 0!==l&&(l=t.applyLocaleFormatting(l,o)),n="html"===i.get("type")?n.replace(a,'<span data-key="calc:'+r+'">'+l+"</span>"):l})),i.set("value",n),t.init[e.get("name")]||i.trigger("reRender"),t.init[e.get("name")]=!1}))},getCalc:function(e,t){return this.calcs[t].findWhere({name:e})},changeCalc:function(e,t){var i=this.replaceAllKeys(e);i=(i=i.replace("[","").replace("]","")).replace(/\r?\n|\r/g,"");try{this.debug("Calculation Decoder "+i+" -> "+this.localeDecodeEquation(i)+" (Change Calc)");const t=new Mexp;e.set("value",Number(t.eval(this.localeDecodeEquation(i))).toFixed(e.get("dec")))}catch(e){console.log(e)}"NaN"===e.get("value")&&e.set("value","0")},applyLocaleFormatting:function(e,t){return new r(nfi18n.siteLocale,nfi18n.thousands_sep,nfi18n.decimal_point).numberEncoder(e,t.get("dec"))},localeDecodeEquation:function(e){var t="",i="",n=/[0-9.,]/,o=new r(nfi18n.siteLocale,nfi18n.thousands_sep,nfi18n.decimal_point);return(e=(e=e.replace(/\s/g,"")).replace(/&nbsp;/g,"")).split("").forEach((function(e){n.test(e)?i+=e:(0<i.length&&(t+=o.numberDecoder(i),i=""),t+=e)})),0<i.length&&(t+=o.numberDecoder(i)),t},debug:function(e){window.nfCalculationsDebug&&console.log(e)}})})),i("controllers/dateBackwardsCompat",[],(function(){return Marionette.Object.extend({initialize:function(){this.listenTo(Backbone.Radio.channel("pikaday-bc"),"init",this.dateBackwardsCompat)},dateBackwardsCompat:function(e,t){if(e.pikaday={},e.pikaday._o={},nfRadio.channel("pikaday").trigger("init",e,t),void 0!==e.pikaday._o.disableDayFn&&e.set("disable",[e.pikaday._o.disableDayFn]),void 0!==e.pikaday._o.i18n||void 0!==e.pikaday._o.firstDay){let t=e.config.locale;void 0!==e.pikaday._o.firstDay&&(t.firstDayOfWeek=e.pikaday._o.firstDay),void 0!==e.pikaday._o.i18n&&(void 0!==e.pikaday._o.i18n.weekdays&&(t.weekdays.longhand=e.pikaday._o.i18n.weekdays),void 0!==e.pikaday._o.i18n.weekdaysShort&&(t.weekdays.shorthand=e.pikaday._o.i18n.weekdaysShort),void 0!==e.pikaday._o.i18n.months&&jQuery(".flatpickr-monthDropdown-months > option").each((function(){this.text=e.pikaday._o.i18n.months[this.value]}))),e.set("locale",t)}Object.keys(e.pikaday._o).length>0&&(console.log("%cDeprecated Ninja Forms Pikaday custom code detected.","color: Red; font-size: large"),console.log("You are using deprecated Ninja Forms Pikaday custom code. Support for this custom code will be removed in a future version of Ninja Forms. Please contact Ninja Forms support for more details."))}})})),i("controllers/fieldDate",[],(function(){return Marionette.Object.extend({initialize:function(){this.listenTo(nfRadio.channel("date"),"init:model",this.initModel),this.listenTo(nfRadio.channel("date"),"render:view",this.initDatepicker)},initModel:function(e){this.registerFunctions(e)},registerFunctions:function(e){e.set("renderHourOptions",this.renderHourOptions),e.set("renderMinuteOptions",this.renderMinuteOptions),e.set("maybeRenderAMPM",this.maybeRenderAMPM),e.set("customClasses",this.customClasses),e.getValue=this.getValue},renderHourOptions:function(){return this.hours_options},renderMinuteOptions:function(){return this.minutes_options},maybeRenderAMPM:function(){if(void 0!==this.hours_24&&1!=this.hours_24)return`<div style="float:left;" class="time-wrap"><select id="ampm-select" class="ampm extra" aria-label="am-pm-select" ${1==this.required?'aria-required="true" required':""}><option value="am">AM</option><option value="pm">PM</option></select></div>`},initDatepicker:function(e){e.model.set("el",e.el);var t=jQuery(e.el).find(".nf-element")[0];if(e.listenTo(nfRadio.channel("form-"+e.model.get("formID")),"before:submit",this.beforeSubmit,e),void 0!==e.model.get("date_mode")&&"time_only"==e.model.get("date_mode"))return jQuery(t).hide(),!1;var i=this.convertDateFormat(e.model.get("date_format"));e.model.set("date_format",i);var n={onReady:(e,i,n)=>{n.altInput.setAttribute("aria-labelledby",jQuery(t).attr("aria-labelledby")),n.altInput.setAttribute("aria-invalid",!1)},dateFormat:i,altFormat:i,altInput:!0,ariaDateFormat:i,mode:"single",allowInput:!0,disableMobile:"true",minDate:this.getMinDate(e.model),maxDate:this.getMaxDate(e.model)};const r=this.checkCustomLocale();r&&(n.locale=r);let o=nfRadio.channel("flatpickr").request("filter:settings",n,e);void 0!==o&&(n=o);var a=flatpickr(t,n);1==e.model.get("date_default")&&(a.defaultDate=new Date,a.setDate(a.defaultDate),e.model.set("value",a.defaultDate)),nfRadio.channel("pikaday-bc").trigger("init",a,e.model,e),nfRadio.channel("flatpickr").trigger("init",a,e.model,e)},beforeSubmit:function(e){if(_.isObject(this.model.get("value"))){const e=this.el.id.replace("-wrap",""),t=this.el.querySelector("#"+e).value;this.model.set("value",t)}if("date_only"==this.model.get("date_mode"))return!1;let t=jQuery(this.el).find(".hour").val(),i=jQuery(this.el).find(".minute").val(),n=jQuery(this.el).find(".ampm").val(),r=this.model.get("value"),o=!1;o=_.isObject(r)?r.date:r;let a={date:o,hour:t,minute:i,ampm:n};this.model.set("value",a)},getMinDate:function(e){let t=null;if(void 0!==e.get("year_range_start")){const i=e.get("year_range_start");i&&(t=flatpickr.formatDate(new Date(String(i)),e.get("date_format")))}return t},getMaxDate:function(e){let t=null;if(void 0!==e.get("year_range_end")){const i=e.get("year_range_end");i&&(t=flatpickr.formatDate(new Date(String(i)),e.get("date_format")))}return t},convertDateFormat:function(e){!e&&this.model&&(e=this.model.get("date_format")),e||(e="default");const t={"MM/DD/YYYY":"m/d/Y","MM-DD-YYYY":"m-d-Y","MM.DD.YYYY":"m.d.Y","DD/MM/YYYY":"d/m/Y","DD-MM-YYYY":"d-m-Y","DD.MM.YYYY":"d.m.Y","YYYY-MM-DD":"Y-m-d","YYYY/MM/DD":"Y/m/d","YYYY.MM.DD":"Y.m.d","dddd, MMMM D YYYY":"l, F d Y",default:nfi18n.dateFormat?nfi18n.dateFormat:"default"};return Object.keys(t).includes(e)?t[e]:e},customClasses:function(e){return"date_and_time"==this.date_mode&&(e+=" date-and-time"),e},checkCustomLocale:function(){let e={};return nfi18n&&((nfi18n.months||nfi18n.monthsShort)&&(e.months={},nfi18n.months&&(e.months.longhand=nfi18n.months),nfi18n.monthsShort&&(e.months.shorthand=nfi18n.monthsShort)),(nfi18n.weekdays||nfi18n.weekdaysShort)&&(e.weekdays={},nfi18n.weekdays&&(e.weekdays.longhand=nfi18n.weekdays),nfi18n.weekdaysShort&&(e.weekdays.shorthand=nfi18n.weekdaysShort)),nfi18n.startOfWeek&&(e.firstDayOfWeek=nfi18n.startOfWeek)),!_.isEmpty(e)&&e},getValue:function(){if("date_only"==this.get("date_mode"))return this.get("value");let e=this.get("el"),t=jQuery(e).find(".hour").val(),i=jQuery(e).find(".minute").val(),n=jQuery(e).find(".ampm").val(),r=this.get("value"),o=!1;o=_.isObject(r)?r.date:r;let a="";return void 0!==o&&(a+=o),void 0!==t&&void 0!==i&&(a+=" "+t+":"+i),void 0!==n&&(a+=" "+n),a}})})),i("controllers/fieldRecaptcha",[],(function(){return Marionette.Object.extend({initialize:function(){this.listenTo(nfRadio.channel("recaptcha"),"init:model",this.initRecaptcha),this.listenTo(nfRadio.channel("forms"),"submit:response",this.resetRecaptcha)},initRecaptcha:function(e){nfRadio.channel("recaptcha").reply("update:response",this.updateResponse,this,e.id)},updateResponse:function(e,t){var i=nfRadio.channel("fields").request("get:field",t);i.set("value",e),nfRadio.channel("fields").request("remove:error",i.get("id"),"required-error")},resetRecaptcha:function(){var e=0;jQuery(".g-recaptcha").each((function(){try{grecaptcha.reset(e)}catch(e){console.log("Notice: Error trying to reset grecaptcha.")}e++}))}})})),i("controllers/fieldRecaptchaV3",[],(function(){return Marionette.Object.extend({initialize:function(){this.listenTo(nfRadio.channel("recaptcha_v3"),"init:model",this.initRecaptcha)},initRecaptcha:function(e){const t=e.get("formID");this.processRecaptcha(t,e),setInterval(this.processRecaptcha,11e4,t,e)},processRecaptcha:function(e,t){try{nfRadio.channel("form-"+e).trigger("disable:submit",t),grecaptcha.ready((function(){grecaptcha.execute(t.get("site_key"),{action:"register"}).then((function(i){t.set("value",i),nfRadio.channel("form-"+e).trigger("enable:submit",t)}))}))}catch(e){jQuery(document).on("nfFormReady",(e=>{let i,n=nf_check_recaptcha_consent();t.collection.models.forEach((e=>{"submit"===e.get("type")&&(i=e.get("id"))})),nfRadio.channel("fields").request("add:error",i,"recaptcha-v3-missing",t.collection.options.formModel.get("settings").recaptchaConsentMissing),this.nf_build_default_consent_action(t,n.services,i,e)}))}},nf_build_default_consent_action:function(e,t,i,n){if(!(t.length<=1&&t.includes("missing_cookie")||t.length<=0)){let r=document.createElement("div");r.setAttribute("id","nf_recaptcha_consent_event"),r.innerText+=e.collection.options.formModel.get("settings").recaptchaConsentEvent;let o=new CustomEvent("nf_consent_link",{detail:{services:t,element:r,submitFieldID:i,layoutView:n}});document.dispatchEvent(o);const a=document.getElementsByClassName("nf-error-recaptcha-v3-missing");Array.prototype.slice.call(a).forEach((e=>{e.append(r)}))}}})})),i("controllers/fieldHTML",[],(function(){return Marionette.Object.extend({htmlFields:[],trackedMergeTags:[],initialize:function(){this.listenTo(Backbone.Radio.channel("fields-html"),"init:model",this.setupFieldMergeTagTracking)},setupFieldMergeTagTracking:function(e){this.htmlFields.push(e);var t=e.get("formID");this.listenTo(nfRadio.channel("form-"+t),"init:model",(function(t){var i=e.get("default").match(new RegExp(/{field:(.*?)}/g));i&&(_.each(i,(function(e){var i=e.replace("{field:","").replace("}",""),n=t.get("fields").findWhere({key:i});void 0!==n&&(this.trackedMergeTags.push(n),this.listenTo(nfRadio.channel("field-"+n.get("id")),"change:modelValue",this.updateFieldMergeTags))}),this),this.updateFieldMergeTags())}),this)},updateFieldMergeTags:function(e){_.each(this.htmlFields,(function(e){var t=e.get("value");_.each(this.trackedMergeTags,(function(e){var i=t.match(new RegExp(/<span data-key="field:(.*?)<\/span>/g));_.each(i,(function(i){-1<i.indexOf('data-key="field:'+e.get("key"))&&(t=t.replace(i,"{field:"+e.get("key")+"}"))}));var n="{field:"+e.get("key")+"}";const r="repeater"===e.get("type")?this.displayRepeaterData(e):e.getValue();t=t.replace(n,'<span data-key="field:'+e.get("key")+'">'+r+"</span>")}),this),e.set("value",t),e.trigger("reRender")}),this)},displayRepeaterData:function(e){const t=Object.keys(e.getValue());let i="",n=[];return _.each(t,(function(e){if(-1===n.indexOf(e)){const t=nfRadio.channel("fields").request("get:field",e);if(void 0!==t){if(-1===["submit","html","hidden","password","passwordconfirm","divider","hr","note","unknown","button","confirm","creditcard","creditcardcvc","creditcardexpiration","creditcardfullname","creditcardnumber","creditcardzip","recaptcha","recaptcha_v3"].indexOf(t.get("type"))&&t.getValue().toString().length>0){const r=Number(e.split("_").pop())+1;i+="<p>"+t.get("label")+" "+r+":"+t.getValue()+"</p>",n.push(e)}}}})),i}})})),i("controllers/helpText",[],(function(){return Marionette.Object.extend({initialize:function(){this.listenTo(nfRadio.channel("form"),"render:view",this.initHelpText),nfRadio.channel("form").reply("init:help",this.initHelpText)},initHelpText:function(e){jQuery(e.el).find(".nf-help").each((function(){var e=jQuery(this).jBox("Tooltip",{theme:"TooltipBorder",content:jQuery(this).data("text"),trigger:"mouseenter focus",closeOnMouseleave:!0,closeOnClick:!0});jQuery(this).on("keydown mouseleave",(function(){e.close()}))}))}})})),i("controllers/fieldTextbox",[],(function(){return Marionette.Object.extend({initialize:function(){nfRadio.channel("textbox").reply("get:calcValue",this.getCalcValue,this)},getCalcValue:function(e){if("currency"==e.get("mask")){var t=nfRadio.channel("app").request("get:form",e.get("formID")),i=void 0!==t?t.get("currencySymbol"):"",n=jQuery("<textarea />").html(i).text();return e.get("value").replace(n,"")}return e.get("value")}})})),i("controllers/fieldTextareaRTE",[],(function(){return Marionette.Object.extend({initialize:function(){this.listenTo(nfRadio.channel("textarea"),"render:view",this.initTextareaRTEs),this.listenTo(nfRadio.channel("textarea"),"click:extra",this.clickExtra),this.meta_image_frame,this.currentContext={},void 0!==jQuery.summernote&&(jQuery.summernote.options.icons={align:"dashicons dashicons-editor-alignleft",alignCenter:"dashicons dashicons-editor-aligncenter",alignJustify:"dashicons dashicons-editor-justify",alignLeft:"dashicons dashicons-editor-alignleft",alignRight:"dashicons dashicons-editor-alignright",indent:"dashicons dashicons-editor-indent",outdent:"dashicons dashicons-editor-outdent",bold:"dashicons dashicons-editor-bold",caret:"dashicons dashicons-arrow-down",close:"dashicons dashicons-dismiss",code:"dashicons dashicons-editor-code",eraser:"dashicons dashicons-editor-removeformatting",italic:"dashicons dashicons-editor-italic",link:"dashicons dashicons-admin-links",unlink:"dashicons dashicons-editor-unlink",magic:"dashicons dashicons-editor-paragraph",minus:"dashicons dashicons-minus",orderedlist:"dashicons dashicons-editor-ol",redo:"dashicons dashicons-redo",square:"dashicons fa-square",table:"dashicons dashicons-editor-table",underline:"dashicons dashicons-editor-underline",undo:"dashicons dashicons-undo",unorderedlist:"dashicons dashicons-editor-ul"})},initTextareaRTEs:function(e){if(1!=e.model.get("textarea_rte"))return!1;var t=this,i=[["paragraphStyle",["style"]],["fontStyle",["bold","italic","underline","clear"]],["lists",["ul","ol"]],["paragraph",["paragraph"]],["customGroup",["linkButton","unlink"]],["table",["table"]],["actions",["undo","redo"]]];1==e.model.get("textarea_media")&&0!=userSettings.uid&&i.push(["tools",["mediaButton"]]),jQuery(e.el).find(".nf-element").summernote({toolbar:i,buttons:{linkButton:function(e){return t.linkButton(e)},mediaButton:function(e){return t.mediaButton(e)}},height:150,codemirror:{theme:"monokai",lineNumbers:!0},prettifyHtml:!0,callbacks:{onChange:function(t){e.model.set("value",jQuery(this).summernote("code"))}}});var n=jQuery(e.el).find(".link-button").next(".dropdown-menu").find("button");n.replaceWith((function(){return jQuery("<div/>",{class:jQuery(n).attr("class"),html:this.innerHTML})}))},linkButton:function(e){var t=this,i=jQuery.summernote.ui,n=nfRadio.channel("app").request("get:template","#tmpl-nf-rte-link-button"),r=nfRadio.channel("app").request("get:template","#tmpl-nf-rte-link-dropdown");return i.buttonGroup([i.button({className:"dropdown-toggle link-button",contents:n({}),tooltip:nfi18n.fieldTextareaRTEInsertLink,click:function(i){t.clickLinkButton(i,e)},data:{toggle:"dropdown"}}),i.dropdown([i.buttonGroup({children:[i.button({contents:r({}),tooltip:""})]})])]).render()},mediaButton:function(e){var t=this,i=jQuery.summernote.ui,n=nfRadio.channel("app").request("get:template","#tmpl-nf-rte-media-button");return i.button({className:"dropdown-toggle",contents:n({}),tooltip:nfi18n.fieldTextareaRTEInsertMedia,click:function(i){t.openMediaManager(i,e)}}).render()},openMediaManager:function(e,t){if(t.invoke("editor.saveRange"),this.meta_image_frame)this.meta_image_frame.open();else{this.meta_image_frame=wp.media.frames.meta_image_frame=wp.media({title:nfi18n.fieldTextareaRTESelectAFile,button:{text:"insert"}});var i=this;this.meta_image_frame.on("select",(function(){var e=i.meta_image_frame.state().get("selection").first().toJSON();i.insertMedia(e,t)})),this.meta_image_frame.open()}},clickLinkButton:function(e,t){var i=t.invoke("editor.createRange");t.invoke("editor.saveRange");var n=i.toString();this.currentContext=t,jQuery(e.target).closest(".note-customGroup > .note-btn-group").on("hide.bs.dropdown",(function(e){return!1})),jQuery(e.target).closest(".note-customGroup > .note-btn-group").on("shown.bs.dropdown",(function(e){jQuery(e.target).parent().parent().find(".link-text").val(n),jQuery(e.target).parent().parent().find(".link-url").focus()}))},clickExtra:function(e){var t=jQuery(e.target).parent().find(".link-text"),i=jQuery(e.target).parent().find(".link-url"),n=jQuery(e.target).parent().find(".link-new-window");if(this.currentContext.invoke("editor.restoreRange"),jQuery(e.target).hasClass("insert-link")){var r=t.val(),o=i.val(),a=!!n.prop("checked");0!=r.length&&0!=o.length&&this.currentContext.invoke("editor.createLink",{text:r,url:o,isNewWindow:a})}t.val(""),i.val(""),n.prop("checked",!1),jQuery(e.target).closest("div.note-btn-group.open").removeClass("open")},insertMedia:function(e,t){t.invoke("editor.restoreRange"),"image"==e.type?t.invoke("editor.insertImage",e.url):t.invoke("editor.createLink",{text:e.filename,url:e.url})}})})),i("controllers/fieldStarRating",[],(function(){return Marionette.Object.extend({initialize:function(){this.listenTo(nfRadio.channel("starrating"),"init:model",this.register),this.listenTo(nfRadio.channel("starrating"),"render:view",this.initRating)},register:function(e){e.set("renderRatings",this.renderRatings)},initRating:function(e){jQuery(e.el).find(".starrating").rating()},renderRatings:function(){for(var e=document.createElement("span"),t=0;t<=this.number_of_stars-1;t++){var i=nfRadio.channel("app").request("get:template","#tmpl-nf-field-starrating-star"),n=t+1,r="";this.value==n&&(r="checked");var o=i({id:this.id,classes:this.classes,num:n,checked:r,required:this.required});e.appendChild(document.createRange().createContextualFragment(o))}return e.innerHTML}})})),i("controllers/fieldTerms",[],(function(){return Marionette.Object.extend({initialize:function(){this.listenTo(nfRadio.channel("terms"),"init:model",this.register)},register:function(e){this.listenTo(nfRadio.channel("field-"+e.get("id")),"click:extra",this.clickExtra),this.listenTo(nfRadio.channel("field-"+e.get("id")),"keyup:field",this.keyUpExtra)},clickExtra:function(e,t){var i=jQuery(e.currentTarget).parent().find(".extra-value").val();this.addOption(t,i)},keyUpExtra:function(e,t,i){13==i&&this.addOption(t,e.val())},addOption:function(e,t){if(t){var i={label:t,value:t,selected:0};e.get("options").push(i),e.get("value").push(t),e.trigger("reRender")}}})})),i("controllers/formContentFilters",[],(function(){return Marionette.Object.extend({initialize:function(){this.viewFilters=[],this.loadFilters=[],nfRadio.channel("formContent").reply("add:viewFilter",this.addViewFilter,this),nfRadio.channel("formContent").reply("add:loadFilter",this.addLoadFilter,this),nfRadio.channel("formContent").reply("get:viewFilters",this.getViewFilters,this),nfRadio.channel("formContent").reply("get:loadFilters",this.getLoadFilters,this),nfRadio.channel("fieldContents").reply("add:viewFilter",this.addViewFilter,this),nfRadio.channel("fieldContents").reply("add:loadFilter",this.addLoadFilter,this),nfRadio.channel("fieldContents").reply("get:viewFilters",this.getViewFilters,this),nfRadio.channel("fieldContents").reply("get:loadFilters",this.getLoadFilters,this)},addViewFilter:function(e,t){this.viewFilters[t]=e},getViewFilters:function(){return this.viewFilters},addLoadFilter:function(e,t){this.loadFilters[t]=e},getLoadFilters:function(){return this.loadFilters}})})),i("views/fieldItem",[],(function(){return Marionette.ItemView.extend({tagName:"div",initialize:function(){this.listenTo(this.model,"reRender",this.render,this),this.listenTo(this.model,"change:addWrapperClass",this.addWrapperClass,this),this.listenTo(this.model,"change:removeWrapperClass",this.removeWrapperClass,this),this.listenTo(this.model,"change:invalid",this.toggleAriaInvalid,this),this.template="#tmpl-nf-field-"+this.model.get("wrap_template")},test:function(e){console.log("firing from trigger 1")},addWrapperClass:function(){var e=this.model.get("addWrapperClass");""!=e&&(jQuery(this.el).addClass(e),this.model.set("addWrapperClass",""))},removeWrapperClass:function(){var e=this.model.get("removeWrapperClass");""!=e&&(jQuery(this.el).removeClass(e),this.model.set("removeWrapperClass",""))},toggleAriaInvalid:function(){var e=this.model.get("invalid");jQuery("[aria-invalid]",this.el).attr("aria-invalid",JSON.stringify(e))},onRender:function(){if(this.$el=this.$el.children(),this.$el.unwrap(),this.setElement(this.$el),void 0!==this.model.get("mask")&&""!=String(this.model.get("mask")).trim()){if("custom"==this.model.get("mask"))var e=this.model.get("custom_mask");else e=this.model.get("mask");if(Number.isInteger=Number.isInteger||function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e},Number.isInteger(e)&&(e=e.toString()),"currency"==e){var t=nfRadio.channel("app").request("get:form",this.model.get("formID")),i=t.get("thousands_sep");"&nbsp;"!=i&&160!=i.charCodeAt(0)||(i=" ");var n=jQuery("<div/>").html(t.get("currencySymbol")).text(),r={digitGroupSeparator:i=jQuery("<div/>").html(i).text(),decimalCharacter:jQuery("<div/>").html(t.get("decimal_point")).text(),currencySymbol:n,modifyValueOnWheel:!1},o=jQuery(jQuery(this.el).find(".nf-element")[0]);new AutoNumeric(jQuery(this.el).find(".nf-element")[0],r);var a=this;o.on("change",(function(e){a.model.set("value",e.target.value)}))}else jQuery(this.el).find(".nf-element").mask(e)}nfRadio.channel(this.model.get("type")).trigger("render:view",this),nfRadio.channel("fields").trigger("render:view",this)},templateHelpers:function(){var e=this;return{renderElement:function(){this.clean&&!this.value&&0===this.default&&(this.value="0");var e=_.find(this.element_templates,(function(e){if(0<jQuery("#tmpl-nf-field-"+e).length)return!0}));return nfRadio.channel("app").request("get:template","#tmpl-nf-field-"+e)(this)},renderLabel:function(){return nfRadio.channel("app").request("get:template","#tmpl-nf-field-label")(this)},renderLabelClasses:function(){var e="";return void 0!==this.customLabelClasses&&(e=this.customLabelClasses(e)),e},renderPlaceholder:function(){var e=this.placeholder;return void 0!==this.customPlaceholder&&(e=this.customPlaceholder(e)),""!=String(e).trim()?'placeholder="'+_.escape(e)+'"':""},renderWrapClass:function(){var e="field-wrap "+this.type+"-wrap";return this.type!==this.parentType&&(e=e+" "+this.parentType+"-wrap"),void 0!==this.old_classname&&0<String(this.old_classname).trim().length&&(e+=" "+this.old_classname+"-wrap"),"undefined"!=typeof customWrapClass&&(e=customWrapClass(e)),e},renderClasses:function(){var e=this.classes;return this.error?e+=" nf-error":e=e.replace("nf-error",""),void 0!==this.element_class&&0<String(this.element_class).trim().length&&(e+=" "+this.element_class),void 0!==this.customClasses&&(e=this.customClasses(e)),e},maybeFilterHTML:function(){return void 0!==nfFrontEnd.filter_esc_status?nfFrontEnd.filter_esc_status:"false"},maybeDisabled:function(){return 1==this.disable_input?"disabled":""},maybeRequired:function(){return 1==this.required?'aria-required="true" required':""},maybeDisableAutocomplete:function(){if(1==this.disable_browser_autocomplete)return'autocomplete="off"';return'autocomplete="'+this.translateAutoCompletionType(this.type)+'"'},translateAutoCompletionType:function(e){switch(e){case"address":return"street-address";case"address2":return"address-line2";case"city":return"address-level2";case"email":return"email";case"firstname":return"given-name";case"lastname":return"family-name";case"zip":return"postal-code";case"phone":return"tel";default:return"on"}},maybeInputLimit:function(){return"characters"==this.input_limit_type&&""!=String(this.input_limit).trim()?'maxlength="'+this.input_limit+'"':""},getHelpText:function(){return void 0!==this.help_text?this.help_text:""},maybeRenderHelp:function(){var e=document.createElement("p");e.innerHTML=this.help_text;var t=!1;if((0!=String(jQuery(e).text()).trim().length||0<jQuery(e).find("img").length)&&(t=!0),void 0!==this.help_text&&t){var i=document.createElement("span");i.classList.add("fa","fa-info-circle","nf-help"),i.setAttribute("data-text",this.getHelpText()),i.setAttribute("tabindex","0"),i.setAttribute("aria-describedby","hidden-help-text-"+this.id);var n=document.createElement("span");return n.textContent=this.help_text.replace(/<\/?[^>]+(>|$)/g,"").trim(),n.id="hidden-help-text-"+this.id,n.classList.add("nf-sr-only"),n.setAttribute("role","tooltip"),i.appendChild(n),i.outerHTML}return""},renderDescText:function(){if(void 0===this.desc_text)return"";var e,t,i,n,r=document.createElement("p");return r.innerHTML=this.desc_text,0==String(r.innerText).trim().length?"":(t=document.createTextNode(this.desc_text),(e=document.createElement("p")).appendChild(t),0!=String(jQuery(e).text()).trim().length?(i=document.createRange().createContextualFragment(this.desc_text),(n=document.createElement("div")).classList.add("nf-field-description"),n.setAttribute("aria-hidden","true"),n.setAttribute("id","nf-description-"+this.id),n.appendChild(i),n.outerHTML):"")},renderNumberDefault:function(){return this.clean?0===this.default||this.default?this.default:this.placeholder?"":this.value:this.value},renderCurrencyFormatting:function(t){var i=t.toString().replace(".","||").replace(/\B(?=(\d{3})+(?!\d))/g,nfi18n.thousands_sep).replace("||",nfi18n.decimal_point);return nfRadio.channel("app").request("get:form",e.model.get("formID")).get("settings").currency_symbol+i},maybeRenderTime:function(){return"time_only"==this.date_mode||"date_and_time"==this.date_mode}}},events:{"change .nf-element":"fieldChange","keyup .nf-element":"fieldKeyup","click .nf-element":"fieldClick","click .extra":"extraClick","change .extra":"extraChange","blur .nf-element":"fieldBlur"},fieldChange:function(e){var t=jQuery(e.currentTarget);nfRadio.channel("nfAdmin").request("change:field",t,this.model)},fieldKeyup:function(e){var t=jQuery(e.currentTarget),i=e.keyCode;nfRadio.channel("field-"+this.model.get("id")).trigger("keyup:field",t,this.model,i),nfRadio.channel(this.model.get("type")).trigger("keyup:field",t,this.model,i),nfRadio.channel("fields").trigger("keyup:field",t,this.model,i)},fieldClick:function(e){var t=jQuery(e.currentTarget);nfRadio.channel("field-"+this.model.get("id")).trigger("click:field",t,this.model),nfRadio.channel(this.model.get("type")).trigger("click:field",t,this.model),nfRadio.channel("fields").trigger("click:field",t,this.model)},extraClick:function(e){nfRadio.channel("field-"+this.model.get("id")).trigger("click:extra",e,this.model),nfRadio.channel(this.model.get("type")).trigger("click:extra",e,this.model),nfRadio.channel("fields").trigger("click:extra",e,this.model)},extraChange:function(e){nfRadio.channel("field-"+this.model.get("id")).trigger("change:extra",e,this.model),nfRadio.channel(this.model.get("type")).trigger("change:extra",e,this.model),nfRadio.channel("fields").trigger("change:extra",e,this.model)},fieldBlur:function(e){var t=jQuery(e.currentTarget);nfRadio.channel("field-"+this.model.get("id")).trigger("blur:field",t,this.model),nfRadio.channel(this.model.get("type")).trigger("blur:field",t,this.model),nfRadio.channel("fields").trigger("blur:field",t,this.model)},onAttach:function(){nfRadio.channel(this.model.get("type")).trigger("attach:view",this)}})})),i("views/beforeField",[],(function(){return Marionette.ItemView.extend({tagName:"nf-section",template:"#tmpl-nf-field-before"})})),i("views/fieldErrorItem",[],(function(){return Marionette.ItemView.extend({tagName:"nf-section",template:"#tmpl-nf-field-error",onRender:function(){this.$el=this.$el.children(),this.$el.unwrap(),this.setElement(this.$el)}})})),i("views/fieldErrorCollection",["views/fieldErrorItem"],(function(e){return Marionette.CollectionView.extend({tagName:"nf-errors",childView:e,initialize:function(e){this.fieldModel=e.fieldModel},onRender:function(){0==this.fieldModel.get("errors").models.length?(this.fieldModel.removeWrapperClass("nf-error"),this.fieldModel.removeWrapperClass("nf-fail"),this.fieldModel.addWrapperClass("nf-pass"),this.fieldModel.setInvalid(!1)):(this.fieldModel.removeWrapperClass("nf-pass"),this.fieldModel.addWrapperClass("nf-fail"),this.fieldModel.addWrapperClass("nf-error"),this.fieldModel.setInvalid(!0))}})})),i("views/inputLimit",[],(function(){return Marionette.ItemView.extend({tagName:"nf-section",template:"#tmpl-nf-field-input-limit",initialize:function(){this.listenTo(nfRadio.channel("field-"+this.model.get("id")),"keyup:field",this.updateCount),this.count=this.model.get("input_limit"),this.render()},updateCount:function(e,t){var i=jQuery(e).val(),n=String(i).trim().replace(/\s+/gi," ").split(" "),r=n.length,o=i.length;if("characters"==this.model.get("input_limit_type")||"char"==this.model.get("input_limit_type"))jQuery(e).attr("maxlength",this.model.get("input_limit")),this.count=this.model.get("input_limit")-o;else{this.count=this.model.get("input_limit")-r;var a=this.model.get("input_limit");r>a&&jQuery(e).val(n.slice(0,a).join(" "))}this.render()},templateHelpers:function(){var e=this;return{currentCount:function(){return e.count}}}})})),i("views/afterField",["views/fieldErrorCollection","views/inputLimit"],(function(e,t){return Marionette.ItemView.extend({tagName:"nf-section",template:"#tmpl-nf-field-after",initialize:function(){this.model.on("change:errors",this.changeError,this)},onRender:function(){var i=jQuery(this.el).children(".nf-error-wrap");if(this.errorCollectionView=new e({el:i,collection:this.model.get("errors"),fieldModel:this.model}),0<this.model.get("errors").length&&this.errorCollectionView.render(),void 0!==this.model.get("input_limit")&&""!=String(this.model.get("input_limit")).trim()){var n=jQuery(this.el).children(".nf-input-limit");this.inputLimitView=new t({el:n,model:this.model}),n.attr("aria-live","polite"),n.attr("role","status"),n.attr("aria-relevant","additions"),n.attr("aria-atomic",!0)}},changeError:function(){this.errorCollectionView.render()}})})),i("views/fieldRepeaterFieldLayout",["views/fieldItem","views/beforeField","views/afterField"],(function(e,t,i){return Marionette.LayoutView.extend({tagName:"nf-field",regions:{beforeField:".nf-before-field",field:".nf-field",afterField:".nf-after-field"},initialize:function(){this.listenTo(this.model,"change:visible",this.render,this)},getTemplate:function(){return this.model.get("visible")?"#tmpl-nf-field-layout":"#tmpl-nf-empty"},onRender:function(){this.model.get("visible")&&(this.beforeField.show(new t({model:this.model})),this.field.show(new e({model:this.model})),this.afterField.show(new i({model:this.model})))},templateHelpers:function(){return{renderContainerClass:function(){var e=" label-"+this.label_pos+" ";return void 0!==this.desc_pos&&(e+="desc-"+this.desc_pos+" "),void 0!==this.container_class&&0<String(this.container_class).trim().length&&(e+=this.container_class+" "),this.type!==this.parentType&&(e+=" "+this.parentType+"-container"),e}}}})})),i("views/fieldRepeaterFieldCollection",["views/fieldRepeaterFieldLayout"],(function(e){return Marionette.CollectionView.extend({tagName:"nf-fields-wrap",childView:e})})),i("views/fieldRepeaterSetLayout",["views/fieldRepeaterFieldCollection"],(function(e){return Marionette.LayoutView.extend({tagName:"fieldset",template:"#tmpl-nf-field-repeater-set",regions:{fields:".nf-repeater-fieldset"},onRender:function(){this.fields.show(new e({collection:this.model.get("fields")}))},templateHelpers:function(){return{maybeFilterHTML:function(){return void 0!==nfFrontEnd.filter_esc_status?nfFrontEnd.filter_esc_status:"false"}}},events:{"click .nf-remove-fieldset":"removeSet"},removeSet:function(){nfRadio.channel("field-repeater").trigger("remove:fieldset",this.model)}})})),i("views/fieldRepeaterSetCollection",["views/fieldRepeaterSetLayout"],(function(e){return Marionette.CollectionView.extend({tagName:"div",childView:e})})),i("views/fieldRepeaterLayout",["views/fieldRepeaterSetCollection"],(function(e){return Marionette.LayoutView.extend({tagName:"div",template:"#tmpl-nf-field-repeater",regions:{sets:".nf-repeater-fieldsets"},initialize:function(){this.collection=this.model.get("sets"),this.listenTo(nfRadio.channel("field-repeater"),"rerender:fieldsets",this.render)},onRender:function(){this.sets.show(new e({collection:this.collection}))},templateHelpers:function(){return{maybeFilterHTML:function(){return void 0!==nfFrontEnd.filter_esc_status?nfFrontEnd.filter_esc_status:"false"},renderDescText:function(){if(void 0===this.desc_text)return"";var e,t,i,n,r=document.createElement("p");return r.innerHTML=this.desc_text,0==String(r.innerText).trim().length?"":(t=document.createTextNode(this.desc_text),(e=document.createElement("p")).appendChild(t),0!=String(jQuery(e).text()).trim().length?(i=document.createRange().createContextualFragment(this.desc_text),(n=document.createElement("div")).classList.add("nf-field-description"),n.appendChild(i),n.outerHTML):"")}}},events:{"click .nf-add-fieldset":"addSet"},addSet:function(){nfRadio.channel("field-repeater").trigger("add:fieldset",this.model.id)},beforeSubmit:function(){this.collection.beforeSubmit(this.model.get("sets"))}})})),i("views/fieldLayout",["views/fieldItem","views/beforeField","views/afterField","views/fieldRepeaterLayout"],(function(e,t,i,n){return Marionette.LayoutView.extend({tagName:"nf-field",regions:{beforeField:".nf-before-field",field:".nf-field",afterField:".nf-after-field"},initialize:function(){this.listenTo(this.model,"change:visible",this.render,this)},getTemplate:function(){return this.model.get("visible")?"#tmpl-nf-field-layout":"#tmpl-nf-empty"},onRender:function(){this.model.get("visible")&&("repeater"==this.model.get("type")?this.field.show(new n({model:this.model})):(this.beforeField.show(new t({model:this.model})),this.field.show(new e({model:this.model})),this.afterField.show(new i({model:this.model}))))},templateHelpers:function(){return{renderContainerClass:function(){var e=" label-"+this.label_pos+" ";return void 0!==this.desc_pos&&(e+="desc-"+this.desc_pos+" "),void 0!==this.container_class&&0<String(this.container_class).trim().length&&(e+=this.container_class+" "),this.type!==this.parentType&&(e+=" "+this.parentType+"-container"),e}}}})})),i("controllers/loadViews",["views/fieldItem","views/fieldLayout"],(function(e,t){return Marionette.Object.extend({initialize:function(){nfRadio.channel("views").reply("get:fieldItem",this.getFieldItem),nfRadio.channel("views").reply("get:fieldLayout",this.getFieldLayout)},getFieldItem:function(t){return e},getFieldLayout:function(){return t}})})),i("controllers/formErrors",[],(function(){return Marionette.Object.extend({initialize:function(){this.listenTo(nfRadio.channel("fields"),"add:error",this.addError),this.listenTo(nfRadio.channel("fields"),"remove:error",this.removeError),nfRadio.channel("form").reply("get:errors",this.getFormErrors)},addError:function(e,t,i){var n=nfRadio.channel("app").request("get:form",e.get("formID"));void 0===n.get("fieldErrors")[e.get("id")]&&(n.get("fieldErrors")[e.get("id")]={}),n.get("fieldErrors")[e.get("id")][t]=i,nfRadio.channel("form-"+e.get("formID")).request("add:error","field-errors",n.get("settings").formErrorsCorrectErrors)},removeError:function(e,t){var i=nfRadio.channel("app").request("get:form",e.get("formID"));i.get("fieldErrors")[e.get("id")]=_.omit(i.get("fieldErrors")[e.get("id")],t),0==_.size(i.get("fieldErrors")[e.get("id")])&&delete i.get("fieldErrors")[e.get("id")],0==_.size(i.get("fieldErrors"))&&nfRadio.channel("form-"+e.get("formID")).request("remove:error","field-errors")},getFormErrors:function(e){var t=nfRadio.channel("app").request("get:form",e),i=!1;return t&&0!==t.get("errors").length&&_.each(t.get("errors").models,(function(e){(i=i||{})[e.get("id")]=e.get("msg")})),i}})})),i("controllers/submit",[],(function(){return Marionette.Object.extend({initialize:function(){this.listenTo(nfRadio.channel("forms"),"init:model",this.registerSubmitHandler)},registerSubmitHandler:function(e){nfRadio.channel("form-"+e.get("id")).reply("submit",this.submit)},submit:function(e){nfRadio.channel("forms").trigger("before:submit",e),nfRadio.channel("form-"+e.get("id")).trigger("before:submit",e);var t=nfRadio.channel("forms").request("maybe:validate",e);if(!1!==t&&(_.each(e.get("fields").models,(function(e){e.set("clean",!1)})),e.get("formContentData").validateFields()),0==nfRadio.channel("form-"+e.get("id")).request("maybe:submit",e))return nfRadio.channel("forms").trigger("submit:cancel",e),void nfRadio.channel("form-"+e.get("id")).trigger("submit:cancel",e);if(!1!==t){var i=_.filter(e.get("errors").models,(function(e){return"invalid_email"!=e.get("id")&&"email_not_sent"!=e.get("id")}));if(0!=_.size(i))return nfRadio.channel("forms").trigger("submit:failed",e),nfRadio.channel("form-"+e.get("id")).trigger("submit:failed",e),!1}nfRadio.channel("forms").trigger("after:submitValidation",e),nfRadio.channel("form-"+e.get("id")).trigger("after:submitValidation",e);var n=e.get("id"),r={};_.each(e.get("fields").models,(function(e){var t={value:e.get("value"),id:e.get("id")};r[e.get("id")]=nfRadio.channel(e.get("type")).request("get:submitData",t,e)||t}));var o=e.get("extra"),a=e.get("settings");delete a.formContentData;var l=JSON.stringify({id:n,fields:r,settings:a,extra:o}),s={action:"nf_ajax_submit",security:nfFrontEnd.ajaxNonce,nonce_ts:nfFrontEnd.nonce_ts,formData:l};jQuery.ajax({url:nfFrontEnd.adminAjax,type:"POST",data:s,cache:!1,success:function(t,i,n){try{var r=t;nfRadio.channel("forms").trigger("submit:response",r,i,n,e.get("id")),nfRadio.channel("form-"+e.get("id")).trigger("submit:response",r,i,n),jQuery(document).trigger("nfFormSubmitResponse",{response:r,id:e.get("id")})}catch(e){console.log(e),console.log("Parse Error"),console.log(e)}},error:function(t,i,n){console.log("ERRORS: "+n),console.log(t);try{var r=jQuery.parseJSON(t.responseText);nfRadio.channel("forms").trigger("submit:response",r,i,t,e.get("id")),nfRadio.channel("form-"+e.get("id")).trigger("submit:response",r,i,t)}catch(i){console.log("Parse Error: "+t.responseText),nfRadio.channel("form-"+e.get("id")).request("add:error","parse-response-ERROR",n)}}})}})})),i("views/fieldCollection",["views/fieldLayout"],(function(e){return Marionette.CollectionView.extend({tagName:"nf-fields-wrap",childView:e})})),i("controllers/defaultFilters",["views/fieldCollection","models/fieldCollection"],(function(e,t){return Marionette.Object.extend({initialize:function(){this.listenTo(nfRadio.channel("form"),"before:filterData",this.registerDefaultDataFilter)},registerDefaultDataFilter:function(e){nfRadio.channel("formContent").request("add:loadFilter",this.defaultFormContentLoad,10,this),nfRadio.channel("formContent").request("add:viewFilter",this.defaultFormContentView,10,this)},defaultFormContentLoad:function(e,i,n){var r=i.get("fields"),o=nfRadio.channel("formContent").request("get:loadFilters");if(1==_.without(o,void 0).length||void 0===e||!0==e instanceof Backbone.Collection)return i.get("fields");var a=_.map(e,(function(e){return i.get("fields").findWhere({key:e})}),this),l=new t(a);return r.on("reset",(function(e){var t=[];l.each((function(i){"submit"!=i.get("type")?t.push(e.findWhere({key:i.get("key")})):t.push(i)})),l.options={formModel:i},l.reset(t)})),l},defaultFormContentView:function(){return e}})})),i("controllers/uniqueFieldError",[],(function(){return Marionette.Object.extend({initialize:function(){this.listenTo(nfRadio.channel("fields"),"change:modelValue",this.removeError),this.listenTo(nfRadio.channel("fields"),"keyup:field",this.removeError),this.listenTo(nfRadio.channel("fields"),"blur:field",this.removeError)},removeError:function(e,t){t=t||e,nfRadio.channel("fields").request("remove:error",t.get("id"),"unique_field")}})}));let n=[];i("models/fieldRepeaterSetModel",[],(function(){return Backbone.Model.extend({initialize:function(e,t){this.repeaterFieldModel=t.repeaterFieldModel,this.set("label",this.repeaterFieldModel.get("label")),e&&t&&this.initAllRepeaterFieldsModels(e,t),nfRadio.channel("field-repeater").reply("get:repeaterFields",this.getRepeaterFields,this),nfRadio.channel("field-repeater").reply("get:repeaterFieldById",this.getRepeaterFieldById,this),nfRadio.channel("field-repeater").reply("get:repeaterModels",this.getAllRepeaterFieldsModels,this),nfRadio.channel("field-repeater").reply("get:repeaterFieldsetsByForm",this.getAllFieldsetsByForm,this),nfRadio.channel("field-repeater").reply("get:repeaterFieldsModelsArrayByForm",this.getAllFieldsModelsArrayByForm,this),this.listenTo(nfRadio.channel("field-repeater"),"set:repeaterModels",this.setAllRepeaterFieldsModels),this.listenTo(nfRadio.channel("field-repeater"),"set:value",this.setAllRepeatersValues)},setAllRepeaterFieldsModels:function(){this.set("repeaterFieldsetsModels",n),this.allRepeatersFieldsetsModels=n},initAllRepeaterFieldsModels:function(e,t){const i=t.repeaterFieldModel.get("formID"),r=t.repeaterFieldModel.get("id"),o=e.fields.models;let a=n.find((e=>e.id===r&&e.form===i));a?a.fields=a.fields.concat(o):n.push({form:i,id:r,fields:o}),this.setAllRepeaterFieldsModels()},getAllRepeaterFieldsModels:function(){return n},getAllFieldsetsByForm:function(e){const t=this.getAllRepeaterFieldsModels().filter((t=>t.form===e));return t},getAllFieldsModelsArrayByForm:function(e){const t=this.getAllFieldsetsByForm(e);let i=[];return t.map((e=>{i=i.concat(e.fields)})),i},getRepeaterFields:function(e){const t=this.getAllRepeaterFieldsModels();let i=t.find((t=>String(t.id)===String(e)));return void 0===i&&(i=this.reverseResearchFieldsetModel(e,t)),i},reverseResearchFieldsetModel:function(e,t){let i;return _.each(t,(function(t){_.each(t.fields,(function(n){String(n.id).startsWith(e)&&(i=t)}))})),i},getRepeaterFieldById:function(e){const t=String(e).split(".")[0],i=this.getRepeaterFields(t);if(void 0===i)return;return i.fields.find((t=>t.id===e))},setAllRepeatersValues:function(){const e=this.getAllRepeaterFieldsModels();e.length>0&&_.each(e,(function(e){let t=e.fields,i=nfRadio.channel("fields").request("get:field",e.id);if(t.length>0){let e={};_.each(t,(function(t){let i=t.get("value"),n=t.get("id");if(n.split("_").length>2){let t=n.split("_");t[1]=t[1].split(".")[1];let i=t[0]+"."+t[1]+"_"+t[2];delete e[n],n=i}e[n]={value:i,id:n},"file_upload"===t.get("type")&&t.get("value")&&(e[n].files=t.attributes.files)})),i.set("isUpdated",!1),nfRadio.channel("nfAdmin").request("update:field",i,e)}}))}})})),i("models/fieldRepeaterSetCollection",["models/fieldRepeaterSetModel","models/fieldCollection"],(function(e,t){return Backbone.Collection.extend({model:e,initialize:function(e,t){this.options=t,this.listenTo(nfRadio.channel("field-repeater"),"sort:fieldsets",this.sortIDs),this.listenTo(nfRadio.channel("field-repeater"),"remove:fieldset",this.removeSet),this.listenTo(nfRadio.channel("field-repeater"),"add:fieldset",this.addSet),nfRadio.channel("field-repeater").reply("get:fieldsets",this.getFieldSets,this)},addSet:function(e=!1){if(e){const i=this.options.repeaterFieldModel.id===e&&this.options.repeaterFieldModel;if(i){let e=new t(this.options.templateFields,{formModel:this.options.formModel,repeaterFieldModel:i});this.add({fields:e},{repeaterFieldModel:i})}}this.sortIDs()},removeSet:function(e){this.removeRequiredFieldsErrors(e);const t=e.repeaterFieldModel.get("formID"),i=e.repeaterFieldModel.get("id"),r=n.find((e=>e.id===i&&e.form===t));r&&(_.each(r.fields,((t,i)=>{void 0!==t&&_.each(e.get("fields").models,(e=>{const n=void 0!==t.id?t.id:t.get("id");e.id===n&&r.fields.splice(i,1)}))})),nfRadio.channel("field-repeater").trigger("set:repeaterModels")),this.remove(e),e.destroy(),this.sortIDs(),nfRadio.channel("field-repeater").trigger("set:value")},removeRequiredFieldsErrors:function(e){let t=e.get("fields");_.each(t.models,(function(e){nfRadio.channel("fields").request("remove:error",e.get("id"),"required-error")}))},getFieldsets:function(){return this.models},sortIDs:function(){const e=this.getFieldsets();_.each(e,(function(e,t){let i=e.get("fields");e.set("index",t+1),_.each(i.models,(function(e){const i=String(e.id).split("_")[0],n=String(i).split(".").length>1&&String(i).split(".").pop();if(!n)return;const r=e.collection.options.repeaterFieldModel.id+"."+n+"_"+t;e.set("id",r)}))})),nfRadio.channel("field-repeater").trigger("rerender:fieldsets")}})})),i("controllers/fieldRepeater",["models/fieldRepeaterSetCollection","models/fieldCollection"],(function(e,t){return Marionette.Object.extend({initialize:function(){this.listenTo(nfRadio.channel("repeater"),"init:model",this.initRepeater)},initRepeater:function(i){if(void 0===i.collection.options.formModel)return!1;let n=new t(i.get("fields"),{formModel:i.collection.options.formModel,repeaterFieldModel:i});i.set("sets",new e([{fields:n}],{templateFields:i.get("fields"),formModel:i.collection.options.formModel,repeaterFieldModel:i})),nfRadio.channel("field-repeater").trigger("sort:fieldsets")}})})),i("controllers/loadControllers",["controllers/formData","controllers/fieldError","controllers/changeField","controllers/changeEmail","controllers/changeDate","controllers/fieldCheckbox","controllers/fieldCheckboxList","controllers/fieldImageList","controllers/fieldRadio","controllers/fieldNumber","controllers/mirrorField","controllers/confirmField","controllers/updateFieldModel","controllers/submitButton","controllers/submitDebug","controllers/getFormErrors","controllers/validateRequired","controllers/submitError","controllers/actionRedirect","controllers/actionSuccess","controllers/fieldSelect","controllers/coreSubmitResponse","controllers/fieldProduct","controllers/fieldTotal","controllers/fieldQuantity","controllers/calculations","controllers/dateBackwardsCompat","controllers/fieldDate","controllers/fieldRecaptcha","controllers/fieldRecaptchaV3","controllers/fieldHTML","controllers/helpText","controllers/fieldTextbox","controllers/fieldTextareaRTE","controllers/fieldStarRating","controllers/fieldTerms","controllers/formContentFilters","controllers/loadViews","controllers/formErrors","controllers/submit","controllers/defaultFilters","controllers/uniqueFieldError","controllers/fieldRepeater"],(function(e,t,i,n,r,o,a,l,s,d,c,f,u,h,m,g,p,v,y,b,R,_,w,F,x,M,C,k,T,E,j,q,D,V,O,I,Q,S,L,A,N,z,B){return Marionette.Object.extend({initialize:function(){new S,new L,new A,new o,new a,new l,new s,new d,new R,new w,new F,new x,new T,new E,new j,new q,new D,new V,new O,new I,new Q,new z,new B,new t,new i,new n,new r,new c,new f,new u,new h,new m,new g,new p,new v,new y,new b,new _,new M,new N,new C,new k,new e}})})),i("views/beforeForm",[],(function(){return Marionette.ItemView.extend({tagName:"nf-section",template:"#tmpl-nf-before-form"})})),i("views/formErrorItem",[],(function(){return Marionette.ItemView.extend({tagName:"nf-section",template:"#tmpl-nf-form-error",onRender:function(){}})})),i("views/formErrorCollection",["views/formErrorItem"],(function(e){return Marionette.CollectionView.extend({tagName:"nf-errors",childView:e})})),i("views/honeyPot",[],(function(){return Marionette.ItemView.extend({tagName:"nf-section",template:"#tmpl-nf-form-hp",events:{"keyup .nf-field-hp":"maybeError","change .nf-field-hp":"maybeError"},maybeError:function(e){if(0==jQuery(e.target).val().length)nfRadio.channel("form-"+this.model.get("id")).request("remove:error","honeyPot");else{var t=nfRadio.channel("app").request("get:form",this.model.get("id"));nfRadio.channel("form-"+this.model.get("id")).request("add:error","honeyPot",t.get("settings").honeypotHoneypotError)}}})})),i("views/afterFormContent",["views/formErrorCollection","views/honeyPot"],(function(e,t){return Marionette.LayoutView.extend({tagName:"nf-section",template:"#tmpl-nf-after-fields",regions:{errors:".nf-form-errors",hp:".nf-form-hp"},onShow:function(){this.errors.show(new e({collection:this.model.get("errors")})),this.hp.show(new t({model:this.model}))}})})),i("views/beforeFormContent",[],(function(){return Marionette.ItemView.extend({tagName:"nf-section",template:"#tmpl-nf-before-fields",templateHelpers:function(){return{renderFieldsMarkedRequired:function(){return this.fields.filter({required:1}).length?this.fieldsMarkedRequired:""}}}})})),i("views/formLayout",["views/afterFormContent","views/beforeFormContent","models/fieldCollection"],(function(e,t,i){return Marionette.LayoutView.extend({tagName:"nf-section",template:"#tmpl-nf-form-layout",regions:{beforeFormContent:".nf-before-form-content",formContent:".nf-form-content",afterFormContent:".nf-after-form-content"},initialize:function(){nfRadio.channel("form-"+this.model.get("id")).reply("get:el",this.getEl,this),this.listenTo(this.model,"hide",this.hide)},onRender:function(){this.$el=this.$el.children(),this.$el.unwrap(),this.setElement(this.$el)},onShow:function(){this.beforeFormContent.show(new t({model:this.model}));var i=this.model.get("formContentData"),n=nfRadio.channel("formContent").request("get:viewFilters"),r=_.without(n,void 0),o=_.first(r);formContentView=o();var a={data:i,formModel:this.model};!1!=i instanceof Backbone.Collection?a.collection=i:!1!=i instanceof Backbone.Model&&(a.model=i),this.formContent.show(new formContentView(a)),this.afterFormContent.show(new e({model:this.model}))},getEl:function(){return this.el},templateHelpers:function(){return{renderClasses:function(){return""}}},hide:function(){jQuery(this.el).hide()}})})),i("views/afterForm",[],(function(){return Marionette.ItemView.extend({tagName:"nf-section",template:"#tmpl-nf-after-form"})})),i("views/mainLayout",["views/beforeForm","views/formLayout","views/afterForm"],(function(e,t,i){return Marionette.LayoutView.extend({template:"#tmpl-nf-layout",regions:{responseMsg:".nf-response-msg",beforeForm:".nf-before-form",formLayout:".nf-form-layout",afterForm:".nf-after-form"},initialize:function(){this.$el=jQuery("#nf-form-"+this.model.id+"-cont"),this.el="#nf-form-"+this.model.id+"-cont",this.render(),this.beforeForm.show(new e({model:this.model})),this.formLayout.show(new t({model:this.model,fieldCollection:this.options.fieldCollection})),this.afterForm.show(new i({model:this.model})),this.listenTo(this.model,"hide",this.hide)},hide:function(){jQuery(this.el).find(".nf-form-title").hide()}})}));var r=function(e,t,i){void 0!==e&&0<e.length?this.locale=e.split("_").join("-"):this.locale="en-US",this.thousands_sep=t||",",this.decimal_sep=i||".",this.uniqueElememts=function(e,t,i){return i.indexOf(e)===t},this.numberDecoder=function(e){var t="",i=!1;"-"===(e=e.toString()).charAt(0)&&(i=!0,e=e.replace("-",""));var n=(e=(e=e.replace(/\s/g,"")).replace(/&nbsp;/g,"")).split("").filter((function(e){return!e.match(/[0-9]/)})),r=n.filter(this.uniqueElememts);switch(r.length){case 0:t=e;break;case 1:var o="";if(1==n.length)separator=n.pop(),o=3==e.split(separator).pop().length&&separator==this.thousands_sep?"":".";else separator=r.pop();t=e.split(separator).join(o);break;case 2:var a,l=r[0];a="."===l?new RegExp("[.]","g"):new RegExp(l,"g"),t=e.replace(a,"");var s,d=r[1];s="."===d?new RegExp("[.]","g"):new RegExp(d,"g"),t=t.replace(s,".");break;default:return"NaN"}return i&&(t="-"+t),this.debug("Number Decoder "+e+" -> "+t),t},this.numberEncoder=function(e,t){return e=this.numberDecoder(e),Intl.NumberFormat(this.locale,{minimumFractionDigits:t,maximumFractionDigits:t}).format(e)},this.debug=function(e){window.nfLocaleConverterDebug&&console.log(e)}};i("../nfLocaleConverter",(function(){})),void 0!==nfInlineVars.nfForms&&(window.nfForms=nfInlineVars.nfForms),function(e){var t=e.fn.val;e.fn.val=function(){var i;arguments.length>0&&(i=t.apply(this,[]));var n=t.apply(this,arguments);return arguments.length>0&&i!=t.apply(this,[])&&e(this).hasClass("nf-element")&&e(this).change(),n}}(jQuery),document.addEventListener("DOMContentLoaded",(function(){t(["models/formCollection","models/formModel","models/fieldCollection","controllers/loadControllers","views/mainLayout","../nfLocaleConverter"],(function(e,t,i,n,o){if("undefined"!=typeof nfForms){var a=Marionette.Application.extend({forms:{},initialize:function(e){var t=this;Marionette.Renderer.render=function(e,i){return(e=t.template(e))(i)},this.urlParameters=_.object(_.compact(_.map(location.search.slice(1).split("&"),(function(e){if(e)return e.split("=")})))),void 0!==this.urlParameters.nf_resume&&this.listenTo(nfRadio.channel("form-"+this.urlParameters.nf_resume),"loaded",this.restart),nfRadio.channel("app").reply("locale:decodeNumber",this.decodeNumber),nfRadio.channel("app").reply("locale:encodeNumber",this.encodeNumber);new n;nfRadio.channel("app").trigger("after:loadControllers"),nfRadio.channel("app").reply("get:template",this.template)},onStart:function(){var e=nfRadio.channel("app").request("get:forms");_.each(e.models,(function(e,t){var i=new o({model:e,fieldCollection:e.get("fields")});nfRadio.channel("form").trigger("render:view",i),jQuery(document).trigger("nfFormReady",i)}))},restart:function(e){if(void 0!==this.urlParameters.nf_resume){var t={action:"nf_ajax_submit",security:nfFrontEnd.ajaxNonce,nf_resume:this.urlParameters};nfRadio.channel("form-"+e.get("id")).trigger("disable:submit"),nfRadio.channel("form-"+e.get("id")).trigger("processingLabel"),this.listenTo(nfRadio.channel("form"),"render:view",(function(){jQuery("#nf-form-"+e.get("id")+"-cont .nf-field-container:not(.submit-container)").hide()})),jQuery.ajax({url:nfFrontEnd.adminAjax,type:"POST",data:t,cache:!1,success:function(t,i,n){try{var r=t;nfRadio.channel("forms").trigger("submit:response",r,i,n,e.get("id")),nfRadio.channel("form-"+e.get("id")).trigger("submit:response",r,i,n)}catch(e){console.log("Parse Error")}},error:function(e,t,i){console.log("ERRORS: "+t),nfRadio.channel("forms").trigger("submit:response","error",t,e,i)}})}},template:function(e){return _.template(jQuery(e).html(),{evaluate:/<#([\s\S]+?)#>/g,interpolate:/\{\{\{([\s\S]+?)\}\}\}/g,escape:/\{\{([^\}]+?)\}\}(?!\})/g,variable:"data"})},encodeNumber:function(e){return new r(nfi18n.siteLocale,nfi18n.thousands_sep,nfi18n.decimal_point).numberEncoder(e)},decodeNumber:function(e){return new r(nfi18n.siteLocale,nfi18n.thousands_sep,nfi18n.decimal_point).numberDecoder(e)}});(new a).start()}else jQuery(".nf-form-cont").empty()}))})),i("main",(function(){}))}();