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,EAAYc,QAAQC,SAC1C,EACIlB,EAAcmB,iBAChBnB,EAAcmB,iBAAiB,SAAUvB,GAAc,GAC9CI,EAAcoB,aACvBpB,EAAcoB,YAAY,WAAYxB,EAtCJ,CAwCrC,CAxDkD,E","sources":["webpack://Scout/./app/javascript/packs/country-state.js"],"sourcesContent":["if (!window.CandidateLink) window.CandidateLink = {};\n(function() {\n var ajax = new XMLHttpRequest();\n ajax.open(\"GET\", window.location.origin + \"/api/system/v1/countries_states.json\");\n ajax.onreadystatechange = function() {\n if (ajax.readyState != 4) return;\n window.CandidateLink.countries = JSON.parse(ajax.responseText);\n try {\n reloadStates();\n preselectState();\n } catch (_exception) {\n }\n };\n ajax.send();\n var selectCountry = document.getElementById(\"application_candidate_attributes_address_attributes_country_id\");\n var selectState = document.getElementById(\"application_candidate_attributes_address_attributes_state_id\");\n if (!selectCountry || !selectState) return;\n var reloadStates = function(e) {\n var val = parseInt(selectCountry.value), country = null;\n for (var i in window.CandidateLink.countries) {\n if (window.CandidateLink.countries[i][\"id\"] == val) {\n country = window.CandidateLink.countries[i];\n break;\n }\n }\n selectState.options.length = 0;\n selectState.add(new Option(\"Please choose...\", \"\"), null);\n if (!country) return;\n var otherIndex;\n for (var i in country[\"states\"]) {\n if (country[\"states\"][i][\"name\"] == \"Other\") {\n otherIndex = i;\n continue;\n }\n var option = new Option(country[\"states\"][i][\"name\"], country[\"states\"][i][\"id\"]);\n try {\n selectState.add(option, null);\n } catch (e2) {\n selectState.add(option);\n }\n }\n try {\n var option = new Option(country[\"states\"][otherIndex][\"name\"], country[\"states\"][otherIndex][\"id\"]);\n selectState.add(option, null);\n } catch (e2) {\n selectState.add(option);\n }\n };\n var preselectState = function() {\n selectState.value = selectState.dataset.initialId;\n };\n if (selectCountry.addEventListener) {\n selectCountry.addEventListener(\"change\", reloadStates, true);\n } else if (selectCountry.attachEvent) {\n selectCountry.attachEvent(\"onchange\", reloadStates);\n }\n})();\n"],"names":["window","CandidateLink","ajax","XMLHttpRequest","open","location","origin","onreadystatechange","readyState","countries","JSON","parse","responseText","reloadStates","preselectState","_exception","send","selectCountry","document","getElementById","selectState","e","val","parseInt","value","country","i","options","length","add","Option","otherIndex","option","e2","dataset","initialId","addEventListener","attachEvent"],"sourceRoot":""}