/**
 * Copyright 2021 The Pennsylvania State University
 * @license Apache-2.0, see License.md for full text.
 */
const t=["target","compression","streamingurl","companyname","productname","productversion","width","height","background"];class UnityWebgl extends HTMLElement{static get tag(){return"unity-webgl"}constructor(){super(),this.template=globalThis.document.createElement("template"),this.attachShadow({mode:"open"})}get html(){return`\n    <style> \n      :host { \n        display: block;\n        width: ${this.width};\n        height: ${this.height};\n        background: ${this.background};\n      }\n    </style>\n    <canvas style="width: ${this.width}; height: ${this.height}; background: ${this.background}"></canvas>`}connectedCallback(){globalThis.ShadyCSS&&globalThis.ShadyCSS.styleElement(this),t.forEach((t=>{this[t]=this.getAttribute(t)}))}render(){this.shadowRoot.innerHTML=null,this.template.innerHTML=this.html,globalThis.ShadyCSS&&globalThis.ShadyCSS.prepareTemplate(this.template,this.tag),this.shadowRoot.appendChild(this.template.content.cloneNode(!0));var t=globalThis.document.createElement("script");t.onload=()=>{createUnityInstance(this.shadowRoot.querySelector("canvas"),{dataUrl:this.target+".data."+this.compression,frameworkUrl:this.target+".framework.js."+this.compression,codeUrl:this.target+".wasm."+this.compression,streamingAssetsUrl:this.streamingurl,company_name:this.companyname,product_name:this.productname,product_version:this.productversion})},t.src=this.target+".loader.js",this.shadowRoot.appendChild(t),t.onerror=function(){console.log("Error loading "+this.src)}}static get observedAttributes(){return t}attributeChangedCallback(t,e,i){this.shadowRoot&&i&&e!=i&&(clearTimeout(this._debounce),this._debounce=setTimeout((()=>{this.render()}),0))}set target(t){this.setAttribute("target",t)}set compression(t){this.setAttribute("compression",t)}set streamingurl(t){this.setAttribute("streamingurl",t)}set companyname(t){this.setAttribute("companyname",t)}set productname(t){this.setAttribute("productname",t)}set productversion(t){this.setAttribute("productversion",t)}set width(t){this.setAttribute("width",t)}set height(t){this.setAttribute("height",t)}set background(t){this.setAttribute("background",t)}get target(){return this.getAttribute("target")}get compression(){return this.getAttribute("compression")}get streamingurl(){return this.getAttribute("streamingurl")}get companyname(){return this.getAttribute("companyname")}get productname(){return this.getAttribute("productname")}get productversion(){return this.getAttribute("productversion")}get width(){return this.getAttribute("width")}get height(){return this.getAttribute("height")}get background(){return this.getAttribute("background")}static get haxProperties(){return{canScale:!1,canEditSource:!0,gizmo:{title:"Unity Player",description:"Unity WebGL Player",icon:"av:games",color:"purple",tags:["3D","game","unity","media"],handles:[],meta:{author:"HAXTheWeb core team"}},settings:{configure:[{property:"target",title:"Target",description:"Target game path",inputMethod:"textfield"},{property:"compression",title:"Compression method",description:"Game's files extention",inputMethod:"textfield"},{property:"streamingurl",title:"Streaming url",description:"Streaming assets url",inputMethod:"textfield"},{property:"companyname",title:"Company Name",description:"Company Name",inputMethod:"textfield"},{property:"productname",title:"Product Name",description:"Game title",inputMethod:"textfield"},{property:"productversion",title:"Product Version",description:"Release Version",inputMethod:"textfield"},{property:"width",title:"Canvas Width",description:"Canvas CSS Width (with px/em/etc.)",inputMethod:"textfield"},{property:"height",title:"Canvas Height",description:"Canvas CSS Height (with px/em/etc.)",inputMethod:"textfield"},{property:"background",title:"Canvas Background",description:"Canvas CSS Background",inputMethod:"textfield"}],advanced:[]},saveOptions:{unsetAttributes:[]},demoSchema:[{tag:"unity-webgl",content:"",properties:{target:"/elements/unity-webgl/demo/example/build web",compression:"unityweb",streamingurl:"StreamingAssets",companyname:"DefaultCompany",productname:"test webgl",productversion:"0.1",width:"460px",height:"400px",background:"#231F20"}}]}}}customElements.define(UnityWebgl.tag,UnityWebgl);export{UnityWebgl};