[
  {
    "path": ".gitignore",
    "content": "/node_modules\n/dist"
  },
  {
    "path": "CODE_OF_CONDUCT.md",
    "content": "\n# Contributor Covenant Code of Conduct\n\n## Our Pledge\n\nWe as members, contributors, and leaders pledge to make participation in our\ncommunity a harassment-free experience for everyone, regardless of age, body\nsize, visible or invisible disability, ethnicity, sex characteristics, gender\nidentity and expression, level of experience, education, socio-economic status,\nnationality, personal appearance, race, caste, color, religion, or sexual\nidentity and orientation.\n\nWe pledge to act and interact in ways that contribute to an open, welcoming,\ndiverse, inclusive, and healthy community.\n\n## Our Standards\n\nExamples of behavior that contributes to a positive environment for our\ncommunity include:\n\n* Demonstrating empathy and kindness toward other people\n* Being respectful of differing opinions, viewpoints, and experiences\n* Giving and gracefully accepting constructive feedback\n* Accepting responsibility and apologizing to those affected by our mistakes,\n  and learning from the experience\n* Focusing on what is best not just for us as individuals, but for the overall\n  community\n\nExamples of unacceptable behavior include:\n\n* The use of sexualized language or imagery, and sexual attention or advances of\n  any kind\n* Trolling, insulting or derogatory comments, and personal or political attacks\n* Public or private harassment\n* Publishing others' private information, such as a physical or email address,\n  without their explicit permission\n* Other conduct which could reasonably be considered inappropriate in a\n  professional setting\n\n## Enforcement Responsibilities\n\nCommunity leaders are responsible for clarifying and enforcing our standards of\nacceptable behavior and will take appropriate and fair corrective action in\nresponse to any behavior that they deem inappropriate, threatening, offensive,\nor harmful.\n\nCommunity leaders have the right and responsibility to remove, edit, or reject\ncomments, commits, code, wiki edits, issues, and other contributions that are\nnot aligned to this Code of Conduct, and will communicate reasons for moderation\ndecisions when appropriate.\n\n## Scope\n\nThis Code of Conduct applies within all community spaces, and also applies when\nan individual is officially representing the community in public spaces.\nExamples of representing our community include using an official email address,\nposting via an official social media account, or acting as an appointed\nrepresentative at an online or offline event.\n\n## Enforcement\n\nInstances of abusive, harassing, or otherwise unacceptable behavior may be\nreported to the community leaders responsible for enforcement at\nsupport@roundtable.ai.\nAll complaints will be reviewed and investigated promptly and fairly.\n\nAll community leaders are obligated to respect the privacy and security of the\nreporter of any incident.\n\n## Enforcement Guidelines\n\nCommunity leaders will follow these Community Impact Guidelines in determining\nthe consequences for any action they deem in violation of this Code of Conduct:\n\n### 1. Correction\n\n**Community Impact**: Use of inappropriate language or other behavior deemed\nunprofessional or unwelcome in the community.\n\n**Consequence**: A private, written warning from community leaders, providing\nclarity around the nature of the violation and an explanation of why the\nbehavior was inappropriate. A public apology may be requested.\n\n### 2. Warning\n\n**Community Impact**: A violation through a single incident or series of\nactions.\n\n**Consequence**: A warning with consequences for continued behavior. No\ninteraction with the people involved, including unsolicited interaction with\nthose enforcing the Code of Conduct, for a specified period of time. This\nincludes avoiding interactions in community spaces as well as external channels\nlike social media. Violating these terms may lead to a temporary or permanent\nban.\n\n### 3. Temporary Ban\n\n**Community Impact**: A serious violation of community standards, including\nsustained inappropriate behavior.\n\n**Consequence**: A temporary ban from any sort of interaction or public\ncommunication with the community for a specified period of time. No public or\nprivate interaction with the people involved, including unsolicited interaction\nwith those enforcing the Code of Conduct, is allowed during this period.\nViolating these terms may lead to a permanent ban.\n\n### 4. Permanent Ban\n\n**Community Impact**: Demonstrating a pattern of violation of community\nstandards, including sustained inappropriate behavior, harassment of an\nindividual, or aggression toward or disparagement of classes of individuals.\n\n**Consequence**: A permanent ban from any sort of public interaction within the\ncommunity.\n\n## Attribution\n\nThis Code of Conduct is adapted from the [Contributor Covenant][homepage],\nversion 2.1, available at\n[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].\n\nCommunity Impact Guidelines were inspired by\n[Mozilla's code of conduct enforcement ladder][Mozilla CoC].\n\nFor answers to common questions about this code of conduct, see the FAQ at\n[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at\n[https://www.contributor-covenant.org/translations][translations].\n\n[homepage]: https://www.contributor-covenant.org\n[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html\n[Mozilla CoC]: https://github.com/mozilla/diversity\n[FAQ]: https://www.contributor-covenant.org/faq\n[translations]: https://www.contributor-covenant.org/translations\n"
  },
  {
    "path": "CONTRIBUTING.md",
    "content": "# Contributing to RoundtableJS\n\nThank you for considering contributing to **RoundtableJS**. Here are a few guidelines to help you get started.\n\n\n### Code of Conduct\n\nPlease read our [Code of Conduct](https://github.com/roundtableAI/roundtable-js/blob/main/CODE_OF_CONDUCT.md) before participating. We expect all contributors to adhere to it.\n\n### How Can I Contribute?\n\n**Reporting Bugs**\n\n\n- Check the [issues](https://github.com/roundtableAI/roundtable-js/issues) for similar reportings.\n- Draft a bug report for submission.\n- Use a clear and descriptive title for the issue to identify the problem.\n- Describe the steps to reproduce the problem in as much detail as possible. Include any relevant information like operating system, browser version, and any logs or error messages. Provide screenshots or animated GIFs if possible.\n\n**Suggesting Enhancements**\n\n- Check the [issues](https://github.com/roundtableAI/roundtable-js/issues) for similar suggestions.\n- Draft an enhancement submission report.\n- Use a clear and descriptive title for the suggestion.\n- Provide a detailed explanation of the suggested enhancement. Explain why this enhancement would be useful to most **RoundtableJS** users.\n\n**Submitting Pull Requests**\n\n1. Check the [issues](https://github.com/roundtableAI/roundtable-js/issues) for relevant discussions.\n2. Fork the repository and create your branch from `main`.\n3. If you've added code that should be tested, add tests.\n4. Ensure the test suite passes and that your code lints.\n5. Create a pull request using the pull request template (in progress)\n\n\nThank you for your contribution! 📊 ✨\n"
  },
  {
    "path": "LICENSE",
    "content": "                                 Apache License\n                           Version 2.0, January 2004\n                        http://www.apache.org/licenses/\n\n   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n   1. Definitions.\n\n      \"License\" shall mean the terms and conditions for use, reproduction,\n      and distribution as defined by Sections 1 through 9 of this document.\n\n      \"Licensor\" shall mean the copyright owner or entity authorized by\n      the copyright owner that is granting the License.\n\n      \"Legal Entity\" shall mean the union of the acting entity and all\n      other entities that control, are controlled by, or are under common\n      control with that entity. For the purposes of this definition,\n      \"control\" means (i) the power, direct or indirect, to cause the\n      direction or management of such entity, whether by contract or\n      otherwise, or (ii) ownership of fifty percent (50%) or more of the\n      outstanding shares, or (iii) beneficial ownership of such entity.\n\n      \"You\" (or \"Your\") shall mean an individual or Legal Entity\n      exercising permissions granted by this License.\n\n      \"Source\" form shall mean the preferred form for making modifications,\n      including but not limited to software source code, documentation\n      source, and configuration files.\n\n      \"Object\" form shall mean any form resulting from mechanical\n      transformation or translation of a Source form, including but\n      not limited to compiled object code, generated documentation,\n      and conversions to other media types.\n\n      \"Work\" shall mean the work of authorship, whether in Source or\n      Object form, made available under the License, as indicated by a\n      copyright notice that is included in or attached to the work\n      (an example is provided in the Appendix below).\n\n      \"Derivative Works\" shall mean any work, whether in Source or Object\n      form, that is based on (or derived from) the Work and for which the\n      editorial revisions, annotations, elaborations, or other modifications\n      represent, as a whole, an original work of authorship. For the purposes\n      of this License, Derivative Works shall not include works that remain\n      separable from, or merely link (or bind by name) to the interfaces of,\n      the Work and Derivative Works thereof.\n\n      \"Contribution\" shall mean any work of authorship, including\n      the original version of the Work and any modifications or additions\n      to that Work or Derivative Works thereof, that is intentionally\n      submitted to Licensor for inclusion in the Work by the copyright owner\n      or by an individual or Legal Entity authorized to submit on behalf of\n      the copyright owner. For the purposes of this definition, \"submitted\"\n      means any form of electronic, verbal, or written communication sent\n      to the Licensor or its representatives, including but not limited to\n      communication on electronic mailing lists, source code control systems,\n      and issue tracking systems that are managed by, or on behalf of, the\n      Licensor for the purpose of discussing and improving the Work, but\n      excluding communication that is conspicuously marked or otherwise\n      designated in writing by the copyright owner as \"Not a Contribution.\"\n\n      \"Contributor\" shall mean Licensor and any individual or Legal Entity\n      on behalf of whom a Contribution has been received by Licensor and\n      subsequently incorporated within the Work.\n\n   2. Grant of Copyright License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      copyright license to reproduce, prepare Derivative Works of,\n      publicly display, publicly perform, sublicense, and distribute the\n      Work and such Derivative Works in Source or Object form.\n\n   3. Grant of Patent License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      (except as stated in this section) patent license to make, have made,\n      use, offer to sell, sell, import, and otherwise transfer the Work,\n      where such license applies only to those patent claims licensable\n      by such Contributor that are necessarily infringed by their\n      Contribution(s) alone or by combination of their Contribution(s)\n      with the Work to which such Contribution(s) was submitted. If You\n      institute patent litigation against any entity (including a\n      cross-claim or counterclaim in a lawsuit) alleging that the Work\n      or a Contribution incorporated within the Work constitutes direct\n      or contributory patent infringement, then any patent licenses\n      granted to You under this License for that Work shall terminate\n      as of the date such litigation is filed.\n\n   4. Redistribution. You may reproduce and distribute copies of the\n      Work or Derivative Works thereof in any medium, with or without\n      modifications, and in Source or Object form, provided that You\n      meet the following conditions:\n\n      (a) You must give any other recipients of the Work or\n          Derivative Works a copy of this License; and\n\n      (b) You must cause any modified files to carry prominent notices\n          stating that You changed the files; and\n\n      (c) You must retain, in the Source form of any Derivative Works\n          that You distribute, all copyright, patent, trademark, and\n          attribution notices from the Source form of the Work,\n          excluding those notices that do not pertain to any part of\n          the Derivative Works; and\n\n      (d) If the Work includes a \"NOTICE\" text file as part of its\n          distribution, then any Derivative Works that You distribute must\n          include a readable copy of the attribution notices contained\n          within such NOTICE file, excluding those notices that do not\n          pertain to any part of the Derivative Works, in at least one\n          of the following places: within a NOTICE text file distributed\n          as part of the Derivative Works; within the Source form or\n          documentation, if provided along with the Derivative Works; or,\n          within a display generated by the Derivative Works, if and\n          wherever such third-party notices normally appear. The contents\n          of the NOTICE file are for informational purposes only and\n          do not modify the License. You may add Your own attribution\n          notices within Derivative Works that You distribute, alongside\n          or as an addendum to the NOTICE text from the Work, provided\n          that such additional attribution notices cannot be construed\n          as modifying the License.\n\n      You may add Your own copyright statement to Your modifications and\n      may provide additional or different license terms and conditions\n      for use, reproduction, or distribution of Your modifications, or\n      for any such Derivative Works as a whole, provided Your use,\n      reproduction, and distribution of the Work otherwise complies with\n      the conditions stated in this License.\n\n   5. Submission of Contributions. Unless You explicitly state otherwise,\n      any Contribution intentionally submitted for inclusion in the Work\n      by You to the Licensor shall be under the terms and conditions of\n      this License, without any additional terms or conditions.\n      Notwithstanding the above, nothing herein shall supersede or modify\n      the terms of any separate license agreement you may have executed\n      with Licensor regarding such Contributions.\n\n   6. Trademarks. This License does not grant permission to use the trade\n      names, trademarks, service marks, or product names of the Licensor,\n      except as required for reasonable and customary use in describing the\n      origin of the Work and reproducing the content of the NOTICE file.\n\n   7. Disclaimer of Warranty. Unless required by applicable law or\n      agreed to in writing, Licensor provides the Work (and each\n      Contributor provides its Contributions) on an \"AS IS\" BASIS,\n      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n      implied, including, without limitation, any warranties or conditions\n      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n      PARTICULAR PURPOSE. You are solely responsible for determining the\n      appropriateness of using or redistributing the Work and assume any\n      risks associated with Your exercise of permissions under this License.\n\n   8. Limitation of Liability. In no event and under no legal theory,\n      whether in tort (including negligence), contract, or otherwise,\n      unless required by applicable law (such as deliberate and grossly\n      negligent acts) or agreed to in writing, shall any Contributor be\n      liable to You for damages, including any direct, indirect, special,\n      incidental, or consequential damages of any character arising as a\n      result of this License or out of the use or inability to use the\n      Work (including but not limited to damages for loss of goodwill,\n      work stoppage, computer failure or malfunction, or any and all\n      other commercial damages or losses), even if such Contributor\n      has been advised of the possibility of such damages.\n\n   9. Accepting Warranty or Additional Liability. While redistributing\n      the Work or Derivative Works thereof, You may choose to offer,\n      and charge a fee for, acceptance of support, warranty, indemnity,\n      or other liability obligations and/or rights consistent with this\n      License. However, in accepting such obligations, You may act only\n      on Your own behalf and on Your sole responsibility, not on behalf\n      of any other Contributor, and only if You agree to indemnify,\n      defend, and hold each Contributor harmless for any liability\n      incurred by, or claims asserted against, such Contributor by reason\n      of your accepting any such warranty or additional liability.\n\n   END OF TERMS AND CONDITIONS\n\n   APPENDIX: How to apply the Apache License to your work.\n\n      To apply the Apache License to your work, attach the following\n      boilerplate notice, with the fields enclosed by brackets \"[]\"\n      replaced with your own identifying information. (Don't include\n      the brackets!)  The text should be enclosed in the appropriate\n      comment syntax for the file format. We also recommend that a\n      file or class name and description of purpose be included on the\n      same \"printed page\" as the copyright notice for easier\n      identification within third-party archives.\n\n   Copyright 2024 Roundtable Technologies Inc.\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n"
  },
  {
    "path": "README.md",
    "content": "<p align=\"center\">\n<a href=\"https://surveys.roundtable.ai\">\n  <img src=\"assets/images/png-logo-black-rounding.png\" alt=\"Roundtable Logo\" width = '100'>\n</a>\n\n<h3 align=\"center\">RoundtableJS</h3>\n<!-- Why is there a line here? -->\n<p align=\"center\"> Programmatic survey software\n<br />\n  <a href=\"https://surveys.roundtable.ai\">Cloud editor</a> •\n  <a href=\"https://join.slack.com/t/roundtablejs/shared_invite/zt-2m09n74yv-B~UeGbxSzGMTO3f0qXhRxQ\">Slack</a> •\n  <a href=\"https://docs.roundtable.ai/rjs/introduction\">Documentation</a>\n</p>\n</p>\n\n<p align=\"center\">\n  <!-- GitHub Stars -->\n  <a href=\"https://github.com/roundtableAI/roundtable-js/stargazers\"><img src=\"https://img.shields.io/github/stars/roundtableAI/roundtable-js\" alt=\"GitHub Stars\"></a>\n  <!-- NPM Downloads -->\n  <a href=\"https://www.npmjs.com/package/roundtable-js\"><img src=\"https://img.shields.io/npm/dm/roundtable-js\" alt=\"NPM Downloads\"></a>\n  <!-- Hacker News -->\n  <a href=\"https://news.ycombinator.com/item?id=36865625\"><img src=\"https://img.shields.io/badge/Hacker%20News-121-%23FF6600\" alt=\"Hacker News\"></a>\n  <!-- Cloud Editor -->\n<a href=\"https://surveys.roundtable.ai\"><img src=\"https://img.shields.io/badge/Cloud%20Editor-surveys.roundtable.ai-teal\" alt=\"Cloud Editor\"></a>\n</p>\n\n<p align=\"center\">\n  <!-- Twitter Follow -->\n  <a href=\"https://twitter.com/roundtabledotai\"><img src=\"https://img.shields.io/twitter/follow/roundtabledotai?style=social\" alt=\"Twitter Follow\"></a>\n  <!-- Join Slack -->\n  <a href=\"https://join.slack.com/t/roundtablejs/shared_invite/zt-2m09n74yv-B~UeGbxSzGMTO3f0qXhRxQ\"><img src=\"https://img.shields.io/badge/Join%20Slack-4A154B?logo=slack\" alt=\"Join Slack\"></a>\n  <!-- LinkedIn Follow -->\n  <a href=\"https://www.linkedin.com/company/roundtable-ai\"><img src=\"https://img.shields.io/badge/LinkedIn-Follow-0077B5?logo=linkedin\" alt=\"LinkedIn Follow\"></a>\n</p>\n\nRoundtableJS is an open-source JavaScript library for building complex surveys, forms, and data annotation tasks. It's designed to be simple but completely customizable. We make it easy to add complex logic (e.g. branching, skipping, looping), modify question types, and fully customize the design.\n\n## 🌟 Features\n\n- **Designed for the Modern Web:** We're designed in JavaScript and leverage its asynchronous functionality for managing survey logic. For example, rather than determining this logic based on callbacks that trigger when a page is submitted, our library builds the timeline in an async function which means the logic flows intuitively from top to bottom. \n\n- **Developer-Friendly:** We are open-source and API-first. The idea for RoundtableJS arose by seeing how difficult it was to integrate Roundtable's API into other survey software. We want the open-source offering to include a robust plugin ecosystem where people can introduce new question types, integrate with tools like CRMs, and control how data is stored and processed. \n\n- **AI-Native Functionality:** Our [cloud offering](https://surveys.roundtable.ai) has AI-native features such as natural language programming and automated fraud detection. We're continuously expanding our AI features. Let us know what tools you'd like to see!\n\n## 🖼️ Examples\n\nHere are some example surveys built with RoundtableJS. All code is in the [examples/studies](examples/studies) directory.\n\n- [Element showcase](https://roundtable.ai/survey/3e76ab92512f398e366baffd772b06cf972c0c0e)\n- [Enterprise market research survey](https://roundtable.ai/survey/3020c264e57a0415889a7d82330af66daf30db15)\n- [Simple NPS with branding](https://roundtable.ai/survey/bed16082755fc02b70f582c1fe143b8e7d292a43)\n- [Typeform survey](https://roundtable.ai/survey/134a2317bb595d7768194de65772f97dc760b60b)\n- [Product market fit survey](https://roundtable.ai/survey/765c87578ccf7e24522e91c44cf41f845c4bcd0e)\n- [Book a demo form](https://roundtable.ai/survey/374fd1f3f1719d69b21438cbacd7013d28b7daeb)\n- [Data annotation task](https://roundtable.ai/survey/1518e8ae74e9075349b07ffeee8ee21166477e4d)\n- [RLHF data collection](https://roundtable.ai/survey/89eeb07064400b58f2d3a3d979b0cff729f1ee2b)\n\n\n## 🚀 Quick Start\n\n## Installation\n\n### Option 1: npm\n\n1. Install roundtable-js using npm:\n   ```bash\n   npm install roundtable-js\n   ```\n\n### Option 2: Git\n\n1. Clone the repository:\n   ```\n   git clone https://github.com/roundtableAI/roundtable-js.git\n   ```\n\n2. Navigate to the project directory:\n   ```\n   cd roundtable-js\n   ```\n\n3. Include the necessary files in your project.\n\n### Option 3: CDN\n\n1. Include the following script tag in your HTML:\n\n   ```html\n   <script src=\"https://cdn.jsdelivr.net/npm/roundtable-js@0.2.3/dist/bundle.js\"></script>\n   ```\n\n## Usage\n\n1. Import the necessary modules in your JavaScript file for npm or Git installations:\n\n\n   ```javascript\n   import Survey from 'roundtable-js/core/survey.js';\n   import SingleSelect from 'roundtable-js/elements/singleSelect.js';\n   ```\n\n   For CDN installation, ensure the script is loaded and use the global `RoundtableJS` object:\n\n   ```javascript\n   const { Survey, SingleSelect } = RoundtableJS;\n   ```\n\n\n2. Create a survey instance and add pages with questions:\n\n   ```javascript\n   // Define an asynchronous function to run the survey\n   async function runSurvey() {\n      // Create a new Survey instance with a specific participant ID\n      const survey = new Survey({ participantId: 'participant_123' });\n\n      // Define the first question as a single-select question with two options\n      const question1 = new SingleSelect({\n         id: 'question1',\n         text: 'A question',\n         options: ['Option 1', 'Option 2'],\n      });\n\n      // Define the second question as a single-select question with two options\n      const question2 = new SingleSelect({\n         id: 'question2',\n         text: 'A second question',\n         options: ['Option 1', 'Option 2'],\n      });\n\n      // Show the first page with the first question and wait for it to be answered\n      await survey.showPage({ id: 'page1', elements: [question1] });\n\n      // This code runs only after the first page is completed\n      console.log('Page 1 completed');\n\n      // Show the next page with the second question and wait for it to be answered\n      await survey.showPage({ id: 'page2', elements: [question2] });\n\n      // Finish the survey once all pages are completed and display an end message\n      survey.finishSurvey('Thank you for completing the survey!');\n   }\n\n   // Start the survey by calling the runSurvey function\n   runSurvey();   \n   ```\n\n3. Set up your HTML:\n\n   ```html\n   <!DOCTYPE html>\n   <html lang=\"en\">\n\n   <head>\n   <meta charset=\"UTF-8\">\n   <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n   <title>Survey</title>\n   <style>\n      * {\n         box-sizing: border-box;\n      }\n\n      .hidden {\n         display: none;\n      }\n   </style>\n   </head>\n\n   <body>\n   <div id=\"survey-container\" class=\"hidden\">\n      <div id=\"page-container\"></div>\n      <div id=\"navigation\">\n         <button id=\"next-button\">Next</button>\n      </div>\n      <div id = 'finish'></div>\n   </div>\n   <script type=\"module\" src=\"survey_script.js\"></script>\n   </body>\n\n   </html>\n   ```\n\n## 📚 Documentation\n\nRead our [full documentation](https://docs.roundtable.ai/rjs/introduction).\n\n## 🎉 Community\n\nJoin our community:\n- [Slack](https://join.slack.com/t/roundtablejs/shared_invite/zt-2m09n74yv-B~UeGbxSzGMTO3f0qXhRxQ)\n- [Twitter](https://twitter.com/roundtabledotai)\n- [Blog](https://roundtable.ai/blog)\n- [LinkedIn](https://www.linkedin.com/company/roundtable-ai)\n\n## 🛠️ Development / Open-Source Community\n\nPlease see our [Contributing Guide](CONTRIBUTING.md).\n\n## 📜 License\n\nRoundtableJS is open source software [licensed](LICENSE).\n\n---\n"
  },
  {
    "path": "examples/index.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n\n<head>\n  <meta charset=\"UTF-8\">\n  <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n  <title>Survey</title>\n  <style>\n    * {\n      box-sizing: border-box;\n    }\n\n    .hidden {\n      display: none;\n    }\n  </style>\n</head>\n\n<body>\n  <div id=\"survey-container\" class=\"hidden\">\n    <div id=\"page-container\"></div>\n    <div id=\"navigation\">\n      <button id=\"next-button\">Next</button>\n    </div>\n    <div id = 'finish'></div>\n  </div>\n  <script type=\"module\" src=\"studies/element-showcase.js\"></script>\n</body>\n\n</html>"
  },
  {
    "path": "examples/studies/book-a-demo.js",
    "content": "import Survey from '../../library/core/survey.js';\nimport TextInput from '../../library/elements/textInput.js';\nimport HTML from '../../library/elements/HTML.js';\nimport OpenEnd from '../../library/elements/openEnd.js';\nimport PageHTML from '../../library/plugins/pageHTML.js';\n\nasync function runSurvey() {\n    const survey = new Survey({\n        condition: 'test',\n        participant_id: 'p123',\n        styles: {\n            container: {\n                maxWidth: '650px',\n                padding: '30px',\n                paddingTop: '40px',\n                paddingBottom: '50px',\n                position: 'relative',\n            },\n            button: {\n                backgroundColor: 'black',\n                '&:hover': {\n                    backgroundColor: '#333333',\n                }\n            }\n        }\n    });\n\n    const logo = new PageHTML({\n        id: 'logo',\n        content: '<img src=\"https://roundtable.ai/images/logo-with-text.svg\" alt=\"Roundtable Logo\">',\n        position: 'top',\n        styles: {\n            root: {\n                display: 'block',\n                margin: '0 auto',\n                maxWidth: '190px',\n                marginBottom: '20px'\n            }\n        }\n    });\n\n    survey.addPlugin(logo);\n\n    const subtitle = new HTML({\n        id: 'subtitle',\n        content: '<p style=\"text-align: center; color: #666; margin-top: -10px;\">Please fill out this form and a member of our sales team will contact you.</p>'\n    });\n\n    const email = new TextInput({\n        id: 'email',\n        text: 'Email',\n        required: true,\n        placeholder: 'Your email',\n    });\n\n    const name = new TextInput({\n        id: 'name',\n        text: 'Name',\n        required: true,\n        placeholder: 'Your name',\n    });\n\n    const company = new TextInput({\n        id: 'company',\n        text: 'Company',\n        required: true,\n        placeholder: 'Your company name',\n    });\n\n    const role = new TextInput({\n        id: 'role',\n        text: 'Role',\n        required: true,\n        placeholder: 'Your role',\n    });\n\n    const participantVolume = new TextInput({\n        id: 'participantVolume',\n        text: 'What is your average participant volume per month?',\n        required: true,\n        placeholder: 'Average participant volume',\n    });\n\n    const businessType = new TextInput({\n        id: 'businessType',\n        text: 'What % B2B vs B2C?',\n        required: true,\n        placeholder: 'Your answer',\n    });\n  \n    const hearAboutUs = new TextInput({\n        id: 'hearAboutUs',\n        text: 'How did you hear about us?',\n        required: false,\n        placeholder: 'Optional',\n    });\n\n    const additionalComments = new OpenEnd({\n        id: 'additionalComments',\n        text: 'Additional comments',\n        required: false,\n        placeholder: 'Optional',\n    });\n\n  const builtWith = new PageHTML({\n      id: 'builtWith',\n      content: '<div>Built with <a href=\"https://docs.roundtable.ai/rjs/introduction\" target=\"_blank\" style=\"color: black;\">RoundtableJS</a></div>',\n      position: 'bottom',\n      styles: {\n          root: {\n              position: 'absolute',\n              bottom: '49px',\n              right: '25px',\n              fontSize: '14px',\n              padding: '0px',\n              textAlign: 'right',\n          }\n      }\n  });\n\n  survey.addPlugin(builtWith);\n\n  await survey.showPage({\n      id: 'demoForm',\n      elements: [\n          subtitle,\n          email,\n          name,\n          company,\n          role,\n          participantVolume,\n          businessType,\n          hearAboutUs,\n          additionalComments,\n      ]\n  });\n\n  survey.removePlugin(builtWith);\n\n  survey.finishSurvey(`\n      <h2 style=\"text-align: center; color: black; font-weight: 400 !important;\">Thank you for your interest</h2>\n      <p style=\"text-align: center; color: #666666 !important; font-weight: 400 !important; margin-top: -10px;\">A member of our sales team will contact you shortly.</p>\n      <div style=\"text-align: center; margin-top: 30px; margin-bottom: 10px\">\n          <a href=\"https://www.roundtable.ai\" style=\"background-color: black; color: white; padding: 10px 20px; text-decoration: none; border-radius: 5px; font-weight: 400 !important; font-size: 16px;\">Back to our website</a>\n      </div>\n  `);\n}\n\nrunSurvey();"
  },
  {
    "path": "examples/studies/data-annotation.js",
    "content": "import Survey from '../../library/core/survey.js';\nimport BoundingBox from '../../library/elements/boundingBox.js';\nimport ProgressBar from '../../library/plugins/progressBar.js';\n\n// Add images and questions for each page\nconst imageUrls = ['https://www.usnews.com/object/image/00000168-b98c-d246-a9f9-fddd8bb50000/190204-seattletunnel-editorial.jpg?update-time=1549301335348&size=responsive640',\n    'https://www.giviexplorer.com/imagesC/11886/576x576xGIVI-Explorer_friends4adventure_Ecuador-cover.jpg'];\n\nasync function addBoundingBoxPage(survey, imageUrl, index) {\n    const boundingBoxQ = new BoundingBox({\n        id: `bb-q${index}`,\n        text: `Draw a bounding box around the vehicles in the image below`,\n        subText: `If there are no vehicles, skip to the next page`,\n        imageUrl: imageUrl,\n    });\n    const id = `q${index}-bb`;\n    await survey.showPage({ id, elements: [ boundingBoxQ ] });\n}\n\nasync function runSurvey() {\n    const survey = new Survey({\n        participantId: 'test-participant',\n        condition: 'car-labeling',\n    });\n\n    const progressBar = new ProgressBar({\n        maxPages: imageUrls.length,\n        styles: {\n            bar: {\n                backgroundColor: 'black'\n            }\n        }\n    });\n    survey.addPlugin(progressBar);\n\n    // Bounding box pages\n    for (let i = 0; i < imageUrls.length; i++) {\n        await addBoundingBoxPage(survey, imageUrls[i], i);\n    }\n\n    survey.finishSurvey('Thank you for completing the task!');\n}\n\nrunSurvey();"
  },
  {
    "path": "examples/studies/element-showcase.js",
    "content": "import Survey from '../../library/core/survey.js';\nimport BoundingBox from '../../library/elements/boundingBox.js';\nimport CheckBox from '../../library/elements/checkBox.js';\nimport TextInput from '../../library/elements/textInput.js';\nimport DropdownSelect from '../../library/elements/dropdownSelect.js';\nimport Grid from '../../library/elements/grid.js';\nimport HTML from '../../library/elements/HTML.js';\nimport MultiSelect from '../../library/elements/multiSelect.js';\nimport NumberEntry from '../../library/elements/numberEntry.js';\nimport NumberScale from '../../library/elements/numberScale.js';\nimport OpenEnd from '../../library/elements/openEnd.js';\nimport SingleSelect from '../../library/elements/singleSelect.js';\nimport ProgressBar from '../../library/plugins/progressBar.js';\nimport PageHTML from '../../library/plugins/pageHTML.js';\n\nasync function runSurvey() {\n    const survey = new Survey({\n        title: \"Comprehensive Survey Example\",\n        description: \"This survey demonstrates all question types and plugins.\",\n        styles: {\n            body: {\n                background: '#f9f9f7',\n            }\n        }\n    });\n\n    const htmlIntro = new HTML({\n        id: 'intro',\n        content: '<h1>Welcome to our element showcase</h1><p>This survey include examples of every question type and plugin. The code for the survey is available on our <a href=\"https://github.com/roundtableAI/roundtable-js\" target=\"_blank\">GitHub</a>.</p>',\n        styles: {\n            root: {\n                textAlign: 'center',\n            }\n        }\n    });\n\n  \n    const textInput = new TextInput({\n        id: 'name',\n        text: 'Name',\n        required: true,\n        placeholder: 'Your name',\n    })\n\n    const singleSelect = new SingleSelect({\n        id: 'favorite-color',\n        text: 'What is your favorite color?',\n        subText: 'Select one option',\n        options: ['Red', 'Blue', 'Green', 'Yellow'],\n        required: true,\n        allowOther: true,\n    });\n\n    const multiSelect = new MultiSelect({\n        id: 'hobbies',\n        text: 'Which of the following are your hobbies? (Select all that apply)',\n        options: ['Reading', 'Sports', 'Cooking', 'Gaming', 'Traveling'],\n        required: true,\n        minSelect: 1,\n        maxSelect: 3\n    });\n\n    const dropdownSelect = new DropdownSelect({\n        id: 'country',\n        text: 'Select your country of residence',\n        options: ['United States', 'Canada', 'United Kingdom', 'Australia', 'Germany', 'France', 'Japan', 'Other'],\n        required: true\n    });\n\n\n    const checkBox = new CheckBox({\n        id: 'terms',\n        text: 'I agree to the terms and conditions',\n        required: true\n    });\n\n    const numberEntry = new NumberEntry({\n        id: 'age',\n        text: 'Please enter your age',\n        min: 18,\n        max: 100,\n        required: true\n    });\n\n    const numberScale = new NumberScale({\n        id: 'satisfaction',\n        text: 'How satisfied are you with our service?',\n        min: 1,\n        max: 10,\n        minLabel: 'Not at all satisfied',\n        maxLabel: 'Extremely satisfied',\n        required: true\n    });\n\n    const openEnd = new OpenEnd({\n        id: 'feedback',\n        text: 'Please provide any additional feedback you may have',\n        required: false,\n        maxLength: 500\n    });\n\n    const grid = new Grid({\n        id: 'feature-rating',\n        text: 'Please rate the following features of our product',\n        rows: ['Ease of use', 'Performance', 'Design', 'Customer support'],\n        columns: ['Poor', 'Fair', 'Good', 'Excellent'],\n        required: true\n    });\n\n    const boundingBox = new BoundingBox({\n        id: 'image-selection',\n        text: 'Please draw a box around the house',\n        imageUrl: 'https://images.pexels.com/photos/106399/pexels-photo-106399.jpeg',\n        required: true\n    });\n\n    // Group questions into pages\n    const page1 = { id: 'page1', elements: [htmlIntro, textInput, singleSelect, multiSelect, dropdownSelect] };\n    const page2 = { id: 'page2', elements: [checkBox, numberEntry, numberScale, openEnd] };\n    const page3 = { id: 'page3', elements: [grid, boundingBox] };\n\n    const progress = new ProgressBar({ maxPages: 3 });\n\n    const logo = new PageHTML({\n        id: 'logo',\n        content: '<img src=\"https://roundtable.ai/images/logo-with-text.svg\" alt=\"Company Logo\">',\n        position: 'top',\n        styles:{\n            root: {\n                margin: '0 auto',\n                width: '100%',\n                maxWidth: '180px',\n                marginTop: '5px',\n                marginBottom: '10px'\n            }\n        }\n    });\n    survey.addPlugin(logo);\n    survey.addPlugin(progress);\n\n    // Show pages sequentially\n    await survey.showPage(page1);\n    await survey.showPage(page2);\n    await survey.showPage(page3);\n\n    // Finish the survey\n    survey.finishSurvey(`\n        <h2>Thank you for completing our comprehensive survey!</h2>\n        <p>Your responses have been recorded and will help us improve our services.</p>\n    `);\n\n    // Log the survey data (in a real scenario, you'd probably send this to a server)\n    console.log('Survey data:', survey.getAllSurveyData());\n}\n\n// Run the survey\nrunSurvey();"
  },
  {
    "path": "examples/studies/enterprise-market-research.js",
    "content": "import Survey from '../../library/core/survey.js';\nimport Grid from '../../library/elements/grid.js';\nimport HTML from '../../library/elements/HTML.js';\nimport MultiSelect from '../../library/elements/multiSelect.js';\nimport NumberEntry from '../../library/elements/numberEntry.js';\nimport OpenEnd from '../../library/elements/openEnd.js';\nimport SingleSelect from '../../library/elements/singleSelect.js';\nimport ProgressBar from '../../library/plugins/progressBar.js';\n\nasync function runSurvey() {\n    const survey = new Survey({\n        condition: 'test',\n        participant_id: 'p123',\n        styles: {\n            body: {\n                background: '#f0f8ff',\n                '@media (max-width: 650px)': {\n                  background: 'white',\n                },\n            },\n            container: {\n                boxShadow: '0 0 10px rgba(0,0,255,0.1)',\n                '@media (max-width: 650px)': {\n                  boxShadow: 'none',\n                },\n            },\n            button: {\n                backgroundColor: '#4682b4',\n                '&:hover': {\n                    backgroundColor: '#5f9ea0',\n                }\n            },\n            question: {\n                borderBottom: '1px solid #b0d4ff',\n                paddingBottom: '20px',\n                '@media (max-width: 650px)': {\n                  borderBottom: 'none',\n                  paddingBottom: '0px',\n                },\n            }\n        }\n    });\n\n    const progressBar = new ProgressBar({\n        maxPages: 8,\n        progressAsPercentage: true,\n        styles: {\n            bar: {\n                background: '#4682b4',\n            }\n        }\n    });\n    survey.addPlugin(progressBar);\n\n    const welcome = new HTML({\n        id: 'welcome',\n        content: `\n            <h1 style=\"color: #4682b4; text-align: center;\">Welcome to the Annual Travel Habits Survey</h1>\n            <p style=\"text-align: center;\">We appreciate your participation in this study.</p>\n        `\n    });\n\n    await survey.showPage({ id: 'welcome_page', elements: [welcome] });\n\n    const q1 = new SingleSelect({\n        id: 'travel_frequency',\n        text: 'How often do you travel for business?',\n        options: ['Never', 'Once a year', '2-3 times a year', '4-6 times a year', 'Monthly', 'Weekly'],\n        required: true\n    });\n\n    await survey.showPage({ id: 'page1', elements: [q1] });\n\n    if (survey.getResponse('travel_frequency') !== 'Never') {\n        const q2 = new MultiSelect({\n            id: 'travel_destinations',\n            text: 'Which regions do you typically travel to for business? (Select all that apply)',\n            options: ['North America', 'South America', 'Europe', 'Asia', 'Africa', 'Australia'],\n            required: true\n        });\n\n        await survey.showPage({ id: 'page2', elements: [q2] });\n\n        const destinations = survey.getResponse('travel_destinations');\n        for (const destination of destinations) {\n            const q_destination = new OpenEnd({\n                id: `travel_experience_${destination}`,\n                text: `Please describe your typical business travel experience in ${destination}:`,\n                minLength: 10,\n                maxLength: 200,\n                required: true\n            });\n\n            await survey.showPage({ id: `page_${destination}`, elements: [q_destination] });\n        }\n\n        const q3 = new Grid({\n            id: 'travel_satisfaction',\n            text: 'Please rate your satisfaction with the following aspects of your most recent business trip:',\n            rows: ['Flight', 'Hotel', 'Transportation', 'Food', 'Meeting facilities'],\n            columns: ['Very Dissatisfied', 'Dissatisfied', 'Neutral', 'Satisfied', 'Very Satisfied'],\n            required: true\n        });\n\n        await survey.showPage({ id: 'page4', elements: [q3] });\n\n        const q4 = new NumberEntry({\n            id: 'travel_budget',\n            text: 'What is your average budget per business trip (in USD)?',\n            min: 0,\n            max: 1000000,\n            required: true\n        });\n\n        await survey.showPage({ id: 'page5', elements: [q4] });\n\n        const q5 = new OpenEnd({\n            id: 'travel_improvement',\n            text: 'What one thing would most improve your business travel experience?',\n            required: true\n        });\n\n        await survey.showPage({ id: 'page6', elements: [q5] });\n    }\n\n    survey.finishSurvey(`\n        <h1 style=\"color: #4682b4;\">Thank you for completing our business travel survey!</h1>\n        <p>Your insights will help us improve business travel experiences.</p>\n        <p>If you have any questions, please contact us at <a href=\"mailto:research@example.com\" style=\"color: #4682b4;\">research@example.com</a>.</p>\n    `);\n}\n\nrunSurvey();"
  },
  {
    "path": "examples/studies/llm-rlhf.js",
    "content": "import Survey from '../../library/core/survey.js';\nimport OpenEnd from '../../library/elements/openEnd.js';\nimport HTML from '../../library/elements/HTML.js';\nimport MultiSelect from '../../library/elements/multiSelect.js';\nimport SingleSelect from '../../library/elements/singleSelect.js';\nimport NumberScale from '../../library/elements/numberScale.js';\nimport ProgressBar from '../../library/plugins/progressBar.js';\n\nfunction generatePromptResponseHTML(prompt, response) {\n    return `\n        <div style=\"margin-bottom: 20px;\">\n            <h3 style=\"font-size: 16px;\">Prompt:</h3>\n            <div style=\"background-color: #f0f0f0; padding: 14px; border-radius: 5px;\">${prompt}</div>\n        </div>\n        <div>\n            <h3 style=\"font-size: 16px;\">Response:</h3>\n            <div style=\"background-color: #f0f0f0; padding: 14px; border-radius: 5px;\">${response}</div>\n        </div>\n    `;\n}\n\nfunction generatePage(pageNumber, prompt, response) {\n    const promptResponseHTML = new HTML({\n        id: `prompt-response-${pageNumber}`,\n        content: generatePromptResponseHTML(prompt, response)\n    });\n\n    const relevanceQuestion = new SingleSelect({\n        id: `relevance-${pageNumber}`,\n        text: 'Is the response relevant for the prompt?',\n        options: ['Yes', 'No', 'Partially'],\n        required: true\n    });\n\n    const avoidanceQuestion = new MultiSelect({\n        id: `avoidance-${pageNumber}`,\n        text: 'Does the response include anything that should be avoided?',\n        options: ['Racial slurs', 'Explicit content', 'Misinformation', 'Biased language'],\n        required: true\n    });\n\n    const qualityQuestion = new NumberScale({\n        id: `quality-${pageNumber}`,\n        text: 'Rate the overall quality of the response',\n        min: 1,\n        max: 10,\n        minLabel: 'Poor',\n        maxLabel: 'Excellent',\n        required: true\n    });\n\n    const feedbackQuestion = new OpenEnd({\n        id: `feedback-${pageNumber}`,\n        text: 'Any additional comments or feedback on the response?',\n        required: false\n    });\n\n    return { \n        id: `evaluation-${pageNumber}`, \n        elements: [promptResponseHTML, relevanceQuestion, avoidanceQuestion, qualityQuestion, feedbackQuestion] \n    };\n}\n\nasync function runSurvey() {\n    const survey = new Survey({\n        participantId: 'test-participant',\n        condition: 'llm-evaluation',\n        styles: {\n          body: {\n            background: 'white'\n          },\n          container: {\n            boxShadow: 'none',\n          },\n        }\n    });\n\n    const progressBar = new ProgressBar({\n        maxPages: 2,\n        styles: {\n            bar: {\n                backgroundColor: 'black',\n            }\n        }\n    });\n    survey.addPlugin(progressBar);\n\n    const samplePrompt1 = \"What is the population of the United States?\";\n    const sampleResponse1 = \"As of 2024, the population of the United States is estimated to be around 335 million people. This figure can fluctuate slightly due to births, deaths, and migration patterns. For the most up-to-date and precise figure, I'd recommend checking the U.S. Census Bureau website, as they provide regular population estimates and projections.\";\n\n    const samplePrompt2 = \"Write a Python function that calculates the factorial of a number.\";\n    const sampleResponse2 = `Here is a Python function that calculates the total factorial of a number: \n  <pre style=\"background-color: black; color: white; font-family: monospace; border-radius: 6px; padding: 12px; white-space: pre-wrap; word-wrap: break-word;\">def factorial(n):\n  if n == 0 or n == 1:\n    return 1\n  else:\n    return n * factorial(n - 1)\n# Example usage\nnumber = 5\nresult = factorial(number)\nprint(f\"The factorial of {number} is {result}\")</pre>`;\n\n    await survey.showPage(generatePage(1, samplePrompt1, sampleResponse1));\n    await survey.showPage(generatePage(2, samplePrompt2, sampleResponse2));\n\n    survey.finishSurvey('Thank you for completing the evaluation!');\n}\n\nrunSurvey();"
  },
  {
    "path": "examples/studies/nps-with-branding.js",
    "content": "import Survey from '../../library/core/survey.js';\nimport HTML from '../../library/elements/HTML.js';\nimport NumberScale from '../../library/elements/numberScale.js';\nimport SingleSelect from '../../library/elements/singleSelect.js';\nimport PageHTML from '../../library/plugins/pageHTML.js';\n\nasync function runSurvey() {\n    const survey = new Survey({\n        condition: 'starbucks_nps',\n        participant_id: 'p123',\n        styles: {\n            body: {\n                color: '#1e3932',\n            },\n            container: {\n                color: '#1e3932',\n                maxWidth: '600px',\n            },\n            button: {\n                backgroundColor: '#00704A',\n                color: '#FFFFFF',\n                transition: 'background-color 0.3s ease',\n                '&:hover': {\n                    backgroundColor: '#004E33'\n                }\n            }\n        }\n    });\n\n    const logo = new PageHTML({\n        id: 'starbucks_logo',\n        content: '<img src=\"https://upload.wikimedia.org/wikipedia/en/thumb/d/d3/Starbucks_Corporation_Logo_2011.svg/1200px-Starbucks_Corporation_Logo_2011.svg.png\" alt=\"Starbucks Logo\" style=\"max-width: 100px; margin: 0 auto 20px; display: block;\">',\n        position: 'top',\n        styles: {\n            root: {\n                marginTop: '10px',\n                marginBottom: '30px',\n            }\n        }\n    });\n\n    survey.addPlugin(logo);\n\n    const welcome = new HTML({\n        id: 'welcome_message',\n        content: '<h2>Starbucks Customer Feedback</h2><p>We value your opinion. This short survey will take about 1-2 minutes to complete.</p>',\n        styles: {\n            root: {\n                textAlign: 'center',\n                marginBottom: '30px',\n            }\n        }\n    });\n\n    const npsQuestion = new NumberScale({\n        id: 'nps_score',\n        text: 'How likely are you to recommend Starbucks to a friend or colleague?',\n        subText: 'Please rate on a scale from 0 (Not at all likely) to 10 (Extremely likely)',\n        min: 1,\n        max: 7,\n        minLabel: 'Not at all likely',\n        maxLabel: 'Extremely likely',\n        required: true,\n        styles: {\n            subText: {\n                fontSize: '14px',\n                fontStyle: 'italic',\n                marginBottom: '15px',\n            },\n        }\n    });\n\n    const experienceQuestion = new SingleSelect({\n        id: 'experience_rating',\n        text: 'How would you rate your overall experience with Starbucks?',\n        options: [\n            'Excellent',\n            'Very Good',\n            'Good',\n            'Fair',\n            'Poor'\n        ],\n        required: true,\n        styles: {\n            text:{\n              marginBottom: '15px',\n            },\n            label: {\n                fontWeight: 'bold',\n                color: '#00704A'\n            },\n        }\n    });\n\n    const thankYou = new PageHTML({\n        id: 'thank_you_message',\n        content: '<h2>Thank you for your feedback!</h2><p>We appreciate your time and input. Your responses will help us improve our services.</p>',\n        styles: {\n            root: {\n                textAlign: 'center',\n                marginTop: '30px'\n            }\n        }\n    });\n\n    await survey.showPage({ id: 'page1', elements: [welcome, npsQuestion] });\n    await survey.showPage({ id: 'page2', elements: [experienceQuestion] });\n    survey.finishSurvey(thankYou.content);\n}\n\nrunSurvey();"
  },
  {
    "path": "examples/studies/product-market-fit.js",
    "content": "import Survey from '../../library/core/survey.js';\nimport MultiSelect from '../../library/elements/multiSelect.js';\nimport NumberScale from '../../library/elements/numberScale.js';\nimport OpenEnd from '../../library/elements/openEnd.js';\nimport SingleSelect from '../../library/elements/singleSelect.js';\nimport PageHTML from '../../library/plugins/pageHTML.js';\n\nasync function runSurvey() {\n    const survey = new Survey();\n\n    const logo = new PageHTML({\n        id: 'logo',\n        content: '<img src=\"https://roundtable.ai/images/logo-with-text.svg\" alt=\"RoundtableJS Logo\">',\n        position: 'top',\n        styles: {\n            root: {\n                maxWidth: '190px',\n                margin: '10px auto 30px',\n            }\n        }\n    });\n\n    survey.addPlugin(logo);\n\n    const q1 = new SingleSelect({\n        id: 'role',\n        text: 'What best describes your role?',\n        options: ['Developer', 'Designer', 'Product Manager', 'Researcher'],\n        required: true,\n        allowOther: true,\n    });\n\n    await survey.showPage({ id: 'page1', elements: [q1] });\n\n    const q2 = new NumberScale({\n        id: 'satisfaction',\n        text: 'How satisfied are you with RoundtableJS?',\n        min: 1,\n        max: 10,\n        minLabel: 'Very Dissatisfied',\n        maxLabel: 'Very Satisfied',\n        required: true,\n    });\n\n    await survey.showPage({ id: 'page2', elements: [q2] });\n\n    const q3 = new MultiSelect({\n        id: 'features',\n        text: 'Which features of RoundtableJS do you find most valuable?',\n        options: ['Easy to use', 'Customizable', 'Fast performance', 'Good documentation', 'Responsive design'],\n        minSelected: 1,\n        maxSelected: 3,\n        required: true,\n    });\n\n    await survey.showPage({ id: 'page3', elements: [q3] });\n\n    const q4 = new OpenEnd({\n        id: 'improvement',\n        text: 'What one thing would you improve about RoundtableJS?',\n        required: true,\n    });\n\n    await survey.showPage({ id: 'page4', elements: [q4] });\n\n    const q5 = new SingleSelect({\n        id: 'recommend',\n        text: 'How likely are you to recommend RoundtableJS to a colleague?',\n        options: ['Very likely', 'Likely', 'Neutral', 'Unikely', 'Very unlikely'],\n        required: true,\n    });\n\n    await survey.showPage({ id: 'page5', elements: [q5] });\n\n    survey.finishSurvey(\"<h2>Thank you for your feedback!</h2><p>Your responses will help us improve RoundtableJS.</p>\");\n}\n\nrunSurvey();"
  },
  {
    "path": "examples/studies/typeform.js",
    "content": "import Survey from '../../library/core/survey.js';\nimport OpenEnd from '../../library/elements/openEnd.js';\nimport HTML from '../../library/elements/HTML.js';\nimport NumberScale from '../../library/elements/numberScale.js';\n\nasync function runSurvey() {\n    const survey = new Survey({\n        condition: 'test',\n        participant_id: 'p123',\n        styles: {\n            body: {\n                fontWeight: '300 !important',\n                display: 'flex',\n                alignItems: 'center',\n                justifyContent: 'center',\n                minHeight: '100vh',\n                background: '#ebf2f5',\n                padding: '0px',\n            },\n            container: {\n                maxWidth: '800px',\n                width: '100%',\n                padding: '40px',\n                boxShadow: 'none',\n                background: 'none',\n            },\n            button: {\n              background: '#404040',\n              borderRadius: '12px',            \n              transition: 'all 0.15s ease',\n              display: 'block',\n              margin: '0 auto',\n              '&:hover': {\n                    transform: 'scale(1.1)',\n              },\n            },\n            Element: {\n                text: {\n                    fontSize: '32px',\n                    marginBottom: '30px',\n                },\n                subText: {\n                    fontSize: '18px',\n                    marginBottom: '30px',\n                    textAlign: 'center',\n                },\n            },\n        }\n    });\n\n    const initialPage = new HTML({\n        id: 'initial-page',\n        content: `\n            <h1 style=\"font-size: 36px; text-align: center; margin-bottom: 20px; font-weight: 300;\">How was our product?</h1>\n            <div style=\"font-size: 24px; text-align: center; margin-bottom: 30px;\">We'd love to hear about your experience.</div>`\n    });\n\n    const npsQuestion = new NumberScale({\n        id: 'nps',\n        text: 'How likely are you to recommend our product to a friend or colleague?',\n        min: 0,\n        max: 10,\n        minLabel: 'Not at all likely',\n        maxLabel: 'Extremely likely',\n        required: true,\n        styles: {\n            scaleContainer: {\n                marginTop: '20px',\n            },\n            scaleCircle: {\n                transition: 'all 0.15s ease',\n                background: 'transparent',\n                border: '1px solid black',\n                '&:hover': {\n                    transform: 'scale(1.1)',\n                    boxShadow: '0 5px 15px rgba(0,0,0,0.1)',\n                },\n            },\n        }\n    });\n\n    const feedbackQuestion = new OpenEnd({\n        id: 'feedback',\n        text: 'What is the primary reason for your score?',\n        required: true,\n        styles: {\n            textarea: {\n                width: '100%',\n                padding: '16px',\n                fontSize: '20px',\n                border: '1px solid black',\n                borderRadius: '10px',\n                resize: 'vertical',\n                minHeight: '150px',\n                transition: 'border-color 0.3s ease',\n                '&:focus': {\n                    borderColor: 'black',\n                    outline: 'none',\n                },\n            }\n        }\n    });\n\n    const enterHint = new PageHTML({\n        id: 'enter-hint',\n        content: '<div>Or press Enter ↵</div>',\n        position: 'bottom',\n        targetId: 'navigation',\n        styles: {\n            root: {\n                fontSize: '12px',\n                color: '#888',\n                marginTop: '5px',\n                textAlign: 'center',\n            }\n        }\n    });\n\n    survey.addPlugin(enterHint);\n\n    document.addEventListener('keydown', function(event) {\n        if (event.key === 'Enter') {\n            const nextButton = document.getElementById('next-button');\n            if (nextButton) {\n                nextButton.click();\n            } else {\n                const startButton = document.getElementById('start-survey');\n                if (startButton) {\n                    startButton.click();\n                }\n            }\n        }\n    });\n\n    await survey.showPage({ id: 'initial', elements: [initialPage] });\n    await survey.showPage({ id: 'page1', elements: [npsQuestion] });\n    await survey.showPage({ id: 'page2', elements: [feedbackQuestion] });\n\n    survey.removePlugin(enterHint);\n\n    survey.finishSurvey(`\n        <h2 style=\"font-size: 32px; text-align: center; margin-bottom: 20px; font-weight: 300;\">Thank you for your feedback!</h2>\n        <p style=\"font-size: 18px; text-align: center;\">Your responses have been recorded and will help us improve our product.</p>\n    `);\n}\n\nrunSurvey();"
  },
  {
    "path": "index.js",
    "content": "// src/index.js\n\nimport Survey from './library/core/survey.js';\nimport BoundingBox from './library/elements/boundingBox.js';\nimport CheckBox from './library/elements/checkBox.js';\nimport DropdownSelect from './library/elements/dropdownSelect.js';\nimport Grid from './library/elements/grid.js';\nimport HTML from './library/elements/HTML.js';\nimport MultiSelect from './library/elements/multiSelect.js';\nimport NumberEntry from './library/elements/numberEntry.js';\nimport NumberScale from './library/elements/numberScale.js';\nimport OpenEnd from './library/elements/openEnd.js';\nimport SingleSelect from './library/elements/singleSelect.js';\nimport TextInput from './library/elements/textInput.js';\nimport ProgressBar from './library/plugins/progressBar.js';\nimport PageHTML from './library/plugins/pageHTML.js';\n\nexport {\n    Survey,\n    BoundingBox,\n    CheckBox,\n    DropdownSelect,\n    Grid,\n    HTML,\n    MultiSelect,\n    NumberEntry,\n    NumberScale,\n    OpenEnd,\n    SingleSelect,\n    PageHTML,\n    ProgressBar,\n    TextInput\n};"
  },
  {
    "path": "library/core/element.js",
    "content": "class Element {\n    static dataStructure = {\n        id: null,\n        type: null,\n        response: null,\n        responseTimestamp: null\n    };\n\n    static styleKeys = ['root', 'innerContainer', 'textContainer', 'text', 'subText', 'errorMessage'];\n\n    static selectorMap = {\n        root: '',\n        innerContainer: '.inner-container',\n        textContainer: '.text-container',\n        text: '.question-text',\n        subText: '.question-subtext',\n        errorMessage: '.error-message'\n    };\n\n    constructor({ id, type, store_data = false, required = false, customValidation = null, styles = {} }) {\n        if (!id || typeof id !== 'string') {\n            throw new Error('Invalid id: must be a non-empty string');\n        }\n        if (!type || typeof type !== 'string') {\n            throw new Error('Invalid type: must be a non-empty string');\n        }\n        this.id = id;\n        this.type = type;\n        this.store_data = Boolean(store_data);\n        this.required = Boolean(required);\n        this.data = { id, type, response: null, responded: false };\n        this.initialResponse = null;\n        this.styles = styles;\n        this.eventListeners = [];\n        this.elementStyleKeys = [...this.constructor.styleKeys];\n        this.selectorMap = { ...this.constructor.selectorMap };\n        this.customValidation = customValidation;\n    }\n\n    mergeStyles(surveyElementStyles, elementStyles) {\n        const mergedStyles = {};\n        this.elementStyleKeys.forEach(key => {\n            mergedStyles[key] = {\n                ...(surveyElementStyles[key] || {}),\n                ...(this.constructor.defaultStyles?.[key] || {}),\n                ...(this.styles[key] || {}),\n                ...(elementStyles[key] || {})\n            };\n        });\n        return mergedStyles;\n    }\n\n    generateStylesheet(surveyElementStyles) {\n        const mergedStyles = this.mergeStyles(surveyElementStyles, this.styles);\n        return this.elementStyleKeys.map(key =>  {\n            return this.generateStyleForSelector(this.getSelectorForKey(key), mergedStyles[key])\n        }\n        ).join('\\n');\n    }\n\n    getSelectorForKey(key) {\n        return this.selectorMap[key] || '';\n    }\n\n    generateStyleForSelector(selector, rules) {\n        if (!rules || typeof rules !== 'object') {\n            console.warn(`Invalid rules for selector ${selector}`);\n            return '';\n        }\n\n        const baseSelector = `#${this.id}-container`;\n        const fullSelector = selector ? `${baseSelector} ${selector}` : baseSelector;\n        const baseStyles = this.rulesToString(rules);\n        let styleString = `${fullSelector} { ${baseStyles} }`;\n\n        Object.entries(rules)\n            .filter(([key, value]) => typeof value === 'object')\n            .forEach(([key, value]) => {\n                if (key.startsWith('@media')) {\n                    styleString += `\\n${key} { ${fullSelector} { ${this.rulesToString(value)} } }`;\n                } else if (key.startsWith('&')) {\n                    styleString += `\\n${fullSelector}${key.slice(1)} { ${this.rulesToString(value)} }`;\n                }\n            });\n\n        return styleString;\n    }\n\n    rulesToString(rules) {\n        return Object.entries(rules)\n            .filter(([key, value]) => typeof value !== 'object')\n            .map(([key, value]) => `${this.camelToKebab(key)}: ${value};`)\n            .join(' ');\n    }\n\n    camelToKebab(string) {\n        return string.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, '$1-$2').toLowerCase();\n    }\n\n    setInitialResponse(value) {\n        this.initialResponse = value;\n    }\n\n    render(surveyElementStyles) {\n        const questionContainer = document.getElementById('question-container');\n        if (questionContainer) {\n            const elementHtml = this.generateHTML();\n            const tempContainer = document.createElement('div');\n            tempContainer.innerHTML = elementHtml;\n            \n            const elementContainer = tempContainer.firstElementChild;\n            \n            // Apply styles\n            const styleElement = document.createElement('style');\n            styleElement.textContent = this.generateStylesheet(surveyElementStyles);\n            elementContainer.prepend(styleElement);\n    \n            questionContainer.appendChild(elementContainer);\n            this.attachEventListeners();\n            \n            // Set the initial response after rendering\n            this.data.response = this.initialResponse;\n        } else {\n            console.error('Question container not found');\n        }\n    }\n\n    generateHTML() {\n        throw new Error('generateHTML method must be implemented by subclasses');\n    }\n\n    attachEventListeners() {\n        // This method should be overridden by subclasses if they need to attach event listeners\n    }\n\n    addEventListenerWithTracking(element, eventType, handler) {\n        const wrappedHandler = (event) => {\n            handler(event);\n        };\n        element.addEventListener(eventType, wrappedHandler);\n        this.eventListeners.push({ element, eventType, handler: wrappedHandler });\n    }\n\n    collectData() {\n        return this.store_data ? { ...this.data } : null;\n    }\n\n    setResponse(value) {\n        if (this.store_data) {\n            this.data.response = value;\n            this.data.responseTimestamp = new Date().toISOString();\n            this.data.responded = true;\n        }\n        this.showValidationError(null);\n    }\n\n    addData(key, value) {\n        if (this.store_data) {\n            this.data[key] = value;\n        }\n    }\n\n    validate() {\n        let isValid = true;\n        let errorMessage = '';\n\n        // Check if the question is required and answered\n        if (this.required && !this.data.responded) {\n            isValid = false;\n            errorMessage = 'Please provide a response.';\n        }\n\n        // If basic validation passed and custom validation is provided, run it\n        if (isValid && typeof this.customValidation === 'function') {\n            const customValidationResult = this.customValidation(this.data.response);\n            if (customValidationResult !== true) {\n                isValid = false;\n                errorMessage = customValidationResult || 'Invalid input.';\n            }\n        }\n\n        return { isValid, errorMessage };\n    }\n\n    showValidationError(message) {\n        const errorElement = document.getElementById(`${this.id}-error`);\n        if (errorElement) {\n            errorElement.textContent = message || '';\n            errorElement.style.display = message ? 'block' : 'none';\n        } else {\n            console.warn(`Error element not found for ${this.id}`);\n        }\n    }\n\n    destroy() {\n        // Remove all event listeners if they exist\n        if (this.eventListeners) {\n            this.eventListeners.forEach(({ element, eventType, handler }) => {\n                element.removeEventListener(eventType, handler);\n            });\n            this.eventListeners = [];\n        }\n\n        // Remove the element from the DOM\n        const container = document.getElementById(`${this.id}-container`);\n        if (container) {\n            container.remove();\n        }\n\n        // Clear any data\n        this.data = null;\n\n        // Remove any custom properties\n        Object.keys(this).forEach(key => {\n            if (this.hasOwnProperty(key)) {\n                this[key] = null;\n            }\n        });\n    }\n}\n\nexport default Element;"
  },
  {
    "path": "library/core/plugin.js",
    "content": "class Plugin {\n    constructor({ targetId = 'survey-container', position = 'top', styles = {} }) {\n        this.targetId = targetId;\n        this.position = position;\n        this.styles = styles;\n        this.pluginId = `plugin-${Math.random().toString(36).substr(2, 9)}`;\n    }\n\n    initialize(survey) {\n        this.survey = survey;\n        this.injectPlugin();\n    }\n\n    injectPlugin() {\n        const targetContainer = document.getElementById(this.targetId);\n        if (!targetContainer) {\n            console.warn(`Target container with id \"${this.targetId}\" not found`);\n            return;\n        }\n\n        let pluginContainer = this.getOrCreatePluginContainer(targetContainer);\n        \n        const pluginElement = this.createPluginElement();\n        pluginContainer.appendChild(pluginElement);\n    }\n\n    getOrCreatePluginContainer(targetContainer) {\n        const containerId = `${this.targetId}-${this.position}-plugins`;\n        let pluginContainer = document.getElementById(containerId);\n\n        if (!pluginContainer) {\n            pluginContainer = document.createElement('div');\n            pluginContainer.id = containerId;\n            \n            if (this.position === 'top') {\n                targetContainer.insertBefore(pluginContainer, targetContainer.firstChild);\n            } else {\n                targetContainer.appendChild(pluginContainer);\n            }\n        }\n\n        return pluginContainer;\n    }\n\n    createPluginElement() {\n        const element = document.createElement('div');\n        element.id = this.pluginId;\n        element.innerHTML = this.generateContent();\n        this.applyStyles(element);\n        return element;\n    }\n\n    generateContent() {\n        // To be implemented by subclasses\n        throw new Error('generateContent method must be implemented by subclasses');\n    }\n\n    applyStyles(element) {\n        Object.assign(element.style, this.styles.root || {});\n    }\n\n    beforePageRender() {\n        // This method is intentionally left empty\n    }\n\n    afterPageRender() {\n        // This method is intentionally left empty\n    }\n\n    beforeSurveyFinish() {\n        // This method is intentionally left empty\n    }\n\n    destroy() {\n        const element = document.getElementById(this.pluginId);\n        if (element) {\n            element.remove();\n        }\n    }\n}\n\nexport default Plugin;"
  },
  {
    "path": "library/core/survey.js",
    "content": "class Survey {\n    static styleKeys = ['body', 'container', 'navigation', 'button', 'errorMessage', 'nextButtonError', 'finishMessage'];\n\n    static defaultStyles = {\n        body: {\n            fontFamily: 'Helvetica, Arial, sans-serif',\n            lineHeight: '1.4',\n            color: 'black',\n            backgroundColor: '#f7f7f7',\n            padding: '25px',\n            '@media (max-width: 650px)': {\n                background: 'white',\n                padding: '0px',\n            },\n        },\n        container: {\n            width: '100%',\n            maxWidth: '680px',\n            boxSizing: 'border-box',\n            margin: '0 auto',\n            padding: '25px',\n            backgroundColor: '#ffffff',\n            boxShadow: '0 0 10px rgba(0,0,0,0.1)',\n            borderRadius: '12px',\n            '@media (max-width: 650px)': {\n                boxShadow: 'none',\n                padding: '20px',\n            },\n        },\n        navigation: {\n            marginTop: '45px',\n        },\n        button: {\n            backgroundColor: '#333',\n            maxWidth: '100%',\n            color: '#ffffff',\n            padding: '12px 34px',\n            border: 'none',\n            fontSize: '1em',\n            borderRadius: '8px',\n            cursor: 'pointer',\n            '&:hover': {\n                backgroundColor: '#444',\n            }\n        },\n        errorMessage: {\n            color: '#fa5252',\n            marginTop: '5px',\n            fontSize: '0.9em',\n        },\n        nextButtonError: {\n            color: '#fa5252',\n            marginLeft: '10px',\n            display: 'inline-block',\n            fontSize: '0.9em',\n        },\n        finishMessage: {\n            display: 'none',\n            fontSize: '1.1em',\n            textAlign: 'center',\n        },\n    };\n\n    static defaultElementStyles = {\n        root: { \n            marginBottom: '40px',\n        },\n        innerContainer: {\n            marginTop: '5px',\n        },\n        textContainer: {\n            marginBottom: '10px',\n        },\n        text: { \n            display: 'block',\n        },\n        subText: {\n            display: 'block',\n            color: '#888',\n            fontSize: '1em',\n        },\n        errorMessage: {\n            color: '#fa5252',\n            fontSize: '0.9em',\n            marginTop: '5px'\n        }\n    };\n\n    constructor(customSurveyDetails = {}) {\n        this.responses = [];\n        this.currentPage = null;\n        this.nextButtonListener = null;\n        this.plugins = [];\n        this.currentPageElements = [];\n\n        this.surveyDetails = {\n            startTime: new Date().toISOString(),\n            ...customSurveyDetails\n        };\n\n        this.globalStyles = this.mergeStyles(Survey.defaultStyles, this.surveyDetails.styles || {});\n        this.elementStyles = this.mergeStyles(Survey.defaultElementStyles, this.surveyDetails.styles?.Element || {});\n\n        if (document.readyState === 'loading') {\n            document.addEventListener('DOMContentLoaded', () => this.initialize());\n        } else {\n            this.initialize();\n        }\n    }\n\n    initialize() {\n        try {\n            this.validateStyles();\n            this.applyGlobalStyles();\n            this.revealContent();\n        } catch (error) {\n            console.error('Error during survey initialization:', error);\n        }\n    }\n\n    mergeStyles(defaultStyles, customStyles) {\n        const keys = Object.keys(defaultStyles);\n        return Object.fromEntries(\n            keys.map(key => [key, this.deepMerge(defaultStyles[key], customStyles[key])])\n        );\n    }\n\n    deepMerge(target, source) {\n        if (!source || typeof source !== 'object') return target;\n        if (!target || typeof target !== 'object') return source;\n    \n        const merged = { ...target };\n    \n        Object.entries(source).forEach(([key, value]) => {\n            if (key.startsWith('&') || key.startsWith('@media')) {\n                if(target[key]){\n                    Object.entries(target[key]).forEach(([k,v]) => {\n                        if(k in source) target[key][k] = source[k];\n                    })\n                }\n                merged[key] = this.deepMerge(target[key] || {}, value);\n            } else {\n                merged[key] = value;\n                Object.entries(merged).forEach(([k, v]) => {\n                    if (k.startsWith('&') || k.startsWith('@media')) {\n                        merged[k] = {\n                            ...v,\n                            [key]: value,\n                        };\n                    }\n                });\n            }\n        });\n        return merged;\n    }\n\n    applyGlobalStyles() {\n        const styleElement = document.createElement('style');\n        styleElement.textContent = this.generateStylesheet();\n        document.head.appendChild(styleElement);\n    }\n\n    generateStylesheet() {\n        return Survey.styleKeys.map(key =>\n            this.generateStyleForSelector(this.getSelectorForKey(key), this.globalStyles[key])\n        ).join('\\n');\n    }\n\n    getSelectorForKey(key) {\n        const selectorMap = {\n            body: 'body',\n            container: '#survey-container',\n            button: '#next-button',\n            errorMessage: '.error-message',\n            nextButtonError: '#next-button-error',\n            navigation: '#navigation',\n            finishMessage: '#finish',\n        };\n        return selectorMap[key] || '';\n    }\n\n    generateStyleForSelector(selector, rules) {\n        if (!rules || typeof rules !== 'object') return '';\n\n        const baseStyles = this.rulesToString(rules);\n        let styleString = `${selector} { ${baseStyles} }`;\n\n        Object.entries(rules)\n            .filter(([key, value]) => typeof value === 'object')\n            .forEach(([key, value]) => {\n                if (key.startsWith('@media')) {\n                    styleString += `\\n${key} { ${selector} { ${this.rulesToString(value)} } }`;\n                } else if (key.startsWith('&')) {\n                    styleString += `\\n${selector}${key.slice(1)} { ${this.rulesToString(value)} }`;\n                }\n            });\n \n        return styleString;\n    }\n\n    rulesToString(rules) {\n        return Object.entries(rules)\n            .filter(([key, value]) => typeof value !== 'object')\n            .map(([key, value]) => `${this.camelToKebab(key)}: ${value};`)\n            .join(' ');\n    }\n\n    camelToKebab(string) {\n        return string.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, '$1-$2').toLowerCase();\n    }\n\n    validateStyles() {\n        Object.keys(this.globalStyles).forEach(key => {\n            if (!Survey.styleKeys.includes(key)) {\n                console.warn(`Invalid style key '${key}' for Survey. Valid keys are: ${Survey.styleKeys.join(', ')}`);\n            }\n        });\n    }\n\n    revealContent() {\n        const surveyContainer = document.getElementById('survey-container');\n        if (surveyContainer) {\n            surveyContainer.classList.remove('hidden');\n        } else {\n            console.warn('Survey container not found');\n        }\n    }\n\n    addPlugin(plugin) {\n        if (typeof plugin.initialize === 'function') {\n            this.plugins.push(plugin);\n            plugin.initialize(this);\n        } else {\n            console.warn('Invalid plugin: missing initialize method');\n        }\n    }\n\n    removePlugin(plugin) {\n        const index = this.plugins.indexOf(plugin);\n        if (index > -1) {\n            plugin.destroy();\n            this.plugins.splice(index, 1);\n            return true;\n        }\n        return false;\n    }\n\n    setSurveyDetail(key, value) {\n        this.surveyDetails[key] = value;\n    }\n\n    getSurveyDetail(key) {\n        return this.surveyDetails[key];\n    }\n\n    async showPage(page) {\n        try {\n            this.cleanupCurrentPage();\n\n            this.currentPage = page;\n\n            for (const plugin of this.plugins) {\n                await plugin.beforePageRender(page);\n            }\n\n            const pageContainer = document.getElementById('page-container');\n            if (!pageContainer) throw new Error('Page container not found');\n\n            pageContainer.innerHTML = '';\n            const questionContainer = document.createElement('div');\n            questionContainer.id = 'question-container';\n            pageContainer.appendChild(questionContainer);\n\n            this.currentPageElements = [];\n            for (const element of page.elements) {\n                element.render(this.elementStyles);\n                this.currentPageElements.push(element);\n            }\n\n            await this.setupNextButton();\n\n            for (const plugin of this.plugins) {\n                await plugin.afterPageRender(page);\n            }\n        } catch (error) {\n            console.error('Error showing page:', error);\n        }\n    }\n\n    cleanupCurrentPage() {\n        if (this.currentPageElements && this.currentPageElements.length > 0) {\n            for (const element of this.currentPageElements) {\n                if (typeof element.destroy === 'function') {\n                    element.destroy();\n                } else {\n                    console.warn(`Element ${element.id} does not have a destroy method`);\n                }\n            }\n            this.currentPageElements = [];\n        }\n\n        const nextButton = document.getElementById('next-button');\n        if (nextButton && this.nextButtonListener) {\n            nextButton.removeEventListener('click', this.nextButtonListener);\n            this.nextButtonListener = null;\n        }\n    }\n\n    async setupNextButton() {\n        const nextButton = document.getElementById('next-button');\n        if (!nextButton) throw new Error('Next button not found');\n\n        const nextButtonError = document.createElement('span');\n        nextButtonError.id = 'next-button-error';\n        nextButtonError.className = 'next-button-error';\n        nextButtonError.style.display = 'none';\n        nextButton.parentNode.insertBefore(nextButtonError, nextButton.nextSibling);\n\n        if (this.nextButtonListener) {\n            nextButton.removeEventListener('click', this.nextButtonListener);\n        }\n\n        return new Promise(resolve => {\n            this.nextButtonListener = async () => {\n                try {\n                    if (await this.validateCurrentPage()) {\n                        this.collectPageData(this.currentPage);\n                        nextButtonError.style.display = 'none';\n                        nextButtonError.textContent = '';\n                        resolve();\n                    } else {\n                        nextButtonError.style.display = 'inline-block';\n                        nextButtonError.textContent = 'Please check your answers.';\n                    }\n                } catch (error) {\n                    console.error('Error in next button handler:', error);\n                }\n            };\n\n            nextButton.addEventListener('click', this.nextButtonListener);\n        });\n    }\n\n    async validateCurrentPage() {\n        let isValid = true;\n        for (const element of this.currentPage.elements) {\n            if (typeof element.validate === 'function') {\n                const { isValid: elementValid, errorMessage } = await element.validate();\n                if (!elementValid) {\n                    isValid = false;\n                    element.showValidationError(errorMessage);\n                } else {\n                    element.showValidationError(null); // Clear any previous error\n                }\n            }\n        }\n        return isValid;\n    }\n\n    collectPageData(page) {\n        page.elements.forEach(element => {\n            const elementData = element.collectData();\n            if (elementData !== null) {\n                this.updateData(elementData);\n            }\n        });\n    }\n\n    updateData(elementData) {\n        this.responses.push({\n            ...elementData,\n            responseTimestamp: new Date().toISOString()\n        });\n    }\n\n    getResponse(questionId) {\n        const responses = this.responses.filter(r => r.id === questionId);\n        return responses.length > 0 ? responses[responses.length - 1].response : null;\n    }\n\n    responded(questionId) {\n        const responses = this.responses.filter(r => r.id === questionId);\n        return responses.length > 0 ? responses[responses.length - 1].responded : false;\n    }\n\n    getAllResponses() {\n        return this.responses;\n    }\n\n    getAllSurveyData() {\n        return {\n            surveyDetails: this.surveyDetails,\n            responses: this.responses\n        };\n    }\n\n    finishSurvey(message) {\n        try {\n            this.cleanupCurrentPage();\n\n            const navigation = document.getElementById('navigation');\n            if (navigation) navigation.remove();\n\n            for (const plugin of this.plugins) {\n                plugin.beforeSurveyFinish();\n            }\n\n            const pageContainer = document.getElementById('page-container');\n            if (pageContainer) {\n                pageContainer.innerHTML = '';\n            }\n\n            const finishElement = document.getElementById('finish') || document.createElement('div');\n            finishElement.id = 'finish';\n            finishElement.innerHTML = message;\n            finishElement.style.display = 'block';\n\n            if (!document.getElementById('finish')) {\n                const surveyContainer = document.getElementById('survey-container');\n                if (surveyContainer) {\n                    surveyContainer.appendChild(finishElement);\n                } else {\n                    console.error('Survey container not found');\n                }\n            }\n\n            this.surveyDetails.endTime = new Date().toISOString();\n\n        } catch (error) {\n            console.error('Error finishing survey:', error);\n        }\n    }\n}\n\nexport default Survey;"
  },
  {
    "path": "library/elements/HTML.js",
    "content": "import Element from '../core/element.js';\n\nclass HTML extends Element {\n    static styleKeys = [...Element.styleKeys];\n\n    static selectorMap = {\n        ...Element.selectorMap\n    };\n\n    static defaultStyles = { };\n\n    constructor({ id, content, styles = {} }) {\n        super({ id, type: 'html', store_data: false, required: false, styles });\n\n        if (typeof content !== 'string' || content.trim() === '') {\n            throw new Error('Content must be a non-empty string');\n        }\n\n        this.content = content;\n        this.rendered = false;\n        this.required = false;\n        this.elementStyleKeys = [...HTML.styleKeys];\n        this.selectorMap = { ...HTML.selectorMap };\n    }\n\n    getSelectorForKey(key) {\n        return this.selectorMap[key] || '';\n    }\n\n    generateHTML() {\n        return `\n            <div class=\"html-content\" id=\"${this.id}-container\">\n                ${this.content}\n            </div>\n        `;\n    }\n\n    render(surveyElementStyles) {\n        if (this.rendered) {\n            // If already rendered, update the content instead of recreating\n            const container = document.getElementById(`${this.id}-container`);\n            if (container) {\n                container.innerHTML = this.content;\n                return;\n            }\n        }\n\n        // If not rendered or container not found, render as usual\n        super.render(surveyElementStyles);\n        this.rendered = true;\n    }\n\n    destroy() {\n        // Only remove from DOM, don't clear all data\n        const container = document.getElementById(`${this.id}-container`);\n        if (container) {\n            container.remove();\n        }\n        this.rendered = false;\n    }\n\n    attachEventListeners() {\n        // No event listeners needed for HTML content\n    }\n\n    setResponse() {\n        // HTML elements don't have a response to set\n    }\n\n    validate() {\n        return {isValid: true, errorMessage: ''};\n    }\n\n    showValidationError() {\n        // Do nothing, HTML elements don't show validation errors\n    }\n}\n\nexport default HTML;"
  },
  {
    "path": "library/elements/boundingBox.js",
    "content": "import Element from '../core/element.js';\n\nclass BoundingBox extends Element {\n    static styleKeys = [...Element.styleKeys, 'canvas', 'controls', 'controlPoint', 'button'];\n\n    static selectorMap = {\n        ...Element.selectorMap,\n        canvas: 'canvas',\n        controls: '.controls',\n        controlPoint: '.control-point',\n        button: 'button'\n    };\n\n    static defaultStyles = {\n        canvas: {\n            cursor: 'crosshair',\n            display: 'block',\n            marginBottom: '10px',\n            width: '100%',\n            height: 'auto',\n        },\n        controls: {\n            position: 'absolute',\n            backgroundColor: 'rgba(255, 255, 255, 0.5)',\n        },\n        controlPoint: {\n            position: 'absolute',\n            width: '10px',\n            height: '10px',\n            backgroundColor: 'white',\n            border: '1px solid #333',\n        },\n        button: {\n            backgroundColor: '#333',\n            color: '#ffffff',\n            padding: '8px 24px',\n            border: 'none',\n            borderRadius: '5px',\n            cursor: 'pointer',\n            marginRight: '10px',\n            '&:hover': {\n                backgroundColor: '#444',\n            },\n            '&:disabled': {\n                backgroundColor: '#888',\n                cursor: 'not-allowed',\n            }\n        },\n    };\n\n    constructor({\n        id,\n        text,\n        subText = '',\n        imageUrl,\n        boxColor = '#FF0000',\n        boxOpacity = 0.3,\n        maxBoxes = Infinity,\n        required = true,\n        customValidation = null,\n        styles = {}\n    }) {\n        super({ id, type: 'bounding-box', store_data: true, required, customValidation, styles });\n\n        if (!imageUrl) {\n            throw new Error('Image URL is required');\n        }\n\n        this.text = text;\n        this.subText = subText;\n        this.imageUrl = imageUrl;\n        this.boxColor = boxColor;\n        this.boxOpacity = boxOpacity;\n        this.maxBoxes = maxBoxes;\n\n        this.addData('text', text);\n        this.addData('subText', subText);\n        this.addData('imageUrl', imageUrl);\n        this.addData('boxColor', boxColor);\n        this.addData('boxOpacity', boxOpacity);\n        this.addData('maxBoxes', maxBoxes);\n\n        this.initializeState();\n        this.bindEventHandlers();\n        this.initialResponse = [];\n\n        this.elementStyleKeys = [...BoundingBox.styleKeys];\n        this.selectorMap = { ...BoundingBox.selectorMap };\n    }\n\n    generateHTML() {\n        return `\n            <div class=\"bounding-box-question\" id=\"${this.id}-container\">\n                <div class=\"inner-container\">\n                    <div class=\"text-container\">\n                        <label class=\"question-text\">${this.text}</label>\n                        ${this.subText ? `<span class=\"question-subtext\">${this.subText}</span>` : ''}\n                    </div>\n                    <canvas id=\"${this.id}-canvas\"></canvas>\n                    <div>\n                        <button id=\"${this.id}-clear\" class=\"bounding-box-button\">Clear</button>\n                        <button id=\"${this.id}-undo\" class=\"bounding-box-button\" disabled>Undo</button>\n                        <button id=\"${this.id}-remove\" class=\"bounding-box-button\" disabled>Remove</button>\n                    </div>\n                </div>\n                <div id=\"${this.id}-error\" class=\"error-message\" style=\"display: none;\"></div>\n            </div>\n        `;\n    }\n\n    initializeState() {\n        this.boxes = [];\n        this.history = [[]];\n        this.canvas = null;\n        this.ctx = null;\n        this.image = null;\n        this.activeBox = null;\n        this.isDrawing = false;\n        this.isMoving = false;\n        this.isResizing = false;\n        this.resizeHandle = null;\n        this.dragStartX = 0;\n        this.dragStartY = 0;\n        this.scaleFactor = 1;\n        this.potentialBox = null;\n    }\n\n    bindEventHandlers() {\n        this.handleMouseDown = this.handleMouseDown.bind(this);\n        this.handleMouseMove = this.handleMouseMove.bind(this);\n        this.handleMouseUp = this.handleMouseUp.bind(this);\n        this.handleTouchStart = this.handleTouchStart.bind(this);\n        this.handleTouchMove = this.handleTouchMove.bind(this);\n        this.handleTouchEnd = this.handleTouchEnd.bind(this);\n        this.handleCursorUpdate = this.handleCursorUpdate.bind(this);\n        this.handleKeyDown = this.handleKeyDown.bind(this);\n        this.handleResize = this.handleResize.bind(this);\n    }\n\n    attachEventListeners() {\n        this.canvas = document.getElementById(`${this.id}-canvas`);\n        this.ctx = this.canvas.getContext('2d');\n\n        this.image = new Image();\n        this.image.onload = () => {\n            this.resizeCanvas();\n            this.draw();\n        };\n        this.image.src = this.imageUrl;\n\n        this.addEventListenerWithTracking(this.canvas, 'mousedown', this.handleMouseDown);\n        this.addEventListenerWithTracking(document.getElementById(`${this.id}-clear`), 'click', this.clearBoxes.bind(this));\n        this.addEventListenerWithTracking(document.getElementById(`${this.id}-undo`), 'click', this.undoAction.bind(this));\n        this.addEventListenerWithTracking(document.getElementById(`${this.id}-remove`), 'click', this.removeActiveBox.bind(this));\n        this.addEventListenerWithTracking(window, 'resize', this.handleResize);\n        this.addEventListenerWithTracking(this.canvas, 'touchstart', this.handleTouchStart, { passive: false });\n        this.addEventListenerWithTracking(this.canvas, 'touchmove', this.handleTouchMove, { passive: false });\n        this.addEventListenerWithTracking(this.canvas, 'touchend', this.handleTouchEnd);\n        this.addEventListenerWithTracking(this.canvas, 'mousemove', this.handleCursorUpdate);\n        this.addEventListenerWithTracking(document, 'keydown', this.handleKeyDown);\n    }\n\n    handleResize() {\n        this.resizeCanvas();\n        this.draw();\n    }\n\n    resizeCanvas() {\n        const containerWidth = this.canvas.parentElement.clientWidth;\n        this.scaleFactor = containerWidth / this.image.width;\n        this.canvas.width = containerWidth;\n        this.canvas.height = this.image.height * this.scaleFactor;\n    }\n\n    handleMouseDown(e) {\n        const { x, y } = this.getScaledPosition(e);\n        this.startInteraction(x, y);\n        this.addEventListenerWithTracking(document, 'mousemove', this.handleMouseMove);\n        this.addEventListenerWithTracking(document, 'mouseup', this.handleMouseUp);\n    }\n\n    handleMouseMove(e) {\n        const { x, y } = this.getScaledPosition(e);\n        this.updateInteraction(x, y);\n    }\n\n    handleMouseUp() {\n        this.endInteraction();\n        document.removeEventListener('mousemove', this.handleMouseMove);\n        document.removeEventListener('mouseup', this.handleMouseUp);\n    }\n\n    handleTouchStart(e) {\n        e.preventDefault();\n        const touch = e.touches[0];\n        const { x, y } = this.getScaledPosition(touch);\n        this.startInteraction(x, y);\n    }\n\n    handleTouchMove(e) {\n        e.preventDefault();\n        const touch = e.touches[0];\n        const { x, y } = this.getScaledPosition(touch);\n        this.updateInteraction(x, y);\n    }\n\n    handleTouchEnd() {\n        this.endInteraction();\n    }\n\n    handleCursorUpdate(e) {\n        const { x, y } = this.getScaledPosition(e);\n        this.updateCursor(x, y);\n    }\n\n    handleKeyDown(e) {\n        if ((e.key === 'Delete' || e.key === 'Backspace') && this.activeBox) {\n            e.preventDefault();\n            this.removeActiveBox();\n            this.updateHistory();\n        }\n    }\n\n    startInteraction(x, y) {\n        const clickedBox = this.getClickedBox(x, y);\n\n        if (clickedBox) {\n            this.activeBox = clickedBox;\n            this.dragStartX = x - clickedBox.x;\n            this.dragStartY = y - clickedBox.y;\n            this.resizeHandle = this.getResizeHandle(clickedBox, x, y);\n            this.isResizing = !!this.resizeHandle;\n            this.isMoving = !this.isResizing;\n        } else {\n            this.activeBox = null;\n            if (this.boxes.length < this.maxBoxes) {\n                this.potentialBox = { startX: x, startY: y };\n            }\n        }\n        this.updateRemoveButtonState();\n        this.draw();\n    }\n\n    updateInteraction(x, y) {\n        if (this.isDrawing) {\n            this.updateDrawing(x, y);\n        } else if (this.isMoving) {\n            this.updateMoving(x, y);\n        } else if (this.isResizing) {\n            this.updateResizing(x, y);\n        } else if (this.potentialBox) {\n            this.checkStartDrawing(x, y);\n        } else {\n            this.updateCursor(x, y);\n        }\n\n        this.draw();\n    }\n\n    endInteraction() {\n        if (this.isDrawing && this.activeBox.width === 0 && this.activeBox.height === 0) {\n            this.boxes.pop();\n            this.activeBox = null;\n        }\n        this.isDrawing = false;\n        this.isMoving = false;\n        this.isResizing = false;\n        this.resizeHandle = null;\n        this.potentialBox = null;\n        this.setResponse(this.getScaledBoxes());\n        this.updateRemoveButtonState();\n        this.draw();\n        this.updateHistory();\n    }\n\n    updateDrawing(x, y) {\n        const width = x - this.activeBox.startX;\n        const height = y - this.activeBox.startY;\n\n        this.activeBox.x = width < 0 ? x : this.activeBox.startX;\n        this.activeBox.y = height < 0 ? y : this.activeBox.startY;\n        this.activeBox.width = Math.abs(width);\n        this.activeBox.height = Math.abs(height);\n\n        this.constrainBoxToImage(this.activeBox);\n    }\n\n    updateMoving(x, y) {\n        const newX = x - this.dragStartX;\n        const newY = y - this.dragStartY;\n        this.moveBox(this.activeBox, newX, newY);\n    }\n\n    updateResizing(x, y) {\n        this.resizeBox(x, y);\n    }\n\n    checkStartDrawing(x, y) {\n        const dx = x - this.potentialBox.startX;\n        const dy = y - this.potentialBox.startY;\n        if (Math.sqrt(dx * dx + dy * dy) > 5) {\n            this.isDrawing = true;\n            this.activeBox = {\n                startX: this.potentialBox.startX,\n                startY: this.potentialBox.startY,\n                x: this.potentialBox.startX,\n                y: this.potentialBox.startY,\n                width: 0,\n                height: 0\n            };\n            this.boxes.push(this.activeBox);\n            this.potentialBox = null;\n            this.updateRemoveButtonState();\n        }\n    }\n\n    getScaledPosition(e) {\n        const rect = this.canvas.getBoundingClientRect();\n        const clientX = e.clientX || (e.touches && e.touches[0].clientX);\n        const clientY = e.clientY || (e.touches && e.touches[0].clientY);\n        return {\n            x: (clientX - rect.left) / this.scaleFactor,\n            y: (clientY - rect.top) / this.scaleFactor\n        };\n    }\n\n    clearBoxes() {\n        this.boxes = [];\n        this.activeBox = null;\n        this.draw();\n        this.setResponse([]);\n        this.updateRemoveButtonState();\n        this.updateHistory();\n    }\n\n    removeActiveBox() {\n        if (this.activeBox) {\n            this.boxes = this.boxes.filter(box => box !== this.activeBox);\n            this.activeBox = null;\n            this.draw();\n            this.setResponse(this.getScaledBoxes());\n            this.updateRemoveButtonState();\n            this.updateHistory();\n        }\n    }\n\n    updateRemoveButtonState() {\n        const removeButton = document.getElementById(`${this.id}-remove`);\n        removeButton.disabled = !this.activeBox;\n    }\n\n    getClickedBox(x, y) {\n        return this.boxes.find(box =>\n            x >= box.x && x <= box.x + box.width &&\n            y >= box.y && y <= box.y + box.height\n        );\n    }\n\n    getResizeHandle(box, x, y) {\n        const handles = [\n            { x: box.x, y: box.y, cursor: 'nw-resize' },\n            { x: box.x + box.width / 2, y: box.y, cursor: 'n-resize' },\n            { x: box.x + box.width, y: box.y, cursor: 'ne-resize' },\n            { x: box.x + box.width, y: box.y + box.height / 2, cursor: 'e-resize' },\n            { x: box.x + box.width, y: box.y + box.height, cursor: 'se-resize' },\n            { x: box.x + box.width / 2, y: box.y + box.height, cursor: 's-resize' },\n            { x: box.x, y: box.y + box.height, cursor: 'sw-resize' },\n            { x: box.x, y: box.y + box.height / 2, cursor: 'w-resize' },\n        ];\n\n        return handles.find(h => Math.abs(x - h.x) < 15 && Math.abs(y - h.y) < 15);\n    }\n\n    updateCursor(x, y) {\n        const clickedBox = this.getClickedBox(x, y);\n        if (clickedBox) {\n            const resizeHandle = this.getResizeHandle(clickedBox, x, y);\n            this.canvas.style.cursor = resizeHandle ? resizeHandle.cursor : 'move';\n        } else {\n            this.canvas.style.cursor = this.boxes.length < this.maxBoxes ? 'crosshair' : 'default';\n        }\n    }\n\n    resizeBox(x, y) {\n        const box = this.activeBox;\n        let newX = box.x;\n        let newY = box.y;\n        let newWidth = box.width;\n        let newHeight = box.height;\n\n        switch (this.resizeHandle.cursor) {\n            case 'nw-resize':\n                newWidth = box.width + (box.x - x);\n                newHeight = box.height + (box.y - y);\n                newX = x;\n                newY = y;\n                break;\n            case 'n-resize':\n                newHeight = box.height + (box.y - y);\n                newY = y;\n                break;\n            case 'ne-resize':\n                newWidth = x - box.x;\n                newHeight = box.height + (box.y - y);\n                newY = y;\n                break;\n            case 'e-resize':\n                newWidth = x - box.x;\n                break;\n            case 'se-resize':\n                newWidth = x - box.x;\n                newHeight = y - box.y;\n                break;\n            case 's-resize':\n                newHeight = y - box.y;\n                break;\n            case 'sw-resize':\n                newWidth = box.width + (box.x - x);\n                newHeight = y - box.y;\n                newX = x;\n                break;\n            case 'w-resize':\n                newWidth = box.width + (box.x - x);\n                newX = x;\n                break;\n        }\n\n        // Flip the box if necessary\n        if (newWidth < 0) {\n            newX += newWidth;\n            newWidth = Math.abs(newWidth);\n            this.flipResizeHandle('horizontal');\n        }\n        if (newHeight < 0) {\n            newY += newHeight;\n            newHeight = Math.abs(newHeight);\n            this.flipResizeHandle('vertical');\n        }\n\n        // Update the box properties\n        box.x = newX;\n        box.y = newY;\n        box.width = newWidth;\n        box.height = newHeight;\n\n        this.constrainBoxToImage(box);\n    }\n\n    flipResizeHandle(direction) {\n        const flipMap = {\n            'horizontal': {\n                'nw-resize': 'ne-resize',\n                'ne-resize': 'nw-resize',\n                'sw-resize': 'se-resize',\n                'se-resize': 'sw-resize',\n                'w-resize': 'e-resize',\n                'e-resize': 'w-resize'\n            },\n            'vertical': {\n                'nw-resize': 'sw-resize',\n                'ne-resize': 'se-resize',\n                'sw-resize': 'nw-resize',\n                'se-resize': 'ne-resize',\n                'n-resize': 's-resize',\n                's-resize': 'n-resize'\n            }\n        };\n\n        if (this.resizeHandle && flipMap[direction][this.resizeHandle.cursor]) {\n            this.resizeHandle.cursor = flipMap[direction][this.resizeHandle.cursor];\n        }\n    }\n\n    moveBox(box, newX, newY) {\n        box.x = Math.max(0, Math.min(newX, this.image.width - box.width));\n        box.y = Math.max(0, Math.min(newY, this.image.height - box.height));\n    }\n\n    constrainBoxToImage(box) {\n        box.x = Math.max(0, Math.min(box.x, this.image.width - 1));\n        box.y = Math.max(0, Math.min(box.y, this.image.height - 1));\n        box.width = Math.max(1, Math.min(box.width, this.image.width - box.x));\n        box.height = Math.max(1, Math.min(box.height, this.image.height - box.y));\n    }\n\n    draw() {\n        this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);\n        this.ctx.drawImage(this.image, 0, 0, this.canvas.width, this.canvas.height);\n\n        this.boxes.forEach(box => {\n            this.ctx.fillStyle = this.getRGBAColor(this.boxColor, this.boxOpacity);\n            this.ctx.fillRect(\n                box.x * this.scaleFactor,\n                box.y * this.scaleFactor,\n                box.width * this.scaleFactor,\n                box.height * this.scaleFactor\n            );\n\n            if (box === this.activeBox) {\n                this.drawResizeHandles(box);\n            }\n        });\n    }\n\n    drawResizeHandles(box) {\n        const handles = [\n            { x: box.x, y: box.y },\n            { x: box.x + box.width / 2, y: box.y },\n            { x: box.x + box.width, y: box.y },\n            { x: box.x + box.width, y: box.y + box.height / 2 },\n            { x: box.x + box.width, y: box.y + box.height },\n            { x: box.x + box.width / 2, y: box.y + box.height },\n            { x: box.x, y: box.y + box.height },\n            { x: box.x, y: box.y + box.height / 2 },\n        ];\n\n        handles.forEach(handle => {\n            this.ctx.fillStyle = 'white';\n            this.ctx.fillRect(\n                handle.x * this.scaleFactor - 5,\n                handle.y * this.scaleFactor - 5,\n                10, 10\n            );\n        });\n    }\n\n    getRGBAColor(color, opacity) {\n        if (color.startsWith('#')) {\n            const r = parseInt(color.slice(1, 3), 16);\n            const g = parseInt(color.slice(3, 5), 16);\n            const b = parseInt(color.slice(5, 7), 16);\n            return `rgba(${r}, ${g}, ${b}, ${opacity})`;\n        } else {\n            return color;\n        }\n    }\n\n    getScaledBoxes() {\n        return this.boxes.map(box => ({\n            x: box.x / this.image.width,\n            y: box.y / this.image.height,\n            width: box.width / this.image.width,\n            height: box.height / this.image.height\n        }));\n    }\n\n    updateHistory() {\n        if (this.boxes.length > 0) {\n            if (this.history.length === 1 || JSON.stringify(this.history[this.history.length - 1]) !== JSON.stringify(this.boxes)) {\n                this.history.push(JSON.parse(JSON.stringify(this.boxes)));\n                document.getElementById(`${this.id}-undo`).disabled = false;\n            }\n        } else if (this.history.length > 1) {\n            this.history = [[]];\n            document.getElementById(`${this.id}-undo`).disabled = true;\n        }\n    }\n\n    undoAction() {\n        if (this.history.length > 1) {\n            this.history.pop();\n            this.boxes = JSON.parse(JSON.stringify(this.history[this.history.length - 1]));\n            this.activeBox = null;\n            this.draw();\n            this.setResponse(this.getScaledBoxes());\n            this.updateRemoveButtonState();\n            if (this.history.length === 1) {\n                document.getElementById(`${this.id}-undo`).disabled = true;\n            }\n        }\n    }\n\n    setResponse(value) {\n        super.setResponse(value, value.length > 0);\n        this.showValidationError(null);\n    }\n\n    validate() {\n        // BoundingBox-specific validation\n        if (this.required && this.boxes.length === 0) {\n            return {\n                isValid: false,\n                errorMessage: 'Please draw at least one bounding box.'\n            };\n        }\n\n        // If BoundingBox-specific validation passed, call parent's validate method\n        return super.validate();\n    }\n\n    destroy() {\n        // Remove all event listeners\n        this.eventListeners.forEach(({ element, eventType, handler }) => {\n            element.removeEventListener(eventType, handler);\n        });\n        this.eventListeners = [];\n\n        // Clear the canvas\n        if (this.ctx) {\n            this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);\n        }\n\n        // Reset all state\n        this.initializeState();\n\n        // Call the parent destroy method\n        super.destroy();\n    }\n}\n\nexport default BoundingBox;"
  },
  {
    "path": "library/elements/checkBox.js",
    "content": "import Element from '../core/element.js';\n\nclass CheckBox extends Element {\n    static styleKeys = [...Element.styleKeys, 'checkboxFlexContainer', 'checkbox', 'checkboxLabel']\n\n    static selectorMap = {\n        ...Element.selectorMap,\n        checkboxFlexContainer: '.checkbox-flex-container',\n        checkbox: 'input[type=\"checkbox\"]',\n        checkboxLabel: '.checkbox-label',\n    };\n\n    static defaultStyles = {\n        checkboxFlexContainer: {\n            display: 'flex',\n            alignItems: 'center',\n            justifyContent: 'flex-start',\n            gap: '5px',\n            background: 'white',\n        },\n        checkbox: {\n            width: '20px',\n            height: '20px',\n            accentColor: 'black',\n            borderColor: 'black',\n            backgroundColor: 'transparent',\n            marginRight: '5px',\n            '@media (max-width: 650px)': {\n                width: '16px',\n                height: '16px'\n            }\n        },\n        checkboxLabel: { }\n    };\n\n    constructor({\n        id,\n        text,\n        required = true,\n        customValidation = null,\n        styles = {}\n    }) {\n        super({ id, type: 'checkbox', store_data: true, required, customValidation, styles });\n        this.text = text;\n        this.addData('text', text);\n        this.initialResponse = false;\n\n        this.elementStyleKeys = [...CheckBox.styleKeys];\n        this.selectorMap = { ...CheckBox.selectorMap };\n    }\n\n    generateHTML() {\n        return `\n            <div id=\"${this.id}-container\" class=\"checkbox-question\">\n                <div class=\"inner-container\">\n                    <div class=\"checkbox-flex-container\">\n                        <input type=\"checkbox\" id=\"${this.id}\" name=\"${this.id}\">\n                        <label for=\"${this.id}\" class=\"checkbox-label\">${this.text}</label>\n                    </div>\n                </div>\n                <div id=\"${this.id}-error\" class=\"error-message\" style=\"display: none;\"></div>\n            </div>\n        `;\n    }\n\n    attachEventListeners() {\n        const checkbox = document.getElementById(this.id);\n        this.addEventListenerWithTracking(checkbox, 'change', (e) => {\n            this.setResponse(e.target.checked);\n        });\n    }\n\n    setResponse(value) {\n        super.setResponse(Boolean(value));\n        this.showValidationError(null);\n    }\n\n    validate() {\n        // CheckBox-specific validation\n        if (this.required && this.data.response !== true) {\n            return {\n                isValid: false,\n                errorMessage: 'This checkbox is required.'\n            };\n        }\n\n        // If CheckBox-specific validation passed, call parent's validate method\n        return super.validate();\n    }\n}\n\nexport default CheckBox;"
  },
  {
    "path": "library/elements/dropdownSelect.js",
    "content": "import Element from '../core/element.js';\n\nclass DropdownSelect extends Element {\n    static styleKeys = [...Element.styleKeys, 'select', 'option'];\n\n    static selectorMap = {\n        ...Element.selectorMap,\n        select: 'select',\n        option: 'option'\n    };\n\n    static defaultStyles = {\n        select: {\n            width: '100%',\n            cursor: 'pointer',\n            padding: '12px',\n            border: '1px solid #ccc',\n            borderRadius: '8px',\n            fontSize: '1em',\n            marginBottom: '0px',\n            display: 'block',\n            appearance: 'none',\n            backgroundImage: 'url(\"data:image/svg+xml,%3Csvg xmlns=\\'http://www.w3.org/2000/svg\\' width=\\'12\\' height=\\'12\\' fill=\\'%23333\\' viewBox=\\'0 0 16 16\\'%3E%3Cpath d=\\'M7.247 11.14L2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z\\'/%3E%3C/svg%3E\")',\n            backgroundRepeat: 'no-repeat',\n            backgroundPosition: 'right 12px center',\n            backgroundSize: '12px',\n            '&:focus': {\n                borderColor: 'black',\n                outline: 'none',\n            },\n        },\n        option: {\n            padding: '8px',\n        }\n    };\n\n    constructor({\n        id,\n        text,\n        subText = '',\n        options,\n        required = true,\n        placeholder = 'Select an option',\n        customValidation = null,\n        styles = {},\n    }) {\n        super({ id, type: 'dropdown-select', store_data: true, required, customValidation, styles });\n\n        if (!Array.isArray(options) || options.length === 0) {\n            throw new Error('Options must be a non-empty array');\n        }\n\n        this.text = text;\n        this.subText = subText;\n        this.options = options;\n        this.placeholder = placeholder;\n\n        this.addData('text', text);\n        this.addData('subText', subText);\n        this.addData('options', options);\n\n        this.initialResponse = '';\n        this.elementStyleKeys = [...DropdownSelect.styleKeys];\n        this.selectorMap = { ...DropdownSelect.selectorMap };\n    }\n\n    generateHTML() {\n        const optionsHTML = this.options.map(option => \n            `<option value=\"${option}\">${option}</option>`\n        ).join('');\n\n        return `\n            <div class=\"dropdown-select-question\" id=\"${this.id}-container\">\n                <div class=\"inner-container\">\n                    <div class=\"text-container\">\n                        <label class=\"question-text\" for=\"${this.id}\">${this.text}</label>\n                        ${this.subText ? `<span class=\"question-subtext\">${this.subText}</span>` : ''}\n                    </div>\n                    <select id=\"${this.id}\" name=\"${this.id}\" ${this.required ? 'required' : ''}>\n                        <option value=\"\" disabled selected>${this.placeholder}</option>\n                        ${optionsHTML}\n                    </select>\n                </div>\n                <div id=\"${this.id}-error\" class=\"error-message\" style=\"display: none;\"></div>\n            </div>\n        `;\n    }\n\n    attachEventListeners() {\n        const select = document.getElementById(this.id);\n        this.addEventListenerWithTracking(select, 'change', this.handleChange.bind(this));\n    }\n\n    handleChange(e) {\n        const value = e.target.value;\n        this.setResponse(value);\n    }\n\n    validate() {\n        const value = this.data.response;\n\n        if (!value && this.required) {\n            return { isValid: false, errorMessage: 'Please select an option.' };\n        }\n\n        if (value && !this.options.includes(value)) {\n            return { isValid: false, errorMessage: 'Selected option is not valid.' };\n        }\n\n        return super.validate();\n    }\n}\n\nexport default DropdownSelect;"
  },
  {
    "path": "library/elements/grid.js",
    "content": "import Element from '../core/element.js';\n\nclass Grid extends Element {\n    static styleKeys = [...Element.styleKeys, 'table', 'headerRow', 'headerCell', 'rowWrapper', 'row', 'rowLabel', 'cell', 'radio'];\n\n    static selectorMap = {\n        ...Element.selectorMap,\n        table: 'table',\n        headerRow: 'thead tr',\n        headerCell: 'thead th',\n        rowWrapper: '.row-wrapper',\n        row: 'tbody tr',\n        rowLabel: 'tbody td.row-label',\n        cell: 'tbody td',\n        radio: 'input[type=\"radio\"]'\n    };\n\n    static defaultStyles = {\n        table: {\n            width: '100%',\n            borderCollapse: 'separate',\n            borderSpacing: '0 10px',\n            lineHeight: '1',\n            '@media (max-width: 650px)': {\n                fontSize: '0.9em'\n            }\n        },\n        headerRow: {},\n        headerCell: {\n            padding: '0px 16px',\n            textAlign: 'center',\n            fontWeight: 'normal',\n            '@media (max-width: 650px)': {\n                padding: '0px 12px'\n            }\n        },\n        row: {\n            backgroundColor: '#f0f0f0',\n            borderRadius: '12px',\n        },\n        rowLabel: {\n            padding: '12px 16px',\n            textAlign: 'left',\n            borderTopLeftRadius: '8px',\n            borderBottomLeftRadius: '8px',\n            '@media (max-width: 650px)': {\n                padding: '12px'\n            }\n        },\n        cell: {\n            textAlign: 'center',\n            verticalAlign: 'middle',\n        },\n        radio: {\n            appearance: 'none',\n            width: '20px',\n            height: '20px',\n            borderRadius: '50%',\n            border: '1px solid black',\n            border: '1px solid #767676',\n            outline: 'none',\n            margin: '0 auto',\n            background: 'white',\n            cursor: 'pointer',\n            verticalAlign: 'middle',\n            '&:checked': {\n                backgroundColor: 'black',\n                boxShadow: 'inset 0 0 0 3px #ffffff'\n            },\n            '@media (max-width: 650px)': {\n                width: '16px',\n                height: '16px'\n            }\n        }\n    };\n\n\n    constructor({\n        id,\n        text,\n        subText = '',\n        rows,\n        columns,\n        required = true,\n        randomizeRows = false,\n        randomizeColumns = false,\n        customValidation = null,\n        styles = {}\n    }) {\n        super({ id, type: 'grid', store_data: true, required, customValidation, styles });\n\n        if (!Array.isArray(rows) || rows.length === 0 || !Array.isArray(columns) || columns.length === 0) {\n            throw new Error('Rows and columns must be non-empty arrays');\n        }\n\n        this.text = text;\n        this.subText = subText;\n        this.rows = rows;\n        this.columns = columns;\n        this.randomizeRows = Boolean(randomizeRows);\n        this.randomizeColumns = Boolean(randomizeColumns);\n\n        this.addData('text', text);\n        this.addData('subText', subText);\n        this.addData('rows', rows);\n        this.addData('columns', columns);\n        this.addData('randomizeRows', this.randomizeRows);\n        this.addData('randomizeColumns', this.randomizeColumns);\n\n        this.initialResponse = {};\n\n        this.elementStyleKeys = [...Grid.styleKeys];\n        this.selectorMap = { ...Grid.selectorMap };\n    }\n\n    generateHTML() {\n        const rowsHTML = this.randomizeRows ? this.shuffleArray([...this.rows]) : this.rows;\n        const columnsHTML = this.randomizeColumns ? this.shuffleArray([...this.columns]) : this.columns;\n\n        const headerRow = `\n            <tr>\n                <th></th>\n                ${columnsHTML.map(column => `<th>${column}</th>`).join('')}\n            </tr>\n        `;\n\n        const bodyRows = rowsHTML.map((row, rowIndex) => `\n            <tr>\n                <td class=\"row-label\">${row}</td>\n                ${columnsHTML.map((column, colIndex) => `\n                    <td>\n                        <input type=\"radio\" id=\"${this.id}-${rowIndex}-${colIndex}\" \n                               name=\"${this.id}-${rowIndex}\" value=\"${column}\">\n                    </td>\n                `).join('')}\n            </tr>\n        `).join('');\n\n        return `\n            <div class=\"grid-question\" id=\"${this.id}-container\">\n                <div class=\"inner-container\">\n                    <div class=\"text-container\">\n                        <label class=\"question-text\">${this.text}</label>\n                        ${this.subText ? `<span class=\"question-subtext\">${this.subText}</span>` : ''}\n                    </div>\n                    <table>\n                        <thead>${headerRow}</thead>\n                        <tbody>${bodyRows}</tbody>\n                    </table>\n                </div>\n                <div id=\"${this.id}-error\" class=\"error-message\" style=\"display: none;\"></div>\n            </div>\n        `;\n    }\n\n    generateStylesheet(surveyElementStyles) {\n        const stylesheet = super.generateStylesheet(surveyElementStyles);\n        \n        // Add styles for the last cell in each row\n        const lastCellStyles = this.generateStyleForSelector(`${this.getSelectorForKey('cell')}:last-child`, {\n            borderTopRightRadius: '8px',\n            borderBottomRightRadius: '8px',\n        });\n\n        return stylesheet + '\\n' + lastCellStyles;\n    }\n\n    shuffleArray(array) {\n        return array.sort(() => Math.random() - 0.5);\n    }\n\n    attachEventListeners() {\n        const container = document.getElementById(`${this.id}-container`);\n        this.addEventListenerWithTracking(container, 'change', this.handleChange.bind(this));\n    }\n\n    handleChange(e) {\n        if (e.target.type === 'radio') {\n            this.updateResponse();\n        }\n    }\n\n    updateResponse() {\n        const container = document.getElementById(`${this.id}-container`);\n        const responses = Object.fromEntries(\n            this.rows.map((row, index) => {\n                const selectedRadio = container.querySelector(`input[name=\"${this.id}-${index}\"]:checked`);\n                return [row, selectedRadio ? selectedRadio.value : null];\n            })\n        );\n        this.setResponse(responses);\n    }\n\n    setResponse(value) {\n        super.setResponse(value);\n        this.showValidationError(null);\n    }\n\n    validate() {\n        // Grid-specific validation\n        const unansweredRows = this.rows.filter(row => !this.data.response[row]);\n\n        if (unansweredRows.length > 0) {\n            return {\n                isValid: false,\n                errorMessage: `Please provide a response for all rows. Missing: ${unansweredRows.join(', ')}`\n            };\n        }\n\n        // If Grid-specific validation passed, call parent's validate method\n        return super.validate();\n    }\n}\n\nexport default Grid;"
  },
  {
    "path": "library/elements/multiSelect.js",
    "content": "import Element from '../core/element.js';\n\nclass MultiSelect extends Element {\n    static styleKeys = [...Element.styleKeys, 'optionsContainer', 'option', 'checkbox', 'label'];\n\n    static selectorMap = {\n        ...Element.selectorMap,\n        optionsContainer: '.options-container',\n        option: '.option',\n        checkbox: 'input[type=\"checkbox\"]',\n        label: 'label'\n    };\n\n    static defaultStyles = {\n        optionsContainer: {\n            display: 'flex',\n            flexDirection: 'column',\n            gap: '10px',\n            lineHeight: '1',\n        },\n        option: {\n            backgroundColor: '#f0f0f0',\n            borderRadius: '8px',\n            padding: '12px 16px',\n            display: 'flex',\n            alignItems: 'center',\n            cursor: 'pointer',\n            '&:hover': {\n                backgroundColor: '#e0e0e0',\n                '@media (max-width: 650px)': {\n                    backgroundColor: '#f0f0f0'\n                }\n            },\n            '@media (max-width: 650px)': {\n                padding: '12px'\n            }\n        },\n\n        checkbox: {\n            width: '20px',\n            height: '20px',\n            accentColor: 'black',\n            borderColor: 'black',\n            backgroundColor: 'transparent',\n            margin: '0',\n            marginRight: '10px',\n            '@media (max-width: 650px)': {\n                width: '16px',\n                height: '16px'\n            }\n        },\n        label: {\n            cursor: 'pointer',\n            flexGrow: 1\n        }\n    };\n\n    constructor({\n        id,\n        text,\n        subText = '',\n        options,\n        required = true,\n        randomize = false,\n        minSelected = 0,\n        maxSelected = null,\n        customValidation = null,\n        styles = {}\n    }) {\n        super({ id, type: 'multi-select', store_data: true, required, customValidation, styles });\n\n        if (!Array.isArray(options) || options.length === 0) {\n            throw new Error('Options must be a non-empty array');\n        }\n        if (minSelected < 0 || (maxSelected !== null && minSelected > maxSelected)) {\n            throw new Error('Invalid minSelected or maxSelected values');\n        }\n\n        this.text = text;\n        this.subText = subText;\n        this.options = options;\n        this.randomize = Boolean(randomize);\n        this.minSelected = minSelected;\n        this.maxSelected = maxSelected;\n\n        this.addData('text', text);\n        this.addData('subText', subText);\n        this.addData('options', options);\n        this.addData('randomize', this.randomize);\n        this.addData('minSelected', minSelected);\n        this.addData('maxSelected', maxSelected);\n        this.initialResponse = [];\n\n        this.elementStyleKeys = [...MultiSelect.styleKeys];\n        this.selectorMap = { ...MultiSelect.selectorMap };\n    }\n\n    generateHTML() {\n        let optionsHTML = this.randomize ? this.shuffleArray([...this.options]) : this.options;\n\n        const optionsString = optionsHTML.map((option, index) => `\n            <div class=\"option\" data-value=\"${option}\">\n                <input type=\"checkbox\" id=\"${this.id}-${index}\" name=\"${this.id}\" value=\"${option}\">\n                <label for=\"${this.id}-${index}\">${option}</label>\n            </div>\n        `).join('');\n\n        return `\n            <div class=\"multi-select-question\" id=\"${this.id}-container\">\n                <div class=\"inner-container\">\n                    <div class=\"text-container\">\n                        <label class=\"question-text\">${this.text}</label>\n                        ${this.subText ? `<span class=\"question-subtext\">${this.subText}</span>` : ''}\n                    </div>\n                    <div class=\"options-container\">\n                        ${optionsString}\n                    </div>\n                </div>\n                <div id=\"${this.id}-error\" class=\"error-message\" style=\"display: none;\"></div>\n            </div>\n        `;\n    }\n    attachEventListeners() {\n        const container = document.getElementById(`${this.id}-container`);\n        this.addEventListenerWithTracking(container, 'click', this.handleClick.bind(this));\n    }\n\n    handleClick(e) {\n        const optionDiv = e.target.closest('.option');\n        if (optionDiv) {\n            const checkbox = optionDiv.querySelector('input[type=\"checkbox\"]');\n            checkbox.checked = !checkbox.checked;\n            this.updateResponse();\n        }\n    }\n\n    updateResponse() {\n        const container = document.getElementById(`${this.id}-container`);\n        const checkedBoxes = container.querySelectorAll(`input[name=\"${this.id}\"]:checked`);\n        const selectedOptions = Array.from(checkedBoxes).map(cb => cb.value);\n        this.setResponse(selectedOptions);\n    }\n\n    setResponse(value) {\n        super.setResponse(value);\n        this.showValidationError(null);\n    }\n\n    validate() {\n        const selectedCount = this.data.response ? this.data.response.length : 0;\n\n        if (this.minSelected > 0 && selectedCount < this.minSelected) {\n            return { isValid: false, errorMessage: `Please select at least ${this.minSelected} option(s).` };\n        }\n\n        if (this.maxSelected !== null && selectedCount > this.maxSelected) {\n            return { isValid: false, errorMessage: `Please select no more than ${this.maxSelected} option(s).` };\n        }\n\n        return super.validate();\n    }\n\n    shuffleArray(array) {\n        for (let i = array.length - 1; i > 0; i--) {\n            const j = Math.floor(Math.random() * (i + 1));\n            [array[i], array[j]] = [array[j], array[i]];\n        }\n        return array;\n    }\n}\n\nexport default MultiSelect;"
  },
  {
    "path": "library/elements/numberEntry.js",
    "content": "import Element from '../core/element.js';\n\nclass NumberEntry extends Element {\n    static styleKeys = [...Element.styleKeys, 'input', 'unit'];\n\n    static selectorMap = {\n        ...Element.selectorMap,\n        input: 'input[type=\"number\"]',\n        unit: '.unit-label'\n    };\n\n    static defaultStyles = {\n        input: {\n            width: '80px',\n            padding: '8px',\n            border: '1px solid #ccc',\n            borderRadius: '4px',\n            fontSize: '1em',\n        },\n        unit: {\n            marginLeft: '5px',\n            fontSize: '0.9em',\n        }\n    };\n\n    constructor({\n        id,\n        text,\n        subText = '',\n        min = null,\n        max = null,\n        step = 1,\n        unit = '',\n        required = true,\n        customValidation = null,\n        styles = {}\n    }) {\n        super({ id, type: 'number-entry', store_data: true, required, customValidation, styles });\n        this.text = text;\n        this.subText = subText;\n        this.min = min;\n        this.max = max;\n        this.step = step;\n        this.unit = unit;\n\n        this.addData('text', text);\n        this.addData('subText', subText);\n        this.addData('min', min);\n        this.addData('max', max);\n        this.addData('step', step);\n        this.addData('unit', unit);\n        this.initialResponse = '';\n\n        this.elementStyleKeys = [...NumberEntry.styleKeys];\n        this.selectorMap = { ...NumberEntry.selectorMap };\n    }\n\n    generateHTML() {\n        const minAttr = this.min !== null ? `min=\"${this.min}\"` : '';\n        const maxAttr = this.max !== null ? `max=\"${this.max}\"` : '';\n\n        return `\n            <div class=\"number-entry-question\" id=\"${this.id}-container\">\n                <div class=\"inner-container\">\n                    <div class=\"text-container\">\n                        <label class=\"question-text\" for=\"${this.id}\">${this.text}</label>\n                        ${this.subText ? `<span class=\"question-subtext\">${this.subText}</span>` : ''}\n                    </div>\n                    <div>\n                        <input \n                            type=\"number\" \n                            id=\"${this.id}\" \n                            name=\"${this.id}\" \n                            ${minAttr}\n                            ${maxAttr}\n                            step=\"${this.step}\"\n                            ${this.required ? 'required' : ''}\n                        >\n                        ${this.unit ? `<span class=\"unit-label\">${this.unit}</span>` : ''}\n                    </div>\n                </div>\n                <div id=\"${this.id}-error\" class=\"error-message\" style=\"display: none;\"></div>\n            </div>\n        `;\n    }\n\n    attachEventListeners() {\n        const input = document.getElementById(this.id);\n        this.addEventListenerWithTracking(input, 'input', (e) => {\n            this.setResponse(e.target.value);\n        });\n    }\n\n    setResponse(value) {\n        super.setResponse(value);\n        this.addData('numericValue', value !== '' ? parseFloat(value) : null);\n        this.showValidationError(null);\n    }\n\n    validate() {\n        const value = this.data.response;\n\n        // NumberEntry-specific validation\n        if (value !== '') {\n            const numValue = parseFloat(value);\n\n            if (isNaN(numValue)) {\n                return { isValid: false, errorMessage: 'Please enter a valid number.' };\n            }\n\n            if (this.min !== null && numValue < this.min) {\n                return { isValid: false, errorMessage: `Please enter a number greater than or equal to ${this.min}.` };\n            }\n\n            if (this.max !== null && numValue > this.max) {\n                return { isValid: false, errorMessage: `Please enter a number less than or equal to ${this.max}.` };\n            }\n        }\n\n        // If NumberEntry-specific validation passes, call parent's validate method\n        return super.validate();\n    }\n}\n\nexport default NumberEntry;"
  },
  {
    "path": "library/elements/numberScale.js",
    "content": "import Element from '../core/element.js';\n\nclass NumberScale extends Element {\n    static styleKeys = [...Element.styleKeys, 'scaleContainer', 'scaleItem', 'scaleInput', 'scaleCircle', 'scaleNumber', 'scaleLabels'];\n\n    static selectorMap = {\n        ...Element.selectorMap,\n        scaleContainer: '.scale-container',\n        scaleItem: '.scale-item',\n        scaleInput: 'input[type=\"radio\"]',\n        scaleCircle: '.scale-circle',\n        scaleNumber: '.scale-number',\n        scaleLabels: '.scale-labels'\n    };\n\n    static defaultStyles = {\n        scaleOuterContainer: {},\n        scaleContainer: {\n            display: 'grid',\n            gridTemplateColumns: `repeat(auto-fit, minmax(36px, 1fr))`,\n            gridGap: '5px',\n            rowGap: '5px',\n        },\n        scaleItem: {\n            display: 'flex',\n            flexDirection: 'column',\n            alignItems: 'center',\n            position: 'relative',\n            height: '42px',\n        },\n        scaleInput: {\n            position: 'absolute',\n            opacity: '0',\n            cursor: 'pointer',\n            height: '0',\n            width: '0',\n        },\n        scaleCircle: {\n            width: '100%',\n            height: '42px',\n            flexGrow: '1',\n            borderRadius: '12px',\n            display: 'flex',\n            justifyContent: 'center',\n            alignItems: 'center',\n            cursor: 'pointer',\n            backgroundColor: '#f0f0f0',\n            '&:hover': {\n                backgroundColor: '#e0e0e0',\n            },\n        },\n        scaleNumber: {\n            fontSize: '16px',\n            textAlign: 'center',\n            color: '#333',\n        },\n        scaleLabels: {\n            marginTop: '5px',\n            fontSize: '12px',\n            color: '#888',\n            display: 'flex',\n            justifyContent: 'space-between',\n        }\n    };\n\n    constructor({\n        id,\n        text,\n        subText = '',\n        required = true,\n        min = 1,\n        max = 5,\n        minLabel = '',\n        maxLabel = '',\n        customValidation = null,\n        styles = {}\n    }) {\n        super({ id, type: 'number-scale', store_data: true, required, customValidation, styles });\n\n        if (min >= max) {\n            throw new Error('Min value must be less than max value');\n        }\n\n        this.text = text;\n        this.subText = subText;\n        this.min = min;\n        this.max = max;\n        this.minLabel = minLabel;\n        this.maxLabel = maxLabel;\n        this.selectedBackgroundColor = '#333';\n        this.selectedTextColor = '#fff';\n\n        this.addData('text', text);\n        this.addData('subText', subText);\n        this.addData('min', min);\n        this.addData('max', max);\n        this.addData('minLabel', minLabel);\n        this.addData('maxLabel', maxLabel);\n\n        this.initialResponse = null;\n\n        this.elementStyleKeys = [...NumberScale.styleKeys];\n        this.selectorMap = { ...NumberScale.selectorMap };\n    }\n\n    generateHTML() {\n        const scaleItems = [];\n        for (let i = this.min; i <= this.max; i++) {\n            scaleItems.push(`\n                <div class=\"scale-item\">\n                    <input type=\"radio\" id=\"${this.id}-${i}\" name=\"${this.id}\" value=\"${i}\">\n                    <label for=\"${this.id}-${i}\" class=\"scale-circle\">\n                        <span class=\"scale-number\">${i}</span>\n                    </label>\n                </div>\n            `);\n        }\n\n        const showLabels = this.minLabel || this.maxLabel;\n\n        return `\n            <div class=\"ordered-scale-question\" id=\"${this.id}-container\">\n                <div class=\"inner-container\">\n                    <div class=\"text-container\">\n                        <label class=\"question-text\" for=\"${this.id}-${this.min}\">${this.text}</label>\n                        ${this.subText ? `<span class=\"question-subtext\">${this.subText}</span>` : ''}\n                    </div>\n                    <div class=\"scale-container\">\n                        ${scaleItems.join('')}\n                    </div>\n                    ${showLabels ? `\n                    <div class=\"scale-labels\">\n                        <div>${this.min} - ${this.minLabel}</div>\n                        <div>${this.max} - ${this.maxLabel}</div>\n                    </div>\n                    ` : ''}\n                </div>\n                <div id=\"${this.id}-error\" class=\"error-message\" style=\"display: none;\"></div>\n            </div>\n        `;\n    }\n\n    attachEventListeners() {\n        const container = document.getElementById(`${this.id}-container`);\n        this.addEventListenerWithTracking(container, 'change', this.handleChange.bind(this));\n        this.updateSelectedStyles();\n    }\n\n    handleChange(e) {\n        if (e.target.type === 'radio') {\n            this.setResponse(parseInt(e.target.value, 10));\n            this.updateSelectedStyles();\n        }\n    }\n\n    updateSelectedStyles() {\n        const container = document.getElementById(`${this.id}-container`);\n        const circles = container.querySelectorAll('.scale-circle');\n        const selectedInput = container.querySelector('input:checked');\n\n        circles.forEach(circle => {\n            // Remove inline styles for all circles\n            circle.style.removeProperty('background-color');\n            circle.querySelector('.scale-number').style.removeProperty('color');\n        });\n\n        if (selectedInput) {\n            const selectedCircle = selectedInput.nextElementSibling;\n            selectedCircle.style.backgroundColor = this.selectedBackgroundColor;\n            selectedCircle.querySelector('.scale-number').style.color = this.selectedTextColor;\n        }\n    }\n\n    setResponse(value) {\n        super.setResponse(value);\n        this.showValidationError(null);\n        this.updateSelectedStyles();\n    }\n\n    validate() {\n        const response = this.data.response;\n\n        if (response === null || isNaN(response)) {\n            return { isValid: false, errorMessage: 'Please select a rating.' };\n        }\n\n        if (response < this.min || response > this.max) {\n            return { isValid: false, errorMessage: `Please select a rating between ${this.min} and ${this.max}.` };\n        }\n\n        return super.validate();\n    }\n}\n\nexport default NumberScale;"
  },
  {
    "path": "library/elements/openEnd.js",
    "content": "import Element from '../core/element.js';\n\nclass OpenEnd extends Element {\n    static styleKeys = [...Element.styleKeys, 'textarea'];\n\n    static selectorMap = {\n        ...Element.selectorMap,\n        textarea: 'textarea'\n    };\n\n    static defaultStyles = {\n        textarea: {\n            width: '100%',\n            padding: '12px',\n            border: '1px solid #ccc',\n            borderRadius: '4px',\n            resize: 'vertical',\n            fontFamily: 'Arial, sans-serif',\n            fontSize: '1em',\n            marginBottom: '0px',\n            display: 'block',\n            '&:focus': {\n                borderColor: 'black',\n                outline: 'none',\n            },\n        }\n    };\n\n    constructor({\n        id,\n        text,\n        subText = '',\n        minLength = 0,\n        maxLength = 10000,\n        rows = 2,\n        placeholder = '',\n        required = true,\n        includeAlias = true,\n        customValidation = null,\n        styles = {}\n    }) {\n        super({ id, type: 'open-end', store_data: true, required, customValidation, styles });\n\n        if (minLength < 0 || maxLength < minLength) {\n            throw new Error('Invalid length constraints');\n        }\n\n        this.text = text;\n        this.subText = subText;\n        this.minLength = minLength;\n        this.maxLength = maxLength;\n        this.rows = rows;\n        this.placeholder = placeholder;\n        this.includeAlias = Boolean(includeAlias);\n        this.aliasMaxLength = 10000;\n        this.aliasTypingHistory = [];\n        this.aliasStartTime = null;\n        this.aliasTextOverLength = false;\n\n        this.addData('text', text);\n        this.addData('subText', subText);\n        this.addData('minLength', minLength);\n        this.addData('maxLength', maxLength);\n        this.addData('includeAlias', this.includeAlias);\n        this.addData('aliasMaxLength', this.aliasMaxLength);\n        this.addData('aliasTypingHistory', this.aliasTypingHistory);\n        this.initialResponse = '';\n\n        this.elementStyleKeys = [...OpenEnd.styleKeys];\n        this.selectorMap = { ...OpenEnd.selectorMap };\n    }\n\n    generateHTML() {\n        return `\n            <div class=\"open-end-question\" id=\"${this.id}-container\">\n                <div class=\"inner-container\">\n                    <div class=\"text-container\">\n                        <label class=\"question-text\" for=\"${this.id}\">${this.text}</label>\n                        ${this.subText ? `<span class=\"question-subtext\">${this.subText}</span>` : ''}\n                    </div>\n                    <textarea \n                        id=\"${this.id}\" \n                        name=\"${this.id}\" \n                        minlength=\"${this.minLength}\" \n                        maxlength=\"${this.maxLength}\" \n                        placeholder=\"${this.placeholder}\"\n                        rows=\"${this.rows}\"\n                        ${this.required ? 'required' : ''}\n                    ></textarea>\n                </div>\n                <div id=\"${this.id}-error\" class=\"error-message\" style=\"display: none;\"></div>\n            </div>\n        `;\n    }\n\n    attachEventListeners() {\n        const textarea = document.getElementById(this.id);\n        this.addEventListenerWithTracking(textarea, 'input', this.handleInput.bind(this));\n        this.addEventListenerWithTracking(textarea, 'copy', this.handleCopy.bind(this));\n    }\n\n    handleInput(e) {\n        const value = e.target.value;\n        this.setResponse(value);\n        if (this.includeAlias && !this.aliasTextOverLength) {\n            const t = this.initializeAliasStartTime();\n            const newHistory = { s: value, t };\n            this.updateAliasTypingHistory(newHistory);\n        }\n    }\n\n    handleCopy(e) {\n        if (this.includeAlias && !this.aliasTextOverLength) {\n            const t = this.initializeAliasStartTime();\n            const newHistory = {\n                s: e.target.value,\n                t,\n                o: 'c',\n                ct: window.getSelection().toString(),\n            };\n            this.updateAliasTypingHistory(newHistory);\n        }\n    }\n\n    updateAliasTypingHistory(newHistory) {\n        const lengthOfHistory = JSON.stringify([...this.aliasTypingHistory, newHistory]).length;\n        if (lengthOfHistory > this.aliasMaxLength) {\n            this.aliasTextOverLength = true;\n            return;\n        }\n        this.aliasTypingHistory.push(newHistory);\n    }\n\n    initializeAliasStartTime() {\n        if (this.aliasStartTime) return Date.now() - this.aliasStartTime;\n        this.aliasStartTime = Date.now();\n        return 0;\n    }\n\n    setResponse(value) {\n        super.setResponse(value);\n        this.addData('responseLength', value.length);\n        this.showValidationError(null);\n    }\n\n    validate() {\n        // OpenEnd-specific validation\n        const value = this.data.response || '';\n\n        if (value.length < this.minLength) {\n            return { isValid: false, errorMessage: `Please enter at least ${this.minLength} characters.` };\n        }\n        if (value.length > this.maxLength) {\n            return { isValid: false, errorMessage: `Please enter no more than ${this.maxLength} characters.` };\n        }\n\n        // If OpenEnd-specific validation passes, call parent's validate method\n        return super.validate();\n    }\n\n    destroy() {\n        // Perform any OpenEnd-specific cleanup here\n        this.aliasTypingHistory = [];\n        this.aliasStartTime = null;\n        this.aliasTextOverLength = false;\n\n        // Then call the parent destroy method\n        super.destroy();\n    }\n}\n\nexport default OpenEnd;"
  },
  {
    "path": "library/elements/singleSelect.js",
    "content": "import Element from '../core/element.js';\n\nclass SingleSelect extends Element {\n    static styleKeys = [...Element.styleKeys, 'optionsContainer', 'option', 'radio', 'label', 'otherInput'];\n\n    static selectorMap = {\n        ...Element.selectorMap,\n        optionsContainer: '.options-container',\n        option: '.option',\n        radio: 'input[type=\"radio\"]',\n        label: 'label',\n        otherInput: '.other-input'\n    };\n\n    static defaultStyles = {\n        optionsContainer: {\n            display: 'flex',\n            flexDirection: 'column',\n            gap: '10px',\n            lineHeight: '1',\n        },\n        option: {\n            backgroundColor: '#f0f0f0',\n            borderRadius: '8px',\n            padding: '12px 16px',\n            display: 'flex',\n            alignItems: 'center',\n            cursor: 'pointer',\n            '&:hover': {\n                backgroundColor: '#e0e0e0',\n            },\n            '@media (max-width: 650px)': {\n                padding: '12px'\n            }\n        },\n        radio: {\n            appearance: 'none',\n            width: '20px',\n            height: '20px',\n            borderRadius: '50%',\n            border: '1px solid #767676',\n            background: 'white',\n            outline: 'none',\n            margin: 'auto',\n            marginRight: '10px',\n            cursor: 'pointer',\n            verticalAlign: 'middle',\n            '&:checked': {\n                backgroundColor: 'black',\n                boxShadow: 'inset 0 0 0 3px #ffffff'\n            },\n            '@media (max-width: 650px)': {\n                width: '16px',\n                height: '16px'\n            }\n        },\n        label: {\n            cursor: 'pointer',\n            flexGrow: 1\n        },\n        otherInput: {\n            marginTop: '0px',\n            fontSize: '16px',\n            padding: '12px',\n            borderRadius: '8px',\n            border: '1px solid #ccc',\n        }\n    };\n\n    constructor({\n        id,\n        text,\n        subText = '',\n        options,\n        required = true,\n        randomize = false,\n        allowOther = false,\n        otherText = 'Other (please specify)',\n        styles = {},\n        customValidation = null\n    }) {\n        super({ id, type: 'single-select', store_data: true, required, styles, customValidation });\n\n        if (!Array.isArray(options) || options.length === 0) {\n            throw new Error('Options must be a non-empty array');\n        }\n\n        this.text = text;\n        this.subText = subText;\n        this.options = options;\n        this.randomize = Boolean(randomize);\n        this.allowOther = Boolean(allowOther);\n        this.otherText = otherText;\n\n        this.addData('text', text);\n        this.addData('subText', subText);\n        this.addData('options', options);\n        this.addData('randomize', this.randomize);\n        this.addData('allowOther', this.allowOther);\n\n        this.initialResponse = '';\n        this.elementStyleKeys = [...SingleSelect.styleKeys];\n        this.selectorMap = { ...SingleSelect.selectorMap };\n    }\n\n    generateHTML() {\n        let optionsHTML = this.randomize ? this.shuffleArray([...this.options]) : this.options;\n\n        const optionsString = optionsHTML.map((option, index) => this.generateOptionHTML(option, index)).join('');\n\n        const otherOptionHTML = this.allowOther ? this.generateOtherOptionHTML() : '';\n\n        return `\n            <div class=\"single-select-question\" id=\"${this.id}-container\">\n                <div class=\"inner-container\">\n                    <div class=\"text-container\">\n                        <label class=\"question-text\">${this.text}</label>\n                        ${this.subText ? `<span class=\"question-subtext\">${this.subText}</span>` : ''}\n                    </div>\n                    <div class=\"options-container\">\n                        ${optionsString}\n                        ${otherOptionHTML}\n                    </div>\n                </div>\n                <div id=\"${this.id}-error\" class=\"error-message\" style=\"display: none;\"></div>\n            </div>\n        `;\n    }\n\n    generateOptionHTML(option, index) {\n        return `\n            <div class=\"option\" data-value=\"${option}\">\n                <input type=\"radio\" id=\"${this.id}-${index}\" name=\"${this.id}\" value=\"${option}\">\n                <label for=\"${this.id}-${index}\">${option}</label>\n            </div>\n        `;\n    }\n\n    generateOtherOptionHTML() {\n        return `\n            <div class=\"option\" data-value=\"other\">\n                <input type=\"radio\" id=\"${this.id}-other\" name=\"${this.id}\" value=\"other\">\n                <label for=\"${this.id}-other\">${this.otherText}</label>\n            </div>\n            <input type=\"text\" class=\"other-input\" id=\"${this.id}-other-input\" style=\"display: none;\">\n        `;\n    }\n\n    attachEventListeners() {\n        const container = document.getElementById(`${this.id}-container`);\n        this.addEventListenerWithTracking(container, 'click', this.handleClick.bind(this));\n        \n        if (this.allowOther) {\n            const otherInput = document.getElementById(`${this.id}-other-input`);\n            this.addEventListenerWithTracking(otherInput, 'input', this.handleOtherInput.bind(this));\n        }\n    }\n\n    handleClick(e) {\n        const optionDiv = e.target.closest('.option');\n        if (optionDiv) {\n            const radio = optionDiv.querySelector('input[type=\"radio\"]');\n            radio.checked = true;\n            const selectedValue = radio.value;\n\n            if (this.allowOther) {\n                const otherInput = document.getElementById(`${this.id}-other-input`);\n                if (selectedValue === 'other') {\n                    otherInput.style.display = 'block';\n                    this.setResponse({ selected: 'other', otherValue: otherInput.value });\n                } else {\n                    otherInput.style.display = 'none';\n                    otherInput.value = '';\n                    this.setResponse(selectedValue);\n                }\n            } else {\n                this.setResponse(selectedValue);\n            }\n        }\n    }\n\n    handleOtherInput(e) {\n        const otherValue = e.target.value;\n        this.setResponse({ selected: 'other', otherValue: otherValue });\n    }\n\n    setResponse(value) {\n        super.setResponse(value);\n        this.showValidationError(null);\n    }\n\n    validate() {\n        const value = this.data.response;\n\n        if (!value && this.required) {\n            return { isValid: false, errorMessage: 'Please select an option.' };\n        }\n\n        if (this.required && this.allowOther) {\n            if (typeof value === 'object' && value.selected === 'other') {\n                if (!value.otherValue || !value.otherValue.trim()) {\n                    return { isValid: false, errorMessage: 'Please specify the other option.' };\n                }\n            }\n        }\n\n        if (typeof value === 'string' && !this.options.includes(value) && value !== 'other') {\n            return { isValid: false, errorMessage: 'Selected option is not valid.' };\n        }\n\n        return super.validate();\n    }\n\n    shuffleArray(array) {\n        for (let i = array.length - 1; i > 0; i--) {\n            const j = Math.floor(Math.random() * (i + 1));\n            [array[i], array[j]] = [array[j], array[i]];\n        }\n        return array;\n    }\n}\n\nexport default SingleSelect;"
  },
  {
    "path": "library/elements/textInput.js",
    "content": "import Element from '../core/element.js';\n\nclass TextInput extends Element {\n    static styleKeys = [...Element.styleKeys, 'input'];\n\n    static selectorMap = {\n        ...Element.selectorMap,\n        input: 'input[type=\"text\"]'\n    };\n\n    static defaultStyles = {\n        input: {\n            width: '100%',\n            padding: '12px',\n            border: '1px solid #ccc',\n            borderRadius: '4px',\n            fontFamily: 'Arial, sans-serif',\n            fontSize: '1em',\n            marginBottom: '0px',\n            display: 'block',\n            // Focus\n            '&:focus': {\n                borderColor: 'black',\n                outline: 'none',\n            },\n        }\n    };\n\n    constructor({\n        id,\n        text,\n        subText = '',\n        minLength = 0,\n        maxLength = 255,\n        placeholder = '',\n        required = true,\n        customValidation = null,\n        styles = {},\n    }) {\n        super({ id, type: 'text-input', store_data: true, required, customValidation, styles });\n\n        if (minLength < 0 || maxLength < minLength) {\n            throw new Error('Invalid length constraints');\n        }\n\n        this.text = text;\n        this.subText = subText;\n        this.minLength = minLength;\n        this.maxLength = maxLength;\n        this.placeholder = placeholder;\n\n        this.addData('text', text);\n        this.addData('subText', subText);\n        this.addData('minLength', minLength);\n        this.addData('maxLength', maxLength);\n\n        this.initialResponse = '';\n        this.elementStyleKeys = [...TextInput.styleKeys];\n        this.selectorMap = { ...TextInput.selectorMap };\n    }\n\n    generateHTML() {\n        return `\n            <div class=\"text-input-question\" id=\"${this.id}-container\">\n                <div class=\"inner-container\">\n                    <div class=\"text-container\">\n                        <label class=\"question-text\" for=\"${this.id}\">${this.text}</label>\n                        ${this.subText ? `<span class=\"question-subtext\">${this.subText}</span>` : ''}\n                    </div>\n                    <input \n                        type=\"text\"\n                        id=\"${this.id}\" \n                        name=\"${this.id}\" \n                        minlength=\"${this.minLength}\" \n                        maxlength=\"${this.maxLength}\" \n                        placeholder=\"${this.placeholder}\"\n                        ${this.required ? 'required' : ''}\n                    >\n                </div>\n                <div id=\"${this.id}-error\" class=\"error-message\" style=\"display: none;\"></div>\n            </div>\n        `;\n    }\n\n    attachEventListeners() {\n        const input = document.getElementById(this.id);\n        this.addEventListenerWithTracking(input, 'input', this.handleInput.bind(this));\n    }\n\n    handleInput(e) {\n        const value = e.target.value;\n        this.setResponse(value);\n    }\n\n    setResponse(value) {\n        super.setResponse(value);\n        this.addData('responseLength', value.length);\n        this.showValidationError(null);\n    }\n\n    validate() {\n        const value = this.data.response || '';\n\n        // TextInput-specific validation\n        if (value.length < this.minLength) {\n            return { isValid: false, errorMessage: `Please enter at least ${this.minLength} characters.` };\n        }\n        if (value.length > this.maxLength) {\n            return { isValid: false, errorMessage: `Please enter no more than ${this.maxLength} characters.` };\n        }\n\n        // If TextInput-specific validation passed, call parent's validate method\n        return super.validate();\n    }\n}\n\nexport default TextInput;"
  },
  {
    "path": "library/plugins/pageHTML.js",
    "content": "import Plugin from '../core/plugin.js';\n\nclass PageHTML extends Plugin {\n    constructor({ content, targetId = 'survey-container', position = 'top', styles = {} }) {\n        super({ targetId, position, styles });\n        \n        if (typeof content !== 'string' || content.trim() === '') {\n            throw new Error('Content must be a non-empty string');\n        }\n        \n        this.content = content;\n    }\n\n    generateContent() {\n        return this.content;\n    }\n\n    initialize(survey) {\n        super.initialize(survey);\n    }\n\n    beforePageRender() {\n        // This method is intentionally left empty\n    }\n\n    beforeSurveyFinish() {\n        // This method is intentionally left empty\n    }\n\n    afterPageRender() {\n        // This method is intentionally left empty\n    }\n\n    updateContent(newContent) {\n        if (typeof newContent !== 'string' || newContent.trim() === '') {\n            throw new Error('New content must be a non-empty string');\n        }\n        this.content = newContent;\n        const pluginElement = document.getElementById(this.pluginId);\n        if (pluginElement) {\n            pluginElement.innerHTML = newContent;\n        }\n    }\n}\n\nexport default PageHTML;"
  },
  {
    "path": "library/plugins/progressBar.js",
    "content": "import Plugin from '../core/plugin.js';\n\nclass ProgressBar extends Plugin {\n    static styleKeys = ['root', 'container', 'bar', 'text'];\n\n    static defaultStyles = {\n        root: {\n            marginBottom: '30px',\n            display: 'flex',\n            alignItems: 'center',\n            gap: '15px',\n        },\n        container: {\n            flex: '1',\n            backgroundColor: '#f0f0f0',\n            borderRadius: '5px',\n            overflow: 'hidden',\n            height: '18px',\n        },\n        bar: {\n            width: '0',\n            height: '100%',\n            backgroundColor: '#333',\n            transition: 'width 0.3s ease-in-out',\n        },\n        text: {\n            textAlign: 'right',\n            padding: '5px 0',\n            fontSize: '14px',\n        }\n    };\n\n    constructor({\n        maxPages,\n        currentPage = -1,\n        includeProgressText = true,\n        includeProgressBar = true,\n        progressAsPercentage = true,\n        targetId = 'survey-container',\n        position = 'top',\n        styles = {}\n    }) {\n        super({ targetId, position, styles: ProgressBar.mergeStyles(ProgressBar.defaultStyles, styles) });\n        \n        if (typeof maxPages !== 'number' || maxPages <= 0) {\n            throw new Error('maxPages must be a positive number');\n        }\n\n        this.currentPage = currentPage;\n        this.maxPages = maxPages;\n        this.includeProgressText = Boolean(includeProgressText);\n        this.includeProgressBar = Boolean(includeProgressBar);\n        this.progressAsPercentage = Boolean(progressAsPercentage);\n    }\n\n    static mergeStyles(defaultStyles, customStyles) {\n        const mergedStyles = { ...defaultStyles };\n        for (const key in customStyles) {\n            if (mergedStyles.hasOwnProperty(key)) {\n                mergedStyles[key] = { ...mergedStyles[key], ...customStyles[key] };\n            }\n        }\n        return mergedStyles;\n    }\n\n    generateContent() {\n        return `\n            <div id=\"${this.pluginId}-progress\">\n                ${this.includeProgressBar ? `<div id=\"${this.pluginId}-progress-container\"><div id=\"${this.pluginId}-progress-bar\"></div></div>` : ''}\n                ${this.includeProgressText ? `<div id=\"${this.pluginId}-progress-text\"></div>` : ''}\n            </div>\n        `;\n    }\n\n    initialize(survey) {\n        super.initialize(survey);\n        this.applyStyles();\n        this.updateProgress();\n    }\n\n    applyStyles() {\n        const styleElement = document.createElement('style');\n        styleElement.textContent = this.generateStylesheet();\n        document.head.appendChild(styleElement);\n    }\n\n    generateStylesheet() {\n        return ProgressBar.styleKeys.map(key => \n            this.generateStyleForSelector(this.getSelectorForKey(key), this.styles[key])\n        ).join('\\n');\n    }\n\n    getSelectorForKey(key) {\n        const selectorMap = {\n            root: `#${this.pluginId}-progress`,\n            container: `#${this.pluginId}-progress-container`,\n            bar: `#${this.pluginId}-progress-bar`,\n            text: `#${this.pluginId}-progress-text`\n        };\n        return selectorMap[key] || '';\n    }\n\n    generateStyleForSelector(selector, rules) {\n        if (!rules || typeof rules !== 'object') return '';\n        const styleString = Object.entries(rules)\n            .map(([key, value]) => `${this.camelToKebab(key)}: ${value};`)\n            .join(' ');\n        return `${selector} { ${styleString} }`;\n    }\n\n    camelToKebab(string) {\n        return string.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, '$1-$2').toLowerCase();\n    }\n\n    beforePageRender() {\n        this.currentPage++;\n        this.updateProgress();\n    }\n\n    updateProgress() {\n        this.updateProgressBar();\n        this.updateProgressText();\n    }\n\n    afterPageRender() {\n        // This method is intentionally left empty\n    }\n\n    updateProgressBar() {\n        if (!this.includeProgressBar) return;\n\n        const progressBar = document.getElementById(`${this.pluginId}-progress-bar`);\n        if (progressBar) {\n            const progressPercentage = (this.currentPage / this.maxPages) * 100;\n            progressBar.style.width = `${progressPercentage}%`;\n        } else {\n            console.warn('Progress bar element not found');\n        }\n    }\n\n    generateProgressText() {\n        if (this.progressAsPercentage) {\n            const percentage = Math.min(Math.round((this.currentPage / this.maxPages) * 100), 100);\n            return `${percentage}%`;\n        } else {\n            const currentPage = Math.min(this.currentPage, this.maxPages + 1);\n            return `Page ${currentPage} of ${this.maxPages}`;\n        }\n    }\n\n    updateProgressText() {\n        if (!this.includeProgressText) return;\n\n        const progressText = document.getElementById(`${this.pluginId}-progress-text`);\n        if (progressText) {\n            const text = this.generateProgressText();\n            progressText.textContent = text;\n        } else {\n            console.warn('Progress text element not found');\n        }\n    }\n\n    beforeSurveyFinish() {\n        this.currentPage = this.maxPages;\n        this.updateProgress();\n    }\n\n    destroy() {\n        const progressBar = document.getElementById(`${this.pluginId}-progress`);\n        if (progressBar) {\n            progressBar.remove();\n        }\n        super.destroy();\n    }\n}\n\nexport default ProgressBar;"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"roundtable-js\",\n  \"version\": \"0.2.3\",\n  \"type\": \"module\",\n  \"description\": \"A modular survey framework built with JavaScript\",\n  \"main\": \"dist/bundle.js\",\n  \"scripts\": {\n    \"start\": \"http-server . -c-1\",\n    \"build\": \"webpack --mode production\"\n  },\n  \"files\": [\n    \"core/\",\n    \"question_types/\",\n    \"utils/\",\n    \"dist/\",\n    \"index.js\",\n    \"README.md\"\n  ],\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"git+https://github.com/roundtableai/roundtable-js.git\"\n  },\n  \"keywords\": [\n    \"survey\",\n    \"framework\",\n    \"javascript\"\n  ],\n  \"author\": \"Roundtable Technologies\",\n  \"license\": \"Apache-2.0\",\n  \"bugs\": {\n    \"url\": \"https://github.com/roundtableai/roundtable-js/issues\"\n  },\n  \"homepage\": \"https://github.com/roundtableai/roundtable-js#readme\",\n  \"devDependencies\": {\n    \"webpack\": \"^5.0.0\",\n    \"webpack-cli\": \"^4.0.0\",\n    \"babel-loader\": \"^8.0.0\",\n    \"@babel/core\": \"^7.0.0\",\n    \"@babel/preset-env\": \"^7.0.0\",\n    \"http-server\": \"^0.12.0\"\n  }\n}\n"
  },
  {
    "path": "webpack.config.cjs",
    "content": "const path = require('path');\n\nmodule.exports = {\n  entry: './index.js', // Adjust the entry point as needed\n  output: {\n    filename: 'bundle.js',\n    path: path.resolve(__dirname, 'dist'),\n    library: 'RoundtableJS',\n    libraryTarget: 'umd',\n    umdNamedDefine: true\n  },\n  module: {\n    rules: [\n      {\n        test: /\\.js$/,\n        exclude: /node_modules/,\n        use: {\n          loader: 'babel-loader',\n          options: {\n            presets: ['@babel/preset-env']\n          }\n        }\n      }\n    ]\n  }\n};"
  }
]