New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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.1.26 to 0.2.0

dist/PageRenderer/index.d.ts

6

dist/main.cjs.js

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

"use strict";var Oe=Object.defineProperty,Me=Object.defineProperties;var De=Object.getOwnPropertyDescriptors;var q=Object.getOwnPropertySymbols;var He=Object.prototype.hasOwnProperty,Re=Object.prototype.propertyIsEnumerable;var X=(e,t,s)=>t in e?Oe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,J=(e,t)=>{for(var s in t||(t={}))He.call(t,s)&&X(e,s,t[s]);if(q)for(var s of q(t))Re.call(t,s)&&X(e,s,t[s]);return e},K=(e,t)=>Me(e,De(t));Object.defineProperty(exports,"__esModule",{value:!0});exports[Symbol.toStringTag]="Module";var Be=`.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:1.5em;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-pages{overflow:hidden;position:relative;height:100%;user-select:none}.netless-app-docs-viewer-static-pages:hover .netless-app-docs-viewer-static-scrollbar{opacity:1}.netless-app-docs-viewer-static-page{display:block;width:100%;height:auto;user-select:none}.netless-app-docs-viewer-static-wb-view{position:absolute;top:0;left:0;width:100%;height:100%;z-index:100;overflow:hidden}.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,.1);opacity:0;transition:background .4s,opacity .4s,transform .2s;will-change:transform,height;user-select:none}.netless-app-docs-viewer-static-scrollbar.netless-app-docs-viewer-static-scrollbar-dragging{background:rgba(68,78,96,.2);opacity:1;transition:background .4s,opacity .4s}.netless-app-docs-viewer-static-scrollbar:hover,.netless-app-docs-viewer-static-scrollbar:focus{background:rgba(68,78,96,.2)}.netless-app-docs-viewer-static-scrollbar:active{background:rgba(68,78,96,.2)}.netless-app-docs-viewer-content:hover .netless-app-docs-viewer-static-scrollbar{opacity:1}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-static-scrollbar{display:none}.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 f=typeof window!="undefined",Z=f&&!("onscroll"in window)||typeof navigator!="undefined"&&/(gle|ing|ro)bot|crawl|spider/i.test(navigator.userAgent),Q=f&&"IntersectionObserver"in window,ee=f&&"classList"in document.createElement("p"),te=f&&window.devicePixelRatio>1,We={elements_selector:".lazy",container:Z||f?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},se=e=>Object.assign({},We,e),oe=function(e,t){let s;const o="LazyLoad::Initialized",i=new e(t);try{s=new CustomEvent(o,{detail:{instance:i}})}catch{s=document.createEvent("CustomEvent"),s.initCustomEvent(o,!1,!1,{instance:i})}window.dispatchEvent(s)},Fe=(e,t)=>{if(!!t)if(!t.length)oe(e,t);else for(let s=0,o;o=t[s];s+=1)oe(e,o)},g="src",V="srcset",z="sizes",ie="poster",y="llOriginalAttrs",O="loading",re="loaded",ae="applied",Ue="entered",M="error",ne="native",ce="data-",le="ll-status",h=(e,t)=>e.getAttribute(ce+t),je=(e,t,s)=>{var o=ce+t;if(s===null){e.removeAttribute(o);return}e.setAttribute(o,s)},E=e=>h(e,le),b=(e,t)=>je(e,le,t),C=e=>b(e,null),D=e=>E(e)===null,Ge=e=>E(e)===O,Ye=e=>E(e)===M,H=e=>E(e)===ne,qe=[O,re,ae,M],Xe=e=>qe.indexOf(E(e))>=0,w=(e,t,s,o)=>{if(!!e){if(o!==void 0){e(t,s,o);return}if(s!==void 0){e(t,s);return}e(t)}},v=(e,t)=>{if(ee){e.classList.add(t);return}e.className+=(e.className?" ":"")+t},u=(e,t)=>{if(ee){e.classList.remove(t);return}e.className=e.className.replace(new RegExp("(^|\\s+)"+t+"(\\s+|$)")," ").replace(/^\s+/,"").replace(/\s+$/,"")},Je=e=>{e.llTempImage=document.createElement("IMG")},Ke=e=>{delete e.llTempImage},de=e=>e.llTempImage,_=(e,t)=>{if(!t)return;const s=t._observer;!s||s.unobserve(e)},Ze=e=>{e.disconnect()},Qe=(e,t,s)=>{t.unobserve_entered&&_(e,s)},R=(e,t)=>{!e||(e.loadingCount+=t)},et=e=>{!e||(e.toLoadCount-=1)},he=(e,t)=>{!e||(e.toLoadCount=t)},tt=e=>e.loadingCount>0,st=e=>e.toLoadCount>0,pe=e=>{let t=[];for(let s=0,o;o=e.children[s];s+=1)o.tagName==="SOURCE"&&t.push(o);return t},B=(e,t)=>{const s=e.parentNode;if(!s||s.tagName!=="PICTURE")return;pe(s).forEach(t)},ue=(e,t)=>{pe(e).forEach(t)},k=[g],ge=[g,ie],I=[g,V,z],L=e=>!!e[y],we=e=>e[y],fe=e=>delete e[y],x=(e,t)=>{if(L(e))return;const s={};t.forEach(o=>{s[o]=e.getAttribute(o)}),e[y]=s},ot=e=>{L(e)||(e[y]={backgroundImage:e.style.backgroundImage})},it=(e,t,s)=>{if(!s){e.removeAttribute(t);return}e.setAttribute(t,s)},N=(e,t)=>{if(!L(e))return;const s=we(e);t.forEach(o=>{it(e,o,s[o])})},rt=e=>{if(!L(e))return;const t=we(e);e.style.backgroundImage=t.backgroundImage},at=(e,t,s)=>{v(e,t.class_applied),b(e,ae),!!s&&(t.unobserve_completed&&_(e,t),w(t.callback_applied,e,s))},be=(e,t,s)=>{v(e,t.class_loading),b(e,O),!!s&&(R(s,1),w(t.callback_loading,e,s))},m=(e,t,s)=>{!s||e.setAttribute(t,s)},me=(e,t)=>{m(e,z,h(e,t.data_sizes)),m(e,V,h(e,t.data_srcset)),m(e,g,h(e,t.data_src))},nt=(e,t)=>{B(e,s=>{x(s,I),me(s,t)}),x(e,I),me(e,t)},ct=(e,t)=>{x(e,k),m(e,g,h(e,t.data_src))},lt=(e,t)=>{ue(e,s=>{x(s,k),m(s,g,h(s,t.data_src))}),x(e,ge),m(e,ie,h(e,t.data_poster)),m(e,g,h(e,t.data_src)),e.load()},dt=(e,t,s)=>{const o=h(e,t.data_bg),i=h(e,t.data_bg_hidpi),r=te&&i?i:o;!r||(e.style.backgroundImage=`url("${r}")`,de(e).setAttribute(g,r),be(e,t,s))},ht=(e,t,s)=>{const o=h(e,t.data_bg_multi),i=h(e,t.data_bg_multi_hidpi),r=te&&i?i:o;!r||(e.style.backgroundImage=r,at(e,t,s))},ve={IMG:nt,IFRAME:ct,VIDEO:lt},pt=(e,t)=>{const s=ve[e.tagName];!s||s(e,t)},ut=(e,t,s)=>{const o=ve[e.tagName];!o||(o(e,t),be(e,t,s))},gt=["IMG","IFRAME","VIDEO"],wt=e=>gt.indexOf(e.tagName)>-1,Se=(e,t)=>{t&&!tt(t)&&!st(t)&&w(e.callback_finish,t)},ye=(e,t,s)=>{e.addEventListener(t,s),e.llEvLisnrs[t]=s},ft=(e,t,s)=>{e.removeEventListener(t,s)},W=e=>!!e.llEvLisnrs,bt=(e,t,s)=>{W(e)||(e.llEvLisnrs={});const o=e.tagName==="VIDEO"?"loadeddata":"load";ye(e,o,t),ye(e,"error",s)},F=e=>{if(!W(e))return;const t=e.llEvLisnrs;for(let s in t){const o=t[s];ft(e,s,o)}delete e.llEvLisnrs},Ee=(e,t,s)=>{Ke(e),R(s,-1),et(s),u(e,t.class_loading),t.unobserve_completed&&_(e,s)},mt=(e,t,s,o)=>{const i=H(t);Ee(t,s,o),v(t,s.class_loaded),b(t,re),w(s.callback_loaded,t,o),i||Se(s,o)},vt=(e,t,s,o)=>{const i=H(t);Ee(t,s,o),v(t,s.class_error),b(t,M),w(s.callback_error,t,o),i||Se(s,o)},U=(e,t,s)=>{const o=de(e)||e;if(W(o))return;bt(o,n=>{mt(n,e,t,s),F(o)},n=>{vt(n,e,t,s),F(o)})},St=(e,t,s)=>{Je(e),U(e,t,s),ot(e),dt(e,t,s),ht(e,t,s)},yt=(e,t,s)=>{U(e,t,s),ut(e,t,s)},j=(e,t,s)=>{wt(e)?yt(e,t,s):St(e,t,s)},Et=(e,t,s)=>{e.setAttribute("loading","lazy"),U(e,t,s),pt(e,t),b(e,ne)},xe=e=>{e.removeAttribute(g),e.removeAttribute(V),e.removeAttribute(z)},xt=e=>{B(e,t=>{xe(t)}),xe(e)},Ne=e=>{B(e,t=>{N(t,I)}),N(e,I)},Nt=e=>{ue(e,t=>{N(t,k)}),N(e,ge),e.load()},$t=e=>{N(e,k)},Tt={IMG:Ne,IFRAME:$t,VIDEO:Nt},Ct=e=>{const t=Tt[e.tagName];if(!t){rt(e);return}t(e)},_t=(e,t)=>{D(e)||H(e)||(u(e,t.class_entered),u(e,t.class_exited),u(e,t.class_applied),u(e,t.class_loading),u(e,t.class_loaded),u(e,t.class_error))},kt=(e,t)=>{Ct(e),_t(e,t),C(e),fe(e)},It=(e,t,s,o)=>{!s.cancel_on_exit||!Ge(e)||e.tagName==="IMG"&&(F(e),xt(e),Ne(e),u(e,s.class_loading),R(o,-1),C(e),w(s.callback_cancel,e,t,o))},Lt=(e,t,s,o)=>{const i=Xe(e);b(e,Ue),v(e,s.class_entered),u(e,s.class_exited),Qe(e,s,o),w(s.callback_enter,e,t,o),!i&&j(e,s,o)},Pt=(e,t,s,o)=>{D(e)||(v(e,s.class_exited),It(e,t,s,o),w(s.callback_exit,e,t,o))},At=["IMG","IFRAME","VIDEO"],$e=e=>e.use_native&&"loading"in HTMLImageElement.prototype,Vt=(e,t,s)=>{e.forEach(o=>{At.indexOf(o.tagName)!==-1&&Et(o,t,s)}),he(s,0)},zt=e=>e.isIntersecting||e.intersectionRatio>0,Ot=e=>({root:e.container===document?null:e.container,rootMargin:e.thresholds||e.threshold+"px"}),Mt=(e,t,s)=>{e.forEach(o=>zt(o)?Lt(o.target,o,t,s):Pt(o.target,o,t,s))},Dt=(e,t)=>{t.forEach(s=>{e.observe(s)})},Ht=(e,t)=>{Ze(e),Dt(e,t)},Rt=(e,t)=>{!Q||$e(e)||(t._observer=new IntersectionObserver(s=>{Mt(s,e,t)},Ot(e)))},Te=e=>Array.prototype.slice.call(e),P=e=>e.container.querySelectorAll(e.elements_selector),Bt=e=>Te(e).filter(D),Wt=e=>Ye(e),Ft=e=>Te(e).filter(Wt),Ce=(e,t)=>Bt(e||P(t)),Ut=(e,t)=>{Ft(P(e)).forEach(o=>{u(o,e.class_error),C(o)}),t.update()},jt=(e,t)=>{!f||window.addEventListener("online",()=>{Ut(e,t)})},S=function(e,t){const s=se(e);this._settings=s,this.loadingCount=0,Rt(s,this),jt(s,this),this.update(t)};S.prototype={update:function(e){const t=this._settings,s=Ce(e,t);if(he(this,s.length),Z||!Q){this.loadAll(s);return}if($e(t)){Vt(s,t,this);return}Ht(this._observer,s)},destroy:function(){this._observer&&this._observer.disconnect(),P(this._settings).forEach(e=>{fe(e)}),delete this._observer,delete this._settings,delete this.loadingCount,delete this.toLoadCount},loadAll:function(e){const t=this._settings;Ce(e,t).forEach(o=>{_(o,this),j(o,t,this)})},restoreAll:function(){const e=this._settings;P(e).forEach(t=>{kt(t,e)})}};S.load=(e,t)=>{const s=se(t);j(e,s)};S.resetStatus=e=>{C(e)};f&&Fe(S,window.lazyLoadOptions);const Gt=(e,t,s,o)=>{if(s==="length"||s==="prototype"||s==="arguments"||s==="caller")return;const i=Object.getOwnPropertyDescriptor(e,s),r=Object.getOwnPropertyDescriptor(t,s);!Yt(i,r)&&o||Object.defineProperty(e,s,r)},Yt=function(e,t){return e===void 0||e.configurable||e.writable===t.writable&&e.enumerable===t.enumerable&&e.configurable===t.configurable&&(e.writable||e.value===t.value)},qt=(e,t)=>{const s=Object.getPrototypeOf(t);s!==Object.getPrototypeOf(e)&&Object.setPrototypeOf(e,s)},Xt=(e,t)=>`/* Wrapped ${e}*/
${t}`,Jt=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),Kt=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),Zt=(e,t,s)=>{const o=s===""?"":`with ${s.trim()}() `,i=Xt.bind(null,o,t.toString());Object.defineProperty(i,"name",Kt),Object.defineProperty(e,"toString",K(J({},Jt),{value:i}))},Qt=(e,t,{ignoreNonConfigurable:s=!1}={})=>{const{name:o}=e;for(const i of Reflect.ownKeys(t))Gt(e,t,i,s);return qt(e,t),Zt(e,t,o),e};var es=Qt;const ts=(e,t={})=>{if(typeof e!="function")throw new TypeError(`Expected the first argument to be a function, got \`${typeof e}\``);const{wait:s=0,maxWait:o=Number.Infinity,before:i=!1,after:r=!0}=t;if(!i&&!r)throw new Error("Both `before` and `after` are false, function wouldn't be called.");let n,c,a;const l=function(...d){const p=this,Ae=()=>{n=void 0,c&&(clearTimeout(c),c=void 0),r&&(a=e.apply(p,d))},Ve=()=>{c=void 0,n&&(clearTimeout(n),n=void 0),r&&(a=e.apply(p,d))},ze=i&&!n;return clearTimeout(n),n=setTimeout(Ae,s),o>0&&o!==Number.Infinity&&!c&&(c=setTimeout(Ve,o)),ze&&(a=e.apply(p,d)),a};return es(l,e),l.cancel=()=>{n&&(clearTimeout(n),n=void 0),c&&(clearTimeout(c),c=void 0)},l},_e="!#%()*+,-./:;=?@[]^_`{|}~ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",ss=_e.length,ke=Array(20),$=()=>{for(let e=0;e<20;e++)ke[e]=_e.charAt(Math.random()*ss);return ke.join("")};class G{constructor(){this.disposers=new Map}add(t,s=$()){return this.flush(s),this.disposers.set(s,t()),s}addDisposer(t,s=$()){return this.flush(s),this.disposers.set(s,t),s}addEventListener(t,s,o,i,r=$()){return this.add(()=>(t.addEventListener(s,o,i),()=>t.removeEventListener(s,o,i)),r),r}setTimeout(t,s,o=$()){return this.add(()=>{const i=window.setTimeout(()=>{this.remove(o),t()},s);return()=>window.clearTimeout(i)},o)}setInterval(t,s,o=$()){return this.add(()=>{const i=window.setInterval(t,s);return()=>window.clearInterval(i)},o)}remove(t){const s=this.disposers.get(t);return this.disposers.delete(t),s}flush(t){const s=this.remove(t);if(s)try{s()}catch(o){console.error(o)}}flushAll(){this.disposers.forEach(t=>{try{t()}catch(s){console.error(s)}}),this.disposers.clear()}}function os(e){const t="http://www.w3.org/2000/svg",s=document.createElementNS(t,"svg");s.setAttribute("class",`${e}-footer-icon-sidebar`),s.setAttribute("viewBox","0 0 64 64");const o=document.createElementNS(t,"path");return o.setAttribute("fill","currentColor"),o.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(o),s}function is(e){const t="http://www.w3.org/2000/svg",s=document.createElementNS(t,"svg");s.setAttribute("class",`${e}-footer-icon-arrow-left`),s.setAttribute("viewBox","0 0 500 500");const o=document.createElementNS(t,"path");return o.setAttribute("fill","currentColor"),o.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(o),s}function rs(e){const t="http://www.w3.org/2000/svg",s=document.createElementNS(t,"svg");s.setAttribute("class",`${e}-footer-icon-arrow-right`),s.setAttribute("viewBox","0 0 500 500");const o=document.createElementNS(t,"path");return o.setAttribute("fill","currentColor"),o.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(o),s}function as(e){const t="http://www.w3.org/2000/svg",s=document.createElementNS(t,"svg");s.setAttribute("class",`${e}-footer-icon-play`),s.setAttribute("viewBox","0 0 500 500");const o=document.createElementNS(t,"path");return o.setAttribute("fill","currentColor"),o.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(o),s}function ns(e){const t="http://www.w3.org/2000/svg",s=document.createElementNS(t,"svg");s.setAttribute("class",`${e}-footer-icon-pause`),s.setAttribute("viewBox","0 0 500 500");const o=document.createElementNS(t,"path");return o.setAttribute("fill","currentColor"),o.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(o),s}class Ie{constructor({readonly:t,box:s,pages:o,onNewPageIndex:i,onPlay:r}){if(this.pageIndex=0,this.namespace="netless-app-docs-viewer",this.isShowPreview=!1,this.isSmallBox=!1,this.sideEffect=new G,o.length<=0)throw new Error("[DocsViewer] Empty pages.");this.readonly=t,this.box=s,this.pages=o,this.onNewPageIndex=i,this.onPlay=r,this.render()}mount(){this.box.mountContent(this.$content),this.box.mountFooter(this.$footer),this.sideEffect.add(()=>{const t=new S({container:this.$preview,elements_selector:`.${this.wrapClassName("preview-page>img")}`});return()=>t.destroy()},"preview-lazyload")}unmount(){this.$content.remove(),this.$footer.remove()}setReadonly(t){this.readonly!==t&&(this.readonly=t,this.$content.classList.toggle(this.wrapClassName("readonly"),t),this.$footer.classList.toggle(this.wrapClassName("readonly"),t),this.$pageNumberInput.disabled=t)}destroy(){this.sideEffect.flushAll(),this.unmount()}setPageIndex(t){Number.isNaN(t)||(this.pageIndex=t,this.$pageNumberInput.value=String(t+1))}setSmallBox(t){this.isSmallBox!==t&&(this.isSmallBox=t,this.$footer.classList.toggle(this.wrapClassName("float-footer"),t))}render(){return this.renderContent(),this.renderFooter(),this.$content}renderContent(){if(!this.$content){const t=document.createElement("div");t.className=this.wrapClassName("content"),this.$content=t,this.readonly&&t.classList.add(this.wrapClassName("readonly")),t.appendChild(this.renderPreviewMask()),t.appendChild(this.renderPreview())}return this.$content}renderPreview(){if(!this.$preview){const t=document.createElement("div");t.className=this.wrapClassName("preview")+" tele-fancy-scrollbar",this.$preview=t;const s=this.wrapClassName("preview-page"),o=this.wrapClassName("preview-page-name");this.pages.forEach((i,r)=>{var p;const n=(p=i.thumbnail)!=null?p:i.src.startsWith("ppt")?void 0:i.src;if(!n)return;const c=String(r),a=document.createElement("a");a.className=s+" "+this.wrapClassName(`preview-page-${r}`),a.setAttribute("href","#"),a.dataset.pageIndex=c;const l=document.createElement("span");l.className=o,l.textContent=String(r+1),l.dataset.pageIndex=c;const d=document.createElement("img");d.width=i.width,d.height=i.height,d.dataset.src=n,d.dataset.pageIndex=c,a.appendChild(d),a.appendChild(l),t.appendChild(a)}),this.sideEffect.addEventListener(t,"click",i=>{var n;if(this.readonly)return;const r=(n=i.target.dataset)==null?void 0:n.pageIndex;r&&(i.preventDefault(),i.stopPropagation(),i.stopImmediatePropagation(),this.onNewPageIndex(Number(r)),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",t=>{this.readonly||t.target===this.$previewMask&&this.togglePreview(!1)})),this.$previewMask}renderFooter(){if(!this.$footer){const t=document.createElement("div");if(t.className=this.wrapClassName("footer"),this.$footer=t,this.readonly&&t.classList.add(this.wrapClassName("readonly")),this.isSmallBox&&t.classList.add(this.wrapClassName("float-footer")),this.pages.some(a=>a.thumbnail||!a.src.startsWith("ppt"))){const a=this.renderFooterBtn("btn-sidebar",os(this.namespace));this.sideEffect.addEventListener(a,"click",()=>{this.readonly||this.togglePreview()}),this.$footer.appendChild(a)}const s=document.createElement("div");s.className=this.wrapClassName("page-jumps");const o=this.renderFooterBtn("btn-page-back",is(this.namespace));if(this.sideEffect.addEventListener(o,"click",()=>{this.readonly||this.onNewPageIndex(this.pageIndex-1)}),s.appendChild(o),this.onPlay){const a=this.renderFooterBtn("btn-page-play",as(this.namespace),ns(this.namespace)),l=()=>{this.sideEffect.setTimeout(()=>{a.classList.toggle(this.wrapClassName("footer-btn-playing"),!1)},500,"returnPlay")};this.sideEffect.addEventListener(a,"click",()=>{this.readonly||(a.classList.toggle(this.wrapClassName("footer-btn-playing"),!0),this.onPlay&&this.onPlay(),l())}),s.appendChild(a)}const i=this.renderFooterBtn("btn-page-next",rs(this.namespace));this.sideEffect.addEventListener(i,"click",()=>{this.readonly||this.onNewPageIndex(this.pageIndex+1)}),s.appendChild(i);const r=document.createElement("div");r.className=this.wrapClassName("page-number");const n=document.createElement("input");n.className=this.wrapClassName("page-number-input"),n.value=String(this.pageIndex+1),this.readonly&&(n.disabled=!0),this.$pageNumberInput=n,this.sideEffect.addEventListener(n,"change",()=>{this.readonly||n.value&&this.onNewPageIndex(Number(n.value)-1)});const c=document.createElement("span");c.textContent=" / "+this.pages.length,r.appendChild(n),r.appendChild(c),this.$footer.appendChild(s),this.$footer.appendChild(r)}return this.$footer}renderFooterBtn(t,s,o){const i=document.createElement("button");return i.className=this.wrapClassName("footer-btn")+" "+this.wrapClassName(t),i.appendChild(s),o&&i.appendChild(o),i}togglePreview(t){if(this.isShowPreview=t!=null?t:!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(t){return`${this.namespace}-${t}`}}function A(e,t,s){return Math.min(Math.max(e,t),s)}function Le(e){return e.touches?e.touches[0]:e}function Pe(e){e.stopPropagation(),e.cancelable&&e.preventDefault()}class cs{constructor(t){var s,o,i;this.velocity=0,this.paused=!0,this._animationFrameID=null,this._loopTimestamp=0,this.looper=r=>{if(this.paused)return;let n=Math.floor((r-this._loopTimestamp)/1e3*60)+1;for(this._loopTimestamp=r;n-- >0;)this.stepper();this.onStep(this.current,this),!this.paused&&this.current!==this.target&&window.requestAnimationFrame(this.looper)},this.current=(s=t.start)!=null?s:0,this.target=this.current,this.stiffness=(o=t.stiffness)!=null?o:170,this.damping=(i=t.damping)!=null?i:26,this.onStep=t.onStep}stepTo(t){this.paused=!1,this.target=t,this.onStep(this.current,this),this._loopTimestamp=Date.now(),window.requestAnimationFrame(this.looper)}pause(){this.paused=!0}destroy(){this.pause()}stepper(){const t=-this.stiffness*(this.current-this.target),s=-this.damping*this.velocity,o=this.velocity+(t+s)/60,i=this.current+o/60;Math.abs(o-0)<.01&&Math.abs(i-this.target)<.01?(this.current=this.target,this.velocity=0):(this.current=i,this.velocity=o)}}const Y=30,T=640;class ls{constructor({whiteboardView:t,readonly:s,box:o,pages:i,pagesSize:r,pageScrollTop:n=0,mountWhiteboard:c,onUserScroll:a}){this.sideEffect=new G,this.userScrolling=!1,this.scrollbarHeight=Y,this.onNewPageIndex=d=>{this.scrollToPage(d)},this.whiteboardView=t,this.readonly=s,this.box=o,this.pages=i,this.pageScrollTop=n,this.pagesSize=r,this.mountWhiteboard=c,this.onUserScroll=a,this.pageScrollStepper=new cs({onStep:d=>{this.pageScrollTo(d)}});const l=this.debounce(()=>{this.userScrolling=!1,this.onUserScroll&&this.onUserScroll(this.pageScrollTop)},{wait:80},"debounce-updateUserScroll");this.updateUserScroll=()=>{this.userScrolling=!0,l()},this.viewer=new Ie({readonly:s,box:o,pages:i,onNewPageIndex:this.onNewPageIndex}),this.render()}mount(){return this.viewer.mount(),this.sideEffect.add(()=>{const t=new S({container:this.$pages,elements_selector:`.${this.wrapClassName("page")}`});return()=>t.destroy()},"page-lazyload"),this.setupWhiteboardCamera(),this.sideEffect.setTimeout(()=>{this.pageScrollTop!==0&&this.pageScrollTo(this.pageScrollTop)},1e3),this.setupScrollTopEvent(),this.sideEffect.add(()=>{const t=this.renderRatioHeight.bind(this);return this.box.events.on("visual_resize",t),()=>this.box.events.off("visual_resize",t)}),this}unmount(){return this.viewer.unmount(),this}setReadonly(t){this.readonly!==t&&(this.readonly=t,this.viewer.setReadonly(t))}destroy(){this.sideEffect.flushAll(),this.pageScrollStepper.destroy(),this.onUserScroll=void 0,this.unmount(),this.viewer.destroy()}syncPageScrollTop(t){!this.userScrolling&&t>=0&&Math.abs(this.pageScrollTop-t)>10&&this.pageScrollStepper.stepTo(t)}render(){this.viewer.$content.appendChild(this.renderPages()),this.viewer.$content.appendChild(this.renderWhiteboardView()),this.viewer.$content.appendChild(this.renderScrollbar()),this.renderRatioHeight()}renderRatioHeight(){const t=this.box.absoluteHeight,s=t<=T;if(this.viewer.setSmallBox(s),s){const o=26/T,i=26/t,r=26/T,n=0,c=Math.max((o+r-(i+n))/2,0);if(this.box.$titleBar){const a=i+c;this.box.$titleBar.style.height=`${a*100}%`}if(this.box.$footer){const a=n+c;this.box.$footer.style.height=`${a*100}%`}}else{if(this.box.$titleBar){const o=Math.max(26/T,26/t);this.box.$titleBar.style.height=`${o*100}%`}if(this.box.$footer){const o=Math.max(26/T,26/t);this.box.$footer.style.height=`${o*100}%`}}}renderPages(){if(!this.$pages){const t=document.createElement("div");t.className=this.wrapClassName("pages"),this.$pages=t;const s=this.wrapClassName("page");this.pages.forEach((o,i)=>{const r=document.createElement("img");r.className=s+" "+this.wrapClassName(`page-${i}`),r.draggable=!1,r.width=o.width,r.height=o.height,r.dataset.src=o.src,r.dataset.pageIndex=String(i),t.appendChild(r)})}return this.$pages}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",t=>{Pe(t),this.readonly||(this.pageScrollTo(this.pageScrollTop+t.deltaY),this.updateUserScroll())},{passive:!1,capture:!0}),this.sideEffect.addEventListener(this.$whiteboardView,"touchmove",t=>{this.readonly||t.touches.length<=1||this.updateUserScroll()},{passive:!0,capture:!0})),this.$whiteboardView}renderScrollbar(){if(!this.$scrollbar){const t=document.createElement("button");this.$scrollbar=t,t.className=this.wrapClassName("scrollbar"),t.style.minHeight=`${Y}px`;const s=o=>{if(this.readonly||o.button!=null&&o.button!==0)return;Pe(o),this.$scrollbar.classList.toggle(this.wrapClassName("scrollbar-dragging"),!0);const i=this.scrollTopPageToEl(this.pageScrollTop),r=this.whiteboardView.size.width/this.pagesSize.width*this.pagesSize.height,{clientY:n}=Le(o),c=l=>{const{clientY:d}=Le(l),{height:p}=this.whiteboardView.size;this.elScrollTo(i+(d-n)*(r/p)),this.updateUserScroll()},a=()=>{this.$scrollbar.classList.toggle(this.wrapClassName("scrollbar-dragging"),!1),window.removeEventListener("mousemove",c,!0),window.removeEventListener("touchmove",c,!0),window.removeEventListener("mouseup",a,!0),window.removeEventListener("touchend",a,!0),window.removeEventListener("touchcancel",a,!0)};window.addEventListener("mousemove",c,!0),window.addEventListener("touchmove",c,!0),window.addEventListener("mouseup",a,!0),window.addEventListener("touchend",a,!0),window.addEventListener("touchcancel",a,!0)};this.sideEffect.addEventListener(t,"mousedown",s),this.sideEffect.addEventListener(t,"touchstart",s)}return this.$scrollbar}scrollTopPageToEl(t){return t*(this.whiteboardView.size.width/this.pagesSize.width)}scrollTopElToPage(t){return t/(this.whiteboardView.size.width/this.pagesSize.width)}elScrollTo(t){this.pageScrollTo(this.scrollTopElToPage(t))}pageScrollTo(t){const s=this.scrollTopElToPage(this.whiteboardView.size.height/2);this.whiteboardView.moveCamera({centerY:A(t+s,s,this.pagesSize.height-s),animationMode:"immediately"})}scrollToPage(t){if(!this.readonly&&this.$pages&&!Number.isNaN(t)){t=A(t,0,this.pages.length-1);const s=this.$pages.querySelector("."+this.wrapClassName(`page-${t}`));if(s){const o=s.offsetTop+5;this.elScrollTo(o),this.updateUserScroll()}}}setupScrollTopEvent(){const t=this.debounce(()=>{if(this.pages.length>0&&this.$pages&&this.$pages.getBoundingClientRect().width>0){let o=0;for(let i=0;i<this.pages.length;i+=1)if(o+=this.pages[i].height,this.pageScrollTop<=o){this.viewer.setPageIndex(i);return}this.viewer.setPageIndex(this.pages.length-1)}},{wait:5,maxWait:100},"debounce-updatePageIndex");this.sideEffect.add(()=>{const s=o=>{const{width:i,height:r}=this.whiteboardView.size,{width:n,height:c}=this.pagesSize,a=i/n*c,l=this.scrollTopPageToEl(o.centerY)-r/2,d=this.scrollTopElToPage(l);this.pageScrollTop=d,this.$pages.scrollTo({top:l}),this.setScrollbarHeight(r/a*r),this.$scrollbar.style.transform=`translateY(${l/(a-r)*(r-this.scrollbarHeight)}px)`,t()};return this.whiteboardView.callbacks.on("onCameraUpdated",s),()=>this.whiteboardView.callbacks.off("onCameraUpdated",s)})}setupWhiteboardCamera(){this.sideEffect.add(()=>{const t=({width:s,height:o})=>{if(s>0&&o>0){const i=this.$pages.scrollTop,r=this.pagesSize.width,n=r/s;this.whiteboardView.moveCameraToContain({originX:0,originY:i*n,width:r,height:o*n,animationMode:"immediately"}),this.whiteboardView.setCameraBound({damping:1,maxContentMode:()=>s/r,minContentMode:()=>s/r,centerX:this.pagesSize.width/2,centerY:this.pagesSize.height/2,width:this.pagesSize.width,height:this.pagesSize.height}),this.elScrollTo(i)}};return this.whiteboardView.callbacks.on("onSizeUpdated",t),()=>{this.whiteboardView.callbacks.off("onSizeUpdated",t)}},"whiteboard-size-update")}debounce(t,s,o){const i=ts(t,s);return this.sideEffect.addDisposer(()=>i.cancel(),o),i}wrapClassName(t){return"netless-app-docs-viewer-static-"+t}setScrollbarHeight(t){t=A(t,Y,this.whiteboardView.size.height),this.scrollbarHeight!==t&&(this.scrollbarHeight=t,this.$scrollbar.style.height=`${t}px`)}}class ds{constructor({displayer:t,whiteboardView:s,getRoom:o,readonly:i,box:r,pages:n,mountWhiteboard:c}){this.sideEffect=new G,this.onPlayPPT=()=>{const a=this.getWhiteboardRoom();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.whiteboardView=s,this.readonly=i,this.box=r,this.pages=n,this.displayer=t,this.getWhiteboardRoom=o,this.mountWhiteboard=c,this.viewer=new Ie({readonly:i,box:r,pages:n,onNewPageIndex:this.onNewPageIndex,onPlay:this.onPlayPPT}),this.render()}mount(){this.viewer.mount();const t=this.getPageIndex();return t!==0&&this.jumpToPage(t),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}setReadonly(t){this.readonly!==t&&(this.readonly=t,this.viewer.setReadonly(t))}destroy(){this.sideEffect.flushAll(),this.unmount(),this.viewer.destroy()}getPageIndex(){return this.displayer.state.sceneState.index}jumpToPage(t,s){if(t=A(t,0,this.pages.length-1),t!==this.getPageIndex()){const o=this.getWhiteboardRoom();o&&(o.setSceneIndex(t),this.scaleDocsToFit())}if(t!==this.viewer.pageIndex&&this.viewer.setPageIndex(t),s){const o=this.getWhiteboardRoom();o&&o.setGlobalState({__pptState:void 0})}}render(){this.viewer.$content.appendChild(this.renderMask()),this.viewer.$content.appendChild(this.renderWhiteboardView()),this.sideEffect.addEventListener(window,"keydown",t=>{var s;if(this.box.focus)switch(t.key){case"ArrowUp":case"ArrowLeft":{this.jumpToPage(this.getPageIndex()-1,!0);break}case"ArrowRight":case"ArrowDown":{(s=this.getWhiteboardRoom())==null||s.pptNextStep();break}}})}renderMask(){if(!this.$mask){const t=document.createElement("div");t.className=this.wrapClassName("mask"),this.$mask=t;const s=document.createElement("button");s.className=this.wrapClassName("back");const o=document.createElement("button");o.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",t=>{var o;const s=this.getWhiteboardRoom();if(s&&s.state.memberState.currentApplianceName==="clicker"){for(let i=t.target;i;i=i.parentElement)if((o=i.classList)==null?void 0:o.contains("ppt-event-source"))return;s.pptNextStep()}}),this.mountWhiteboard(this.$whiteboardView)),this.$whiteboardView}wrapClassName(t){return"netless-app-docs-viewer-dynamic-"+t}}const hs="DocsViewer",ps={kind:hs,setup(e){const t=e.getBox(),s=e.getScenes();if(!s)throw new Error("[Docs Viewer]: scenes not found.");const o=e.getView();if(!o)throw new Error("[Docs Viewer]: no whiteboard view.");const i=s.map(({ppt:r})=>r?{width:r.width,height:r.height,src:r.src,thumbnail:r.previewURL}:null).filter(r=>Boolean(r));if(i.length<=0)throw new Error("[Docs Viewer]: empty scenes.");t.mountStyles(Be),i[0].src.startsWith("ppt")?gs(e,o,t,i):us(e,o,t,i)}};function us(e,t,s,o){var n;const i={width:o[0].width,height:o.reduce((c,a)=>c+a.height*(o[0].width/a.width),0)},r=new ls({whiteboardView:t,readonly:s.readonly,box:s,pages:o,pagesSize:i,pageScrollTop:(n=e.getAttributes())==null?void 0:n.pageScrollTop,mountWhiteboard:e.mountView.bind(e),onUserScroll:c=>{var a;((a=e.getAttributes())==null?void 0:a.pageScrollTop)!==c&&!s.readonly&&e.updateAttributes(["pageScrollTop"],c)}}).mount();e.emitter.on("attributesUpdate",c=>{c&&c.pageScrollTop!=null&&r.syncPageScrollTop(c.pageScrollTop)}),s.events.on("readonly",c=>{r.setReadonly(c)})}function gs(e,t,s,o){t.disableCameraTransform=!0;const i=e.getDisplayer(),r=new ds({displayer:i,whiteboardView:t,getRoom:()=>e.getIsWritable()?e.getDisplayer():void 0,readonly:s.readonly,box:s,pages:o,mountWhiteboard:e.mountView.bind(e)}).mount();e.mountView(r.$whiteboardView),e.isAddApp&&t.callbacks.once("onSizeUpdated",({width:n,height:c})=>{if(o.length>0&&s.state!=="maximized"){const{width:a,height:l}=o[0],p=l/a*n-c;p!==0&&e.getIsWritable()&&e.emitter.emit("setBoxSize",{width:s.width,height:s.height+p/s.containerRect.height})}}),e.emitter.on("sceneStateChange",n=>{r.jumpToPage(n.index)}),s.events.on("readonly",n=>{r.setReadonly(n)})}exports.default=ps;
"use strict";var Re=Object.defineProperty,Ve=Object.defineProperties;var Me=Object.getOwnPropertyDescriptors;var X=Object.getOwnPropertySymbols;var ze=Object.prototype.hasOwnProperty,De=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))De.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 Oe=`.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-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),o=Object.getOwnPropertyDescriptor(e,s);!Be(r,o)&&i||Object.defineProperty(t,s,o)},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:o=!0}=e;if(!r&&!o)throw new Error("Both `before` and `after` are false, function wouldn't be called.");let a,c,n;const h=function(...d){const l=this,Pe=()=>{a=void 0,c&&(clearTimeout(c),c=void 0),o&&(n=t.apply(l,d))},Ae=()=>{c=void 0,a&&(clearTimeout(a),a=void 0),o&&(n=t.apply(l,d))},He=r&&!a;return clearTimeout(a),a=setTimeout(Pe,s),i>0&&i!==Number.Infinity&&!c&&(c=setTimeout(Ae,i)),He&&(n=t.apply(l,d)),n};return Xe(h,t),h.cancel=()=>{a&&(clearTimeout(a),a=void 0),c&&(clearTimeout(c),c=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 N{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,o=y()){return this.add(()=>(e.addEventListener(s,i,r),()=>e.removeEventListener(s,i,r)),o),o}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",oe="poster",E="llOriginalAttrs",D="loading",ae="loaded",ne="applied",ot="entered",O="error",ce="native",le="data-",he="ll-status",p=(t,e)=>t.getAttribute(le+e),at=(t,e,s)=>{var i=le+e;if(s===null){t.removeAttribute(i);return}t.setAttribute(i,s)},x=t=>p(t,he),m=(t,e)=>at(t,he,e),_=t=>m(t,null),W=t=>x(t)===null,nt=t=>x(t)===D,ct=t=>x(t)===O,B=t=>x(t)===ce,lt=[D,ae,ne,O],ht=t=>lt.indexOf(x(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,mt=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,oe],P=[g,M,z],A=t=>!!t[E],we=t=>t[E],me=t=>delete t[E],$=(t,e)=>{if(A(t))return;const s={};e.forEach(i=>{s[i]=t.getAttribute(i)}),t[E]=s},bt=t=>{A(t)||(t[E]={backgroundImage:t.style.backgroundImage})},vt=(t,e,s)=>{if(!s){t.removeAttribute(e);return}t.setAttribute(e,s)},T=(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),m(t,ne),!!s&&(e.unobserve_completed&&k(t,e),f(e.callback_applied,t,s))},be=(t,e,s)=>{v(t,e.class_loading),m(t,D),!!s&&(F(s,1),f(e.callback_loading,t,s))},b=(t,e,s)=>{!s||t.setAttribute(e,s)},ve=(t,e)=>{b(t,z,p(t,e.data_sizes)),b(t,M,p(t,e.data_srcset)),b(t,g,p(t,e.data_src))},Et=(t,e)=>{U(t,s=>{$(s,P),ve(s,e)}),$(t,P),ve(t,e)},xt=(t,e)=>{$(t,L),b(t,g,p(t,e.data_src))},$t=(t,e)=>{ge(t,s=>{$(s,L),b(s,g,p(s,e.data_src))}),$(t,fe),b(t,oe,p(t,e.data_poster)),b(t,g,p(t,e.data_src)),t.load()},Tt=(t,e,s)=>{const i=p(t,e.data_bg),r=p(t,e.data_bg_hidpi),o=se&&r?r:i;!o||(t.style.backgroundImage=`url("${o}")`,de(t).setAttribute(g,o),be(t,e,s))},It=(t,e,s)=>{const i=p(t,e.data_bg_multi),r=p(t,e.data_bg_multi_hidpi),o=se&&r?r:i;!o||(t.style.backgroundImage=o,yt(t,e,s))},Se={IMG:Et,IFRAME:xt,VIDEO:$t},Ct=(t,e)=>{const s=Se[t.tagName];!s||s(t,e)},Nt=(t,e,s)=>{const i=Se[t.tagName];!i||(i(t,e),be(t,e,s))},_t=["IMG","IFRAME","VIDEO"],kt=t=>_t.indexOf(t.tagName)>-1,ye=(t,e)=>{e&&!wt(e)&&!mt(e)&&f(t.callback_finish,e)},Ee=(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";Ee(t,i,e),Ee(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},xe=(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);xe(e,s,i),v(e,s.class_loaded),m(e,ae),f(s.callback_loaded,e,i),r||ye(s,i)},Ht=(t,e,s,i)=>{const r=B(e);xe(e,s,i),v(e,s.class_error),m(e,O),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,a=>{At(a,t,e,s),j(i)},a=>{Ht(a,t,e,s),j(i)})},Rt=(t,e,s)=>{dt(t),G(t,e,s),bt(t),Tt(t,e,s),It(t,e,s)},Vt=(t,e,s)=>{G(t,e,s),Nt(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),Ct(t,e),m(t,ce)},$e=t=>{t.removeAttribute(g),t.removeAttribute(M),t.removeAttribute(z)},zt=t=>{U(t,e=>{$e(e)}),$e(t)},Te=t=>{U(t,e=>{T(e,P)}),T(t,P)},Dt=t=>{ge(t,e=>{T(e,L)}),T(t,fe),t.load()},Ot=t=>{T(t,L)},Wt={IMG:Te,IFRAME:Ot,VIDEO:Dt},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),_(t),me(t)},Yt=(t,e,s,i)=>{!s.cancel_on_exit||!nt(t)||t.tagName==="IMG"&&(j(t),zt(t),Te(t),u(t,s.class_loading),F(i,-1),_(t),f(s.callback_cancel,t,e,i))},jt=(t,e,s,i)=>{const r=ht(t);m(t,ot),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"],Ie=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||Ie(t)||(e._observer=new IntersectionObserver(s=>{Zt(s,t,e)},Kt(t)))},Ce=t=>Array.prototype.slice.call(t),H=t=>t.container.querySelectorAll(t.elements_selector),ss=t=>Ce(t).filter(W),is=t=>ct(t),rs=t=>Ce(t).filter(is),Ne=(t,e)=>ss(t||H(e)),os=(t,e)=>{rs(H(t)).forEach(i=>{u(i,t.class_error),_(i)}),e.update()},as=(t,e)=>{!w||window.addEventListener("online",()=>{os(t,e)})},I=function(t,e){const s=ie(t);this._settings=s,this.loadingCount=0,ts(s,this),as(s,this),this.update(e)};I.prototype={update:function(t){const e=this._settings,s=Ne(t,e);if(pe(this,s.length),Q||!ee){this.loadAll(s);return}if(Ie(e)){Xt(s,e,this);return}es(this._observer,s)},destroy:function(){this._observer&&this._observer.disconnect(),H(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=>{k(i,this),q(i,e,this)})},restoreAll:function(){const t=this._settings;H(t).forEach(e=>{Ut(e,t)})}};I.load=(t,e)=>{const s=ie(e);q(t,s)};I.resetStatus=t=>{_(t)};w&&rt(I,window.lazyLoadOptions);class _e{constructor({readonly:e,box:s,pages:i,onNewPageIndex:r,onPlay:o}){if(this.pageIndex=0,this.namespace="netless-app-docs-viewer",this.isShowPreview=!1,this.isSmallBox=!1,this.sideEffect=new N,i.length<=0)throw new Error("[DocsViewer] Empty pages.");this.readonly=e,this.box=s,this.pages=i,this.onNewPageIndex=r,this.onPlay=o,this.render()}mount(){this.box.mountContent(this.$content),this.box.mountFooter(this.$footer),this.sideEffect.add(()=>{const e=new I({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,o)=>{var l;const a=(l=r.thumbnail)!=null?l:r.src.startsWith("ppt")?void 0:r.src;if(!a)return;const c=String(o),n=document.createElement("a");n.className=s+" "+this.wrapClassName(`preview-page-${o}`),n.setAttribute("href","#"),n.dataset.pageIndex=c;const h=document.createElement("span");h.className=i,h.textContent=String(o+1),h.dataset.pageIndex=c;const d=document.createElement("img");d.width=r.width,d.height=r.height,d.dataset.src=a,d.dataset.pageIndex=c,n.appendChild(d),n.appendChild(h),e.appendChild(n)}),this.sideEffect.addEventListener(e,"click",r=>{var a;if(this.readonly)return;const o=(a=r.target.dataset)==null?void 0:a.pageIndex;o&&(r.preventDefault(),r.stopPropagation(),r.stopImmediatePropagation(),this.onNewPageIndex(Number(o)),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(n=>n.thumbnail||!n.src.startsWith("ppt"))){const n=this.renderFooterBtn("btn-sidebar",Ze(this.namespace));this.sideEffect.addEventListener(n,"click",()=>{this.readonly||this.togglePreview()}),this.$footer.appendChild(n)}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 n=this.renderFooterBtn("btn-page-play",tt(this.namespace),st(this.namespace)),h=()=>{this.sideEffect.setTimeout(()=>{n.classList.toggle(this.wrapClassName("footer-btn-playing"),!1)},500,"returnPlay")};this.sideEffect.addEventListener(n,"click",()=>{this.readonly||(n.classList.toggle(this.wrapClassName("footer-btn-playing"),!0),this.onPlay&&this.onPlay(),h())}),s.appendChild(n)}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 o=document.createElement("div");o.className=this.wrapClassName("page-number");const a=document.createElement("input");a.className=this.wrapClassName("page-number-input"),a.value=String(this.pageIndex+1),this.readonly&&(a.disabled=!0),this.$pageNumberInput=a,this.sideEffect.addEventListener(a,"focus",()=>{a.select()}),this.sideEffect.addEventListener(a,"change",()=>{this.readonly||a.value&&this.onNewPageIndex(Number(a.value)-1)});const c=document.createElement("span");c.textContent=" / "+this.pages.length,o.appendChild(a),o.appendChild(c),this.$footer.appendChild(s),this.$footer.appendChild(o)}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=o=>{if(this.paused)return;let a=Math.floor((o-this._loopTimestamp)/1e3*60)+1;for(this._loopTimestamp=o;a-- >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 o=document.createElement("img");o.className="page-renderer-page-img",o.width=s.width,o.height=s.height,o.src=s.src,r.appendChild(o),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,o)=>o.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.pagesScrollTop=e.pagesScrollTop||0,this.containerWidth=e.containerWidth||1,this.containerHeight=e.containerHeight||1,this.pages=e.pages.map(o=>{if(o.thumbnail)return o;try{const a=new URL(o.src);return a.searchParams.set("x-oss-process","image/resize,l_50"),V(R({},o),{thumbnail:a.toString()})}catch(a){return console.error(a),o}});const s=Array(this.pages.length);let i=1/0,r=0;this.pagesIntrinsicHeight=this.pages.reduce((o,a,c)=>(s[c]=o,a.width>r&&(r=a.width),a.height<=i&&(i=a.height),o+a.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.pagesScrollTop=e;const i=this.findScrollPageIndex(),r=Math.max(i-this.threshold,0),o=Math.min(i+this.threshold,this.pages.length-1);for(let a=0;a<this.$pages.children.length;a++){const c=this.$pages.children[a],n=Number(c.dataset.index);n>=r&&n<=o||(c.remove(),a--)}for(let a=r;a<=o;a++){const c=this.pageElManager.getEl(a);c.$page.parentElement!==this.$pages&&this.$pages.appendChild(c.$page),c.translateY(this.pagesIntrinsicYs[a]-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()}_calcScale(){return this.containerWidth/this.pagesIntrinsicWidth||1}_calcThreshold(){return S(Math.ceil(this.containerHeight/this.scale/this.pagesMinHeight/2),1,this.pages.length)}}const us=30;class gs{constructor(e){this.sideEffect=new N,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,o=i/(r-this.containerHeight)*(this.containerHeight-this.scrollbarHeight);window.requestAnimationFrame?window.requestAnimationFrame(()=>{this.$scrollbar.style.transform=`translateY(${o}px)`}):this.$scrollbar.style.transform=`translateY(${o}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 o=this.pagesScrollTop,{clientY:a}=ke(i),c=h=>{if(this.readonly)return;const{clientY:d}=ke(h),l=(d-a)/this.scale;Math.abs(l)>0&&this.onDragScroll&&this.onDragScroll(o+l*(this.pagesHeight*this.scale/this.containerHeight))},n=()=>{e.classList.toggle(r,!1),window.removeEventListener("mousemove",c,!0),window.removeEventListener("touchmove",c,!0),window.removeEventListener("mouseup",n,!0),window.removeEventListener("touchend",n,!0),window.removeEventListener("touchcancel",n,!0)};window.addEventListener("mousemove",c,!0),window.addEventListener("touchmove",c,!0),window.addEventListener("mouseup",n,!0),window.addEventListener("touchend",n,!0),window.addEventListener("touchcancel",n,!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 C=640;class fs{constructor({whiteboardView:e,readonly:s,box:i,pages:r,pageScrollTop:o=0,mountWhiteboard:a,onUserScroll:c}){this.sideEffect=new N,this.userScrolling=!1,this.onNewPageIndex=l=>{this.scrollToPage(l)},this.whiteboardView=e,this.readonly=s,this.box=i,this.pages=r,this.mountWhiteboard=a,this._onUserScroll=c;const n=this.debounce(()=>{this.userScrolling=!1,this._onUserScroll&&this._onUserScroll(this.pageRenderer.pagesScrollTop)},{wait:80},"debounce-updateUserScroll");this.updateUserScroll=()=>{this.userScrolling=!0,n()},this.viewer=new _e({readonly:s,box:i,pages:r,onNewPageIndex:this.onNewPageIndex});const{width:h,height:d}=this.whiteboardView.size;this.pageRenderer=new ps({pagesScrollTop:o,pages:this.pages,containerWidth:h,containerHeight:d,onPageIndexChanged:this.viewer.setPageIndex.bind(this.viewer)}),this.scrollbar=new gs({pagesScrollTop:this.pageRenderer.pagesScrollTop,containerWidth:h,containerHeight:d,pagesWidth:this.pageRenderer.pagesIntrinsicWidth,pagesHeight:this.pageRenderer.pagesIntrinsicHeight,readonly:this.readonly,wrapClassName:this.wrapClassName.bind(this),onDragScroll:l=>{this.pageScrollTo(l),this.updateUserScroll()}}),this.pageScrollStepper=new ns({start:this.pageRenderer.pagesScrollTop,onStep:l=>{this.pageScrollTo(l)}}),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<=C;if(this.viewer.setSmallBox(s),s){const i=26/C,r=26/e,o=26/C,a=0,c=Math.max((i+o-(r+a))/2,0);if(this.box.$titleBar){const n=r+c;this.box.$titleBar.style.height=`${n*100}%`}if(this.box.$footer){const n=a+c;this.box.$footer.style.height=`${n*100}%`}}else{if(this.box.$titleBar){const i=Math.max(26/C,26/e);this.box.$titleBar.style.height=`${i*100}%`}if(this.box.$footer){const i=Math.max(26/C,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 o=s.centerY-this.pageRenderer.containerHeight/this.pageRenderer.scale/2;this.pageRenderer.pagesScrollTo(o),this.scrollbar.pagesScrollTo(o)};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:o}=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:o/2,width:r,height:o})};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({displayer:e,whiteboardView:s,getRoom:i,readonly:r,box:o,pages:a,mountWhiteboard:c}){this.sideEffect=new N,this.onPlayPPT=()=>{const n=this.getWhiteboardRoom();n&&n.pptNextStep()},this._scaleDocsToFitImpl=()=>{const n=this.pages[this.getPageIndex()];n&&this.whiteboardView.moveCameraToContain({originX:-n.width/2,originY:-n.height/2,width:n.width,height:n.height,animationMode:"immediately"})},this._scaleDocsToFitDebounced=()=>{this.sideEffect.setTimeout(this._scaleDocsToFitImpl,1e3,"_scaleDocsToFitDebounced")},this.scaleDocsToFit=()=>{this._scaleDocsToFitImpl(),this._scaleDocsToFitDebounced()},this.onNewPageIndex=n=>{this.jumpToPage(n,!0)},this.whiteboardView=s,this.readonly=r,this.box=o,this.pages=a,this.displayer=e,this.getWhiteboardRoom=i,this.mountWhiteboard=c,this.viewer=new _e({readonly:r,box:o,pages:a,onNewPageIndex:this.onNewPageIndex,onPlay:this.onPlayPPT}),this.render()}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}setReadonly(e){this.readonly!==e&&(this.readonly=e,this.viewer.setReadonly(e))}destroy(){this.sideEffect.flushAll(),this.unmount(),this.viewer.destroy()}getPageIndex(){return this.displayer.state.sceneState.index}jumpToPage(e,s){if(e=S(e,0,this.pages.length-1),e!==this.getPageIndex()){const i=this.getWhiteboardRoom();i&&(i.setSceneIndex(e),this.scaleDocsToFit())}if(e!==this.viewer.pageIndex&&this.viewer.setPageIndex(e),s){const i=this.getWhiteboardRoom();i&&i.setGlobalState({__pptState:void 0})}}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.getWhiteboardRoom())==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.getWhiteboardRoom();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.mountWhiteboard(this.$whiteboardView)),this.$whiteboardView}wrapClassName(e){return"netless-app-docs-viewer-dynamic-"+e}}const ms="DocsViewer",bs={kind:ms,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:o})=>o?{width:o.width,height:o.height,src:o.src,thumbnail:o.previewURL}:null).filter(o=>Boolean(o));if(r.length<=0)throw new Error("[Docs Viewer]: empty scenes.");e.mountStyles(Oe),r[0].src.startsWith("ppt")?Ss(t,i,e,r):vs(t,i,e,r)}};function vs(t,e,s,i){var o;const r=new fs({whiteboardView:e,readonly:s.readonly,box:s,pages:i,pageScrollTop:(o=t.getAttributes())==null?void 0:o.pageScrollTop,mountWhiteboard:t.mountView.bind(t),onUserScroll:a=>{var c;((c=t.getAttributes())==null?void 0:c.pageScrollTop)!==a&&!s.readonly&&t.updateAttributes(["pageScrollTop"],a)}}).mount();t.emitter.on("attributesUpdate",a=>{a&&a.pageScrollTop!=null&&r.syncPageScrollTop(a.pageScrollTop)}),s.events.on("readonly",a=>{r.setReadonly(a)})}function Ss(t,e,s,i){e.disableCameraTransform=!0;const r=t.getDisplayer(),o=new ws({displayer:r,whiteboardView:e,getRoom:()=>t.getIsWritable()?t.getDisplayer():void 0,readonly:s.readonly,box:s,pages:i,mountWhiteboard:t.mountView.bind(t)}).mount();t.mountView(o.$whiteboardView),t.isAddApp&&e.callbacks.once("onSizeUpdated",({width:a,height:c})=>{if(i.length>0&&s.state!=="maximized"){const{width:n,height:h}=i[0],l=h/n*a-c;l!==0&&t.getIsWritable()&&t.emitter.emit("setBoxSize",{width:s.width,height:s.height+l/s.containerRect.height})}}),t.emitter.on("sceneStateChange",a=>{o.jumpToPage(a.index)}),s.events.on("readonly",a=>{o.setReadonly(a)})}exports.default=bs;
//# sourceMappingURL=main.cjs.js.map

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

var ns=Object.defineProperty,cs=Object.defineProperties;var ls=Object.getOwnPropertyDescriptors;var Le=Object.getOwnPropertySymbols;var ds=Object.prototype.hasOwnProperty,hs=Object.prototype.propertyIsEnumerable;var Pe=(p,u,d)=>u in p?ns(p,u,{enumerable:!0,configurable:!0,writable:!0,value:d}):p[u]=d,Ae=(p,u)=>{for(var d in u||(u={}))ds.call(u,d)&&Pe(p,d,u[d]);if(Le)for(var d of Le(u))hs.call(u,d)&&Pe(p,d,u[d]);return p},Ve=(p,u)=>cs(p,ls(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:1.5em;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-pages{overflow:hidden;position:relative;height:100%;user-select:none}.netless-app-docs-viewer-static-pages:hover .netless-app-docs-viewer-static-scrollbar{opacity:1}.netless-app-docs-viewer-static-page{display:block;width:100%;height:auto;user-select:none}.netless-app-docs-viewer-static-wb-view{position:absolute;top:0;left:0;width:100%;height:100%;z-index:100;overflow:hidden}.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,.1);opacity:0;transition:background .4s,opacity .4s,transform .2s;will-change:transform,height;user-select:none}.netless-app-docs-viewer-static-scrollbar.netless-app-docs-viewer-static-scrollbar-dragging{background:rgba(68,78,96,.2);opacity:1;transition:background .4s,opacity .4s}.netless-app-docs-viewer-static-scrollbar:hover,.netless-app-docs-viewer-static-scrollbar:focus{background:rgba(68,78,96,.2)}.netless-app-docs-viewer-static-scrollbar:active{background:rgba(68,78,96,.2)}.netless-app-docs-viewer-content:hover .netless-app-docs-viewer-static-scrollbar{opacity:1}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-static-scrollbar{display:none}.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 d=typeof window!="undefined",J=d&&!("onscroll"in window)||typeof navigator!="undefined"&&/(gle|ing|ro)bot|crawl|spider/i.test(navigator.userAgent),K=d&&"IntersectionObserver"in window,Z=d&&"classList"in document.createElement("p"),Q=d&&window.devicePixelRatio>1,ze={elements_selector:".lazy",container:J||d?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},ee=e=>Object.assign({},ze,e),te=function(e,t){let s;const i="LazyLoad::Initialized",o=new e(t);try{s=new CustomEvent(i,{detail:{instance:o}})}catch{s=document.createEvent("CustomEvent"),s.initCustomEvent(i,!1,!1,{instance:o})}window.dispatchEvent(s)},Oe=(e,t)=>{if(!!t)if(!t.length)te(e,t);else for(let s=0,i;i=t[s];s+=1)te(e,i)},b="src",O="srcset",M="sizes",se="poster",N="llOriginalAttrs",D="loading",ie="loaded",oe="applied",Me="entered",H="error",re="native",ae="data-",ne="ll-status",g=(e,t)=>e.getAttribute(ae+t),De=(e,t,s)=>{var i=ae+t;if(s===null){e.removeAttribute(i);return}e.setAttribute(i,s)},$=e=>g(e,ne),v=(e,t)=>De(e,ne,t),k=e=>v(e,null),R=e=>$(e)===null,He=e=>$(e)===D,Re=e=>$(e)===H,B=e=>$(e)===re,Be=[D,ie,oe,H],Fe=e=>Be.indexOf($(e))>=0,m=(e,t,s,i)=>{if(!!e){if(i!==void 0){e(t,s,i);return}if(s!==void 0){e(t,s);return}e(t)}},y=(e,t)=>{if(Z){e.classList.add(t);return}e.className+=(e.className?" ":"")+t},f=(e,t)=>{if(Z){e.classList.remove(t);return}e.className=e.className.replace(new RegExp("(^|\\s+)"+t+"(\\s+|$)")," ").replace(/^\s+/,"").replace(/\s+$/,"")},We=e=>{e.llTempImage=document.createElement("IMG")},Ue=e=>{delete e.llTempImage},ce=e=>e.llTempImage,I=(e,t)=>{if(!t)return;const s=t._observer;!s||s.unobserve(e)},je=e=>{e.disconnect()},Ge=(e,t,s)=>{t.unobserve_entered&&I(e,s)},F=(e,t)=>{!e||(e.loadingCount+=t)},Ye=e=>{!e||(e.toLoadCount-=1)},le=(e,t)=>{!e||(e.toLoadCount=t)},qe=e=>e.loadingCount>0,Xe=e=>e.toLoadCount>0,de=e=>{let t=[];for(let s=0,i;i=e.children[s];s+=1)i.tagName==="SOURCE"&&t.push(i);return t},W=(e,t)=>{const s=e.parentNode;if(!s||s.tagName!=="PICTURE")return;de(s).forEach(t)},he=(e,t)=>{de(e).forEach(t)},L=[b],pe=[b,se],P=[b,O,M],A=e=>!!e[N],ue=e=>e[N],ge=e=>delete e[N],x=(e,t)=>{if(A(e))return;const s={};t.forEach(i=>{s[i]=e.getAttribute(i)}),e[N]=s},Je=e=>{A(e)||(e[N]={backgroundImage:e.style.backgroundImage})},Ke=(e,t,s)=>{if(!s){e.removeAttribute(t);return}e.setAttribute(t,s)},T=(e,t)=>{if(!A(e))return;const s=ue(e);t.forEach(i=>{Ke(e,i,s[i])})},Ze=e=>{if(!A(e))return;const t=ue(e);e.style.backgroundImage=t.backgroundImage},Qe=(e,t,s)=>{y(e,t.class_applied),v(e,oe),!!s&&(t.unobserve_completed&&I(e,t),m(t.callback_applied,e,s))},we=(e,t,s)=>{y(e,t.class_loading),v(e,D),!!s&&(F(s,1),m(t.callback_loading,e,s))},S=(e,t,s)=>{!s||e.setAttribute(t,s)},fe=(e,t)=>{S(e,M,g(e,t.data_sizes)),S(e,O,g(e,t.data_srcset)),S(e,b,g(e,t.data_src))},et=(e,t)=>{W(e,s=>{x(s,P),fe(s,t)}),x(e,P),fe(e,t)},tt=(e,t)=>{x(e,L),S(e,b,g(e,t.data_src))},st=(e,t)=>{he(e,s=>{x(s,L),S(s,b,g(s,t.data_src))}),x(e,pe),S(e,se,g(e,t.data_poster)),S(e,b,g(e,t.data_src)),e.load()},it=(e,t,s)=>{const i=g(e,t.data_bg),o=g(e,t.data_bg_hidpi),r=Q&&o?o:i;!r||(e.style.backgroundImage=`url("${r}")`,ce(e).setAttribute(b,r),we(e,t,s))},ot=(e,t,s)=>{const i=g(e,t.data_bg_multi),o=g(e,t.data_bg_multi_hidpi),r=Q&&o?o:i;!r||(e.style.backgroundImage=r,Qe(e,t,s))},be={IMG:et,IFRAME:tt,VIDEO:st},rt=(e,t)=>{const s=be[e.tagName];!s||s(e,t)},at=(e,t,s)=>{const i=be[e.tagName];!i||(i(e,t),we(e,t,s))},nt=["IMG","IFRAME","VIDEO"],ct=e=>nt.indexOf(e.tagName)>-1,me=(e,t)=>{t&&!qe(t)&&!Xe(t)&&m(e.callback_finish,t)},ve=(e,t,s)=>{e.addEventListener(t,s),e.llEvLisnrs[t]=s},lt=(e,t,s)=>{e.removeEventListener(t,s)},U=e=>!!e.llEvLisnrs,dt=(e,t,s)=>{U(e)||(e.llEvLisnrs={});const i=e.tagName==="VIDEO"?"loadeddata":"load";ve(e,i,t),ve(e,"error",s)},j=e=>{if(!U(e))return;const t=e.llEvLisnrs;for(let s in t){const i=t[s];lt(e,s,i)}delete e.llEvLisnrs},Se=(e,t,s)=>{Ue(e),F(s,-1),Ye(s),f(e,t.class_loading),t.unobserve_completed&&I(e,s)},ht=(e,t,s,i)=>{const o=B(t);Se(t,s,i),y(t,s.class_loaded),v(t,ie),m(s.callback_loaded,t,i),o||me(s,i)},pt=(e,t,s,i)=>{const o=B(t);Se(t,s,i),y(t,s.class_error),v(t,H),m(s.callback_error,t,i),o||me(s,i)},G=(e,t,s)=>{const i=ce(e)||e;if(U(i))return;dt(i,n=>{ht(n,e,t,s),j(i)},n=>{pt(n,e,t,s),j(i)})},ut=(e,t,s)=>{We(e),G(e,t,s),Je(e),it(e,t,s),ot(e,t,s)},gt=(e,t,s)=>{G(e,t,s),at(e,t,s)},Y=(e,t,s)=>{ct(e)?gt(e,t,s):ut(e,t,s)},wt=(e,t,s)=>{e.setAttribute("loading","lazy"),G(e,t,s),rt(e,t),v(e,re)},ye=e=>{e.removeAttribute(b),e.removeAttribute(O),e.removeAttribute(M)},ft=e=>{W(e,t=>{ye(t)}),ye(e)},Ee=e=>{W(e,t=>{T(t,P)}),T(e,P)},bt={IMG:Ee,IFRAME:e=>{T(e,L)},VIDEO:e=>{he(e,t=>{T(t,L)}),T(e,pe),e.load()}},mt=e=>{const t=bt[e.tagName];if(!t){Ze(e);return}t(e)},vt=(e,t)=>{R(e)||B(e)||(f(e,t.class_entered),f(e,t.class_exited),f(e,t.class_applied),f(e,t.class_loading),f(e,t.class_loaded),f(e,t.class_error))},St=(e,t)=>{mt(e),vt(e,t),k(e),ge(e)},yt=(e,t,s,i)=>{!s.cancel_on_exit||!He(e)||e.tagName==="IMG"&&(j(e),ft(e),Ee(e),f(e,s.class_loading),F(i,-1),k(e),m(s.callback_cancel,e,t,i))},Et=(e,t,s,i)=>{const o=Fe(e);v(e,Me),y(e,s.class_entered),f(e,s.class_exited),Ge(e,s,i),m(s.callback_enter,e,t,i),!o&&Y(e,s,i)},Nt=(e,t,s,i)=>{R(e)||(y(e,s.class_exited),yt(e,t,s,i),m(s.callback_exit,e,t,i))},$t=["IMG","IFRAME","VIDEO"],Ne=e=>e.use_native&&"loading"in HTMLImageElement.prototype,xt=(e,t,s)=>{e.forEach(i=>{$t.indexOf(i.tagName)!==-1&&wt(i,t,s)}),le(s,0)},Tt=e=>e.isIntersecting||e.intersectionRatio>0,Ct=e=>({root:e.container===document?null:e.container,rootMargin:e.thresholds||e.threshold+"px"}),_t=(e,t,s)=>{e.forEach(i=>Tt(i)?Et(i.target,i,t,s):Nt(i.target,i,t,s))},kt=(e,t)=>{t.forEach(s=>{e.observe(s)})},It=(e,t)=>{je(e),kt(e,t)},Lt=(e,t)=>{!K||Ne(e)||(t._observer=new IntersectionObserver(s=>{_t(s,e,t)},Ct(e)))},$e=e=>Array.prototype.slice.call(e),V=e=>e.container.querySelectorAll(e.elements_selector),Pt=e=>$e(e).filter(R),At=e=>Re(e),Vt=e=>$e(e).filter(At),xe=(e,t)=>Pt(e||V(t)),zt=(e,t)=>{Vt(V(e)).forEach(i=>{f(i,e.class_error),k(i)}),t.update()},Ot=(e,t)=>{!d||window.addEventListener("online",()=>{zt(e,t)})},E=function(e,t){const s=ee(e);this._settings=s,this.loadingCount=0,Lt(s,this),Ot(s,this),this.update(t)};E.prototype={update:function(e){const t=this._settings,s=xe(e,t);if(le(this,s.length),J||!K){this.loadAll(s);return}if(Ne(t)){xt(s,t,this);return}It(this._observer,s)},destroy:function(){this._observer&&this._observer.disconnect(),V(this._settings).forEach(e=>{ge(e)}),delete this._observer,delete this._settings,delete this.loadingCount,delete this.toLoadCount},loadAll:function(e){const t=this._settings;xe(e,t).forEach(i=>{I(i,this),Y(i,t,this)})},restoreAll:function(){const e=this._settings;V(e).forEach(t=>{St(t,e)})}},E.load=(e,t)=>{const s=ee(t);Y(e,s)},E.resetStatus=e=>{k(e)},d&&Oe(E,window.lazyLoadOptions);const Mt=(e,t,s,i)=>{if(s==="length"||s==="prototype"||s==="arguments"||s==="caller")return;const o=Object.getOwnPropertyDescriptor(e,s),r=Object.getOwnPropertyDescriptor(t,s);!Dt(o,r)&&i||Object.defineProperty(e,s,r)},Dt=function(e,t){return e===void 0||e.configurable||e.writable===t.writable&&e.enumerable===t.enumerable&&e.configurable===t.configurable&&(e.writable||e.value===t.value)},Ht=(e,t)=>{const s=Object.getPrototypeOf(t);s!==Object.getPrototypeOf(e)&&Object.setPrototypeOf(e,s)},Rt=(e,t)=>`/* Wrapped ${e}*/
${t}`,Bt=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),Ft=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),Wt=(e,t,s)=>{const i=s===""?"":`with ${s.trim()}() `,o=Rt.bind(null,i,t.toString());Object.defineProperty(o,"name",Ft),Object.defineProperty(e,"toString",Ve(Ae({},Bt),{value:o}))};var Ut=(e,t,{ignoreNonConfigurable:s=!1}={})=>{const{name:i}=e;for(const o of Reflect.ownKeys(t))Mt(e,t,o,s);return Ht(e,t),Wt(e,t,i),e};const jt=(e,t={})=>{if(typeof e!="function")throw new TypeError(`Expected the first argument to be a function, got \`${typeof e}\``);const{wait:s=0,maxWait:i=Number.Infinity,before:o=!1,after:r=!0}=t;if(!o&&!r)throw new Error("Both `before` and `after` are false, function wouldn't be called.");let n,c,a;const l=function(...h){const w=this,os=()=>{n=void 0,c&&(clearTimeout(c),c=void 0),r&&(a=e.apply(w,h))},rs=()=>{c=void 0,n&&(clearTimeout(n),n=void 0),r&&(a=e.apply(w,h))},as=o&&!n;return clearTimeout(n),n=setTimeout(os,s),i>0&&i!==Number.Infinity&&!c&&(c=setTimeout(rs,i)),as&&(a=e.apply(w,h)),a};return Ut(l,e),l.cancel=()=>{n&&(clearTimeout(n),n=void 0),c&&(clearTimeout(c),c=void 0)},l},Te="!#%()*+,-./:;=?@[]^_`{|}~ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",Gt=Te.length,Ce=Array(20),C=()=>{for(let e=0;e<20;e++)Ce[e]=Te.charAt(Math.random()*Gt);return Ce.join("")};class q{constructor(){this.disposers=new Map}add(t,s=C()){return this.flush(s),this.disposers.set(s,t()),s}addDisposer(t,s=C()){return this.flush(s),this.disposers.set(s,t),s}addEventListener(t,s,i,o,r=C()){return this.add(()=>(t.addEventListener(s,i,o),()=>t.removeEventListener(s,i,o)),r),r}setTimeout(t,s,i=C()){return this.add(()=>{const o=window.setTimeout(()=>{this.remove(i),t()},s);return()=>window.clearTimeout(o)},i)}setInterval(t,s,i=C()){return this.add(()=>{const o=window.setInterval(t,s);return()=>window.clearInterval(o)},i)}remove(t){const s=this.disposers.get(t);return this.disposers.delete(t),s}flush(t){const s=this.remove(t);if(s)try{s()}catch(i){console.error(i)}}flushAll(){this.disposers.forEach(t=>{try{t()}catch(s){console.error(s)}}),this.disposers.clear()}}function Yt(e){const t="http://www.w3.org/2000/svg",s=document.createElementNS(t,"svg");s.setAttribute("class",`${e}-footer-icon-sidebar`),s.setAttribute("viewBox","0 0 64 64");const i=document.createElementNS(t,"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 qt(e){const t="http://www.w3.org/2000/svg",s=document.createElementNS(t,"svg");s.setAttribute("class",`${e}-footer-icon-arrow-left`),s.setAttribute("viewBox","0 0 500 500");const i=document.createElementNS(t,"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 Xt(e){const t="http://www.w3.org/2000/svg",s=document.createElementNS(t,"svg");s.setAttribute("class",`${e}-footer-icon-arrow-right`),s.setAttribute("viewBox","0 0 500 500");const i=document.createElementNS(t,"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 Jt(e){const t="http://www.w3.org/2000/svg",s=document.createElementNS(t,"svg");s.setAttribute("class",`${e}-footer-icon-play`),s.setAttribute("viewBox","0 0 500 500");const i=document.createElementNS(t,"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 Kt(e){const t="http://www.w3.org/2000/svg",s=document.createElementNS(t,"svg");s.setAttribute("class",`${e}-footer-icon-pause`),s.setAttribute("viewBox","0 0 500 500");const i=document.createElementNS(t,"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}class _e{constructor({readonly:t,box:s,pages:i,onNewPageIndex:o,onPlay:r}){if(this.pageIndex=0,this.namespace="netless-app-docs-viewer",this.isShowPreview=!1,this.isSmallBox=!1,this.sideEffect=new q,i.length<=0)throw new Error("[DocsViewer] Empty pages.");this.readonly=t,this.box=s,this.pages=i,this.onNewPageIndex=o,this.onPlay=r,this.render()}mount(){this.box.mountContent(this.$content),this.box.mountFooter(this.$footer),this.sideEffect.add(()=>{const t=new E({container:this.$preview,elements_selector:`.${this.wrapClassName("preview-page>img")}`});return()=>t.destroy()},"preview-lazyload")}unmount(){this.$content.remove(),this.$footer.remove()}setReadonly(t){this.readonly!==t&&(this.readonly=t,this.$content.classList.toggle(this.wrapClassName("readonly"),t),this.$footer.classList.toggle(this.wrapClassName("readonly"),t),this.$pageNumberInput.disabled=t)}destroy(){this.sideEffect.flushAll(),this.unmount()}setPageIndex(t){Number.isNaN(t)||(this.pageIndex=t,this.$pageNumberInput.value=String(t+1))}setSmallBox(t){this.isSmallBox!==t&&(this.isSmallBox=t,this.$footer.classList.toggle(this.wrapClassName("float-footer"),t))}render(){return this.renderContent(),this.renderFooter(),this.$content}renderContent(){if(!this.$content){const t=document.createElement("div");t.className=this.wrapClassName("content"),this.$content=t,this.readonly&&t.classList.add(this.wrapClassName("readonly")),t.appendChild(this.renderPreviewMask()),t.appendChild(this.renderPreview())}return this.$content}renderPreview(){if(!this.$preview){const t=document.createElement("div");t.className=this.wrapClassName("preview")+" tele-fancy-scrollbar",this.$preview=t;const s=this.wrapClassName("preview-page"),i=this.wrapClassName("preview-page-name");this.pages.forEach((o,r)=>{var w;const n=(w=o.thumbnail)!=null?w:o.src.startsWith("ppt")?void 0:o.src;if(!n)return;const c=String(r),a=document.createElement("a");a.className=s+" "+this.wrapClassName(`preview-page-${r}`),a.setAttribute("href","#"),a.dataset.pageIndex=c;const l=document.createElement("span");l.className=i,l.textContent=String(r+1),l.dataset.pageIndex=c;const h=document.createElement("img");h.width=o.width,h.height=o.height,h.dataset.src=n,h.dataset.pageIndex=c,a.appendChild(h),a.appendChild(l),t.appendChild(a)}),this.sideEffect.addEventListener(t,"click",o=>{var n;if(this.readonly)return;const r=(n=o.target.dataset)==null?void 0:n.pageIndex;r&&(o.preventDefault(),o.stopPropagation(),o.stopImmediatePropagation(),this.onNewPageIndex(Number(r)),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",t=>{this.readonly||t.target===this.$previewMask&&this.togglePreview(!1)})),this.$previewMask}renderFooter(){if(!this.$footer){const t=document.createElement("div");if(t.className=this.wrapClassName("footer"),this.$footer=t,this.readonly&&t.classList.add(this.wrapClassName("readonly")),this.isSmallBox&&t.classList.add(this.wrapClassName("float-footer")),this.pages.some(a=>a.thumbnail||!a.src.startsWith("ppt"))){const a=this.renderFooterBtn("btn-sidebar",Yt(this.namespace));this.sideEffect.addEventListener(a,"click",()=>{this.readonly||this.togglePreview()}),this.$footer.appendChild(a)}const s=document.createElement("div");s.className=this.wrapClassName("page-jumps");const i=this.renderFooterBtn("btn-page-back",qt(this.namespace));if(this.sideEffect.addEventListener(i,"click",()=>{this.readonly||this.onNewPageIndex(this.pageIndex-1)}),s.appendChild(i),this.onPlay){const a=this.renderFooterBtn("btn-page-play",Jt(this.namespace),Kt(this.namespace)),l=()=>{this.sideEffect.setTimeout(()=>{a.classList.toggle(this.wrapClassName("footer-btn-playing"),!1)},500,"returnPlay")};this.sideEffect.addEventListener(a,"click",()=>{this.readonly||(a.classList.toggle(this.wrapClassName("footer-btn-playing"),!0),this.onPlay&&this.onPlay(),l())}),s.appendChild(a)}const o=this.renderFooterBtn("btn-page-next",Xt(this.namespace));this.sideEffect.addEventListener(o,"click",()=>{this.readonly||this.onNewPageIndex(this.pageIndex+1)}),s.appendChild(o);const r=document.createElement("div");r.className=this.wrapClassName("page-number");const n=document.createElement("input");n.className=this.wrapClassName("page-number-input"),n.value=String(this.pageIndex+1),this.readonly&&(n.disabled=!0),this.$pageNumberInput=n,this.sideEffect.addEventListener(n,"change",()=>{this.readonly||n.value&&this.onNewPageIndex(Number(n.value)-1)});const c=document.createElement("span");c.textContent=" / "+this.pages.length,r.appendChild(n),r.appendChild(c),this.$footer.appendChild(s),this.$footer.appendChild(r)}return this.$footer}renderFooterBtn(t,s,i){const o=document.createElement("button");return o.className=this.wrapClassName("footer-btn")+" "+this.wrapClassName(t),o.appendChild(s),i&&o.appendChild(i),o}togglePreview(t){if(this.isShowPreview=t!=null?t:!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(t){return`${this.namespace}-${t}`}}function z(e,t,s){return Math.min(Math.max(e,t),s)}function ke(e){return e.touches?e.touches[0]:e}function Ie(e){e.stopPropagation(),e.cancelable&&e.preventDefault()}class Zt{constructor(t){var s,i,o;this.velocity=0,this.paused=!0,this._animationFrameID=null,this._loopTimestamp=0,this.looper=r=>{if(this.paused)return;let n=Math.floor((r-this._loopTimestamp)/1e3*60)+1;for(this._loopTimestamp=r;n-- >0;)this.stepper();this.onStep(this.current,this),!this.paused&&this.current!==this.target&&window.requestAnimationFrame(this.looper)},this.current=(s=t.start)!=null?s:0,this.target=this.current,this.stiffness=(i=t.stiffness)!=null?i:170,this.damping=(o=t.damping)!=null?o:26,this.onStep=t.onStep}stepTo(t){this.paused=!1,this.target=t,this.onStep(this.current,this),this._loopTimestamp=Date.now(),window.requestAnimationFrame(this.looper)}pause(){this.paused=!0}destroy(){this.pause()}stepper(){const t=-this.stiffness*(this.current-this.target),s=-this.damping*this.velocity,i=this.velocity+(t+s)/60,o=this.current+i/60;Math.abs(i-0)<.01&&Math.abs(o-this.target)<.01?(this.current=this.target,this.velocity=0):(this.current=o,this.velocity=i)}}const X=30,_=640;class Qt{constructor({whiteboardView:t,readonly:s,box:i,pages:o,pagesSize:r,pageScrollTop:n=0,mountWhiteboard:c,onUserScroll:a}){this.sideEffect=new q,this.userScrolling=!1,this.scrollbarHeight=X,this.onNewPageIndex=h=>{this.scrollToPage(h)},this.whiteboardView=t,this.readonly=s,this.box=i,this.pages=o,this.pageScrollTop=n,this.pagesSize=r,this.mountWhiteboard=c,this.onUserScroll=a,this.pageScrollStepper=new Zt({onStep:h=>{this.pageScrollTo(h)}});const l=this.debounce(()=>{this.userScrolling=!1,this.onUserScroll&&this.onUserScroll(this.pageScrollTop)},{wait:80},"debounce-updateUserScroll");this.updateUserScroll=()=>{this.userScrolling=!0,l()},this.viewer=new _e({readonly:s,box:i,pages:o,onNewPageIndex:this.onNewPageIndex}),this.render()}mount(){return this.viewer.mount(),this.sideEffect.add(()=>{const t=new E({container:this.$pages,elements_selector:`.${this.wrapClassName("page")}`});return()=>t.destroy()},"page-lazyload"),this.setupWhiteboardCamera(),this.sideEffect.setTimeout(()=>{this.pageScrollTop!==0&&this.pageScrollTo(this.pageScrollTop)},1e3),this.setupScrollTopEvent(),this.sideEffect.add(()=>{const t=this.renderRatioHeight.bind(this);return this.box.events.on("visual_resize",t),()=>this.box.events.off("visual_resize",t)}),this}unmount(){return this.viewer.unmount(),this}setReadonly(t){this.readonly!==t&&(this.readonly=t,this.viewer.setReadonly(t))}destroy(){this.sideEffect.flushAll(),this.pageScrollStepper.destroy(),this.onUserScroll=void 0,this.unmount(),this.viewer.destroy()}syncPageScrollTop(t){!this.userScrolling&&t>=0&&Math.abs(this.pageScrollTop-t)>10&&this.pageScrollStepper.stepTo(t)}render(){this.viewer.$content.appendChild(this.renderPages()),this.viewer.$content.appendChild(this.renderWhiteboardView()),this.viewer.$content.appendChild(this.renderScrollbar()),this.renderRatioHeight()}renderRatioHeight(){const t=this.box.absoluteHeight,s=t<=_;if(this.viewer.setSmallBox(s),s){const i=26/_,o=26/t,r=26/_,n=0,c=Math.max((i+r-(o+n))/2,0);if(this.box.$titleBar){const a=o+c;this.box.$titleBar.style.height=`${a*100}%`}if(this.box.$footer){const a=n+c;this.box.$footer.style.height=`${a*100}%`}}else{if(this.box.$titleBar){const i=Math.max(26/_,26/t);this.box.$titleBar.style.height=`${i*100}%`}if(this.box.$footer){const i=Math.max(26/_,26/t);this.box.$footer.style.height=`${i*100}%`}}}renderPages(){if(!this.$pages){const t=document.createElement("div");t.className=this.wrapClassName("pages"),this.$pages=t;const s=this.wrapClassName("page");this.pages.forEach((i,o)=>{const r=document.createElement("img");r.className=s+" "+this.wrapClassName(`page-${o}`),r.draggable=!1,r.width=i.width,r.height=i.height,r.dataset.src=i.src,r.dataset.pageIndex=String(o),t.appendChild(r)})}return this.$pages}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",t=>{Ie(t),this.readonly||(this.pageScrollTo(this.pageScrollTop+t.deltaY),this.updateUserScroll())},{passive:!1,capture:!0}),this.sideEffect.addEventListener(this.$whiteboardView,"touchmove",t=>{this.readonly||t.touches.length<=1||this.updateUserScroll()},{passive:!0,capture:!0})),this.$whiteboardView}renderScrollbar(){if(!this.$scrollbar){const t=document.createElement("button");this.$scrollbar=t,t.className=this.wrapClassName("scrollbar"),t.style.minHeight=`${X}px`;const s=i=>{if(this.readonly||i.button!=null&&i.button!==0)return;Ie(i),this.$scrollbar.classList.toggle(this.wrapClassName("scrollbar-dragging"),!0);const o=this.scrollTopPageToEl(this.pageScrollTop),r=this.whiteboardView.size.width/this.pagesSize.width*this.pagesSize.height,{clientY:n}=ke(i),c=l=>{const{clientY:h}=ke(l),{height:w}=this.whiteboardView.size;this.elScrollTo(o+(h-n)*(r/w)),this.updateUserScroll()},a=()=>{this.$scrollbar.classList.toggle(this.wrapClassName("scrollbar-dragging"),!1),window.removeEventListener("mousemove",c,!0),window.removeEventListener("touchmove",c,!0),window.removeEventListener("mouseup",a,!0),window.removeEventListener("touchend",a,!0),window.removeEventListener("touchcancel",a,!0)};window.addEventListener("mousemove",c,!0),window.addEventListener("touchmove",c,!0),window.addEventListener("mouseup",a,!0),window.addEventListener("touchend",a,!0),window.addEventListener("touchcancel",a,!0)};this.sideEffect.addEventListener(t,"mousedown",s),this.sideEffect.addEventListener(t,"touchstart",s)}return this.$scrollbar}scrollTopPageToEl(t){return t*(this.whiteboardView.size.width/this.pagesSize.width)}scrollTopElToPage(t){return t/(this.whiteboardView.size.width/this.pagesSize.width)}elScrollTo(t){this.pageScrollTo(this.scrollTopElToPage(t))}pageScrollTo(t){const s=this.scrollTopElToPage(this.whiteboardView.size.height/2);this.whiteboardView.moveCamera({centerY:z(t+s,s,this.pagesSize.height-s),animationMode:"immediately"})}scrollToPage(t){if(!this.readonly&&this.$pages&&!Number.isNaN(t)){t=z(t,0,this.pages.length-1);const s=this.$pages.querySelector("."+this.wrapClassName(`page-${t}`));if(s){const i=s.offsetTop+5;this.elScrollTo(i),this.updateUserScroll()}}}setupScrollTopEvent(){const t=this.debounce(()=>{if(this.pages.length>0&&this.$pages&&this.$pages.getBoundingClientRect().width>0){let i=0;for(let o=0;o<this.pages.length;o+=1)if(i+=this.pages[o].height,this.pageScrollTop<=i){this.viewer.setPageIndex(o);return}this.viewer.setPageIndex(this.pages.length-1)}},{wait:5,maxWait:100},"debounce-updatePageIndex");this.sideEffect.add(()=>{const s=i=>{const{width:o,height:r}=this.whiteboardView.size,{width:n,height:c}=this.pagesSize,a=o/n*c,l=this.scrollTopPageToEl(i.centerY)-r/2,h=this.scrollTopElToPage(l);this.pageScrollTop=h,this.$pages.scrollTo({top:l}),this.setScrollbarHeight(r/a*r),this.$scrollbar.style.transform=`translateY(${l/(a-r)*(r-this.scrollbarHeight)}px)`,t()};return this.whiteboardView.callbacks.on("onCameraUpdated",s),()=>this.whiteboardView.callbacks.off("onCameraUpdated",s)})}setupWhiteboardCamera(){this.sideEffect.add(()=>{const t=({width:s,height:i})=>{if(s>0&&i>0){const o=this.$pages.scrollTop,r=this.pagesSize.width,n=r/s;this.whiteboardView.moveCameraToContain({originX:0,originY:o*n,width:r,height:i*n,animationMode:"immediately"}),this.whiteboardView.setCameraBound({damping:1,maxContentMode:()=>s/r,minContentMode:()=>s/r,centerX:this.pagesSize.width/2,centerY:this.pagesSize.height/2,width:this.pagesSize.width,height:this.pagesSize.height}),this.elScrollTo(o)}};return this.whiteboardView.callbacks.on("onSizeUpdated",t),()=>{this.whiteboardView.callbacks.off("onSizeUpdated",t)}},"whiteboard-size-update")}debounce(t,s,i){const o=jt(t,s);return this.sideEffect.addDisposer(()=>o.cancel(),i),o}wrapClassName(t){return"netless-app-docs-viewer-static-"+t}setScrollbarHeight(t){t=z(t,X,this.whiteboardView.size.height),this.scrollbarHeight!==t&&(this.scrollbarHeight=t,this.$scrollbar.style.height=`${t}px`)}}class es{constructor({displayer:t,whiteboardView:s,getRoom:i,readonly:o,box:r,pages:n,mountWhiteboard:c}){this.sideEffect=new q,this.onPlayPPT=()=>{const a=this.getWhiteboardRoom();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.whiteboardView=s,this.readonly=o,this.box=r,this.pages=n,this.displayer=t,this.getWhiteboardRoom=i,this.mountWhiteboard=c,this.viewer=new _e({readonly:o,box:r,pages:n,onNewPageIndex:this.onNewPageIndex,onPlay:this.onPlayPPT}),this.render()}mount(){this.viewer.mount();const t=this.getPageIndex();return t!==0&&this.jumpToPage(t),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}setReadonly(t){this.readonly!==t&&(this.readonly=t,this.viewer.setReadonly(t))}destroy(){this.sideEffect.flushAll(),this.unmount(),this.viewer.destroy()}getPageIndex(){return this.displayer.state.sceneState.index}jumpToPage(t,s){if(t=z(t,0,this.pages.length-1),t!==this.getPageIndex()){const i=this.getWhiteboardRoom();i&&(i.setSceneIndex(t),this.scaleDocsToFit())}if(t!==this.viewer.pageIndex&&this.viewer.setPageIndex(t),s){const i=this.getWhiteboardRoom();i&&i.setGlobalState({__pptState:void 0})}}render(){this.viewer.$content.appendChild(this.renderMask()),this.viewer.$content.appendChild(this.renderWhiteboardView()),this.sideEffect.addEventListener(window,"keydown",t=>{var s;if(this.box.focus)switch(t.key){case"ArrowUp":case"ArrowLeft":{this.jumpToPage(this.getPageIndex()-1,!0);break}case"ArrowRight":case"ArrowDown":{(s=this.getWhiteboardRoom())==null||s.pptNextStep();break}}})}renderMask(){if(!this.$mask){const t=document.createElement("div");t.className=this.wrapClassName("mask"),this.$mask=t;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",t=>{var i;const s=this.getWhiteboardRoom();if(s&&s.state.memberState.currentApplianceName==="clicker"){for(let o=t.target;o;o=o.parentElement)if((i=o.classList)==null?void 0:i.contains("ppt-event-source"))return;s.pptNextStep()}}),this.mountWhiteboard(this.$whiteboardView)),this.$whiteboardView}wrapClassName(t){return"netless-app-docs-viewer-dynamic-"+t}}const ts={kind:"DocsViewer",setup(e){const t=e.getBox(),s=e.getScenes();if(!s)throw new Error("[Docs Viewer]: scenes not found.");const i=e.getView();if(!i)throw new Error("[Docs Viewer]: no whiteboard view.");const o=s.map(({ppt:r})=>r?{width:r.width,height:r.height,src:r.src,thumbnail:r.previewURL}:null).filter(r=>Boolean(r));if(o.length<=0)throw new Error("[Docs Viewer]: empty scenes.");t.mountStyles(u),o[0].src.startsWith("ppt")?is(e,i,t,o):ss(e,i,t,o)}};function ss(e,t,s,i){var n;const o={width:i[0].width,height:i.reduce((c,a)=>c+a.height*(i[0].width/a.width),0)},r=new Qt({whiteboardView:t,readonly:s.readonly,box:s,pages:i,pagesSize:o,pageScrollTop:(n=e.getAttributes())==null?void 0:n.pageScrollTop,mountWhiteboard:e.mountView.bind(e),onUserScroll:c=>{var a;((a=e.getAttributes())==null?void 0:a.pageScrollTop)!==c&&!s.readonly&&e.updateAttributes(["pageScrollTop"],c)}}).mount();e.emitter.on("attributesUpdate",c=>{c&&c.pageScrollTop!=null&&r.syncPageScrollTop(c.pageScrollTop)}),s.events.on("readonly",c=>{r.setReadonly(c)})}function is(e,t,s,i){t.disableCameraTransform=!0;const o=e.getDisplayer(),r=new es({displayer:o,whiteboardView:t,getRoom:()=>e.getIsWritable()?e.getDisplayer():void 0,readonly:s.readonly,box:s,pages:i,mountWhiteboard:e.mountView.bind(e)}).mount();e.mountView(r.$whiteboardView),e.isAddApp&&t.callbacks.once("onSizeUpdated",({width:n,height:c})=>{if(i.length>0&&s.state!=="maximized"){const{width:a,height:l}=i[0],w=l/a*n-c;w!==0&&e.getIsWritable()&&e.emitter.emit("setBoxSize",{width:s.width,height:s.height+w/s.containerRect.height})}}),e.emitter.on("sceneStateChange",n=>{r.jumpToPage(n.index)}),s.events.on("readonly",n=>{r.setReadonly(n)})}return p.default=ts,Object.defineProperty(p,"__esModule",{value:!0}),p[Symbol.toStringTag]="Module",p}({});
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-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),o=Object.getOwnPropertyDescriptor(e,s);!Re(r,o)&&i||Object.defineProperty(t,s,o)},Re=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)},Ve=(t,e)=>{const s=Object.getPrototypeOf(e);s!==Object.getPrototypeOf(t)&&Object.setPrototypeOf(t,s)},Me=(t,e)=>`/* Wrapped ${t}*/
${e}`,De=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),ze=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",ze),Object.defineProperty(t,"toString",K(J({},De),{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 Ve(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:o=!0}=e;if(!r&&!o)throw new Error("Both `before` and `after` are false, function wouldn't be called.");let a,c,n;const h=function(...d){const l=this,hs=()=>{a=void 0,c&&(clearTimeout(c),c=void 0),o&&(n=t.apply(l,d))},ds=()=>{c=void 0,a&&(clearTimeout(a),a=void 0),o&&(n=t.apply(l,d))},ps=r&&!a;return clearTimeout(a),a=setTimeout(hs,s),i>0&&i!==Number.Infinity&&!c&&(c=setTimeout(ds,i)),ps&&(n=t.apply(l,d)),n};return We(h,t),h.cancel=()=>{a&&(clearTimeout(a),a=void 0),c&&(clearTimeout(c),c=void 0)},h},Z="!#%()*+,-./:;=?@[]^_`{|}~ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",Be=Z.length,Q=Array(20),$=()=>{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=$()){return this.flush(s),this.disposers.set(s,e()),s}addDisposer(e,s=$()){return this.flush(s),this.disposers.set(s,e),s}addEventListener(e,s,i,r,o=$()){return this.add(()=>(e.addEventListener(s,i,r),()=>e.removeEventListener(s,i,r)),o),o}setTimeout(e,s,i=$()){return this.add(()=>{const r=window.setTimeout(()=>{this.remove(i),e()},s);return()=>window.clearTimeout(r)},i)}setInterval(e,s,i=$()){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),oe=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)oe(t,e);else for(let s=0,i;i=e[s];s+=1)oe(t,i)},m="src",D="srcset",z="sizes",ae="poster",T="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)},I=t=>f(t,de),S=(t,e)=>Ze(t,de,e),P=t=>S(t,null),F=t=>I(t)===null,Qe=t=>I(t)===O,et=t=>I(t)===W,B=t=>I(t)===le,tt=[O,ne,ce,W],st=t=>tt.indexOf(I(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)}},E=(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)},ot=t=>{t.disconnect()},at=(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,ae],R=[m,D,z],V=t=>!!t[T],me=t=>t[T],be=t=>delete t[T],C=(t,e)=>{if(V(t))return;const s={};e.forEach(i=>{s[i]=t.getAttribute(i)}),t[T]=s},ht=t=>{V(t)||(t[T]={backgroundImage:t.style.backgroundImage})},dt=(t,e,s)=>{if(!s){t.removeAttribute(e);return}t.setAttribute(e,s)},N=(t,e)=>{if(!V(t))return;const s=me(t);e.forEach(i=>{dt(t,i,s[i])})},pt=t=>{if(!V(t))return;const e=me(t);t.style.backgroundImage=e.backgroundImage},ut=(t,e,s)=>{E(t,e.class_applied),S(t,ce),!!s&&(e.unobserve_completed&&A(t,e),b(e.callback_applied,t,s))},ve=(t,e,s)=>{E(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,z,f(t,e.data_sizes)),y(t,D,f(t,e.data_srcset)),y(t,m,f(t,e.data_src))},gt=(t,e)=>{Y(t,s=>{C(s,R),Se(s,e)}),C(t,R),Se(t,e)},ft=(t,e)=>{C(t,H),y(t,m,f(t,e.data_src))},wt=(t,e)=>{fe(t,s=>{C(s,H),y(s,m,f(s,e.data_src))}),C(t,we),y(t,ae,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),o=ie&&r?r:i;!o||(t.style.backgroundImage=`url("${o}")`,pe(t).setAttribute(m,o),ve(t,e,s))},bt=(t,e,s)=>{const i=f(t,e.data_bg_multi),r=f(t,e.data_bg_multi_hidpi),o=ie&&r?r:i;!o||(t.style.backgroundImage=o,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"],Et=t=>yt.indexOf(t.tagName)>-1,Ee=(t,e)=>{e&&!ct(e)&&!lt(e)&&b(t.callback_finish,e)},xe=(t,e,s)=>{t.addEventListener(e,s),t.llEvLisnrs[e]=s},xt=(t,e,s)=>{t.removeEventListener(e,s)},j=t=>!!t.llEvLisnrs,$t=(t,e,s)=>{j(t)||(t.llEvLisnrs={});const i=t.tagName==="VIDEO"?"loadeddata":"load";xe(t,i,e),xe(t,"error",s)},G=t=>{if(!j(t))return;const e=t.llEvLisnrs;for(let s in e){const i=e[s];xt(t,s,i)}delete t.llEvLisnrs},$e=(t,e,s)=>{rt(t),U(s,-1),nt(s),w(t,e.class_loading),e.unobserve_completed&&A(t,s)},Tt=(t,e,s,i)=>{const r=B(e);$e(e,s,i),E(e,s.class_loaded),S(e,ne),b(s.callback_loaded,e,i),r||Ee(s,i)},It=(t,e,s,i)=>{const r=B(e);$e(e,s,i),E(e,s.class_error),S(e,W),b(s.callback_error,e,i),r||Ee(s,i)},q=(t,e,s)=>{const i=pe(t)||t;if(j(i))return;$t(i,a=>{Tt(a,t,e,s),G(i)},a=>{It(a,t,e,s),G(i)})},Ct=(t,e,s)=>{it(t),q(t,e,s),ht(t),mt(t,e,s),bt(t,e,s)},Nt=(t,e,s)=>{q(t,e,s),St(t,e,s)},X=(t,e,s)=>{Et(t)?Nt(t,e,s):Ct(t,e,s)},_t=(t,e,s)=>{t.setAttribute("loading","lazy"),q(t,e,s),vt(t,e),S(t,le)},Te=t=>{t.removeAttribute(m),t.removeAttribute(D),t.removeAttribute(z)},kt=t=>{Y(t,e=>{Te(e)}),Te(t)},Ie=t=>{Y(t,e=>{N(e,R)}),N(t,R)},Lt={IMG:Ie,IFRAME:t=>{N(t,H)},VIDEO:t=>{fe(t,e=>{N(e,H)}),N(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)},Rt=(t,e,s,i)=>{!s.cancel_on_exit||!Qe(t)||t.tagName==="IMG"&&(G(t),kt(t),Ie(t),w(t,s.class_loading),U(i,-1),P(t),b(s.callback_cancel,t,e,i))},Vt=(t,e,s,i)=>{const r=st(t);S(t,Ke),E(t,s.class_entered),w(t,s.class_exited),at(t,s,i),b(s.callback_enter,t,e,i),!r&&X(t,s,i)},Mt=(t,e,s,i)=>{F(t)||(E(t,s.class_exited),Rt(t,e,s,i),b(s.callback_exit,t,e,i))},Dt=["IMG","IFRAME","VIDEO"],Ce=t=>t.use_native&&"loading"in HTMLImageElement.prototype,zt=(t,e,s)=>{t.forEach(i=>{Dt.indexOf(i.tagName)!==-1&&_t(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)?Vt(i.target,i,e,s):Mt(i.target,i,e,s))},Bt=(t,e)=>{e.forEach(s=>{t.observe(s)})},Ut=(t,e)=>{ot(t),Bt(t,e)},Yt=(t,e)=>{!te||Ce(t)||(e._observer=new IntersectionObserver(s=>{Ft(s,t,e)},Wt(t)))},Ne=t=>Array.prototype.slice.call(t),M=t=>t.container.querySelectorAll(t.elements_selector),jt=t=>Ne(t).filter(F),Gt=t=>et(t),qt=t=>Ne(t).filter(Gt),_e=(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)})},_=function(t,e){const s=re(t);this._settings=s,this.loadingCount=0,Yt(s,this),Jt(s,this),this.update(e)};_.prototype={update:function(t){const e=this._settings,s=_e(t,e);if(ue(this,s.length),ee||!te){this.loadAll(s);return}if(Ce(e)){zt(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;_e(t,e).forEach(i=>{A(i,this),X(i,e,this)})},restoreAll:function(){const t=this._settings;M(t).forEach(e=>{Ht(e,t)})}},_.load=(t,e)=>{const s=re(e);X(t,s)},_.resetStatus=t=>{P(t)},v&&Je(_,window.lazyLoadOptions);class ke{constructor({readonly:e,box:s,pages:i,onNewPageIndex:r,onPlay:o}){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=o,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,o)=>{var l;const a=(l=r.thumbnail)!=null?l:r.src.startsWith("ppt")?void 0:r.src;if(!a)return;const c=String(o),n=document.createElement("a");n.className=s+" "+this.wrapClassName(`preview-page-${o}`),n.setAttribute("href","#"),n.dataset.pageIndex=c;const h=document.createElement("span");h.className=i,h.textContent=String(o+1),h.dataset.pageIndex=c;const d=document.createElement("img");d.width=r.width,d.height=r.height,d.dataset.src=a,d.dataset.pageIndex=c,n.appendChild(d),n.appendChild(h),e.appendChild(n)}),this.sideEffect.addEventListener(e,"click",r=>{var a;if(this.readonly)return;const o=(a=r.target.dataset)==null?void 0:a.pageIndex;o&&(r.preventDefault(),r.stopPropagation(),r.stopImmediatePropagation(),this.onNewPageIndex(Number(o)),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(n=>n.thumbnail||!n.src.startsWith("ppt"))){const n=this.renderFooterBtn("btn-sidebar",Ue(this.namespace));this.sideEffect.addEventListener(n,"click",()=>{this.readonly||this.togglePreview()}),this.$footer.appendChild(n)}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 n=this.renderFooterBtn("btn-page-play",Ge(this.namespace),qe(this.namespace)),h=()=>{this.sideEffect.setTimeout(()=>{n.classList.toggle(this.wrapClassName("footer-btn-playing"),!1)},500,"returnPlay")};this.sideEffect.addEventListener(n,"click",()=>{this.readonly||(n.classList.toggle(this.wrapClassName("footer-btn-playing"),!0),this.onPlay&&this.onPlay(),h())}),s.appendChild(n)}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 o=document.createElement("div");o.className=this.wrapClassName("page-number");const a=document.createElement("input");a.className=this.wrapClassName("page-number-input"),a.value=String(this.pageIndex+1),this.readonly&&(a.disabled=!0),this.$pageNumberInput=a,this.sideEffect.addEventListener(a,"focus",()=>{a.select()}),this.sideEffect.addEventListener(a,"change",()=>{this.readonly||a.value&&this.onNewPageIndex(Number(a.value)-1)});const c=document.createElement("span");c.textContent=" / "+this.pages.length,o.appendChild(a),o.appendChild(c),this.$footer.appendChild(s),this.$footer.appendChild(o)}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 x(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=o=>{if(this.paused)return;let a=Math.floor((o-this._loopTimestamp)/1e3*60)+1;for(this._loopTimestamp=o;a-- >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)}}var ys="";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 o=document.createElement("img");o.className="page-renderer-page-img",o.width=s.width,o.height=s.height,o.src=s.src,r.appendChild(o),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,o)=>o.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.pagesScrollTop=e.pagesScrollTop||0,this.containerWidth=e.containerWidth||1,this.containerHeight=e.containerHeight||1,this.pages=e.pages.map(o=>{if(o.thumbnail)return o;try{const a=new URL(o.src);return a.searchParams.set("x-oss-process","image/resize,l_50"),K(J({},o),{thumbnail:a.toString()})}catch(a){return console.error(a),o}});const s=Array(this.pages.length);let i=1/0,r=0;this.pagesIntrinsicHeight=this.pages.reduce((o,a,c)=>(s[c]=o,a.width>r&&(r=a.width),a.height<=i&&(i=a.height),o+a.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=x(e,0,this.pagesIntrinsicHeight-this.containerHeight/this.scale),s||Math.abs(e-this.pagesScrollTop)>=.001){this.pagesScrollTop=e;const i=this.findScrollPageIndex(),r=Math.max(i-this.threshold,0),o=Math.min(i+this.threshold,this.pages.length-1);for(let a=0;a<this.$pages.children.length;a++){const c=this.$pages.children[a],n=Number(c.dataset.index);n>=r&&n<=o||(c.remove(),a--)}for(let a=r;a<=o;a++){const c=this.pageElManager.getEl(a);c.$page.parentElement!==this.$pages&&this.$pages.appendChild(c.$page),c.translateY(this.pagesIntrinsicYs[a]-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()}_calcScale(){return this.containerWidth/this.pagesIntrinsicWidth||1}_calcThreshold(){return x(Math.ceil(this.containerHeight/this.scale/this.pagesMinHeight/2),1,this.pages.length)}}var Es="";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=x(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,o=i/(r-this.containerHeight)*(this.containerHeight-this.scrollbarHeight);window.requestAnimationFrame?window.requestAnimationFrame(()=>{this.$scrollbar.style.transform=`translateY(${o}px)`}):this.$scrollbar.style.transform=`translateY(${o}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 o=this.pagesScrollTop,{clientY:a}=Le(i),c=h=>{if(this.readonly)return;const{clientY:d}=Le(h),l=(d-a)/this.scale;Math.abs(l)>0&&this.onDragScroll&&this.onDragScroll(o+l*(this.pagesHeight*this.scale/this.containerHeight))},n=()=>{e.classList.toggle(r,!1),window.removeEventListener("mousemove",c,!0),window.removeEventListener("touchmove",c,!0),window.removeEventListener("mouseup",n,!0),window.removeEventListener("touchend",n,!0),window.removeEventListener("touchcancel",n,!0)};window.addEventListener("mousemove",c,!0),window.addEventListener("touchmove",c,!0),window.addEventListener("mouseup",n,!0),window.addEventListener("touchend",n,!0),window.addEventListener("touchcancel",n,!0)};return this.sideEffect.addEventListener(e,"mousedown",s),this.sideEffect.addEventListener(e,"touchstart",s),e}_calcScale(){return this.containerWidth/this.pagesWidth||1}_calcScrollbarHeight(){return x(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 os{constructor({whiteboardView:e,readonly:s,box:i,pages:r,pageScrollTop:o=0,mountWhiteboard:a,onUserScroll:c}){this.sideEffect=new L,this.userScrolling=!1,this.onNewPageIndex=l=>{this.scrollToPage(l)},this.whiteboardView=e,this.readonly=s,this.box=i,this.pages=r,this.mountWhiteboard=a,this._onUserScroll=c;const n=this.debounce(()=>{this.userScrolling=!1,this._onUserScroll&&this._onUserScroll(this.pageRenderer.pagesScrollTop)},{wait:80},"debounce-updateUserScroll");this.updateUserScroll=()=>{this.userScrolling=!0,n()},this.viewer=new ke({readonly:s,box:i,pages:r,onNewPageIndex:this.onNewPageIndex});const{width:h,height:d}=this.whiteboardView.size;this.pageRenderer=new ss({pagesScrollTop:o,pages:this.pages,containerWidth:h,containerHeight:d,onPageIndexChanged:this.viewer.setPageIndex.bind(this.viewer)}),this.scrollbar=new rs({pagesScrollTop:this.pageRenderer.pagesScrollTop,containerWidth:h,containerHeight:d,pagesWidth:this.pageRenderer.pagesIntrinsicWidth,pagesHeight:this.pageRenderer.pagesIntrinsicHeight,readonly:this.readonly,wrapClassName:this.wrapClassName.bind(this),onDragScroll:l=>{this.pageScrollTo(l),this.updateUserScroll()}}),this.pageScrollStepper=new Kt({start:this.pageRenderer.pagesScrollTop,onStep:l=>{this.pageScrollTo(l)}}),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,o=26/k,a=0,c=Math.max((i+o-(r+a))/2,0);if(this.box.$titleBar){const n=r+c;this.box.$titleBar.style.height=`${n*100}%`}if(this.box.$footer){const n=a+c;this.box.$footer.style.height=`${n*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:x(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 o=s.centerY-this.pageRenderer.containerHeight/this.pageRenderer.scale/2;this.pageRenderer.pagesScrollTo(o),this.scrollbar.pagesScrollTo(o)};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:o}=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:o/2,width:r,height:o})};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 as{constructor({displayer:e,whiteboardView:s,getRoom:i,readonly:r,box:o,pages:a,mountWhiteboard:c}){this.sideEffect=new L,this.onPlayPPT=()=>{const n=this.getWhiteboardRoom();n&&n.pptNextStep()},this._scaleDocsToFitImpl=()=>{const n=this.pages[this.getPageIndex()];n&&this.whiteboardView.moveCameraToContain({originX:-n.width/2,originY:-n.height/2,width:n.width,height:n.height,animationMode:"immediately"})},this._scaleDocsToFitDebounced=()=>{this.sideEffect.setTimeout(this._scaleDocsToFitImpl,1e3,"_scaleDocsToFitDebounced")},this.scaleDocsToFit=()=>{this._scaleDocsToFitImpl(),this._scaleDocsToFitDebounced()},this.onNewPageIndex=n=>{this.jumpToPage(n,!0)},this.whiteboardView=s,this.readonly=r,this.box=o,this.pages=a,this.displayer=e,this.getWhiteboardRoom=i,this.mountWhiteboard=c,this.viewer=new ke({readonly:r,box:o,pages:a,onNewPageIndex:this.onNewPageIndex,onPlay:this.onPlayPPT}),this.render()}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}setReadonly(e){this.readonly!==e&&(this.readonly=e,this.viewer.setReadonly(e))}destroy(){this.sideEffect.flushAll(),this.unmount(),this.viewer.destroy()}getPageIndex(){return this.displayer.state.sceneState.index}jumpToPage(e,s){if(e=x(e,0,this.pages.length-1),e!==this.getPageIndex()){const i=this.getWhiteboardRoom();i&&(i.setSceneIndex(e),this.scaleDocsToFit())}if(e!==this.viewer.pageIndex&&this.viewer.setPageIndex(e),s){const i=this.getWhiteboardRoom();i&&i.setGlobalState({__pptState:void 0})}}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.getWhiteboardRoom())==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.getWhiteboardRoom();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.mountWhiteboard(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:o})=>o?{width:o.width,height:o.height,src:o.src,thumbnail:o.previewURL}:null).filter(o=>Boolean(o));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 o;const r=new os({whiteboardView:e,readonly:s.readonly,box:s,pages:i,pageScrollTop:(o=t.getAttributes())==null?void 0:o.pageScrollTop,mountWhiteboard:t.mountView.bind(t),onUserScroll:a=>{var c;((c=t.getAttributes())==null?void 0:c.pageScrollTop)!==a&&!s.readonly&&t.updateAttributes(["pageScrollTop"],a)}}).mount();t.emitter.on("attributesUpdate",a=>{a&&a.pageScrollTop!=null&&r.syncPageScrollTop(a.pageScrollTop)}),s.events.on("readonly",a=>{r.setReadonly(a)})}function ls(t,e,s,i){e.disableCameraTransform=!0;const r=t.getDisplayer(),o=new as({displayer:r,whiteboardView:e,getRoom:()=>t.getIsWritable()?t.getDisplayer():void 0,readonly:s.readonly,box:s,pages:i,mountWhiteboard:t.mountView.bind(t)}).mount();t.mountView(o.$whiteboardView),t.isAddApp&&e.callbacks.once("onSizeUpdated",({width:a,height:c})=>{if(i.length>0&&s.state!=="maximized"){const{width:n,height:h}=i[0],l=h/n*a-c;l!==0&&t.getIsWritable()&&t.emitter.emit("setBoxSize",{width:s.width,height:s.height+l/s.containerRect.height})}}),t.emitter.on("sceneStateChange",a=>{o.jumpToPage(a.index)}),s.events.on("readonly",a=>{o.setReadonly(a)})}return p.default=ns,Object.defineProperty(p,"__esModule",{value:!0}),p[Symbol.toStringTag]="Module",p}({});
//# sourceMappingURL=main.iife.js.map

@@ -8,2 +8,4 @@ import type { ReadonlyTeleBox } from "@netless/window-manager";

import { Stepper } from "./stepper";
import { PageRenderer } from "../PageRenderer";
import { ScrollBar } from "../ScrollBar";
export interface StaticDocsViewerConfig {

@@ -14,6 +16,2 @@ whiteboardView: View;

pages: DocsViewerPage[];
pagesSize: {
width: number;
height: number;
};
mountWhiteboard: (dom: HTMLDivElement) => void;

@@ -25,7 +23,8 @@ /** Scroll Top of the original page */

export declare class StaticDocsViewer {
constructor({ whiteboardView, readonly, box, pages, pagesSize, pageScrollTop, mountWhiteboard, onUserScroll, }: StaticDocsViewerConfig);
constructor({ whiteboardView, readonly, box, pages, pageScrollTop, mountWhiteboard, onUserScroll, }: StaticDocsViewerConfig);
readonly pageRenderer: PageRenderer;
readonly scrollbar: ScrollBar;
protected sideEffect: SideEffectManager;
protected pageScrollStepper: Stepper;
protected userScrolling: boolean;
protected scrollbarHeight: number;
protected readonly: boolean;

@@ -36,12 +35,5 @@ protected pages: DocsViewerPage[];

protected mountWhiteboard: (dom: HTMLDivElement) => void;
pageScrollTop: number;
pagesSize: {
width: number;
height: number;
};
onUserScroll?: (pageScrollTop: number) => void;
_onUserScroll?: (pageScrollTop: number) => void;
viewer: DocsViewer;
$pages: HTMLElement;
$whiteboardView: HTMLDivElement;
$scrollbar: HTMLElement;
mount(): this;

@@ -55,5 +47,3 @@ unmount(): this;

protected renderRatioHeight(): void;
protected renderPages(): HTMLElement;
protected renderWhiteboardView(): HTMLDivElement;
protected renderScrollbar(): HTMLElement;
protected scrollTopPageToEl(pageScrollTop: number): number;

@@ -66,4 +56,3 @@ protected scrollTopElToPage(elScrollTop: number): number;

protected scrollToPage(index: number): void;
protected setupScrollTopEvent(): void;
protected setupWhiteboardCamera(): void;
protected setupScrollListener(): void;
protected debounce<ArgumentsType extends unknown[], ReturnType>(fn: (...args: ArgumentsType) => ReturnType, options: Options, disposerID?: string): DebouncedFunction<ArgumentsType, ReturnType | undefined>;

@@ -73,3 +62,2 @@ protected updateUserScroll: () => void;

protected onNewPageIndex: (index: number) => void;
protected setScrollbarHeight(elScrollbarHeight: number): void;
}

@@ -18,3 +18,3 @@ export interface StepperConfig {

constructor(config: StepperConfig);
stepTo(target: number): void;
stepTo(target: number, start?: number): void;
pause(): void;

@@ -21,0 +21,0 @@ destroy(): void;

{
"name": "@netless/app-docs-viewer",
"version": "0.1.26",
"version": "0.2.0",
"description": "Netless App Docs Viewer",

@@ -18,2 +18,10 @@ "repository": "netless-io/netless-app",

],
"dependencies": {
"debounce-fn": "^5.0.0",
"vanilla-lazyload": "^17.5.0"
},
"devDependencies": {
"@netless/app-shared": "0.1.2",
"side-effect-manager": "^0.1.5"
},
"scripts": {

@@ -25,10 +33,3 @@ "types": "cross-env NODE_ENV=production tsc --declaration --emitDeclarationOnly --outDir dist",

},
"dependencies": {
"debounce-fn": "^5.0.0",
"vanilla-lazyload": "^17.5.0"
},
"devDependencies": {
"@netless/app-shared": "workspace:*",
"side-effect-manager": "^0.1.5"
}
}
"readme": "## @netless/app-docs-viewer\n\nNetless App for viewing static documents and animated slides.\n\n### Usage\n\nSee [playground](https://github.com/netless-io/netless-app/tree/master/packages/playground).\n\n### Licence\n\nMIT @ [netless](https://github.com/netless-io)\n"
}

@@ -282,2 +282,5 @@ import { sidebarSVG } from "./icons/sidebar";

this.$pageNumberInput = $pageNumberInput;
this.sideEffect.addEventListener($pageNumberInput, "focus", () => {
$pageNumberInput.select();
});
this.sideEffect.addEventListener($pageNumberInput, "change", () => {

@@ -284,0 +287,0 @@ if (this.readonly) {

@@ -81,7 +81,2 @@ import styles from "./style.scss?inline";

): void {
const pagesSize = {
width: pages[0].width,
height: pages.reduce((height, page) => height + page.height * (pages[0].width / page.width), 0),
};
const docsViewer = new StaticDocsViewer({

@@ -92,3 +87,2 @@ whiteboardView,

pages: pages,
pagesSize,
pageScrollTop: context.getAttributes()?.pageScrollTop,

@@ -95,0 +89,0 @@ mountWhiteboard: context.mountView.bind(context),

import type { AnimationMode, ReadonlyTeleBox } from "@netless/window-manager";
import type { View, Size, Camera } from "white-web-sdk";
import LazyLoad from "vanilla-lazyload";
import type { DebouncedFunction, Options } from "debounce-fn";

@@ -9,7 +8,7 @@ import debounceFn from "debounce-fn";

import { DocsViewer } from "../DocsViewer";
import { clamp, flattenEvent, preventEvent } from "../utils/helpers";
import { clamp, preventEvent } from "../utils/helpers";
import { Stepper } from "./stepper";
import { PageRenderer } from "../PageRenderer";
import { ScrollBar } from "../ScrollBar";
const SCROLLBAR_MIN_HEIGHT = 30;
const RATIO_BASE_CONTAINER_HEIGHT = 640;

@@ -22,3 +21,2 @@

pages: DocsViewerPage[];
pagesSize: { width: number; height: number };
mountWhiteboard: (dom: HTMLDivElement) => void;

@@ -36,3 +34,2 @@ /** Scroll Top of the original page */

pages,
pagesSize,
pageScrollTop = 0,

@@ -46,18 +43,10 @@ mountWhiteboard,

this.pages = pages;
this.pageScrollTop = pageScrollTop;
this.pagesSize = pagesSize;
this.mountWhiteboard = mountWhiteboard;
this.onUserScroll = onUserScroll;
this._onUserScroll = onUserScroll;
this.pageScrollStepper = new Stepper({
onStep: pageScrollTop => {
this.pageScrollTo(pageScrollTop);
},
});
const debouncedOnUserScroll = this.debounce(
() => {
this.userScrolling = false;
if (this.onUserScroll) {
this.onUserScroll(this.pageScrollTop);
if (this._onUserScroll) {
this._onUserScroll(this.pageRenderer.pagesScrollTop);
}

@@ -81,5 +70,39 @@ },

const { width: containerWidth, height: containerHeight } = this.whiteboardView.size;
this.pageRenderer = new PageRenderer({
pagesScrollTop: pageScrollTop,
pages: this.pages,
containerWidth,
containerHeight,
onPageIndexChanged: this.viewer.setPageIndex.bind(this.viewer),
});
this.scrollbar = new ScrollBar({
pagesScrollTop: this.pageRenderer.pagesScrollTop,
containerWidth,
containerHeight,
pagesWidth: this.pageRenderer.pagesIntrinsicWidth,
pagesHeight: this.pageRenderer.pagesIntrinsicHeight,
readonly: this.readonly,
wrapClassName: this.wrapClassName.bind(this),
onDragScroll: pageScrollTop => {
this.pageScrollTo(pageScrollTop);
this.updateUserScroll();
},
});
this.pageScrollStepper = new Stepper({
start: this.pageRenderer.pagesScrollTop,
onStep: pageScrollTop => {
this.pageScrollTo(pageScrollTop);
},
});
this.render();
}
readonly pageRenderer: PageRenderer;
readonly scrollbar: ScrollBar;
protected sideEffect = new SideEffectManager();

@@ -90,4 +113,2 @@

protected scrollbarHeight = SCROLLBAR_MIN_HEIGHT;
protected readonly: boolean;

@@ -99,11 +120,7 @@ protected pages: DocsViewerPage[];

public pageScrollTop: number;
public pagesSize: { width: number; height: number };
public onUserScroll?: (pageScrollTop: number) => void;
public _onUserScroll?: (pageScrollTop: number) => void;
public viewer: DocsViewer;
public $pages!: HTMLElement;
public $whiteboardView!: HTMLDivElement;
public $scrollbar!: HTMLElement;

@@ -113,21 +130,4 @@ public mount(): this {

this.sideEffect.add(() => {
const contentLazyLoad = new LazyLoad({
container: this.$pages,
elements_selector: `.${this.wrapClassName("page")}`,
});
return () => contentLazyLoad.destroy();
}, "page-lazyload");
this.setupScrollListener();
this.setupWhiteboardCamera();
this.sideEffect.setTimeout(() => {
if (this.pageScrollTop !== 0) {
this.pageScrollTo(this.pageScrollTop);
}
}, 1000);
// add event listener after scrollTop is set
this.setupScrollTopEvent();
this.sideEffect.add(() => {

@@ -139,2 +139,9 @@ const handler = this.renderRatioHeight.bind(this);

// guard scroll position
this.sideEffect.setTimeout(() => {
if (!this.userScrolling) {
this.pageScrollTo(this.pageRenderer.pagesScrollTop);
}
}, 100);
return this;

@@ -152,2 +159,3 @@ }

this.viewer.setReadonly(readonly);
this.scrollbar.setReadonly(readonly);
}

@@ -159,5 +167,7 @@ }

this.pageScrollStepper.destroy();
this.onUserScroll = void 0;
this._onUserScroll = void 0;
this.unmount();
this.viewer.destroy();
this.pageRenderer.destroy();
this.scrollbar.destroy();
}

@@ -170,5 +180,5 @@

pageScrollTop >= 0 &&
Math.abs(this.pageScrollTop - pageScrollTop) > 10
Math.abs(this.pageRenderer.pagesScrollTop - pageScrollTop) > 0.01
) {
this.pageScrollStepper.stepTo(pageScrollTop);
this.pageScrollStepper.stepTo(pageScrollTop, this.pageRenderer.pagesScrollTop);
}

@@ -178,5 +188,5 @@ }

public render(): void {
this.viewer.$content.appendChild(this.renderPages());
this.pageRenderer.mount(this.viewer.$content);
this.viewer.$content.appendChild(this.renderWhiteboardView());
this.viewer.$content.appendChild(this.renderScrollbar());
this.scrollbar.mount(this.viewer.$content);
this.renderRatioHeight();

@@ -227,24 +237,2 @@ }

protected renderPages(): HTMLElement {
if (!this.$pages) {
const $pages = document.createElement("div");
$pages.className = this.wrapClassName("pages");
this.$pages = $pages;
const pageClassName = this.wrapClassName("page");
this.pages.forEach((page, i) => {
const $img = document.createElement("img");
$img.className = pageClassName + " " + this.wrapClassName(`page-${i}`);
$img.draggable = false;
$img.width = page.width;
$img.height = page.height;
$img.dataset.src = page.src;
$img.dataset.pageIndex = String(i);
$pages.appendChild($img);
});
}
return this.$pages;
}
protected renderWhiteboardView(): HTMLDivElement {

@@ -261,3 +249,3 @@ if (!this.$whiteboardView) {

if (!this.readonly) {
this.pageScrollTo(this.pageScrollTop + ev.deltaY);
this.pageScrollTo(this.pageRenderer.pagesScrollTop + ev.deltaY);
this.updateUserScroll();

@@ -283,62 +271,8 @@ }

protected renderScrollbar(): HTMLElement {
if (!this.$scrollbar) {
const $scrollbar = document.createElement("button");
this.$scrollbar = $scrollbar;
$scrollbar.className = this.wrapClassName("scrollbar");
$scrollbar.style.minHeight = `${SCROLLBAR_MIN_HEIGHT}px`;
const trackStart = (ev: MouseEvent | TouchEvent): void => {
if (this.readonly) {
return;
}
if ((ev as MouseEvent).button != null && (ev as MouseEvent).button !== 0) {
// Not left mouse
return;
}
preventEvent(ev);
this.$scrollbar.classList.toggle(this.wrapClassName("scrollbar-dragging"), true);
const startTop = this.scrollTopPageToEl(this.pageScrollTop);
const elScrollHeight =
(this.whiteboardView.size.width / this.pagesSize.width) * this.pagesSize.height;
const { clientY: startY } = flattenEvent(ev);
const tracking = (ev: MouseEvent | TouchEvent): void => {
const { clientY } = flattenEvent(ev);
const { height: wbHeight } = this.whiteboardView.size;
this.elScrollTo(startTop + (clientY - startY) * (elScrollHeight / wbHeight));
this.updateUserScroll();
};
const trackEnd = (): void => {
this.$scrollbar.classList.toggle(this.wrapClassName("scrollbar-dragging"), false);
window.removeEventListener("mousemove", tracking, true);
window.removeEventListener("touchmove", tracking, true);
window.removeEventListener("mouseup", trackEnd, true);
window.removeEventListener("touchend", trackEnd, true);
window.removeEventListener("touchcancel", trackEnd, true);
};
window.addEventListener("mousemove", tracking, true);
window.addEventListener("touchmove", tracking, true);
window.addEventListener("mouseup", trackEnd, true);
window.addEventListener("touchend", trackEnd, true);
window.addEventListener("touchcancel", trackEnd, true);
};
this.sideEffect.addEventListener($scrollbar, "mousedown", trackStart);
this.sideEffect.addEventListener($scrollbar, "touchstart", trackStart);
}
return this.$scrollbar;
}
protected scrollTopPageToEl(pageScrollTop: number): number {
return pageScrollTop * (this.whiteboardView.size.width / this.pagesSize.width);
return pageScrollTop * this.pageRenderer.scale;
}
protected scrollTopElToPage(elScrollTop: number): number {
return elScrollTop / (this.whiteboardView.size.width / this.pagesSize.width);
return elScrollTop / this.pageRenderer.scale;
}

@@ -358,3 +292,3 @@

halfWbHeight,
this.pagesSize.height - halfWbHeight
this.pageRenderer.pagesIntrinsicHeight - halfWbHeight
),

@@ -366,10 +300,6 @@ animationMode: "immediately" as AnimationMode,

protected scrollToPage(index: number): void {
if (!this.readonly && this.$pages && !Number.isNaN(index)) {
index = clamp(index, 0, this.pages.length - 1);
const $page = this.$pages.querySelector<HTMLElement>(
"." + this.wrapClassName(`page-${index}`)
);
if ($page) {
const elOffsetTop = $page.offsetTop + 5;
this.elScrollTo(elOffsetTop);
if (!this.readonly && !Number.isNaN(index)) {
const offsetY = this.pageRenderer.pagesIntrinsicYs[index];
if (offsetY >= 0) {
this.pageScrollTo(offsetY + 5 / this.pageRenderer.scale);
this.updateUserScroll();

@@ -380,42 +310,15 @@ }

protected setupScrollTopEvent(): void {
const updatePageIndex = this.debounce(
() => {
if (this.pages.length > 0 && this.$pages) {
const pagesWidth = this.$pages.getBoundingClientRect().width;
if (pagesWidth > 0) {
let pageTop = 0;
for (let i = 0; i < this.pages.length; i += 1) {
pageTop += this.pages[i].height;
if (this.pageScrollTop <= pageTop) {
this.viewer.setPageIndex(i);
return;
}
}
this.viewer.setPageIndex(this.pages.length - 1);
}
}
},
{ wait: 5, maxWait: 100 },
"debounce-updatePageIndex"
);
protected setupScrollListener(): void {
this.sideEffect.add(() => {
const handleCameraUpdate = (camera: Camera) => {
const { width: wbWidth, height: wbHeight } = this.whiteboardView.size;
const { width: pageWidth, height: pageHeight } = this.pagesSize;
const elScrollHeight = (wbWidth / pageWidth) * pageHeight;
if (wbWidth <= 0 || wbHeight <= 0) {
return;
}
const elScrollTop = this.scrollTopPageToEl(camera.centerY) - wbHeight / 2;
const pageScrollTop = this.scrollTopElToPage(elScrollTop);
this.pageScrollTop = pageScrollTop;
const pagesScrollTop =
camera.centerY - this.pageRenderer.containerHeight / this.pageRenderer.scale / 2;
this.$pages.scrollTo({ top: elScrollTop });
this.setScrollbarHeight((wbHeight / elScrollHeight) * wbHeight);
this.$scrollbar.style.transform = `translateY(${
(elScrollTop / (elScrollHeight - wbHeight)) * (wbHeight - this.scrollbarHeight)
}px)`;
updatePageIndex();
this.pageRenderer.pagesScrollTo(pagesScrollTop);
this.scrollbar.pagesScrollTo(pagesScrollTop);
};

@@ -425,29 +328,31 @@ this.whiteboardView.callbacks.on("onCameraUpdated", handleCameraUpdate);

});
}
protected setupWhiteboardCamera(): void {
this.sideEffect.add(() => {
const handleSizeUpdate = ({ width, height }: Size): void => {
if (width > 0 && height > 0) {
const elScrollTop = this.$pages.scrollTop;
const pageWidth = this.pagesSize.width;
const ratio = pageWidth / width;
this.whiteboardView.moveCameraToContain({
originX: 0,
originY: elScrollTop * ratio,
width: pageWidth,
height: height * ratio,
animationMode: "immediately" as AnimationMode,
});
this.whiteboardView.setCameraBound({
damping: 1,
maxContentMode: () => width / pageWidth,
minContentMode: () => width / pageWidth,
centerX: this.pagesSize.width / 2,
centerY: this.pagesSize.height / 2,
width: this.pagesSize.width,
height: this.pagesSize.height,
});
this.elScrollTo(elScrollTop);
const handleSizeUpdate = ({ width: wbWidth, height: wbHeight }: Size): void => {
if (wbWidth <= 0 || wbHeight <= 0) {
return;
}
this.pageRenderer.setContainerSize(wbWidth, wbHeight);
this.scrollbar.setContainerSize(wbWidth, wbHeight);
const { pagesIntrinsicWidth, pagesIntrinsicHeight } = this.pageRenderer;
this.whiteboardView.moveCameraToContain({
originX: 0,
originY: this.pageRenderer.pagesScrollTop,
width: pagesIntrinsicWidth,
height: wbHeight / this.pageRenderer.scale,
animationMode: "immediately" as AnimationMode,
});
this.whiteboardView.setCameraBound({
damping: 1,
maxContentMode: () => this.pageRenderer.scale,
minContentMode: () => this.pageRenderer.scale,
centerX: pagesIntrinsicWidth / 2,
centerY: pagesIntrinsicHeight / 2,
width: pagesIntrinsicWidth,
height: pagesIntrinsicHeight,
});
};

@@ -459,2 +364,51 @@ this.whiteboardView.callbacks.on("onSizeUpdated", handleSizeUpdate);

}, "whiteboard-size-update");
this.sideEffect.addEventListener(
window,
"keyup",
ev => {
if (this.readonly || !this.box.focus || this.box.minimized) {
return;
}
let newPageScrollTop: number | null = null;
switch (ev.key) {
case "PageDown": {
newPageScrollTop =
this.pageRenderer.pagesScrollTop +
this.pageRenderer.containerHeight / this.pageRenderer.scale;
break;
}
case "PageUp": {
newPageScrollTop =
this.pageRenderer.pagesScrollTop -
this.pageRenderer.containerHeight / this.pageRenderer.scale;
break;
}
case "ArrowDown": {
newPageScrollTop =
this.pageRenderer.pagesScrollTop +
this.pageRenderer.containerHeight / 4 / this.pageRenderer.scale;
break;
}
case "ArrowUp": {
newPageScrollTop =
this.pageRenderer.pagesScrollTop -
this.pageRenderer.containerHeight / 4 / this.pageRenderer.scale;
break;
}
default:
break;
}
if (newPageScrollTop !== null) {
if (this._onUserScroll) {
// this will trigger stepper for smooth scrolling effect
this._onUserScroll(newPageScrollTop);
} else {
this.pageScrollTo(newPageScrollTop);
this.updateUserScroll();
}
}
},
{ capture: true }
);
}

@@ -481,14 +435,2 @@

};
protected setScrollbarHeight(elScrollbarHeight: number): void {
elScrollbarHeight = clamp(
elScrollbarHeight,
SCROLLBAR_MIN_HEIGHT,
this.whiteboardView.size.height
);
if (this.scrollbarHeight !== elScrollbarHeight) {
this.scrollbarHeight = elScrollbarHeight;
this.$scrollbar.style.height = `${elScrollbarHeight}px`;
}
}
}

@@ -29,3 +29,6 @@ export interface StepperConfig {

public stepTo(target: number) {
public stepTo(target: number, start?: number) {
if (this.paused && start != null) {
this.current = start;
}
this.paused = false;

@@ -32,0 +35,0 @@ this.target = target;

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

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