var RLIS={token:typeof(RLIS_TOKEN)!='undefined'?RLIS_TOKEN:'sJskhasRzcoxvybCNK4OhwxaNdCPknmFgEiHpULZO_zyvsHp5VrhSVhgjWEzNScKCl6bazHiX7MfEQnnwscrCA..',baseRlisApiUrl:'https://qa-gis.oregonmetro.gov/rlisapi2/',baseAgsServicesUrl:'https://qa-gis.oregonmetro.gov/arcgis/rest/services/',debugging:!0,eft:!1,version:"xx",userToken:"",b:!1,n:9e3,_inputData:null,intervalId:null,j:"undefined"!=typeof JSON,_XssAJAX:function(controller,data,method,callback){var that=this,_x,isIE10=10===document.documentMode;_x="undefined"==typeof XDomainRequest||isIE10?new XMLHttpRequest:new XDomainRequest,void 0!==_x.withCredentials&&(this.b=!0);let url="";url="GET"==method?this.baseRlisApiUrl+controller+"/?"+data:this.baseRlisApiUrl+controller+"/",_x.open(method,url),_x.onload=function(){clearTimeout(_o);var g=_x.responseText;callback(this.j?JSON.parse(g):eval("("+g+")"))},this.b&&_x.setRequestHeader&&_x.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8"),_x.send(data);var _o=setTimeout(function(){_x.abort(),callback("Server did not respond",!0)},that.n)},Geocode:function(t,e,s){if(this.debugging&&console.log("%c Begin Geocode","background: #bada55; color: #111"),!t||0==t.trim().length)return this.debugging&&console.log("%c No address received","background: #FF0000; color: #111"),e({error:!0,message:"Please enter a valid address"});this.debugging&&console.log("%c type of fields is "+typeof s,"background: #bada55; color: #111"),s=this._defaultFieldsToStar(s),this.debugging&&console.log("%c fields="+s,"background: #bada55; color: #111");const i=function(t){void 0!==t.data&&null!==t.data?e(t.data,null):e(null,t.error)};this._XssAJAX("Locate","input="+encodeURIComponent(t)+"&fields="+s+"&token="+this.token,"GET",i)},ReverseLocate:function(t,e,s,i){const r=e||!1;i=this._defaultFieldsToStar(i),this._XssAJAX("ReverseLocate","intersection="+r+"&lat="+t.y+"&lng="+t.x+"&fields="+i+"&token="+this.token,"GET",function(t){null!==t.data?s(t.data,null):s(null,t.error)})},ReverseQuery:function(t,e,s,i){i=this._defaultFieldsToStar(i),this._XssAJAX("ReverseQuery","intersection="+e+"&lat="+t.y+"&lng="+t.x+"&fields="+i+"&token="+this.token,"GET",function(t){console.log("%c Completed Reverse Geocode ","background: #222; color: #bada55","more text"),null!==t.data?s(t.data,null):s(null,t.error)})},BatchGeocode:function(t,e,s,i,r,o){this._Batch(t,e,s,"BatchLocate",i,r||1e3,o)},BatchQueryAddress:function(t,e,s,i,r,o){this._Batch(t,e,s,"BatchQueryAddress",i,r||1e3,o)},BatchQueryPoint:function(t,e,s,i,r){this._Batch(t,0,e,"BatchQueryPoint",s,i||1e3,r)},_Batch:function(t,e,s,i,r,o,n){if(!(t.length<1)){n=this._defaultFieldsToStar(n);var l=t,h=this,a=o&&o>499?o:1e3;this.debugging&&console.log("%c Using this token: "+h.token,"background: #bada55; color: #111"),this._XssAJAX(i,"data="+encodeURIComponent(l)+"&token="+h.token+"&fields="+n+"&i_heart_ie="+(new Date).getTime(),"POST",function(t){h.intervalId=setInterval(function(){h._PollBatchProgress(i,t.id,s,r)},a)})}},ToCSV:function(t){if(this.debugging&&console.log("%c Inside ToCSV function ","background: #222; color: #bada55"),!Array.isArray(t)||0===t.length||"object"!=typeof t[0])return"Invalid input";let e="";for(const s of Object.keys(t[0]))e+=s+",";e=e.slice(0,-1),e+="\n";for(const s of t){for(const t of Object.keys(s)){const i=s[t];e+="string"==typeof i?"'"+i+"',":i+","}e=e.slice(0,-1),e+="\n"}return e},_PollBatchProgress:function(t,e,s,i){var r=this;this._XssAJAX(t,"id="+e+"&token="+r.token,"GET",function(t){if(t.progress>=100){if(clearInterval(r.intervalId),null===t.data)return void s(null,t.error);s(t.data,null)}i&&i(t)})},QueryPoint:function(t,e,s){this.debugging&&console.log("%c Begin QueryPoint","background: #bada55; color: #111");const i="Incorrect coordinates or out of bounds. RLISQuery only accepts Oregon State Plane (feet) (wkid:2913), Lat/Long (DD.DDDD) (wkid:4326), or Web Mercator (meters) (wkid:102100)";return t.hasOwnProperty("x")&&t.hasOwnProperty("y")&&t&&0!=t.x.length&&0!=t.y.length?isNaN(parseFloat(t.x))||isNaN(parseFloat(t.y))?(this.debugging&&console.log("%c At least one coordinate is not a number","background: #FF0000; color: #111"),e({error:!0,message:i})):this._areCoordinatesValid(t.x,t.y)?(s=this._defaultFieldsToStar(s),void this._XssAJAX("QueryPoint","lat="+t.y+"&lng="+t.x+"&fields="+s+"&token="+this.token,"GET",function(t){null!==t.data?e(t.data,null):e(null,t.error)})):(this.debugging&&console.log("%c At least one coordinate out of range","background: #FF0000; color: #111"),e({error:!0,message:i})):(this.debugging&&console.log("%c Missing coordinate pair","background: #FF0000; color: #111"),e({error:!0,message:i}))},QueryAddress:function(t,e,s){if(this.debugging&&console.log("%c Begin QueryAddress","background: #bada55; color: #111"),!t||0==t.trim().length)return this.debugging&&console.log("%c No address received","background: #FF0000; color: #111"),e({error:!0,message:"Please enter a valid address"});s=this._defaultFieldsToStar(s),this._XssAJAX("QueryAddress","input="+encodeURIComponent(t)+"&fields="+s+"&token="+this.token,"GET",function(t){null!==t.data?e(t.data,null):e(null,t.error)})},_autoSuggest:function(t,e,s){this._XssAJAX("GetSuggestion","input="+encodeURIComponent(t)+"&numvals="+e+"&token="+this.token,"GET",function(t){null!==t?s(t,null):s(null,t.error)})},_areCoordinatesValid:function(t,e){return-123.6450&&(i=e._bindEsriLocator(o.candidates[0])),i}catch(t){return e.debugging&&console.log("%c Error in EsriLocateInput: "+t,"background: #FF0000; color: #ffffff"),null}},_safeToFixed:function(t,e=6,s=null){const i=parseFloat(t);return isFinite(i)?i.toFixed(e):s},_defaultFieldsToStar:function(t){return null!=t&&""!==t.toString().trim()?t:"*"}};RLIS.Autosuggest.prototype={construct:function(){function t(t,e,s,i){return function(){t.call(e,s||null,i||null)}}return this.field.autosuggest=this,this.funcClick=this.mouseClick,this.funcCheck=this.checkKey,this.funcPress=this.keyPress,this.funcHighlight=this.highlightTable,this.funcClear=t(this.clearEvents,this),this.funcUp=t(this.scroll,this,!0,1),this.funcDown=t(this.scroll,this,!1,1),this.funcFocus=t(this.focusTable,this),this.funcUnfocus=t(this.unfocusTable,this),this.addEvent(this.field,"focus",t(this.setupEvents,this)),this.addEvent(window,"resize",t(this.reposition,this)),this},setupEvents:function(){this.evsetup||(this.evsetup=!0,this.addEvent(document,"keydown",this.funcCheck),this.addEvent(this.field,"blur",this.funcClear),this.addEvent(document,"keypress",this.funcPress))},clearEvents:function(){function t(t,e,s){t.removeEventListener&&!window.opera?t.removeEventListener(e,s,!0):t.detachEvent?t.detachEvent("on"+e,s):t["on"+e]=null}var e=window.event;if(e&&this.cur_h){var s=e.srcElement||e.target,i=this.mouse_x+(document.documentElement.scrollLeft||document.body.scrollLeft||0),r=this.mouse_y+(document.documentElement.scrollTop||document.body.scrollTop||0);if(s.id==this.field_id&&i>this.cur_x&&ithis.cur_y&&r",i[r++]=t.substring(o,e+o),i[r++]="",i[r++]=t.substring(e+o,t.length),i.join("")},build:function(){function t(t){var e=u.insertRow(-1);e.className=t?"up":"down";var s=e.insertCell(0);return c+=s.offsetHeight+1,s}function e(t,e){var i=s.rows[p]=u.insertRow(-1);i.className=e||s.previous==t?"selected":"";var r=i.insertCell(0);return r.innerHTML=s.parse(s.keywords[t],_,y),r.setAttribute("pos",p++),r.autosuggest=s,s.use_mouse&&(s.addEvent(r,"click",s.funcClick),r.onmouseover=s.funcHighlight),[i.offsetWidth,i.offsetHeight]}if(0!==this.total){this.rows=[],this.current=this.no_default?-1:0;var s=this;this.addEvent(document,"mousemove",function(t){t=t||window.event,s.mouse_x=t.x,s.mouse_y=t.y});var i=document.getElementById("suggest_table_"+this.field_id);if(i){this.displayed=!1,i.parentNode.removeChild(i);var r=document.getElementById("suggest_helper_"+this.field_id);r&&document.getElementById("autosuggest").removeChild(r)}var o=document.createElement("div");o.id="suggest_table_"+this.field_id,o.className="autosuggest-body",this.cur_y=this.curPos(this.field,"Top")+this.field.offsetHeight,o.style.top=this.cur_y+"px",this.cur_x=this.curPos(this.field,"Left"),o.style.left=this.cur_x+"px",this.cur_w=this.field.offsetWidth-(this.msie?2:6),o.style.width=this.cur_w+"px",this.cur_h=1,o.style.height="1px",o.style.zIndex="1000";var n=null,l=this.total>this.entry_limit;n&&(document.body.appendChild(n),n.style.top=this.cur_y+"px",n.style.left=this.cur_x+"px",n.style.width=o.offsetWidth+2),document.body.appendChild(o);var h=!0,a=(l?this.entry_limit:this.total,[]),d=0;a[d++]="",o.innerHTML=a.join("");var u=o.firstChild;this.use_mouse&&(u.onmouseout=this.funcUnfocus,u.onmouseover=this.funcFocus);var c=0,f=0;!this.use_scroll&&l&&(t(!0).parentNode.className="up-disabled");var g,_,m=this.keywords.length,v=0,p=0;if(this.text_delimiter.length>0){var w=this.delim_words[this.current_word];g=this.trim(this.addSlashes(w)),_=this.trim(w).length}else{w=this.field.value;g=this.addSlashes(w),_=w.length}for(var y=new RegExp((this.limit_start?"^":"")+g,"i"),b=0;bo.offsetWidth?f:o.offsetWidth)+(this.msie?-2:2),o.style.width=this.cur_w+"px",n&&(n.style.height=this.cur_h+"px",n.style.width=this.cur_w+"px"),this.range_up=0,this.range_down=p-1,this.displayed=!0,this.use_scroll&&setTimeout(function(){v=0;for(var t=x;tthis.entry_limit){var o=this.range_up>0;t(this,!0,o,this.funcUp)}if(this.text_delimiter.length>0){var n=this.delim_words[this.current_word];e=this.trim(this.addSlashes(n)),s=this.trim(n).length}else{n=this.field.value;e=this.addSlashes(n),s=n.length}for(var l=new RegExp((this.limit_start?"^":"")+e,"i"),h=this.keywords.length,a=0,d=0;d=this.range_up&&a<=this.range_down){var u=this.rows[a]=i.rows[r++];u.className="";var c=u.firstChild;c.innerHTML=this.parse(this.keywords[d],s,l),c.setAttribute("pos",a)}if(++a>this.range_down)break}if(h>this.entry_limit){o=a0&&(this.timer=setTimeout(function(){this.mouse_on_list=t,this.hide()},this.time_out))},stopTimer:function(){this.timer&&(clearTimeout(this.timer),this.timer=0)},getRow:function(t){return void 0===t&&(t=this.current),this.rows[t]||null},fixArrows:function(t){if(!(this.total<=this.entry_limit)){var e=t.firstChild,s=0===this.current,i=this.current==this.total-1,r=e.rows[0];r.className=s?"up-disabled":"up",r=e.rows[this.entry_limit+1],r.className=i?"down-disabled":"down"}},scroll:function(t,e){if(this.displayed&&(this.field.focus(),this.current!=(t?0:this.total-1))){if(!t&&this.current<0)this.current=-1;else{var s=this.getRow();s&&s.style&&(s.className="")}this.current+=e*(t?-1:1),t?this.current<0&&(this.current=0):(this.current>=this.total&&(this.current=this.total-1),this.use_scroll&&this.current>=this.rows.length&&(this.current=this.rows.length-1));s=this.getRow();var i=document.getElementById("suggest_table_"+this.field_id);if(this.use_scroll){if(t)s.offsetTopi.scrollTop+i.offsetHeight){var r=this.current-this.entry_limit+1;r>0&&(i.scrollTop=this.getRow(r).offsetTop)}}else t?this.currentthis.range_down?(this.range_down+=e,this.range_down>this.total-1&&(this.range_down=this.total-1),this.range_up=this.range_down-this.entry_limit+1,this.remake()):this.fixArrows(i),s=this.getRow();s&&s.style&&(s.className="selected"),this.stopTimer(),this.startTimer(1),this.field.focus()}},mouseClick:function(t){t=t||window.event;var e=t.srcElement||t.target;e.id||(e=e.parentNode);var s=e.autosuggest;if(!s){var i=e.tagName.toLowerCase();e="tr"==i?e.firstChild:e.parentNode,s=e.autosuggest}s&&s.displayed&&(s.mouse_on_list=0,s.current=parseInt(e.getAttribute("pos"),10),s.choose())},focusTable:function(){this.mouse_on_list=1},unfocusTable:function(){this.mouse_on_list=0,this.stopTimer(),this.startTimer(0)},highlightTable:function(t){t=t||window.event;var e=t.srcElement||t.target,s=e.autosuggest;if(s){s.mouse_on_list=1;var i=s.getRow();i&&i.style&&(i.className=""),s.current=parseInt(e.getAttribute("pos"),10),i=s.getRow(),i&&i.style&&(i.className="selected"),s.stopTimer(),s.startTimer(0)}},choose:function(){if(this.displayed&&!(this.current<0)){this.displayed=!1;for(var t=this.keywords.length,e=0,s=0;e0){for(var s="",i=this.delim_words[this.current_word],r=i.length,o=0,n=0;n=0&&" "==i.charAt(d);--d)h+=" ";s+=l,s+=t,o=s.length,a&&(s+=h)}else s+=this.delim_words[n];n!=this.delim_words.length-1&&(s+=this.delim_char[n])}this.field.value=s,e(this.field,o)}else this.field.value=t;this.mouse_on_list=0,this.hide()},hide:function(){if(0===this.mouse_on_list){this.displayed=!1;var t=document.getElementById("suggest_table_"+this.field_id);if(t){var e=document.getElementById("suggest_helper_"+this.field_id);e&&e.parentNode.removeChild(e),document.body.removeChild(t)}this.stopTimer(),this.cur_x=0,this.cur_y=0,this.cur_w=0,this.cur_h=0,this.rows=[]}},keyPress:function(t){t=t||window.event;var e=window.event?t.keyCode:t.charCode,s=t.srcElement||t.target;if(s=s.autosuggest,s.restrict_typing&&!s.suggest_url.length&&e>=32){var i=s.getCaretEnd(s.field),r=s.field.value.substr(0,i).toLowerCase(),o=!1;if(s.text_delimiter.length>0){for(var n="",l=0;l=0)return s.caret_moved=1,s.stopEvent(t),s.choose(),!1;if(s.field.value.length>0){if(s.displayed&&s.hide(),s.enableTLSearch){var r=new RegExp("\\d\\d(W|E)|\\d(N|S)\\d.+");if(s.field.value.toUpperCase().match(r))return s.TLSearch(s.field.value.toUpperCase()),!1}return"locate"==s.mode?RLIS.Geocode(s.field.value,s.callback,s.fields):RLIS.QueryAddress(s.field.value,s.callback,s.fields),!1}break;case 9:if(s.displayed&&s.current>=0||s.timer)return s.caret_moved=1,s.choose(),setTimeout(function(){s.field.focus()},25),!1;break;case 16:break;default:s.caret_moved=0,s.timer=setTimeout(function(){s.preSuggest(e)},s.response_time<10?10:s.response_time)}return i.length&&setTimeout(function(){s.field.value=i},25),!0},preSuggest:function(t){if(this.timer&&(this.stopTimer(),(!this.displayed||this.lastterm!=this.field.value)&&(this.lastterm=this.field.value,38!=t&&40!=t&&13!=t))){var e,s,i=0;if(this.displayed&&this.current>=0){for(var r=0;r0){var o=this.getCaretEnd(this.field),n="";for(r=0;r=d&&o<=d+this.delim_words[r].length&&(this.current_word=r),d+=this.delim_words[r].length+1;e=this.trim(this.delim_words[this.current_word]),s=this.trim(this.addSlashes(this.delim_words[this.current_word]))}else e=this.field.value,s=this.addSlashes(e);if(0===e.length&&-1!=t)this.mouse_on_list=0,this.hide();else if(1==e.length||this.full_refresh||e.length>1&&!this.keywords.length||e.length>1&&this.keywords[0].charAt(0).toLowerCase()!=e.charAt(0).toLowerCase()){var u=e.length>1&&!this.full_refresh?e.charAt(0):e;if(e.lengtht.value.length?-1:i}return-1},curPos:function(t,e){for(var s=0;t;)s+=t["offset"+e],t=t.offsetParent;return s},addSlashes:function(t){return t.replace(/(['\\\.\|\[\]\^\*\+\?\$\(\)])/g,"\\$1")},trim:function(t){return t.replace(/^\s*(\S*(\s+\S+)*)\s*$/,"$1")}};