@prose-reader/react-reader 1.202.0 → 1.203.0

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.
@@ -1,2 +1,2 @@
1
- (function(b,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("react/jsx-runtime"),require("react"),require("reactjrx"),require("rxjs"),require("@chakra-ui/react"),require("react-icons/lu"),require("react-dom"),require("react-icons/bs"),require("@prose-reader/core"),require("react-icons/ri"),require("react-icons/rx"),require("react-icons/hi"),require("rc-slider"),require("rc-slider/assets/index.css"),require("react-icons/io"),require("react-icons/md")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","reactjrx","rxjs","@chakra-ui/react","react-icons/lu","react-dom","react-icons/bs","@prose-reader/core","react-icons/ri","react-icons/rx","react-icons/hi","rc-slider","rc-slider/assets/index.css","react-icons/io","react-icons/md"],e):(b=typeof globalThis<"u"?globalThis:b||self,e(b["prose-react-reader"]={},b.jsxRuntime,b.React,b.reactjrx,b.rxjs,b.react,b.lu,b.reactDom,b.bs,b.core,b.ri,b.rx,b.hi,b.RcSlider,null,b.io,b.md))})(this,function(b,e,a,f,u,s,v,j,q,R,ee,$,oe,ne,Ye,Q,K){"use strict";function se(o){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const l in o)if(l!=="default"){const t=Object.getOwnPropertyDescriptor(o,l);Object.defineProperty(n,l,t.get?t:{enumerable:!0,get:()=>o[l]})}}return n.default=o,Object.freeze(n)}const w=se(a),F=a.createContext({reader:void 0,quickMenuSignal:f.signal({default:!1})}),le=a.memo(({children:o,reader:n,quickMenuOpen:l,onQuickMenuOpenChange:t})=>{const[,i]=f.useSignal({default:l}),r=f.useLiveRef(t),c=a.useMemo(()=>({quickMenuSignal:i,reader:n}),[i,n]);return a.useEffect(()=>{i.setValue(l)},[l,i]),f.useSubscribe(()=>i.subject.pipe(u.tap(r.current)),[i,r]),e.jsx(F.Provider,{value:c,children:o})}),te=w.forwardRef(function(n,l){return e.jsx(s.IconButton,{variant:"ghost","aria-label":"Close",ref:l,...n,children:n.children??e.jsx(v.LuX,{})})}),B=w.forwardRef(function(n,l){const{children:t,portalled:i=!0,portalRef:r,backdrop:c=!0,...h}=n;return e.jsxs(s.Portal,{disabled:!i,container:r,children:[c&&e.jsx(s.Dialog.Backdrop,{}),e.jsx(s.Dialog.Positioner,{children:e.jsx(s.Dialog.Content,{ref:l,...h,asChild:!1,children:t})})]})}),E=w.forwardRef(function(n,l){return e.jsx(s.Dialog.CloseTrigger,{position:"absolute",top:"2",insetEnd:"2",...n,asChild:!0,children:e.jsx(te,{size:"sm",ref:l,children:n.children})})}),z=s.Dialog.Root,A=s.Dialog.Footer,L=s.Dialog.Header,M=s.Dialog.Body;s.Dialog.Backdrop;const m=s.Dialog.Title;s.Dialog.Description,s.Dialog.Trigger;const _=s.Dialog.ActionTrigger,k=()=>{const{reader:o}=a.useContext(F);return o},W=o=>!!o&&"__PROSE_READER_ENHANCER_SEARCH"in o,V=o=>!!o&&"__PROSE_READER_ENHANCER_BOOKMARKS"in o,X=o=>!!o&&"__PROSE_READER_ENHANCER_ANNOTATIONS"in o,Z=o=>!!o&&"__PROSE_READER_ENHANCER_GALLERY"in o,re=a.memo(({onNavigate:o})=>{const n=k(),l=X(n)?n:void 0,t=f.useObserve(()=>l==null?void 0:l.annotations.highlights$.pipe(u.switchMap(r=>l.pagination.locate(r))),[l]),i=(r,c)=>{var h;return e.jsx(s.List.Item,{children:e.jsxs(s.Link,{href:"#",onClick:()=>{o(),n==null||n.navigation.goToCfi(r.cfi??"")},children:[(r.contents??[])[0]?e.jsx(s.List.Indicator,{asChild:!0,children:e.jsx(v.LuNotebookPen,{})}):e.jsx(s.List.Indicator,{asChild:!0,visibility:"hidden",children:e.jsx(v.LuNotebookPen,{})}),e.jsxs(s.Stack,{gap:0,children:[e.jsx(s.Text,{lineClamp:2,fontSize:"md",children:r.selectionAsText?r.selectionAsText??"":e.jsx("i",{children:e.jsx("b",{children:"unknown (not loaded)"})})}),e.jsx(s.Text,{fontStyle:"italic",fontWeight:"bold",fontSize:"sm",children:`Book page: ${((h=r.meta)==null?void 0:h.absolutePageIndex)!==void 0?r.meta.absolutePageIndex+1:"unknown (not loaded)"}`})]})]})},c)};return e.jsx(s.List.Root,{overflowY:"auto",gap:3,pt:4,variant:"plain",children:t==null?void 0:t.map((r,c)=>i(r,c))})}),ie=a.memo(({open:o,setOpen:n,onNavigate:l})=>e.jsx(z,{lazyMount:!0,placement:"center",open:o,onOpenChange:t=>n(t.open),size:{mdDown:"full",md:"lg"},scrollBehavior:"inside",children:e.jsxs(B,{height:"100%",children:[e.jsx(L,{children:e.jsx(m,{children:"Annotations"})}),e.jsx(M,{flex:1,children:e.jsx(re,{onNavigate:l})}),e.jsx(A,{children:e.jsx(_,{asChild:!0,children:e.jsx(s.Button,{variant:"outline",children:"Cancel"})})}),e.jsx(E,{})]})})),ae=a.memo(()=>{const o=k(),n=V(o)?o:void 0,l=f.useObserve(()=>o==null?void 0:o.spine.element$,[o]),t=f.useObserve(()=>n==null?void 0:n.bookmarks.pages$,[n]),i=f.useObserve(()=>n==null?void 0:n.bookmarks.bookmarks$,[n]),r=f.useObserve(()=>o==null?void 0:o.pagination.locate(i??[]),[o,i]);return l?e.jsx(e.Fragment,{children:j.createPortal(t==null?void 0:t.map(({isBookmarkable:c,absolutePosition:{left:h,top:p,width:d}},C)=>{const g=r==null?void 0:r.find(S=>{var x;return((x=S.meta)==null?void 0:x.absolutePageIndex)===C});return c?e.jsx(s.Presence,{present:!0,lazyMount:!0,animationName:{_open:"fade-in",_closed:"fade-out"},animationDuration:"moderate",children:e.jsx(s.Box,{"data-bookmark-area":!0,position:"absolute",left:h+d,transform:"translateX(-100%)",top:p,p:2,children:g?e.jsx(s.IconButton,{"aria-label":"bookmark",opacity:.5,_hover:{opacity:1},onClick:()=>{g&&(n==null||n.bookmarks.delete(g==null?void 0:g.id))},size:"lg",variant:"ghost",_icon:{boxSize:"36px"},children:e.jsx(q.BsBookmarkXFill,{})}):e.jsx(s.IconButton,{"aria-label":"bookmark",onClick:()=>{n==null||n.bookmarks.bookmark(C)},size:"lg",bgColor:"white",opacity:.5,_hover:{opacity:1},variant:"ghost",_icon:{boxSize:"36px"},children:e.jsx(q.BsBookmarkPlus,{})})})},C):null}),l)}):null}),ce=a.memo(({onNavigate:o})=>{const n=k(),l=V(n)?n:void 0,t=f.useObserve(()=>l==null?void 0:l.bookmarks.bookmarks$.pipe(u.switchMap(r=>l.pagination.locate(r))),[l]),i=(r,c)=>{var h,p,d,C,g;return e.jsxs(s.List.Item,{justifyContent:"space-between",alignItems:"center",children:[e.jsx(s.Link,{href:"#",onClick:()=>{o(),n==null||n.navigation.goToCfi(r.cfi??"")},children:e.jsxs(s.Stack,{gap:0,children:[e.jsx(s.Text,{fontSize:"md",children:`Book page: ${((h=r.meta)==null?void 0:h.absolutePageIndex)!==void 0?r.meta.absolutePageIndex+1:"unknown"}`}),e.jsx(s.Text,{fontStyle:"italic",fontWeight:"bold",fontSize:"sm",truncate:!0,lineClamp:2,children:(d=(p=r.meta)==null?void 0:p.startNode)!=null&&d.textContent?(g=(C=r.meta)==null?void 0:C.startNode)==null?void 0:g.textContent:"..."})]})}),e.jsx(s.Button,{colorPalette:"red",variant:"solid",size:"xs",onClick:()=>{l==null||l.bookmarks.delete(r.id)},children:"Delete"})]},c)};return e.jsx(s.List.Root,{overflowY:"auto",gap:3,variant:"plain",overflow:"auto",children:t==null?void 0:t.map((r,c)=>i(r,c))})}),de=a.memo(({open:o,setOpen:n,onNavigate:l})=>e.jsx(z,{lazyMount:!0,placement:"center",open:o,onOpenChange:t=>n(t.open),size:{mdDown:"full",md:"lg"},scrollBehavior:"inside",children:e.jsxs(B,{height:"100%",children:[e.jsx(L,{children:e.jsx(m,{children:"Bookmarks"})}),e.jsx(M,{children:e.jsx(ce,{onNavigate:l})}),e.jsx(A,{children:e.jsx(_,{asChild:!0,children:e.jsx(s.Button,{variant:"outline",children:"Cancel"})})}),e.jsx(E,{})]})})),G=s.createToaster({placement:"bottom-end",pauseOnPageIdle:!0}),he=()=>e.jsx(s.Portal,{children:e.jsx(s.Toaster,{toaster:G,insetInline:{mdDown:"4"},children:o=>{var n;return e.jsxs(s.Toast.Root,{width:{md:"sm"},children:[o.type==="loading"?e.jsx(s.Spinner,{size:"sm",color:"blue.solid"}):e.jsx(s.Toast.Indicator,{}),e.jsxs(s.Stack,{gap:"1",flex:"1",maxWidth:"100%",children:[o.title&&e.jsx(s.Toast.Title,{children:o.title}),o.description&&e.jsx(s.Toast.Description,{children:o.description})]}),o.action&&e.jsx(s.Toast.ActionTrigger,{children:o.action.label}),((n=o.meta)==null?void 0:n.closable)&&e.jsx(s.Toast.CloseTrigger,{})]})}})}),ge=a.memo(({open:o,setOpen:n})=>{const l=k(),[t,i]=a.useState(null),r=Z(l)?l:void 0,c="prose-gallery-grid-item",h=f.useObserve(()=>r==null?void 0:r.gallery.create({gridItemClassName:c}),[r]);return a.useEffect(()=>{t&&h&&(t.innerHTML="",t.appendChild(h))},[h,t]),e.jsx(z,{lazyMount:!0,placement:"center",open:o,onOpenChange:p=>n(p.open),size:{mdDown:"full",md:"lg"},scrollBehavior:"inside",children:e.jsxs(B,{height:"100%",children:[e.jsx(L,{children:e.jsx(m,{children:"Gallery"})}),e.jsx(M,{ref:i,css:{"--prose-gallery-columns":["2","3"],[`& .${c}`]:{border:"1px solid red",borderColor:"border",borderRadius:"md"}}}),e.jsx(A,{children:e.jsx(_,{asChild:!0,children:e.jsx(s.Button,{variant:"outline",children:"Cancel"})})}),e.jsx(E,{})]})})}),pe="@prose-reader/react-reader",fe="1.201.0",ue=a.memo(({open:o,setOpen:n})=>e.jsx(z,{lazyMount:!0,placement:"center",open:o,onOpenChange:l=>n(l.open),size:{mdDown:"full",md:"lg"},scrollBehavior:"inside",children:e.jsxs(B,{children:[e.jsx(L,{children:e.jsx(m,{children:"Help"})}),e.jsxs(M,{overflowY:"auto",flex:1,children:[e.jsx(s.Heading,{mb:2,as:"h3",size:"lg",children:"Shortcuts"}),e.jsxs(s.HStack,{mb:1,children:[e.jsx(s.Kbd,{children:e.jsx(v.LuArrowBigRight,{})})," ",e.jsx(s.Text,{children:"Navigate to right page"})]}),e.jsxs(s.HStack,{mb:1,children:[e.jsx(s.Kbd,{children:e.jsx(v.LuArrowBigLeft,{})})," ",e.jsx(s.Text,{children:"Navigate to left page"})]}),e.jsx(s.Heading,{mb:2,mt:4,as:"h3",size:"lg",children:"About"}),e.jsxs(s.Text,{children:[pe," version: ",fe]})]}),e.jsx(A,{children:e.jsx(_,{asChild:!0,children:e.jsx(s.Button,{variant:"outline",children:"Cancel"})})}),e.jsx(E,{})]})})),N=()=>{const o=k();return f.useObserve(()=>o?u.combineLatest([o.pagination.state$,o.context.state$]).pipe(u.map(([n,l])=>{var i;const t=(i=l.manifest)==null?void 0:i.spineItems.every(r=>{var c;return(c=r.mediaType)==null?void 0:c.startsWith("image/")});return{...n,hasChapters:!l.isFullyPrePaginated&&!t}})):u.NEVER,[o])},be=()=>{const o=N(),n=Math.floor(((o==null?void 0:o.percentageEstimateOfBook)??0)*100),l=n>0?n:1;return(o==null?void 0:o.percentageEstimateOfBook)===void 0?null:e.jsx(s.Box,{position:"absolute",right:0,bottom:0,p:2,color:"black",children:e.jsxs(s.Text,{fontSize:"sm",children:[l," %"]})})},Ce=()=>{const[o,n]=a.useState(new Date);return a.useEffect(()=>{const l=setInterval(()=>{n(new Date)},6e4);return()=>clearInterval(l)},[]),o},ve=o=>{const n=Ce();return e.jsx(s.Text,{fontSize:"xs",...o,children:n.toLocaleTimeString(navigator.language,{hour:"2-digit",minute:"2-digit"})})},Y=()=>{const{quickMenuSignal:o}=a.useContext(F);return[f.useSignalValue(o),o.setValue,o]},ke=()=>{const[o]=Y();return e.jsx(s.Box,{position:"absolute",left:0,bottom:0,p:2,color:o?void 0:"colorPalette.contrast",children:e.jsx(ve,{})})},Se=()=>{const o=k();f.useSubscribe(()=>o==null?void 0:o.links$.subscribe(n=>{if(n.type==="click"&&R.isHtmlTagElement(n.target,"a")){if(!n.target.href)return;const l=new URL(n.target.href);window.location.host!==l.host&&confirm("You are going to be redirected to external link")&&window.open(n.target.href,"__blank")}}),[o])},H=f.signal({default:void 0}),xe=()=>{const o=k();f.useSubscribe(()=>o==null?void 0:o.zoom.isZooming$.pipe(u.switchMap(n=>{if(!n)return u.EMPTY;const l=new u.Subject;return H.setValue({key:"zoom",title:"Zooming",duration:999999,abort:l}),u.NEVER.pipe(u.finalize(()=>{l.next(),l.complete()}))})),[o])},Te=()=>{const o=k();f.useSubscribe(()=>o==null?void 0:o.settings.values$.pipe(u.map(({fontScale:n})=>n),u.distinctUntilChanged(),u.skip(1),u.tap(n=>{H.setValue({key:"fontScaleChange",title:"Font size changed",description:`${n*100} %`})})),[o])},Ie=()=>{Te(),xe(),f.useSubscribe(()=>H.subject.pipe(u.skip(1),u.filter(f.isDefined),u.mergeMap(o=>{const n=o.duration??3e3,l=G.create({title:o.title,description:o.description,duration:n}),t=H.subject.pipe(u.skip(1),u.filter(i=>!!o.key&&(i==null?void 0:i.key)===o.key));return u.merge(u.timer(n),o.abort??u.NEVER,t).pipe(u.first(),u.finalize(()=>{G.dismiss(l)}))})))},ye=w.forwardRef(function(n,l){const{showArrow:t,children:i,portalled:r=!0,content:c,portalRef:h,...p}=n;return e.jsxs(s.Popover.Root,{...p,positioning:{...p.positioning,gutter:4},children:[e.jsx(s.Popover.Trigger,{asChild:!0,children:i}),e.jsx(s.Portal,{disabled:!r,container:h,children:e.jsx(s.Popover.Positioner,{children:e.jsxs(s.Popover.Content,{width:"auto",px:"2",py:"1",textStyle:"xs",rounded:"sm",ref:l,children:[t&&e.jsx(s.Popover.Arrow,{children:e.jsx(s.Popover.ArrowTip,{})}),c]})})})]})}),Pe=w.forwardRef(function(n,l){const{children:t,...i}=n;return e.jsx(ye,{content:t,...i,ref:l,children:e.jsx(s.IconButton,{variant:"ghost","aria-label":"info",size:"2xs",colorPalette:"gray",children:e.jsx(oe.HiOutlineInformationCircle,{})})})}),Oe=w.forwardRef(function(n,l){return e.jsx(s.Progress.Track,{...n,ref:l,children:e.jsx(s.Progress.Range,{})})});w.forwardRef(function(n,l){const{children:t,info:i,...r}=n;return e.jsxs(s.Progress.Label,{...r,ref:l,children:[t,i&&e.jsx(Pe,{children:i})]})});const we=s.Progress.Root,De=s.Progress.ValueText,U=()=>{const o=N(),n=(o==null?void 0:o.numberOfTotalPages)===1,l=((o==null?void 0:o.beginNumberOfPagesInSpineItem)??0)>1,t=((o==null?void 0:o.endNumberOfPagesInSpineItem)??0)>1,i=(o!=null&&o.hasChapters?o==null?void 0:o.beginPageIndexInSpineItem:o==null?void 0:o.beginAbsolutePageIndex)??0,r=(o!=null&&o.hasChapters?o==null?void 0:o.endPageIndexInSpineItem:o==null?void 0:o.endAbsolutePageIndex)??0,[c=0,h=0]=[i,r].sort((C,g)=>C-g),p=(o==null?void 0:o.beginPageIndexInSpineItem)!==(o==null?void 0:o.endPageIndexInSpineItem)||(o==null?void 0:o.beginSpineItemIndex)!==(o==null?void 0:o.endSpineItemIndex),d=o!=null&&o.hasChapters?o==null?void 0:o.beginNumberOfPagesInSpineItem:o==null?void 0:o.numberOfTotalPages;return{hasOnlyOnePage:n,beginPageIndex:i,endPageIndex:r,isBeginWithinChapter:l,isEndWithinChapter:t,beginAndEndAreDifferent:p,totalApproximatePages:d,leftPageIndex:c,rightPageIndex:h}},Be=()=>{const o=N(),{hasOnlyOnePage:n,leftPageIndex:l,rightPageIndex:t,totalApproximatePages:i,beginAndEndAreDifferent:r}=U(),c=Math.round(((o==null?void 0:o.percentageEstimateOfBook)??0)*100),h=d=>d!=null&&d.subChapter?`${d.title} / ${h(d.subChapter)}`:(d==null?void 0:d.title)||"",p=h(o==null?void 0:o.beginChapterInfo);return e.jsxs(s.Stack,{alignItems:"center",gap:1,maxW:"100%",overflow:"auto",children:[e.jsx(we,{value:c,size:"xs",width:150,children:e.jsxs(s.HStack,{justifyContent:"space-between",children:[e.jsx(Oe,{width:110}),e.jsx(De,{children:`${c}%`})]})}),e.jsx(s.Text,{truncate:!0,maxWidth:"100%",fontSize:"sm",mt:1,children:p?`Chapter: ${p}`:" "}),!n&&e.jsxs(s.HStack,{children:[e.jsx(s.Text,{fontSize:"xs",children:r?`${l+1} - ${t+1} of ${i}`:`${l+1} of ${i}`}),!!(o!=null&&o.hasChapters)&&e.jsxs(e.Fragment,{children:[e.jsx(s.Text,{children:"-"}),e.jsxs(s.Text,{fontSize:"xs",children:["(",((o==null?void 0:o.beginAbsolutePageIndex)??0)+1,")"]})]})]})]})},J=a.memo(({children:o,position:n,...l})=>e.jsx(s.Presence,{display:"flex",flexDirection:"row",width:"100%",position:"absolute",...n==="bottom"?{bottom:0}:{top:0},animationName:n==="bottom"?{_open:"slide-from-bottom, fade-in",_closed:"slide-to-bottom, fade-out"}:{_open:"slide-from-top, fade-in",_closed:"slide-to-top, fade-out"},animationDuration:"moderate",bgColor:"bg.panel",alignItems:"center",justifyContent:"center",shadow:"md",p:4,...l,children:o})),Ee=s.chakra(ne),ze=a.memo(o=>e.jsx(s.Box,{display:"contents",css:{"--bg":"colors.bg","--bg-emphasized":"colors.bg.emphasized","--color-solid":"colors.colorPalette.solid"},children:e.jsx(Ee,{keyboard:!1,style:{padding:0},css:{"& > .rc-slider-handle:focus-visible":{boxShadow:"0 0 0 2px var(--color-solid) !important"},"& > .rc-slider-handle:active":{boxShadow:"0 0 5px var(--color-solid) !important"},"& > .rc-slider-handle.rc-slider-handle-dragging":{boxShadow:"0 0 0 3px var(--color-solid) !important"}},styles:{rail:{height:"8px",top:"50%",transform:"translateY(-50%)",backgroundColor:"var(--bg-emphasized)"},track:{height:"8px",top:"50%",transform:"translateY(-50%)",backgroundColor:"var(--color-solid)"},handle:{width:"24px",height:"24px",top:"50%",borderColor:"var(--color-solid)",transform:`translate(${o.reverse?"50%":"-50%"}, -50%)`,backgroundColor:"var(--bg)",marginTop:"0px"}},...o})})),Ae=()=>{const o=N(),n=o==null?void 0:o.isUsingSpread,{beginPageIndex:l,totalApproximatePages:t=0}=U(),i=n?Math.floor((l||0)/2):l,[r,c]=f.useSignal({default:i||0}),h=0,p=Math.max(0,n?Math.floor((t-1)/2):t-1);return a.useEffect(()=>{c.setValue(i||0)},[i,c]),{value:r,valueSignal:c,min:h,max:p}},Le=o=>{const n=k(),l=N(),{manifest:t}=f.useObserve(()=>n==null?void 0:n.context.state$,[n])??{},i=(t==null?void 0:t.readingDirection)==="rtl",r=l==null?void 0:l.isUsingSpread,{totalApproximatePages:c=0,isBeginWithinChapter:h}=U(),p=1,d=h,{value:C,valueSignal:g,min:S,max:x}=Ae(),I=a.useCallback(P=>{const[T=0]=Array.isArray(P)?P:[P];g.setValue(T);const D=r?Math.floor(T)*2:Math.floor(T);d?n==null||n.navigation.goToPageOfSpineItem({pageIndex:D,spineItemId:n.pagination.getState().beginSpineItemIndex??0,animation:!1}):n==null||n.navigation.goToAbsolutePageIndex({absolutePageIndex:D,animation:!1})},[n,r,g,d]);return f.useSubscribe(()=>n==null?void 0:n.navigation.throttleLock({duration:100,trigger:g.subject}),[n,g]),c===1||r&&c===2?e.jsx(s.Box,{style:o.style}):e.jsx(ze,{value:[C],max:x,min:S,reverse:i,step:p,onChange:I,...o})},Me=a.memo(({open:o,onItemClick:n})=>{const l=k(),t=f.useObserve(()=>l==null?void 0:l.navigation.state$,[l]),i=f.useObserve(()=>l==null?void 0:l.settings.values$,[l]),r=(i==null?void 0:i.computedPageTurnDirection)==="vertical",[c,h]=a.useState(!0);return e.jsxs(J,{present:o,position:"bottom",display:"flex",flexDirection:"column",overflow:"auto",pb:8,children:[e.jsxs(s.HStack,{flex:1,alignItems:"center",justifyContent:"center",children:[e.jsx(s.IconButton,{"aria-label":"left",size:"lg",variant:"ghost",flexShrink:0,onClick:()=>l==null?void 0:l.navigation.goToLeftOrTopSpineItem(),disabled:!(t!=null&&t.canGoLeftSpineItem)&&!(t!=null&&t.canGoTopSpineItem),children:r?e.jsx($.RxDoubleArrowUp,{}):e.jsx($.RxDoubleArrowLeft,{})}),e.jsxs(s.Stack,{flex:1,maxW:400,gap:2,alignItems:"center",overflow:"auto",px:4,children:[e.jsx(Be,{}),e.jsx(Le,{style:{width:"100%",maxWidth:"300px",height:"35px"}})]}),e.jsx(s.IconButton,{"aria-label":"right",size:"lg",flexShrink:0,variant:"ghost",disabled:!(t!=null&&t.canGoRightSpineItem)&&!(t!=null&&t.canGoBottomSpineItem),onClick:()=>{l==null||l.navigation.goToRightOrBottomSpineItem()},children:r?e.jsx($.RxDoubleArrowDown,{}):e.jsx($.RxDoubleArrowRight,{})})]}),e.jsx(s.HStack,{alignItems:"center",justifyContent:"center",children:e.jsxs(s.Collapsible.Root,{open:c,flex:1,onOpenChange:({open:p})=>{h(p)},children:[e.jsx(s.Collapsible.Trigger,{paddingY:"3",width:"100%",display:"flex",justifyContent:"center",children:e.jsx(v.LuChevronDown,{style:{transform:c?"rotate(0deg)":"rotate(180deg)"}})}),e.jsxs(s.Collapsible.Content,{display:"flex",justifyContent:"center",children:[e.jsx(s.IconButton,{"aria-label":"Help",size:"lg",variant:"ghost",onClick:()=>n("help"),children:e.jsx(v.LuCircleHelp,{})}),e.jsx(s.IconButton,{"aria-label":"Table of contents",size:"lg",variant:"ghost",onClick:()=>n("toc"),children:e.jsx(v.LuTableOfContents,{})}),W(l)&&e.jsx(s.IconButton,{"aria-label":"Search",size:"lg",variant:"ghost",onClick:()=>n("search"),children:e.jsx(v.LuSearch,{})}),V(l)&&e.jsx(s.IconButton,{"aria-label":"Search",size:"lg",variant:"ghost",onClick:()=>n("bookmarks"),children:e.jsx(q.BsBookmarks,{})}),X(l)&&e.jsx(s.IconButton,{"aria-label":"Search",size:"lg",variant:"ghost",onClick:()=>n("annotations"),children:e.jsx(v.LuNotebookPen,{})}),e.jsx(s.IconButton,{"aria-label":"Thumbnails",size:"lg",variant:(l==null?void 0:l.settings.values.viewportMode)==="thumbnails"?"solid":"ghost",onClick:()=>{l==null||l.settings.update({viewportMode:(l==null?void 0:l.settings.values.viewportMode)==="normal"?"thumbnails":"normal"})},children:e.jsx(v.LuGalleryHorizontal,{})}),Z(l)&&e.jsx(s.IconButton,{"aria-label":"Gallery",size:"lg",variant:"ghost",onClick:()=>n("gallery"),children:e.jsx(ee.RiGalleryView2,{})})]})]})})]})}),me=()=>{const[o,n]=a.useState(!1),l=a.useCallback(()=>document.fullscreenElement?document.exitFullscreen().catch(console.error).then(()=>{n(!1)}):document.documentElement.requestFullscreen({navigationUI:"hide"}).catch(console.error).then(()=>{n(!0)}),[]);return a.useEffect(()=>{function t(){n(!!document.fullscreenElement)}return document.addEventListener("fullscreenchange",t),()=>{document.removeEventListener("fullscreenchange",t)}},[]),{isFullscreen:o,onToggleFullscreenClick:l}},_e=a.memo(({open:o,onItemClick:n})=>{const l=k(),t=f.useObserve(()=>l==null?void 0:l.context.manifest$,[l]),{isFullscreen:i,onToggleFullscreenClick:r}=me();return e.jsxs(J,{present:o,position:"top",height:"80px",justifyContent:"space-between",children:[e.jsx(s.IconButton,{"aria-label":"left",size:"lg",variant:"ghost",flexShrink:0,onClick:()=>n("back"),children:e.jsx(Q.IoIosArrowBack,{})}),e.jsx(s.Stack,{flex:1,maxW:600,gap:1,alignItems:"center",overflow:"auto",px:4,children:e.jsx(s.Text,{truncate:!0,maxWidth:"100%",children:t==null?void 0:t.title})}),e.jsxs(s.HStack,{children:[e.jsx(s.IconButton,{"aria-label":"right",size:"lg",flexShrink:0,variant:"ghost",onClick:()=>n("more"),children:e.jsx(Q.IoMdMore,{})}),e.jsx(s.IconButton,{"aria-label":"right",size:"lg",flexShrink:0,variant:"ghost",onClick:r,children:i?e.jsx(K.MdFullscreenExit,{}):e.jsx(K.MdFullscreen,{})})]})]})}),Ne=a.memo(({onItemClick:o})=>{const[n]=Y();return e.jsxs(e.Fragment,{children:[e.jsx(_e,{open:n,onItemClick:o}),e.jsx(Me,{open:n,onItemClick:o})]})}),$e=a.memo(({contextText:o="",startOffset:n=0,text:l,cfi:t="#",onClick:i,absolutePageIndex:r})=>{const h=o.substring(Math.max(n-15,0),Math.max(n,0)),p=o.substring(Math.min(n+l.length,o.length-1),Math.min(n+l.length+15,o.length-1));return e.jsxs(s.Link,{href:t,style:{margin:5,overflow:"hidden"},onClick:d=>{d.preventDefault(),i(t)},display:"flex",flexDirection:"column",alignItems:"flex-start",gap:0,children:[e.jsxs(s.Text,{lineClamp:1,as:"cite",style:{display:"block"},children:['"',h,e.jsx("b",{children:l}),p,'"']}),e.jsx(s.Text,{fontSize:"sm",color:"gray.500",style:{textDecoration:"none"},children:`Book page: ${r!==void 0?r+1:"unknown (not loaded)"}`})]})}),He=a.memo(({onNavigate:o})=>{const[n,l]=a.useState(""),t=k(),i=W(t)?t:void 0,r=g=>{l(g.target.value)},c=a.useCallback(g=>{o(),t==null||t.navigation.goToCfi(g)},[t,o]),h=f.useObserve(()=>i==null?void 0:i.search.search(n).pipe(u.map(g=>({type:"end",data:g})),u.startWith({type:"start"})),[t,n]),p=(h==null?void 0:h.type)==="start",d=(h==null?void 0:h.type)==="end"?h.data:[],C=f.useObserve(()=>t==null?void 0:t.pagination.locate(d.slice(0,100)),[d]);return e.jsxs(s.Stack,{flex:1,height:"100%",children:[e.jsx(s.Box,{px:4,children:e.jsx(s.Input,{placeholder:"Type something...",value:n,onChange:r,borderRadius:0})}),e.jsxs(s.Box,{px:4,pb:4,mt:2,flex:1,style:{overflow:"hidden",overflowY:"auto"},children:[p&&e.jsx(s.Text,{children:"Searching ..."}),!p&&d.length===0&&e.jsx("p",{children:"There are no results"}),!p&&d.length>=0&&e.jsxs(s.Stack,{children:[e.jsxs(s.Heading,{as:"h2",size:"md",children:[d.length," result(s)"]}),e.jsx(s.Stack,{gap:0,children:C==null?void 0:C.map((g,S)=>{var x,I,O,P,T,D,y;return e.jsx($e,{contextText:((O=(I=(x=g.meta)==null?void 0:x.range)==null?void 0:I.startContainer.parentElement)==null?void 0:O.textContent)??"",pageIndex:(P=g.meta)==null?void 0:P.itemPageIndex,startOffset:((D=(T=g.meta)==null?void 0:T.range)==null?void 0:D.startOffset)??0,text:n,cfi:g.cfi,onClick:c,absolutePageIndex:(y=g.meta)==null?void 0:y.absolutePageIndex},S)})})]})]})]})}),qe=a.memo(({open:o,setOpen:n,onNavigate:l})=>e.jsx(z,{lazyMount:!0,placement:"center",open:o,onOpenChange:t=>n(t.open),size:{mdDown:"full",md:"lg"},scrollBehavior:"inside",children:e.jsxs(B,{height:"100%",children:[e.jsx(L,{children:e.jsx(m,{children:"Search"})}),e.jsx(M,{flex:1,children:e.jsx(He,{onNavigate:l})}),e.jsx(A,{children:e.jsx(_,{asChild:!0,children:e.jsx(s.Button,{variant:"outline",children:"Cancel"})})}),e.jsx(E,{})]})})),Fe=a.memo(({onNavigate:o})=>{const n=k(),{manifest:l,assumedRenditionLayout:t}=f.useObserve(()=>n==null?void 0:n.context.state$,[n])??{},{nav:i}=l??{},r=N();i!=null&&i.toc;const{beginSpineItemIndex:c,beginPageIndexInSpineItem:h}=r??{},p=(t==="reflowable"?h:c)||0;console.log({assumedRenditionLayout:t,currentSpineItemOrChapterPageIndex:p});let d=r==null?void 0:r.beginChapterInfo;for(;d!=null&&d.subChapter;)d=d==null?void 0:d.subChapter;const C=(g,S,x)=>e.jsxs(a.Fragment,{children:[e.jsx(s.List.Item,{pl:4*(x+1),style:{display:"flex",alignItems:"center"},children:e.jsxs(s.Link,{onClick:()=>{o(),n==null||n.navigation.goToUrl(g.href)},href:"#",children:[(d==null?void 0:d.path)===g.path&&e.jsx(s.List.Indicator,{asChild:!0,children:e.jsx(v.LuCircleCheck,{})}),(d==null?void 0:d.path)!==g.path&&e.jsx(s.List.Indicator,{asChild:!0,visibility:"hidden",children:e.jsx(v.LuCircleCheck,{})}),e.jsxs(s.Stack,{gap:0,children:[e.jsx(s.Text,{fontSize:"md",children:g.title||g.path}),(d==null?void 0:d.path)===g.path&&e.jsx(s.Text,{fontStyle:"italic",fontWeight:"bold",fontSize:"sm",children:`Currently on page ${p+1}`})]})]})}),g.contents.length>0&&e.jsx(s.List.Root,{as:"div",gap:2,children:g.contents.map((I,O)=>C(I,O,x+1))})]},S);return e.jsx(s.List.Root,{gap:3,overflowY:"auto",py:4,flex:1,children:i==null?void 0:i.toc.map((g,S)=>C(g,S,0))})}),Ve=a.memo(({open:o,setOpen:n,onNavigate:l})=>e.jsx(z,{lazyMount:!0,placement:"center",open:o,onOpenChange:t=>n(t.open),size:{mdDown:"full",md:"lg"},scrollBehavior:"inside",children:e.jsxs(B,{children:[e.jsx(L,{children:e.jsx(m,{children:"Table of Contents"})}),e.jsx(M,{overflowY:"auto",flex:1,children:e.jsx(Fe,{onNavigate:l})}),e.jsx(A,{children:e.jsx(_,{asChild:!0,children:e.jsx(s.Button,{variant:"outline",children:"Cancel"})})}),e.jsx(E,{})]})})),Ge=({enableFloatingTime:o=!0,enableFloatingProgress:n=!0,onItemClick:l})=>{const[t,i]=a.useState(!1),[r,c]=a.useState(!1),[h,p]=a.useState(!1),[d,C]=a.useState(!1),[g,S]=a.useState(!1),[x,I]=a.useState(!1),[O,P]=Y(),T=a.useCallback(()=>{i(!1),c(!1),p(!1),C(!1),S(!1),P(!1),I(!1)},[P]),D=a.useCallback(y=>{y==="annotations"?C(!0):y==="search"?p(!0):y==="help"?c(!0):y==="toc"?i(!0):y==="bookmarks"?S(!0):y==="gallery"&&I(!0),l==null||l(y)},[l]);return Se(),Ie(),e.jsxs(e.Fragment,{children:[n&&e.jsx(s.Presence,{present:!O,animationName:{_open:"fade-in",_closed:"fade-out"},animationDuration:"moderate",children:e.jsx(be,{})}),e.jsx(ge,{open:x,setOpen:I}),e.jsx(Ne,{onItemClick:D}),e.jsx(ae,{}),e.jsx(ue,{open:r,setOpen:c}),e.jsx(Ve,{open:t,setOpen:i,onNavigate:T}),e.jsx(qe,{open:h,setOpen:p,onNavigate:T}),e.jsx(ie,{open:d,setOpen:C,onNavigate:T}),e.jsx(de,{open:g,setOpen:S,onNavigate:T}),e.jsx(s.Presence,{present:o||O,animationName:{_open:"fade-in",_closed:"fade-out"},animationDuration:"slow",overflow:"hidden",children:e.jsx(ke,{})}),e.jsx(he,{})]})};b.ReactReader=Ge,b.ReactReaderProvider=le,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})});
1
+ (function(C,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("react/jsx-runtime"),require("react"),require("reactjrx"),require("rxjs"),require("@chakra-ui/react"),require("react-icons/lu"),require("react-dom"),require("react-icons/bs"),require("@prose-reader/core"),require("react-icons/ri"),require("react-icons/rx"),require("react-icons/hi"),require("rc-slider"),require("rc-slider/assets/index.css"),require("react-icons/io"),require("react-icons/md")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","reactjrx","rxjs","@chakra-ui/react","react-icons/lu","react-dom","react-icons/bs","@prose-reader/core","react-icons/ri","react-icons/rx","react-icons/hi","rc-slider","rc-slider/assets/index.css","react-icons/io","react-icons/md"],e):(C=typeof globalThis<"u"?globalThis:C||self,e(C["prose-react-reader"]={},C.jsxRuntime,C.React,C.reactjrx,C.rxjs,C.react,C.lu,C.reactDom,C.bs,C.core,C.ri,C.rx,C.hi,C.RcSlider,null,C.io,C.md))})(this,function(C,e,c,u,g,t,x,R,q,F,ee,$,oe,ne,We,K,W){"use strict";function se(o){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const s in o)if(s!=="default"){const l=Object.getOwnPropertyDescriptor(o,s);Object.defineProperty(n,s,l.get?l:{enumerable:!0,get:()=>o[s]})}}return n.default=o,Object.freeze(n)}const O=se(c),V=c.createContext({reader:void 0,quickMenuSignal:u.signal({default:!1})}),te=c.memo(({children:o,reader:n,quickMenuOpen:s,onQuickMenuOpenChange:l})=>{const[,r]=u.useSignal({default:s}),i=u.useLiveRef(l),a=c.useMemo(()=>({quickMenuSignal:r,reader:n}),[r,n]);return c.useEffect(()=>{r.setValue(s)},[s,r]),u.useSubscribe(()=>r.subject.pipe(g.tap(i.current)),[r,i]),e.jsx(V.Provider,{value:a,children:o})}),le=O.forwardRef(function(n,s){return e.jsx(t.IconButton,{variant:"ghost","aria-label":"Close",ref:s,...n,children:n.children??e.jsx(x.LuX,{})})}),E=O.forwardRef(function(n,s){const{children:l,portalled:r=!0,portalRef:i,backdrop:a=!0,...p}=n;return e.jsxs(t.Portal,{disabled:!r,container:i,children:[a&&e.jsx(t.Dialog.Backdrop,{}),e.jsx(t.Dialog.Positioner,{children:e.jsx(t.Dialog.Content,{ref:s,...p,asChild:!1,children:l})})]})}),B=O.forwardRef(function(n,s){return e.jsx(t.Dialog.CloseTrigger,{position:"absolute",top:"2",insetEnd:"2",...n,asChild:!0,children:e.jsx(le,{size:"sm",ref:s,children:n.children})})}),z=t.Dialog.Root,A=t.Dialog.Footer,L=t.Dialog.Header,M=t.Dialog.Body;t.Dialog.Backdrop;const m=t.Dialog.Title;t.Dialog.Description,t.Dialog.Trigger;const _=t.Dialog.ActionTrigger,v=()=>{const{reader:o}=c.useContext(V);return o},X=o=>!!o&&"__PROSE_READER_ENHANCER_SEARCH"in o,G=o=>!!o&&"__PROSE_READER_ENHANCER_BOOKMARKS"in o,Z=o=>!!o&&"__PROSE_READER_ENHANCER_ANNOTATIONS"in o,J=o=>!!o&&"__PROSE_READER_ENHANCER_GALLERY"in o,re=c.memo(({onNavigate:o})=>{const n=v(),s=Z(n)?n:void 0,l=u.useObserve(()=>s==null?void 0:s.annotations.highlights$.pipe(g.switchMap(i=>s.pagination.locate(i))),[s]),r=(i,a)=>{var p;return e.jsx(t.List.Item,{children:e.jsxs(t.Link,{href:"#",onClick:()=>{o(),n==null||n.navigation.goToCfi(i.cfi??"")},children:[(i.contents??[])[0]?e.jsx(t.List.Indicator,{asChild:!0,children:e.jsx(x.LuNotebookPen,{})}):e.jsx(t.List.Indicator,{asChild:!0,visibility:"hidden",children:e.jsx(x.LuNotebookPen,{})}),e.jsxs(t.Stack,{gap:0,children:[e.jsx(t.Text,{lineClamp:2,fontSize:"md",children:i.selectionAsText?i.selectionAsText??"":e.jsx("i",{children:e.jsx("b",{children:"unknown (not loaded)"})})}),e.jsx(t.Text,{fontStyle:"italic",fontWeight:"bold",fontSize:"sm",children:`Book page: ${((p=i.meta)==null?void 0:p.absolutePageIndex)!==void 0?i.meta.absolutePageIndex+1:"unknown (not loaded)"}`})]})]})},a)};return e.jsx(t.List.Root,{overflowY:"auto",gap:3,pt:4,variant:"plain",children:l==null?void 0:l.map((i,a)=>r(i,a))})}),ie=c.memo(({open:o,setOpen:n,onNavigate:s})=>e.jsx(z,{lazyMount:!0,placement:"center",open:o,onOpenChange:l=>n(l.open),size:{mdDown:"full",md:"lg"},scrollBehavior:"inside",children:e.jsxs(E,{height:"100%",children:[e.jsx(L,{children:e.jsx(m,{children:"Annotations"})}),e.jsx(M,{flex:1,children:e.jsx(re,{onNavigate:s})}),e.jsx(A,{children:e.jsx(_,{asChild:!0,children:e.jsx(t.Button,{variant:"outline",children:"Cancel"})})}),e.jsx(B,{})]})})),ae=c.memo(()=>{const o=v(),n=G(o)?o:void 0,s=u.useObserve(()=>o==null?void 0:o.spine.element$,[o]),l=u.useObserve(()=>n==null?void 0:n.bookmarks.pages$,[n]),r=u.useObserve(()=>n==null?void 0:n.bookmarks.bookmarks$,[n]),i=u.useObserve(()=>o==null?void 0:o.pagination.locate(r??[]),[o,r]);return s?e.jsx(e.Fragment,{children:R.createPortal(l==null?void 0:l.map(({isBookmarkable:a,absolutePosition:{left:p,top:f,width:d}},b)=>{const h=i==null?void 0:i.find(S=>{var k;return((k=S.meta)==null?void 0:k.absolutePageIndex)===b});return a?e.jsx(t.Presence,{present:!0,lazyMount:!0,animationName:{_open:"fade-in",_closed:"fade-out"},animationDuration:"moderate",children:e.jsx(t.Box,{"data-bookmark-area":!0,position:"absolute",left:p+d,transform:"translateX(-100%)",top:f,p:2,children:h?e.jsx(t.IconButton,{"aria-label":"bookmark",opacity:.5,_hover:{opacity:1},onClick:()=>{h&&(n==null||n.bookmarks.delete(h==null?void 0:h.id))},size:"lg",variant:"ghost",_icon:{boxSize:"36px"},children:e.jsx(q.BsBookmarkXFill,{})}):e.jsx(t.IconButton,{"aria-label":"bookmark",onClick:()=>{n==null||n.bookmarks.bookmark(b)},size:"lg",bgColor:"white",opacity:.5,_hover:{opacity:1},variant:"ghost",_icon:{boxSize:"36px"},children:e.jsx(q.BsBookmarkPlus,{})})})},b):null}),s)}):null}),ce=c.memo(({onNavigate:o})=>{const n=v(),s=G(n)?n:void 0,l=u.useObserve(()=>s==null?void 0:s.bookmarks.bookmarks$.pipe(g.switchMap(i=>s.pagination.locate(i))),[s]),r=(i,a)=>{var p,f,d,b,h;return e.jsxs(t.List.Item,{justifyContent:"space-between",alignItems:"center",children:[e.jsx(t.Link,{href:"#",onClick:()=>{o(),n==null||n.navigation.goToCfi(i.cfi??"")},children:e.jsxs(t.Stack,{gap:0,children:[e.jsx(t.Text,{fontSize:"md",children:`Book page: ${((p=i.meta)==null?void 0:p.absolutePageIndex)!==void 0?i.meta.absolutePageIndex+1:"unknown"}`}),e.jsx(t.Text,{fontStyle:"italic",fontWeight:"bold",fontSize:"sm",truncate:!0,lineClamp:2,children:(d=(f=i.meta)==null?void 0:f.startNode)!=null&&d.textContent?(h=(b=i.meta)==null?void 0:b.startNode)==null?void 0:h.textContent:"..."})]})}),e.jsx(t.Button,{colorPalette:"red",variant:"solid",size:"xs",onClick:()=>{s==null||s.bookmarks.delete(i.id)},children:"Delete"})]},a)};return e.jsx(t.List.Root,{overflowY:"auto",gap:3,variant:"plain",overflow:"auto",children:l==null?void 0:l.map((i,a)=>r(i,a))})}),de=c.memo(({open:o,setOpen:n,onNavigate:s})=>e.jsx(z,{lazyMount:!0,placement:"center",open:o,onOpenChange:l=>n(l.open),size:{mdDown:"full",md:"lg"},scrollBehavior:"inside",children:e.jsxs(E,{height:"100%",children:[e.jsx(L,{children:e.jsx(m,{children:"Bookmarks"})}),e.jsx(M,{children:e.jsx(ce,{onNavigate:s})}),e.jsx(A,{children:e.jsx(_,{asChild:!0,children:e.jsx(t.Button,{variant:"outline",children:"Cancel"})})}),e.jsx(B,{})]})})),Y=t.createToaster({placement:"bottom-end",pauseOnPageIdle:!0}),he=()=>e.jsx(t.Portal,{children:e.jsx(t.Toaster,{toaster:Y,insetInline:{mdDown:"4"},children:o=>{var n;return e.jsxs(t.Toast.Root,{width:{md:"sm"},children:[o.type==="loading"?e.jsx(t.Spinner,{size:"sm",color:"blue.solid"}):e.jsx(t.Toast.Indicator,{}),e.jsxs(t.Stack,{gap:"1",flex:"1",maxWidth:"100%",children:[o.title&&e.jsx(t.Toast.Title,{children:o.title}),o.description&&e.jsx(t.Toast.Description,{children:o.description})]}),o.action&&e.jsx(t.Toast.ActionTrigger,{children:o.action.label}),((n=o.meta)==null?void 0:n.closable)&&e.jsx(t.Toast.CloseTrigger,{})]})}})}),ge={x:0,y:0,width:0,height:0,top:0,left:0,bottom:0,right:0};function pe(){const[o,n]=c.useState(null),[s,l]=c.useState(ge),r=c.useMemo(()=>new ResizeObserver(i=>{if(i[0]){const{x:a,y:p,width:f,height:d,top:b,left:h,bottom:S,right:k}=i[0].contentRect;l({x:a,y:p,width:f,height:d,top:b,left:h,bottom:S,right:k})}}),[]);return c.useLayoutEffect(()=>{if(o)return r.observe(o),()=>{r.disconnect()}},[o,r]),[n,s,o]}const fe=(o,n,s)=>{const l=v(),r=J(l)?l:void 0;u.useSubscribe(()=>!r||!o?g.NEVER:n.isReady$.pipe(g.filter(a=>a),g.map(()=>n.layout.layoutInfo),g.distinctUntilChanged(F.isShallowEqual)).pipe(g.switchMap(()=>r==null?void 0:r.gallery.snapshot(n,s)),g.tap(a=>{o.innerHTML="",o.appendChild(a)})),[r,n,s,o])},ue=c.memo(({item:o})=>{const n=v(),[s,l,r]=pe();return fe(r,o,l),u.useSubscribe(()=>(r?F.observeIntersection(r,{}):g.NEVER).pipe(g.switchMap(i=>{if(i.some(a=>a.isIntersecting)){const a=n==null?void 0:n.spine.spineItemsLoader.forceOpen([o]);return g.NEVER.pipe(g.finalize(()=>a==null?void 0:a()))}return g.NEVER})),[o,n,r]),e.jsx(t.Box,{ref:s,width:"100%",aspectRatio:"2/3",border:"1px solid",borderColor:"border",borderRadius:"md","data-grid-item":!0})}),be=c.memo(({open:o,setOpen:n})=>{const s=v(),l=u.useObserve(()=>s==null?void 0:s.spineItemsManager.items$,[s]);return e.jsx(z,{lazyMount:!0,placement:"center",open:o,onOpenChange:r=>n(r.open),size:{mdDown:"full",md:"lg"},scrollBehavior:"inside",children:e.jsxs(E,{height:"100%",children:[e.jsx(L,{children:e.jsx(m,{children:"Gallery"})}),e.jsx(M,{children:e.jsx(t.Box,{gridTemplateColumns:["repeat(2, minmax(0, 1fr))","repeat(3, minmax(0, 1fr))"],display:"grid",gap:[2,4],pt:2,"data-grid":!0,children:l==null?void 0:l.map(r=>e.jsx(ue,{item:r},r.item.id))})}),e.jsx(A,{children:e.jsx(_,{asChild:!0,children:e.jsx(t.Button,{variant:"outline",children:"Cancel"})})}),e.jsx(B,{})]})})}),Ce="@prose-reader/react-reader",ve="1.202.0",Se=c.memo(({open:o,setOpen:n})=>e.jsx(z,{lazyMount:!0,placement:"center",open:o,onOpenChange:s=>n(s.open),size:{mdDown:"full",md:"lg"},scrollBehavior:"inside",children:e.jsxs(E,{children:[e.jsx(L,{children:e.jsx(m,{children:"Help"})}),e.jsxs(M,{overflowY:"auto",flex:1,children:[e.jsx(t.Heading,{mb:2,as:"h3",size:"lg",children:"Shortcuts"}),e.jsxs(t.HStack,{mb:1,children:[e.jsx(t.Kbd,{children:e.jsx(x.LuArrowBigRight,{})})," ",e.jsx(t.Text,{children:"Navigate to right page"})]}),e.jsxs(t.HStack,{mb:1,children:[e.jsx(t.Kbd,{children:e.jsx(x.LuArrowBigLeft,{})})," ",e.jsx(t.Text,{children:"Navigate to left page"})]}),e.jsx(t.Heading,{mb:2,mt:4,as:"h3",size:"lg",children:"About"}),e.jsxs(t.Text,{children:[Ce," version: ",ve]})]}),e.jsx(A,{children:e.jsx(_,{asChild:!0,children:e.jsx(t.Button,{variant:"outline",children:"Cancel"})})}),e.jsx(B,{})]})})),N=()=>{const o=v();return u.useObserve(()=>o?g.combineLatest([o.pagination.state$,o.context.state$]).pipe(g.map(([n,s])=>{var r;const l=(r=s.manifest)==null?void 0:r.spineItems.every(i=>{var a;return(a=i.mediaType)==null?void 0:a.startsWith("image/")});return{...n,hasChapters:!s.isFullyPrePaginated&&!l}})):g.NEVER,[o])},ke=()=>{const o=N(),n=Math.floor(((o==null?void 0:o.percentageEstimateOfBook)??0)*100),s=n>0?n:1;return(o==null?void 0:o.percentageEstimateOfBook)===void 0?null:e.jsx(t.Box,{position:"absolute",right:0,bottom:0,p:2,color:"black",children:e.jsxs(t.Text,{fontSize:"sm",children:[s," %"]})})},xe=()=>{const[o,n]=c.useState(new Date);return c.useEffect(()=>{const s=setInterval(()=>{n(new Date)},6e4);return()=>clearInterval(s)},[]),o},ye=o=>{const n=xe();return e.jsx(t.Text,{fontSize:"xs",...o,children:n.toLocaleTimeString(navigator.language,{hour:"2-digit",minute:"2-digit"})})},U=()=>{const{quickMenuSignal:o}=c.useContext(V);return[u.useSignalValue(o),o.setValue,o]},Ie=()=>{const[o]=U();return e.jsx(t.Box,{position:"absolute",left:0,bottom:0,p:2,color:o?void 0:"colorPalette.contrast",children:e.jsx(ye,{})})},Te=()=>{const o=v();u.useSubscribe(()=>o==null?void 0:o.links$.subscribe(n=>{if(n.type==="click"&&F.isHtmlTagElement(n.target,"a")){if(!n.target.href)return;const s=new URL(n.target.href);window.location.host!==s.host&&confirm("You are going to be redirected to external link")&&window.open(n.target.href,"__blank")}}),[o])},H=u.signal({default:void 0}),Pe=()=>{const o=v();u.useSubscribe(()=>o==null?void 0:o.zoom.isZooming$.pipe(g.switchMap(n=>{if(!n)return g.EMPTY;const s=new g.Subject;return H.setValue({key:"zoom",title:"Zooming",duration:999999,abort:s}),g.NEVER.pipe(g.finalize(()=>{s.next(),s.complete()}))})),[o])},we=()=>{const o=v();u.useSubscribe(()=>o==null?void 0:o.settings.values$.pipe(g.map(({fontScale:n})=>n),g.distinctUntilChanged(),g.skip(1),g.tap(n=>{H.setValue({key:"fontScaleChange",title:"Font size changed",description:`${n*100} %`})})),[o])},Oe=()=>{we(),Pe(),u.useSubscribe(()=>H.subject.pipe(g.skip(1),g.filter(u.isDefined),g.mergeMap(o=>{const n=o.duration??3e3,s=Y.create({title:o.title,description:o.description,duration:n}),l=H.subject.pipe(g.skip(1),g.filter(r=>!!o.key&&(r==null?void 0:r.key)===o.key));return g.merge(g.timer(n),o.abort??g.NEVER,l).pipe(g.first(),g.finalize(()=>{Y.dismiss(s)}))})))},De=O.forwardRef(function(n,s){const{showArrow:l,children:r,portalled:i=!0,content:a,portalRef:p,...f}=n;return e.jsxs(t.Popover.Root,{...f,positioning:{...f.positioning,gutter:4},children:[e.jsx(t.Popover.Trigger,{asChild:!0,children:r}),e.jsx(t.Portal,{disabled:!i,container:p,children:e.jsx(t.Popover.Positioner,{children:e.jsxs(t.Popover.Content,{width:"auto",px:"2",py:"1",textStyle:"xs",rounded:"sm",ref:s,children:[l&&e.jsx(t.Popover.Arrow,{children:e.jsx(t.Popover.ArrowTip,{})}),a]})})})]})}),Ee=O.forwardRef(function(n,s){const{children:l,...r}=n;return e.jsx(De,{content:l,...r,ref:s,children:e.jsx(t.IconButton,{variant:"ghost","aria-label":"info",size:"2xs",colorPalette:"gray",children:e.jsx(oe.HiOutlineInformationCircle,{})})})}),Be=O.forwardRef(function(n,s){return e.jsx(t.Progress.Track,{...n,ref:s,children:e.jsx(t.Progress.Range,{})})});O.forwardRef(function(n,s){const{children:l,info:r,...i}=n;return e.jsxs(t.Progress.Label,{...i,ref:s,children:[l,r&&e.jsx(Ee,{children:r})]})});const ze=t.Progress.Root,Ae=t.Progress.ValueText,Q=()=>{const o=N(),n=(o==null?void 0:o.numberOfTotalPages)===1,s=((o==null?void 0:o.beginNumberOfPagesInSpineItem)??0)>1,l=((o==null?void 0:o.endNumberOfPagesInSpineItem)??0)>1,r=(o!=null&&o.hasChapters?o==null?void 0:o.beginPageIndexInSpineItem:o==null?void 0:o.beginAbsolutePageIndex)??0,i=(o!=null&&o.hasChapters?o==null?void 0:o.endPageIndexInSpineItem:o==null?void 0:o.endAbsolutePageIndex)??0,[a=0,p=0]=[r,i].sort((b,h)=>b-h),f=(o==null?void 0:o.beginPageIndexInSpineItem)!==(o==null?void 0:o.endPageIndexInSpineItem)||(o==null?void 0:o.beginSpineItemIndex)!==(o==null?void 0:o.endSpineItemIndex),d=o!=null&&o.hasChapters?o==null?void 0:o.beginNumberOfPagesInSpineItem:o==null?void 0:o.numberOfTotalPages;return{hasOnlyOnePage:n,beginPageIndex:r,endPageIndex:i,isBeginWithinChapter:s,isEndWithinChapter:l,beginAndEndAreDifferent:f,totalApproximatePages:d,leftPageIndex:a,rightPageIndex:p}},Le=()=>{const o=N(),{hasOnlyOnePage:n,leftPageIndex:s,rightPageIndex:l,totalApproximatePages:r,beginAndEndAreDifferent:i}=Q(),a=Math.round(((o==null?void 0:o.percentageEstimateOfBook)??0)*100),p=d=>d!=null&&d.subChapter?`${d.title} / ${p(d.subChapter)}`:(d==null?void 0:d.title)||"",f=p(o==null?void 0:o.beginChapterInfo);return e.jsxs(t.Stack,{alignItems:"center",gap:1,maxW:"100%",overflow:"auto",children:[e.jsx(ze,{value:a,size:"xs",width:150,children:e.jsxs(t.HStack,{justifyContent:"space-between",children:[e.jsx(Be,{width:110}),e.jsx(Ae,{children:`${a}%`})]})}),e.jsx(t.Text,{truncate:!0,maxWidth:"100%",fontSize:"sm",mt:1,children:f?`Chapter: ${f}`:" "}),!n&&e.jsxs(t.HStack,{children:[e.jsx(t.Text,{fontSize:"xs",children:i?`${s+1} - ${l+1} of ${r}`:`${s+1} of ${r}`}),!!(o!=null&&o.hasChapters)&&e.jsxs(e.Fragment,{children:[e.jsx(t.Text,{children:"-"}),e.jsxs(t.Text,{fontSize:"xs",children:["(",((o==null?void 0:o.beginAbsolutePageIndex)??0)+1,")"]})]})]})]})},j=c.memo(({children:o,position:n,...s})=>e.jsx(t.Presence,{display:"flex",flexDirection:"row",width:"100%",position:"absolute",...n==="bottom"?{bottom:0}:{top:0},animationName:n==="bottom"?{_open:"slide-from-bottom, fade-in",_closed:"slide-to-bottom, fade-out"}:{_open:"slide-from-top, fade-in",_closed:"slide-to-top, fade-out"},animationDuration:"moderate",bgColor:"bg.panel",alignItems:"center",justifyContent:"center",shadow:"md",p:4,...s,children:o})),Me=t.chakra(ne),me=c.memo(o=>e.jsx(t.Box,{display:"contents",css:{"--bg":"colors.bg","--bg-emphasized":"colors.bg.emphasized","--color-solid":"colors.colorPalette.solid"},children:e.jsx(Me,{keyboard:!1,style:{padding:0},css:{"& > .rc-slider-handle:focus-visible":{boxShadow:"0 0 0 2px var(--color-solid) !important"},"& > .rc-slider-handle:active":{boxShadow:"0 0 5px var(--color-solid) !important"},"& > .rc-slider-handle.rc-slider-handle-dragging":{boxShadow:"0 0 0 3px var(--color-solid) !important"}},styles:{rail:{height:"8px",top:"50%",transform:"translateY(-50%)",backgroundColor:"var(--bg-emphasized)"},track:{height:"8px",top:"50%",transform:"translateY(-50%)",backgroundColor:"var(--color-solid)"},handle:{width:"24px",height:"24px",top:"50%",borderColor:"var(--color-solid)",transform:`translate(${o.reverse?"50%":"-50%"}, -50%)`,backgroundColor:"var(--bg)",marginTop:"0px"}},...o})})),_e=()=>{const o=N(),n=o==null?void 0:o.isUsingSpread,{beginPageIndex:s,totalApproximatePages:l=0}=Q(),r=n?Math.floor((s||0)/2):s,[i,a]=u.useSignal({default:r||0}),p=0,f=Math.max(0,n?Math.floor((l-1)/2):l-1);return c.useEffect(()=>{a.setValue(r||0)},[r,a]),{value:i,valueSignal:a,min:p,max:f}},Ne=o=>{const n=v(),s=N(),{manifest:l}=u.useObserve(()=>n==null?void 0:n.context.state$,[n])??{},r=(l==null?void 0:l.readingDirection)==="rtl",i=s==null?void 0:s.isUsingSpread,{totalApproximatePages:a=0,isBeginWithinChapter:p}=Q(),f=1,d=p,{value:b,valueSignal:h,min:S,max:k}=_e(),I=c.useCallback(P=>{const[y=0]=Array.isArray(P)?P:[P];h.setValue(y);const D=i?Math.floor(y)*2:Math.floor(y);d?n==null||n.navigation.goToPageOfSpineItem({pageIndex:D,spineItemId:n.pagination.getState().beginSpineItemIndex??0,animation:!1}):n==null||n.navigation.goToAbsolutePageIndex({absolutePageIndex:D,animation:!1})},[n,i,h,d]);return u.useSubscribe(()=>n==null?void 0:n.navigation.throttleLock({duration:100,trigger:h.subject}),[n,h]),a===1||i&&a===2?e.jsx(t.Box,{style:o.style}):e.jsx(me,{value:[b],max:k,min:S,reverse:r,step:f,onChange:I,...o})},$e=c.memo(({open:o,onItemClick:n})=>{const s=v(),l=u.useObserve(()=>s==null?void 0:s.navigation.state$,[s]),r=u.useObserve(()=>s==null?void 0:s.settings.values$,[s]),i=(r==null?void 0:r.computedPageTurnDirection)==="vertical",[a,p]=c.useState(!0);return e.jsxs(j,{present:o,position:"bottom",display:"flex",flexDirection:"column",overflow:"auto",pb:8,children:[e.jsxs(t.HStack,{flex:1,alignItems:"center",justifyContent:"center",children:[e.jsx(t.IconButton,{"aria-label":"left",size:"lg",variant:"ghost",flexShrink:0,onClick:()=>s==null?void 0:s.navigation.goToLeftOrTopSpineItem(),disabled:!(l!=null&&l.canGoLeftSpineItem)&&!(l!=null&&l.canGoTopSpineItem),children:i?e.jsx($.RxDoubleArrowUp,{}):e.jsx($.RxDoubleArrowLeft,{})}),e.jsxs(t.Stack,{flex:1,maxW:400,gap:2,alignItems:"center",overflow:"auto",px:4,children:[e.jsx(Le,{}),e.jsx(Ne,{style:{width:"100%",maxWidth:"300px",height:"35px"}})]}),e.jsx(t.IconButton,{"aria-label":"right",size:"lg",flexShrink:0,variant:"ghost",disabled:!(l!=null&&l.canGoRightSpineItem)&&!(l!=null&&l.canGoBottomSpineItem),onClick:()=>{s==null||s.navigation.goToRightOrBottomSpineItem()},children:i?e.jsx($.RxDoubleArrowDown,{}):e.jsx($.RxDoubleArrowRight,{})})]}),e.jsx(t.HStack,{alignItems:"center",justifyContent:"center",children:e.jsxs(t.Collapsible.Root,{open:a,flex:1,onOpenChange:({open:f})=>{p(f)},children:[e.jsx(t.Collapsible.Trigger,{paddingY:"3",width:"100%",display:"flex",justifyContent:"center",children:e.jsx(x.LuChevronDown,{style:{transform:a?"rotate(0deg)":"rotate(180deg)"}})}),e.jsxs(t.Collapsible.Content,{display:"flex",justifyContent:"center",children:[e.jsx(t.IconButton,{"aria-label":"Help",size:"lg",variant:"ghost",onClick:()=>n("help"),children:e.jsx(x.LuCircleHelp,{})}),e.jsx(t.IconButton,{"aria-label":"Table of contents",size:"lg",variant:"ghost",onClick:()=>n("toc"),children:e.jsx(x.LuTableOfContents,{})}),X(s)&&e.jsx(t.IconButton,{"aria-label":"Search",size:"lg",variant:"ghost",onClick:()=>n("search"),children:e.jsx(x.LuSearch,{})}),G(s)&&e.jsx(t.IconButton,{"aria-label":"Search",size:"lg",variant:"ghost",onClick:()=>n("bookmarks"),children:e.jsx(q.BsBookmarks,{})}),Z(s)&&e.jsx(t.IconButton,{"aria-label":"Search",size:"lg",variant:"ghost",onClick:()=>n("annotations"),children:e.jsx(x.LuNotebookPen,{})}),e.jsx(t.IconButton,{"aria-label":"Thumbnails",size:"lg",variant:(s==null?void 0:s.settings.values.viewportMode)==="thumbnails"?"solid":"ghost",onClick:()=>{s==null||s.settings.update({viewportMode:(s==null?void 0:s.settings.values.viewportMode)==="normal"?"thumbnails":"normal"})},children:e.jsx(x.LuGalleryHorizontal,{})}),J(s)&&e.jsx(t.IconButton,{"aria-label":"Gallery",size:"lg",variant:"ghost",onClick:()=>n("gallery"),children:e.jsx(ee.RiGalleryView2,{})})]})]})})]})}),He=()=>{const[o,n]=c.useState(!1),s=c.useCallback(()=>document.fullscreenElement?document.exitFullscreen().catch(console.error).then(()=>{n(!1)}):document.documentElement.requestFullscreen({navigationUI:"hide"}).catch(console.error).then(()=>{n(!0)}),[]);return c.useEffect(()=>{function l(){n(!!document.fullscreenElement)}return document.addEventListener("fullscreenchange",l),()=>{document.removeEventListener("fullscreenchange",l)}},[]),{isFullscreen:o,onToggleFullscreenClick:s}},qe=c.memo(({open:o,onItemClick:n})=>{const s=v(),l=u.useObserve(()=>s==null?void 0:s.context.manifest$,[s]),{isFullscreen:r,onToggleFullscreenClick:i}=He();return e.jsxs(j,{present:o,position:"top",height:"80px",justifyContent:"space-between",children:[e.jsx(t.IconButton,{"aria-label":"left",size:"lg",variant:"ghost",flexShrink:0,onClick:()=>n("back"),children:e.jsx(K.IoIosArrowBack,{})}),e.jsx(t.Stack,{flex:1,maxW:600,gap:1,alignItems:"center",overflow:"auto",px:4,children:e.jsx(t.Text,{truncate:!0,maxWidth:"100%",children:l==null?void 0:l.title})}),e.jsxs(t.HStack,{children:[e.jsx(t.IconButton,{"aria-label":"right",size:"lg",flexShrink:0,variant:"ghost",onClick:()=>n("more"),children:e.jsx(K.IoMdMore,{})}),e.jsx(t.IconButton,{"aria-label":"right",size:"lg",flexShrink:0,variant:"ghost",onClick:i,children:r?e.jsx(W.MdFullscreenExit,{}):e.jsx(W.MdFullscreen,{})})]})]})}),Fe=c.memo(({onItemClick:o})=>{const[n]=U();return e.jsxs(e.Fragment,{children:[e.jsx(qe,{open:n,onItemClick:o}),e.jsx($e,{open:n,onItemClick:o})]})}),Ve=c.memo(({contextText:o="",startOffset:n=0,text:s,cfi:l="#",onClick:r,absolutePageIndex:i})=>{const p=o.substring(Math.max(n-15,0),Math.max(n,0)),f=o.substring(Math.min(n+s.length,o.length-1),Math.min(n+s.length+15,o.length-1));return e.jsxs(t.Link,{href:l,style:{margin:5,overflow:"hidden"},onClick:d=>{d.preventDefault(),r(l)},display:"flex",flexDirection:"column",alignItems:"flex-start",gap:0,children:[e.jsxs(t.Text,{lineClamp:1,as:"cite",style:{display:"block"},children:['"',p,e.jsx("b",{children:s}),f,'"']}),e.jsx(t.Text,{fontSize:"sm",color:"gray.500",style:{textDecoration:"none"},children:`Book page: ${i!==void 0?i+1:"unknown (not loaded)"}`})]})}),Ge=c.memo(({onNavigate:o})=>{const[n,s]=c.useState(""),l=v(),r=X(l)?l:void 0,i=h=>{s(h.target.value)},a=c.useCallback(h=>{o(),l==null||l.navigation.goToCfi(h)},[l,o]),p=u.useObserve(()=>r==null?void 0:r.search.search(n).pipe(g.map(h=>({type:"end",data:h})),g.startWith({type:"start"})),[l,n]),f=(p==null?void 0:p.type)==="start",d=(p==null?void 0:p.type)==="end"?p.data:[],b=u.useObserve(()=>l==null?void 0:l.pagination.locate(d.slice(0,100)),[d]);return e.jsxs(t.Stack,{flex:1,height:"100%",children:[e.jsx(t.Box,{px:4,children:e.jsx(t.Input,{placeholder:"Type something...",value:n,onChange:i,borderRadius:0})}),e.jsxs(t.Box,{px:4,pb:4,mt:2,flex:1,style:{overflow:"hidden",overflowY:"auto"},children:[f&&e.jsx(t.Text,{children:"Searching ..."}),!f&&d.length===0&&e.jsx("p",{children:"There are no results"}),!f&&d.length>=0&&e.jsxs(t.Stack,{children:[e.jsxs(t.Heading,{as:"h2",size:"md",children:[d.length," result(s)"]}),e.jsx(t.Stack,{gap:0,children:b==null?void 0:b.map((h,S)=>{var k,I,w,P,y,D,T;return e.jsx(Ve,{contextText:((w=(I=(k=h.meta)==null?void 0:k.range)==null?void 0:I.startContainer.parentElement)==null?void 0:w.textContent)??"",pageIndex:(P=h.meta)==null?void 0:P.itemPageIndex,startOffset:((D=(y=h.meta)==null?void 0:y.range)==null?void 0:D.startOffset)??0,text:n,cfi:h.cfi,onClick:a,absolutePageIndex:(T=h.meta)==null?void 0:T.absolutePageIndex},S)})})]})]})]})}),Ye=c.memo(({open:o,setOpen:n,onNavigate:s})=>e.jsx(z,{lazyMount:!0,placement:"center",open:o,onOpenChange:l=>n(l.open),size:{mdDown:"full",md:"lg"},scrollBehavior:"inside",children:e.jsxs(E,{height:"100%",children:[e.jsx(L,{children:e.jsx(m,{children:"Search"})}),e.jsx(M,{flex:1,children:e.jsx(Ge,{onNavigate:s})}),e.jsx(A,{children:e.jsx(_,{asChild:!0,children:e.jsx(t.Button,{variant:"outline",children:"Cancel"})})}),e.jsx(B,{})]})})),Ue=c.memo(({onNavigate:o})=>{const n=v(),{manifest:s,assumedRenditionLayout:l}=u.useObserve(()=>n==null?void 0:n.context.state$,[n])??{},{nav:r}=s??{},i=N();r!=null&&r.toc;const{beginSpineItemIndex:a,beginPageIndexInSpineItem:p}=i??{},f=(l==="reflowable"?p:a)||0;console.log({assumedRenditionLayout:l,currentSpineItemOrChapterPageIndex:f});let d=i==null?void 0:i.beginChapterInfo;for(;d!=null&&d.subChapter;)d=d==null?void 0:d.subChapter;const b=(h,S,k)=>e.jsxs(c.Fragment,{children:[e.jsx(t.List.Item,{pl:4*(k+1),style:{display:"flex",alignItems:"center"},children:e.jsxs(t.Link,{onClick:()=>{o(),n==null||n.navigation.goToUrl(h.href)},href:"#",children:[(d==null?void 0:d.path)===h.path&&e.jsx(t.List.Indicator,{asChild:!0,children:e.jsx(x.LuCircleCheck,{})}),(d==null?void 0:d.path)!==h.path&&e.jsx(t.List.Indicator,{asChild:!0,visibility:"hidden",children:e.jsx(x.LuCircleCheck,{})}),e.jsxs(t.Stack,{gap:0,children:[e.jsx(t.Text,{fontSize:"md",children:h.title||h.path}),(d==null?void 0:d.path)===h.path&&e.jsx(t.Text,{fontStyle:"italic",fontWeight:"bold",fontSize:"sm",children:`Currently on page ${f+1}`})]})]})}),h.contents.length>0&&e.jsx(t.List.Root,{as:"div",gap:2,children:h.contents.map((I,w)=>b(I,w,k+1))})]},S);return e.jsx(t.List.Root,{gap:3,overflowY:"auto",py:4,flex:1,children:r==null?void 0:r.toc.map((h,S)=>b(h,S,0))})}),Qe=c.memo(({open:o,setOpen:n,onNavigate:s})=>e.jsx(z,{lazyMount:!0,placement:"center",open:o,onOpenChange:l=>n(l.open),size:{mdDown:"full",md:"lg"},scrollBehavior:"inside",children:e.jsxs(E,{children:[e.jsx(L,{children:e.jsx(m,{children:"Table of Contents"})}),e.jsx(M,{overflowY:"auto",flex:1,children:e.jsx(Ue,{onNavigate:s})}),e.jsx(A,{children:e.jsx(_,{asChild:!0,children:e.jsx(t.Button,{variant:"outline",children:"Cancel"})})}),e.jsx(B,{})]})})),Ke=({enableFloatingTime:o=!0,enableFloatingProgress:n=!0,onItemClick:s})=>{const[l,r]=c.useState(!1),[i,a]=c.useState(!1),[p,f]=c.useState(!1),[d,b]=c.useState(!1),[h,S]=c.useState(!1),[k,I]=c.useState(!1),[w,P]=U(),y=c.useCallback(()=>{r(!1),a(!1),f(!1),b(!1),S(!1),P(!1),I(!1)},[P]),D=c.useCallback(T=>{T==="annotations"?b(!0):T==="search"?f(!0):T==="help"?a(!0):T==="toc"?r(!0):T==="bookmarks"?S(!0):T==="gallery"&&I(!0),s==null||s(T)},[s]);return Te(),Oe(),e.jsxs(e.Fragment,{children:[n&&e.jsx(t.Presence,{present:!w,animationName:{_open:"fade-in",_closed:"fade-out"},animationDuration:"moderate",children:e.jsx(ke,{})}),e.jsx(be,{open:k,setOpen:I}),e.jsx(Fe,{onItemClick:D}),e.jsx(ae,{}),e.jsx(Se,{open:i,setOpen:a}),e.jsx(Qe,{open:l,setOpen:r,onNavigate:y}),e.jsx(Ye,{open:p,setOpen:f,onNavigate:y}),e.jsx(ie,{open:d,setOpen:b,onNavigate:y}),e.jsx(de,{open:h,setOpen:S,onNavigate:y}),e.jsx(t.Presence,{present:o||w,animationName:{_open:"fade-in",_closed:"fade-out"},animationDuration:"slow",overflow:"hidden",children:e.jsx(Ie,{})}),e.jsx(he,{})]})};C.ReactReader=Ke,C.ReactReaderProvider=te,Object.defineProperty(C,Symbol.toStringTag,{value:"Module"})});
2
2
  //# sourceMappingURL=index.umd.cjs.map