export const inverse=function(e){const t=new Multimap;for(const[s,r]of e.entries())t.set(r,s);return t};export class Multimap{constructor(){this.map=new Map}set(e,t){let s=this.map.get(e);s||(s=new Set,this.map.set(e,s)),s.add(t)}get(e){return this.map.get(e)||new Set}has(e){return this.map.has(e)}hasValue(e,t){const s=this.map.get(e);return!!s&&s.has(t)}get size(){return this.map.size}delete(e,t){const s=this.get(e);if(!s)return!1;const r=s.delete(t);return s.size||this.map.delete(e),r}deleteAll(e){this.map.delete(e)}keysArray(){return[...this.map.keys()]}valuesArray(){const e=[];for(const t of this.map.values())e.push(...t.values());return e}clear(){this.map.clear()}}