| Schedule of revenues disaggregated by category | Revenues disaggregated by category were as follows (in thousands): 
|  |  |  |  |  |  |  |  |  |  |  
|  |  | Year Ended December 31,  |  
|  |  | 2023 |      | 2022 |      | 2021 |  
| Product sales: |  |  |  |  |  |  |  |  |  |  
| Gross product sales |  | $ |  147,058 |  | $ |  108,523 |  | $ |  81,186 |  
| Discounts and allowances |  |  |  (42,764) |   |  |  (31,805) |   |  |  (18,176) |  
| Total product sales, net |  |  |  104,294 |  |  |  76,718 |  |  |  63,010 |  
| Revenues from collaborations: |  |  |  |  |  |  |  |  |  |  
| License revenues |  |  |  — |  |  |  7,932 |  |  |  70,553 |  
| Milestone revenue |  |  |  75 |   |  |  25,000 |   |  |  1,875 |  
| Delivery of drug supplies, royalty and others |  |  |  11,413 |   |  |  6,092 |   |  |  3,298 |  
| Total revenues from collaborations |  |  |  11,488 |  |  |  39,024 |  |  |  75,726 |  
| Government contracts |  |  |  1,100 |  |  |  4,500 |  |  |  10,500 |  
| Total revenues |  | $ |  116,882 |  | $ |  120,242 |  | $ |  149,236 |  | 
| Schedule of product revenue allowance and reserve categories |  
|  |  |  |  |  |  |  |  |  |  |  |  |  |  
|  |  | Chargebacks, |  | Government |  |  |  |  |  
|  |  | Discounts and |  | and Other |  |  |  |  |  
|  |  | Fees |  | Rebates |  | Returns |  | Total |  
| Balance as of January 1, 2023 |      | $ |  6,213 |  | $ |  2,636 |  | $ |  3,296 |  | $ |  12,145 |  
| Provision related to current period sales |  |  |  32,330 |  |  |  8,299 |  |  |  869 |  |  |  41,498 |  
| Credit or payments made during the period |  |  |  (30,307) |  |  |  (7,418) |  |  |  (234) |  |  |  (37,959) |  
| Balance as of December 31, 2023 |   | $ |  8,236 |  | $ |  3,517 |  | $ |  3,931 |  | $ |  15,684 |      
|  |  |  |  |  |  |  |  |  |  |  |  |  |  
|  |  | Chargebacks, |  | Government |  |  |  |  |  |  |  
|  |  | Discounts and |  | and Other |  |  |  |  |  |  |  
|  |  | Fees |  | Rebates |  | Returns |  | Total |  
| Balance as of January 1, 2022 |      | $ |  3,404 |  | $ |  2,494 |  | $ |  2,017 |  | $ |  7,915 |  
| Provision related to current period sales |  |  |  23,488 |  |  |  5,901 |  |  |  1,514 |  |  |  30,903 |  
| Credit or payments made during the period |  |  |  (20,679) |  |  |  (5,759) |  |  |  (235) |  |  |  (26,673) |  
| Balance as of December 31, 2022 |   | $ |  6,213 |  | $ |  2,636 |  | $ |  3,296 |  | $ |  12,145 |  |