/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/blocksdk@1.3.0/blocksdk.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
var SDK=function(e,t,s){Array.isArray(e)&&(s=t=e,e=void 0),e&&e.onEditClose&&(this.handlers={onEditClose:e.onEditClose},e.onEditClose=!0),this._whitelistOverride=t,this._sslOverride=s,this._messageId=1,this._messages={0:function(){}},this._readyToPost=!1,this._pendingMessages=[],this._receiveMessage=this._receiveMessage.bind(this),window.addEventListener("message",this._receiveMessage,!1),window.parent.postMessage({method:"handShake",origin:window.location.origin,payload:e},"*")};SDK.prototype.execute=function(e,t){var s=(t=t||{}).data,i=t.success;this._readyToPost?this._post({method:e,payload:s},i):this._pendingMessages.push({method:e,payload:s,callback:i})},SDK.prototype.getCentralData=function(e){this.execute("getCentralData",{success:e})},SDK.prototype.getContent=function(e){this.execute("getContent",{success:e})},SDK.prototype.getData=function(e){this.execute("getData",{success:e})},SDK.prototype.getUserData=function(e){this.execute("getUserData",{success:e})},SDK.prototype.getView=function(e){this.execute("getView",{success:e})},SDK.prototype.setBlockEditorWidth=function(e,t){this.execute("setBlockEditorWidth",{data:e,success:t})},SDK.prototype.setCentralData=function(e,t){this.execute("setCentralData",{data:e,success:t})},SDK.prototype.setContent=function(e,t){this.execute("setContent",{data:e,success:t})},SDK.prototype.setData=function(e,t){this.execute("setData",{data:e,success:t})},SDK.prototype.setSuperContent=function(e,t){this.execute("setSuperContent",{data:e,success:t})},SDK.prototype.triggerAuth=function(e){this.getUserData((function(t){var s=t.stack;0===s.indexOf("qa")&&(s=s.substring(3,5)+"."+s.substring(0,3));var i=document.createElement("IFRAME");i.src="https://mc."+s+".exacttarget.com/cloud/tools/SSO.aspx?appId="+e+"&restToken=1&hub=1",i.style.width="1px",i.style.height="1px",i.style.position="absolute",i.style.top="0",i.style.left="0",i.style.visibility="hidden",i.className="authframe",document.body.appendChild(i)}))},SDK.prototype.triggerAuth2=function(e){var t=document.createElement("IFRAME"),s="",i="";Array.isArray(e.scope)&&(s="&scope="+e.scope.join("%20")),e.state&&(i="&state="+e.state),t.src=e.authURL+(e.authURL.endsWith("/")?"":"/")+"v2/authorize?response_type=code&client_id="+e.clientId+"&redirect_uri="+encodeURIComponent(e.redirectURL)+s+i,t.style.width="1px",t.style.height="1px",t.style.position="absolute",t.style.top="0",t.style.left="0",t.style.visibility="hidden",t.className="authframe",document.body.appendChild(t)},SDK.prototype._executePendingMessages=function(){var e=this;this._pendingMessages.forEach((function(t){e.execute(t.method,{data:t.payload,success:t.callback})})),this._pendingMessages=[]},SDK.prototype._post=function(e,t){this._messages[this._messageId]=t,e.id=this._messageId,this._messageId+=1,window.parent.postMessage(e,this._parentOrigin)},SDK.prototype._receiveMessage=function(e){var t=(e=e||{}).data||{};if("handShake"===t.method){if(this._validateOrigin(t.origin))return this._parentOrigin=t.origin,this._readyToPost=!0,void this._executePendingMessages()}else if("closeBlock"===t.method&&this._validateOrigin(t.origin))return this.handlers&&this.handlers.onEditClose&&this.handlers.onEditClose(),void this.execute("blockReadyToClose");this._parentOrigin&&this._parentOrigin===e.origin&&((this._messages[t.id||0]||function(){})(t.payload),delete this._messages[t.id])},SDK.prototype._validateOrigin=function(e){for(var t=this._whitelistOverride||["exacttarget\\.com","marketingcloudapps\\.com","blocktester\\.herokuapp\\.com"],s=0;s<t.length;s++){var i=this._sslOverride?"?":"",o="exacttarget\\.com"===t[s]?"mc\\.":"";if(new RegExp("^https"+i+"://"+o+"([a-zA-Z0-9-]+\\.)*"+t[s]+"(:[0-9]+)?$","i").test(e))return!0}return!1},"object"==typeof window&&(window.sfdc=window.sfdc||{},window.sfdc.BlockSDK=SDK),"object"==typeof module&&(module.exports=SDK);
//# sourceMappingURL=/sm/e5b9f81e0516c2cddcf21341d28c7c764e57a7b0939a8eb87adea61e83ef7ace.map