"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var plugin_poll_exports = {};
__export(plugin_poll_exports, {
  PollData: () => PollData,
  PollData_Design: () => PollData_Design,
  PollData_Design_OptionDesign: () => PollData_Design_OptionDesign,
  PollData_Design_PollDesign: () => PollData_Design_PollDesign,
  PollData_Design_PollDesign_Background: () => PollData_Design_PollDesign_Background,
  PollData_Design_PollDesign_Background_Gradient: () => PollData_Design_PollDesign_Background_Gradient,
  PollData_Layout: () => PollData_Layout,
  PollData_Layout_OptionLayout: () => PollData_Layout_OptionLayout,
  PollData_Layout_PollLayout: () => PollData_Layout_PollLayout,
  PollData_Poll: () => PollData_Poll,
  PollData_Poll_Option: () => PollData_Poll_Option,
  PollData_Poll_Settings: () => PollData_Poll_Settings,
  PollData_Poll_Settings_Permissions: () => PollData_Poll_Settings_Permissions,
  pollData_Design_PollDesign_Background_TypeFromJSON: () => pollData_Design_PollDesign_Background_TypeFromJSON,
  pollData_Design_PollDesign_Background_TypeToJSON: () => pollData_Design_PollDesign_Background_TypeToJSON,
  pollData_Layout_PollLayout_DirectionFromJSON: () => pollData_Layout_PollLayout_DirectionFromJSON,
  pollData_Layout_PollLayout_DirectionToJSON: () => pollData_Layout_PollLayout_DirectionToJSON,
  pollData_Layout_PollLayout_TypeFromJSON: () => pollData_Layout_PollLayout_TypeFromJSON,
  pollData_Layout_PollLayout_TypeToJSON: () => pollData_Layout_PollLayout_TypeToJSON,
  pollData_Poll_Settings_Permissions_ViewRoleFromJSON: () => pollData_Poll_Settings_Permissions_ViewRoleFromJSON,
  pollData_Poll_Settings_Permissions_ViewRoleToJSON: () => pollData_Poll_Settings_Permissions_ViewRoleToJSON,
  pollData_Poll_Settings_Permissions_VoteRoleFromJSON: () => pollData_Poll_Settings_Permissions_VoteRoleFromJSON,
  pollData_Poll_Settings_Permissions_VoteRoleToJSON: () => pollData_Poll_Settings_Permissions_VoteRoleToJSON
});
module.exports = __toCommonJS(plugin_poll_exports);
var import_common = require("./common.js");
var import_plugin_poll_enums = require("./plugin_poll.enums.js");
function pollData_Poll_Settings_Permissions_ViewRoleFromJSON(object) {
  switch (object) {
    case 0:
    case "CREATOR":
      return import_plugin_poll_enums.PollData_Poll_Settings_Permissions_ViewRole.CREATOR;
    case 1:
    case "VOTERS":
      return import_plugin_poll_enums.PollData_Poll_Settings_Permissions_ViewRole.VOTERS;
    case 2:
    case "EVERYONE":
      return import_plugin_poll_enums.PollData_Poll_Settings_Permissions_ViewRole.EVERYONE;
    case -1:
    case "UNRECOGNIZED":
    default:
      return import_plugin_poll_enums.PollData_Poll_Settings_Permissions_ViewRole.UNRECOGNIZED;
  }
}
function pollData_Poll_Settings_Permissions_ViewRoleToJSON(object) {
  switch (object) {
    case import_plugin_poll_enums.PollData_Poll_Settings_Permissions_ViewRole.CREATOR:
      return "CREATOR";
    case import_plugin_poll_enums.PollData_Poll_Settings_Permissions_ViewRole.VOTERS:
      return "VOTERS";
    case import_plugin_poll_enums.PollData_Poll_Settings_Permissions_ViewRole.EVERYONE:
      return "EVERYONE";
    default:
      return "UNKNOWN";
  }
}
function pollData_Poll_Settings_Permissions_VoteRoleFromJSON(object) {
  switch (object) {
    case 0:
    case "SITE_MEMBERS":
      return import_plugin_poll_enums.PollData_Poll_Settings_Permissions_VoteRole.SITE_MEMBERS;
    case 1:
    case "ALL":
      return import_plugin_poll_enums.PollData_Poll_Settings_Permissions_VoteRole.ALL;
    case -1:
    case "UNRECOGNIZED":
    default:
      return import_plugin_poll_enums.PollData_Poll_Settings_Permissions_VoteRole.UNRECOGNIZED;
  }
}
function pollData_Poll_Settings_Permissions_VoteRoleToJSON(object) {
  switch (object) {
    case import_plugin_poll_enums.PollData_Poll_Settings_Permissions_VoteRole.SITE_MEMBERS:
      return "SITE_MEMBERS";
    case import_plugin_poll_enums.PollData_Poll_Settings_Permissions_VoteRole.ALL:
      return "ALL";
    default:
      return "UNKNOWN";
  }
}
function pollData_Layout_PollLayout_TypeFromJSON(object) {
  switch (object) {
    case 0:
    case "LIST":
      return import_plugin_poll_enums.PollData_Layout_PollLayout_Type.LIST;
    case 1:
    case "GRID":
      return import_plugin_poll_enums.PollData_Layout_PollLayout_Type.GRID;
    case -1:
    case "UNRECOGNIZED":
    default:
      return import_plugin_poll_enums.PollData_Layout_PollLayout_Type.UNRECOGNIZED;
  }
}
function pollData_Layout_PollLayout_TypeToJSON(object) {
  switch (object) {
    case import_plugin_poll_enums.PollData_Layout_PollLayout_Type.LIST:
      return "LIST";
    case import_plugin_poll_enums.PollData_Layout_PollLayout_Type.GRID:
      return "GRID";
    default:
      return "UNKNOWN";
  }
}
function pollData_Layout_PollLayout_DirectionFromJSON(object) {
  switch (object) {
    case 0:
    case "LTR":
      return import_plugin_poll_enums.PollData_Layout_PollLayout_Direction.LTR;
    case 1:
    case "RTL":
      return import_plugin_poll_enums.PollData_Layout_PollLayout_Direction.RTL;
    case -1:
    case "UNRECOGNIZED":
    default:
      return import_plugin_poll_enums.PollData_Layout_PollLayout_Direction.UNRECOGNIZED;
  }
}
function pollData_Layout_PollLayout_DirectionToJSON(object) {
  switch (object) {
    case import_plugin_poll_enums.PollData_Layout_PollLayout_Direction.LTR:
      return "LTR";
    case import_plugin_poll_enums.PollData_Layout_PollLayout_Direction.RTL:
      return "RTL";
    default:
      return "UNKNOWN";
  }
}
function pollData_Design_PollDesign_Background_TypeFromJSON(object) {
  switch (object) {
    case 0:
    case "COLOR":
      return import_plugin_poll_enums.PollData_Design_PollDesign_Background_Type.COLOR;
    case 1:
    case "IMAGE":
      return import_plugin_poll_enums.PollData_Design_PollDesign_Background_Type.IMAGE;
    case 2:
    case "GRADIENT":
      return import_plugin_poll_enums.PollData_Design_PollDesign_Background_Type.GRADIENT;
    case -1:
    case "UNRECOGNIZED":
    default:
      return import_plugin_poll_enums.PollData_Design_PollDesign_Background_Type.UNRECOGNIZED;
  }
}
function pollData_Design_PollDesign_Background_TypeToJSON(object) {
  switch (object) {
    case import_plugin_poll_enums.PollData_Design_PollDesign_Background_Type.COLOR:
      return "COLOR";
    case import_plugin_poll_enums.PollData_Design_PollDesign_Background_Type.IMAGE:
      return "IMAGE";
    case import_plugin_poll_enums.PollData_Design_PollDesign_Background_Type.GRADIENT:
      return "GRADIENT";
    default:
      return "UNKNOWN";
  }
}
const basePollData = {};
const PollData = {
  fromJSON(object) {
    const message = { ...basePollData };
    message.containerData = object.containerData !== void 0 && object.containerData !== null ? import_common.PluginContainerData.fromJSON(object.containerData) : void 0;
    message.poll = object.poll !== void 0 && object.poll !== null ? PollData_Poll.fromJSON(object.poll) : void 0;
    message.layout = object.layout !== void 0 && object.layout !== null ? PollData_Layout.fromJSON(object.layout) : void 0;
    message.design = object.design !== void 0 && object.design !== null ? PollData_Design.fromJSON(object.design) : void 0;
    return message;
  },
  toJSON(message) {
    const obj = {};
    message.containerData !== void 0 && (obj.containerData = message.containerData ? import_common.PluginContainerData.toJSON(message.containerData) : void 0);
    message.poll !== void 0 && (obj.poll = message.poll ? PollData_Poll.toJSON(message.poll) : void 0);
    message.layout !== void 0 && (obj.layout = message.layout ? PollData_Layout.toJSON(message.layout) : void 0);
    message.design !== void 0 && (obj.design = message.design ? PollData_Design.toJSON(message.design) : void 0);
    return obj;
  }
};
const basePollData_Poll = {};
const PollData_Poll = {
  fromJSON(object) {
    const message = { ...basePollData_Poll };
    message.id = object.id !== void 0 && object.id !== null ? String(object.id) : void 0;
    message.title = object.title !== void 0 && object.title !== null ? String(object.title) : void 0;
    message.creatorId = object.creatorId !== void 0 && object.creatorId !== null ? String(object.creatorId) : void 0;
    message.image = object.image !== void 0 && object.image !== null ? import_common.Media.fromJSON(object.image) : void 0;
    message.options = (object.options ?? []).map(
      (e) => PollData_Poll_Option.fromJSON(e)
    );
    message.settings = object.settings !== void 0 && object.settings !== null ? PollData_Poll_Settings.fromJSON(object.settings) : void 0;
    return message;
  },
  toJSON(message) {
    const obj = {};
    message.id !== void 0 && (obj.id = message.id);
    message.title !== void 0 && (obj.title = message.title);
    message.creatorId !== void 0 && (obj.creatorId = message.creatorId);
    message.image !== void 0 && (obj.image = message.image ? import_common.Media.toJSON(message.image) : void 0);
    if (message.options) {
      obj.options = message.options.map(
        (e) => e ? PollData_Poll_Option.toJSON(e) : void 0
      );
    } else {
      obj.options = [];
    }
    message.settings !== void 0 && (obj.settings = message.settings ? PollData_Poll_Settings.toJSON(message.settings) : void 0);
    return obj;
  }
};
const basePollData_Poll_Option = {};
const PollData_Poll_Option = {
  fromJSON(object) {
    const message = { ...basePollData_Poll_Option };
    message.id = object.id !== void 0 && object.id !== null ? String(object.id) : void 0;
    message.title = object.title !== void 0 && object.title !== null ? String(object.title) : void 0;
    message.image = object.image !== void 0 && object.image !== null ? import_common.Media.fromJSON(object.image) : void 0;
    return message;
  },
  toJSON(message) {
    const obj = {};
    message.id !== void 0 && (obj.id = message.id);
    message.title !== void 0 && (obj.title = message.title);
    message.image !== void 0 && (obj.image = message.image ? import_common.Media.toJSON(message.image) : void 0);
    return obj;
  }
};
const basePollData_Poll_Settings = {};
const PollData_Poll_Settings = {
  fromJSON(object) {
    const message = { ...basePollData_Poll_Settings };
    message.permissions = object.permissions !== void 0 && object.permissions !== null ? PollData_Poll_Settings_Permissions.fromJSON(object.permissions) : void 0;
    message.showVoters = object.showVoters !== void 0 && object.showVoters !== null ? Boolean(object.showVoters) : void 0;
    message.showVotesCount = object.showVotesCount !== void 0 && object.showVotesCount !== null ? Boolean(object.showVotesCount) : void 0;
    return message;
  },
  toJSON(message) {
    const obj = {};
    message.permissions !== void 0 && (obj.permissions = message.permissions ? PollData_Poll_Settings_Permissions.toJSON(message.permissions) : void 0);
    message.showVoters !== void 0 && (obj.showVoters = message.showVoters);
    message.showVotesCount !== void 0 && (obj.showVotesCount = message.showVotesCount);
    return obj;
  }
};
const basePollData_Poll_Settings_Permissions = {
  view: import_plugin_poll_enums.PollData_Poll_Settings_Permissions_ViewRole.CREATOR,
  vote: import_plugin_poll_enums.PollData_Poll_Settings_Permissions_VoteRole.SITE_MEMBERS
};
const PollData_Poll_Settings_Permissions = {
  fromJSON(object) {
    const message = {
      ...basePollData_Poll_Settings_Permissions
    };
    message.view = object.view !== void 0 && object.view !== null ? pollData_Poll_Settings_Permissions_ViewRoleFromJSON(object.view) : import_plugin_poll_enums.PollData_Poll_Settings_Permissions_ViewRole.CREATOR;
    message.vote = object.vote !== void 0 && object.vote !== null ? pollData_Poll_Settings_Permissions_VoteRoleFromJSON(object.vote) : import_plugin_poll_enums.PollData_Poll_Settings_Permissions_VoteRole.SITE_MEMBERS;
    message.allowMultipleVotes = object.allowMultipleVotes !== void 0 && object.allowMultipleVotes !== null ? Boolean(object.allowMultipleVotes) : void 0;
    return message;
  },
  toJSON(message) {
    const obj = {};
    message.view !== void 0 && (obj.view = pollData_Poll_Settings_Permissions_ViewRoleToJSON(
      message.view
    ));
    message.vote !== void 0 && (obj.vote = pollData_Poll_Settings_Permissions_VoteRoleToJSON(
      message.vote
    ));
    message.allowMultipleVotes !== void 0 && (obj.allowMultipleVotes = message.allowMultipleVotes);
    return obj;
  }
};
const basePollData_Layout = {};
const PollData_Layout = {
  fromJSON(object) {
    const message = { ...basePollData_Layout };
    message.poll = object.poll !== void 0 && object.poll !== null ? PollData_Layout_PollLayout.fromJSON(object.poll) : void 0;
    message.options = object.options !== void 0 && object.options !== null ? PollData_Layout_OptionLayout.fromJSON(object.options) : void 0;
    return message;
  },
  toJSON(message) {
    const obj = {};
    message.poll !== void 0 && (obj.poll = message.poll ? PollData_Layout_PollLayout.toJSON(message.poll) : void 0);
    message.options !== void 0 && (obj.options = message.options ? PollData_Layout_OptionLayout.toJSON(message.options) : void 0);
    return obj;
  }
};
const basePollData_Layout_PollLayout = {
  type: import_plugin_poll_enums.PollData_Layout_PollLayout_Type.LIST,
  direction: import_plugin_poll_enums.PollData_Layout_PollLayout_Direction.LTR
};
const PollData_Layout_PollLayout = {
  fromJSON(object) {
    const message = {
      ...basePollData_Layout_PollLayout
    };
    message.type = object.type !== void 0 && object.type !== null ? pollData_Layout_PollLayout_TypeFromJSON(object.type) : import_plugin_poll_enums.PollData_Layout_PollLayout_Type.LIST;
    message.direction = object.direction !== void 0 && object.direction !== null ? pollData_Layout_PollLayout_DirectionFromJSON(object.direction) : import_plugin_poll_enums.PollData_Layout_PollLayout_Direction.LTR;
    message.enableImage = object.enableImage !== void 0 && object.enableImage !== null ? Boolean(object.enableImage) : void 0;
    return message;
  },
  toJSON(message) {
    const obj = {};
    message.type !== void 0 && (obj.type = pollData_Layout_PollLayout_TypeToJSON(message.type));
    message.direction !== void 0 && (obj.direction = pollData_Layout_PollLayout_DirectionToJSON(
      message.direction
    ));
    message.enableImage !== void 0 && (obj.enableImage = message.enableImage);
    return obj;
  }
};
const basePollData_Layout_OptionLayout = {};
const PollData_Layout_OptionLayout = {
  fromJSON(object) {
    const message = {
      ...basePollData_Layout_OptionLayout
    };
    message.enableImage = object.enableImage !== void 0 && object.enableImage !== null ? Boolean(object.enableImage) : void 0;
    return message;
  },
  toJSON(message) {
    const obj = {};
    message.enableImage !== void 0 && (obj.enableImage = message.enableImage);
    return obj;
  }
};
const basePollData_Design = {};
const PollData_Design = {
  fromJSON(object) {
    const message = { ...basePollData_Design };
    message.poll = object.poll !== void 0 && object.poll !== null ? PollData_Design_PollDesign.fromJSON(object.poll) : void 0;
    message.options = object.options !== void 0 && object.options !== null ? PollData_Design_OptionDesign.fromJSON(object.options) : void 0;
    return message;
  },
  toJSON(message) {
    const obj = {};
    message.poll !== void 0 && (obj.poll = message.poll ? PollData_Design_PollDesign.toJSON(message.poll) : void 0);
    message.options !== void 0 && (obj.options = message.options ? PollData_Design_OptionDesign.toJSON(message.options) : void 0);
    return obj;
  }
};
const basePollData_Design_PollDesign = {};
const PollData_Design_PollDesign = {
  fromJSON(object) {
    const message = {
      ...basePollData_Design_PollDesign
    };
    message.background = object.background !== void 0 && object.background !== null ? PollData_Design_PollDesign_Background.fromJSON(object.background) : void 0;
    message.borderRadius = object.borderRadius !== void 0 && object.borderRadius !== null ? Number(object.borderRadius) : void 0;
    return message;
  },
  toJSON(message) {
    const obj = {};
    message.background !== void 0 && (obj.background = message.background ? PollData_Design_PollDesign_Background.toJSON(message.background) : void 0);
    message.borderRadius !== void 0 && (obj.borderRadius = message.borderRadius);
    return obj;
  }
};
const basePollData_Design_PollDesign_Background = {
  type: import_plugin_poll_enums.PollData_Design_PollDesign_Background_Type.COLOR
};
const PollData_Design_PollDesign_Background = {
  fromJSON(object) {
    const message = {
      ...basePollData_Design_PollDesign_Background
    };
    message.type = object.type !== void 0 && object.type !== null ? pollData_Design_PollDesign_Background_TypeFromJSON(object.type) : import_plugin_poll_enums.PollData_Design_PollDesign_Background_Type.COLOR;
    message.color = object.color !== void 0 && object.color !== null ? String(object.color) : void 0;
    message.image = object.image !== void 0 && object.image !== null ? import_common.Media.fromJSON(object.image) : void 0;
    message.gradient = object.gradient !== void 0 && object.gradient !== null ? PollData_Design_PollDesign_Background_Gradient.fromJSON(
      object.gradient
    ) : void 0;
    return message;
  },
  toJSON(message) {
    const obj = {};
    message.type !== void 0 && (obj.type = pollData_Design_PollDesign_Background_TypeToJSON(
      message.type
    ));
    message.color !== void 0 && (obj.color = message.color);
    message.image !== void 0 && (obj.image = message.image ? import_common.Media.toJSON(message.image) : void 0);
    message.gradient !== void 0 && (obj.gradient = message.gradient ? PollData_Design_PollDesign_Background_Gradient.toJSON(
      message.gradient
    ) : void 0);
    return obj;
  }
};
const basePollData_Design_PollDesign_Background_Gradient = {};
const PollData_Design_PollDesign_Background_Gradient = {
  fromJSON(object) {
    const message = {
      ...basePollData_Design_PollDesign_Background_Gradient
    };
    message.angle = object.angle !== void 0 && object.angle !== null ? Number(object.angle) : void 0;
    message.startColor = object.startColor !== void 0 && object.startColor !== null ? String(object.startColor) : void 0;
    message.lastColor = object.lastColor !== void 0 && object.lastColor !== null ? String(object.lastColor) : void 0;
    return message;
  },
  toJSON(message) {
    const obj = {};
    message.angle !== void 0 && (obj.angle = message.angle);
    message.startColor !== void 0 && (obj.startColor = message.startColor);
    message.lastColor !== void 0 && (obj.lastColor = message.lastColor);
    return obj;
  }
};
const basePollData_Design_OptionDesign = {};
const PollData_Design_OptionDesign = {
  fromJSON(object) {
    const message = {
      ...basePollData_Design_OptionDesign
    };
    message.borderRadius = object.borderRadius !== void 0 && object.borderRadius !== null ? Number(object.borderRadius) : void 0;
    return message;
  },
  toJSON(message) {
    const obj = {};
    message.borderRadius !== void 0 && (obj.borderRadius = message.borderRadius);
    return obj;
  }
};
//# sourceMappingURL=plugin_poll.js.map
