/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["../../chunks/_rollupPluginBabelHelpers","../../chunks/tslib.es6","../../core/Error","../../core/Logger","../../core/accessorSupport/decorators/property","../../core/arrayUtils","../../core/has","../../core/accessorSupport/ensureType","../../core/accessorSupport/decorators/subclass","./MediaElementBase"],(function(e,o,t,r,s,n,i,a,c,d){"use strict";let l=function(o){function s(e){var t;return(t=o.call(this,e)||this).content=null,t.type="video",t}e._inheritsLoose(s,o);var n=s.prototype;return n.load=function(){const e=this.video;if("string"==typeof e){const o=document.createElement("video");o.src=e,o.crossOrigin="anonymous",o.autoplay=!0,o.muted=!0,o.loop=!0,this.addResolvingPromise(this._loadVideo(o).then((()=>{this._set("content",o)})))}else e instanceof HTMLVideoElement?this.addResolvingPromise(this._loadVideo(e).then((()=>{this._set("content",e)}))):this.addResolvingPromise(Promise.reject(new t("video-element:invalid-video-type","Invalid video type",{video:e})));return Promise.resolve(this)},n._loadVideo=function(e){return new Promise(((o,t)=>{e.oncanplay=()=>{e.oncanplay=null,e.play().then(o,t)},"anonymous"!==e.crossOrigin&&(e.crossOrigin="anonymous",e.src=e.src)}))},e._createClass(s,[{key:"video",set:function(e){"not-loaded"===this.loadStatus?this._set("video",e):r.getLogger(this.declaredClass).error("#video","video cannot be changed after the element is loaded.")}}]),s}(d);o.__decorate([s.property({readOnly:!0})],l.prototype,"content",void 0),o.__decorate([s.property()],l.prototype,"video",null),l=o.__decorate([c.subclass("esri.layers.support.VideoElement")],l);return l}));
