if ( !document.IncludedFiles ) document.IncludedFiles = [];
document.IncludedFiles['https://www.nelson-naturally.co.nz/process/x_g/68WC4F1u%2dQkvTkMyb/mv_display/zest_controller.js'] = 1;
//Included: logic/javascript/zest_controller.js
// Check browser compatibility
var BrowserTest = (function() {
	
	/**
	 * constructor - set up css, private variables etc
	 * @param {String} CSS selector, or DOM element for the wrapper element (containing the form elements to validate)
	 * @param {Object} options.noStyle - don't load any CSS styles
	 */
	var BrowserTest = function() {}

	/**
	 * public methods
	 */
	BrowserTest.prototype = {

		/**
		 * Checks if one or more predefined tests pass & returns the result
		 * @param {String} tests a space separated list of tests to perform
		 * @returns {Boolean} did all tests pass
		 */
		supports: function(tests) {
			var tests = tests.split(/\s+/);
			for (var i=0; i < tests.length; i++) {
				if (!execute(tests[i])) {
					return false;
				}
			}
			return true;
		}
	}

	/**
	 * private methods
	 */
	var execute = function(test) {

		// supported tests
		var tests = {
			'es6': function() {
				var browserTest = null;
				try {
					eval('class BrowserTest {constructor() {}}browserTest = new BrowserTest();');
				} catch(error) {}
				return browserTest != null;
			},
			'grids': function() {
				return tests.es6();
			}
		}
		return tests[ test ]();
	}

	return BrowserTest;
})();
if (!(new BrowserTest()).supports('es6 grids')) {
	// promise polyfill
	!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n():"function"==typeof define&&define.amd?define(n):n()}(0,function(){"use strict";function e(e){var n=this.constructor;return this.then(function(t){return n.resolve(e()).then(function(){return t})},function(t){return n.resolve(e()).then(function(){return n.reject(t)})})}function n(){}function t(e){if(!(this instanceof t))throw new TypeError("Promises must be constructed via new");if("function"!=typeof e)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=undefined,this._deferreds=[],u(e,this)}function o(e,n){for(;3===e._state;)e=e._value;0!==e._state?(e._handled=!0,t._immediateFn(function(){var t=1===e._state?n.onFulfilled:n.onRejected;if(null!==t){var o;try{o=t(e._value)}catch(f){return void i(n.promise,f)}r(n.promise,o)}else(1===e._state?r:i)(n.promise,e._value)})):e._deferreds.push(n)}function r(e,n){try{if(n===e)throw new TypeError("A promise cannot be resolved with itself.");if(n&&("object"==typeof n||"function"==typeof n)){var o=n.then;if(n instanceof t)return e._state=3,e._value=n,void f(e);if("function"==typeof o)return void u(function(e,n){return function(){e.apply(n,arguments)}}(o,n),e)}e._state=1,e._value=n,f(e)}catch(r){i(e,r)}}function i(e,n){e._state=2,e._value=n,f(e)}function f(e){2===e._state&&0===e._deferreds.length&&t._immediateFn(function(){e._handled||t._unhandledRejectionFn(e._value)});for(var n=0,r=e._deferreds.length;r>n;n++)o(e,e._deferreds[n]);e._deferreds=null}function u(e,n){var t=!1;try{e(function(e){t||(t=!0,r(n,e))},function(e){t||(t=!0,i(n,e))})}catch(o){if(t)return;t=!0,i(n,o)}}var c=setTimeout;t.prototype["catch"]=function(e){return this.then(null,e)},t.prototype.then=function(e,t){var r=new this.constructor(n);return o(this,new function(e,n,t){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof n?n:null,this.promise=t}(e,t,r)),r},t.prototype["finally"]=e,t.all=function(e){return new t(function(n,t){function o(e,f){try{if(f&&("object"==typeof f||"function"==typeof f)){var u=f.then;if("function"==typeof u)return void u.call(f,function(n){o(e,n)},t)}r[e]=f,0==--i&&n(r)}catch(c){t(c)}}if(!e||"undefined"==typeof e.length)throw new TypeError("Promise.all accepts an array");var r=Array.prototype.slice.call(e);if(0===r.length)return n([]);for(var i=r.length,f=0;r.length>f;f++)o(f,r[f])})},t.resolve=function(e){return e&&"object"==typeof e&&e.constructor===t?e:new t(function(n){n(e)})},t.reject=function(e){return new t(function(n,t){t(e)})},t.race=function(e){return new t(function(n,t){for(var o=0,r=e.length;r>o;o++)e[o].then(n,t)})},t._immediateFn="function"==typeof setImmediate&&function(e){setImmediate(e)}||function(e){c(e,0)},t._unhandledRejectionFn=function(e){void 0!==console&&console&&console.warn("Possible Unhandled Promise Rejection:",e)};var l=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw Error("unable to locate global object")}();"Promise"in l?l.Promise.prototype["finally"]||(l.Promise.prototype["finally"]=e):l.Promise=t});

	/*! atomicjs v4.4.0 | (c) 2019 Chris Ferdinandi | MIT License | https://github.com/cferdinandi/atomic */
	// use polyfills if older version of browsers (e.g. IE)
	!(function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.ES6Promise=e()})(this,(function(){"use strict";function t(t){return"function"==typeof t}var e=Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)},n=0,r=void 0,o=void 0,i=function(t,e){h[n]=t,h[n+1]=e,2===(n+=2)&&(o?o(p):m())};var s="undefined"!=typeof window?window:void 0,u=s||{},a=u.MutationObserver||u.WebKitMutationObserver,c="undefined"==typeof self&&"undefined"!=typeof process&&"[object process]"==={}.toString.call(process),f="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel;function l(){var t=setTimeout;return function(){return t(p,1)}}var h=new Array(1e3);function p(){for(var t=0;t<n;t+=2){(0,h[t])(h[t+1]),h[t]=void 0,h[t+1]=void 0}n=0}var d,v,y,_,m=void 0;function w(t,e){var n=this,r=new this.constructor(A);void 0===r[g]&&J(r);var o=n._state;if(o){var s=arguments[o-1];i((function(){return N(o,r,s,n._result)}))}else R(n,r,t,e);return r}function b(t){if(t&&"object"==typeof t&&t.constructor===this)return t;var e=new this(A);return P(e,t),e}c?m=function(){return process.nextTick(p)}:a?(v=0,y=new a(p),_=document.createTextNode(""),y.observe(_,{characterData:!0}),m=function(){_.data=v=++v%2}):f?((d=new MessageChannel).port1.onmessage=p,m=function(){return d.port2.postMessage(0)}):m=void 0===s&&"function"==typeof require?(function(){try{var t=Function("return this")().require("vertx");return void 0!==(r=t.runOnLoop||t.runOnContext)?function(){r(p)}:l()}catch(t){return l()}})():l();var g=Math.random().toString(36).substring(2);function A(){}var T=void 0,j=1,x=2,S={error:null};function O(t){try{return t.then}catch(t){return S.error=t,S}}function C(e,n,r){n.constructor===e.constructor&&r===w&&n.constructor.resolve===b?(function(t,e){e._state===j?M(t,e._result):e._state===x?q(t,e._result):R(e,void 0,(function(e){return P(t,e)}),(function(e){return q(t,e)}))})(e,n):r===S?(q(e,S.error),S.error=null):void 0===r?M(e,n):t(r)?(function(t,e,n){i((function(t){var r=!1,o=(function(t,e,n,r){try{t.call(e,n,r)}catch(t){return t}})(n,e,(function(n){r||(r=!0,e!==n?P(t,n):M(t,n))}),(function(e){r||(r=!0,q(t,e))}),t._label);!r&&o&&(r=!0,q(t,o))}),t)})(e,n,r):M(e,n)}function P(t,e){var n,r;t===e?q(t,new TypeError("You cannot resolve a promise with itself")):(r=typeof(n=e),null===n||"object"!==r&&"function"!==r?M(t,e):C(t,e,O(e)))}function E(t){t._onerror&&t._onerror(t._result),F(t)}function M(t,e){t._state===T&&(t._result=e,t._state=j,0!==t._subscribers.length&&i(F,t))}function q(t,e){t._state===T&&(t._state=x,t._result=e,i(E,t))}function R(t,e,n,r){var o=t._subscribers,s=o.length;t._onerror=null,o[s]=e,o[s+j]=n,o[s+x]=r,0===s&&t._state&&i(F,t)}function F(t){var e=t._subscribers,n=t._state;if(0!==e.length){for(var r=void 0,o=void 0,i=t._result,s=0;s<e.length;s+=3)r=e[s],o=e[s+n],r?N(n,r,o,i):o(i);t._subscribers.length=0}}function N(e,n,r,o){var i=t(r),s=void 0,u=void 0,a=void 0,c=void 0;if(i){if((s=(function(t,e){try{return t(e)}catch(t){return S.error=t,S}})(r,o))===S?(c=!0,u=s.error,s.error=null):a=!0,n===s)return void q(n,new TypeError("A promises callback cannot return that same promise."))}else s=o,a=!0;n._state!==T||(i&&a?P(n,s):c?q(n,u):e===j?M(n,s):e===x&&q(n,s))}var H=0;function J(t){t[g]=H++,t._state=void 0,t._result=void 0,t._subscribers=[]}var L=(function(){function t(t,n){this._instanceConstructor=t,this.promise=new t(A),this.promise[g]||J(this.promise),e(n)?(this.length=n.length,this._remaining=n.length,this._result=new Array(this.length),0===this.length?M(this.promise,this._result):(this.length=this.length||0,this._enumerate(n),0===this._remaining&&M(this.promise,this._result))):q(this.promise,new Error("Array Methods must be provided an Array"))}return t.prototype._enumerate=function(t){for(var e=0;this._state===T&&e<t.length;e++)this._eachEntry(t[e],e)},t.prototype._eachEntry=function(t,e){var n=this._instanceConstructor,r=n.resolve;if(r===b){var o=O(t);if(o===w&&t._state!==T)this._settledAt(t._state,e,t._result);else if("function"!=typeof o)this._remaining--,this._result[e]=t;else if(n===U){var i=new n(A);C(i,t,o),this._willSettleAt(i,e)}else this._willSettleAt(new n(function(e){return e(t)}),e)}else this._willSettleAt(r(t),e)},t.prototype._settledAt=function(t,e,n){var r=this.promise;r._state===T&&(this._remaining--,t===x?q(r,n):this._result[e]=n),0===this._remaining&&M(r,this._result)},t.prototype._willSettleAt=function(t,e){var n=this;R(t,void 0,(function(t){return n._settledAt(j,e,t)}),(function(t){return n._settledAt(x,e,t)}))},t})();var U=(function(){function t(e){this[g]=H++,this._result=this._state=void 0,this._subscribers=[],A!==e&&("function"!=typeof e&&(function(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")})(),this instanceof t?(function(t,e){try{e((function(e){P(t,e)}),(function(e){q(t,e)}))}catch(e){q(t,e)}})(this,e):(function(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")})())}return t.prototype.catch=function(t){return this.then(null,t)},t.prototype.finally=function(t){var e=this.constructor;return this.then((function(n){return e.resolve(t()).then((function(){return n}))}),(function(n){return e.resolve(t()).then((function(){throw n}))}))},t})();return U.prototype.then=w,U.all=function(t){return new L(this,t).promise},U.race=function(t){var n=this;return e(t)?new n(function(e,r){for(var o=t.length,i=0;i<o;i++)n.resolve(t[i]).then(e,r)}):new n(function(t,e){return e(new TypeError("You must pass an array to race."))})},U.resolve=b,U.reject=function(t){var e=new this(A);return q(e,t),e},U._setScheduler=function(t){o=t},U._setAsap=function(t){i=t},U._asap=i,U.polyfill=function(){var t=void 0;if("undefined"!=typeof global)t=global;else if("undefined"!=typeof self)t=self;else try{t=Function("return this")()}catch(t){throw new Error("polyfill failed because global object is unavailable in this environment")}var e=t.Promise;if(e){var n=null;try{n=Object.prototype.toString.call(e.resolve())}catch(t){}if("[object Promise]"===n&&!e.cast)return}t.Promise=U},U.Promise=U,U})),(function(t,e){"function"==typeof define&&define.amd?define([],(function(){return e(t)})):"object"==typeof exports?module.exports=e(t):window.atomic=e(t)})("undefined"!=typeof global?global:"undefined"!=typeof window?window:this,(function(t){"use strict";var e,n={method:"GET",username:null,password:null,data:{},headers:{"Content-type":"application/x-www-form-urlencoded"},responseType:"text",timeout:null,withCredentials:!1},r=function(){for(var t={},e=function(e){for(var n in e)e.hasOwnProperty(n)&&("[object Object]"===Object.prototype.toString.call(e[n])?t[n]=r(t[n],e[n]):t[n]=e[n])},n=0;n<arguments.length;n++){e(arguments[n])}return t},o=function(t){var n=new XMLHttpRequest,r=new Promise(function(r,o){for(var i in n.onreadystatechange=function(){4===n.readyState&&(n.status>=200&&n.status<300?r(function(t){var n;if("text"!==e.responseType&&""!==e.responseType)return{data:t.response,xhr:t};try{n=JSON.parse(t.responseText)}catch(e){n=t.responseText}return{data:n,xhr:t}}(n)):o({status:n.status,statusText:n.statusText,responseText:n.responseText}))},n.open(e.method,t,!0,e.username,e.password),n.responseType=e.responseType,e.headers)e.headers.hasOwnProperty(i)&&n.setRequestHeader(i,e.headers[i]);e.timeout&&(n.timeout=e.timeout,n.ontimeout=function(t){o({status:408,statusText:"Request timeout"})}),e.withCredentials&&(n.withCredentials=!0),n.send(function(t){if("string"==typeof t||"[object FormData]"===Object.prototype.toString.call(t))return t;if(/application\/json/i.test(e.headers["Content-type"])||"[object Array]"===Object.prototype.toString.call(t))return JSON.stringify(t);var n=[];for(var r in t)t.hasOwnProperty(r)&&n.push(encodeURIComponent(r)+"="+encodeURIComponent(t[r]));return n.join("&")}(e.data))});return r.cancel=function(){n.abort()},r};return function(i,s){if(!("XMLHttpRequest"in t&&"JSON"in t&&"Promise"in t))throw"Atomic: This browser does not support the methods used in this plugin.";return e=r(n,s||{}),o(i)}}));
} else {
	/*! atomic v4.2.1 | (c) 2018 Chris Ferdinandi | MIT License | https://github.com/cferdinandi/atomic */
	!(function(t,e){"function"==typeof define&&define.amd?define([],(function(){return e(t)})):"object"==typeof exports?module.exports=e(t):window.atomic=e(t)})("undefined"!=typeof global?global:"undefined"!=typeof window?window:this,(function(t){"use strict";var e,n={method:"GET",username:null,password:null,data:{},headers:{"Content-type":"application/x-www-form-urlencoded"},responseType:"text",timeout:null,withCredentials:!1},o=function(){return"XMLHttpRequest"in t&&"JSON"in t&&"Promise"in t},r=function(){for(var t={},e=0;e<arguments.length;e++){var n=arguments[e];!(function(e){for(var n in e)e.hasOwnProperty(n)&&("[object Object]"===Object.prototype.toString.call(e[n])?t[n]=r(t[n],e[n]):t[n]=e[n])})(n)}return t},s=function(t){var n;if("text"!==e.responseType&&""!==e.responseType)return{data:t.response,xhr:t};try{n=JSON.parse(t.responseText)}catch(e){n=t.responseText}return{data:n,xhr:t}},i=function(t){if("string"==typeof t||"[object FormData]"===Object.prototype.toString.call(t))return t;if(/application\/json/i.test(e.headers["Content-type"])||"[object Array]"===Object.prototype.toString.call(t))return JSON.stringify(t);var n=[];for(var o in t)t.hasOwnProperty(o)&&n.push(encodeURIComponent(o)+"="+encodeURIComponent(t[o]));return n.join("&")},a=function(t){var n=new XMLHttpRequest,o=new Promise(function(o,r){n.onreadystatechange=function(){4===n.readyState&&(n.status>=200&&n.status<300?o(s(n)):r({status:n.status,statusText:n.statusText}))},n.open(e.method,t,!0,e.username,e.password),n.responseType=e.responseType;for(var a in e.headers)e.headers.hasOwnProperty(a)&&n.setRequestHeader(a,e.headers[a]);e.timeout&&(n.timeout=e.timeout,n.ontimeout=function(t){r({status:408,statusText:"Request timeout"})}),e.withCredentials&&(n.withCredentials=!0),n.send(i(e.data))});return o.cancel=function(){n.abort()},o};return function(t,s){if(!o())throw"Atomic: This browser does not support the methods used in this plugin.";return e=r(n,s||{}),a(t)}}));
}

// controller object
!function(){var t=!1,e=[];let o=()=>{let t=window.location.origin,e=RegExp(".*secure.zeald.com|^http://localhost($|:)");if(e.test(t)){let o=window.location.pathname.split("/")[1];t+="/"+o}return t+"/process"};var n=function(t,e){this.route=t,n.notReadyForDispatch=window.controllerNotReadyForDispatch||!1,this.url=o(),this.url+=this.url.indexOf("?")>-1?"&":"?",this.url+="mv_route="+this.route,this.componentId=e||this.determineComponentId()};n.prototype={execute:function(e){return((e=e||{}).cid=e.cid||this.componentId||"",t)?this.queue(e):this.send(e)},queue:function(t){var o=this;return this.payload=t,e.push(this),new Promise(function(t,e){o.resolve=t,o.reject=e})},send:function(t){return atomic(this.url,{method:"POST",data:t})},determineComponentId:function(){var t=this.route.split("/").slice(0,-1).join("_"),e=document.querySelector(".component_"+t);return e?e.id.replace(/^c/,""):null},lockSession:function(){if(-1===this.url.indexOf("?"))this.url+="?";else{if(-1!==this.url.indexOf("mv_sessionlock="))return this;this.url+="&"}return this.url+="mv_sessionlock=1",this}},n.batch=function(){t=!0},n.resetMode=function(){t=!1},n.completeDelayedDispatch=function(){n.notReadyForDispatch=!1,n.resolveDispatchPromise&&(n.dispatch(),n.resolveDispatchPromise())},n.dispatch=function(){if(n.notReadyForDispatch)return new Promise((t,e)=>{n.resolveDispatchPromise=t});var t=e.map(function(t){return{route:t.route,payload:t.payload}});return 0==e.length?Promise.resolve():atomic(o(),{method:"POST",headers:{"Content-type":"application/json"},data:{mv_batch:t}}).then(function(t){if(Array.isArray(data=t.data)&&data.length==e.length)for(var o=0;o<e.length;o++)e[o].resolve(data[o]);else for(var o=0;o<e.length;o++)e[o].reject(t)})},window.Controller=n}();





