Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@netless/app-docs-viewer

Package Overview
Dependencies
Maintainers
10
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@netless/app-docs-viewer - npm Package Compare versions

Comparing version 0.2.5 to 0.2.6

4

dist/main.cjs.js

@@ -1,4 +0,4 @@

"use strict";var Re=Object.defineProperty,Ve=Object.defineProperties;var Me=Object.getOwnPropertyDescriptors;var X=Object.getOwnPropertySymbols;var ze=Object.prototype.hasOwnProperty,Oe=Object.prototype.propertyIsEnumerable;var J=(t,e,s)=>e in t?Re(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,R=(t,e)=>{for(var s in e||(e={}))ze.call(e,s)&&J(t,s,e[s]);if(X)for(var s of X(e))Oe.call(e,s)&&J(t,s,e[s]);return t},V=(t,e)=>Ve(t,Me(e));Object.defineProperty(exports,"__esModule",{value:!0});exports[Symbol.toStringTag]="Module";var De=`.netless-app-docs-viewer-content{position:relative;height:100%;overflow:hidden}.netless-app-docs-viewer-preview-mask{display:none;position:absolute;z-index:200;top:0;left:0;width:100%;height:100%}.netless-app-docs-viewer-preview{display:flex;flex-direction:column;align-items:center;position:absolute;z-index:300;top:0;left:0;width:33%;max-width:200px;height:100%;padding-top:10px;transform:translate(-100%);background:rgba(237,237,240,.9);box-shadow:inset -1px 0 #0000001c;transition:transform .4s}.netless-app-docs-viewer-preview-active .netless-app-docs-viewer-preview-mask{display:block}.netless-app-docs-viewer-preview-active .netless-app-docs-viewer-preview{transform:translate(0)}.netless-app-docs-viewer-preview-page{position:relative;display:block;width:55%;margin-bottom:10px;font-size:0;color:transparent;outline:none;border:7px solid transparent;border-radius:4px;transition:border-color .3s;user-select:none}.netless-app-docs-viewer-preview-page:hover,.netless-app-docs-viewer-preview-page.netless-app-docs-viewer-preview-page-active{border-color:#444e601a}.netless-app-docs-viewer-preview-page>img{width:100%;height:auto;box-sizing:border-box;border:1px solid rgba(0,0,0,.5);border-radius:1px;background-color:#fff;box-shadow:0 2px 8px #0000004d}.netless-app-docs-viewer-preview-page-name{position:absolute;top:1px;left:-10px;transform:translate(-100%);text-align:right;font-size:12px;color:#5f5f5f;user-select:none}.netless-app-docs-viewer-footer{box-sizing:border-box;height:26px;display:flex;align-items:center;padding:0 16px;border-top:1px solid #eeeef7;color:#191919}.netless-app-docs-viewer-float-footer{width:100%;min-height:26px;position:absolute;left:0;bottom:0;z-index:2000;background:rgba(249,249,252,.9);transition:opacity .4s}.netless-app-docs-viewer-footer-btn{box-sizing:border-box;width:26px;height:26px;font-size:0;margin:0;padding:3px;border:none;border-radius:1px;outline:none;color:currentColor;background:transparent;transition:background .4s;cursor:pointer;user-select:none;-webkit-tap-highlight-color:rgba(0,0,0,0)}.netless-app-docs-viewer-footer-btn:hover{background:rgba(237,237,240,.9)}@media (hover: none){.netless-app-docs-viewer-footer-btn:hover{background:transparent!important}}.netless-app-docs-viewer-footer-btn>svg{width:100%;height:100%}.netless-app-docs-viewer-footer-btn>svg:nth-of-type(2){display:none}.netless-app-docs-viewer-footer-btn.netless-app-docs-viewer-footer-btn-playing>svg:nth-of-type(1){display:none}.netless-app-docs-viewer-footer-btn.netless-app-docs-viewer-footer-btn-playing>svg:nth-of-type(2){display:initial}.netless-app-docs-viewer-footer-btn~.netless-app-docs-viewer-footer-btn{margin-left:15px}.netless-app-docs-viewer-page-jumps{flex:1;display:flex;justify-content:center;align-items:center}.netless-app-docs-viewer-page-number{margin-left:auto;font-size:13px;user-select:none;white-space:nowrap;word-break:keep-all}.netless-app-docs-viewer-page-number-input{border:none;outline:none;width:3em;margin:0;padding:0 2px;text-align:right;font-size:13px;line-height:1;font-weight:400;font-family:inherit;border-radius:2px;color:currentColor;background:transparent;transition:background .4s;user-select:text;-webkit-tap-highlight-color:rgba(0,0,0,0)}.netless-app-docs-viewer-page-number-input:hover,.netless-app-docs-viewer-page-number-input:focus,.netless-app-docs-viewer-page-number-input:active{background:#fff;box-shadow:#63636333 0 2px 8px}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-footer-btn{cursor:not-allowed}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-footer-btn:hover{background:transparent}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-page-number-input{cursor:not-allowed}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-page-number-input:hover,.netless-app-docs-viewer-readonly .netless-app-docs-viewer-page-number-input:focus,.netless-app-docs-viewer-readonly .netless-app-docs-viewer-page-number-input:active{background:transparent;box-shadow:none}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-page-number-input:disabled{color:inherit}.netless-app-docs-viewer-readonly.netless-app-docs-viewer-float-footer{display:none}.telebox-color-scheme-dark .netless-app-docs-viewer-page-number-input{color:#a6a6a8}.telebox-color-scheme-dark .netless-app-docs-viewer-page-number-input:active,.telebox-color-scheme-dark .netless-app-docs-viewer-page-number-input:focus,.telebox-color-scheme-dark .netless-app-docs-viewer-page-number-input:hover{color:#222}.telebox-color-scheme-dark .netless-app-docs-viewer-footer{color:#a6a6a8;background:#2d2d33;border-top:none}.telebox-color-scheme-dark .netless-app-docs-viewer-footer-btn:hover{background:#212126}.telebox-color-scheme-dark .netless-app-docs-viewer-preview{background:rgba(50,50,50,.9)}.netless-app-docs-viewer-static-scrollbar{position:absolute;top:0;right:0;z-index:2147483647;width:8px;min-height:30px;margin:0;padding:0;border:none;outline:none;border-radius:4px;background:rgba(68,78,96,.4);box-shadow:1px 1px 8px #ffffffb3;opacity:0;transition:background .4s,opacity .4s 3s,transform .2s;user-select:none}.netless-app-docs-viewer-static-scrollbar.netless-app-docs-viewer-static-scrollbar-dragging{background:rgba(68,78,96,.6);opacity:1;transition:background .4s,opacity .4s 3s!important}.netless-app-docs-viewer-static-scrollbar:hover,.netless-app-docs-viewer-static-scrollbar:focus{background:rgba(68,78,96,.5)}.netless-app-docs-viewer-static-scrollbar:active{background:rgba(68,78,96,.6)}.netless-app-docs-viewer-content:hover .netless-app-docs-viewer-static-scrollbar{opacity:1;transition:background .4s,opacity .4s,transform .2s}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-static-scrollbar{display:none}.netless-app-docs-viewer-static-pages:hover .netless-app-docs-viewer-static-scrollbar{opacity:1;transition:background .4s,opacity .4s,transform .2s}.page-renderer-pages-container{position:relative;overflow:hidden}.page-renderer-page{position:absolute;top:0;left:0;background-position:center;background-size:cover;background-repeat:no-repeat}.page-renderer-pages-container.is-hwa .page-renderer-page{will-change:transform}.page-renderer-page-img{display:block;width:100%;height:auto;user-select:none}.netless-app-docs-viewer-static-pages{overflow:hidden;position:relative;height:100%;user-select:none}.netless-app-docs-viewer-static-page{display:block;width:100%;height:auto;user-select:none}.netless-app-docs-viewer-static-wb-view,.netless-app-docs-viewer-dynamic-wb-view{position:absolute;top:0;left:0;width:100%;height:100%;z-index:100;overflow:hidden}.netless-app-docs-viewer-dynamic-wb-view .cursor-clicker .ppt-event-source{cursor:pointer}
"use strict";var Re=Object.defineProperty,Ve=Object.defineProperties;var Me=Object.getOwnPropertyDescriptors;var X=Object.getOwnPropertySymbols;var Oe=Object.prototype.hasOwnProperty,ze=Object.prototype.propertyIsEnumerable;var J=(t,e,s)=>e in t?Re(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,R=(t,e)=>{for(var s in e||(e={}))Oe.call(e,s)&&J(t,s,e[s]);if(X)for(var s of X(e))ze.call(e,s)&&J(t,s,e[s]);return t},V=(t,e)=>Ve(t,Me(e));Object.defineProperty(exports,"__esModule",{value:!0});exports[Symbol.toStringTag]="Module";var De=`.netless-app-docs-viewer-content{position:relative;height:100%;overflow:hidden}.netless-app-docs-viewer-preview-mask{display:none;position:absolute;z-index:200;top:0;left:0;width:100%;height:100%}.netless-app-docs-viewer-preview{display:flex;flex-direction:column;align-items:center;position:absolute;z-index:300;top:0;left:0;width:33%;max-width:200px;height:100%;padding-top:10px;transform:translate(-100%);background:rgba(237,237,240,.9);box-shadow:inset -1px 0 #0000001c;transition:transform .4s}.netless-app-docs-viewer-preview-active .netless-app-docs-viewer-preview-mask{display:block}.netless-app-docs-viewer-preview-active .netless-app-docs-viewer-preview{transform:translate(0)}.netless-app-docs-viewer-preview-page{position:relative;display:block;width:55%;margin-bottom:10px;font-size:0;color:transparent;outline:none;border:7px solid transparent;border-radius:4px;transition:border-color .3s;user-select:none}.netless-app-docs-viewer-preview-page:hover,.netless-app-docs-viewer-preview-page.netless-app-docs-viewer-preview-page-active{border-color:#444e601a}.netless-app-docs-viewer-preview-page>img{width:100%;height:auto;box-sizing:border-box;border:1px solid rgba(0,0,0,.5);border-radius:1px;background-color:#fff;box-shadow:0 2px 8px #0000004d}.netless-app-docs-viewer-preview-page-name{position:absolute;top:1px;left:-10px;transform:translate(-100%);text-align:right;font-size:12px;color:#5f5f5f;user-select:none}.netless-app-docs-viewer-footer{box-sizing:border-box;height:26px;display:flex;align-items:center;padding:0 16px;border-top:1px solid #eeeef7;color:#191919}.netless-app-docs-viewer-float-footer{width:100%;min-height:26px;position:absolute;left:0;bottom:0;z-index:2000;background:rgba(249,249,252,.9);transition:opacity .4s}.netless-app-docs-viewer-footer-btn{box-sizing:border-box;width:26px;height:26px;font-size:0;margin:0;padding:3px;border:none;border-radius:1px;outline:none;color:currentColor;background:transparent;transition:background .4s;cursor:pointer;user-select:none;-webkit-tap-highlight-color:rgba(0,0,0,0)}.netless-app-docs-viewer-footer-btn:hover{background:rgba(237,237,240,.9)}@media (hover: none){.netless-app-docs-viewer-footer-btn:hover{background:transparent!important}}.netless-app-docs-viewer-footer-btn>svg{width:100%;height:100%}.netless-app-docs-viewer-footer-btn>svg:nth-of-type(2){display:none}.netless-app-docs-viewer-footer-btn.netless-app-docs-viewer-footer-btn-playing>svg:nth-of-type(1){display:none}.netless-app-docs-viewer-footer-btn.netless-app-docs-viewer-footer-btn-playing>svg:nth-of-type(2){display:initial}.netless-app-docs-viewer-footer-btn~.netless-app-docs-viewer-footer-btn{margin-left:15px}.netless-app-docs-viewer-page-jumps{flex:1;display:flex;justify-content:center;align-items:center}.netless-app-docs-viewer-page-number{margin-left:auto;font-size:13px;user-select:none;white-space:nowrap;word-break:keep-all}.netless-app-docs-viewer-page-number-input{border:none;outline:none;width:3em;margin:0;padding:0 2px;text-align:right;font-size:13px;line-height:1;font-weight:400;font-family:inherit;border-radius:2px;color:currentColor;background:transparent;transition:background .4s;user-select:text;-webkit-tap-highlight-color:rgba(0,0,0,0)}.netless-app-docs-viewer-page-number-input:hover,.netless-app-docs-viewer-page-number-input:focus,.netless-app-docs-viewer-page-number-input:active{background:#fff;box-shadow:#63636333 0 2px 8px}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-footer-btn{cursor:not-allowed}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-footer-btn:hover{background:transparent}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-page-number-input{cursor:not-allowed}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-page-number-input:hover,.netless-app-docs-viewer-readonly .netless-app-docs-viewer-page-number-input:focus,.netless-app-docs-viewer-readonly .netless-app-docs-viewer-page-number-input:active{background:transparent;box-shadow:none}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-page-number-input:disabled{color:inherit}.netless-app-docs-viewer-readonly.netless-app-docs-viewer-float-footer{display:none}.telebox-color-scheme-dark .netless-app-docs-viewer-page-number-input{color:#a6a6a8}.telebox-color-scheme-dark .netless-app-docs-viewer-page-number-input:active,.telebox-color-scheme-dark .netless-app-docs-viewer-page-number-input:focus,.telebox-color-scheme-dark .netless-app-docs-viewer-page-number-input:hover{color:#222}.telebox-color-scheme-dark .netless-app-docs-viewer-footer{color:#a6a6a8;background:#2d2d33;border-top:none}.telebox-color-scheme-dark .netless-app-docs-viewer-footer-btn:hover{background:#212126}.telebox-color-scheme-dark .netless-app-docs-viewer-preview{background:rgba(50,50,50,.9)}.netless-app-docs-viewer-static-scrollbar{position:absolute;top:0;right:0;z-index:2147483647;width:8px;min-height:30px;margin:0;padding:0;border:none;outline:none;border-radius:4px;background:rgba(68,78,96,.4);box-shadow:1px 1px 8px #ffffffb3;opacity:0;transition:background .4s,opacity .4s 3s,transform .2s;user-select:none}.netless-app-docs-viewer-static-scrollbar.netless-app-docs-viewer-static-scrollbar-dragging{background:rgba(68,78,96,.6);opacity:1;transition:background .4s,opacity .4s 3s!important}.netless-app-docs-viewer-static-scrollbar:hover,.netless-app-docs-viewer-static-scrollbar:focus{background:rgba(68,78,96,.5)}.netless-app-docs-viewer-static-scrollbar:active{background:rgba(68,78,96,.6)}.netless-app-docs-viewer-content:hover .netless-app-docs-viewer-static-scrollbar{opacity:1;transition:background .4s,opacity .4s,transform .2s}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-static-scrollbar{display:none}.netless-app-docs-viewer-static-pages:hover .netless-app-docs-viewer-static-scrollbar{opacity:1;transition:background .4s,opacity .4s,transform .2s}.page-renderer-pages-container{position:relative;overflow:hidden}.page-renderer-page{position:absolute;top:0;left:0;background-position:center;background-size:cover;background-repeat:no-repeat}.page-renderer-pages-container.is-hwa .page-renderer-page{will-change:transform}.page-renderer-page-img{display:block;width:100%;height:auto;user-select:none}.netless-app-docs-viewer-static-pages{overflow:hidden;position:relative;height:100%;user-select:none}.netless-app-docs-viewer-static-page{display:block;width:100%;height:auto;user-select:none}.netless-app-docs-viewer-static-wb-view,.netless-app-docs-viewer-dynamic-wb-view{position:absolute;top:0;left:0;width:100%;height:100%;z-index:100;overflow:hidden}.netless-app-docs-viewer-dynamic-wb-view .cursor-clicker .ppt-event-source{cursor:pointer}
`;const We=(t,e,s,i)=>{if(s==="length"||s==="prototype"||s==="arguments"||s==="caller")return;const r=Object.getOwnPropertyDescriptor(t,s),a=Object.getOwnPropertyDescriptor(e,s);!Be(r,a)&&i||Object.defineProperty(t,s,a)},Be=function(t,e){return t===void 0||t.configurable||t.writable===e.writable&&t.enumerable===e.enumerable&&t.configurable===e.configurable&&(t.writable||t.value===e.value)},Fe=(t,e)=>{const s=Object.getPrototypeOf(e);s!==Object.getPrototypeOf(t)&&Object.setPrototypeOf(t,s)},Ue=(t,e)=>`/* Wrapped ${t}*/
${e}`,Ye=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),je=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),Ge=(t,e,s)=>{const i=s===""?"":`with ${s.trim()}() `,r=Ue.bind(null,i,e.toString());Object.defineProperty(r,"name",je),Object.defineProperty(t,"toString",V(R({},Ye),{value:r}))},qe=(t,e,{ignoreNonConfigurable:s=!1}={})=>{const{name:i}=t;for(const r of Reflect.ownKeys(e))We(t,e,r,s);return Fe(t,e),Ge(t,e,i),t};var Xe=qe;const Je=(t,e={})=>{if(typeof t!="function")throw new TypeError(`Expected the first argument to be a function, got \`${typeof t}\``);const{wait:s=0,maxWait:i=Number.Infinity,before:r=!1,after:a=!0}=e;if(!r&&!a)throw new Error("Both `before` and `after` are false, function wouldn't be called.");let o,n,c;const h=function(...l){const d=this,Pe=()=>{o=void 0,n&&(clearTimeout(n),n=void 0),a&&(c=t.apply(d,l))},Ae=()=>{n=void 0,o&&(clearTimeout(o),o=void 0),a&&(c=t.apply(d,l))},He=r&&!o;return clearTimeout(o),o=setTimeout(Pe,s),i>0&&i!==Number.Infinity&&!n&&(n=setTimeout(Ae,i)),He&&(c=t.apply(d,l)),c};return Xe(h,t),h.cancel=()=>{o&&(clearTimeout(o),o=void 0),n&&(clearTimeout(n),n=void 0)},h},K="!#%()*+,-./:;=?@[]^_`{|}~ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",Ke=K.length,Z=Array(20),y=()=>{for(let t=0;t<20;t++)Z[t]=K.charAt(Math.random()*Ke);return Z.join("")};class C{constructor(){this.disposers=new Map}add(e,s=y()){return this.flush(s),this.disposers.set(s,e()),s}addDisposer(e,s=y()){return this.flush(s),this.disposers.set(s,e),s}addEventListener(e,s,i,r,a=y()){return this.add(()=>(e.addEventListener(s,i,r),()=>e.removeEventListener(s,i,r)),a),a}setTimeout(e,s,i=y()){return this.add(()=>{const r=window.setTimeout(()=>{this.remove(i),e()},s);return()=>window.clearTimeout(r)},i)}setInterval(e,s,i=y()){return this.add(()=>{const r=window.setInterval(e,s);return()=>window.clearInterval(r)},i)}remove(e){const s=this.disposers.get(e);return this.disposers.delete(e),s}flush(e){const s=this.remove(e);if(s)try{s()}catch(i){console.error(i)}}flushAll(){this.disposers.forEach(e=>{try{e()}catch(s){console.error(s)}}),this.disposers.clear()}}function Ze(t){const e="http://www.w3.org/2000/svg",s=document.createElementNS(e,"svg");s.setAttribute("class",`${t}-footer-icon-sidebar`),s.setAttribute("viewBox","0 0 64 64");const i=document.createElementNS(e,"path");return i.setAttribute("fill","currentColor"),i.setAttribute("d","M50 8H14c-3.309 0-6 2.691-6 6v36c0 3.309 2.691 6 6 6h36c3.309 0 6-2.691 6-6V14c0-3.309-2.691-6-6-6zM12 50V14c0-1.103.897-2 2-2h8v40h-8c-1.103 0-2-.897-2-2zm40 0c0 1.103-.897 2-2 2H26V12h24c1.103 0 2 .897 2 2z"),s.appendChild(i),s}function Qe(t){const e="http://www.w3.org/2000/svg",s=document.createElementNS(e,"svg");s.setAttribute("class",`${t}-footer-icon-arrow-left`),s.setAttribute("viewBox","0 0 500 500");const i=document.createElementNS(e,"path");return i.setAttribute("fill","currentColor"),i.setAttribute("d","M177.81 249.959L337.473 90.295c2.722-2.865 2.651-7.378-.143-10.1-2.793-2.65-7.163-2.65-9.956 0l-164.75 164.75c-2.793 2.793-2.793 7.306 0 10.1l164.75 164.75c2.865 2.722 7.378 2.65 10.099-.143 2.651-2.794 2.651-7.163 0-9.957L177.809 249.959z"),s.appendChild(i),s}function et(t){const e="http://www.w3.org/2000/svg",s=document.createElementNS(e,"svg");s.setAttribute("class",`${t}-footer-icon-arrow-right`),s.setAttribute("viewBox","0 0 500 500");const i=document.createElementNS(e,"path");return i.setAttribute("fill","currentColor"),i.setAttribute("d","M322.19 250.041L162.527 409.705c-2.722 2.865-2.651 7.378.143 10.1 2.793 2.65 7.163 2.65 9.956 0l164.75-164.75c2.793-2.793 2.793-7.306 0-10.1l-164.75-164.75c-2.865-2.722-7.378-2.65-10.099.143-2.651 2.794-2.651 7.163 0 9.957l159.664 159.736z"),s.appendChild(i),s}function tt(t){const e="http://www.w3.org/2000/svg",s=document.createElementNS(e,"svg");s.setAttribute("class",`${t}-footer-icon-play`),s.setAttribute("viewBox","0 0 500 500");const i=document.createElementNS(e,"path");return i.setAttribute("fill","currentColor"),i.setAttribute("d","M418.158 257.419L174.663 413.33c-6.017 3.919-15.708 3.772-21.291-.29-2.791-2.018-4.295-4.483-4.295-7.084V94.109c0-5.65 6.883-10.289 15.271-10.289 4.298 0 8.391 1.307 11.181 3.332l242.629 155.484c6.016 3.917 6.451 10.292.649 14.491-.216.154-.432.154-.649.292zM170.621 391.288l223.116-141.301L170.71 107.753l-.089 283.535z"),s.appendChild(i),s}function st(t){const e="http://www.w3.org/2000/svg",s=document.createElementNS(e,"svg");s.setAttribute("class",`${t}-footer-icon-pause`),s.setAttribute("viewBox","0 0 500 500");const i=document.createElementNS(e,"path");return i.setAttribute("fill","currentColor"),i.setAttribute("d","M312.491 78.261c0-6.159 4.893-11.213 11.04-11.213 6.158 0 11.211 5.054 11.211 11.213v343.478c0 6.159-5.053 11.213-11.211 11.213-6.147 0-11.04-5.054-11.04-11.213V78.261zM165.257 78.261c0-6.159 4.893-11.213 11.04-11.213 6.158 0 11.211 5.054 11.211 11.213v343.478c0 6.159-5.053 11.213-11.211 11.213-6.147 0-11.04-5.054-11.04-11.213V78.261z"),s.appendChild(i),s}const w=typeof window!="undefined",Q=w&&!("onscroll"in window)||typeof navigator!="undefined"&&/(gle|ing|ro)bot|crawl|spider/i.test(navigator.userAgent),ee=w&&"IntersectionObserver"in window,te=w&&"classList"in document.createElement("p"),se=w&&window.devicePixelRatio>1,it={elements_selector:".lazy",container:Q||w?document:null,threshold:300,thresholds:null,data_src:"src",data_srcset:"srcset",data_sizes:"sizes",data_bg:"bg",data_bg_hidpi:"bg-hidpi",data_bg_multi:"bg-multi",data_bg_multi_hidpi:"bg-multi-hidpi",data_poster:"poster",class_applied:"applied",class_loading:"loading",class_loaded:"loaded",class_error:"error",class_entered:"entered",class_exited:"exited",unobserve_completed:!0,unobserve_entered:!1,cancel_on_exit:!0,callback_enter:null,callback_exit:null,callback_applied:null,callback_loading:null,callback_loaded:null,callback_error:null,callback_finish:null,callback_cancel:null,use_native:!1},ie=t=>Object.assign({},it,t),re=function(t,e){let s;const i="LazyLoad::Initialized",r=new t(e);try{s=new CustomEvent(i,{detail:{instance:r}})}catch{s=document.createEvent("CustomEvent"),s.initCustomEvent(i,!1,!1,{instance:r})}window.dispatchEvent(s)},rt=(t,e)=>{if(!!e)if(!e.length)re(t,e);else for(let s=0,i;i=e[s];s+=1)re(t,i)},g="src",M="srcset",z="sizes",ae="poster",x="llOriginalAttrs",O="loading",oe="loaded",ne="applied",at="entered",D="error",ce="native",le="data-",he="ll-status",p=(t,e)=>t.getAttribute(le+e),ot=(t,e,s)=>{var i=le+e;if(s===null){t.removeAttribute(i);return}t.setAttribute(i,s)},E=t=>p(t,he),b=(t,e)=>ot(t,he,e),N=t=>b(t,null),W=t=>E(t)===null,nt=t=>E(t)===O,ct=t=>E(t)===D,B=t=>E(t)===ce,lt=[O,oe,ne,D],ht=t=>lt.indexOf(E(t))>=0,f=(t,e,s,i)=>{if(!!t){if(i!==void 0){t(e,s,i);return}if(s!==void 0){t(e,s);return}t(e)}},v=(t,e)=>{if(te){t.classList.add(e);return}t.className+=(t.className?" ":"")+e},u=(t,e)=>{if(te){t.classList.remove(e);return}t.className=t.className.replace(new RegExp("(^|\\s+)"+e+"(\\s+|$)")," ").replace(/^\s+/,"").replace(/\s+$/,"")},dt=t=>{t.llTempImage=document.createElement("IMG")},pt=t=>{delete t.llTempImage},de=t=>t.llTempImage,k=(t,e)=>{if(!e)return;const s=e._observer;!s||s.unobserve(t)},ut=t=>{t.disconnect()},gt=(t,e,s)=>{e.unobserve_entered&&k(t,s)},F=(t,e)=>{!t||(t.loadingCount+=e)},ft=t=>{!t||(t.toLoadCount-=1)},pe=(t,e)=>{!t||(t.toLoadCount=e)},wt=t=>t.loadingCount>0,bt=t=>t.toLoadCount>0,ue=t=>{let e=[];for(let s=0,i;i=t.children[s];s+=1)i.tagName==="SOURCE"&&e.push(i);return e},U=(t,e)=>{const s=t.parentNode;if(!s||s.tagName!=="PICTURE")return;ue(s).forEach(e)},ge=(t,e)=>{ue(t).forEach(e)},L=[g],fe=[g,ae],P=[g,M,z],A=t=>!!t[x],we=t=>t[x],be=t=>delete t[x],T=(t,e)=>{if(A(t))return;const s={};e.forEach(i=>{s[i]=t.getAttribute(i)}),t[x]=s},mt=t=>{A(t)||(t[x]={backgroundImage:t.style.backgroundImage})},vt=(t,e,s)=>{if(!s){t.removeAttribute(e);return}t.setAttribute(e,s)},$=(t,e)=>{if(!A(t))return;const s=we(t);e.forEach(i=>{vt(t,i,s[i])})},St=t=>{if(!A(t))return;const e=we(t);t.style.backgroundImage=e.backgroundImage},yt=(t,e,s)=>{v(t,e.class_applied),b(t,ne),!!s&&(e.unobserve_completed&&k(t,e),f(e.callback_applied,t,s))},me=(t,e,s)=>{v(t,e.class_loading),b(t,O),!!s&&(F(s,1),f(e.callback_loading,t,s))},m=(t,e,s)=>{!s||t.setAttribute(e,s)},ve=(t,e)=>{m(t,z,p(t,e.data_sizes)),m(t,M,p(t,e.data_srcset)),m(t,g,p(t,e.data_src))},xt=(t,e)=>{U(t,s=>{T(s,P),ve(s,e)}),T(t,P),ve(t,e)},Et=(t,e)=>{T(t,L),m(t,g,p(t,e.data_src))},Tt=(t,e)=>{ge(t,s=>{T(s,L),m(s,g,p(s,e.data_src))}),T(t,fe),m(t,ae,p(t,e.data_poster)),m(t,g,p(t,e.data_src)),t.load()},$t=(t,e,s)=>{const i=p(t,e.data_bg),r=p(t,e.data_bg_hidpi),a=se&&r?r:i;!a||(t.style.backgroundImage=`url("${a}")`,de(t).setAttribute(g,a),me(t,e,s))},_t=(t,e,s)=>{const i=p(t,e.data_bg_multi),r=p(t,e.data_bg_multi_hidpi),a=se&&r?r:i;!a||(t.style.backgroundImage=a,yt(t,e,s))},Se={IMG:xt,IFRAME:Et,VIDEO:Tt},It=(t,e)=>{const s=Se[t.tagName];!s||s(t,e)},Ct=(t,e,s)=>{const i=Se[t.tagName];!i||(i(t,e),me(t,e,s))},Nt=["IMG","IFRAME","VIDEO"],kt=t=>Nt.indexOf(t.tagName)>-1,ye=(t,e)=>{e&&!wt(e)&&!bt(e)&&f(t.callback_finish,e)},xe=(t,e,s)=>{t.addEventListener(e,s),t.llEvLisnrs[e]=s},Lt=(t,e,s)=>{t.removeEventListener(e,s)},Y=t=>!!t.llEvLisnrs,Pt=(t,e,s)=>{Y(t)||(t.llEvLisnrs={});const i=t.tagName==="VIDEO"?"loadeddata":"load";xe(t,i,e),xe(t,"error",s)},j=t=>{if(!Y(t))return;const e=t.llEvLisnrs;for(let s in e){const i=e[s];Lt(t,s,i)}delete t.llEvLisnrs},Ee=(t,e,s)=>{pt(t),F(s,-1),ft(s),u(t,e.class_loading),e.unobserve_completed&&k(t,s)},At=(t,e,s,i)=>{const r=B(e);Ee(e,s,i),v(e,s.class_loaded),b(e,oe),f(s.callback_loaded,e,i),r||ye(s,i)},Ht=(t,e,s,i)=>{const r=B(e);Ee(e,s,i),v(e,s.class_error),b(e,D),f(s.callback_error,e,i),r||ye(s,i)},G=(t,e,s)=>{const i=de(t)||t;if(Y(i))return;Pt(i,o=>{At(o,t,e,s),j(i)},o=>{Ht(o,t,e,s),j(i)})},Rt=(t,e,s)=>{dt(t),G(t,e,s),mt(t),$t(t,e,s),_t(t,e,s)},Vt=(t,e,s)=>{G(t,e,s),Ct(t,e,s)},q=(t,e,s)=>{kt(t)?Vt(t,e,s):Rt(t,e,s)},Mt=(t,e,s)=>{t.setAttribute("loading","lazy"),G(t,e,s),It(t,e),b(t,ce)},Te=t=>{t.removeAttribute(g),t.removeAttribute(M),t.removeAttribute(z)},zt=t=>{U(t,e=>{Te(e)}),Te(t)},$e=t=>{U(t,e=>{$(e,P)}),$(t,P)},Ot=t=>{ge(t,e=>{$(e,L)}),$(t,fe),t.load()},Dt=t=>{$(t,L)},Wt={IMG:$e,IFRAME:Dt,VIDEO:Ot},Bt=t=>{const e=Wt[t.tagName];if(!e){St(t);return}e(t)},Ft=(t,e)=>{W(t)||B(t)||(u(t,e.class_entered),u(t,e.class_exited),u(t,e.class_applied),u(t,e.class_loading),u(t,e.class_loaded),u(t,e.class_error))},Ut=(t,e)=>{Bt(t),Ft(t,e),N(t),be(t)},Yt=(t,e,s,i)=>{!s.cancel_on_exit||!nt(t)||t.tagName==="IMG"&&(j(t),zt(t),$e(t),u(t,s.class_loading),F(i,-1),N(t),f(s.callback_cancel,t,e,i))},jt=(t,e,s,i)=>{const r=ht(t);b(t,at),v(t,s.class_entered),u(t,s.class_exited),gt(t,s,i),f(s.callback_enter,t,e,i),!r&&q(t,s,i)},Gt=(t,e,s,i)=>{W(t)||(v(t,s.class_exited),Yt(t,e,s,i),f(s.callback_exit,t,e,i))},qt=["IMG","IFRAME","VIDEO"],_e=t=>t.use_native&&"loading"in HTMLImageElement.prototype,Xt=(t,e,s)=>{t.forEach(i=>{qt.indexOf(i.tagName)!==-1&&Mt(i,e,s)}),pe(s,0)},Jt=t=>t.isIntersecting||t.intersectionRatio>0,Kt=t=>({root:t.container===document?null:t.container,rootMargin:t.thresholds||t.threshold+"px"}),Zt=(t,e,s)=>{t.forEach(i=>Jt(i)?jt(i.target,i,e,s):Gt(i.target,i,e,s))},Qt=(t,e)=>{e.forEach(s=>{t.observe(s)})},es=(t,e)=>{ut(t),Qt(t,e)},ts=(t,e)=>{!ee||_e(t)||(e._observer=new IntersectionObserver(s=>{Zt(s,t,e)},Kt(t)))},Ie=t=>Array.prototype.slice.call(t),H=t=>t.container.querySelectorAll(t.elements_selector),ss=t=>Ie(t).filter(W),is=t=>ct(t),rs=t=>Ie(t).filter(is),Ce=(t,e)=>ss(t||H(e)),as=(t,e)=>{rs(H(t)).forEach(i=>{u(i,t.class_error),N(i)}),e.update()},os=(t,e)=>{!w||window.addEventListener("online",()=>{as(t,e)})},_=function(t,e){const s=ie(t);this._settings=s,this.loadingCount=0,ts(s,this),os(s,this),this.update(e)};_.prototype={update:function(t){const e=this._settings,s=Ce(t,e);if(pe(this,s.length),Q||!ee){this.loadAll(s);return}if(_e(e)){Xt(s,e,this);return}es(this._observer,s)},destroy:function(){this._observer&&this._observer.disconnect(),H(this._settings).forEach(t=>{be(t)}),delete this._observer,delete this._settings,delete this.loadingCount,delete this.toLoadCount},loadAll:function(t){const e=this._settings;Ce(t,e).forEach(i=>{k(i,this),q(i,e,this)})},restoreAll:function(){const t=this._settings;H(t).forEach(e=>{Ut(e,t)})}};_.load=(t,e)=>{const s=ie(e);q(t,s)};_.resetStatus=t=>{N(t)};w&&rt(_,window.lazyLoadOptions);class Ne{constructor({readonly:e,box:s,pages:i,onNewPageIndex:r,onPlay:a}){if(this.pageIndex=0,this.namespace="netless-app-docs-viewer",this.isShowPreview=!1,this.isSmallBox=!1,this.sideEffect=new C,i.length<=0)throw new Error("[DocsViewer] Empty pages.");this.readonly=e,this.box=s,this.pages=i,this.onNewPageIndex=r,this.onPlay=a,this.render()}mount(){this.box.mountContent(this.$content),this.box.mountFooter(this.$footer),this.sideEffect.add(()=>{const e=new _({container:this.$preview,elements_selector:`.${this.wrapClassName("preview-page>img")}`});return()=>e.destroy()},"preview-lazyload")}unmount(){this.$content.remove(),this.$footer.remove()}setReadonly(e){this.readonly!==e&&(this.readonly=e,this.$content.classList.toggle(this.wrapClassName("readonly"),e),this.$footer.classList.toggle(this.wrapClassName("readonly"),e),this.$pageNumberInput.disabled=e)}destroy(){this.sideEffect.flushAll(),this.unmount()}setPageIndex(e){Number.isNaN(e)||(this.pageIndex=e,this.$pageNumberInput.value=String(e+1))}setSmallBox(e){this.isSmallBox!==e&&(this.isSmallBox=e,this.$footer.classList.toggle(this.wrapClassName("float-footer"),e))}render(){return this.renderContent(),this.renderFooter(),this.$content}renderContent(){if(!this.$content){const e=document.createElement("div");e.className=this.wrapClassName("content"),this.$content=e,this.readonly&&e.classList.add(this.wrapClassName("readonly")),e.appendChild(this.renderPreviewMask()),e.appendChild(this.renderPreview())}return this.$content}renderPreview(){if(!this.$preview){const e=document.createElement("div");e.className=this.wrapClassName("preview")+" tele-fancy-scrollbar",this.$preview=e;const s=this.wrapClassName("preview-page"),i=this.wrapClassName("preview-page-name");this.pages.forEach((r,a)=>{var d;const o=(d=r.thumbnail)!=null?d:r.src.startsWith("ppt")?void 0:r.src;if(!o)return;const n=String(a),c=document.createElement("a");c.className=s+" "+this.wrapClassName(`preview-page-${a}`),c.setAttribute("href","#"),c.dataset.pageIndex=n;const h=document.createElement("span");h.className=i,h.textContent=String(a+1),h.dataset.pageIndex=n;const l=document.createElement("img");l.width=r.width,l.height=r.height,l.dataset.src=o,l.dataset.pageIndex=n,c.appendChild(l),c.appendChild(h),e.appendChild(c)}),this.sideEffect.addEventListener(e,"click",r=>{var o;if(this.readonly)return;const a=(o=r.target.dataset)==null?void 0:o.pageIndex;a&&(r.preventDefault(),r.stopPropagation(),r.stopImmediatePropagation(),this.onNewPageIndex(Number(a)),this.togglePreview(!1))})}return this.$preview}renderPreviewMask(){return this.$previewMask||(this.$previewMask=document.createElement("div"),this.$previewMask.className=this.wrapClassName("preview-mask"),this.sideEffect.addEventListener(this.$previewMask,"click",e=>{this.readonly||e.target===this.$previewMask&&this.togglePreview(!1)})),this.$previewMask}renderFooter(){if(!this.$footer){const e=document.createElement("div");if(e.className=this.wrapClassName("footer"),this.$footer=e,this.readonly&&e.classList.add(this.wrapClassName("readonly")),this.isSmallBox&&e.classList.add(this.wrapClassName("float-footer")),this.pages.some(c=>c.thumbnail||!c.src.startsWith("ppt"))){const c=this.renderFooterBtn("btn-sidebar",Ze(this.namespace));this.sideEffect.addEventListener(c,"click",()=>{this.readonly||this.togglePreview()}),this.$footer.appendChild(c)}const s=document.createElement("div");s.className=this.wrapClassName("page-jumps");const i=this.renderFooterBtn("btn-page-back",Qe(this.namespace));if(this.sideEffect.addEventListener(i,"click",()=>{this.readonly||this.onNewPageIndex(this.pageIndex-1)}),s.appendChild(i),this.onPlay){const c=this.renderFooterBtn("btn-page-play",tt(this.namespace),st(this.namespace)),h=()=>{this.sideEffect.setTimeout(()=>{c.classList.toggle(this.wrapClassName("footer-btn-playing"),!1)},500,"returnPlay")};this.sideEffect.addEventListener(c,"click",()=>{this.readonly||(c.classList.toggle(this.wrapClassName("footer-btn-playing"),!0),this.onPlay&&this.onPlay(),h())}),s.appendChild(c)}const r=this.renderFooterBtn("btn-page-next",et(this.namespace));this.sideEffect.addEventListener(r,"click",()=>{this.readonly||this.onNewPageIndex(this.pageIndex+1)}),s.appendChild(r);const a=document.createElement("div");a.className=this.wrapClassName("page-number");const o=document.createElement("input");o.className=this.wrapClassName("page-number-input"),o.value=String(this.pageIndex+1),this.readonly&&(o.disabled=!0),this.$pageNumberInput=o,this.sideEffect.addEventListener(o,"focus",()=>{o.select()}),this.sideEffect.addEventListener(o,"change",()=>{this.readonly||o.value&&this.onNewPageIndex(Number(o.value)-1)});const n=document.createElement("span");n.textContent=" / "+this.pages.length,a.appendChild(o),a.appendChild(n),this.$footer.appendChild(s),this.$footer.appendChild(a)}return this.$footer}renderFooterBtn(e,s,i){const r=document.createElement("button");return r.className=this.wrapClassName("footer-btn")+" "+this.wrapClassName(e),r.appendChild(s),i&&r.appendChild(i),r}togglePreview(e){if(this.isShowPreview=e!=null?e:!this.isShowPreview,this.$content.classList.toggle(this.wrapClassName("preview-active"),this.isShowPreview),this.isShowPreview){const s=this.$preview.querySelector("."+this.wrapClassName(`preview-page-${this.pageIndex}`));s&&this.$preview.scrollTo({top:s.offsetTop-16})}}wrapClassName(e){return`${this.namespace}-${e}`}}function S(t,e,s){return Math.min(Math.max(t,e),s)}function ke(t){return t.touches?t.touches[0]:t}function Le(t){t.stopPropagation(),t.cancelable&&t.preventDefault()}class ns{constructor(e){var s,i,r;this.velocity=0,this.paused=!0,this._animationFrameID=null,this._loopTimestamp=0,this.looper=a=>{if(this.paused)return;let o=Math.floor((a-this._loopTimestamp)/1e3*60)+1;for(this._loopTimestamp=a;o-- >0;)this.stepper();this.onStep(this.current,this),!this.paused&&this.current!==this.target&&window.requestAnimationFrame(this.looper)},this.current=(s=e.start)!=null?s:0,this.target=this.current,this.stiffness=(i=e.stiffness)!=null?i:170,this.damping=(r=e.damping)!=null?r:26,this.onStep=e.onStep}stepTo(e,s){this.paused&&s!=null&&(this.current=s),this.paused=!1,this.target=e,this.onStep(this.current,this),this._loopTimestamp=Date.now(),window.requestAnimationFrame(this.looper)}pause(){this.paused=!0}destroy(){this.pause()}stepper(){const e=-this.stiffness*(this.current-this.target),s=-this.damping*this.velocity,i=this.velocity+(e+s)/60,r=this.current+i/60;Math.abs(i-0)<.01&&Math.abs(r-this.target)<.01?(this.current=this.target,this.velocity=0):(this.current=r,this.velocity=i)}}class cs{constructor(e,s,i){this.scale=1,this.lastVisit=Date.now(),this.pageOffsetY=0,this.visible=!0,this.index=e,this.page=s,this.scale=i;const r=document.createElement("div");r.className="page-renderer-page",r.dataset.index=`${e}`,r.style.width=`${s.width*i}px`,r.style.height=`${s.height*i}px`,s.thumbnail&&(r.style.backgroundImage=`url("${s.thumbnail}")`);const a=document.createElement("img");a.className="page-renderer-page-img",a.width=s.width,a.height=s.height,a.src=s.src,r.appendChild(a),this.$page=r}translateY(e){Math.abs(e-this.pageOffsetY)>=.001&&(this.pageOffsetY=e,window.requestAnimationFrame?window.requestAnimationFrame(()=>{this.$page.style.transform=`translateY(${e*this.scale}px)`}):this.$page.style.transform=`translateY(${e*this.scale}px)`)}setScale(e){Math.abs(e-this.scale)>=.001&&(this.scale=e,this.$page.style.width=`${this.page.width*this.scale}px`,this.$page.style.height=`${this.page.height*this.scale}px`,this.$page.style.transform=`translateY(${this.pageOffsetY*this.scale}px)`)}setVisible(e){e!==this.visible&&(this.visible=e,this.$page.style.opacity=e?"1":"0")}}const ls=window.requestIdleCallback||(t=>window.setTimeout(t,5e3)),hs=window.cancelIdleCallback||window.clearTimeout;class ds{constructor(e,s){this.pages=e,this.scale=s,this.els=new Map,this.maxElCount=200,this.gcTimer=null,this.gc=()=>{if(this.gcTimer=null,this.els.size>this.maxElCount){const i=[...this.els.values()].sort((r,a)=>a.lastVisit-r.lastVisit);for(let r=Math.floor(this.maxElCount/4);r<i.length;r++)this.els.delete(i[r].index)}}}getEl(e){let s=this.els.get(e);return s||(s=new cs(e,this.pages[e],this.scale),this.els.set(e,s)),s.lastVisit=Date.now(),this.els.size>this.maxElCount&&this.gcTimer===null&&(this.gcTimer=ls(this.gc)),s}setScale(e){e!==this.scale&&(this.scale=e,this.els.forEach(s=>s.setScale(e)))}destroy(){this.els.clear(),this.gcTimer!==null&&(hs(this.gcTimer),this.gcTimer=null)}}class ps{constructor(e){this._hwaTimeout=NaN,this._turnOffHWA=()=>{window.clearTimeout(this._hwaTimeout),this._hwaTimeout=NaN,this.$pages.classList.toggle("is-hwa",!1)},this.pagesScrollTop=e.pagesScrollTop||0,this.containerWidth=e.containerWidth||1,this.containerHeight=e.containerHeight||1,this.pages=e.pages.map(a=>{if(a.thumbnail)return a;try{const o=new URL(a.src);return o.searchParams.set("x-oss-process","image/resize,l_50"),V(R({},a),{thumbnail:o.toString()})}catch(o){return console.error(o),a}});const s=Array(this.pages.length);let i=1/0,r=0;this.pagesIntrinsicHeight=this.pages.reduce((a,o,n)=>(s[n]=a,o.width>r&&(r=o.width),o.height<=i&&(i=o.height),a+o.height),0),this.pagesIntrinsicWidth=r,this.pagesMinHeight=i,this.pagesIntrinsicYs=s,this.scale=this._calcScale(),this.threshold=this._calcThreshold(),this.onPageIndexChanged=e.onPageIndexChanged,this.pageScrollIndex=0,this.pagesScrollTop!==0&&(this.pageScrollIndex=this.findScrollPageIndex(),this.onPageIndexChanged&&this.pageScrollIndex>0&&this.onPageIndexChanged(this.pageScrollIndex)),this.pageElManager=new ds(this.pages,this.scale),this.$pages=this.renderPages()}setContainerSize(e,s){e>0&&s>0&&(e!==this.containerWidth||s!==this.containerHeight)&&(this.containerWidth=e,this.containerHeight=s,this.$pages.style.width=`${this.containerWidth}px`,this.$pages.style.height=`${this.containerHeight}px`,this.scale=this._calcScale(),this.threshold=this._calcThreshold(),this.pageElManager.setScale(this.scale),this.$pages.parentElement&&this.pagesScrollTo(this.pagesScrollTop,!0))}renderPages(){const e=document.createElement("div");return e.className="page-renderer-pages-container",e.style.width=`${this.containerWidth}px`,e.style.height=`${this.containerHeight}px`,e}pagesScrollTo(e,s){if(e=S(e,0,this.pagesIntrinsicHeight-this.containerHeight/this.scale),s||Math.abs(e-this.pagesScrollTop)>=.001){this._turnOnHWA(),this.pagesScrollTop=e;const i=this.findScrollPageIndex(),r=Math.max(i-this.threshold,0),a=Math.min(i+this.threshold,this.pages.length-1);for(let o=0;o<this.$pages.children.length;o++){const n=this.$pages.children[o],c=Number(n.dataset.index);c>=r&&c<=a||(n.remove(),o--)}for(let o=r;o<=a;o++){const n=this.pageElManager.getEl(o);n.$page.parentElement!==this.$pages&&this.$pages.appendChild(n.$page),n.translateY(this.pagesIntrinsicYs[o]-this.pagesScrollTop)}i!==this.pageScrollIndex&&(this.pageScrollIndex=i,this.onPageIndexChanged&&this.onPageIndexChanged(i))}}findScrollPageIndex(){for(let e=0;e<this.pagesIntrinsicYs.length;e++)if(this.pagesIntrinsicYs[e]+this.pages[e].height-this.pagesScrollTop>=.001)return e;return this.pagesIntrinsicYs.length-1}mount(e){e.appendChild(this.$pages),this.pagesScrollTo(this.pagesScrollTop,!0)}unmount(){this.$pages.remove()}destroy(){this.unmount(),this.onPageIndexChanged=void 0,this.pageElManager.destroy(),this._hwaTimeout&&(window.clearTimeout(this._hwaTimeout),this._hwaTimeout=NaN)}_calcScale(){return this.containerWidth/this.pagesIntrinsicWidth||1}_calcThreshold(){return S(Math.ceil(this.containerHeight/this.scale/this.pagesMinHeight/2),1,this.pages.length)}_turnOnHWA(){this._hwaTimeout?window.clearTimeout(this._hwaTimeout):this.$pages.classList.toggle("is-hwa",!0),this._hwaTimeout=window.setTimeout(this._turnOffHWA,1e3)}}const us=30;class gs{constructor(e){this.sideEffect=new C,this.pagesScrollTop=e.pagesScrollTop||0,this.containerWidth=e.containerWidth||1,this.containerHeight=e.containerHeight||1,this.pagesWidth=e.pagesWidth||1,this.pagesHeight=e.pagesHeight||1,this.scale=this._calcScale(),this.scrollbarMinHeight=e.scrollbarMinHeight||us,this.scrollbarHeight=this._calcScrollbarHeight(),this.readonly=e.readonly,this.wrapClassName=e.wrapClassName,this.onDragScroll=e.onDragScroll,this.$scrollbar=this.renderScrollbar()}mount(e){e.appendChild(this.$scrollbar),this.pagesScrollTo(this.pagesScrollTop,!0)}unmount(){this.$scrollbar.remove()}setReadonly(e){this.readonly=e}setContainerSize(e,s){e>0&&s>0&&(e!==this.containerWidth||s!==this.containerHeight)&&(this.containerWidth=e,this.containerHeight=s,this.scale=this._calcScale(),this._updateScrollbarHeight(),this.$scrollbar.parentElement&&this.pagesScrollTo(this.pagesScrollTop,!0))}pagesScrollTo(e,s){if(e=S(e,0,this.pagesHeight-this.containerHeight/this.scale),s||Math.abs(e-this.pagesScrollTop)>=.001){this.pagesScrollTop=e;const i=this.pagesScrollTop*this.scale,r=this.pagesHeight*this.scale,a=i/(r-this.containerHeight)*(this.containerHeight-this.scrollbarHeight);window.requestAnimationFrame?window.requestAnimationFrame(()=>{this.$scrollbar.style.transform=`translateY(${a}px)`}):this.$scrollbar.style.transform=`translateY(${a}px)`}}destroy(){this.unmount(),this.onDragScroll=void 0,this.sideEffect.flushAll()}renderScrollbar(){const e=document.createElement("button");e.className=this.wrapClassName("scrollbar"),e.style.minHeight=`${this.scrollbarMinHeight}px`,e.style.height=`${this.scrollbarHeight}px`;const s=i=>{if(this.readonly||i.button!=null&&i.button!==0)return;Le(i);const r=this.wrapClassName("scrollbar-dragging");e.classList.toggle(r,!0);const a=this.pagesScrollTop,{clientY:o}=ke(i),n=h=>{if(this.readonly)return;const{clientY:l}=ke(h),d=(l-o)/this.scale;Math.abs(d)>0&&this.onDragScroll&&this.onDragScroll(a+d*(this.pagesHeight*this.scale/this.containerHeight))},c=()=>{e.classList.toggle(r,!1),window.removeEventListener("mousemove",n,!0),window.removeEventListener("touchmove",n,!0),window.removeEventListener("mouseup",c,!0),window.removeEventListener("touchend",c,!0),window.removeEventListener("touchcancel",c,!0)};window.addEventListener("mousemove",n,!0),window.addEventListener("touchmove",n,!0),window.addEventListener("mouseup",c,!0),window.addEventListener("touchend",c,!0),window.addEventListener("touchcancel",c,!0)};return this.sideEffect.addEventListener(e,"mousedown",s),this.sideEffect.addEventListener(e,"touchstart",s),e}_calcScale(){return this.containerWidth/this.pagesWidth||1}_calcScrollbarHeight(){return S(this.containerHeight/(this.pagesHeight*this.scale)*this.containerHeight,this.scrollbarMinHeight,this.containerHeight)}_updateScrollbarHeight(){const e=this._calcScrollbarHeight();Math.abs(e-this.scrollbarHeight)>.001&&(this.scrollbarHeight=e,this.$scrollbar.style.height=`${e}px`)}}const I=640;class fs{constructor({whiteboardView:e,readonly:s,box:i,pages:r,pageScrollTop:a=0,mountWhiteboard:o,onUserScroll:n}){this.sideEffect=new C,this.userScrolling=!1,this.onNewPageIndex=d=>{this.scrollToPage(d)},this.whiteboardView=e,this.readonly=s,this.box=i,this.pages=r,this.mountWhiteboard=o,this._onUserScroll=n;const c=this.debounce(()=>{this.userScrolling=!1,this._onUserScroll&&this._onUserScroll(this.pageRenderer.pagesScrollTop)},{wait:80},"debounce-updateUserScroll");this.updateUserScroll=()=>{this.userScrolling=!0,c()},this.viewer=new Ne({readonly:s,box:i,pages:r,onNewPageIndex:this.onNewPageIndex});const{width:h,height:l}=this.whiteboardView.size;this.pageRenderer=new ps({pagesScrollTop:a,pages:this.pages,containerWidth:h,containerHeight:l,onPageIndexChanged:this.viewer.setPageIndex.bind(this.viewer)}),this.scrollbar=new gs({pagesScrollTop:this.pageRenderer.pagesScrollTop,containerWidth:h,containerHeight:l,pagesWidth:this.pageRenderer.pagesIntrinsicWidth,pagesHeight:this.pageRenderer.pagesIntrinsicHeight,readonly:this.readonly,wrapClassName:this.wrapClassName.bind(this),onDragScroll:d=>{this.pageScrollTo(d),this.updateUserScroll()}}),this.pageScrollStepper=new ns({start:this.pageRenderer.pagesScrollTop,onStep:d=>{this.pageScrollTo(d)}}),this.render()}mount(){return this.viewer.mount(),this.setupScrollListener(),this.sideEffect.add(()=>{const e=this.renderRatioHeight.bind(this);return this.box.events.on("visual_resize",e),()=>this.box.events.off("visual_resize",e)}),this.sideEffect.setTimeout(()=>{this.userScrolling||this.pageScrollTo(this.pageRenderer.pagesScrollTop)},100),this}unmount(){return this.viewer.unmount(),this}setReadonly(e){this.readonly!==e&&(this.readonly=e,this.viewer.setReadonly(e),this.scrollbar.setReadonly(e))}destroy(){this.sideEffect.flushAll(),this.pageScrollStepper.destroy(),this._onUserScroll=void 0,this.unmount(),this.viewer.destroy(),this.pageRenderer.destroy(),this.scrollbar.destroy()}syncPageScrollTop(e){!this.userScrolling&&e>=0&&Math.abs(this.pageRenderer.pagesScrollTop-e)>.01&&this.pageScrollStepper.stepTo(e,this.pageRenderer.pagesScrollTop)}render(){this.pageRenderer.mount(this.viewer.$content),this.viewer.$content.appendChild(this.renderWhiteboardView()),this.scrollbar.mount(this.viewer.$content),this.renderRatioHeight()}renderRatioHeight(){const e=this.box.absoluteHeight,s=e<=I;if(this.viewer.setSmallBox(s),s){const i=26/I,r=26/e,a=26/I,o=0,n=Math.max((i+a-(r+o))/2,0);if(this.box.$titleBar){const c=r+n;this.box.$titleBar.style.height=`${c*100}%`}if(this.box.$footer){const c=o+n;this.box.$footer.style.height=`${c*100}%`}}else{if(this.box.$titleBar){const i=Math.max(26/I,26/e);this.box.$titleBar.style.height=`${i*100}%`}if(this.box.$footer){const i=Math.max(26/I,26/e);this.box.$footer.style.height=`${i*100}%`}}}renderWhiteboardView(){return this.$whiteboardView||(this.$whiteboardView=document.createElement("div"),this.$whiteboardView.className=this.wrapClassName("wb-view"),this.mountWhiteboard(this.$whiteboardView),this.sideEffect.addEventListener(this.$whiteboardView,"wheel",e=>{Le(e),this.readonly||(this.pageScrollTo(this.pageRenderer.pagesScrollTop+e.deltaY),this.updateUserScroll())},{passive:!1,capture:!0}),this.sideEffect.addEventListener(this.$whiteboardView,"touchmove",e=>{this.readonly||e.touches.length<=1||this.updateUserScroll()},{passive:!0,capture:!0})),this.$whiteboardView}scrollTopPageToEl(e){return e*this.pageRenderer.scale}scrollTopElToPage(e){return e/this.pageRenderer.scale}elScrollTo(e){this.pageScrollTo(this.scrollTopElToPage(e))}pageScrollTo(e){const s=this.scrollTopElToPage(this.whiteboardView.size.height/2);this.whiteboardView.moveCamera({centerY:S(e+s,s,this.pageRenderer.pagesIntrinsicHeight-s),animationMode:"immediately"})}scrollToPage(e){if(!this.readonly&&!Number.isNaN(e)){const s=this.pageRenderer.pagesIntrinsicYs[e];s>=0&&(this.pageScrollTo(s+5/this.pageRenderer.scale),this.updateUserScroll())}}setupScrollListener(){this.sideEffect.add(()=>{const e=s=>{const{width:i,height:r}=this.whiteboardView.size;if(i<=0||r<=0)return;const a=s.centerY-this.pageRenderer.containerHeight/this.pageRenderer.scale/2;this.pageRenderer.pagesScrollTo(a),this.scrollbar.pagesScrollTo(a)};return this.whiteboardView.callbacks.on("onCameraUpdated",e),()=>this.whiteboardView.callbacks.off("onCameraUpdated",e)}),this.sideEffect.add(()=>{const e=({width:s,height:i})=>{if(s<=0||i<=0)return;this.pageRenderer.setContainerSize(s,i),this.scrollbar.setContainerSize(s,i);const{pagesIntrinsicWidth:r,pagesIntrinsicHeight:a}=this.pageRenderer;this.whiteboardView.moveCameraToContain({originX:0,originY:this.pageRenderer.pagesScrollTop,width:r,height:i/this.pageRenderer.scale,animationMode:"immediately"}),this.whiteboardView.setCameraBound({damping:1,maxContentMode:()=>this.pageRenderer.scale,minContentMode:()=>this.pageRenderer.scale,centerX:r/2,centerY:a/2,width:r,height:a})};return this.whiteboardView.callbacks.on("onSizeUpdated",e),()=>{this.whiteboardView.callbacks.off("onSizeUpdated",e)}},"whiteboard-size-update"),this.sideEffect.addEventListener(window,"keyup",e=>{if(this.readonly||!this.box.focus||this.box.minimized)return;let s=null;switch(e.key){case"PageDown":{s=this.pageRenderer.pagesScrollTop+this.pageRenderer.containerHeight/this.pageRenderer.scale;break}case"PageUp":{s=this.pageRenderer.pagesScrollTop-this.pageRenderer.containerHeight/this.pageRenderer.scale;break}case"ArrowDown":{s=this.pageRenderer.pagesScrollTop+this.pageRenderer.containerHeight/4/this.pageRenderer.scale;break}case"ArrowUp":{s=this.pageRenderer.pagesScrollTop-this.pageRenderer.containerHeight/4/this.pageRenderer.scale;break}}s!==null&&(this._onUserScroll?this._onUserScroll(s):(this.pageScrollTo(s),this.updateUserScroll()))},{capture:!0})}debounce(e,s,i){const r=Je(e,s);return this.sideEffect.addDisposer(()=>r.cancel(),i),r}wrapClassName(e){return"netless-app-docs-viewer-static-"+e}}class ws{constructor({context:e,whiteboardView:s,box:i,pages:r}){this.sideEffect=new C,this.onPlayPPT=()=>{const a=this.context.getRoom();a&&a.pptNextStep()},this._scaleDocsToFitImpl=()=>{const a=this.pages[this.getPageIndex()];a&&this.whiteboardView.moveCameraToContain({originX:-a.width/2,originY:-a.height/2,width:a.width,height:a.height,animationMode:"immediately"})},this._scaleDocsToFitDebounced=()=>{this.sideEffect.setTimeout(this._scaleDocsToFitImpl,1e3,"_scaleDocsToFitDebounced")},this.scaleDocsToFit=()=>{this._scaleDocsToFitImpl(),this._scaleDocsToFitDebounced()},this.onNewPageIndex=a=>{this.jumpToPage(a,!0)},this.context=e,this.whiteboardView=s,this.box=i,this.pages=r,this.displayer=e.getDisplayer(),this.viewer=new Ne({readonly:!e.getIsWritable(),box:i,pages:r,onNewPageIndex:this.onNewPageIndex,onPlay:this.onPlayPPT}),this.render(),this.sideEffect.add(()=>{const a=o=>{this.viewer.setReadonly(!o)};return this.context.emitter.on("writableChange",a),()=>this.context.emitter.off("writableChange",a)}),this.sideEffect.add(()=>{const a=o=>{this.jumpToPage(o.index)};return this.context.emitter.on("sceneStateChange",a),()=>this.context.emitter.off("sceneStateChange",a)})}mount(){this.viewer.mount();const e=this.getPageIndex();return e!==0&&this.jumpToPage(e),this.scaleDocsToFit(),this.sideEffect.add(()=>(this.whiteboardView.callbacks.on("onSizeUpdated",this.scaleDocsToFit),()=>{this.whiteboardView.callbacks.off("onSizeUpdated",this.scaleDocsToFit)})),this}unmount(){return this.viewer.unmount(),this}destroy(){this.sideEffect.flushAll(),this.unmount(),this.viewer.destroy()}getPageIndex(){return this.displayer.state.sceneState.index}jumpToPage(e,s){var i,r;if(e=S(e,0,this.pages.length-1),e!==this.getPageIndex()&&this.context.getIsWritable()){const a=this.context.getInitScenePath(),o=(r=(i=this.context.getScenes())==null?void 0:i[e])==null?void 0:r.name;a&&o&&this.context.setScenePath(`${a}/${o}`),this.scaleDocsToFit()}if(e!==this.viewer.pageIndex&&this.viewer.setPageIndex(e),s){const a=this.context.getRoom();if(a){const o=a.state.globalState.__pptState;a.setGlobalState({__pptState:o&&{uuid:o.uuid,pageIndex:e,disableAutoPlay:o.disableAutoPlay}})}}}render(){this.viewer.$content.appendChild(this.renderMask()),this.viewer.$content.appendChild(this.renderWhiteboardView()),this.sideEffect.addEventListener(window,"keydown",e=>{var s;if(this.box.focus)switch(e.key){case"ArrowUp":case"ArrowLeft":{this.jumpToPage(this.getPageIndex()-1,!0);break}case"ArrowRight":case"ArrowDown":{(s=this.context.getRoom())==null||s.pptNextStep();break}}})}renderMask(){if(!this.$mask){const e=document.createElement("div");e.className=this.wrapClassName("mask"),this.$mask=e;const s=document.createElement("button");s.className=this.wrapClassName("back");const i=document.createElement("button");i.className=this.wrapClassName("next")}return this.$mask}renderWhiteboardView(){return this.$whiteboardView||(this.$whiteboardView=document.createElement("div"),this.$whiteboardView.className=this.wrapClassName("wb-view"),this.sideEffect.addEventListener(this.$whiteboardView,"click",e=>{var i;const s=this.context.getRoom();if(s&&s.state.memberState.currentApplianceName==="clicker"){for(let r=e.target;r;r=r.parentElement)if((i=r.classList)==null?void 0:i.contains("ppt-event-source"))return;s.pptNextStep()}}),this.context.mountView(this.$whiteboardView)),this.$whiteboardView}wrapClassName(e){return"netless-app-docs-viewer-dynamic-"+e}}const bs="DocsViewer",ms={kind:bs,setup(t){const e=t.getBox(),s=t.getScenes();if(!s)throw new Error("[Docs Viewer]: scenes not found.");const i=t.getView();if(!i)throw new Error("[Docs Viewer]: no whiteboard view.");const r=s.map(({ppt:a})=>a?{width:a.width,height:a.height,src:a.src,thumbnail:a.previewURL}:null).filter(a=>Boolean(a));if(r.length<=0)throw new Error("[Docs Viewer]: empty scenes.");e.mountStyles(De),r[0].src.startsWith("ppt")?Ss(t,i,e,r):vs(t,i,e,r)}};function vs(t,e,s,i){var a;e.disableCameraTransform=!t.getIsWritable();const r=new fs({whiteboardView:e,readonly:!t.getIsWritable(),box:s,pages:i,pageScrollTop:(a=t.getAttributes())==null?void 0:a.pageScrollTop,mountWhiteboard:t.mountView.bind(t),onUserScroll:o=>{var n;((n=t.getAttributes())==null?void 0:n.pageScrollTop)!==o&&!s.readonly&&t.updateAttributes(["pageScrollTop"],o)}}).mount();t.emitter.on("attributesUpdate",o=>{o&&o.pageScrollTop!=null&&r.syncPageScrollTop(o.pageScrollTop)}),t.emitter.on("writableChange",o=>{r.setReadonly(!o),e.disableCameraTransform=!o})}function Ss(t,e,s,i){e.disableCameraTransform=!0;const r=new ws({context:t,whiteboardView:e,box:s,pages:i}).mount();t.mountView(r.$whiteboardView),t.isAddApp&&e.callbacks.once("onSizeUpdated",({width:a,height:o})=>{if(i.length>0&&s.state!=="maximized"){const{width:n,height:c}=i[0],l=c/n*a-o;l!==0&&t.getIsWritable()&&t.emitter.emit("setBoxSize",{width:s.width,height:s.height+l/s.containerRect.height})}})}exports.default=ms;
${e}`,Ye=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),je=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),Ge=(t,e,s)=>{const i=s===""?"":`with ${s.trim()}() `,r=Ue.bind(null,i,e.toString());Object.defineProperty(r,"name",je),Object.defineProperty(t,"toString",V(R({},Ye),{value:r}))},qe=(t,e,{ignoreNonConfigurable:s=!1}={})=>{const{name:i}=t;for(const r of Reflect.ownKeys(e))We(t,e,r,s);return Fe(t,e),Ge(t,e,i),t};var Xe=qe;const Je=(t,e={})=>{if(typeof t!="function")throw new TypeError(`Expected the first argument to be a function, got \`${typeof t}\``);const{wait:s=0,maxWait:i=Number.Infinity,before:r=!1,after:a=!0}=e;if(!r&&!a)throw new Error("Both `before` and `after` are false, function wouldn't be called.");let o,n,c;const h=function(...l){const d=this,Pe=()=>{o=void 0,n&&(clearTimeout(n),n=void 0),a&&(c=t.apply(d,l))},Ae=()=>{n=void 0,o&&(clearTimeout(o),o=void 0),a&&(c=t.apply(d,l))},He=r&&!o;return clearTimeout(o),o=setTimeout(Pe,s),i>0&&i!==Number.Infinity&&!n&&(n=setTimeout(Ae,i)),He&&(c=t.apply(d,l)),c};return Xe(h,t),h.cancel=()=>{o&&(clearTimeout(o),o=void 0),n&&(clearTimeout(n),n=void 0)},h},K="!#%()*+,-./:;=?@[]^_`{|}~ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",Ke=K.length,Z=Array(20),y=()=>{for(let t=0;t<20;t++)Z[t]=K.charAt(Math.random()*Ke);return Z.join("")};class C{constructor(){this.disposers=new Map}add(e,s=y()){return this.flush(s),this.disposers.set(s,e()),s}addDisposer(e,s=y()){return this.flush(s),this.disposers.set(s,e),s}addEventListener(e,s,i,r,a=y()){return this.add(()=>(e.addEventListener(s,i,r),()=>e.removeEventListener(s,i,r)),a),a}setTimeout(e,s,i=y()){return this.add(()=>{const r=window.setTimeout(()=>{this.remove(i),e()},s);return()=>window.clearTimeout(r)},i)}setInterval(e,s,i=y()){return this.add(()=>{const r=window.setInterval(e,s);return()=>window.clearInterval(r)},i)}remove(e){const s=this.disposers.get(e);return this.disposers.delete(e),s}flush(e){const s=this.remove(e);if(s)try{s()}catch(i){console.error(i)}}flushAll(){this.disposers.forEach(e=>{try{e()}catch(s){console.error(s)}}),this.disposers.clear()}}function Ze(t){const e="http://www.w3.org/2000/svg",s=document.createElementNS(e,"svg");s.setAttribute("class",`${t}-footer-icon-sidebar`),s.setAttribute("viewBox","0 0 64 64");const i=document.createElementNS(e,"path");return i.setAttribute("fill","currentColor"),i.setAttribute("d","M50 8H14c-3.309 0-6 2.691-6 6v36c0 3.309 2.691 6 6 6h36c3.309 0 6-2.691 6-6V14c0-3.309-2.691-6-6-6zM12 50V14c0-1.103.897-2 2-2h8v40h-8c-1.103 0-2-.897-2-2zm40 0c0 1.103-.897 2-2 2H26V12h24c1.103 0 2 .897 2 2z"),s.appendChild(i),s}function Qe(t){const e="http://www.w3.org/2000/svg",s=document.createElementNS(e,"svg");s.setAttribute("class",`${t}-footer-icon-arrow-left`),s.setAttribute("viewBox","0 0 500 500");const i=document.createElementNS(e,"path");return i.setAttribute("fill","currentColor"),i.setAttribute("d","M177.81 249.959L337.473 90.295c2.722-2.865 2.651-7.378-.143-10.1-2.793-2.65-7.163-2.65-9.956 0l-164.75 164.75c-2.793 2.793-2.793 7.306 0 10.1l164.75 164.75c2.865 2.722 7.378 2.65 10.099-.143 2.651-2.794 2.651-7.163 0-9.957L177.809 249.959z"),s.appendChild(i),s}function et(t){const e="http://www.w3.org/2000/svg",s=document.createElementNS(e,"svg");s.setAttribute("class",`${t}-footer-icon-arrow-right`),s.setAttribute("viewBox","0 0 500 500");const i=document.createElementNS(e,"path");return i.setAttribute("fill","currentColor"),i.setAttribute("d","M322.19 250.041L162.527 409.705c-2.722 2.865-2.651 7.378.143 10.1 2.793 2.65 7.163 2.65 9.956 0l164.75-164.75c2.793-2.793 2.793-7.306 0-10.1l-164.75-164.75c-2.865-2.722-7.378-2.65-10.099.143-2.651 2.794-2.651 7.163 0 9.957l159.664 159.736z"),s.appendChild(i),s}function tt(t){const e="http://www.w3.org/2000/svg",s=document.createElementNS(e,"svg");s.setAttribute("class",`${t}-footer-icon-play`),s.setAttribute("viewBox","0 0 500 500");const i=document.createElementNS(e,"path");return i.setAttribute("fill","currentColor"),i.setAttribute("d","M418.158 257.419L174.663 413.33c-6.017 3.919-15.708 3.772-21.291-.29-2.791-2.018-4.295-4.483-4.295-7.084V94.109c0-5.65 6.883-10.289 15.271-10.289 4.298 0 8.391 1.307 11.181 3.332l242.629 155.484c6.016 3.917 6.451 10.292.649 14.491-.216.154-.432.154-.649.292zM170.621 391.288l223.116-141.301L170.71 107.753l-.089 283.535z"),s.appendChild(i),s}function st(t){const e="http://www.w3.org/2000/svg",s=document.createElementNS(e,"svg");s.setAttribute("class",`${t}-footer-icon-pause`),s.setAttribute("viewBox","0 0 500 500");const i=document.createElementNS(e,"path");return i.setAttribute("fill","currentColor"),i.setAttribute("d","M312.491 78.261c0-6.159 4.893-11.213 11.04-11.213 6.158 0 11.211 5.054 11.211 11.213v343.478c0 6.159-5.053 11.213-11.211 11.213-6.147 0-11.04-5.054-11.04-11.213V78.261zM165.257 78.261c0-6.159 4.893-11.213 11.04-11.213 6.158 0 11.211 5.054 11.211 11.213v343.478c0 6.159-5.053 11.213-11.211 11.213-6.147 0-11.04-5.054-11.04-11.213V78.261z"),s.appendChild(i),s}const w=typeof window!="undefined",Q=w&&!("onscroll"in window)||typeof navigator!="undefined"&&/(gle|ing|ro)bot|crawl|spider/i.test(navigator.userAgent),ee=w&&"IntersectionObserver"in window,te=w&&"classList"in document.createElement("p"),se=w&&window.devicePixelRatio>1,it={elements_selector:".lazy",container:Q||w?document:null,threshold:300,thresholds:null,data_src:"src",data_srcset:"srcset",data_sizes:"sizes",data_bg:"bg",data_bg_hidpi:"bg-hidpi",data_bg_multi:"bg-multi",data_bg_multi_hidpi:"bg-multi-hidpi",data_poster:"poster",class_applied:"applied",class_loading:"loading",class_loaded:"loaded",class_error:"error",class_entered:"entered",class_exited:"exited",unobserve_completed:!0,unobserve_entered:!1,cancel_on_exit:!0,callback_enter:null,callback_exit:null,callback_applied:null,callback_loading:null,callback_loaded:null,callback_error:null,callback_finish:null,callback_cancel:null,use_native:!1},ie=t=>Object.assign({},it,t),re=function(t,e){let s;const i="LazyLoad::Initialized",r=new t(e);try{s=new CustomEvent(i,{detail:{instance:r}})}catch{s=document.createEvent("CustomEvent"),s.initCustomEvent(i,!1,!1,{instance:r})}window.dispatchEvent(s)},rt=(t,e)=>{if(!!e)if(!e.length)re(t,e);else for(let s=0,i;i=e[s];s+=1)re(t,i)},u="src",M="srcset",O="sizes",ae="poster",x="llOriginalAttrs",z="loading",oe="loaded",ne="applied",at="entered",D="error",ce="native",le="data-",he="ll-status",p=(t,e)=>t.getAttribute(le+e),ot=(t,e,s)=>{var i=le+e;if(s===null){t.removeAttribute(i);return}t.setAttribute(i,s)},E=t=>p(t,he),b=(t,e)=>ot(t,he,e),N=t=>b(t,null),W=t=>E(t)===null,nt=t=>E(t)===z,ct=t=>E(t)===D,B=t=>E(t)===ce,lt=[z,oe,ne,D],ht=t=>lt.indexOf(E(t))>=0,f=(t,e,s,i)=>{if(!!t){if(i!==void 0){t(e,s,i);return}if(s!==void 0){t(e,s);return}t(e)}},v=(t,e)=>{if(te){t.classList.add(e);return}t.className+=(t.className?" ":"")+e},g=(t,e)=>{if(te){t.classList.remove(e);return}t.className=t.className.replace(new RegExp("(^|\\s+)"+e+"(\\s+|$)")," ").replace(/^\s+/,"").replace(/\s+$/,"")},dt=t=>{t.llTempImage=document.createElement("IMG")},pt=t=>{delete t.llTempImage},de=t=>t.llTempImage,k=(t,e)=>{if(!e)return;const s=e._observer;!s||s.unobserve(t)},gt=t=>{t.disconnect()},ut=(t,e,s)=>{e.unobserve_entered&&k(t,s)},F=(t,e)=>{!t||(t.loadingCount+=e)},ft=t=>{!t||(t.toLoadCount-=1)},pe=(t,e)=>{!t||(t.toLoadCount=e)},wt=t=>t.loadingCount>0,bt=t=>t.toLoadCount>0,ge=t=>{let e=[];for(let s=0,i;i=t.children[s];s+=1)i.tagName==="SOURCE"&&e.push(i);return e},U=(t,e)=>{const s=t.parentNode;if(!s||s.tagName!=="PICTURE")return;ge(s).forEach(e)},ue=(t,e)=>{ge(t).forEach(e)},L=[u],fe=[u,ae],P=[u,M,O],A=t=>!!t[x],we=t=>t[x],be=t=>delete t[x],T=(t,e)=>{if(A(t))return;const s={};e.forEach(i=>{s[i]=t.getAttribute(i)}),t[x]=s},mt=t=>{A(t)||(t[x]={backgroundImage:t.style.backgroundImage})},vt=(t,e,s)=>{if(!s){t.removeAttribute(e);return}t.setAttribute(e,s)},$=(t,e)=>{if(!A(t))return;const s=we(t);e.forEach(i=>{vt(t,i,s[i])})},St=t=>{if(!A(t))return;const e=we(t);t.style.backgroundImage=e.backgroundImage},yt=(t,e,s)=>{v(t,e.class_applied),b(t,ne),!!s&&(e.unobserve_completed&&k(t,e),f(e.callback_applied,t,s))},me=(t,e,s)=>{v(t,e.class_loading),b(t,z),!!s&&(F(s,1),f(e.callback_loading,t,s))},m=(t,e,s)=>{!s||t.setAttribute(e,s)},ve=(t,e)=>{m(t,O,p(t,e.data_sizes)),m(t,M,p(t,e.data_srcset)),m(t,u,p(t,e.data_src))},xt=(t,e)=>{U(t,s=>{T(s,P),ve(s,e)}),T(t,P),ve(t,e)},Et=(t,e)=>{T(t,L),m(t,u,p(t,e.data_src))},Tt=(t,e)=>{ue(t,s=>{T(s,L),m(s,u,p(s,e.data_src))}),T(t,fe),m(t,ae,p(t,e.data_poster)),m(t,u,p(t,e.data_src)),t.load()},$t=(t,e,s)=>{const i=p(t,e.data_bg),r=p(t,e.data_bg_hidpi),a=se&&r?r:i;!a||(t.style.backgroundImage=`url("${a}")`,de(t).setAttribute(u,a),me(t,e,s))},_t=(t,e,s)=>{const i=p(t,e.data_bg_multi),r=p(t,e.data_bg_multi_hidpi),a=se&&r?r:i;!a||(t.style.backgroundImage=a,yt(t,e,s))},Se={IMG:xt,IFRAME:Et,VIDEO:Tt},It=(t,e)=>{const s=Se[t.tagName];!s||s(t,e)},Ct=(t,e,s)=>{const i=Se[t.tagName];!i||(i(t,e),me(t,e,s))},Nt=["IMG","IFRAME","VIDEO"],kt=t=>Nt.indexOf(t.tagName)>-1,ye=(t,e)=>{e&&!wt(e)&&!bt(e)&&f(t.callback_finish,e)},xe=(t,e,s)=>{t.addEventListener(e,s),t.llEvLisnrs[e]=s},Lt=(t,e,s)=>{t.removeEventListener(e,s)},Y=t=>!!t.llEvLisnrs,Pt=(t,e,s)=>{Y(t)||(t.llEvLisnrs={});const i=t.tagName==="VIDEO"?"loadeddata":"load";xe(t,i,e),xe(t,"error",s)},j=t=>{if(!Y(t))return;const e=t.llEvLisnrs;for(let s in e){const i=e[s];Lt(t,s,i)}delete t.llEvLisnrs},Ee=(t,e,s)=>{pt(t),F(s,-1),ft(s),g(t,e.class_loading),e.unobserve_completed&&k(t,s)},At=(t,e,s,i)=>{const r=B(e);Ee(e,s,i),v(e,s.class_loaded),b(e,oe),f(s.callback_loaded,e,i),r||ye(s,i)},Ht=(t,e,s,i)=>{const r=B(e);Ee(e,s,i),v(e,s.class_error),b(e,D),f(s.callback_error,e,i),r||ye(s,i)},G=(t,e,s)=>{const i=de(t)||t;if(Y(i))return;Pt(i,o=>{At(o,t,e,s),j(i)},o=>{Ht(o,t,e,s),j(i)})},Rt=(t,e,s)=>{dt(t),G(t,e,s),mt(t),$t(t,e,s),_t(t,e,s)},Vt=(t,e,s)=>{G(t,e,s),Ct(t,e,s)},q=(t,e,s)=>{kt(t)?Vt(t,e,s):Rt(t,e,s)},Mt=(t,e,s)=>{t.setAttribute("loading","lazy"),G(t,e,s),It(t,e),b(t,ce)},Te=t=>{t.removeAttribute(u),t.removeAttribute(M),t.removeAttribute(O)},Ot=t=>{U(t,e=>{Te(e)}),Te(t)},$e=t=>{U(t,e=>{$(e,P)}),$(t,P)},zt=t=>{ue(t,e=>{$(e,L)}),$(t,fe),t.load()},Dt=t=>{$(t,L)},Wt={IMG:$e,IFRAME:Dt,VIDEO:zt},Bt=t=>{const e=Wt[t.tagName];if(!e){St(t);return}e(t)},Ft=(t,e)=>{W(t)||B(t)||(g(t,e.class_entered),g(t,e.class_exited),g(t,e.class_applied),g(t,e.class_loading),g(t,e.class_loaded),g(t,e.class_error))},Ut=(t,e)=>{Bt(t),Ft(t,e),N(t),be(t)},Yt=(t,e,s,i)=>{!s.cancel_on_exit||!nt(t)||t.tagName==="IMG"&&(j(t),Ot(t),$e(t),g(t,s.class_loading),F(i,-1),N(t),f(s.callback_cancel,t,e,i))},jt=(t,e,s,i)=>{const r=ht(t);b(t,at),v(t,s.class_entered),g(t,s.class_exited),ut(t,s,i),f(s.callback_enter,t,e,i),!r&&q(t,s,i)},Gt=(t,e,s,i)=>{W(t)||(v(t,s.class_exited),Yt(t,e,s,i),f(s.callback_exit,t,e,i))},qt=["IMG","IFRAME","VIDEO"],_e=t=>t.use_native&&"loading"in HTMLImageElement.prototype,Xt=(t,e,s)=>{t.forEach(i=>{qt.indexOf(i.tagName)!==-1&&Mt(i,e,s)}),pe(s,0)},Jt=t=>t.isIntersecting||t.intersectionRatio>0,Kt=t=>({root:t.container===document?null:t.container,rootMargin:t.thresholds||t.threshold+"px"}),Zt=(t,e,s)=>{t.forEach(i=>Jt(i)?jt(i.target,i,e,s):Gt(i.target,i,e,s))},Qt=(t,e)=>{e.forEach(s=>{t.observe(s)})},es=(t,e)=>{gt(t),Qt(t,e)},ts=(t,e)=>{!ee||_e(t)||(e._observer=new IntersectionObserver(s=>{Zt(s,t,e)},Kt(t)))},Ie=t=>Array.prototype.slice.call(t),H=t=>t.container.querySelectorAll(t.elements_selector),ss=t=>Ie(t).filter(W),is=t=>ct(t),rs=t=>Ie(t).filter(is),Ce=(t,e)=>ss(t||H(e)),as=(t,e)=>{rs(H(t)).forEach(i=>{g(i,t.class_error),N(i)}),e.update()},os=(t,e)=>{!w||window.addEventListener("online",()=>{as(t,e)})},_=function(t,e){const s=ie(t);this._settings=s,this.loadingCount=0,ts(s,this),os(s,this),this.update(e)};_.prototype={update:function(t){const e=this._settings,s=Ce(t,e);if(pe(this,s.length),Q||!ee){this.loadAll(s);return}if(_e(e)){Xt(s,e,this);return}es(this._observer,s)},destroy:function(){this._observer&&this._observer.disconnect(),H(this._settings).forEach(t=>{be(t)}),delete this._observer,delete this._settings,delete this.loadingCount,delete this.toLoadCount},loadAll:function(t){const e=this._settings;Ce(t,e).forEach(i=>{k(i,this),q(i,e,this)})},restoreAll:function(){const t=this._settings;H(t).forEach(e=>{Ut(e,t)})}};_.load=(t,e)=>{const s=ie(e);q(t,s)};_.resetStatus=t=>{N(t)};w&&rt(_,window.lazyLoadOptions);class Ne{constructor({readonly:e,box:s,pages:i,onNewPageIndex:r,onPlay:a}){if(this.pageIndex=0,this.namespace="netless-app-docs-viewer",this.isShowPreview=!1,this.isSmallBox=!1,this.sideEffect=new C,i.length<=0)throw new Error("[DocsViewer] Empty pages.");this.readonly=e,this.box=s,this.pages=i,this.onNewPageIndex=r,this.onPlay=a,this.render()}mount(){this.box.mountContent(this.$content),this.box.mountFooter(this.$footer),this.sideEffect.add(()=>{const e=new _({container:this.$preview,elements_selector:`.${this.wrapClassName("preview-page>img")}`});return()=>e.destroy()},"preview-lazyload")}unmount(){this.$content.remove(),this.$footer.remove()}setReadonly(e){this.readonly!==e&&(this.readonly=e,this.$content.classList.toggle(this.wrapClassName("readonly"),e),this.$footer.classList.toggle(this.wrapClassName("readonly"),e),this.$pageNumberInput.disabled=e)}destroy(){this.sideEffect.flushAll(),this.unmount()}setPageIndex(e){Number.isNaN(e)||(this.pageIndex=e,this.$pageNumberInput.value=String(e+1))}setSmallBox(e){this.isSmallBox!==e&&(this.isSmallBox=e,this.$footer.classList.toggle(this.wrapClassName("float-footer"),e))}render(){return this.renderContent(),this.renderFooter(),this.$content}renderContent(){if(!this.$content){const e=document.createElement("div");e.className=this.wrapClassName("content"),this.$content=e,this.readonly&&e.classList.add(this.wrapClassName("readonly")),e.appendChild(this.renderPreviewMask()),e.appendChild(this.renderPreview())}return this.$content}renderPreview(){if(!this.$preview){const e=document.createElement("div");e.className=this.wrapClassName("preview")+" tele-fancy-scrollbar",this.$preview=e;const s=this.wrapClassName("preview-page"),i=this.wrapClassName("preview-page-name");this.pages.forEach((r,a)=>{var d;const o=(d=r.thumbnail)!=null?d:r.src.startsWith("ppt")?void 0:r.src;if(!o)return;const n=String(a),c=document.createElement("a");c.className=s+" "+this.wrapClassName(`preview-page-${a}`),c.setAttribute("href","#"),c.dataset.pageIndex=n;const h=document.createElement("span");h.className=i,h.textContent=String(a+1),h.dataset.pageIndex=n;const l=document.createElement("img");l.width=r.width,l.height=r.height,l.dataset.src=o,l.dataset.pageIndex=n,c.appendChild(l),c.appendChild(h),e.appendChild(c)}),this.sideEffect.addEventListener(e,"click",r=>{var o;if(this.readonly)return;const a=(o=r.target.dataset)==null?void 0:o.pageIndex;a&&(r.preventDefault(),r.stopPropagation(),r.stopImmediatePropagation(),this.onNewPageIndex(Number(a)),this.togglePreview(!1))})}return this.$preview}renderPreviewMask(){return this.$previewMask||(this.$previewMask=document.createElement("div"),this.$previewMask.className=this.wrapClassName("preview-mask"),this.sideEffect.addEventListener(this.$previewMask,"click",e=>{this.readonly||e.target===this.$previewMask&&this.togglePreview(!1)})),this.$previewMask}renderFooter(){if(!this.$footer){const e=document.createElement("div");if(e.className=this.wrapClassName("footer"),this.$footer=e,this.readonly&&e.classList.add(this.wrapClassName("readonly")),this.isSmallBox&&e.classList.add(this.wrapClassName("float-footer")),this.pages.some(c=>c.thumbnail||!c.src.startsWith("ppt"))){const c=this.renderFooterBtn("btn-sidebar",Ze(this.namespace));this.sideEffect.addEventListener(c,"click",()=>{this.readonly||this.togglePreview()}),this.$footer.appendChild(c)}const s=document.createElement("div");s.className=this.wrapClassName("page-jumps");const i=this.renderFooterBtn("btn-page-back",Qe(this.namespace));if(this.sideEffect.addEventListener(i,"click",()=>{this.readonly||this.onNewPageIndex(this.pageIndex-1)}),s.appendChild(i),this.onPlay){const c=this.renderFooterBtn("btn-page-play",tt(this.namespace),st(this.namespace)),h=()=>{this.sideEffect.setTimeout(()=>{c.classList.toggle(this.wrapClassName("footer-btn-playing"),!1)},500,"returnPlay")};this.sideEffect.addEventListener(c,"click",()=>{this.readonly||(c.classList.toggle(this.wrapClassName("footer-btn-playing"),!0),this.onPlay&&this.onPlay(),h())}),s.appendChild(c)}const r=this.renderFooterBtn("btn-page-next",et(this.namespace));this.sideEffect.addEventListener(r,"click",()=>{this.readonly||this.onNewPageIndex(this.pageIndex+1)}),s.appendChild(r);const a=document.createElement("div");a.className=this.wrapClassName("page-number");const o=document.createElement("input");o.className=this.wrapClassName("page-number-input"),o.value=String(this.pageIndex+1),this.readonly&&(o.disabled=!0),this.$pageNumberInput=o,this.sideEffect.addEventListener(o,"focus",()=>{o.select()}),this.sideEffect.addEventListener(o,"change",()=>{this.readonly||o.value&&this.onNewPageIndex(Number(o.value)-1)});const n=document.createElement("span");n.textContent=" / "+this.pages.length,a.appendChild(o),a.appendChild(n),this.$footer.appendChild(s),this.$footer.appendChild(a)}return this.$footer}renderFooterBtn(e,s,i){const r=document.createElement("button");return r.className=this.wrapClassName("footer-btn")+" "+this.wrapClassName(e),r.appendChild(s),i&&r.appendChild(i),r}togglePreview(e){if(this.isShowPreview=e!=null?e:!this.isShowPreview,this.$content.classList.toggle(this.wrapClassName("preview-active"),this.isShowPreview),this.isShowPreview){const s=this.$preview.querySelector("."+this.wrapClassName(`preview-page-${this.pageIndex}`));s&&this.$preview.scrollTo({top:s.offsetTop-16})}}wrapClassName(e){return`${this.namespace}-${e}`}}function S(t,e,s){return Math.min(Math.max(t,e),s)}function ke(t){return t.touches?t.touches[0]:t}function Le(t){t.stopPropagation(),t.cancelable&&t.preventDefault()}class ns{constructor(e){var s,i,r;this.velocity=0,this.paused=!0,this._animationFrameID=null,this._loopTimestamp=0,this.looper=a=>{if(this.paused)return;let o=Math.floor((a-this._loopTimestamp)/1e3*60)+1;for(this._loopTimestamp=a;o-- >0;)this.stepper();this.onStep(this.current,this),!this.paused&&this.current!==this.target&&window.requestAnimationFrame(this.looper)},this.current=(s=e.start)!=null?s:0,this.target=this.current,this.stiffness=(i=e.stiffness)!=null?i:170,this.damping=(r=e.damping)!=null?r:26,this.onStep=e.onStep}stepTo(e,s){this.paused&&s!=null&&(this.current=s),this.paused=!1,this.target=e,this.onStep(this.current,this),this._loopTimestamp=Date.now(),window.requestAnimationFrame(this.looper)}pause(){this.paused=!0}destroy(){this.pause()}stepper(){const e=-this.stiffness*(this.current-this.target),s=-this.damping*this.velocity,i=this.velocity+(e+s)/60,r=this.current+i/60;Math.abs(i-0)<.01&&Math.abs(r-this.target)<.01?(this.current=this.target,this.velocity=0):(this.current=r,this.velocity=i)}}class cs{constructor(e,s,i){this.scale=1,this.lastVisit=Date.now(),this.pageOffsetY=0,this.visible=!0,this.index=e,this.page=s,this.scale=i;const r=document.createElement("div");r.className="page-renderer-page",r.dataset.index=`${e}`,r.style.width=`${s.width*i}px`,r.style.height=`${s.height*i}px`,s.thumbnail&&(r.style.backgroundImage=`url("${s.thumbnail}")`);const a=document.createElement("img");a.className="page-renderer-page-img",a.width=s.width,a.height=s.height,a.src=s.src,r.appendChild(a),this.$page=r}translateY(e){Math.abs(e-this.pageOffsetY)>=.001&&(this.pageOffsetY=e,this.$page.style.transform=`translateY(${this.pageOffsetY*this.scale}px)`)}setScale(e){Math.abs(e-this.scale)>=.001&&(this.scale=e,this.$page.style.width=`${this.page.width*this.scale}px`,this.$page.style.height=`${this.page.height*this.scale}px`,this.$page.style.transform=`translateY(${this.pageOffsetY*this.scale}px)`)}setVisible(e){e!==this.visible&&(this.visible=e,this.$page.style.opacity=e?"1":"0")}}const ls=window.requestIdleCallback||(t=>window.setTimeout(t,5e3)),hs=window.cancelIdleCallback||window.clearTimeout;class ds{constructor(e,s){this.pages=e,this.scale=s,this.els=new Map,this.maxElCount=200,this.gcTimer=null,this.gc=()=>{if(this.gcTimer=null,this.els.size>this.maxElCount){const i=[...this.els.values()].sort((r,a)=>a.lastVisit-r.lastVisit);for(let r=Math.floor(this.maxElCount/4);r<i.length;r++)this.els.delete(i[r].index)}}}getEl(e){let s=this.els.get(e);return s||(s=new cs(e,this.pages[e],this.scale),this.els.set(e,s)),s.lastVisit=Date.now(),this.els.size>this.maxElCount&&this.gcTimer===null&&(this.gcTimer=ls(this.gc)),s}setScale(e){e!==this.scale&&(this.scale=e,this.els.forEach(s=>s.setScale(e)))}destroy(){this.els.clear(),this.gcTimer!==null&&(hs(this.gcTimer),this.gcTimer=null)}}class ps{constructor(e){this._hwaTimeout=NaN,this._turnOffHWA=()=>{window.clearTimeout(this._hwaTimeout),this._hwaTimeout=NaN,this.$pages.classList.toggle("is-hwa",!1)},this.pagesScrollTop=e.pagesScrollTop||0,this.containerWidth=e.containerWidth||1,this.containerHeight=e.containerHeight||1,this.pages=e.pages.map(a=>{if(a.thumbnail)return a;try{const o=new URL(a.src);return o.searchParams.set("x-oss-process","image/resize,l_50"),V(R({},a),{thumbnail:o.toString()})}catch(o){return console.error(o),a}});const s=Array(this.pages.length);let i=1/0,r=0;this.pagesIntrinsicHeight=this.pages.reduce((a,o,n)=>(s[n]=a,o.width>r&&(r=o.width),o.height<=i&&(i=o.height),a+o.height),0),this.pagesIntrinsicWidth=r,this.pagesMinHeight=i,this.pagesIntrinsicYs=s,this.scale=this._calcScale(),this.threshold=this._calcThreshold(),this.onPageIndexChanged=e.onPageIndexChanged,this.pageScrollIndex=0,this.pagesScrollTop!==0&&(this.pageScrollIndex=this.findScrollPageIndex(),this.onPageIndexChanged&&this.pageScrollIndex>0&&this.onPageIndexChanged(this.pageScrollIndex)),this.pageElManager=new ds(this.pages,this.scale),this.$pages=this.renderPages()}setContainerSize(e,s){e>0&&s>0&&(e!==this.containerWidth||s!==this.containerHeight)&&(this.containerWidth=e,this.containerHeight=s,this.$pages.style.width=`${this.containerWidth}px`,this.$pages.style.height=`${this.containerHeight}px`,this.scale=this._calcScale(),this.threshold=this._calcThreshold(),this.pageElManager.setScale(this.scale),this.$pages.parentElement&&this.pagesScrollTo(this.pagesScrollTop,!0))}renderPages(){const e=document.createElement("div");return e.className="page-renderer-pages-container",e.style.width=`${this.containerWidth}px`,e.style.height=`${this.containerHeight}px`,e}pagesScrollTo(e,s){if(e=S(e,0,this.pagesIntrinsicHeight-this.containerHeight/this.scale),s||Math.abs(e-this.pagesScrollTop)>=.001){this._turnOnHWA(),this.pagesScrollTop=e;const i=this.findScrollPageIndex(),r=Math.max(i-this.threshold,0),a=Math.min(i+this.threshold,this.pages.length-1);for(let o=0;o<this.$pages.children.length;o++){const n=this.$pages.children[o],c=Number(n.dataset.index);c>=r&&c<=a||(n.remove(),o--)}for(let o=r;o<=a;o++){const n=this.pageElManager.getEl(o);n.$page.parentElement!==this.$pages&&this.$pages.appendChild(n.$page),n.translateY(this.pagesIntrinsicYs[o]-this.pagesScrollTop)}i!==this.pageScrollIndex&&(this.pageScrollIndex=i,this.onPageIndexChanged&&this.onPageIndexChanged(i))}}findScrollPageIndex(){for(let e=0;e<this.pagesIntrinsicYs.length;e++)if(this.pagesIntrinsicYs[e]+this.pages[e].height-this.pagesScrollTop>=.001)return e;return this.pagesIntrinsicYs.length-1}mount(e){e.appendChild(this.$pages),this.pagesScrollTo(this.pagesScrollTop,!0)}unmount(){this.$pages.remove()}destroy(){this.unmount(),this.onPageIndexChanged=void 0,this.pageElManager.destroy(),this._hwaTimeout&&(window.clearTimeout(this._hwaTimeout),this._hwaTimeout=NaN)}_calcScale(){return this.containerWidth/this.pagesIntrinsicWidth||1}_calcThreshold(){return S(Math.ceil(this.containerHeight/this.scale/this.pagesMinHeight/2),1,this.pages.length)}_turnOnHWA(){this._hwaTimeout?window.clearTimeout(this._hwaTimeout):this.$pages.classList.toggle("is-hwa",!0),this._hwaTimeout=window.setTimeout(this._turnOffHWA,1e3)}}const gs=30;class us{constructor(e){this.sideEffect=new C,this.pagesScrollTop=e.pagesScrollTop||0,this.containerWidth=e.containerWidth||1,this.containerHeight=e.containerHeight||1,this.pagesWidth=e.pagesWidth||1,this.pagesHeight=e.pagesHeight||1,this.scale=this._calcScale(),this.scrollbarMinHeight=e.scrollbarMinHeight||gs,this.scrollbarHeight=this._calcScrollbarHeight(),this.readonly=e.readonly,this.wrapClassName=e.wrapClassName,this.onDragScroll=e.onDragScroll,this.$scrollbar=this.renderScrollbar()}mount(e){e.appendChild(this.$scrollbar),this.pagesScrollTo(this.pagesScrollTop,!0)}unmount(){this.$scrollbar.remove()}setReadonly(e){this.readonly=e}setContainerSize(e,s){e>0&&s>0&&(e!==this.containerWidth||s!==this.containerHeight)&&(this.containerWidth=e,this.containerHeight=s,this.scale=this._calcScale(),this._updateScrollbarHeight(),this.$scrollbar.parentElement&&this.pagesScrollTo(this.pagesScrollTop,!0))}pagesScrollTo(e,s){if(e=S(e,0,this.pagesHeight-this.containerHeight/this.scale),s||Math.abs(e-this.pagesScrollTop)>=.001){this.pagesScrollTop=e;const i=this.pagesScrollTop*this.scale,r=this.pagesHeight*this.scale,a=i/(r-this.containerHeight)*(this.containerHeight-this.scrollbarHeight);window.requestAnimationFrame?window.requestAnimationFrame(()=>{this.$scrollbar.style.transform=`translateY(${a}px)`}):this.$scrollbar.style.transform=`translateY(${a}px)`}}destroy(){this.unmount(),this.onDragScroll=void 0,this.sideEffect.flushAll()}renderScrollbar(){const e=document.createElement("button");e.className=this.wrapClassName("scrollbar"),e.style.minHeight=`${this.scrollbarMinHeight}px`,e.style.height=`${this.scrollbarHeight}px`;const s=i=>{if(this.readonly||i.button!=null&&i.button!==0)return;Le(i);const r=this.wrapClassName("scrollbar-dragging");e.classList.toggle(r,!0);const a=this.pagesScrollTop,{clientY:o}=ke(i),n=h=>{if(this.readonly)return;const{clientY:l}=ke(h),d=(l-o)/this.scale;Math.abs(d)>0&&this.onDragScroll&&this.onDragScroll(a+d*(this.pagesHeight*this.scale/this.containerHeight))},c=()=>{e.classList.toggle(r,!1),window.removeEventListener("mousemove",n,!0),window.removeEventListener("touchmove",n,!0),window.removeEventListener("mouseup",c,!0),window.removeEventListener("touchend",c,!0),window.removeEventListener("touchcancel",c,!0)};window.addEventListener("mousemove",n,!0),window.addEventListener("touchmove",n,!0),window.addEventListener("mouseup",c,!0),window.addEventListener("touchend",c,!0),window.addEventListener("touchcancel",c,!0)};return this.sideEffect.addEventListener(e,"mousedown",s),this.sideEffect.addEventListener(e,"touchstart",s),e}_calcScale(){return this.containerWidth/this.pagesWidth||1}_calcScrollbarHeight(){return S(this.containerHeight/(this.pagesHeight*this.scale)*this.containerHeight,this.scrollbarMinHeight,this.containerHeight)}_updateScrollbarHeight(){const e=this._calcScrollbarHeight();Math.abs(e-this.scrollbarHeight)>.001&&(this.scrollbarHeight=e,this.$scrollbar.style.height=`${e}px`)}}const I=640;class fs{constructor({whiteboardView:e,readonly:s,box:i,pages:r,pageScrollTop:a=0,mountWhiteboard:o,onUserScroll:n}){this.sideEffect=new C,this.userScrolling=!1,this.onNewPageIndex=d=>{this.scrollToPage(d)},this.whiteboardView=e,this.readonly=s,this.box=i,this.pages=r,this.mountWhiteboard=o,this._onUserScroll=n;const c=this.debounce(()=>{this.userScrolling=!1,this._onUserScroll&&this._onUserScroll(this.pageRenderer.pagesScrollTop)},{wait:80},"debounce-updateUserScroll");this.updateUserScroll=()=>{this.userScrolling=!0,c()},this.viewer=new Ne({readonly:s,box:i,pages:r,onNewPageIndex:this.onNewPageIndex});const{width:h,height:l}=this.whiteboardView.size;this.pageRenderer=new ps({pagesScrollTop:a,pages:this.pages,containerWidth:h,containerHeight:l,onPageIndexChanged:this.viewer.setPageIndex.bind(this.viewer)}),this.scrollbar=new us({pagesScrollTop:this.pageRenderer.pagesScrollTop,containerWidth:h,containerHeight:l,pagesWidth:this.pageRenderer.pagesIntrinsicWidth,pagesHeight:this.pageRenderer.pagesIntrinsicHeight,readonly:this.readonly,wrapClassName:this.wrapClassName.bind(this),onDragScroll:d=>{this.pageScrollTo(d),this.updateUserScroll()}}),this.pageScrollStepper=new ns({start:this.pageRenderer.pagesScrollTop,onStep:d=>{this.pageScrollTo(d)}}),this.render()}mount(){return this.viewer.mount(),this.setupScrollListener(),this.sideEffect.add(()=>{const e=this.renderRatioHeight.bind(this);return this.box.events.on("visual_resize",e),()=>this.box.events.off("visual_resize",e)}),this.sideEffect.setTimeout(()=>{this.userScrolling||this.pageScrollTo(this.pageRenderer.pagesScrollTop)},100),this}unmount(){return this.viewer.unmount(),this}setReadonly(e){this.readonly!==e&&(this.readonly=e,this.viewer.setReadonly(e),this.scrollbar.setReadonly(e))}destroy(){this.sideEffect.flushAll(),this.pageScrollStepper.destroy(),this._onUserScroll=void 0,this.unmount(),this.viewer.destroy(),this.pageRenderer.destroy(),this.scrollbar.destroy()}syncPageScrollTop(e){!this.userScrolling&&e>=0&&Math.abs(this.pageRenderer.pagesScrollTop-e)>.01&&this.pageScrollStepper.stepTo(e,this.pageRenderer.pagesScrollTop)}render(){this.pageRenderer.mount(this.viewer.$content),this.viewer.$content.appendChild(this.renderWhiteboardView()),this.scrollbar.mount(this.viewer.$content),this.renderRatioHeight()}renderRatioHeight(){const e=this.box.absoluteHeight,s=e<=I;if(this.viewer.setSmallBox(s),s){const i=26/I,r=26/e,a=26/I,o=0,n=Math.max((i+a-(r+o))/2,0);if(this.box.$titleBar){const c=r+n;this.box.$titleBar.style.height=`${c*100}%`}if(this.box.$footer){const c=o+n;this.box.$footer.style.height=`${c*100}%`}}else{if(this.box.$titleBar){const i=Math.max(26/I,26/e);this.box.$titleBar.style.height=`${i*100}%`}if(this.box.$footer){const i=Math.max(26/I,26/e);this.box.$footer.style.height=`${i*100}%`}}}renderWhiteboardView(){return this.$whiteboardView||(this.$whiteboardView=document.createElement("div"),this.$whiteboardView.className=this.wrapClassName("wb-view"),this.mountWhiteboard(this.$whiteboardView),this.sideEffect.addEventListener(this.$whiteboardView,"wheel",e=>{Le(e),this.readonly||(this.pageScrollTo(this.pageRenderer.pagesScrollTop+e.deltaY),this.updateUserScroll())},{passive:!1,capture:!0}),this.sideEffect.addEventListener(this.$whiteboardView,"touchmove",e=>{this.readonly||e.touches.length<=1||this.updateUserScroll()},{passive:!0,capture:!0})),this.$whiteboardView}scrollTopPageToEl(e){return e*this.pageRenderer.scale}scrollTopElToPage(e){return e/this.pageRenderer.scale}elScrollTo(e){this.pageScrollTo(this.scrollTopElToPage(e))}pageScrollTo(e){const s=this.scrollTopElToPage(this.whiteboardView.size.height/2);this.whiteboardView.moveCamera({centerY:S(e+s,s,this.pageRenderer.pagesIntrinsicHeight-s),animationMode:"immediately"})}scrollToPage(e){if(!this.readonly&&!Number.isNaN(e)){const s=this.pageRenderer.pagesIntrinsicYs[e];s>=0&&(this.pageScrollTo(s+5/this.pageRenderer.scale),this.updateUserScroll())}}setupScrollListener(){this.sideEffect.add(()=>{const e=s=>{const{width:i,height:r}=this.whiteboardView.size;if(i<=0||r<=0)return;const a=s.centerY-this.pageRenderer.containerHeight/this.pageRenderer.scale/2;this.pageRenderer.pagesScrollTo(a),this.scrollbar.pagesScrollTo(a)};return this.whiteboardView.callbacks.on("onCameraUpdated",e),()=>this.whiteboardView.callbacks.off("onCameraUpdated",e)}),this.sideEffect.add(()=>{const e=({width:s,height:i})=>{if(s<=0||i<=0)return;this.pageRenderer.setContainerSize(s,i),this.scrollbar.setContainerSize(s,i);const{pagesIntrinsicWidth:r,pagesIntrinsicHeight:a}=this.pageRenderer;this.whiteboardView.moveCameraToContain({originX:0,originY:this.pageRenderer.pagesScrollTop,width:r,height:i/this.pageRenderer.scale,animationMode:"immediately"}),this.whiteboardView.setCameraBound({damping:1,maxContentMode:()=>this.pageRenderer.scale,minContentMode:()=>this.pageRenderer.scale,centerX:r/2,centerY:a/2,width:r,height:a})};return this.whiteboardView.callbacks.on("onSizeUpdated",e),()=>{this.whiteboardView.callbacks.off("onSizeUpdated",e)}},"whiteboard-size-update"),this.sideEffect.addEventListener(window,"keyup",e=>{if(this.readonly||!this.box.focus||this.box.minimized)return;let s=null;switch(e.key){case"PageDown":{s=this.pageRenderer.pagesScrollTop+this.pageRenderer.containerHeight/this.pageRenderer.scale;break}case"PageUp":{s=this.pageRenderer.pagesScrollTop-this.pageRenderer.containerHeight/this.pageRenderer.scale;break}case"ArrowDown":{s=this.pageRenderer.pagesScrollTop+this.pageRenderer.containerHeight/4/this.pageRenderer.scale;break}case"ArrowUp":{s=this.pageRenderer.pagesScrollTop-this.pageRenderer.containerHeight/4/this.pageRenderer.scale;break}}s!==null&&(this._onUserScroll?this._onUserScroll(s):(this.pageScrollTo(s),this.updateUserScroll()))},{capture:!0})}debounce(e,s,i){const r=Je(e,s);return this.sideEffect.addDisposer(()=>r.cancel(),i),r}wrapClassName(e){return"netless-app-docs-viewer-static-"+e}}class ws{constructor({context:e,whiteboardView:s,box:i,pages:r}){this.sideEffect=new C,this.onPlayPPT=()=>{const a=this.context.getRoom();a&&a.pptNextStep()},this._scaleDocsToFitImpl=()=>{const a=this.pages[this.getPageIndex()];a&&this.whiteboardView.moveCameraToContain({originX:-a.width/2,originY:-a.height/2,width:a.width,height:a.height,animationMode:"immediately"})},this._scaleDocsToFitDebounced=()=>{this.sideEffect.setTimeout(this._scaleDocsToFitImpl,1e3,"_scaleDocsToFitDebounced")},this.scaleDocsToFit=()=>{this._scaleDocsToFitImpl(),this._scaleDocsToFitDebounced()},this.onNewPageIndex=a=>{this.jumpToPage(a,!0)},this.context=e,this.whiteboardView=s,this.box=i,this.pages=r,this.displayer=e.getDisplayer(),this.viewer=new Ne({readonly:!e.getIsWritable(),box:i,pages:r,onNewPageIndex:this.onNewPageIndex,onPlay:this.onPlayPPT}),this.render(),this.sideEffect.add(()=>{const a=o=>{this.viewer.setReadonly(!o)};return this.context.emitter.on("writableChange",a),()=>this.context.emitter.off("writableChange",a)}),this.sideEffect.add(()=>{const a=o=>{this.jumpToPage(o.index)};return this.context.emitter.on("sceneStateChange",a),()=>this.context.emitter.off("sceneStateChange",a)})}mount(){this.viewer.mount();const e=this.getPageIndex();return e!==0&&this.jumpToPage(e),this.scaleDocsToFit(),this.sideEffect.add(()=>(this.whiteboardView.callbacks.on("onSizeUpdated",this.scaleDocsToFit),()=>{this.whiteboardView.callbacks.off("onSizeUpdated",this.scaleDocsToFit)})),this}unmount(){return this.viewer.unmount(),this}destroy(){this.sideEffect.flushAll(),this.unmount(),this.viewer.destroy()}getPageIndex(){return this.displayer.state.sceneState.index}jumpToPage(e,s){var i,r;if(e=S(e,0,this.pages.length-1),e!==this.getPageIndex()&&this.context.getIsWritable()){const a=this.context.getInitScenePath(),o=(r=(i=this.context.getScenes())==null?void 0:i[e])==null?void 0:r.name;a&&o&&this.context.setScenePath(`${a}/${o}`),this.scaleDocsToFit()}if(e!==this.viewer.pageIndex&&this.viewer.setPageIndex(e),s){const a=this.context.getRoom();if(a){const o=a.state.globalState.__pptState;a.setGlobalState({__pptState:o&&{uuid:o.uuid,pageIndex:e,disableAutoPlay:o.disableAutoPlay}})}}}render(){this.viewer.$content.appendChild(this.renderMask()),this.viewer.$content.appendChild(this.renderWhiteboardView()),this.sideEffect.addEventListener(window,"keydown",e=>{var s;if(this.box.focus)switch(e.key){case"ArrowUp":case"ArrowLeft":{this.jumpToPage(this.getPageIndex()-1,!0);break}case"ArrowRight":case"ArrowDown":{(s=this.context.getRoom())==null||s.pptNextStep();break}}})}renderMask(){if(!this.$mask){const e=document.createElement("div");e.className=this.wrapClassName("mask"),this.$mask=e;const s=document.createElement("button");s.className=this.wrapClassName("back");const i=document.createElement("button");i.className=this.wrapClassName("next")}return this.$mask}renderWhiteboardView(){return this.$whiteboardView||(this.$whiteboardView=document.createElement("div"),this.$whiteboardView.className=this.wrapClassName("wb-view"),this.sideEffect.addEventListener(this.$whiteboardView,"click",e=>{var i;const s=this.context.getRoom();if(s&&s.state.memberState.currentApplianceName==="clicker"){for(let r=e.target;r;r=r.parentElement)if((i=r.classList)==null?void 0:i.contains("ppt-event-source"))return;s.pptNextStep()}}),this.context.mountView(this.$whiteboardView)),this.$whiteboardView}wrapClassName(e){return"netless-app-docs-viewer-dynamic-"+e}}const bs="DocsViewer",ms={kind:bs,setup(t){const e=t.getBox(),s=t.getScenes();if(!s)throw new Error("[Docs Viewer]: scenes not found.");const i=t.getView();if(!i)throw new Error("[Docs Viewer]: no whiteboard view.");const r=s.map(({ppt:a})=>a?{width:a.width,height:a.height,src:a.src,thumbnail:a.previewURL}:null).filter(a=>Boolean(a));if(r.length<=0)throw new Error("[Docs Viewer]: empty scenes.");e.mountStyles(De),r[0].src.startsWith("ppt")?Ss(t,i,e,r):vs(t,i,e,r)}};function vs(t,e,s,i){var a;e.disableCameraTransform=!t.getIsWritable();const r=new fs({whiteboardView:e,readonly:!t.getIsWritable(),box:s,pages:i,pageScrollTop:(a=t.getAttributes())==null?void 0:a.pageScrollTop,mountWhiteboard:t.mountView.bind(t),onUserScroll:o=>{var n;((n=t.getAttributes())==null?void 0:n.pageScrollTop)!==o&&!s.readonly&&t.updateAttributes(["pageScrollTop"],o)}}).mount();t.emitter.on("attributesUpdate",o=>{o&&o.pageScrollTop!=null&&r.syncPageScrollTop(o.pageScrollTop)}),t.emitter.on("writableChange",o=>{r.setReadonly(!o),e.disableCameraTransform=!o})}function Ss(t,e,s,i){e.disableCameraTransform=!0;const r=new ws({context:t,whiteboardView:e,box:s,pages:i}).mount();t.mountView(r.$whiteboardView),t.isAddApp&&e.callbacks.once("onSizeUpdated",({width:a,height:o})=>{if(i.length>0&&s.state!=="maximized"){const{width:n,height:c}=i[0],l=c/n*a-o;l!==0&&t.getIsWritable()&&t.emitter.emit("setBoxSize",{width:s.width,height:s.height+l/s.containerRect.height})}})}exports.default=ms;
//# sourceMappingURL=main.cjs.js.map

@@ -1,4 +0,4 @@

var us=Object.defineProperty,gs=Object.defineProperties;var fs=Object.getOwnPropertyDescriptors;var Ae=Object.getOwnPropertySymbols;var ws=Object.prototype.hasOwnProperty,ms=Object.prototype.propertyIsEnumerable;var He=(p,u,g)=>u in p?us(p,u,{enumerable:!0,configurable:!0,writable:!0,value:g}):p[u]=g,J=(p,u)=>{for(var g in u||(u={}))ws.call(u,g)&&He(p,g,u[g]);if(Ae)for(var g of Ae(u))ms.call(u,g)&&He(p,g,u[g]);return p},K=(p,u)=>gs(p,fs(u));var NetlessAppDocsViewer=function(p){"use strict";var u=`.netless-app-docs-viewer-content{position:relative;height:100%;overflow:hidden}.netless-app-docs-viewer-preview-mask{display:none;position:absolute;z-index:200;top:0;left:0;width:100%;height:100%}.netless-app-docs-viewer-preview{display:flex;flex-direction:column;align-items:center;position:absolute;z-index:300;top:0;left:0;width:33%;max-width:200px;height:100%;padding-top:10px;transform:translate(-100%);background:rgba(237,237,240,.9);box-shadow:inset -1px 0 #0000001c;transition:transform .4s}.netless-app-docs-viewer-preview-active .netless-app-docs-viewer-preview-mask{display:block}.netless-app-docs-viewer-preview-active .netless-app-docs-viewer-preview{transform:translate(0)}.netless-app-docs-viewer-preview-page{position:relative;display:block;width:55%;margin-bottom:10px;font-size:0;color:transparent;outline:none;border:7px solid transparent;border-radius:4px;transition:border-color .3s;user-select:none}.netless-app-docs-viewer-preview-page:hover,.netless-app-docs-viewer-preview-page.netless-app-docs-viewer-preview-page-active{border-color:#444e601a}.netless-app-docs-viewer-preview-page>img{width:100%;height:auto;box-sizing:border-box;border:1px solid rgba(0,0,0,.5);border-radius:1px;background-color:#fff;box-shadow:0 2px 8px #0000004d}.netless-app-docs-viewer-preview-page-name{position:absolute;top:1px;left:-10px;transform:translate(-100%);text-align:right;font-size:12px;color:#5f5f5f;user-select:none}.netless-app-docs-viewer-footer{box-sizing:border-box;height:26px;display:flex;align-items:center;padding:0 16px;border-top:1px solid #eeeef7;color:#191919}.netless-app-docs-viewer-float-footer{width:100%;min-height:26px;position:absolute;left:0;bottom:0;z-index:2000;background:rgba(249,249,252,.9);transition:opacity .4s}.netless-app-docs-viewer-footer-btn{box-sizing:border-box;width:26px;height:26px;font-size:0;margin:0;padding:3px;border:none;border-radius:1px;outline:none;color:currentColor;background:transparent;transition:background .4s;cursor:pointer;user-select:none;-webkit-tap-highlight-color:rgba(0,0,0,0)}.netless-app-docs-viewer-footer-btn:hover{background:rgba(237,237,240,.9)}@media (hover: none){.netless-app-docs-viewer-footer-btn:hover{background:transparent!important}}.netless-app-docs-viewer-footer-btn>svg{width:100%;height:100%}.netless-app-docs-viewer-footer-btn>svg:nth-of-type(2){display:none}.netless-app-docs-viewer-footer-btn.netless-app-docs-viewer-footer-btn-playing>svg:nth-of-type(1){display:none}.netless-app-docs-viewer-footer-btn.netless-app-docs-viewer-footer-btn-playing>svg:nth-of-type(2){display:initial}.netless-app-docs-viewer-footer-btn~.netless-app-docs-viewer-footer-btn{margin-left:15px}.netless-app-docs-viewer-page-jumps{flex:1;display:flex;justify-content:center;align-items:center}.netless-app-docs-viewer-page-number{margin-left:auto;font-size:13px;user-select:none;white-space:nowrap;word-break:keep-all}.netless-app-docs-viewer-page-number-input{border:none;outline:none;width:3em;margin:0;padding:0 2px;text-align:right;font-size:13px;line-height:1;font-weight:400;font-family:inherit;border-radius:2px;color:currentColor;background:transparent;transition:background .4s;user-select:text;-webkit-tap-highlight-color:rgba(0,0,0,0)}.netless-app-docs-viewer-page-number-input:hover,.netless-app-docs-viewer-page-number-input:focus,.netless-app-docs-viewer-page-number-input:active{background:#fff;box-shadow:#63636333 0 2px 8px}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-footer-btn{cursor:not-allowed}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-footer-btn:hover{background:transparent}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-page-number-input{cursor:not-allowed}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-page-number-input:hover,.netless-app-docs-viewer-readonly .netless-app-docs-viewer-page-number-input:focus,.netless-app-docs-viewer-readonly .netless-app-docs-viewer-page-number-input:active{background:transparent;box-shadow:none}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-page-number-input:disabled{color:inherit}.netless-app-docs-viewer-readonly.netless-app-docs-viewer-float-footer{display:none}.telebox-color-scheme-dark .netless-app-docs-viewer-page-number-input{color:#a6a6a8}.telebox-color-scheme-dark .netless-app-docs-viewer-page-number-input:active,.telebox-color-scheme-dark .netless-app-docs-viewer-page-number-input:focus,.telebox-color-scheme-dark .netless-app-docs-viewer-page-number-input:hover{color:#222}.telebox-color-scheme-dark .netless-app-docs-viewer-footer{color:#a6a6a8;background:#2d2d33;border-top:none}.telebox-color-scheme-dark .netless-app-docs-viewer-footer-btn:hover{background:#212126}.telebox-color-scheme-dark .netless-app-docs-viewer-preview{background:rgba(50,50,50,.9)}.netless-app-docs-viewer-static-scrollbar{position:absolute;top:0;right:0;z-index:2147483647;width:8px;min-height:30px;margin:0;padding:0;border:none;outline:none;border-radius:4px;background:rgba(68,78,96,.4);box-shadow:1px 1px 8px #ffffffb3;opacity:0;transition:background .4s,opacity .4s 3s,transform .2s;user-select:none}.netless-app-docs-viewer-static-scrollbar.netless-app-docs-viewer-static-scrollbar-dragging{background:rgba(68,78,96,.6);opacity:1;transition:background .4s,opacity .4s 3s!important}.netless-app-docs-viewer-static-scrollbar:hover,.netless-app-docs-viewer-static-scrollbar:focus{background:rgba(68,78,96,.5)}.netless-app-docs-viewer-static-scrollbar:active{background:rgba(68,78,96,.6)}.netless-app-docs-viewer-content:hover .netless-app-docs-viewer-static-scrollbar{opacity:1;transition:background .4s,opacity .4s,transform .2s}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-static-scrollbar{display:none}.netless-app-docs-viewer-static-pages:hover .netless-app-docs-viewer-static-scrollbar{opacity:1;transition:background .4s,opacity .4s,transform .2s}.page-renderer-pages-container{position:relative;overflow:hidden}.page-renderer-page{position:absolute;top:0;left:0;background-position:center;background-size:cover;background-repeat:no-repeat}.page-renderer-pages-container.is-hwa .page-renderer-page{will-change:transform}.page-renderer-page-img{display:block;width:100%;height:auto;user-select:none}.netless-app-docs-viewer-static-pages{overflow:hidden;position:relative;height:100%;user-select:none}.netless-app-docs-viewer-static-page{display:block;width:100%;height:auto;user-select:none}.netless-app-docs-viewer-static-wb-view,.netless-app-docs-viewer-dynamic-wb-view{position:absolute;top:0;left:0;width:100%;height:100%;z-index:100;overflow:hidden}.netless-app-docs-viewer-dynamic-wb-view .cursor-clicker .ppt-event-source{cursor:pointer}
`;const g=(t,e,s,i)=>{if(s==="length"||s==="prototype"||s==="arguments"||s==="caller")return;const r=Object.getOwnPropertyDescriptor(t,s),a=Object.getOwnPropertyDescriptor(e,s);!Ve(r,a)&&i||Object.defineProperty(t,s,a)},Ve=function(t,e){return t===void 0||t.configurable||t.writable===e.writable&&t.enumerable===e.enumerable&&t.configurable===e.configurable&&(t.writable||t.value===e.value)},Re=(t,e)=>{const s=Object.getPrototypeOf(e);s!==Object.getPrototypeOf(t)&&Object.setPrototypeOf(t,s)},Me=(t,e)=>`/* Wrapped ${t}*/
${e}`,ze=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),De=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),Oe=(t,e,s)=>{const i=s===""?"":`with ${s.trim()}() `,r=Me.bind(null,i,e.toString());Object.defineProperty(r,"name",De),Object.defineProperty(t,"toString",K(J({},ze),{value:r}))};var We=(t,e,{ignoreNonConfigurable:s=!1}={})=>{const{name:i}=t;for(const r of Reflect.ownKeys(e))g(t,e,r,s);return Re(t,e),Oe(t,e,i),t};const Fe=(t,e={})=>{if(typeof t!="function")throw new TypeError(`Expected the first argument to be a function, got \`${typeof t}\``);const{wait:s=0,maxWait:i=Number.Infinity,before:r=!1,after:a=!0}=e;if(!r&&!a)throw new Error("Both `before` and `after` are false, function wouldn't be called.");let o,n,c;const h=function(...l){const d=this,hs=()=>{o=void 0,n&&(clearTimeout(n),n=void 0),a&&(c=t.apply(d,l))},ds=()=>{n=void 0,o&&(clearTimeout(o),o=void 0),a&&(c=t.apply(d,l))},ps=r&&!o;return clearTimeout(o),o=setTimeout(hs,s),i>0&&i!==Number.Infinity&&!n&&(n=setTimeout(ds,i)),ps&&(c=t.apply(d,l)),c};return We(h,t),h.cancel=()=>{o&&(clearTimeout(o),o=void 0),n&&(clearTimeout(n),n=void 0)},h},Z="!#%()*+,-./:;=?@[]^_`{|}~ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",Be=Z.length,Q=Array(20),T=()=>{for(let t=0;t<20;t++)Q[t]=Z.charAt(Math.random()*Be);return Q.join("")};class L{constructor(){this.disposers=new Map}add(e,s=T()){return this.flush(s),this.disposers.set(s,e()),s}addDisposer(e,s=T()){return this.flush(s),this.disposers.set(s,e),s}addEventListener(e,s,i,r,a=T()){return this.add(()=>(e.addEventListener(s,i,r),()=>e.removeEventListener(s,i,r)),a),a}setTimeout(e,s,i=T()){return this.add(()=>{const r=window.setTimeout(()=>{this.remove(i),e()},s);return()=>window.clearTimeout(r)},i)}setInterval(e,s,i=T()){return this.add(()=>{const r=window.setInterval(e,s);return()=>window.clearInterval(r)},i)}remove(e){const s=this.disposers.get(e);return this.disposers.delete(e),s}flush(e){const s=this.remove(e);if(s)try{s()}catch(i){console.error(i)}}flushAll(){this.disposers.forEach(e=>{try{e()}catch(s){console.error(s)}}),this.disposers.clear()}}function Ue(t){const e="http://www.w3.org/2000/svg",s=document.createElementNS(e,"svg");s.setAttribute("class",`${t}-footer-icon-sidebar`),s.setAttribute("viewBox","0 0 64 64");const i=document.createElementNS(e,"path");return i.setAttribute("fill","currentColor"),i.setAttribute("d","M50 8H14c-3.309 0-6 2.691-6 6v36c0 3.309 2.691 6 6 6h36c3.309 0 6-2.691 6-6V14c0-3.309-2.691-6-6-6zM12 50V14c0-1.103.897-2 2-2h8v40h-8c-1.103 0-2-.897-2-2zm40 0c0 1.103-.897 2-2 2H26V12h24c1.103 0 2 .897 2 2z"),s.appendChild(i),s}function Ye(t){const e="http://www.w3.org/2000/svg",s=document.createElementNS(e,"svg");s.setAttribute("class",`${t}-footer-icon-arrow-left`),s.setAttribute("viewBox","0 0 500 500");const i=document.createElementNS(e,"path");return i.setAttribute("fill","currentColor"),i.setAttribute("d","M177.81 249.959L337.473 90.295c2.722-2.865 2.651-7.378-.143-10.1-2.793-2.65-7.163-2.65-9.956 0l-164.75 164.75c-2.793 2.793-2.793 7.306 0 10.1l164.75 164.75c2.865 2.722 7.378 2.65 10.099-.143 2.651-2.794 2.651-7.163 0-9.957L177.809 249.959z"),s.appendChild(i),s}function je(t){const e="http://www.w3.org/2000/svg",s=document.createElementNS(e,"svg");s.setAttribute("class",`${t}-footer-icon-arrow-right`),s.setAttribute("viewBox","0 0 500 500");const i=document.createElementNS(e,"path");return i.setAttribute("fill","currentColor"),i.setAttribute("d","M322.19 250.041L162.527 409.705c-2.722 2.865-2.651 7.378.143 10.1 2.793 2.65 7.163 2.65 9.956 0l164.75-164.75c2.793-2.793 2.793-7.306 0-10.1l-164.75-164.75c-2.865-2.722-7.378-2.65-10.099.143-2.651 2.794-2.651 7.163 0 9.957l159.664 159.736z"),s.appendChild(i),s}function Ge(t){const e="http://www.w3.org/2000/svg",s=document.createElementNS(e,"svg");s.setAttribute("class",`${t}-footer-icon-play`),s.setAttribute("viewBox","0 0 500 500");const i=document.createElementNS(e,"path");return i.setAttribute("fill","currentColor"),i.setAttribute("d","M418.158 257.419L174.663 413.33c-6.017 3.919-15.708 3.772-21.291-.29-2.791-2.018-4.295-4.483-4.295-7.084V94.109c0-5.65 6.883-10.289 15.271-10.289 4.298 0 8.391 1.307 11.181 3.332l242.629 155.484c6.016 3.917 6.451 10.292.649 14.491-.216.154-.432.154-.649.292zM170.621 391.288l223.116-141.301L170.71 107.753l-.089 283.535z"),s.appendChild(i),s}function qe(t){const e="http://www.w3.org/2000/svg",s=document.createElementNS(e,"svg");s.setAttribute("class",`${t}-footer-icon-pause`),s.setAttribute("viewBox","0 0 500 500");const i=document.createElementNS(e,"path");return i.setAttribute("fill","currentColor"),i.setAttribute("d","M312.491 78.261c0-6.159 4.893-11.213 11.04-11.213 6.158 0 11.211 5.054 11.211 11.213v343.478c0 6.159-5.053 11.213-11.211 11.213-6.147 0-11.04-5.054-11.04-11.213V78.261zM165.257 78.261c0-6.159 4.893-11.213 11.04-11.213 6.158 0 11.211 5.054 11.211 11.213v343.478c0 6.159-5.053 11.213-11.211 11.213-6.147 0-11.04-5.054-11.04-11.213V78.261z"),s.appendChild(i),s}const v=typeof window!="undefined",ee=v&&!("onscroll"in window)||typeof navigator!="undefined"&&/(gle|ing|ro)bot|crawl|spider/i.test(navigator.userAgent),te=v&&"IntersectionObserver"in window,se=v&&"classList"in document.createElement("p"),ie=v&&window.devicePixelRatio>1,Xe={elements_selector:".lazy",container:ee||v?document:null,threshold:300,thresholds:null,data_src:"src",data_srcset:"srcset",data_sizes:"sizes",data_bg:"bg",data_bg_hidpi:"bg-hidpi",data_bg_multi:"bg-multi",data_bg_multi_hidpi:"bg-multi-hidpi",data_poster:"poster",class_applied:"applied",class_loading:"loading",class_loaded:"loaded",class_error:"error",class_entered:"entered",class_exited:"exited",unobserve_completed:!0,unobserve_entered:!1,cancel_on_exit:!0,callback_enter:null,callback_exit:null,callback_applied:null,callback_loading:null,callback_loaded:null,callback_error:null,callback_finish:null,callback_cancel:null,use_native:!1},re=t=>Object.assign({},Xe,t),ae=function(t,e){let s;const i="LazyLoad::Initialized",r=new t(e);try{s=new CustomEvent(i,{detail:{instance:r}})}catch{s=document.createEvent("CustomEvent"),s.initCustomEvent(i,!1,!1,{instance:r})}window.dispatchEvent(s)},Je=(t,e)=>{if(!!e)if(!e.length)ae(t,e);else for(let s=0,i;i=e[s];s+=1)ae(t,i)},m="src",z="srcset",D="sizes",oe="poster",$="llOriginalAttrs",O="loading",ne="loaded",ce="applied",Ke="entered",W="error",le="native",he="data-",de="ll-status",f=(t,e)=>t.getAttribute(he+e),Ze=(t,e,s)=>{var i=he+e;if(s===null){t.removeAttribute(i);return}t.setAttribute(i,s)},_=t=>f(t,de),S=(t,e)=>Ze(t,de,e),P=t=>S(t,null),F=t=>_(t)===null,Qe=t=>_(t)===O,et=t=>_(t)===W,B=t=>_(t)===le,tt=[O,ne,ce,W],st=t=>tt.indexOf(_(t))>=0,b=(t,e,s,i)=>{if(!!t){if(i!==void 0){t(e,s,i);return}if(s!==void 0){t(e,s);return}t(e)}},x=(t,e)=>{if(se){t.classList.add(e);return}t.className+=(t.className?" ":"")+e},w=(t,e)=>{if(se){t.classList.remove(e);return}t.className=t.className.replace(new RegExp("(^|\\s+)"+e+"(\\s+|$)")," ").replace(/^\s+/,"").replace(/\s+$/,"")},it=t=>{t.llTempImage=document.createElement("IMG")},rt=t=>{delete t.llTempImage},pe=t=>t.llTempImage,A=(t,e)=>{if(!e)return;const s=e._observer;!s||s.unobserve(t)},at=t=>{t.disconnect()},ot=(t,e,s)=>{e.unobserve_entered&&A(t,s)},U=(t,e)=>{!t||(t.loadingCount+=e)},nt=t=>{!t||(t.toLoadCount-=1)},ue=(t,e)=>{!t||(t.toLoadCount=e)},ct=t=>t.loadingCount>0,lt=t=>t.toLoadCount>0,ge=t=>{let e=[];for(let s=0,i;i=t.children[s];s+=1)i.tagName==="SOURCE"&&e.push(i);return e},Y=(t,e)=>{const s=t.parentNode;if(!s||s.tagName!=="PICTURE")return;ge(s).forEach(e)},fe=(t,e)=>{ge(t).forEach(e)},H=[m],we=[m,oe],V=[m,z,D],R=t=>!!t[$],me=t=>t[$],be=t=>delete t[$],I=(t,e)=>{if(R(t))return;const s={};e.forEach(i=>{s[i]=t.getAttribute(i)}),t[$]=s},ht=t=>{R(t)||(t[$]={backgroundImage:t.style.backgroundImage})},dt=(t,e,s)=>{if(!s){t.removeAttribute(e);return}t.setAttribute(e,s)},C=(t,e)=>{if(!R(t))return;const s=me(t);e.forEach(i=>{dt(t,i,s[i])})},pt=t=>{if(!R(t))return;const e=me(t);t.style.backgroundImage=e.backgroundImage},ut=(t,e,s)=>{x(t,e.class_applied),S(t,ce),!!s&&(e.unobserve_completed&&A(t,e),b(e.callback_applied,t,s))},ve=(t,e,s)=>{x(t,e.class_loading),S(t,O),!!s&&(U(s,1),b(e.callback_loading,t,s))},y=(t,e,s)=>{!s||t.setAttribute(e,s)},Se=(t,e)=>{y(t,D,f(t,e.data_sizes)),y(t,z,f(t,e.data_srcset)),y(t,m,f(t,e.data_src))},gt=(t,e)=>{Y(t,s=>{I(s,V),Se(s,e)}),I(t,V),Se(t,e)},ft=(t,e)=>{I(t,H),y(t,m,f(t,e.data_src))},wt=(t,e)=>{fe(t,s=>{I(s,H),y(s,m,f(s,e.data_src))}),I(t,we),y(t,oe,f(t,e.data_poster)),y(t,m,f(t,e.data_src)),t.load()},mt=(t,e,s)=>{const i=f(t,e.data_bg),r=f(t,e.data_bg_hidpi),a=ie&&r?r:i;!a||(t.style.backgroundImage=`url("${a}")`,pe(t).setAttribute(m,a),ve(t,e,s))},bt=(t,e,s)=>{const i=f(t,e.data_bg_multi),r=f(t,e.data_bg_multi_hidpi),a=ie&&r?r:i;!a||(t.style.backgroundImage=a,ut(t,e,s))},ye={IMG:gt,IFRAME:ft,VIDEO:wt},vt=(t,e)=>{const s=ye[t.tagName];!s||s(t,e)},St=(t,e,s)=>{const i=ye[t.tagName];!i||(i(t,e),ve(t,e,s))},yt=["IMG","IFRAME","VIDEO"],xt=t=>yt.indexOf(t.tagName)>-1,xe=(t,e)=>{e&&!ct(e)&&!lt(e)&&b(t.callback_finish,e)},Ee=(t,e,s)=>{t.addEventListener(e,s),t.llEvLisnrs[e]=s},Et=(t,e,s)=>{t.removeEventListener(e,s)},j=t=>!!t.llEvLisnrs,Tt=(t,e,s)=>{j(t)||(t.llEvLisnrs={});const i=t.tagName==="VIDEO"?"loadeddata":"load";Ee(t,i,e),Ee(t,"error",s)},G=t=>{if(!j(t))return;const e=t.llEvLisnrs;for(let s in e){const i=e[s];Et(t,s,i)}delete t.llEvLisnrs},Te=(t,e,s)=>{rt(t),U(s,-1),nt(s),w(t,e.class_loading),e.unobserve_completed&&A(t,s)},$t=(t,e,s,i)=>{const r=B(e);Te(e,s,i),x(e,s.class_loaded),S(e,ne),b(s.callback_loaded,e,i),r||xe(s,i)},_t=(t,e,s,i)=>{const r=B(e);Te(e,s,i),x(e,s.class_error),S(e,W),b(s.callback_error,e,i),r||xe(s,i)},q=(t,e,s)=>{const i=pe(t)||t;if(j(i))return;Tt(i,o=>{$t(o,t,e,s),G(i)},o=>{_t(o,t,e,s),G(i)})},It=(t,e,s)=>{it(t),q(t,e,s),ht(t),mt(t,e,s),bt(t,e,s)},Ct=(t,e,s)=>{q(t,e,s),St(t,e,s)},X=(t,e,s)=>{xt(t)?Ct(t,e,s):It(t,e,s)},Nt=(t,e,s)=>{t.setAttribute("loading","lazy"),q(t,e,s),vt(t,e),S(t,le)},$e=t=>{t.removeAttribute(m),t.removeAttribute(z),t.removeAttribute(D)},kt=t=>{Y(t,e=>{$e(e)}),$e(t)},_e=t=>{Y(t,e=>{C(e,V)}),C(t,V)},Lt={IMG:_e,IFRAME:t=>{C(t,H)},VIDEO:t=>{fe(t,e=>{C(e,H)}),C(t,we),t.load()}},Pt=t=>{const e=Lt[t.tagName];if(!e){pt(t);return}e(t)},At=(t,e)=>{F(t)||B(t)||(w(t,e.class_entered),w(t,e.class_exited),w(t,e.class_applied),w(t,e.class_loading),w(t,e.class_loaded),w(t,e.class_error))},Ht=(t,e)=>{Pt(t),At(t,e),P(t),be(t)},Vt=(t,e,s,i)=>{!s.cancel_on_exit||!Qe(t)||t.tagName==="IMG"&&(G(t),kt(t),_e(t),w(t,s.class_loading),U(i,-1),P(t),b(s.callback_cancel,t,e,i))},Rt=(t,e,s,i)=>{const r=st(t);S(t,Ke),x(t,s.class_entered),w(t,s.class_exited),ot(t,s,i),b(s.callback_enter,t,e,i),!r&&X(t,s,i)},Mt=(t,e,s,i)=>{F(t)||(x(t,s.class_exited),Vt(t,e,s,i),b(s.callback_exit,t,e,i))},zt=["IMG","IFRAME","VIDEO"],Ie=t=>t.use_native&&"loading"in HTMLImageElement.prototype,Dt=(t,e,s)=>{t.forEach(i=>{zt.indexOf(i.tagName)!==-1&&Nt(i,e,s)}),ue(s,0)},Ot=t=>t.isIntersecting||t.intersectionRatio>0,Wt=t=>({root:t.container===document?null:t.container,rootMargin:t.thresholds||t.threshold+"px"}),Ft=(t,e,s)=>{t.forEach(i=>Ot(i)?Rt(i.target,i,e,s):Mt(i.target,i,e,s))},Bt=(t,e)=>{e.forEach(s=>{t.observe(s)})},Ut=(t,e)=>{at(t),Bt(t,e)},Yt=(t,e)=>{!te||Ie(t)||(e._observer=new IntersectionObserver(s=>{Ft(s,t,e)},Wt(t)))},Ce=t=>Array.prototype.slice.call(t),M=t=>t.container.querySelectorAll(t.elements_selector),jt=t=>Ce(t).filter(F),Gt=t=>et(t),qt=t=>Ce(t).filter(Gt),Ne=(t,e)=>jt(t||M(e)),Xt=(t,e)=>{qt(M(t)).forEach(i=>{w(i,t.class_error),P(i)}),e.update()},Jt=(t,e)=>{!v||window.addEventListener("online",()=>{Xt(t,e)})},N=function(t,e){const s=re(t);this._settings=s,this.loadingCount=0,Yt(s,this),Jt(s,this),this.update(e)};N.prototype={update:function(t){const e=this._settings,s=Ne(t,e);if(ue(this,s.length),ee||!te){this.loadAll(s);return}if(Ie(e)){Dt(s,e,this);return}Ut(this._observer,s)},destroy:function(){this._observer&&this._observer.disconnect(),M(this._settings).forEach(t=>{be(t)}),delete this._observer,delete this._settings,delete this.loadingCount,delete this.toLoadCount},loadAll:function(t){const e=this._settings;Ne(t,e).forEach(i=>{A(i,this),X(i,e,this)})},restoreAll:function(){const t=this._settings;M(t).forEach(e=>{Ht(e,t)})}},N.load=(t,e)=>{const s=re(e);X(t,s)},N.resetStatus=t=>{P(t)},v&&Je(N,window.lazyLoadOptions);class ke{constructor({readonly:e,box:s,pages:i,onNewPageIndex:r,onPlay:a}){if(this.pageIndex=0,this.namespace="netless-app-docs-viewer",this.isShowPreview=!1,this.isSmallBox=!1,this.sideEffect=new L,i.length<=0)throw new Error("[DocsViewer] Empty pages.");this.readonly=e,this.box=s,this.pages=i,this.onNewPageIndex=r,this.onPlay=a,this.render()}mount(){this.box.mountContent(this.$content),this.box.mountFooter(this.$footer),this.sideEffect.add(()=>{const e=new N({container:this.$preview,elements_selector:`.${this.wrapClassName("preview-page>img")}`});return()=>e.destroy()},"preview-lazyload")}unmount(){this.$content.remove(),this.$footer.remove()}setReadonly(e){this.readonly!==e&&(this.readonly=e,this.$content.classList.toggle(this.wrapClassName("readonly"),e),this.$footer.classList.toggle(this.wrapClassName("readonly"),e),this.$pageNumberInput.disabled=e)}destroy(){this.sideEffect.flushAll(),this.unmount()}setPageIndex(e){Number.isNaN(e)||(this.pageIndex=e,this.$pageNumberInput.value=String(e+1))}setSmallBox(e){this.isSmallBox!==e&&(this.isSmallBox=e,this.$footer.classList.toggle(this.wrapClassName("float-footer"),e))}render(){return this.renderContent(),this.renderFooter(),this.$content}renderContent(){if(!this.$content){const e=document.createElement("div");e.className=this.wrapClassName("content"),this.$content=e,this.readonly&&e.classList.add(this.wrapClassName("readonly")),e.appendChild(this.renderPreviewMask()),e.appendChild(this.renderPreview())}return this.$content}renderPreview(){if(!this.$preview){const e=document.createElement("div");e.className=this.wrapClassName("preview")+" tele-fancy-scrollbar",this.$preview=e;const s=this.wrapClassName("preview-page"),i=this.wrapClassName("preview-page-name");this.pages.forEach((r,a)=>{var d;const o=(d=r.thumbnail)!=null?d:r.src.startsWith("ppt")?void 0:r.src;if(!o)return;const n=String(a),c=document.createElement("a");c.className=s+" "+this.wrapClassName(`preview-page-${a}`),c.setAttribute("href","#"),c.dataset.pageIndex=n;const h=document.createElement("span");h.className=i,h.textContent=String(a+1),h.dataset.pageIndex=n;const l=document.createElement("img");l.width=r.width,l.height=r.height,l.dataset.src=o,l.dataset.pageIndex=n,c.appendChild(l),c.appendChild(h),e.appendChild(c)}),this.sideEffect.addEventListener(e,"click",r=>{var o;if(this.readonly)return;const a=(o=r.target.dataset)==null?void 0:o.pageIndex;a&&(r.preventDefault(),r.stopPropagation(),r.stopImmediatePropagation(),this.onNewPageIndex(Number(a)),this.togglePreview(!1))})}return this.$preview}renderPreviewMask(){return this.$previewMask||(this.$previewMask=document.createElement("div"),this.$previewMask.className=this.wrapClassName("preview-mask"),this.sideEffect.addEventListener(this.$previewMask,"click",e=>{this.readonly||e.target===this.$previewMask&&this.togglePreview(!1)})),this.$previewMask}renderFooter(){if(!this.$footer){const e=document.createElement("div");if(e.className=this.wrapClassName("footer"),this.$footer=e,this.readonly&&e.classList.add(this.wrapClassName("readonly")),this.isSmallBox&&e.classList.add(this.wrapClassName("float-footer")),this.pages.some(c=>c.thumbnail||!c.src.startsWith("ppt"))){const c=this.renderFooterBtn("btn-sidebar",Ue(this.namespace));this.sideEffect.addEventListener(c,"click",()=>{this.readonly||this.togglePreview()}),this.$footer.appendChild(c)}const s=document.createElement("div");s.className=this.wrapClassName("page-jumps");const i=this.renderFooterBtn("btn-page-back",Ye(this.namespace));if(this.sideEffect.addEventListener(i,"click",()=>{this.readonly||this.onNewPageIndex(this.pageIndex-1)}),s.appendChild(i),this.onPlay){const c=this.renderFooterBtn("btn-page-play",Ge(this.namespace),qe(this.namespace)),h=()=>{this.sideEffect.setTimeout(()=>{c.classList.toggle(this.wrapClassName("footer-btn-playing"),!1)},500,"returnPlay")};this.sideEffect.addEventListener(c,"click",()=>{this.readonly||(c.classList.toggle(this.wrapClassName("footer-btn-playing"),!0),this.onPlay&&this.onPlay(),h())}),s.appendChild(c)}const r=this.renderFooterBtn("btn-page-next",je(this.namespace));this.sideEffect.addEventListener(r,"click",()=>{this.readonly||this.onNewPageIndex(this.pageIndex+1)}),s.appendChild(r);const a=document.createElement("div");a.className=this.wrapClassName("page-number");const o=document.createElement("input");o.className=this.wrapClassName("page-number-input"),o.value=String(this.pageIndex+1),this.readonly&&(o.disabled=!0),this.$pageNumberInput=o,this.sideEffect.addEventListener(o,"focus",()=>{o.select()}),this.sideEffect.addEventListener(o,"change",()=>{this.readonly||o.value&&this.onNewPageIndex(Number(o.value)-1)});const n=document.createElement("span");n.textContent=" / "+this.pages.length,a.appendChild(o),a.appendChild(n),this.$footer.appendChild(s),this.$footer.appendChild(a)}return this.$footer}renderFooterBtn(e,s,i){const r=document.createElement("button");return r.className=this.wrapClassName("footer-btn")+" "+this.wrapClassName(e),r.appendChild(s),i&&r.appendChild(i),r}togglePreview(e){if(this.isShowPreview=e!=null?e:!this.isShowPreview,this.$content.classList.toggle(this.wrapClassName("preview-active"),this.isShowPreview),this.isShowPreview){const s=this.$preview.querySelector("."+this.wrapClassName(`preview-page-${this.pageIndex}`));s&&this.$preview.scrollTo({top:s.offsetTop-16})}}wrapClassName(e){return`${this.namespace}-${e}`}}function E(t,e,s){return Math.min(Math.max(t,e),s)}function Le(t){return t.touches?t.touches[0]:t}function Pe(t){t.stopPropagation(),t.cancelable&&t.preventDefault()}class Kt{constructor(e){var s,i,r;this.velocity=0,this.paused=!0,this._animationFrameID=null,this._loopTimestamp=0,this.looper=a=>{if(this.paused)return;let o=Math.floor((a-this._loopTimestamp)/1e3*60)+1;for(this._loopTimestamp=a;o-- >0;)this.stepper();this.onStep(this.current,this),!this.paused&&this.current!==this.target&&window.requestAnimationFrame(this.looper)},this.current=(s=e.start)!=null?s:0,this.target=this.current,this.stiffness=(i=e.stiffness)!=null?i:170,this.damping=(r=e.damping)!=null?r:26,this.onStep=e.onStep}stepTo(e,s){this.paused&&s!=null&&(this.current=s),this.paused=!1,this.target=e,this.onStep(this.current,this),this._loopTimestamp=Date.now(),window.requestAnimationFrame(this.looper)}pause(){this.paused=!0}destroy(){this.pause()}stepper(){const e=-this.stiffness*(this.current-this.target),s=-this.damping*this.velocity,i=this.velocity+(e+s)/60,r=this.current+i/60;Math.abs(i-0)<.01&&Math.abs(r-this.target)<.01?(this.current=this.target,this.velocity=0):(this.current=r,this.velocity=i)}}class Zt{constructor(e,s,i){this.scale=1,this.lastVisit=Date.now(),this.pageOffsetY=0,this.visible=!0,this.index=e,this.page=s,this.scale=i;const r=document.createElement("div");r.className="page-renderer-page",r.dataset.index=`${e}`,r.style.width=`${s.width*i}px`,r.style.height=`${s.height*i}px`,s.thumbnail&&(r.style.backgroundImage=`url("${s.thumbnail}")`);const a=document.createElement("img");a.className="page-renderer-page-img",a.width=s.width,a.height=s.height,a.src=s.src,r.appendChild(a),this.$page=r}translateY(e){Math.abs(e-this.pageOffsetY)>=.001&&(this.pageOffsetY=e,window.requestAnimationFrame?window.requestAnimationFrame(()=>{this.$page.style.transform=`translateY(${e*this.scale}px)`}):this.$page.style.transform=`translateY(${e*this.scale}px)`)}setScale(e){Math.abs(e-this.scale)>=.001&&(this.scale=e,this.$page.style.width=`${this.page.width*this.scale}px`,this.$page.style.height=`${this.page.height*this.scale}px`,this.$page.style.transform=`translateY(${this.pageOffsetY*this.scale}px)`)}setVisible(e){e!==this.visible&&(this.visible=e,this.$page.style.opacity=e?"1":"0")}}const Qt=window.requestIdleCallback||(t=>window.setTimeout(t,5e3)),es=window.cancelIdleCallback||window.clearTimeout;class ts{constructor(e,s){this.pages=e,this.scale=s,this.els=new Map,this.maxElCount=200,this.gcTimer=null,this.gc=()=>{if(this.gcTimer=null,this.els.size>this.maxElCount){const i=[...this.els.values()].sort((r,a)=>a.lastVisit-r.lastVisit);for(let r=Math.floor(this.maxElCount/4);r<i.length;r++)this.els.delete(i[r].index)}}}getEl(e){let s=this.els.get(e);return s||(s=new Zt(e,this.pages[e],this.scale),this.els.set(e,s)),s.lastVisit=Date.now(),this.els.size>this.maxElCount&&this.gcTimer===null&&(this.gcTimer=Qt(this.gc)),s}setScale(e){e!==this.scale&&(this.scale=e,this.els.forEach(s=>s.setScale(e)))}destroy(){this.els.clear(),this.gcTimer!==null&&(es(this.gcTimer),this.gcTimer=null)}}class ss{constructor(e){this._hwaTimeout=NaN,this._turnOffHWA=()=>{window.clearTimeout(this._hwaTimeout),this._hwaTimeout=NaN,this.$pages.classList.toggle("is-hwa",!1)},this.pagesScrollTop=e.pagesScrollTop||0,this.containerWidth=e.containerWidth||1,this.containerHeight=e.containerHeight||1,this.pages=e.pages.map(a=>{if(a.thumbnail)return a;try{const o=new URL(a.src);return o.searchParams.set("x-oss-process","image/resize,l_50"),K(J({},a),{thumbnail:o.toString()})}catch(o){return console.error(o),a}});const s=Array(this.pages.length);let i=1/0,r=0;this.pagesIntrinsicHeight=this.pages.reduce((a,o,n)=>(s[n]=a,o.width>r&&(r=o.width),o.height<=i&&(i=o.height),a+o.height),0),this.pagesIntrinsicWidth=r,this.pagesMinHeight=i,this.pagesIntrinsicYs=s,this.scale=this._calcScale(),this.threshold=this._calcThreshold(),this.onPageIndexChanged=e.onPageIndexChanged,this.pageScrollIndex=0,this.pagesScrollTop!==0&&(this.pageScrollIndex=this.findScrollPageIndex(),this.onPageIndexChanged&&this.pageScrollIndex>0&&this.onPageIndexChanged(this.pageScrollIndex)),this.pageElManager=new ts(this.pages,this.scale),this.$pages=this.renderPages()}setContainerSize(e,s){e>0&&s>0&&(e!==this.containerWidth||s!==this.containerHeight)&&(this.containerWidth=e,this.containerHeight=s,this.$pages.style.width=`${this.containerWidth}px`,this.$pages.style.height=`${this.containerHeight}px`,this.scale=this._calcScale(),this.threshold=this._calcThreshold(),this.pageElManager.setScale(this.scale),this.$pages.parentElement&&this.pagesScrollTo(this.pagesScrollTop,!0))}renderPages(){const e=document.createElement("div");return e.className="page-renderer-pages-container",e.style.width=`${this.containerWidth}px`,e.style.height=`${this.containerHeight}px`,e}pagesScrollTo(e,s){if(e=E(e,0,this.pagesIntrinsicHeight-this.containerHeight/this.scale),s||Math.abs(e-this.pagesScrollTop)>=.001){this._turnOnHWA(),this.pagesScrollTop=e;const i=this.findScrollPageIndex(),r=Math.max(i-this.threshold,0),a=Math.min(i+this.threshold,this.pages.length-1);for(let o=0;o<this.$pages.children.length;o++){const n=this.$pages.children[o],c=Number(n.dataset.index);c>=r&&c<=a||(n.remove(),o--)}for(let o=r;o<=a;o++){const n=this.pageElManager.getEl(o);n.$page.parentElement!==this.$pages&&this.$pages.appendChild(n.$page),n.translateY(this.pagesIntrinsicYs[o]-this.pagesScrollTop)}i!==this.pageScrollIndex&&(this.pageScrollIndex=i,this.onPageIndexChanged&&this.onPageIndexChanged(i))}}findScrollPageIndex(){for(let e=0;e<this.pagesIntrinsicYs.length;e++)if(this.pagesIntrinsicYs[e]+this.pages[e].height-this.pagesScrollTop>=.001)return e;return this.pagesIntrinsicYs.length-1}mount(e){e.appendChild(this.$pages),this.pagesScrollTo(this.pagesScrollTop,!0)}unmount(){this.$pages.remove()}destroy(){this.unmount(),this.onPageIndexChanged=void 0,this.pageElManager.destroy(),this._hwaTimeout&&(window.clearTimeout(this._hwaTimeout),this._hwaTimeout=NaN)}_calcScale(){return this.containerWidth/this.pagesIntrinsicWidth||1}_calcThreshold(){return E(Math.ceil(this.containerHeight/this.scale/this.pagesMinHeight/2),1,this.pages.length)}_turnOnHWA(){this._hwaTimeout?window.clearTimeout(this._hwaTimeout):this.$pages.classList.toggle("is-hwa",!0),this._hwaTimeout=window.setTimeout(this._turnOffHWA,1e3)}}const is=30;class rs{constructor(e){this.sideEffect=new L,this.pagesScrollTop=e.pagesScrollTop||0,this.containerWidth=e.containerWidth||1,this.containerHeight=e.containerHeight||1,this.pagesWidth=e.pagesWidth||1,this.pagesHeight=e.pagesHeight||1,this.scale=this._calcScale(),this.scrollbarMinHeight=e.scrollbarMinHeight||is,this.scrollbarHeight=this._calcScrollbarHeight(),this.readonly=e.readonly,this.wrapClassName=e.wrapClassName,this.onDragScroll=e.onDragScroll,this.$scrollbar=this.renderScrollbar()}mount(e){e.appendChild(this.$scrollbar),this.pagesScrollTo(this.pagesScrollTop,!0)}unmount(){this.$scrollbar.remove()}setReadonly(e){this.readonly=e}setContainerSize(e,s){e>0&&s>0&&(e!==this.containerWidth||s!==this.containerHeight)&&(this.containerWidth=e,this.containerHeight=s,this.scale=this._calcScale(),this._updateScrollbarHeight(),this.$scrollbar.parentElement&&this.pagesScrollTo(this.pagesScrollTop,!0))}pagesScrollTo(e,s){if(e=E(e,0,this.pagesHeight-this.containerHeight/this.scale),s||Math.abs(e-this.pagesScrollTop)>=.001){this.pagesScrollTop=e;const i=this.pagesScrollTop*this.scale,r=this.pagesHeight*this.scale,a=i/(r-this.containerHeight)*(this.containerHeight-this.scrollbarHeight);window.requestAnimationFrame?window.requestAnimationFrame(()=>{this.$scrollbar.style.transform=`translateY(${a}px)`}):this.$scrollbar.style.transform=`translateY(${a}px)`}}destroy(){this.unmount(),this.onDragScroll=void 0,this.sideEffect.flushAll()}renderScrollbar(){const e=document.createElement("button");e.className=this.wrapClassName("scrollbar"),e.style.minHeight=`${this.scrollbarMinHeight}px`,e.style.height=`${this.scrollbarHeight}px`;const s=i=>{if(this.readonly||i.button!=null&&i.button!==0)return;Pe(i);const r=this.wrapClassName("scrollbar-dragging");e.classList.toggle(r,!0);const a=this.pagesScrollTop,{clientY:o}=Le(i),n=h=>{if(this.readonly)return;const{clientY:l}=Le(h),d=(l-o)/this.scale;Math.abs(d)>0&&this.onDragScroll&&this.onDragScroll(a+d*(this.pagesHeight*this.scale/this.containerHeight))},c=()=>{e.classList.toggle(r,!1),window.removeEventListener("mousemove",n,!0),window.removeEventListener("touchmove",n,!0),window.removeEventListener("mouseup",c,!0),window.removeEventListener("touchend",c,!0),window.removeEventListener("touchcancel",c,!0)};window.addEventListener("mousemove",n,!0),window.addEventListener("touchmove",n,!0),window.addEventListener("mouseup",c,!0),window.addEventListener("touchend",c,!0),window.addEventListener("touchcancel",c,!0)};return this.sideEffect.addEventListener(e,"mousedown",s),this.sideEffect.addEventListener(e,"touchstart",s),e}_calcScale(){return this.containerWidth/this.pagesWidth||1}_calcScrollbarHeight(){return E(this.containerHeight/(this.pagesHeight*this.scale)*this.containerHeight,this.scrollbarMinHeight,this.containerHeight)}_updateScrollbarHeight(){const e=this._calcScrollbarHeight();Math.abs(e-this.scrollbarHeight)>.001&&(this.scrollbarHeight=e,this.$scrollbar.style.height=`${e}px`)}}const k=640;class as{constructor({whiteboardView:e,readonly:s,box:i,pages:r,pageScrollTop:a=0,mountWhiteboard:o,onUserScroll:n}){this.sideEffect=new L,this.userScrolling=!1,this.onNewPageIndex=d=>{this.scrollToPage(d)},this.whiteboardView=e,this.readonly=s,this.box=i,this.pages=r,this.mountWhiteboard=o,this._onUserScroll=n;const c=this.debounce(()=>{this.userScrolling=!1,this._onUserScroll&&this._onUserScroll(this.pageRenderer.pagesScrollTop)},{wait:80},"debounce-updateUserScroll");this.updateUserScroll=()=>{this.userScrolling=!0,c()},this.viewer=new ke({readonly:s,box:i,pages:r,onNewPageIndex:this.onNewPageIndex});const{width:h,height:l}=this.whiteboardView.size;this.pageRenderer=new ss({pagesScrollTop:a,pages:this.pages,containerWidth:h,containerHeight:l,onPageIndexChanged:this.viewer.setPageIndex.bind(this.viewer)}),this.scrollbar=new rs({pagesScrollTop:this.pageRenderer.pagesScrollTop,containerWidth:h,containerHeight:l,pagesWidth:this.pageRenderer.pagesIntrinsicWidth,pagesHeight:this.pageRenderer.pagesIntrinsicHeight,readonly:this.readonly,wrapClassName:this.wrapClassName.bind(this),onDragScroll:d=>{this.pageScrollTo(d),this.updateUserScroll()}}),this.pageScrollStepper=new Kt({start:this.pageRenderer.pagesScrollTop,onStep:d=>{this.pageScrollTo(d)}}),this.render()}mount(){return this.viewer.mount(),this.setupScrollListener(),this.sideEffect.add(()=>{const e=this.renderRatioHeight.bind(this);return this.box.events.on("visual_resize",e),()=>this.box.events.off("visual_resize",e)}),this.sideEffect.setTimeout(()=>{this.userScrolling||this.pageScrollTo(this.pageRenderer.pagesScrollTop)},100),this}unmount(){return this.viewer.unmount(),this}setReadonly(e){this.readonly!==e&&(this.readonly=e,this.viewer.setReadonly(e),this.scrollbar.setReadonly(e))}destroy(){this.sideEffect.flushAll(),this.pageScrollStepper.destroy(),this._onUserScroll=void 0,this.unmount(),this.viewer.destroy(),this.pageRenderer.destroy(),this.scrollbar.destroy()}syncPageScrollTop(e){!this.userScrolling&&e>=0&&Math.abs(this.pageRenderer.pagesScrollTop-e)>.01&&this.pageScrollStepper.stepTo(e,this.pageRenderer.pagesScrollTop)}render(){this.pageRenderer.mount(this.viewer.$content),this.viewer.$content.appendChild(this.renderWhiteboardView()),this.scrollbar.mount(this.viewer.$content),this.renderRatioHeight()}renderRatioHeight(){const e=this.box.absoluteHeight,s=e<=k;if(this.viewer.setSmallBox(s),s){const i=26/k,r=26/e,a=26/k,o=0,n=Math.max((i+a-(r+o))/2,0);if(this.box.$titleBar){const c=r+n;this.box.$titleBar.style.height=`${c*100}%`}if(this.box.$footer){const c=o+n;this.box.$footer.style.height=`${c*100}%`}}else{if(this.box.$titleBar){const i=Math.max(26/k,26/e);this.box.$titleBar.style.height=`${i*100}%`}if(this.box.$footer){const i=Math.max(26/k,26/e);this.box.$footer.style.height=`${i*100}%`}}}renderWhiteboardView(){return this.$whiteboardView||(this.$whiteboardView=document.createElement("div"),this.$whiteboardView.className=this.wrapClassName("wb-view"),this.mountWhiteboard(this.$whiteboardView),this.sideEffect.addEventListener(this.$whiteboardView,"wheel",e=>{Pe(e),this.readonly||(this.pageScrollTo(this.pageRenderer.pagesScrollTop+e.deltaY),this.updateUserScroll())},{passive:!1,capture:!0}),this.sideEffect.addEventListener(this.$whiteboardView,"touchmove",e=>{this.readonly||e.touches.length<=1||this.updateUserScroll()},{passive:!0,capture:!0})),this.$whiteboardView}scrollTopPageToEl(e){return e*this.pageRenderer.scale}scrollTopElToPage(e){return e/this.pageRenderer.scale}elScrollTo(e){this.pageScrollTo(this.scrollTopElToPage(e))}pageScrollTo(e){const s=this.scrollTopElToPage(this.whiteboardView.size.height/2);this.whiteboardView.moveCamera({centerY:E(e+s,s,this.pageRenderer.pagesIntrinsicHeight-s),animationMode:"immediately"})}scrollToPage(e){if(!this.readonly&&!Number.isNaN(e)){const s=this.pageRenderer.pagesIntrinsicYs[e];s>=0&&(this.pageScrollTo(s+5/this.pageRenderer.scale),this.updateUserScroll())}}setupScrollListener(){this.sideEffect.add(()=>{const e=s=>{const{width:i,height:r}=this.whiteboardView.size;if(i<=0||r<=0)return;const a=s.centerY-this.pageRenderer.containerHeight/this.pageRenderer.scale/2;this.pageRenderer.pagesScrollTo(a),this.scrollbar.pagesScrollTo(a)};return this.whiteboardView.callbacks.on("onCameraUpdated",e),()=>this.whiteboardView.callbacks.off("onCameraUpdated",e)}),this.sideEffect.add(()=>{const e=({width:s,height:i})=>{if(s<=0||i<=0)return;this.pageRenderer.setContainerSize(s,i),this.scrollbar.setContainerSize(s,i);const{pagesIntrinsicWidth:r,pagesIntrinsicHeight:a}=this.pageRenderer;this.whiteboardView.moveCameraToContain({originX:0,originY:this.pageRenderer.pagesScrollTop,width:r,height:i/this.pageRenderer.scale,animationMode:"immediately"}),this.whiteboardView.setCameraBound({damping:1,maxContentMode:()=>this.pageRenderer.scale,minContentMode:()=>this.pageRenderer.scale,centerX:r/2,centerY:a/2,width:r,height:a})};return this.whiteboardView.callbacks.on("onSizeUpdated",e),()=>{this.whiteboardView.callbacks.off("onSizeUpdated",e)}},"whiteboard-size-update"),this.sideEffect.addEventListener(window,"keyup",e=>{if(this.readonly||!this.box.focus||this.box.minimized)return;let s=null;switch(e.key){case"PageDown":{s=this.pageRenderer.pagesScrollTop+this.pageRenderer.containerHeight/this.pageRenderer.scale;break}case"PageUp":{s=this.pageRenderer.pagesScrollTop-this.pageRenderer.containerHeight/this.pageRenderer.scale;break}case"ArrowDown":{s=this.pageRenderer.pagesScrollTop+this.pageRenderer.containerHeight/4/this.pageRenderer.scale;break}case"ArrowUp":{s=this.pageRenderer.pagesScrollTop-this.pageRenderer.containerHeight/4/this.pageRenderer.scale;break}}s!==null&&(this._onUserScroll?this._onUserScroll(s):(this.pageScrollTo(s),this.updateUserScroll()))},{capture:!0})}debounce(e,s,i){const r=Fe(e,s);return this.sideEffect.addDisposer(()=>r.cancel(),i),r}wrapClassName(e){return"netless-app-docs-viewer-static-"+e}}class os{constructor({context:e,whiteboardView:s,box:i,pages:r}){this.sideEffect=new L,this.onPlayPPT=()=>{const a=this.context.getRoom();a&&a.pptNextStep()},this._scaleDocsToFitImpl=()=>{const a=this.pages[this.getPageIndex()];a&&this.whiteboardView.moveCameraToContain({originX:-a.width/2,originY:-a.height/2,width:a.width,height:a.height,animationMode:"immediately"})},this._scaleDocsToFitDebounced=()=>{this.sideEffect.setTimeout(this._scaleDocsToFitImpl,1e3,"_scaleDocsToFitDebounced")},this.scaleDocsToFit=()=>{this._scaleDocsToFitImpl(),this._scaleDocsToFitDebounced()},this.onNewPageIndex=a=>{this.jumpToPage(a,!0)},this.context=e,this.whiteboardView=s,this.box=i,this.pages=r,this.displayer=e.getDisplayer(),this.viewer=new ke({readonly:!e.getIsWritable(),box:i,pages:r,onNewPageIndex:this.onNewPageIndex,onPlay:this.onPlayPPT}),this.render(),this.sideEffect.add(()=>{const a=o=>{this.viewer.setReadonly(!o)};return this.context.emitter.on("writableChange",a),()=>this.context.emitter.off("writableChange",a)}),this.sideEffect.add(()=>{const a=o=>{this.jumpToPage(o.index)};return this.context.emitter.on("sceneStateChange",a),()=>this.context.emitter.off("sceneStateChange",a)})}mount(){this.viewer.mount();const e=this.getPageIndex();return e!==0&&this.jumpToPage(e),this.scaleDocsToFit(),this.sideEffect.add(()=>(this.whiteboardView.callbacks.on("onSizeUpdated",this.scaleDocsToFit),()=>{this.whiteboardView.callbacks.off("onSizeUpdated",this.scaleDocsToFit)})),this}unmount(){return this.viewer.unmount(),this}destroy(){this.sideEffect.flushAll(),this.unmount(),this.viewer.destroy()}getPageIndex(){return this.displayer.state.sceneState.index}jumpToPage(e,s){var i,r;if(e=E(e,0,this.pages.length-1),e!==this.getPageIndex()&&this.context.getIsWritable()){const a=this.context.getInitScenePath(),o=(r=(i=this.context.getScenes())==null?void 0:i[e])==null?void 0:r.name;a&&o&&this.context.setScenePath(`${a}/${o}`),this.scaleDocsToFit()}if(e!==this.viewer.pageIndex&&this.viewer.setPageIndex(e),s){const a=this.context.getRoom();if(a){const o=a.state.globalState.__pptState;a.setGlobalState({__pptState:o&&{uuid:o.uuid,pageIndex:e,disableAutoPlay:o.disableAutoPlay}})}}}render(){this.viewer.$content.appendChild(this.renderMask()),this.viewer.$content.appendChild(this.renderWhiteboardView()),this.sideEffect.addEventListener(window,"keydown",e=>{var s;if(this.box.focus)switch(e.key){case"ArrowUp":case"ArrowLeft":{this.jumpToPage(this.getPageIndex()-1,!0);break}case"ArrowRight":case"ArrowDown":{(s=this.context.getRoom())==null||s.pptNextStep();break}}})}renderMask(){if(!this.$mask){const e=document.createElement("div");e.className=this.wrapClassName("mask"),this.$mask=e;const s=document.createElement("button");s.className=this.wrapClassName("back");const i=document.createElement("button");i.className=this.wrapClassName("next")}return this.$mask}renderWhiteboardView(){return this.$whiteboardView||(this.$whiteboardView=document.createElement("div"),this.$whiteboardView.className=this.wrapClassName("wb-view"),this.sideEffect.addEventListener(this.$whiteboardView,"click",e=>{var i;const s=this.context.getRoom();if(s&&s.state.memberState.currentApplianceName==="clicker"){for(let r=e.target;r;r=r.parentElement)if((i=r.classList)==null?void 0:i.contains("ppt-event-source"))return;s.pptNextStep()}}),this.context.mountView(this.$whiteboardView)),this.$whiteboardView}wrapClassName(e){return"netless-app-docs-viewer-dynamic-"+e}}const ns={kind:"DocsViewer",setup(t){const e=t.getBox(),s=t.getScenes();if(!s)throw new Error("[Docs Viewer]: scenes not found.");const i=t.getView();if(!i)throw new Error("[Docs Viewer]: no whiteboard view.");const r=s.map(({ppt:a})=>a?{width:a.width,height:a.height,src:a.src,thumbnail:a.previewURL}:null).filter(a=>Boolean(a));if(r.length<=0)throw new Error("[Docs Viewer]: empty scenes.");e.mountStyles(u),r[0].src.startsWith("ppt")?ls(t,i,e,r):cs(t,i,e,r)}};function cs(t,e,s,i){var a;e.disableCameraTransform=!t.getIsWritable();const r=new as({whiteboardView:e,readonly:!t.getIsWritable(),box:s,pages:i,pageScrollTop:(a=t.getAttributes())==null?void 0:a.pageScrollTop,mountWhiteboard:t.mountView.bind(t),onUserScroll:o=>{var n;((n=t.getAttributes())==null?void 0:n.pageScrollTop)!==o&&!s.readonly&&t.updateAttributes(["pageScrollTop"],o)}}).mount();t.emitter.on("attributesUpdate",o=>{o&&o.pageScrollTop!=null&&r.syncPageScrollTop(o.pageScrollTop)}),t.emitter.on("writableChange",o=>{r.setReadonly(!o),e.disableCameraTransform=!o})}function ls(t,e,s,i){e.disableCameraTransform=!0;const r=new os({context:t,whiteboardView:e,box:s,pages:i}).mount();t.mountView(r.$whiteboardView),t.isAddApp&&e.callbacks.once("onSizeUpdated",({width:a,height:o})=>{if(i.length>0&&s.state!=="maximized"){const{width:n,height:c}=i[0],l=c/n*a-o;l!==0&&t.getIsWritable()&&t.emitter.emit("setBoxSize",{width:s.width,height:s.height+l/s.containerRect.height})}})}return p.default=ns,Object.defineProperty(p,"__esModule",{value:!0}),p[Symbol.toStringTag]="Module",p}({});
var gs=Object.defineProperty,us=Object.defineProperties;var fs=Object.getOwnPropertyDescriptors;var Ae=Object.getOwnPropertySymbols;var ws=Object.prototype.hasOwnProperty,bs=Object.prototype.propertyIsEnumerable;var He=(p,g,u)=>g in p?gs(p,g,{enumerable:!0,configurable:!0,writable:!0,value:u}):p[g]=u,J=(p,g)=>{for(var u in g||(g={}))ws.call(g,u)&&He(p,u,g[u]);if(Ae)for(var u of Ae(g))bs.call(g,u)&&He(p,u,g[u]);return p},K=(p,g)=>us(p,fs(g));var NetlessAppDocsViewer=function(p){"use strict";var g=`.netless-app-docs-viewer-content{position:relative;height:100%;overflow:hidden}.netless-app-docs-viewer-preview-mask{display:none;position:absolute;z-index:200;top:0;left:0;width:100%;height:100%}.netless-app-docs-viewer-preview{display:flex;flex-direction:column;align-items:center;position:absolute;z-index:300;top:0;left:0;width:33%;max-width:200px;height:100%;padding-top:10px;transform:translate(-100%);background:rgba(237,237,240,.9);box-shadow:inset -1px 0 #0000001c;transition:transform .4s}.netless-app-docs-viewer-preview-active .netless-app-docs-viewer-preview-mask{display:block}.netless-app-docs-viewer-preview-active .netless-app-docs-viewer-preview{transform:translate(0)}.netless-app-docs-viewer-preview-page{position:relative;display:block;width:55%;margin-bottom:10px;font-size:0;color:transparent;outline:none;border:7px solid transparent;border-radius:4px;transition:border-color .3s;user-select:none}.netless-app-docs-viewer-preview-page:hover,.netless-app-docs-viewer-preview-page.netless-app-docs-viewer-preview-page-active{border-color:#444e601a}.netless-app-docs-viewer-preview-page>img{width:100%;height:auto;box-sizing:border-box;border:1px solid rgba(0,0,0,.5);border-radius:1px;background-color:#fff;box-shadow:0 2px 8px #0000004d}.netless-app-docs-viewer-preview-page-name{position:absolute;top:1px;left:-10px;transform:translate(-100%);text-align:right;font-size:12px;color:#5f5f5f;user-select:none}.netless-app-docs-viewer-footer{box-sizing:border-box;height:26px;display:flex;align-items:center;padding:0 16px;border-top:1px solid #eeeef7;color:#191919}.netless-app-docs-viewer-float-footer{width:100%;min-height:26px;position:absolute;left:0;bottom:0;z-index:2000;background:rgba(249,249,252,.9);transition:opacity .4s}.netless-app-docs-viewer-footer-btn{box-sizing:border-box;width:26px;height:26px;font-size:0;margin:0;padding:3px;border:none;border-radius:1px;outline:none;color:currentColor;background:transparent;transition:background .4s;cursor:pointer;user-select:none;-webkit-tap-highlight-color:rgba(0,0,0,0)}.netless-app-docs-viewer-footer-btn:hover{background:rgba(237,237,240,.9)}@media (hover: none){.netless-app-docs-viewer-footer-btn:hover{background:transparent!important}}.netless-app-docs-viewer-footer-btn>svg{width:100%;height:100%}.netless-app-docs-viewer-footer-btn>svg:nth-of-type(2){display:none}.netless-app-docs-viewer-footer-btn.netless-app-docs-viewer-footer-btn-playing>svg:nth-of-type(1){display:none}.netless-app-docs-viewer-footer-btn.netless-app-docs-viewer-footer-btn-playing>svg:nth-of-type(2){display:initial}.netless-app-docs-viewer-footer-btn~.netless-app-docs-viewer-footer-btn{margin-left:15px}.netless-app-docs-viewer-page-jumps{flex:1;display:flex;justify-content:center;align-items:center}.netless-app-docs-viewer-page-number{margin-left:auto;font-size:13px;user-select:none;white-space:nowrap;word-break:keep-all}.netless-app-docs-viewer-page-number-input{border:none;outline:none;width:3em;margin:0;padding:0 2px;text-align:right;font-size:13px;line-height:1;font-weight:400;font-family:inherit;border-radius:2px;color:currentColor;background:transparent;transition:background .4s;user-select:text;-webkit-tap-highlight-color:rgba(0,0,0,0)}.netless-app-docs-viewer-page-number-input:hover,.netless-app-docs-viewer-page-number-input:focus,.netless-app-docs-viewer-page-number-input:active{background:#fff;box-shadow:#63636333 0 2px 8px}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-footer-btn{cursor:not-allowed}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-footer-btn:hover{background:transparent}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-page-number-input{cursor:not-allowed}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-page-number-input:hover,.netless-app-docs-viewer-readonly .netless-app-docs-viewer-page-number-input:focus,.netless-app-docs-viewer-readonly .netless-app-docs-viewer-page-number-input:active{background:transparent;box-shadow:none}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-page-number-input:disabled{color:inherit}.netless-app-docs-viewer-readonly.netless-app-docs-viewer-float-footer{display:none}.telebox-color-scheme-dark .netless-app-docs-viewer-page-number-input{color:#a6a6a8}.telebox-color-scheme-dark .netless-app-docs-viewer-page-number-input:active,.telebox-color-scheme-dark .netless-app-docs-viewer-page-number-input:focus,.telebox-color-scheme-dark .netless-app-docs-viewer-page-number-input:hover{color:#222}.telebox-color-scheme-dark .netless-app-docs-viewer-footer{color:#a6a6a8;background:#2d2d33;border-top:none}.telebox-color-scheme-dark .netless-app-docs-viewer-footer-btn:hover{background:#212126}.telebox-color-scheme-dark .netless-app-docs-viewer-preview{background:rgba(50,50,50,.9)}.netless-app-docs-viewer-static-scrollbar{position:absolute;top:0;right:0;z-index:2147483647;width:8px;min-height:30px;margin:0;padding:0;border:none;outline:none;border-radius:4px;background:rgba(68,78,96,.4);box-shadow:1px 1px 8px #ffffffb3;opacity:0;transition:background .4s,opacity .4s 3s,transform .2s;user-select:none}.netless-app-docs-viewer-static-scrollbar.netless-app-docs-viewer-static-scrollbar-dragging{background:rgba(68,78,96,.6);opacity:1;transition:background .4s,opacity .4s 3s!important}.netless-app-docs-viewer-static-scrollbar:hover,.netless-app-docs-viewer-static-scrollbar:focus{background:rgba(68,78,96,.5)}.netless-app-docs-viewer-static-scrollbar:active{background:rgba(68,78,96,.6)}.netless-app-docs-viewer-content:hover .netless-app-docs-viewer-static-scrollbar{opacity:1;transition:background .4s,opacity .4s,transform .2s}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-static-scrollbar{display:none}.netless-app-docs-viewer-static-pages:hover .netless-app-docs-viewer-static-scrollbar{opacity:1;transition:background .4s,opacity .4s,transform .2s}.page-renderer-pages-container{position:relative;overflow:hidden}.page-renderer-page{position:absolute;top:0;left:0;background-position:center;background-size:cover;background-repeat:no-repeat}.page-renderer-pages-container.is-hwa .page-renderer-page{will-change:transform}.page-renderer-page-img{display:block;width:100%;height:auto;user-select:none}.netless-app-docs-viewer-static-pages{overflow:hidden;position:relative;height:100%;user-select:none}.netless-app-docs-viewer-static-page{display:block;width:100%;height:auto;user-select:none}.netless-app-docs-viewer-static-wb-view,.netless-app-docs-viewer-dynamic-wb-view{position:absolute;top:0;left:0;width:100%;height:100%;z-index:100;overflow:hidden}.netless-app-docs-viewer-dynamic-wb-view .cursor-clicker .ppt-event-source{cursor:pointer}
`;const u=(t,e,s,i)=>{if(s==="length"||s==="prototype"||s==="arguments"||s==="caller")return;const r=Object.getOwnPropertyDescriptor(t,s),a=Object.getOwnPropertyDescriptor(e,s);!Ve(r,a)&&i||Object.defineProperty(t,s,a)},Ve=function(t,e){return t===void 0||t.configurable||t.writable===e.writable&&t.enumerable===e.enumerable&&t.configurable===e.configurable&&(t.writable||t.value===e.value)},Re=(t,e)=>{const s=Object.getPrototypeOf(e);s!==Object.getPrototypeOf(t)&&Object.setPrototypeOf(t,s)},Me=(t,e)=>`/* Wrapped ${t}*/
${e}`,Oe=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),ze=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),De=(t,e,s)=>{const i=s===""?"":`with ${s.trim()}() `,r=Me.bind(null,i,e.toString());Object.defineProperty(r,"name",ze),Object.defineProperty(t,"toString",K(J({},Oe),{value:r}))};var We=(t,e,{ignoreNonConfigurable:s=!1}={})=>{const{name:i}=t;for(const r of Reflect.ownKeys(e))u(t,e,r,s);return Re(t,e),De(t,e,i),t};const Be=(t,e={})=>{if(typeof t!="function")throw new TypeError(`Expected the first argument to be a function, got \`${typeof t}\``);const{wait:s=0,maxWait:i=Number.Infinity,before:r=!1,after:a=!0}=e;if(!r&&!a)throw new Error("Both `before` and `after` are false, function wouldn't be called.");let o,n,c;const h=function(...l){const d=this,hs=()=>{o=void 0,n&&(clearTimeout(n),n=void 0),a&&(c=t.apply(d,l))},ds=()=>{n=void 0,o&&(clearTimeout(o),o=void 0),a&&(c=t.apply(d,l))},ps=r&&!o;return clearTimeout(o),o=setTimeout(hs,s),i>0&&i!==Number.Infinity&&!n&&(n=setTimeout(ds,i)),ps&&(c=t.apply(d,l)),c};return We(h,t),h.cancel=()=>{o&&(clearTimeout(o),o=void 0),n&&(clearTimeout(n),n=void 0)},h},Z="!#%()*+,-./:;=?@[]^_`{|}~ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",Fe=Z.length,Q=Array(20),T=()=>{for(let t=0;t<20;t++)Q[t]=Z.charAt(Math.random()*Fe);return Q.join("")};class L{constructor(){this.disposers=new Map}add(e,s=T()){return this.flush(s),this.disposers.set(s,e()),s}addDisposer(e,s=T()){return this.flush(s),this.disposers.set(s,e),s}addEventListener(e,s,i,r,a=T()){return this.add(()=>(e.addEventListener(s,i,r),()=>e.removeEventListener(s,i,r)),a),a}setTimeout(e,s,i=T()){return this.add(()=>{const r=window.setTimeout(()=>{this.remove(i),e()},s);return()=>window.clearTimeout(r)},i)}setInterval(e,s,i=T()){return this.add(()=>{const r=window.setInterval(e,s);return()=>window.clearInterval(r)},i)}remove(e){const s=this.disposers.get(e);return this.disposers.delete(e),s}flush(e){const s=this.remove(e);if(s)try{s()}catch(i){console.error(i)}}flushAll(){this.disposers.forEach(e=>{try{e()}catch(s){console.error(s)}}),this.disposers.clear()}}function Ue(t){const e="http://www.w3.org/2000/svg",s=document.createElementNS(e,"svg");s.setAttribute("class",`${t}-footer-icon-sidebar`),s.setAttribute("viewBox","0 0 64 64");const i=document.createElementNS(e,"path");return i.setAttribute("fill","currentColor"),i.setAttribute("d","M50 8H14c-3.309 0-6 2.691-6 6v36c0 3.309 2.691 6 6 6h36c3.309 0 6-2.691 6-6V14c0-3.309-2.691-6-6-6zM12 50V14c0-1.103.897-2 2-2h8v40h-8c-1.103 0-2-.897-2-2zm40 0c0 1.103-.897 2-2 2H26V12h24c1.103 0 2 .897 2 2z"),s.appendChild(i),s}function Ye(t){const e="http://www.w3.org/2000/svg",s=document.createElementNS(e,"svg");s.setAttribute("class",`${t}-footer-icon-arrow-left`),s.setAttribute("viewBox","0 0 500 500");const i=document.createElementNS(e,"path");return i.setAttribute("fill","currentColor"),i.setAttribute("d","M177.81 249.959L337.473 90.295c2.722-2.865 2.651-7.378-.143-10.1-2.793-2.65-7.163-2.65-9.956 0l-164.75 164.75c-2.793 2.793-2.793 7.306 0 10.1l164.75 164.75c2.865 2.722 7.378 2.65 10.099-.143 2.651-2.794 2.651-7.163 0-9.957L177.809 249.959z"),s.appendChild(i),s}function je(t){const e="http://www.w3.org/2000/svg",s=document.createElementNS(e,"svg");s.setAttribute("class",`${t}-footer-icon-arrow-right`),s.setAttribute("viewBox","0 0 500 500");const i=document.createElementNS(e,"path");return i.setAttribute("fill","currentColor"),i.setAttribute("d","M322.19 250.041L162.527 409.705c-2.722 2.865-2.651 7.378.143 10.1 2.793 2.65 7.163 2.65 9.956 0l164.75-164.75c2.793-2.793 2.793-7.306 0-10.1l-164.75-164.75c-2.865-2.722-7.378-2.65-10.099.143-2.651 2.794-2.651 7.163 0 9.957l159.664 159.736z"),s.appendChild(i),s}function Ge(t){const e="http://www.w3.org/2000/svg",s=document.createElementNS(e,"svg");s.setAttribute("class",`${t}-footer-icon-play`),s.setAttribute("viewBox","0 0 500 500");const i=document.createElementNS(e,"path");return i.setAttribute("fill","currentColor"),i.setAttribute("d","M418.158 257.419L174.663 413.33c-6.017 3.919-15.708 3.772-21.291-.29-2.791-2.018-4.295-4.483-4.295-7.084V94.109c0-5.65 6.883-10.289 15.271-10.289 4.298 0 8.391 1.307 11.181 3.332l242.629 155.484c6.016 3.917 6.451 10.292.649 14.491-.216.154-.432.154-.649.292zM170.621 391.288l223.116-141.301L170.71 107.753l-.089 283.535z"),s.appendChild(i),s}function qe(t){const e="http://www.w3.org/2000/svg",s=document.createElementNS(e,"svg");s.setAttribute("class",`${t}-footer-icon-pause`),s.setAttribute("viewBox","0 0 500 500");const i=document.createElementNS(e,"path");return i.setAttribute("fill","currentColor"),i.setAttribute("d","M312.491 78.261c0-6.159 4.893-11.213 11.04-11.213 6.158 0 11.211 5.054 11.211 11.213v343.478c0 6.159-5.053 11.213-11.211 11.213-6.147 0-11.04-5.054-11.04-11.213V78.261zM165.257 78.261c0-6.159 4.893-11.213 11.04-11.213 6.158 0 11.211 5.054 11.211 11.213v343.478c0 6.159-5.053 11.213-11.211 11.213-6.147 0-11.04-5.054-11.04-11.213V78.261z"),s.appendChild(i),s}const v=typeof window!="undefined",ee=v&&!("onscroll"in window)||typeof navigator!="undefined"&&/(gle|ing|ro)bot|crawl|spider/i.test(navigator.userAgent),te=v&&"IntersectionObserver"in window,se=v&&"classList"in document.createElement("p"),ie=v&&window.devicePixelRatio>1,Xe={elements_selector:".lazy",container:ee||v?document:null,threshold:300,thresholds:null,data_src:"src",data_srcset:"srcset",data_sizes:"sizes",data_bg:"bg",data_bg_hidpi:"bg-hidpi",data_bg_multi:"bg-multi",data_bg_multi_hidpi:"bg-multi-hidpi",data_poster:"poster",class_applied:"applied",class_loading:"loading",class_loaded:"loaded",class_error:"error",class_entered:"entered",class_exited:"exited",unobserve_completed:!0,unobserve_entered:!1,cancel_on_exit:!0,callback_enter:null,callback_exit:null,callback_applied:null,callback_loading:null,callback_loaded:null,callback_error:null,callback_finish:null,callback_cancel:null,use_native:!1},re=t=>Object.assign({},Xe,t),ae=function(t,e){let s;const i="LazyLoad::Initialized",r=new t(e);try{s=new CustomEvent(i,{detail:{instance:r}})}catch{s=document.createEvent("CustomEvent"),s.initCustomEvent(i,!1,!1,{instance:r})}window.dispatchEvent(s)},Je=(t,e)=>{if(!!e)if(!e.length)ae(t,e);else for(let s=0,i;i=e[s];s+=1)ae(t,i)},b="src",O="srcset",z="sizes",oe="poster",$="llOriginalAttrs",D="loading",ne="loaded",ce="applied",Ke="entered",W="error",le="native",he="data-",de="ll-status",f=(t,e)=>t.getAttribute(he+e),Ze=(t,e,s)=>{var i=he+e;if(s===null){t.removeAttribute(i);return}t.setAttribute(i,s)},_=t=>f(t,de),S=(t,e)=>Ze(t,de,e),P=t=>S(t,null),B=t=>_(t)===null,Qe=t=>_(t)===D,et=t=>_(t)===W,F=t=>_(t)===le,tt=[D,ne,ce,W],st=t=>tt.indexOf(_(t))>=0,m=(t,e,s,i)=>{if(!!t){if(i!==void 0){t(e,s,i);return}if(s!==void 0){t(e,s);return}t(e)}},x=(t,e)=>{if(se){t.classList.add(e);return}t.className+=(t.className?" ":"")+e},w=(t,e)=>{if(se){t.classList.remove(e);return}t.className=t.className.replace(new RegExp("(^|\\s+)"+e+"(\\s+|$)")," ").replace(/^\s+/,"").replace(/\s+$/,"")},it=t=>{t.llTempImage=document.createElement("IMG")},rt=t=>{delete t.llTempImage},pe=t=>t.llTempImage,A=(t,e)=>{if(!e)return;const s=e._observer;!s||s.unobserve(t)},at=t=>{t.disconnect()},ot=(t,e,s)=>{e.unobserve_entered&&A(t,s)},U=(t,e)=>{!t||(t.loadingCount+=e)},nt=t=>{!t||(t.toLoadCount-=1)},ge=(t,e)=>{!t||(t.toLoadCount=e)},ct=t=>t.loadingCount>0,lt=t=>t.toLoadCount>0,ue=t=>{let e=[];for(let s=0,i;i=t.children[s];s+=1)i.tagName==="SOURCE"&&e.push(i);return e},Y=(t,e)=>{const s=t.parentNode;if(!s||s.tagName!=="PICTURE")return;ue(s).forEach(e)},fe=(t,e)=>{ue(t).forEach(e)},H=[b],we=[b,oe],V=[b,O,z],R=t=>!!t[$],be=t=>t[$],me=t=>delete t[$],I=(t,e)=>{if(R(t))return;const s={};e.forEach(i=>{s[i]=t.getAttribute(i)}),t[$]=s},ht=t=>{R(t)||(t[$]={backgroundImage:t.style.backgroundImage})},dt=(t,e,s)=>{if(!s){t.removeAttribute(e);return}t.setAttribute(e,s)},C=(t,e)=>{if(!R(t))return;const s=be(t);e.forEach(i=>{dt(t,i,s[i])})},pt=t=>{if(!R(t))return;const e=be(t);t.style.backgroundImage=e.backgroundImage},gt=(t,e,s)=>{x(t,e.class_applied),S(t,ce),!!s&&(e.unobserve_completed&&A(t,e),m(e.callback_applied,t,s))},ve=(t,e,s)=>{x(t,e.class_loading),S(t,D),!!s&&(U(s,1),m(e.callback_loading,t,s))},y=(t,e,s)=>{!s||t.setAttribute(e,s)},Se=(t,e)=>{y(t,z,f(t,e.data_sizes)),y(t,O,f(t,e.data_srcset)),y(t,b,f(t,e.data_src))},ut=(t,e)=>{Y(t,s=>{I(s,V),Se(s,e)}),I(t,V),Se(t,e)},ft=(t,e)=>{I(t,H),y(t,b,f(t,e.data_src))},wt=(t,e)=>{fe(t,s=>{I(s,H),y(s,b,f(s,e.data_src))}),I(t,we),y(t,oe,f(t,e.data_poster)),y(t,b,f(t,e.data_src)),t.load()},bt=(t,e,s)=>{const i=f(t,e.data_bg),r=f(t,e.data_bg_hidpi),a=ie&&r?r:i;!a||(t.style.backgroundImage=`url("${a}")`,pe(t).setAttribute(b,a),ve(t,e,s))},mt=(t,e,s)=>{const i=f(t,e.data_bg_multi),r=f(t,e.data_bg_multi_hidpi),a=ie&&r?r:i;!a||(t.style.backgroundImage=a,gt(t,e,s))},ye={IMG:ut,IFRAME:ft,VIDEO:wt},vt=(t,e)=>{const s=ye[t.tagName];!s||s(t,e)},St=(t,e,s)=>{const i=ye[t.tagName];!i||(i(t,e),ve(t,e,s))},yt=["IMG","IFRAME","VIDEO"],xt=t=>yt.indexOf(t.tagName)>-1,xe=(t,e)=>{e&&!ct(e)&&!lt(e)&&m(t.callback_finish,e)},Ee=(t,e,s)=>{t.addEventListener(e,s),t.llEvLisnrs[e]=s},Et=(t,e,s)=>{t.removeEventListener(e,s)},j=t=>!!t.llEvLisnrs,Tt=(t,e,s)=>{j(t)||(t.llEvLisnrs={});const i=t.tagName==="VIDEO"?"loadeddata":"load";Ee(t,i,e),Ee(t,"error",s)},G=t=>{if(!j(t))return;const e=t.llEvLisnrs;for(let s in e){const i=e[s];Et(t,s,i)}delete t.llEvLisnrs},Te=(t,e,s)=>{rt(t),U(s,-1),nt(s),w(t,e.class_loading),e.unobserve_completed&&A(t,s)},$t=(t,e,s,i)=>{const r=F(e);Te(e,s,i),x(e,s.class_loaded),S(e,ne),m(s.callback_loaded,e,i),r||xe(s,i)},_t=(t,e,s,i)=>{const r=F(e);Te(e,s,i),x(e,s.class_error),S(e,W),m(s.callback_error,e,i),r||xe(s,i)},q=(t,e,s)=>{const i=pe(t)||t;if(j(i))return;Tt(i,o=>{$t(o,t,e,s),G(i)},o=>{_t(o,t,e,s),G(i)})},It=(t,e,s)=>{it(t),q(t,e,s),ht(t),bt(t,e,s),mt(t,e,s)},Ct=(t,e,s)=>{q(t,e,s),St(t,e,s)},X=(t,e,s)=>{xt(t)?Ct(t,e,s):It(t,e,s)},Nt=(t,e,s)=>{t.setAttribute("loading","lazy"),q(t,e,s),vt(t,e),S(t,le)},$e=t=>{t.removeAttribute(b),t.removeAttribute(O),t.removeAttribute(z)},kt=t=>{Y(t,e=>{$e(e)}),$e(t)},_e=t=>{Y(t,e=>{C(e,V)}),C(t,V)},Lt={IMG:_e,IFRAME:t=>{C(t,H)},VIDEO:t=>{fe(t,e=>{C(e,H)}),C(t,we),t.load()}},Pt=t=>{const e=Lt[t.tagName];if(!e){pt(t);return}e(t)},At=(t,e)=>{B(t)||F(t)||(w(t,e.class_entered),w(t,e.class_exited),w(t,e.class_applied),w(t,e.class_loading),w(t,e.class_loaded),w(t,e.class_error))},Ht=(t,e)=>{Pt(t),At(t,e),P(t),me(t)},Vt=(t,e,s,i)=>{!s.cancel_on_exit||!Qe(t)||t.tagName==="IMG"&&(G(t),kt(t),_e(t),w(t,s.class_loading),U(i,-1),P(t),m(s.callback_cancel,t,e,i))},Rt=(t,e,s,i)=>{const r=st(t);S(t,Ke),x(t,s.class_entered),w(t,s.class_exited),ot(t,s,i),m(s.callback_enter,t,e,i),!r&&X(t,s,i)},Mt=(t,e,s,i)=>{B(t)||(x(t,s.class_exited),Vt(t,e,s,i),m(s.callback_exit,t,e,i))},Ot=["IMG","IFRAME","VIDEO"],Ie=t=>t.use_native&&"loading"in HTMLImageElement.prototype,zt=(t,e,s)=>{t.forEach(i=>{Ot.indexOf(i.tagName)!==-1&&Nt(i,e,s)}),ge(s,0)},Dt=t=>t.isIntersecting||t.intersectionRatio>0,Wt=t=>({root:t.container===document?null:t.container,rootMargin:t.thresholds||t.threshold+"px"}),Bt=(t,e,s)=>{t.forEach(i=>Dt(i)?Rt(i.target,i,e,s):Mt(i.target,i,e,s))},Ft=(t,e)=>{e.forEach(s=>{t.observe(s)})},Ut=(t,e)=>{at(t),Ft(t,e)},Yt=(t,e)=>{!te||Ie(t)||(e._observer=new IntersectionObserver(s=>{Bt(s,t,e)},Wt(t)))},Ce=t=>Array.prototype.slice.call(t),M=t=>t.container.querySelectorAll(t.elements_selector),jt=t=>Ce(t).filter(B),Gt=t=>et(t),qt=t=>Ce(t).filter(Gt),Ne=(t,e)=>jt(t||M(e)),Xt=(t,e)=>{qt(M(t)).forEach(i=>{w(i,t.class_error),P(i)}),e.update()},Jt=(t,e)=>{!v||window.addEventListener("online",()=>{Xt(t,e)})},N=function(t,e){const s=re(t);this._settings=s,this.loadingCount=0,Yt(s,this),Jt(s,this),this.update(e)};N.prototype={update:function(t){const e=this._settings,s=Ne(t,e);if(ge(this,s.length),ee||!te){this.loadAll(s);return}if(Ie(e)){zt(s,e,this);return}Ut(this._observer,s)},destroy:function(){this._observer&&this._observer.disconnect(),M(this._settings).forEach(t=>{me(t)}),delete this._observer,delete this._settings,delete this.loadingCount,delete this.toLoadCount},loadAll:function(t){const e=this._settings;Ne(t,e).forEach(i=>{A(i,this),X(i,e,this)})},restoreAll:function(){const t=this._settings;M(t).forEach(e=>{Ht(e,t)})}},N.load=(t,e)=>{const s=re(e);X(t,s)},N.resetStatus=t=>{P(t)},v&&Je(N,window.lazyLoadOptions);class ke{constructor({readonly:e,box:s,pages:i,onNewPageIndex:r,onPlay:a}){if(this.pageIndex=0,this.namespace="netless-app-docs-viewer",this.isShowPreview=!1,this.isSmallBox=!1,this.sideEffect=new L,i.length<=0)throw new Error("[DocsViewer] Empty pages.");this.readonly=e,this.box=s,this.pages=i,this.onNewPageIndex=r,this.onPlay=a,this.render()}mount(){this.box.mountContent(this.$content),this.box.mountFooter(this.$footer),this.sideEffect.add(()=>{const e=new N({container:this.$preview,elements_selector:`.${this.wrapClassName("preview-page>img")}`});return()=>e.destroy()},"preview-lazyload")}unmount(){this.$content.remove(),this.$footer.remove()}setReadonly(e){this.readonly!==e&&(this.readonly=e,this.$content.classList.toggle(this.wrapClassName("readonly"),e),this.$footer.classList.toggle(this.wrapClassName("readonly"),e),this.$pageNumberInput.disabled=e)}destroy(){this.sideEffect.flushAll(),this.unmount()}setPageIndex(e){Number.isNaN(e)||(this.pageIndex=e,this.$pageNumberInput.value=String(e+1))}setSmallBox(e){this.isSmallBox!==e&&(this.isSmallBox=e,this.$footer.classList.toggle(this.wrapClassName("float-footer"),e))}render(){return this.renderContent(),this.renderFooter(),this.$content}renderContent(){if(!this.$content){const e=document.createElement("div");e.className=this.wrapClassName("content"),this.$content=e,this.readonly&&e.classList.add(this.wrapClassName("readonly")),e.appendChild(this.renderPreviewMask()),e.appendChild(this.renderPreview())}return this.$content}renderPreview(){if(!this.$preview){const e=document.createElement("div");e.className=this.wrapClassName("preview")+" tele-fancy-scrollbar",this.$preview=e;const s=this.wrapClassName("preview-page"),i=this.wrapClassName("preview-page-name");this.pages.forEach((r,a)=>{var d;const o=(d=r.thumbnail)!=null?d:r.src.startsWith("ppt")?void 0:r.src;if(!o)return;const n=String(a),c=document.createElement("a");c.className=s+" "+this.wrapClassName(`preview-page-${a}`),c.setAttribute("href","#"),c.dataset.pageIndex=n;const h=document.createElement("span");h.className=i,h.textContent=String(a+1),h.dataset.pageIndex=n;const l=document.createElement("img");l.width=r.width,l.height=r.height,l.dataset.src=o,l.dataset.pageIndex=n,c.appendChild(l),c.appendChild(h),e.appendChild(c)}),this.sideEffect.addEventListener(e,"click",r=>{var o;if(this.readonly)return;const a=(o=r.target.dataset)==null?void 0:o.pageIndex;a&&(r.preventDefault(),r.stopPropagation(),r.stopImmediatePropagation(),this.onNewPageIndex(Number(a)),this.togglePreview(!1))})}return this.$preview}renderPreviewMask(){return this.$previewMask||(this.$previewMask=document.createElement("div"),this.$previewMask.className=this.wrapClassName("preview-mask"),this.sideEffect.addEventListener(this.$previewMask,"click",e=>{this.readonly||e.target===this.$previewMask&&this.togglePreview(!1)})),this.$previewMask}renderFooter(){if(!this.$footer){const e=document.createElement("div");if(e.className=this.wrapClassName("footer"),this.$footer=e,this.readonly&&e.classList.add(this.wrapClassName("readonly")),this.isSmallBox&&e.classList.add(this.wrapClassName("float-footer")),this.pages.some(c=>c.thumbnail||!c.src.startsWith("ppt"))){const c=this.renderFooterBtn("btn-sidebar",Ue(this.namespace));this.sideEffect.addEventListener(c,"click",()=>{this.readonly||this.togglePreview()}),this.$footer.appendChild(c)}const s=document.createElement("div");s.className=this.wrapClassName("page-jumps");const i=this.renderFooterBtn("btn-page-back",Ye(this.namespace));if(this.sideEffect.addEventListener(i,"click",()=>{this.readonly||this.onNewPageIndex(this.pageIndex-1)}),s.appendChild(i),this.onPlay){const c=this.renderFooterBtn("btn-page-play",Ge(this.namespace),qe(this.namespace)),h=()=>{this.sideEffect.setTimeout(()=>{c.classList.toggle(this.wrapClassName("footer-btn-playing"),!1)},500,"returnPlay")};this.sideEffect.addEventListener(c,"click",()=>{this.readonly||(c.classList.toggle(this.wrapClassName("footer-btn-playing"),!0),this.onPlay&&this.onPlay(),h())}),s.appendChild(c)}const r=this.renderFooterBtn("btn-page-next",je(this.namespace));this.sideEffect.addEventListener(r,"click",()=>{this.readonly||this.onNewPageIndex(this.pageIndex+1)}),s.appendChild(r);const a=document.createElement("div");a.className=this.wrapClassName("page-number");const o=document.createElement("input");o.className=this.wrapClassName("page-number-input"),o.value=String(this.pageIndex+1),this.readonly&&(o.disabled=!0),this.$pageNumberInput=o,this.sideEffect.addEventListener(o,"focus",()=>{o.select()}),this.sideEffect.addEventListener(o,"change",()=>{this.readonly||o.value&&this.onNewPageIndex(Number(o.value)-1)});const n=document.createElement("span");n.textContent=" / "+this.pages.length,a.appendChild(o),a.appendChild(n),this.$footer.appendChild(s),this.$footer.appendChild(a)}return this.$footer}renderFooterBtn(e,s,i){const r=document.createElement("button");return r.className=this.wrapClassName("footer-btn")+" "+this.wrapClassName(e),r.appendChild(s),i&&r.appendChild(i),r}togglePreview(e){if(this.isShowPreview=e!=null?e:!this.isShowPreview,this.$content.classList.toggle(this.wrapClassName("preview-active"),this.isShowPreview),this.isShowPreview){const s=this.$preview.querySelector("."+this.wrapClassName(`preview-page-${this.pageIndex}`));s&&this.$preview.scrollTo({top:s.offsetTop-16})}}wrapClassName(e){return`${this.namespace}-${e}`}}function E(t,e,s){return Math.min(Math.max(t,e),s)}function Le(t){return t.touches?t.touches[0]:t}function Pe(t){t.stopPropagation(),t.cancelable&&t.preventDefault()}class Kt{constructor(e){var s,i,r;this.velocity=0,this.paused=!0,this._animationFrameID=null,this._loopTimestamp=0,this.looper=a=>{if(this.paused)return;let o=Math.floor((a-this._loopTimestamp)/1e3*60)+1;for(this._loopTimestamp=a;o-- >0;)this.stepper();this.onStep(this.current,this),!this.paused&&this.current!==this.target&&window.requestAnimationFrame(this.looper)},this.current=(s=e.start)!=null?s:0,this.target=this.current,this.stiffness=(i=e.stiffness)!=null?i:170,this.damping=(r=e.damping)!=null?r:26,this.onStep=e.onStep}stepTo(e,s){this.paused&&s!=null&&(this.current=s),this.paused=!1,this.target=e,this.onStep(this.current,this),this._loopTimestamp=Date.now(),window.requestAnimationFrame(this.looper)}pause(){this.paused=!0}destroy(){this.pause()}stepper(){const e=-this.stiffness*(this.current-this.target),s=-this.damping*this.velocity,i=this.velocity+(e+s)/60,r=this.current+i/60;Math.abs(i-0)<.01&&Math.abs(r-this.target)<.01?(this.current=this.target,this.velocity=0):(this.current=r,this.velocity=i)}}class Zt{constructor(e,s,i){this.scale=1,this.lastVisit=Date.now(),this.pageOffsetY=0,this.visible=!0,this.index=e,this.page=s,this.scale=i;const r=document.createElement("div");r.className="page-renderer-page",r.dataset.index=`${e}`,r.style.width=`${s.width*i}px`,r.style.height=`${s.height*i}px`,s.thumbnail&&(r.style.backgroundImage=`url("${s.thumbnail}")`);const a=document.createElement("img");a.className="page-renderer-page-img",a.width=s.width,a.height=s.height,a.src=s.src,r.appendChild(a),this.$page=r}translateY(e){Math.abs(e-this.pageOffsetY)>=.001&&(this.pageOffsetY=e,this.$page.style.transform=`translateY(${this.pageOffsetY*this.scale}px)`)}setScale(e){Math.abs(e-this.scale)>=.001&&(this.scale=e,this.$page.style.width=`${this.page.width*this.scale}px`,this.$page.style.height=`${this.page.height*this.scale}px`,this.$page.style.transform=`translateY(${this.pageOffsetY*this.scale}px)`)}setVisible(e){e!==this.visible&&(this.visible=e,this.$page.style.opacity=e?"1":"0")}}const Qt=window.requestIdleCallback||(t=>window.setTimeout(t,5e3)),es=window.cancelIdleCallback||window.clearTimeout;class ts{constructor(e,s){this.pages=e,this.scale=s,this.els=new Map,this.maxElCount=200,this.gcTimer=null,this.gc=()=>{if(this.gcTimer=null,this.els.size>this.maxElCount){const i=[...this.els.values()].sort((r,a)=>a.lastVisit-r.lastVisit);for(let r=Math.floor(this.maxElCount/4);r<i.length;r++)this.els.delete(i[r].index)}}}getEl(e){let s=this.els.get(e);return s||(s=new Zt(e,this.pages[e],this.scale),this.els.set(e,s)),s.lastVisit=Date.now(),this.els.size>this.maxElCount&&this.gcTimer===null&&(this.gcTimer=Qt(this.gc)),s}setScale(e){e!==this.scale&&(this.scale=e,this.els.forEach(s=>s.setScale(e)))}destroy(){this.els.clear(),this.gcTimer!==null&&(es(this.gcTimer),this.gcTimer=null)}}class ss{constructor(e){this._hwaTimeout=NaN,this._turnOffHWA=()=>{window.clearTimeout(this._hwaTimeout),this._hwaTimeout=NaN,this.$pages.classList.toggle("is-hwa",!1)},this.pagesScrollTop=e.pagesScrollTop||0,this.containerWidth=e.containerWidth||1,this.containerHeight=e.containerHeight||1,this.pages=e.pages.map(a=>{if(a.thumbnail)return a;try{const o=new URL(a.src);return o.searchParams.set("x-oss-process","image/resize,l_50"),K(J({},a),{thumbnail:o.toString()})}catch(o){return console.error(o),a}});const s=Array(this.pages.length);let i=1/0,r=0;this.pagesIntrinsicHeight=this.pages.reduce((a,o,n)=>(s[n]=a,o.width>r&&(r=o.width),o.height<=i&&(i=o.height),a+o.height),0),this.pagesIntrinsicWidth=r,this.pagesMinHeight=i,this.pagesIntrinsicYs=s,this.scale=this._calcScale(),this.threshold=this._calcThreshold(),this.onPageIndexChanged=e.onPageIndexChanged,this.pageScrollIndex=0,this.pagesScrollTop!==0&&(this.pageScrollIndex=this.findScrollPageIndex(),this.onPageIndexChanged&&this.pageScrollIndex>0&&this.onPageIndexChanged(this.pageScrollIndex)),this.pageElManager=new ts(this.pages,this.scale),this.$pages=this.renderPages()}setContainerSize(e,s){e>0&&s>0&&(e!==this.containerWidth||s!==this.containerHeight)&&(this.containerWidth=e,this.containerHeight=s,this.$pages.style.width=`${this.containerWidth}px`,this.$pages.style.height=`${this.containerHeight}px`,this.scale=this._calcScale(),this.threshold=this._calcThreshold(),this.pageElManager.setScale(this.scale),this.$pages.parentElement&&this.pagesScrollTo(this.pagesScrollTop,!0))}renderPages(){const e=document.createElement("div");return e.className="page-renderer-pages-container",e.style.width=`${this.containerWidth}px`,e.style.height=`${this.containerHeight}px`,e}pagesScrollTo(e,s){if(e=E(e,0,this.pagesIntrinsicHeight-this.containerHeight/this.scale),s||Math.abs(e-this.pagesScrollTop)>=.001){this._turnOnHWA(),this.pagesScrollTop=e;const i=this.findScrollPageIndex(),r=Math.max(i-this.threshold,0),a=Math.min(i+this.threshold,this.pages.length-1);for(let o=0;o<this.$pages.children.length;o++){const n=this.$pages.children[o],c=Number(n.dataset.index);c>=r&&c<=a||(n.remove(),o--)}for(let o=r;o<=a;o++){const n=this.pageElManager.getEl(o);n.$page.parentElement!==this.$pages&&this.$pages.appendChild(n.$page),n.translateY(this.pagesIntrinsicYs[o]-this.pagesScrollTop)}i!==this.pageScrollIndex&&(this.pageScrollIndex=i,this.onPageIndexChanged&&this.onPageIndexChanged(i))}}findScrollPageIndex(){for(let e=0;e<this.pagesIntrinsicYs.length;e++)if(this.pagesIntrinsicYs[e]+this.pages[e].height-this.pagesScrollTop>=.001)return e;return this.pagesIntrinsicYs.length-1}mount(e){e.appendChild(this.$pages),this.pagesScrollTo(this.pagesScrollTop,!0)}unmount(){this.$pages.remove()}destroy(){this.unmount(),this.onPageIndexChanged=void 0,this.pageElManager.destroy(),this._hwaTimeout&&(window.clearTimeout(this._hwaTimeout),this._hwaTimeout=NaN)}_calcScale(){return this.containerWidth/this.pagesIntrinsicWidth||1}_calcThreshold(){return E(Math.ceil(this.containerHeight/this.scale/this.pagesMinHeight/2),1,this.pages.length)}_turnOnHWA(){this._hwaTimeout?window.clearTimeout(this._hwaTimeout):this.$pages.classList.toggle("is-hwa",!0),this._hwaTimeout=window.setTimeout(this._turnOffHWA,1e3)}}const is=30;class rs{constructor(e){this.sideEffect=new L,this.pagesScrollTop=e.pagesScrollTop||0,this.containerWidth=e.containerWidth||1,this.containerHeight=e.containerHeight||1,this.pagesWidth=e.pagesWidth||1,this.pagesHeight=e.pagesHeight||1,this.scale=this._calcScale(),this.scrollbarMinHeight=e.scrollbarMinHeight||is,this.scrollbarHeight=this._calcScrollbarHeight(),this.readonly=e.readonly,this.wrapClassName=e.wrapClassName,this.onDragScroll=e.onDragScroll,this.$scrollbar=this.renderScrollbar()}mount(e){e.appendChild(this.$scrollbar),this.pagesScrollTo(this.pagesScrollTop,!0)}unmount(){this.$scrollbar.remove()}setReadonly(e){this.readonly=e}setContainerSize(e,s){e>0&&s>0&&(e!==this.containerWidth||s!==this.containerHeight)&&(this.containerWidth=e,this.containerHeight=s,this.scale=this._calcScale(),this._updateScrollbarHeight(),this.$scrollbar.parentElement&&this.pagesScrollTo(this.pagesScrollTop,!0))}pagesScrollTo(e,s){if(e=E(e,0,this.pagesHeight-this.containerHeight/this.scale),s||Math.abs(e-this.pagesScrollTop)>=.001){this.pagesScrollTop=e;const i=this.pagesScrollTop*this.scale,r=this.pagesHeight*this.scale,a=i/(r-this.containerHeight)*(this.containerHeight-this.scrollbarHeight);window.requestAnimationFrame?window.requestAnimationFrame(()=>{this.$scrollbar.style.transform=`translateY(${a}px)`}):this.$scrollbar.style.transform=`translateY(${a}px)`}}destroy(){this.unmount(),this.onDragScroll=void 0,this.sideEffect.flushAll()}renderScrollbar(){const e=document.createElement("button");e.className=this.wrapClassName("scrollbar"),e.style.minHeight=`${this.scrollbarMinHeight}px`,e.style.height=`${this.scrollbarHeight}px`;const s=i=>{if(this.readonly||i.button!=null&&i.button!==0)return;Pe(i);const r=this.wrapClassName("scrollbar-dragging");e.classList.toggle(r,!0);const a=this.pagesScrollTop,{clientY:o}=Le(i),n=h=>{if(this.readonly)return;const{clientY:l}=Le(h),d=(l-o)/this.scale;Math.abs(d)>0&&this.onDragScroll&&this.onDragScroll(a+d*(this.pagesHeight*this.scale/this.containerHeight))},c=()=>{e.classList.toggle(r,!1),window.removeEventListener("mousemove",n,!0),window.removeEventListener("touchmove",n,!0),window.removeEventListener("mouseup",c,!0),window.removeEventListener("touchend",c,!0),window.removeEventListener("touchcancel",c,!0)};window.addEventListener("mousemove",n,!0),window.addEventListener("touchmove",n,!0),window.addEventListener("mouseup",c,!0),window.addEventListener("touchend",c,!0),window.addEventListener("touchcancel",c,!0)};return this.sideEffect.addEventListener(e,"mousedown",s),this.sideEffect.addEventListener(e,"touchstart",s),e}_calcScale(){return this.containerWidth/this.pagesWidth||1}_calcScrollbarHeight(){return E(this.containerHeight/(this.pagesHeight*this.scale)*this.containerHeight,this.scrollbarMinHeight,this.containerHeight)}_updateScrollbarHeight(){const e=this._calcScrollbarHeight();Math.abs(e-this.scrollbarHeight)>.001&&(this.scrollbarHeight=e,this.$scrollbar.style.height=`${e}px`)}}const k=640;class as{constructor({whiteboardView:e,readonly:s,box:i,pages:r,pageScrollTop:a=0,mountWhiteboard:o,onUserScroll:n}){this.sideEffect=new L,this.userScrolling=!1,this.onNewPageIndex=d=>{this.scrollToPage(d)},this.whiteboardView=e,this.readonly=s,this.box=i,this.pages=r,this.mountWhiteboard=o,this._onUserScroll=n;const c=this.debounce(()=>{this.userScrolling=!1,this._onUserScroll&&this._onUserScroll(this.pageRenderer.pagesScrollTop)},{wait:80},"debounce-updateUserScroll");this.updateUserScroll=()=>{this.userScrolling=!0,c()},this.viewer=new ke({readonly:s,box:i,pages:r,onNewPageIndex:this.onNewPageIndex});const{width:h,height:l}=this.whiteboardView.size;this.pageRenderer=new ss({pagesScrollTop:a,pages:this.pages,containerWidth:h,containerHeight:l,onPageIndexChanged:this.viewer.setPageIndex.bind(this.viewer)}),this.scrollbar=new rs({pagesScrollTop:this.pageRenderer.pagesScrollTop,containerWidth:h,containerHeight:l,pagesWidth:this.pageRenderer.pagesIntrinsicWidth,pagesHeight:this.pageRenderer.pagesIntrinsicHeight,readonly:this.readonly,wrapClassName:this.wrapClassName.bind(this),onDragScroll:d=>{this.pageScrollTo(d),this.updateUserScroll()}}),this.pageScrollStepper=new Kt({start:this.pageRenderer.pagesScrollTop,onStep:d=>{this.pageScrollTo(d)}}),this.render()}mount(){return this.viewer.mount(),this.setupScrollListener(),this.sideEffect.add(()=>{const e=this.renderRatioHeight.bind(this);return this.box.events.on("visual_resize",e),()=>this.box.events.off("visual_resize",e)}),this.sideEffect.setTimeout(()=>{this.userScrolling||this.pageScrollTo(this.pageRenderer.pagesScrollTop)},100),this}unmount(){return this.viewer.unmount(),this}setReadonly(e){this.readonly!==e&&(this.readonly=e,this.viewer.setReadonly(e),this.scrollbar.setReadonly(e))}destroy(){this.sideEffect.flushAll(),this.pageScrollStepper.destroy(),this._onUserScroll=void 0,this.unmount(),this.viewer.destroy(),this.pageRenderer.destroy(),this.scrollbar.destroy()}syncPageScrollTop(e){!this.userScrolling&&e>=0&&Math.abs(this.pageRenderer.pagesScrollTop-e)>.01&&this.pageScrollStepper.stepTo(e,this.pageRenderer.pagesScrollTop)}render(){this.pageRenderer.mount(this.viewer.$content),this.viewer.$content.appendChild(this.renderWhiteboardView()),this.scrollbar.mount(this.viewer.$content),this.renderRatioHeight()}renderRatioHeight(){const e=this.box.absoluteHeight,s=e<=k;if(this.viewer.setSmallBox(s),s){const i=26/k,r=26/e,a=26/k,o=0,n=Math.max((i+a-(r+o))/2,0);if(this.box.$titleBar){const c=r+n;this.box.$titleBar.style.height=`${c*100}%`}if(this.box.$footer){const c=o+n;this.box.$footer.style.height=`${c*100}%`}}else{if(this.box.$titleBar){const i=Math.max(26/k,26/e);this.box.$titleBar.style.height=`${i*100}%`}if(this.box.$footer){const i=Math.max(26/k,26/e);this.box.$footer.style.height=`${i*100}%`}}}renderWhiteboardView(){return this.$whiteboardView||(this.$whiteboardView=document.createElement("div"),this.$whiteboardView.className=this.wrapClassName("wb-view"),this.mountWhiteboard(this.$whiteboardView),this.sideEffect.addEventListener(this.$whiteboardView,"wheel",e=>{Pe(e),this.readonly||(this.pageScrollTo(this.pageRenderer.pagesScrollTop+e.deltaY),this.updateUserScroll())},{passive:!1,capture:!0}),this.sideEffect.addEventListener(this.$whiteboardView,"touchmove",e=>{this.readonly||e.touches.length<=1||this.updateUserScroll()},{passive:!0,capture:!0})),this.$whiteboardView}scrollTopPageToEl(e){return e*this.pageRenderer.scale}scrollTopElToPage(e){return e/this.pageRenderer.scale}elScrollTo(e){this.pageScrollTo(this.scrollTopElToPage(e))}pageScrollTo(e){const s=this.scrollTopElToPage(this.whiteboardView.size.height/2);this.whiteboardView.moveCamera({centerY:E(e+s,s,this.pageRenderer.pagesIntrinsicHeight-s),animationMode:"immediately"})}scrollToPage(e){if(!this.readonly&&!Number.isNaN(e)){const s=this.pageRenderer.pagesIntrinsicYs[e];s>=0&&(this.pageScrollTo(s+5/this.pageRenderer.scale),this.updateUserScroll())}}setupScrollListener(){this.sideEffect.add(()=>{const e=s=>{const{width:i,height:r}=this.whiteboardView.size;if(i<=0||r<=0)return;const a=s.centerY-this.pageRenderer.containerHeight/this.pageRenderer.scale/2;this.pageRenderer.pagesScrollTo(a),this.scrollbar.pagesScrollTo(a)};return this.whiteboardView.callbacks.on("onCameraUpdated",e),()=>this.whiteboardView.callbacks.off("onCameraUpdated",e)}),this.sideEffect.add(()=>{const e=({width:s,height:i})=>{if(s<=0||i<=0)return;this.pageRenderer.setContainerSize(s,i),this.scrollbar.setContainerSize(s,i);const{pagesIntrinsicWidth:r,pagesIntrinsicHeight:a}=this.pageRenderer;this.whiteboardView.moveCameraToContain({originX:0,originY:this.pageRenderer.pagesScrollTop,width:r,height:i/this.pageRenderer.scale,animationMode:"immediately"}),this.whiteboardView.setCameraBound({damping:1,maxContentMode:()=>this.pageRenderer.scale,minContentMode:()=>this.pageRenderer.scale,centerX:r/2,centerY:a/2,width:r,height:a})};return this.whiteboardView.callbacks.on("onSizeUpdated",e),()=>{this.whiteboardView.callbacks.off("onSizeUpdated",e)}},"whiteboard-size-update"),this.sideEffect.addEventListener(window,"keyup",e=>{if(this.readonly||!this.box.focus||this.box.minimized)return;let s=null;switch(e.key){case"PageDown":{s=this.pageRenderer.pagesScrollTop+this.pageRenderer.containerHeight/this.pageRenderer.scale;break}case"PageUp":{s=this.pageRenderer.pagesScrollTop-this.pageRenderer.containerHeight/this.pageRenderer.scale;break}case"ArrowDown":{s=this.pageRenderer.pagesScrollTop+this.pageRenderer.containerHeight/4/this.pageRenderer.scale;break}case"ArrowUp":{s=this.pageRenderer.pagesScrollTop-this.pageRenderer.containerHeight/4/this.pageRenderer.scale;break}}s!==null&&(this._onUserScroll?this._onUserScroll(s):(this.pageScrollTo(s),this.updateUserScroll()))},{capture:!0})}debounce(e,s,i){const r=Be(e,s);return this.sideEffect.addDisposer(()=>r.cancel(),i),r}wrapClassName(e){return"netless-app-docs-viewer-static-"+e}}class os{constructor({context:e,whiteboardView:s,box:i,pages:r}){this.sideEffect=new L,this.onPlayPPT=()=>{const a=this.context.getRoom();a&&a.pptNextStep()},this._scaleDocsToFitImpl=()=>{const a=this.pages[this.getPageIndex()];a&&this.whiteboardView.moveCameraToContain({originX:-a.width/2,originY:-a.height/2,width:a.width,height:a.height,animationMode:"immediately"})},this._scaleDocsToFitDebounced=()=>{this.sideEffect.setTimeout(this._scaleDocsToFitImpl,1e3,"_scaleDocsToFitDebounced")},this.scaleDocsToFit=()=>{this._scaleDocsToFitImpl(),this._scaleDocsToFitDebounced()},this.onNewPageIndex=a=>{this.jumpToPage(a,!0)},this.context=e,this.whiteboardView=s,this.box=i,this.pages=r,this.displayer=e.getDisplayer(),this.viewer=new ke({readonly:!e.getIsWritable(),box:i,pages:r,onNewPageIndex:this.onNewPageIndex,onPlay:this.onPlayPPT}),this.render(),this.sideEffect.add(()=>{const a=o=>{this.viewer.setReadonly(!o)};return this.context.emitter.on("writableChange",a),()=>this.context.emitter.off("writableChange",a)}),this.sideEffect.add(()=>{const a=o=>{this.jumpToPage(o.index)};return this.context.emitter.on("sceneStateChange",a),()=>this.context.emitter.off("sceneStateChange",a)})}mount(){this.viewer.mount();const e=this.getPageIndex();return e!==0&&this.jumpToPage(e),this.scaleDocsToFit(),this.sideEffect.add(()=>(this.whiteboardView.callbacks.on("onSizeUpdated",this.scaleDocsToFit),()=>{this.whiteboardView.callbacks.off("onSizeUpdated",this.scaleDocsToFit)})),this}unmount(){return this.viewer.unmount(),this}destroy(){this.sideEffect.flushAll(),this.unmount(),this.viewer.destroy()}getPageIndex(){return this.displayer.state.sceneState.index}jumpToPage(e,s){var i,r;if(e=E(e,0,this.pages.length-1),e!==this.getPageIndex()&&this.context.getIsWritable()){const a=this.context.getInitScenePath(),o=(r=(i=this.context.getScenes())==null?void 0:i[e])==null?void 0:r.name;a&&o&&this.context.setScenePath(`${a}/${o}`),this.scaleDocsToFit()}if(e!==this.viewer.pageIndex&&this.viewer.setPageIndex(e),s){const a=this.context.getRoom();if(a){const o=a.state.globalState.__pptState;a.setGlobalState({__pptState:o&&{uuid:o.uuid,pageIndex:e,disableAutoPlay:o.disableAutoPlay}})}}}render(){this.viewer.$content.appendChild(this.renderMask()),this.viewer.$content.appendChild(this.renderWhiteboardView()),this.sideEffect.addEventListener(window,"keydown",e=>{var s;if(this.box.focus)switch(e.key){case"ArrowUp":case"ArrowLeft":{this.jumpToPage(this.getPageIndex()-1,!0);break}case"ArrowRight":case"ArrowDown":{(s=this.context.getRoom())==null||s.pptNextStep();break}}})}renderMask(){if(!this.$mask){const e=document.createElement("div");e.className=this.wrapClassName("mask"),this.$mask=e;const s=document.createElement("button");s.className=this.wrapClassName("back");const i=document.createElement("button");i.className=this.wrapClassName("next")}return this.$mask}renderWhiteboardView(){return this.$whiteboardView||(this.$whiteboardView=document.createElement("div"),this.$whiteboardView.className=this.wrapClassName("wb-view"),this.sideEffect.addEventListener(this.$whiteboardView,"click",e=>{var i;const s=this.context.getRoom();if(s&&s.state.memberState.currentApplianceName==="clicker"){for(let r=e.target;r;r=r.parentElement)if((i=r.classList)==null?void 0:i.contains("ppt-event-source"))return;s.pptNextStep()}}),this.context.mountView(this.$whiteboardView)),this.$whiteboardView}wrapClassName(e){return"netless-app-docs-viewer-dynamic-"+e}}const ns={kind:"DocsViewer",setup(t){const e=t.getBox(),s=t.getScenes();if(!s)throw new Error("[Docs Viewer]: scenes not found.");const i=t.getView();if(!i)throw new Error("[Docs Viewer]: no whiteboard view.");const r=s.map(({ppt:a})=>a?{width:a.width,height:a.height,src:a.src,thumbnail:a.previewURL}:null).filter(a=>Boolean(a));if(r.length<=0)throw new Error("[Docs Viewer]: empty scenes.");e.mountStyles(g),r[0].src.startsWith("ppt")?ls(t,i,e,r):cs(t,i,e,r)}};function cs(t,e,s,i){var a;e.disableCameraTransform=!t.getIsWritable();const r=new as({whiteboardView:e,readonly:!t.getIsWritable(),box:s,pages:i,pageScrollTop:(a=t.getAttributes())==null?void 0:a.pageScrollTop,mountWhiteboard:t.mountView.bind(t),onUserScroll:o=>{var n;((n=t.getAttributes())==null?void 0:n.pageScrollTop)!==o&&!s.readonly&&t.updateAttributes(["pageScrollTop"],o)}}).mount();t.emitter.on("attributesUpdate",o=>{o&&o.pageScrollTop!=null&&r.syncPageScrollTop(o.pageScrollTop)}),t.emitter.on("writableChange",o=>{r.setReadonly(!o),e.disableCameraTransform=!o})}function ls(t,e,s,i){e.disableCameraTransform=!0;const r=new os({context:t,whiteboardView:e,box:s,pages:i}).mount();t.mountView(r.$whiteboardView),t.isAddApp&&e.callbacks.once("onSizeUpdated",({width:a,height:o})=>{if(i.length>0&&s.state!=="maximized"){const{width:n,height:c}=i[0],l=c/n*a-o;l!==0&&t.getIsWritable()&&t.emitter.emit("setBoxSize",{width:s.width,height:s.height+l/s.containerRect.height})}})}return p.default=ns,Object.defineProperty(p,"__esModule",{value:!0}),p[Symbol.toStringTag]="Module",p}({});
//# sourceMappingURL=main.iife.js.map
{
"name": "@netless/app-docs-viewer",
"version": "0.2.5",
"version": "0.2.6",
"description": "Netless App Docs Viewer",

@@ -5,0 +5,0 @@ "repository": "netless-io/netless-app",

@@ -41,10 +41,3 @@ import type { DocsViewerPage } from "../DocsViewer";

this.pageOffsetY = pageOffsetY;
if (window.requestAnimationFrame) {
window.requestAnimationFrame(() => {
this.$page.style.transform = `translateY(${pageOffsetY * this.scale}px)`;
});
} else {
this.$page.style.transform = `translateY(${pageOffsetY * this.scale}px)`;
}
this.$page.style.transform = `translateY(${this.pageOffsetY * this.scale}px)`;
}

@@ -51,0 +44,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc