Files
m.heisig 2d11c43579 Added minimal functionality for Robot teaching
- Added minimal HMI
- Added possibility to open and close all chamber doors
2026-01-17 09:20:39 +01:00

1 line
146 KiB
JavaScript

import"./API/Access.js";import"./API/Animation.js";import"./API/Base64BinaryReader.js";import"./API/Base64BinaryWriter.js";import"./API/Binding.js";import"./API/Callback.js";import"./API/Config.js";import"./API/Control.js";import"./API/ControlFactory.js";import"./API/Controls.js";import"./API/Decorators.js";import"./API/DialogManager.js";import"./API/Engineering.ErrorPane.js";import"./API/Environment.js";import"./API/EventProvider.js";import"./API/Exception.js";import"./API/FileUploader.js";import"./API/FilterInstance.js";import"./API/Function.js";import"./API/Functions.js";import"./API/Interval.js";import"./API/Keyboard.js";import"./API/List.js";import"./API/LocalStorage.js";import"./API/Locale.js";import"./API/Localization.js";import"./API/Log.Controls.js";import"./API/Log.js";import"./API/ObjectPath.js";import"./API/Server.ADS.js";import"./API/Server.AuditTrail.js";import"./API/Server.Domains.js";import"./API/Server.Events.js";import"./API/Server.Historize.js";import"./API/Server.RecipeManagement.js";import"./API/Server.UserManagement.js";import"./API/Server.js";import"./API/StyleProvider.js";import"./API/Symbol.js";import"./API/SymbolExpression.js";import"./API/TcSpeech.js";import"./API/Theme.Properties.js";import"./API/Theme.Resources.js";import"./API/Theme.js";import"./API/TimedAsyncTask.js";import"./API/TopMostLayer.js";import"./API/Trigger.Actions.js";import"./API/Trigger.js";import"./API/Type.Schema.js";import"./API/Type.js";import"./API/UiProvider.KeyboardProvider.js";import"./API/UiProvider.PopupProvider.js";import"./API/UiProvider.js";import"./API/ValueConverter.js";import"./API/View.js";import"./API/_TypeGuards.IFunction.js";import"./API/_TypeGuards.js";import"./System/AutomationCommandManager.js";import"./System/SymbolEventHandler.js";import{automationCommandManager}from"./System/AutomationCommandManager.js";import{config,Data,hostPrefix,setConfig,setFrameworkDescription,setHostBaseUri,setHostPrefix,setServerSidePathAndQuery,Init as SystemInit,setIsPreloaded,setDestroyGlobalTrigger,setIsInitialized,mapControlNamesFromPackageManifestApi1ToApi0}from"./System/System.js";import{controlRegistrations}from"./System/RegistrationHelpers.js";import{functionRegistrations}from"./System/RegistrationHelpers.js";import*as Environment from"./API/Environment.js";import{Log}from"./API/Log.js";import*as DialogManager from"./API/DialogManager.js";import{dialogManager}from"./System/DialogManager.js";import{run as auditTrailRun}from"./System/AuditTrail.js";import{controlManager}from"./System/ControlManager.js";import{localizationManager}from"./System/LocalizationManager.js";import{themeManager}from"./System/ThemeManager.js";import{promiseTimeout,resolveQualifiedName,resolveReplaceExpressions,resolveViewMarkupReplaceExpressions,resolveContentMarkupReplaceExpressions,prepareTcHmiConfig,preparePackageManifest}from"./System/SystemFunctions.js";import{accessManager}from"./System/AccessManager.js";import{frameworkLocalization}from"./System/Locale.js";import{serverManager}from"./System/ServerManager.js";import*as ValueConverter from"./API/ValueConverter.js";import{splashScreen}from"./System/SplashScreen.js";import{typeManager}from"./System/Type.TypeManager.js";import{internalSymbolManager}from"./System/InternalSymbolManager.js";import{timerSymbolManager}from"./System/TimerSymbolManager.js";import{intervalManager}from"./System/IntervalManager.js";import{bindingManager}from"./System/BindingManager.js";import{triggerManager}from"./System/TriggerManager.js";import{viewManager}from"./System/ViewManager.js";import{keyboardManager}from"./System/KeyboardManager.js";import{init as symbolEventHandlerInit}from"./System/SymbolEventHandler.js";import{packageSymbolManager}from"./System/PackageSymbolManager.js";TCHMI_DYNAMIC_INSTANCE_ID=tchmi_create_guid();export function printGeneralLogInformation(){TCHMI_CONSOLE_LOG_LEVEL>=4&&(Log.debugEx("[Source=Framework, Module=TcHmi.Init] Loading TwinCAT HMI Application"),Log.debugEx("[Source=Framework, Module=TcHmi.Init] window.location.href: %o",window.location.href),Log.debugEx("[Source=Framework, Module=TcHmi.Init] window.navigator.appName: %o",window.navigator.appName),Log.debugEx("[Source=Framework, Module=TcHmi.Init] window.navigator.appCodeName: %o",window.navigator.appCodeName),"userAgentData"in window.navigator&&window.navigator.userAgentData?(Log.debugEx("[Source=Framework, Module=TcHmi.Init] navigator.userAgentData.brands: %o",window.navigator.userAgentData?.brands),Log.debugEx("[Source=Framework, Module=TcHmi.Init] navigator.userAgentData.platform: %o",window.navigator.userAgentData?.platform),Log.debugEx("[Source=Framework, Module=TcHmi.Init] navigator.userAgentData.mobile: %o",window.navigator.userAgentData?.mobile)):(Log.debugEx("[Source=Framework, Module=TcHmi.Init] window.navigator.appVersion: %o",window.navigator.appVersion),Log.debugEx("[Source=Framework, Module=TcHmi.Init] window.navigator.platform: %o",window.navigator.platform),Log.debugEx("[Source=Framework, Module=TcHmi.Init] window.navigator.userAgent: %o",window.navigator.userAgent)),Log.debugEx("[Source=Framework, Module=TcHmi.Init] window.navigator.cookieEnabled: %o",window.navigator.cookieEnabled),Log.debugEx("[Source=Framework, Module=TcHmi.Init] window.navigator.maxTouchPoints: %o",window.navigator.maxTouchPoints),Log.debugEx("[Source=Framework, Module=TcHmi.Init] TCHMI_DYNAMIC_INSTANCE_ID: %o",TCHMI_DYNAMIC_INSTANCE_ID),Log.debugEx("[Source=Framework, Module=TcHmi.Init] TCHMI_DEBUG_TIME_LOAD_LIBRARY: %o",TCHMI_DEBUG_TIME_LOAD_LIBRARY),Log.debugEx("[Source=Framework, Module=TcHmi.Init] TCHMI_ENGINEERING: %o",TCHMI_ENGINEERING),Log.debugEx("[Source=Framework, Module=TcHmi.Init] TCHMI_DESIGNER: %o",TCHMI_DESIGNER),Log.debugEx("[Source=Framework, Module=TcHmi.Init] TCHMI_LIVEVIEW: %o",TCHMI_LIVEVIEW),Log.debugEx("[Source=Framework, Module=TcHmi.Init] TCHMI_RUNTIME: %o",TCHMI_RUNTIME),Log.debugEx("[Source=Framework, Module=TcHmi.Init] TCHMI_TARGET_PARTIAL: %o",TCHMI_TARGET_PARTIAL),Log.debugEx("[Source=Framework, Module=TcHmi.Init] TCHMI_CONFIG_OVERRIDE: %o",TCHMI_CONFIG_OVERRIDE),TCHMI_ENGINEERING_WEBSOCKET?Log.debugEx("[Source=Framework, Module=TcHmi.Init] TCHMI_ENGINEERING_WEBSOCKET: %o",TCHMI_ENGINEERING_WEBSOCKET):Log.debugEx("[Source=Framework, Module=TcHmi.Init] Engineering communication will be done via server events."),Log.debugEx("[Source=Framework, Module=TcHmi.Init] TCHMI_CONSOLE_LOG_LEVEL: %o",TCHMI_CONSOLE_LOG_LEVEL),Log.debugEx("[Source=Framework, Module=TcHmi.Init] TCHMI_CONSOLE_LOG_PERSISTENT: %o",TCHMI_CONSOLE_LOG_PERSISTENT),Log.debugEx("[Source=Framework, Module=TcHmi.Init] TCHMI_CONSOLE_LOG_PERSISTENT_MAX_ENTRIES: %o",TCHMI_CONSOLE_LOG_PERSISTENT_MAX_ENTRIES),Log.debugEx("[Source=Framework, Module=TcHmi.Init] TCHMI_CONSOLE_LOG_TCHMISERVER_MESSAGES: %o",TCHMI_CONSOLE_LOG_TCHMISERVER_MESSAGES),Log.debugEx("[Source=Framework, Module=TcHmi.Init] TCHMI_LOG_ENGINEERING_COM_MESSAGES: %o",TCHMI_LOG_ENGINEERING_COM_MESSAGES),Log.debugEx("[Source=Framework, Module=TcHmi.Init] TCHMI_UNITTEST_MODE: %o",TCHMI_UNITTEST_MODE),SystemInit.buildtime&&Log.debugEx("[Source=Framework, Module=TcHmi.Init] TcHmi.System.buildtime: %o",SystemInit.buildtime))}export function printForcedLogInformation(){TCHMI_FLAG_OVERRIDES&&(TcHmi.Log.Force=!0,Log.infoEx("Overrides are used for some client flags.\nTo get rid of the flag overrides either clear the browsers localStorage entry with the key %o or reset the settings on server config page %s. The following flag overrides are currently used: %o","TCHMI_FLAG_OVERRIDES",`${Environment.getHostBaseUri()}/Config/Client`,TCHMI_FLAG_OVERRIDES),TcHmi.Log.Force=!1)}export let __initStep=0;export let __fetchFromIndexedDb=!0;export let firstLoadAfterPublish=!1;export function prepare(){TcHmi.System??={};const pathName=window.location.pathname,dirIndex=pathName.lastIndexOf("/");0!==dirIndex&&setHostPrefix(pathName.substring(1,dirIndex)+":"),document.body.innerHTML="",automationCommandManager.postMessageToParent({messageType:"System.InitStageFinished",stage:"Preparing Init"})}export function run(initStep){let INIT_STAGE;Log.performanceLogStart("[Source=Framework, Module=TcHmi.Init] INIT_OVERALL"),__initStep=initStep,function(INIT_STAGE){INIT_STAGE[INIT_STAGE.BaseConfiguration=0]="BaseConfiguration",INIT_STAGE[INIT_STAGE.PreparingSystem=1]="PreparingSystem",INIT_STAGE[INIT_STAGE.PackagesConfiguration=2]="PackagesConfiguration",INIT_STAGE[INIT_STAGE.PreparingControls=3]="PreparingControls",INIT_STAGE[INIT_STAGE.PreparingFunctions=4]="PreparingFunctions",INIT_STAGE[INIT_STAGE.Connectivity=5]="Connectivity",INIT_STAGE[INIT_STAGE.Validation=6]="Validation",INIT_STAGE[INIT_STAGE.LoadingTypeDefinitions=7]="LoadingTypeDefinitions",INIT_STAGE[INIT_STAGE.LoadingUserControls=8]="LoadingUserControls",INIT_STAGE[INIT_STAGE.LoadingContent=9]="LoadingContent",INIT_STAGE[INIT_STAGE.LoadingViews=10]="LoadingViews",INIT_STAGE[INIT_STAGE.CompilingContent=11]="CompilingContent",INIT_STAGE[INIT_STAGE.CompilingViews=12]="CompilingViews",INIT_STAGE[INIT_STAGE.PreloadingBindings=13]="PreloadingBindings",INIT_STAGE[INIT_STAGE.Finalize=14]="Finalize",INIT_STAGE[INIT_STAGE.Loaded=15]="Loaded"}(INIT_STAGE||(INIT_STAGE={}));let indexedDbRequest,initStage=INIT_STAGE.BaseConfiguration,configControls=[],configFunctions=[],configUserControls=[],configViews=[],configContents=[],packageControlsLoaded=new Set,packageControls=[],packageFunctionsLoaded=new Set,packageFunctions=[],packageUserControlsLoaded=new Set,packageUserControls=[],packageContentsLoaded=new Set,packageContents=[],packageViewsLoaded=new Set,packageViews=[],xhrCacheSuffix=TCHMI_ENGINEERING?"?preventcache="+TCHMI_DYNAMIC_INSTANCE_ID:"";const PendingCounter={PackageLoaded:2e9,BaseConfigLoaded:2e9,BaseDescriptionLoaded:2e9,BasePackageLoaded:2e9,OpenEngineeringConnection:2e9,OpenServerConnection:2e9,ConfigControlsDescriptionLoaded:2e9,PackageControlsDescriptionLoaded:2e9,ControlsDescriptionResolved:2e9,TypeDefinitionsResolved:2e9,ServerSymbolMetaDataCacheResolved:2e9,AuditTrailInitialized:2e9,ControlsTemplatesLoaded:2e9,PackageFunctionDescriptionLoaded:2e9,ConfigFunctionDescriptionLoaded:2e9,PackageUserControlsLoaded:2e9,ConfigUserControlsLoaded:2e9,PackageContentsLoaded:2e9,ConfigContentsLoaded:2e9,PackageViewsLoaded:2e9,ConfigViewsLoaded:2e9,ContentCompiled:2e9,ViewCompiled:2e9};let initStageInfo=new Map([[INIT_STAGE.BaseConfiguration,{id:0,text:"System Configuration",toDo:2,done:0}],[INIT_STAGE.PreparingSystem,{id:1,text:"Preparing System",toDo:1,done:0}],[INIT_STAGE.PackagesConfiguration,{id:2,text:"Loading Packages",toDo:0,done:0}],[INIT_STAGE.PreparingControls,{id:3,text:"Preparing Controls",toDo:1,done:0}],[INIT_STAGE.PreparingFunctions,{id:4,text:"Preparing Functions",toDo:1,done:0}],[INIT_STAGE.Connectivity,{id:5,text:"Connectivity",toDo:2,done:0}],[INIT_STAGE.Validation,{id:6,text:"Validation",toDo:1,done:0}],[INIT_STAGE.LoadingTypeDefinitions,{id:7,text:"Type Definitions",toDo:1,done:0}],[INIT_STAGE.LoadingUserControls,{id:8,text:"Loading UserControls",toDo:0,done:0}],[INIT_STAGE.LoadingContent,{id:9,text:"Loading Content",toDo:0,done:0}],[INIT_STAGE.LoadingViews,{id:10,text:"Loading Views",toDo:0,done:0}],[INIT_STAGE.CompilingContent,{id:11,text:"Compiling Content",toDo:0,done:0}],[INIT_STAGE.CompilingViews,{id:12,text:"Compiling Views",toDo:0,done:0}],[INIT_STAGE.PreloadingBindings,{id:13,text:"Preloading Bindings",toDo:0,done:0}],[INIT_STAGE.Finalize,{id:14,text:"Finalize",toDo:1,done:0}],[INIT_STAGE.Loaded,{id:15,text:"Loaded",toDo:0,done:0}]]);const loadNextStage=newStage=>{const oldStageInfo=initStageInfo.get(initStage);if(-1===TCHMI_CONSOLE_LOG_LEVEL){const newStageInfo=initStageInfo.get(newStage);newStageInfo.startTime=performance.now(),oldStageInfo.duration=newStageInfo.startTime-oldStageInfo.startTime}automationCommandManager.postMessageToParent({messageType:"System.InitStageFinished",stage:oldStageInfo.text}),initStage=newStage},updateSplashScreen=option=>{if(TCHMI_DESIGNER||TCHMI_SINGLECONTROL)option?.callInitStateMachine&&InitStateMachine();else{if(option?.updateVersion)switch(config.splash.versionSource){case"Framework":splashScreen.updateVersionInfo("Version: "+TcHmi.version.full);break;case"Project":splashScreen.updateVersionInfo("Version: "+config.projectVersion)}if(!option?.skipStageUpdate){const stage=initStageInfo.get(initStage);if(!stage)return;splashScreen.updateStageInfo("Stage "+(stage.id+1)+" / "+initStageInfo.size+": "+stage.text),0===stage.done&&0===stage.toDo?splashScreen.updateStageProgress(100):0===stage.done&&stage.toDo>0?splashScreen.updateStageProgress(0):splashScreen.updateStageProgress(stage.done/stage.toDo*100)}option?.callInitStateMachine&&!TCHMI_UNITTEST_INIT_NO_NEXT_STAGE&&(document.hidden?InitStateMachine():setTimeout(()=>{InitStateMachine()}))}},loadPackage=function(packageInfo,callback=null){const cleanPath=tchmi_path(packageInfo.basePath+"/Manifest.json");let xhr=new XMLHttpRequest;xhr.open("GET",tchmi_encode_uri_components(cleanPath)+xhrCacheSuffix);let error=function(_evt){TcHmi.Callback.callSafeEx(callback,null,{error:TcHmi.Errors.ERROR,details:{code:TcHmi.Errors.ERROR,message:TcHmi.Errors[TcHmi.Errors.ERROR],reason:`Failed to load package: "${packageInfo.name}" from "Properties/tchmiconfig.json". Missing "Manifest.json". Expected path: "${cleanPath}". Details: HTTP error ${xhr.status} ${xhr.statusText}`}})};xhr.addEventListener("load",function(evt){if(200!==xhr.status)return void error(evt);const manifestRes=TcHmi.ValueConverter.toObjectEx(resolveReplaceExpressions(xhr.responseText,{PkgId:packageInfo.name,PkgBasePath:packageInfo.basePath}));let manifest=manifestRes.value;if(!manifest||!manifest.modules)return void TcHmi.Callback.callSafeEx(callback,null,{error:TcHmi.Errors.ERROR,details:{code:TcHmi.Errors.ERROR,message:TcHmi.Errors[TcHmi.Errors.ERROR],reason:`Failed to load package: "${packageInfo.name}" from "Properties/tchmiconfig.json". Response returns no valid "Manifest.json" content. Details: ${Log.buildMessage(manifestRes.details)}`}});preparePackageManifest(manifest);let packageObj={name:packageInfo.name,basePath:tchmi_path(packageInfo.basePath),manifest,config:packageInfo};if(Data.packages.has(packageObj.name))Log.warnEx(`[Source=Framework, Module=TcHmi.Init] Found duplicate entry in Properties/tchmiconfig.json#package ${packageObj.name} Skipping entry.`);else if(Data.packages.set(packageObj.name,packageObj),manifest.modules.length>0)for(let i=0,ii=manifest.modules.length;i<ii;i++){let module=manifest.modules[i];if(module&&"Control"===module.type){let descrUrl=tchmi_path(packageObj.basePath+"/"+module.basePath+"/"+module.descriptionFile);if(packageControlsLoaded.has(descrUrl))continue;packageControlsLoaded.add(descrUrl),packageControls.push({package:packageObj,module})}else if(module&&"Function"===module.type){let descrUrl=tchmi_path(packageObj.basePath+"/"+module.basePath+"/"+module.descriptionFile);if(packageFunctionsLoaded.has(descrUrl))continue;packageFunctionsLoaded.add(descrUrl),packageFunctions.push({package:packageObj,module})}else if(module&&"UserControl"===module.type){let packageInfoModuleConfig,url=tchmi_path(packageObj.basePath+"/"+module.path);if(packageFunctionsLoaded.has(url))continue;if(packageInfo.userControls)for(let piUserControl of packageInfo.userControls)if(tchmi_path(piUserControl.url)===tchmi_path(module.path)){packageInfoModuleConfig=piUserControl;break}packageInfoModuleConfig||(packageInfoModuleConfig={url}),Data.isPackageUserControl.set(url,!0),packageUserControlsLoaded.add(url),packageUserControls.push({package:packageObj,module,config:packageInfoModuleConfig}),Data.Modules.userControls.map.set(url,{error:TcHmi.Errors.NONE,package:packageObj,manifestData:module,configData:packageInfoModuleConfig})}else if(module&&"Content"===module.type){let packageInfoModuleConfig,url=tchmi_path(packageObj.basePath+"/"+module.path);if(packageFunctionsLoaded.has(url))continue;if(packageInfo.content)for(let piContent of packageInfo.content)if(tchmi_path(piContent.url)===tchmi_path(module.path)){packageInfoModuleConfig=piContent;break}Data.isPackageContent.set(url,!0),packageContentsLoaded.add(url),packageContents.push({package:packageObj,module,config:packageInfoModuleConfig}),Data.Modules.contents.map.set(url,{error:TcHmi.Errors.NONE,package:packageObj,manifestData:module,configData:packageInfoModuleConfig}),packageInfoModuleConfig&&(void 0===packageInfoModuleConfig.preload&&(packageInfoModuleConfig.preload=!1),packageInfoModuleConfig.preload&&(initStageInfo.get(INIT_STAGE.LoadingContent).toDo++,initStageInfo.get(INIT_STAGE.CompilingContent).toDo++,packageInfoModuleConfig.keepAlive=!0),void 0===packageInfoModuleConfig.keepAlive&&(packageInfoModuleConfig.keepAlive=!1),packageInfoModuleConfig.keepAlive&&!TCHMI_DESIGNER?Data.isKeepAlivePartial.set(url,!0):Data.isKeepAlivePartial.set(url,!1),packageInfoModuleConfig.preloadBindings&&!TCHMI_DESIGNER?Data.isPreloadBindingPartial.set(url,!0):Data.isPreloadBindingPartial.set(url,!1),Data.isLoadSyncContent.set(url,packageInfoModuleConfig.loadSync??!1))}else if(module&&"View"===module.type){let packageInfoModuleConfig,url=tchmi_path(packageObj.basePath+"/"+module.path);if(packageFunctionsLoaded.has(url))continue;if(packageInfo.views)for(let piView of packageInfo.views)if(tchmi_path(piView.url)===tchmi_path(module.path)){packageInfoModuleConfig=piView;break}Data.isPackageView.set(url,!0),packageViewsLoaded.add(url),packageViews.push({package:packageObj,module,config:packageInfoModuleConfig}),Data.Modules.views.map.set(url,{error:TcHmi.Errors.NONE,package:packageObj,manifestData:module,configData:packageInfoModuleConfig}),packageInfoModuleConfig&&(void 0===packageInfoModuleConfig.preload&&(packageInfoModuleConfig.preload=!1),packageInfoModuleConfig.preload&&(initStageInfo.get(INIT_STAGE.LoadingViews).toDo++,initStageInfo.get(INIT_STAGE.CompilingViews).toDo++,packageInfoModuleConfig.keepAlive=!0),void 0===packageInfoModuleConfig.keepAlive&&(packageInfoModuleConfig.keepAlive=!1),packageInfoModuleConfig.keepAlive?Data.isKeepAlivePartial.set(url,!0):Data.isKeepAlivePartial.set(url,!1),packageInfoModuleConfig.preloadBindings&&!TCHMI_DESIGNER?Data.isPreloadBindingPartial.set(url,!0):Data.isPreloadBindingPartial.set(url,!1))}}Log.debugEx("[Source=Framework, Module=TcHmi.Init] Loading %o finished!",cleanPath),TcHmi.Callback.callSafeEx(callback,null,{error:TcHmi.Errors.NONE}),manifest=null}),xhr.addEventListener("error",error),xhr.send()},InitStateMachine=function InitStateMachine(){switch(Log.debugEx("[Source=Framework, Module=TcHmi.Init] Entering init state: %o",INIT_STATE[__initStep]),__initStep){case INIT_STATE.IDLE:break;case INIT_STATE.CHECK_BROWSER_FEATURES:{Log.performanceLog(`[Source=Framework, Module=TcHmi.Init] INIT_STATE.${INIT_STATE[__initStep]}`);let missingBrowserFeatures=[],neededInGlobal=["WebSocket","Map","WeakMap","MutationObserver","indexedDB","Set","Promise"];for(let feature of neededInGlobal)feature in window||missingBrowserFeatures.push(feature);let neededInDiv=["replaceWith","before","after","prepend","append"];for(let feature of neededInDiv)feature in document.head||missingBrowserFeatures.push("Node."+feature);let neededInArray=["find","includes"];for(let feature of neededInArray)feature in Array.prototype||missingBrowserFeatures.push("Array.prototype."+feature);Array.from||missingBrowserFeatures.push("Array.from");let neededInString=["startsWith","endsWith","includes"];for(let feature of neededInString)feature in String.prototype||missingBrowserFeatures.push("String.prototype."+feature);if(document.head.classList){const testDiv=document.createElement("div");testDiv.classList.add("a","b"),"a b"!==testDiv.className&&missingBrowserFeatures.push("Element.classList.add with multiple arguments"),testDiv.className="a",testDiv.classList.toggle("a",!0),"a"!==testDiv.className&&missingBrowserFeatures.push("Element.classList.toggle with force")}else missingBrowserFeatures.push("Element.classList");if(missingBrowserFeatures.length>0)return Log.errorEx("[Source=Framework, Module=TcHmi.Init] Browser does not support required features: "+missingBrowserFeatures.join(", ")),dialogManager.showDialog("__TcHmiMain",!0,TcHmi.DialogManager.DialogType.Overlay),dialogManager.updateTextEx("__TcHmiMain",`Browser does not support required features:\n <ul>\n <li>${missingBrowserFeatures.join("</li>\n<li>")}</li>\n </ul>`,{severity:TcHmi.DialogManager.DialogSeverity.Error,buttonReload:!TCHMI_DESIGNER}),__initStep=INIT_STATE.ERROR,void InitStateMachine();__initStep=INIT_STATE.BASE_CONFIGURATION}case INIT_STATE.BASE_CONFIGURATION:{if(Log.performanceLog(`[Source=Framework, Module=TcHmi.Init] INIT_STATE.${INIT_STATE[__initStep]}`),SystemInit.buildtime){window.localStorage.getItem(hostPrefix+"TcHmi.Init.cachedBuildtime")!==SystemInit.buildtime&&(firstLoadAfterPublish=!0),window.localStorage.setItem(hostPrefix+"TcHmi.Init.cachedBuildtime",SystemInit.buildtime)}__initStep=INIT_STATE.IDLE,PendingCounter.BaseConfigLoaded=1;const tchmiConfigPath="Properties/tchmiconfig.json";let xhrTcHmiConfig=new XMLHttpRequest;xhrTcHmiConfig.open("GET",tchmi_encode_uri_components(tchmiConfigPath)+xhrCacheSuffix);let xhrTcHmiConfigSuccess=function(evt){const hostBaseUri=xhrTcHmiConfig.getResponseHeader("X-Custom-Reverse-Proxy-Host-Uri");if(hostBaseUri&&(setHostBaseUri(hostBaseUri),setHostPrefix(hostBaseUri+":"),window.location.href.startsWith(hostBaseUri)&&setServerSidePathAndQuery(window.location.href.substring(hostBaseUri.length))),200!==xhrTcHmiConfig.status)return void xhrTcHmiConfigError(evt);if(__initStep===INIT_STATE.ERROR)return;const configResult=ValueConverter.toObjectEx(xhrTcHmiConfig.responseText);if(configResult.error!==TcHmi.Errors.NONE||!configResult.value)return Log.errorEx(`[Source=Framework, Module=TcHmi.Init] Configuration file: ${xhrTcHmiConfig.responseURL||tchmiConfigPath} is not valid JSON. Details: `+Log.buildMessage(configResult.details)),dialogManager.showDialog("__TcHmiMain",!0,TcHmi.DialogManager.DialogType.Overlay),dialogManager.updateTextEx("__TcHmiMain",'Configuration file: "Properties/tchmiconfig.json" is not valid JSON.',{severity:TcHmi.DialogManager.DialogSeverity.Error,buttonReload:!TCHMI_DESIGNER}),__initStep=INIT_STATE.ERROR,void InitStateMachine();setConfig(configResult.value);for(let key in config)if(key.startsWith("__COMMENT"))return Log.errorEx('[Source=Framework, Module=TcHmi.Init] Configuration file: "Properties/tchmiconfig.json" is not valid. Content was not generated from "tchmiconfig.tpl.json".'),dialogManager.showDialog("__TcHmiMain",!0,TcHmi.DialogManager.DialogType.Overlay),dialogManager.updateTextEx("__TcHmiMain",'Configuration file: "Properties/tchmiconfig.json" is not valid. Content was not generated from "tchmiconfig.tpl.json".',{severity:TcHmi.DialogManager.DialogSeverity.Error,buttonReload:!TCHMI_DESIGNER}),__initStep=INIT_STATE.ERROR,void InitStateMachine();prepareTcHmiConfig(config),configControls=[];let configControlsPrepared=new Set;for(const entry of tchmi_clone_object(config.controls)){entry.basePath=tchmi_path(entry.basePath);let url=tchmi_path(`${entry.basePath}/${entry.descriptionFile}`);configControlsPrepared.has(url)||(configControlsPrepared.add(url),configControls.push(entry))}configFunctions=[];let configFunctionsPrepared=new Set;for(const entry of tchmi_clone_object(config.userFunctions))entry.url=tchmi_path(entry.url),configFunctionsPrepared.has(entry.url)||(configFunctionsPrepared.add(entry.url),configFunctions.push(entry));configUserControls=[];let configUserControlsPrepared=new Set;for(const entry of tchmi_clone_object(config.userControls))entry.url=tchmi_path(entry.url),configUserControlsPrepared.has(entry.url)||(configUserControlsPrepared.add(entry.url),configUserControls.push(entry),Data.isConfigUserControl.set(entry.url,!0));initStageInfo.get(INIT_STAGE.LoadingUserControls).toDo+=2*configUserControls.length,configContents=[];let configContentsPrepared=new Set;for(const entry of tchmi_clone_object(config.content))entry.url=tchmi_path(entry.url),configContentsPrepared.has(entry.url)||(entry.preload&&(initStageInfo.get(INIT_STAGE.LoadingContent).toDo++,initStageInfo.get(INIT_STAGE.CompilingContent).toDo++,entry.keepAlive=!0),void 0===entry.keepAlive&&(entry.keepAlive=!1),!entry.keepAlive||TCHMI_DESIGNER||TCHMI_SINGLECONTROL?Data.isKeepAlivePartial.set(entry.url,!1):Data.isKeepAlivePartial.set(entry.url,!0),!0!==entry.preloadBindings||TCHMI_DESIGNER||TCHMI_SINGLECONTROL?Data.isPreloadBindingPartial.set(entry.url,!1):Data.isPreloadBindingPartial.set(entry.url,!0),Data.isLoadSyncContent.set(entry.url,entry.loadSync??!1),configContentsPrepared.add(entry.url),configContents.push(entry),Data.isConfigContent.set(entry.url,!0));configViews=[];let configViewsPrepared=new Set;for(const entry of tchmi_clone_object(config.views))entry.url=tchmi_path(entry.url),configViewsPrepared.has(entry.url)||(entry.preload&&(initStageInfo.get(INIT_STAGE.LoadingViews).toDo++,initStageInfo.get(INIT_STAGE.CompilingViews).toDo++,entry.keepAlive=!0),void 0===entry.keepAlive&&(entry.keepAlive=!1),entry.keepAlive?Data.isKeepAlivePartial.set(entry.url,!0):Data.isKeepAlivePartial.set(entry.url,!1),!0!==entry.preloadBindings||TCHMI_DESIGNER||TCHMI_SINGLECONTROL?Data.isPreloadBindingPartial.set(entry.url,!1):Data.isPreloadBindingPartial.set(entry.url,!0),configViewsPrepared.add(entry.url),configViews.push(entry),Data.isConfigView.set(entry.url,!0));if(initStageInfo.get(INIT_STAGE.PackagesConfiguration).toDo=config.packages.length,TCHMI_ENGINEERING){const TchmiConfigOverride=TCHMI_CONFIG_OVERRIDE;TchmiConfigOverride&&(void 0!==TchmiConfigOverride.basePath&&(config.basePath=TchmiConfigOverride.basePath),TchmiConfigOverride.tcHmiServer&&TchmiConfigOverride.tcHmiServer.websocketIntervalTime&&(config.tcHmiServer.websocketIntervalTime=TchmiConfigOverride.tcHmiServer.websocketIntervalTime))}Log.debugEx("[Source=Framework, Module=TcHmi.Init] Loading %o finished.","Properties/tchmiconfig.json"),PendingCounter.BaseConfigLoaded--,0===PendingCounter.BaseConfigLoaded&&(__initStep=INIT_STATE.BASE_DESCRIPTION,updateSplashScreen({callInitStateMachine:!0}))},xhrTcHmiConfigError=function(evt){Log.errorEx(`[Source=Framework, Module=TcHmi.Init] Loading ${xhrTcHmiConfig.responseURL||tchmiConfigPath} failed! Details: HTTP error ${xhrTcHmiConfig.status} ${xhrTcHmiConfig.statusText}`),dialogManager.showDialog("__TcHmiMain",!0,TcHmi.DialogManager.DialogType.Overlay),dialogManager.updateTextEx("__TcHmiMain",`Loading configuration file: "Properties/tchmiconfig.json" failed. Details: HTTP error ${xhrTcHmiConfig.status} ${xhrTcHmiConfig.statusText}`,{severity:TcHmi.DialogManager.DialogSeverity.Error,buttonReload:!TCHMI_DESIGNER}),__initStep!==INIT_STATE.ERROR&&(__initStep=INIT_STATE.ERROR,updateSplashScreen({callInitStateMachine:!0,skipStageUpdate:!0}))};xhrTcHmiConfig.addEventListener("load",xhrTcHmiConfigSuccess),xhrTcHmiConfig.addEventListener("error",xhrTcHmiConfigError),xhrTcHmiConfig.send()}break;case INIT_STATE.BASE_DESCRIPTION:{__initStep=INIT_STATE.IDLE,Log.performanceLog(`[Source=Framework, Module=TcHmi.Init] INIT_STATE.${INIT_STATE[__initStep]}`),PendingCounter.BaseDescriptionLoaded=1;const frameworkDescriptionPath=tchmi_path(config.basePath+"/Description.json");let xhrFwDescr=new XMLHttpRequest;xhrFwDescr.open("GET",tchmi_encode_uri_components(frameworkDescriptionPath)+xhrCacheSuffix);let xhrFwDescrSuccess=function(evt){if(200!==xhrFwDescr.status)return void xhrFwDescrError(evt);if(__initStep===INIT_STATE.ERROR)return;const frameworkDescrRes=ValueConverter.toObjectEx(xhrFwDescr.responseText);if(!frameworkDescrRes.value||!frameworkDescrRes.value.version)return Log.errorEx(`[Source=Framework, Module=TcHmi.Init] Loading Framework description file: "${frameworkDescriptionPath}" failed. File is not a valid Framework description file. Details: ${Log.buildMessage(frameworkDescrRes.details)}`),dialogManager.showDialog("__TcHmiMain",!0,TcHmi.DialogManager.DialogType.Overlay),dialogManager.updateTextEx("__TcHmiMain",`Loading Framework description file: "${frameworkDescriptionPath}" failed. File is not a valid Framework description file.`,{severity:TcHmi.DialogManager.DialogSeverity.Error,buttonReload:!TCHMI_DESIGNER}),__initStep=INIT_STATE.ERROR,void InitStateMachine();setFrameworkDescription(frameworkDescrRes.value),TcHmi.version=frameworkDescrRes.value.version,Log.debugEx("[Source=Framework, Module=TcHmi.Init] TcHmi.version.full: %o",TcHmi.version.full),PendingCounter.BaseDescriptionLoaded--,0===PendingCounter.BaseDescriptionLoaded&&(SystemInit.__resolveInitializedBaseConfigPromise(),__initStep=INIT_STATE.BASE_PACKAGE_LOAD,updateSplashScreen({callInitStateMachine:!0,updateVersion:!0}))},xhrFwDescrError=function(evt){Log.errorEx(`[Source=Framework, Module=TcHmi.Init] Loading Framework description file: "${frameworkDescriptionPath}" failed. Details: HTTP error ${xhrFwDescr.status} ${xhrFwDescr.statusText}`),dialogManager.showDialog("__TcHmiMain",!0,TcHmi.DialogManager.DialogType.Overlay),dialogManager.updateTextEx("__TcHmiMain",`Loading Framework description file: "${frameworkDescriptionPath}" failed. Details: HTTP error ${xhrFwDescr.status} ${xhrFwDescr.statusText}`,{severity:TcHmi.DialogManager.DialogSeverity.Error,buttonReload:!TCHMI_DESIGNER}),__initStep!==INIT_STATE.ERROR&&(__initStep=INIT_STATE.ERROR,InitStateMachine())};xhrFwDescr.addEventListener("load",xhrFwDescrSuccess),xhrFwDescr.addEventListener("error",xhrFwDescrError),xhrFwDescr.send()}break;case INIT_STATE.BASE_PACKAGE_LOAD:{__initStep=INIT_STATE.IDLE,Log.performanceLog(`[Source=Framework, Module=TcHmi.Init] INIT_STATE.${INIT_STATE[__initStep]}`),PendingCounter.BasePackageLoaded=1;const frameworkPackageInfo=config.packages.find(packageInfo=>"Beckhoff.TwinCAT.HMI.Framework"===packageInfo.name);if(!frameworkPackageInfo)return Log.errorEx('[Source=Framework, Module=TcHmi.Init] Loading Framework package "Beckhoff.TwinCAT.HMI.Framework" failed. Details: Package information in tchmiconfig.json is missing.'),dialogManager.showDialog("__TcHmiMain",!0,TcHmi.DialogManager.DialogType.Overlay),dialogManager.updateTextEx("__TcHmiMain",'Loading Framework package "Beckhoff.TwinCAT.HMI.Framework" failed. Details: Package information in tchmiconfig.json is missing.',{severity:TcHmi.DialogManager.DialogSeverity.Error,buttonReload:!TCHMI_DESIGNER}),__initStep=INIT_STATE.ERROR,void InitStateMachine();loadPackage(tchmi_clone_object(frameworkPackageInfo),data=>{data.error===TcHmi.Errors.NONE?(PendingCounter.BasePackageLoaded--,initStageInfo.get(initStage).done++,PendingCounter.BasePackageLoaded<=0?(__initStep=INIT_STATE.LOCALIZATION_EARLY,updateSplashScreen({callInitStateMachine:!0})):updateSplashScreen()):(Log.errorEx('[Source=Framework, Module=TcHmi.Init] Loading Framework package "Beckhoff.TwinCAT.HMI.Framework" failed. Details: '+Log.buildMessage(data.details)),dialogManager.showDialog("__TcHmiMain",!0,TcHmi.DialogManager.DialogType.Overlay),dialogManager.updateTextEx("__TcHmiMain",'Loading Framework package "Beckhoff.TwinCAT.HMI.Framework" failed. Details: '+Log.buildMessage(data.details),{severity:TcHmi.DialogManager.DialogSeverity.Error,buttonReload:!TCHMI_DESIGNER}),__initStep=INIT_STATE.ERROR,InitStateMachine())});break}case INIT_STATE.LOCALIZATION_EARLY:{Log.performanceLog(`[Source=Framework, Module=TcHmi.Init] INIT_STATE.${INIT_STATE[__initStep]}`);let frameworkPackage=Data.packages.get("Beckhoff.TwinCAT.HMI.Framework");if(!frameworkPackage)return Log.errorEx('[Source=Framework, Module=TcHmi.Init] Loading Framework package "Beckhoff.TwinCAT.HMI.Framework" failed. Details: Package information is missing.'),dialogManager.showDialog("__TcHmiMain",!0,TcHmi.DialogManager.DialogType.Overlay),dialogManager.updateTextEx("__TcHmiMain",'Loading Framework package "Beckhoff.TwinCAT.HMI.Framework" failed. Details: Package information is missing.',{severity:TcHmi.DialogManager.DialogSeverity.Error,buttonReload:!TCHMI_DESIGNER}),__initStep=INIT_STATE.ERROR,void InitStateMachine();let frameworkLanguageModules=frameworkPackage.manifest.modules.filter(module=>"Language"===module.type);if(frameworkLanguageModules){for(let frameworkLanguageModule of frameworkLanguageModules)if(Array.isArray(frameworkLanguageModule.files)){const sanitizedLanguageArray=[];for(const file of frameworkLanguageModule.files)sanitizedLanguageArray.push(tchmi_path(frameworkPackage.basePath+"//"+file));localizationManager.registerLocalizationFile("TcHmi.System.Localization.Framework",frameworkLanguageModule.locale,sanitizedLanguageArray)}else localizationManager.registerLocalizationFile("TcHmi.System.Localization.Framework",frameworkLanguageModule.locale,tchmi_path(frameworkPackage.basePath+"//"+frameworkLanguageModule.files));if(config.languagesForFramework)for(const[locale,languageEntry]of Object.entries(config.languagesForFramework))if(Array.isArray(languageEntry)){const sanitizedLanguageArray=[];for(const subEntry of languageEntry)sanitizedLanguageArray.push(tchmi_path(subEntry));localizationManager.registerLocalizationFile("TcHmi.System.Localization.Framework",locale,sanitizedLanguageArray)}else localizationManager.registerLocalizationFile("TcHmi.System.Localization.Framework",locale,tchmi_path(languageEntry));let pending=0;const finalize=()=>{pending>0||(__initStep=INIT_STATE.THEME_MANAGER_EARLY,updateSplashScreen({callInitStateMachine:!0,skipStageUpdate:!0}))};TCHMI_DESIGNER&&(pending++,localizationManager.processLocale("en",{level:TcHmi.Locale.Level.Engineering},data=>{pending--,finalize()})),pending++,localizationManager.processLocale("en",{level:TcHmi.Locale.Level.Application},data=>{pending--,finalize()})}break}case INIT_STATE.THEME_MANAGER_EARLY:TCHMI_DESIGNER?(document.documentElement.classList.add("tchmi-html-designer"),document.body.classList.add("tchmi-body-designer")):(document.documentElement.classList.add("tchmi-html-runtime"),document.body.classList.add("tchmi-body-runtime")),document.body.firstElementChild||document.body.firstChild?.nodeType!==Node.TEXT_NODE||(document.body.textContent=""),Log.performanceLog(`[Source=Framework, Module=TcHmi.Init] INIT_STATE.${INIT_STATE[__initStep]}`),__initStep=INIT_STATE.IDLE,themeManager.setTheme(config.activeTheme,!1),themeManager.processActiveTheme(()=>{SystemInit.__resolveInitializedThemesPromise(),initStageInfo.get(initStage).done++,__initStep=INIT_STATE.CACHE_LOADING,loadNextStage(INIT_STAGE.PreparingSystem),TCHMI_DESIGNER||splashScreen.show(),updateSplashScreen({callInitStateMachine:!0})});break;case INIT_STATE.CACHE_LOADING:{Log.performanceLog(`[Source=Framework, Module=TcHmi.Init] INIT_STATE.${INIT_STATE[__initStep]}`),__fetchFromIndexedDb=!config.disableLoadingOptimization,TCHMI_RUNTIME||(__fetchFromIndexedDb=!1);const lastLoadingUser=window.localStorage.getItem(hostPrefix+"TcHmi.Init.lastLoadingUser");if(lastLoadingUser||(__fetchFromIndexedDb=!1),!__fetchFromIndexedDb)return __initStep=INIT_STATE.SYSTEM_PREPARATION,void InitStateMachine();TcHmi.EventProvider.register("onUserChanged",(evt,currentUser)=>{if(evt.destroy(),currentUser)if(lastLoadingUser)lastLoadingUser!==currentUser&&(__fetchFromIndexedDb=!1,window.localStorage.removeItem(hostPrefix+"TcHmi.lastLoadingUser"));else try{window.localStorage.setItem(hostPrefix+"TcHmi.lastLoadingUser",currentUser)}catch(ex){}});const currentObjectStoreNames=["controlTemplate","contentMarkup","userControlMarkup","userControlConfig"].sort();indexedDbRequest=window.indexedDB.open(hostPrefix+"TcHmi.Init"),indexedDbRequest.onerror=function(event){indexedDbRequest=void 0},indexedDbRequest.onupgradeneeded=function(event){try{for(const name of currentObjectStoreNames){if(this.result.objectStoreNames.contains(name))try{this.result.deleteObjectStore(name)}catch(e){}this.result.createObjectStore(name)}}catch(e){}},indexedDbRequest.onsuccess=function(event){if(!SystemInit.buildtime)return;const deleteDatabase=!tchmi_equal(Array.from(this.result.objectStoreNames).sort(),currentObjectStoreNames);if(firstLoadAfterPublish||deleteDatabase||!__fetchFromIndexedDb)try{if(deleteDatabase)window.localStorage.removeItem(hostPrefix+"TcHmi.Init.cachedBuildtime"),window.indexedDB.deleteDatabase(hostPrefix+"TcHmi.Init");else for(const name of currentObjectStoreNames)this.result.transaction(name,"readwrite").objectStore(name).clear()}catch(e){}else{const transaction=this.result.transaction(currentObjectStoreNames,"readonly");transaction.objectStore("controlTemplate").openCursor().onsuccess=function(event){if(!__fetchFromIndexedDb)return;const result=this.result;result&&(Data.Caches.templateMarkupCache.set(result.key,result.value),result.continue())},transaction.objectStore("userControlMarkup").openCursor().onsuccess=function(event){if(!__fetchFromIndexedDb)return;const result=this.result;result&&(Data.Caches.partialMarkupCache.set(result.key,{markup:result.value}),result.continue())},transaction.objectStore("userControlConfig").openCursor().onsuccess=function(event){if(!__fetchFromIndexedDb)return;const result=this.result;result&&(Data.Caches.partialCompositeConfigCache.set(result.key,result.value),result.continue())},transaction.objectStore("contentMarkup").openCursor().onsuccess=function(event){if(!__fetchFromIndexedDb)return;const result=this.result;result&&(Data.Caches.partialMarkupCache.set(result.key,{markup:result.value}),result.continue())}}},__initStep=INIT_STATE.SYSTEM_PREPARATION}case INIT_STATE.SYSTEM_PREPARATION:if(__initStep=INIT_STATE.IDLE,Log.performanceLog(`[Source=Framework, Module=TcHmi.Init] INIT_STATE.${INIT_STATE[__initStep]}`),"3.7.1"!==$().jquery)return Log.errorEx("[Source=Framework, Module=TcHmi.Init] Mismatching jquery version. Please avoid overriding."),dialogManager.showDialog("__TcHmiMain",!0,TcHmi.DialogManager.DialogType.Overlay),dialogManager.updateTextEx("__TcHmiMain","Mismatching jQuery version. Please avoid overriding",{severity:TcHmi.DialogManager.DialogSeverity.Error,buttonReload:!TCHMI_DESIGNER}),__initStep=INIT_STATE.ERROR,void InitStateMachine();if(keyboardManager.refreshConfig(),TCHMI_DESIGNER){const tchmiConfigOverride=TCHMI_CONFIG_OVERRIDE;tchmiConfigOverride?.tcHmiServer?.websocketOverwrite&&serverManager.setServerAddress(window.location.protocol,tchmiConfigOverride.tcHmiServer.websocketOverwrite.host??window.location.host,tchmiConfigOverride.tcHmiServer.websocketOverwrite.port)}TcHmi.EventProvider.raise("System.onInitializedServices"),__initStep=INIT_STATE.PACKAGE_MANIFEST_LOAD,loadNextStage(INIT_STAGE.PackagesConfiguration),initStageInfo.get(initStage).done++,updateSplashScreen({callInitStateMachine:!0});break;case INIT_STATE.PACKAGE_MANIFEST_LOAD:{Log.performanceLog(`[Source=Framework, Module=TcHmi.Init] INIT_STATE.${INIT_STATE[__initStep]}: ${config.packages.length} Packages`),__initStep=INIT_STATE.IDLE;const deduplicatedPackages=new Map;for(const packageInfo of config.packages)"Beckhoff.TwinCAT.HMI.Framework"!==packageInfo.name&&deduplicatedPackages.set(packageInfo.name,packageInfo);if(PendingCounter.PackageLoaded=deduplicatedPackages.size,deduplicatedPackages.size)for(const packageInfo of deduplicatedPackages.values())loadPackage(tchmi_clone_object(packageInfo),data=>{data.error!==TcHmi.Errors.NONE&&Log.errorEx(`[Source=Framework, Module=TcHmi.Init] Failed to load package: "${packageInfo.name}" from "Properties/tchmiconfig.json". Details: ${Log.buildMessage(data.details)}`),PendingCounter.PackageLoaded--,initStageInfo.get(initStage).done++,PendingCounter.PackageLoaded<=0?(Data.packages.forEach(packageIterator=>{packageIterator.manifest.modules.forEach(moduleData=>{"Package"===moduleData.type&&(Data.packages.has(moduleData.nugetId)||Log.errorEx(`[Source=Framework, Module=TcHmi.Init] Package ${packageIterator.name} references the unknown package ${moduleData.nugetId}. Reference will be skipped.`))})}),__initStep=INIT_STATE.CONFIG_CONTROLS_DESCRIPTION_LOAD,loadNextStage(INIT_STAGE.PreparingControls),updateSplashScreen({callInitStateMachine:!0})):updateSplashScreen()});else __initStep=INIT_STATE.CONFIG_CONTROLS_DESCRIPTION_LOAD,initStageInfo.get(initStage).done++,loadNextStage(INIT_STAGE.PreparingControls),updateSplashScreen({callInitStateMachine:!0})}break;case INIT_STATE.CONFIG_CONTROLS_DESCRIPTION_LOAD:if("complete"!==document.readyState){document.addEventListener("readystatechange",InitStateMachine,{once:!0});break}if(Log.performanceLog(`[Source=Framework, Module=TcHmi.Init] INIT_STATE.${INIT_STATE[__initStep]}: ${configControls.length} Controls`),__initStep=INIT_STATE.IDLE,PendingCounter.ConfigControlsDescriptionLoaded=configControls.length,configControls.length>0){const loadConfigControlDescription=function(configControl){configControl.basePath||(configControl.basePath="");const cleanPath=tchmi_path(configControl.basePath+"/"+configControl.descriptionFile);let xhrCtrlDescr=new XMLHttpRequest;xhrCtrlDescr.open("GET",tchmi_encode_uri_components(cleanPath)+xhrCacheSuffix);let xhrCtrlDescrError=function(evt){__initStep!==INIT_STATE.ERROR&&(Log.errorEx(`[Source=Framework, Module=TcHmi.Init] Failed to load control description: "${xhrCtrlDescr.responseURL||cleanPath}". Related control type will not be available. Details: HTTP error ${xhrCtrlDescr.status} ${xhrCtrlDescr.statusText}`),PendingCounter.ConfigControlsDescriptionLoaded--,PendingCounter.ConfigControlsDescriptionLoaded<=0&&(__initStep=INIT_STATE.PACKAGE_CONTROLS_DESCRIPTION_LOAD,updateSplashScreen({callInitStateMachine:!0,skipStageUpdate:!0})))};xhrCtrlDescr.addEventListener("load",function(evt){if(200!==xhrCtrlDescr.status)return void xhrCtrlDescrError(evt);if(__initStep===INIT_STATE.ERROR)return;const descrRes=ValueConverter.toObjectEx(resolveReplaceExpressions(xhrCtrlDescr.responseText,{PkgBasePath:"."}));let descr=descrRes.value;if(!descr)return Log.errorEx(`[Source=Framework, Module=TcHmi.Init] Failed to load control description "${cleanPath}" from tchmiconfig.json. Response contains no valid control description file. Details: ${Log.buildMessage(descrRes.details)}`),dialogManager.showDialog("__TcHmiMain",!0,TcHmi.DialogManager.DialogType.Overlay),dialogManager.updateTextEx("__TcHmiMain",tchmi_format_string(frameworkLocalization.getText("Control_Description_Response_Invalid",{level:TcHmi.Locale.Level.Engineering,preventHtml:!0}),cleanPath),{severity:TcHmi.DialogManager.DialogSeverity.Error,buttonReload:!TCHMI_DESIGNER}),__initStep=INIT_STATE.ERROR,void updateSplashScreen({callInitStateMachine:!0,skipStageUpdate:!0});let qname,name=descr.name,namespace=descr.namespace;namespace&&(qname=resolveQualifiedName(name,namespace));let registration=controlRegistrations.map.get(name);if(registration&&registration.error!==TcHmi.Errors.E_NOT_UNIQUE||!qname||(registration=controlRegistrations.map.get(qname)),registration&&registration.error===TcHmi.Errors.NONE){let module={reg:registration,error:TcHmi.Errors.NONE,configData:configControl,description:descr,descriptionExpanded:{...tchmi_clone_object(descr),inheritationResolved:!1,inheritedTypes:[],inheritedAttributes:[],inheritedAttributesNameMap:new Map,inheritedAttributesPropertyNameMap:new Map,inheritedAttributesPropertyGetterNameMap:new Map,inheritedAttributesPropertySetterNameMap:new Map,inheritedAccess:[],inheritedEvents:[],inheritedFunctions:[],inheritedLanguages:{}}};if(Data.Modules.controls.array.push(module),registration.namespace!==namespace){let qnameErrorhandling;Log.errorEx(`[Source=Framework, Module=TcHmi.Init] Namespace from Description.json (${namespace}) and control registration (${registration.namespace}) for control ${descr.name} from tchmiconfig.json are different.`),namespace?qnameErrorhandling=resolveQualifiedName(name,namespace):registration.namespace&&(qnameErrorhandling=resolveQualifiedName(name,registration.namespace));let modulError={error:TcHmi.Errors.E_CONTROL_INVALID_CONFIGURATION,errorDetails:{code:TcHmi.Errors.E_CONTROL_INVALID_CONFIGURATION,message:TcHmi.Errors[TcHmi.Errors.E_CONTROL_INVALID_CONFIGURATION],domain:"TcHmi",reason:`Namespace from Description.json (${namespace}) and control registration (${registration.namespace}) for control ${descr.name} are different.`}};Data.Modules.controls.map.set(name,modulError),qnameErrorhandling&&Data.Modules.controls.map.set(qnameErrorhandling,modulError)}else Data.Modules.controls.map.has(name)?(Data.Modules.controls.map.set(name,{error:TcHmi.Errors.E_NOT_UNIQUE,errorDetails:{code:TcHmi.Errors.E_NOT_UNIQUE,message:TcHmi.Errors[TcHmi.Errors.E_NOT_UNIQUE],domain:"TcHmi",reason:`Ambiguous module definitions for the name: "${name}". Please try fully qualified name.`}}),Data.Modules.controls.urlMap.delete(cleanPath)):(Data.Modules.controls.map.set(name,module),Data.Modules.controls.urlMap.set(cleanPath,module));if(qname&&(Data.Modules.controls.map.has(qname)?(Data.Modules.controls.map.set(qname,{error:TcHmi.Errors.E_NOT_UNIQUE,errorDetails:{code:TcHmi.Errors.E_NOT_UNIQUE,message:TcHmi.Errors[TcHmi.Errors.E_NOT_UNIQUE],domain:"TcHmi",reason:`Multiple module definitions with the name ${qname} found.`}}),Data.Modules.controls.urlMap.delete(cleanPath)):(Data.Modules.controls.map.set(qname,module),Data.Modules.controls.urlMap.set(cleanPath,module))),qname){let nameLegacy=mapControlNamesFromPackageManifestApi1ToApi0.get(qname);nameLegacy&&(Data.Modules.controls.map.has(nameLegacy)?Data.Modules.controls.map.set(nameLegacy,{error:TcHmi.Errors.E_NOT_UNIQUE,errorDetails:{code:TcHmi.Errors.E_NOT_UNIQUE,message:TcHmi.Errors[TcHmi.Errors.E_NOT_UNIQUE],domain:"TcHmi",reason:`Multiple module definitions with the name ${nameLegacy} found.`}}):Data.Modules.controls.map.set(nameLegacy,module))}themeManager.registerControlThemeFiles(descr)}else if(registration)registration.error!==TcHmi.Errors.NONE&&Log.errorEx(`[Source=Framework, Module=TcHmi.Init] Registration of control type "${qname}" is not valid and will therefore not be available. Details: ${Log.buildMessage(registration.errorDetails)}`);else{Log.errorEx('[Source=Framework, Module=TcHmi.Init] Control type "'+qname+'" is not registered and will therefore not be available.\nPossible reasons:\n- Related source file is not included in html document.\n- Related source file could not be loaded due to wrong tchmiconfig.json entry.\n- Related source file is not available (would result in console errors).\n- Related source file is not included in required order in html document (would result in console errors).\n- Related source file contains no call to "TcHmi.Controls.registerEx" or "TcHmi.Controls.register".\n- Related source file contains a call to "TcHmi.Controls.registerEx" or "TcHmi.Controls.register" with name and/or namespace not matching the definition in control description file: "'+cleanPath+'".');let modulError={error:TcHmi.Errors.E_CONTROL_INVALID_CONFIGURATION,errorDetails:{code:TcHmi.Errors.E_CONTROL_INVALID_CONFIGURATION,message:TcHmi.Errors[TcHmi.Errors.E_CONTROL_INVALID_CONFIGURATION],domain:"TcHmi",reason:`Control type "${qname}" is not registered and will therefore not be available.`}};Data.Modules.controls.urlMap.set(cleanPath,modulError)}PendingCounter.ConfigControlsDescriptionLoaded--,PendingCounter.ConfigControlsDescriptionLoaded<=0&&(descr=null,__initStep=INIT_STATE.PACKAGE_CONTROLS_DESCRIPTION_LOAD,updateSplashScreen({callInitStateMachine:!0,skipStageUpdate:!0}))}),xhrCtrlDescr.addEventListener("error",xhrCtrlDescrError),xhrCtrlDescr.send()};for(const configControl of configControls)loadConfigControlDescription(configControl);break}__initStep=INIT_STATE.PACKAGE_CONTROLS_DESCRIPTION_LOAD,updateSplashScreen({callInitStateMachine:!0,skipStageUpdate:!0});break;case INIT_STATE.PACKAGE_CONTROLS_DESCRIPTION_LOAD:if("complete"!==document.readyState){document.addEventListener("readystatechange",InitStateMachine,{once:!0});break}if(Log.performanceLog(`[Source=Framework, Module=TcHmi.Init] INIT_STATE.${INIT_STATE[__initStep]}: ${packageControls.length} Controls`),__initStep=INIT_STATE.IDLE,PendingCounter.PackageControlsDescriptionLoaded=packageControls.length,packageControls.length>0){const loadPackageControlDescription=function(packageControl){packageControl.module.basePath||(packageControl.module.basePath="");const cleanPath=tchmi_path(packageControl.package.basePath+"/"+packageControl.module.basePath+"/"+packageControl.module.descriptionFile);let xhrCtrlDescr=new XMLHttpRequest;xhrCtrlDescr.open("GET",tchmi_encode_uri_components(cleanPath)+xhrCacheSuffix);let xhrCtrlDescrError=function(evt){__initStep!==INIT_STATE.ERROR&&(Log.errorEx(`[Source=Framework, Module=TcHmi.Init] Failed to load control description: "${xhrCtrlDescr.responseURL||cleanPath}". Related control type will not be available. Details: HTTP error ${xhrCtrlDescr.status} ${xhrCtrlDescr.statusText}`),PendingCounter.PackageControlsDescriptionLoaded--,PendingCounter.PackageControlsDescriptionLoaded<=0&&(__initStep=INIT_STATE.CONTROLS_DESCRIPTION_RESOLVE,updateSplashScreen({callInitStateMachine:!0,skipStageUpdate:!0})))};xhrCtrlDescr.addEventListener("load",function(evt){if(200!==xhrCtrlDescr.status)return void xhrCtrlDescrError(evt);if(__initStep===INIT_STATE.ERROR)return;const descrRes=ValueConverter.toObjectEx(resolveReplaceExpressions(xhrCtrlDescr.responseText,{PkgId:packageControl.package.config.name,PkgBasePath:packageControl.package.config.basePath}));let descr=descrRes.value;if(descr&&1===packageControl.package.manifest.apiVersion){let name=descr.name;descr.apiVersion||Log.warnEx(`[Source=Framework, Module=TcHmi.Init] Package: "${packageControl.package.name}": API Version mismatch. This may lead to consequential errors. Please contact the developer of the package. Control module: "${name}" has apiVersion: "0" but package has apiVersion: "1". Do not mix TwinCAT HMI 1.10 and TwinCAT 1.12 and greater API modules in one package. If the package is designed to provide TwinCAT HMI 1.10 API controls the apiVersion of the Manifest.json has to be set to "0" if it is designed to provide TwinCAT HMI 1.12 api logic remove the TwinCAT HMI 1.10 API control or set the apiVersion in Description.json to "1" if the control is designed based on TwinCAT HMI 1.12 API.`);let qname,namespace=descr.namespace;namespace&&(qname=resolveQualifiedName(name,namespace));let registration=controlRegistrations.map.get(name);if(registration&&registration.error!==TcHmi.Errors.E_NOT_UNIQUE||!qname||(registration=controlRegistrations.map.get(qname)),registration&&registration.error===TcHmi.Errors.NONE){let module={reg:registration,error:TcHmi.Errors.NONE,manifestData:packageControl.module,package:packageControl.package,description:descr,descriptionExpanded:{...tchmi_clone_object(descr),inheritationResolved:!1,inheritedTypes:[],inheritedAttributes:[],inheritedAttributesNameMap:new Map,inheritedAttributesPropertyNameMap:new Map,inheritedAttributesPropertyGetterNameMap:new Map,inheritedAttributesPropertySetterNameMap:new Map,inheritedAccess:[],inheritedEvents:[],inheritedFunctions:[],inheritedLanguages:{}}};if(Data.Modules.controls.array.push(module),registration.namespace!==namespace){let qnameErrorhandling;Log.errorEx(`[Source=Framework, Module=TcHmi.Init] Package: "${packageControl.package.name}": Namespace from Description.json (${namespace}) and control registration (${registration.namespace}) for control ${descr.name} are different. Please contact the developer of the package.`),namespace?qnameErrorhandling=resolveQualifiedName(name,namespace):registration.namespace&&(qnameErrorhandling=resolveQualifiedName(name,registration.namespace));let modulError={error:TcHmi.Errors.E_CONTROL_INVALID_CONFIGURATION,errorDetails:{code:TcHmi.Errors.E_CONTROL_INVALID_CONFIGURATION,message:TcHmi.Errors[TcHmi.Errors.E_CONTROL_INVALID_CONFIGURATION],domain:"TcHmi",reason:`Namespace from Description.json (${namespace}) and control registration (${registration.namespace}) for control ${descr.name} are different.`}};Data.Modules.controls.map.set(name,modulError),qnameErrorhandling&&Data.Modules.controls.map.set(qnameErrorhandling,modulError)}else Data.Modules.controls.map.has(name)?(Data.Modules.controls.map.set(name,{error:TcHmi.Errors.E_NOT_UNIQUE,errorDetails:{code:TcHmi.Errors.E_NOT_UNIQUE,message:TcHmi.Errors[TcHmi.Errors.E_NOT_UNIQUE],domain:"TcHmi",reason:`Ambiguous module definitions for the name: "${name}". Please try fully qualified name.`}}),Data.Modules.controls.urlMap.delete(cleanPath)):(Data.Modules.controls.map.set(name,module),Data.Modules.controls.urlMap.set(cleanPath,module));if(qname&&(Data.Modules.controls.map.has(qname)?(Data.Modules.controls.map.set(qname,{error:TcHmi.Errors.E_NOT_UNIQUE,errorDetails:{code:TcHmi.Errors.E_NOT_UNIQUE,message:TcHmi.Errors[TcHmi.Errors.E_NOT_UNIQUE],domain:"TcHmi",reason:`Multiple module definitions with the name ${qname} found.`}}),Data.Modules.controls.urlMap.delete(cleanPath)):(Data.Modules.controls.map.set(qname,module),Data.Modules.controls.urlMap.set(cleanPath,module))),qname){let nameLegacy=mapControlNamesFromPackageManifestApi1ToApi0.get(qname);nameLegacy&&(Data.Modules.controls.map.has(nameLegacy)?Data.Modules.controls.map.set(nameLegacy,{error:TcHmi.Errors.E_NOT_UNIQUE,errorDetails:{code:TcHmi.Errors.E_NOT_UNIQUE,message:TcHmi.Errors[TcHmi.Errors.E_NOT_UNIQUE],domain:"TcHmi",reason:`Multiple module definitions with the name ${nameLegacy} found.`}}):Data.Modules.controls.map.set(nameLegacy,module))}themeManager.registerControlThemeFiles(descr)}else if(registration)registration.error!==TcHmi.Errors.NONE&&Log.errorEx(`[Source=Framework, Module=TcHmi.Init] Registration of control type "${qname}" is not valid and will therefore not be available. Details: ${Log.buildMessage(registration.errorDetails)}`);else{Log.errorEx('[Source=Framework, Module=TcHmi.Init] Control type "'+qname+'" is not registered and will therefore not be available.\nPossible reasons:\n- Needed package is not referenced in project.\n- Related source file is not included in html document.\n- Related source file could not be loaded due to missing build or wrong/missing reference.\n- Related source file is not available (would result in console errors).\n- Related source file is not included in required order in html document (would result in console errors).\n- Related source file contains no call to "TcHmi.Controls.registerEx" or "TcHmi.Controls.register".\n- Related source file contains a call to "TcHmi.Controls.registerEx" or "TcHmi.Controls.register" with name and/or namespace not matching the definition in control description file: "'+cleanPath+'".');let modulError={error:TcHmi.Errors.E_CONTROL_INVALID_CONFIGURATION,errorDetails:{code:TcHmi.Errors.E_CONTROL_INVALID_CONFIGURATION,message:TcHmi.Errors[TcHmi.Errors.E_CONTROL_INVALID_CONFIGURATION],domain:"TcHmi",reason:`Control type "${qname}" is not registered and will therefore not be available.`}};Data.Modules.controls.urlMap.set(cleanPath,modulError)}}else if(descr){let name=descr.name,registration=controlRegistrations.map.get(name);if(registration&&registration.error===TcHmi.Errors.NONE){if(registration.directory&&registration.template){let cleanTemplatePath=tchmi_path(registration.template),cleanTemplateDirectory=tchmi_path(registration.directory);cleanTemplatePath.includes(cleanTemplateDirectory)&&(descr.template=cleanTemplatePath.replace(cleanTemplateDirectory,""))}let module={reg:registration,error:TcHmi.Errors.NONE,manifestData:packageControl.module,package:packageControl.package,description:descr,descriptionExpanded:{...tchmi_clone_object(descr),inheritationResolved:!1,inheritedTypes:[],inheritedAttributes:[],inheritedAttributesNameMap:new Map,inheritedAttributesPropertyNameMap:new Map,inheritedAttributesPropertyGetterNameMap:new Map,inheritedAttributesPropertySetterNameMap:new Map,inheritedAccess:[],inheritedEvents:[],inheritedFunctions:[],inheritedLanguages:{}}};Data.Modules.controls.array.push(module),Data.Modules.controls.map.has(name)?(Data.Modules.controls.map.set(name,{error:TcHmi.Errors.E_NOT_UNIQUE,errorDetails:{code:TcHmi.Errors.E_NOT_UNIQUE,message:TcHmi.Errors[TcHmi.Errors.E_NOT_UNIQUE],domain:"TcHmi",reason:`Ambiguous module definitions for the name: "${name}". Please try fully qualified name.`}}),Data.Modules.controls.urlMap.delete(cleanPath)):(Data.Modules.controls.map.set(name,module),Data.Modules.controls.urlMap.set(cleanPath,module)),themeManager.registerControlThemeFiles(descr)}else registration?registration.error!==TcHmi.Errors.NONE&&Log.errorEx(`[Source=Framework, Module=TcHmi.Init] Registration of control type "${name}" is not valid and will therefore not be available. Details: ${Log.buildMessage(registration.errorDetails)}`):Log.errorEx('[Source=Framework, Module=TcHmi.Init] Control type "'+name+'" is not registered and will therefore not be available.\nPossible reason/s:\n- Related source file contains a call to "TcHmi.Controls.registerEx" or "TcHmi.Controls.register" with name and/or namespace not matching the definition in control description file: "'+cleanPath+'".\n- Related source file is not included in html document.\n- Related source file is not included in required order in html document (would result in console errors).\n- Related source file contains no call to "TcHmi.Controls.registerEx" or "TcHmi.Controls.register".')}else if(!descr)return Log.errorEx(`[Source=Framework, Module=TcHmi.Init] Failed to load control description "${cleanPath}" in package ${packageControl.package.name}. Response contains no valid control description file. Details: ${Log.buildMessage(descrRes.details)}`),dialogManager.showDialog("__TcHmiMain",!0,TcHmi.DialogManager.DialogType.Overlay),dialogManager.updateTextEx("__TcHmiMain",tchmi_format_string(frameworkLocalization.getText("Control_Description_Response_Invalid",{level:TcHmi.Locale.Level.Engineering,preventHtml:!0}),cleanPath),{severity:TcHmi.DialogManager.DialogSeverity.Error,buttonReload:!TCHMI_DESIGNER}),__initStep=INIT_STATE.ERROR,void updateSplashScreen({callInitStateMachine:!0,skipStageUpdate:!0});PendingCounter.PackageControlsDescriptionLoaded--,PendingCounter.PackageControlsDescriptionLoaded<=0&&(descr=null,__initStep=INIT_STATE.CONTROLS_DESCRIPTION_RESOLVE,updateSplashScreen({callInitStateMachine:!0,skipStageUpdate:!0}))}),xhrCtrlDescr.addEventListener("error",xhrCtrlDescrError),xhrCtrlDescr.send()};for(const packageControl of packageControls)loadPackageControlDescription(packageControl);break}__initStep=INIT_STATE.CONTROLS_DESCRIPTION_RESOLVE,updateSplashScreen({callInitStateMachine:!0,skipStageUpdate:!0});break;case INIT_STATE.CONTROLS_DESCRIPTION_RESOLVE:Log.performanceLog(`[Source=Framework, Module=TcHmi.Init] INIT_STATE.${INIT_STATE[__initStep]}`),__initStep=INIT_STATE.IDLE,PendingCounter.ControlsDescriptionResolved=1;try{controlManager.resolveDescriptionInheritation()}catch(e){return Log.errorEx(e),dialogManager.showDialog("__TcHmiMain",!0,TcHmi.DialogManager.DialogType.Overlay),dialogManager.updateTextEx("__TcHmiMain",frameworkLocalization.getText("Resolving_Control_Description_Inheritation_Failed",{level:TcHmi.Locale.Level.Engineering,preventHtml:!0}),{severity:TcHmi.DialogManager.DialogSeverity.Error,buttonReload:!TCHMI_DESIGNER}),__initStep=INIT_STATE.ERROR,void InitStateMachine()}PendingCounter.ControlsDescriptionResolved=0,__initStep=INIT_STATE.LOCALIZATION_FINAL,updateSplashScreen({callInitStateMachine:!0});break;case INIT_STATE.LOCALIZATION_FINAL:{if(Log.performanceLog(`[Source=Framework, Module=TcHmi.Init] INIT_STATE.${INIT_STATE[__initStep]}: ${Object.keys(config.languages).length} Languages`),config.languages)for(const[key,languageEntry]of Object.entries(config.languages))if(Array.isArray(languageEntry)){const sanitizedLanguageArray=[];for(const subEntry of languageEntry)sanitizedLanguageArray.push(tchmi_path(subEntry));localizationManager.registerLocalizationFile("TcHmi.System.Localization.Application",key,sanitizedLanguageArray),TCHMI_ENGINEERING&&localizationManager.registerLocalizationFile("TcHmi.System.Localization.Package<{PkgId}>",key,sanitizedLanguageArray)}else localizationManager.registerLocalizationFile("TcHmi.System.Localization.Application",key,tchmi_path(languageEntry)),TCHMI_ENGINEERING&&localizationManager.registerLocalizationFile("TcHmi.System.Localization.Package<{PkgId}>",key,tchmi_path(languageEntry));if(config.languageFallback&&localizationManager.setFallbackLocale(config.languageFallback),Data.packages.forEach(packageObj=>{packageObj.manifest.modules.forEach(module=>{if("Language"!==module.type)return;let files=[];if("string"==typeof module.files)files.push(tchmi_path(packageObj.basePath+"/"+module.files));else{if(!Array.isArray(module.files))return;for(let file of module.files)files.push(tchmi_path(packageObj.basePath+"/"+file))}localizationManager.registerLocalizationFile("TcHmi.System.Localization.Package<"+packageObj.name+">",module.locale,files)})}),config.languagesForPackages)for(const[name,files]of Object.entries(config.languagesForPackages))for(const[locale,languageEntry]of Object.entries(files))if(Array.isArray(languageEntry)){const sanitizedLanguageArray=[];for(const subEntry of languageEntry)sanitizedLanguageArray.push(tchmi_path(subEntry));localizationManager.registerLocalizationFile(`TcHmi.System.Localization.Package<${name}>`,locale,sanitizedLanguageArray)}else localizationManager.registerLocalizationFile(`TcHmi.System.Localization.Package<${name}>`,locale,tchmi_path(languageEntry));if(Data.Modules.controls.array.forEach(module=>{if(module.descriptionExpanded&&module.descriptionExpanded.languages){if(module.error!==TcHmi.Errors.NONE||!module.reg)return;if(0===module.reg.apiVersion)return;let qname=resolveQualifiedName(module.reg.name,module.reg.namespace);for(let key in module.descriptionExpanded.languages){const languageEntry=module.descriptionExpanded.languages[key];if(Array.isArray(languageEntry)){const sanitizedLanguageArray=[];for(const subEntry of languageEntry)sanitizedLanguageArray.push(tchmi_path(TcHmi.Environment.getControlBasePath(qname)+"/"+subEntry));localizationManager.registerLocalizationFile(`TcHmi.System.Localization.Control<${qname}>`,key,sanitizedLanguageArray)}else localizationManager.registerLocalizationFile(`TcHmi.System.Localization.Control<${qname}>`,key,tchmi_path(TcHmi.Environment.getControlBasePath(qname)+"/"+languageEntry))}}}),config.languagesForControls)for(const[name,files]of Object.entries(config.languagesForControls))for(const[locale,languageEntry]of Object.entries(files))if(Array.isArray(languageEntry)){const sanitizedLanguageArray=[];for(const subEntry of languageEntry)sanitizedLanguageArray.push(tchmi_path(subEntry));localizationManager.registerLocalizationFile(`TcHmi.System.Localization.Control<${name}>`,locale,sanitizedLanguageArray)}else localizationManager.registerLocalizationFile(`TcHmi.System.Localization.Control<${name}>`,locale,tchmi_path(languageEntry));for(const module of new Set(Data.Modules.functions.map.values())){if(!(module.error===TcHmi.Errors.NONE&&module.reg&&module.package&&module.manifestData&&module.description?.languages))continue;let qname=resolveQualifiedName(module.reg.name,module.reg.namespace);for(let key in module.description.languages){const languageEntry=module.description.languages[key];if(Array.isArray(languageEntry))for(const subEntry of languageEntry)localizationManager.registerLocalizationFile(`TcHmi.System.Localization.Function<${qname}>`,key,tchmi_path(`${module.package.basePath}/${module.manifestData.basePath}/${subEntry}`));else localizationManager.registerLocalizationFile(`TcHmi.System.Localization.Function<${qname}>`,key,tchmi_path(`${module.package.basePath}/${module.manifestData.basePath}/${languageEntry}`))}}if(config.languagesForFunctions)for(const[name,files]of Object.entries(config.languagesForFunctions))for(const[locale,languageEntry]of Object.entries(files))if(Array.isArray(languageEntry))for(const subEntry of languageEntry)localizationManager.registerLocalizationFile(`TcHmi.System.Localization.Function<${name}>`,locale,tchmi_path(subEntry));else localizationManager.registerLocalizationFile(`TcHmi.System.Localization.Function<${name}>`,locale,tchmi_path(languageEntry));const finalize=()=>{__initStep=INIT_STATE.CONTROLS_TEMPLATES_LOAD,updateSplashScreen({callInitStateMachine:!0,skipStageUpdate:!0})};TCHMI_DESIGNER?localizationManager.processLocale("en",{level:TcHmi.Locale.Level.Engineering},data=>{finalize()}):finalize()}break;case INIT_STATE.CONTROLS_TEMPLATES_LOAD:{__initStep=INIT_STATE.IDLE;let templates=[];if(Data.Modules.controls.array.forEach((module,index)=>{module.descriptionExpanded&&module.descriptionExpanded.inheritedTemplate&&!templates.find(t=>t.url===module.descriptionExpanded?.inheritedTemplate)&&templates.push({url:module.descriptionExpanded.inheritedTemplate,module})}),Log.performanceLog(`[Source=Framework, Module=TcHmi.Init] INIT_STATE.${INIT_STATE[__initStep]}: ${templates.length} Templates`),PendingCounter.ControlsTemplatesLoaded=templates.length,templates.length>0){const loadControlTemplate=function(url,module){let xhrCtrlTempl=new XMLHttpRequest;xhrCtrlTempl.open("GET",tchmi_encode_uri_components(url)+xhrCacheSuffix);let xhrCtrlTemplError=function(evt){__initStep!==INIT_STATE.ERROR&&(Log.errorEx(`[Source=Framework, Module=TcHmi.Init] Loading ${xhrCtrlTempl.responseURL||url} failed! Details: HTTP error ${xhrCtrlTempl.status} ${xhrCtrlTempl.statusText}`),dialogManager.showDialog("__TcHmiMain",!0,TcHmi.DialogManager.DialogType.Overlay),dialogManager.updateTextEx("__TcHmiMain",tchmi_format_string(frameworkLocalization.getText("Loading_File_Failed_With_Error",{level:TcHmi.Locale.Level.Engineering,preventHtml:!0}),url,`HTTP error ${xhrCtrlTempl.status} ${xhrCtrlTempl.statusText}`),{severity:TcHmi.DialogManager.DialogSeverity.Error,buttonReload:!TCHMI_DESIGNER}),__initStep=INIT_STATE.ERROR,InitStateMachine())};xhrCtrlTempl.addEventListener("load",function(evt){200===xhrCtrlTempl.status?__initStep!==INIT_STATE.ERROR&&(module.package?Data.Caches.templateMarkupCache.set(url,resolveReplaceExpressions(xhrCtrlTempl.responseText,{PkgId:module.package.config.name,PkgBasePath:module.package.config.basePath})):Data.Caches.templateMarkupCache.set(url,xhrCtrlTempl.responseText),__fetchFromIndexedDb&&"done"===indexedDbRequest?.readyState&&indexedDbRequest.result?.objectStoreNames?.contains("controlTemplate")&&indexedDbRequest.result.transaction("controlTemplate","readwrite").objectStore("controlTemplate").put(xhrCtrlTempl.responseText,url),PendingCounter.ControlsTemplatesLoaded--,PendingCounter.ControlsTemplatesLoaded<=0&&(initStageInfo.get(initStage).done++,__initStep=INIT_STATE.PACKAGE_FUNCTION_DESCRIPTION_LOAD,loadNextStage(INIT_STAGE.PreparingFunctions),updateSplashScreen({callInitStateMachine:!0}))):xhrCtrlTemplError(evt)}),xhrCtrlTempl.addEventListener("error",xhrCtrlTemplError),xhrCtrlTempl.send()};for(const template of templates)__fetchFromIndexedDb&&Data.Caches.templateMarkupCache.has(template.url)?PendingCounter.ControlsTemplatesLoaded--:loadControlTemplate(template.url,template.module)}PendingCounter.ControlsTemplatesLoaded<=0&&(initStageInfo.get(initStage).done++,__initStep=INIT_STATE.PACKAGE_FUNCTION_DESCRIPTION_LOAD,loadNextStage(INIT_STAGE.PreparingFunctions),updateSplashScreen({callInitStateMachine:!0}))}break;case INIT_STATE.PACKAGE_FUNCTION_DESCRIPTION_LOAD:if("complete"!==document.readyState){document.addEventListener("readystatechange",InitStateMachine,{once:!0});break}if(Log.performanceLog(`[Source=Framework, Module=TcHmi.Init] INIT_STATE.${INIT_STATE[__initStep]}: ${packageFunctions.length} Functions`),__initStep=INIT_STATE.IDLE,PendingCounter.PackageFunctionDescriptionLoaded=packageFunctions.length,packageFunctions.length){const loadPackageFunctionDescription=function(packageFunction){if(packageFunction.module.basePath||(packageFunction.module.basePath=""),!packageFunction.module.descriptionFile)return PendingCounter.PackageFunctionDescriptionLoaded--,PendingCounter.PackageFunctionDescriptionLoaded<=0?(__initStep=INIT_STATE.CONFIG_FUNCTION_DESCRIPTION_LOAD,void updateSplashScreen({callInitStateMachine:!0,skipStageUpdate:!0})):void 0;const cleanPath=tchmi_path(packageFunction.package.basePath+"/"+packageFunction.module.basePath+"/"+packageFunction.module.descriptionFile);let xhrPackageFunctionDescr=new XMLHttpRequest;xhrPackageFunctionDescr.open("GET",tchmi_encode_uri_components(cleanPath)+xhrCacheSuffix);let xhrPackageFunctionDescrError=function(evt){if(__initStep!==INIT_STATE.ERROR)return Log.errorEx(`[Source=Framework, Module=TcHmi.Init] Failed to load function description: "${cleanPath}". Related functions will not be available. Details: HTTP error ${xhrPackageFunctionDescr.status} ${xhrPackageFunctionDescr.statusText}`),PendingCounter.PackageFunctionDescriptionLoaded--,PendingCounter.PackageFunctionDescriptionLoaded<=0?(__initStep=INIT_STATE.CONFIG_FUNCTION_DESCRIPTION_LOAD,void updateSplashScreen({callInitStateMachine:!0,skipStageUpdate:!0})):void 0};xhrPackageFunctionDescr.addEventListener("load",function(evt){if(200!==xhrPackageFunctionDescr.status)return void xhrPackageFunctionDescrError(evt);if(__initStep===INIT_STATE.ERROR)return;const descrRes=ValueConverter.toObjectEx(resolveReplaceExpressions(xhrPackageFunctionDescr.responseText,{PkgId:packageFunction.package.config.name,PkgBasePath:packageFunction.package.config.basePath}));let descr=descrRes.value;if(!descr||!descr.function)return Log.errorEx(`[Source=Framework, Module=TcHmi.Init] Failed to load function description: "${xhrPackageFunctionDescr.responseURL||cleanPath}". Related functions will not be available. Response is no valid function JSON. Details: ${Log.buildMessage(descrRes.details)}`),PendingCounter.PackageFunctionDescriptionLoaded--,PendingCounter.PackageFunctionDescriptionLoaded<=0?(__initStep=INIT_STATE.CONFIG_FUNCTION_DESCRIPTION_LOAD,void updateSplashScreen({callInitStateMachine:!0,skipStageUpdate:!0})):void 0;let name=descr.function.name,namespace=descr.function.namespace,qname=resolveQualifiedName(name,namespace),registration=functionRegistrations.map.get(name);if(registration&&registration.error!==TcHmi.Errors.E_NOT_UNIQUE||(registration=functionRegistrations.map.get(qname)),registration&&registration.error===TcHmi.Errors.NONE){let module={reg:registration,error:TcHmi.Errors.NONE,manifestData:packageFunction.module,package:packageFunction.package,description:descr};Data.Modules.functions.map.has(name)?Data.Modules.functions.map.set(name,{error:TcHmi.Errors.E_NOT_UNIQUE,errorDetails:{code:TcHmi.Errors.E_NOT_UNIQUE,message:TcHmi.Errors[TcHmi.Errors.E_NOT_UNIQUE],domain:"TcHmi",reason:`Ambiguous module definitions for the name: "${name}". Please try fully qualified name.`}}):Data.Modules.functions.map.set(name,module),qname!==name&&(Data.Modules.functions.map.has(qname)?Data.Modules.functions.map.set(qname,{error:TcHmi.Errors.E_NOT_UNIQUE,errorDetails:{code:TcHmi.Errors.E_NOT_UNIQUE,message:TcHmi.Errors[TcHmi.Errors.E_NOT_UNIQUE],domain:"TcHmi",reason:`Multiple module definitions with the name ${qname} found.`}}):Data.Modules.functions.map.set(qname,module))}else registration?registration.error!==TcHmi.Errors.NONE&&Log.errorEx(`[Source=Framework, Module=TcHmi.Init] Registration of function "${qname}" is not valid and function will therefore not be available. Details: ${Log.buildMessage(registration.errorDetails)}`):Log.errorEx('[Source=Framework, Module=TcHmi.Init] Function "'+qname+'" is not registered and will therefore not be available.\nPossible reason/s:\n- Source file: "'+cleanPath.replace(".function.json",".js")+'" contains a call to "TcHmi.Functions.registerFunctionEx" or "TcHmi.Functions.registerFunction" with name and/or namespace not matching the definition in function description file: "'+cleanPath+'".\n- Source file: "'+cleanPath.replace(".function.json",".js")+'" is not included in html document.\n- Source file: "'+cleanPath.replace(".function.json",".js")+'" contains no call to "TcHmi.Functions.registerFunctionEx" or "TcHmi.Functions.registerFunction".');return PendingCounter.PackageFunctionDescriptionLoaded--,PendingCounter.PackageFunctionDescriptionLoaded<=0?(__initStep=INIT_STATE.CONFIG_FUNCTION_DESCRIPTION_LOAD,void updateSplashScreen({callInitStateMachine:!0,skipStageUpdate:!0})):void 0}),xhrPackageFunctionDescr.addEventListener("error",xhrPackageFunctionDescrError),xhrPackageFunctionDescr.send()};for(let i=0,ii=packageFunctions.length;i<ii;i++)loadPackageFunctionDescription(packageFunctions[i]);break}__initStep=INIT_STATE.CONFIG_FUNCTION_DESCRIPTION_LOAD,updateSplashScreen({callInitStateMachine:!0,skipStageUpdate:!0});break;case INIT_STATE.CONFIG_FUNCTION_DESCRIPTION_LOAD:if("complete"!==document.readyState){document.addEventListener("readystatechange",InitStateMachine,{once:!0});break}if(Log.performanceLog(`[Source=Framework, Module=TcHmi.Init] INIT_STATE.${INIT_STATE[__initStep]}: ${configFunctions.length} User Functions`),__initStep=INIT_STATE.IDLE,PendingCounter.ConfigFunctionDescriptionLoaded=configFunctions.length,configFunctions.length){const loadConfigFunctionDescription=function(url){const cleanPath=tchmi_path(url);let xhrConfigFunctionDescr=new XMLHttpRequest;xhrConfigFunctionDescr.open("GET",tchmi_encode_uri_components(url)+xhrCacheSuffix);let xhrConfigFunctionDescrError=function(evt){Log.errorEx(`[Source=Framework, Module=TcHmi.Init] Failed to load function description: "${xhrConfigFunctionDescr.responseURL||cleanPath}". Related functions will not be available. Details: HTTP error ${xhrConfigFunctionDescr.status} ${xhrConfigFunctionDescr.statusText}`),PendingCounter.ConfigFunctionDescriptionLoaded--,PendingCounter.ConfigFunctionDescriptionLoaded<=0&&(__initStep=INIT_STATE.REGISTRATION_CHECK,initStageInfo.get(initStage).done++,loadNextStage(INIT_STAGE.Connectivity),updateSplashScreen({callInitStateMachine:!0}))};xhrConfigFunctionDescr.addEventListener("load",function(evt){if(200!==xhrConfigFunctionDescr.status)return void xhrConfigFunctionDescrError(evt);const descrRes=ValueConverter.toObjectEx(xhrConfigFunctionDescr.responseText);let descr=descrRes.value;if(!descr||!descr.function)return Log.errorEx(`[Source=Framework, Module=TcHmi.Init] Failed to load function description: "${cleanPath}". Related functions will not be available. Response is no valid function JSON. Details: ${Log.buildMessage(descrRes.details)}`),PendingCounter.ConfigFunctionDescriptionLoaded--,PendingCounter.ConfigFunctionDescriptionLoaded<=0?(__initStep=INIT_STATE.REGISTRATION_CHECK,void updateSplashScreen({callInitStateMachine:!0,skipStageUpdate:!0})):void 0;let name=descr.function.name,namespace=descr.function.namespace,qname=resolveQualifiedName(name,namespace),registration=functionRegistrations.map.get(name);if(registration&&registration.error!==TcHmi.Errors.E_NOT_UNIQUE||(registration=functionRegistrations.map.get(qname)),registration&&registration.error===TcHmi.Errors.NONE){let module={reg:registration,description:descr,error:TcHmi.Errors.NONE};Data.Modules.functions.map.has(name)?Data.Modules.functions.map.set(name,{error:TcHmi.Errors.E_NOT_UNIQUE,errorDetails:{code:TcHmi.Errors.E_NOT_UNIQUE,message:TcHmi.Errors[TcHmi.Errors.E_NOT_UNIQUE],domain:"TcHmi",reason:`Ambiguous module definitions for the name: "${name}". Please try fully qualified name.`}}):Data.Modules.functions.map.set(name,module),qname!==name&&(Data.Modules.functions.map.has(qname)?Data.Modules.functions.map.set(qname,{error:TcHmi.Errors.E_NOT_UNIQUE,errorDetails:{code:TcHmi.Errors.E_NOT_UNIQUE,message:TcHmi.Errors[TcHmi.Errors.E_NOT_UNIQUE],domain:"TcHmi",reason:`Multiple module definitions with the name ${qname} found.`}}):Data.Modules.functions.map.set(qname,module))}else registration?registration.error!==TcHmi.Errors.NONE&&Log.errorEx(`[Source=Framework, Module=TcHmi.Init] Registration of function "${qname}" is not valid and function will therefore not be available. Details: ${Log.buildMessage(registration.errorDetails)}`):Log.errorEx('[Source=Framework, Module=TcHmi.Init] Function "'+qname+'" is not registered and will therefore not be available.\nPossible reason/s:\n- Source file: "'+cleanPath.replace(".function.json",".js")+'" contains a call to "TcHmi.Functions.registerFunctionEx" or "TcHmi.Functions.registerFunction" (deprecated) with name and/or namespace not matching the definition in function description file: "'+url+'".\n- Source file: "'+cleanPath.replace(".function.json",".js")+'" contains no call to "TcHmi.Functions.registerFunctionEx" or "TcHmi.Functions.registerFunction" (deprecated).\n- Source file: "'+cleanPath.replace(".function.json",".js")+'" is not included in html document.\n');PendingCounter.ConfigFunctionDescriptionLoaded--,PendingCounter.ConfigFunctionDescriptionLoaded<=0&&(__initStep=INIT_STATE.REGISTRATION_CHECK,initStageInfo.get(initStage).done++,loadNextStage(INIT_STAGE.Connectivity),updateSplashScreen({callInitStateMachine:!0}))}),xhrConfigFunctionDescr.addEventListener("error",xhrConfigFunctionDescrError),xhrConfigFunctionDescr.send()};for(const configFunction of configFunctions)if(configFunction.url.endsWith(".js")||configFunction.url.endsWith(".mjs")){loadConfigFunctionDescription(configFunction.url.replace(".js",".function.json").replace(".mjs",".function.json"))}else Log.errorEx('[Source=Framework, Module=TcHmi.Init] Configuration file: "Properties/tchmiconfig.json" is not valid. userFunctions includes a wrong formed entry. url must end with ".js". Reference will be skipped. Entry:',configFunction),PendingCounter.ConfigFunctionDescriptionLoaded--}PendingCounter.ConfigFunctionDescriptionLoaded<=0&&(__initStep=INIT_STATE.REGISTRATION_CHECK,initStageInfo.get(initStage).done++,loadNextStage(INIT_STAGE.Connectivity),updateSplashScreen({callInitStateMachine:!0}));break;case INIT_STATE.REGISTRATION_CHECK:{Log.performanceLog(`[Source=Framework, Module=TcHmi.Init] INIT_STATE.${INIT_STATE[__initStep]}`);const unresolvedControlRegistrations=controlRegistrations.array.filter(registeredControl=>!!registeredControl.name&&!controlManager.getDescription(resolveQualifiedName(registeredControl.name,registeredControl.namespace))),controlsWithoutMetadataNameList=[];for(const registration of unresolvedControlRegistrations)registration.name&&controlRegistrations.map.get(registration.name)?.error!==TcHmi.Errors.E_NOT_UNIQUE&&controlsWithoutMetadataNameList.push(resolveQualifiedName(registration.name,registration.namespace));controlsWithoutMetadataNameList.length&&Log.errorEx("[Source=Framework, Module=TcHmi.Init] Missing metadata for controls: "+controlsWithoutMetadataNameList.join(", ")+". Control types will not be available. Possible reasons could be: Missing entry in tchmiconfig.json#packages, incomplete Manifest.json or missing/invalid Description.json (including type=JavaScript vs type=EsModule errors)");const unresolvedFunctionRegistrations=functionRegistrations.array.filter(registeredFunction=>!!registeredFunction.name&&!Data.Modules.functions.map.has(resolveQualifiedName(registeredFunction.name,registeredFunction.namespace))),functionsWithoutMetadataNameList=[];for(const registration of unresolvedFunctionRegistrations)registration.name&&functionsWithoutMetadataNameList.push(resolveQualifiedName(registration.name,registration.namespace));functionsWithoutMetadataNameList.length&&Log.errorEx("[Source=Framework, Module=TcHmi.Init] Missing metadata for functions: "+functionsWithoutMetadataNameList.join(", ")+". Functions will not be available. Possible reasons could be: Missing entry in tchmiconfig.json#userFunctions, incomplete Manifest.json or missing/invalid *.function.json"),__initStep=INIT_STATE.OPEN_SERVER_CONNECTION}case INIT_STATE.OPEN_SERVER_CONNECTION:Log.performanceLog(`[Source=Framework, Module=TcHmi.Init] INIT_STATE.${INIT_STATE[__initStep]}`),__initStep=INIT_STATE.IDLE,PendingCounter.OpenServerConnection=1,serverManager.open(resultObject=>{if(0===PendingCounter.OpenServerConnection)return;if(PendingCounter.OpenServerConnection=0,__initStep===INIT_STATE.ERROR)return;SystemInit.__resolveInitializedServerCommunicationPromise();let finalized=!1;const finalize=()=>{if(!finalized){if(finalized=!0,initStageInfo.get(initStage).done++,updateSplashScreen(),resultObject.error===TcHmi.Errors.NONE)return __initStep=INIT_STATE.OPEN_ENGINEERING_CONNECTION,void InitStateMachine();resultObject.error===TcHmi.Errors.E_WEBSOCKET_OPEN_SERVER_LICENSE_CHECK_FAILED?(Log.errorEx("[Source=Framework, Module=TcHmi.Init] Failed to check server license: "+Log.buildMessage(resultObject.details)),dialogManager.showDialog("__TcHmiMain",!0,TcHmi.DialogManager.DialogType.Overlay),dialogManager.updateTextEx("__TcHmiMain",frameworkLocalization.getText("Open_Server_Connection_Failed",{level:TcHmi.Locale.Level.Engineering,preventHtml:!0})+" "+frameworkLocalization.getText("Server_License_Check_Failed failed",{level:TcHmi.Locale.Level.Engineering,preventHtml:!0})+"<br/>\n"+TcHmi.DialogManager.buildMessage(resultObject.details)+'<br/>\n<input type="submit" value="'+frameworkLocalization.getText("Reload",{level:TcHmi.Locale.Level.Engineering,preventHtml:!0})+'" style="padding:10px;" onclick="window.location.reload()">',{severity:TcHmi.DialogManager.DialogSeverity.Error,buttonReload:!TCHMI_DESIGNER})):resultObject.error===TcHmi.Errors.E_SERVER_COMMAND_ERROR?(Log.errorEx("[Source=Framework, Module=TcHmi.Init] Server license symbol invalid: "+Log.buildMessage(resultObject.details)),dialogManager.showDialog("__TcHmiMain",!0,TcHmi.DialogManager.DialogType.Overlay),dialogManager.updateTextEx("__TcHmiMain",frameworkLocalization.getText("Open_Server_Connection_Failed",{level:TcHmi.Locale.Level.Engineering,preventHtml:!0})+" "+frameworkLocalization.getText("Server_Command_Error",{level:TcHmi.Locale.Level.Engineering,preventHtml:!0})+"<br/>\n"+TcHmi.DialogManager.buildMessage(resultObject.details),{severity:TcHmi.DialogManager.DialogSeverity.Error,buttonReload:!TCHMI_DESIGNER})):resultObject.error===TcHmi.Errors.E_WEBSOCKET_OPEN_SERVER_LICENSE_MISSING?(Log.errorEx("[Source=Framework, Module=TcHmi.Init] Server license is missing: "+Log.buildMessage(resultObject.details)),TCHMI_DESIGNER?(dialogManager.showDialog("__TcHmiMain",!0,TcHmi.DialogManager.DialogType.Overlay),dialogManager.updateTextEx("__TcHmiMain",frameworkLocalization.getText("Open_Server_Connection_Failed",{level:TcHmi.Locale.Level.Engineering,preventHtml:!0})+" "+frameworkLocalization.getText("License_Missing",{level:TcHmi.Locale.Level.Engineering,preventHtml:!0})+" "+frameworkLocalization.getText("Reopen_Editor_Window",{level:TcHmi.Locale.Level.Engineering,preventHtml:!0}),{severity:TcHmi.DialogManager.DialogSeverity.Error,buttonReload:!TCHMI_DESIGNER})):(dialogManager.showDialog("__TcHmiMain",!0,TcHmi.DialogManager.DialogType.Overlay),dialogManager.updateTextEx("__TcHmiMain",frameworkLocalization.getText("Open_Server_Connection_Failed",{level:TcHmi.Locale.Level.Engineering,preventHtml:!0})+" "+frameworkLocalization.getText("License_Missing",{level:TcHmi.Locale.Level.Engineering,preventHtml:!0})+"<br/>\n"+TcHmi.DialogManager.buildMessage(resultObject.details),{severity:TcHmi.DialogManager.DialogSeverity.Error,buttonReload:!TCHMI_DESIGNER}))):resultObject.error===TcHmi.Errors.E_WEBSOCKET_OPEN_SERVER_NO_ACCESS?(dialogManager.showDialog("__TcHmiMain",!0,TcHmi.DialogManager.DialogType.Overlay),dialogManager.updateTextEx("__TcHmiMain",frameworkLocalization.getText("Open_Server_Connection_Failed",{level:TcHmi.Locale.Level.Engineering,preventHtml:!0})+" "+frameworkLocalization.getText("Server_Denied_Access",{level:TcHmi.Locale.Level.Engineering,preventHtml:!0})+" "+tchmi_format_string(frameworkLocalization.getText("Reload_In_N_Seconds",{level:TcHmi.Locale.Level.Engineering,preventHtml:!0}),"5")+"<br/>\n"+TcHmi.DialogManager.buildMessage(resultObject.details),{severity:TcHmi.DialogManager.DialogSeverity.Error,buttonReload:!TCHMI_DESIGNER}),setTimeout(function(){window.location.reload()},5e3)):TCHMI_DESIGNER?(Log.errorEx("[Source=Framework, Module=TcHmi.Init] Opening connection to engineering server failed: "+Log.buildMessage(resultObject.details)),dialogManager.showDialog("__TcHmiMain",!0,TcHmi.DialogManager.DialogType.Overlay),dialogManager.updateTextEx("__TcHmiMain",frameworkLocalization.getText("Open_Server_Connection_Failed",{level:TcHmi.Locale.Level.Engineering,preventHtml:!0})+" "+frameworkLocalization.getText("Please_Start_Engineering_Server",{level:TcHmi.Locale.Level.Engineering,preventHtml:!0}),{severity:TcHmi.DialogManager.DialogSeverity.Error,buttonReload:!TCHMI_DESIGNER})):(Log.errorEx("[Source=Framework, Module=TcHmi.Init] Opening connection to server failed: "+Log.buildMessage(resultObject.details)),dialogManager.showDialog("__TcHmiMain",!0,TcHmi.DialogManager.DialogType.Overlay),dialogManager.updateTextEx("__TcHmiMain",frameworkLocalization.getText("Open_Server_Connection_Failed",{level:TcHmi.Locale.Level.Engineering,preventHtml:!0})+"<br />\n"+frameworkLocalization.getText("Possible_Reasons",{level:TcHmi.Locale.Level.Engineering,preventHtml:!0})+":<br />\n- "+frameworkLocalization.getText("Possibly_Reason_Server_Websocket_Certificate_Not_Trusted",{level:TcHmi.Locale.Level.Engineering,preventHtml:!0})+"<br />\n- "+tchmi_format_string(frameworkLocalization.getText("Possibly_Reason_Url_Targets_No_Running_Websocket_Server",{level:TcHmi.Locale.Level.Engineering,preventHtml:!0}),resultObject.url)+"<br />\n- "+frameworkLocalization.getText("Possibly_Reason_Proxy_Problem",{level:TcHmi.Locale.Level.Engineering,preventHtml:!0})+"<br />\n<br />\n"+frameworkLocalization.getText("Browser_Console_Could_Have_More_Information",{level:TcHmi.Locale.Level.Engineering,preventHtml:!0}),{severity:TcHmi.DialogManager.DialogSeverity.Error,buttonReload:!TCHMI_DESIGNER})),__initStep=INIT_STATE.ERROR,InitStateMachine()}};if(accessManager.isReady()||resultObject.error!==TcHmi.Errors.NONE)finalize();else{let timeoutId=0,destroy=TcHmi.EventProvider.register("System.onAccessManagerReady",(e,data)=>{clearTimeout(timeoutId),e.destroy(),destroy=null,finalize()});timeoutId=setTimeout(()=>{destroy&&(destroy(),destroy=null),finalize()},5e3)}});break;case INIT_STATE.OPEN_ENGINEERING_CONNECTION:if(Log.performanceLog(`[Source=Framework, Module=TcHmi.Init] INIT_STATE.${INIT_STATE[__initStep]}`),!TCHMI_ENGINEERING||TCHMI_SINGLECONTROL)return __initStep=INIT_STATE.THEME_MANAGER_FINAL,initStageInfo.get(initStage).done++,SystemInit.__resolveInitializedCommunicationPromise(),loadNextStage(INIT_STAGE.LoadingTypeDefinitions),void updateSplashScreen({callInitStateMachine:!0});__initStep=INIT_STATE.IDLE,PendingCounter.OpenEngineeringConnection=1,promiseTimeout(import("./System/Engineering/DesignerModeComManager.js")).catch(ex=>{const resourceUrl="./System/Engineering/DesignerModeComManager.js";return Log.errorEx(`[Source=Framework, Module=TcHmi.Init] Failed to load ${resourceUrl} in Framework init:`,ex),dialogManager.showDialog("__TcHmiMain",!0,TcHmi.DialogManager.DialogType.Overlay),dialogManager.updateTextEx("__TcHmiMain",tchmi_format_string(frameworkLocalization.getText("Loading_File_Failed_With_Error",{level:TcHmi.Locale.Level.Engineering,preventHtml:!0}),resourceUrl,ex),{severity:TcHmi.DialogManager.DialogSeverity.Error,buttonReload:!TCHMI_DESIGNER}),PendingCounter.OpenEngineeringConnection=0,__initStep=INIT_STATE.ERROR,InitStateMachine(),Promise.reject(ex)}).then(module=>{module.designerModeComManager.open(resultObject=>{if(0!==PendingCounter.OpenEngineeringConnection&&__initStep!==INIT_STATE.ERROR){if(resultObject.error===TcHmi.Errors.NONE)return PendingCounter.OpenEngineeringConnection=0,initStageInfo.get(initStage).done++,__initStep=INIT_STATE.THEME_MANAGER_FINAL,SystemInit.__resolveInitializedCommunicationPromise(),loadNextStage(INIT_STAGE.LoadingTypeDefinitions),void updateSplashScreen({callInitStateMachine:!0});Log.errorEx("[Source=Framework, Module=TcHmi.Init] Communication to TwinCAT HMI Creator failed: "+Log.buildMessage(resultObject.details)),dialogManager.showDialog("__TcHmiMain",!0,TcHmi.DialogManager.DialogType.Overlay),TCHMI_DESIGNER?dialogManager.updateTextEx("__TcHmiMain",frameworkLocalization.getText("Open_Engineering_Server_Connection_Failed",{level:TcHmi.Locale.Level.Engineering,preventHtml:!0})+" "+TcHmi.DialogManager.buildMessage(resultObject.details)+"<br/>\n"+frameworkLocalization.getText("Try_Reopen_Designer_Window",{level:TcHmi.Locale.Level.Engineering,preventHtml:!0}),{severity:TcHmi.DialogManager.DialogSeverity.Error,buttonReload:!TCHMI_DESIGNER}):dialogManager.updateTextEx("__TcHmiMain",frameworkLocalization.getText("Open_Engineering_Server_Connection_Failed",{level:TcHmi.Locale.Level.Engineering,preventHtml:!0})+" "+TcHmi.DialogManager.buildMessage(resultObject.details),{severity:TcHmi.DialogManager.DialogSeverity.Error,buttonReload:!TCHMI_DESIGNER}),PendingCounter.OpenEngineeringConnection=0,__initStep=INIT_STATE.ERROR,InitStateMachine()}})});break;case INIT_STATE.THEME_MANAGER_FINAL:Log.performanceLog(`[Source=Framework, Module=TcHmi.Init] INIT_STATE.${INIT_STATE[__initStep]}`),__initStep=INIT_STATE.IDLE,themeManager.processActiveTheme(),__initStep=INIT_STATE.TYPEDEFINITIONS,updateSplashScreen({callInitStateMachine:!0});break;case INIT_STATE.TYPEDEFINITIONS:Log.performanceLog(`[Source=Framework, Module=TcHmi.Init] INIT_STATE.${INIT_STATE[__initStep]}`),__initStep=INIT_STATE.IDLE,PendingCounter.TypeDefinitionsResolved=1,typeManager.doWatchOrResolveSchemaDefinitions(function(data){data.error===TcHmi.Errors.NONE?(PendingCounter.TypeDefinitionsResolved=0,Log.debugEx("[Source=Framework, Module=TcHmi.Init] Resolving type definitions finished."),__initStep=INIT_STATE.AUDIT_TRAIL_INIT):(Log.errorEx("[Source=Framework, Module=TcHmi.Init] Resolving type definitions failed: "+Log.buildMessage(data.details)),dialogManager.showDialog("__TcHmiMain",!0,TcHmi.DialogManager.DialogType.Overlay),dialogManager.updateTextEx("__TcHmiMain",frameworkLocalization.getText("Resolving_Type_Definition_Failed",{level:TcHmi.Locale.Level.Engineering,preventHtml:!0})+": "+Log.buildMessage(data.details),{severity:TcHmi.DialogManager.DialogSeverity.Error,buttonReload:!TCHMI_DESIGNER}),__initStep=INIT_STATE.ERROR),InitStateMachine()});break;case INIT_STATE.AUDIT_TRAIL_INIT:Log.performanceLog(`[Source=Framework, Module=TcHmi.Init] INIT_STATE.${INIT_STATE[__initStep]}`),__initStep=INIT_STATE.IDLE,PendingCounter.AuditTrailInitialized=1,auditTrailRun(()=>{0!==PendingCounter.AuditTrailInitialized&&(PendingCounter.AuditTrailInitialized=0,__initStep=INIT_STATE.SERVER_SYMBOL_META_DATA_CACHE,TCHMI_UNITTEST_INIT_NO_NEXT_STAGE||InitStateMachine())});break;case INIT_STATE.SERVER_SYMBOL_META_DATA_CACHE:Log.performanceLog(`[Source=Framework, Module=TcHmi.Init] INIT_STATE.${INIT_STATE[__initStep]}`),__initStep=INIT_STATE.IDLE,PendingCounter.ServerSymbolMetaDataCacheResolved=1,serverManager.watchOrResolveServerSymbolMetaData(data=>{if(initStageInfo.get(initStage).done++,updateSplashScreen(),data.error===TcHmi.Errors.NONE){PendingCounter.ServerSymbolMetaDataCacheResolved=0;for(const[key,item]of Object.entries(tchmi_clone_object(config.symbols.internal)))internalSymbolManager.add(key,item),TCHMI_ENGINEERING&&internalSymbolManager.add(`Package:{PkgId};${key}`,item);for(const[key,item]of Object.entries(tchmi_clone_object(config.symbols.timer)))timerSymbolManager.add(key,item),TCHMI_ENGINEERING&&timerSymbolManager.add(`Package:{PkgId};${key}`,item);for(const[key,item]of Object.entries(tchmi_clone_object(config.intervals)))intervalManager.add(key,item),TCHMI_ENGINEERING&&intervalManager.add(`Package:{PkgId};${key}`,item);if(TCHMI_ENGINEERING)for(const[key,item]of Object.entries(tchmi_clone_object(config.symbols.package)))internalSymbolManager.add(`Package_Symbol_Engineering_Mapping_Symbol_Simulation:{PkgId};${key}`,item),packageSymbolManager.add(key,{type:item.type,symbol:`%i%Package_Symbol_Engineering_Mapping_Symbol_Simulation:{PkgId};${key}%/i%`}),packageSymbolManager.add(`Package:{PkgId};${key}`,{type:item.type,symbol:`%i%Package_Symbol_Engineering_Mapping_Symbol_Simulation:{PkgId};${key}%/i%`});Data.packages.forEach((pkg,name)=>{if(pkg.manifest.symbols){if(pkg.manifest.symbols.internal)for(const[key,item]of Object.entries(tchmi_clone_object(pkg.manifest.symbols.internal))){let override;if(pkg.config&&pkg.config.symbols&&pkg.config.symbols.internal)for(const[overrideKey,overrideItem]of Object.entries(tchmi_clone_object(pkg.config.symbols.internal)))if(overrideKey===key){override=overrideItem;break}internalSymbolManager.add("Package:"+pkg.name+";"+key,{type:item.type,value:override&&void 0!==override.value?override.value:item.value,persist:override&&void 0!==override.persist?override.persist:item.persist,readonly:override&&void 0!==override.readonly?override.readonly:item.readonly})}if(pkg.manifest.symbols.timer)for(const[key,item]of Object.entries(tchmi_clone_object(pkg.manifest.symbols.timer))){let override;if(pkg.config&&pkg.config.symbols&&pkg.config.symbols.timer)for(const[overrideKey,overrideItem]of Object.entries(tchmi_clone_object(pkg.config.symbols.timer)))if(overrideKey===key){override=overrideItem;break}timerSymbolManager.add("Package:"+pkg.name+";"+key,{type:item.type,pattern:override&&void 0!==override.pattern?override.pattern:item.pattern,stopValue:override&&void 0!==override.stopValue?override.stopValue:item.stopValue,runSymbol:override&&void 0!==override.runSymbol?override.runSymbol:item.runSymbol})}if(pkg.manifest.symbols.package)for(const[key,item]of Object.entries(tchmi_clone_object(pkg.manifest.symbols.package))){let mapping;if(pkg.config&&pkg.config.symbols&&pkg.config.symbols.package)for(const[mappingKey,mappingItem]of Object.entries(tchmi_clone_object(pkg.config.symbols.package)))if(mappingKey===key){mapping=mappingItem;break}mapping&&packageSymbolManager.add("Package:"+pkg.name+";"+key,mapping)}if(pkg.manifest.intervals)for(const[key,item]of Object.entries(tchmi_clone_object(pkg.manifest.intervals)))intervalManager.add("Package:"+pkg.name+";"+key,item)}}),__initStep=INIT_STATE.VALIDATION,loadNextStage(INIT_STAGE.Validation),updateSplashScreen({callInitStateMachine:!0})}else Log.errorEx("[Source=Framework, Module=TcHmi.Init] Resolving server symbol schema cache failed: "+Log.buildMessage(data.details)),dialogManager.showDialog("__TcHmiMain",!0,TcHmi.DialogManager.DialogType.Overlay),dialogManager.updateTextEx("__TcHmiMain",frameworkLocalization.getText("Resolving_Server_Symbol_Meta_Data_Cache_Failed",{level:TcHmi.Locale.Level.Engineering,preventHtml:!0})+": "+Log.buildMessage(data.details),{severity:TcHmi.DialogManager.DialogSeverity.Error,buttonReload:!TCHMI_DESIGNER}),__initStep=INIT_STATE.ERROR,InitStateMachine()});break;case INIT_STATE.VALIDATION:{Log.performanceLog(`[Source=Framework, Module=TcHmi.Init] INIT_STATE.${INIT_STATE[__initStep]}`);for(const module of Data.Modules.controls.array)module.description?.attributes.forEach(attribute=>{const res=typeManager.getSchemaEx(attribute.type);res.error!==TcHmi.Errors.NONE&&Log.errorEx(`[Source=Framework, Module=TcHmi.Init] Attribute ${attribute.propertyName} of control `+resolveQualifiedName(module.description.name,module.description?.namespace)+` uses invalid data type ${attribute.type}: ${Log.buildMessage(res.details)}`)});const importMap=JSON.parse(document.querySelector("script[type=importmap]")?.textContent??"{}");importMap?.imports||(Log.warnEx("[Source=Framework, Module=TcHmi.Init] No modern importmap was found in HTML. Please consider upgrading TwinCAT HMI Engineering for full support of Javascript Module controls."),TCHMI_DESIGNER&&TCHMI_TARGET_PARTIAL===config.startupView&&TcHmi.Engineering.ErrorPane.add("missing-importmap","No modern importmap was found in HTML. Please consider upgrading TwinCAT HMI Engineering for full support of Javascript Module controls.",TcHmi.Engineering.ErrorPane.MessageType.Warning));for(const module of new Set(Data.Modules.functions.map.values())){if(module.error!==TcHmi.Errors.NONE||!module.description)continue;let qname=resolveQualifiedName(module.description.function.name,module.description.function.namespace);if(module.description.function.returnValue?.type){const res=typeManager.getSchemaEx(module.description.function.returnValue.type);res.error!==TcHmi.Errors.NONE&&Log.errorEx(`[Source=Framework, Module=TcHmi.Init] ReturnValue of function ${qname} uses invalid data type ${module.description.function.returnValue.type}: ${Log.buildMessage(res.details)}`)}module.description.function.arguments&&module.description.function.arguments.forEach((argument,index)=>{const res=typeManager.getSchemaEx(argument.type);res.error!==TcHmi.Errors.NONE&&Log.errorEx(`[Source=Framework, Module=TcHmi.Init] Argument#${index} ${argument.name} of function ${qname} uses invalid data type ${argument.type}: ${Log.buildMessage(res.details)}`)})}__initStep=INIT_STATE.PACKAGE_USERCONTROL_LOAD,loadNextStage(INIT_STAGE.LoadingUserControls),updateSplashScreen({callInitStateMachine:!0})}break;case INIT_STATE.PACKAGE_USERCONTROL_LOAD:{Log.performanceLog(`[Source=Framework, Module=TcHmi.Init] INIT_STATE.${INIT_STATE[__initStep]}: ${configUserControls.length} User Controls`),__initStep=INIT_STATE.IDLE;const loadUserControlMarkup=function(url){let xhrUserControl=new XMLHttpRequest;xhrUserControl.open("GET",tchmi_encode_uri_components(url)+xhrCacheSuffix);let xhrUserControlError=function(evt){__initStep!==INIT_STATE.ERROR&&(Log.errorEx("[Source=Framework, Module=TcHmi.Init] Loading "+url+" failed. Errordetail: "+xhrUserControl.statusText),PendingCounter.PackageUserControlsLoaded--,initStageInfo.get(initStage).done++,updateSplashScreen(),PendingCounter.PackageUserControlsLoaded<=0&&(controlManager.resolveUcAttributes(),themeManager.retriggerUserControls(),__initStep=INIT_STATE.USERCONTROL_LOAD,TCHMI_DESIGNER||document.hidden?(loadNextStage(INIT_STAGE.LoadingContent),InitStateMachine()):setTimeout(()=>{loadNextStage(INIT_STAGE.LoadingContent),updateSplashScreen(),setTimeout(()=>{InitStateMachine()})})))};xhrUserControl.addEventListener("load",function(evt){200===xhrUserControl.status?__initStep!==INIT_STATE.ERROR&&(Data.Caches.partialMarkupCache.set(url,{markup:xhrUserControl.responseText}),!TCHMI_DESIGNER&&__fetchFromIndexedDb&&"done"===indexedDbRequest?.readyState&&indexedDbRequest.result?.objectStoreNames?.contains("userControlMarkup")&&indexedDbRequest.result.transaction("userControlMarkup","readwrite").objectStore("userControlMarkup").put(xhrUserControl.responseText,url),initStageInfo.get(initStage).done++,PendingCounter.PackageUserControlsLoaded--,updateSplashScreen(),PendingCounter.PackageUserControlsLoaded<=0&&(controlManager.resolveUcAttributes(),themeManager.retriggerUserControls(),__initStep=INIT_STATE.USERCONTROL_LOAD,TCHMI_DESIGNER||document.hidden?(loadNextStage(INIT_STAGE.LoadingUserControls),InitStateMachine()):setTimeout(()=>{loadNextStage(INIT_STAGE.LoadingUserControls),updateSplashScreen(),setTimeout(()=>{InitStateMachine()})}))):xhrUserControlError(evt)}),xhrUserControl.addEventListener("error",xhrUserControlError),xhrUserControl.send()},loadUserControlMarkupEngineering=function(urls){promiseTimeout(import("./System/Engineering/DesignerModePartialContentManager.js")).catch(ex=>{const resourceUrl="./System/Engineering/DesignerModePartialContentManager.js";return Log.errorEx(`Failed to load ${resourceUrl} in Framework init: ${ex}`),dialogManager.showDialog("__TcHmiMain",!0,TcHmi.DialogManager.DialogType.Overlay),dialogManager.updateTextEx("__TcHmiMain",tchmi_format_string(frameworkLocalization.getText("Loading_File_Failed_With_Error",{level:TcHmi.Locale.Level.Engineering,preventHtml:!0}),resourceUrl,ex),{severity:TcHmi.DialogManager.DialogSeverity.Error,buttonReload:!TCHMI_DESIGNER}),PendingCounter.OpenEngineeringConnection=0,__initStep=INIT_STATE.ERROR,InitStateMachine(),Promise.reject(ex)}).then(module=>{module.partialContentManager.requestCurrentPartialContents(urls.map(value=>({path:value})),data=>{if(data.error===TcHmi.Errors.NONE&&data.targetPartials){if(__initStep===INIT_STATE.ERROR)return;for(const targetPartial of data.targetPartials)targetPartial.content&&Data.Caches.partialMarkupCache.set(targetPartial.path,{markup:targetPartial.content});initStageInfo.get(initStage).done+=Object.keys(data.targetPartials).length,PendingCounter.PackageUserControlsLoaded-=Object.keys(data.targetPartials).length,PendingCounter.PackageUserControlsLoaded<=0?(controlManager.resolveUcAttributes(),themeManager.retriggerUserControls(),__initStep=INIT_STATE.USERCONTROL_LOAD,loadNextStage(INIT_STAGE.LoadingUserControls),updateSplashScreen({callInitStateMachine:!0})):updateSplashScreen()}else{if(__initStep===INIT_STATE.ERROR)return;Log.errorEx("[Source=Framework, Module=TcHmi.Init] Loading usercontrols failed. Errordetail: "+Log.buildMessage(data.details)),data.targetPartials.find(entry=>entry.path===TCHMI_TARGET_PARTIAL)?(dialogManager.showDialog("__TcHmiMain",!0,TcHmi.DialogManager.DialogType.Overlay),dialogManager.updateTextEx("__TcHmiMain",tchmi_format_string(frameworkLocalization.getText("Loading_File_Failed",{level:TcHmi.Locale.Level.Engineering,preventHtml:!0}),TCHMI_TARGET_PARTIAL),{severity:TcHmi.DialogManager.DialogSeverity.Error,buttonReload:!TCHMI_DESIGNER}),__initStep=INIT_STATE.ERROR,InitStateMachine()):(initStageInfo.get(initStage).done++,PendingCounter.PackageUserControlsLoaded--,PendingCounter.PackageUserControlsLoaded<=0?(controlManager.resolveUcAttributes(),themeManager.retriggerUserControls(),__initStep=INIT_STATE.USERCONTROL_LOAD,loadNextStage(INIT_STAGE.LoadingUserControls),updateSplashScreen({callInitStateMachine:!0})):updateSplashScreen())}})})},loadUserControlConfig=function(url,packageInfo){let xhrUserControlDescr=new XMLHttpRequest;xhrUserControlDescr.open("GET",tchmi_encode_uri_components(url)+xhrCacheSuffix);let xhrUserControlDescrError=function(evt){PendingCounter.PackageUserControlsLoaded--,PendingCounter.PackageUserControlsLoaded<=0&&(controlManager.resolveUcAttributes(),themeManager.retriggerUserControls(),__initStep=INIT_STATE.USERCONTROL_LOAD,loadNextStage(INIT_STAGE.LoadingUserControls),TCHMI_DESIGNER||document.hidden?InitStateMachine():setTimeout(()=>{updateSplashScreen(),setTimeout(()=>{InitStateMachine()})}))};xhrUserControlDescr.addEventListener("load",function(evt){if(200!==xhrUserControlDescr.status)return void xhrUserControlDescrError(evt);const ucConfigRes=TcHmi.ValueConverter.toObjectEx(resolveReplaceExpressions(xhrUserControlDescr.responseText,{PkgId:packageInfo.name,PkgBasePath:packageInfo.basePath}));let ucConfig=ucConfigRes.value;ucConfig?(Data.Caches.partialCompositeConfigCache.set(url,ucConfig),!TCHMI_DESIGNER&&__fetchFromIndexedDb&&"done"===indexedDbRequest?.readyState&&indexedDbRequest.result?.objectStoreNames?.contains("userControlConfig")&&indexedDbRequest.result.transaction("userControlConfig","readwrite").objectStore("userControlConfig").put(ucConfig,url)):Log.errorEx('[Source=Framework, Module=TcHmi.Init] Failed to load user control config: "'+url+'". Response is no valid user control JSON. Details: '+Log.buildMessage(ucConfigRes.details)),PendingCounter.PackageUserControlsLoaded--,initStageInfo.get(initStage).done++,updateSplashScreen(),PendingCounter.PackageUserControlsLoaded<=0&&(controlManager.resolveUcAttributes(),themeManager.retriggerUserControls(),__initStep=INIT_STATE.USERCONTROL_LOAD,loadNextStage(INIT_STAGE.LoadingUserControls),TCHMI_DESIGNER||document.hidden?InitStateMachine():setTimeout(()=>{updateSplashScreen(),setTimeout(()=>{InitStateMachine()})}))}),xhrUserControlDescr.addEventListener("error",xhrUserControlDescrError),xhrUserControlDescr.send()};if(PendingCounter.PackageUserControlsLoaded=2*packageUserControls.length,packageUserControls&&packageUserControls.length>0){const urlsToFetchFromEngineering=[];for(const packageUserControl of packageUserControls){let markupUrl=tchmi_path(packageUserControl.package.basePath+"/"+packageUserControl.module.path);if(__fetchFromIndexedDb&&Data.Caches.partialMarkupCache.has(markupUrl))PendingCounter.PackageUserControlsLoaded--,initStageInfo.get(initStage).done++;else{TCHMI_ENGINEERING&&(packageUserControl.package.config.engineering?.projectReference??!1)?urlsToFetchFromEngineering.push(markupUrl):loadUserControlMarkup(markupUrl)}if(!markupUrl.endsWith(".usercontrol")){Log.errorEx('[Source=Framework, Module=TcHmi.Init] Configuration file: "Properties/tchmiconfig.json" is not valid. userControls includes a wrong formed entry. url must end with ".js". Reference will be skipped. Entry: ',markupUrl),PendingCounter.PackageUserControlsLoaded--,initStageInfo.get(initStage).done++;continue}let configUrl=markupUrl.replace(".usercontrol",".usercontrol.json");__fetchFromIndexedDb&&Data.Caches.partialCompositeConfigCache.has(configUrl)?(PendingCounter.PackageUserControlsLoaded--,initStageInfo.get(initStage).done++):loadUserControlConfig(configUrl,packageUserControl.package)}urlsToFetchFromEngineering.length&&loadUserControlMarkupEngineering(urlsToFetchFromEngineering),PendingCounter.PackageUserControlsLoaded<=0&&(controlManager.resolveUcAttributes(),themeManager.retriggerUserControls(),__initStep=INIT_STATE.USERCONTROL_LOAD,loadNextStage(INIT_STAGE.LoadingUserControls),TCHMI_DESIGNER||document.hidden?InitStateMachine():setTimeout(()=>{updateSplashScreen(),setTimeout(()=>{InitStateMachine()})}))}else __initStep=INIT_STATE.USERCONTROL_LOAD,TCHMI_DESIGNER||document.hidden?(loadNextStage(INIT_STAGE.LoadingUserControls),InitStateMachine()):(updateSplashScreen(),setTimeout(()=>{loadNextStage(INIT_STAGE.LoadingUserControls),updateSplashScreen(),setTimeout(()=>{InitStateMachine()})}))}break;case INIT_STATE.USERCONTROL_LOAD:{Log.performanceLog(`[Source=Framework, Module=TcHmi.Init] INIT_STATE.${INIT_STATE[__initStep]}: ${configUserControls.length} User Controls`),__initStep=INIT_STATE.IDLE;const loadUserControlMarkup=function(urls){if(TCHMI_ENGINEERING)promiseTimeout(import("./System/Engineering/DesignerModePartialContentManager.js")).catch(ex=>{const resourceUrl="./System/Engineering/DesignerModePartialContentManager.js";return Log.errorEx(`[Source=Framework, Module=TcHmi.Init] Failed to load ${resourceUrl} in Framework init: ${ex}`),dialogManager.showDialog("__TcHmiMain",!0,TcHmi.DialogManager.DialogType.Overlay),dialogManager.updateTextEx("__TcHmiMain",tchmi_format_string(frameworkLocalization.getText("Loading_File_Failed_With_Error",{level:TcHmi.Locale.Level.Engineering,preventHtml:!0}),resourceUrl,ex),{severity:TcHmi.DialogManager.DialogSeverity.Error,buttonReload:!TCHMI_DESIGNER}),PendingCounter.OpenEngineeringConnection=0,__initStep=INIT_STATE.ERROR,InitStateMachine(),Promise.reject(ex)}).then(module=>{module.partialContentManager.requestCurrentPartialContents(urls.map(value=>({path:value})),data=>{if(data.error===TcHmi.Errors.NONE&&data.targetPartials){if(__initStep===INIT_STATE.ERROR)return;for(const targetPartial of data.targetPartials)targetPartial.content&&Data.Caches.partialMarkupCache.set(targetPartial.path,{markup:targetPartial.content});initStageInfo.get(initStage).done+=Object.keys(data.targetPartials).length,PendingCounter.ConfigUserControlsLoaded-=Object.keys(data.targetPartials).length,PendingCounter.ConfigUserControlsLoaded<=0?(controlManager.resolveUcAttributes(),themeManager.retriggerUserControls(),__initStep=INIT_STATE.CONTENT_LOAD,loadNextStage(INIT_STAGE.LoadingContent),updateSplashScreen({callInitStateMachine:!0})):updateSplashScreen()}else{if(__initStep===INIT_STATE.ERROR)return;Log.errorEx(`[Source=Framework, Module=TcHmi.Init] Loading usercontrols failed. Errordetail: ${Log.buildMessage(data.details)}`),data.targetPartials.find(entry=>entry.path===TCHMI_TARGET_PARTIAL)?(dialogManager.showDialog("__TcHmiMain",!0,TcHmi.DialogManager.DialogType.Overlay),dialogManager.updateTextEx("__TcHmiMain",tchmi_format_string(frameworkLocalization.getText("Loading_File_Failed",{level:TcHmi.Locale.Level.Engineering,preventHtml:!0}),TCHMI_TARGET_PARTIAL),{severity:DialogManager.DialogSeverity.Error,buttonReload:!TCHMI_DESIGNER}),__initStep=INIT_STATE.ERROR,InitStateMachine()):(initStageInfo.get(initStage).done+=urls.length,PendingCounter.ConfigUserControlsLoaded-=urls.length,PendingCounter.ConfigUserControlsLoaded<=0?(controlManager.resolveUcAttributes(),themeManager.retriggerUserControls(),__initStep=INIT_STATE.PACKAGE_CONTENT_LOAD,loadNextStage(INIT_STAGE.LoadingContent),updateSplashScreen({callInitStateMachine:!0})):updateSplashScreen())}})});else for(const url of urls){let xhrUserControl=new XMLHttpRequest;xhrUserControl.open("GET",tchmi_encode_uri_components(url)+xhrCacheSuffix);let xhrUserControlSuccess=function(evt){200===xhrUserControl.status?__initStep!==INIT_STATE.ERROR&&(Data.Caches.partialMarkupCache.set(url,{markup:xhrUserControl.responseText}),__fetchFromIndexedDb&&"done"===indexedDbRequest?.readyState&&indexedDbRequest.result?.objectStoreNames?.contains("userControlMarkup")&&indexedDbRequest.result.transaction("userControlMarkup","readwrite").objectStore("userControlMarkup").put(xhrUserControl.responseText,url),initStageInfo.get(initStage).done++,PendingCounter.ConfigUserControlsLoaded--,PendingCounter.ConfigUserControlsLoaded<=0?(controlManager.resolveUcAttributes(),themeManager.retriggerUserControls(),__initStep=INIT_STATE.PACKAGE_CONTENT_LOAD,loadNextStage(INIT_STAGE.LoadingContent),updateSplashScreen({callInitStateMachine:!0})):updateSplashScreen()):xhrUserControlError(evt)},xhrUserControlError=function(evt){__initStep!==INIT_STATE.ERROR&&(Log.errorEx(`[Source=Framework, Module=TcHmi.Init] Loading ${xhrUserControl.responseURL||url} failed. Details: HTTP error ${xhrUserControl.status} ${xhrUserControl.statusText}`),url===TCHMI_TARGET_PARTIAL?(dialogManager.showDialog("__TcHmiMain",!0,TcHmi.DialogManager.DialogType.Overlay),dialogManager.updateTextEx("__TcHmiMain",tchmi_format_string(frameworkLocalization.getText("Loading_File_Failed",{level:TcHmi.Locale.Level.Engineering,preventHtml:!0}),url)+" "+frameworkLocalization.getText("Propably_Syntax_Error_Html_Or_Wrong_Entry_Config",{level:TcHmi.Locale.Level.Engineering,preventHtml:!0})+" "+tchmi_format_string(frameworkLocalization.getText("Details_Placeholder",{level:TcHmi.Locale.Level.Engineering,preventHtml:!0}),"HTTP error "+xhrUserControl.status+" "+xhrUserControl.statusText),{severity:TcHmi.DialogManager.DialogSeverity.Error,buttonReload:!TCHMI_DESIGNER}),__initStep=INIT_STATE.ERROR,InitStateMachine()):(PendingCounter.ConfigUserControlsLoaded--,initStageInfo.get(initStage).done++,PendingCounter.ConfigUserControlsLoaded<=0?(controlManager.resolveUcAttributes(),themeManager.retriggerUserControls(),__initStep=INIT_STATE.PACKAGE_CONTENT_LOAD,loadNextStage(INIT_STAGE.LoadingContent),updateSplashScreen({callInitStateMachine:!0})):updateSplashScreen()))};xhrUserControl.addEventListener("load",xhrUserControlSuccess),xhrUserControl.addEventListener("error",xhrUserControlError),xhrUserControl.send()}},loadUserControlConfig=function(url){let xhrUserControlDescr=new XMLHttpRequest;xhrUserControlDescr.open("GET",tchmi_encode_uri_components(url)+xhrCacheSuffix);let xhrUserControlDescrError=function(evt){PendingCounter.ConfigUserControlsLoaded--,PendingCounter.ConfigUserControlsLoaded<=0&&(controlManager.resolveUcAttributes(),themeManager.retriggerUserControls(),__initStep=INIT_STATE.PACKAGE_CONTENT_LOAD,loadNextStage(INIT_STAGE.LoadingContent),updateSplashScreen({callInitStateMachine:!0}))};xhrUserControlDescr.addEventListener("load",function(evt){if(200!==xhrUserControlDescr.status)return void xhrUserControlDescrError(evt);const ucConfigRes=ValueConverter.toObjectEx(xhrUserControlDescr.responseText);let ucConfig=ucConfigRes.value;ucConfig?(Data.Caches.partialCompositeConfigCache.set(url,ucConfig),__fetchFromIndexedDb&&"done"===indexedDbRequest?.readyState&&indexedDbRequest.result?.objectStoreNames?.contains("userControlConfig")&&indexedDbRequest.result.transaction("userControlConfig","readwrite").objectStore("userControlConfig").put(ucConfig,url)):Log.errorEx(`[Source=Framework, Module=TcHmi.Init] Failed to load user control config: "${url}". Response is no valid user control JSON. Details: ${Log.buildMessage(ucConfigRes.details)}`),PendingCounter.ConfigUserControlsLoaded--,initStageInfo.get(initStage).done++,PendingCounter.ConfigUserControlsLoaded<=0?(controlManager.resolveUcAttributes(),themeManager.retriggerUserControls(),__initStep=INIT_STATE.PACKAGE_CONTENT_LOAD,loadNextStage(INIT_STAGE.LoadingContent),updateSplashScreen({callInitStateMachine:!0})):updateSplashScreen()}),xhrUserControlDescr.addEventListener("error",xhrUserControlDescrError),xhrUserControlDescr.send()};if(PendingCounter.ConfigUserControlsLoaded=2*configUserControls.length,configUserControls.length>0){const urlsToFetch=[];for(const usercControlPartial of configUserControls){if(__fetchFromIndexedDb&&Data.Caches.partialMarkupCache.has(usercControlPartial.url)?(PendingCounter.ConfigUserControlsLoaded--,initStageInfo.get(initStage).done++):urlsToFetch.push(usercControlPartial.url),!usercControlPartial.url.endsWith(".usercontrol")){Log.errorEx('[Source=Framework, Module=TcHmi.Init] Configuration file: "Properties/tchmiconfig.json" is not valid. userControls includes a wrong formed entry. url must end with ".js". Reference will be skipped. Entry: ',usercControlPartial),PendingCounter.ConfigUserControlsLoaded--,initStageInfo.get(initStage).done++;continue}let configurl=usercControlPartial.url.replace(".usercontrol",".usercontrol.json");__fetchFromIndexedDb&&Data.Caches.partialCompositeConfigCache.has(configurl)?(PendingCounter.ConfigUserControlsLoaded--,initStageInfo.get(initStage).done++):loadUserControlConfig(configurl)}loadUserControlMarkup(urlsToFetch)}PendingCounter.ConfigUserControlsLoaded<=0&&(controlManager.resolveUcAttributes(),themeManager.retriggerUserControls(),__initStep=INIT_STATE.PACKAGE_CONTENT_LOAD,loadNextStage(INIT_STAGE.LoadingContent),updateSplashScreen({callInitStateMachine:!0}))}break;case INIT_STATE.PACKAGE_CONTENT_LOAD:{Log.performanceLog(`[Source=Framework, Module=TcHmi.Init] INIT_STATE.${INIT_STATE[__initStep]}: ${configContents.length} Contents`),__initStep=INIT_STATE.IDLE;const loadContent=function(url){let xhrContent=new XMLHttpRequest;xhrContent.open("GET",url+xhrCacheSuffix);let xhrContentError=function(evt){__initStep!==INIT_STATE.ERROR&&(Log.errorEx("[Source=Framework, Module=TcHmi.Init] Loading "+url+" failed. Errordetail: "+xhrContent.statusText),url===TCHMI_TARGET_PARTIAL?(dialogManager.showDialog("__TcHmiMain",!0,TcHmi.DialogManager.DialogType.Overlay),dialogManager.updateTextEx("__TcHmiMain",tchmi_format_string(frameworkLocalization.getText("Loading_File_Failed",{level:TcHmi.Locale.Level.Engineering,preventHtml:!0}),url)+" "+frameworkLocalization.getText("Propably_Syntax_Error_Html_Or_Wrong_Entry_Config",{level:TcHmi.Locale.Level.Engineering,preventHtml:!0})+" "+tchmi_format_string(frameworkLocalization.getText("Details_Placeholder",{level:TcHmi.Locale.Level.Engineering,preventHtml:!0}),xhrContent.statusText),{severity:TcHmi.DialogManager.DialogSeverity.Error,buttonReload:!TCHMI_DESIGNER}),__initStep=INIT_STATE.ERROR,InitStateMachine()):(PendingCounter.PackageContentsLoaded--,PendingCounter.PackageContentsLoaded<=0&&(__initStep=INIT_STATE.CONTENT_LOAD,loadNextStage(INIT_STAGE.LoadingContent),updateSplashScreen({callInitStateMachine:!0}))))};xhrContent.addEventListener("load",function(evt){200===xhrContent.status?__initStep!==INIT_STATE.ERROR&&(Data.Caches.partialMarkupCache.set(url,{markup:xhrContent.responseText}),!TCHMI_DESIGNER&&__fetchFromIndexedDb&&"done"===indexedDbRequest?.readyState&&indexedDbRequest.result?.objectStoreNames?.contains("contentMarkup")&&indexedDbRequest.result.transaction("contentMarkup","readwrite").objectStore("contentMarkup").put(xhrContent.responseText,url),initStageInfo.get(initStage).done++,PendingCounter.PackageContentsLoaded--,PendingCounter.PackageContentsLoaded<=0?(__initStep=INIT_STATE.CONTENT_LOAD,loadNextStage(INIT_STAGE.LoadingContent),updateSplashScreen({callInitStateMachine:!0})):updateSplashScreen()):xhrContentError(evt)}),xhrContent.addEventListener("error",xhrContentError),xhrContent.send()},loadContentEngineering=function(urls){promiseTimeout(import("./System/Engineering/DesignerModePartialContentManager.js")).catch(ex=>{const resourceUrl="./System/Engineering/DesignerModePartialContentManager.js";return Log.errorEx(`Failed to load ${resourceUrl} in Framework init: ${ex}`),dialogManager.showDialog("__TcHmiMain",!0,TcHmi.DialogManager.DialogType.Overlay),dialogManager.updateTextEx("__TcHmiMain",tchmi_format_string(frameworkLocalization.getText("Loading_File_Failed_With_Error",{level:TcHmi.Locale.Level.Engineering,preventHtml:!0}),resourceUrl,ex),{severity:TcHmi.DialogManager.DialogSeverity.Error,buttonReload:!TCHMI_DESIGNER}),PendingCounter.OpenEngineeringConnection=0,__initStep=INIT_STATE.ERROR,InitStateMachine(),Promise.reject(ex)}).then(module=>{module.partialContentManager.requestCurrentPartialContents(urls.map(value=>({path:value})),data=>{if(data.error===TcHmi.Errors.NONE&&data.targetPartials){if(__initStep===INIT_STATE.ERROR)return;for(const targetPartial of data.targetPartials)targetPartial.content&&Data.Caches.partialMarkupCache.set(targetPartial.path,{markup:targetPartial.content});initStageInfo.get(initStage).done+=Object.keys(data.targetPartials).length,PendingCounter.PackageContentsLoaded-=Object.keys(data.targetPartials).length,PendingCounter.PackageContentsLoaded<=0?(__initStep=INIT_STATE.CONTENT_LOAD,loadNextStage(INIT_STAGE.LoadingContent),updateSplashScreen({callInitStateMachine:!0})):updateSplashScreen()}else{if(__initStep===INIT_STATE.ERROR)return;Log.errorEx("[Source=Framework, Module=TcHmi.Init] Loading content files failed. Errordetail: "+Log.buildMessage(data.details)),data.targetPartials.find(entry=>entry.path===TCHMI_TARGET_PARTIAL)?(dialogManager.showDialog("__TcHmiMain",!0,TcHmi.DialogManager.DialogType.Overlay),dialogManager.updateTextEx("__TcHmiMain",tchmi_format_string(frameworkLocalization.getText("Loading_File_Failed",{level:TcHmi.Locale.Level.Engineering,preventHtml:!0}),TCHMI_TARGET_PARTIAL),{severity:TcHmi.DialogManager.DialogSeverity.Error,buttonReload:!TCHMI_DESIGNER}),__initStep=INIT_STATE.ERROR,InitStateMachine()):(PendingCounter.PackageContentsLoaded--,PendingCounter.PackageContentsLoaded<=0&&(__initStep=INIT_STATE.CONTENT_LOAD,loadNextStage(INIT_STAGE.LoadingContent),updateSplashScreen({callInitStateMachine:!0})))}})})};if(PendingCounter.PackageContentsLoaded=packageContents.length,packageContents&&packageContents.length>0){const urlsToFetchFromEngineering=[];for(const packageContent of packageContents){let url=tchmi_path(packageContent.package.basePath+"/"+packageContent.module.path);if(packageContent.config&&packageContent.config.preload)if(__fetchFromIndexedDb&&Data.Caches.partialMarkupCache.has(url))initStageInfo.get(initStage).done++,PendingCounter.PackageContentsLoaded--;else{TCHMI_ENGINEERING&&(packageContent.package.config.engineering?.projectReference??!1)?urlsToFetchFromEngineering.push(url):loadContent(url)}else initStageInfo.get(initStage).done++,updateSplashScreen(),PendingCounter.PackageContentsLoaded--}urlsToFetchFromEngineering.length&&loadContentEngineering(urlsToFetchFromEngineering)}PendingCounter.PackageContentsLoaded<=0&&(__initStep=INIT_STATE.CONTENT_LOAD,loadNextStage(INIT_STAGE.LoadingContent),updateSplashScreen({callInitStateMachine:!0}))}break;case INIT_STATE.CONTENT_LOAD:{Log.performanceLog(`[Source=Framework, Module=TcHmi.Init] INIT_STATE.${INIT_STATE[__initStep]}: ${configContents.length} Contents`),__initStep=INIT_STATE.IDLE;const loadContent=function(urls){if(TCHMI_ENGINEERING)promiseTimeout(import("./System/Engineering/DesignerModePartialContentManager.js")).catch(ex=>{const resourceUrl="./System/Engineering/DesignerModePartialContentManager.js";return Log.errorEx(`[Source=Framework, Module=TcHmi.Init] Failed to load ${resourceUrl} in Framework init: ${ex}`),dialogManager.showDialog("__TcHmiMain",!0,TcHmi.DialogManager.DialogType.Overlay),dialogManager.updateTextEx("__TcHmiMain",tchmi_format_string(frameworkLocalization.getText("Loading_File_Failed_With_Error",{level:TcHmi.Locale.Level.Engineering,preventHtml:!0}),resourceUrl,ex),{severity:TcHmi.DialogManager.DialogSeverity.Error,buttonReload:!TCHMI_DESIGNER}),PendingCounter.OpenEngineeringConnection=0,__initStep=INIT_STATE.ERROR,InitStateMachine(),Promise.reject(ex)}).then(module=>{module.partialContentManager.requestCurrentPartialContents(urls.map(value=>({path:value})),data=>{if(data.error===TcHmi.Errors.NONE&&data.targetPartials){if(__initStep===INIT_STATE.ERROR)return;for(const targetPartial of data.targetPartials)targetPartial.content&&Data.Caches.partialMarkupCache.set(targetPartial.path,{markup:targetPartial.content});initStageInfo.get(initStage).done+=Object.keys(data.targetPartials).length,PendingCounter.ConfigContentsLoaded-=Object.keys(data.targetPartials).length,PendingCounter.ConfigContentsLoaded<=0?(__initStep=INIT_STATE.PACKAGE_VIEW_LOAD,loadNextStage(INIT_STAGE.LoadingViews),updateSplashScreen({callInitStateMachine:!0})):updateSplashScreen()}else{if(__initStep===INIT_STATE.ERROR)return;Log.errorEx(`[Source=Framework, Module=TcHmi.Init] Loading content files failed. Errordetail: ${Log.buildMessage(data.details)}`),data.targetPartials.find(entry=>entry.path===TCHMI_TARGET_PARTIAL)?(dialogManager.showDialog("__TcHmiMain",!0,TcHmi.DialogManager.DialogType.Overlay),dialogManager.updateTextEx("__TcHmiMain",tchmi_format_string(frameworkLocalization.getText("Loading_File_Failed",{level:TcHmi.Locale.Level.Engineering,preventHtml:!0}),TCHMI_TARGET_PARTIAL),{severity:DialogManager.DialogSeverity.Error,buttonReload:!TCHMI_DESIGNER}),__initStep=INIT_STATE.ERROR,InitStateMachine()):(PendingCounter.ConfigContentsLoaded-=urls.length,PendingCounter.ConfigContentsLoaded<=0&&(__initStep=INIT_STATE.PACKAGE_VIEW_LOAD,loadNextStage(INIT_STAGE.LoadingViews),updateSplashScreen({callInitStateMachine:!0})))}})});else for(const url of urls){let xhrContent=new XMLHttpRequest;xhrContent.open("GET",tchmi_encode_uri_components(url)+xhrCacheSuffix);let xhrContentSuccess=function(evt){200===xhrContent.status?__initStep!==INIT_STATE.ERROR&&(Data.Caches.partialMarkupCache.set(url,{markup:xhrContent.responseText}),__fetchFromIndexedDb&&"done"===indexedDbRequest?.readyState&&indexedDbRequest.result?.objectStoreNames?.contains("contentMarkup")&&indexedDbRequest.result.transaction("contentMarkup","readwrite").objectStore("contentMarkup").put(xhrContent.responseText,url),initStageInfo.get(initStage).done++,PendingCounter.ConfigContentsLoaded--,PendingCounter.ConfigContentsLoaded<=0?(__initStep=INIT_STATE.PACKAGE_VIEW_LOAD,loadNextStage(INIT_STAGE.LoadingViews),updateSplashScreen({callInitStateMachine:!0})):updateSplashScreen()):xhrContentError(evt)},xhrContentError=function(evt){__initStep!==INIT_STATE.ERROR&&(Log.errorEx(`[Source=Framework, Module=TcHmi.Init] Loading ${xhrContent.responseURL||url} failed. HTTP error ${xhrContent.status} ${xhrContent.statusText}`),url===TCHMI_TARGET_PARTIAL?(dialogManager.showDialog("__TcHmiMain",!0,TcHmi.DialogManager.DialogType.Overlay),dialogManager.updateTextEx("__TcHmiMain",tchmi_format_string(frameworkLocalization.getText("Loading_File_Failed",{level:TcHmi.Locale.Level.Engineering,preventHtml:!0}),url)+" "+frameworkLocalization.getText("Propably_Syntax_Error_Html_Or_Wrong_Entry_Config",{level:TcHmi.Locale.Level.Engineering,preventHtml:!0})+" "+tchmi_format_string(frameworkLocalization.getText("Details_Placeholder",{level:TcHmi.Locale.Level.Engineering,preventHtml:!0}),`HTTP error ${xhrContent.status} ${xhrContent.statusText}`),{severity:TcHmi.DialogManager.DialogSeverity.Error,buttonReload:!TCHMI_DESIGNER}),__initStep=INIT_STATE.ERROR,InitStateMachine()):(PendingCounter.ConfigContentsLoaded--,PendingCounter.ConfigContentsLoaded<=0&&(__initStep=INIT_STATE.PACKAGE_VIEW_LOAD,loadNextStage(INIT_STAGE.LoadingViews),updateSplashScreen({callInitStateMachine:!0}))))};xhrContent.addEventListener("load",xhrContentSuccess),xhrContent.addEventListener("error",xhrContentError),xhrContent.send()}};if(PendingCounter.ConfigContentsLoaded=configContents.length,configContents.length>0){const urlsToFetch=[];for(const contentPartial of configContents)!contentPartial.preload||TCHMI_DESIGNER||TCHMI_SINGLECONTROL||TCHMI_LIVEVIEW&&contentPartial.url===TCHMI_TARGET_PARTIAL?(contentPartial.preload&&TCHMI_LIVEVIEW&&contentPartial.url===TCHMI_TARGET_PARTIAL&&(initStageInfo.get(initStage).done++,updateSplashScreen()),PendingCounter.ConfigContentsLoaded--):__fetchFromIndexedDb&&Data.Caches.partialMarkupCache.has(contentPartial.url)?(initStageInfo.get(initStage).done++,PendingCounter.ConfigContentsLoaded--):urlsToFetch.push(contentPartial.url);urlsToFetch.length&&loadContent(urlsToFetch)}PendingCounter.ConfigContentsLoaded<=0&&(__initStep=INIT_STATE.PACKAGE_VIEW_LOAD,loadNextStage(INIT_STAGE.LoadingViews),updateSplashScreen({callInitStateMachine:!0}))}break;case INIT_STATE.PACKAGE_VIEW_LOAD:{Log.performanceLog(`[Source=Framework, Module=TcHmi.Init] INIT_STATE.${INIT_STATE[__initStep]}: ${configViews.length} Views`),__initStep=INIT_STATE.IDLE;const loadView=function(url){let xhrView=new XMLHttpRequest;xhrView.open("GET",url+xhrCacheSuffix);let xhrViewError=function(evt){if(__initStep!==INIT_STATE.ERROR){if(Log.errorEx("[Source=Framework, Module=TcHmi.Init] Loading "+url+" failed. Errordetail: "+xhrView.statusText),url===TCHMI_TARGET_PARTIAL)return dialogManager.showDialog("__TcHmiMain",!0,TcHmi.DialogManager.DialogType.Overlay),dialogManager.updateTextEx("__TcHmiMain",tchmi_format_string(frameworkLocalization.getText("Loading_File_Failed",{level:TcHmi.Locale.Level.Engineering,preventHtml:!0}),url)+" "+frameworkLocalization.getText("Propably_Syntax_Error_Html_Or_Wrong_Entry_Config",{level:TcHmi.Locale.Level.Engineering,preventHtml:!0})+" "+tchmi_format_string(frameworkLocalization.getText("Details_Placeholder",{level:TcHmi.Locale.Level.Engineering,preventHtml:!0}),xhrView.statusText),{severity:TcHmi.DialogManager.DialogSeverity.Error,buttonReload:!TCHMI_DESIGNER}),__initStep=INIT_STATE.ERROR,void InitStateMachine();PendingCounter.PackageViewsLoaded--,PendingCounter.PackageViewsLoaded<=0&&(__initStep=INIT_STATE.VIEW_LOAD,loadNextStage(INIT_STAGE.LoadingViews),updateSplashScreen({callInitStateMachine:!0}))}};xhrView.addEventListener("load",function(evt){200===xhrView.status?__initStep!==INIT_STATE.ERROR&&(Data.Caches.partialMarkupCache.set(url,{markup:xhrView.responseText}),initStageInfo.get(initStage).done++,PendingCounter.PackageViewsLoaded--,PendingCounter.PackageViewsLoaded<=0?(__initStep=INIT_STATE.VIEW_LOAD,loadNextStage(INIT_STAGE.LoadingViews),updateSplashScreen({callInitStateMachine:!0})):updateSplashScreen()):xhrViewError(evt)}),xhrView.addEventListener("error",xhrViewError),xhrView.send()},loadViewEngineering=function(urls){promiseTimeout(import("./System/Engineering/DesignerModePartialContentManager.js")).catch(ex=>{const resourceUrl="./System/Engineering/DesignerModePartialContentManager.js";return Log.errorEx(`Failed to load ${resourceUrl} in Framework init: ${ex}`),dialogManager.showDialog("__TcHmiMain",!0,TcHmi.DialogManager.DialogType.Overlay),dialogManager.updateTextEx("__TcHmiMain",tchmi_format_string(frameworkLocalization.getText("Loading_File_Failed_With_Error",{level:TcHmi.Locale.Level.Engineering,preventHtml:!0}),resourceUrl,ex),{severity:TcHmi.DialogManager.DialogSeverity.Error,buttonReload:!TCHMI_DESIGNER}),PendingCounter.OpenEngineeringConnection=0,__initStep=INIT_STATE.ERROR,InitStateMachine(),Promise.reject(ex)}).then(module=>{module.partialContentManager.requestCurrentPartialContents(urls.map(value=>({path:value})),data=>{if(data.error===TcHmi.Errors.NONE&&data.targetPartials){if(__initStep===INIT_STATE.ERROR)return;for(const targetPartial of data.targetPartials)targetPartial.content&&Data.Caches.partialMarkupCache.set(targetPartial.path,{markup:targetPartial.content});initStageInfo.get(initStage).done+=Object.keys(data.targetPartials).length,PendingCounter.PackageViewsLoaded-=Object.keys(data.targetPartials).length,PendingCounter.PackageViewsLoaded<=0?(__initStep=INIT_STATE.VIEW_LOAD,loadNextStage(INIT_STAGE.LoadingViews),updateSplashScreen({callInitStateMachine:!0})):updateSplashScreen()}else{if(__initStep===INIT_STATE.ERROR)return;Log.errorEx("[Source=Framework, Module=TcHmi.Init] Loading views failed. Errordetail: "+Log.buildMessage(data.details)),data.targetPartials.find(entry=>entry.path===TCHMI_TARGET_PARTIAL)?(dialogManager.showDialog("__TcHmiMain",!0,TcHmi.DialogManager.DialogType.Overlay),dialogManager.updateTextEx("__TcHmiMain",tchmi_format_string(frameworkLocalization.getText("Loading_File_Failed",{level:TcHmi.Locale.Level.Engineering,preventHtml:!0}),TCHMI_TARGET_PARTIAL),{severity:TcHmi.DialogManager.DialogSeverity.Error,buttonReload:!TCHMI_DESIGNER}),__initStep=INIT_STATE.ERROR,InitStateMachine()):(PendingCounter.PackageViewsLoaded--,PendingCounter.PackageViewsLoaded<=0&&(__initStep=INIT_STATE.VIEW_LOAD,loadNextStage(INIT_STAGE.LoadingViews),updateSplashScreen({callInitStateMachine:!0})))}})})};if(PendingCounter.PackageViewsLoaded=packageViews.length,packageViews&&packageViews.length>0){const urlsToFetchFromEngineering=[];for(const packageView of packageViews){let url=tchmi_path(packageView.package.basePath+"/"+packageView.module.path);packageView.config&&packageView.config.preload?TCHMI_ENGINEERING&&(packageView.package.config.engineering?.projectReference??!1)?urlsToFetchFromEngineering.push(url):loadView(url):(initStageInfo.get(initStage).done++,updateSplashScreen(),PendingCounter.PackageViewsLoaded--)}urlsToFetchFromEngineering.length&&loadViewEngineering(urlsToFetchFromEngineering)}PendingCounter.PackageViewsLoaded<=0&&(__initStep=INIT_STATE.VIEW_LOAD,loadNextStage(INIT_STAGE.LoadingViews),updateSplashScreen({callInitStateMachine:!0}))}break;case INIT_STATE.VIEW_LOAD:{Log.performanceLog(`[Source=Framework, Module=TcHmi.Init] INIT_STATE.${INIT_STATE[__initStep]}: ${configViews.length} Views`),__initStep=INIT_STATE.IDLE,PendingCounter.ConfigViewsLoaded=configViews.length;const loadView=function(urls){if(TCHMI_ENGINEERING)promiseTimeout(import("./System/Engineering/DesignerModePartialContentManager.js")).catch(ex=>{const resourceUrl="./System/Engineering/DesignerModePartialContentManager.js";return Log.errorEx(`[Source=Framework, Module=TcHmi.Init] Failed to load ${resourceUrl} in Framework init:`,ex),dialogManager.showDialog("__TcHmiMain",!0,TcHmi.DialogManager.DialogType.Overlay),dialogManager.updateTextEx("__TcHmiMain",tchmi_format_string(frameworkLocalization.getText("Loading_File_Failed_With_Error",{level:TcHmi.Locale.Level.Engineering,preventHtml:!0}),resourceUrl,ex),{severity:TcHmi.DialogManager.DialogSeverity.Error,buttonReload:!TCHMI_DESIGNER}),PendingCounter.OpenEngineeringConnection=0,__initStep=INIT_STATE.ERROR,InitStateMachine(),Promise.reject(ex)}).then(module=>{module.partialContentManager.requestCurrentPartialContents(urls.map(value=>({path:value})),data=>{if(data.error===TcHmi.Errors.NONE&&data.targetPartials){if(__initStep===INIT_STATE.ERROR)return;for(const targetPartial of data.targetPartials)targetPartial.content&&Data.Caches.partialMarkupCache.set(targetPartial.path,{markup:targetPartial.content});initStageInfo.get(initStage).done+=Object.keys(data.targetPartials).length,PendingCounter.ConfigViewsLoaded-=Object.keys(data.targetPartials).length,PendingCounter.ConfigViewsLoaded<=0?(__initStep=INIT_STATE.CONTENT_COMPILE,loadNextStage(INIT_STAGE.CompilingContent),updateSplashScreen({callInitStateMachine:!0})):updateSplashScreen()}else{if(__initStep===INIT_STATE.ERROR)return;Log.errorEx(`[Source=Framework, Module=TcHmi.Init] Loading views failed. Errordetail: ${Log.buildMessage(data.details)}`),data.targetPartials.find(entry=>entry.path===TCHMI_TARGET_PARTIAL)?(dialogManager.showDialog("__TcHmiMain",!0,TcHmi.DialogManager.DialogType.Overlay),dialogManager.updateTextEx("__TcHmiMain",tchmi_format_string(frameworkLocalization.getText("Loading_File_Failed",{level:TcHmi.Locale.Level.Engineering,preventHtml:!0}),TCHMI_TARGET_PARTIAL),{severity:DialogManager.DialogSeverity.Error,buttonReload:!TCHMI_DESIGNER}),__initStep=INIT_STATE.ERROR,InitStateMachine()):(PendingCounter.ConfigViewsLoaded-=urls.length,PendingCounter.ConfigViewsLoaded<=0&&(__initStep=INIT_STATE.CONTENT_COMPILE,loadNextStage(INIT_STAGE.CompilingContent),updateSplashScreen({callInitStateMachine:!0})))}})});else for(const url of urls){let xhrView=new XMLHttpRequest;xhrView.open("GET",tchmi_encode_uri_components(url)+xhrCacheSuffix);let xhrViewSuccess=function(evt){200===xhrView.status?__initStep!==INIT_STATE.ERROR&&(Data.Caches.partialMarkupCache.set(url,{markup:xhrView.responseText}),initStageInfo.get(initStage).done++,PendingCounter.ConfigViewsLoaded--,PendingCounter.ConfigViewsLoaded<=0?(__initStep=INIT_STATE.CONTENT_COMPILE,loadNextStage(INIT_STAGE.CompilingContent),updateSplashScreen({callInitStateMachine:!0})):updateSplashScreen()):xhrViewError(evt)},xhrViewError=function(evt){if(__initStep!==INIT_STATE.ERROR)return Log.errorEx(`[Source=Framework, Module=TcHmi.Init] Loading ${xhrView.responseURL||url} failed. Details: HTTP error ${xhrView.status} ${xhrView.statusText}`),url===TCHMI_TARGET_PARTIAL?(dialogManager.showDialog("__TcHmiMain",!0,TcHmi.DialogManager.DialogType.Overlay),dialogManager.updateTextEx("__TcHmiMain",tchmi_format_string(frameworkLocalization.getText("Loading_File_Failed",{level:TcHmi.Locale.Level.Engineering,preventHtml:!0}),url)+" "+frameworkLocalization.getText("Propably_Syntax_Error_Html_Or_Wrong_Entry_Config",{level:TcHmi.Locale.Level.Engineering,preventHtml:!0})+" "+tchmi_format_string(frameworkLocalization.getText("Details_Placeholder",{level:TcHmi.Locale.Level.Engineering,preventHtml:!0}),`HTTP error ${xhrView.status} ${xhrView.statusText}`),{severity:TcHmi.DialogManager.DialogSeverity.Error,buttonReload:!TCHMI_DESIGNER}),__initStep=INIT_STATE.ERROR,void InitStateMachine()):(PendingCounter.ConfigViewsLoaded--,PendingCounter.ConfigViewsLoaded<=0?(__initStep=INIT_STATE.CONTENT_COMPILE,loadNextStage(INIT_STAGE.CompilingContent),void updateSplashScreen({callInitStateMachine:!0})):void 0)};xhrView.addEventListener("load",xhrViewSuccess),xhrView.addEventListener("error",xhrViewError),xhrView.send()}},urlsToFetch=[];for(const viewPartial of configViews)!viewPartial.preload||TCHMI_DESIGNER||TCHMI_SINGLECONTROL||TCHMI_LIVEVIEW&&viewPartial.url===TCHMI_TARGET_PARTIAL?(TCHMI_LIVEVIEW&&viewPartial.preload&&viewPartial.url===TCHMI_TARGET_PARTIAL&&(initStageInfo.get(initStage).done++,updateSplashScreen()),PendingCounter.ConfigViewsLoaded--):urlsToFetch.push(viewPartial.url);urlsToFetch.length&&loadView(urlsToFetch)}PendingCounter.ConfigViewsLoaded<=0&&(__initStep=INIT_STATE.CONTENT_COMPILE,loadNextStage(INIT_STAGE.CompilingContent),updateSplashScreen({callInitStateMachine:!0}));break;case INIT_STATE.CONTENT_COMPILE:{if(configContents.length&&"complete"!==document.readyState){document.addEventListener("readystatechange",InitStateMachine,{once:!0});break}let waitForTheme=configContents.some(content=>content.preload)||packageContents.some(packageContent=>packageContent.config?.preload);if(themeManager.__asyncJsonLoadCount&&waitForTheme){TcHmi.EventProvider.register("System.onThemeJsonDataChanged",evt=>{evt.destroy(),InitStateMachine()});break}Log.performanceLog(`[Source=Framework, Module=TcHmi.Init] INIT_STATE.${INIT_STATE[__initStep]}: ${configContents.length} Contents`),__initStep=INIT_STATE.IDLE,PendingCounter.ContentCompiled=configContents.length+packageContents.length;for(let configContent of configContents)!configContent.preload||TCHMI_DESIGNER||TCHMI_SINGLECONTROL||TCHMI_LIVEVIEW&&configContent.url===TCHMI_TARGET_PARTIAL?(TCHMI_LIVEVIEW&&configContent.preload&&configContent.url===TCHMI_TARGET_PARTIAL&&(initStageInfo.get(initStage).done++,updateSplashScreen()),PendingCounter.ContentCompiled--):setTimeout(()=>{const cleanPath=configContent.url;let htmlFiltered=Data.Caches.partialMarkupCache.get(cleanPath);if(htmlFiltered){let markup=resolveContentMarkupReplaceExpressions(cleanPath,htmlFiltered.markup),tempDiv=document.createElement("div");tempDiv.innerHTML=markup;let tempContent=tempDiv.firstElementChild;if(tempContent){tempContent.remove(),htmlFiltered.partialId=tempContent.id,tempContent.setAttribute("data-tchmi-partial-url",cleanPath);let contentControl=controlManager.compile(tempContent).control;contentControl?.__setKeepAlive(!0)}}PendingCounter.ContentCompiled--,initStageInfo.get(initStage).done++,updateSplashScreen(),PendingCounter.ContentCompiled<=0&&(__initStep=INIT_STATE.VIEW_COMPILE,loadNextStage(INIT_STAGE.CompilingViews),TCHMI_DESIGNER||document.hidden?InitStateMachine():setTimeout(()=>{updateSplashScreen(),setTimeout(()=>{InitStateMachine()})}))});for(let packageContent of packageContents)packageContent.config&&packageContent.config.preload?setTimeout(()=>{const cleanPath=tchmi_path(packageContent.package.basePath+"/"+packageContent.module.path);let htmlFiltered=Data.Caches.partialMarkupCache.get(cleanPath);if(htmlFiltered){let markup=resolveContentMarkupReplaceExpressions(cleanPath,htmlFiltered.markup),tempDiv=document.createElement("div");tempDiv.innerHTML=markup;let tempContent=tempDiv.firstElementChild;if(tempContent){tempContent.remove(),htmlFiltered.partialId=tempContent.id,tempContent.setAttribute("data-tchmi-partial-url",cleanPath);let contentControl=controlManager.compile(tempContent).control;contentControl?.__setKeepAlive(!0)}}PendingCounter.ContentCompiled--,initStageInfo.get(initStage).done++,updateSplashScreen(),PendingCounter.ContentCompiled<=0&&(__initStep=INIT_STATE.VIEW_COMPILE,loadNextStage(INIT_STAGE.CompilingViews),updateSplashScreen({callInitStateMachine:!0}))}):(initStageInfo.get(initStage).done++,updateSplashScreen(),PendingCounter.ContentCompiled--);if(PendingCounter.ContentCompiled<=0)return __initStep=INIT_STATE.VIEW_COMPILE,loadNextStage(INIT_STAGE.CompilingViews),void updateSplashScreen({callInitStateMachine:!0})}break;case INIT_STATE.VIEW_COMPILE:if((configViews.length||packageViews.length)&&"complete"!==document.readyState){document.addEventListener("readystatechange",InitStateMachine,{once:!0});break}if((configViews.length||packageViews.length)&&themeManager.__asyncJsonLoadCount){TcHmi.EventProvider.register("System.onThemeJsonDataChanged",evt=>{evt.destroy(),InitStateMachine()});break}Log.performanceLog(`[Source=Framework, Module=TcHmi.Init] INIT_STATE.${INIT_STATE[__initStep]}: ${configViews.length} Views`),__initStep=INIT_STATE.IDLE,PendingCounter.ViewCompiled=configViews.length+packageViews.length;for(let configView of configViews)!configView.preload||TCHMI_DESIGNER||TCHMI_SINGLECONTROL||TCHMI_LIVEVIEW&&configView.url===TCHMI_TARGET_PARTIAL?(TCHMI_LIVEVIEW&&configView.preload&&configView.url===TCHMI_TARGET_PARTIAL&&(initStageInfo.get(initStage).done++,updateSplashScreen()),PendingCounter.ViewCompiled--):setTimeout(()=>{const cleanPath=configView.url;let htmlFiltered=Data.Caches.partialMarkupCache.get(cleanPath);if(htmlFiltered){let tempDiv=document.createElement("div");tempDiv.innerHTML=resolveViewMarkupReplaceExpressions(cleanPath,htmlFiltered.markup);let tempView=tempDiv.firstElementChild;if(tempView){tempView.remove(),tempView.setAttribute("data-tchmi-partial-url",cleanPath),htmlFiltered.partialId=tempView.id;let viewControl=controlManager.compile(tempView).control;viewControl?.__setKeepAlive(!0),htmlFiltered=void 0}}if(PendingCounter.ViewCompiled--,initStageInfo.get(initStage).done++,updateSplashScreen(),PendingCounter.ViewCompiled<=0)return __initStep=INIT_STATE.PRELOAD_BINDINGS,loadNextStage(INIT_STAGE.Finalize),void(TCHMI_DESIGNER||document.hidden?InitStateMachine():setTimeout(()=>{updateSplashScreen(),setTimeout(()=>{InitStateMachine()})}))});for(let packageView of packageViews)packageView.config&&packageView.config.preload?setTimeout(()=>{const cleanPath=tchmi_path(packageView.package.basePath+"/"+packageView.module.path);let htmlFiltered=Data.Caches.partialMarkupCache.get(cleanPath);if(htmlFiltered){let markup=resolveViewMarkupReplaceExpressions(cleanPath,htmlFiltered.markup),tempDiv=document.createElement("div");tempDiv.innerHTML=markup;let tempView=tempDiv.firstElementChild;if(tempView){tempView.remove(),tempView.setAttribute("data-tchmi-partial-url",cleanPath),htmlFiltered.partialId=tempView.id;let viewControl=controlManager.compile(tempView).control;viewControl?.__setKeepAlive(!0),htmlFiltered=void 0}}if(PendingCounter.ViewCompiled--,initStageInfo.get(initStage).done++,updateSplashScreen(),PendingCounter.ViewCompiled<=0)return __initStep=INIT_STATE.PRELOAD_BINDINGS,loadNextStage(INIT_STAGE.Finalize),void updateSplashScreen({callInitStateMachine:!0})}):(initStageInfo.get(initStage).done++,updateSplashScreen(),PendingCounter.ViewCompiled--);if(PendingCounter.ViewCompiled<=0)return __initStep=INIT_STATE.PRELOAD_BINDINGS,loadNextStage(INIT_STAGE.PreloadingBindings),void updateSplashScreen({callInitStateMachine:!0});break;case INIT_STATE.PRELOAD_BINDINGS:{Log.performanceLog(`[Source=Framework, Module=TcHmi.Init] INIT_STATE.${INIT_STATE[__initStep]}`);let preloadingBindings=bindingManager.getPreloadingBindings(),preloadingBindingsDone=0;initStageInfo.get(INIT_STAGE.PreloadingBindings).done=preloadingBindingsDone;let preloadingBindingsSizeStart=preloadingBindings.size;initStageInfo.get(INIT_STAGE.PreloadingBindings).toDo=preloadingBindingsSizeStart,updateSplashScreen();const done=()=>{setIsPreloaded(!0),__initStep=INIT_STATE.FINAL,loadNextStage(INIT_STAGE.Finalize),updateSplashScreen({callInitStateMachine:!0})};let destroyPreloadingBindingsWatch=bindingManager.watchPreloadingBindingDone(data=>{if(preloadingBindings.has(data.binding)&&(preloadingBindingsDone++,initStageInfo.get(INIT_STAGE.PreloadingBindings).done=preloadingBindingsDone,updateSplashScreen(),preloadingBindingsDone===preloadingBindingsSizeStart)){if(preloadingBindings=bindingManager.getPreloadingBindings(),0===preloadingBindings.size)return data.destroy?.(),void done();preloadingBindingsDone=0,initStageInfo.get(INIT_STAGE.PreloadingBindings).done=preloadingBindingsDone,preloadingBindingsSizeStart=preloadingBindings.size,initStageInfo.get(INIT_STAGE.PreloadingBindings).toDo=preloadingBindingsSizeStart,updateSplashScreen(),Array.from(preloadingBindings.values()).reverse().forEach(binding=>{const control=binding.getControl();binding.__resume({forcePreload:!0,reason:control?control.getId()+">PreloadBinding":"PreloadBinding"})})}});if(Array.from(preloadingBindings.values()).reverse().forEach(binding=>{const control=binding.getControl();binding.__resume({forcePreload:!0,reason:control?control.getId()+">PreloadBinding":"PreloadBinding"})}),0===preloadingBindings.size)return destroyPreloadingBindingsWatch(),void done()}break;case INIT_STATE.FINAL:{Log.performanceLog(`[Source=Framework, Module=TcHmi.Init] INIT_STATE.${INIT_STATE[__initStep]}`),__initStep=INIT_STATE.IDLE;const destroyGlobalTrigger=triggerManager.register(tchmi_clone_object(config.trigger));let vurl;if(setDestroyGlobalTrigger(destroyGlobalTrigger),TCHMI_DESIGNER)vurl=TCHMI_TARGET_PARTIAL;else{const startupView=config.startupView;if(!startupView)return dialogManager.showDialog("__TcHmiMain",!0,TcHmi.DialogManager.DialogType.Overlay),dialogManager.updateTextEx("__TcHmiMain",frameworkLocalization.getText("Startup_View_Not_Defined_Please_Configure",{level:TcHmi.Locale.Level.Engineering,preventHtml:!0}),{severity:TcHmi.DialogManager.DialogSeverity.Error,buttonReload:!TCHMI_DESIGNER}),__initStep=INIT_STATE.ERROR,void InitStateMachine();const cleanStartupPath=tchmi_path(startupView);let bValid=Data.isConfigView.get(cleanStartupPath)??!1;if(bValid||(bValid=Data.isPackageView.get(cleanStartupPath)??!1),!bValid)return dialogManager.showDialog("__TcHmiMain",!0,TcHmi.DialogManager.DialogType.Overlay),dialogManager.updateTextEx("__TcHmiMain",frameworkLocalization.getText("Unable_To_Find_View_Definition_Matching_Startup_View_Definition",{level:TcHmi.Locale.Level.Engineering,preventHtml:!0}),{severity:TcHmi.DialogManager.DialogSeverity.Error,buttonReload:!TCHMI_DESIGNER}),__initStep=INIT_STATE.ERROR,void InitStateMachine();vurl=cleanStartupPath}if(viewManager.setScaleMode(config.scaleMode),timerSymbolManager.run(),TCHMI_SINGLECONTROL){setIsInitialized(!0),SystemInit.__resolveInitializedPromise(),TcHmi.EventProvider.raise("onInitialized"),automationCommandManager.postMessageToParent({messageType:"System.FrameworkLoaded"});break}viewManager.loadView(vurl,function(data){if(initStageInfo.get(initStage).done++,updateSplashScreen(),data.error!==TcHmi.Errors.NONE)return dialogManager.showDialog("__TcHmiMain",!0,TcHmi.DialogManager.DialogType.Overlay),dialogManager.updateTextEx("__TcHmiMain",tchmi_format_string(frameworkLocalization.getText("Loading_File_Failed",{level:TcHmi.Locale.Level.Engineering,preventHtml:!0}),vurl)+": "+Log.buildMessage(data.details),{severity:TcHmi.DialogManager.DialogSeverity.Error,buttonReload:!TCHMI_DESIGNER}),Log.errorEx(`Failed to load ${vurl}: ${Log.buildMessage(data.details)}`),__initStep=INIT_STATE.ERROR,void InitStateMachine();"done"!==indexedDbRequest?.readyState||indexedDbRequest.error||indexedDbRequest.result.close(),viewManager.checkBrowserFeatures(),setIsInitialized(!0),TcHmi.EventProvider.raise("onInitialized"),automationCommandManager.postMessageToParent({messageType:"System.Initialized"}),-1===TCHMI_CONSOLE_LOG_LEVEL&&performance.mark("Event: onInitialized");const mainViewCtrl=viewManager.getView();mainViewCtrl&&!mainViewCtrl.getIsAttached()&&TcHmi.EventProvider.register("System.onPrevControlsAttached",evt=>{evt.destroy(),perfReport()});const perfReport=()=>{if(-1!==TCHMI_CONSOLE_LOG_LEVEL)return;performance.mark("System.SplashScreen: finished"),Log.performanceLog(null),Log.performanceLogEnd("[Source=Framework, Module=TcHmi.Init] INIT_OVERALL");const detail={};for(const[key,info]of initStageInfo)info.duration&&(detail[INIT_STAGE[key]]??={duration:info.duration},detail[INIT_STAGE[key]].duration=info.duration);performance.measure("[Source=Framework, Module=TcHmi.Init] Initializing",{start:0,detail})};document.hidden?(splashScreen.hide(),loadNextStage(INIT_STAGE.Loaded),mainViewCtrl?.getIsAttached()&&perfReport()):setTimeout(()=>{splashScreen.hide(),loadNextStage(INIT_STAGE.Loaded),mainViewCtrl?.getIsAttached()&&perfReport()})})}break;case INIT_STATE.ERROR:if(splashScreen.hide(),Log.performanceLog(`[Source=Framework, Module=TcHmi.Init] INIT_STATE.${INIT_STATE[__initStep]}`),automationCommandManager.postMessageToParent({messageType:"System.Error",reason:dialogManager.__currentHtmlContent??""}),"loading"===document.readyState){const restartStatemaschine=function(){dialogManager.showDialog("__TcHmiMain",!0,TcHmi.DialogManager.DialogType.Overlay),InitStateMachine()};document.addEventListener("readystatechange",restartStatemaschine,{once:!0});break}Log.performanceLog(null),Log.performanceLogEnd("[Source=Framework, Module=TcHmi.Init] INIT_OVERALL");break;default:__initStep=INIT_STATE.IDLE}};InitStateMachine()}export var INIT_STATE;!function(INIT_STATE){INIT_STATE[INIT_STATE.INVALID=0]="INVALID",INIT_STATE[INIT_STATE.IDLE=1]="IDLE",INIT_STATE[INIT_STATE.CHECK_BROWSER_FEATURES=2]="CHECK_BROWSER_FEATURES",INIT_STATE[INIT_STATE.BASE_CONFIGURATION=3]="BASE_CONFIGURATION",INIT_STATE[INIT_STATE.BASE_DESCRIPTION=4]="BASE_DESCRIPTION",INIT_STATE[INIT_STATE.BASE_PACKAGE_LOAD=5]="BASE_PACKAGE_LOAD",INIT_STATE[INIT_STATE.LOCALIZATION_EARLY=6]="LOCALIZATION_EARLY",INIT_STATE[INIT_STATE.THEME_MANAGER_EARLY=7]="THEME_MANAGER_EARLY",INIT_STATE[INIT_STATE.CACHE_LOADING=8]="CACHE_LOADING",INIT_STATE[INIT_STATE.SYSTEM_PREPARATION=9]="SYSTEM_PREPARATION",INIT_STATE[INIT_STATE.PACKAGE_MANIFEST_LOAD=10]="PACKAGE_MANIFEST_LOAD",INIT_STATE[INIT_STATE.CONFIG_CONTROLS_DESCRIPTION_LOAD=11]="CONFIG_CONTROLS_DESCRIPTION_LOAD",INIT_STATE[INIT_STATE.PACKAGE_CONTROLS_DESCRIPTION_LOAD=12]="PACKAGE_CONTROLS_DESCRIPTION_LOAD",INIT_STATE[INIT_STATE.CONTROLS_DESCRIPTION_RESOLVE=13]="CONTROLS_DESCRIPTION_RESOLVE",INIT_STATE[INIT_STATE.LOCALIZATION_FINAL=14]="LOCALIZATION_FINAL",INIT_STATE[INIT_STATE.THEME_MANAGER_FINAL=15]="THEME_MANAGER_FINAL",INIT_STATE[INIT_STATE.CONTROLS_TEMPLATES_LOAD=16]="CONTROLS_TEMPLATES_LOAD",INIT_STATE[INIT_STATE.PACKAGE_FUNCTION_DESCRIPTION_LOAD=17]="PACKAGE_FUNCTION_DESCRIPTION_LOAD",INIT_STATE[INIT_STATE.CONFIG_FUNCTION_DESCRIPTION_LOAD=18]="CONFIG_FUNCTION_DESCRIPTION_LOAD",INIT_STATE[INIT_STATE.OPEN_ENGINEERING_CONNECTION=19]="OPEN_ENGINEERING_CONNECTION",INIT_STATE[INIT_STATE.REGISTRATION_CHECK=20]="REGISTRATION_CHECK",INIT_STATE[INIT_STATE.OPEN_SERVER_CONNECTION=21]="OPEN_SERVER_CONNECTION",INIT_STATE[INIT_STATE.TYPEDEFINITIONS=22]="TYPEDEFINITIONS",INIT_STATE[INIT_STATE.SERVER_SYMBOL_META_DATA_CACHE=23]="SERVER_SYMBOL_META_DATA_CACHE",INIT_STATE[INIT_STATE.AUDIT_TRAIL_INIT=24]="AUDIT_TRAIL_INIT",INIT_STATE[INIT_STATE.VALIDATION=25]="VALIDATION",INIT_STATE[INIT_STATE.PACKAGE_USERCONTROL_LOAD=26]="PACKAGE_USERCONTROL_LOAD",INIT_STATE[INIT_STATE.USERCONTROL_LOAD=27]="USERCONTROL_LOAD",INIT_STATE[INIT_STATE.PACKAGE_CONTENT_LOAD=28]="PACKAGE_CONTENT_LOAD",INIT_STATE[INIT_STATE.CONTENT_LOAD=29]="CONTENT_LOAD",INIT_STATE[INIT_STATE.PACKAGE_VIEW_LOAD=30]="PACKAGE_VIEW_LOAD",INIT_STATE[INIT_STATE.VIEW_LOAD=31]="VIEW_LOAD",INIT_STATE[INIT_STATE.CONTENT_COMPILE=32]="CONTENT_COMPILE",INIT_STATE[INIT_STATE.VIEW_COMPILE=33]="VIEW_COMPILE",INIT_STATE[INIT_STATE.PRELOAD_BINDINGS=34]="PRELOAD_BINDINGS",INIT_STATE[INIT_STATE.FINAL=1e3]="FINAL",INIT_STATE[INIT_STATE.ERROR=1e4]="ERROR"}(INIT_STATE||(INIT_STATE={})),TCHMI_UNITTEST_MODE||queueMicrotask(()=>{symbolEventHandlerInit(),printGeneralLogInformation(),printForcedLogInformation(),prepare(),run(INIT_STATE.CHECK_BROWSER_FEATURES)});