define(["exports","./../modules/viewmanager/baseview.js","./../modules/loading/loading.js","./../modules/emby-elements/emby-input/emby-input.js","./../modules/emby-elements/emby-button/emby-button.js","./../modules/emby-elements/emby-checkbox/emby-checkbox.js","./../modules/emby-elements/emby-scroller/emby-scroller.js","./../modules/emby-apiclient/connectionmanager.js","./../modules/approuter.js"],function(_exports,_baseview,_loading,_embyInput,_embyButton,_embyCheckbox,_embyScroller,_connectionmanager,_approuter){function trimEnd(string,charToRemove){for(;string.charAt(string.length-1)===charToRemove;)string=string.substring(0,string.length-1);return string}function onPortChange(e){var value=(this.value||"").trim();"443"!==value&&"8920"!==value||((value=this.closest("form").querySelector(".txtServerHost")).value=value.value.replace(new RegExp("http:","gi"),"https:"))}function View(view,params){_baseview.default.apply(this,arguments),view.querySelector("form").addEventListener("submit",function(e){e.preventDefault();var address=this.querySelector(".txtServerHost").value,e=this.querySelector(".txtServerPort").value,address=function(address,port){if(port){address=trimEnd(address,"/");try{var url=new URL(address);if(url.port)return address;url.port=port;var urlString=url.toString();if("string"==typeof urlString&&urlString&&!urlString.toLowerCase().includes("object url"))return trimEnd(urlString,"/")}catch(err){console.log("error parsing url: "+err)}address+=":"+port}return address}(address,e);return _loading.default.show(),_connectionmanager.default.connectToAddress(address,{}).then(function(result){_loading.default.hide(),result.EnteredAddress=address,_approuter.default.handleConnectionResult(result)}),!1}),view.querySelector(".txtServerPort").addEventListener("change",onPortChange),view.querySelector(".buttonCancel").addEventListener("click",function(e){_approuter.default.back()})}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,require(["material-icons"]),Object.assign(View.prototype,_baseview.default.prototype),View.prototype.onResume=function(options){_baseview.default.prototype.onResume.apply(this,arguments);var view=this.view;view.querySelector(".txtServerHost").value="",view.querySelector(".txtServerPort").value="8096"};_exports.default=View});