@prose-reader/react-reader 1.231.0 → 1.233.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/annotations/bookmarks/BookmarkPageMarkers.d.ts +1 -0
- package/dist/annotations/useReaderWithAnnotations.d.ts +14 -15
- package/dist/common/useSpineItemReady.d.ts +4 -1
- package/dist/context/useReader.d.ts +14 -15
- package/dist/index.js +96 -102
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +1 -1
- package/dist/index.umd.cjs.map +1 -1
- package/package.json +2 -2
- package/dist/annotations/bookmarks/Bookmarks.d.ts +0 -1
package/dist/index.umd.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(b,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("react/jsx-runtime"),require("react"),require("reactjrx"),require("rxjs"),require("@chakra-ui/react"),require("react-icons/lu"),require("react-dom"),require("@prose-reader/enhancer-gestures"),require("@prose-reader/core"),require("react-icons/bs"),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","@prose-reader/enhancer-gestures","@prose-reader/core","react-icons/bs","react-icons/ri","react-icons/rx","react-icons/hi","rc-slider","rc-slider/assets/index.css","react-icons/io","react-icons/md"],o):(b=typeof globalThis<"u"?globalThis:b||self,o(b["prose-react-reader"]={},b.jsxRuntime,b.React,b.reactjrx,b.rxjs,b.react,b.lu,b.reactDom,b.enhancerGestures,b.core,b.bs,b.ri,b.rx,b.hi,b.RcSlider,null,b.io,b.md))})(this,function(b,o,a,u,g,t,I,ee,oe,q,ne,se,N,te,re,ro,U,Y){"use strict";function le(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const r=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(n,s,r.get?r:{enumerable:!0,get:()=>e[s]})}}return n.default=e,Object.freeze(n)}const w=le(a),K=a.createContext({reader:void 0,quickMenuSignal:u.signal({default:!1}),notificationsSubject:new g.Subject}),ie=a.memo(({children:e,reader:n,quickMenuOpen:s,onQuickMenuOpenChange:r})=>{const[,l]=u.useSignalState(()=>u.signal({default:s})),i=u.useConstant(()=>new g.Subject),h=u.useLiveRef(r),c=a.useMemo(()=>({quickMenuSignal:l,reader:n,notificationsSubject:i}),[l,n,i]);return a.useEffect(()=>{l.setValue(s)},[s,l]),u.useSubscribe(()=>l.pipe(g.tap(h.current)),[l,h]),o.jsx(K.Provider,{value:c,children:e})}),ae=w.forwardRef(function(n,s){return o.jsx(t.IconButton,{variant:"ghost","aria-label":"Close",ref:s,...n,children:n.children??o.jsx(I.LuX,{})})}),m=w.forwardRef(function(n,s){const{children:r,portalled:l=!0,portalRef:i,backdrop:h=!0,...c}=n;return o.jsxs(t.Portal,{disabled:!l,container:i,children:[h&&o.jsx(t.Dialog.Backdrop,{}),o.jsx(t.Dialog.Positioner,{children:o.jsx(t.Dialog.Content,{ref:s,...c,asChild:!1,children:r})})]})}),B=w.forwardRef(function(n,s){return o.jsx(t.Dialog.CloseTrigger,{position:"absolute",top:"2",insetEnd:"2",...n,asChild:!0,children:o.jsx(ae,{size:"sm",ref:s,children:n.children})})}),D=t.Dialog.Root,A=t.Dialog.Footer,E=t.Dialog.Header,L=t.Dialog.Body;t.Dialog.Backdrop;const M=t.Dialog.Title;t.Dialog.Description,t.Dialog.Trigger;const z=t.Dialog.ActionTrigger,_=()=>a.useContext(K),v=()=>{const{reader:e}=_();return e},Q=e=>!!e&&"__PROSE_READER_ENHANCER_SEARCH"in e,$=e=>!!e&&"__PROSE_READER_ENHANCER_ANNOTATIONS"in e,Z=e=>!!e&&"__PROSE_READER_ENHANCER_GALLERY"in e,ce=e=>{const n=v(),s=$(n)?n:void 0;return{data:u.useObserve(()=>s==null?void 0:s.annotations.annotations$.pipe(g.map(l=>l.find(i=>i.id===e)),g.filter(u.isDefined),g.switchMap(l=>s.locateResource(l))),[s])}},X=({id:e,onNavigate:n})=>{var l,i;const s=v(),{data:r}=ce(e);return o.jsx(t.List.Item,{children:o.jsxs(t.Link,{href:"#",onClick:()=>{n(),s==null||s.navigation.goToCfi((r==null?void 0:r.meta.cfi)??"")},children:[(l=r==null?void 0:r.resource)!=null&&l.notes?o.jsx(t.List.Indicator,{asChild:!0,children:o.jsx(I.LuNotebookPen,{})}):o.jsx(t.List.Indicator,{asChild:!0,visibility:"hidden",children:o.jsx(I.LuNotebookPen,{})}),o.jsxs(t.Stack,{gap:0,children:[o.jsx(t.Text,{lineClamp:2,fontSize:"md",children:r!=null&&r.meta.range?r==null?void 0:r.meta.range.toString():o.jsx("i",{children:o.jsx("b",{children:"unknown (not loaded)"})})}),o.jsx(t.Text,{fontStyle:"italic",fontWeight:"bold",fontSize:"sm",children:`Book page: ${((i=r==null?void 0:r.meta)==null?void 0:i.absolutePageIndex)!==void 0?r.meta.absolutePageIndex+1:"unknown (not loaded)"}`})]})]})})},F=()=>{const e=v(),n=$(e)?e:void 0;return{data:u.useObserve(()=>n==null?void 0:n.annotations.annotations$.pipe(g.switchMap(r=>n.locateResource(r))),[n])}},de=({onNavigate:e})=>{const{data:n}=F();return o.jsx(t.List.Root,{overflowY:"auto",gap:3,pt:4,variant:"plain",children:n==null?void 0:n.map(s=>o.jsx(X,{id:s.resource.id,onNavigate:e},s.resource.id))})},he=()=>{const{data:e}=F();return{data:e==null?void 0:e.filter(n=>!n.meta.range)}},ge=({onNavigate:e})=>{const{data:n}=he();return o.jsx(t.List.Root,{overflowY:"auto",gap:3,pt:4,variant:"plain",children:n==null?void 0:n.map(s=>o.jsx(X,{id:s.resource.id,onNavigate:e},s.resource.id))})},pe=a.memo(({onNavigate:e,defaultTab:n})=>{const[s,r]=a.useState(n??"bookmarks");return o.jsxs(t.Tabs.Root,{value:s,onValueChange:l=>r(l.value),children:[o.jsxs(t.Tabs.List,{children:[o.jsxs(t.Tabs.Trigger,{value:"bookmarks",children:[o.jsx(I.LuBookmark,{}),"Bookmarks"]}),o.jsxs(t.Tabs.Trigger,{value:"annotations",children:[o.jsx(I.LuNotebookPen,{}),"Annotations"]}),o.jsx(t.Tabs.Indicator,{})]}),o.jsx(t.Tabs.Content,{value:"bookmarks",children:o.jsx(ge,{onNavigate:e})}),o.jsx(t.Tabs.Content,{value:"annotations",children:o.jsx(de,{onNavigate:e})})]})}),fe=a.memo(({openWith:e,setOpen:n,onNavigate:s})=>o.jsx(D,{lazyMount:!0,placement:"center",open:!!e,onOpenChange:r=>n(r.open),size:{mdDown:"full",md:"lg"},scrollBehavior:"inside",children:o.jsxs(m,{height:"100%",children:[o.jsx(E,{children:o.jsx(M,{children:"Annotations"})}),o.jsx(L,{flex:1,children:o.jsx(pe,{onNavigate:s,defaultTab:e})}),o.jsx(A,{children:o.jsx(z,{asChild:!0,children:o.jsx(t.Button,{variant:"outline",children:"Cancel"})})}),o.jsx(B,{})]})})),ue=a.memo(({children:e})=>{const n=v(),s=u.useObserve(()=>n==null?void 0:n.spine.element$,[n]);return s?o.jsx(o.Fragment,{children:ee.createPortal(e,s)}):null}),be=({absolutePageIndex:e,itemIndex:n})=>{const s=v(),r=u.useObserve(()=>s==null?void 0:s.spine.spineItemsManager.items$,[s]);return{spineItem:a.useMemo(()=>{if(n!==void 0)return s==null?void 0:s.spine.spineItemsManager.get(n);if(e!==void 0){const{itemIndex:i}=(s==null?void 0:s.spine.locator.getSpineInfoFromAbsolutePageIndex({absolutePageIndex:e}))??{};return s==null?void 0:s.spine.spineItemsManager.get(i)}},[n,e,s,r])}},ve=({absolutePageIndex:e,itemIndex:n})=>{const{spineItem:s}=be({absolutePageIndex:e,itemIndex:n});return u.useObserve(()=>(s==null?void 0:s.isReady$)??g.of(!1),[s])},J="data-bookmark-area",Se=a.memo(({absolutePageIndex:e,left:n,top:s,width:r})=>{const l=ve({absolutePageIndex:e}),{data:i}=F(),h=i==null?void 0:i.find(f=>{var d;return((d=f==null?void 0:f.meta)==null?void 0:d.absolutePageIndex)===e&&f.meta.range===void 0});if(!l)return null;const c=r*.1/2;return o.jsx(t.Presence,{present:!!h,lazyMount:!0,animationName:{_open:"fade-in",_closed:"fade-out"},animationDuration:"moderate",children:o.jsx(t.Box,{"data-bookmark-area":J,position:"absolute",left:n+r,transform:"translateX(-100%)",pointerEvents:"none",top:s,width:c,height:c,_before:{content:'""',position:"absolute",top:0,left:0,width:0,height:0,borderTop:`${c}px solid #03030373`,borderLeft:`${c}px solid transparent`}})})}),Te=a.memo(()=>{const e=v(),n=u.useObserve(()=>e==null?void 0:e.layoutInfo$,[e]);return o.jsx(ue,{children:n==null?void 0:n.pages.map(({absoluteLayout:{left:s,top:r,width:l}},i)=>o.jsx(Se,{absolutePageIndex:i,left:s,top:r,width:l},i))})}),Ce=()=>{const e=v();return $(e)?e:void 0},Ie=()=>{const e=Ce(),{data:n}=F();a.useEffect(()=>e?e.gestures.hooks.register("beforeTapGesture",({event$:r})=>r.pipe(g.withLatestFrom(e==null?void 0:e.annotations.candidates$),g.map(([l,i])=>{if(!l.page)return!0;const{spineItem:h,spineItemPageIndex:c,spineItemPagePosition:f,pageSize:d}=l.page;if(oe.isPositionInArea(f,{type:"corner",corner:"top-right",size:10,unit:"%"},d)){const p=e.spine.pages.fromSpineItemPageIndex(h,c);if(!p)return!0;const T=n==null?void 0:n.find(k=>{var y;return((y=k==null?void 0:k.meta)==null?void 0:y.absolutePageIndex)===p.absolutePageIndex&&k.meta.range===void 0});if(T)return e==null||e.annotations.delete(T.resource.id),!1;if(i==null?void 0:i[p.absolutePageIndex])return e==null||e.annotations.annotateAbsolutePage({absolutePageIndex:p.absolutePageIndex}),!1}return!0}))):void 0,[e,n])},W=t.createToaster({placement:"bottom-end",pauseOnPageIdle:!0}),ke=()=>o.jsx(t.Portal,{children:o.jsx(t.Toaster,{toaster:W,insetInline:{mdDown:"4"},children:e=>{var n;return o.jsxs(t.Toast.Root,{width:{md:"sm"},children:[e.type==="loading"?o.jsx(t.Spinner,{size:"sm",color:"blue.solid"}):o.jsx(t.Toast.Indicator,{}),o.jsxs(t.Stack,{gap:"1",flex:"1",maxWidth:"100%",children:[e.title&&o.jsx(t.Toast.Title,{children:e.title}),e.description&&o.jsx(t.Toast.Description,{children:e.description})]}),e.action&&o.jsx(t.Toast.ActionTrigger,{children:e.action.label}),((n=e.meta)==null?void 0:n.closable)&&o.jsx(t.Toast.CloseTrigger,{})]})}})}),Pe={x:0,y:0,width:0,height:0,top:0,left:0,bottom:0,right:0};function ye(){const[e,n]=a.useState(null),[s,r]=a.useState(Pe),l=a.useMemo(()=>new ResizeObserver(i=>{if(i[0]){const{x:h,y:c,width:f,height:d,top:S,left:p,bottom:T,right:P}=i[0].contentRect;r({x:h,y:c,width:f,height:d,top:S,left:p,bottom:T,right:P})}}),[]);return a.useLayoutEffect(()=>{if(e)return l.observe(e),()=>{l.disconnect()}},[e,l]),[n,s,e]}const xe=(e,n,s)=>{const r=v(),l=Z(r)?r:void 0;u.useSubscribe(()=>{if(!l||!e)return g.NEVER;const i=n.layout.layout$.pipe(g.startWith(n.layout.layoutInfo),g.distinctUntilChanged(q.isShallowEqual)),h=q.observeIntersection(e).pipe(g.map(c=>c.some(f=>f.isIntersecting)));return i.pipe(g.throttleTime(100,void 0,{trailing:!0}),g.switchMap(()=>h.pipe(g.tap(c=>{c||(e.innerHTML="")}),g.filter(c=>c),g.first()).pipe(g.switchMap(()=>(e.innerHTML="",l==null?void 0:l.gallery.snapshot(n,e,s))))))},[l,n,s,e])},we=a.memo(({item:e,onNavigated:n})=>{var c;const[s,r,l]=ye(),i=v();xe(l,e,r);const h=u.useObserve(()=>i==null?void 0:i.locateResource(e,{mode:"shallow"}),[i,e]);return o.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(),i==null||i.navigation.goToSpineItem({indexOrId:e})},children:[o.jsx(t.Box,{height:"100%",width:"100%",overflow:"hidden",pointerEvents:"none",ref:s}),o.jsxs(t.Text,{position:"absolute",bottom:0,left:"0",right:"0",textAlign:"center",bgColor:"white",p:4,fontSize:"xs",children:["Page ",(((c=h==null?void 0:h.meta)==null?void 0:c.absolutePageIndex)??0)+1]})]})}),Oe=a.memo(({open:e,setOpen:n})=>{const s=v(),r=u.useObserve(()=>s==null?void 0:s.spineItemsManager.items$,[s]);return o.jsx(D,{lazyMount:!0,placement:"center",open:e,onOpenChange:l=>n(l.open),size:{mdDown:"full",md:"lg"},scrollBehavior:"inside",children:o.jsxs(m,{height:"100%",children:[o.jsx(E,{children:o.jsx(M,{children:"Gallery"})}),o.jsx(L,{children:o.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:r==null?void 0:r.map(l=>o.jsx(we,{item:l,onNavigated:()=>{n(!1)}},l.item.id))})}),o.jsx(A,{children:o.jsx(z,{asChild:!0,children:o.jsx(t.Button,{variant:"outline",children:"Cancel"})})}),o.jsx(B,{})]})})}),me="@prose-reader/react-reader",Be="1.230.0",De=a.memo(({open:e,setOpen:n})=>o.jsx(D,{lazyMount:!0,placement:"center",open:e,onOpenChange:s=>n(s.open),size:{mdDown:"full",md:"lg"},scrollBehavior:"inside",children:o.jsxs(m,{children:[o.jsx(E,{children:o.jsx(M,{children:"Help"})}),o.jsxs(L,{overflowY:"auto",flex:1,children:[o.jsx(t.Heading,{mb:2,as:"h3",size:"lg",children:"Shortcuts"}),o.jsxs(t.HStack,{mb:1,children:[o.jsx(t.Kbd,{children:o.jsx(I.LuArrowBigRight,{})})," ",o.jsx(t.Text,{children:"Navigate to right page"})]}),o.jsxs(t.HStack,{mb:1,children:[o.jsx(t.Kbd,{children:o.jsx(I.LuArrowBigLeft,{})})," ",o.jsx(t.Text,{children:"Navigate to left page"})]}),o.jsx(t.Heading,{mb:2,mt:4,as:"h3",size:"lg",children:"About"}),o.jsxs(t.Text,{children:[me," version: ",Be]})]}),o.jsx(A,{children:o.jsx(z,{asChild:!0,children:o.jsx(t.Button,{variant:"outline",children:"Cancel"})})}),o.jsx(B,{})]})})),O=()=>{const e=v();return u.useObserve(()=>e?g.combineLatest([e.pagination.state$,e.context.state$]).pipe(g.map(([n,s])=>{var l;const r=(l=s.manifest)==null?void 0:l.spineItems.every(i=>{var h;return(h=i.mediaType)==null?void 0:h.startsWith("image/")});return{...n,hasChapters:!s.isFullyPrePaginated&&!r}})):g.NEVER,[e])},Ae=()=>{const e=O(),n=Math.floor(((e==null?void 0:e.percentageEstimateOfBook)??0)*100),s=n>0?n:1;return(e==null?void 0:e.percentageEstimateOfBook)===void 0?null:o.jsx(t.Box,{position:"absolute",right:0,bottom:0,p:2,color:"black",children:o.jsxs(t.Text,{fontSize:"sm",children:[s," %"]})})},Ee=()=>{const[e,n]=a.useState(new Date);return a.useEffect(()=>{const s=setInterval(()=>{n(new Date)},6e4);return()=>clearInterval(s)},[]),e},Le=e=>{const n=Ee();return o.jsx(t.Text,{fontSize:"xs",...e,children:n.toLocaleTimeString(navigator.language,{hour:"2-digit",minute:"2-digit"})})},G=()=>{const{quickMenuSignal:e}=_();return[u.useSignalValue(e),e.setValue,e]},Me=()=>{const[e]=G();return o.jsx(t.Box,{position:"absolute",left:0,bottom:0,p:2,color:e?void 0:"colorPalette.contrast",children:o.jsx(Le,{})})},ze=()=>{const e=v();u.useSubscribe(()=>e==null?void 0:e.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")}}),[e])},_e=()=>{const e=v(),{notificationsSubject:n}=_();u.useSubscribe(()=>e==null?void 0:e.zoom.isZooming$.pipe(g.switchMap(s=>{if(!s)return g.EMPTY;const r=new g.Subject;return n.next({key:"zoom",title:"Zooming",duration:999999,abort:r}),g.NEVER.pipe(g.finalize(()=>{r.next(),r.complete()}))})),[e])},$e=()=>{const e=v(),{notificationsSubject:n}=_();u.useSubscribe(()=>e==null?void 0:e.settings.values$.pipe(g.map(({fontScale:s})=>s),g.distinctUntilChanged(),g.skip(1),g.tap(s=>{n.next({key:"fontScaleChange",title:"Font size changed",description:`${s*100} %`})})),[e,n])},He=()=>{const{notificationsSubject:e}=_();$e(),_e(),u.useSubscribe(()=>e.pipe(g.filter(u.isDefined),g.mergeMap(n=>{const s=n.duration??3e3,r=W.create({title:n.title,description:n.description,duration:s}),l=e.pipe(g.skip(1),g.filter(i=>!!n.key&&(i==null?void 0:i.key)===n.key));return g.merge(g.timer(s),n.abort??g.NEVER,l).pipe(g.first(),g.finalize(()=>{W.dismiss(r)}))})),[e])},Ne=w.forwardRef(function(n,s){const{showArrow:r,children:l,portalled:i=!0,content:h,portalRef:c,...f}=n;return o.jsxs(t.Popover.Root,{...f,positioning:{...f.positioning,gutter:4},children:[o.jsx(t.Popover.Trigger,{asChild:!0,children:l}),o.jsx(t.Portal,{disabled:!i,container:c,children:o.jsx(t.Popover.Positioner,{children:o.jsxs(t.Popover.Content,{width:"auto",px:"2",py:"1",textStyle:"xs",rounded:"sm",ref:s,children:[r&&o.jsx(t.Popover.Arrow,{children:o.jsx(t.Popover.ArrowTip,{})}),h]})})})]})}),Fe=w.forwardRef(function(n,s){const{children:r,...l}=n;return o.jsx(Ne,{content:r,...l,ref:s,children:o.jsx(t.IconButton,{variant:"ghost","aria-label":"info",size:"2xs",colorPalette:"gray",children:o.jsx(te.HiOutlineInformationCircle,{})})})}),qe=w.forwardRef(function(n,s){return o.jsx(t.Progress.Track,{...n,ref:s,children:o.jsx(t.Progress.Range,{})})});w.forwardRef(function(n,s){const{children:r,info:l,...i}=n;return o.jsxs(t.Progress.Label,{...i,ref:s,children:[r,l&&o.jsx(Fe,{children:l})]})});const We=t.Progress.Root,Ge=t.Progress.ValueText,V=()=>{const e=O(),n=(e==null?void 0:e.numberOfTotalPages)===1,s=((e==null?void 0:e.beginNumberOfPagesInSpineItem)??0)>1,r=((e==null?void 0:e.endNumberOfPagesInSpineItem)??0)>1,l=(e!=null&&e.hasChapters?e==null?void 0:e.beginPageIndexInSpineItem:e==null?void 0:e.beginAbsolutePageIndex)??0,i=(e!=null&&e.hasChapters?e==null?void 0:e.endPageIndexInSpineItem:e==null?void 0:e.endAbsolutePageIndex)??0,[h=0,c=0]=[l,i].sort((S,p)=>S-p),f=(e==null?void 0:e.beginPageIndexInSpineItem)!==(e==null?void 0:e.endPageIndexInSpineItem)||(e==null?void 0:e.beginSpineItemIndex)!==(e==null?void 0:e.endSpineItemIndex),d=e!=null&&e.hasChapters?e==null?void 0:e.beginNumberOfPagesInSpineItem:e==null?void 0:e.numberOfTotalPages;return{hasOnlyOnePage:n,beginPageIndex:l,endPageIndex:i,isBeginWithinChapter:s,isEndWithinChapter:r,beginAndEndAreDifferent:f,totalApproximatePages:d,leftPageIndex:h,rightPageIndex:c}},Ve=()=>{const e=O(),{hasOnlyOnePage:n,leftPageIndex:s,rightPageIndex:r,totalApproximatePages:l,beginAndEndAreDifferent:i}=V(),h=Math.round(((e==null?void 0:e.percentageEstimateOfBook)??0)*100),c=d=>d!=null&&d.subChapter?`${d.title} / ${c(d.subChapter)}`:(d==null?void 0:d.title)||"",f=c(e==null?void 0:e.beginChapterInfo);return o.jsxs(t.Stack,{alignItems:"center",gap:1,maxW:"100%",overflow:"auto",children:[o.jsx(We,{value:h,size:"xs",width:150,children:o.jsxs(t.HStack,{justifyContent:"space-between",children:[o.jsx(qe,{width:110}),o.jsx(Ge,{children:`${h}%`})]})}),o.jsx(t.Text,{truncate:!0,maxWidth:"100%",fontSize:"sm",mt:1,children:f?`Chapter: ${f}`:" "}),!n&&o.jsxs(t.HStack,{children:[o.jsx(t.Text,{fontSize:"xs",children:i?`${s+1} - ${r+1} of ${l}`:`${s+1} of ${l}`}),!!(e!=null&&e.hasChapters)&&o.jsxs(o.Fragment,{children:[o.jsx(t.Text,{children:"-"}),o.jsxs(t.Text,{fontSize:"xs",children:["(",((e==null?void 0:e.beginAbsolutePageIndex)??0)+1,")"]})]})]})]})},j=a.memo(({children:e,position:n,...s})=>o.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:e})),Ue=t.chakra(re),Ye=a.memo(e=>o.jsx(t.Box,{display:"contents",css:{"--bg":"colors.bg","--bg-emphasized":"colors.bg.emphasized","--color-solid":"colors.colorPalette.solid"},children:o.jsx(Ue,{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(${e.reverse?"50%":"-50%"}, -50%)`,backgroundColor:"var(--bg)",marginTop:"0px"}},...e})})),Ke=()=>{const e=O(),n=e==null?void 0:e.isUsingSpread,{beginPageIndex:s,totalApproximatePages:r=0}=V(),l=n?Math.floor((s||0)/2):s,[i,h]=u.useSignalState(()=>u.signal({default:l||0})),c=0,f=Math.max(0,n?Math.floor((r-1)/2):r-1);return a.useEffect(()=>{h.update(l||0)},[l,h]),{value:i,valueSignal:h,min:c,max:f}},Qe=e=>{const n=v(),s=O(),{manifest:r}=u.useObserve(()=>n==null?void 0:n.context.state$,[n])??{},l=(r==null?void 0:r.readingDirection)==="rtl",i=s==null?void 0:s.isUsingSpread,{totalApproximatePages:h=0,isBeginWithinChapter:c}=V(),f=1,d=c,{value:S,valueSignal:p,min:T,max:P}=Ke(),k=a.useCallback(x=>{const[C=0]=Array.isArray(x)?x:[x];p.setValue(C);const H=i?Math.floor(C)*2:Math.floor(C);d?n==null||n.navigation.goToPageOfSpineItem({pageIndex:H,spineItemId:n.pagination.state.beginSpineItemIndex??0,animation:!1}):n==null||n.navigation.goToAbsolutePageIndex({absolutePageIndex:H,animation:!1})},[n,i,p,d]);return u.useSubscribe(()=>n==null?void 0:n.navigation.throttleLock({duration:100,trigger:p.subject}),[n,p]),h===1||i&&h===2?o.jsx(t.Box,{style:e.style}):o.jsx(Ye,{value:[S],max:P,min:T,reverse:l,step:f,onChange:k,...e})},Ze=a.memo(({open:e,onItemClick:n})=>{const s=v(),r=u.useObserve(()=>s==null?void 0:s.navigation.state$,[s]),l=u.useObserve(()=>s==null?void 0:s.settings.values$,[s]),i=(l==null?void 0:l.computedPageTurnDirection)==="vertical",[h,c]=a.useState(!0);return o.jsxs(j,{present:e,position:"bottom",display:"flex",flexDirection:"column",overflow:"auto",pb:8,children:[o.jsxs(t.HStack,{flex:1,alignItems:"center",justifyContent:"center",maxWidth:"100%",children:[o.jsx(t.IconButton,{"aria-label":"left",size:"lg",variant:"ghost",flexShrink:0,onClick:()=>s==null?void 0:s.navigation.goToLeftOrTopSpineItem(),disabled:!(r!=null&&r.canGoLeftSpineItem)&&!(r!=null&&r.canGoTopSpineItem),children:i?o.jsx(N.RxDoubleArrowUp,{}):o.jsx(N.RxDoubleArrowLeft,{})}),o.jsxs(t.Stack,{flex:1,maxW:400,gap:2,alignItems:"center",overflow:"auto",px:4,children:[o.jsx(Ve,{}),o.jsx(Qe,{style:{width:"100%",maxWidth:"300px",height:"35px"}})]}),o.jsx(t.IconButton,{"aria-label":"right",size:"lg",flexShrink:0,variant:"ghost",disabled:!(r!=null&&r.canGoRightSpineItem)&&!(r!=null&&r.canGoBottomSpineItem),onClick:()=>{s==null||s.navigation.goToRightOrBottomSpineItem()},children:i?o.jsx(N.RxDoubleArrowDown,{}):o.jsx(N.RxDoubleArrowRight,{})})]}),o.jsx(t.HStack,{alignSelf:"stretch",alignItems:"center",justifyContent:"center",children:o.jsxs(t.Collapsible.Root,{open:h,flex:1,onOpenChange:({open:f})=>{c(f)},children:[o.jsx(t.Collapsible.Trigger,{paddingY:"3",width:"100%",display:"flex",justifyContent:"center",children:o.jsx(I.LuChevronDown,{style:{transform:h?"rotate(0deg)":"rotate(180deg)"}})}),o.jsxs(t.Collapsible.Content,{display:"flex",justifyContent:"center",children:[o.jsx(t.IconButton,{"aria-label":"Help",size:"lg",variant:"ghost",onClick:()=>n("help"),children:o.jsx(I.LuCircleHelp,{})}),o.jsx(t.IconButton,{"aria-label":"Table of contents",size:"lg",variant:"ghost",onClick:()=>n("toc"),children:o.jsx(I.LuTableOfContents,{})}),Q(s)&&o.jsx(t.IconButton,{"aria-label":"Search",size:"lg",variant:"ghost",onClick:()=>n("search"),children:o.jsx(I.LuSearch,{})}),$(s)&&o.jsx(t.IconButton,{"aria-label":"Bookmarks",size:"lg",variant:"ghost",onClick:()=>n("bookmarks"),children:o.jsx(ne.BsBookmarks,{})}),$(s)&&o.jsx(t.IconButton,{"aria-label":"Annotations",size:"lg",variant:"ghost",onClick:()=>n("annotations"),children:o.jsx(I.LuNotebookPen,{})}),o.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:o.jsx(I.LuGalleryHorizontal,{})}),Z(s)&&o.jsx(t.IconButton,{"aria-label":"Gallery",size:"lg",variant:"ghost",onClick:()=>n("gallery"),children:o.jsx(se.RiGalleryView2,{})})]})]})})]})}),Xe=()=>{const[e,n]=a.useState(!1),s=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 r(){n(!!document.fullscreenElement)}return document.addEventListener("fullscreenchange",r),()=>{document.removeEventListener("fullscreenchange",r)}},[]),{isFullscreen:e,onToggleFullscreenClick:s}},Je=a.memo(({open:e,onItemClick:n})=>{const s=v(),r=u.useObserve(()=>s==null?void 0:s.context.manifest$,[s]),{isFullscreen:l,onToggleFullscreenClick:i}=Xe();return o.jsxs(j,{present:e,position:"top",height:"80px",justifyContent:"space-between",children:[o.jsx(t.IconButton,{"aria-label":"left",size:"lg",variant:"ghost",flexShrink:0,onClick:()=>n("back"),children:o.jsx(U.IoIosArrowBack,{})}),o.jsx(t.Stack,{flex:1,maxW:600,gap:1,alignItems:"center",overflow:"auto",px:4,children:o.jsx(t.Text,{truncate:!0,maxWidth:"100%",children:r==null?void 0:r.title})}),o.jsxs(t.HStack,{children:[o.jsx(t.IconButton,{"aria-label":"right",size:"lg",flexShrink:0,variant:"ghost",onClick:()=>n("more"),children:o.jsx(U.IoMdMore,{})}),o.jsx(t.IconButton,{"aria-label":"right",size:"lg",flexShrink:0,variant:"ghost",onClick:i,children:l?o.jsx(Y.MdFullscreenExit,{}):o.jsx(Y.MdFullscreen,{})})]})]})}),je=a.memo(({onItemClick:e})=>{const[n]=G();return o.jsxs(o.Fragment,{children:[o.jsx(Je,{open:n,onItemClick:e}),o.jsx(Ze,{open:n,onItemClick:e})]})}),Re=a.memo(({contextText:e="",startOffset:n=0,text:s,cfi:r="#",onClick:l,absolutePageIndex:i})=>{const c=e.substring(Math.max(n-15,0),Math.max(n,0)),f=e.substring(Math.min(n+s.length,e.length-1),Math.min(n+s.length+15,e.length-1));return o.jsxs(t.Link,{href:r,style:{margin:5,overflow:"hidden"},onClick:d=>{d.preventDefault(),l(r)},display:"flex",flexDirection:"column",alignItems:"flex-start",gap:0,children:[o.jsxs(t.Text,{lineClamp:1,as:"cite",style:{display:"block"},children:['"',c,o.jsx("b",{children:s}),f,'"']}),o.jsx(t.Text,{fontSize:"sm",color:"gray.500",style:{textDecoration:"none"},children:`Book page: ${i!==void 0?i+1:"unknown (not loaded)"}`})]})}),eo=a.memo(({onNavigate:e})=>{const[n,s]=a.useState(""),r=v(),l=Q(r)?r:void 0,i=p=>{s(p.target.value)},h=a.useCallback(p=>{e(),r==null||r.navigation.goToCfi(p)},[r,e]),c=u.useObserve(()=>l==null?void 0:l.search.search(n).pipe(g.map(p=>({type:"end",data:p})),g.startWith({type:"start"})),[r,n]),f=(c==null?void 0:c.type)==="start",d=(c==null?void 0:c.type)==="end"?c.data:[],S=u.useObserve(()=>r==null?void 0:r.locateResource(d.slice(0,100)),[d]);return o.jsxs(t.Stack,{flex:1,height:"100%",children:[o.jsx(t.Box,{px:4,children:o.jsx(t.Input,{placeholder:"Type something...",value:n,onChange:i,borderRadius:0})}),o.jsxs(t.Box,{px:4,pb:4,mt:2,flex:1,style:{overflow:"hidden",overflowY:"auto"},children:[f&&o.jsx(t.Text,{children:"Searching ..."}),!f&&d.length===0&&o.jsx("p",{children:"There are no results"}),!f&&d.length>=0&&o.jsxs(t.Stack,{children:[o.jsxs(t.Heading,{as:"h2",size:"md",children:[d.length," result(s)"]}),o.jsx(t.Stack,{gap:0,children:S==null?void 0:S.map((p,T)=>{var P,k,y,x,C,H,R;return o.jsx(Re,{contextText:((y=(k=(P=p.meta)==null?void 0:P.range)==null?void 0:k.startContainer.parentElement)==null?void 0:y.textContent)??"",pageIndex:(x=p.meta)==null?void 0:x.itemPageIndex,startOffset:((H=(C=p.meta)==null?void 0:C.range)==null?void 0:H.startOffset)??0,text:n,cfi:p.meta.cfi,onClick:h,absolutePageIndex:(R=p.meta)==null?void 0:R.absolutePageIndex},T)})})]})]})]})}),oo=a.memo(({open:e,setOpen:n,onNavigate:s})=>o.jsx(D,{lazyMount:!0,placement:"center",open:e,onOpenChange:r=>n(r.open),size:{mdDown:"full",md:"lg"},scrollBehavior:"inside",children:o.jsxs(m,{height:"100%",children:[o.jsx(E,{children:o.jsx(M,{children:"Search"})}),o.jsx(L,{flex:1,children:o.jsx(eo,{onNavigate:s})}),o.jsx(A,{children:o.jsx(z,{asChild:!0,children:o.jsx(t.Button,{variant:"outline",children:"Cancel"})})}),o.jsx(B,{})]})})),no=a.memo(({onNavigate:e})=>{const n=v(),{manifest:s,assumedRenditionLayout:r}=u.useObserve(()=>n==null?void 0:n.context.state$,[n])??{},{nav:l}=s??{},i=O();l!=null&&l.toc;const{beginSpineItemIndex:h,beginPageIndexInSpineItem:c}=i??{},f=(r==="reflowable"?c:h)||0;let d=i==null?void 0:i.beginChapterInfo;for(;d!=null&&d.subChapter;)d=d==null?void 0:d.subChapter;const S=(p,T,P)=>o.jsxs(a.Fragment,{children:[o.jsx(t.List.Item,{pl:4*(P+1),style:{display:"flex",alignItems:"center"},children:o.jsxs(t.Link,{onClick:()=>{e(),n==null||n.navigation.goToUrl(p.href)},href:"#",children:[(d==null?void 0:d.path)===p.path&&o.jsx(t.List.Indicator,{asChild:!0,children:o.jsx(I.LuCircleCheck,{})}),(d==null?void 0:d.path)!==p.path&&o.jsx(t.List.Indicator,{asChild:!0,visibility:"hidden",children:o.jsx(I.LuCircleCheck,{})}),o.jsxs(t.Stack,{gap:0,children:[o.jsx(t.Text,{fontSize:"md",children:p.title||p.path}),(d==null?void 0:d.path)===p.path&&o.jsx(t.Text,{fontStyle:"italic",fontWeight:"bold",fontSize:"sm",children:`Currently on page ${f+1}`})]})]})}),p.contents.length>0&&o.jsx(t.List.Root,{as:"div",gap:2,children:p.contents.map((k,y)=>S(k,y,P+1))})]},T);return o.jsx(t.List.Root,{gap:3,overflowY:"auto",py:4,flex:1,children:l==null?void 0:l.toc.map((p,T)=>S(p,T,0))})}),so=a.memo(({open:e,setOpen:n,onNavigate:s})=>o.jsx(D,{lazyMount:!0,placement:"center",open:e,onOpenChange:r=>n(r.open),size:{mdDown:"full",md:"lg"},scrollBehavior:"inside",children:o.jsxs(m,{children:[o.jsx(E,{children:o.jsx(M,{children:"Table of Contents"})}),o.jsx(L,{overflowY:"auto",flex:1,children:o.jsx(no,{onNavigate:s})}),o.jsx(A,{children:o.jsx(z,{asChild:!0,children:o.jsx(t.Button,{variant:"outline",children:"Cancel"})})}),o.jsx(B,{})]})})),to=({enableFloatingTime:e=!0,enableFloatingProgress:n=!0,onItemClick:s})=>{const[r,l]=a.useState(!1),[i,h]=a.useState(!1),[c,f]=a.useState(!1),[d,S]=a.useState(void 0),[p,T]=a.useState(!1),[P,k]=G(),y=a.useCallback(()=>{l(!1),h(!1),f(!1),S(void 0),k(!1),T(!1)},[k]),x=a.useCallback(C=>{C==="annotations"?S("annotations"):C==="search"?f(!0):C==="help"?h(!0):C==="toc"?l(!0):C==="bookmarks"?S("bookmarks"):C==="gallery"&&T(!0),s==null||s(C)},[s]);return ze(),He(),Ie(),o.jsxs(o.Fragment,{children:[n&&o.jsx(t.Presence,{present:!P,animationName:{_open:"fade-in",_closed:"fade-out"},animationDuration:"moderate",children:o.jsx(Ae,{})}),o.jsx(Oe,{open:p,setOpen:T}),o.jsx(je,{onItemClick:x}),o.jsx(Te,{}),o.jsx(De,{open:i,setOpen:h}),o.jsx(so,{open:r,setOpen:l,onNavigate:y}),o.jsx(oo,{open:c,setOpen:f,onNavigate:y}),o.jsx(fe,{openWith:d,setOpen:C=>S(C?"annotations":void 0),onNavigate:y}),o.jsx(t.Presence,{present:e||P,animationName:{_open:"fade-in",_closed:"fade-out"},animationDuration:"slow",overflow:"hidden",children:o.jsx(Me,{})}),o.jsx(ke,{})]})};b.BOOKMARK_AREA_DATA_ATTRIBUTE=J,b.ReactReader=to,b.ReactReaderProvider=ie,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(b,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("react/jsx-runtime"),require("react"),require("reactjrx"),require("rxjs"),require("@chakra-ui/react"),require("react-icons/lu"),require("react-dom"),require("@prose-reader/enhancer-gestures"),require("@prose-reader/core"),require("react-icons/bs"),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","@prose-reader/enhancer-gestures","@prose-reader/core","react-icons/bs","react-icons/ri","react-icons/rx","react-icons/hi","rc-slider","rc-slider/assets/index.css","react-icons/io","react-icons/md"],o):(b=typeof globalThis<"u"?globalThis:b||self,o(b["prose-react-reader"]={},b.jsxRuntime,b.React,b.reactjrx,b.rxjs,b.react,b.lu,b.reactDom,b.enhancerGestures,b.core,b.bs,b.ri,b.rx,b.hi,b.RcSlider,null,b.io,b.md))})(this,function(b,o,a,u,d,t,k,ee,oe,q,ne,se,N,te,re,ro,Y,U){"use strict";function le(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const r=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(n,s,r.get?r:{enumerable:!0,get:()=>e[s]})}}return n.default=e,Object.freeze(n)}const w=le(a),K=a.createContext({reader:void 0,quickMenuSignal:u.signal({default:!1}),notificationsSubject:new d.Subject}),ie=a.memo(({children:e,reader:n,quickMenuOpen:s,onQuickMenuOpenChange:r})=>{const[,l]=u.useSignalState(()=>u.signal({default:s})),i=u.useConstant(()=>new d.Subject),g=u.useLiveRef(r),c=a.useMemo(()=>({quickMenuSignal:l,reader:n,notificationsSubject:i}),[l,n,i]);return a.useEffect(()=>{l.setValue(s)},[s,l]),u.useSubscribe(()=>l.pipe(d.tap(g.current)),[l,g]),o.jsx(K.Provider,{value:c,children:e})}),ae=w.forwardRef(function(n,s){return o.jsx(t.IconButton,{variant:"ghost","aria-label":"Close",ref:s,...n,children:n.children??o.jsx(k.LuX,{})})}),B=w.forwardRef(function(n,s){const{children:r,portalled:l=!0,portalRef:i,backdrop:g=!0,...c}=n;return o.jsxs(t.Portal,{disabled:!l,container:i,children:[g&&o.jsx(t.Dialog.Backdrop,{}),o.jsx(t.Dialog.Positioner,{children:o.jsx(t.Dialog.Content,{ref:s,...c,asChild:!1,children:r})})]})}),m=w.forwardRef(function(n,s){return o.jsx(t.Dialog.CloseTrigger,{position:"absolute",top:"2",insetEnd:"2",...n,asChild:!0,children:o.jsx(ae,{size:"sm",ref:s,children:n.children})})}),D=t.Dialog.Root,A=t.Dialog.Footer,E=t.Dialog.Header,L=t.Dialog.Body;t.Dialog.Backdrop;const M=t.Dialog.Title;t.Dialog.Description,t.Dialog.Trigger;const z=t.Dialog.ActionTrigger,_=()=>a.useContext(K),v=()=>{const{reader:e}=_();return e},Q=e=>!!e&&"__PROSE_READER_ENHANCER_SEARCH"in e,$=e=>!!e&&"__PROSE_READER_ENHANCER_ANNOTATIONS"in e,Z=e=>!!e&&"__PROSE_READER_ENHANCER_GALLERY"in e,ce=e=>{const n=v(),s=$(n)?n:void 0;return{data:u.useObserve(()=>s==null?void 0:s.annotations.annotations$.pipe(d.map(l=>l.find(i=>i.id===e)),d.filter(u.isDefined),d.switchMap(l=>s.locateResource(l))),[s])}},X=({id:e,onNavigate:n})=>{var l,i;const s=v(),{data:r}=ce(e);return o.jsx(t.List.Item,{children:o.jsxs(t.Link,{href:"#",onClick:()=>{n(),s==null||s.navigation.goToCfi((r==null?void 0:r.meta.cfi)??"")},children:[(l=r==null?void 0:r.resource)!=null&&l.notes?o.jsx(t.List.Indicator,{asChild:!0,children:o.jsx(k.LuNotebookPen,{})}):o.jsx(t.List.Indicator,{asChild:!0,visibility:"hidden",children:o.jsx(k.LuNotebookPen,{})}),o.jsxs(t.Stack,{gap:0,children:[o.jsx(t.Text,{lineClamp:2,fontSize:"md",children:r!=null&&r.meta.range?r==null?void 0:r.meta.range.toString():o.jsx("i",{children:o.jsx("b",{children:"unknown (not loaded)"})})}),o.jsx(t.Text,{fontStyle:"italic",fontWeight:"bold",fontSize:"sm",children:`Book page: ${((i=r==null?void 0:r.meta)==null?void 0:i.absolutePageIndex)!==void 0?r.meta.absolutePageIndex+1:"unknown (not loaded)"}`})]})]})})},F=()=>{const e=v(),n=$(e)?e:void 0;return{data:u.useObserve(()=>n==null?void 0:n.annotations.annotations$.pipe(d.switchMap(r=>n.locateResource(r))),[n])}},de=({onNavigate:e})=>{const{data:n}=F();return o.jsx(t.List.Root,{overflowY:"auto",gap:3,pt:4,variant:"plain",children:n==null?void 0:n.map(s=>o.jsx(X,{id:s.resource.id,onNavigate:e},s.resource.id))})},he=()=>{const{data:e}=F();return{data:e==null?void 0:e.filter(n=>!n.meta.isCfiRange&&!n.resource.notes)}},ge=({onNavigate:e})=>{const{data:n}=he();return o.jsx(t.List.Root,{overflowY:"auto",gap:3,pt:4,variant:"plain",children:n==null?void 0:n.map(s=>o.jsx(X,{id:s.resource.id,onNavigate:e},s.resource.id))})},pe=a.memo(({onNavigate:e,defaultTab:n})=>{const[s,r]=a.useState(n??"bookmarks");return o.jsxs(t.Tabs.Root,{value:s,onValueChange:l=>r(l.value),children:[o.jsxs(t.Tabs.List,{children:[o.jsxs(t.Tabs.Trigger,{value:"bookmarks",children:[o.jsx(k.LuBookmark,{}),"Bookmarks"]}),o.jsxs(t.Tabs.Trigger,{value:"annotations",children:[o.jsx(k.LuNotebookPen,{}),"Annotations"]}),o.jsx(t.Tabs.Indicator,{})]}),o.jsx(t.Tabs.Content,{value:"bookmarks",children:o.jsx(ge,{onNavigate:e})}),o.jsx(t.Tabs.Content,{value:"annotations",children:o.jsx(de,{onNavigate:e})})]})}),fe=a.memo(({openWith:e,setOpen:n,onNavigate:s})=>o.jsx(D,{lazyMount:!0,placement:"center",open:!!e,onOpenChange:r=>n(r.open),size:{mdDown:"full",md:"lg"},scrollBehavior:"inside",children:o.jsxs(B,{height:"100%",children:[o.jsx(E,{children:o.jsx(M,{children:"Annotations"})}),o.jsx(L,{flex:1,children:o.jsx(pe,{onNavigate:s,defaultTab:e})}),o.jsx(A,{children:o.jsx(z,{asChild:!0,children:o.jsx(t.Button,{variant:"outline",children:"Cancel"})})}),o.jsx(m,{})]})})),ue=a.memo(({children:e})=>{const n=v(),s=u.useObserve(()=>n==null?void 0:n.spine.element$,[n]);return s?o.jsx(o.Fragment,{children:ee.createPortal(e,s)}):null}),be=({absolutePageIndex:e,itemIndex:n})=>{const s=v();return{spineItem:u.useObserve(()=>s?n!==void 0?d.of(s.spine.spineItemsManager.get(n)):e!==void 0?s.spine.pages.observeFromAbsolutePageIndex(e).pipe(d.map(l=>s.spine.spineItemsManager.get(l==null?void 0:l.itemIndex))):d.EMPTY:d.EMPTY,[n,e,s])}},ve=({absolutePageIndex:e,itemIndex:n})=>{const{spineItem:s}=be({absolutePageIndex:e,itemIndex:n}),r=u.useObserve(()=>(s==null?void 0:s.isReady$)??d.of(!1),[s]);return{spineItem:s,isReady:r}},J="data-bookmark-area",Se=a.memo(({absolutePageIndex:e,left:n,top:s,width:r})=>{const{isReady:l}=ve({absolutePageIndex:e}),{data:i}=F(),g=i==null?void 0:i.find(f=>{var h;return((h=f==null?void 0:f.meta)==null?void 0:h.absolutePageIndex)===e&&f.meta.range===void 0});if(!l)return null;const c=r*.1/2;return o.jsx(t.Presence,{present:!!g,lazyMount:!0,animationName:{_open:"fade-in",_closed:"fade-out"},animationDuration:"moderate",children:o.jsx(t.Box,{"data-bookmark-area":J,position:"absolute",left:n+r,transform:"translateX(-100%)",pointerEvents:"none",top:s,width:c,height:c,_before:{content:'""',position:"absolute",top:0,left:0,width:0,height:0,borderTop:`${c}px solid #03030373`,borderLeft:`${c}px solid transparent`}})})}),Te=a.memo(()=>{const e=v(),n=u.useObserve(()=>e==null?void 0:e.layoutInfo$,[e]);return o.jsx(ue,{children:n==null?void 0:n.pages.map(({absoluteLayout:{left:s,top:r,width:l}},i)=>o.jsx(Se,{absolutePageIndex:i,left:s,top:r,width:l},i))})}),Ce=()=>{const e=v();return $(e)?e:void 0},ke=()=>{const e=Ce(),{data:n}=F();a.useEffect(()=>e?e.gestures.hooks.register("beforeTapGesture",({event$:r})=>r.pipe(d.withLatestFrom(e==null?void 0:e.annotations.candidates$),d.map(([l,i])=>{if(!l.page)return!0;const{spineItem:g,spineItemPageIndex:c,spineItemPagePosition:f,pageSize:h}=l.page;if(oe.isPositionInArea(f,{type:"corner",corner:"top-right",size:10,unit:"%"},h)){const p=e.spine.pages.fromSpineItemPageIndex(g,c);if(!p)return!0;const T=n==null?void 0:n.find(I=>{var y;return((y=I==null?void 0:I.meta)==null?void 0:y.absolutePageIndex)===p.absolutePageIndex&&I.meta.range===void 0});if(T)return e==null||e.annotations.delete(T.resource.id),!1;if(i==null?void 0:i[p.absolutePageIndex])return e==null||e.annotations.annotateAbsolutePage({absolutePageIndex:p.absolutePageIndex}),!1}return!0}))):void 0,[e,n])},W=t.createToaster({placement:"bottom-end",pauseOnPageIdle:!0}),Ie=()=>o.jsx(t.Portal,{children:o.jsx(t.Toaster,{toaster:W,insetInline:{mdDown:"4"},children:e=>{var n;return o.jsxs(t.Toast.Root,{width:{md:"sm"},children:[e.type==="loading"?o.jsx(t.Spinner,{size:"sm",color:"blue.solid"}):o.jsx(t.Toast.Indicator,{}),o.jsxs(t.Stack,{gap:"1",flex:"1",maxWidth:"100%",children:[e.title&&o.jsx(t.Toast.Title,{children:e.title}),e.description&&o.jsx(t.Toast.Description,{children:e.description})]}),e.action&&o.jsx(t.Toast.ActionTrigger,{children:e.action.label}),((n=e.meta)==null?void 0:n.closable)&&o.jsx(t.Toast.CloseTrigger,{})]})}})}),Pe={x:0,y:0,width:0,height:0,top:0,left:0,bottom:0,right:0};function ye(){const[e,n]=a.useState(null),[s,r]=a.useState(Pe),l=a.useMemo(()=>new ResizeObserver(i=>{if(i[0]){const{x:g,y:c,width:f,height:h,top:S,left:p,bottom:T,right:P}=i[0].contentRect;r({x:g,y:c,width:f,height:h,top:S,left:p,bottom:T,right:P})}}),[]);return a.useLayoutEffect(()=>{if(e)return l.observe(e),()=>{l.disconnect()}},[e,l]),[n,s,e]}const xe=(e,n,s)=>{const r=v(),l=Z(r)?r:void 0;u.useSubscribe(()=>{if(!l||!e)return d.NEVER;const i=n.layout.layout$.pipe(d.startWith(n.layout.layoutInfo),d.distinctUntilChanged(q.isShallowEqual)),g=q.observeIntersection(e).pipe(d.map(c=>c.some(f=>f.isIntersecting)));return i.pipe(d.throttleTime(100,void 0,{trailing:!0}),d.switchMap(()=>g.pipe(d.tap(c=>{c||(e.innerHTML="")}),d.filter(c=>c),d.first()).pipe(d.switchMap(()=>(e.innerHTML="",l==null?void 0:l.gallery.snapshot(n,e,s))))))},[l,n,s,e])},we=a.memo(({item:e,onNavigated:n})=>{var c;const[s,r,l]=ye(),i=v();xe(l,e,r);const g=u.useObserve(()=>i==null?void 0:i.locateResource(e,{mode:"shallow"}),[i,e]);return o.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(),i==null||i.navigation.goToSpineItem({indexOrId:e})},children:[o.jsx(t.Box,{height:"100%",width:"100%",overflow:"hidden",pointerEvents:"none",ref:s}),o.jsxs(t.Text,{position:"absolute",bottom:0,left:"0",right:"0",textAlign:"center",bgColor:"white",p:4,fontSize:"xs",children:["Page ",(((c=g==null?void 0:g.meta)==null?void 0:c.absolutePageIndex)??0)+1]})]})}),Oe=a.memo(({open:e,setOpen:n})=>{const s=v(),r=u.useObserve(()=>s==null?void 0:s.spineItemsManager.items$,[s]);return o.jsx(D,{lazyMount:!0,placement:"center",open:e,onOpenChange:l=>n(l.open),size:{mdDown:"full",md:"lg"},scrollBehavior:"inside",children:o.jsxs(B,{height:"100%",children:[o.jsx(E,{children:o.jsx(M,{children:"Gallery"})}),o.jsx(L,{children:o.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:r==null?void 0:r.map(l=>o.jsx(we,{item:l,onNavigated:()=>{n(!1)}},l.item.id))})}),o.jsx(A,{children:o.jsx(z,{asChild:!0,children:o.jsx(t.Button,{variant:"outline",children:"Cancel"})})}),o.jsx(m,{})]})})}),Be="@prose-reader/react-reader",me="1.232.0",De=a.memo(({open:e,setOpen:n})=>o.jsx(D,{lazyMount:!0,placement:"center",open:e,onOpenChange:s=>n(s.open),size:{mdDown:"full",md:"lg"},scrollBehavior:"inside",children:o.jsxs(B,{children:[o.jsx(E,{children:o.jsx(M,{children:"Help"})}),o.jsxs(L,{overflowY:"auto",flex:1,children:[o.jsx(t.Heading,{mb:2,as:"h3",size:"lg",children:"Shortcuts"}),o.jsxs(t.HStack,{mb:1,children:[o.jsx(t.Kbd,{children:o.jsx(k.LuArrowBigRight,{})})," ",o.jsx(t.Text,{children:"Navigate to right page"})]}),o.jsxs(t.HStack,{mb:1,children:[o.jsx(t.Kbd,{children:o.jsx(k.LuArrowBigLeft,{})})," ",o.jsx(t.Text,{children:"Navigate to left page"})]}),o.jsx(t.Heading,{mb:2,mt:4,as:"h3",size:"lg",children:"About"}),o.jsxs(t.Text,{children:[Be," version: ",me]})]}),o.jsx(A,{children:o.jsx(z,{asChild:!0,children:o.jsx(t.Button,{variant:"outline",children:"Cancel"})})}),o.jsx(m,{})]})})),O=()=>{const e=v();return u.useObserve(()=>e?d.combineLatest([e.pagination.state$,e.context.state$]).pipe(d.map(([n,s])=>{var l;const r=(l=s.manifest)==null?void 0:l.spineItems.every(i=>{var g;return(g=i.mediaType)==null?void 0:g.startsWith("image/")});return{...n,hasChapters:!s.isFullyPrePaginated&&!r}})):d.NEVER,[e])},Ae=()=>{const e=O(),n=Math.floor(((e==null?void 0:e.percentageEstimateOfBook)??0)*100),s=n>0?n:1;return(e==null?void 0:e.percentageEstimateOfBook)===void 0?null:o.jsx(t.Box,{position:"absolute",right:0,bottom:0,p:2,color:"black",children:o.jsxs(t.Text,{fontSize:"sm",children:[s," %"]})})},Ee=()=>{const[e,n]=a.useState(new Date);return a.useEffect(()=>{const s=setInterval(()=>{n(new Date)},6e4);return()=>clearInterval(s)},[]),e},Le=e=>{const n=Ee();return o.jsx(t.Text,{fontSize:"xs",...e,children:n.toLocaleTimeString(navigator.language,{hour:"2-digit",minute:"2-digit"})})},G=()=>{const{quickMenuSignal:e}=_();return[u.useSignalValue(e),e.setValue,e]},Me=()=>{const[e]=G();return o.jsx(t.Box,{position:"absolute",left:0,bottom:0,p:2,color:e?void 0:"colorPalette.contrast",children:o.jsx(Le,{})})},ze=()=>{const e=v();u.useSubscribe(()=>e==null?void 0:e.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")}}),[e])},_e=()=>{const e=v(),{notificationsSubject:n}=_();u.useSubscribe(()=>e==null?void 0:e.zoom.isZooming$.pipe(d.switchMap(s=>{if(!s)return d.EMPTY;const r=new d.Subject;return n.next({key:"zoom",title:"Zooming",duration:999999,abort:r}),d.NEVER.pipe(d.finalize(()=>{r.next(),r.complete()}))})),[e])},$e=()=>{const e=v(),{notificationsSubject:n}=_();u.useSubscribe(()=>e==null?void 0:e.settings.values$.pipe(d.map(({fontScale:s})=>s),d.distinctUntilChanged(),d.skip(1),d.tap(s=>{n.next({key:"fontScaleChange",title:"Font size changed",description:`${s*100} %`})})),[e,n])},He=()=>{const{notificationsSubject:e}=_();$e(),_e(),u.useSubscribe(()=>e.pipe(d.filter(u.isDefined),d.mergeMap(n=>{const s=n.duration??3e3,r=W.create({title:n.title,description:n.description,duration:s}),l=e.pipe(d.skip(1),d.filter(i=>!!n.key&&(i==null?void 0:i.key)===n.key));return d.merge(d.timer(s),n.abort??d.NEVER,l).pipe(d.first(),d.finalize(()=>{W.dismiss(r)}))})),[e])},Ne=w.forwardRef(function(n,s){const{showArrow:r,children:l,portalled:i=!0,content:g,portalRef:c,...f}=n;return o.jsxs(t.Popover.Root,{...f,positioning:{...f.positioning,gutter:4},children:[o.jsx(t.Popover.Trigger,{asChild:!0,children:l}),o.jsx(t.Portal,{disabled:!i,container:c,children:o.jsx(t.Popover.Positioner,{children:o.jsxs(t.Popover.Content,{width:"auto",px:"2",py:"1",textStyle:"xs",rounded:"sm",ref:s,children:[r&&o.jsx(t.Popover.Arrow,{children:o.jsx(t.Popover.ArrowTip,{})}),g]})})})]})}),Fe=w.forwardRef(function(n,s){const{children:r,...l}=n;return o.jsx(Ne,{content:r,...l,ref:s,children:o.jsx(t.IconButton,{variant:"ghost","aria-label":"info",size:"2xs",colorPalette:"gray",children:o.jsx(te.HiOutlineInformationCircle,{})})})}),qe=w.forwardRef(function(n,s){return o.jsx(t.Progress.Track,{...n,ref:s,children:o.jsx(t.Progress.Range,{})})});w.forwardRef(function(n,s){const{children:r,info:l,...i}=n;return o.jsxs(t.Progress.Label,{...i,ref:s,children:[r,l&&o.jsx(Fe,{children:l})]})});const We=t.Progress.Root,Ge=t.Progress.ValueText,V=()=>{const e=O(),n=(e==null?void 0:e.numberOfTotalPages)===1,s=((e==null?void 0:e.beginNumberOfPagesInSpineItem)??0)>1,r=((e==null?void 0:e.endNumberOfPagesInSpineItem)??0)>1,l=(e!=null&&e.hasChapters?e==null?void 0:e.beginPageIndexInSpineItem:e==null?void 0:e.beginAbsolutePageIndex)??0,i=(e!=null&&e.hasChapters?e==null?void 0:e.endPageIndexInSpineItem:e==null?void 0:e.endAbsolutePageIndex)??0,[g=0,c=0]=[l,i].sort((S,p)=>S-p),f=(e==null?void 0:e.beginPageIndexInSpineItem)!==(e==null?void 0:e.endPageIndexInSpineItem)||(e==null?void 0:e.beginSpineItemIndex)!==(e==null?void 0:e.endSpineItemIndex),h=e!=null&&e.hasChapters?e==null?void 0:e.beginNumberOfPagesInSpineItem:e==null?void 0:e.numberOfTotalPages;return{hasOnlyOnePage:n,beginPageIndex:l,endPageIndex:i,isBeginWithinChapter:s,isEndWithinChapter:r,beginAndEndAreDifferent:f,totalApproximatePages:h,leftPageIndex:g,rightPageIndex:c}},Ve=()=>{const e=O(),{hasOnlyOnePage:n,leftPageIndex:s,rightPageIndex:r,totalApproximatePages:l,beginAndEndAreDifferent:i}=V(),g=Math.round(((e==null?void 0:e.percentageEstimateOfBook)??0)*100),c=h=>h!=null&&h.subChapter?`${h.title} / ${c(h.subChapter)}`:(h==null?void 0:h.title)||"",f=c(e==null?void 0:e.beginChapterInfo);return o.jsxs(t.Stack,{alignItems:"center",gap:1,maxW:"100%",overflow:"auto",children:[o.jsx(We,{value:g,size:"xs",width:150,children:o.jsxs(t.HStack,{justifyContent:"space-between",children:[o.jsx(qe,{width:110}),o.jsx(Ge,{children:`${g}%`})]})}),o.jsx(t.Text,{truncate:!0,maxWidth:"100%",fontSize:"sm",mt:1,children:f?`Chapter: ${f}`:" "}),!n&&o.jsxs(t.HStack,{children:[o.jsx(t.Text,{fontSize:"xs",children:i?`${s+1} - ${r+1} of ${l}`:`${s+1} of ${l}`}),!!(e!=null&&e.hasChapters)&&o.jsxs(o.Fragment,{children:[o.jsx(t.Text,{children:"-"}),o.jsxs(t.Text,{fontSize:"xs",children:["(",((e==null?void 0:e.beginAbsolutePageIndex)??0)+1,")"]})]})]})]})},j=a.memo(({children:e,position:n,...s})=>o.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:e})),Ye=t.chakra(re),Ue=a.memo(e=>o.jsx(t.Box,{display:"contents",css:{"--bg":"colors.bg","--bg-emphasized":"colors.bg.emphasized","--color-solid":"colors.colorPalette.solid"},children:o.jsx(Ye,{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(${e.reverse?"50%":"-50%"}, -50%)`,backgroundColor:"var(--bg)",marginTop:"0px"}},...e})})),Ke=()=>{const e=O(),n=e==null?void 0:e.isUsingSpread,{beginPageIndex:s,totalApproximatePages:r=0}=V(),l=n?Math.floor((s||0)/2):s,[i,g]=u.useSignalState(()=>u.signal({default:l||0})),c=0,f=Math.max(0,n?Math.floor((r-1)/2):r-1);return a.useEffect(()=>{g.update(l||0)},[l,g]),{value:i,valueSignal:g,min:c,max:f}},Qe=e=>{const n=v(),s=O(),{manifest:r}=u.useObserve(()=>n==null?void 0:n.context.state$,[n])??{},l=(r==null?void 0:r.readingDirection)==="rtl",i=s==null?void 0:s.isUsingSpread,{totalApproximatePages:g=0,isBeginWithinChapter:c}=V(),f=1,h=c,{value:S,valueSignal:p,min:T,max:P}=Ke(),I=a.useCallback(x=>{const[C=0]=Array.isArray(x)?x:[x];p.setValue(C);const H=i?Math.floor(C)*2:Math.floor(C);h?n==null||n.navigation.goToPageOfSpineItem({pageIndex:H,spineItemId:n.pagination.state.beginSpineItemIndex??0,animation:!1}):n==null||n.navigation.goToAbsolutePageIndex({absolutePageIndex:H,animation:!1})},[n,i,p,h]);return u.useSubscribe(()=>n==null?void 0:n.navigation.throttleLock({duration:100,trigger:p.subject}),[n,p]),g===1||i&&g===2?o.jsx(t.Box,{style:e.style}):o.jsx(Ue,{value:[S],max:P,min:T,reverse:l,step:f,onChange:I,...e})},Ze=a.memo(({open:e,onItemClick:n})=>{const s=v(),r=u.useObserve(()=>s==null?void 0:s.navigation.state$,[s]),l=u.useObserve(()=>s==null?void 0:s.settings.values$,[s]),i=(l==null?void 0:l.computedPageTurnDirection)==="vertical",[g,c]=a.useState(!0);return o.jsxs(j,{present:e,position:"bottom",display:"flex",flexDirection:"column",overflow:"auto",pb:8,children:[o.jsxs(t.HStack,{flex:1,alignItems:"center",justifyContent:"center",maxWidth:"100%",children:[o.jsx(t.IconButton,{"aria-label":"left",size:"lg",variant:"ghost",flexShrink:0,onClick:()=>s==null?void 0:s.navigation.goToLeftOrTopSpineItem(),disabled:!(r!=null&&r.canGoLeftSpineItem)&&!(r!=null&&r.canGoTopSpineItem),children:i?o.jsx(N.RxDoubleArrowUp,{}):o.jsx(N.RxDoubleArrowLeft,{})}),o.jsxs(t.Stack,{flex:1,maxW:400,gap:2,alignItems:"center",overflow:"auto",px:4,children:[o.jsx(Ve,{}),o.jsx(Qe,{style:{width:"100%",maxWidth:"300px",height:"35px"}})]}),o.jsx(t.IconButton,{"aria-label":"right",size:"lg",flexShrink:0,variant:"ghost",disabled:!(r!=null&&r.canGoRightSpineItem)&&!(r!=null&&r.canGoBottomSpineItem),onClick:()=>{s==null||s.navigation.goToRightOrBottomSpineItem()},children:i?o.jsx(N.RxDoubleArrowDown,{}):o.jsx(N.RxDoubleArrowRight,{})})]}),o.jsx(t.HStack,{alignSelf:"stretch",alignItems:"center",justifyContent:"center",children:o.jsxs(t.Collapsible.Root,{open:g,flex:1,onOpenChange:({open:f})=>{c(f)},children:[o.jsx(t.Collapsible.Trigger,{paddingY:"3",width:"100%",display:"flex",justifyContent:"center",children:o.jsx(k.LuChevronDown,{style:{transform:g?"rotate(0deg)":"rotate(180deg)"}})}),o.jsxs(t.Collapsible.Content,{display:"flex",justifyContent:"center",children:[o.jsx(t.IconButton,{"aria-label":"Help",size:"lg",variant:"ghost",onClick:()=>n("help"),children:o.jsx(k.LuCircleHelp,{})}),o.jsx(t.IconButton,{"aria-label":"Table of contents",size:"lg",variant:"ghost",onClick:()=>n("toc"),children:o.jsx(k.LuTableOfContents,{})}),Q(s)&&o.jsx(t.IconButton,{"aria-label":"Search",size:"lg",variant:"ghost",onClick:()=>n("search"),children:o.jsx(k.LuSearch,{})}),$(s)&&o.jsx(t.IconButton,{"aria-label":"Bookmarks",size:"lg",variant:"ghost",onClick:()=>n("bookmarks"),children:o.jsx(ne.BsBookmarks,{})}),$(s)&&o.jsx(t.IconButton,{"aria-label":"Annotations",size:"lg",variant:"ghost",onClick:()=>n("annotations"),children:o.jsx(k.LuNotebookPen,{})}),o.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:o.jsx(k.LuGalleryHorizontal,{})}),Z(s)&&o.jsx(t.IconButton,{"aria-label":"Gallery",size:"lg",variant:"ghost",onClick:()=>n("gallery"),children:o.jsx(se.RiGalleryView2,{})})]})]})})]})}),Xe=()=>{const[e,n]=a.useState(!1),s=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 r(){n(!!document.fullscreenElement)}return document.addEventListener("fullscreenchange",r),()=>{document.removeEventListener("fullscreenchange",r)}},[]),{isFullscreen:e,onToggleFullscreenClick:s}},Je=a.memo(({open:e,onItemClick:n})=>{const s=v(),r=u.useObserve(()=>s==null?void 0:s.context.manifest$,[s]),{isFullscreen:l,onToggleFullscreenClick:i}=Xe();return o.jsxs(j,{present:e,position:"top",height:"80px",justifyContent:"space-between",children:[o.jsx(t.IconButton,{"aria-label":"left",size:"lg",variant:"ghost",flexShrink:0,onClick:()=>n("back"),children:o.jsx(Y.IoIosArrowBack,{})}),o.jsx(t.Stack,{flex:1,maxW:600,gap:1,alignItems:"center",overflow:"auto",px:4,children:o.jsx(t.Text,{truncate:!0,maxWidth:"100%",children:r==null?void 0:r.title})}),o.jsxs(t.HStack,{children:[o.jsx(t.IconButton,{"aria-label":"right",size:"lg",flexShrink:0,variant:"ghost",onClick:()=>n("more"),children:o.jsx(Y.IoMdMore,{})}),o.jsx(t.IconButton,{"aria-label":"right",size:"lg",flexShrink:0,variant:"ghost",onClick:i,children:l?o.jsx(U.MdFullscreenExit,{}):o.jsx(U.MdFullscreen,{})})]})]})}),je=a.memo(({onItemClick:e})=>{const[n]=G();return o.jsxs(o.Fragment,{children:[o.jsx(Je,{open:n,onItemClick:e}),o.jsx(Ze,{open:n,onItemClick:e})]})}),Re=a.memo(({contextText:e="",startOffset:n=0,text:s,cfi:r="#",onClick:l,absolutePageIndex:i})=>{const c=e.substring(Math.max(n-15,0),Math.max(n,0)),f=e.substring(Math.min(n+s.length,e.length-1),Math.min(n+s.length+15,e.length-1));return o.jsxs(t.Link,{href:r,style:{margin:5,overflow:"hidden"},onClick:h=>{h.preventDefault(),l(r)},display:"flex",flexDirection:"column",alignItems:"flex-start",gap:0,children:[o.jsxs(t.Text,{lineClamp:1,as:"cite",style:{display:"block"},children:['"',c,o.jsx("b",{children:s}),f,'"']}),o.jsx(t.Text,{fontSize:"sm",color:"gray.500",style:{textDecoration:"none"},children:`Book page: ${i!==void 0?i+1:"unknown (not loaded)"}`})]})}),eo=a.memo(({onNavigate:e})=>{const[n,s]=a.useState(""),r=v(),l=Q(r)?r:void 0,i=p=>{s(p.target.value)},g=a.useCallback(p=>{e(),r==null||r.navigation.goToCfi(p)},[r,e]),c=u.useObserve(()=>l==null?void 0:l.search.search(n).pipe(d.map(p=>({type:"end",data:p})),d.startWith({type:"start"})),[r,n]),f=(c==null?void 0:c.type)==="start",h=(c==null?void 0:c.type)==="end"?c.data:[],S=u.useObserve(()=>r==null?void 0:r.locateResource(h.slice(0,100)),[h]);return o.jsxs(t.Stack,{flex:1,height:"100%",children:[o.jsx(t.Box,{px:4,children:o.jsx(t.Input,{placeholder:"Type something...",value:n,onChange:i,borderRadius:0})}),o.jsxs(t.Box,{px:4,pb:4,mt:2,flex:1,style:{overflow:"hidden",overflowY:"auto"},children:[f&&o.jsx(t.Text,{children:"Searching ..."}),!f&&h.length===0&&o.jsx("p",{children:"There are no results"}),!f&&h.length>=0&&o.jsxs(t.Stack,{children:[o.jsxs(t.Heading,{as:"h2",size:"md",children:[h.length," result(s)"]}),o.jsx(t.Stack,{gap:0,children:S==null?void 0:S.map((p,T)=>{var P,I,y,x,C,H,R;return o.jsx(Re,{contextText:((y=(I=(P=p.meta)==null?void 0:P.range)==null?void 0:I.startContainer.parentElement)==null?void 0:y.textContent)??"",pageIndex:(x=p.meta)==null?void 0:x.itemPageIndex,startOffset:((H=(C=p.meta)==null?void 0:C.range)==null?void 0:H.startOffset)??0,text:n,cfi:p.meta.cfi,onClick:g,absolutePageIndex:(R=p.meta)==null?void 0:R.absolutePageIndex},T)})})]})]})]})}),oo=a.memo(({open:e,setOpen:n,onNavigate:s})=>o.jsx(D,{lazyMount:!0,placement:"center",open:e,onOpenChange:r=>n(r.open),size:{mdDown:"full",md:"lg"},scrollBehavior:"inside",children:o.jsxs(B,{height:"100%",children:[o.jsx(E,{children:o.jsx(M,{children:"Search"})}),o.jsx(L,{flex:1,children:o.jsx(eo,{onNavigate:s})}),o.jsx(A,{children:o.jsx(z,{asChild:!0,children:o.jsx(t.Button,{variant:"outline",children:"Cancel"})})}),o.jsx(m,{})]})})),no=a.memo(({onNavigate:e})=>{const n=v(),{manifest:s,assumedRenditionLayout:r}=u.useObserve(()=>n==null?void 0:n.context.state$,[n])??{},{nav:l}=s??{},i=O();l!=null&&l.toc;const{beginSpineItemIndex:g,beginPageIndexInSpineItem:c}=i??{},f=(r==="reflowable"?c:g)||0;let h=i==null?void 0:i.beginChapterInfo;for(;h!=null&&h.subChapter;)h=h==null?void 0:h.subChapter;const S=(p,T,P)=>o.jsxs(a.Fragment,{children:[o.jsx(t.List.Item,{pl:4*(P+1),style:{display:"flex",alignItems:"center"},children:o.jsxs(t.Link,{onClick:()=>{e(),n==null||n.navigation.goToUrl(p.href)},href:"#",children:[(h==null?void 0:h.path)===p.path&&o.jsx(t.List.Indicator,{asChild:!0,children:o.jsx(k.LuCircleCheck,{})}),(h==null?void 0:h.path)!==p.path&&o.jsx(t.List.Indicator,{asChild:!0,visibility:"hidden",children:o.jsx(k.LuCircleCheck,{})}),o.jsxs(t.Stack,{gap:0,children:[o.jsx(t.Text,{fontSize:"md",children:p.title||p.path}),(h==null?void 0:h.path)===p.path&&o.jsx(t.Text,{fontStyle:"italic",fontWeight:"bold",fontSize:"sm",children:`Currently on page ${f+1}`})]})]})}),p.contents.length>0&&o.jsx(t.List.Root,{as:"div",gap:2,children:p.contents.map((I,y)=>S(I,y,P+1))})]},T);return o.jsx(t.List.Root,{gap:3,overflowY:"auto",py:4,flex:1,children:l==null?void 0:l.toc.map((p,T)=>S(p,T,0))})}),so=a.memo(({open:e,setOpen:n,onNavigate:s})=>o.jsx(D,{lazyMount:!0,placement:"center",open:e,onOpenChange:r=>n(r.open),size:{mdDown:"full",md:"lg"},scrollBehavior:"inside",children:o.jsxs(B,{children:[o.jsx(E,{children:o.jsx(M,{children:"Table of Contents"})}),o.jsx(L,{overflowY:"auto",flex:1,children:o.jsx(no,{onNavigate:s})}),o.jsx(A,{children:o.jsx(z,{asChild:!0,children:o.jsx(t.Button,{variant:"outline",children:"Cancel"})})}),o.jsx(m,{})]})})),to=({enableFloatingTime:e=!0,enableFloatingProgress:n=!0,onItemClick:s})=>{const[r,l]=a.useState(!1),[i,g]=a.useState(!1),[c,f]=a.useState(!1),[h,S]=a.useState(void 0),[p,T]=a.useState(!1),[P,I]=G(),y=a.useCallback(()=>{l(!1),g(!1),f(!1),S(void 0),I(!1),T(!1)},[I]),x=a.useCallback(C=>{C==="annotations"?S("annotations"):C==="search"?f(!0):C==="help"?g(!0):C==="toc"?l(!0):C==="bookmarks"?S("bookmarks"):C==="gallery"&&T(!0),s==null||s(C)},[s]);return ze(),He(),ke(),o.jsxs(o.Fragment,{children:[n&&o.jsx(t.Presence,{present:!P,animationName:{_open:"fade-in",_closed:"fade-out"},animationDuration:"moderate",children:o.jsx(Ae,{})}),o.jsx(Oe,{open:p,setOpen:T}),o.jsx(je,{onItemClick:x}),o.jsx(Te,{}),o.jsx(De,{open:i,setOpen:g}),o.jsx(so,{open:r,setOpen:l,onNavigate:y}),o.jsx(oo,{open:c,setOpen:f,onNavigate:y}),o.jsx(fe,{openWith:h,setOpen:C=>S(C?"annotations":void 0),onNavigate:y}),o.jsx(t.Presence,{present:e||P,animationName:{_open:"fade-in",_closed:"fade-out"},animationDuration:"slow",overflow:"hidden",children:o.jsx(Me,{})}),o.jsx(Ie,{})]})};b.BOOKMARK_AREA_DATA_ATTRIBUTE=J,b.ReactReader=to,b.ReactReaderProvider=ie,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})});
|
|
2
2
|
//# sourceMappingURL=index.umd.cjs.map
|