!function(n,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("zoid",[],e):"object"==typeof exports?exports.zoid=e():n.zoid=e()}("undefined"!=typeof self?self:this,(function(){return function(n){var e={};function r(t){if(e[t])return e[t].exports;var o=e[t]={i:t,l:!1,exports:{}};return n[t].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=n,r.c=e,r.d=function(n,e,t){r.o(n,e)||Object.defineProperty(n,e,{enumerable:!0,get:t})},r.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},r.t=function(n,e){if(1&e&&(n=r(n)),8&e)return n;if(4&e&&"object"==typeof n&&n&&n.__esModule)return n;var t=Object.create(null);if(r.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:n}),2&e&&"string"!=typeof n)for(var o in n)r.d(t,o,function(e){return n[e]}.bind(null,o));return t},r.n=function(n){var e=n&&n.__esModule?function(){return n.default}:function(){return n};return r.d(e,"a",e),e},r.o=function(n,e){return{}.hasOwnProperty.call(n,e)},r.p="",r(r.s=0)}([function(n,e,r){"use strict";function t(n,e){n.prototype=Object.create(e.prototype),n.prototype.constructor=n,n.__proto__=e}function o(){return(o=Object.assign||function(n){for(var e=1;e>>0)+"__",function(){if("undefined"==typeof WeakMap)return!1;if(void 0===Object.freeze)return!1;try{var n=new WeakMap,e={};return Object.freeze(e),n.set(e,"__testvalue__"),"__testvalue__"===n.get(e)}catch(n){return!1}}())try{this.weakmap=new WeakMap}catch(n){}this.keys=[],this.values=[]}var e=n.prototype;return e._cleanupClosedWindows=function(){for(var n=this.weakmap,e=this.keys,r=0;r=3)return"stringifyError stack overflow";try{if(!n)return"";if("string"==typeof n)return n;if(n instanceof Error){var r=n&&n.stack,t=n&&n.message;if(r&&t)return-1!==r.indexOf(t)?r:t+"\n"+r;if(r)return r;if(t)return t}return n&&n.toString&&"function"==typeof n.toString?n.toString():{}.toString.call(n)}catch(n){return"Error while stringifying error: "+cn(n,e+1)}}function sn(n){return"string"==typeof n?n:n&&n.toString&&"function"==typeof n.toString?n.toString():{}.toString.call(n)}function fn(n,e){if(!e)return n;if(Object.assign)return Object.assign(n,e);for(var r in e)e.hasOwnProperty(r)&&(n[r]=e[r]);return n}function dn(n){return n}function ln(n,e){var r;return function t(){r=setTimeout((function(){n(),t()}),e)}(),{cancel:function(){clearTimeout(r)}}}function hn(n){return[].slice.call(n)}function wn(n){return null!=n}function pn(n){return"[object RegExp]"==={}.toString.call(n)}function vn(n,e,r){if(n.hasOwnProperty(e))return n[e];var t=r();return n[e]=t,t}function mn(n){var e=[],r=!1;return{set:function(e,t){return r||(n[e]=t,this.register((function(){delete n[e]}))),t},register:function(n){r?n():e.push(an(n))},all:function(){var n=[];for(r=!0;e.length;){var t=e.shift();n.push(t())}return h.all(n).then(un)}}}function yn(n,e){if(null==e)throw new Error("Expected "+n+" to be present");return e}rn.clear=function(){for(var n=0;n { ... }":"<"+typeof n+">"})).join(", ")+") failed\n\n")+n.stack),n}))})).then((function(n){return{result:n,id:o,name:i}}))}))}));var c=r.__id__||Q();n=we.unwrap(n);var s=r.__name__||r.name||t;return"string"==typeof s&&"function"==typeof s.indexOf&&0===s.indexOf("anonymous::")&&(s=s.replace("anonymous::",t+"::")),we.isProxyWindow(n)?(pe(c,r,s,n,e),n.awaitWindow().then((function(n){pe(c,r,s,n,e)}))):pe(c,r,s,n,e),ue("cross_domain_function",{id:c,name:s})}function ye(n,e,r,t){var o,i=t.on,u=t.send;return function(n,e){void 0===e&&(e=se);var r=JSON.stringify(n,(function(n){var r=this[n];if(oe(this))return r;var t=ie(r);if(!t)return r;var o=e[t]||ce[t];return o?o(r,n):r}));return void 0===r?"undefined":r}(r,((o={}).promise=function(r,t){return function(n,e,r,t,o){return ue("cross_domain_zalgo_promise",{then:me(n,e,(function(n,e){return r.then(n,e)}),t,{on:o.on,send:o.send})})}(n,e,r,t,{on:i,send:u})},o.function=function(r,t){return me(n,e,r,t,{on:i,send:u})},o.object=function(n){return q(n)||we.isProxyWindow(n)?ue("cross_domain_window",we.serialize(n,{send:u})):n},o))}function ge(n,e,r,t){var o,i=t.send;return function(n,e){if(void 0===e&&(e=de),"undefined"!==n)return JSON.parse(n,(function(n,r){if(oe(this))return r;var t,o;if(oe(r)?(t=r.__type__,o=r.__val__):(t=ie(r),o=r),!t)return o;var i=e[t]||fe[t];return i?i(o,n):o}))}(r,((o={}).cross_domain_zalgo_promise=function(n){return function(n,e,r){return new h(r.then)}(0,0,n)},o.cross_domain_function=function(r){return function(n,e,r,t){var o=r.id,i=r.name,u=t.send,a=function(r){function t(){var a=arguments;return we.toProxyWindow(n,{send:u}).awaitWindow().then((function(n){var c=ve(n,o);if(c&&c.val!==t)return c.val.apply({source:window,origin:b()},a);var s=[].slice.call(a);return r.fireAndForget?u(n,"postrobot_method",{id:o,name:i,args:s},{domain:e,fireAndForget:!0}):u(n,"postrobot_method",{id:o,name:i,args:s},{domain:e,fireAndForget:!1}).then((function(n){return n.data.result}))})).catch((function(n){throw n}))}return void 0===r&&(r={}),t.__name__=i,t.__origin__=e,t.__source__=n,t.__id__=o,t.origin=e,t},c=a();return c.fireAndForget=a({fireAndForget:!0}),c}(n,e,r,{send:i})},o.cross_domain_window=function(n){return we.deserialize(n,{send:i})},o))}var _e={};function Ee(n,e,r,t){var o=t.on,i=t.send;return h.try((function(){var t=Kn().getOrSet(n,(function(){return{}}));return t.buffer=t.buffer||[],t.buffer.push(r),t.flush=t.flush||h.flush().then((function(){if(k(n))throw new Error("Window is closed");var r,u=ye(n,e,((r={}).__post_robot_10_0_41__=t.buffer||[],r),{on:o,send:i});delete t.buffer;for(var a=Object.keys(_e),c=[],s=0;s1?e-1:0),t=1;t1?e-1:0),o=1;o iframe {\n display: inline-block;\n position: absolute;\n width: 100%;\n height: 100%;\n top: 0;\n left: 0;\n transition: opacity .2s ease-in-out;\n }\n\n #"+e+" > iframe.zoid-invisible {\n opacity: 0;\n }\n\n #"+e+" > iframe.zoid-visible {\n opacity: 1;\n }\n ")),f.appendChild(r),f.appendChild(t),f.appendChild(d),t.classList.add("zoid-visible"),r.classList.add("zoid-invisible"),u.on(qe.RENDERED,(function(){t.classList.remove("zoid-visible"),t.classList.add("zoid-invisible"),r.classList.remove("zoid-invisible"),r.classList.add("zoid-visible"),setTimeout((function(){In(t)}),1)})),u.on(qe.RESIZE,(function(n){var e=n.width,r=n.height;"number"==typeof e&&(f.style.width=Hn(e)),"number"==typeof r&&(f.style.height=Hn(r))})),f}}var Ge=function(){return un},Xe=function(n){return an(n.value)},Ke=mn(),Qe=mn();function nr(n){var e,r,t=function(n){var e=n.tag,r=n.url,t=n.domain,i=n.bridgeUrl,u=n.props,a=void 0===u?{}:u,c=n.dimensions,s=void 0===c?{}:c,f=n.autoResize,d=void 0===f?{}:f,l=n.allowedParentDomains,h=void 0===l?"*":l,w=n.attributes,p=void 0===w?{}:w,v=n.defaultContext,m=void 0===v?Me.IFRAME:v,y=n.containerTemplate,g=void 0===y?$e:y,_=n.prerenderTemplate,E=void 0===_?null:_,b=n.validate,P=n.eligible,O=void 0===P?function(){return{eligible:!0}}:P,W=n.logger,S=void 0===W?{info:un}:W,C=e.replace(/-/g,"_"),j=s.width,D=void 0===j?"300px":j,R=s.height,A=void 0===R?"150px":R;if(a=o({},{window:{type:"object",sendToChild:!1,required:!1,allowDelegate:!0,validate:function(n){var e=n.value;if(!q(e)&&!we.isProxyWindow(e))throw new Error("Expected Window or ProxyWindow");if(q(e)){if(k(e))throw new Error("Window is closed");if(!x(e))throw new Error("Window is not same domain")}},decorate:function(n){return ze(n.value)}},timeout:{type:"number",required:!1,sendToChild:!1},close:{type:"function",required:!1,sendToChild:!1,childDecorate:function(n){return n.close}},focus:{type:"function",required:!1,sendToChild:!1,childDecorate:function(n){return n.focus}},resize:{type:"function",required:!1,sendToChild:!1,childDecorate:function(n){return n.resize}},uid:{type:"string",required:!1,sendToChild:!1,childDecorate:function(n){return n.uid}},cspNonce:{type:"string",required:!1},getParent:{type:"function",required:!1,sendToChild:!1,childDecorate:function(n){return n.getParent}},getParentDomain:{type:"function",required:!1,sendToChild:!1,childDecorate:function(n){return n.getParentDomain}},show:{type:"function",required:!1,sendToChild:!1,childDecorate:function(n){return n.show}},hide:{type:"function",required:!1,sendToChild:!1,childDecorate:function(n){return n.hide}},onDisplay:{type:"function",required:!1,sendToChild:!1,allowDelegate:!0,default:Ge,decorate:Xe},onRendered:{type:"function",required:!1,sendToChild:!1,default:Ge,decorate:Xe},onRender:{type:"function",required:!1,sendToChild:!1,default:Ge,decorate:Xe},onClose:{type:"function",required:!1,sendToChild:!1,allowDelegate:!0,default:Ge,decorate:Xe},onDestroy:{type:"function",required:!1,sendToChild:!1,allowDelegate:!0,default:Ge,decorate:Xe},onResize:{type:"function",required:!1,sendToChild:!1,allowDelegate:!0,default:Ge},onFocus:{type:"function",required:!1,sendToChild:!1,allowDelegate:!0,default:Ge},onError:{type:"function",required:!1,sendToChild:!1,childDecorate:function(n){return n.onError}},onProps:{type:"function",required:!1,sendToChild:!1,default:Ge,childDecorate:function(n){return n.onProps}}},a),!g)throw new Error("Container template required");return{name:C,tag:e,url:r,domain:t,bridgeUrl:i,propsDef:a,dimensions:{width:D,height:A},autoResize:d,allowedParentDomains:h,attributes:p,defaultContext:m,containerTemplate:g,prerenderTemplate:E,validate:b,logger:S,eligible:O}}(n),i=t.name,u=t.tag,a=t.defaultContext,c=t.eligible,s=Te(),f=[],d=function(){var n=Be();return Boolean(n&&n.tag===u&&n.childDomain===b())},l=rn((function(){if(d()){if(window.xprops)throw delete s.components[u],new Error("Can not register "+i+" as child - child already registered");var n=function(n){var e,r=n.propsDef,t=n.autoResize,o=n.allowedParentDomains,i=[],u=Be();if(!u)throw new Error("No child payload found");if("9_0_62"!==u.version)throw new Error("Parent window has zoid version "+u.version+", child window has version 9_0_62");var a=u.uid,c=u.parentDomain,s=u.exports,f=u.context,d=u.props,l=function(n){var e,r,t=n.type;if("opener"===t)return yn("opener",g(window));if("parent"===t&&"number"==typeof n.distance)return yn("parent",(e=window,void 0===(r=n.distance)&&(r=1),function(n,e){void 0===e&&(e=1);for(var r=n,t=0;t { let url = backUrl(props.env)+'/v1/offset-website'; return url; }, dimensions: { width: '171px', height: '62px' }, autoResize: { width: true, height: true }, props: { code: { type: 'string', required: true, queryParam: true }, lang: { type: 'string', required: false, queryParam: true }, theme: { type: 'string', required: false, queryParam: true }, } }); // Offset products widget var TreeNationOffsetProducts = zoid.create({ tag: 'tree-nation-offset-products', url: ({ props }) => { let url = backUrl(props.env)+'/v1/offset-products'; return url; }, dimensions: { width: '171px', height: '62px' }, autoResize: { width: true, height: true }, props: { code: { type: 'string', required: true, queryParam: true }, lang: { type: 'string', required: false, queryParam: true }, theme: { type: 'string', required: false, queryParam: true }, } }); // Offset team widget var TreeNationOffsetTeam = zoid.create({ tag: 'tree-nation-offset-team', url: ({ props }) => { let url = backUrl(props.env)+'/v1/offset-team'; return url; }, dimensions: { width: '171px', height: '62px' }, autoResize: { width: true, height: true }, props: { code: { type: 'string', required: true, queryParam: true }, lang: { type: 'string', required: false, queryParam: true }, theme: { type: 'string', required: false, queryParam: true }, } }); // Tree counter widget var TreeNationTreeCounter = zoid.create({ tag: 'tree-nation-tree-counter', url: ({ props }) => { let url = backUrl(props.env)+'/v1/tree-counter'; return url; }, dimensions: { width: '171px', height: '62px' }, autoResize: { width: true, height: true }, props: { code: { type: 'string', required: true, queryParam: true }, lang: { type: 'string', required: false, queryParam: true }, theme: { type: 'string', required: false, queryParam: true }, } }); // DEMO WIDGETS // Offset website widget var TreeNationOffsetWebsiteDemo = zoid.create({ tag: 'tree-nation-offset-website-demo', url: ({ props }) => { let url = backUrl(props.env)+'/demo/offset-website'; return url; }, dimensions: { width: '171px', height: '62px' }, autoResize: { width: true, height: true }, props: { slugDemo: { type: 'string', required: true, queryParam: true }, langDemo: { type: 'string', required: true, queryParam: true }, themeDemo: { type: 'string', required: true, queryParam: true } } }); // Offset products widget var TreeNationOffsetProductsDemo = zoid.create({ tag: 'tree-nation-offset-products-demo', url: ({ props }) => { let url = backUrl(props.env)+'/demo/offset-products'; return url; }, dimensions: { width: '171px', height: '62px' }, autoResize: { width: true, height: true }, props: { slugDemo: { type: 'string', required: true, queryParam: true }, langDemo: { type: 'string', required: false, queryParam: true }, themeDemo: { type: 'string', required: false, queryParam: true }, } }); // Offset team widget var TreeNationOffsetTeamDemo = zoid.create({ tag: 'tree-nation-offset-team-demo', url: ({ props }) => { let url = backUrl(props.env)+'/demo/offset-team'; return url; }, dimensions: { width: '171px', height: '62px' }, autoResize: { width: true, height: true }, props: { slugDemo: { type: 'string', required: true, queryParam: true }, langDemo: { type: 'string', required: false, queryParam: true }, themeDemo: { type: 'string', required: false, queryParam: true }, } }); // Tree counter widget var TreeNationTreeCounterDemo = zoid.create({ tag: 'tree-nation-tree-counter-demo', url: ({ props }) => { let url = backUrl(props.env)+'/demo/tree-counter'; return url; }, dimensions: { width: '171px', height: '62px' }, autoResize: { width: true, height: true }, props: { slugDemo: { type: 'string', required: true, queryParam: true }, langDemo: { type: 'string', required: false, queryParam: true }, themeDemo: { type: 'string', required: false, queryParam: true }, } });