var __runInitializers=this&&this.__runInitializers||function(thisArg,initializers,value){for(var useValue=arguments.length>2,i=0;i=0;i--){var context={};for(var p in contextIn)context[p]="access"===p?{}:contextIn[p];for(var p in contextIn.access)context.access[p]=contextIn.access[p];context.addInitializer=function(f){if(done)throw new TypeError("Cannot add initializers after decoration has completed");extraInitializers.push(accept(f||null))};var result=(0,decorators[i])("accessor"===kind?{get:descriptor.get,set:descriptor.set}:descriptor[key],context);if("accessor"===kind){if(void 0===result)continue;if(null===result||"object"!=typeof result)throw new TypeError("Object expected");(_=accept(result.get))&&(descriptor.get=_),(_=accept(result.set))&&(descriptor.set=_),(_=accept(result.init))&&initializers.unshift(_)}else(_=accept(result))&&("field"===kind?initializers.unshift(_):descriptor[key]=_)}target&&Object.defineProperty(target,contextIn.name,descriptor),done=!0};import{TcHmiControl}from"Beckhoff.TwinCAT.HMI.Framework/index.esm.js";let TcHmiIFrame=(()=>{let ___onLoad_decorators,___onError_decorators,_classSuper=TcHmiControl.Control,_instanceExtraInitializers=[];return class extends _classSuper{static{const _metadata="function"==typeof Symbol&&Symbol.metadata?Object.create(_classSuper[Symbol.metadata]??null):void 0;___onLoad_decorators=[TcHmi.EventHandler({checkIsEnabled:!0})],___onError_decorators=[TcHmi.EventHandler({checkIsEnabled:!0})],__esDecorate(this,null,___onLoad_decorators,{kind:"method",name:"__onLoad",static:!1,private:!1,access:{has:obj=>"__onLoad"in obj,get:obj=>obj.__onLoad},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,___onError_decorators,{kind:"method",name:"__onError",static:!1,private:!1,access:{has:obj=>"__onError"in obj,get:obj=>obj.__onError},metadata:_metadata},null,_instanceExtraInitializers),_metadata&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:_metadata})}static#tchmiFQN="TcHmi.Controls.Beckhoff."+this.name;constructor(element,pcElement,attrs){super(element,pcElement,attrs)}__elementTemplateRoot=__runInitializers(this,_instanceExtraInitializers);__elementFrame;__loadingSpinner;__localizedElements=new Map;__localizationReader=void 0;__src;__showLoadingSpinner;__tchmiWithoutSplashScreen=!1;__previnit(){this.__elementTemplateRoot=this.__element.find(".TcHmi_Controls_Beckhoff_TcHmiIFrame-template"),0===this.__elementTemplateRoot.length&&(this.__elementTemplateRoot=this.__element.find(".tchmi-iframe-template")),this.__elementFrame=this.__elementTemplateRoot.find(".TcHmi_Controls_Beckhoff_TcHmiIFrame-template-frame"),0===this.__elementFrame.length&&(this.__elementFrame=this.__elementTemplateRoot.find(".tchmi-iframe-template-frame"));let loadingSpinner=TcHmi.Controls.get(this.getId()+"._TcHmiLoadingSpinner");if(0===this.__elementTemplateRoot.length||0===this.__elementFrame.length||void 0===loadingSpinner)throw new Error("Invalid Template.html");TCHMI_DESIGNER&&this.__destroyOnDestroy.push(this.__localization.watchEx({level:TcHmi.Locale.Level.Engineering},data=>{if(data.error===TcHmi.Errors.NONE&&data.reader){this.__localizationReader=data.reader;for(const[key,info]of this.__localizedElements){let localizedText=data.reader.get(key);info.textContent=localizedText}}})),this.__loadingSpinner=loadingSpinner,super.__previnit()}__init(){super.__init(),this.__destroyOnDestroy.push(TcHmi.EventProvider.registerDomEvent(this.__elementFrame,"load",this.__onLoad),TcHmi.EventProvider.registerDomEvent(this.__elementFrame,"error",this.__onError))}__attach(){super.__attach(),this.__destroyOnDetach.push(TcHmi.EventProvider.registerDomEvent(window,"message",evt=>{evt.source===this.__elementFrame[0].contentWindow&&evt.data.messageType&&("Ack:System.hideSplashScreen"===evt.data.messageType?this.__tchmiWithoutSplashScreen=!0:("System.FrameworkLoaded"===evt.data.messageType||"System.Initialized"===evt.data.messageType||"System.Error"===evt.data.messageType)&&this.__loadingSpinner?.setVisibility("Collapsed"))})),this.__processSrc()}__detach(){super.__detach()}destroy(){this.__keepAlive||super.destroy()}setSrc(valueNew){let convertedValue=TcHmi.ValueConverter.toString(valueNew);null===convertedValue&&(convertedValue=this.getAttributeDefaultValueInternal("Src")),convertedValue!==this.__src&&(this.__src=convertedValue,TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"Src"}),this.__processSrc())}getSrc(){return this.__src}__processSrc(){if(TCHMI_DESIGNER){const designerMessage=this.__element.find(".tchmi-designer-control-message")[0]??document.createElement("div");designerMessage.classList.add("tchmi-designer-control-message"),this.__src?(this.__localizedElements.delete("Engineering_Not_Configured"),designerMessage.textContent=this.__src):(designerMessage.textContent="Engineering_Not_Configured",this.__localizedElements.set("Engineering_Not_Configured",designerMessage),this.__localizationReader&&(designerMessage.textContent=this.__localizationReader.get("Engineering_Not_Configured"))),this.__element[0].appendChild(designerMessage)}else{this.__tchmiWithoutSplashScreen=!1,this.__showLoadingSpinner&&this.__loadingSpinner?.setVisibility("Visible");const iframeObj=this.__elementFrame[0];this.__src&&TcHmi.Access.checkAccess(this,"observe")&&this.getIsEnabled()?iframeObj.getAttribute("src")!==this.__src&&(iframeObj.src=this.__src):""!==iframeObj.getAttribute("src")&&(iframeObj.src="")}}setShowLoadingSpinner(valueNew){let convertedValue=TcHmi.ValueConverter.toBoolean(valueNew);null===convertedValue&&(convertedValue=this.getAttributeDefaultValueInternal("ShowLoadingSpinner")),convertedValue!==this.__showLoadingSpinner&&(this.__showLoadingSpinner=convertedValue,TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"ShowLoadingSpinner"}),this.__processShowLoadingSpinner())}getShowLoadingSpinner(){return this.__showLoadingSpinner}__processShowLoadingSpinner(){this.__loadingSpinner?.setVisibility("Collapsed")}__processAccessConfig(){super.__processAccessConfig(),this.__processSrc()}__processIsEnabled(){super.__processIsEnabled(),this.__processSrc()}__onLoad(event){this.__processWidth(),this.__processHeight(),TcHmi.EventProvider.raise(this.__id+".onLoad",event),this.__tchmiWithoutSplashScreen||this.__loadingSpinner?.setVisibility("Collapsed")}__onError(event){TcHmi.EventProvider.raise(this.__id+".onError",event),this.__loadingSpinner?.setVisibility("Collapsed")}}})();TcHmi.Controls.registerEx("TcHmiIFrame","TcHmi.Controls.Beckhoff",TcHmiIFrame,{injectInGlobalObject:!0});export{TcHmiIFrame as Control};