if (self.CavalryLogger) { CavalryLogger.start_js(["nqcnC"]); }

/**
 * License: https://www.facebook.com/legal/license/sfP_pLcAtrJ/
 */
__d("SlideshowMaker",[],(function a(b,c,d,e,f,g){__p&&__p();!function(h,i){"object"==typeof g&&"undefined"!=typeof f?f.exports=i():"function"==typeof define&&define.amd?define(i):h.SlideshowMaker=i()}(this,function(){"use strict";__p&&__p();function h(h){Object.getOwnPropertyNames(m).forEach(function(i){h.setRequestHeader(i,m[i])})}function i(i,j,k,l){var n=new XMLHttpRequest();n.onload=function(){var h="response"in n?n.response:n.responseText;k(JSON.parse(h))},n.onerror=l,n.ontimeout=l,n.open("get",i,!0),m["X-Animoto-Authorization"]="Bearer "+j,h(n),n.send(null)}function j(h){var i=document.createElement("a");return i.href=h,i.origin||(i.origin=i.protocol+"//"+i.hostname),i.origin}function k(h,i){return h.origin===i&&"object"===o(h.data)&&"action"in h.data&&h.data.contentType===u}function l(h,i,j){i.contentType=u,h.postMessage(i,j)}var m={"X-Animoto-Accept":"application/vnd.animoto-v4+json","Content-Type":"application/json"},n=function(){},o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(h){return typeof h}:function(h){return h&&"function"==typeof Symbol&&h.constructor===Symbol?"symbol":typeof h},p=function(h,i){if(!(h instanceof i))throw new TypeError("Cannot call a class as a function")},q=function(){function h(h,i){for(var j=0;j<i.length;j++){var k=i[j];k.enumerable=k.enumerable||!1,k.configurable=!0,"value"in k&&(k.writable=!0),Object.defineProperty(h,k.key,k)}}return function(i,j,k){return j&&h(i.prototype,j),k&&h(i,k),i}}(),r=Object.assign||function(h){for(var i=1;i<arguments.length;i++){var j=arguments[i];for(var k in j)Object.prototype.hasOwnProperty.call(j,k)&&(h[k]=j[k])}return h},s=3,t=function(){__p&&__p();function h(i){p(this,h),this.url=i.url,this.clientToken=i.clientToken,this.success=i.success||n,this.error=i.error||n,this.retries=0,this.makeRequest()}return q(h,[{key:"makeRequest",value:function(){var h=this,j=function(i){h.checkStatus(i)},k=function(){h.retry()};i(this.url,this.clientToken,j,k)}},{key:"checkStatus",value:function(h){var i=h.response.payload.rendering_job,j=i.state;return"completed"===j?void this.success(i.links.video):"failed"===i.state?void this.retry():void this.poll()}},{key:"poll",value:function h(){var i=this,h=function(){i.makeRequest()};setTimeout(h,2e4)}},{key:"retry",value:function(){return this.retries===s?void this.error():(this.retries+=1,void this.poll())}}]),h}(),u="application/x-maker-v1+json",v="https://video440.com",w=v+"/mm/fb/create",x=["src","srcdoc","align"],y=function(){__p&&__p();function h(i){p(this,h);var k={name:"slideshow-maker",id:"slideshow-maker",title:"Slideshow Maker",style:"width:100%;height:100%;border:0",frameborder:"0",allowtransparency:"true",allowfullscreen:"true",scrolling:"no"},l={iframeAttrs:k,onIframeClose:n,onRenderComplete:n,onRenderError:n,onFinalize:n};if(this.options=r(l,i||{}),this.iframeAttrs=this.options.iframeAttrs,!this.options.id)throw new Error("Slideshow Maker was initialized without an ID");this.id=this.options.id,this.contentWindow=window,this.iframeOrigin=j(w),this.addListener(),this.createIframe()}return q(h,[{key:"addListener",value:function(){var h=this,i=function i(j){h.messageHandler(j,i)};this.contentWindow.addEventListener("message",i,!1)}},{key:"removeListener",value:function(h){this.contentWindow.removeEventListener("message",h,!1)}},{key:"createIframe",value:function(){var h=this,i=document.getElementById(this.id);this.iframe=document.createElement("iframe"),Object.keys(this.iframeAttrs).forEach(function(i){x.indexOf(i)===-1&&h.iframe.setAttribute(i,h.iframeAttrs[i])}),this.iframe.src=w,i&&(i.appendChild(this.iframe),this.childWindow=this.iframe.contentWindow,this.iframe.onload=function(){l(h.childWindow,{action:"handshake"},h.iframeOrigin)})}},{key:"renderComplete",value:function(h){this.options.onRenderComplete(h)}},{key:"renderError",value:function(){throw this.options.onRenderError(),new Error("Rendering job failed to completed")}},{key:"pollForRender",value:function(h){var i=this;this.renderJob=new t({url:h,clientToken:this.clientToken,success:function(h){i.renderComplete(h)},error:function(){i.renderError()}})}},{key:"messageHandler",value:function(h,i){__p&&__p();if(k(h,this.iframeOrigin)){var j=h.data,l=j.action;if("handshake"===l)this.clientToken=j.clientToken;else if("render"===l){var m=j.renderJob;this.pollForRender(m),this.removeListener(i),this.options.onFinalize()}else"close"===l&&(this.removeListener(i),this.options.onIframeClose())}}}]),h}();f.exports=y;return y})}),null);