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.2.7 to 0.2.8

./dist/main.cjs.js

6

dist/main.cjs.js

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

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

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

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

@@ -52,3 +52,3 @@ import type { ReadonlyTeleBox } from "@netless/window-manager";

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

@@ -55,0 +55,0 @@ protected wrapClassName(className: string): string;

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

@@ -19,3 +19,4 @@ "repository": "netless-io/netless-app",

"dependencies": {
"debounce-fn": "^5.0.0",
"@juggle/resize-observer": "^3.3.1",
"debounce-fn": "^5.1.0",
"vanilla-lazyload": "^17.5.0"

@@ -22,0 +23,0 @@ },

@@ -6,2 +6,3 @@ import type { AnimationMode, ReadonlyTeleBox } from "@netless/window-manager";

import { SideEffectManager } from "side-effect-manager";
import { ResizeObserver as Polyfill } from "@juggle/resize-observer";
import type { DocsViewerPage } from "../DocsViewer";

@@ -14,2 +15,4 @@ import { DocsViewer } from "../DocsViewer";

const ResizeObserver = window.ResizeObserver || Polyfill;
const RATIO_BASE_CONTAINER_HEIGHT = 640;

@@ -127,6 +130,10 @@

const debouncedRenderRatioHeight = this.debounce(this.renderRatioHeight.bind(this), {
wait: 80,
});
this.sideEffect.add(() => {
const handler = this.renderRatioHeight.bind(this);
this.box.events.on("visual_resize", handler);
return () => this.box.events.off("visual_resize", handler);
const observer = new ResizeObserver(debouncedRenderRatioHeight);
observer.observe(this.viewer.$content);
return () => observer.disconnect();
});

@@ -400,3 +407,3 @@

fn: (...args: ArgumentsType) => ReturnType,
options: Options,
options?: Options,
disposerID?: string

@@ -403,0 +410,0 @@ ): DebouncedFunction<ArgumentsType, ReturnType | undefined> {

Sorry, the diff of this file is not supported yet

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc