@prose-reader/react-reader 1.219.0 → 1.220.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.
package/dist/index.js CHANGED
@@ -466,7 +466,7 @@ const Ot = (e, n, o) => {
466
466
  }
467
467
  );
468
468
  }
469
- ), Et = "@prose-reader/react-reader", At = "1.218.0", Mt = f(
469
+ ), Et = "@prose-reader/react-reader", At = "1.219.0", Mt = f(
470
470
  ({
471
471
  open: e,
472
472
  setOpen: n
@@ -1,2 +1,2 @@
1
- (function(v,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):(v=typeof globalThis<"u"?globalThis:v||self,e(v["prose-react-reader"]={},v.jsxRuntime,v.React,v.reactjrx,v.rxjs,v.react,v.lu,v.reactDom,v.bs,v.core,v.ri,v.rx,v.hi,v.RcSlider,null,v.io,v.md))})(this,function(v,e,h,u,p,t,x,R,F,q,ee,H,oe,ne,We,Q,K){"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(h),W=h.createContext({reader:void 0,quickMenuSignal:u.signal({default:!1}),notificationsSubject:new p.Subject}),te=h.memo(({children:o,reader:n,quickMenuOpen:s,onQuickMenuOpenChange:l})=>{const[,i]=u.useSignalState(()=>u.signal({default:s})),r=u.useConstant(()=>new p.Subject),a=u.useLiveRef(l),d=h.useMemo(()=>({quickMenuSignal:i,reader:n,notificationsSubject:r}),[i,n,r]);return h.useEffect(()=>{i.setValue(s)},[s,i]),u.useSubscribe(()=>i.pipe(p.tap(a.current)),[i,a]),e.jsx(W.Provider,{value:d,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,{})})}),B=O.forwardRef(function(n,s){const{children:l,portalled:i=!0,portalRef:r,backdrop:a=!0,...d}=n;return e.jsxs(t.Portal,{disabled:!i,container:r,children:[a&&e.jsx(t.Dialog.Backdrop,{}),e.jsx(t.Dialog.Positioner,{children:e.jsx(t.Dialog.Content,{ref:s,...d,asChild:!1,children:l})})]})}),E=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,$=()=>h.useContext(W),C=()=>{const{reader:o}=$();return o},X=o=>!!o&&"__PROSE_READER_ENHANCER_SEARCH"in o,V=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=h.memo(({onNavigate:o})=>{const n=C(),s=Z(n)?n:void 0,l=u.useObserve(()=>s==null?void 0:s.annotations.highlights$.pipe(p.switchMap(r=>s.locateResource(r))),[s]),i=(r,a)=>{var d,f,c;return e.jsx(t.List.Item,{children:e.jsxs(t.Link,{href:"#",onClick:()=>{o(),n==null||n.navigation.goToCfi(r.meta.cfi??"")},children:[(((d=r.resource)==null?void 0:d.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:(f=r.resource)!=null&&f.selectionAsText?r.resource.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: ${((c=r.meta)==null?void 0:c.absolutePageIndex)!==void 0?r.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((r,a)=>i(r,a))})}),ie=h.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(B,{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(E,{})]})})),ae=h.memo(()=>{const o=C(),n=V(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]),i=u.useObserve(()=>n==null?void 0:n.bookmarks.bookmarks$,[n]),r=u.useObserve(()=>o==null?void 0:o.locateResource(i??[]),[o,i]);return s?e.jsx(e.Fragment,{children:R.createPortal(l==null?void 0:l.map(({isBookmarkable:a,absolutePosition:{left:d,top:f,width:c}},b)=>{const g=r==null?void 0:r.find(S=>{var k;return((k=S==null?void 0: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:d+c,transform:"translateX(-100%)",top:f,p:2,children:g?e.jsx(t.IconButton,{"aria-label":"bookmark",opacity:.5,_hover:{opacity:1},onClick:()=>{g&&(n==null||n.bookmarks.delete(g.resource.id))},size:"lg",variant:"ghost",_icon:{boxSize:"36px"},children:e.jsx(F.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(F.BsBookmarkPlus,{})})})},b):null}),s)}):null}),ce=h.memo(({onNavigate:o})=>{const n=C(),s=V(n)?n:void 0,l=u.useObserve(()=>s==null?void 0:s.bookmarks.bookmarks$.pipe(p.switchMap(r=>s.locateResource(r))),[s]),i=(r,a)=>{var d,f,c,b,g;return e.jsxs(t.List.Item,{justifyContent:"space-between",alignItems:"center",children:[e.jsx(t.Link,{href:"#",onClick:()=>{o(),n==null||n.navigation.goToCfi(r.meta.cfi??"")},children:e.jsxs(t.Stack,{gap:0,children:[e.jsx(t.Text,{fontSize:"md",children:`Book page: ${((d=r.meta)==null?void 0:d.absolutePageIndex)!==void 0?r.meta.absolutePageIndex+1:"unknown"}`}),e.jsx(t.Text,{fontStyle:"italic",fontWeight:"bold",fontSize:"sm",truncate:!0,lineClamp:2,children:(c=(f=r.meta)==null?void 0:f.startNode)!=null&&c.textContent?(g=(b=r.meta)==null?void 0:b.startNode)==null?void 0:g.textContent:"..."})]})}),e.jsx(t.Button,{colorPalette:"red",variant:"solid",size:"xs",onClick:()=>{s==null||s.bookmarks.delete(r.resource.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((r,a)=>i(r,a))})}),de=h.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(B,{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(E,{})]})})),G=t.createToaster({placement:"bottom-end",pauseOnPageIdle:!0}),he=()=>e.jsx(t.Portal,{children:e.jsx(t.Toaster,{toaster:G,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]=h.useState(null),[s,l]=h.useState(ge),i=h.useMemo(()=>new ResizeObserver(r=>{if(r[0]){const{x:a,y:d,width:f,height:c,top:b,left:g,bottom:S,right:k}=r[0].contentRect;l({x:a,y:d,width:f,height:c,top:b,left:g,bottom:S,right:k})}}),[]);return h.useLayoutEffect(()=>{if(o)return i.observe(o),()=>{i.disconnect()}},[o,i]),[n,s,o]}const fe=(o,n,s)=>{const l=C(),i=J(l)?l:void 0;u.useSubscribe(()=>{if(!i||!o)return p.NEVER;const r=n.layout.layout$.pipe(p.startWith(n.layout.layoutInfo),p.distinctUntilChanged(q.isShallowEqual)),a=q.observeIntersection(o).pipe(p.map(d=>d.some(f=>f.isIntersecting)));return r.pipe(p.throttleTime(100,void 0,{trailing:!0}),p.switchMap(()=>a.pipe(p.tap(d=>{d||(o.innerHTML="")}),p.filter(d=>d),p.first()).pipe(p.switchMap(()=>(o.innerHTML="",i==null?void 0:i.gallery.snapshot(n,o,s))))))},[i,n,s,o])},ue=h.memo(({item:o,onNavigated:n})=>{var d;const[s,l,i]=pe(),r=C();fe(i,o,l);const a=u.useObserve(()=>r==null?void 0:r.locateResource(o,{mode:"shallow"}),[r,o]);return e.jsxs(t.Box,{width:"100%",aspectRatio:"2/3",border:"1px solid",borderColor:"border",borderRadius:"md","data-grid-item":!0,cursor:"pointer",position:"relative",overflow:"hidden",onClick:()=>{n(),r==null||r.navigation.goToSpineItem({indexOrId:o})},children:[e.jsx(t.Box,{height:"100%",width:"100%",overflow:"hidden",pointerEvents:"none",ref:s}),e.jsxs(t.Text,{position:"absolute",bottom:0,left:"0",right:"0",textAlign:"center",bgColor:"white",p:4,fontSize:"xs",children:["Page ",(((d=a==null?void 0:a.meta)==null?void 0:d.absolutePageIndex)??0)+1]})]})}),be=h.memo(({open:o,setOpen:n})=>{const s=C(),l=u.useObserve(()=>s==null?void 0:s.spineItemsManager.items$,[s]);return e.jsx(z,{lazyMount:!0,placement:"center",open:o,onOpenChange:i=>n(i.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,{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(i=>e.jsx(ue,{item:i,onNavigated:()=>{n(!1)}},i.item.id))})}),e.jsx(A,{children:e.jsx(_,{asChild:!0,children:e.jsx(t.Button,{variant:"outline",children:"Cancel"})})}),e.jsx(E,{})]})})}),ve="@prose-reader/react-reader",Se="1.218.0",Ce=h.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(B,{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:[ve," version: ",Se]})]}),e.jsx(A,{children:e.jsx(_,{asChild:!0,children:e.jsx(t.Button,{variant:"outline",children:"Cancel"})})}),e.jsx(E,{})]})})),N=()=>{const o=C();return u.useObserve(()=>o?p.combineLatest([o.pagination.state$,o.context.state$]).pipe(p.map(([n,s])=>{var i;const l=(i=s.manifest)==null?void 0:i.spineItems.every(r=>{var a;return(a=r.mediaType)==null?void 0:a.startsWith("image/")});return{...n,hasChapters:!s.isFullyPrePaginated&&!l}})):p.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]=h.useState(new Date);return h.useEffect(()=>{const s=setInterval(()=>{n(new Date)},6e4);return()=>clearInterval(s)},[]),o},Ie=o=>{const n=xe();return e.jsx(t.Text,{fontSize:"xs",...o,children:n.toLocaleTimeString(navigator.language,{hour:"2-digit",minute:"2-digit"})})},Y=()=>{const{quickMenuSignal:o}=$();return[u.useSignalValue(o),o.setValue,o]},Te=()=>{const[o]=Y();return e.jsx(t.Box,{position:"absolute",left:0,bottom:0,p:2,color:o?void 0:"colorPalette.contrast",children:e.jsx(Ie,{})})},ye=()=>{const o=C();u.useSubscribe(()=>o==null?void 0:o.links$.subscribe(n=>{if(n.type==="click"&&q.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])},Pe=()=>{const o=C(),{notificationsSubject:n}=$();u.useSubscribe(()=>o==null?void 0:o.zoom.isZooming$.pipe(p.switchMap(s=>{if(!s)return p.EMPTY;const l=new p.Subject;return n.next({key:"zoom",title:"Zooming",duration:999999,abort:l}),p.NEVER.pipe(p.finalize(()=>{l.next(),l.complete()}))})),[o])},we=()=>{const o=C(),{notificationsSubject:n}=$();u.useSubscribe(()=>o==null?void 0:o.settings.values$.pipe(p.map(({fontScale:s})=>s),p.distinctUntilChanged(),p.skip(1),p.tap(s=>{n.next({key:"fontScaleChange",title:"Font size changed",description:`${s*100} %`})})),[o,n])},Oe=()=>{const{notificationsSubject:o}=$();we(),Pe(),u.useSubscribe(()=>o.pipe(p.filter(u.isDefined),p.mergeMap(n=>{const s=n.duration??3e3,l=G.create({title:n.title,description:n.description,duration:s}),i=o.pipe(p.skip(1),p.filter(r=>!!n.key&&(r==null?void 0:r.key)===n.key));return p.merge(p.timer(s),n.abort??p.NEVER,i).pipe(p.first(),p.finalize(()=>{G.dismiss(l)}))})),[o])},De=O.forwardRef(function(n,s){const{showArrow:l,children:i,portalled:r=!0,content:a,portalRef:d,...f}=n;return e.jsxs(t.Popover.Root,{...f,positioning:{...f.positioning,gutter:4},children:[e.jsx(t.Popover.Trigger,{asChild:!0,children:i}),e.jsx(t.Portal,{disabled:!r,container:d,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]})})})]})}),Be=O.forwardRef(function(n,s){const{children:l,...i}=n;return e.jsx(De,{content:l,...i,ref:s,children:e.jsx(t.IconButton,{variant:"ghost","aria-label":"info",size:"2xs",colorPalette:"gray",children:e.jsx(oe.HiOutlineInformationCircle,{})})})}),Ee=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:i,...r}=n;return e.jsxs(t.Progress.Label,{...r,ref:s,children:[l,i&&e.jsx(Be,{children:i})]})});const ze=t.Progress.Root,Ae=t.Progress.ValueText,U=()=>{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,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,[a=0,d=0]=[i,r].sort((b,g)=>b-g),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),c=o!=null&&o.hasChapters?o==null?void 0:o.beginNumberOfPagesInSpineItem:o==null?void 0:o.numberOfTotalPages;return{hasOnlyOnePage:n,beginPageIndex:i,endPageIndex:r,isBeginWithinChapter:s,isEndWithinChapter:l,beginAndEndAreDifferent:f,totalApproximatePages:c,leftPageIndex:a,rightPageIndex:d}},Le=()=>{const o=N(),{hasOnlyOnePage:n,leftPageIndex:s,rightPageIndex:l,totalApproximatePages:i,beginAndEndAreDifferent:r}=U(),a=Math.round(((o==null?void 0:o.percentageEstimateOfBook)??0)*100),d=c=>c!=null&&c.subChapter?`${c.title} / ${d(c.subChapter)}`:(c==null?void 0:c.title)||"",f=d(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(Ee,{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:r?`${s+1} - ${l+1} of ${i}`:`${s+1} of ${i}`}),!!(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=h.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=h.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}=U(),i=n?Math.floor((s||0)/2):s,[r,a]=u.useSignalState(()=>u.signal({default:i||0})),d=0,f=Math.max(0,n?Math.floor((l-1)/2):l-1);return h.useEffect(()=>{a.update(i||0)},[i,a]),{value:r,valueSignal:a,min:d,max:f}},Ne=o=>{const n=C(),s=N(),{manifest:l}=u.useObserve(()=>n==null?void 0:n.context.state$,[n])??{},i=(l==null?void 0:l.readingDirection)==="rtl",r=s==null?void 0:s.isUsingSpread,{totalApproximatePages:a=0,isBeginWithinChapter:d}=U(),f=1,c=d,{value:b,valueSignal:g,min:S,max:k}=_e(),T=h.useCallback(P=>{const[I=0]=Array.isArray(P)?P:[P];g.setValue(I);const D=r?Math.floor(I)*2:Math.floor(I);c?n==null||n.navigation.goToPageOfSpineItem({pageIndex:D,spineItemId:n.pagination.state.beginSpineItemIndex??0,animation:!1}):n==null||n.navigation.goToAbsolutePageIndex({absolutePageIndex:D,animation:!1})},[n,r,g,c]);return u.useSubscribe(()=>n==null?void 0:n.navigation.throttleLock({duration:100,trigger:g.subject}),[n,g]),a===1||r&&a===2?e.jsx(t.Box,{style:o.style}):e.jsx(me,{value:[b],max:k,min:S,reverse:i,step:f,onChange:T,...o})},$e=h.memo(({open:o,onItemClick:n})=>{const s=C(),l=u.useObserve(()=>s==null?void 0:s.navigation.state$,[s]),i=u.useObserve(()=>s==null?void 0:s.settings.values$,[s]),r=(i==null?void 0:i.computedPageTurnDirection)==="vertical",[a,d]=h.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:r?e.jsx(H.RxDoubleArrowUp,{}):e.jsx(H.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:r?e.jsx(H.RxDoubleArrowDown,{}):e.jsx(H.RxDoubleArrowRight,{})})]}),e.jsx(t.HStack,{alignSelf:"stretch",alignItems:"center",justifyContent:"center",children:e.jsxs(t.Collapsible.Root,{open:a,flex:1,onOpenChange:({open:f})=>{d(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,{})}),V(s)&&e.jsx(t.IconButton,{"aria-label":"Search",size:"lg",variant:"ghost",onClick:()=>n("bookmarks"),children:e.jsx(F.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]=h.useState(!1),s=h.useCallback(()=>document.fullscreenElement?document.exitFullscreen().catch(console.error).then(()=>{n(!1)}):document.documentElement.requestFullscreen({navigationUI:"hide"}).catch(console.error).then(()=>{n(!0)}),[]);return h.useEffect(()=>{function l(){n(!!document.fullscreenElement)}return document.addEventListener("fullscreenchange",l),()=>{document.removeEventListener("fullscreenchange",l)}},[]),{isFullscreen:o,onToggleFullscreenClick:s}},Fe=h.memo(({open:o,onItemClick:n})=>{const s=C(),l=u.useObserve(()=>s==null?void 0:s.context.manifest$,[s]),{isFullscreen:i,onToggleFullscreenClick:r}=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(Q.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(Q.IoMdMore,{})}),e.jsx(t.IconButton,{"aria-label":"right",size:"lg",flexShrink:0,variant:"ghost",onClick:r,children:i?e.jsx(K.MdFullscreenExit,{}):e.jsx(K.MdFullscreen,{})})]})]})}),qe=h.memo(({onItemClick:o})=>{const[n]=Y();return e.jsxs(e.Fragment,{children:[e.jsx(Fe,{open:n,onItemClick:o}),e.jsx($e,{open:n,onItemClick:o})]})}),Ve=h.memo(({contextText:o="",startOffset:n=0,text:s,cfi:l="#",onClick:i,absolutePageIndex:r})=>{const d=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:c=>{c.preventDefault(),i(l)},display:"flex",flexDirection:"column",alignItems:"flex-start",gap:0,children:[e.jsxs(t.Text,{lineClamp:1,as:"cite",style:{display:"block"},children:['"',d,e.jsx("b",{children:s}),f,'"']}),e.jsx(t.Text,{fontSize:"sm",color:"gray.500",style:{textDecoration:"none"},children:`Book page: ${r!==void 0?r+1:"unknown (not loaded)"}`})]})}),Ge=h.memo(({onNavigate:o})=>{const[n,s]=h.useState(""),l=C(),i=X(l)?l:void 0,r=g=>{s(g.target.value)},a=h.useCallback(g=>{o(),l==null||l.navigation.goToCfi(g)},[l,o]),d=u.useObserve(()=>i==null?void 0:i.search.search(n).pipe(p.map(g=>({type:"end",data:g})),p.startWith({type:"start"})),[l,n]),f=(d==null?void 0:d.type)==="start",c=(d==null?void 0:d.type)==="end"?d.data:[],b=u.useObserve(()=>l==null?void 0:l.locateResource(c.slice(0,100)),[c]);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:r,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&&c.length===0&&e.jsx("p",{children:"There are no results"}),!f&&c.length>=0&&e.jsxs(t.Stack,{children:[e.jsxs(t.Heading,{as:"h2",size:"md",children:[c.length," result(s)"]}),e.jsx(t.Stack,{gap:0,children:b==null?void 0:b.map((g,S)=>{var k,T,w,P,I,D,y;return e.jsx(Ve,{contextText:((w=(T=(k=g.meta)==null?void 0:k.range)==null?void 0:T.startContainer.parentElement)==null?void 0:w.textContent)??"",pageIndex:(P=g.meta)==null?void 0:P.itemPageIndex,startOffset:((D=(I=g.meta)==null?void 0:I.range)==null?void 0:D.startOffset)??0,text:n,cfi:g.meta.cfi,onClick:a,absolutePageIndex:(y=g.meta)==null?void 0:y.absolutePageIndex},S)})})]})]})]})}),Ye=h.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(B,{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(E,{})]})})),Ue=h.memo(({onNavigate:o})=>{const n=C(),{manifest:s,assumedRenditionLayout:l}=u.useObserve(()=>n==null?void 0:n.context.state$,[n])??{},{nav:i}=s??{},r=N();i!=null&&i.toc;const{beginSpineItemIndex:a,beginPageIndexInSpineItem:d}=r??{},f=(l==="reflowable"?d:a)||0;console.log({assumedRenditionLayout:l,currentSpineItemOrChapterPageIndex:f});let c=r==null?void 0:r.beginChapterInfo;for(;c!=null&&c.subChapter;)c=c==null?void 0:c.subChapter;const b=(g,S,k)=>e.jsxs(h.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(g.href)},href:"#",children:[(c==null?void 0:c.path)===g.path&&e.jsx(t.List.Indicator,{asChild:!0,children:e.jsx(x.LuCircleCheck,{})}),(c==null?void 0:c.path)!==g.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:g.title||g.path}),(c==null?void 0:c.path)===g.path&&e.jsx(t.Text,{fontStyle:"italic",fontWeight:"bold",fontSize:"sm",children:`Currently on page ${f+1}`})]})]})}),g.contents.length>0&&e.jsx(t.List.Root,{as:"div",gap:2,children:g.contents.map((T,w)=>b(T,w,k+1))})]},S);return e.jsx(t.List.Root,{gap:3,overflowY:"auto",py:4,flex:1,children:i==null?void 0:i.toc.map((g,S)=>b(g,S,0))})}),Qe=h.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(B,{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(E,{})]})})),Ke=({enableFloatingTime:o=!0,enableFloatingProgress:n=!0,onItemClick:s})=>{const[l,i]=h.useState(!1),[r,a]=h.useState(!1),[d,f]=h.useState(!1),[c,b]=h.useState(!1),[g,S]=h.useState(!1),[k,T]=h.useState(!1),[w,P]=Y(),I=h.useCallback(()=>{i(!1),a(!1),f(!1),b(!1),S(!1),P(!1),T(!1)},[P]),D=h.useCallback(y=>{y==="annotations"?b(!0):y==="search"?f(!0):y==="help"?a(!0):y==="toc"?i(!0):y==="bookmarks"?S(!0):y==="gallery"&&T(!0),s==null||s(y)},[s]);return ye(),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:T}),e.jsx(qe,{onItemClick:D}),e.jsx(ae,{}),e.jsx(Ce,{open:r,setOpen:a}),e.jsx(Qe,{open:l,setOpen:i,onNavigate:I}),e.jsx(Ye,{open:d,setOpen:f,onNavigate:I}),e.jsx(ie,{open:c,setOpen:b,onNavigate:I}),e.jsx(de,{open:g,setOpen:S,onNavigate:I}),e.jsx(t.Presence,{present:o||w,animationName:{_open:"fade-in",_closed:"fade-out"},animationDuration:"slow",overflow:"hidden",children:e.jsx(Te,{})}),e.jsx(he,{})]})};v.ReactReader=Ke,v.ReactReaderProvider=te,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})});
1
+ (function(v,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):(v=typeof globalThis<"u"?globalThis:v||self,e(v["prose-react-reader"]={},v.jsxRuntime,v.React,v.reactjrx,v.rxjs,v.react,v.lu,v.reactDom,v.bs,v.core,v.ri,v.rx,v.hi,v.RcSlider,null,v.io,v.md))})(this,function(v,e,h,u,p,t,x,R,F,q,ee,H,oe,ne,We,Q,K){"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(h),W=h.createContext({reader:void 0,quickMenuSignal:u.signal({default:!1}),notificationsSubject:new p.Subject}),te=h.memo(({children:o,reader:n,quickMenuOpen:s,onQuickMenuOpenChange:l})=>{const[,i]=u.useSignalState(()=>u.signal({default:s})),r=u.useConstant(()=>new p.Subject),a=u.useLiveRef(l),d=h.useMemo(()=>({quickMenuSignal:i,reader:n,notificationsSubject:r}),[i,n,r]);return h.useEffect(()=>{i.setValue(s)},[s,i]),u.useSubscribe(()=>i.pipe(p.tap(a.current)),[i,a]),e.jsx(W.Provider,{value:d,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,{})})}),B=O.forwardRef(function(n,s){const{children:l,portalled:i=!0,portalRef:r,backdrop:a=!0,...d}=n;return e.jsxs(t.Portal,{disabled:!i,container:r,children:[a&&e.jsx(t.Dialog.Backdrop,{}),e.jsx(t.Dialog.Positioner,{children:e.jsx(t.Dialog.Content,{ref:s,...d,asChild:!1,children:l})})]})}),E=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,$=()=>h.useContext(W),C=()=>{const{reader:o}=$();return o},X=o=>!!o&&"__PROSE_READER_ENHANCER_SEARCH"in o,V=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=h.memo(({onNavigate:o})=>{const n=C(),s=Z(n)?n:void 0,l=u.useObserve(()=>s==null?void 0:s.annotations.highlights$.pipe(p.switchMap(r=>s.locateResource(r))),[s]),i=(r,a)=>{var d,f,c;return e.jsx(t.List.Item,{children:e.jsxs(t.Link,{href:"#",onClick:()=>{o(),n==null||n.navigation.goToCfi(r.meta.cfi??"")},children:[(((d=r.resource)==null?void 0:d.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:(f=r.resource)!=null&&f.selectionAsText?r.resource.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: ${((c=r.meta)==null?void 0:c.absolutePageIndex)!==void 0?r.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((r,a)=>i(r,a))})}),ie=h.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(B,{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(E,{})]})})),ae=h.memo(()=>{const o=C(),n=V(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]),i=u.useObserve(()=>n==null?void 0:n.bookmarks.bookmarks$,[n]),r=u.useObserve(()=>o==null?void 0:o.locateResource(i??[]),[o,i]);return s?e.jsx(e.Fragment,{children:R.createPortal(l==null?void 0:l.map(({isBookmarkable:a,absolutePosition:{left:d,top:f,width:c}},b)=>{const g=r==null?void 0:r.find(S=>{var k;return((k=S==null?void 0: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:d+c,transform:"translateX(-100%)",top:f,p:2,children:g?e.jsx(t.IconButton,{"aria-label":"bookmark",opacity:.5,_hover:{opacity:1},onClick:()=>{g&&(n==null||n.bookmarks.delete(g.resource.id))},size:"lg",variant:"ghost",_icon:{boxSize:"36px"},children:e.jsx(F.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(F.BsBookmarkPlus,{})})})},b):null}),s)}):null}),ce=h.memo(({onNavigate:o})=>{const n=C(),s=V(n)?n:void 0,l=u.useObserve(()=>s==null?void 0:s.bookmarks.bookmarks$.pipe(p.switchMap(r=>s.locateResource(r))),[s]),i=(r,a)=>{var d,f,c,b,g;return e.jsxs(t.List.Item,{justifyContent:"space-between",alignItems:"center",children:[e.jsx(t.Link,{href:"#",onClick:()=>{o(),n==null||n.navigation.goToCfi(r.meta.cfi??"")},children:e.jsxs(t.Stack,{gap:0,children:[e.jsx(t.Text,{fontSize:"md",children:`Book page: ${((d=r.meta)==null?void 0:d.absolutePageIndex)!==void 0?r.meta.absolutePageIndex+1:"unknown"}`}),e.jsx(t.Text,{fontStyle:"italic",fontWeight:"bold",fontSize:"sm",truncate:!0,lineClamp:2,children:(c=(f=r.meta)==null?void 0:f.startNode)!=null&&c.textContent?(g=(b=r.meta)==null?void 0:b.startNode)==null?void 0:g.textContent:"..."})]})}),e.jsx(t.Button,{colorPalette:"red",variant:"solid",size:"xs",onClick:()=>{s==null||s.bookmarks.delete(r.resource.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((r,a)=>i(r,a))})}),de=h.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(B,{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(E,{})]})})),G=t.createToaster({placement:"bottom-end",pauseOnPageIdle:!0}),he=()=>e.jsx(t.Portal,{children:e.jsx(t.Toaster,{toaster:G,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]=h.useState(null),[s,l]=h.useState(ge),i=h.useMemo(()=>new ResizeObserver(r=>{if(r[0]){const{x:a,y:d,width:f,height:c,top:b,left:g,bottom:S,right:k}=r[0].contentRect;l({x:a,y:d,width:f,height:c,top:b,left:g,bottom:S,right:k})}}),[]);return h.useLayoutEffect(()=>{if(o)return i.observe(o),()=>{i.disconnect()}},[o,i]),[n,s,o]}const fe=(o,n,s)=>{const l=C(),i=J(l)?l:void 0;u.useSubscribe(()=>{if(!i||!o)return p.NEVER;const r=n.layout.layout$.pipe(p.startWith(n.layout.layoutInfo),p.distinctUntilChanged(q.isShallowEqual)),a=q.observeIntersection(o).pipe(p.map(d=>d.some(f=>f.isIntersecting)));return r.pipe(p.throttleTime(100,void 0,{trailing:!0}),p.switchMap(()=>a.pipe(p.tap(d=>{d||(o.innerHTML="")}),p.filter(d=>d),p.first()).pipe(p.switchMap(()=>(o.innerHTML="",i==null?void 0:i.gallery.snapshot(n,o,s))))))},[i,n,s,o])},ue=h.memo(({item:o,onNavigated:n})=>{var d;const[s,l,i]=pe(),r=C();fe(i,o,l);const a=u.useObserve(()=>r==null?void 0:r.locateResource(o,{mode:"shallow"}),[r,o]);return e.jsxs(t.Box,{width:"100%",aspectRatio:"2/3",border:"1px solid",borderColor:"border",borderRadius:"md","data-grid-item":!0,cursor:"pointer",position:"relative",overflow:"hidden",onClick:()=>{n(),r==null||r.navigation.goToSpineItem({indexOrId:o})},children:[e.jsx(t.Box,{height:"100%",width:"100%",overflow:"hidden",pointerEvents:"none",ref:s}),e.jsxs(t.Text,{position:"absolute",bottom:0,left:"0",right:"0",textAlign:"center",bgColor:"white",p:4,fontSize:"xs",children:["Page ",(((d=a==null?void 0:a.meta)==null?void 0:d.absolutePageIndex)??0)+1]})]})}),be=h.memo(({open:o,setOpen:n})=>{const s=C(),l=u.useObserve(()=>s==null?void 0:s.spineItemsManager.items$,[s]);return e.jsx(z,{lazyMount:!0,placement:"center",open:o,onOpenChange:i=>n(i.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,{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(i=>e.jsx(ue,{item:i,onNavigated:()=>{n(!1)}},i.item.id))})}),e.jsx(A,{children:e.jsx(_,{asChild:!0,children:e.jsx(t.Button,{variant:"outline",children:"Cancel"})})}),e.jsx(E,{})]})})}),ve="@prose-reader/react-reader",Se="1.219.0",Ce=h.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(B,{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:[ve," version: ",Se]})]}),e.jsx(A,{children:e.jsx(_,{asChild:!0,children:e.jsx(t.Button,{variant:"outline",children:"Cancel"})})}),e.jsx(E,{})]})})),N=()=>{const o=C();return u.useObserve(()=>o?p.combineLatest([o.pagination.state$,o.context.state$]).pipe(p.map(([n,s])=>{var i;const l=(i=s.manifest)==null?void 0:i.spineItems.every(r=>{var a;return(a=r.mediaType)==null?void 0:a.startsWith("image/")});return{...n,hasChapters:!s.isFullyPrePaginated&&!l}})):p.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]=h.useState(new Date);return h.useEffect(()=>{const s=setInterval(()=>{n(new Date)},6e4);return()=>clearInterval(s)},[]),o},Ie=o=>{const n=xe();return e.jsx(t.Text,{fontSize:"xs",...o,children:n.toLocaleTimeString(navigator.language,{hour:"2-digit",minute:"2-digit"})})},Y=()=>{const{quickMenuSignal:o}=$();return[u.useSignalValue(o),o.setValue,o]},Te=()=>{const[o]=Y();return e.jsx(t.Box,{position:"absolute",left:0,bottom:0,p:2,color:o?void 0:"colorPalette.contrast",children:e.jsx(Ie,{})})},ye=()=>{const o=C();u.useSubscribe(()=>o==null?void 0:o.links$.subscribe(n=>{if(n.type==="click"&&q.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])},Pe=()=>{const o=C(),{notificationsSubject:n}=$();u.useSubscribe(()=>o==null?void 0:o.zoom.isZooming$.pipe(p.switchMap(s=>{if(!s)return p.EMPTY;const l=new p.Subject;return n.next({key:"zoom",title:"Zooming",duration:999999,abort:l}),p.NEVER.pipe(p.finalize(()=>{l.next(),l.complete()}))})),[o])},we=()=>{const o=C(),{notificationsSubject:n}=$();u.useSubscribe(()=>o==null?void 0:o.settings.values$.pipe(p.map(({fontScale:s})=>s),p.distinctUntilChanged(),p.skip(1),p.tap(s=>{n.next({key:"fontScaleChange",title:"Font size changed",description:`${s*100} %`})})),[o,n])},Oe=()=>{const{notificationsSubject:o}=$();we(),Pe(),u.useSubscribe(()=>o.pipe(p.filter(u.isDefined),p.mergeMap(n=>{const s=n.duration??3e3,l=G.create({title:n.title,description:n.description,duration:s}),i=o.pipe(p.skip(1),p.filter(r=>!!n.key&&(r==null?void 0:r.key)===n.key));return p.merge(p.timer(s),n.abort??p.NEVER,i).pipe(p.first(),p.finalize(()=>{G.dismiss(l)}))})),[o])},De=O.forwardRef(function(n,s){const{showArrow:l,children:i,portalled:r=!0,content:a,portalRef:d,...f}=n;return e.jsxs(t.Popover.Root,{...f,positioning:{...f.positioning,gutter:4},children:[e.jsx(t.Popover.Trigger,{asChild:!0,children:i}),e.jsx(t.Portal,{disabled:!r,container:d,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]})})})]})}),Be=O.forwardRef(function(n,s){const{children:l,...i}=n;return e.jsx(De,{content:l,...i,ref:s,children:e.jsx(t.IconButton,{variant:"ghost","aria-label":"info",size:"2xs",colorPalette:"gray",children:e.jsx(oe.HiOutlineInformationCircle,{})})})}),Ee=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:i,...r}=n;return e.jsxs(t.Progress.Label,{...r,ref:s,children:[l,i&&e.jsx(Be,{children:i})]})});const ze=t.Progress.Root,Ae=t.Progress.ValueText,U=()=>{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,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,[a=0,d=0]=[i,r].sort((b,g)=>b-g),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),c=o!=null&&o.hasChapters?o==null?void 0:o.beginNumberOfPagesInSpineItem:o==null?void 0:o.numberOfTotalPages;return{hasOnlyOnePage:n,beginPageIndex:i,endPageIndex:r,isBeginWithinChapter:s,isEndWithinChapter:l,beginAndEndAreDifferent:f,totalApproximatePages:c,leftPageIndex:a,rightPageIndex:d}},Le=()=>{const o=N(),{hasOnlyOnePage:n,leftPageIndex:s,rightPageIndex:l,totalApproximatePages:i,beginAndEndAreDifferent:r}=U(),a=Math.round(((o==null?void 0:o.percentageEstimateOfBook)??0)*100),d=c=>c!=null&&c.subChapter?`${c.title} / ${d(c.subChapter)}`:(c==null?void 0:c.title)||"",f=d(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(Ee,{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:r?`${s+1} - ${l+1} of ${i}`:`${s+1} of ${i}`}),!!(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=h.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=h.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}=U(),i=n?Math.floor((s||0)/2):s,[r,a]=u.useSignalState(()=>u.signal({default:i||0})),d=0,f=Math.max(0,n?Math.floor((l-1)/2):l-1);return h.useEffect(()=>{a.update(i||0)},[i,a]),{value:r,valueSignal:a,min:d,max:f}},Ne=o=>{const n=C(),s=N(),{manifest:l}=u.useObserve(()=>n==null?void 0:n.context.state$,[n])??{},i=(l==null?void 0:l.readingDirection)==="rtl",r=s==null?void 0:s.isUsingSpread,{totalApproximatePages:a=0,isBeginWithinChapter:d}=U(),f=1,c=d,{value:b,valueSignal:g,min:S,max:k}=_e(),T=h.useCallback(P=>{const[I=0]=Array.isArray(P)?P:[P];g.setValue(I);const D=r?Math.floor(I)*2:Math.floor(I);c?n==null||n.navigation.goToPageOfSpineItem({pageIndex:D,spineItemId:n.pagination.state.beginSpineItemIndex??0,animation:!1}):n==null||n.navigation.goToAbsolutePageIndex({absolutePageIndex:D,animation:!1})},[n,r,g,c]);return u.useSubscribe(()=>n==null?void 0:n.navigation.throttleLock({duration:100,trigger:g.subject}),[n,g]),a===1||r&&a===2?e.jsx(t.Box,{style:o.style}):e.jsx(me,{value:[b],max:k,min:S,reverse:i,step:f,onChange:T,...o})},$e=h.memo(({open:o,onItemClick:n})=>{const s=C(),l=u.useObserve(()=>s==null?void 0:s.navigation.state$,[s]),i=u.useObserve(()=>s==null?void 0:s.settings.values$,[s]),r=(i==null?void 0:i.computedPageTurnDirection)==="vertical",[a,d]=h.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:r?e.jsx(H.RxDoubleArrowUp,{}):e.jsx(H.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:r?e.jsx(H.RxDoubleArrowDown,{}):e.jsx(H.RxDoubleArrowRight,{})})]}),e.jsx(t.HStack,{alignSelf:"stretch",alignItems:"center",justifyContent:"center",children:e.jsxs(t.Collapsible.Root,{open:a,flex:1,onOpenChange:({open:f})=>{d(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,{})}),V(s)&&e.jsx(t.IconButton,{"aria-label":"Search",size:"lg",variant:"ghost",onClick:()=>n("bookmarks"),children:e.jsx(F.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]=h.useState(!1),s=h.useCallback(()=>document.fullscreenElement?document.exitFullscreen().catch(console.error).then(()=>{n(!1)}):document.documentElement.requestFullscreen({navigationUI:"hide"}).catch(console.error).then(()=>{n(!0)}),[]);return h.useEffect(()=>{function l(){n(!!document.fullscreenElement)}return document.addEventListener("fullscreenchange",l),()=>{document.removeEventListener("fullscreenchange",l)}},[]),{isFullscreen:o,onToggleFullscreenClick:s}},Fe=h.memo(({open:o,onItemClick:n})=>{const s=C(),l=u.useObserve(()=>s==null?void 0:s.context.manifest$,[s]),{isFullscreen:i,onToggleFullscreenClick:r}=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(Q.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(Q.IoMdMore,{})}),e.jsx(t.IconButton,{"aria-label":"right",size:"lg",flexShrink:0,variant:"ghost",onClick:r,children:i?e.jsx(K.MdFullscreenExit,{}):e.jsx(K.MdFullscreen,{})})]})]})}),qe=h.memo(({onItemClick:o})=>{const[n]=Y();return e.jsxs(e.Fragment,{children:[e.jsx(Fe,{open:n,onItemClick:o}),e.jsx($e,{open:n,onItemClick:o})]})}),Ve=h.memo(({contextText:o="",startOffset:n=0,text:s,cfi:l="#",onClick:i,absolutePageIndex:r})=>{const d=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:c=>{c.preventDefault(),i(l)},display:"flex",flexDirection:"column",alignItems:"flex-start",gap:0,children:[e.jsxs(t.Text,{lineClamp:1,as:"cite",style:{display:"block"},children:['"',d,e.jsx("b",{children:s}),f,'"']}),e.jsx(t.Text,{fontSize:"sm",color:"gray.500",style:{textDecoration:"none"},children:`Book page: ${r!==void 0?r+1:"unknown (not loaded)"}`})]})}),Ge=h.memo(({onNavigate:o})=>{const[n,s]=h.useState(""),l=C(),i=X(l)?l:void 0,r=g=>{s(g.target.value)},a=h.useCallback(g=>{o(),l==null||l.navigation.goToCfi(g)},[l,o]),d=u.useObserve(()=>i==null?void 0:i.search.search(n).pipe(p.map(g=>({type:"end",data:g})),p.startWith({type:"start"})),[l,n]),f=(d==null?void 0:d.type)==="start",c=(d==null?void 0:d.type)==="end"?d.data:[],b=u.useObserve(()=>l==null?void 0:l.locateResource(c.slice(0,100)),[c]);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:r,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&&c.length===0&&e.jsx("p",{children:"There are no results"}),!f&&c.length>=0&&e.jsxs(t.Stack,{children:[e.jsxs(t.Heading,{as:"h2",size:"md",children:[c.length," result(s)"]}),e.jsx(t.Stack,{gap:0,children:b==null?void 0:b.map((g,S)=>{var k,T,w,P,I,D,y;return e.jsx(Ve,{contextText:((w=(T=(k=g.meta)==null?void 0:k.range)==null?void 0:T.startContainer.parentElement)==null?void 0:w.textContent)??"",pageIndex:(P=g.meta)==null?void 0:P.itemPageIndex,startOffset:((D=(I=g.meta)==null?void 0:I.range)==null?void 0:D.startOffset)??0,text:n,cfi:g.meta.cfi,onClick:a,absolutePageIndex:(y=g.meta)==null?void 0:y.absolutePageIndex},S)})})]})]})]})}),Ye=h.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(B,{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(E,{})]})})),Ue=h.memo(({onNavigate:o})=>{const n=C(),{manifest:s,assumedRenditionLayout:l}=u.useObserve(()=>n==null?void 0:n.context.state$,[n])??{},{nav:i}=s??{},r=N();i!=null&&i.toc;const{beginSpineItemIndex:a,beginPageIndexInSpineItem:d}=r??{},f=(l==="reflowable"?d:a)||0;console.log({assumedRenditionLayout:l,currentSpineItemOrChapterPageIndex:f});let c=r==null?void 0:r.beginChapterInfo;for(;c!=null&&c.subChapter;)c=c==null?void 0:c.subChapter;const b=(g,S,k)=>e.jsxs(h.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(g.href)},href:"#",children:[(c==null?void 0:c.path)===g.path&&e.jsx(t.List.Indicator,{asChild:!0,children:e.jsx(x.LuCircleCheck,{})}),(c==null?void 0:c.path)!==g.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:g.title||g.path}),(c==null?void 0:c.path)===g.path&&e.jsx(t.Text,{fontStyle:"italic",fontWeight:"bold",fontSize:"sm",children:`Currently on page ${f+1}`})]})]})}),g.contents.length>0&&e.jsx(t.List.Root,{as:"div",gap:2,children:g.contents.map((T,w)=>b(T,w,k+1))})]},S);return e.jsx(t.List.Root,{gap:3,overflowY:"auto",py:4,flex:1,children:i==null?void 0:i.toc.map((g,S)=>b(g,S,0))})}),Qe=h.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(B,{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(E,{})]})})),Ke=({enableFloatingTime:o=!0,enableFloatingProgress:n=!0,onItemClick:s})=>{const[l,i]=h.useState(!1),[r,a]=h.useState(!1),[d,f]=h.useState(!1),[c,b]=h.useState(!1),[g,S]=h.useState(!1),[k,T]=h.useState(!1),[w,P]=Y(),I=h.useCallback(()=>{i(!1),a(!1),f(!1),b(!1),S(!1),P(!1),T(!1)},[P]),D=h.useCallback(y=>{y==="annotations"?b(!0):y==="search"?f(!0):y==="help"?a(!0):y==="toc"?i(!0):y==="bookmarks"?S(!0):y==="gallery"&&T(!0),s==null||s(y)},[s]);return ye(),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:T}),e.jsx(qe,{onItemClick:D}),e.jsx(ae,{}),e.jsx(Ce,{open:r,setOpen:a}),e.jsx(Qe,{open:l,setOpen:i,onNavigate:I}),e.jsx(Ye,{open:d,setOpen:f,onNavigate:I}),e.jsx(ie,{open:c,setOpen:b,onNavigate:I}),e.jsx(de,{open:g,setOpen:S,onNavigate:I}),e.jsx(t.Presence,{present:o||w,animationName:{_open:"fade-in",_closed:"fade-out"},animationDuration:"slow",overflow:"hidden",children:e.jsx(Te,{})}),e.jsx(he,{})]})};v.ReactReader=Ke,v.ReactReaderProvider=te,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})});
2
2
  //# sourceMappingURL=index.umd.cjs.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@prose-reader/react-reader",
3
3
  "private": false,
4
- "version": "1.219.0",
4
+ "version": "1.220.0",
5
5
  "type": "module",
6
6
  "types": "./dist/index.d.ts",
7
7
  "exports": {
@@ -53,5 +53,5 @@
53
53
  "optional": true
54
54
  }
55
55
  },
56
- "gitHead": "8723de00587d0979a2a3050e4883251aa439c73c"
56
+ "gitHead": "4ab5c006338689ec5d7e161a90b83e18d91d3923"
57
57
  }