@openpolicy/vite 0.0.12 → 0.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../core/dist/index.js","../src/index.ts"],"sourcesContent":["import { marked } from \"marked\";\n//#region src/renderers/markdown.ts\nfunction renderMarkdown(sections) {\n\treturn sections.map((section) => `## ${section.title}\\n\\n${section.body}`).join(\"\\n\\n---\\n\\n\");\n}\n//#endregion\n//#region src/renderers/html.ts\nfunction renderHTML(sections) {\n\treturn marked(renderMarkdown(sections));\n}\n//#endregion\n//#region src/templates/cookie/consent.ts\nfunction buildConsent(config) {\n\tif (!config.consentMechanism) return null;\n\tconst mechanisms = [];\n\tif (config.consentMechanism.hasBanner) mechanisms.push(\"A **cookie consent banner** displayed on your first visit, where you can accept or decline non-essential cookies\");\n\tif (config.consentMechanism.hasPreferencePanel) mechanisms.push(\"A **preference panel** where you can manage individual cookie categories\");\n\tif (config.consentMechanism.canWithdraw) mechanisms.push(\"The ability to **withdraw your consent** at any time by updating your cookie preferences\");\n\treturn {\n\t\tid: \"consent\",\n\t\ttitle: \"User Consent\",\n\t\tbody: `Where required by law, we will request your consent before placing non-essential cookies on your device.${mechanisms.length > 0 ? `\\n\\nWe provide the following consent controls:\\n\\n${mechanisms.map((m) => `- ${m}`).join(\"\\n\")}` : \"\"}\n\nEssential cookies do not require your consent as they are strictly necessary for the operation of our service.`\n\t};\n}\n//#endregion\n//#region src/templates/cookie/contact.ts\nfunction buildContact$2(config) {\n\treturn {\n\t\tid: \"contact\",\n\t\ttitle: \"Contact Us\",\n\t\tbody: `If you have any questions about our use of cookies or this Cookie Policy, please contact us:\n\n**${config.company.legalName}**\n${config.company.address}\n${config.company.contact}`\n\t};\n}\n//#endregion\n//#region src/templates/cookie/cookie-duration.ts\nfunction buildCookieDuration(_config) {\n\treturn {\n\t\tid: \"cookie-duration\",\n\t\ttitle: \"Cookie Duration\",\n\t\tbody: `Cookies can be either **session cookies** or **persistent cookies**:\n\n- **Session cookies** are temporary and are deleted from your device when you close your browser. They are used to carry information across pages of our website and avoid having to re-enter information.\n- **Persistent cookies** remain on your device for a set period of time specified in the cookie. They are activated each time you visit the website that created that particular cookie.\n\nThe specific duration of each cookie depends on its purpose and is determined at the time it is set.`\n\t};\n}\n//#endregion\n//#region src/templates/cookie/cookie-types.ts\nfunction buildCookieTypes(config) {\n\tconst types = [];\n\tif (config.cookies.essential) types.push(\"**Essential Cookies** — These cookies are necessary for our website to function and cannot be switched off. They are usually set in response to actions you take, such as setting your privacy preferences, logging in, or filling in forms.\");\n\tif (config.cookies.analytics) types.push(\"**Analytics Cookies** — These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand which pages are most and least popular and see how visitors move around the site.\");\n\tif (config.cookies.functional) types.push(\"**Functional Cookies** — These cookies enable enhanced functionality and personalization, such as remembering your preferences and settings. They may be set by us or by third-party providers whose services we have added to our pages.\");\n\tif (config.cookies.marketing) types.push(\"**Marketing Cookies** — These cookies may be set through our site by our advertising partners. They may be used to build a profile of your interests and show you relevant advertisements on other sites.\");\n\treturn {\n\t\tid: \"cookie-types\",\n\t\ttitle: \"Types of Cookies We Use\",\n\t\tbody: `We use the following categories of cookies:\\n\\n${types.map((t) => `- ${t}`).join(\"\\n\")}`\n\t};\n}\n//#endregion\n//#region src/templates/cookie/cookie-usage.ts\nfunction buildCookieUsage(config) {\n\tconst purposes = [];\n\tif (config.cookies.essential) {\n\t\tpurposes.push(\"Providing core website functionality and security\");\n\t\tpurposes.push(\"Remembering your session and authentication state\");\n\t}\n\tif (config.cookies.analytics) {\n\t\tpurposes.push(\"Measuring website traffic and usage patterns\");\n\t\tpurposes.push(\"Identifying which pages and features are most popular\");\n\t}\n\tif (config.cookies.functional) {\n\t\tpurposes.push(\"Saving your preferences and settings\");\n\t\tpurposes.push(\"Providing personalized content and features\");\n\t}\n\tif (config.cookies.marketing) {\n\t\tpurposes.push(\"Delivering targeted advertising\");\n\t\tpurposes.push(\"Tracking the effectiveness of our marketing campaigns\");\n\t}\n\tconst list = purposes.map((p) => `- ${p}`).join(\"\\n\");\n\treturn {\n\t\tid: \"cookie-usage\",\n\t\ttitle: \"How We Use Cookies\",\n\t\tbody: `${config.company.name} uses cookies to:\\n\\n${list}`\n\t};\n}\n//#endregion\n//#region src/templates/cookie/introduction.ts\nfunction buildIntroduction$2(config) {\n\treturn {\n\t\tid: \"introduction\",\n\t\ttitle: \"Introduction\",\n\t\tbody: `This Cookie Policy explains how ${config.company.name} (\"we\", \"us\", or \"our\") uses cookies and similar tracking technologies when you visit our website or use our services.\n\n**Effective Date:** ${config.effectiveDate}\n\nBy using our services, you consent to the use of cookies as described in this policy. If you have questions, please contact us at ${config.company.contact}.`\n\t};\n}\n//#endregion\n//#region src/templates/cookie/jurisdiction.ts\nfunction buildJurisdiction(config) {\n\tif (!config.jurisdictions || config.jurisdictions.length === 0) return null;\n\tconst requirements = [];\n\tif (config.jurisdictions.includes(\"eu\")) requirements.push(\"**European Union (GDPR/ePrivacy Directive):** We comply with EU cookie consent requirements. Non-essential cookies require your prior, informed, and freely given consent. You have the right to withdraw consent at any time.\");\n\tif (config.jurisdictions.includes(\"ca\")) requirements.push(\"**California (CCPA):** California residents have the right to opt out of the sale of personal information collected through cookies. To exercise this right, please contact us.\");\n\tif (config.jurisdictions.includes(\"us\")) requirements.push(\"**United States:** We comply with applicable U.S. federal and state privacy laws regarding cookie usage and disclosure.\");\n\tif (config.jurisdictions.includes(\"au\")) requirements.push(\"**Australia (Privacy Act):** We comply with the Australian Privacy Principles regarding the collection of personal information through cookies.\");\n\tif (config.jurisdictions.includes(\"nz\")) requirements.push(\"**New Zealand (Privacy Act 2020):** We comply with New Zealand privacy requirements for the collection of personal information through cookies.\");\n\tif (config.jurisdictions.includes(\"other\")) requirements.push(\"**Other Jurisdictions:** We strive to comply with applicable cookie laws and regulations in all jurisdictions where we operate.\");\n\treturn {\n\t\tid: \"jurisdiction\",\n\t\ttitle: \"Legal Requirements\",\n\t\tbody: `Our cookie practices are designed to comply with applicable laws across the jurisdictions in which we operate:\\n\\n${requirements.map((r) => `- ${r}`).join(\"\\n\")}`\n\t};\n}\n//#endregion\n//#region src/templates/cookie/managing-cookies.ts\nfunction buildManagingCookies(_config) {\n\treturn {\n\t\tid: \"managing-cookies\",\n\t\ttitle: \"Managing Your Cookie Preferences\",\n\t\tbody: `You can control and manage cookies in several ways:\n\n**Browser settings:** Most browsers allow you to refuse cookies or delete existing ones. The process varies by browser:\n- **Chrome:** Settings → Privacy and security → Cookies and other site data\n- **Firefox:** Settings → Privacy & Security → Cookies and Site Data\n- **Safari:** Preferences → Privacy → Manage Website Data\n- **Edge:** Settings → Cookies and site permissions\n\n**Opt-out tools:** For analytics and advertising cookies, you may use industry opt-out tools such as the [NAI opt-out](http://optout.networkadvertising.org/) or [DAA opt-out](http://optout.aboutads.info/).\n\nPlease note that blocking or deleting cookies may affect your experience on our website, and some features may not function correctly if cookies are disabled.`\n\t};\n}\n//#endregion\n//#region src/templates/cookie/third-party-cookies.ts\nfunction buildThirdPartyCookies(config) {\n\tif (!config.thirdParties || config.thirdParties.length === 0) return null;\n\treturn {\n\t\tid: \"third-party-cookies\",\n\t\ttitle: \"Third-Party Cookies\",\n\t\tbody: `Some cookies on our site are placed by third-party services. These third parties may use cookies to collect information about your online activities across different websites. We do not control these third-party cookies.\n\nThe following third parties may set cookies through our service:\\n\\n${config.thirdParties.map((tp) => {\n\t\t\tconst policyLink = tp.policyUrl ? ` ([Privacy Policy](${tp.policyUrl}))` : \"\";\n\t\t\treturn `- **${tp.name}** — ${tp.purpose}${policyLink}`;\n\t\t}).join(\"\\n\")}\\n\\nWe encourage you to review the privacy policies of these third parties to understand their data practices.`\n\t};\n}\n//#endregion\n//#region src/templates/cookie/tracking-technologies.ts\nfunction buildTrackingTechnologies(config) {\n\tif (!config.trackingTechnologies || config.trackingTechnologies.length === 0) return null;\n\treturn {\n\t\tid: \"tracking-technologies\",\n\t\ttitle: \"Similar Tracking Technologies\",\n\t\tbody: `In addition to cookies, we may use the following tracking technologies:\\n\\n${config.trackingTechnologies.map((t) => `- ${t}`).join(\"\\n\")}\\n\\nThese technologies work similarly to cookies and are subject to the same controls described in this policy.`\n\t};\n}\n//#endregion\n//#region src/templates/cookie/updates.ts\nfunction buildUpdates(config) {\n\treturn {\n\t\tid: \"updates\",\n\t\ttitle: \"Updates to This Policy\",\n\t\tbody: `We may update this Cookie Policy from time to time to reflect changes in our practices or applicable law. When we make changes, we will update the **Effective Date** at the top of this policy.\n\nWe encourage you to review this Cookie Policy periodically. Your continued use of our services after any changes constitutes your acceptance of the updated policy.\n\nIf you have questions about changes to this policy, please contact ${config.company.name} at ${config.company.contact}.`\n\t};\n}\n//#endregion\n//#region src/templates/cookie/what-are-cookies.ts\nfunction buildWhatAreCookies(_config) {\n\treturn {\n\t\tid: \"what-are-cookies\",\n\t\ttitle: \"What Are Cookies\",\n\t\tbody: `Cookies are small text files that are placed on your device (computer, tablet, or mobile phone) when you visit a website. They are widely used to make websites work, or work more efficiently, and to provide information to the website owner.\n\nCookies are set by the website you visit (first-party cookies) or by third parties whose content appears on that page (third-party cookies). Cookies remain on your device for varying lengths of time depending on their type.`\n\t};\n}\n//#endregion\n//#region src/cookie.ts\nconst SECTION_BUILDERS$2 = [\n\tbuildIntroduction$2,\n\tbuildWhatAreCookies,\n\tbuildCookieTypes,\n\tbuildTrackingTechnologies,\n\tbuildCookieUsage,\n\tbuildCookieDuration,\n\tbuildConsent,\n\tbuildManagingCookies,\n\tbuildThirdPartyCookies,\n\tbuildJurisdiction,\n\tbuildUpdates,\n\tbuildContact$2\n];\nfunction compileCookiePolicy(config, options = { formats: [\"markdown\"] }) {\n\tconst sections = SECTION_BUILDERS$2.map((builder) => builder(config)).filter((s) => s !== null);\n\treturn options.formats.map((format) => {\n\t\tswitch (format) {\n\t\t\tcase \"markdown\": return {\n\t\t\t\tformat,\n\t\t\t\tcontent: renderMarkdown(sections),\n\t\t\t\tsections\n\t\t\t};\n\t\t\tcase \"html\": return {\n\t\t\t\tformat,\n\t\t\t\tcontent: renderHTML(sections),\n\t\t\t\tsections\n\t\t\t};\n\t\t\tcase \"pdf\": throw new Error(\"pdf format is not yet implemented\");\n\t\t\tcase \"jsx\": throw new Error(\"jsx format is not yet implemented\");\n\t\t\tdefault: throw new Error(`Unsupported format: ${format}`);\n\t\t}\n\t});\n}\n//#endregion\n//#region src/templates/privacy/ccpa-supplement.ts\nfunction buildCcpaSupplement(config) {\n\tif (!config.jurisdictions.includes(\"ca\")) return null;\n\treturn {\n\t\tid: \"ccpa-supplement\",\n\t\ttitle: \"California Privacy Rights (CCPA)\",\n\t\tbody: `This section applies to California residents under the California Consumer Privacy Act (CCPA) and the California Privacy Rights Act (CPRA).\n\n**Categories of Personal Information Collected:** We collect the categories of personal information described in the \"Information We Collect\" section above.\n\n**Your California Rights:**\n- **Right to Know:** You may request information about the personal information we have collected about you, including the categories of sources, the business purpose for collection, and the categories of third parties with whom we share information.\n- **Right to Delete:** You may request deletion of personal information we have collected from you, subject to certain exceptions.\n- **Right to Opt-Out:** You may opt out of the sale or sharing of your personal information.\n- **Right to Non-Discrimination:** We will not discriminate against you for exercising your California privacy rights.\n\nTo exercise your rights, contact us at ${config.company.contact}.`\n\t};\n}\n//#endregion\n//#region src/templates/privacy/children-privacy.ts\nfunction buildChildrenPrivacy(config) {\n\tif (!config.children) return null;\n\tconst { underAge, noticeUrl } = config.children;\n\tlet body = `Our service is not directed at children under ${underAge} years old.`;\n\tif (noticeUrl) body += ` See our notice for parents and guardians: ${noticeUrl}`;\n\treturn {\n\t\tid: \"children-privacy\",\n\t\ttitle: \"Children’s Privacy\",\n\t\tbody\n\t};\n}\n//#endregion\n//#region src/templates/privacy/contact.ts\nfunction buildContact$1(config) {\n\treturn {\n\t\tid: \"contact\",\n\t\ttitle: \"Contact Us\",\n\t\tbody: `If you have questions or concerns about this Privacy Policy or our data practices, please contact us:\n\n**${config.company.legalName}**\n${config.company.address}\n\nEmail: ${config.company.contact}`\n\t};\n}\n//#endregion\n//#region src/templates/privacy/cookies.ts\nfunction buildCookies(config) {\n\tconst enabled = [];\n\tif (config.cookies.essential) enabled.push(\"**Essential cookies** — required for the service to function\");\n\tif (config.cookies.analytics) enabled.push(\"**Analytics cookies** — help us understand how visitors interact with our service\");\n\tif (config.cookies.marketing) enabled.push(\"**Marketing cookies** — used to deliver relevant advertisements\");\n\treturn {\n\t\tid: \"cookies\",\n\t\ttitle: \"Cookies and Tracking\",\n\t\tbody: enabled.length > 0 ? `We use the following types of cookies and tracking technologies:\\n\\n${enabled.map((e) => `- ${e}`).join(\"\\n\")}` : \"We do not use cookies or tracking technologies on our service.\"\n\t};\n}\n//#endregion\n//#region src/templates/privacy/data-collected.ts\nfunction buildDataCollected(config) {\n\treturn {\n\t\tid: \"data-collected\",\n\t\ttitle: \"Information We Collect\",\n\t\tbody: `We collect the following categories of information:\\n\\n${Object.entries(config.dataCollected).map(([category, items]) => {\n\t\t\treturn `**${category}:**\\n${items.map((item) => ` - ${item}`).join(\"\\n\")}`;\n\t\t}).join(\"\\n\\n\")}`\n\t};\n}\n//#endregion\n//#region src/templates/privacy/data-retention.ts\nfunction buildDataRetention(config) {\n\treturn {\n\t\tid: \"data-retention\",\n\t\ttitle: \"Data Retention\",\n\t\tbody: `We retain your information for the following periods:\\n\\n${Object.entries(config.retention).map(([category, period]) => `- **${category}:** ${period}`).join(\"\\n\")}`\n\t};\n}\n//#endregion\n//#region src/templates/privacy/gdpr-supplement.ts\nfunction buildGdprSupplement(config) {\n\tif (!config.jurisdictions.includes(\"eu\")) return null;\n\treturn {\n\t\tid: \"gdpr-supplement\",\n\t\ttitle: \"GDPR Supplemental Disclosures\",\n\t\tbody: `This section applies to individuals in the European Economic Area (EEA) under the General Data Protection Regulation (GDPR).\n\n**Data Controller:** ${config.company.legalName}, ${config.company.address}\n\n**Your GDPR Rights:** In addition to the rights listed above, you have the right to lodge a complaint with your local data protection authority if you believe we have not handled your data in accordance with applicable law.\n\n**International Transfers:** If we transfer your personal data outside the EEA, we ensure adequate safeguards are in place in accordance with GDPR requirements.`\n\t};\n}\n//#endregion\n//#region src/templates/privacy/introduction.ts\nfunction buildIntroduction$1(config) {\n\treturn {\n\t\tid: \"introduction\",\n\t\ttitle: \"Introduction\",\n\t\tbody: `This Privacy Policy describes how ${config.company.name} (\"we\", \"us\", or \"our\") collects, uses, and shares information about you when you use our services.\n\n**Effective Date:** ${config.effectiveDate}\n\nIf you have questions about this policy, please contact us at ${config.company.contact}.`\n\t};\n}\n//#endregion\n//#region src/templates/privacy/legal-basis.ts\nfunction buildLegalBasis(config) {\n\tif (!config.jurisdictions.includes(\"eu\")) return null;\n\treturn {\n\t\tid: \"legal-basis\",\n\t\ttitle: \"Legal Basis for Processing\",\n\t\tbody: `We process your personal data under the following legal basis:\\n\\n${config.legalBasis}`\n\t};\n}\n//#endregion\n//#region src/templates/privacy/third-parties.ts\nfunction buildThirdParties(config) {\n\tconst lines = config.thirdParties.map((tp) => `- **${tp.name}** — ${tp.purpose}`);\n\treturn {\n\t\tid: \"third-parties\",\n\t\ttitle: \"Third-Party Services\",\n\t\tbody: lines.length > 0 ? `We share data with the following third-party services:\\n\\n${lines.join(\"\\n\")}` : \"We do not share your data with third-party services.\"\n\t};\n}\n//#endregion\n//#region src/templates/privacy/user-rights.ts\nconst RIGHTS_LABELS = {\n\taccess: \"Right to access your personal data\",\n\trectification: \"Right to correct inaccurate data\",\n\terasure: \"Right to request deletion of your data\",\n\tportability: \"Right to receive your data in a portable format\",\n\trestriction: \"Right to restrict how we process your data\",\n\tobjection: \"Right to object to processing\",\n\topt_out_sale: \"Right to opt out of the sale of your personal information\",\n\tnon_discrimination: \"Right to non-discriminatory treatment for exercising your rights\"\n};\nfunction buildUserRights(config) {\n\treturn {\n\t\tid: \"user-rights\",\n\t\ttitle: \"Your Rights\",\n\t\tbody: `You have the following rights regarding your personal data:\\n\\n${config.userRights.map((right) => {\n\t\t\treturn `- ${RIGHTS_LABELS[right] ?? right}`;\n\t\t}).join(\"\\n\")}`\n\t};\n}\n//#endregion\n//#region src/privacy.ts\nconst SECTION_BUILDERS$1 = [\n\tbuildIntroduction$1,\n\tbuildChildrenPrivacy,\n\tbuildDataCollected,\n\tbuildLegalBasis,\n\tbuildDataRetention,\n\tbuildCookies,\n\tbuildThirdParties,\n\tbuildUserRights,\n\tbuildGdprSupplement,\n\tbuildCcpaSupplement,\n\tbuildContact$1\n];\nfunction compilePrivacyPolicy(config, options = { formats: [\"markdown\"] }) {\n\tconst sections = SECTION_BUILDERS$1.map((builder) => builder(config)).filter((s) => s !== null);\n\treturn options.formats.map((format) => {\n\t\tswitch (format) {\n\t\t\tcase \"markdown\": return {\n\t\t\t\tformat,\n\t\t\t\tcontent: renderMarkdown(sections),\n\t\t\t\tsections\n\t\t\t};\n\t\t\tcase \"html\": return {\n\t\t\t\tformat,\n\t\t\t\tcontent: renderHTML(sections),\n\t\t\t\tsections\n\t\t\t};\n\t\t\tcase \"pdf\": throw new Error(\"pdf format is not yet implemented\");\n\t\t\tcase \"jsx\": throw new Error(\"jsx format is not yet implemented\");\n\t\t\tdefault: throw new Error(`Unsupported format: ${format}`);\n\t\t}\n\t});\n}\n//#endregion\n//#region src/templates/terms/acceptance.ts\nfunction buildAcceptance(config) {\n\treturn {\n\t\tid: \"tos-acceptance\",\n\t\ttitle: \"Acceptance of Terms\",\n\t\tbody: `By accessing or using our services, you agree to be bound by these Terms. You accept these Terms by:\\n\\n${config.acceptance.methods.map((m) => `- ${m}`).join(\"\\n\")}\\n\\nIf you do not agree to these Terms, you may not use our services.`\n\t};\n}\n//#endregion\n//#region src/templates/terms/accounts.ts\nfunction buildAccounts(config) {\n\tif (!config.accounts) return null;\n\tconst { registrationRequired, userResponsibleForCredentials, companyCanTerminate } = config.accounts;\n\tconst lines = [];\n\tif (registrationRequired) lines.push(\"You must create an account to access certain features of our services. You agree to provide accurate, current, and complete information during registration.\");\n\tif (userResponsibleForCredentials) lines.push(\"You are responsible for maintaining the confidentiality of your account credentials and for all activities that occur under your account. You must notify us immediately of any unauthorized use of your account.\");\n\tif (companyCanTerminate) lines.push(`${config.company.name} reserves the right to suspend or terminate your account at any time, with or without notice, for any reason including violation of these Terms.`);\n\treturn {\n\t\tid: \"tos-accounts\",\n\t\ttitle: \"Accounts\",\n\t\tbody: lines.join(\"\\n\\n\")\n\t};\n}\n//#endregion\n//#region src/templates/terms/availability.ts\nfunction buildAvailability(config) {\n\tif (!config.availability) return null;\n\tconst lines = [];\n\tif (config.availability.noUptimeGuarantee) lines.push(\"We do not guarantee that our services will be available at all times. Our services may be subject to interruptions, delays, or errors.\");\n\tif (config.availability.maintenanceWindows) lines.push(`**Maintenance:** ${config.availability.maintenanceWindows}`);\n\treturn {\n\t\tid: \"tos-availability\",\n\t\ttitle: \"Service Availability\",\n\t\tbody: lines.join(\"\\n\\n\")\n\t};\n}\n//#endregion\n//#region src/templates/terms/changes-to-terms.ts\nfunction buildChangesToTerms(config) {\n\tif (!config.changesPolicy) return null;\n\tconst { noticeMethod, noticePeriodDays } = config.changesPolicy;\n\treturn {\n\t\tid: \"tos-changes\",\n\t\ttitle: \"Changes to These Terms\",\n\t\tbody: `We may update these Terms from time to time. We will notify you of material changes via ${noticeMethod}${noticePeriodDays ? ` at least **${noticePeriodDays} days** before they take effect` : \" before they take effect\"}. Your continued use of our services after changes become effective constitutes your acceptance of the revised Terms.`\n\t};\n}\n//#endregion\n//#region src/templates/terms/contact.ts\nfunction buildContact(config) {\n\treturn {\n\t\tid: \"tos-contact\",\n\t\ttitle: \"Contact Us\",\n\t\tbody: `If you have any questions about these Terms, please contact us at:\n\n**${config.company.legalName}**\n${config.company.address}\n${config.company.contact}`\n\t};\n}\n//#endregion\n//#region src/templates/terms/disclaimers.ts\nfunction buildDisclaimers(config) {\n\tif (!config.disclaimers) return null;\n\tconst lines = [];\n\tif (config.disclaimers.serviceProvidedAsIs) lines.push(\"OUR SERVICES ARE PROVIDED \\\"AS IS\\\" AND \\\"AS AVAILABLE\\\" WITHOUT WARRANTIES OF ANY KIND.\");\n\tif (config.disclaimers.noWarranties) lines.push(`${config.company.legalName} EXPRESSLY DISCLAIMS ALL WARRANTIES, WHETHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.`);\n\treturn {\n\t\tid: \"tos-disclaimers\",\n\t\ttitle: \"Disclaimer of Warranties\",\n\t\tbody: lines.join(\"\\n\\n\")\n\t};\n}\n//#endregion\n//#region src/templates/terms/dispute-resolution.ts\nfunction buildDisputeResolution(config) {\n\tif (!config.disputeResolution) return null;\n\tconst { method, venue, classActionWaiver } = config.disputeResolution;\n\tconst lines = [{\n\t\tarbitration: \"Any disputes arising out of or relating to these Terms or our services shall be resolved by binding arbitration rather than in court.\",\n\t\tlitigation: \"Any disputes arising out of or relating to these Terms or our services shall be resolved through litigation in a court of competent jurisdiction.\",\n\t\tmediation: \"Any disputes arising out of or relating to these Terms or our services shall first be submitted to non-binding mediation before pursuing other remedies.\"\n\t}[method] ?? \"Disputes arising out of or relating to these Terms shall be resolved as described below.\"];\n\tif (venue) lines.push(`**Venue:** ${venue}`);\n\tif (classActionWaiver) lines.push(\"**Class Action Waiver:** You agree that any dispute resolution proceedings will be conducted only on an individual basis and not in a class, consolidated, or representative action.\");\n\treturn {\n\t\tid: \"tos-dispute-resolution\",\n\t\ttitle: \"Dispute Resolution\",\n\t\tbody: lines.join(\"\\n\\n\")\n\t};\n}\n//#endregion\n//#region src/templates/terms/eligibility.ts\nfunction buildEligibility(config) {\n\tif (!config.eligibility) return null;\n\tconst { minimumAge, jurisdictionRestrictions } = config.eligibility;\n\tlet body = `You must be at least **${minimumAge} years old** to use our services. By using our services, you represent and warrant that you meet this age requirement.`;\n\tif (jurisdictionRestrictions && jurisdictionRestrictions.length > 0) {\n\t\tconst list = jurisdictionRestrictions.map((r) => `- ${r}`).join(\"\\n\");\n\t\tbody += `\\n\\nOur services are not available in the following jurisdictions:\\n\\n${list}`;\n\t}\n\treturn {\n\t\tid: \"tos-eligibility\",\n\t\ttitle: \"Eligibility\",\n\t\tbody\n\t};\n}\n//#endregion\n//#region src/templates/terms/governing-law.ts\nfunction buildGoverningLaw(config) {\n\treturn {\n\t\tid: \"tos-governing-law\",\n\t\ttitle: \"Governing Law\",\n\t\tbody: `These Terms shall be governed by and construed in accordance with the laws of **${config.governingLaw.jurisdiction}**, without regard to its conflict of law provisions.`\n\t};\n}\n//#endregion\n//#region src/templates/terms/indemnification.ts\nfunction buildIndemnification(config) {\n\tif (!config.indemnification) return null;\n\tconst lines = [];\n\tif (config.indemnification.userIndemnifiesCompany) lines.push(`You agree to indemnify and hold harmless ${config.company.legalName} and its officers, directors, employees, and agents from and against any claims, liabilities, damages, losses, and expenses arising out of or in any way connected with your access to or use of our services.`);\n\tif (config.indemnification.scope) lines.push(`**Scope:** ${config.indemnification.scope}`);\n\treturn {\n\t\tid: \"tos-indemnification\",\n\t\ttitle: \"Indemnification\",\n\t\tbody: lines.join(\"\\n\\n\")\n\t};\n}\n//#endregion\n//#region src/templates/terms/intellectual-property.ts\nfunction buildIntellectualProperty(config) {\n\tif (!config.intellectualProperty) return null;\n\tconst { companyOwnsService, usersMayNotCopy } = config.intellectualProperty;\n\tconst lines = [];\n\tif (companyOwnsService) lines.push(`The services and all content, features, and functionality (including but not limited to text, graphics, logos, and software) are owned by ${config.company.legalName} and are protected by intellectual property laws.`);\n\tif (usersMayNotCopy) lines.push(\"You may not copy, modify, distribute, sell, or lease any part of our services or included software, nor may you reverse engineer or attempt to extract the source code of that software.\");\n\treturn {\n\t\tid: \"tos-intellectual-property\",\n\t\ttitle: \"Intellectual Property\",\n\t\tbody: lines.join(\"\\n\\n\")\n\t};\n}\n//#endregion\n//#region src/templates/terms/introduction.ts\nfunction buildIntroduction(config) {\n\tconst privacyLine = config.privacyPolicyUrl ? `\\n\\nFor information about how we collect and use your data, please review our [Privacy Policy](${config.privacyPolicyUrl}).` : \"\";\n\treturn {\n\t\tid: \"tos-introduction\",\n\t\ttitle: \"Terms of Service\",\n\t\tbody: `These Terms of Service (\"Terms\") govern your access to and use of the services provided by ${config.company.name} (\"${config.company.name}\", \"we\", \"us\", or \"our\"). By using our services, you agree to these Terms.\n\n**Effective Date:** ${config.effectiveDate}${privacyLine}`\n\t};\n}\n//#endregion\n//#region src/templates/terms/limitation-of-liability.ts\nfunction buildLimitationOfLiability(config) {\n\tif (!config.limitationOfLiability) return null;\n\tconst lines = [];\n\tif (config.limitationOfLiability.excludesIndirectDamages) lines.push(`TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, ${config.company.legalName.toUpperCase()} SHALL NOT BE LIABLE FOR ANY INDIRECT, INCIDENTAL, SPECIAL, CONSEQUENTIAL, OR PUNITIVE DAMAGES, OR ANY LOSS OF PROFITS OR REVENUES, WHETHER INCURRED DIRECTLY OR INDIRECTLY, OR ANY LOSS OF DATA, USE, GOODWILL, OR OTHER INTANGIBLE LOSSES.`);\n\tif (config.limitationOfLiability.liabilityCap) lines.push(`**Liability Cap:** ${config.limitationOfLiability.liabilityCap}`);\n\treturn {\n\t\tid: \"tos-limitation-of-liability\",\n\t\ttitle: \"Limitation of Liability\",\n\t\tbody: lines.join(\"\\n\\n\")\n\t};\n}\n//#endregion\n//#region src/templates/terms/payments.ts\nfunction buildPayments(config) {\n\tif (!config.payments || !config.payments.hasPaidFeatures) return null;\n\tconst lines = [\"Some features of our services require payment. By selecting a paid plan, you agree to pay all applicable fees.\"];\n\tif (config.payments.refundPolicy) lines.push(`**Refunds:** ${config.payments.refundPolicy}`);\n\tif (config.payments.priceChangesNotice) lines.push(`**Price Changes:** ${config.payments.priceChangesNotice}`);\n\treturn {\n\t\tid: \"tos-payments\",\n\t\ttitle: \"Payments and Billing\",\n\t\tbody: lines.join(\"\\n\\n\")\n\t};\n}\n//#endregion\n//#region src/templates/terms/prohibited-use.ts\nfunction buildProhibitedUse(config) {\n\tif (!config.prohibitedUses || config.prohibitedUses.length === 0) return null;\n\treturn {\n\t\tid: \"tos-prohibited-use\",\n\t\ttitle: \"Prohibited Uses\",\n\t\tbody: `You agree not to use our services for any of the following purposes:\\n\\n${config.prohibitedUses.map((u) => `- ${u}`).join(\"\\n\")}`\n\t};\n}\n//#endregion\n//#region src/templates/terms/termination.ts\nfunction buildTermination(config) {\n\tif (!config.termination) return null;\n\tconst { companyCanTerminate, userCanTerminate, effectOfTermination } = config.termination;\n\tconst lines = [];\n\tif (companyCanTerminate) lines.push(`${config.company.name} may suspend or terminate your access to the services at any time, with or without cause, and with or without notice.`);\n\tif (userCanTerminate) lines.push(\"You may terminate your account at any time by discontinuing use of our services or by contacting us to close your account.\");\n\tif (effectOfTermination) lines.push(`**Effect of Termination:** ${effectOfTermination}`);\n\treturn {\n\t\tid: \"tos-termination\",\n\t\ttitle: \"Termination\",\n\t\tbody: lines.join(\"\\n\\n\")\n\t};\n}\n//#endregion\n//#region src/templates/terms/third-party-services.ts\nfunction buildThirdPartyServices(config) {\n\tif (!config.thirdPartyServices || config.thirdPartyServices.length === 0) return null;\n\treturn {\n\t\tid: \"tos-third-party-services\",\n\t\ttitle: \"Third-Party Services\",\n\t\tbody: `Our services may integrate with or link to third-party services. Your use of those services is governed by their own terms and policies.\\n\\n${config.thirdPartyServices.map((s) => `- **${s.name}** — ${s.purpose}`).join(\"\\n\")}`\n\t};\n}\n//#endregion\n//#region src/templates/terms/user-content.ts\nfunction buildUserContent(config) {\n\tif (!config.userContent) return null;\n\tconst { usersOwnContent, licenseGrantedToCompany, licenseDescription, companyCanRemoveContent } = config.userContent;\n\tconst lines = [];\n\tif (usersOwnContent) lines.push(\"You retain ownership of any content you submit, post, or display on or through our services (\\\"User Content\\\").\");\n\tif (licenseGrantedToCompany) {\n\t\tconst desc = licenseDescription ? licenseDescription : \"a worldwide, royalty-free, non-exclusive license to use, reproduce, modify, and distribute your User Content in connection with operating and improving our services\";\n\t\tlines.push(`By submitting User Content, you grant ${config.company.name} ${desc}.`);\n\t}\n\tif (companyCanRemoveContent) lines.push(`${config.company.name} reserves the right to remove any User Content that violates these Terms or that we find objectionable, at our sole discretion.`);\n\treturn {\n\t\tid: \"tos-user-content\",\n\t\ttitle: \"User Content\",\n\t\tbody: lines.join(\"\\n\\n\")\n\t};\n}\n//#endregion\n//#region src/terms.ts\nconst SECTION_BUILDERS = [\n\tbuildIntroduction,\n\tbuildAcceptance,\n\tbuildEligibility,\n\tbuildAccounts,\n\tbuildProhibitedUse,\n\tbuildUserContent,\n\tbuildIntellectualProperty,\n\tbuildPayments,\n\tbuildAvailability,\n\tbuildTermination,\n\tbuildDisclaimers,\n\tbuildLimitationOfLiability,\n\tbuildIndemnification,\n\tbuildThirdPartyServices,\n\tbuildDisputeResolution,\n\tbuildGoverningLaw,\n\tbuildChangesToTerms,\n\tbuildContact\n];\nfunction compileTermsOfService(config, options = { formats: [\"markdown\"] }) {\n\tconst sections = SECTION_BUILDERS.map((builder) => builder(config)).filter((s) => s !== null);\n\treturn options.formats.map((format) => {\n\t\tswitch (format) {\n\t\t\tcase \"markdown\": return {\n\t\t\t\tformat,\n\t\t\t\tcontent: renderMarkdown(sections),\n\t\t\t\tsections\n\t\t\t};\n\t\t\tcase \"html\": return {\n\t\t\t\tformat,\n\t\t\t\tcontent: renderHTML(sections),\n\t\t\t\tsections\n\t\t\t};\n\t\t\tcase \"pdf\": throw new Error(\"pdf format is not yet implemented\");\n\t\t\tcase \"jsx\": throw new Error(\"jsx format is not yet implemented\");\n\t\t\tdefault: throw new Error(`Unsupported format: ${format}`);\n\t\t}\n\t});\n}\n//#endregion\n//#region src/types.ts\nfunction isOpenPolicyConfig(value) {\n\tif (value === null || typeof value !== \"object\") return false;\n\tconst obj = value;\n\treturn \"company\" in obj && !(\"effectiveDate\" in obj) && (\"privacy\" in obj || \"terms\" in obj || \"cookie\" in obj);\n}\n//#endregion\n//#region src/validate.ts\nfunction validatePrivacyPolicy(config) {\n\tconst issues = [];\n\tif (!config.effectiveDate) issues.push({\n\t\tlevel: \"error\",\n\t\tmessage: \"effectiveDate is required\"\n\t});\n\tif (!config.company.name) issues.push({\n\t\tlevel: \"error\",\n\t\tmessage: \"company.name is required\"\n\t});\n\tif (!config.company.legalName) issues.push({\n\t\tlevel: \"error\",\n\t\tmessage: \"company.legalName is required\"\n\t});\n\tif (!config.company.address) issues.push({\n\t\tlevel: \"error\",\n\t\tmessage: \"company.address is required\"\n\t});\n\tif (!config.company.contact) issues.push({\n\t\tlevel: \"error\",\n\t\tmessage: \"company.contact is required\"\n\t});\n\tif (Object.keys(config.dataCollected).length === 0) issues.push({\n\t\tlevel: \"error\",\n\t\tmessage: \"dataCollected must have at least one entry\"\n\t});\n\tif (config.userRights.length === 0) issues.push({\n\t\tlevel: \"warning\",\n\t\tmessage: \"userRights is empty — consider listing applicable rights\"\n\t});\n\tif (config.jurisdictions.includes(\"eu\")) {\n\t\tif (!config.legalBasis) issues.push({\n\t\t\tlevel: \"error\",\n\t\t\tmessage: \"GDPR requires a legalBasis\"\n\t\t});\n\t\tfor (const right of [\n\t\t\t\"access\",\n\t\t\t\"rectification\",\n\t\t\t\"erasure\",\n\t\t\t\"portability\",\n\t\t\t\"restriction\",\n\t\t\t\"objection\"\n\t\t]) if (!config.userRights.includes(right)) issues.push({\n\t\t\tlevel: \"warning\",\n\t\t\tmessage: `GDPR recommends including the \"${right}\" right`\n\t\t});\n\t}\n\tif (config.jurisdictions.includes(\"ca\")) {\n\t\tfor (const right of [\n\t\t\t\"access\",\n\t\t\t\"erasure\",\n\t\t\t\"opt_out_sale\",\n\t\t\t\"non_discrimination\"\n\t\t]) if (!config.userRights.includes(right)) issues.push({\n\t\t\tlevel: \"warning\",\n\t\t\tmessage: `CCPA recommends including the \"${right}\" right`\n\t\t});\n\t}\n\tif (config.children) {\n\t\tif (config.children.underAge <= 0) issues.push({\n\t\t\tlevel: \"error\",\n\t\t\tmessage: \"children.underAge must be a positive number\"\n\t\t});\n\t}\n\treturn issues;\n}\n//#endregion\n//#region src/validate-cookie.ts\nfunction validateCookiePolicy(config) {\n\tconst issues = [];\n\tif (!config.effectiveDate) issues.push({\n\t\tlevel: \"error\",\n\t\tmessage: \"effectiveDate is required\"\n\t});\n\tif (!config.company.name) issues.push({\n\t\tlevel: \"error\",\n\t\tmessage: \"company.name is required\"\n\t});\n\tif (!config.company.legalName) issues.push({\n\t\tlevel: \"error\",\n\t\tmessage: \"company.legalName is required\"\n\t});\n\tif (!config.company.address) issues.push({\n\t\tlevel: \"error\",\n\t\tmessage: \"company.address is required\"\n\t});\n\tif (!config.company.contact) issues.push({\n\t\tlevel: \"error\",\n\t\tmessage: \"company.contact is required\"\n\t});\n\tconst { essential, analytics, functional, marketing } = config.cookies;\n\tif (!essential && !analytics && !functional && !marketing) issues.push({\n\t\tlevel: \"error\",\n\t\tmessage: \"At least one cookie type must be enabled (essential, analytics, functional, or marketing)\"\n\t});\n\tif (!config.consentMechanism) issues.push({\n\t\tlevel: \"warning\",\n\t\tmessage: \"consentMechanism is not provided — consider describing how users can manage cookie consent\"\n\t});\n\tif (config.jurisdictions.includes(\"eu\") && config.consentMechanism && !config.consentMechanism.canWithdraw) issues.push({\n\t\tlevel: \"warning\",\n\t\tmessage: \"GDPR requires that users can withdraw cookie consent — consider setting consentMechanism.canWithdraw to true\"\n\t});\n\treturn issues;\n}\n//#endregion\n//#region src/validate-terms.ts\nfunction validateTermsOfService(config) {\n\tconst issues = [];\n\tif (!config.effectiveDate) issues.push({\n\t\tlevel: \"error\",\n\t\tmessage: \"effectiveDate is required\"\n\t});\n\tif (!config.company.name) issues.push({\n\t\tlevel: \"error\",\n\t\tmessage: \"company.name is required\"\n\t});\n\tif (!config.company.legalName) issues.push({\n\t\tlevel: \"error\",\n\t\tmessage: \"company.legalName is required\"\n\t});\n\tif (!config.company.address) issues.push({\n\t\tlevel: \"error\",\n\t\tmessage: \"company.address is required\"\n\t});\n\tif (!config.company.contact) issues.push({\n\t\tlevel: \"error\",\n\t\tmessage: \"company.contact is required\"\n\t});\n\tif (!config.governingLaw.jurisdiction) issues.push({\n\t\tlevel: \"error\",\n\t\tmessage: \"governingLaw.jurisdiction is required\"\n\t});\n\tif (!config.disclaimers) issues.push({\n\t\tlevel: \"warning\",\n\t\tmessage: \"disclaimers is missing — consider adding a disclaimer of warranties\"\n\t});\n\tif (!config.limitationOfLiability) issues.push({\n\t\tlevel: \"warning\",\n\t\tmessage: \"limitationOfLiability is missing — consider adding a limitation of liability clause\"\n\t});\n\tif (config.acceptance.methods.length === 0) issues.push({\n\t\tlevel: \"warning\",\n\t\tmessage: \"acceptance.methods is empty — consider listing how users accept these Terms\"\n\t});\n\treturn issues;\n}\n//#endregion\n//#region src/index.ts\nfunction expandOpenPolicyConfig(config) {\n\tconst inputs = [];\n\tif (config.privacy) inputs.push({\n\t\ttype: \"privacy\",\n\t\tcompany: config.company,\n\t\t...config.privacy\n\t});\n\tif (config.terms) inputs.push({\n\t\ttype: \"terms\",\n\t\tcompany: config.company,\n\t\t...config.terms\n\t});\n\tif (config.cookie) inputs.push({\n\t\ttype: \"cookie\",\n\t\tcompany: config.company,\n\t\t...config.cookie\n\t});\n\treturn inputs;\n}\nfunction compilePolicy(input, options) {\n\tswitch (input.type) {\n\t\tcase \"privacy\": {\n\t\t\tconst { type: _, ...config } = input;\n\t\t\treturn compilePrivacyPolicy(config, options);\n\t\t}\n\t\tcase \"terms\": {\n\t\t\tconst { type: _, ...config } = input;\n\t\t\treturn compileTermsOfService(config, options);\n\t\t}\n\t\tcase \"cookie\": {\n\t\t\tconst { type: _, ...config } = input;\n\t\t\treturn compileCookiePolicy(config, options);\n\t\t}\n\t}\n}\n//#endregion\nexport { compileCookiePolicy, compilePolicy, compilePrivacyPolicy, compileTermsOfService, expandOpenPolicyConfig, isOpenPolicyConfig, validateCookiePolicy, validatePrivacyPolicy, validateTermsOfService };\n\n//# sourceMappingURL=index.js.map","import { access, mkdir, writeFile } from \"node:fs/promises\";\nimport { join, resolve } from \"node:path\";\nimport type { OpenPolicyConfig, OutputFormat } from \"@openpolicy/core\";\nimport {\n\tcompilePolicy,\n\texpandOpenPolicyConfig,\n\tisOpenPolicyConfig,\n\tvalidateCookiePolicy,\n\tvalidatePrivacyPolicy,\n\tvalidateTermsOfService,\n} from \"@openpolicy/core\";\nimport type { Plugin } from \"vite\";\n\nexport interface OpenPolicyOptions {\n\tconfigPath?: string;\n\tformats?: OutputFormat[];\n\toutDir?: string;\n}\n\nexport async function generatePolicies(\n\tconfigPath: string,\n\toutDir: string,\n\tformats: OutputFormat[],\n): Promise<void> {\n\tconst mod = await import(`${configPath}?t=${Date.now()}`);\n\tconst config =\n\t\t(mod as Record<string, unknown>)[\"default\"] ??\n\t\t(mod as Record<string, unknown>)[\"module.exports\"] ??\n\t\tmod;\n\n\tif (config === null || config === undefined || typeof config !== \"object\") {\n\t\tthrow new Error(\n\t\t\t`[openpolicy] Config must export a non-null object: ${configPath}`,\n\t\t);\n\t}\n\n\tif (isOpenPolicyConfig(config)) {\n\t\tconst inputs = expandOpenPolicyConfig(config as OpenPolicyConfig);\n\t\tawait mkdir(outDir, { recursive: true });\n\t\tfor (const input of inputs) {\n\t\t\tconst issues =\n\t\t\t\tinput.type === \"terms\"\n\t\t\t\t\t? validateTermsOfService(input)\n\t\t\t\t\t: input.type === \"cookie\"\n\t\t\t\t\t\t? validateCookiePolicy(input)\n\t\t\t\t\t\t: validatePrivacyPolicy(input);\n\t\t\tfor (const issue of issues) {\n\t\t\t\tif (issue.level === \"error\")\n\t\t\t\t\tthrow new Error(`[openpolicy] ${issue.message}`);\n\t\t\t\tconsole.warn(`[openpolicy] Warning: ${issue.message}`);\n\t\t\t}\n\t\t\tconst results = compilePolicy(input, { formats });\n\t\t\tconst outputFilename =\n\t\t\t\tinput.type === \"terms\"\n\t\t\t\t\t? \"terms-of-service\"\n\t\t\t\t\t: input.type === \"cookie\"\n\t\t\t\t\t\t? \"cookie-policy\"\n\t\t\t\t\t\t: \"privacy-policy\";\n\t\t\tfor (const result of results) {\n\t\t\t\tconst ext = result.format === \"markdown\" ? \"md\" : result.format;\n\t\t\t\tawait writeFile(\n\t\t\t\t\tjoin(outDir, `${outputFilename}.${ext}`),\n\t\t\t\t\tresult.content,\n\t\t\t\t\t\"utf8\",\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\treturn;\n\t}\n\n\tthrow new Error(\n\t\t`[openpolicy] Config must use defineConfig() (OpenPolicyConfig): ${configPath}`,\n\t);\n}\n\nexport function openPolicy(options: OpenPolicyOptions = {}): Plugin {\n\tconst formats: OutputFormat[] = options.formats ?? [\"markdown\"];\n\tconst configFile = options.configPath ?? \"openpolicy.ts\";\n\tlet resolvedOutDir: string;\n\tlet resolvedConfigPath: string;\n\n\treturn {\n\t\tname: \"openpolicy\",\n\n\t\tconfigResolved(config) {\n\t\t\tresolvedOutDir = resolve(\n\t\t\t\tconfig.root,\n\t\t\t\toptions.outDir ?? \"public/policies\",\n\t\t\t);\n\t\t\tresolvedConfigPath = resolve(config.root, configFile);\n\t\t},\n\n\t\tasync buildStart() {\n\t\t\tconst configExists = await access(resolvedConfigPath).then(\n\t\t\t\t() => true,\n\t\t\t\t() => false,\n\t\t\t);\n\t\t\tif (!configExists) {\n\t\t\t\tconsole.warn(`[openpolicy] no configuration file found`);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tawait generatePolicies(resolvedConfigPath, resolvedOutDir, formats);\n\t\t},\n\n\t\tconfigureServer(server) {\n\t\t\tserver.watcher.add(resolvedConfigPath);\n\t\t\tserver.watcher.on(\"change\", async (path) => {\n\t\t\t\tif (path !== resolvedConfigPath) return;\n\t\t\t\ttry {\n\t\t\t\t\tawait generatePolicies(resolvedConfigPath, resolvedOutDir, formats);\n\t\t\t\t\tconsole.log(\"[openpolicy] Policies regenerated\");\n\t\t\t\t} catch (err) {\n\t\t\t\t\tconsole.error(\"[openpolicy]\", err);\n\t\t\t\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IAAI;CACJ,IAAI;AAEJ,QAAO;EACN,MAAM;EAEN,eAAe,QAAQ;AACtB,oBAAiB,QAChB,OAAO,MACP,QAAQ,UAAU,kBAClB;AACD,wBAAqB,QAAQ,OAAO,MAAM,WAAW;;EAGtD,MAAM,aAAa;AAKlB,OAAI,CAJiB,MAAM,OAAO,mBAAmB,CAAC,WAC/C,YACA,MACN,EACkB;AAClB,YAAQ,KAAK,2CAA2C;AACxD;;AAED,SAAM,iBAAiB,oBAAoB,gBAAgB,QAAQ;;EAGpE,gBAAgB,QAAQ;AACvB,UAAO,QAAQ,IAAI,mBAAmB;AACtC,UAAO,QAAQ,GAAG,UAAU,OAAO,SAAS;AAC3C,QAAI,SAAS,mBAAoB;AACjC,QAAI;AACH,WAAM,iBAAiB,oBAAoB,gBAAgB,QAAQ;AACnE,aAAQ,IAAI,oCAAoC;aACxC,KAAK;AACb,aAAQ,MAAM,gBAAgB,IAAI;;KAElC;;EAEH"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../core/dist/index.js","../../renderers/src/index.ts","../src/index.ts"],"sourcesContent":["//#region src/documents/helpers.ts\nconst heading = (value, levelOrContext, context) => {\n\tconst level = typeof levelOrContext === \"number\" ? levelOrContext : void 0;\n\tconst ctx = typeof levelOrContext === \"object\" ? levelOrContext : context;\n\treturn {\n\t\ttype: \"heading\",\n\t\t...level !== void 0 && { level },\n\t\tvalue,\n\t\t...ctx && { context: ctx }\n\t};\n};\nconst text = (value, context) => ({\n\ttype: \"text\",\n\tvalue,\n\t...context && { context }\n});\nconst bold = (value, context) => ({\n\ttype: \"bold\",\n\tvalue,\n\t...context && { context }\n});\nconst italic = (value, context) => ({\n\ttype: \"italic\",\n\tvalue,\n\t...context && { context }\n});\nconst link = (href, value, context) => ({\n\ttype: \"link\",\n\thref,\n\tvalue,\n\t...context && { context }\n});\nconst p = (children, context) => ({\n\ttype: \"paragraph\",\n\tchildren: children.map((c) => typeof c === \"string\" ? text(c) : c),\n\t...context && { context }\n});\nconst li = (children, context) => ({\n\ttype: \"listItem\",\n\tchildren: children.map((c) => typeof c === \"string\" ? text(c) : c),\n\t...context && { context }\n});\nconst ul = (items, context) => ({\n\ttype: \"list\",\n\titems,\n\t...context && { context }\n});\nconst ol = (items, context) => ({\n\ttype: \"list\",\n\tordered: true,\n\titems,\n\t...context && { context }\n});\nconst section = (id, content, context) => ({\n\ttype: \"section\",\n\tid,\n\tcontent,\n\t...context && { context }\n});\n//#endregion\n//#region src/documents/cookie.ts\nfunction buildIntroduction$2(config) {\n\treturn section(\"cookie-introduction\", [heading(\"Cookie Policy\"), p([`This Cookie Policy explains how ${config.company.name} (\"we\", \"us\", or \"our\") uses cookies and similar tracking technologies on our services. Effective Date: ${config.effectiveDate}.`])]);\n}\nfunction buildWhatAreCookies() {\n\treturn section(\"cookie-what-are-cookies\", [\n\t\theading(\"What Are Cookies?\"),\n\t\tp([\"Cookies are small text files placed on your device by websites you visit. They are widely used to make websites work more efficiently and to provide information to site owners.\"]),\n\t\tp([\"Cookies can be \\\"session cookies\\\" (deleted when you close your browser) or \\\"persistent cookies\\\" (remain on your device until they expire or you delete them).\"])\n\t]);\n}\nfunction buildTypes(config) {\n\tconst types = [];\n\tif (config.cookies.essential) types.push({\n\t\tlabel: \"Essential Cookies\",\n\t\tdescription: \"Required for the basic functioning of our services. These cannot be disabled.\"\n\t});\n\tif (config.cookies.analytics) types.push({\n\t\tlabel: \"Analytics Cookies\",\n\t\tdescription: \"Help us understand how visitors interact with our services so we can improve them.\"\n\t});\n\tif (config.cookies.functional) types.push({\n\t\tlabel: \"Functional Cookies\",\n\t\tdescription: \"Enable enhanced functionality and personalisation, such as remembering your preferences.\"\n\t});\n\tif (config.cookies.marketing) types.push({\n\t\tlabel: \"Marketing Cookies\",\n\t\tdescription: \"Used to deliver advertisements more relevant to you and your interests.\"\n\t});\n\tif (types.length === 0) return section(\"cookie-types\", [heading(\"Types of Cookies We Use\"), p([\"We do not currently use any cookies.\"])]);\n\treturn section(\"cookie-types\", [heading(\"Types of Cookies We Use\"), ul(types.map((t) => li([\n\t\tbold(t.label),\n\t\t\" — \",\n\t\tt.description\n\t])))]);\n}\nfunction buildTrackingTechnologies(config) {\n\tif (!config.trackingTechnologies || config.trackingTechnologies.length === 0) return null;\n\treturn section(\"cookie-tracking-technologies\", [\n\t\theading(\"Other Tracking Technologies\"),\n\t\tp([\"In addition to cookies, we may use the following tracking technologies:\"]),\n\t\tul(config.trackingTechnologies.map((t) => li([t])))\n\t]);\n}\nfunction buildThirdParties$1(config) {\n\tif (!config.thirdParties || config.thirdParties.length === 0) return null;\n\treturn section(\"cookie-third-parties\", [\n\t\theading(\"Third-Party Cookies\"),\n\t\tp([\"The following third parties may set cookies through our services:\"]),\n\t\tul(config.thirdParties.map((t) => li([\n\t\t\tbold(t.name),\n\t\t\t\" — \",\n\t\t\tt.purpose,\n\t\t\t...t.policyUrl ? [\n\t\t\t\t\" (\",\n\t\t\t\tlink(t.policyUrl, \"Privacy Policy\"),\n\t\t\t\t\")\"\n\t\t\t] : []\n\t\t])))\n\t]);\n}\nfunction buildConsent(config) {\n\tif (!config.consentMechanism) return null;\n\tconst { hasBanner, hasPreferencePanel, canWithdraw } = config.consentMechanism;\n\tconst items = [];\n\tif (hasBanner) items.push(\"We display a cookie consent banner when you first visit our services.\");\n\tif (hasPreferencePanel) items.push(\"You can manage your cookie preferences at any time via our preference panel.\");\n\tif (canWithdraw) items.push(\"You may withdraw your consent at any time; however, this will not affect the lawfulness of processing based on consent before its withdrawal.\");\n\tif (items.length === 0) return null;\n\treturn section(\"cookie-consent\", [heading(\"Your Consent\"), ul(items.map((i) => li([i])))]);\n}\nfunction buildManaging() {\n\treturn section(\"cookie-managing\", [\n\t\theading(\"Managing Cookies\"),\n\t\tp([\"Most web browsers allow you to control cookies through their settings. You can:\"]),\n\t\tul([\n\t\t\tli([\"Delete cookies already stored on your device\"]),\n\t\t\tli([\"Block cookies from being set on your device\"]),\n\t\t\tli([\"Set your browser to notify you when a cookie is being set\"])\n\t\t]),\n\t\tp([\"Please note that restricting cookies may impact the functionality of our services. Consult your browser's help documentation for instructions on managing cookies.\"])\n\t]);\n}\nfunction buildJurisdictionEu(config) {\n\tif (!config.jurisdictions.includes(\"eu\")) return null;\n\treturn section(\"cookie-jurisdiction-eu\", [\n\t\theading(\"European Users (GDPR)\", { reason: \"Required under ePrivacy Directive and GDPR\" }),\n\t\tp([\"If you are located in the European Economic Area, we rely on your consent as our legal basis for setting non-essential cookies. You have the right to withdraw consent at any time.\"]),\n\t\tp([\"Essential cookies are set on the basis of our legitimate interests to provide you with a functioning service.\"])\n\t]);\n}\nfunction buildContact$2(config) {\n\treturn section(\"cookie-contact\", [\n\t\theading(\"Contact Us\"),\n\t\tp([\"If you have questions about this Cookie Policy, please contact us:\"]),\n\t\tul([\n\t\t\tli([bold(\"Legal Name: \"), config.company.legalName]),\n\t\t\tli([bold(\"Address: \"), config.company.address]),\n\t\t\tli([bold(\"Email: \"), config.company.contact])\n\t\t])\n\t]);\n}\nconst SECTION_BUILDERS$2 = [\n\tbuildIntroduction$2,\n\t() => buildWhatAreCookies(),\n\tbuildTypes,\n\tbuildTrackingTechnologies,\n\tbuildThirdParties$1,\n\tbuildConsent,\n\t() => buildManaging(),\n\tbuildJurisdictionEu,\n\tbuildContact$2\n];\nfunction compileCookieDocument(config) {\n\treturn SECTION_BUILDERS$2.map((builder) => builder(config)).filter((s) => s !== null);\n}\n//#endregion\n//#region src/documents/privacy.ts\nconst RIGHTS_LABELS = {\n\taccess: \"Right to access your personal data\",\n\trectification: \"Right to correct inaccurate data\",\n\terasure: \"Right to request deletion of your data\",\n\tportability: \"Right to receive your data in a portable format\",\n\trestriction: \"Right to restrict how we process your data\",\n\tobjection: \"Right to object to processing\",\n\topt_out_sale: \"Right to opt out of the sale of your personal information\",\n\tnon_discrimination: \"Right to non-discriminatory treatment for exercising your rights\"\n};\nfunction buildIntroduction$1(config) {\n\treturn section(\"introduction\", [\n\t\theading(\"Introduction\"),\n\t\tp([`This Privacy Policy describes how ${config.company.name} (\"we\", \"us\", or \"our\") collects, uses, and shares information about you when you use our services. Effective Date: ${config.effectiveDate}.`]),\n\t\tp([`If you have questions about this policy, please contact us at ${config.company.contact}.`])\n\t]);\n}\nfunction buildChildrenPrivacy(config) {\n\tif (!config.children) return null;\n\tconst { underAge, noticeUrl } = config.children;\n\treturn section(\"children-privacy\", [\n\t\theading(\"Children's Privacy\", { reason: \"Required by COPPA\" }),\n\t\tp([`Our services are not directed to children under the age of ${underAge}. We do not knowingly collect personal information from children under ${underAge}. If you believe we have collected information from a child, please contact us immediately.`]),\n\t\t...noticeUrl ? [p([\n\t\t\t\"For more information, see our \",\n\t\t\tlink(noticeUrl, \"Children's Privacy Notice\"),\n\t\t\t\".\"\n\t\t])] : []\n\t]);\n}\nfunction buildDataCollected(config) {\n\tconst items = Object.entries(config.dataCollected).map(([category, fields]) => li([bold(category), ul(fields.map((f) => li([f])))]));\n\treturn section(\"data-collected\", [\n\t\theading(\"Information We Collect\"),\n\t\tp([\"We collect the following categories of information:\"]),\n\t\tul(items)\n\t]);\n}\nfunction buildLegalBasis(config) {\n\tif (!config.jurisdictions.includes(\"eu\")) return null;\n\treturn section(\"legal-basis\", [heading(\"Legal Basis for Processing\", { reason: \"Required by GDPR Article 13\" }), p([config.legalBasis])]);\n}\nfunction buildDataRetention(config) {\n\tconst items = Object.entries(config.retention).map(([category, period]) => li([\n\t\tbold(category),\n\t\t\": \",\n\t\tperiod\n\t]));\n\treturn section(\"data-retention\", [\n\t\theading(\"Data Retention\"),\n\t\tp([\"We retain your data for the following periods:\"]),\n\t\tul(items)\n\t]);\n}\nfunction buildCookies(config) {\n\tconst enabled = [];\n\tif (config.cookies.essential) enabled.push(\"Essential cookies — required for the service to function\");\n\tif (config.cookies.analytics) enabled.push(\"Analytics cookies — help us understand how the service is used\");\n\tif (config.cookies.marketing) enabled.push(\"Marketing cookies — used to deliver relevant advertisements\");\n\tif (enabled.length === 0) return section(\"cookies\", [heading(\"Cookies and Tracking\"), p([\"We do not use cookies or similar tracking technologies.\"])]);\n\treturn section(\"cookies\", [\n\t\theading(\"Cookies and Tracking\"),\n\t\tp([\"We use the following types of cookies and tracking technologies:\"]),\n\t\tul(enabled.map((e) => li([e])))\n\t]);\n}\nfunction buildThirdParties(config) {\n\tif (config.thirdParties.length === 0) return section(\"third-parties\", [heading(\"Third-Party Services\"), p([\"We do not share your personal information with third parties except as required by law.\"])]);\n\treturn section(\"third-parties\", [\n\t\theading(\"Third-Party Services\"),\n\t\tp([\"We share data with the following third-party services:\"]),\n\t\tul(config.thirdParties.map((t) => li([\n\t\t\tbold(t.name),\n\t\t\t\" — \",\n\t\t\tt.purpose\n\t\t])))\n\t]);\n}\nfunction buildUserRights(config) {\n\tconst items = config.userRights.map((right) => {\n\t\treturn li([RIGHTS_LABELS[right] ?? right]);\n\t});\n\treturn section(\"user-rights\", [\n\t\theading(\"Your Rights\"),\n\t\tp([\"You have the following rights regarding your personal data:\"]),\n\t\tul(items)\n\t]);\n}\nfunction buildGdprSupplement(config) {\n\tif (!config.jurisdictions.includes(\"eu\")) return null;\n\treturn section(\"gdpr-supplement\", [\n\t\theading(\"GDPR Supplemental Disclosures\", { reason: \"Required by GDPR Article 13\" }),\n\t\tp([\"This section applies to individuals in the European Economic Area (EEA) under the General Data Protection Regulation (GDPR).\"]),\n\t\tp([\n\t\t\t\"Data Controller: \",\n\t\t\tbold(config.company.legalName),\n\t\t\t`, ${config.company.address}`\n\t\t]),\n\t\tp([\"In addition to the rights listed above, you have the right to lodge a complaint with your local data protection authority if you believe we have not handled your data in accordance with applicable law.\"]),\n\t\tp([\"If we transfer your personal data outside the EEA, we ensure adequate safeguards are in place in accordance with GDPR requirements.\"])\n\t]);\n}\nfunction buildCcpaSupplement(config) {\n\tif (!config.jurisdictions.includes(\"ca\")) return null;\n\treturn section(\"ccpa-supplement\", [\n\t\theading(\"California Privacy Rights (CCPA)\", { reason: \"Required by CCPA\" }),\n\t\tp([\"If you are a California resident, you have the following additional rights:\"]),\n\t\tul([\n\t\t\tli([\"Right to Know — You may request disclosure of the personal information we collect, use, and share about you.\"]),\n\t\t\tli([\"Right to Delete — You may request deletion of personal information we have collected about you.\"]),\n\t\t\tli([\"Right to Opt-Out — You may opt out of the sale of your personal information.\"]),\n\t\t\tli([\"Right to Non-Discrimination — We will not discriminate against you for exercising your CCPA rights.\"])\n\t\t])\n\t]);\n}\nfunction buildContact$1(config) {\n\treturn section(\"contact\", [\n\t\theading(\"Contact Us\"),\n\t\tp([\"Contact us:\"]),\n\t\tul([\n\t\t\tli([bold(\"Legal Name: \"), config.company.legalName]),\n\t\t\tli([bold(\"Address: \"), config.company.address]),\n\t\t\tli([bold(\"Email: \"), config.company.contact])\n\t\t])\n\t]);\n}\nconst SECTION_BUILDERS$1 = [\n\tbuildIntroduction$1,\n\tbuildChildrenPrivacy,\n\tbuildDataCollected,\n\tbuildLegalBasis,\n\tbuildDataRetention,\n\tbuildCookies,\n\tbuildThirdParties,\n\tbuildUserRights,\n\tbuildGdprSupplement,\n\tbuildCcpaSupplement,\n\tbuildContact$1\n];\nfunction compilePrivacyDocument(config) {\n\treturn SECTION_BUILDERS$1.map((builder) => builder(config)).filter((s) => s !== null);\n}\n//#endregion\n//#region src/documents/terms.ts\nfunction buildIntroduction(config) {\n\treturn section(\"tos-introduction\", [heading(\"Terms of Service\"), p([`These Terms of Service (\"Terms\") govern your use of services provided by ${config.company.name} (\"we\", \"us\", or \"our\"). By using our services, you agree to these Terms. Effective Date: ${config.effectiveDate}.`])]);\n}\nfunction buildAcceptance(config) {\n\treturn section(\"tos-acceptance\", [\n\t\theading(\"Acceptance of Terms\"),\n\t\tp([\"You accept these Terms by:\"]),\n\t\tul(config.acceptance.methods.map((m) => li([m])))\n\t]);\n}\nfunction buildEligibility(config) {\n\tif (!config.eligibility) return null;\n\tconst { minimumAge, jurisdictionRestrictions } = config.eligibility;\n\treturn section(\"tos-eligibility\", [\n\t\theading(\"Eligibility\"),\n\t\tp([`You must be at least ${minimumAge} years old to use our services. By using the services, you represent that you meet this age requirement.`]),\n\t\t...jurisdictionRestrictions && jurisdictionRestrictions.length > 0 ? [p([\"Our services are not available in the following jurisdictions:\"]), ul(jurisdictionRestrictions.map((j) => li([j])))] : []\n\t]);\n}\nfunction buildAccounts(config) {\n\tif (!config.accounts) return null;\n\tconst { registrationRequired, userResponsibleForCredentials, companyCanTerminate } = config.accounts;\n\tconst items = [];\n\tif (registrationRequired) items.push(\"Registration is required to access certain features of our services.\");\n\tif (userResponsibleForCredentials) items.push(\"You are responsible for maintaining the confidentiality of your account credentials and for all activity under your account.\");\n\tif (companyCanTerminate) items.push(\"We reserve the right to terminate or suspend accounts at our discretion.\");\n\treturn section(\"tos-accounts\", [heading(\"Accounts\"), ul(items.map((i) => li([i])))]);\n}\nfunction buildProhibitedUses(config) {\n\tif (!config.prohibitedUses || config.prohibitedUses.length === 0) return null;\n\treturn section(\"tos-prohibited-uses\", [\n\t\theading(\"Prohibited Uses\"),\n\t\tp([\"You may not use our services for the following purposes:\"]),\n\t\tul(config.prohibitedUses.map((u) => li([u])))\n\t]);\n}\nfunction buildUserContent(config) {\n\tif (!config.userContent) return null;\n\tconst { usersOwnContent, licenseGrantedToCompany, licenseDescription, companyCanRemoveContent } = config.userContent;\n\tconst items = [];\n\tif (usersOwnContent) items.push(\"You retain ownership of content you submit to our services.\");\n\tif (licenseGrantedToCompany) items.push(licenseDescription ?? \"By submitting content, you grant us a license to use, reproduce, and display that content in connection with our services.\");\n\tif (companyCanRemoveContent) items.push(\"We reserve the right to remove content that violates these Terms or that we find objectionable.\");\n\treturn section(\"tos-user-content\", [heading(\"User Content\"), ul(items.map((i) => li([i])))]);\n}\nfunction buildIntellectualProperty(config) {\n\tif (!config.intellectualProperty) return null;\n\tconst { companyOwnsService, usersMayNotCopy } = config.intellectualProperty;\n\tconst items = [];\n\tif (companyOwnsService) items.push(`All content, features, and functionality of our services are owned by ${config.company.name} and are protected by intellectual property laws.`);\n\tif (usersMayNotCopy) items.push(\"You may not copy, modify, distribute, sell, or lease any part of our services without our express written permission.\");\n\treturn section(\"tos-intellectual-property\", [heading(\"Intellectual Property\"), ul(items.map((i) => li([i])))]);\n}\nfunction buildPayments(config) {\n\tif (!config.payments) return null;\n\tconst { hasPaidFeatures, refundPolicy, priceChangesNotice } = config.payments;\n\tconst items = [];\n\tif (hasPaidFeatures) items.push(\"Some features of our services require payment.\");\n\tif (refundPolicy) items.push(refundPolicy);\n\tif (priceChangesNotice) items.push(priceChangesNotice);\n\tif (items.length === 0) return null;\n\treturn section(\"tos-payments\", [heading(\"Payments\"), ul(items.map((i) => li([i])))]);\n}\nfunction buildAvailability(config) {\n\tif (!config.availability) return null;\n\tconst { noUptimeGuarantee, maintenanceWindows } = config.availability;\n\tconst items = [];\n\tif (noUptimeGuarantee) items.push(\"We do not guarantee uninterrupted or error-free access to our services.\");\n\tif (maintenanceWindows) items.push(maintenanceWindows);\n\treturn section(\"tos-availability\", [heading(\"Service Availability\"), ul(items.map((i) => li([i])))]);\n}\nfunction buildTermination(config) {\n\tif (!config.termination) return null;\n\tconst { companyCanTerminate, userCanTerminate, effectOfTermination } = config.termination;\n\tconst items = [];\n\tif (companyCanTerminate) items.push(\"We may terminate or suspend your access to our services at any time, with or without cause or notice.\");\n\tif (userCanTerminate) items.push(\"You may terminate your use of our services at any time.\");\n\tif (effectOfTermination) items.push(effectOfTermination);\n\treturn section(\"tos-termination\", [heading(\"Termination\"), ul(items.map((i) => li([i])))]);\n}\nfunction buildDisclaimers(config) {\n\tif (!config.disclaimers) return null;\n\tconst { serviceProvidedAsIs, noWarranties } = config.disclaimers;\n\tconst items = [];\n\tif (serviceProvidedAsIs) items.push(\"Our services are provided on an \\\"as is\\\" and \\\"as available\\\" basis.\");\n\tif (noWarranties) items.push(\"We make no warranties, express or implied, regarding the reliability, accuracy, or fitness for a particular purpose of our services.\");\n\treturn section(\"tos-disclaimers\", [heading(\"Disclaimers\"), ul(items.map((i) => li([i])))]);\n}\nfunction buildLimitationOfLiability(config) {\n\tif (!config.limitationOfLiability) return null;\n\tconst { excludesIndirectDamages, liabilityCap } = config.limitationOfLiability;\n\tconst items = [];\n\tif (excludesIndirectDamages) items.push(\"To the fullest extent permitted by law, we shall not be liable for any indirect, incidental, special, or consequential damages.\");\n\tif (liabilityCap) items.push(liabilityCap);\n\treturn section(\"tos-limitation-of-liability\", [heading(\"Limitation of Liability\"), ul(items.map((i) => li([i])))]);\n}\nfunction buildIndemnification(config) {\n\tif (!config.indemnification) return null;\n\tconst { userIndemnifiesCompany, scope } = config.indemnification;\n\tif (!userIndemnifiesCompany) return null;\n\treturn section(\"tos-indemnification\", [heading(\"Indemnification\"), p([scope ?? `You agree to indemnify and hold harmless ${config.company.name} and its officers, directors, employees, and agents from any claims arising out of your use of the services or violation of these Terms.`])]);\n}\nfunction buildThirdPartyServices(config) {\n\tif (!config.thirdPartyServices || config.thirdPartyServices.length === 0) return null;\n\treturn section(\"tos-third-party-services\", [\n\t\theading(\"Third-Party Services\"),\n\t\tp([\"Our services may integrate with or link to third-party services:\"]),\n\t\tul(config.thirdPartyServices.map((t) => li([\n\t\t\tbold(t.name),\n\t\t\t\" — \",\n\t\t\tt.purpose\n\t\t])))\n\t]);\n}\nfunction buildDisputeResolution(config) {\n\tif (!config.disputeResolution) return null;\n\tconst { method, venue, classActionWaiver } = config.disputeResolution;\n\tconst items = [];\n\tconst methodLabel = method === \"arbitration\" ? \"binding arbitration\" : method === \"mediation\" ? \"mediation\" : \"litigation\";\n\titems.push(`Any disputes arising from these Terms or your use of our services shall be resolved through ${methodLabel}.`);\n\tif (venue) items.push(`Venue: ${venue}.`);\n\tif (classActionWaiver) items.push(\"You waive any right to participate in class action lawsuits or class-wide arbitration.\");\n\treturn section(\"tos-dispute-resolution\", [heading(\"Dispute Resolution\"), ul(items.map((i) => li([i])))]);\n}\nfunction buildGoverningLaw(config) {\n\treturn section(\"tos-governing-law\", [heading(\"Governing Law\"), p([`These Terms are governed by the laws of ${config.governingLaw.jurisdiction}, without regard to conflict of law principles.`])]);\n}\nfunction buildChanges(config) {\n\tif (!config.changesPolicy) return null;\n\tconst { noticeMethod, noticePeriodDays } = config.changesPolicy;\n\tconst notice = noticePeriodDays ? `at least ${noticePeriodDays} days' notice via ${noticeMethod}` : `notice via ${noticeMethod}`;\n\treturn section(\"tos-changes\", [heading(\"Changes to These Terms\"), p([`We may update these Terms from time to time. We will provide ${notice} before changes take effect. Continued use of our services after changes constitutes acceptance of the revised Terms.`])]);\n}\nfunction buildContact(config) {\n\treturn section(\"tos-contact\", [\n\t\theading(\"Contact Us\"),\n\t\tp([\"If you have questions about these Terms, please contact us:\"]),\n\t\tul([\n\t\t\tli([bold(\"Legal Name: \"), config.company.legalName]),\n\t\t\tli([bold(\"Address: \"), config.company.address]),\n\t\t\tli([bold(\"Email: \"), config.company.contact])\n\t\t])\n\t]);\n}\nconst SECTION_BUILDERS = [\n\tbuildIntroduction,\n\tbuildAcceptance,\n\tbuildEligibility,\n\tbuildAccounts,\n\tbuildProhibitedUses,\n\tbuildUserContent,\n\tbuildIntellectualProperty,\n\tbuildPayments,\n\tbuildAvailability,\n\tbuildTermination,\n\tbuildDisclaimers,\n\tbuildLimitationOfLiability,\n\tbuildIndemnification,\n\tbuildThirdPartyServices,\n\tbuildDisputeResolution,\n\tbuildGoverningLaw,\n\tbuildChanges,\n\tbuildContact\n];\nfunction compileTermsDocument(config) {\n\treturn SECTION_BUILDERS.map((builder) => builder(config)).filter((s) => s !== null);\n}\n//#endregion\n//#region src/documents/index.ts\nfunction compile(input) {\n\tif (input.type === \"privacy\") {\n\t\tconst { type: _, ...config } = input;\n\t\treturn {\n\t\t\ttype: \"document\",\n\t\t\tpolicyType: \"privacy\",\n\t\t\tsections: compilePrivacyDocument(config)\n\t\t};\n\t}\n\tif (input.type === \"terms\") {\n\t\tconst { type: _, ...config } = input;\n\t\treturn {\n\t\t\ttype: \"document\",\n\t\t\tpolicyType: \"terms\",\n\t\t\tsections: compileTermsDocument(config)\n\t\t};\n\t}\n\tconst { type: _, ...config } = input;\n\treturn {\n\t\ttype: \"document\",\n\t\tpolicyType: \"cookie\",\n\t\tsections: compileCookieDocument(config)\n\t};\n}\n//#endregion\n//#region src/types.ts\nfunction isOpenPolicyConfig(value) {\n\tif (value === null || typeof value !== \"object\") return false;\n\tconst obj = value;\n\treturn \"company\" in obj && !(\"effectiveDate\" in obj) && (\"privacy\" in obj || \"terms\" in obj || \"cookie\" in obj);\n}\n//#endregion\n//#region src/validate.ts\nfunction validatePrivacyPolicy(config) {\n\tconst issues = [];\n\tif (!config.effectiveDate) issues.push({\n\t\tlevel: \"error\",\n\t\tmessage: \"effectiveDate is required\"\n\t});\n\tif (!config.company.name) issues.push({\n\t\tlevel: \"error\",\n\t\tmessage: \"company.name is required\"\n\t});\n\tif (!config.company.legalName) issues.push({\n\t\tlevel: \"error\",\n\t\tmessage: \"company.legalName is required\"\n\t});\n\tif (!config.company.address) issues.push({\n\t\tlevel: \"error\",\n\t\tmessage: \"company.address is required\"\n\t});\n\tif (!config.company.contact) issues.push({\n\t\tlevel: \"error\",\n\t\tmessage: \"company.contact is required\"\n\t});\n\tif (Object.keys(config.dataCollected).length === 0) issues.push({\n\t\tlevel: \"error\",\n\t\tmessage: \"dataCollected must have at least one entry\"\n\t});\n\tif (config.userRights.length === 0) issues.push({\n\t\tlevel: \"warning\",\n\t\tmessage: \"userRights is empty — consider listing applicable rights\"\n\t});\n\tif (config.jurisdictions.includes(\"eu\")) {\n\t\tif (!config.legalBasis) issues.push({\n\t\t\tlevel: \"error\",\n\t\t\tmessage: \"GDPR requires a legalBasis\"\n\t\t});\n\t\tfor (const right of [\n\t\t\t\"access\",\n\t\t\t\"rectification\",\n\t\t\t\"erasure\",\n\t\t\t\"portability\",\n\t\t\t\"restriction\",\n\t\t\t\"objection\"\n\t\t]) if (!config.userRights.includes(right)) issues.push({\n\t\t\tlevel: \"warning\",\n\t\t\tmessage: `GDPR recommends including the \"${right}\" right`\n\t\t});\n\t}\n\tif (config.jurisdictions.includes(\"ca\")) {\n\t\tfor (const right of [\n\t\t\t\"access\",\n\t\t\t\"erasure\",\n\t\t\t\"opt_out_sale\",\n\t\t\t\"non_discrimination\"\n\t\t]) if (!config.userRights.includes(right)) issues.push({\n\t\t\tlevel: \"warning\",\n\t\t\tmessage: `CCPA recommends including the \"${right}\" right`\n\t\t});\n\t}\n\tif (config.children) {\n\t\tif (config.children.underAge <= 0) issues.push({\n\t\t\tlevel: \"error\",\n\t\t\tmessage: \"children.underAge must be a positive number\"\n\t\t});\n\t}\n\treturn issues;\n}\n//#endregion\n//#region src/validate-cookie.ts\nfunction validateCookiePolicy(config) {\n\tconst issues = [];\n\tif (!config.effectiveDate) issues.push({\n\t\tlevel: \"error\",\n\t\tmessage: \"effectiveDate is required\"\n\t});\n\tif (!config.company.name) issues.push({\n\t\tlevel: \"error\",\n\t\tmessage: \"company.name is required\"\n\t});\n\tif (!config.company.legalName) issues.push({\n\t\tlevel: \"error\",\n\t\tmessage: \"company.legalName is required\"\n\t});\n\tif (!config.company.address) issues.push({\n\t\tlevel: \"error\",\n\t\tmessage: \"company.address is required\"\n\t});\n\tif (!config.company.contact) issues.push({\n\t\tlevel: \"error\",\n\t\tmessage: \"company.contact is required\"\n\t});\n\tconst { essential, analytics, functional, marketing } = config.cookies;\n\tif (!essential && !analytics && !functional && !marketing) issues.push({\n\t\tlevel: \"error\",\n\t\tmessage: \"At least one cookie type must be enabled (essential, analytics, functional, or marketing)\"\n\t});\n\tif (!config.consentMechanism) issues.push({\n\t\tlevel: \"warning\",\n\t\tmessage: \"consentMechanism is not provided — consider describing how users can manage cookie consent\"\n\t});\n\tif (config.jurisdictions.includes(\"eu\") && config.consentMechanism && !config.consentMechanism.canWithdraw) issues.push({\n\t\tlevel: \"warning\",\n\t\tmessage: \"GDPR requires that users can withdraw cookie consent — consider setting consentMechanism.canWithdraw to true\"\n\t});\n\treturn issues;\n}\n//#endregion\n//#region src/validate-terms.ts\nfunction validateTermsOfService(config) {\n\tconst issues = [];\n\tif (!config.effectiveDate) issues.push({\n\t\tlevel: \"error\",\n\t\tmessage: \"effectiveDate is required\"\n\t});\n\tif (!config.company.name) issues.push({\n\t\tlevel: \"error\",\n\t\tmessage: \"company.name is required\"\n\t});\n\tif (!config.company.legalName) issues.push({\n\t\tlevel: \"error\",\n\t\tmessage: \"company.legalName is required\"\n\t});\n\tif (!config.company.address) issues.push({\n\t\tlevel: \"error\",\n\t\tmessage: \"company.address is required\"\n\t});\n\tif (!config.company.contact) issues.push({\n\t\tlevel: \"error\",\n\t\tmessage: \"company.contact is required\"\n\t});\n\tif (!config.governingLaw.jurisdiction) issues.push({\n\t\tlevel: \"error\",\n\t\tmessage: \"governingLaw.jurisdiction is required\"\n\t});\n\tif (!config.disclaimers) issues.push({\n\t\tlevel: \"warning\",\n\t\tmessage: \"disclaimers is missing — consider adding a disclaimer of warranties\"\n\t});\n\tif (!config.limitationOfLiability) issues.push({\n\t\tlevel: \"warning\",\n\t\tmessage: \"limitationOfLiability is missing — consider adding a limitation of liability clause\"\n\t});\n\tif (config.acceptance.methods.length === 0) issues.push({\n\t\tlevel: \"warning\",\n\t\tmessage: \"acceptance.methods is empty — consider listing how users accept these Terms\"\n\t});\n\treturn issues;\n}\n//#endregion\n//#region src/index.ts\nfunction expandOpenPolicyConfig(config) {\n\tconst inputs = [];\n\tif (config.privacy) inputs.push({\n\t\ttype: \"privacy\",\n\t\tcompany: config.company,\n\t\t...config.privacy\n\t});\n\tif (config.terms) inputs.push({\n\t\ttype: \"terms\",\n\t\tcompany: config.company,\n\t\t...config.terms\n\t});\n\tif (config.cookie) inputs.push({\n\t\ttype: \"cookie\",\n\t\tcompany: config.company,\n\t\t...config.cookie\n\t});\n\treturn inputs;\n}\n//#endregion\nexport { bold, compile, expandOpenPolicyConfig, heading, isOpenPolicyConfig, italic, li, link, ol, p, section, text, ul, validateCookiePolicy, validatePrivacyPolicy, validateTermsOfService };\n\n//# sourceMappingURL=index.js.map","import type {\n\tCompileOptions,\n\tOutputFormat,\n\tPolicyInput,\n} from \"@openpolicy/core\";\nimport { compile } from \"@openpolicy/core\";\n\nexport { renderHTML } from \"./html\";\nexport { renderMarkdown } from \"./markdown\";\nexport { renderPDF } from \"./pdf\";\n\nfunction filenameFor(type: PolicyInput[\"type\"], ext: string): string {\n\tswitch (type) {\n\t\tcase \"privacy\":\n\t\t\treturn `privacy-policy.${ext}`;\n\t\tcase \"terms\":\n\t\t\treturn `terms-of-service.${ext}`;\n\t\tcase \"cookie\":\n\t\t\treturn `cookie-policy.${ext}`;\n\t}\n}\n\nexport async function compilePolicy(\n\tinput: PolicyInput,\n\toptions?: CompileOptions,\n): Promise<\n\t{ format: OutputFormat; filename: string; content: string | Buffer }[]\n> {\n\tconst doc = compile(input);\n\tconst formats = options?.formats ?? [\"markdown\"];\n\treturn Promise.all(\n\t\tformats.map(async (format) => {\n\t\t\tswitch (format) {\n\t\t\t\tcase \"markdown\": {\n\t\t\t\t\tconst { renderMarkdown } = await import(\"./markdown\");\n\t\t\t\t\treturn {\n\t\t\t\t\t\tformat,\n\t\t\t\t\t\tfilename: filenameFor(input.type, \"md\"),\n\t\t\t\t\t\tcontent: renderMarkdown(doc),\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tcase \"html\": {\n\t\t\t\t\tconst { renderHTML } = await import(\"./html\");\n\t\t\t\t\treturn {\n\t\t\t\t\t\tformat,\n\t\t\t\t\t\tfilename: filenameFor(input.type, \"html\"),\n\t\t\t\t\t\tcontent: renderHTML(doc),\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tcase \"pdf\": {\n\t\t\t\t\tconst { renderPDF } = await import(\"./pdf\");\n\t\t\t\t\treturn {\n\t\t\t\t\t\tformat,\n\t\t\t\t\t\tfilename: filenameFor(input.type, \"pdf\"),\n\t\t\t\t\t\tcontent: await renderPDF(doc),\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tcase \"jsx\":\n\t\t\t\t\tthrow new Error(\"jsx format is not yet implemented\");\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error(`Format not yet implemented: ${format}`);\n\t\t\t}\n\t\t}),\n\t);\n}\n","import { access, mkdir, writeFile } from \"node:fs/promises\";\nimport { join, resolve } from \"node:path\";\nimport type { OpenPolicyConfig, OutputFormat } from \"@openpolicy/core\";\nimport {\n\texpandOpenPolicyConfig,\n\tisOpenPolicyConfig,\n\tvalidateCookiePolicy,\n\tvalidatePrivacyPolicy,\n\tvalidateTermsOfService,\n} from \"@openpolicy/core\";\nimport { compilePolicy } from \"@openpolicy/renderers\";\nimport type { Plugin } from \"vite\";\n\nexport interface OpenPolicyOptions {\n\tconfigPath?: string;\n\tformats?: OutputFormat[];\n\toutDir?: string;\n}\n\nexport async function generatePolicies(\n\tconfigPath: string,\n\toutDir: string,\n\tformats: OutputFormat[],\n): Promise<void> {\n\tconst mod = await import(`${configPath}?t=${Date.now()}`);\n\tconst config =\n\t\t(mod as Record<string, unknown>)[\"default\"] ??\n\t\t(mod as Record<string, unknown>)[\"module.exports\"] ??\n\t\tmod;\n\n\tif (config === null || config === undefined || typeof config !== \"object\") {\n\t\tthrow new Error(\n\t\t\t`[openpolicy] Config must export a non-null object: ${configPath}`,\n\t\t);\n\t}\n\n\tif (isOpenPolicyConfig(config)) {\n\t\tconst inputs = expandOpenPolicyConfig(config as OpenPolicyConfig);\n\t\tawait mkdir(outDir, { recursive: true });\n\t\tfor (const input of inputs) {\n\t\t\tconst issues =\n\t\t\t\tinput.type === \"terms\"\n\t\t\t\t\t? validateTermsOfService(input)\n\t\t\t\t\t: input.type === \"cookie\"\n\t\t\t\t\t\t? validateCookiePolicy(input)\n\t\t\t\t\t\t: validatePrivacyPolicy(input);\n\t\t\tfor (const issue of issues) {\n\t\t\t\tif (issue.level === \"error\")\n\t\t\t\t\tthrow new Error(`[openpolicy] ${issue.message}`);\n\t\t\t\tconsole.warn(`[openpolicy] Warning: ${issue.message}`);\n\t\t\t}\n\t\t\tconst results = await compilePolicy(input, { formats });\n\t\t\tconst outputFilename =\n\t\t\t\tinput.type === \"terms\"\n\t\t\t\t\t? \"terms-of-service\"\n\t\t\t\t\t: input.type === \"cookie\"\n\t\t\t\t\t\t? \"cookie-policy\"\n\t\t\t\t\t\t: \"privacy-policy\";\n\t\t\tfor (const result of results) {\n\t\t\t\tconst ext = result.format === \"markdown\" ? \"md\" : result.format;\n\t\t\t\tawait writeFile(\n\t\t\t\t\tjoin(outDir, `${outputFilename}.${ext}`),\n\t\t\t\t\tresult.content,\n\t\t\t\t\t\"utf8\",\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\treturn;\n\t}\n\n\tthrow new Error(\n\t\t`[openpolicy] Config must use defineConfig() (OpenPolicyConfig): ${configPath}`,\n\t);\n}\n\nexport function openPolicy(options: OpenPolicyOptions = {}): Plugin {\n\tconst formats: OutputFormat[] = options.formats ?? [\"markdown\"];\n\tconst configFile = options.configPath ?? \"openpolicy.ts\";\n\tlet resolvedOutDir: string;\n\tlet resolvedConfigPath: string;\n\n\treturn {\n\t\tname: \"openpolicy\",\n\n\t\tconfigResolved(config) {\n\t\t\tresolvedOutDir = resolve(\n\t\t\t\tconfig.root,\n\t\t\t\toptions.outDir ?? \"public/policies\",\n\t\t\t);\n\t\t\tresolvedConfigPath = resolve(config.root, configFile);\n\t\t},\n\n\t\tasync buildStart() {\n\t\t\tconst configExists = await access(resolvedConfigPath).then(\n\t\t\t\t() => true,\n\t\t\t\t() => false,\n\t\t\t);\n\t\t\tif (!configExists) {\n\t\t\t\tconsole.warn(`[openpolicy] no configuration file found`);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tawait generatePolicies(resolvedConfigPath, resolvedOutDir, formats);\n\t\t},\n\n\t\tconfigureServer(server) {\n\t\t\tserver.watcher.add(resolvedConfigPath);\n\t\t\tserver.watcher.on(\"change\", async (path) => {\n\t\t\t\tif (path !== resolvedConfigPath) return;\n\t\t\t\ttry {\n\t\t\t\t\tawait generatePolicies(resolvedConfigPath, resolvedOutDir, formats);\n\t\t\t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,MAAM,UAA0B,QAAQ,WAAW,CAAC,WAAW;CAC/D,MAAM,aAAa,QAAQ,cAAc;CACzC,IAAI;CACJ,IAAI;AAEJ,QAAO;EACN,MAAM;EAEN,eAAe,QAAQ;AACtB,oBAAiB,QAChB,OAAO,MACP,QAAQ,UAAU,kBAClB;AACD,wBAAqB,QAAQ,OAAO,MAAM,WAAW;;EAGtD,MAAM,aAAa;AAKlB,OAAI,CAJiB,MAAM,OAAO,mBAAmB,CAAC,WAC/C,YACA,MACN,EACkB;AAClB,YAAQ,KAAK,2CAA2C;AACxD;;AAED,SAAM,iBAAiB,oBAAoB,gBAAgB,QAAQ;;EAGpE,gBAAgB,QAAQ;AACvB,UAAO,QAAQ,IAAI,mBAAmB;AACtC,UAAO,QAAQ,GAAG,UAAU,OAAO,SAAS;AAC3C,QAAI,SAAS,mBAAoB;AACjC,QAAI;AACH,WAAM,iBAAiB,oBAAoB,gBAAgB,QAAQ;AACnE,aAAQ,IAAI,oCAAoC;aACxC,KAAK;AACb,aAAQ,MAAM,gBAAgB,IAAI;;KAElC;;EAEH"}
@@ -0,0 +1,35 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-CiIaOW0V.js";
2
+ //#region ../renderers/src/markdown.ts
3
+ var markdown_exports = /* @__PURE__ */ __exportAll({ renderMarkdown: () => renderMarkdown });
4
+ function renderInline(node) {
5
+ switch (node.type) {
6
+ case "text": return node.value;
7
+ case "bold": return `**${node.value}**`;
8
+ case "italic": return `_${node.value}_`;
9
+ case "link": return `[${node.value}](${node.href})`;
10
+ }
11
+ }
12
+ function renderListItem(item, indent = "", ordered = false, index = 0) {
13
+ const parts = [];
14
+ let nestedList = null;
15
+ for (const child of item.children) if (child.type === "list") nestedList = child;
16
+ else parts.push(renderInline(child));
17
+ const line = `${indent}${ordered ? `${index + 1}.` : "-"} ${parts.join("")}`;
18
+ if (nestedList) return `${line}\n${nestedList.items.map((i, idx) => renderListItem(i, `${indent} `, nestedList.ordered, idx)).join("\n")}`;
19
+ return line;
20
+ }
21
+ function renderMarkdown(doc) {
22
+ return doc.sections.map((section) => {
23
+ return section.content.map((node) => {
24
+ switch (node.type) {
25
+ case "heading": return `${"#".repeat(node.level ?? 2)} ${node.value}`;
26
+ case "paragraph": return node.children.map(renderInline).join("");
27
+ case "list": return node.items.map((item, idx) => renderListItem(item, "", node.ordered, idx)).join("\n");
28
+ }
29
+ }).join("\n\n");
30
+ }).join("\n\n---\n\n");
31
+ }
32
+ //#endregion
33
+ export { markdown_exports as t };
34
+
35
+ //# sourceMappingURL=markdown-8LgFTJSZ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markdown-8LgFTJSZ.js","names":[],"sources":["../../renderers/src/markdown.ts"],"sourcesContent":["import type {\n\tDocument,\n\tInlineNode,\n\tListItemNode,\n\tListNode,\n} from \"@openpolicy/core\";\n\nfunction renderInline(node: InlineNode): string {\n\tswitch (node.type) {\n\t\tcase \"text\":\n\t\t\treturn node.value;\n\t\tcase \"bold\":\n\t\t\treturn `**${node.value}**`;\n\t\tcase \"italic\":\n\t\t\treturn `_${node.value}_`;\n\t\tcase \"link\":\n\t\t\treturn `[${node.value}](${node.href})`;\n\t}\n}\n\nfunction renderListItem(\n\titem: ListItemNode,\n\tindent = \"\",\n\tordered = false,\n\tindex = 0,\n): string {\n\tconst parts: string[] = [];\n\tlet nestedList: ListNode | null = null;\n\tfor (const child of item.children) {\n\t\tif (child.type === \"list\") {\n\t\t\tnestedList = child;\n\t\t} else {\n\t\t\tparts.push(renderInline(child));\n\t\t}\n\t}\n\tconst bullet = ordered ? `${index + 1}.` : \"-\";\n\tconst line = `${indent}${bullet} ${parts.join(\"\")}`;\n\tif (nestedList) {\n\t\tconst nested = nestedList.items\n\t\t\t.map((i, idx) =>\n\t\t\t\trenderListItem(i, `${indent} `, nestedList!.ordered, idx),\n\t\t\t)\n\t\t\t.join(\"\\n\");\n\t\treturn `${line}\\n${nested}`;\n\t}\n\treturn line;\n}\n\nexport function renderMarkdown(doc: Document): string {\n\treturn doc.sections\n\t\t.map((section) => {\n\t\t\t// biome-ignore lint/suspicious/useIterableCallbackReturn: typed\n\t\t\tconst blocks = section.content.map((node) => {\n\t\t\t\tswitch (node.type) {\n\t\t\t\t\tcase \"heading\": {\n\t\t\t\t\t\tconst hashes = \"#\".repeat(node.level ?? 2);\n\t\t\t\t\t\treturn `${hashes} ${node.value}`;\n\t\t\t\t\t}\n\t\t\t\t\tcase \"paragraph\":\n\t\t\t\t\t\treturn node.children.map(renderInline).join(\"\");\n\t\t\t\t\tcase \"list\":\n\t\t\t\t\t\treturn node.items\n\t\t\t\t\t\t\t.map((item, idx) => renderListItem(item, \"\", node.ordered, idx))\n\t\t\t\t\t\t\t.join(\"\\n\");\n\t\t\t\t}\n\t\t\t});\n\t\t\treturn blocks.join(\"\\n\\n\");\n\t\t})\n\t\t.join(\"\\n\\n---\\n\\n\");\n}\n"],"mappings":";;;AAOA,SAAS,aAAa,MAA0B;AAC/C,SAAQ,KAAK,MAAb;EACC,KAAK,OACJ,QAAO,KAAK;EACb,KAAK,OACJ,QAAO,KAAK,KAAK,MAAM;EACxB,KAAK,SACJ,QAAO,IAAI,KAAK,MAAM;EACvB,KAAK,OACJ,QAAO,IAAI,KAAK,MAAM,IAAI,KAAK,KAAK;;;AAIvC,SAAS,eACR,MACA,SAAS,IACT,UAAU,OACV,QAAQ,GACC;CACT,MAAM,QAAkB,EAAE;CAC1B,IAAI,aAA8B;AAClC,MAAK,MAAM,SAAS,KAAK,SACxB,KAAI,MAAM,SAAS,OAClB,cAAa;KAEb,OAAM,KAAK,aAAa,MAAM,CAAC;CAIjC,MAAM,OAAO,GAAG,SADD,UAAU,GAAG,QAAQ,EAAE,KAAK,IACX,GAAG,MAAM,KAAK,GAAG;AACjD,KAAI,WAMH,QAAO,GAAG,KAAK,IALA,WAAW,MACxB,KAAK,GAAG,QACR,eAAe,GAAG,GAAG,OAAO,KAAK,WAAY,SAAS,IAAI,CAC1D,CACA,KAAK,KAAK;AAGb,QAAO;;AAGR,SAAgB,eAAe,KAAuB;AACrD,QAAO,IAAI,SACT,KAAK,YAAY;AAgBjB,SAde,QAAQ,QAAQ,KAAK,SAAS;AAC5C,WAAQ,KAAK,MAAb;IACC,KAAK,UAEJ,QAAO,GADQ,IAAI,OAAO,KAAK,SAAS,EAAE,CACzB,GAAG,KAAK;IAE1B,KAAK,YACJ,QAAO,KAAK,SAAS,IAAI,aAAa,CAAC,KAAK,GAAG;IAChD,KAAK,OACJ,QAAO,KAAK,MACV,KAAK,MAAM,QAAQ,eAAe,MAAM,IAAI,KAAK,SAAS,IAAI,CAAC,CAC/D,KAAK,KAAK;;IAEb,CACY,KAAK,OAAO;GACzB,CACD,KAAK,cAAc"}
@@ -0,0 +1,93 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-CiIaOW0V.js";
2
+ import PDFDocument from "pdfkit";
3
+ //#region ../renderers/src/pdf.ts
4
+ var pdf_exports = /* @__PURE__ */ __exportAll({ renderPDF: () => renderPDF });
5
+ const FONT_REGULAR = "Helvetica";
6
+ const FONT_BOLD = "Helvetica-Bold";
7
+ const FONT_ITALIC = "Helvetica-Oblique";
8
+ const SIZE_HEADING_BASE = 16;
9
+ const SIZE_BODY = 11;
10
+ const COLOR_BODY = "#374151";
11
+ const COLOR_HEADING = "#111827";
12
+ const COLOR_LINK = "#2563eb";
13
+ function headingSize(level) {
14
+ return Math.max(10, SIZE_HEADING_BASE - (level - 1) * 1.5);
15
+ }
16
+ function renderInlineNodes(doc, nodes) {
17
+ for (let i = 0; i < nodes.length; i++) {
18
+ const node = nodes[i];
19
+ const continued = i < nodes.length - 1;
20
+ switch (node.type) {
21
+ case "text":
22
+ doc.font(FONT_REGULAR).fillColor(COLOR_BODY).text(node.value, { continued });
23
+ break;
24
+ case "bold":
25
+ doc.font(FONT_BOLD).fillColor(COLOR_HEADING).text(node.value, { continued });
26
+ break;
27
+ case "italic":
28
+ doc.font(FONT_ITALIC).fillColor(COLOR_BODY).text(node.value, { continued });
29
+ break;
30
+ case "link":
31
+ doc.font(FONT_REGULAR).fillColor(COLOR_LINK).text(node.value, {
32
+ continued,
33
+ link: node.href,
34
+ underline: true
35
+ });
36
+ doc.fillColor(COLOR_BODY);
37
+ break;
38
+ }
39
+ }
40
+ }
41
+ function renderListItem(doc, item, depth, ordered, index) {
42
+ const indent = doc.page.margins.left + 10 + depth * 15;
43
+ const bullet = ordered ? `${index + 1}.` : depth === 0 ? "•" : "◦";
44
+ const inlineNodes = item.children.filter((c) => c.type !== "list");
45
+ const nested = item.children.find((c) => c.type === "list") ?? null;
46
+ doc.font(FONT_REGULAR).fontSize(SIZE_BODY).fillColor(COLOR_BODY).text(`${bullet} `, {
47
+ continued: true,
48
+ indent
49
+ });
50
+ if (inlineNodes.length > 0) renderInlineNodes(doc, inlineNodes);
51
+ else doc.text("");
52
+ if (nested) for (let i = 0; i < nested.items.length; i++) renderListItem(doc, nested.items[i], depth + 1, nested.ordered ?? false, i);
53
+ }
54
+ function renderSection(doc, section, isFirst) {
55
+ if (!isFirst) {
56
+ doc.moveDown(.5);
57
+ doc.moveTo(doc.page.margins.left, doc.y).lineTo(doc.page.width - doc.page.margins.right, doc.y).strokeColor("#e5e7eb").lineWidth(.5).stroke();
58
+ doc.moveDown(.5);
59
+ }
60
+ for (const node of section.content) switch (node.type) {
61
+ case "heading":
62
+ doc.font(FONT_BOLD).fontSize(headingSize(node.level ?? 2)).fillColor(COLOR_HEADING).text(node.value).moveDown(.3);
63
+ break;
64
+ case "paragraph":
65
+ doc.font(FONT_REGULAR).fontSize(SIZE_BODY);
66
+ renderInlineNodes(doc, node.children);
67
+ doc.moveDown(.3);
68
+ break;
69
+ case "list":
70
+ doc.fontSize(SIZE_BODY);
71
+ for (let i = 0; i < node.items.length; i++) renderListItem(doc, node.items[i], 0, node.ordered ?? false, i);
72
+ doc.moveDown(.3);
73
+ break;
74
+ }
75
+ }
76
+ function renderPDF(document) {
77
+ return new Promise((resolve, reject) => {
78
+ const pdf = new PDFDocument({
79
+ margin: 50,
80
+ size: "A4"
81
+ });
82
+ const chunks = [];
83
+ pdf.on("data", (chunk) => chunks.push(chunk));
84
+ pdf.on("end", () => resolve(Buffer.concat(chunks)));
85
+ pdf.on("error", reject);
86
+ for (let i = 0; i < document.sections.length; i++) renderSection(pdf, document.sections[i], i === 0);
87
+ pdf.end();
88
+ });
89
+ }
90
+ //#endregion
91
+ export { pdf_exports as t };
92
+
93
+ //# sourceMappingURL=pdf-CTsnJvZX.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pdf-CTsnJvZX.js","names":[],"sources":["../../renderers/src/pdf.ts"],"sourcesContent":["import type {\n\tDocument,\n\tDocumentSection,\n\tInlineNode,\n\tListItemNode,\n\tListNode,\n} from \"@openpolicy/core\";\nimport PDFDocument from \"pdfkit\";\n\nconst FONT_REGULAR = \"Helvetica\";\nconst FONT_BOLD = \"Helvetica-Bold\";\nconst FONT_ITALIC = \"Helvetica-Oblique\";\nconst SIZE_HEADING_BASE = 16;\nconst SIZE_BODY = 11;\nconst COLOR_BODY = \"#374151\";\nconst COLOR_HEADING = \"#111827\";\nconst COLOR_LINK = \"#2563eb\";\n\nfunction headingSize(level: number): number {\n\t// H1=16, H2=14, H3=13, H4=12, H5=11, H6=10\n\treturn Math.max(10, SIZE_HEADING_BASE - (level - 1) * 1.5);\n}\n\nfunction renderInlineNodes(\n\tdoc: InstanceType<typeof PDFDocument>,\n\tnodes: InlineNode[],\n): void {\n\tfor (let i = 0; i < nodes.length; i++) {\n\t\tconst node = nodes[i];\n\t\tconst continued = i < nodes.length - 1;\n\t\tswitch (node!.type) {\n\t\t\tcase \"text\":\n\t\t\t\tdoc\n\t\t\t\t\t.font(FONT_REGULAR)\n\t\t\t\t\t.fillColor(COLOR_BODY)\n\t\t\t\t\t.text(node!.value, { continued });\n\t\t\t\tbreak;\n\t\t\tcase \"bold\":\n\t\t\t\tdoc\n\t\t\t\t\t.font(FONT_BOLD)\n\t\t\t\t\t.fillColor(COLOR_HEADING)\n\t\t\t\t\t.text(node!.value, { continued });\n\t\t\t\tbreak;\n\t\t\tcase \"italic\":\n\t\t\t\tdoc\n\t\t\t\t\t.font(FONT_ITALIC)\n\t\t\t\t\t.fillColor(COLOR_BODY)\n\t\t\t\t\t.text(node!.value, { continued });\n\t\t\t\tbreak;\n\t\t\tcase \"link\":\n\t\t\t\tdoc\n\t\t\t\t\t.font(FONT_REGULAR)\n\t\t\t\t\t.fillColor(COLOR_LINK)\n\t\t\t\t\t.text(node!.value, { continued, link: node!.href, underline: true });\n\t\t\t\tdoc.fillColor(COLOR_BODY);\n\t\t\t\tbreak;\n\t\t}\n\t}\n}\n\nfunction renderListItem(\n\tdoc: InstanceType<typeof PDFDocument>,\n\titem: ListItemNode,\n\tdepth: number,\n\tordered: boolean,\n\tindex: number,\n): void {\n\tconst indent = doc.page.margins.left + 10 + depth * 15;\n\tconst bullet = ordered ? `${index + 1}.` : depth === 0 ? \"•\" : \"◦\";\n\n\tconst inlineNodes = item.children.filter(\n\t\t(c): c is InlineNode => c.type !== \"list\",\n\t);\n\tconst nested =\n\t\titem.children.find((c): c is ListNode => c.type === \"list\") ?? null;\n\n\tdoc\n\t\t.font(FONT_REGULAR)\n\t\t.fontSize(SIZE_BODY)\n\t\t.fillColor(COLOR_BODY)\n\t\t.text(`${bullet} `, { continued: true, indent });\n\n\tif (inlineNodes.length > 0) {\n\t\trenderInlineNodes(doc, inlineNodes);\n\t} else {\n\t\tdoc.text(\"\");\n\t}\n\n\tif (nested) {\n\t\tfor (let i = 0; i < nested.items.length; i++) {\n\t\t\trenderListItem(\n\t\t\t\tdoc,\n\t\t\t\tnested.items[i]!,\n\t\t\t\tdepth + 1,\n\t\t\t\tnested.ordered ?? false,\n\t\t\t\ti,\n\t\t\t);\n\t\t}\n\t}\n}\n\nfunction renderSection(\n\tdoc: InstanceType<typeof PDFDocument>,\n\tsection: DocumentSection,\n\tisFirst: boolean,\n): void {\n\tif (!isFirst) {\n\t\tdoc.moveDown(0.5);\n\t\tdoc\n\t\t\t.moveTo(doc.page.margins.left, doc.y)\n\t\t\t.lineTo(doc.page.width - doc.page.margins.right, doc.y)\n\t\t\t.strokeColor(\"#e5e7eb\")\n\t\t\t.lineWidth(0.5)\n\t\t\t.stroke();\n\t\tdoc.moveDown(0.5);\n\t}\n\n\tfor (const node of section.content) {\n\t\tswitch (node.type) {\n\t\t\tcase \"heading\":\n\t\t\t\tdoc\n\t\t\t\t\t.font(FONT_BOLD)\n\t\t\t\t\t.fontSize(headingSize(node.level ?? 2))\n\t\t\t\t\t.fillColor(COLOR_HEADING)\n\t\t\t\t\t.text(node.value)\n\t\t\t\t\t.moveDown(0.3);\n\t\t\t\tbreak;\n\t\t\tcase \"paragraph\":\n\t\t\t\tdoc.font(FONT_REGULAR).fontSize(SIZE_BODY);\n\t\t\t\trenderInlineNodes(doc, node.children);\n\t\t\t\tdoc.moveDown(0.3);\n\t\t\t\tbreak;\n\t\t\tcase \"list\":\n\t\t\t\tdoc.fontSize(SIZE_BODY);\n\t\t\t\tfor (let i = 0; i < node.items.length; i++) {\n\t\t\t\t\trenderListItem(doc, node.items[i]!, 0, node.ordered ?? false, i);\n\t\t\t\t}\n\t\t\t\tdoc.moveDown(0.3);\n\t\t\t\tbreak;\n\t\t}\n\t}\n}\n\nexport function renderPDF(document: Document): Promise<Buffer> {\n\treturn new Promise<Buffer>((resolve, reject) => {\n\t\tconst pdf = new PDFDocument({ margin: 50, size: \"A4\" });\n\t\tconst chunks: Buffer[] = [];\n\t\tpdf.on(\"data\", (chunk: Buffer) => chunks.push(chunk));\n\t\tpdf.on(\"end\", () => resolve(Buffer.concat(chunks)));\n\t\tpdf.on(\"error\", reject);\n\n\t\tfor (let i = 0; i < document.sections.length; i++) {\n\t\t\trenderSection(pdf, document.sections[i]!, i === 0);\n\t\t}\n\n\t\tpdf.end();\n\t});\n}\n"],"mappings":";;;;AASA,MAAM,eAAe;AACrB,MAAM,YAAY;AAClB,MAAM,cAAc;AACpB,MAAM,oBAAoB;AAC1B,MA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ACnD,MAAI,GAAG,SAAS,OAAO;AAEvB,OAAK,IAAI,IAAI,GAAG,IAAI,SAAS,SAAS,QAAQ,IAC7C,eAAc,KAAK,SAAS,SAAS,IAAK,MAAM,EAAE;AAGnD,MAAI,KAAK;GACR"}
@@ -0,0 +1,13 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __defProp = Object.defineProperty;
3
+ var __exportAll = (all, no_symbols) => {
4
+ let target = {};
5
+ for (var name in all) __defProp(target, name, {
6
+ get: all[name],
7
+ enumerable: true
8
+ });
9
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
10
+ return target;
11
+ };
12
+ //#endregion
13
+ export { __exportAll as t };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openpolicy/vite",
3
- "version": "0.0.12",
3
+ "version": "0.0.15",
4
4
  "type": "module",
5
5
  "description": "Vite plugin for compiling OpenPolicy privacy policy documents at build time",
6
6
  "license": "GPL-3.0-only",
@@ -33,6 +33,7 @@
33
33
  },
34
34
  "devDependencies": {
35
35
  "@openpolicy/core": "workspace:*",
36
+ "@openpolicy/renderers": "workspace:*",
36
37
  "@openpolicy/tooling": "workspace:*",
37
38
  "vite": "^5.0.0"
38
39
  }
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=index.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../src/index.test.ts"],"names":[],"mappings":""}