!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.Widgetic=e()}(this,function(){"use strict";var o,t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function e(t,e){return t(e={exports:{}},e.exports),e.exports}(o=function(t){var e,n,i,r;for(n=(i=o.options).parser[i.strictMode?"strict":"loose"].exec(t),r={},e=14;e--;)r[i.key[e]]=n[e]||"";return r[i.q.name]={},r[i.key[12]].replace(i.q.parser,function(t,e,n){if(e)return r[i.q.name][e]=n}),r[i.h.name]={},r[i.key[13]].replace(i.h.parser,function(t,e,n){if(e)return r[i.h.name][e]=n}),r}).options={strictMode:!1,key:["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","hash"],q:{name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},h:{name:"hashKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/}};var n,i,r,s,a,u,c,l,d,p,h,f,m=o;(f=window.location).origin||(f.origin=f.protocol+"//"+f.hostname+(f.port?":"+f.port:"")),a=m,n=(null!=(l=window.widgeticOptions)?l.domain:void 0)||"widgetic.com",i=(null!=(d=window.widgeticOptions)?d.domainProtocol:void 0)||"https",s="?lo="+encodeURIComponent(f.origin);var y,g,v={proxy:(c=!1===(null!=(p=window.widgeticOptions)?p.secure:void 0)?"http":"https")+"://"+(r=(u=a(n)).host+(u.port?":"+u.port:""))+"/sdk/proxy.html"+s+"#proxy",popup:c+"://"+r+"/sdk/proxy.html"+s+"#popup",auth:c+"://"+n+"/oauth/v2/auth",composition:c+"://"+n+"/api/v2/compositions/{id}/embed.html"+s,widget:c+"://"+n+"/api/v2/widgets/{id}/embed.html"+s,editor:c+"://"+n+"/api/v2/editor.html"+s,plugin:c+"://"+r+"/plugin"+s,api:"/api/v2/",domain:i+"://"+r,lo:decodeURIComponent(a(f).queryKey.lo||f.origin),crossdomain:(null!=(h=window.widgeticOptions)?h.crossdomain:void 0)||!0};y="addEventListener",g="removeEventListener";var w,_,b={on:function(t,e,n,i){return null==i&&(i=!1),t[y]?t[y](e,n,i):t.attachEvent("on"+e,n)},off:function(t,e,n,i){return null==i&&(i=!1),t[g]?t[g](e,n,i):t.detachEvent("on"+e,n)}},k=e(function(t,e){t.exports=function(t,e,n){e=e||"";var i=(n=n||{}).complete||function(){},r=n.success||function(){},o=n.error||function(){},s=n.headers||{},a=n.method||"GET",u=n.sync||!1,c=0===t.indexOf("http")&&"undefined"!=typeof XDomainRequest?new XDomainRequest:new XMLHttpRequest;if(!c)throw new Error("Browser doesn't support XHR");if("string"!=typeof e){var l=[];for(var d in e)l.push(d+"="+e[d]);e=l.join("&")}for(var p in"ontimeout"in c&&(c.ontimeout=+n.timeout||0),c.onload=function(){i(c.responseText,c.status),r(c.responseText)},c.onerror=function(){i(c.responseText),o(c.responseText,c.status)},c.open(a,"GET"===a&&e?t+"?"+e:t,!u),s)c.setRequestHeader(p,s[p]);return c.send("GET"!==a?e:null),c}});_=k,w=v;var E=function(t){var e,n,i,r,o,s;if(t.id&&(e=t.a))return s=e.u,o=e.m,n=e.d,r={id:t.id,t:"e",a:{}},i={"Content-type":"application/json"},"PUT"!==(o=o.toUpperCase())&&"DELETE"!==o||(i["X-HTTP-Method-Override"]=o,o="POST"),_(s,n,{method:o,headers:i,complete:function(t,e){return r.a.t=200===e||201===e||202===e||204===e?"t":"f",r.a.d=t,r=JSON.stringify(r),w.crossdomain?window.parent.postMessage(r,"*"):window.widgeticReceiver({origin:window.location.origin,data:r})}})},x=[].slice,S={};function O(t){this._size=t,this._call=this._error=null,this._tasks=[],this._data=[],this._waiting=this._active=this._ended=this._start=0}function T(e){if(!e._start)try{!function(t){for(;t._start=t._waiting&&t._active
',this.document.body.appendChild(this.loader),this.content=document.createElement("div"),this.document.body.appendChild(this.content),n='",this.head.insertAdjacentHTML("beforeend",n),n=document.querySelectorAll("[data-widget-style=true]"),n=(n=Array.prototype.map.call(n,ke)).reduce(function(t,e){return t+e},""),this.style(n,!0),e=document.querySelectorAll('link[rel="stylesheet"]'),e=Array.prototype.map.call(e,function(t){return t.href}),(this.css||e.length)&&(this.loader.style.display="block",this.content.style.display="none",Se.call(this,this.head,this.css,e,(i=this,function(){return i.loader.style.display="none",i.content.style.display="block",i.resize().then(function(){return i.position()}).then(function(){return i})}))),this},r}(),we.on(window.document,"click",de.hideAll);var Ie,We,Ne,Pe,Re,je,ze,Ue,He,Le,De=de;Ue=Bt,Ie="allow-scale-down",Re=function(t){var e,n,i;return e=t.children[0],i=t.parentNode,t.removeChild(e),(n=document.createDocumentFragment()).insertBefore(e,null),i.insertBefore(n,t),i.removeChild(t),e},Ne=function(t){return t.children[0]},je=function(t,e,n,i){var r;return r=e?"display:inline-block;vertical-align:middle;":"",i?'
$$$
':'
'},ze={fixed:function(t,e){return{wrapStyle:"max-width: "+t+"px; min-width: "+t+"px;",holdStyle:"padding-top: "+100*e/t+"%;"}},"allow-scale-down":function(t,e){return{wrapStyle:"max-width: "+t+"px;",holdStyle:"padding-top: "+100*e/t+"%;"}},"fixed-height":function(t,e){return{holdStyle:"height: "+e+"px; padding-top: 0;"}},"fill-width":function(t,e){return{holdStyle:"padding-top: "+100*e/t+"%;"}},fill:function(t,e){return{wrapStyle:"height: 100%",holdStyle:"height: 100%;min-height:"+e+"px"}}},(Pe=function(){return Ue(function(){var t,e,n,i;for(n=0,i=(t=document.querySelectorAll(".widgetic-composition")).length;n