@netless/app-docs-viewer
Advanced tools
Comparing version 0.3.1 to 0.3.2
@@ -1,3 +0,3 @@ | ||
var NetlessAppDocsViewer=function(j){"use strict";var Qe=(()=>`.netless-app-docs-viewer-footer{box-sizing:border-box;height:26px;display:flex;align-items:center;padding:0 16px;border-top:1px solid #eeeef7;font-family:PingFang SC,Source Han Sans SC,Microsoft YaHei,Helvetica Neue,Noto Sans CJK SC,WenQuanYi Micro Hei,sans-serif}.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{display:flex;align-items:center;height:26px;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 .5em 0 2px;text-align:right;font-size:13px;line-height:1;font-weight:400;font-family:inherit;border-radius:2px;color:currentColor;font-family:PingFang SC,Source Han Sans SC,Microsoft YaHei,Helvetica Neue,Noto Sans CJK SC,WenQuanYi Micro Hei,sans-serif;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}.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:currentColor;background:#25282e}.telebox-color-scheme-dark .netless-app-docs-viewer-footer{border-top:none}.telebox-color-scheme-dark .netless-app-docs-viewer-footer-btn:hover{background:#212126}.netless-app-docs-viewer-preview.netless-app-docs-viewer-preview-active{transform:translate(0)}.netless-app-docs-viewer-content{position:relative;height:100%;overflow:hidden}.netless-app-docs-viewer-preview-mask{position:absolute;z-index:10200;top:0;left:0;width:100%;height:100%}.netless-app-docs-viewer-preview{box-sizing:border-box;display:flex;flex-direction:column;align-items:center;position:absolute;z-index:10300;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;user-select:none}.telebox-color-scheme-dark .netless-app-docs-viewer-preview{background:rgba(50,50,50,.9)}.netless-app-docs-viewer-static-scrollbar{box-sizing:border-box;position:absolute;top:0;right:0;z-index:2147483647;width:16px;min-height:30px;margin:0;padding:0 0 0 8px;border:none;outline:none;opacity:0;background:transparent;transition:opacity .4s 3s,transform .1s;user-select:none;touch-action:none}.netless-app-docs-viewer-static-scrollbar:after{content:"";display:block;width:8px;height:100%;border-radius:4px;background:rgba(68,78,96,.4);box-shadow:1px 1px 8px #ffffffb3;transition:background .4s}.netless-app-docs-viewer-static-scrollbar.netless-app-docs-viewer-static-scrolling{opacity:1;transition:opacity .4s,transform .1s}.netless-app-docs-viewer-static-scrollbar.netless-app-docs-viewer-static-scrollbar-dragging{opacity:1;transition:opacity .4s 3s!important}.netless-app-docs-viewer-static-scrollbar.netless-app-docs-viewer-static-scrollbar-dragging:after{background:rgba(68,78,96,.6)}.netless-app-docs-viewer-static-scrollbar:hover:after,.netless-app-docs-viewer-static-scrollbar:focus:after{background:rgba(68,78,96,.5)}.netless-app-docs-viewer-static-scrollbar:active:after{background:rgba(68,78,96,.6)}.telebox-body-wrap:hover .netless-app-docs-viewer-static-scrollbar{opacity:1;transition:opacity .4s,transform .1s}.telebox-readonly .netless-app-docs-viewer-static-scrollbar{display:none}.page-renderer-pages-container{position:relative;width:100%;height:100%}.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-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 oe="!#%()*+,-./:;=?@[]^_`{|}~ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",Ze=oe.length,ne=Array(20),et=()=>{for(let t=0;t<20;t++)ne[t]=oe.charAt(Math.random()*Ze);return ne.join("")};function ce(t){try{return t()}catch(e){console.error(e)}}class k{constructor(){this.disposers=new Map}addDisposer(e,s=this.genUID()){return this.flush(s),this.disposers.set(s,Array.isArray(e)?()=>e.forEach(ce):e),s}add(e,s=this.genUID()){const r=e();return r?this.addDisposer(r,s):s}addEventListener(e,s,r,i,a=this.genUID()){return e.addEventListener(s,r,i),this.addDisposer(()=>e.removeEventListener(s,r,i),a),a}setTimeout(e,s,r=this.genUID()){const i=window.setTimeout(()=>{this.remove(r),e()},s);return this.addDisposer(()=>window.clearTimeout(i),r)}setInterval(e,s,r=this.genUID()){const i=window.setInterval(e,s);return this.addDisposer(()=>window.clearInterval(i),r)}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(r){console.error(r)}}flushAll(){this.disposers.forEach(ce),this.disposers.clear()}genUID(){let e;do e=et();while(this.disposers.has(e));return e}}var tt=Object.defineProperty,st=Object.defineProperties,rt=Object.getOwnPropertyDescriptors,le=Object.getOwnPropertySymbols,it=Object.prototype.hasOwnProperty,at=Object.prototype.propertyIsEnumerable,W=(t,e,s)=>e in t?tt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,de=(t,e)=>{for(var s in e||(e={}))it.call(e,s)&&W(t,s,e[s]);if(le)for(var s of le(e))at.call(e,s)&&W(t,s,e[s]);return t},he=(t,e)=>st(t,rt(e)),E=(t,e,s)=>(W(t,typeof e!="symbol"?e+"":e,s),s);class ot{constructor(e){E(this,"_subscribers"),E(this,"_bSub"),E(this,"_bSubDisposer"),this._bSub=e}get size(){return this._subscribers?this._subscribers.size:0}invoke(e,s){this._subscribers&&this._subscribers.forEach(r=>r(e,s))}add(e){this._bSub&&(!this._subscribers||this._subscribers.size<=0)&&(this._bSubDisposer=this._bSub()),this._subscribers||(this._subscribers=new Set),this._subscribers.add(e)}remove(e){if(this._subscribers&&this._subscribers.delete(e),this._subscribers&&this._subscribers.size<=0&&this._bSubDisposer){const s=this._bSubDisposer;this._bSubDisposer=null,s()}}clear(){if(this._subscribers&&this._subscribers.clear(),this._bSubDisposer){const e=this._bSubDisposer;this._bSubDisposer=null,e()}}destroy(){this.clear()}}class Y{constructor(e,s){E(this,"_subscribers"),E(this,"_value"),this._value=e;let r;if(s&&(s.compare&&(this.compare=s.compare),s.beforeSubscribe)){const i=s.beforeSubscribe,a=this._setValue.bind(this);r=()=>i(a)}this._subscribers=new ot(r)}_setValue(e,s){this.compare(e,this._value)||(this._value=e,this._subscribers.invoke(e,s))}get value(){return this._value}reaction(e){return this._subscribers.add(e),()=>{this._subscribers.remove(e)}}subscribe(e,s){const r=this.reaction(e);return e(this._value,s),r}destroy(){this._subscribers.destroy()}unsubscribe(e){this._subscribers.remove(e)}get size(){return this._subscribers.size}compare(e,s){return e===s}}class S extends Y{constructor(){super(...arguments),E(this,"setValue",this._setValue)}}class nt extends Y{constructor(e,s,r={}){super(s(e.value),he(de({},r),{beforeSubscribe:i=>{const a=e.subscribe((n,c)=>i(s(n),c));if(r.beforeSubscribe){const n=r.beforeSubscribe(i);if(n)return()=>{a(),n()}}return a}})),E(this,"_srcValue"),this._srcValue=()=>s(e.value)}get value(){if(this.size<=0){const e=this._srcValue();return this.compare(e,this._value)?this._value:e}return this._value}}function A(t,e=r=>r,s={}){return new nt(t,e,s)}class ct extends Y{constructor(e,s,r={}){super(s(G(e)),he(de({},r),{beforeSubscribe:i=>{let a=G(e);i(s(a));const n=e.map((l,o)=>l.reaction((d,p)=>{a=a.slice(),a[o]=d,i(s(a),p)})),c=()=>n.forEach(l=>l());if(r.beforeSubscribe){const l=r.beforeSubscribe(i);if(l)return()=>{c(),l()}}return c}})),E(this,"_srcValue"),this._srcValue=()=>s(G(e))}get value(){if(this.size<=0){const e=this._srcValue();return this.compare(e,this._value)?this._value:e}return this._value}}function G(t){return t.map(lt)}function lt(t){return t.value}function w(t,e=r=>r,s={}){return new ct(t,e,s)}function pe(t){t.onValChanged||(t.onValChanged=dt)}function dt(t,e){const s=this[`_${t}$`]||this[t];if(!(s!=null&&s.reaction))throw new TypeError(`"${t}" is not related to a Val in this instance`);return s.reaction(e)}function ht(t,e,s){Object.keys(e).forEach(r=>{pt(t,r,e[r]),s&&s.attach(e[r])}),pe(t)}function pt(t,e,s){return Object.defineProperties(t,{[e]:{get(){return s.value}},[`_${e}$`]:{value:s}}),t}function ut(t,e,s){Object.keys(e).forEach(r=>{gt(t,r,e[r]),s&&s.attach(e[r])}),pe(t)}function gt(t,e,s){return Object.defineProperties(t,{[e]:{get(){return s.value},set(r){s.setValue(r)}},[`_${e}$`]:{value:s},[`set${ft(e)}`]:{value:(r,i)=>s.setValue(r,i)}}),t}function ft(t){return t[0].toUpperCase()+t.slice(1)}const y=typeof window!="undefined",ue=y&&!("onscroll"in window)||typeof navigator!="undefined"&&/(gle|ing|ro)bot|crawl|spider/i.test(navigator.userAgent),ge=y&&"IntersectionObserver"in window,fe=y&&"classList"in document.createElement("p"),be=y&&window.devicePixelRatio>1,bt={elements_selector:".lazy",container:ue||y?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_bg_set:"bg-set",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,restore_on_error:!1},we=t=>Object.assign({},bt,t),ve=function(t,e){let s;const r="LazyLoad::Initialized",i=new t(e);try{s=new CustomEvent(r,{detail:{instance:i}})}catch{s=document.createEvent("CustomEvent"),s.initCustomEvent(r,!1,!1,{instance:i})}window.dispatchEvent(s)},wt=(t,e)=>{if(!!e)if(!e.length)ve(t,e);else for(let s=0,r;r=e[s];s+=1)ve(t,r)},_="src",q="srcset",J="sizes",me="poster",P="llOriginalAttrs",Se="data",X="loading",_e="loaded",Ee="applied",vt="entered",K="error",ye="native",$e="data-",xe="ll-status",b=(t,e)=>t.getAttribute($e+e),mt=(t,e,s)=>{var r=$e+e;if(s===null){t.removeAttribute(r);return}t.setAttribute(r,s)},V=t=>b(t,xe),D=(t,e)=>mt(t,xe,e),R=t=>D(t,null),Q=t=>V(t)===null,St=t=>V(t)===X,_t=t=>V(t)===K,Z=t=>V(t)===ye,Et=[X,_e,Ee,K],yt=t=>Et.indexOf(V(t))>=0,$=(t,e,s,r)=>{if(!!t){if(r!==void 0){t(e,s,r);return}if(s!==void 0){t(e,s);return}t(e)}},T=(t,e)=>{if(fe){t.classList.add(e);return}t.className+=(t.className?" ":"")+e},v=(t,e)=>{if(fe){t.classList.remove(e);return}t.className=t.className.replace(new RegExp("(^|\\s+)"+e+"(\\s+|$)")," ").replace(/^\s+/,"").replace(/\s+$/,"")},$t=t=>{t.llTempImage=document.createElement("IMG")},xt=t=>{delete t.llTempImage},Ce=t=>t.llTempImage,H=(t,e)=>{if(!e)return;const s=e._observer;!s||s.unobserve(t)},Ct=t=>{t.disconnect()},Lt=(t,e,s)=>{e.unobserve_entered&&H(t,s)},ee=(t,e)=>{!t||(t.loadingCount+=e)},kt=t=>{!t||(t.toLoadCount-=1)},Le=(t,e)=>{!t||(t.toLoadCount=e)},Dt=t=>t.loadingCount>0,It=t=>t.toLoadCount>0,ke=t=>{let e=[];for(let s=0,r;r=t.children[s];s+=1)r.tagName==="SOURCE"&&e.push(r);return e},te=(t,e)=>{const s=t.parentNode;if(!s||s.tagName!=="PICTURE")return;ke(s).forEach(e)},De=(t,e)=>{ke(t).forEach(e)},B=[_],Ie=[_,me],z=[_,q,J],Te=[Se],U=t=>!!t[P],Ne=t=>t[P],Ae=t=>delete t[P],N=(t,e)=>{if(U(t))return;const s={};e.forEach(r=>{s[r]=t.getAttribute(r)}),t[P]=s},Tt=t=>{U(t)||(t[P]={backgroundImage:t.style.backgroundImage})},Nt=(t,e,s)=>{if(!s){t.removeAttribute(e);return}t.setAttribute(e,s)},I=(t,e)=>{if(!U(t))return;const s=Ne(t);e.forEach(r=>{Nt(t,r,s[r])})},At=t=>{if(!U(t))return;const e=Ne(t);t.style.backgroundImage=e.backgroundImage},Pe=(t,e,s)=>{T(t,e.class_applied),D(t,Ee),s&&(e.unobserve_completed&&H(t,e),$(e.callback_applied,t,s))},Ve=(t,e,s)=>{T(t,e.class_loading),D(t,X),s&&(ee(s,1),$(e.callback_loading,t,s))},x=(t,e,s)=>{!s||t.setAttribute(e,s)},ze=(t,e)=>{x(t,J,b(t,e.data_sizes)),x(t,q,b(t,e.data_srcset)),x(t,_,b(t,e.data_src))},Pt=(t,e)=>{te(t,s=>{N(s,z),ze(s,e)}),N(t,z),ze(t,e)},Vt=(t,e)=>{N(t,B),x(t,_,b(t,e.data_src))},zt=(t,e)=>{De(t,s=>{N(s,B),x(s,_,b(s,e.data_src))}),N(t,Ie),x(t,me,b(t,e.data_poster)),x(t,_,b(t,e.data_src)),t.load()},Ot=(t,e)=>{N(t,Te),x(t,Se,b(t,e.data_src))},Mt=(t,e,s)=>{const r=b(t,e.data_bg),i=b(t,e.data_bg_hidpi),a=be&&i?i:r;!a||(t.style.backgroundImage=`url("${a}")`,Ce(t).setAttribute(_,a),Ve(t,e,s))},Rt=(t,e,s)=>{const r=b(t,e.data_bg_multi),i=b(t,e.data_bg_multi_hidpi),a=be&&i?i:r;!a||(t.style.backgroundImage=a,Pe(t,e,s))},Ht=(t,e,s)=>{const r=b(t,e.data_bg_set);if(!r)return;const i=r.split("|");let a=i.map(n=>`image-set(${n})`);t.style.backgroundImage=a.join(),t.style.backgroundImage===""&&(a=i.map(n=>`-webkit-image-set(${n})`),t.style.backgroundImage=a.join()),Pe(t,e,s)},Oe={IMG:Pt,IFRAME:Vt,VIDEO:zt,OBJECT:Ot},Bt=(t,e)=>{const s=Oe[t.tagName];!s||s(t,e)},Ut=(t,e,s)=>{const r=Oe[t.tagName];!r||(r(t,e),Ve(t,e,s))},Ft=["IMG","IFRAME","VIDEO","OBJECT"],jt=t=>Ft.indexOf(t.tagName)>-1,Me=(t,e)=>{e&&!Dt(e)&&!It(e)&&$(t.callback_finish,e)},Re=(t,e,s)=>{t.addEventListener(e,s),t.llEvLisnrs[e]=s},Wt=(t,e,s)=>{t.removeEventListener(e,s)},se=t=>!!t.llEvLisnrs,Yt=(t,e,s)=>{se(t)||(t.llEvLisnrs={});const r=t.tagName==="VIDEO"?"loadeddata":"load";Re(t,r,e),Re(t,"error",s)},re=t=>{if(!se(t))return;const e=t.llEvLisnrs;for(let s in e){const r=e[s];Wt(t,s,r)}delete t.llEvLisnrs},He=(t,e,s)=>{xt(t),ee(s,-1),kt(s),v(t,e.class_loading),e.unobserve_completed&&H(t,s)},Gt=(t,e,s,r)=>{const i=Z(e);He(e,s,r),T(e,s.class_loaded),D(e,_e),$(s.callback_loaded,e,r),i||Me(s,r)},qt=(t,e,s,r)=>{const i=Z(e);He(e,s,r),T(e,s.class_error),D(e,K),$(s.callback_error,e,r),s.restore_on_error&&I(e,z),i||Me(s,r)},ie=(t,e,s)=>{const r=Ce(t)||t;if(se(r))return;Yt(r,n=>{Gt(n,t,e,s),re(r)},n=>{qt(n,t,e,s),re(r)})},Jt=(t,e,s)=>{$t(t),ie(t,e,s),Tt(t),Mt(t,e,s),Rt(t,e,s),Ht(t,e,s)},Xt=(t,e,s)=>{ie(t,e,s),Ut(t,e,s)},ae=(t,e,s)=>{jt(t)?Xt(t,e,s):Jt(t,e,s)},Kt=(t,e,s)=>{t.setAttribute("loading","lazy"),ie(t,e,s),Bt(t,e),D(t,ye)},Be=t=>{t.removeAttribute(_),t.removeAttribute(q),t.removeAttribute(J)},Qt=t=>{te(t,e=>{Be(e)}),Be(t)},Ue=t=>{te(t,e=>{I(e,z)}),I(t,z)},Zt={IMG:Ue,IFRAME:t=>{I(t,B)},VIDEO:t=>{De(t,e=>{I(e,B)}),I(t,Ie),t.load()},OBJECT:t=>{I(t,Te)}},es=t=>{const e=Zt[t.tagName];if(!e){At(t);return}e(t)},ts=(t,e)=>{Q(t)||Z(t)||(v(t,e.class_entered),v(t,e.class_exited),v(t,e.class_applied),v(t,e.class_loading),v(t,e.class_loaded),v(t,e.class_error))},ss=(t,e)=>{es(t),ts(t,e),R(t),Ae(t)},rs=(t,e,s,r)=>{!s.cancel_on_exit||!St(t)||t.tagName==="IMG"&&(re(t),Qt(t),Ue(t),v(t,s.class_loading),ee(r,-1),R(t),$(s.callback_cancel,t,e,r))},is=(t,e,s,r)=>{const i=yt(t);D(t,vt),T(t,s.class_entered),v(t,s.class_exited),Lt(t,s,r),$(s.callback_enter,t,e,r),!i&&ae(t,s,r)},as=(t,e,s,r)=>{Q(t)||(T(t,s.class_exited),rs(t,e,s,r),$(s.callback_exit,t,e,r))},os=["IMG","IFRAME","VIDEO"],Fe=t=>t.use_native&&"loading"in HTMLImageElement.prototype,ns=(t,e,s)=>{t.forEach(r=>{os.indexOf(r.tagName)!==-1&&Kt(r,e,s)}),Le(s,0)},cs=t=>t.isIntersecting||t.intersectionRatio>0,ls=t=>({root:t.container===document?null:t.container,rootMargin:t.thresholds||t.threshold+"px"}),ds=(t,e,s)=>{t.forEach(r=>cs(r)?is(r.target,r,e,s):as(r.target,r,e,s))},hs=(t,e)=>{e.forEach(s=>{t.observe(s)})},ps=(t,e)=>{Ct(t),hs(t,e)},us=(t,e)=>{!ge||Fe(t)||(e._observer=new IntersectionObserver(s=>{ds(s,t,e)},ls(t)))},je=t=>Array.prototype.slice.call(t),F=t=>t.container.querySelectorAll(t.elements_selector),gs=t=>je(t).filter(Q),fs=t=>_t(t),bs=t=>je(t).filter(fs),We=(t,e)=>gs(t||F(e)),ws=(t,e)=>{bs(F(t)).forEach(r=>{v(r,t.class_error),R(r)}),e.update()},vs=(t,e)=>{!y||(e._onlineHandler=()=>{ws(t,e)},window.addEventListener("online",e._onlineHandler))},ms=t=>{!y||window.removeEventListener("online",t._onlineHandler)},O=function(t,e){const s=we(t);this._settings=s,this.loadingCount=0,us(s,this),vs(s,this),this.update(e)};O.prototype={update:function(t){const e=this._settings,s=We(t,e);if(Le(this,s.length),ue||!ge){this.loadAll(s);return}if(Fe(e)){ns(s,e,this);return}ps(this._observer,s)},destroy:function(){this._observer&&this._observer.disconnect(),ms(this),F(this._settings).forEach(t=>{Ae(t)}),delete this._observer,delete this._settings,delete this._onlineHandler,delete this.loadingCount,delete this.toLoadCount},loadAll:function(t){const e=this._settings;We(t,e).forEach(r=>{H(r,this),ae(r,e,this)})},restoreAll:function(){const t=this._settings;F(t).forEach(e=>{ss(e,t)})}},O.load=(t,e)=>{const s=we(e);ae(t,s)},O.resetStatus=t=>{R(t)},y&&wt(O,window.lazyLoadOptions);class Ss{constructor({namespace:e,pages$:s,sideEffect:r,readonly$:i,events:a,wrapClassName:n,root:c,pagesIndex$:l}){this.showPreview$=new S(!1),this.namespace=e,this.pages$=s,this.sideEffect=r,this.readonly$=i,this.events=a,this.wrapClassName=n,this.sideEffect.addDisposer(this.events.on("togglePreview",()=>{this.showPreview$.setValue(!this.showPreview$.value)})),this.sideEffect.addDisposer(this.showPreview$.subscribe(o=>{this.sideEffect.add(()=>{const d=this.renderPreview(),p=this.renderPreviewMask();if(o){c.appendChild(d),c.appendChild(p),d.scrollTop;const u=d.querySelector("."+this.wrapClassName(`preview-page-${l.value}`));return u&&d.scrollTo({top:u.offsetTop-16}),d.classList.toggle(this.wrapClassName("preview-active"),!0),this.previewLazyLoad=new O({container:this.$preview,elements_selector:"."+this.wrapClassName("preview-page>img")}),()=>{var h;return(h=this.previewLazyLoad)==null?void 0:h.destroy()}}else return d.classList.toggle(this.wrapClassName("preview-active"),!1),this.sideEffect.setTimeout(()=>{d.remove(),p.remove()},500,"preview-remove"),null},"preview-lazyload")}))}destroy(){var e,s;(e=this.$preview)==null||e.remove(),(s=this.$previewMask)==null||s.remove()}renderPreview(){if(this.$preview)return this.$preview;const e=document.createElement("div");return e.className=this.wrapClassName("preview")+" tele-fancy-scrollbar",this.$preview=e,this.sideEffect.addEventListener(e,"wheel",s=>s.stopPropagation(),{passive:!1}),this.sideEffect.addDisposer(this.pages$.subscribe(s=>{var r;this.sideEffect.add(()=>{const i=s.map((a,n)=>{var u;const c=(u=a.thumbnail)!=null?u:a.src.startsWith("ppt")?void 0:a.src;if(!c)return;const l=String(n),o=document.createElement("a");o.className=this.wrapClassName("preview-page")+" "+this.wrapClassName(`preview-page-${n}`),o.setAttribute("href","#"),o.dataset.pageIndex=l;const d=document.createElement("span");d.className=this.wrapClassName("preview-page-name"),d.textContent=String(n+1),d.dataset.pageIndex=l;const p=document.createElement("img");return p.width=a.width,p.height=a.height,p.dataset.src=c,p.dataset.pageIndex=l,o.appendChild(p),o.appendChild(d),e.appendChild(o),o});return()=>i.forEach(a=>a==null?void 0:a.remove())},"render-preview-pages"),(r=this.previewLazyLoad)==null||r.update()})),this.sideEffect.addEventListener(e,"click",s=>{var i;if(this.readonly$.value)return;const r=(i=s.target.dataset)==null?void 0:i.pageIndex;r&&(s.preventDefault(),s.stopPropagation(),s.stopImmediatePropagation(),this.events.emit("jumpPage",Number(r)),this.showPreview$.setValue(!1))}),e}renderPreviewMask(){if(this.$previewMask)return this.$previewMask;const e=document.createElement("div");return e.className=this.wrapClassName("preview-mask"),this.$previewMask=e,this.sideEffect.addEventListener(e,"click",s=>{this.readonly$.value||s.target===e&&this.showPreview$.setValue(!1)}),e}}function _s(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 r=document.createElementNS(e,"path");return r.setAttribute("fill","currentColor"),r.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(r),s}function Es(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 r=document.createElementNS(e,"path");return r.setAttribute("fill","currentColor"),r.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(r),s}function ys(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 r=document.createElementNS(e,"path");return r.setAttribute("fill","currentColor"),r.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(r),s}function $s(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 r=document.createElementNS(e,"path");return r.setAttribute("fill","currentColor"),r.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(r),s}function xs(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 r=document.createElementNS(e,"path");return r.setAttribute("fill","currentColor"),r.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(r),s}class Cs{constructor({namespace:e,pages$:s,sideEffect:r,readonly$:i,events:a,playable:n,wrapClassName:c,pagesIndex$:l,root:o}){this.namespace=e,this.pages$=s,this.sideEffect=r,this.readonly$=i,this.events=a,this.wrapClassName=c,this.pagesIndex$=l,this.playable=n,this.$footer=this.render(),o.appendChild(this.$footer)}destroy(){this.$footer.remove()}render(){const e=document.createElement("div");e.className=this.wrapClassName("footer"),this.sideEffect.addDisposer(this.readonly$.subscribe(o=>e.classList.toggle(this.wrapClassName("readonly"),o)));const s=this.renderFooterBtn("btn-sidebar",_s(this.namespace));this.sideEffect.addEventListener(s,"click",()=>{this.readonly$.value||this.events.emit("togglePreview")}),e.appendChild(s),this.sideEffect.addDisposer(this.pages$.subscribe(o=>{const d=o.some(p=>p.thumbnail||!p.src.startsWith("ppt"));s.style.display=d?"":"none"}));const r=document.createElement("div");r.className=this.wrapClassName("page-jumps");const i=this.renderFooterBtn("btn-page-back",Es(this.namespace));if(this.sideEffect.addEventListener(i,"click",()=>{this.readonly$.value||this.events.emit("back")}),r.appendChild(i),this.playable){const o=this.renderFooterBtn("btn-page-play",$s(this.namespace),xs(this.namespace));this.sideEffect.addEventListener(o,"click",()=>{this.readonly$.value||(o.classList.toggle(this.wrapClassName("footer-btn-playing"),!0),this.events.emit("play"),this.sideEffect.setTimeout(()=>o.classList.toggle(this.wrapClassName("footer-btn-playing"),!1),500,"returnPlay"))}),r.appendChild(o)}const a=this.renderFooterBtn("btn-page-next",ys(this.namespace));this.sideEffect.addEventListener(a,"click",()=>{this.readonly$.value||this.events.emit("next")}),r.appendChild(a);const n=document.createElement("div");n.className=this.wrapClassName("page-number");const c=document.createElement("input");c.className=this.wrapClassName("page-number-input"),this.sideEffect.addDisposer(this.readonly$.subscribe(o=>c.disabled=o)),this.sideEffect.addDisposer(this.pagesIndex$.subscribe(o=>c.value=String(o+1))),this.sideEffect.addEventListener(c,"focus",()=>{c.select()}),this.sideEffect.addEventListener(c,"change",()=>{if(this.readonly$.value)return;const o=Number(c.value)-1;o>=0&&this.events.emit("jumpPage",o)});const l=document.createElement("span");return this.sideEffect.addDisposer(this.pages$.subscribe(o=>{l.textContent=" / "+o.length})),n.appendChild(c),n.appendChild(l),e.appendChild(r),e.appendChild(n),e}renderFooterBtn(e,s,r){const i=document.createElement("button");return i.className=this.wrapClassName("footer-btn")+" "+this.wrapClassName(e),i.appendChild(s),r&&i.appendChild(r),i}}class Ls{constructor(){this.listeners=new Map,this.relayListeners=new Set}emit(e,s){var r;(r=this.listeners.get(e))==null||r.forEach(i=>i(s))}on(e,s){let r=this.listeners.get(e);return r||(r=new Set,this.listeners.set(e,r)),r.add(s),r.size===1&&this.relayListeners.forEach(i=>i.start(e)),()=>{this.off(e,s)}}off(e,s){const r=this.listeners.get(e);if(r){const i=r.delete(s);return r.size<=0&&(this.listeners.delete(e),this.relayListeners.forEach(a=>a.dispose(e))),i}return!1}clear(e){var s;e?(s=this.listeners.get(e))==null||s.clear():this.listeners.clear()}count(e){var s;if(e)return((s=this.listeners.get(e))==null?void 0:s.size)||0;{let r=0;return this.listeners.forEach(i=>{r+=i.size}),r}}remit(e,s){let r;const i={start:a=>{a===e&&(r=s(this))},dispose:a=>{r&&(!a||a===e)&&r()}};return this.relayListeners.add(i),()=>{this.relayListeners.delete(i),r&&r()}}destroy(){this.clear(),this.relayListeners.forEach(e=>e.dispose()),this.relayListeners.clear()}}class Ye{constructor({readonly$:e,pagesIndex$:s,box:r,pages:i=[],playable:a}){this.wrapClassName=c=>`${this.namespace}-${c}`,this.namespace="netless-app-docs-viewer",this.sideEffect=new k,this.events=new Ls;const n=new S(i);ut(this,{pages:n}),this.preview=new Ss({pages$:n,readonly$:e,pagesIndex$:s,root:r.$body,sideEffect:this.sideEffect,events:this.events,namespace:this.namespace,wrapClassName:this.wrapClassName}),this.footer=new Cs({pages$:n,readonly$:e,playable:a,pagesIndex$:s,root:r.$footer,namespace:this.namespace,sideEffect:this.sideEffect,events:this.events,wrapClassName:this.wrapClassName})}destroy(){this.preview.destroy(),this.footer.destroy(),this.sideEffect.flushAll(),this.events.destroy()}}function C(t,e,s){return Math.min(Math.max(t,e),s)}function Ge(t){return t.touches?t.touches[0]:t}function qe(t){t.stopPropagation(),t.cancelable&&t.preventDefault()}function Je(t,e){return t.width===e.width&&t.height===e.height}class ks{constructor(e){var s,r,i;this.velocity=0,this._paused=!0,this._animationFrameID=null,this._loopTimestamp=0,this.looper=a=>{var c;if(this._paused)return;let n=Math.floor((a-this._loopTimestamp)/1e3*60)+1;for(this._loopTimestamp=a;n-- >0;)this.stepper();(c=this.onStep)==null||c.call(this,this.current),this._paused?this._animationFrameID=null:this._animationFrameID=window.requestAnimationFrame(this.looper)},this.current=(s=e.start)!=null?s:0,this.target=this.current,this.stiffness=(r=e.stiffness)!=null?r:170,this.damping=(i=e.damping)!=null?i:26,this.onStep=e.onStep}get paused(){return this._paused}stepTo(e,s){var r;this._paused&&s!=null&&(this.current=s),this._paused=!1,this.target=e,(r=this.onStep)==null||r.call(this,this.current),this._loopTimestamp=Date.now(),this._animationFrameID=window.requestAnimationFrame(this.looper)}pause(){this._paused=!0,this._animationFrameID!=null&&window.cancelAnimationFrame(this._animationFrameID)}destroy(){this.pause(),this.onStep=void 0}stepper(){const e=-this.stiffness*(this.current-this.target),s=-this.damping*this.velocity,r=this.velocity+(e+s)/60,i=this.current+r/60;Math.abs(r-0)<.01&&Math.abs(i-this.target)<.01?(this.current=this.target,this.velocity=0,this._paused=!0):(this.current=i,this.velocity=r)}}class Ds{constructor(e,s,r,i,a,n){this.index=e,this.lastVisit=Date.now(),this.sideEffect=new k;const c=A(s,u=>u[e]||{width:0,height:0}),l=w([c,r],([u,h])=>(h.width-u.width)/2),o=w([a,n],([u,h])=>(u[e]||0)-h),d=document.createElement("div");d.className="page-renderer-page",d.dataset.index=`${e}`;const p=document.createElement("img");p.className="page-renderer-page-img",d.appendChild(p),this.sideEffect.addDisposer([w([c,i]).subscribe(([u,h])=>{d.style.width=`${u.width*h}px`,d.style.height=`${u.height*h}px`}),c.subscribe(u=>{u.thumbnail&&(d.style.backgroundImage=`url("${u.thumbnail}")`),p.width=u.width,p.height=u.height,p.src=u.src}),w([l,o,i]).subscribe(([u,h,g])=>{d.style.transform=`translate(${u*g}px, ${h*g}px)`})]),this.$page=d}destroy(){this.sideEffect.flushAll(),this.$page.remove()}}const Is=window.requestIdleCallback||(t=>window.setTimeout(t,5e3)),Ts=window.cancelIdleCallback||window.clearTimeout;class Ns{constructor(e,s,r,i,a){this.pages$=e,this.pagesSize$=s,this.scale$=r,this.pagesYs$=i,this.pagesScrollTop$=a,this.els=new Map,this.maxElCount=200,this.gcTimer=null,this.gc=()=>{var n;if(this.gcTimer=null,this.els.size>this.maxElCount){const c=[...this.els.values()].sort((l,o)=>o.lastVisit-l.lastVisit);for(let l=Math.floor(this.maxElCount/4);l<c.length;l++)(n=this.els.get(c[l].index))==null||n.destroy(),this.els.delete(c[l].index)}}}getEl(e){let s=this.els.get(e);return s||(s=new Ds(e,this.pages$,this.pagesSize$,this.scale$,this.pagesYs$,this.pagesScrollTop$),this.els.set(e,s)),s.lastVisit=Date.now(),this.els.size>this.maxElCount&&this.gcTimer===null&&(this.gcTimer=Is(this.gc)),s}destroy(){this.els.forEach(e=>e.destroy()),this.els.clear(),this.gcTimer!==null&&(Ts(this.gcTimer),this.gcTimer=null)}}class As{constructor({pagesScrollTop$:e,containerRect$:s,pages$:r,pagesSize$:i}){this.sideEffect=new k,r=A(r,h=>h.map(g=>{if(g.thumbnail)return g;try{const f=new URL(g.src);return f.searchParams.set("x-oss-process","image/resize,l_50"),{...g,thumbnail:f.toString()}}catch(f){return console.error(f),g}}));const a=A(r,h=>{const g=Array(h.length);for(let f=0;f<h.length;f++)g[f]=f>0?g[f-1]+h[f-1].height:0;return g}),n=A(r,h=>{let g=1/0;for(let f=h.length-1;f>=0;f--)h[f].height<=g&&(g=h[f].height);return g}),c=w([e,a,r],([h,g,f])=>{for(let m=0;m<g.length;m++)if(g[m]+f[m].height-h>=.001)return m;return g.length-1}),l=w([s,i],([h,g])=>h.width/g.width||1),o=w([r,s,n,l],([h,g,f,m])=>C(Math.ceil(g.height/m/f/2),1,h.length));ht(this,{pagesScrollTop:e,containerRect:s,pages:r,pagesSize:i,pagesIndex:c,pagesYs:a,pagesMinHeight:n,scale:l}),this.pageElManager=new Ns(r,i,l,a,e),this.$pages=this.renderPages();const d=new S(!1);this.sideEffect.addDisposer(d.subscribe(h=>this.$pages.classList.toggle("is-hwa",h)));const p=()=>d.setValue(!1),u=()=>{this.sideEffect.setTimeout(p,1e3,"turn-off-hwa"),d.setValue(!0)};this.sideEffect.addDisposer(w([c,o,r]).subscribe(([h,g,f])=>{u();const m=Math.max(h-g,0),Xe=Math.min(h+g,f.length-1);for(let L=0;L<this.$pages.children.length;L++){const M=this.$pages.children[L],Ke=Number(M.dataset.index);Ke>=m&&Ke<=Xe||(M.remove(),L--)}for(let L=m;L<=Xe;L++){const M=this.pageElManager.getEl(L);M.$page.parentElement!==this.$pages&&this.$pages.appendChild(M.$page)}}))}renderPages(){const e=document.createElement("div");return e.className="page-renderer-pages-container",this.sideEffect.addDisposer(this._containerRect$.subscribe(s=>{e.style.width=`${s.width}px`,e.style.height=`${s.height}px`}),"render-pages-size"),e}destroy(){this.sideEffect.flushAll(),this.$pages.remove(),this.pageElManager.destroy()}}const Ps=30;class Vs{constructor({pagesScrollTop$:e,containerRect$:s,stageRect$:r,pagesSize$:i,readonly$:a,scrollbarMinHeight:n=Ps,wrapClassName:c,onDragScroll:l}){this.sideEffect=new k,this.scrolling$=new S(!1),this.pagesScrollTop$=e,this.containerRect$=s,this.stageRect$=r,this.pagesSize$=i,this.scrollbarMinHeight=n,this.readonly$=a,this.wrapClassName=c,this.onDragScroll=l,this.scrollbarHeight$=w([s,r,i],([o,d,p])=>C(d.height/(d.width/p.width*p.height)*o.height,n,o.height)),this.scrollTop$=w([s,r,i,this.scrollbarHeight$,this.pagesScrollTop$],([o,d,p,u,h])=>C(h/(p.height-p.width/d.width*d.height)*(o.height-u),0,o.height-u)),this.$scrollbar=this.renderScrollbar()}mount(e){e.appendChild(this.$scrollbar)}destroy(){this.$scrollbar.remove(),this.onDragScroll=void 0,this.sideEffect.flushAll()}renderScrollbar(){const e=document.createElement("button");e.className=this.wrapClassName("scrollbar"),e.style.minHeight=`${this.scrollbarMinHeight}px`,this.sideEffect.addDisposer([this.scrollbarHeight$.subscribe(r=>{e.style.height=`${r}px`}),this.scrollTop$.subscribe(r=>{this.scrolling$.setValue(!0),this.sideEffect.setTimeout(()=>this.scrolling$.setValue(!1),100,"reset-scrolling");const i=()=>e.style.transform=`translateY(${r}px)`;window.requestAnimationFrame?window.requestAnimationFrame(i):i()}),this.scrolling$.subscribe(r=>{e.classList.toggle(this.wrapClassName("scrolling"),r)})]);const s=r=>{if(!r.isPrimary||this.readonly$.value||r.button!=null&&r.button!==0)return;qe(r);const i=this.wrapClassName("scrollbar-dragging");e.classList.toggle(i,!0);const a=this.pagesScrollTop$.value,{clientY:n}=Ge(r),c=o=>{if(!o.isPrimary||this.readonly$.value)return;const{clientY:d}=Ge(o),p=d-n;Math.abs(p)>0&&this.onDragScroll&&this.onDragScroll(a+p/this.containerRect$.value.height*this.pagesSize$.value.height)},l=o=>{!o.isPrimary||(e.classList.toggle(i,!1),window.removeEventListener("pointermove",c,!0),window.removeEventListener("pointerup",l,!0),window.removeEventListener("pointercancel",l,!0))};window.addEventListener("pointermove",c,!0),window.addEventListener("pointerup",l,!0),window.addEventListener("pointercancel",l,!0)};return this.sideEffect.addEventListener(e,"pointerdown",s),e}}class zs{constructor({whiteboard:e,readonly$:s,box:r,pages:i,pagesScrollTop:a=0,onUserScroll:n}){this.sideEffect=new k,this.userScrolling=!1,this.whiteboard=e,this.readonly$=s,this.box=r,this.pages=i,this.onUserScroll=n;const c=()=>{var o;this.userScrolling=!1,(o=this.onUserScroll)==null||o.call(this,this.pagesScrollTop$.value)};this.debounceOnUserScroll=()=>{this.userScrolling=!0,this.sideEffect.setTimeout(c,80,"debounceOnUserScroll")};const l=new S(i);this.pagesScrollTop$=new S(a),this.pagesSize$=A(l,o=>{let d=0,p=0;for(let u=o.length-1;u>=0;u--){const h=o[u];h.width>d&&(d=h.width),p+=h.height}return{width:Math.max(1,d),height:Math.max(1,p)}},{compare:Je}),this.pageRenderer=new As({pagesScrollTop$:this.pagesScrollTop$,containerRect$:r._stageRect$,pages$:l,pagesSize$:this.pagesSize$}),this.viewer=new Ye({readonly$:s,pagesIndex$:this.pageRenderer._pagesIndex$,box:r,pages:i,playable:!1}),this.sideEffect.addDisposer([this.viewer.events.on("next",()=>{this.userScrollByPercent(.8)}),this.viewer.events.on("back",()=>{this.userScrollByPercent(-.8)})]),this.scrollbar=new Vs({pagesScrollTop$:this.pagesScrollTop$,containerRect$:r._bodyRect$,stageRect$:r._stageRect$,pagesSize$:this.pagesSize$,readonly$:s,wrapClassName:this.wrapClassName.bind(this),onDragScroll:o=>{this.pageScrollTo(o),this.debounceOnUserScroll()}}),this.pageScrollStepper=new ks({start:this.pagesScrollTop$.value,onStep:o=>{this.pageScrollTo(o)}}),this.sideEffect.addDisposer(this.viewer.events.on("jumpPage",o=>this.userScrollToPageIndex(o))),this.render(),this.setupScrollListener(),this.sideEffect.setTimeout(()=>{this.userScrolling||this.pageScrollTo(this.pageRenderer.pagesScrollTop)},100)}get pagesScrollTop(){return this.pagesScrollTop$.value}destroy(){this.sideEffect.flushAll(),this.pageScrollStepper.destroy(),this.onUserScroll=void 0,this.viewer.destroy(),this.pageRenderer.destroy(),this.scrollbar.destroy()}syncPageScrollTop(e){!this.userScrolling&&e>=0&&Math.abs(this.pagesScrollTop$.value-e)>.01&&this.pageScrollStepper.stepTo(e,this.pagesScrollTop$.value)}render(){this.box.$content.style.overflow="hidden",this.box.mountStage(this.pageRenderer.$pages),this.scrollbar.mount(this.box.$body)}pageScrollTo(e){const s=this.whiteboard.view.size.height/2/this.pageRenderer.scale;this.whiteboard.view.moveCamera({centerY:C(e+s,s,this.pagesSize$.value.height-s),animationMode:"immediately"})}userScrollToPageIndex(e){var s;if(e=C(e,0,this.pages.length-1),!this.readonly$.value&&!Number.isNaN(e)){const r=this.pageRenderer.pagesYs[e];r>=0&&((s=this.onUserScroll)==null||s.call(this,r+5/this.pageRenderer.scale))}}userScrollByPercent(e){var s;this.readonly$.value||(s=this.onUserScroll)==null||s.call(this,C(this.pageRenderer.pagesScrollTop+this.pageRenderer.containerRect.height/this.pageRenderer.scale*C(e,-1,1),0,this.pageRenderer.pagesSize.height-this.pageRenderer.containerRect.height/this.pageRenderer.scale))}setupScrollListener(){this.sideEffect.addEventListener(this.box.$main,"wheel",e=>{qe(e),!this.readonly$.value&&this.pageScrollStepper.paused&&(this.pageScrollTo(this.pagesScrollTop+e.deltaY),this.debounceOnUserScroll())},{passive:!1}),this.sideEffect.addEventListener(this.box.$main,"touchmove",e=>{!this.readonly$.value&&e.touches.length>1&&this.debounceOnUserScroll()},{passive:!0,capture:!0}),this.sideEffect.add(()=>{const e=s=>{const{width:r,height:i}=this.whiteboard.view.size;if(r<=0||i<=0)return;const a=s.centerY-this.pageRenderer.containerRect.height/this.pageRenderer.scale/2;this.pagesScrollTop$.setValue(a)};return this.whiteboard.view.callbacks.on("onCameraUpdated",e),()=>this.whiteboard.view.callbacks.off("onCameraUpdated",e)}),this.sideEffect.addDisposer(this.box._stageRect$.subscribe(e=>{const{width:s,height:r}=this.pagesSize$.value;this.whiteboard.view.moveCameraToContain({originX:0,originY:this.pageRenderer.pagesScrollTop,width:s,height:e.height/this.pageRenderer.scale,animationMode:"immediately"}),this.whiteboard.view.setCameraBound({damping:1,maxContentMode:()=>this.pageRenderer.scale,minContentMode:()=>this.pageRenderer.scale,centerX:s/2,centerY:r/2,width:s,height:r})}),"whiteboard-size-update"),this.sideEffect.addEventListener(window,"keyup",e=>{if(!(this.readonly$.value||!this.box.focus||this.box.minimized))switch(e.key){case"PageDown":{this.userScrollByPercent(.8);break}case"PageUp":{this.userScrollByPercent(-.8);break}case"ArrowLeft":{this.userScrollByPercent(-.25);break}case"ArrowRight":{this.userScrollByPercent(.25);break}case"ArrowDown":{this.userScrollByPercent(.5);break}case"ArrowUp":{this.userScrollByPercent(-.5);break}}},{capture:!0})}wrapClassName(e){return"netless-app-docs-viewer-static-"+e}}class Os{constructor({readonly$:e,context:s,whiteboard:r,box:i,pages:a}){this.sideEffect=new k,this.context=s,this.whiteboard=r,this.box=i,this.pages=a;const n=new S(s.displayer.state.sceneState.index||0);this.pagesIndex$=n,this.sideEffect.add(()=>{const c=l=>{this.jumpToPage(l.index)};return this.context.emitter.on("sceneStateChange",c),()=>this.context.emitter.off("sceneStateChange",c)}),this.viewer=new Ye({readonly$:e,pagesIndex$:n,box:i,pages:a,playable:!0}),this.sideEffect.addDisposer([this.viewer.events.on("jumpPage",c=>this.jumpToPage(c,!0)),this.viewer.events.on("play",()=>{var c;return(c=this.context.room)==null?void 0:c.pptNextStep()}),this.viewer.events.on("back",()=>this.prevPage()),this.viewer.events.on("next",()=>this.nextPage())]),this.render(),this.sideEffect.addDisposer(n.subscribe((c,l)=>{var p,u;if(e.value)return;const o=this.context.getInitScenePath(),d=(u=(p=this.context.getScenes())==null?void 0:p[c])==null?void 0:u.name;if(o&&d&&this.context.setScenePath(`${o}/${d}`),l){const h=this.context.room;if(h){const g=h.state.globalState.__pptState;h.setGlobalState({__pptState:g&&{uuid:g.uuid,pageIndex:c,disableAutoPlay:g.disableAutoPlay}})}}}))}destroy(){this.sideEffect.flushAll(),this.viewer.destroy()}nextPage(){this.jumpToPage(this.pagesIndex$.value+1,!0)}prevPage(){this.jumpToPage(this.pagesIndex$.value-1,!0)}jumpToPage(e,s=!1){this.pagesIndex$.setValue(C(e,0,this.pages.length-1),s)}render(){var s;this.box.mountStage(document.createElement("div")),this.sideEffect.addEventListener(window,"keydown",r=>{var i;if(this.box.focus)switch(r.key){case"ArrowUp":case"ArrowLeft":{this.prevPage();break}case"ArrowRight":case"ArrowDown":{(i=this.context.room)==null||i.pptNextStep();break}}});const e=(s=this.whiteboard.view.divElement)==null?void 0:s.parentElement;e&&this.sideEffect.addEventListener(e,"click",r=>{var a;const i=this.context.room;if(i&&i.state.memberState.currentApplianceName==="clicker"){for(let n=r.target;n;n=n.parentElement)if((a=n.classList)!=null&&a.contains("ppt-event-source"))return;i.pptNextStep()}})}wrapClassName(e){return"netless-app-docs-viewer-dynamic-"+e}}const Ms={kind:"DocsViewer",setup(t){const e=t.box,s=t.getScenes();if(!s)throw new Error("[Docs Viewer]: scenes not found.");const r=new k,i=s.map(({ppt:n})=>n?{width:n.width,height:n.height,src:n.src,thumbnail:n.previewURL}:null).filter(n=>Boolean(n));if(i.length<=0)throw new Error("[Docs Viewer]: empty scenes.");e.mountStyles(Qe);const a=new S(!t.isWritable);r.addDisposer(t.emitter.on("writableChange",n=>{a.setValue(!n)})),i[0].src.startsWith("ppt")?Hs(r,t,e,i,a):Rs(r,t,e,i,a),r.addDisposer(t.emitter.on("destroy",()=>{r.flushAll()}))}};function Rs(t,e,s,r,i){const a=e.createWhiteBoardView({syncCamera:!1});t.addDisposer(i.subscribe(l=>{a.view.disableCameraTransform=l}));const n=e.createStorage("static-docs-viewer",{pagesScrollTop:0}),c=new zs({whiteboard:a,readonly$:i,box:s,pages:r,pagesScrollTop:n.state.pagesScrollTop,onUserScroll:l=>{e.isWritable&&n.setState({pagesScrollTop:l})}});t.addDisposer(()=>c.destroy()),t.addDisposer(n.addStateChangedListener(l=>{l.pagesScrollTop&&c.syncPageScrollTop(l.pagesScrollTop.newValue||0)})),t.addDisposer(w([s._maximized$,s._managerStageRect$,s._intrinsicSize$,c.pagesSize$,c.pageRenderer._pagesMinHeight$],([l,o,d,p,u])=>l?Math.max(u/p.width*.4,o.height/o.width):d.height/d.width*(o.height/o.width)).subscribe(l=>{s.setStageRatio(l)}))}function Hs(t,e,s,r,i){const a=e.createWhiteBoardView();a.view.disableCameraTransform=!0;const n=new Os({context:e,whiteboard:a,box:s,pages:r,readonly$:i});t.addDisposer(()=>n.destroy());const c=new S({width:r[0].width,height:r[0].height},{compare:Je});if(t.addDisposer(n.pagesIndex$.subscribe(l=>{const o=r[l];o&&c.setValue({width:o.width,height:o.height})})),t.addDisposer(c.subscribe(l=>{i.value||a.setBaseRect(l)})),e.isAddApp){const l=t.add(()=>{const o=({width:d,height:p})=>{if(r.length>0&&s.state!=="maximized"){const{width:u,height:h}=r[0],f=h/u*d-p;f!==0&&e.isWritable&&e.emitter.emit("setBoxSize",{width:s.intrinsicWidth,height:s.intrinsicHeight+f/s.rootRect.height})}t.remove(l)};return a.view.callbacks.once("onSizeUpdated",o),()=>a.view.callbacks.off("onSizeUpdated",o)})}}return j.default=Ms,Object.defineProperties(j,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),j}({}); | ||
const NetlessAppDocsViewer=function(j){"use strict";const Qe=`.netless-app-docs-viewer-footer{box-sizing:border-box;height:26px;display:flex;align-items:center;padding:0 16px;border-top:1px solid #eeeef7;font-family:PingFang SC,Source Han Sans SC,Microsoft YaHei,Helvetica Neue,Noto Sans CJK SC,WenQuanYi Micro Hei,sans-serif}.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{display:flex;align-items:center;height:26px;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 .5em 0 2px;text-align:right;font-size:13px;line-height:1;font-weight:400;font-family:inherit;border-radius:2px;color:currentColor;font-family:PingFang SC,Source Han Sans SC,Microsoft YaHei,Helvetica Neue,Noto Sans CJK SC,WenQuanYi Micro Hei,sans-serif;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}.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:currentColor;background:#25282e}.telebox-color-scheme-dark .netless-app-docs-viewer-footer{border-top:none}.telebox-color-scheme-dark .netless-app-docs-viewer-footer-btn:hover{background:#212126}.netless-app-docs-viewer-preview.netless-app-docs-viewer-preview-active{transform:translate(0)}.netless-app-docs-viewer-content{position:relative;height:100%;overflow:hidden}.netless-app-docs-viewer-preview-mask{position:absolute;z-index:10200;top:0;left:0;width:100%;height:100%}.netless-app-docs-viewer-preview{box-sizing:border-box;display:flex;flex-direction:column;align-items:center;position:absolute;z-index:10300;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;user-select:none}.telebox-color-scheme-dark .netless-app-docs-viewer-preview{background:rgba(50,50,50,.9)}.netless-app-docs-viewer-static-scrollbar{box-sizing:border-box;position:absolute;top:0;right:0;z-index:2147483647;width:16px;min-height:30px;margin:0;padding:0 0 0 8px;border:none;outline:none;opacity:0;background:transparent;transition:opacity .4s 3s,transform .1s;user-select:none;touch-action:none}.netless-app-docs-viewer-static-scrollbar:after{content:"";display:block;width:8px;height:100%;border-radius:4px;background:rgba(68,78,96,.4);box-shadow:1px 1px 8px #ffffffb3;transition:background .4s}.netless-app-docs-viewer-static-scrollbar.netless-app-docs-viewer-static-scrolling{opacity:1;transition:opacity .4s,transform .1s}.netless-app-docs-viewer-static-scrollbar.netless-app-docs-viewer-static-scrollbar-dragging{opacity:1;transition:opacity .4s 3s!important}.netless-app-docs-viewer-static-scrollbar.netless-app-docs-viewer-static-scrollbar-dragging:after{background:rgba(68,78,96,.6)}.netless-app-docs-viewer-static-scrollbar:hover:after,.netless-app-docs-viewer-static-scrollbar:focus:after{background:rgba(68,78,96,.5)}.netless-app-docs-viewer-static-scrollbar:active:after{background:rgba(68,78,96,.6)}.telebox-body-wrap:hover .netless-app-docs-viewer-static-scrollbar{opacity:1;transition:opacity .4s,transform .1s}.telebox-readonly .netless-app-docs-viewer-static-scrollbar{display:none}.page-renderer-pages-container{position:relative;width:100%;height:100%}.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-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} | ||
`,oe="!#%()*+,-./:;=?@[]^_`{|}~ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",Ze=oe.length,ne=Array(20),et=()=>{for(let t=0;t<20;t++)ne[t]=oe.charAt(Math.random()*Ze);return ne.join("")};function ce(t){try{return t()}catch(e){console.error(e)}}class k{constructor(){this.disposers=new Map}addDisposer(e,s=this.genUID()){return this.flush(s),this.disposers.set(s,Array.isArray(e)?()=>e.forEach(ce):e),s}add(e,s=this.genUID()){const r=e();return r?this.addDisposer(r,s):s}addEventListener(e,s,r,i,a=this.genUID()){return e.addEventListener(s,r,i),this.addDisposer(()=>e.removeEventListener(s,r,i),a),a}setTimeout(e,s,r=this.genUID()){const i=window.setTimeout(()=>{this.remove(r),e()},s);return this.addDisposer(()=>window.clearTimeout(i),r)}setInterval(e,s,r=this.genUID()){const i=window.setInterval(e,s);return this.addDisposer(()=>window.clearInterval(i),r)}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(r){console.error(r)}}flushAll(){this.disposers.forEach(ce),this.disposers.clear()}genUID(){let e;do e=et();while(this.disposers.has(e));return e}}var tt=Object.defineProperty,st=Object.defineProperties,rt=Object.getOwnPropertyDescriptors,le=Object.getOwnPropertySymbols,it=Object.prototype.hasOwnProperty,at=Object.prototype.propertyIsEnumerable,W=(t,e,s)=>e in t?tt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,de=(t,e)=>{for(var s in e||(e={}))it.call(e,s)&&W(t,s,e[s]);if(le)for(var s of le(e))at.call(e,s)&&W(t,s,e[s]);return t},he=(t,e)=>st(t,rt(e)),E=(t,e,s)=>(W(t,typeof e!="symbol"?e+"":e,s),s);class ot{constructor(e){E(this,"_subscribers"),E(this,"_bSub"),E(this,"_bSubDisposer"),this._bSub=e}get size(){return this._subscribers?this._subscribers.size:0}invoke(e,s){this._subscribers&&this._subscribers.forEach(r=>r(e,s))}add(e){this._bSub&&(!this._subscribers||this._subscribers.size<=0)&&(this._bSubDisposer=this._bSub()),this._subscribers||(this._subscribers=new Set),this._subscribers.add(e)}remove(e){if(this._subscribers&&this._subscribers.delete(e),this._subscribers&&this._subscribers.size<=0&&this._bSubDisposer){const s=this._bSubDisposer;this._bSubDisposer=null,s()}}clear(){if(this._subscribers&&this._subscribers.clear(),this._bSubDisposer){const e=this._bSubDisposer;this._bSubDisposer=null,e()}}destroy(){this.clear()}}class Y{constructor(e,s){E(this,"_subscribers"),E(this,"_value"),this._value=e;let r;if(s&&(s.compare&&(this.compare=s.compare),s.beforeSubscribe)){const i=s.beforeSubscribe,a=this._setValue.bind(this);r=()=>i(a)}this._subscribers=new ot(r)}_setValue(e,s){this.compare(e,this._value)||(this._value=e,this._subscribers.invoke(e,s))}get value(){return this._value}reaction(e){return this._subscribers.add(e),()=>{this._subscribers.remove(e)}}subscribe(e,s){const r=this.reaction(e);return e(this._value,s),r}destroy(){this._subscribers.destroy()}unsubscribe(e){this._subscribers.remove(e)}get size(){return this._subscribers.size}compare(e,s){return e===s}}class S extends Y{constructor(){super(...arguments),E(this,"setValue",this._setValue)}}class nt extends Y{constructor(e,s,r={}){super(s(e.value),he(de({},r),{beforeSubscribe:i=>{const a=e.subscribe((n,c)=>i(s(n),c));if(r.beforeSubscribe){const n=r.beforeSubscribe(i);if(n)return()=>{a(),n()}}return a}})),E(this,"_srcValue"),this._srcValue=()=>s(e.value)}get value(){if(this.size<=0){const e=this._srcValue();return this.compare(e,this._value)?this._value:e}return this._value}}function A(t,e=r=>r,s={}){return new nt(t,e,s)}class ct extends Y{constructor(e,s,r={}){super(s(G(e)),he(de({},r),{beforeSubscribe:i=>{let a=G(e);i(s(a));const n=e.map((l,o)=>l.reaction((d,p)=>{a=a.slice(),a[o]=d,i(s(a),p)})),c=()=>n.forEach(l=>l());if(r.beforeSubscribe){const l=r.beforeSubscribe(i);if(l)return()=>{c(),l()}}return c}})),E(this,"_srcValue"),this._srcValue=()=>s(G(e))}get value(){if(this.size<=0){const e=this._srcValue();return this.compare(e,this._value)?this._value:e}return this._value}}function G(t){return t.map(lt)}function lt(t){return t.value}function w(t,e=r=>r,s={}){return new ct(t,e,s)}function pe(t){t.onValChanged||(t.onValChanged=dt)}function dt(t,e){const s=this[`_${t}$`]||this[t];if(!(s!=null&&s.reaction))throw new TypeError(`"${t}" is not related to a Val in this instance`);return s.reaction(e)}function ht(t,e,s){Object.keys(e).forEach(r=>{pt(t,r,e[r]),s&&s.attach(e[r])}),pe(t)}function pt(t,e,s){return Object.defineProperties(t,{[e]:{get(){return s.value}},[`_${e}$`]:{value:s}}),t}function ut(t,e,s){Object.keys(e).forEach(r=>{gt(t,r,e[r]),s&&s.attach(e[r])}),pe(t)}function gt(t,e,s){return Object.defineProperties(t,{[e]:{get(){return s.value},set(r){s.setValue(r)}},[`_${e}$`]:{value:s},[`set${ft(e)}`]:{value:(r,i)=>s.setValue(r,i)}}),t}function ft(t){return t[0].toUpperCase()+t.slice(1)}const y=typeof window<"u",ue=y&&!("onscroll"in window)||typeof navigator<"u"&&/(gle|ing|ro)bot|crawl|spider/i.test(navigator.userAgent),ge=y&&"IntersectionObserver"in window,fe=y&&"classList"in document.createElement("p"),be=y&&window.devicePixelRatio>1,bt={elements_selector:".lazy",container:ue||y?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_bg_set:"bg-set",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,restore_on_error:!1},we=t=>Object.assign({},bt,t),ve=function(t,e){let s;const r="LazyLoad::Initialized",i=new t(e);try{s=new CustomEvent(r,{detail:{instance:i}})}catch{s=document.createEvent("CustomEvent"),s.initCustomEvent(r,!1,!1,{instance:i})}window.dispatchEvent(s)},wt=(t,e)=>{if(!!e)if(!e.length)ve(t,e);else for(let s=0,r;r=e[s];s+=1)ve(t,r)},_="src",q="srcset",J="sizes",me="poster",P="llOriginalAttrs",Se="data",X="loading",_e="loaded",Ee="applied",vt="entered",K="error",ye="native",$e="data-",xe="ll-status",b=(t,e)=>t.getAttribute($e+e),mt=(t,e,s)=>{var r=$e+e;if(s===null){t.removeAttribute(r);return}t.setAttribute(r,s)},V=t=>b(t,xe),D=(t,e)=>mt(t,xe,e),R=t=>D(t,null),Q=t=>V(t)===null,St=t=>V(t)===X,_t=t=>V(t)===K,Z=t=>V(t)===ye,Et=[X,_e,Ee,K],yt=t=>Et.indexOf(V(t))>=0,$=(t,e,s,r)=>{if(!!t){if(r!==void 0){t(e,s,r);return}if(s!==void 0){t(e,s);return}t(e)}},T=(t,e)=>{if(fe){t.classList.add(e);return}t.className+=(t.className?" ":"")+e},v=(t,e)=>{if(fe){t.classList.remove(e);return}t.className=t.className.replace(new RegExp("(^|\\s+)"+e+"(\\s+|$)")," ").replace(/^\s+/,"").replace(/\s+$/,"")},$t=t=>{t.llTempImage=document.createElement("IMG")},xt=t=>{delete t.llTempImage},Ce=t=>t.llTempImage,H=(t,e)=>{if(!e)return;const s=e._observer;!s||s.unobserve(t)},Ct=t=>{t.disconnect()},Lt=(t,e,s)=>{e.unobserve_entered&&H(t,s)},ee=(t,e)=>{!t||(t.loadingCount+=e)},kt=t=>{!t||(t.toLoadCount-=1)},Le=(t,e)=>{!t||(t.toLoadCount=e)},Dt=t=>t.loadingCount>0,It=t=>t.toLoadCount>0,ke=t=>{let e=[];for(let s=0,r;r=t.children[s];s+=1)r.tagName==="SOURCE"&&e.push(r);return e},te=(t,e)=>{const s=t.parentNode;if(!s||s.tagName!=="PICTURE")return;ke(s).forEach(e)},De=(t,e)=>{ke(t).forEach(e)},B=[_],Ie=[_,me],z=[_,q,J],Te=[Se],U=t=>!!t[P],Ne=t=>t[P],Ae=t=>delete t[P],N=(t,e)=>{if(U(t))return;const s={};e.forEach(r=>{s[r]=t.getAttribute(r)}),t[P]=s},Tt=t=>{U(t)||(t[P]={backgroundImage:t.style.backgroundImage})},Nt=(t,e,s)=>{if(!s){t.removeAttribute(e);return}t.setAttribute(e,s)},I=(t,e)=>{if(!U(t))return;const s=Ne(t);e.forEach(r=>{Nt(t,r,s[r])})},At=t=>{if(!U(t))return;const e=Ne(t);t.style.backgroundImage=e.backgroundImage},Pe=(t,e,s)=>{T(t,e.class_applied),D(t,Ee),s&&(e.unobserve_completed&&H(t,e),$(e.callback_applied,t,s))},Ve=(t,e,s)=>{T(t,e.class_loading),D(t,X),s&&(ee(s,1),$(e.callback_loading,t,s))},x=(t,e,s)=>{!s||t.setAttribute(e,s)},ze=(t,e)=>{x(t,J,b(t,e.data_sizes)),x(t,q,b(t,e.data_srcset)),x(t,_,b(t,e.data_src))},Pt=(t,e)=>{te(t,s=>{N(s,z),ze(s,e)}),N(t,z),ze(t,e)},Vt=(t,e)=>{N(t,B),x(t,_,b(t,e.data_src))},zt=(t,e)=>{De(t,s=>{N(s,B),x(s,_,b(s,e.data_src))}),N(t,Ie),x(t,me,b(t,e.data_poster)),x(t,_,b(t,e.data_src)),t.load()},Ot=(t,e)=>{N(t,Te),x(t,Se,b(t,e.data_src))},Mt=(t,e,s)=>{const r=b(t,e.data_bg),i=b(t,e.data_bg_hidpi),a=be&&i?i:r;!a||(t.style.backgroundImage=`url("${a}")`,Ce(t).setAttribute(_,a),Ve(t,e,s))},Rt=(t,e,s)=>{const r=b(t,e.data_bg_multi),i=b(t,e.data_bg_multi_hidpi),a=be&&i?i:r;!a||(t.style.backgroundImage=a,Pe(t,e,s))},Ht=(t,e,s)=>{const r=b(t,e.data_bg_set);if(!r)return;const i=r.split("|");let a=i.map(n=>`image-set(${n})`);t.style.backgroundImage=a.join(),t.style.backgroundImage===""&&(a=i.map(n=>`-webkit-image-set(${n})`),t.style.backgroundImage=a.join()),Pe(t,e,s)},Oe={IMG:Pt,IFRAME:Vt,VIDEO:zt,OBJECT:Ot},Bt=(t,e)=>{const s=Oe[t.tagName];!s||s(t,e)},Ut=(t,e,s)=>{const r=Oe[t.tagName];!r||(r(t,e),Ve(t,e,s))},Ft=["IMG","IFRAME","VIDEO","OBJECT"],jt=t=>Ft.indexOf(t.tagName)>-1,Me=(t,e)=>{e&&!Dt(e)&&!It(e)&&$(t.callback_finish,e)},Re=(t,e,s)=>{t.addEventListener(e,s),t.llEvLisnrs[e]=s},Wt=(t,e,s)=>{t.removeEventListener(e,s)},se=t=>!!t.llEvLisnrs,Yt=(t,e,s)=>{se(t)||(t.llEvLisnrs={});const r=t.tagName==="VIDEO"?"loadeddata":"load";Re(t,r,e),Re(t,"error",s)},re=t=>{if(!se(t))return;const e=t.llEvLisnrs;for(let s in e){const r=e[s];Wt(t,s,r)}delete t.llEvLisnrs},He=(t,e,s)=>{xt(t),ee(s,-1),kt(s),v(t,e.class_loading),e.unobserve_completed&&H(t,s)},Gt=(t,e,s,r)=>{const i=Z(e);He(e,s,r),T(e,s.class_loaded),D(e,_e),$(s.callback_loaded,e,r),i||Me(s,r)},qt=(t,e,s,r)=>{const i=Z(e);He(e,s,r),T(e,s.class_error),D(e,K),$(s.callback_error,e,r),s.restore_on_error&&I(e,z),i||Me(s,r)},ie=(t,e,s)=>{const r=Ce(t)||t;if(se(r))return;Yt(r,n=>{Gt(n,t,e,s),re(r)},n=>{qt(n,t,e,s),re(r)})},Jt=(t,e,s)=>{$t(t),ie(t,e,s),Tt(t),Mt(t,e,s),Rt(t,e,s),Ht(t,e,s)},Xt=(t,e,s)=>{ie(t,e,s),Ut(t,e,s)},ae=(t,e,s)=>{jt(t)?Xt(t,e,s):Jt(t,e,s)},Kt=(t,e,s)=>{t.setAttribute("loading","lazy"),ie(t,e,s),Bt(t,e),D(t,ye)},Be=t=>{t.removeAttribute(_),t.removeAttribute(q),t.removeAttribute(J)},Qt=t=>{te(t,e=>{Be(e)}),Be(t)},Ue=t=>{te(t,e=>{I(e,z)}),I(t,z)},Zt={IMG:Ue,IFRAME:t=>{I(t,B)},VIDEO:t=>{De(t,e=>{I(e,B)}),I(t,Ie),t.load()},OBJECT:t=>{I(t,Te)}},es=t=>{const e=Zt[t.tagName];if(!e){At(t);return}e(t)},ts=(t,e)=>{Q(t)||Z(t)||(v(t,e.class_entered),v(t,e.class_exited),v(t,e.class_applied),v(t,e.class_loading),v(t,e.class_loaded),v(t,e.class_error))},ss=(t,e)=>{es(t),ts(t,e),R(t),Ae(t)},rs=(t,e,s,r)=>{!s.cancel_on_exit||!St(t)||t.tagName==="IMG"&&(re(t),Qt(t),Ue(t),v(t,s.class_loading),ee(r,-1),R(t),$(s.callback_cancel,t,e,r))},is=(t,e,s,r)=>{const i=yt(t);D(t,vt),T(t,s.class_entered),v(t,s.class_exited),Lt(t,s,r),$(s.callback_enter,t,e,r),!i&&ae(t,s,r)},as=(t,e,s,r)=>{Q(t)||(T(t,s.class_exited),rs(t,e,s,r),$(s.callback_exit,t,e,r))},os=["IMG","IFRAME","VIDEO"],Fe=t=>t.use_native&&"loading"in HTMLImageElement.prototype,ns=(t,e,s)=>{t.forEach(r=>{os.indexOf(r.tagName)!==-1&&Kt(r,e,s)}),Le(s,0)},cs=t=>t.isIntersecting||t.intersectionRatio>0,ls=t=>({root:t.container===document?null:t.container,rootMargin:t.thresholds||t.threshold+"px"}),ds=(t,e,s)=>{t.forEach(r=>cs(r)?is(r.target,r,e,s):as(r.target,r,e,s))},hs=(t,e)=>{e.forEach(s=>{t.observe(s)})},ps=(t,e)=>{Ct(t),hs(t,e)},us=(t,e)=>{!ge||Fe(t)||(e._observer=new IntersectionObserver(s=>{ds(s,t,e)},ls(t)))},je=t=>Array.prototype.slice.call(t),F=t=>t.container.querySelectorAll(t.elements_selector),gs=t=>je(t).filter(Q),fs=t=>_t(t),bs=t=>je(t).filter(fs),We=(t,e)=>gs(t||F(e)),ws=(t,e)=>{bs(F(t)).forEach(r=>{v(r,t.class_error),R(r)}),e.update()},vs=(t,e)=>{!y||(e._onlineHandler=()=>{ws(t,e)},window.addEventListener("online",e._onlineHandler))},ms=t=>{!y||window.removeEventListener("online",t._onlineHandler)},O=function(t,e){const s=we(t);this._settings=s,this.loadingCount=0,us(s,this),vs(s,this),this.update(e)};O.prototype={update:function(t){const e=this._settings,s=We(t,e);if(Le(this,s.length),ue||!ge){this.loadAll(s);return}if(Fe(e)){ns(s,e,this);return}ps(this._observer,s)},destroy:function(){this._observer&&this._observer.disconnect(),ms(this),F(this._settings).forEach(t=>{Ae(t)}),delete this._observer,delete this._settings,delete this._onlineHandler,delete this.loadingCount,delete this.toLoadCount},loadAll:function(t){const e=this._settings;We(t,e).forEach(r=>{H(r,this),ae(r,e,this)})},restoreAll:function(){const t=this._settings;F(t).forEach(e=>{ss(e,t)})}},O.load=(t,e)=>{const s=we(e);ae(t,s)},O.resetStatus=t=>{R(t)},y&&wt(O,window.lazyLoadOptions);class Ss{constructor({namespace:e,pages$:s,sideEffect:r,readonly$:i,events:a,wrapClassName:n,root:c,pagesIndex$:l}){this.showPreview$=new S(!1),this.namespace=e,this.pages$=s,this.sideEffect=r,this.readonly$=i,this.events=a,this.wrapClassName=n,this.sideEffect.addDisposer(this.events.on("togglePreview",()=>{this.showPreview$.setValue(!this.showPreview$.value)})),this.sideEffect.addDisposer(this.showPreview$.subscribe(o=>{this.sideEffect.add(()=>{const d=this.renderPreview(),p=this.renderPreviewMask();if(o){c.appendChild(d),c.appendChild(p),d.scrollTop;const u=d.querySelector("."+this.wrapClassName(`preview-page-${l.value}`));return u&&d.scrollTo({top:u.offsetTop-16}),d.classList.toggle(this.wrapClassName("preview-active"),!0),this.previewLazyLoad=new O({container:this.$preview,elements_selector:"."+this.wrapClassName("preview-page>img")}),()=>{var h;return(h=this.previewLazyLoad)==null?void 0:h.destroy()}}else return d.classList.toggle(this.wrapClassName("preview-active"),!1),this.sideEffect.setTimeout(()=>{d.remove(),p.remove()},500,"preview-remove"),null},"preview-lazyload")}))}destroy(){var e,s;(e=this.$preview)==null||e.remove(),(s=this.$previewMask)==null||s.remove()}renderPreview(){if(this.$preview)return this.$preview;const e=document.createElement("div");return e.className=this.wrapClassName("preview")+" tele-fancy-scrollbar",this.$preview=e,this.sideEffect.addEventListener(e,"wheel",s=>s.stopPropagation(),{passive:!1}),this.sideEffect.addDisposer(this.pages$.subscribe(s=>{var r;this.sideEffect.add(()=>{const i=s.map((a,n)=>{var u;const c=(u=a.thumbnail)!=null?u:a.src.startsWith("ppt")?void 0:a.src;if(!c)return;const l=String(n),o=document.createElement("a");o.className=this.wrapClassName("preview-page")+" "+this.wrapClassName(`preview-page-${n}`),o.setAttribute("href","#"),o.dataset.pageIndex=l;const d=document.createElement("span");d.className=this.wrapClassName("preview-page-name"),d.textContent=String(n+1),d.dataset.pageIndex=l;const p=document.createElement("img");return p.width=a.width,p.height=a.height,p.dataset.src=c,p.dataset.pageIndex=l,o.appendChild(p),o.appendChild(d),e.appendChild(o),o});return()=>i.forEach(a=>a==null?void 0:a.remove())},"render-preview-pages"),(r=this.previewLazyLoad)==null||r.update()})),this.sideEffect.addEventListener(e,"click",s=>{var i;if(this.readonly$.value)return;const r=(i=s.target.dataset)==null?void 0:i.pageIndex;r&&(s.preventDefault(),s.stopPropagation(),s.stopImmediatePropagation(),this.events.emit("jumpPage",Number(r)),this.showPreview$.setValue(!1))}),e}renderPreviewMask(){if(this.$previewMask)return this.$previewMask;const e=document.createElement("div");return e.className=this.wrapClassName("preview-mask"),this.$previewMask=e,this.sideEffect.addEventListener(e,"click",s=>{this.readonly$.value||s.target===e&&this.showPreview$.setValue(!1)}),e}}function _s(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 r=document.createElementNS(e,"path");return r.setAttribute("fill","currentColor"),r.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(r),s}function Es(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 r=document.createElementNS(e,"path");return r.setAttribute("fill","currentColor"),r.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(r),s}function ys(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 r=document.createElementNS(e,"path");return r.setAttribute("fill","currentColor"),r.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(r),s}function $s(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 r=document.createElementNS(e,"path");return r.setAttribute("fill","currentColor"),r.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(r),s}function xs(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 r=document.createElementNS(e,"path");return r.setAttribute("fill","currentColor"),r.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(r),s}class Cs{constructor({namespace:e,pages$:s,sideEffect:r,readonly$:i,events:a,playable:n,wrapClassName:c,pagesIndex$:l,root:o}){this.namespace=e,this.pages$=s,this.sideEffect=r,this.readonly$=i,this.events=a,this.wrapClassName=c,this.pagesIndex$=l,this.playable=n,this.$footer=this.render(),o.appendChild(this.$footer)}destroy(){this.$footer.remove()}render(){const e=document.createElement("div");e.className=this.wrapClassName("footer"),this.sideEffect.addDisposer(this.readonly$.subscribe(o=>e.classList.toggle(this.wrapClassName("readonly"),o)));const s=this.renderFooterBtn("btn-sidebar",_s(this.namespace));this.sideEffect.addEventListener(s,"click",()=>{this.readonly$.value||this.events.emit("togglePreview")}),e.appendChild(s),this.sideEffect.addDisposer(this.pages$.subscribe(o=>{const d=o.some(p=>p.thumbnail||!p.src.startsWith("ppt"));s.style.display=d?"":"none"}));const r=document.createElement("div");r.className=this.wrapClassName("page-jumps");const i=this.renderFooterBtn("btn-page-back",Es(this.namespace));if(this.sideEffect.addEventListener(i,"click",()=>{this.readonly$.value||this.events.emit("back")}),r.appendChild(i),this.playable){const o=this.renderFooterBtn("btn-page-play",$s(this.namespace),xs(this.namespace));this.sideEffect.addEventListener(o,"click",()=>{this.readonly$.value||(o.classList.toggle(this.wrapClassName("footer-btn-playing"),!0),this.events.emit("play"),this.sideEffect.setTimeout(()=>o.classList.toggle(this.wrapClassName("footer-btn-playing"),!1),500,"returnPlay"))}),r.appendChild(o)}const a=this.renderFooterBtn("btn-page-next",ys(this.namespace));this.sideEffect.addEventListener(a,"click",()=>{this.readonly$.value||this.events.emit("next")}),r.appendChild(a);const n=document.createElement("div");n.className=this.wrapClassName("page-number");const c=document.createElement("input");c.className=this.wrapClassName("page-number-input"),this.sideEffect.addDisposer(this.readonly$.subscribe(o=>c.disabled=o)),this.sideEffect.addDisposer(this.pagesIndex$.subscribe(o=>c.value=String(o+1))),this.sideEffect.addEventListener(c,"focus",()=>{c.select()}),this.sideEffect.addEventListener(c,"change",()=>{if(this.readonly$.value)return;const o=Number(c.value)-1;o>=0&&this.events.emit("jumpPage",o)});const l=document.createElement("span");return this.sideEffect.addDisposer(this.pages$.subscribe(o=>{l.textContent=" / "+o.length})),n.appendChild(c),n.appendChild(l),e.appendChild(r),e.appendChild(n),e}renderFooterBtn(e,s,r){const i=document.createElement("button");return i.className=this.wrapClassName("footer-btn")+" "+this.wrapClassName(e),i.appendChild(s),r&&i.appendChild(r),i}}class Ls{constructor(){this.listeners=new Map,this.relayListeners=new Set}emit(e,s){var r;(r=this.listeners.get(e))==null||r.forEach(i=>i(s))}on(e,s){let r=this.listeners.get(e);return r||(r=new Set,this.listeners.set(e,r)),r.add(s),r.size===1&&this.relayListeners.forEach(i=>i.start(e)),()=>{this.off(e,s)}}off(e,s){const r=this.listeners.get(e);if(r){const i=r.delete(s);return r.size<=0&&(this.listeners.delete(e),this.relayListeners.forEach(a=>a.dispose(e))),i}return!1}clear(e){var s;e?(s=this.listeners.get(e))==null||s.clear():this.listeners.clear()}count(e){var s;if(e)return((s=this.listeners.get(e))==null?void 0:s.size)||0;{let r=0;return this.listeners.forEach(i=>{r+=i.size}),r}}remit(e,s){let r;const i={start:a=>{a===e&&(r=s(this))},dispose:a=>{r&&(!a||a===e)&&r()}};return this.relayListeners.add(i),()=>{this.relayListeners.delete(i),r&&r()}}destroy(){this.clear(),this.relayListeners.forEach(e=>e.dispose()),this.relayListeners.clear()}}class Ye{constructor({readonly$:e,pagesIndex$:s,box:r,pages:i=[],playable:a}){this.wrapClassName=c=>`${this.namespace}-${c}`,this.namespace="netless-app-docs-viewer",this.sideEffect=new k,this.events=new Ls;const n=new S(i);ut(this,{pages:n}),this.preview=new Ss({pages$:n,readonly$:e,pagesIndex$:s,root:r.$body,sideEffect:this.sideEffect,events:this.events,namespace:this.namespace,wrapClassName:this.wrapClassName}),this.footer=new Cs({pages$:n,readonly$:e,playable:a,pagesIndex$:s,root:r.$footer,namespace:this.namespace,sideEffect:this.sideEffect,events:this.events,wrapClassName:this.wrapClassName})}destroy(){this.preview.destroy(),this.footer.destroy(),this.sideEffect.flushAll(),this.events.destroy()}}function C(t,e,s){return Math.min(Math.max(t,e),s)}function Ge(t){return t.touches?t.touches[0]:t}function qe(t){t.stopPropagation(),t.cancelable&&t.preventDefault()}function Je(t,e){return t.width===e.width&&t.height===e.height}class ks{constructor(e){var s,r,i;this.velocity=0,this._paused=!0,this._animationFrameID=null,this._loopTimestamp=0,this.looper=a=>{var c;if(this._paused)return;let n=Math.floor((a-this._loopTimestamp)/1e3*60)+1;for(this._loopTimestamp=a;n-- >0;)this.stepper();(c=this.onStep)==null||c.call(this,this.current),this._paused?this._animationFrameID=null:this._animationFrameID=window.requestAnimationFrame(this.looper)},this.current=(s=e.start)!=null?s:0,this.target=this.current,this.stiffness=(r=e.stiffness)!=null?r:170,this.damping=(i=e.damping)!=null?i:26,this.onStep=e.onStep}get paused(){return this._paused}stepTo(e,s){var r;this._paused&&s!=null&&(this.current=s),this._paused=!1,this.target=e,(r=this.onStep)==null||r.call(this,this.current),this._loopTimestamp=Date.now(),this._animationFrameID=window.requestAnimationFrame(this.looper)}pause(){this._paused=!0,this._animationFrameID!=null&&window.cancelAnimationFrame(this._animationFrameID)}destroy(){this.pause(),this.onStep=void 0}stepper(){const e=-this.stiffness*(this.current-this.target),s=-this.damping*this.velocity,r=this.velocity+(e+s)/60,i=this.current+r/60;Math.abs(r-0)<.01&&Math.abs(i-this.target)<.01?(this.current=this.target,this.velocity=0,this._paused=!0):(this.current=i,this.velocity=r)}}class Ds{constructor(e,s,r,i,a,n){this.index=e,this.lastVisit=Date.now(),this.sideEffect=new k;const c=A(s,u=>u[e]||{width:0,height:0}),l=w([c,r],([u,h])=>(h.width-u.width)/2),o=w([a,n],([u,h])=>(u[e]||0)-h),d=document.createElement("div");d.className="page-renderer-page",d.dataset.index=`${e}`;const p=document.createElement("img");p.className="page-renderer-page-img",d.appendChild(p),this.sideEffect.addDisposer([w([c,i]).subscribe(([u,h])=>{d.style.width=`${u.width*h}px`,d.style.height=`${u.height*h}px`}),c.subscribe(u=>{u.thumbnail&&(d.style.backgroundImage=`url("${u.thumbnail}")`),p.width=u.width,p.height=u.height,p.src=u.src}),w([l,o,i]).subscribe(([u,h,g])=>{d.style.transform=`translate(${u*g}px, ${h*g}px)`})]),this.$page=d}destroy(){this.sideEffect.flushAll(),this.$page.remove()}}const Is=window.requestIdleCallback||(t=>window.setTimeout(t,5e3)),Ts=window.cancelIdleCallback||window.clearTimeout;class Ns{constructor(e,s,r,i,a){this.pages$=e,this.pagesSize$=s,this.scale$=r,this.pagesYs$=i,this.pagesScrollTop$=a,this.els=new Map,this.maxElCount=200,this.gcTimer=null,this.gc=()=>{var n;if(this.gcTimer=null,this.els.size>this.maxElCount){const c=[...this.els.values()].sort((l,o)=>o.lastVisit-l.lastVisit);for(let l=Math.floor(this.maxElCount/4);l<c.length;l++)(n=this.els.get(c[l].index))==null||n.destroy(),this.els.delete(c[l].index)}}}getEl(e){let s=this.els.get(e);return s||(s=new Ds(e,this.pages$,this.pagesSize$,this.scale$,this.pagesYs$,this.pagesScrollTop$),this.els.set(e,s)),s.lastVisit=Date.now(),this.els.size>this.maxElCount&&this.gcTimer===null&&(this.gcTimer=Is(this.gc)),s}destroy(){this.els.forEach(e=>e.destroy()),this.els.clear(),this.gcTimer!==null&&(Ts(this.gcTimer),this.gcTimer=null)}}class As{constructor({pagesScrollTop$:e,containerRect$:s,pages$:r,pagesSize$:i}){this.sideEffect=new k,r=A(r,h=>h.map(g=>{if(g.thumbnail)return g;try{const f=new URL(g.src);return f.searchParams.set("x-oss-process","image/resize,l_50"),{...g,thumbnail:f.toString()}}catch(f){return console.error(f),g}}));const a=A(r,h=>{const g=Array(h.length);for(let f=0;f<h.length;f++)g[f]=f>0?g[f-1]+h[f-1].height:0;return g}),n=A(r,h=>{let g=1/0;for(let f=h.length-1;f>=0;f--)h[f].height<=g&&(g=h[f].height);return g}),c=w([e,a,r],([h,g,f])=>{for(let m=0;m<g.length;m++)if(g[m]+f[m].height-h>=.001)return m;return g.length-1}),l=w([s,i],([h,g])=>h.width/g.width||1),o=w([r,s,n,l],([h,g,f,m])=>C(Math.ceil(g.height/m/f/2),1,h.length));ht(this,{pagesScrollTop:e,containerRect:s,pages:r,pagesSize:i,pagesIndex:c,pagesYs:a,pagesMinHeight:n,scale:l}),this.pageElManager=new Ns(r,i,l,a,e),this.$pages=this.renderPages();const d=new S(!1);this.sideEffect.addDisposer(d.subscribe(h=>this.$pages.classList.toggle("is-hwa",h)));const p=()=>d.setValue(!1),u=()=>{this.sideEffect.setTimeout(p,1e3,"turn-off-hwa"),d.setValue(!0)};this.sideEffect.addDisposer(w([c,o,r]).subscribe(([h,g,f])=>{u();const m=Math.max(h-g,0),Xe=Math.min(h+g,f.length-1);for(let L=0;L<this.$pages.children.length;L++){const M=this.$pages.children[L],Ke=Number(M.dataset.index);Ke>=m&&Ke<=Xe||(M.remove(),L--)}for(let L=m;L<=Xe;L++){const M=this.pageElManager.getEl(L);M.$page.parentElement!==this.$pages&&this.$pages.appendChild(M.$page)}}))}renderPages(){const e=document.createElement("div");return e.className="page-renderer-pages-container",this.sideEffect.addDisposer(this._containerRect$.subscribe(s=>{e.style.width=`${s.width}px`,e.style.height=`${s.height}px`}),"render-pages-size"),e}destroy(){this.sideEffect.flushAll(),this.$pages.remove(),this.pageElManager.destroy()}}const Ps=30;class Vs{constructor({pagesScrollTop$:e,containerRect$:s,stageRect$:r,pagesSize$:i,readonly$:a,scrollbarMinHeight:n=Ps,wrapClassName:c,onDragScroll:l}){this.sideEffect=new k,this.scrolling$=new S(!1),this.pagesScrollTop$=e,this.containerRect$=s,this.stageRect$=r,this.pagesSize$=i,this.scrollbarMinHeight=n,this.readonly$=a,this.wrapClassName=c,this.onDragScroll=l,this.scrollbarHeight$=w([s,r,i],([o,d,p])=>C(d.height/(d.width/p.width*p.height)*o.height,n,o.height)),this.scrollTop$=w([s,r,i,this.scrollbarHeight$,this.pagesScrollTop$],([o,d,p,u,h])=>C(h/(p.height-p.width/d.width*d.height)*(o.height-u),0,o.height-u)),this.$scrollbar=this.renderScrollbar()}mount(e){e.appendChild(this.$scrollbar)}destroy(){this.$scrollbar.remove(),this.onDragScroll=void 0,this.sideEffect.flushAll()}renderScrollbar(){const e=document.createElement("button");e.className=this.wrapClassName("scrollbar"),e.style.minHeight=`${this.scrollbarMinHeight}px`,this.sideEffect.addDisposer([this.scrollbarHeight$.subscribe(r=>{e.style.height=`${r}px`}),this.scrollTop$.subscribe(r=>{this.scrolling$.setValue(!0),this.sideEffect.setTimeout(()=>this.scrolling$.setValue(!1),100,"reset-scrolling");const i=()=>e.style.transform=`translateY(${r}px)`;window.requestAnimationFrame?window.requestAnimationFrame(i):i()}),this.scrolling$.subscribe(r=>{e.classList.toggle(this.wrapClassName("scrolling"),r)})]);const s=r=>{if(!r.isPrimary||this.readonly$.value||r.button!=null&&r.button!==0)return;qe(r);const i=this.wrapClassName("scrollbar-dragging");e.classList.toggle(i,!0);const a=this.pagesScrollTop$.value,{clientY:n}=Ge(r),c=o=>{if(!o.isPrimary||this.readonly$.value)return;const{clientY:d}=Ge(o),p=d-n;Math.abs(p)>0&&this.onDragScroll&&this.onDragScroll(a+p/this.containerRect$.value.height*this.pagesSize$.value.height)},l=o=>{!o.isPrimary||(e.classList.toggle(i,!1),window.removeEventListener("pointermove",c,!0),window.removeEventListener("pointerup",l,!0),window.removeEventListener("pointercancel",l,!0))};window.addEventListener("pointermove",c,!0),window.addEventListener("pointerup",l,!0),window.addEventListener("pointercancel",l,!0)};return this.sideEffect.addEventListener(e,"pointerdown",s),e}}class zs{constructor({whiteboard:e,readonly$:s,box:r,pages:i,pagesScrollTop:a=0,onUserScroll:n}){this.sideEffect=new k,this.userScrolling=!1,this.whiteboard=e,this.readonly$=s,this.box=r,this.pages=i,this.onUserScroll=n;const c=()=>{var o;this.userScrolling=!1,(o=this.onUserScroll)==null||o.call(this,this.pagesScrollTop$.value)};this.debounceOnUserScroll=()=>{this.userScrolling=!0,this.sideEffect.setTimeout(c,80,"debounceOnUserScroll")};const l=new S(i);this.pagesScrollTop$=new S(a),this.pagesSize$=A(l,o=>{let d=0,p=0;for(let u=o.length-1;u>=0;u--){const h=o[u];h.width>d&&(d=h.width),p+=h.height}return{width:Math.max(1,d),height:Math.max(1,p)}},{compare:Je}),this.pageRenderer=new As({pagesScrollTop$:this.pagesScrollTop$,containerRect$:r._stageRect$,pages$:l,pagesSize$:this.pagesSize$}),this.viewer=new Ye({readonly$:s,pagesIndex$:this.pageRenderer._pagesIndex$,box:r,pages:i,playable:!1}),this.sideEffect.addDisposer([this.viewer.events.on("next",()=>{this.userScrollByPercent(.8)}),this.viewer.events.on("back",()=>{this.userScrollByPercent(-.8)})]),this.scrollbar=new Vs({pagesScrollTop$:this.pagesScrollTop$,containerRect$:r._bodyRect$,stageRect$:r._stageRect$,pagesSize$:this.pagesSize$,readonly$:s,wrapClassName:this.wrapClassName.bind(this),onDragScroll:o=>{this.pageScrollTo(o),this.debounceOnUserScroll()}}),this.pageScrollStepper=new ks({start:this.pagesScrollTop$.value,onStep:o=>{this.pageScrollTo(o)}}),this.sideEffect.addDisposer(this.viewer.events.on("jumpPage",o=>this.userScrollToPageIndex(o))),this.render(),this.setupScrollListener(),this.sideEffect.setTimeout(()=>{this.userScrolling||this.pageScrollTo(this.pageRenderer.pagesScrollTop)},100)}get pagesScrollTop(){return this.pagesScrollTop$.value}destroy(){this.sideEffect.flushAll(),this.pageScrollStepper.destroy(),this.onUserScroll=void 0,this.viewer.destroy(),this.pageRenderer.destroy(),this.scrollbar.destroy()}syncPageScrollTop(e){!this.userScrolling&&e>=0&&Math.abs(this.pagesScrollTop$.value-e)>.01&&this.pageScrollStepper.stepTo(e,this.pagesScrollTop$.value)}render(){this.box.$content.style.overflow="hidden",this.box.mountStage(this.pageRenderer.$pages),this.scrollbar.mount(this.box.$body)}pageScrollTo(e){const s=this.whiteboard.view.size.height/2/this.pageRenderer.scale;this.whiteboard.view.moveCamera({centerY:C(e+s,s,this.pagesSize$.value.height-s),animationMode:"immediately"})}userScrollToPageIndex(e){var s;if(e=C(e,0,this.pages.length-1),!this.readonly$.value&&!Number.isNaN(e)){const r=this.pageRenderer.pagesYs[e];r>=0&&((s=this.onUserScroll)==null||s.call(this,r+5/this.pageRenderer.scale))}}userScrollByPercent(e){var s;this.readonly$.value||(s=this.onUserScroll)==null||s.call(this,C(this.pageRenderer.pagesScrollTop+this.pageRenderer.containerRect.height/this.pageRenderer.scale*C(e,-1,1),0,this.pageRenderer.pagesSize.height-this.pageRenderer.containerRect.height/this.pageRenderer.scale))}setupScrollListener(){this.sideEffect.addEventListener(this.box.$main,"wheel",e=>{qe(e),!this.readonly$.value&&this.pageScrollStepper.paused&&(this.pageScrollTo(this.pagesScrollTop+e.deltaY),this.debounceOnUserScroll())},{passive:!1}),this.sideEffect.addEventListener(this.box.$main,"touchmove",e=>{!this.readonly$.value&&e.touches.length>1&&this.debounceOnUserScroll()},{passive:!0,capture:!0}),this.sideEffect.add(()=>{const e=s=>{const{width:r,height:i}=this.whiteboard.view.size;if(r<=0||i<=0)return;const a=s.centerY-this.pageRenderer.containerRect.height/this.pageRenderer.scale/2;this.pagesScrollTop$.setValue(a)};return this.whiteboard.view.callbacks.on("onCameraUpdated",e),()=>this.whiteboard.view.callbacks.off("onCameraUpdated",e)}),this.sideEffect.addDisposer(this.box._stageRect$.subscribe(e=>{const{width:s,height:r}=this.pagesSize$.value;this.whiteboard.view.moveCameraToContain({originX:0,originY:this.pageRenderer.pagesScrollTop,width:s,height:e.height/this.pageRenderer.scale,animationMode:"immediately"}),this.whiteboard.view.setCameraBound({damping:1,maxContentMode:()=>this.pageRenderer.scale,minContentMode:()=>this.pageRenderer.scale,centerX:s/2,centerY:r/2,width:s,height:r})}),"whiteboard-size-update"),this.sideEffect.addEventListener(window,"keyup",e=>{if(!(this.readonly$.value||!this.box.focus||this.box.minimized))switch(e.key){case"PageDown":{this.userScrollByPercent(.8);break}case"PageUp":{this.userScrollByPercent(-.8);break}case"ArrowLeft":{this.userScrollByPercent(-.25);break}case"ArrowRight":{this.userScrollByPercent(.25);break}case"ArrowDown":{this.userScrollByPercent(.5);break}case"ArrowUp":{this.userScrollByPercent(-.5);break}}},{capture:!0})}wrapClassName(e){return"netless-app-docs-viewer-static-"+e}}class Os{constructor({readonly$:e,context:s,whiteboard:r,box:i,pages:a}){this.sideEffect=new k,this.context=s,this.whiteboard=r,this.box=i,this.pages=a;const n=new S(s.displayer.state.sceneState.index||0);this.pagesIndex$=n,this.sideEffect.add(()=>{const c=l=>{this.jumpToPage(l.index)};return this.context.emitter.on("sceneStateChange",c),()=>this.context.emitter.off("sceneStateChange",c)}),this.viewer=new Ye({readonly$:e,pagesIndex$:n,box:i,pages:a,playable:!0}),this.sideEffect.addDisposer([this.viewer.events.on("jumpPage",c=>this.jumpToPage(c,!0)),this.viewer.events.on("play",()=>{var c;return(c=this.context.room)==null?void 0:c.pptNextStep()}),this.viewer.events.on("back",()=>this.prevPage()),this.viewer.events.on("next",()=>this.nextPage())]),this.render(),this.sideEffect.addDisposer(n.subscribe((c,l)=>{var p,u;if(e.value)return;const o=this.context.getInitScenePath(),d=(u=(p=this.context.getScenes())==null?void 0:p[c])==null?void 0:u.name;if(o&&d&&this.context.setScenePath(`${o}/${d}`),l){const h=this.context.room;if(h){const g=h.state.globalState.__pptState;h.setGlobalState({__pptState:g&&{uuid:g.uuid,pageIndex:c,disableAutoPlay:g.disableAutoPlay}})}}}))}destroy(){this.sideEffect.flushAll(),this.viewer.destroy()}nextPage(){this.jumpToPage(this.pagesIndex$.value+1,!0)}prevPage(){this.jumpToPage(this.pagesIndex$.value-1,!0)}jumpToPage(e,s=!1){this.pagesIndex$.setValue(C(e,0,this.pages.length-1),s)}render(){var s;this.box.mountStage(document.createElement("div")),this.sideEffect.addEventListener(window,"keydown",r=>{var i;if(this.box.focus)switch(r.key){case"ArrowUp":case"ArrowLeft":{this.prevPage();break}case"ArrowRight":case"ArrowDown":{(i=this.context.room)==null||i.pptNextStep();break}}});const e=(s=this.whiteboard.view.divElement)==null?void 0:s.parentElement;e&&this.sideEffect.addEventListener(e,"click",r=>{var a;const i=this.context.room;if(i&&i.state.memberState.currentApplianceName==="clicker"){for(let n=r.target;n;n=n.parentElement)if((a=n.classList)!=null&&a.contains("ppt-event-source"))return;i.pptNextStep()}})}wrapClassName(e){return"netless-app-docs-viewer-dynamic-"+e}}const Ms={kind:"DocsViewer",setup(t){const e=t.box,s=t.getScenes();if(!s)throw new Error("[Docs Viewer]: scenes not found.");const r=new k,i=s.map(({ppt:n})=>n?{width:n.width,height:n.height,src:n.src,thumbnail:n.previewURL}:null).filter(n=>Boolean(n));if(i.length<=0)throw new Error("[Docs Viewer]: empty scenes.");e.mountStyles(Qe);const a=new S(!t.isWritable);r.addDisposer(t.emitter.on("writableChange",n=>{a.setValue(!n)})),i[0].src.startsWith("ppt")?Hs(r,t,e,i,a):Rs(r,t,e,i,a),r.addDisposer(t.emitter.on("destroy",()=>{r.flushAll()}))}};function Rs(t,e,s,r,i){const a=e.createWhiteBoardView({syncCamera:!1});t.addDisposer(i.subscribe(l=>{a.view.disableCameraTransform=l}));const n=e.createStorage("static-docs-viewer",{pagesScrollTop:0}),c=new zs({whiteboard:a,readonly$:i,box:s,pages:r,pagesScrollTop:n.state.pagesScrollTop,onUserScroll:l=>{e.isWritable&&n.setState({pagesScrollTop:l})}});t.addDisposer(()=>c.destroy()),t.addDisposer(n.addStateChangedListener(l=>{l.pagesScrollTop&&c.syncPageScrollTop(l.pagesScrollTop.newValue||0)})),t.addDisposer(w([s._maximized$,s._managerStageRect$,s._intrinsicSize$,c.pagesSize$,c.pageRenderer._pagesMinHeight$],([l,o,d,p,u])=>l?Math.max(u/p.width*.4,o.height/o.width):d.height/d.width*(o.height/o.width)).subscribe(l=>{s.setStageRatio(l)}))}function Hs(t,e,s,r,i){const a=e.createWhiteBoardView();a.view.disableCameraTransform=!0;const n=new Os({context:e,whiteboard:a,box:s,pages:r,readonly$:i});t.addDisposer(()=>n.destroy());const c=new S({width:r[0].width,height:r[0].height},{compare:Je});if(t.addDisposer(n.pagesIndex$.subscribe(l=>{const o=r[l];o&&c.setValue({width:o.width,height:o.height})})),t.addDisposer(c.subscribe(l=>{i.value||a.setBaseRect(l)})),e.isAddApp){const l=t.add(()=>{const o=({width:d,height:p})=>{if(r.length>0&&s.state!=="maximized"){const{width:u,height:h}=r[0],f=h/u*d-p;f!==0&&e.isWritable&&e.emitter.emit("setBoxSize",{width:s.intrinsicWidth,height:s.intrinsicHeight+f/s.rootRect.height})}t.remove(l)};return a.view.callbacks.once("onSizeUpdated",o),()=>a.view.callbacks.off("onSizeUpdated",o)})}}return j.default=Ms,Object.defineProperties(j,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),j}({}); | ||
//# sourceMappingURL=main.iife.js.map |
{ | ||
"name": "@netless/app-docs-viewer", | ||
"version": "0.3.1", | ||
"version": "0.3.2", | ||
"description": "Netless App Docs Viewer", | ||
@@ -5,0 +5,0 @@ "repository": "netless-io/netless-app", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
658225
3696
1