UNPKG

@tindtechnologies/universalviewer

Version:

The Universal Viewer is a community-developed open source project on a mission to help you share your 📚📜📰📽️📻🗿 with the 🌎

2 lines (1 loc) 15.2 kB
import{b as R,d as D}from"./chunk-7SGMGVTY.js";import{a as M}from"./chunk-GHTJH4NP.js";import"./chunk-BYXBJQAS.js";import{b as E,e as x,f as y,g as d,h as B,i as Q,j as C,k}from"./chunk-PYNED64U.js";import"./chunk-J6QTJS4P.js";import{a}from"./chunk-M4MN2QTO.js";import{a as l}from"./chunk-IRIM6TPQ.js";import{g as m}from"./chunk-5XPHF4E5.js";import"./chunk-L67DAW3A.js";var n=class n{};n.namespace="ebookExtension.",n.CFI_FRAGMENT_CHANGE=n.namespace+"cfiFragmentChange",n.ITEM_CLICKED=n.namespace+"itemClicked",n.LOADED_NAVIGATION=n.namespace+"loadedNavigation",n.RELOCATED=n.namespace+"relocated",n.RENDITION_ATTACHED=n.namespace+"renditionAttached",n.TOC_READY=n.namespace+"tocReady";var o=n;function s(){var e=window,A=[];(!e.customElements||e.Element&&(!e.Element.prototype.closest||!e.Element.prototype.matches||!e.Element.prototype.remove))&&A.push(import("./dom-Q2LG6LKA.js"));function t(){try{var i=new URL("b","http://a");return i.pathname="c%20d",i.href==="http://a/c%20d"&&i.searchParams}catch{return!1}}return(typeof Object.assign!="function"||!Object.entries||!Array.prototype.find||!Array.prototype.includes||!String.prototype.startsWith||!String.prototype.endsWith||e.NodeList&&!e.NodeList.prototype.forEach||!e.fetch||!t()||typeof WeakMap>"u")&&A.push(import("./core-js-DYXRFGE7.js")),Promise.all(A)}var c=function(e,A){return R().then(function(){D([["uv-ebook-reader_2",[[0,"uv-ebook-reader",{width:[1],height:[1],mobileWidth:[2,"mobile-width"],minSpreadWidth:[2,"min-spread-width"],_bookPath:[32],_bookReady:[32],_prevEnabled:[32],_mobile:[32],_nextEnabled:[32],_showDivider:[32],load:[64],resize:[64],display:[64],getBook:[64]},[[8,"keydown","handleKeyDown"]]],[0,"uv-ebook-toc",{toc:[16],selected:[1025],disabled:[4]}]]]],A)})};(function(){if(!(window.Reflect===void 0||window.customElements===void 0)){var e=HTMLElement;window.HTMLElement=function(){return Reflect.construct(e,[],this.constructor)},HTMLElement.prototype=e.prototype,HTMLElement.prototype.constructor=HTMLElement,Object.setPrototypeOf(HTMLElement,e)}})();var U=window.$,p=class extends y{constructor(A){super(A)}async create(){this.setConfig("ebookLeftPanel"),super.create(),this._$container=U('<div class="container"></div>'),await s(),c(window),this._ebookTOC=document.createElement("uv-ebook-toc"),this._$ebookTOC=U(this._ebookTOC),this.$main.addClass("disabled"),this.$main.append(this._$container),this._$container.append(this._$ebookTOC),this.setTitle(this.content.title),this.extensionHost.subscribe(o.LOADED_NAVIGATION,A=>{this.$main.removeClass("disabled"),this._ebookTOC.toc=A.toc}),this.extensionHost.subscribe(o.RELOCATED,A=>{this._ebookTOC.selected=A.start.href}),this._ebookTOC.addEventListener("itemClicked",A=>{this.extensionHost.publish(o.ITEM_CLICKED,A.detail),this.extension.isMetric("sm")&&this.toggle(!0)}),l.waitFor(()=>window.customElements!==void 0,()=>{customElements.whenDefined("uv-ebook-toc").then(()=>{this.extensionHost.publish(o.TOC_READY)})})}expandFullStart(){super.expandFullStart(),this.extensionHost.publish(a.LEFTPANEL_EXPAND_FULL_START)}expandFullFinish(){super.expandFullFinish(),this.extensionHost.publish(a.LEFTPANEL_EXPAND_FULL_FINISH)}collapseFullStart(){super.collapseFullStart(),this.extensionHost.publish(a.LEFTPANEL_COLLAPSE_FULL_START)}collapseFullFinish(){super.collapseFullFinish(),this.extensionHost.publish(a.LEFTPANEL_COLLAPSE_FULL_FINISH)}resize(){super.resize(),this._$container.height(this.$main.height()-this._$container.verticalPadding())}};var u=class extends M{constructor(A){super(A)}create(){this.setConfig("downloadDialogue"),super.create()}open(A){super.open(A),this.addEntireFileDownloadOptions(),this.updateNoneAvailable(),this.resize()}isDownloadOptionAvailable(A){return super.isDownloadOptionAvailable(A)}};var g=class extends E{constructor(t){super(t);this._ebookReaderReady=!1;this._state={};this._prevState={};this.attributionPosition=8}async create(){this.setConfig("ebookCenterPanel"),super.create(),await s(),c(window),this._ebookReader=document.createElement("uv-ebook-reader"),this.$content.prepend(this._ebookReader),this._ebookReader.setAttribute("width","100%"),this._ebookReader.setAttribute("height","100%"),this._ebookReader.addEventListener("loadedNavigation",i=>{this.extensionHost.publish(o.LOADED_NAVIGATION,i.detail)},!1),this._ebookReader.addEventListener("relocated",i=>{this.extensionHost.publish(o.RELOCATED,i.detail),this._cfi=i.detail.start.cfi,this.extensionHost.publish(o.CFI_FRAGMENT_CHANGE,this._cfi)},!1),l.waitFor(()=>window.customElements!==void 0,()=>{customElements.whenDefined("uv-ebook-reader").then(()=>{this._ebookReaderReady=!0})});let t=this;this.extensionHost.subscribe(a.OPEN_EXTERNAL_RESOURCE,i=>{t.openMedia(i)}),this.extensionHost.subscribe(o.ITEM_CLICKED,i=>{this._nextState({cfi:i})}),this.extensionHost.subscribe(o.CFI_FRAGMENT_CHANGE,i=>{l.waitFor(()=>this._ebookReaderReady,()=>{i!==this._cfi&&this._nextState({cfi:i})})})}openMedia(t){this.extension.getExternalResources(t).then(()=>{let r=this.extension.helper.getCurrentCanvas().getContent();if(r.length){let I=r[0].getBody();if(I.length){let G=I[0];this._nextState({bookPath:G.id})}}this.extensionHost.publish(m.EXTERNAL_RESOURCE_OPENED),this.extensionHost.publish(m.LOAD)})}_nextState(t){this._state=Object.assign({},this._state,t),l.waitFor(()=>this._ebookReaderReady,()=>{this._state.bookPath&&this._state.bookPath!==this._prevState.bookPath&&this._ebookReader.load(this._state.bookPath),this._state.cfi&&this._state.cfi!==this._prevState.cfi&&this._ebookReader.display(this._state.cfi),this._prevState=Object.assign({},this._state)})}resize(){super.resize(),this._ebookReaderReady&&setTimeout(()=>{this._ebookReader.resize()},10)}};var b=class extends d{constructor(A){super(A)}create(){this.setConfig("mobileFooterPanel"),super.create()}resize(){super.resize(),this.$options.css("left",Math.floor(this.$element.width()/2-this.$options.width()/2))}};var v=class extends C{constructor(A){super(A)}create(){this.setConfig("settingsDialogue"),super.create()}};var h=class extends k{constructor(A){super(A)}create(){this.setConfig("shareDialogue"),super.create()}update(){super.update(),this.embedCode=this.extension.getEmbedScript(this.options.embedTemplate,this.currentWidth,this.currentHeight),this.$embedCode.val(this.embedCode)}resize(){super.resize()}};var F={options:{allowStealFocus:!1,authAPIVersion:1,bookmarkThumbHeight:150,bookmarkThumbWidth:90,dropEnabled:!0,footerPanelEnabled:!0,headerPanelEnabled:!0,leftPanelEnabled:!0,limitLocales:!1,metrics:[{type:"sm",minWidth:0},{type:"md",minWidth:768},{type:"lg",minWidth:1024},{type:"xl",minWidth:1280}],multiSelectionMimeType:"application/zip",navigatorEnabled:!0,openTemplate:"http://universalviewer.io?manifest={0}",overrideFullScreen:!1,preserveViewport:!1,rightPanelEnabled:!0,saveUserSettings:!1,clickToZoomEnabled:!0,searchWithinEnabled:!0,termsOfUseEnabled:!1,tokenStorage:"session",useArrowKeysToNavigate:!1,zoomToSearchResultEnabled:!0},modules:{leftPanel:{options:{expandFullEnabled:!1,panelAnimationDuration:250,panelCollapsedWidth:30,panelExpandedWidth:255,panelOpen:!1},content:{collapse:"$collapse",collapseFull:"$collapseFull",expand:"$expandContents",expandFull:"$expandGallery"}},ebookLeftPanel:{options:{expandFullEnabled:!1,panelAnimationDuration:250,panelCollapsedWidth:30,panelExpandedWidth:255,panelOpen:!1},content:{title:"$contents",collapse:"$collapse",collapseFull:"$collapseFull",expand:"$expandContents",expandFull:"$expandGallery"}},dialogue:{options:{topCloseButtonEnabled:!1},content:{close:"$close"}},footerPanel:{options:{bookmarkEnabled:!1,downloadEnabled:!0,embedEnabled:!1,feedbackEnabled:!1,fullscreenEnabled:!0,minimiseButtons:!0,moreInfoEnabled:!0,openEnabled:!1,printEnabled:!1,shareEnabled:!0},content:{bookmark:"$add_to_bookmarks",download:"$download",embed:"$embed",exitFullScreen:"$exitFullScreen",feedback:"$feedback",fullScreen:"$fullScreen",moreInfo:"$moreInfo",open:"$open",share:"$share",openLeftPanel:"$openLeftPanel",closeLeftPanel:"$closeLeftPanel",openRightPanel:"$openRightPanel",closeRightPanel:"$closeRightPanel"}},genericDialogue:{options:{topCloseButtonEnabled:!1},content:{close:"$close",emptyValue:"$emptyValue",invalidNumber:"$invalidNumber",noMatches:"$noMatches",ok:"$ok",pageNotFound:"$pageNotFound",refresh:"$refresh"}},headerPanel:{options:{centerOptionsEnabled:!0,localeToggleEnabled:!1,settingsButtonEnabled:!0,helpEnabled:!1,helpUrl:"https://universalviewer.io"},content:{close:"$close",settings:"$settings",help:"$help"}},helpDialogue:{options:{topCloseButtonEnabled:!1},content:{close:"$close",text:"$placeholder_text",title:"$help"}},moreInfoRightPanel:{options:{canvasDisplayOrder:"",canvasExclude:"",copyToClipboardEnabled:!1,expandFullEnabled:!1,limitToRange:!1,manifestDisplayOrder:"",manifestExclude:"",panelAnimationDuration:250,panelCollapsedWidth:30,panelExpandedWidth:255,panelOpen:!1,rtlLanguageCodes:"ar, ara, dv, div, he, heb, ur, urd",showAllLanguages:!1,textLimit:4,textLimitType:"lines",topCloseButtonEnabled:!1},content:{attribution:"$attribution",canvasHeader:"$aboutTheImage",close:"$close",collapse:"$collapseInformation",collapseFull:"$collapseGallery",copiedToClipboard:"$copiedToClipboard",copyToClipboard:"$copyToClipboard",description:"$description",expand:"$expandInformation",expandFull:"$expandGallery",holdingText:"$moduleGoesHere",less:"$less",lessAriaLabelTemplate:"$lessAriaLabelTemplate",license:"$license",logo:"$logo",manifestHeader:"$aboutTheItem",more:"$more",moreAriaLabelTemplate:"$moreAriaLabelTemplate",noData:"$noDataToDisplay",page:"$page",rangeHeader:"$aboutThisSection",title:"$moreInformation"}},centerPanel:{options:{titleEnabled:!0,subtitleEnabled:!0,mostSpecificRequiredStatement:!0,requiredStatementEnabled:!0},content:{attribution:"$attribution",close:"$close",closeAttribution:"$closeAttribution"}},ebookCenterPanel:{options:{titleEnabled:!0,subtitleEnabled:!0,mostSpecificRequiredStatement:!0,requiredStatementEnabled:!0},content:{attribution:"$attribution",close:"$close",closeAttribution:"$closeAttribution"}},settingsDialogue:{options:{topCloseButtonEnabled:!1},content:{close:"$close",locale:"$locale",navigatorEnabled:"$navigatorEnabled",clickToZoomEnabled:"$clickToZoomEnabled",reducedMotion:"$reducedMotion",truncateThumbnailLabels:"$truncateThumbnailLabels",preserveViewport:"$preserveViewport",title:"$settings",website:"$uvWebsite"}},shareDialogue:{options:{embedEnabled:!0,shareEnabled:!0,embedPath:"/uv.html",embedTemplate:'<iframe src="{0}" width="{1}" height="{2}" allowfullscreen frameborder="0" title="{3}"></iframe>',shareManifestsEnabled:!0,topCloseButtonEnabled:!1,copyToClipboardEnabled:!0},content:{close:"$close",copyBtn:"$copyBtn",copyToClipboard:"$copyToClipboard",customSize:"custom",embed:"Embed",embedInstructions:"To embed this item in your own website, copy and paste the code below.",height:"Height",iiif:"IIIF Manifest",share:"Share",shareInstructions:"To share this item, copy the URL below.",shareLink:"$shareLink",size:"Size:",width:"Width",shareUrl:"$shareUrl"}},authDialogue:{options:{topCloseButtonEnabled:!1},content:{cancel:"$cancel",close:"$close",confirm:"$confirm"}},adjustImageDialogue:{options:{topCloseButtonEnabled:!1},content:{title:"$adjustImage",brightness:"$brightness",contrast:"$contrast",saturation:"$saturation",close:"$close",reset:"$reset",remember:"$remember"}},clickThroughDialogue:{options:{topCloseButtonEnabled:!1},content:{close:"$close",viewTerms:"$viewTerms"}},downloadDialogue:{options:{topCloseButtonEnabled:!1},content:{allPages:"$allPages",close:"$close",currentViewAsJpg:"$currentViewAsJpg",currentViewAsJpgExplanation:"$openNewWindow",download:"$download",downloadSelection:"$downloadSelection",downloadSelectionExplanation:"$downloadSelectionExplanation",editSettings:"$editSettings",entireDocument:"$entireDocument",entireFileAsOriginal:"$entireFile",entireFileAsOriginalWithFormat:"$entireFileAsOriginalWithFormat",individualPages:"$individualPages",noneAvailable:"$noDownloadOptionsAvailable",pagingNote:"$pagingNote",preview:"$preview",selection:"$selection",termsOfUse:"$termsOfUse",title:"$download",wholeImageHighRes:"$wholeImageHighRes",wholeImageHighResExplanation:"$openNewWindow",wholeImageLowResAsJpg:"$wholeImageLowResAsJpg",wholeImageLowResAsJpgExplanation:"$openNewWindow",wholeImagesHighRes:"$wholeImagesHighRes",wholeImagesHighResExplanation:"$wholeImagesHighResExplanation"}},loginDialogue:{options:{topCloseButtonEnabled:!1},content:{login:"$login",logout:"$logout",cancel:"$cancel",close:"$close"}},restrictedDialogue:{options:{topCloseButtonEnabled:!1},content:{cancel:"$cancel",close:"$close"}}},localisation:{label:"English (GB)",locales:[{name:"cy-GB",label:"Cymraeg"},{name:"en-GB",label:"English (GB)"},{name:"fr-FR",label:"Fran\xE7ais (FR)"},{name:"pl-PL",label:"Polski"},{name:"sv-SE",label:"Svenska"}]},content:{authCORSError:"$authCORSError",authorisationFailedMessage:"$authorisationFailedMessage",canvasIndexOutOfRange:"$canvasIndexOutOfRange",fallbackDegradedLabel:"$fallbackDegradedLabel",fallbackDegradedMessage:"$fallbackDegradedMessage",forbiddenResourceMessage:"$forbiddenResourceMessage",termsOfUse:"$termsOfUse",mediaViewer:"$mediaViewer",skipToDownload:"$skipToDownload"}};var w=class extends x{constructor(){super(...arguments);this.defaultConfig=F}create(){super.create(),this.extensionHost.subscribe(a.CANVAS_INDEX_CHANGE,t=>{this.viewCanvas(t)}),this.extensionHost.subscribe(o.CFI_FRAGMENT_CHANGE,t=>{this.cfiFragement=t,this.fire(o.CFI_FRAGMENT_CHANGE,this.cfiFragement)})}createModules(){super.createModules(),this.isHeaderPanelEnabled()?this.headerPanel=new B(this.shell.$headerPanel):this.shell.$headerPanel.hide(),this.isLeftPanelEnabled()?this.leftPanel=new p(this.shell.$leftPanel):this.shell.$leftPanel.hide(),this.centerPanel=new g(this.shell.$centerPanel),this.isRightPanelEnabled()?this.rightPanel=new Q(this.shell.$rightPanel):this.shell.$rightPanel.hide(),this.isFooterPanelEnabled()?(this.footerPanel=new d(this.shell.$footerPanel),this.mobileFooterPanel=new b(this.shell.$mobileFooterPanel)):this.shell.$footerPanel.hide(),this.$shareDialogue=$('<div class="overlay share" aria-hidden="true"></div>'),this.shell.$overlays.append(this.$shareDialogue),this.shareDialogue=new h(this.$shareDialogue),this.$downloadDialogue=$('<div class="overlay download" aria-hidden="true" role="region"></div>'),this.shell.$overlays.append(this.$downloadDialogue),this.downloadDialogue=new u(this.$downloadDialogue),this.$settingsDialogue=$('<div class="overlay settings" aria-hidden="true"></div>'),this.shell.$overlays.append(this.$settingsDialogue),this.settingsDialogue=new v(this.$settingsDialogue),this.isHeaderPanelEnabled()&&this.headerPanel.init(),this.isLeftPanelEnabled()&&this.leftPanel.init(),this.isRightPanelEnabled()&&this.rightPanel.init(),this.isFooterPanelEnabled()&&this.footerPanel.init()}isLeftPanelEnabled(){return!0}render(){super.render(),this.checkForCFIParam()}getEmbedScript(t,i,r){let f=new URLSearchParams({manifest:this.helper.manifestUri,cfi:this.cfiFragement});return super.buildEmbedScript(t,i,r,f)}checkForCFIParam(){let t=this.data.cfi;t&&this.extensionHost.publish(o.CFI_FRAGMENT_CHANGE,t)}};export{w as default};