@paprize/react 0.0.3 → 0.0.5

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paprize-react.js","sources":["../src/components/ReportPreview.tsx","../src/internal/useReportBuilder.ts","../src/components/ReportRoot.tsx","../src/components/PageContent.tsx","../src/components/PageFooter.tsx","../src/components/PageHeader.tsx","../src/components/SectionFooter.tsx","../src/components/SectionHeader.tsx","../src/components/PageOverlay.tsx","../src/internal/parseSectionChildren.ts","../src/internal/SectionIdContext.ts","../src/internal/PageInfoContext.ts","../src/components/Page.tsx","../src/internal/SectionControllerContext.ts","../src/internal/useSectionControllerState.tsx","../src/internal/SectionLayout.tsx","../src/components/Section.tsx","../src/components/PageBreak.tsx","../src/components/Layout.tsx","../src/components/usePageInfo.ts","../src/components/useSectionInfo.ts","../src/internal/eventHelper.ts","../src/components/useReportInfo.ts","../src/components/useSectionSuspension.ts","../src/components/useJsonData.ts"],"sourcesContent":["import type { ReactNode } from 'react';\nimport { previewClassName } from '@paprize/core/src';\n\n/**\n * ReportPreview is a wrapper component that applies styles to its children, mimicking the appearance of the Chrome Print Preview screen.\n * Use this component to render reports or documents with a print-friendly layout and consistent visual formatting in client side application.\n */\nexport function ReportPreview({ children }: { children: ReactNode }) {\n return <div className={previewClassName}>{children}</div>;\n}\n","import type { ReportBuilder } from '@paprize/core/src';\nimport { createContext, useContext } from 'react';\n\nexport const ReportBuilderContext = createContext<ReportBuilder | null>(null);\n\nexport function useReportBuilder() {\n const context = useContext(ReportBuilderContext);\n if (!context) {\n throw new Error(\n 'ReportRoot is missing. Please wrap your component tree with ReportRoot component.'\n );\n }\n\n return context;\n}\n","import { useEffect, useMemo, type ReactNode } from 'react';\nimport { ReportBuilder } from '@paprize/core/src';\nimport { ReportBuilderContext } from '../internal/useReportBuilder';\n\nexport interface ReportRootProps {\n children: ReactNode;\n}\n\nexport function ReportRoot({ children }: ReportRootProps) {\n const reportBuilder = useMemo(() => new ReportBuilder(), []);\n\n useEffect(() => {\n reportBuilder.schedulePaginate();\n }, [reportBuilder]);\n\n return (\n <ReportBuilderContext value={reportBuilder}>\n {children}\n </ReportBuilderContext>\n );\n}\n","import { useEffect, useRef, type ReactNode } from 'react';\nimport { useReportBuilder } from '../internal/useReportBuilder';\n\nexport function PageContent({ children }: { children: ReactNode }) {\n const reportBuilder = useReportBuilder();\n const isFirstCycleCompleted = useRef(false);\n\n useEffect(() => {\n const unsubscribe = reportBuilder.monitor.addEventListener(\n 'paginationCycleCompleted',\n () => {\n isFirstCycleCompleted.current = true;\n }\n );\n\n return () => unsubscribe();\n }, [reportBuilder.monitor]);\n\n // If the children change after the first pagination cycle, we need to re-paginate\n // this can happen if the content is dynamic or loaded asynchronously\n // if we don't do this, the new content will be ignored in the pagination\n useEffect(() => {\n if (isFirstCycleCompleted.current) {\n reportBuilder.schedulePaginate();\n }\n }, [children, reportBuilder]);\n\n return <>{children}</>;\n}\n","export function PageFooter({ children }: { children: React.ReactNode }) {\n return <>{children}</>;\n}\n","import type { ReactNode } from 'react';\n\nexport function PageHeader({ children }: { children: ReactNode }) {\n return <>{children}</>;\n}\n","export function SectionFooter({ children }: { children: React.ReactNode }) {\n return <>{children}</>;\n}\n","export function SectionHeader({ children }: { children: React.ReactNode }) {\n return <>{children}</>;\n}\n","import type { ReactNode } from 'react';\n\nexport function PageOverlay({ children }: { children: ReactNode }) {\n return <>{children}</>;\n}\n","import {\n Children,\n isValidElement,\n type FC,\n type ReactElement,\n type ReactNode,\n} from 'react';\nimport { PageContent } from '../components/PageContent';\nimport { PageFooter } from '../components/PageFooter';\nimport { PageHeader } from '../components/PageHeader';\nimport { SectionFooter } from '../components/SectionFooter';\nimport { SectionHeader } from '../components/SectionHeader';\nimport { PageOverlay } from '../components/PageOverlay';\n\nconst validChildren: FC<{ children: ReactNode }>[] = [\n PageContent,\n PageHeader,\n PageFooter,\n PageOverlay,\n SectionHeader,\n SectionFooter,\n];\n\nexport interface PageElements {\n content: ReactElement;\n header?: ReactElement;\n footer?: ReactElement;\n overlay?: ReactElement;\n sectionHeader?: ReactElement;\n sectionFooter?: ReactElement;\n}\n\nfunction parseSectionChildren(children: ReactNode): PageElements {\n let content: ReactElement | null = null;\n const pageElements: Partial<PageElements> = {};\n\n Children.forEach(children, (child) => {\n if (!isValidElement(child)) {\n throw new Error(\n `Invalid React element found in children: ${child}`,\n {\n cause: { child },\n }\n );\n }\n\n const component = validChildren.find((x) => x === child.type);\n if (!component) {\n throw Error(\n `Component \"${child.type}\" is not valid as a child for Section, Expected one of: ${validChildren\n .map((x) => x.name)\n .join(',')}`\n );\n }\n\n switch (component) {\n case SectionHeader:\n pageElements.sectionHeader = child;\n break;\n\n case SectionFooter:\n pageElements.sectionFooter = child;\n break;\n\n case PageContent:\n content = child;\n break;\n\n case PageHeader:\n pageElements.header = child;\n break;\n\n case PageFooter:\n pageElements.footer = child;\n break;\n\n case PageOverlay:\n pageElements.overlay = child;\n break;\n }\n });\n\n if (!content) {\n throw Error('PageContent component is a required child for Section');\n }\n\n return { ...pageElements, content: content };\n}\n\nexport default parseSectionChildren;\n","import { createContext } from 'react';\n\nexport const SectionIdContext = createContext<string>('');\n","import { createContext } from 'react';\n\nexport const PageInfoContext = createContext<{\n pageIndex: number;\n totalPages: number;\n}>({\n pageIndex: 0,\n totalPages: 0,\n});\n","import { useContext, useMemo, type Ref } from 'react';\nimport { type PageElements } from '../internal/parseSectionChildren';\nimport { PageInfoContext } from '../internal/PageInfoContext';\nimport { SectionIdContext } from '../internal/SectionIdContext';\nimport {\n pageClassName,\n pageMargin,\n reportStyles,\n type PageDimension,\n type PageMargin,\n} from '@paprize/core/src';\n\nexport interface PageProps {\n elements: PageElements;\n dimension: PageDimension;\n margin?: PageMargin;\n pageIndex: number;\n totalPages: number;\n ref?: Ref<HTMLDivElement>;\n sectionHeaderRef?: Ref<HTMLDivElement>;\n sectionFooterRef?: Ref<HTMLDivElement>;\n pageHeaderRef?: Ref<HTMLDivElement>;\n pageFooterRef?: Ref<HTMLDivElement>;\n contentRef?: Ref<HTMLDivElement>;\n}\n\nexport function Page({\n elements,\n dimension,\n margin,\n pageIndex,\n totalPages,\n ref,\n sectionHeaderRef,\n sectionFooterRef,\n pageHeaderRef,\n pageFooterRef,\n contentRef,\n}: PageProps) {\n const sectionId = useContext(SectionIdContext);\n const contextValue = useMemo(\n () => ({ pageIndex, totalPages }),\n [pageIndex, totalPages]\n );\n\n return (\n <PageInfoContext value={contextValue}>\n <div\n id={`${sectionId}-${pageIndex}`}\n className={pageClassName}\n ref={ref}\n style={reportStyles.page(dimension, margin ?? pageMargin.None)}\n >\n {elements.sectionHeader && pageIndex === 0 && (\n <div style={reportStyles.component} ref={sectionHeaderRef}>\n {elements.sectionHeader}\n </div>\n )}\n {elements.header && (\n <div style={reportStyles.component} ref={pageHeaderRef}>\n {elements.header}\n </div>\n )}\n\n <div style={reportStyles.pageContent} ref={contentRef}>\n {elements.content}\n </div>\n\n {elements.overlay && (\n <div style={reportStyles.overlay}>{elements.overlay}</div>\n )}\n\n {(elements.footer || elements.sectionFooter) && (\n <div\n style={{ ...reportStyles.component, marginTop: 'auto' }}\n >\n {elements.footer && (\n <div\n style={reportStyles.component}\n ref={pageFooterRef}\n >\n {elements.footer}\n </div>\n )}\n {elements.sectionFooter &&\n pageIndex === totalPages - 1 && (\n <div\n style={reportStyles.component}\n ref={sectionFooterRef}\n >\n {elements.sectionFooter}\n </div>\n )}\n </div>\n )}\n </div>\n </PageInfoContext>\n );\n}\n","import type { PaginationPlugin } from '@paprize/core/src';\nimport { createContext } from 'react';\n\nexport interface SectionController {\n addPlugin: (plugin: PaginationPlugin) => void;\n addSuspense: (suspense: Promise<void>) => void;\n}\n\nexport const SectionControllerContext = createContext<SectionController>({\n addPlugin: () => {\n throw new Error('addPlugin must be used within a Section');\n },\n addSuspense: () => {\n throw new Error('addSuspense must be used within a Section');\n },\n});\n","import { useMemo } from 'react';\nimport { type SectionController } from './SectionControllerContext';\nimport type { PaginationPlugin } from '@paprize/core/src';\n\nexport function useSectionControllerState(plugins?: PaginationPlugin[]) {\n const state = useMemo(\n () => ({\n plugins: plugins ?? ([] as PaginationPlugin[]),\n suspense: [] as Promise<void>[],\n }),\n [plugins]\n );\n\n const sectionController: SectionController = useMemo(\n () => ({\n addPlugin: (plugin: PaginationPlugin) => {\n state.plugins.push(plugin);\n },\n addSuspense: (suspense: Promise<void>) => {\n state.suspense.push(suspense);\n },\n }),\n [state]\n );\n\n return {\n controllerState: state,\n controllerValue: sectionController,\n };\n}\n","import {\n reportStyles,\n type PageContext,\n type PageDimension,\n type PageMargin,\n type PaginationConfig,\n} from '@paprize/core/src';\nimport { useContext, useEffect, useRef, useState } from 'react';\nimport { createPortal } from 'react-dom';\nimport { Page } from '../components/Page';\nimport { useReportBuilder } from './useReportBuilder';\nimport { SectionIdContext } from './SectionIdContext';\nimport type { PageElements } from './parseSectionChildren';\nimport { useSectionControllerState } from './useSectionControllerState';\nimport { SectionControllerContext } from './SectionControllerContext';\n\nexport interface SectionLayoutProps {\n elements: PageElements;\n dimension: PageDimension;\n margin: PageMargin | undefined;\n config?: Partial<PaginationConfig>;\n}\n\nexport function SectionLayout({\n elements,\n dimension,\n margin,\n config,\n}: SectionLayoutProps) {\n const sectionId = useContext(SectionIdContext);\n const { controllerState, controllerValue } = useSectionControllerState(\n config?.plugins\n );\n const reportBuilder = useReportBuilder();\n const pageRef = useRef<HTMLDivElement>(null);\n const sectionHeaderRef = useRef<HTMLDivElement>(null);\n const sectionFooterRef = useRef<HTMLDivElement>(null);\n const pageHeaderRef = useRef<HTMLDivElement>(null);\n const pageFooterRef = useRef<HTMLDivElement>(null);\n const contentRef = useRef<HTMLDivElement>(null);\n const [pageContexts, setPageContexts] = useState<PageContext[] | null>(\n null\n );\n\n useEffect(() => {\n if (!contentRef.current) {\n return;\n }\n\n reportBuilder.tryAddSection(\n {\n ...config,\n id: sectionId,\n dimension: dimension,\n margin: margin,\n plugins: controllerState.plugins,\n suspense: controllerState.suspense,\n },\n {\n pageContent: contentRef.current,\n sectionHeader: sectionHeaderRef.current,\n sectionFooter: sectionFooterRef.current,\n pageFooter: pageFooterRef.current,\n pageHeader: pageHeaderRef.current,\n },\n (pages) => {\n setPageContexts(pages);\n }\n );\n\n return () => {\n reportBuilder.removeSection(sectionId);\n };\n }, [config, controllerState, dimension, margin, reportBuilder, sectionId]);\n\n return (\n <SectionControllerContext value={controllerValue}>\n {pageContexts?.map((pageContext) => (\n <Page\n key={pageContext.index}\n elements={{\n ...elements,\n content: (\n <div\n style={{ display: 'contents' }}\n dangerouslySetInnerHTML={{\n __html: pageContext.pageContentHtml,\n }}\n />\n ),\n }}\n dimension={dimension}\n margin={margin}\n pageIndex={pageContext.index}\n totalPages={pageContext.totalPages}\n />\n ))}\n\n {createPortal(\n <div style={reportStyles.outOfScreen}>\n <Page\n elements={elements}\n dimension={dimension}\n margin={margin}\n pageIndex={0}\n totalPages={1}\n ref={pageRef}\n sectionHeaderRef={sectionHeaderRef}\n sectionFooterRef={sectionFooterRef}\n pageHeaderRef={pageHeaderRef}\n pageFooterRef={pageFooterRef}\n contentRef={contentRef}\n />\n </div>,\n document.body\n )}\n </SectionControllerContext>\n );\n}\n","import { useMemo, type ReactNode } from 'react';\nimport parseSectionChildren from '../internal/parseSectionChildren';\nimport { SectionIdContext } from '../internal/SectionIdContext';\nimport {\n adjustDimension,\n reportStyles,\n sectionClassName,\n type PageDimension,\n type PageMargin,\n type PageOrientation,\n type PaginationConfig,\n} from '@paprize/core/src';\nimport { SectionLayout } from '../internal/SectionLayout';\n\nexport interface SectionProps {\n children: ReactNode;\n id?: string;\n dimension: PageDimension;\n orientation?: PageOrientation;\n margin?: PageMargin;\n config?: Partial<PaginationConfig>;\n}\n\nlet sectionIdCounter = 1;\n\nexport function Section({\n children,\n id,\n dimension,\n orientation = 'portrait',\n margin,\n config,\n}: SectionProps) {\n const sectionId = useMemo(() => id ?? `__000${sectionIdCounter++}`, [id]);\n const elements = useMemo(() => parseSectionChildren(children), [children]);\n\n const adjustedDimension = useMemo(\n () => adjustDimension(dimension, orientation),\n [dimension, orientation]\n );\n\n return (\n <section\n className={sectionClassName}\n id={sectionId}\n style={reportStyles.section(sectionId)}\n >\n <SectionIdContext value={sectionId}>\n <SectionLayout\n elements={elements}\n dimension={adjustedDimension}\n margin={margin}\n config={config}\n />\n </SectionIdContext>\n </section>\n );\n}\n","import { pageBreakAttributeName } from '@paprize/core/src';\n\nexport function PageBreak() {\n return <span {...{ [pageBreakAttributeName]: 'true' }} />;\n}\n","import { configToAttributeMap, type ConfigAttribute } from '@paprize/core/src';\n\nexport interface LayoutProps extends ConfigAttribute {\n children: React.ReactNode;\n}\n\nexport function Layout({ children, ...attributes }: LayoutProps) {\n return (\n <div\n style={{ display: 'contents' }}\n {...configToAttributeMap(attributes)}\n >\n {children}\n </div>\n );\n}\n","import { useContext } from 'react';\nimport { PageInfoContext } from '../internal/PageInfoContext';\n\nexport const usePageInfo = () => {\n const pageContext = useContext(PageInfoContext);\n\n return {\n pageIndex: pageContext.pageIndex,\n totalPages: pageContext.totalPages,\n };\n};\n","import { useContext, useRef, useSyncExternalStore } from 'react';\nimport type { SectionContext } from '@paprize/core/src';\nimport { useReportBuilder } from '../internal/useReportBuilder';\nimport { SectionIdContext } from '../internal/SectionIdContext';\nimport type { SectionInfo } from '../internal/eventHelper';\n\nexport const useSectionInfo = (): SectionInfo => {\n const sectionId = useContext(SectionIdContext);\n const reportBuilder = useReportBuilder();\n const stateRef = useRef<SectionContext>({\n pages: [],\n isPaginated: false,\n isSuspended: false,\n index: -1,\n sectionId: sectionId,\n });\n\n const state = useSyncExternalStore(\n (callback) => {\n return reportBuilder.monitor.addEventListener(\n 'sectionCompleted',\n (sc) => {\n if (sc.sectionId !== sectionId) return;\n stateRef.current = sc;\n callback();\n }\n );\n },\n () => stateRef.current\n );\n\n return {\n sectionId: sectionId,\n sectionIndex: state.index,\n isSuspended: state.isSuspended,\n isPaginated: state.isPaginated,\n pages: state.pages.map((p) => ({\n pageIndex: p.index,\n totalPages: p.totalPages,\n })),\n };\n};\n","import type {\n PaginationCycleCompleted,\n SectionContext,\n} from '@paprize/core/src';\n\nexport interface SectionInfo {\n sectionId: string;\n sectionIndex: number;\n isPaginated: boolean;\n isSuspended: boolean;\n pages: PageInfo[];\n}\n\nexport interface PageInfo {\n pageIndex: number;\n totalPages: number;\n}\n\nexport interface ReportInfo {\n sections: SectionInfo[];\n}\n\nexport function pageContextToPageInfo(pc: {\n index: number;\n totalPages: number;\n}): PageInfo {\n return {\n pageIndex: pc.index,\n totalPages: pc.totalPages,\n };\n}\n\nexport function sectionContextToSectionInfo(sc: SectionContext): SectionInfo {\n return {\n sectionId: sc.sectionId,\n sectionIndex: sc.index,\n isPaginated: sc.isPaginated,\n isSuspended: sc.isSuspended,\n pages: sc.pages.map(pageContextToPageInfo),\n };\n}\n\nexport function paginationCycleToReportInfo(\n rc: PaginationCycleCompleted\n): ReportInfo {\n return {\n sections: rc.sections.map(sectionContextToSectionInfo),\n };\n}\n","import { useRef, useSyncExternalStore } from 'react';\nimport { useReportBuilder } from '../internal/useReportBuilder';\nimport type { PaginationCycleCompleted } from '@paprize/core/src';\nimport {\n paginationCycleToReportInfo,\n type ReportInfo,\n} from '../internal/eventHelper';\n\nexport function useReportInfo(): ReportInfo {\n const reportBuilder = useReportBuilder();\n const stateRef = useRef<PaginationCycleCompleted>({\n sections: [],\n });\n\n const state = useSyncExternalStore(\n (callback) => {\n return reportBuilder.monitor.addEventListener(\n 'paginationCycleCompleted',\n (pg) => {\n stateRef.current = pg;\n callback();\n }\n );\n },\n () => stateRef.current\n );\n\n return paginationCycleToReportInfo(state);\n}\n","import { useContext, useEffect, useMemo, useRef } from 'react';\nimport { SectionControllerContext } from '../internal/SectionControllerContext';\n\nexport function useSectionSuspension(\n promise: Promise<void> | Promise<unknown>\n): void;\nexport function useSectionSuspension(): {\n release: () => void;\n reset: () => void;\n};\nexport function useSectionSuspension(\n promise?: Promise<void> | Promise<unknown>\n) {\n const resolveFn = useRef<() => void | null>(null);\n const { addSuspense } = useContext(SectionControllerContext);\n\n useEffect(() => {\n if (resolveFn.current) {\n return;\n }\n\n const pr =\n promise ??\n new Promise<void>((resolve) => {\n resolveFn.current = resolve;\n });\n resolveFn.current ||= () => {};\n\n addSuspense(pr as Promise<void>);\n }, [addSuspense, promise]);\n\n return useMemo(\n () => ({\n reset: () => {\n if (resolveFn.current) return;\n\n addSuspense(\n new Promise<void>((resolve) => {\n resolveFn.current = resolve;\n })\n );\n },\n release: () => {\n resolveFn.current?.();\n resolveFn.current = null;\n },\n }),\n [addSuspense]\n );\n}\n","import { paprize_readJsonDataFile } from '@paprize/core/src';\nimport { useSectionSuspension } from './useSectionSuspension';\n\nfunction lazy<T>(factory: () => Promise<T>): () => Promise<T> {\n let promise: Promise<T> | null = null;\n\n return () => {\n if (!promise) {\n promise = factory();\n }\n return promise;\n };\n}\n\n// the function is not available in browser, and in puppeteer it is injected before anything else but we\n// still need to delay the call\nexport const jsonData = lazy(async () => {\n if (!(paprize_readJsonDataFile in window)) {\n throw new Error(\n 'The function paprize_readJsonDataFile is not available in the current environment.'\n );\n }\n\n const strData = await window[paprize_readJsonDataFile]?.();\n return strData ? (JSON.parse(strData) as unknown) : null;\n});\n\nexport function useJsonData<DataModel>(\n defaultValue?: DataModel\n): DataModel | undefined {\n return useSectionSuspension(jsonData().catch(() => defaultValue)) as\n | DataModel\n | undefined;\n}\n"],"names":["ReportPreview","children","jsx","previewClassName","ReportBuilderContext","createContext","useReportBuilder","context","useContext","ReportRoot","reportBuilder","useMemo","ReportBuilder","useEffect","PageContent","isFirstCycleCompleted","useRef","unsubscribe","PageFooter","PageHeader","SectionFooter","SectionHeader","PageOverlay","validChildren","parseSectionChildren","content","pageElements","Children","child","isValidElement","component","x","SectionIdContext","PageInfoContext","Page","elements","dimension","margin","pageIndex","totalPages","ref","sectionHeaderRef","sectionFooterRef","pageHeaderRef","pageFooterRef","contentRef","sectionId","contextValue","jsxs","pageClassName","reportStyles","pageMargin","SectionControllerContext","useSectionControllerState","plugins","state","sectionController","plugin","suspense","SectionLayout","config","controllerState","controllerValue","pageRef","pageContexts","setPageContexts","useState","pages","pageContext","createPortal","sectionIdCounter","Section","id","orientation","adjustedDimension","adjustDimension","sectionClassName","PageBreak","pageBreakAttributeName","Layout","attributes","configToAttributeMap","usePageInfo","useSectionInfo","stateRef","useSyncExternalStore","callback","sc","p","pageContextToPageInfo","pc","sectionContextToSectionInfo","paginationCycleToReportInfo","rc","useReportInfo","pg","useSectionSuspension","promise","resolveFn","addSuspense","pr","resolve","lazy","factory","jsonData","paprize_readJsonDataFile","strData","useJsonData","defaultValue"],"mappings":";;;;AAOO,SAASA,GAAc,EAAE,UAAAC,KAAqC;AACjE,SAAO,gBAAAC,EAAC,OAAA,EAAI,WAAWC,GAAmB,UAAAF,EAAA,CAAS;AACvD;ACNO,MAAMG,IAAuBC,EAAoC,IAAI;AAErE,SAASC,IAAmB;AAC/B,QAAMC,IAAUC,EAAWJ,CAAoB;AAC/C,MAAI,CAACG;AACD,UAAM,IAAI;AAAA,MACN;AAAA,IAAA;AAIR,SAAOA;AACX;ACNO,SAASE,GAAW,EAAE,UAAAR,KAA6B;AACtD,QAAMS,IAAgBC,EAAQ,MAAM,IAAIC,EAAA,GAAiB,CAAA,CAAE;AAE3D,SAAAC,EAAU,MAAM;AACZ,IAAAH,EAAc,iBAAA;AAAA,EAClB,GAAG,CAACA,CAAa,CAAC,GAGd,gBAAAR,EAACE,GAAA,EAAqB,OAAOM,GACxB,UAAAT,EAAA,CACL;AAER;ACjBO,SAASa,EAAY,EAAE,UAAAb,KAAqC;AAC/D,QAAMS,IAAgBJ,EAAA,GAChBS,IAAwBC,EAAO,EAAK;AAE1C,SAAAH,EAAU,MAAM;AACZ,UAAMI,IAAcP,EAAc,QAAQ;AAAA,MACtC;AAAA,MACA,MAAM;AACF,QAAAK,EAAsB,UAAU;AAAA,MACpC;AAAA,IAAA;AAGJ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,SAAOQ,GAA4BrC,CAAK;AAC5C;AClBO,SAASyC,GACZC,GACF;AACE,QAAMC,IAAYlF,EAA0B,IAAI,GAC1C,EAAE,aAAAmF,EAAA,IAAgB3F,EAAW4C,CAAwB;AAE3D,SAAAvC,EAAU,MAAM;AACZ,QAAIqF,EAAU;AACV;AAGJ,UAAME,IACFH,KACA,IAAI,QAAc,CAACI,MAAY;AAC3B,MAAAH,EAAU,UAAUG;AAAA,IACxB,CAAC;AACL,IAAAH,EAAU,YAAY,MAAM;AAAA,IAAC,GAE7BC,EAAYC,CAAmB;AAAA,EACnC,GAAG,CAACD,GAAaF,CAAO,CAAC,GAElBtF;AAAA,IACH,OAAO;AAAA,MACH,OAAO,MAAM;AACT,QAAIuF,EAAU,WAEdC;AAAA,UACI,IAAI,QAAc,CAACE,MAAY;AAC3B,YAAAH,EAAU,UAAUG;AAAA,UACxB,CAAC;AAAA,QAAA;AAAA,MAET;AAAA,MACA,SAAS,MAAM;AACX,QAAAH,EAAU,UAAA,GACVA,EAAU,UAAU;AAAA,MACxB;AAAA,IAAA;AAAA,IAEJ,CAACC,CAAW;AAAA,EAAA;AAEpB;AC9CA,SAASG,GAAQC,GAA6C;AAC1D,MAAIN,IAA6B;AAEjC,SAAO,OACEA,MACDA,IAAUM,EAAA,IAEPN;AAEf;AAIO,MAAMO,KAAWF,GAAK,YAAY;AACrC,MAAI,EAAEG,KAA4B;AAC9B,UAAM,IAAI;AAAA,MACN;AAAA,IAAA;AAIR,QAAMC,IAAU,MAAM,OAAOD,CAAwB,IAAA;AACrD,SAAOC,IAAW,KAAK,MAAMA,CAAO,IAAgB;AACxD,CAAC;AAEM,SAASC,GACZC,GACqB;AACrB,SAAOZ,GAAqBQ,GAAA,EAAW,MAAM,MAAMI,CAAY,CAAC;AAGpE;"}
@@ -1,55 +1,2 @@
1
- (function(w,_){typeof exports=="object"&&typeof module<"u"?_(exports,require("react/jsx-runtime"),require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","react-dom"],_):(w=typeof globalThis<"u"?globalThis:w||self,_(w.paprize_react={},w.jsxRuntime,w.React,w.ReactDOM))})(this,(function(w,_,h,st){"use strict";function re(e){h.useInsertionEffect(()=>{const t=document.createElement("style");return t.textContent=e,document.head.appendChild(t),()=>t.remove()},[e])}const at=`
2
- :root {
3
- --paprize-page-background-color: #ffffff;
4
- --paprize-page-margin-bottom: 10px;
5
- --paprize-page-box-shadow: rgb(142 138 138) -1px 3px 5px 2px;
6
- --paprize-section-margin-bottom: 10px;
7
- --paprize-preview-background-color: rgb(218 220 224);
8
- --paprize-preview-padding: 30px 10px;
9
- }
10
-
11
- body {
12
- margin: 0;
13
- }
14
-
15
- @media screen {
16
- .paprize-preview {
17
- min-height: 100vh;
18
- display: flex;
19
- flex-direction: column;
20
- align-items: center;
21
- background-color: var(--paprize-preview-background-color);
22
- padding: var(--paprize-preview-padding);
23
- }
24
-
25
- .paprize-page {
26
- box-shadow: var(--paprize-page-box-shadow);
27
- margin-bottom: var(--paprize-page-margin-bottom);
28
- background-color: var(--paprize-page-background-color);
29
- }
30
-
31
- .paprize-section {
32
- margin-bottom: var(--paprize-section-margin-bottom);
33
- }
34
- }
35
- `;function ct({children:e}){return re(at),_.jsx("div",{className:"paprize-preview",children:e})}const B={};function xe(e,t){return e.unstable_is?e.unstable_is(t):t===e}function Te(e){return"init"in e}function se(e){return!!e.write}function Ie(e){return"v"in e||"e"in e}function Y(e){if("e"in e)throw e.e;if((B?"production":void 0)!=="production"&&!("v"in e))throw new Error("[Bug] atom state is not initialized");return e.v}const Z=new WeakMap;function Le(e){var t;return X(e)&&!!((t=Z.get(e))!=null&&t[0])}function lt(e){const t=Z.get(e);t?.[0]&&(t[0]=!1,t[1].forEach(n=>n()))}function ae(e,t){let n=Z.get(e);if(!n){n=[!0,new Set],Z.set(e,n);const o=()=>{n[0]=!1};e.then(o,o)}n[1].add(t)}function X(e){return typeof e?.then=="function"}function Fe(e,t,n){if(!n.p.has(e)){n.p.add(e);const o=()=>n.p.delete(e);t.then(o,o)}}function ze(e,t,n){var o;const i=new Set;for(const r of((o=n.get(e))==null?void 0:o.t)||[])n.has(r)&&i.add(r);for(const r of t.p)i.add(r);return i}const ut=(e,t,...n)=>t.read(...n),dt=(e,t,...n)=>t.write(...n),ft=(e,t)=>{var n;return(n=t.unstable_onInit)==null?void 0:n.call(t,e)},pt=(e,t,n)=>{var o;return(o=t.onMount)==null?void 0:o.call(t,n)},gt=(e,t)=>{const n=A(e),o=n[0],i=n[9];if((B?"production":void 0)!=="production"&&!t)throw new Error("Atom is undefined or null");let r=o.get(t);return r||(r={d:new Map,p:new Set,n:0},o.set(t,r),i?.(e,t)),r},ht=e=>{const t=A(e),n=t[1],o=t[3],i=t[4],r=t[5],s=t[6],f=t[13],m=[],d=l=>{try{l()}catch(g){m.push(g)}};do{s.f&&d(s.f);const l=new Set,g=l.add.bind(l);o.forEach(S=>{var v;return(v=n.get(S))==null?void 0:v.l.forEach(g)}),o.clear(),r.forEach(g),r.clear(),i.forEach(g),i.clear(),l.forEach(d),o.size&&f(e)}while(o.size||r.size||i.size);if(m.length)throw new AggregateError(m)},mt=e=>{const t=A(e),n=t[1],o=t[2],i=t[3],r=t[11],s=t[14],f=t[17],m=[],d=new WeakSet,l=new WeakSet,g=Array.from(i);for(;g.length;){const S=g[g.length-1],v=r(e,S);if(l.has(S)){g.pop();continue}if(d.has(S)){if(o.get(S)===v.n)m.push([S,v]);else if((B?"production":void 0)!=="production"&&o.has(S))throw new Error("[Bug] invalidated atom exists");l.add(S),g.pop();continue}d.add(S);for(const b of ze(S,v,n))d.has(b)||g.push(b)}for(let S=m.length-1;S>=0;--S){const[v,b]=m[S];let a=!1;for(const u of b.d.keys())if(u!==v&&i.has(u)){a=!0;break}a&&(s(e,v),f(e,v)),o.delete(v)}},vt=(e,t)=>{var n;const o=A(e),i=o[1],r=o[2],s=o[3],f=o[6],m=o[7],d=o[11],l=o[12],g=o[13],S=o[14],v=o[16],b=o[17],a=d(e,t);if(Ie(a)&&(i.has(t)&&r.get(t)!==a.n||Array.from(a.d).every(([E,L])=>S(e,E).n===L)))return a;a.d.clear();let u=!0;function c(){i.has(t)&&(b(e,t),g(e),l(e))}function C(E){var L;if(xe(t,E)){const F=d(e,E);if(!Ie(F))if(Te(E))K(e,E,E.init);else throw new Error("no atom init");return Y(F)}const T=S(e,E);try{return Y(T)}finally{a.d.set(E,T.n),Le(a.v)&&Fe(t,a.v,T),(L=i.get(E))==null||L.t.add(t),u||c()}}let N,P;const k={get signal(){return N||(N=new AbortController),N.signal},get setSelf(){return(B?"production":void 0)!=="production"&&!se(t)&&console.warn("setSelf function cannot be used with read-only atom"),!P&&se(t)&&(P=(...E)=>{if((B?"production":void 0)!=="production"&&u&&console.warn("setSelf function cannot be called in sync"),!u)try{return v(e,t,...E)}finally{g(e),l(e)}}),P}},V=a.n;try{const E=m(e,t,C,k);return K(e,t,E),X(E)&&(ae(E,()=>N?.abort()),E.then(c,c)),a}catch(E){return delete a.v,a.e=E,++a.n,a}finally{u=!1,V!==a.n&&r.get(t)===V&&(r.set(t,a.n),s.add(t),(n=f.c)==null||n.call(f,t))}},St=(e,t)=>{const n=A(e),o=n[1],i=n[2],r=n[11],s=[t];for(;s.length;){const f=s.pop(),m=r(e,f);for(const d of ze(f,m,o)){const l=r(e,d);i.set(d,l.n),s.push(d)}}},Oe=(e,t,...n)=>{const o=A(e),i=o[3],r=o[6],s=o[8],f=o[11],m=o[12],d=o[13],l=o[14],g=o[15],S=o[17];let v=!0;const b=u=>Y(l(e,u)),a=(u,...c)=>{var C;const N=f(e,u);try{if(xe(t,u)){if(!Te(u))throw new Error("atom not writable");const P=N.n,k=c[0];K(e,u,k),S(e,u),P!==N.n&&(i.add(u),(C=r.c)==null||C.call(r,u),g(e,u));return}else return Oe(e,u,...c)}finally{v||(d(e),m(e))}};try{return s(e,t,b,a,...n)}finally{v=!1}},_t=(e,t)=>{var n;const o=A(e),i=o[1],r=o[3],s=o[6],f=o[11],m=o[15],d=o[18],l=o[19],g=f(e,t),S=i.get(t);if(S&&!Le(g.v)){for(const[v,b]of g.d)if(!S.d.has(v)){const a=f(e,v);d(e,v).t.add(t),S.d.add(v),b!==a.n&&(r.add(v),(n=s.c)==null||n.call(s,v),m(e,v))}for(const v of S.d||[])if(!g.d.has(v)){S.d.delete(v);const b=l(e,v);b?.t.delete(t)}}},Be=(e,t)=>{var n;const o=A(e),i=o[1],r=o[4],s=o[6],f=o[10],m=o[11],d=o[12],l=o[13],g=o[14],S=o[16],v=m(e,t);let b=i.get(t);if(!b){g(e,t);for(const a of v.d.keys())Be(e,a).t.add(t);if(b={l:new Set,d:new Set(v.d.keys()),t:new Set},i.set(t,b),(n=s.m)==null||n.call(s,t),se(t)){const a=()=>{let u=!0;const c=(...C)=>{try{return S(e,t,...C)}finally{u||(l(e),d(e))}};try{const C=f(e,t,c);C&&(b.u=()=>{u=!0;try{C()}finally{u=!1}})}finally{u=!1}};r.add(a)}}return b},yt=(e,t)=>{var n;const o=A(e),i=o[1],r=o[5],s=o[6],f=o[11],m=o[19],d=f(e,t);let l=i.get(t);if(l&&!l.l.size&&!Array.from(l.t).some(g=>{var S;return(S=i.get(g))==null?void 0:S.d.has(t)})){l.u&&r.add(l.u),l=void 0,i.delete(t),(n=s.u)==null||n.call(s,t);for(const g of d.d.keys()){const S=m(e,g);S?.t.delete(t)}return}return l},K=(e,t,n)=>{const o=A(e)[11],i=o(e,t),r="v"in i,s=i.v;if(X(n))for(const f of i.d.keys())Fe(t,n,o(e,f));i.v=n,delete i.e,(!r||!Object.is(s,i.v))&&(++i.n,X(s)&&lt(s))},wt=(e,t)=>{const n=A(e)[14];return Y(n(e,t))},bt=(e,t,...n)=>{const o=A(e),i=o[12],r=o[13],s=o[16];try{return s(e,t,...n)}finally{r(e),i(e)}},kt=(e,t,n)=>{const o=A(e),i=o[12],r=o[18],s=o[19],m=r(e,t).l;return m.add(n),i(e),()=>{m.delete(n),s(e,t),i(e)}},Me=new WeakMap;function A(e){const t=Me.get(e);if((B?"production":void 0)!=="production"&&!t)throw new Error("Store must be created by buildStore to read its building blocks");return t}function Et(...e){const t={get(o){const i=A(t)[21];return i(t,o)},set(o,...i){const r=A(t)[22];return r(t,o,...i)},sub(o,i){const r=A(t)[23];return r(t,o,i)}},n=[new WeakMap,new WeakMap,new WeakMap,new Set,new Set,new Set,{},ut,dt,ft,pt,gt,ht,mt,vt,St,Oe,_t,Be,yt,K,wt,bt,kt].map((o,i)=>e[i]||o);return Me.set(t,Object.freeze(n)),t}const De={};let Ct=0;function U(e,t){const n=`atom${++Ct}`,o={toString(){return(De?"production":void 0)!=="production"&&this.debugLabel?n+":"+this.debugLabel:n}};return typeof e=="function"?o.read=e:(o.init=e,o.read=Pt,o.write=Nt),t&&(o.write=t),o}function Pt(e){return e(this)}function Nt(e,t,n){return t(this,typeof n=="function"?n(e(this)):n)}function ce(){return Et()}let R;function At(){return R||(R=ce(),(De?"production":void 0)!=="production"&&(globalThis.__JOTAI_DEFAULT_STORE__||(globalThis.__JOTAI_DEFAULT_STORE__=R),globalThis.__JOTAI_DEFAULT_STORE__!==R&&console.warn("Detected multiple Jotai instances. It may cause unexpected behavior with the default store. https://github.com/pmndrs/jotai/discussions/2044"))),R}const xt={},He=h.createContext(void 0);function $e(e){return h.useContext(He)||At()}function Tt({children:e,store:t}){const n=h.useRef(void 0);return!t&&!n.current&&(n.current=ce()),h.createElement(He.Provider,{value:t||n.current},e)}const le=e=>typeof e?.then=="function",ue=e=>{e.status||(e.status="pending",e.then(t=>{e.status="fulfilled",e.value=t},t=>{e.status="rejected",e.reason=t}))},It=h.use||(e=>{if(e.status==="pending")throw e;if(e.status==="fulfilled")return e.value;throw e.status==="rejected"?e.reason:(ue(e),e)}),de=new WeakMap,We=(e,t)=>{let n=de.get(e);return n||(n=new Promise((o,i)=>{let r=e;const s=d=>l=>{r===d&&o(l)},f=d=>l=>{r===d&&i(l)},m=()=>{try{const d=t();le(d)?(de.set(d,n),r=d,d.then(s(d),f(d)),ae(d,m)):o(d)}catch(d){i(d)}};e.then(s(e),f(e)),ae(e,m)}),de.set(e,n)),n};function Q(e,t){const{delay:n,unstable_promiseStatus:o=!h.use}={},i=$e(),[[r,s,f],m]=h.useReducer(l=>{const g=i.get(e);return Object.is(l[0],g)&&l[1]===i&&l[2]===e?l:[g,i,e]},void 0,()=>[i.get(e),i,e]);let d=r;if((s!==i||f!==e)&&(m(),d=i.get(e)),h.useEffect(()=>{const l=i.sub(e,()=>{if(o)try{const g=i.get(e);le(g)&&ue(We(g,()=>i.get(e)))}catch{}if(typeof n=="number"){setTimeout(m,n);return}m()});return m(),l},[i,e,n,o]),h.useDebugValue(d),le(d)){const l=We(d,()=>i.get(e));return o&&ue(l),It(l)}return d}function fe(e,t){const n=$e();return h.useCallback((...i)=>{if((xt?"production":void 0)!=="production"&&!("write"in e))throw new Error("not writable atom");return n.set(e,...i)},[n,e])}const Lt="__PAPRIZE_IS_READY",Ft="__PAPRIZE_READ_JSON_DATA_FILE",zt=ce(),Ot={totalPages:0,isPaginated:!1,pendingSuspensions:new Set},M=U(new Map);M.debugLabel="sectionsAtom";const pe=U({totalSections:0,isPaginated:!1});pe.debugLabel="reportAtom";function Bt(){const e=fe(pe),t=Q(M);return h.useEffect(()=>{const n=t.size,o=Array.from(t.values()).every(i=>i.isPaginated);window[Lt]=o,e({isPaginated:o&&n>0,totalSections:n})},[t,e]),null}const Mt=`
36
- html {
37
- box-sizing: border-box;
38
- }
39
-
40
- *,
41
- *:before,
42
- *:after {
43
- box-sizing: inherit;
44
- }
45
-
46
- .paprize-page-component {
47
- display: flex;
48
- flex-direction: column;
49
- }
50
- `;function Dt({children:e}){return re(Mt),_.jsxs(Tt,{store:zt,children:[e,_.jsx(Bt,{})]})}function ge({children:e}){return _.jsx(_.Fragment,{children:e})}function he({children:e}){return _.jsx(_.Fragment,{children:e})}function me({children:e}){return _.jsx(_.Fragment,{children:e})}function ve({children:e}){return _.jsx(_.Fragment,{children:e})}function Se({children:e}){return _.jsx(_.Fragment,{children:e})}function _e({children:e}){return _.jsx(_.Fragment,{children:e})}function Ht(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ee={exports:{}},$t=ee.exports,Ve;function Wt(){return Ve||(Ve=1,(function(e){(function(t,n){e.exports?e.exports=n():t.log=n()})($t,function(){var t=function(){},n="undefined",o=typeof window!==n&&typeof window.navigator!==n&&/Trident\/|MSIE /.test(window.navigator.userAgent),i=["trace","debug","info","warn","error"],r={},s=null;function f(a,u){var c=a[u];if(typeof c.bind=="function")return c.bind(a);try{return Function.prototype.bind.call(c,a)}catch{return function(){return Function.prototype.apply.apply(c,[a,arguments])}}}function m(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function d(a){return a==="debug"&&(a="log"),typeof console===n?!1:a==="trace"&&o?m:console[a]!==void 0?f(console,a):console.log!==void 0?f(console,"log"):t}function l(){for(var a=this.getLevel(),u=0;u<i.length;u++){var c=i[u];this[c]=u<a?t:this.methodFactory(c,a,this.name)}if(this.log=this.debug,typeof console===n&&a<this.levels.SILENT)return"No console available for logging"}function g(a){return function(){typeof console!==n&&(l.call(this),this[a].apply(this,arguments))}}function S(a,u,c){return d(a)||g.apply(this,arguments)}function v(a,u){var c=this,C,N,P,k="loglevel";typeof a=="string"?k+=":"+a:typeof a=="symbol"&&(k=void 0);function V(p){var y=(i[p]||"silent").toUpperCase();if(!(typeof window===n||!k)){try{window.localStorage[k]=y;return}catch{}try{window.document.cookie=encodeURIComponent(k)+"="+y+";"}catch{}}}function E(){var p;if(!(typeof window===n||!k)){try{p=window.localStorage[k]}catch{}if(typeof p===n)try{var y=window.document.cookie,O=encodeURIComponent(k),q=y.indexOf(O+"=");q!==-1&&(p=/^([^;]+)/.exec(y.slice(q+O.length+1))[1])}catch{}return c.levels[p]===void 0&&(p=void 0),p}}function L(){if(!(typeof window===n||!k)){try{window.localStorage.removeItem(k)}catch{}try{window.document.cookie=encodeURIComponent(k)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}function T(p){var y=p;if(typeof y=="string"&&c.levels[y.toUpperCase()]!==void 0&&(y=c.levels[y.toUpperCase()]),typeof y=="number"&&y>=0&&y<=c.levels.SILENT)return y;throw new TypeError("log.setLevel() called with invalid level: "+p)}c.name=a,c.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},c.methodFactory=u||S,c.getLevel=function(){return P??N??C},c.setLevel=function(p,y){return P=T(p),y!==!1&&V(P),l.call(c)},c.setDefaultLevel=function(p){N=T(p),E()||c.setLevel(p,!1)},c.resetLevel=function(){P=null,L(),l.call(c)},c.enableAll=function(p){c.setLevel(c.levels.TRACE,p)},c.disableAll=function(p){c.setLevel(c.levels.SILENT,p)},c.rebuild=function(){if(s!==c&&(C=T(s.getLevel())),l.call(c),s===c)for(var p in r)r[p].rebuild()},C=T(s?s.getLevel():"WARN");var F=E();F!=null&&(P=T(F)),l.call(c)}s=new v,s.getLogger=function(u){if(typeof u!="symbol"&&typeof u!="string"||u==="")throw new TypeError("You must supply a name when creating a logger.");var c=r[u];return c||(c=r[u]=new v(u,s.methodFactory)),c};var b=typeof window!==n?window.log:void 0;return s.noConflict=function(){return typeof window!==n&&window.log===s&&(window.log=b),s},s.getLoggers=function(){return r},s.default=s,s})})(ee)),ee.exports}var Vt=Wt();const z=Ht(Vt),Ue=[ge,me,he,_e,Se,ve];function Ut(e){let t=null;const n={};if(h.Children.forEach(e,o=>{if(!h.isValidElement(o))throw z.error("Invalid React element found in children",{child:o}),new Error("Invalid React element found in children");const i=Ue.find(r=>r===o.type);if(!i)throw Error(`Component "${o.type}" is not valid as a child for Section, Expected one of: ${Ue.map(r=>r.name).join(",")}`);switch(i){case Se:n.sectionHeader=o;break;case ve:n.sectionFooter=o;break;case ge:t=o;break;case me:n.header=o;break;case he:n.footer=o;break;case _e:n.overlay=o;break}}),!t)throw Error("PageContent component is a required child for Section");return{...n,content:t}}function Rt(e,t){return t==="landscape"?{height:e.width,width:e.height}:e}function jt(e,t){return`@page section-${e} {
51
- margin: none;
52
- size:${t.width} ${t.height};
53
- width:${t.width};
54
- height:${t.height};
55
- }`}const Jt="paprize",Re="pz-temp-container",ye="data-pz-";function je(e){return e.nodeType===Node.ELEMENT_NODE}function Gt(e){return e.nodeType===Node.TEXT_NODE}function te(e){const t=e.getBoundingClientRect(),n=getComputedStyle(e),o=parseFloat(n.marginTop)||0,i=parseFloat(n.marginBottom)||0;return t.height+o+i}function qt(e){e.style.visibility="hidden",e.style.position="absolute",e.style.left="-9999px",e.style.top="-9999px"}class D{name;defaultValue;_reader;constructor(t,n,o){this.name=t,this._reader=n,this.defaultValue=o}read(t){return this._reader(t)}static createStr(t,n){return new D(t,o=>o,n)}static createBool(t,n){return new D(t,o=>o==="true",n)}}const ne={hyphen:D.createStr("hyphen","-"),keepOnSamePage:D.createBool("keep-on-same-page",!1),hyphenationEnabled:D.createBool("hyphenation-enabled",!0)};function Yt(e){const t={};for(const n in e){const o=e[n];if(o!==void 0){const i=ne[n];t[`${ye}${i.name}`]=String(o)}}return t}const Zt=Object.fromEntries(Object.entries(ne).map(([e,t])=>[e,t.defaultValue])),Je=new WeakMap;function Ge(e){if(!e)return{};if(!(e instanceof Element))return Ge(e?.parentNode);const t={};for(const i in ne){const r=ne[i],s=`${ye}${r.name}`,f=e.getAttribute(s);f!==null&&(t[i]=r.read(f))}const o={...e.parentNode?Je.get(e.parentNode):void 0,...t};return Je.set(e,o),o}const qe={id:"default",plugins:[],...Zt};function Xt(e,t){const n=Ge(e);return{...qe,...t,...n}}const x=z.getLogger(Jt);x.setDefaultLevel("info");const we="\x1B[46mPLUGIN\x1B[0m";function H(e,t,...n){e.sort((o,i)=>o.order-i.order).forEach(o=>{const i=o[t];if(i){x.debug(we,`executing plugin ${o.name}:${String(t)} ()`,n);try{i(...n),x.debug(we,`plugin ${o.name}:${String(t)} executed`,n)}catch(r){x.debug(we,`plugin ${o.name}:${String(t)} failed`,r)}}})}const $={Element:"element",Text:"text"};class be{_node;_transaction;type=$.Element;config;constructor(t,n,o){this._node=t,this._transaction=n,this.config=o}appendChild(t){this._transaction.isActive&&this._transaction.addRollbackCallback(()=>{this._node.removeChild(t.getNode())}),this._node.appendChild(t.getNode())}clone(t){const n=this._node.cloneNode(t),o=new be(n,this._transaction,this.config);return H(this.config.plugins,"onClone",this.config.id,this._node,o),o}getHeight(){return te(this._node)}remove(){this._transaction.addCommitCallback(()=>{this._node.remove()})}isEmpty(){return this._node.innerHTML===""}getChildrenCount(){return this._node.childNodes.length}getNode(){return this._node}}class Kt{_node;_transaction;type=$.Text;config;constructor(t,n,o){this._node=t,this._transaction=n,this.config=o}get textContent(){return this._node.textContent??""}set textContent(t){this._node.textContent=t}remove(){this._transaction.addCommitCallback(()=>{this._node.remove()})}getNode(){return this._node}}function ke(e,t,n){if(Gt(e))return new Kt(e,t,n);if(je(e))return new be(e,t,n);throw new Error("Unsupported node type")}function Bn(e){}function Mn(e){}function Dn(e){}const j="\x1B[106mDOM\x1B[0m";class Qt{_transaction;_treeWalker;_config;_completed=!1;_currentNode=null;_previousNode=null;constructor(t,n,o){this._transaction=n,this._config=o,this._treeWalker=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT)}get completed(){return this._completed}get currentNode(){return this._currentNode}get previousNode(){return this._previousNode}nextNode(){this._treeWalker.nextNode()||(this._completed=!0),x.debug(j,"moving to next node"),this.setState()}nextSiblingOrParentSibling(){let t=0;if(this._treeWalker.nextSibling())return x.debug(j,"moving to next sibling node"),this.setState(),{parentsTraversed:t};for(;this._treeWalker.parentNode();)if(t++,this._treeWalker.nextSibling())return x.debug(j,"moving to parent sibling node, traversed:",t),this.setState(),{parentsTraversed:t};return this._completed=!0,{parentsTraversed:t}}firstChildOrNextNode(){return this._treeWalker.firstChild()?(x.debug(j,"moving to first child node"),this.setState(),{parentsTraversed:1}):(this.nextNode(),{parentsTraversed:0})}setState(){this._previousNode=this._currentNode,this._currentNode=ke(this._treeWalker.currentNode,this._transaction,Xt(this._treeWalker.currentNode,this._config)),this.currentNode,this.previousNode,x.debug(j,"moved to node",{currentNode:this.currentNode,previousNode:this.previousNode})}}class en{_onRollback;_onCommit;isActive;constructor(){this._onRollback=[],this._onCommit=[],this.isActive=!1}start=()=>{if(this.isActive)throw new Error("Transaction already in progress");this.isActive=!0,this._onRollback=[],this._onCommit=[]};addRollbackCallback=t=>{this._onRollback.push(t)};addCommitCallback=t=>{if(!this.isActive){t();return}this._onCommit.push(t)};rollback=()=>{this.isActive&&(this.isActive=!1,this._onRollback.forEach(t=>t()))};commit=()=>{this.isActive&&(this.isActive=!1,this._onCommit.forEach(t=>t()))}}const Ye="\x1B[102mPAGE\x1B[0m";class J{currentPage;activeElement;currentElement;parentStack;pageIsFull;pageIndex;pageHeight;constructor(t,n,o,i,r,s,f){this.currentPage=t,this.activeElement=n,this.currentElement=o,this.parentStack=i,this.pageIsFull=r,this.pageIndex=s,this.pageHeight=f}static create(t,n,o,i){return new J(t,null,t,n,!1,o,i)}clone=()=>new J(this.currentPage,this.activeElement,this.currentElement,[...this.parentStack],this.pageIsFull,this.pageIndex,this.pageHeight)}class Ee{_pageState;_transaction;_tempContainer;_config;constructor(t,n,o,i){this._tempContainer=t,this._config=i,this._transaction=o;const r=Ee.createPageHtmlElement(n.width),s=this.createNewPage(r);this._pageState=J.create(s,[],0,n.height),H(this._config.plugins,"onNewPage",i.id,this)}nextPage(){const t=this.createNewPage(this._pageState.currentPage.getNode().cloneNode(!1)),n=J.create(t,[],this._pageState.pageIndex+1,this._pageState.pageHeight);this.cloneParentStackToNewPage(n),this.cleanupEmptyParent(),this._pageState=n,H(this._config.plugins,"onNewPage",this._config.id,this)}cloneParentStackToNewPage(t){for(const n of this._pageState.parentStack){const o=n.clone(!1);t.currentElement.appendChild(o),t.currentElement=o,t.parentStack.push(o)}}cleanupEmptyParent(){const t=[...this._pageState.parentStack],n=()=>{for(let o=t.length-1;o>=0;o--){const i=t[o];i.isEmpty()&&i.remove()}};this._transaction.addCommitCallback(n)}enterElement(){if(!this._pageState.activeElement||this._pageState.activeElement.type!==$.Element)throw new Error("Invalid state: activeElement is not an Element");x.debug(Ye,"entering an element",this._pageState.activeElement),this._pageState.currentElement=this._pageState.activeElement,this._pageState.parentStack.push(this._pageState.activeElement)}leaveElement(){this._pageState.activeElement=null;const t=this._pageState.parentStack.pop();x.debug(Ye,"leaving a parent element",t);const n=this._pageState.parentStack.at(-1);this._pageState.currentElement=n??this._pageState.currentPage}static createPageHtmlElement(t){const n=document.createElement("div");return n.style.width=`${t}px`,n.style.maxWidth=`${t}px`,n}createNewPage(t){return this._tempContainer.appendChild(t),this._transaction.isActive&&this._transaction.addRollbackCallback(()=>{this._tempContainer.removeChild(t)}),ke(t,this._transaction,this._config)}startTransaction(){this._transaction.start();const t=this._pageState.clone();return this._transaction.addRollbackCallback(()=>{this._pageState=t}),this._transaction}hasEmptySpace(t){return!this._pageState.pageIsFull&&this._pageState.currentPage.getHeight()+(t||1e-4)<=this._pageState.pageHeight}isOverFlow(){return this._pageState.currentPage.getHeight()>this._pageState.pageHeight}markPageAsFull(){this._pageState.pageIsFull=!0}appendChild(t,n){const o=t.clone(n);return this._pageState.currentElement.appendChild(o),this._pageState.activeElement=o,o}addTextNode(t){if(this._pageState.activeElement?.type===$.Text)return this._pageState.activeElement;const n=document.createTextNode(t),o=ke(n,this._transaction,this._config);return this._pageState.currentElement.appendChild(o),this._pageState.activeElement=o,o}getPageState(){return this._pageState}}const I={None:0,FullNodePlaced:1,SplitChildren:2};function tn(e,t){const n=Ze(e,t);if(n!==I.None)return n;const{rollback:o,commit:i}=t.startTransaction();t.nextPage();const r=Ze(e,t);return r!==I.None?(i(),r):(o(),x.debug("Element is too big to fit on a page",e),I.None)}function Ze(e,t){if(t.hasEmptySpace(e.getHeight())){const o=t.appendChild(e,!0);if(t.isOverFlow())o.remove();else return I.FullNodePlaced}if(e.config.keepOnSamePage||e.getChildrenCount()===0)return I.None;const n=t.appendChild(e,!1);return t.isOverFlow()?(n.remove(),I.None):I.SplitChildren}function nn(e,t){let n=I.FullNodePlaced;const o=e.textContent.split(/(\s+)/).filter(s=>s!=="");let i,r=0;for(;i||r<o.length;){const s=i??o[r],f=on(s,t,e.config);f.completed||(n=I.None),f.pendingToken?i=f.pendingToken:(i=void 0,r++)}return n}function on(e,t,n){t.hasEmptySpace()||t.nextPage();let o=t.addTextNode("");const i=o.textContent;if(o.textContent+=e,!t.isOverFlow())return{completed:!0};o.textContent=i;const r=rn(e,t,n);return{pendingToken:r.leftovers,completed:r.completed}}function rn(e,t,n){const{rollback:o,commit:i}=t.startTransaction();if(t.nextPage(),t.addTextNode(e),!t.isOverFlow())return i(),{completed:!0};if(o(),!n.hyphenationEnabled)return x.warn("Hyphenation disabled, skipping oversized token:",e),{completed:!1};const r=sn(e,n.hyphen,t);return{completed:!0,leftovers:r&&r.length>0?r:void 0}}function sn(e,t,n){const o=n.addTextNode("");let i="";for(let r=0;r<e.length;r++){const s=e[r],f=i+s;if(o.textContent=f+t,!n.hasEmptySpace())return o.textContent=i?i+t:"",n.markPageAsFull(),e.slice(r);i=f}return null}const G="\x1B[103mPAGINATOR\x1B[0m";class oe{_domState;_pageManager;_transaction;_tempContainer;_config;constructor(t,n,o){this._config={...qe,...o},this._tempContainer=oe.createTempContainer(this._config.id),this._transaction=new en,this._domState=new Qt(t,this._transaction,this._config),this._pageManager=new Ee(this._tempContainer,n,this._transaction,this._config)}static createTempContainer(t){const n=document.createElement("div");return n.style.display="flex",n.style.flexDirection="column",n.style.gap="20px",n.setAttribute(`${ye}-section-id`,t),n.classList.add(Re),qt(n),document.body.appendChild(n),n}static paginate(t,n,o){const i=new oe(t,n,o);i.processAllNodes();const r=Array.from(i._tempContainer.childNodes).filter(s=>je(s)).map(s=>s.innerHTML);return i._tempContainer.remove(),r}processAllNodes(){this._domState.nextNode();do{switch(z.debug(G,"paginating node",this._domState.currentNode),this.processCurrentNode()){case I.None:this.handleNodeSkipped();break;case I.FullNodePlaced:this.handleFullNodePlaced();break;case I.SplitChildren:this.handleChildrenSplit();break}H(this._config.plugins,"afterVisitNode",this._config.id,this._domState,this._pageManager)}while(this._domState.completed===!1);z.debug(G,"pagination completed")}handleNodeSkipped(){z.debug(G,"node skipped - couldn't paginate"),this._domState.currentNode,this._domState.nextNode()}handleFullNodePlaced(){z.debug(G,"node fully paginated");const{parentsTraversed:t}=this._domState.nextSiblingOrParentSibling();for(let n=0;n<t;n++)this._pageManager.leaveElement()}handleChildrenSplit(){z.debug(G,"node partially paginated - splitting children"),this._domState.firstChildOrNextNode().parentsTraversed===1&&this._domState.previousNode?.type===$.Element&&this._pageManager.enterElement()}processCurrentNode(){if(!this._domState.currentNode)return I.None;if(this._domState.currentNode.type===$.Element){const t={};return H(this._config.plugins,"onVisitElement",this._config.id,this._domState,this._pageManager,t),t.result!==void 0?t.result:tn(this._domState.currentNode,this._pageManager)}else{const t={};return H(this._config.plugins,"onVisitText",this._config.id,this._domState,this._pageManager,t),t.result!==void 0?t.result:nn(this._domState.currentNode,this._pageManager)}}}const Xe="data-pz-page-break",an=[{name:"pageBreak",order:1,onVisitElement:(e,t,n,o)=>{t.currentNode.getNode().getAttribute(Xe)==="true"&&(n.markPageAsFull(),o.result=I.FullNodePlaced)}}],Ke=h.createContext({pageNumber:0,totalPages:0});function cn(e){return e?`${e.top} ${e.right} ${e.bottom} ${e.left}`:"0"}function ln(e){const t=e.getBoundingClientRect(),n=getComputedStyle(e),o=parseFloat(n.marginLeft)||0,i=parseFloat(n.marginRight)||0;return{height:te(e),width:t.width+o+i}}const ie=h.createContext("");function Qe({elements:e,dimensions:t,margin:n,pageNumber:o,totalPages:i,ref:r,sectionHeaderRef:s,sectionFooterRef:f,contentRef:m}){const d=h.useContext(ie),l=h.useMemo(()=>({pageNumber:o,totalPages:i}),[o,i]);return _.jsx(Ke,{value:l,children:_.jsxs("div",{id:`${d}-${o}`,className:"paprize-page paprize-page-component",ref:r,style:{width:t.width,height:t.height,maxHeight:t.height,position:"relative",padding:cn(n),zIndex:1},children:[e.sectionHeader&&o==1&&_.jsx("div",{className:"paprize-page-component",ref:s,children:e.sectionHeader}),e.header&&_.jsx("div",{className:"paprize-page-component",children:e.header}),_.jsx("div",{style:{overflow:"hidden",width:"100%",height:"100%"},ref:m,children:e.content}),e.overlay&&_.jsx("div",{style:{position:"absolute",width:"100%",height:"100%",left:0,top:0},children:e.overlay}),(e.footer||e.sectionFooter)&&_.jsxs("div",{className:"paprize-page-component",style:{marginTop:"auto"},children:[e.footer&&_.jsx("div",{className:"paprize-page-component",children:e.footer}),e.sectionFooter&&o==i&&_.jsx("div",{className:"paprize-page-component",ref:f,children:e.sectionFooter})]})]})})}function un(e,t,n){const{height:o,width:i}=ln(e),r=t?te(t):0,s=n?te(n):0;return{height:o,width:i,sectionHeaderHeight:r,sectionFooterHeight:s}}function dn(e,t,n){return{name:"sectionPageHeight",order:1,afterVisitNode:(o,i,r)=>{!i.completed||n<=0||r.hasEmptySpace(n)||r.nextPage()},onNewPage:(o,i)=>{const r=i.getPageState();r.pageIndex===0?r.pageHeight=e+n:r.pageHeight=e+t+n}}}function fn(e,t){const n=h.useMemo(()=>U(null,(o,i,...r)=>e(o,i,...r)),[e]);return fe(n)}const pn={totalPages:0,isPaginated:!1,pendingSuspensions:0},Ce=()=>{const e=h.useContext(ie),t=h.useMemo(()=>U(o=>{const i=o(M).get(e);return i?{totalPages:i.totalPages,isPaginated:i.isPaginated,pendingSuspensions:i.pendingSuspensions.size}:pn}),[e]),n=Q(t);return{sectionId:e,totalPages:n.totalPages}};function gn(e){return Ce(),fn(n=>(n(M).get(e)?.pendingSuspensions?.size??0)>0)}const Pe=e=>{const t=h.useMemo(()=>U(()=>0,(n,o,i)=>{o(M,r=>new Map(r).set(e,i(r.get(e)??Ot)))}),[e]);return fe(t)},Ne="\x1B[41mREACT\x1B[0m",et=(e,t,n,o,i)=>e?.dimensions===n&&e?.margin===o&&e?.elements===t&&e?.config===i&&e?.elements===t;function hn(e,t,n,o){const i=h.useContext(ie),r=gn(i),s=Pe(i),f=h.useRef(null),[m,d]=h.useState({results:null,isLoading:!0}),l=h.useRef(null),g=h.useRef(null),S=h.useRef(null),v=h.useRef(null);return h.useEffect(()=>{et(f.current,e,t,n,o)||d({results:null,isLoading:!0})},[t,e,n,o]),h.useEffect(()=>{if(!l.current||!v.current||et(f.current,e,t,n,o))return;if(r()){x.info(Ne,`Section "${i}" is suspended`);return}const{height:b,width:a,sectionFooterHeight:u,sectionHeaderHeight:c}=un(v.current,g.current,S.current),C=[...o.plugins??an,dn(b,c,u)];x.debug(Ne,"Calling Paginator",{sectionName:i,height:b,width:a,sectionFooterHeight:u,sectionHeaderHeight:c,plugins:C});const N=oe.paginate(v.current,{height:b,width:a},{...o,plugins:C});x.debug(Ne,"Paginator Result",{sectionName:i,paginatorResult:N}),d({results:N,isLoading:!1}),s(P=>({...P,totalPages:N.length,isPaginated:!0})),f.current={elements:e,dimensions:t,margin:n,config:o}}),{...m,pageRef:l,sectionHeaderRef:g,sectionFooterRef:S,contentRef:v}}function mn({elements:e,dimensions:t,margin:n,config:o}){const{results:i,pageRef:r,sectionHeaderRef:s,sectionFooterRef:f,contentRef:m}=hn(e,t,n,o);if(i!==null)return _.jsx(_.Fragment,{children:i.map((l,g)=>_.jsx(Qe,{elements:{...e,content:_.jsx("div",{style:{display:"contents"},dangerouslySetInnerHTML:{__html:l}})},dimensions:t,margin:n,pageNumber:g+1,totalPages:i.length},g))});const d={visibility:"hidden",position:"absolute",left:"-9999px",top:"-9999px"};return st.createPortal(_.jsx("div",{className:Re,style:d,children:_.jsx(Qe,{elements:e,dimensions:t,margin:n,pageNumber:1,totalPages:1,ref:r,sectionHeaderRef:s,sectionFooterRef:f,contentRef:m})}),document.body)}function vn({children:e,dimension:t,orientation:n="portrait",margin:o,config:i}){const r=h.useId(),s=h.useMemo(()=>({...i,id:i?.id??r}),[i,r]),f=s.id,m=Pe(f);h.useMemo(()=>{m(l=>({...l,isPaginated:!1}))},[m]);const d=h.useMemo(()=>({dimensions:Rt(t,n),elements:Ut(e),margin:o,config:s}),[e,t,o,s,n]);return re(jt(f,d.dimensions)),_.jsx("section",{className:"paprize-section",id:`section-${f}`,style:{page:`section-${f}`},children:_.jsx(ie,{value:f,children:_.jsx(mn,{elements:d.elements,dimensions:d.dimensions,margin:d.margin,config:d.config})})})}function Sn(){return _.jsx("span",{[Xe]:"true"})}function _n({children:e,...t}){return _.jsx("div",{style:{display:"contents"},...Yt(t),children:e})}const yn=()=>{const e=h.useContext(Ke);return{pageNumber:e.pageNumber,totalPages:e.totalPages}};function wn(){const e=Q(M),t=Q(pe);return h.useMemo(()=>({totalSections:t.totalSections,isPaginated:t.isPaginated,isFirstPaginationCompleted:t.totalSections>0,sections:Array.from(e.entries()).map(([n,{totalPages:o,isPaginated:i}])=>({sectionId:n,totalPages:o,isPaginated:i}))}),[t.isPaginated,t.totalSections,e])}function tt(e,t=!0){const n=h.useId(),o=Pe(e);return h.useMemo(()=>{t&&o(i=>({...i,pendingSuspensions:new Set(i.pendingSuspensions).add(n)}))},[n,o,t]),h.useMemo(()=>({release:()=>{o(i=>{const r=new Set(i.pendingSuspensions);return r.delete(n),{...i,pendingSuspensions:r}})}}),[n,o])}const bn="paprize";class W{name;defaultValue;_reader;constructor(t,n,o){this.name=t,this._reader=n,this.defaultValue=o}read(t){return this._reader(t)}static createStr(t,n){return new W(t,o=>o,n)}static createBool(t,n){return new W(t,o=>o==="true",n)}}const kn={hyphen:W.createStr("hyphen","-"),keepOnSamePage:W.createBool("keep-on-same-page",!1),hyphenationEnabled:W.createBool("hyphenation-enabled",!0)};({...Object.fromEntries(Object.entries(kn).map(([e,t])=>[e,t.defaultValue]))});function En(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Ae={exports:{}},Cn=Ae.exports,nt;function Pn(){return nt||(nt=1,(function(e){(function(t,n){e.exports?e.exports=n():t.log=n()})(Cn,function(){var t=function(){},n="undefined",o=typeof window!==n&&typeof window.navigator!==n&&/Trident\/|MSIE /.test(window.navigator.userAgent),i=["trace","debug","info","warn","error"],r={},s=null;function f(a,u){var c=a[u];if(typeof c.bind=="function")return c.bind(a);try{return Function.prototype.bind.call(c,a)}catch{return function(){return Function.prototype.apply.apply(c,[a,arguments])}}}function m(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function d(a){return a==="debug"&&(a="log"),typeof console===n?!1:a==="trace"&&o?m:console[a]!==void 0?f(console,a):console.log!==void 0?f(console,"log"):t}function l(){for(var a=this.getLevel(),u=0;u<i.length;u++){var c=i[u];this[c]=u<a?t:this.methodFactory(c,a,this.name)}if(this.log=this.debug,typeof console===n&&a<this.levels.SILENT)return"No console available for logging"}function g(a){return function(){typeof console!==n&&(l.call(this),this[a].apply(this,arguments))}}function S(a,u,c){return d(a)||g.apply(this,arguments)}function v(a,u){var c=this,C,N,P,k="loglevel";typeof a=="string"?k+=":"+a:typeof a=="symbol"&&(k=void 0);function V(p){var y=(i[p]||"silent").toUpperCase();if(!(typeof window===n||!k)){try{window.localStorage[k]=y;return}catch{}try{window.document.cookie=encodeURIComponent(k)+"="+y+";"}catch{}}}function E(){var p;if(!(typeof window===n||!k)){try{p=window.localStorage[k]}catch{}if(typeof p===n)try{var y=window.document.cookie,O=encodeURIComponent(k),q=y.indexOf(O+"=");q!==-1&&(p=/^([^;]+)/.exec(y.slice(q+O.length+1))[1])}catch{}return c.levels[p]===void 0&&(p=void 0),p}}function L(){if(!(typeof window===n||!k)){try{window.localStorage.removeItem(k)}catch{}try{window.document.cookie=encodeURIComponent(k)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}function T(p){var y=p;if(typeof y=="string"&&c.levels[y.toUpperCase()]!==void 0&&(y=c.levels[y.toUpperCase()]),typeof y=="number"&&y>=0&&y<=c.levels.SILENT)return y;throw new TypeError("log.setLevel() called with invalid level: "+p)}c.name=a,c.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},c.methodFactory=u||S,c.getLevel=function(){return P??N??C},c.setLevel=function(p,y){return P=T(p),y!==!1&&V(P),l.call(c)},c.setDefaultLevel=function(p){N=T(p),E()||c.setLevel(p,!1)},c.resetLevel=function(){P=null,L(),l.call(c)},c.enableAll=function(p){c.setLevel(c.levels.TRACE,p)},c.disableAll=function(p){c.setLevel(c.levels.SILENT,p)},c.rebuild=function(){if(s!==c&&(C=T(s.getLevel())),l.call(c),s===c)for(var p in r)r[p].rebuild()},C=T(s?s.getLevel():"WARN");var F=E();F!=null&&(P=T(F)),l.call(c)}s=new v,s.getLogger=function(a){if(typeof a!="symbol"&&typeof a!="string"||a==="")throw new TypeError("You must supply a name when creating a logger.");var u=r[a];return u||(u=r[a]=new v(a,s.methodFactory)),u};var b=typeof window!==n?window.log:void 0;return s.noConflict=function(){return typeof window!==n&&window.log===s&&(window.log=b),s},s.getLoggers=function(){return r},s.default=s,s})})(Ae)),Ae.exports}var Nn=Pn();const An=En(Nn),ot=An.getLogger(bn);ot.setDefaultLevel("info");function it(e,t){const{sectionId:n}=Ce(),{release:o}=tt(n),[i,r]=h.useState({state:"loading",value:t});return h.useMemo(()=>{e.then(s=>r({state:"hasData",value:s})).catch(s=>{r({state:"hasError",value:s}),ot.error("Error in useSuspenseForPromise",s)})},[e]),h.useEffect(()=>{i.state!=="loading"&&o()},[i,o]),i.value}function xn(e){let t=null;return()=>(t||(t=e()),t)}const rt=xn(async()=>{const e=await window[Ft]?.();return e?JSON.parse(e):null});function Tn(e){return it(rt(),e)}const In={A1:{height:"841mm",width:"594mm"},A2:{height:"594mm",width:"420mm"},A3:{height:"420mm",width:"297mm"},A4:{height:"297mm",width:"210mm"},A5:{height:"210mm",width:"148mm"},A6:{height:"148mm",width:"105mm"},B3:{height:"500mm",width:"353mm"},B4:{height:"353mm",width:"250mm"},B5:{height:"250mm",width:"176mm"},Letter:{height:"8.5in",width:"11in"},Legal:{height:"11in",width:"8.5in"},Tabloid:{height:"11in",width:"17in"}},Ln={Normal:{top:"1in",right:"1in",bottom:"1in",left:"1in"},Narrow:{top:"0.4in",right:"0.6in",bottom:"0.6in",left:"0.6in"},Wide:{top:"0.5in",right:"2in",bottom:"0.5in",left:"2in"},None:{top:"0in",right:"0in",bottom:"0in",left:"0in"}},Fn=In,zn=Ln;w.Layout=_n,w.PageBreak=Sn,w.PageContent=ge,w.PageFooter=he,w.PageHeader=me,w.PageOverlay=_e,w.ReportPreview=ct,w.ReportRoot=Dt,w.Section=vn,w.SectionFooter=ve,w.SectionHeader=Se,w.jsonData=rt,w.pageMargin=zn,w.pageSize=Fn,w.useJsonData=Tn,w.usePageInfo=yn,w.useReportInfo=wn,w.useSectionInfo=Ce,w.useSectionSuspension=tt,w.useSuspenseForPromise=it,Object.defineProperty(w,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(a,r){typeof exports=="object"&&typeof module<"u"?r(exports,require("react/jsx-runtime"),require("@paprize/core"),require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@paprize/core","react","react-dom"],r):(a=typeof globalThis<"u"?globalThis:a||self,r(a["paprize-react"]={},a.jsxRuntime,a.PaprizeCore,a.React,a.ReactDOM))})(this,(function(a,r,u,o,N){"use strict";function z({children:e}){return r.jsx("div",{className:u.previewClassName,children:e})}const b=o.createContext(null);function g(){const e=o.useContext(b);if(!e)throw new Error("ReportRoot is missing. Please wrap your component tree with ReportRoot component.");return e}function L({children:e}){const t=o.useMemo(()=>new u.ReportBuilder,[]);return o.useEffect(()=>{t.schedulePaginate()},[t]),r.jsx(b,{value:t,children:e})}function h({children:e}){const t=g(),s=o.useRef(!1);return o.useEffect(()=>{const n=t.monitor.addEventListener("paginationCycleCompleted",()=>{s.current=!0});return()=>n()},[t.monitor]),o.useEffect(()=>{s.current&&t.schedulePaginate()},[e,t]),r.jsx(r.Fragment,{children:e})}function w({children:e}){return r.jsx(r.Fragment,{children:e})}function I({children:e}){return r.jsx(r.Fragment,{children:e})}function F({children:e}){return r.jsx(r.Fragment,{children:e})}function E({children:e}){return r.jsx(r.Fragment,{children:e})}function m({children:e}){return r.jsx(r.Fragment,{children:e})}const H=[h,I,w,m,E,F];function _(e){let t=null;const s={};if(o.Children.forEach(e,n=>{if(!o.isValidElement(n))throw new Error(`Invalid React element found in children: ${n}`,{cause:{child:n}});const i=H.find(c=>c===n.type);if(!i)throw Error(`Component "${n.type}" is not valid as a child for Section, Expected one of: ${H.map(c=>c.name).join(",")}`);switch(i){case E:s.sectionHeader=n;break;case F:s.sectionFooter=n;break;case h:t=n;break;case I:s.header=n;break;case w:s.footer=n;break;case m:s.overlay=n;break}}),!t)throw Error("PageContent component is a required child for Section");return{...s,content:t}}const S=o.createContext(""),M=o.createContext({pageIndex:0,totalPages:0});function B({elements:e,dimension:t,margin:s,pageIndex:n,totalPages:i,ref:c,sectionHeaderRef:d,sectionFooterRef:l,pageHeaderRef:f,pageFooterRef:y,contentRef:P}){const C=o.useContext(S),v=o.useMemo(()=>({pageIndex:n,totalPages:i}),[n,i]);return r.jsx(M,{value:v,children:r.jsxs("div",{id:`${C}-${n}`,className:u.pageClassName,ref:c,style:u.reportStyles.page(t,s??u.pageMargin.None),children:[e.sectionHeader&&n===0&&r.jsx("div",{style:u.reportStyles.component,ref:d,children:e.sectionHeader}),e.header&&r.jsx("div",{style:u.reportStyles.component,ref:f,children:e.header}),r.jsx("div",{style:u.reportStyles.pageContent,ref:P,children:e.content}),e.overlay&&r.jsx("div",{style:u.reportStyles.overlay,children:e.overlay}),(e.footer||e.sectionFooter)&&r.jsxs("div",{style:{...u.reportStyles.component,marginTop:"auto"},children:[e.footer&&r.jsx("div",{style:u.reportStyles.component,ref:y,children:e.footer}),e.sectionFooter&&n===i-1&&r.jsx("div",{style:u.reportStyles.component,ref:l,children:e.sectionFooter})]})]})})}const D=o.createContext({addPlugin:()=>{throw new Error("addPlugin must be used within a Section")},addSuspense:()=>{throw new Error("addSuspense must be used within a Section")}});function J(e){const t=o.useMemo(()=>({plugins:e??[],suspense:[]}),[e]),s=o.useMemo(()=>({addPlugin:n=>{t.plugins.push(n)},addSuspense:n=>{t.suspense.push(n)}}),[t]);return{controllerState:t,controllerValue:s}}function O({elements:e,dimension:t,margin:s,config:n}){const i=o.useContext(S),{controllerState:c,controllerValue:d}=J(n?.plugins),l=g(),f=o.useRef(null),y=o.useRef(null),P=o.useRef(null),C=o.useRef(null),v=o.useRef(null),x=o.useRef(null),[Y,Z]=o.useState(null);return o.useEffect(()=>{if(x.current)return l.tryAddSection({...n,id:i,dimension:t,margin:s,plugins:c.plugins,suspense:c.suspense},{pageContent:x.current,sectionHeader:y.current,sectionFooter:P.current,pageFooter:v.current,pageHeader:C.current},p=>{Z(p)}),()=>{l.removeSection(i)}},[n,c,t,s,l,i]),r.jsxs(D,{value:d,children:[Y?.map(p=>r.jsx(B,{elements:{...e,content:r.jsx("div",{style:{display:"contents"},dangerouslySetInnerHTML:{__html:p.pageContentHtml}})},dimension:t,margin:s,pageIndex:p.index,totalPages:p.totalPages},p.index)),N.createPortal(r.jsx("div",{style:u.reportStyles.outOfScreen,children:r.jsx(B,{elements:e,dimension:t,margin:s,pageIndex:0,totalPages:1,ref:f,sectionHeaderRef:y,sectionFooterRef:P,pageHeaderRef:C,pageFooterRef:v,contentRef:x})}),document.body)]})}let R=1;function $({children:e,id:t,dimension:s,orientation:n="portrait",margin:i,config:c}){const d=o.useMemo(()=>t??`__000${R++}`,[t]),l=o.useMemo(()=>_(e),[e]),f=o.useMemo(()=>u.adjustDimension(s,n),[s,n]);return r.jsx("section",{className:u.sectionClassName,id:d,style:u.reportStyles.section(d),children:r.jsx(S,{value:d,children:r.jsx(O,{elements:l,dimension:f,margin:i,config:c})})})}function j(){return r.jsx("span",{[u.pageBreakAttributeName]:"true"})}function q({children:e,...t}){return r.jsx("div",{style:{display:"contents"},...u.configToAttributeMap(t),children:e})}const V=()=>{const e=o.useContext(M);return{pageIndex:e.pageIndex,totalPages:e.totalPages}},A=()=>{const e=o.useContext(S),t=g(),s=o.useRef({pages:[],isPaginated:!1,isSuspended:!1,index:-1,sectionId:e}),n=o.useSyncExternalStore(i=>t.monitor.addEventListener("sectionCompleted",c=>{c.sectionId===e&&(s.current=c,i())}),()=>s.current);return{sectionId:e,sectionIndex:n.index,isSuspended:n.isSuspended,isPaginated:n.isPaginated,pages:n.pages.map(i=>({pageIndex:i.index,totalPages:i.totalPages}))}};function G(e){return{pageIndex:e.index,totalPages:e.totalPages}}function K(e){return{sectionId:e.sectionId,sectionIndex:e.index,isPaginated:e.isPaginated,isSuspended:e.isSuspended,pages:e.pages.map(G)}}function Q(e){return{sections:e.sections.map(K)}}function U(){const e=g(),t=o.useRef({sections:[]}),s=o.useSyncExternalStore(n=>e.monitor.addEventListener("paginationCycleCompleted",i=>{t.current=i,n()}),()=>t.current);return Q(s)}function T(e){const t=o.useRef(null),{addSuspense:s}=o.useContext(D);return o.useEffect(()=>{if(t.current)return;const n=e??new Promise(i=>{t.current=i});t.current||=()=>{},s(n)},[s,e]),o.useMemo(()=>({reset:()=>{t.current||s(new Promise(n=>{t.current=n}))},release:()=>{t.current?.(),t.current=null}}),[s])}function W(e){let t=null;return()=>(t||(t=e()),t)}const k=W(async()=>{if(!(u.paprize_readJsonDataFile in window))throw new Error("The function paprize_readJsonDataFile is not available in the current environment.");const e=await window[u.paprize_readJsonDataFile]?.();return e?JSON.parse(e):null});function X(e){return T(k().catch(()=>e))}a.Layout=q,a.PageBreak=j,a.PageContent=h,a.PageFooter=w,a.PageHeader=I,a.PageOverlay=m,a.ReportPreview=z,a.ReportRoot=L,a.Section=$,a.SectionFooter=F,a.SectionHeader=E,a.jsonData=k,a.useJsonData=X,a.usePageInfo=V,a.useReportInfo=U,a.useSectionInfo=A,a.useSectionSuspension=T,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})}));
2
+ //# sourceMappingURL=paprize-react.umd.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paprize-react.umd.cjs","sources":["../src/components/ReportPreview.tsx","../src/internal/useReportBuilder.ts","../src/components/ReportRoot.tsx","../src/components/PageContent.tsx","../src/components/PageFooter.tsx","../src/components/PageHeader.tsx","../src/components/SectionFooter.tsx","../src/components/SectionHeader.tsx","../src/components/PageOverlay.tsx","../src/internal/parseSectionChildren.ts","../src/internal/SectionIdContext.ts","../src/internal/PageInfoContext.ts","../src/components/Page.tsx","../src/internal/SectionControllerContext.ts","../src/internal/useSectionControllerState.tsx","../src/internal/SectionLayout.tsx","../src/components/Section.tsx","../src/components/PageBreak.tsx","../src/components/Layout.tsx","../src/components/usePageInfo.ts","../src/components/useSectionInfo.ts","../src/internal/eventHelper.ts","../src/components/useReportInfo.ts","../src/components/useSectionSuspension.ts","../src/components/useJsonData.ts"],"sourcesContent":["import type { ReactNode } from 'react';\nimport { previewClassName } from '@paprize/core/src';\n\n/**\n * ReportPreview is a wrapper component that applies styles to its children, mimicking the appearance of the Chrome Print Preview screen.\n * Use this component to render reports or documents with a print-friendly layout and consistent visual formatting in client side application.\n */\nexport function ReportPreview({ children }: { children: ReactNode }) {\n return <div className={previewClassName}>{children}</div>;\n}\n","import type { ReportBuilder } from '@paprize/core/src';\nimport { createContext, useContext } from 'react';\n\nexport const ReportBuilderContext = createContext<ReportBuilder | null>(null);\n\nexport function useReportBuilder() {\n const context = useContext(ReportBuilderContext);\n if (!context) {\n throw new Error(\n 'ReportRoot is missing. Please wrap your component tree with ReportRoot component.'\n );\n }\n\n return context;\n}\n","import { useEffect, useMemo, type ReactNode } from 'react';\nimport { ReportBuilder } from '@paprize/core/src';\nimport { ReportBuilderContext } from '../internal/useReportBuilder';\n\nexport interface ReportRootProps {\n children: ReactNode;\n}\n\nexport function ReportRoot({ children }: ReportRootProps) {\n const reportBuilder = useMemo(() => new ReportBuilder(), []);\n\n useEffect(() => {\n reportBuilder.schedulePaginate();\n }, [reportBuilder]);\n\n return (\n <ReportBuilderContext value={reportBuilder}>\n {children}\n </ReportBuilderContext>\n );\n}\n","import { useEffect, useRef, type ReactNode } from 'react';\nimport { useReportBuilder } from '../internal/useReportBuilder';\n\nexport function PageContent({ children }: { children: ReactNode }) {\n const reportBuilder = useReportBuilder();\n const isFirstCycleCompleted = useRef(false);\n\n useEffect(() => {\n const unsubscribe = reportBuilder.monitor.addEventListener(\n 'paginationCycleCompleted',\n () => {\n isFirstCycleCompleted.current = true;\n }\n );\n\n return () => unsubscribe();\n }, [reportBuilder.monitor]);\n\n // If the children change after the first pagination cycle, we need to re-paginate\n // this can happen if the content is dynamic or loaded asynchronously\n // if we don't do this, the new content will be ignored in the pagination\n useEffect(() => {\n if (isFirstCycleCompleted.current) {\n reportBuilder.schedulePaginate();\n }\n }, [children, reportBuilder]);\n\n return <>{children}</>;\n}\n","export function PageFooter({ children }: { children: React.ReactNode }) {\n return <>{children}</>;\n}\n","import type { ReactNode } from 'react';\n\nexport function PageHeader({ children }: { children: ReactNode }) {\n return <>{children}</>;\n}\n","export function SectionFooter({ children }: { children: React.ReactNode }) {\n return <>{children}</>;\n}\n","export function SectionHeader({ children }: { children: React.ReactNode }) {\n return <>{children}</>;\n}\n","import type { ReactNode } from 'react';\n\nexport function PageOverlay({ children }: { children: ReactNode }) {\n return <>{children}</>;\n}\n","import {\n Children,\n isValidElement,\n type FC,\n type ReactElement,\n type ReactNode,\n} from 'react';\nimport { PageContent } from '../components/PageContent';\nimport { PageFooter } from '../components/PageFooter';\nimport { PageHeader } from '../components/PageHeader';\nimport { SectionFooter } from '../components/SectionFooter';\nimport { SectionHeader } from '../components/SectionHeader';\nimport { PageOverlay } from '../components/PageOverlay';\n\nconst validChildren: FC<{ children: ReactNode }>[] = [\n PageContent,\n PageHeader,\n PageFooter,\n PageOverlay,\n SectionHeader,\n SectionFooter,\n];\n\nexport interface PageElements {\n content: ReactElement;\n header?: ReactElement;\n footer?: ReactElement;\n overlay?: ReactElement;\n sectionHeader?: ReactElement;\n sectionFooter?: ReactElement;\n}\n\nfunction parseSectionChildren(children: ReactNode): PageElements {\n let content: ReactElement | null = null;\n const pageElements: Partial<PageElements> = {};\n\n Children.forEach(children, (child) => {\n if (!isValidElement(child)) {\n throw new Error(\n `Invalid React element found in children: ${child}`,\n {\n cause: { child },\n }\n );\n }\n\n const component = validChildren.find((x) => x === child.type);\n if (!component) {\n throw Error(\n `Component \"${child.type}\" is not valid as a child for Section, Expected one of: ${validChildren\n .map((x) => x.name)\n .join(',')}`\n );\n }\n\n switch (component) {\n case SectionHeader:\n pageElements.sectionHeader = child;\n break;\n\n case SectionFooter:\n pageElements.sectionFooter = child;\n break;\n\n case PageContent:\n content = child;\n break;\n\n case PageHeader:\n pageElements.header = child;\n break;\n\n case PageFooter:\n pageElements.footer = child;\n break;\n\n case PageOverlay:\n pageElements.overlay = child;\n break;\n }\n });\n\n if (!content) {\n throw Error('PageContent component is a required child for Section');\n }\n\n return { ...pageElements, content: content };\n}\n\nexport default parseSectionChildren;\n","import { createContext } from 'react';\n\nexport const SectionIdContext = createContext<string>('');\n","import { createContext } from 'react';\n\nexport const PageInfoContext = createContext<{\n pageIndex: number;\n totalPages: number;\n}>({\n pageIndex: 0,\n totalPages: 0,\n});\n","import { useContext, useMemo, type Ref } from 'react';\nimport { type PageElements } from '../internal/parseSectionChildren';\nimport { PageInfoContext } from '../internal/PageInfoContext';\nimport { SectionIdContext } from '../internal/SectionIdContext';\nimport {\n pageClassName,\n pageMargin,\n reportStyles,\n type PageDimension,\n type PageMargin,\n} from '@paprize/core/src';\n\nexport interface PageProps {\n elements: PageElements;\n dimension: PageDimension;\n margin?: PageMargin;\n pageIndex: number;\n totalPages: number;\n ref?: Ref<HTMLDivElement>;\n sectionHeaderRef?: Ref<HTMLDivElement>;\n sectionFooterRef?: Ref<HTMLDivElement>;\n pageHeaderRef?: Ref<HTMLDivElement>;\n pageFooterRef?: Ref<HTMLDivElement>;\n contentRef?: Ref<HTMLDivElement>;\n}\n\nexport function Page({\n elements,\n dimension,\n margin,\n pageIndex,\n totalPages,\n ref,\n sectionHeaderRef,\n sectionFooterRef,\n pageHeaderRef,\n pageFooterRef,\n contentRef,\n}: PageProps) {\n const sectionId = useContext(SectionIdContext);\n const contextValue = useMemo(\n () => ({ pageIndex, totalPages }),\n [pageIndex, totalPages]\n );\n\n return (\n <PageInfoContext value={contextValue}>\n <div\n id={`${sectionId}-${pageIndex}`}\n className={pageClassName}\n ref={ref}\n style={reportStyles.page(dimension, margin ?? pageMargin.None)}\n >\n {elements.sectionHeader && pageIndex === 0 && (\n <div style={reportStyles.component} ref={sectionHeaderRef}>\n {elements.sectionHeader}\n </div>\n )}\n {elements.header && (\n <div style={reportStyles.component} ref={pageHeaderRef}>\n {elements.header}\n </div>\n )}\n\n <div style={reportStyles.pageContent} ref={contentRef}>\n {elements.content}\n </div>\n\n {elements.overlay && (\n <div style={reportStyles.overlay}>{elements.overlay}</div>\n )}\n\n {(elements.footer || elements.sectionFooter) && (\n <div\n style={{ ...reportStyles.component, marginTop: 'auto' }}\n >\n {elements.footer && (\n <div\n style={reportStyles.component}\n ref={pageFooterRef}\n >\n {elements.footer}\n </div>\n )}\n {elements.sectionFooter &&\n pageIndex === totalPages - 1 && (\n <div\n style={reportStyles.component}\n ref={sectionFooterRef}\n >\n {elements.sectionFooter}\n </div>\n )}\n </div>\n )}\n </div>\n </PageInfoContext>\n );\n}\n","import type { PaginationPlugin } from '@paprize/core/src';\nimport { createContext } from 'react';\n\nexport interface SectionController {\n addPlugin: (plugin: PaginationPlugin) => void;\n addSuspense: (suspense: Promise<void>) => void;\n}\n\nexport const SectionControllerContext = createContext<SectionController>({\n addPlugin: () => {\n throw new Error('addPlugin must be used within a Section');\n },\n addSuspense: () => {\n throw new Error('addSuspense must be used within a Section');\n },\n});\n","import { useMemo } from 'react';\nimport { type SectionController } from './SectionControllerContext';\nimport type { PaginationPlugin } from '@paprize/core/src';\n\nexport function useSectionControllerState(plugins?: PaginationPlugin[]) {\n const state = useMemo(\n () => ({\n plugins: plugins ?? ([] as PaginationPlugin[]),\n suspense: [] as Promise<void>[],\n }),\n [plugins]\n );\n\n const sectionController: SectionController = useMemo(\n () => ({\n addPlugin: (plugin: PaginationPlugin) => {\n state.plugins.push(plugin);\n },\n addSuspense: (suspense: Promise<void>) => {\n state.suspense.push(suspense);\n },\n }),\n [state]\n );\n\n return {\n controllerState: state,\n controllerValue: sectionController,\n };\n}\n","import {\n reportStyles,\n type PageContext,\n type PageDimension,\n type PageMargin,\n type PaginationConfig,\n} from '@paprize/core/src';\nimport { useContext, useEffect, useRef, useState } from 'react';\nimport { createPortal } from 'react-dom';\nimport { Page } from '../components/Page';\nimport { useReportBuilder } from './useReportBuilder';\nimport { SectionIdContext } from './SectionIdContext';\nimport type { PageElements } from './parseSectionChildren';\nimport { useSectionControllerState } from './useSectionControllerState';\nimport { SectionControllerContext } from './SectionControllerContext';\n\nexport interface SectionLayoutProps {\n elements: PageElements;\n dimension: PageDimension;\n margin: PageMargin | undefined;\n config?: Partial<PaginationConfig>;\n}\n\nexport function SectionLayout({\n elements,\n dimension,\n margin,\n config,\n}: SectionLayoutProps) {\n const sectionId = useContext(SectionIdContext);\n const { controllerState, controllerValue } = useSectionControllerState(\n config?.plugins\n );\n const reportBuilder = useReportBuilder();\n const pageRef = useRef<HTMLDivElement>(null);\n const sectionHeaderRef = useRef<HTMLDivElement>(null);\n const sectionFooterRef = useRef<HTMLDivElement>(null);\n const pageHeaderRef = useRef<HTMLDivElement>(null);\n const pageFooterRef = useRef<HTMLDivElement>(null);\n const contentRef = useRef<HTMLDivElement>(null);\n const [pageContexts, setPageContexts] = useState<PageContext[] | null>(\n null\n );\n\n useEffect(() => {\n if (!contentRef.current) {\n return;\n }\n\n reportBuilder.tryAddSection(\n {\n ...config,\n id: sectionId,\n dimension: dimension,\n margin: margin,\n plugins: controllerState.plugins,\n suspense: controllerState.suspense,\n },\n {\n pageContent: contentRef.current,\n sectionHeader: sectionHeaderRef.current,\n sectionFooter: sectionFooterRef.current,\n pageFooter: pageFooterRef.current,\n pageHeader: pageHeaderRef.current,\n },\n (pages) => {\n setPageContexts(pages);\n }\n );\n\n return () => {\n reportBuilder.removeSection(sectionId);\n };\n }, [config, controllerState, dimension, margin, reportBuilder, sectionId]);\n\n return (\n <SectionControllerContext value={controllerValue}>\n {pageContexts?.map((pageContext) => (\n <Page\n key={pageContext.index}\n elements={{\n ...elements,\n content: (\n <div\n style={{ display: 'contents' }}\n dangerouslySetInnerHTML={{\n __html: pageContext.pageContentHtml,\n }}\n />\n ),\n }}\n dimension={dimension}\n margin={margin}\n pageIndex={pageContext.index}\n totalPages={pageContext.totalPages}\n />\n ))}\n\n {createPortal(\n <div style={reportStyles.outOfScreen}>\n <Page\n elements={elements}\n dimension={dimension}\n margin={margin}\n pageIndex={0}\n totalPages={1}\n ref={pageRef}\n sectionHeaderRef={sectionHeaderRef}\n sectionFooterRef={sectionFooterRef}\n pageHeaderRef={pageHeaderRef}\n pageFooterRef={pageFooterRef}\n contentRef={contentRef}\n />\n </div>,\n document.body\n )}\n </SectionControllerContext>\n );\n}\n","import { useMemo, type ReactNode } from 'react';\nimport parseSectionChildren from '../internal/parseSectionChildren';\nimport { SectionIdContext } from '../internal/SectionIdContext';\nimport {\n adjustDimension,\n reportStyles,\n sectionClassName,\n type PageDimension,\n type PageMargin,\n type PageOrientation,\n type PaginationConfig,\n} from '@paprize/core/src';\nimport { SectionLayout } from '../internal/SectionLayout';\n\nexport interface SectionProps {\n children: ReactNode;\n id?: string;\n dimension: PageDimension;\n orientation?: PageOrientation;\n margin?: PageMargin;\n config?: Partial<PaginationConfig>;\n}\n\nlet sectionIdCounter = 1;\n\nexport function Section({\n children,\n id,\n dimension,\n orientation = 'portrait',\n margin,\n config,\n}: SectionProps) {\n const sectionId = useMemo(() => id ?? `__000${sectionIdCounter++}`, [id]);\n const elements = useMemo(() => parseSectionChildren(children), [children]);\n\n const adjustedDimension = useMemo(\n () => adjustDimension(dimension, orientation),\n [dimension, orientation]\n );\n\n return (\n <section\n className={sectionClassName}\n id={sectionId}\n style={reportStyles.section(sectionId)}\n >\n <SectionIdContext value={sectionId}>\n <SectionLayout\n elements={elements}\n dimension={adjustedDimension}\n margin={margin}\n config={config}\n />\n </SectionIdContext>\n </section>\n );\n}\n","import { pageBreakAttributeName } from '@paprize/core/src';\n\nexport function PageBreak() {\n return <span {...{ [pageBreakAttributeName]: 'true' }} />;\n}\n","import { configToAttributeMap, type ConfigAttribute } from '@paprize/core/src';\n\nexport interface LayoutProps extends ConfigAttribute {\n children: React.ReactNode;\n}\n\nexport function Layout({ children, ...attributes }: LayoutProps) {\n return (\n <div\n style={{ display: 'contents' }}\n {...configToAttributeMap(attributes)}\n >\n {children}\n </div>\n );\n}\n","import { useContext } from 'react';\nimport { PageInfoContext } from '../internal/PageInfoContext';\n\nexport const usePageInfo = () => {\n const pageContext = useContext(PageInfoContext);\n\n return {\n pageIndex: pageContext.pageIndex,\n totalPages: pageContext.totalPages,\n };\n};\n","import { useContext, useRef, useSyncExternalStore } from 'react';\nimport type { SectionContext } from '@paprize/core/src';\nimport { useReportBuilder } from '../internal/useReportBuilder';\nimport { SectionIdContext } from '../internal/SectionIdContext';\nimport type { SectionInfo } from '../internal/eventHelper';\n\nexport const useSectionInfo = (): SectionInfo => {\n const sectionId = useContext(SectionIdContext);\n const reportBuilder = useReportBuilder();\n const stateRef = useRef<SectionContext>({\n pages: [],\n isPaginated: false,\n isSuspended: false,\n index: -1,\n sectionId: sectionId,\n });\n\n const state = useSyncExternalStore(\n (callback) => {\n return reportBuilder.monitor.addEventListener(\n 'sectionCompleted',\n (sc) => {\n if (sc.sectionId !== sectionId) return;\n stateRef.current = sc;\n callback();\n }\n );\n },\n () => stateRef.current\n );\n\n return {\n sectionId: sectionId,\n sectionIndex: state.index,\n isSuspended: state.isSuspended,\n isPaginated: state.isPaginated,\n pages: state.pages.map((p) => ({\n pageIndex: p.index,\n totalPages: p.totalPages,\n })),\n };\n};\n","import type {\n PaginationCycleCompleted,\n SectionContext,\n} from '@paprize/core/src';\n\nexport interface SectionInfo {\n sectionId: string;\n sectionIndex: number;\n isPaginated: boolean;\n isSuspended: boolean;\n pages: PageInfo[];\n}\n\nexport interface PageInfo {\n pageIndex: number;\n totalPages: number;\n}\n\nexport interface ReportInfo {\n sections: SectionInfo[];\n}\n\nexport function pageContextToPageInfo(pc: {\n index: number;\n totalPages: number;\n}): PageInfo {\n return {\n pageIndex: pc.index,\n totalPages: pc.totalPages,\n };\n}\n\nexport function sectionContextToSectionInfo(sc: SectionContext): SectionInfo {\n return {\n sectionId: sc.sectionId,\n sectionIndex: sc.index,\n isPaginated: sc.isPaginated,\n isSuspended: sc.isSuspended,\n pages: sc.pages.map(pageContextToPageInfo),\n };\n}\n\nexport function paginationCycleToReportInfo(\n rc: PaginationCycleCompleted\n): ReportInfo {\n return {\n sections: rc.sections.map(sectionContextToSectionInfo),\n };\n}\n","import { useRef, useSyncExternalStore } from 'react';\nimport { useReportBuilder } from '../internal/useReportBuilder';\nimport type { PaginationCycleCompleted } from '@paprize/core/src';\nimport {\n paginationCycleToReportInfo,\n type ReportInfo,\n} from '../internal/eventHelper';\n\nexport function useReportInfo(): ReportInfo {\n const reportBuilder = useReportBuilder();\n const stateRef = useRef<PaginationCycleCompleted>({\n sections: [],\n });\n\n const state = useSyncExternalStore(\n (callback) => {\n return reportBuilder.monitor.addEventListener(\n 'paginationCycleCompleted',\n (pg) => {\n stateRef.current = pg;\n callback();\n }\n );\n },\n () => stateRef.current\n );\n\n return paginationCycleToReportInfo(state);\n}\n","import { useContext, useEffect, useMemo, useRef } from 'react';\nimport { SectionControllerContext } from '../internal/SectionControllerContext';\n\nexport function useSectionSuspension(\n promise: Promise<void> | Promise<unknown>\n): void;\nexport function useSectionSuspension(): {\n release: () => void;\n reset: () => void;\n};\nexport function useSectionSuspension(\n promise?: Promise<void> | Promise<unknown>\n) {\n const resolveFn = useRef<() => void | null>(null);\n const { addSuspense } = useContext(SectionControllerContext);\n\n useEffect(() => {\n if (resolveFn.current) {\n return;\n }\n\n const pr =\n promise ??\n new Promise<void>((resolve) => {\n resolveFn.current = resolve;\n });\n resolveFn.current ||= () => {};\n\n addSuspense(pr as Promise<void>);\n }, [addSuspense, promise]);\n\n return useMemo(\n () => ({\n reset: () => {\n if (resolveFn.current) return;\n\n addSuspense(\n new Promise<void>((resolve) => {\n resolveFn.current = resolve;\n })\n );\n },\n release: () => {\n resolveFn.current?.();\n resolveFn.current = null;\n },\n }),\n [addSuspense]\n );\n}\n","import { paprize_readJsonDataFile } from '@paprize/core/src';\nimport { useSectionSuspension } from './useSectionSuspension';\n\nfunction lazy<T>(factory: () => Promise<T>): () => Promise<T> {\n let promise: Promise<T> | null = null;\n\n return () => {\n if (!promise) {\n promise = factory();\n }\n return promise;\n };\n}\n\n// the function is not available in browser, and in puppeteer it is injected before anything else but we\n// still need to delay the call\nexport const jsonData = lazy(async () => {\n if (!(paprize_readJsonDataFile in window)) {\n throw new Error(\n 'The function paprize_readJsonDataFile is not available in the current environment.'\n );\n }\n\n const strData = await window[paprize_readJsonDataFile]?.();\n return strData ? (JSON.parse(strData) as unknown) : null;\n});\n\nexport function useJsonData<DataModel>(\n defaultValue?: DataModel\n): DataModel | undefined {\n return useSectionSuspension(jsonData().catch(() => defaultValue)) as\n | DataModel\n | undefined;\n}\n"],"names":["ReportPreview","children","jsx","previewClassName","ReportBuilderContext","createContext","useReportBuilder","context","useContext","ReportRoot","reportBuilder","useMemo","ReportBuilder","useEffect","PageContent","isFirstCycleCompleted","useRef","unsubscribe","PageFooter","PageHeader","SectionFooter","SectionHeader","PageOverlay","validChildren","parseSectionChildren","content","pageElements","Children","child","isValidElement","component","x","SectionIdContext","PageInfoContext","Page","elements","dimension","margin","pageIndex","totalPages","ref","sectionHeaderRef","sectionFooterRef","pageHeaderRef","pageFooterRef","contentRef","sectionId","contextValue","jsxs","pageClassName","reportStyles","pageMargin","SectionControllerContext","useSectionControllerState","plugins","state","sectionController","plugin","suspense","SectionLayout","config","controllerState","controllerValue","pageRef","pageContexts","setPageContexts","useState","pages","pageContext","createPortal","sectionIdCounter","Section","id","orientation","adjustedDimension","adjustDimension","sectionClassName","PageBreak","pageBreakAttributeName","Layout","attributes","configToAttributeMap","usePageInfo","useSectionInfo","stateRef","useSyncExternalStore","callback","sc","p","pageContextToPageInfo","pc","sectionContextToSectionInfo","paginationCycleToReportInfo","rc","useReportInfo","pg","useSectionSuspension","promise","resolveFn","addSuspense","pr","resolve","lazy","factory","jsonData","paprize_readJsonDataFile","strData","useJsonData","defaultValue"],"mappings":"mbAOO,SAASA,EAAc,CAAE,SAAAC,GAAqC,CACjE,OAAOC,EAAAA,IAAC,MAAA,CAAI,UAAWC,EAAAA,iBAAmB,SAAAF,CAAA,CAAS,CACvD,CCNO,MAAMG,EAAuBC,EAAAA,cAAoC,IAAI,EAErE,SAASC,GAAmB,CAC/B,MAAMC,EAAUC,EAAAA,WAAWJ,CAAoB,EAC/C,GAAI,CAACG,EACD,MAAM,IAAI,MACN,mFAAA,EAIR,OAAOA,CACX,CCNO,SAASE,EAAW,CAAE,SAAAR,GAA6B,CACtD,MAAMS,EAAgBC,EAAAA,QAAQ,IAAM,IAAIC,EAAAA,cAAiB,CAAA,CAAE,EAE3DC,OAAAA,EAAAA,UAAU,IAAM,CACZH,EAAc,iBAAA,CAClB,EAAG,CAACA,CAAa,CAAC,EAGdR,EAAAA,IAACE,EAAA,CAAqB,MAAOM,EACxB,SAAAT,CAAA,CACL,CAER,CCjBO,SAASa,EAAY,CAAE,SAAAb,GAAqC,CAC/D,MAAMS,EAAgBJ,EAAA,EAChBS,EAAwBC,EAAAA,OAAO,EAAK,EAE1CH,OAAAA,EAAAA,UAAU,IAAM,CACZ,MAAMI,EAAcP,EAAc,QAAQ,iBACtC,2BACA,IAAM,CACFK,EAAsB,QAAU,EACpC,CAAA,EAGJ,MAAO,IAAME,EAAA,CACjB,EAAG,CAACP,EAAc,OAAO,CAAC,EAK1BG,EAAAA,UAAU,IAAM,CACRE,EAAsB,SACtBL,EAAc,iBAAA,CAE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AAIqF,EAAU,QACV,OAGJ,MAAME,EACFH,GACA,IAAI,QAAeI,GAAY,CAC3BH,EAAU,QAAUG,CACxB,CAAC,EACLH,EAAU,UAAY,IAAM,CAAC,EAE7BC,EAAYC,CAAmB,CACnC,EAAG,CAACD,EAAaF,CAAO,CAAC,EAElBtF,EAAAA,QACH,KAAO,CACH,MAAO,IAAM,CACLuF,EAAU,SAEdC,EACI,IAAI,QAAeE,GAAY,CAC3BH,EAAU,QAAUG,CACxB,CAAC,CAAA,CAET,EACA,QAAS,IAAM,CACXH,EAAU,UAAA,EACVA,EAAU,QAAU,IACxB,CAAA,GAEJ,CAACC,CAAW,CAAA,CAEpB,CC9CA,SAASG,EAAQC,EAA6C,CAC1D,IAAIN,EAA6B,KAEjC,MAAO,KACEA,IACDA,EAAUM,EAAA,GAEPN,EAEf,CAIO,MAAMO,EAAWF,EAAK,SAAY,CACrC,GAAI,EAAEG,EAAAA,4BAA4B,QAC9B,MAAM,IAAI,MACN,oFAAA,EAIR,MAAMC,EAAU,MAAM,OAAOD,EAAAA,wBAAwB,IAAA,EACrD,OAAOC,EAAW,KAAK,MAAMA,CAAO,EAAgB,IACxD,CAAC,EAEM,SAASC,EACZC,EACqB,CACrB,OAAOZ,EAAqBQ,EAAA,EAAW,MAAM,IAAMI,CAAY,CAAC,CAGpE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paprize/react",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "description": "React library for creating professional, print-ready reports",
5
5
  "type": "module",
6
6
  "files": [
@@ -41,32 +41,20 @@
41
41
  "prepack": "node ../../scripts/prepack.mjs"
42
42
  },
43
43
  "dependencies": {
44
- "@paprize/core": "*",
45
- "@paprize/puppeteer": "*",
46
- "jotai": "^2.13.1",
47
- "loglevel": "^1.9.2"
44
+ "@paprize/core": "*"
48
45
  },
49
46
  "peerDependencies": {
50
47
  "react": ">=17.0.0",
51
48
  "react-dom": ">=17.0.0"
52
49
  },
53
50
  "devDependencies": {
54
- "@eslint/js": "^9.30.1",
55
- "@types/react": "^19.1.8",
56
- "@types/react-dom": "^19.1.6",
57
- "@vitejs/plugin-react-swc": "^3.10.2",
58
- "eslint": "^9.30.1",
59
- "eslint-plugin-react-hooks": "^5.2.0",
60
- "eslint-plugin-react-refresh": "^0.4.20",
61
- "globals": "^16.3.0",
62
- "jotai-devtools": "^0.12.0",
63
- "react": "^19.1.1",
64
- "react-dom": "^19.1.1",
65
- "typescript": "~5.8.3",
66
- "typescript-eslint": "^8.35.1",
67
- "unplugin-dts": "^1.0.0-beta.6",
68
- "vite": "^7.0.4",
69
- "vite-plugin-checker": "^0.10.3",
70
- "vite-plugin-lib-inject-css": "^2.2.2"
51
+ "@paprize/config": "*",
52
+ "@types/react": "^19.2.0",
53
+ "@types/react-dom": "^19.2.0",
54
+ "@vitejs/plugin-react-swc": "^4.1.0",
55
+ "react": "^19.2.0",
56
+ "react-dom": "^19.2.0",
57
+ "typescript": "~5.9.3",
58
+ "vite": "^7.1.9"
71
59
  }
72
60
  }