Inclusion Criteria:
1. Has a primary diagnosis of IH or narcolepsy Type 1 or Type 2 (NT1 or NT2)
2. Participants with a primary diagnosis of NT1 must have a history of at least 14 cataplexy attacks in a typical 2-week period, based on participant history at the time of diagnosis and prior to initiating treatment.
3. Participants with a primary diagnosis of IH must have an average total nightly sleep time of at least 7 hours, based on participant history at the time of diagnosis and prior to initiating treatment.
4. If not currently treated with oxybate, has clinically significant symptoms of excessive daytime sleepiness (EDS) with an Epworth Sleepiness Scale (ESS) score \> 11 at screening and baseline.
5. If currently treated with oxybate, must have documented improvement of EDS with oxybate treatment per the investigator's clinical judgement.
6. If currently treated with oxybate, has been taking the same stable dosing regimen at a total nightly dosage of 3 g to 9 g (inclusive) for at least 2 months at screening.
7. If previously treated with (and not currently taking) oxybate, must have been off oxybate treatment for at least 2 weeks prior to screening. Must not have previously discontinued oxybate due to reasons related to intolerability, safety, or lack of efficacy.
8. If currently treated with alerting agents, has been taking the same dosage for at least 1 month prior to screening and has no current plans to adjust the dosage during the study period.
9. If currently prescribed non-oxybate anticataplectic medications for cataplexy (NT1 only), must agree to taper off these medications (under the guidance and instruction of the investigator) during the OL-TOP and remain off these medications through the end of the DBRWP.
10. If currently treated with nicotine replacement therapy, has been taking the same dosage for at least 1 month prior to screening and has no current plans to adjust the dosage during the study period.
11. Adequate contraceptive precautions
Exclusion criteria:
1. Shows evidence of a previous untreated or inadequately treated sleep disorder considered by the investigator to negatively impact the conduct of the study, including sleep-disordered breathing, parasomnias, circadian rhythm sleep disorders, or restless legs syndrome determined by a previous sleep-laboratory diagnosis or interview utilizing modules of the Diagnostic Interview for Sleep Patterns and Disorders.
2. Has succinic semi-aldehyde dehydrogenase deficiency by medical history.
3. Has uncontrolled hypothyroidism as determined by central clinical laboratory test results.
4. Has a current seizure disorder.
5. Has a history of head trauma associated with loss of consciousness in the past 5 years
6. Has a history or presence of bipolar disorder, bipolar-related disorders, schizophrenia, schizophrenia spectrum disorders, or other psychotic disorders
7. Has a history or presence of any unstable or clinically significant medical condition, behavioral or psychiatric disorder, or history or presence of another neurologic disorder or surgical history that might affect the participant's safety and/or interfere with the conduct of the study, in the opinion of the investigator.
8. Has any other significant disease or disorder that, in the opinion of the investigator, may either put the participant, other participants, or study staff at risk because of participation in the study, may influence the result of the study, or may affect the participant's safety or ability to take part in the study.
9. Any past or current medical conditions or experience that, in the investigator's clinical judgment, would preclude treatment with a once-nightly dose \> 6 g up to 7.5 g dose or twice-nightly regimen with a total nightly dosage \> 9 g up to 12 g (divided into 2 doses).
10. Has any severe drug allergy or a history of allergic or severe adverse reactions or intolerance to Xyrem, Xywav, Gamma-hydroxybutyrate (GHB), or any components of the dosage forms.
11. Has a history of substance abuse and/or a positive urine drug screen for drugs of abuse or alcohol
12. Has recently taken, is taking, or plans to take any of the following:
1. A substance or medication contraindicated with Xywav use
2. A medication with a known drug-drug interaction with Xywav
3. Medications known to have clinically significant CNS sedating effects
4. Other medications, natural health products, or substances from which the participant experiences clinically significant sedation
13. Has recently taken, is taking, or plans to take an Orexin 2 receptor (OX2R) agonist during the study.
14. Has tobacco-use disorder or uses vaping products that impact sleep
15. Has excessive caffeine consumption that may impact sleep
16. Has clinically significant abnormal laboratory values
17. Has an occupation that requires nighttime or variable shift work
18. Has plans for travel across more than 3 time zones during the study