"use strict";

import { xml } from '@xmpp/client';
import { createTimeoutPromise } from './createTimeoutPromise.xmpp';
export const getRooms = async client => {
  let stanzaHdlrPointer;
  const unsubscribe = () => {
    client.off('stanza', stanzaHdlrPointer);
  };
  const responsePromise = new Promise((resolve, reject) => {
    stanzaHdlrPointer = stanza => {};
    client.on('stanza', stanzaHdlrPointer);
    const message = xml('iq', {
      type: 'get',
      from: client.jid?.toString(),
      id: 'getUserRooms'
    }, xml('query', {
      xmlns: 'ns:getrooms'
    }));
    client.send(message).catch(err => {
      console.error('Error sending getRooms request:', err);
      unsubscribe();
      reject(err);
    });
    resolve();
  });
  const timeoutPromise = createTimeoutPromise(2000, unsubscribe);
  try {
    return await Promise.race([responsePromise, timeoutPromise]);
  } catch (e) {
    console.error('Error in getRooms:', e);
    return null;
  }
};
//# sourceMappingURL=getRooms.xmpp.js.map