| Total Complexity | 8 | 
| Complexity/F | 0 | 
| Lines of Code | 49 | 
| Function Count | 0 | 
| Duplicated Lines | 0 | 
| Ratio | 0 % | 
| Changes | 0 | ||
| 1 | const getDeptInput = (): HTMLSelectElement | null =>  | 
            ||
| 2 |   document.querySelector("select#department"); | 
            ||
| 3 | const getGovEmailWrapper = () => document.querySelector("#gov_email_wrapper"); | 
            ||
| 4 | const getGovEmailInput = (): HTMLInputElement | null =>  | 
            ||
| 5 |   document.querySelector("input#gov_email"); | 
            ||
| 6 | |||
| 7 | const hideGovEmail = (): void => { | 
            ||
| 8 | const wrapper = getGovEmailWrapper();  | 
            ||
| 9 |   if (wrapper !== null) { | 
            ||
| 10 |     wrapper.setAttribute("data-c-visibility", "hidden"); | 
            ||
| 11 | }  | 
            ||
| 12 | const input = getGovEmailInput();  | 
            ||
| 13 |   if (input !== null) { | 
            ||
| 14 |     input.removeAttribute("required"); | 
            ||
| 15 | }  | 
            ||
| 16 | };  | 
            ||
| 17 | |||
| 18 | const showGovEmail = (): void => { | 
            ||
| 19 | const wrapper = getGovEmailWrapper();  | 
            ||
| 20 |   if (wrapper !== null) { | 
            ||
| 21 |     wrapper.removeAttribute("data-c-visibility"); | 
            ||
| 22 | }  | 
            ||
| 23 | const input = getGovEmailInput();  | 
            ||
| 24 |   if (input !== null) { | 
            ||
| 25 |     input.setAttribute("required", ""); | 
            ||
| 26 | }  | 
            ||
| 27 | };  | 
            ||
| 28 | |||
| 29 | const handleDeptChange = (event: Event): void => { | 
            ||
| 30 |   if (event.target instanceof HTMLSelectElement) { | 
            ||
| 31 |     const { value } = event.target; | 
            ||
| 32 | const NOT_IN_GOV = "0";  | 
            ||
| 33 | const govEmailInput = getGovEmailInput();  | 
            ||
| 34 |     if (value !== null && value !== "" && value !== NOT_IN_GOV) { | 
            ||
| 35 | showGovEmail();  | 
            ||
| 36 |     } else { | 
            ||
| 37 | hideGovEmail();  | 
            ||
| 38 |       if (govEmailInput !== null) { | 
            ||
| 39 | govEmailInput.value = "";  | 
            ||
| 40 | }  | 
            ||
| 41 | }  | 
            ||
| 42 | }  | 
            ||
| 43 | };  | 
            ||
| 44 | |||
| 45 | const deptInput = getDeptInput();  | 
            ||
| 46 | if (deptInput !== null) { | 
            ||
| 47 |   deptInput.addEventListener("change", handleDeptChange); | 
            ||
| 48 | }  | 
            ||
| 49 |