@netless/app-docs-viewer
Advanced tools
Comparing version 0.2.12 to 0.2.13
@@ -1,4 +0,4 @@ | ||
"use strict";var Nt=Object.defineProperty,Pt=Object.defineProperties;var kt=Object.getOwnPropertyDescriptors;var _e=Object.getOwnPropertySymbols;var Rt=Object.prototype.hasOwnProperty,Ot=Object.prototype.propertyIsEnumerable;var Ie=(t,e,s)=>e in t?Nt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,ne=(t,e)=>{for(var s in e||(e={}))Rt.call(e,s)&&Ie(t,s,e[s]);if(_e)for(var s of _e(e))Ot.call(e,s)&&Ie(t,s,e[s]);return t},ce=(t,e)=>Pt(t,kt(e));Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});function Lt(t){if(t&&t.__esModule)return t;var e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});return t&&Object.keys(t).forEach(function(s){if(s!=="default"){var r=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(e,s,r.get?r:{enumerable:!0,get:function(){return t[s]}})}}),e.default=t,Object.freeze(e)}var zt=(()=>`.netless-app-docs-viewer-content{position:relative;height:100%;overflow:hidden}.netless-app-docs-viewer-preview-mask{display:none;position:absolute;z-index:200;top:0;left:0;width:100%;height:100%}.netless-app-docs-viewer-preview{display:flex;flex-direction:column;align-items:center;position:absolute;z-index:300;top:0;left:0;width:33%;max-width:200px;height:100%;padding-top:10px;transform:translate(-100%);background:rgba(237,237,240,.9);box-shadow:inset -1px 0 #0000001c;transition:transform .4s}.netless-app-docs-viewer-preview-active .netless-app-docs-viewer-preview-mask{display:block}.netless-app-docs-viewer-preview-active .netless-app-docs-viewer-preview{transform:translate(0)}.netless-app-docs-viewer-preview-page{position:relative;display:block;width:55%;margin-bottom:10px;font-size:0;color:transparent;outline:none;border:7px solid transparent;border-radius:4px;transition:border-color .3s;user-select:none}.netless-app-docs-viewer-preview-page:hover,.netless-app-docs-viewer-preview-page.netless-app-docs-viewer-preview-page-active{border-color:#444e601a}.netless-app-docs-viewer-preview-page>img{width:100%;height:auto;box-sizing:border-box;border:1px solid rgba(0,0,0,.5);border-radius:1px;background-color:#fff;box-shadow:0 2px 8px #0000004d}.netless-app-docs-viewer-preview-page-name{position:absolute;top:1px;left:-10px;transform:translate(-100%);text-align:right;font-size:12px;color:#5f5f5f;user-select:none}.netless-app-docs-viewer-footer{box-sizing:border-box;height:26px;display:flex;align-items:center;padding:0 16px;border-top:1px solid #eeeef7;color:#191919}.netless-app-docs-viewer-float-footer{width:100%;min-height:26px;position:absolute;left:0;bottom:0;z-index:2000;background:rgba(249,249,252,.9);transition:opacity .4s}.netless-app-docs-viewer-footer-btn{box-sizing:border-box;width:26px;height:26px;font-size:0;margin:0;padding:3px;border:none;border-radius:1px;outline:none;color:currentColor;background:transparent;transition:background .4s;cursor:pointer;user-select:none;-webkit-tap-highlight-color:rgba(0,0,0,0)}.netless-app-docs-viewer-footer-btn:hover{background:rgba(237,237,240,.9)}@media (hover: none){.netless-app-docs-viewer-footer-btn:hover{background:transparent!important}}.netless-app-docs-viewer-footer-btn>svg{width:100%;height:100%}.netless-app-docs-viewer-footer-btn>svg:nth-of-type(2){display:none}.netless-app-docs-viewer-footer-btn.netless-app-docs-viewer-footer-btn-playing>svg:nth-of-type(1){display:none}.netless-app-docs-viewer-footer-btn.netless-app-docs-viewer-footer-btn-playing>svg:nth-of-type(2){display:initial}.netless-app-docs-viewer-footer-btn~.netless-app-docs-viewer-footer-btn{margin-left:15px}.netless-app-docs-viewer-page-jumps{flex:1;display:flex;justify-content:center;align-items:center}.netless-app-docs-viewer-page-number{margin-left:auto;font-size:13px;user-select:none;white-space:nowrap;word-break:keep-all}.netless-app-docs-viewer-page-number-input{border:none;outline:none;width:3em;margin:0;padding:0 2px;text-align:right;font-size:13px;line-height:1;font-weight:400;font-family:inherit;border-radius:2px;color:currentColor;background:transparent;transition:background .4s;user-select:text;-webkit-tap-highlight-color:rgba(0,0,0,0)}.netless-app-docs-viewer-page-number-input:hover,.netless-app-docs-viewer-page-number-input:focus,.netless-app-docs-viewer-page-number-input:active{background:#fff;box-shadow:#63636333 0 2px 8px}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-footer-btn{cursor:not-allowed}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-footer-btn:hover{background:transparent}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-page-number-input{cursor:not-allowed}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-page-number-input:hover,.netless-app-docs-viewer-readonly .netless-app-docs-viewer-page-number-input:focus,.netless-app-docs-viewer-readonly .netless-app-docs-viewer-page-number-input:active{background:transparent;box-shadow:none}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-page-number-input:disabled{color:inherit}.netless-app-docs-viewer-readonly.netless-app-docs-viewer-float-footer{display:none}.telebox-color-scheme-dark .netless-app-docs-viewer-page-number-input{color:#a6a6a8}.telebox-color-scheme-dark .netless-app-docs-viewer-page-number-input:active,.telebox-color-scheme-dark .netless-app-docs-viewer-page-number-input:focus,.telebox-color-scheme-dark .netless-app-docs-viewer-page-number-input:hover{color:#222}.telebox-color-scheme-dark .netless-app-docs-viewer-footer{color:#a6a6a8;background:#2d2d33;border-top:none}.telebox-color-scheme-dark .netless-app-docs-viewer-footer-btn:hover{background:#212126}.telebox-color-scheme-dark .netless-app-docs-viewer-preview{background:rgba(50,50,50,.9)}.netless-app-docs-viewer-static-scrollbar{position:absolute;top:0;right:0;z-index:2147483647;width:8px;min-height:30px;margin:0;padding:0;border:none;outline:none;border-radius:4px;background:rgba(68,78,96,.4);box-shadow:1px 1px 8px #ffffffb3;opacity:0;transition:background .4s,opacity .4s 3s,transform .2s;user-select:none}.netless-app-docs-viewer-static-scrollbar.netless-app-docs-viewer-static-scrollbar-dragging{background:rgba(68,78,96,.6);opacity:1;transition:background .4s,opacity .4s 3s!important}.netless-app-docs-viewer-static-scrollbar:hover,.netless-app-docs-viewer-static-scrollbar:focus{background:rgba(68,78,96,.5)}.netless-app-docs-viewer-static-scrollbar:active{background:rgba(68,78,96,.6)}.netless-app-docs-viewer-content:hover .netless-app-docs-viewer-static-scrollbar{opacity:1;transition:background .4s,opacity .4s,transform .2s}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-static-scrollbar{display:none}.netless-app-docs-viewer-static-pages:hover .netless-app-docs-viewer-static-scrollbar{opacity:1;transition:background .4s,opacity .4s,transform .2s}.page-renderer-pages-container{position:relative;overflow:hidden}.page-renderer-page{position:absolute;top:0;left:0;background-position:center;background-size:cover;background-repeat:no-repeat}.page-renderer-pages-container.is-hwa .page-renderer-page{will-change:transform}.page-renderer-page-img{display:block;width:100%;height:auto;user-select:none}.netless-app-docs-viewer-static-pages{overflow:hidden;position:relative;height:100%;user-select:none}.netless-app-docs-viewer-static-page{display:block;width:100%;height:auto;user-select:none}.netless-app-docs-viewer-static-wb-view,.netless-app-docs-viewer-dynamic-wb-view{position:absolute;top:0;left:0;width:100%;height:100%;z-index:100;overflow:hidden}.netless-app-docs-viewer-dynamic-wb-view .cursor-clicker .ppt-event-source{cursor:pointer} | ||
`)();const At=(t,e,s,r)=>{if(s==="length"||s==="prototype"||s==="arguments"||s==="caller")return;const i=Object.getOwnPropertyDescriptor(t,s),o=Object.getOwnPropertyDescriptor(e,s);!Ht(i,o)&&r||Object.defineProperty(t,s,o)},Ht=function(t,e){return t===void 0||t.configurable||t.writable===e.writable&&t.enumerable===e.enumerable&&t.configurable===e.configurable&&(t.writable||t.value===e.value)},Dt=(t,e)=>{const s=Object.getPrototypeOf(e);s!==Object.getPrototypeOf(t)&&Object.setPrototypeOf(t,s)},Mt=(t,e)=>`/* Wrapped ${t}*/ | ||
${e}`,Vt=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),Bt=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),Wt=(t,e,s)=>{const r=s===""?"":`with ${s.trim()}() `,i=Mt.bind(null,r,e.toString());Object.defineProperty(i,"name",Bt),Object.defineProperty(t,"toString",ce(ne({},Vt),{value:i}))};function Ft(t,e,{ignoreNonConfigurable:s=!1}={}){const{name:r}=t;for(const i of Reflect.ownKeys(e))At(t,e,i,s);return Dt(t,e),Wt(t,e,r),t}const Ut=(t,e={})=>{if(typeof t!="function")throw new TypeError(`Expected the first argument to be a function, got \`${typeof t}\``);const{wait:s=0,maxWait:r=Number.Infinity,before:i=!1,after:o=!0}=e;if(!i&&!o)throw new Error("Both `before` and `after` are false, function wouldn't be called.");let a,n,c;const l=function(...h){const d=this,P=()=>{a=void 0,n&&(clearTimeout(n),n=void 0),o&&(c=t.apply(d,h))},p=()=>{n=void 0,a&&(clearTimeout(a),a=void 0),o&&(c=t.apply(d,h))},b=i&&!a;return clearTimeout(a),a=setTimeout(P,s),r>0&&r!==Number.Infinity&&!n&&(n=setTimeout(p,r)),b&&(c=t.apply(d,h)),c};return Ft(l,t),l.cancel=()=>{a&&(clearTimeout(a),a=void 0),n&&(clearTimeout(n),n=void 0)},l},Ue="!#%()*+,-./:;=?@[]^_`{|}~ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",jt=Ue.length,Ce=Array(20),Yt=()=>{for(let t=0;t<20;t++)Ce[t]=Ue.charAt(Math.random()*jt);return Ce.join("")};function $e(t){try{return t()}catch(e){console.error(e)}}class ee{constructor(){this.disposers=new Map}addDisposer(e,s=this.genUID()){return this.flush(s),this.disposers.set(s,Array.isArray(e)?()=>e.forEach($e):e),s}add(e,s=this.genUID()){return this.addDisposer(e(),s)}addEventListener(e,s,r,i,o=this.genUID()){return e.addEventListener(s,r,i),this.addDisposer(()=>e.removeEventListener(s,r,i),o),o}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($e),this.disposers.clear()}genUID(){let e;do e=Yt();while(this.disposers.has(e));return e}}var I=[],Gt=function(){return I.some(function(t){return t.activeTargets.length>0})},Xt=function(){return I.some(function(t){return t.skippedTargets.length>0})},Ne="ResizeObserver loop completed with undelivered notifications.",qt=function(){var t;typeof ErrorEvent=="function"?t=new ErrorEvent("error",{message:Ne}):(t=document.createEvent("Event"),t.initEvent("error",!1,!1),t.message=Ne),window.dispatchEvent(t)},B;(function(t){t.BORDER_BOX="border-box",t.CONTENT_BOX="content-box",t.DEVICE_PIXEL_CONTENT_BOX="device-pixel-content-box"})(B||(B={}));var C=function(t){return Object.freeze(t)},Jt=function(){function t(e,s){this.inlineSize=e,this.blockSize=s,C(this)}return t}(),je=function(){function t(e,s,r,i){return this.x=e,this.y=s,this.width=r,this.height=i,this.top=this.y,this.left=this.x,this.bottom=this.top+this.height,this.right=this.left+this.width,C(this)}return t.prototype.toJSON=function(){var e=this,s=e.x,r=e.y,i=e.top,o=e.right,a=e.bottom,n=e.left,c=e.width,l=e.height;return{x:s,y:r,top:i,right:o,bottom:a,left:n,width:c,height:l}},t.fromRect=function(e){return new t(e.x,e.y,e.width,e.height)},t}(),ue=function(t){return t instanceof SVGElement&&"getBBox"in t},Ye=function(t){if(ue(t)){var e=t.getBBox(),s=e.width,r=e.height;return!s&&!r}var i=t,o=i.offsetWidth,a=i.offsetHeight;return!(o||a||t.getClientRects().length)},Pe=function(t){var e,s;if(t instanceof Element)return!0;var r=(s=(e=t)===null||e===void 0?void 0:e.ownerDocument)===null||s===void 0?void 0:s.defaultView;return!!(r&&t instanceof r.Element)},Kt=function(t){switch(t.tagName){case"INPUT":if(t.type!=="image")break;case"VIDEO":case"AUDIO":case"EMBED":case"OBJECT":case"CANVAS":case"IFRAME":case"IMG":return!0}return!1},V=typeof window!="undefined"?window:{},q=new WeakMap,ke=/auto|scroll/,Zt=/^tb|vertical/,Qt=/msie|trident/i.test(V.navigator&&V.navigator.userAgent),v=function(t){return parseFloat(t||"0")},O=function(t,e,s){return t===void 0&&(t=0),e===void 0&&(e=0),s===void 0&&(s=!1),new Jt((s?e:t)||0,(s?t:e)||0)},Re=C({devicePixelContentBoxSize:O(),borderBoxSize:O(),contentBoxSize:O(),contentRect:new je(0,0,0,0)}),Ge=function(t,e){if(e===void 0&&(e=!1),q.has(t)&&!e)return q.get(t);if(Ye(t))return q.set(t,Re),Re;var s=getComputedStyle(t),r=ue(t)&&t.ownerSVGElement&&t.getBBox(),i=!Qt&&s.boxSizing==="border-box",o=Zt.test(s.writingMode||""),a=!r&&ke.test(s.overflowY||""),n=!r&&ke.test(s.overflowX||""),c=r?0:v(s.paddingTop),l=r?0:v(s.paddingRight),h=r?0:v(s.paddingBottom),d=r?0:v(s.paddingLeft),P=r?0:v(s.borderTopWidth),p=r?0:v(s.borderRightWidth),b=r?0:v(s.borderBottomWidth),oe=r?0:v(s.borderLeftWidth),T=d+l,Y=c+h,S=oe+p,H=P+b,_=n?t.offsetHeight-H-t.clientHeight:0,G=a?t.offsetWidth-S-t.clientWidth:0,f=i?T+S:0,g=i?Y+H:0,k=r?r.width:v(s.width)-f-G,R=r?r.height:v(s.height)-g-_,ae=k+T+G+S,D=R+Y+_+H,X=C({devicePixelContentBoxSize:O(Math.round(k*devicePixelRatio),Math.round(R*devicePixelRatio),o),borderBoxSize:O(ae,D,o),contentBoxSize:O(k,R,o),contentRect:new je(d,c,k,R)});return q.set(t,X),X},Xe=function(t,e,s){var r=Ge(t,s),i=r.borderBoxSize,o=r.contentBoxSize,a=r.devicePixelContentBoxSize;switch(e){case B.DEVICE_PIXEL_CONTENT_BOX:return a;case B.BORDER_BOX:return i;default:return o}},es=function(){function t(e){var s=Ge(e);this.target=e,this.contentRect=s.contentRect,this.borderBoxSize=C([s.borderBoxSize]),this.contentBoxSize=C([s.contentBoxSize]),this.devicePixelContentBoxSize=C([s.devicePixelContentBoxSize])}return t}(),qe=function(t){if(Ye(t))return 1/0;for(var e=0,s=t.parentNode;s;)e+=1,s=s.parentNode;return e},ts=function(){var t=1/0,e=[];I.forEach(function(a){if(a.activeTargets.length!==0){var n=[];a.activeTargets.forEach(function(l){var h=new es(l.target),d=qe(l.target);n.push(h),l.lastReportedSize=Xe(l.target,l.observedBox),d<t&&(t=d)}),e.push(function(){a.callback.call(a.observer,n,a.observer)}),a.activeTargets.splice(0,a.activeTargets.length)}});for(var s=0,r=e;s<r.length;s++){var i=r[s];i()}return t},Oe=function(t){I.forEach(function(s){s.activeTargets.splice(0,s.activeTargets.length),s.skippedTargets.splice(0,s.skippedTargets.length),s.observationTargets.forEach(function(i){i.isActive()&&(qe(i.target)>t?s.activeTargets.push(i):s.skippedTargets.push(i))})})},ss=function(){var t=0;for(Oe(t);Gt();)t=ts(),Oe(t);return Xt()&&qt(),t>0},le,Je=[],rs=function(){return Je.splice(0).forEach(function(t){return t()})},is=function(t){if(!le){var e=0,s=document.createTextNode(""),r={characterData:!0};new MutationObserver(function(){return rs()}).observe(s,r),le=function(){s.textContent=""+(e?e--:e++)}}Je.push(t),le()},os=function(t){is(function(){requestAnimationFrame(t)})},Z=0,as=function(){return!!Z},ns=250,cs={attributes:!0,characterData:!0,childList:!0,subtree:!0},Le=["resize","load","transitionend","animationend","animationstart","animationiteration","keyup","keydown","mouseup","mousedown","mouseover","mouseout","blur","focus"],ze=function(t){return t===void 0&&(t=0),Date.now()+t},he=!1,ls=function(){function t(){var e=this;this.stopped=!0,this.listener=function(){return e.schedule()}}return t.prototype.run=function(e){var s=this;if(e===void 0&&(e=ns),!he){he=!0;var r=ze(e);os(function(){var i=!1;try{i=ss()}finally{if(he=!1,e=r-ze(),!as())return;i?s.run(1e3):e>0?s.run(e):s.start()}})}},t.prototype.schedule=function(){this.stop(),this.run()},t.prototype.observe=function(){var e=this,s=function(){return e.observer&&e.observer.observe(document.body,cs)};document.body?s():V.addEventListener("DOMContentLoaded",s)},t.prototype.start=function(){var e=this;this.stopped&&(this.stopped=!1,this.observer=new MutationObserver(this.listener),this.observe(),Le.forEach(function(s){return V.addEventListener(s,e.listener,!0)}))},t.prototype.stop=function(){var e=this;this.stopped||(this.observer&&this.observer.disconnect(),Le.forEach(function(s){return V.removeEventListener(s,e.listener,!0)}),this.stopped=!0)},t}(),de=new ls,Ae=function(t){!Z&&t>0&&de.start(),Z+=t,!Z&&de.stop()},hs=function(t){return!ue(t)&&!Kt(t)&&getComputedStyle(t).display==="inline"},ds=function(){function t(e,s){this.target=e,this.observedBox=s||B.CONTENT_BOX,this.lastReportedSize={inlineSize:0,blockSize:0}}return t.prototype.isActive=function(){var e=Xe(this.target,this.observedBox,!0);return hs(this.target)&&(this.lastReportedSize=e),this.lastReportedSize.inlineSize!==e.inlineSize||this.lastReportedSize.blockSize!==e.blockSize},t}(),ps=function(){function t(e,s){this.activeTargets=[],this.skippedTargets=[],this.observationTargets=[],this.observer=e,this.callback=s}return t}(),J=new WeakMap,He=function(t,e){for(var s=0;s<t.length;s+=1)if(t[s].target===e)return s;return-1},K=function(){function t(){}return t.connect=function(e,s){var r=new ps(e,s);J.set(e,r)},t.observe=function(e,s,r){var i=J.get(e),o=i.observationTargets.length===0;He(i.observationTargets,s)<0&&(o&&I.push(i),i.observationTargets.push(new ds(s,r&&r.box)),Ae(1),de.schedule())},t.unobserve=function(e,s){var r=J.get(e),i=He(r.observationTargets,s),o=r.observationTargets.length===1;i>=0&&(o&&I.splice(I.indexOf(r),1),r.observationTargets.splice(i,1),Ae(-1))},t.disconnect=function(e){var s=this,r=J.get(e);r.observationTargets.slice().forEach(function(i){return s.unobserve(e,i.target)}),r.activeTargets.splice(0,r.activeTargets.length)},t}(),us=function(){function t(e){if(arguments.length===0)throw new TypeError("Failed to construct 'ResizeObserver': 1 argument required, but only 0 present.");if(typeof e!="function")throw new TypeError("Failed to construct 'ResizeObserver': The callback provided as parameter 1 is not a function.");K.connect(this,e)}return t.prototype.observe=function(e,s){if(arguments.length===0)throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': 1 argument required, but only 0 present.");if(!Pe(e))throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': parameter 1 is not of type 'Element");K.observe(this,e,s)},t.prototype.unobserve=function(e){if(arguments.length===0)throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': 1 argument required, but only 0 present.");if(!Pe(e))throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': parameter 1 is not of type 'Element");K.unobserve(this,e)},t.prototype.disconnect=function(){K.disconnect(this)},t.toString=function(){return"function ResizeObserver () { [polyfill code] }"},t}();function gs(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 fs(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 vs(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 ws(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 bs(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}const E=typeof window!="undefined",Ke=E&&!("onscroll"in window)||typeof navigator!="undefined"&&/(gle|ing|ro)bot|crawl|spider/i.test(navigator.userAgent),Ze=E&&"IntersectionObserver"in window,Qe=E&&"classList"in document.createElement("p"),et=E&&window.devicePixelRatio>1,ms={elements_selector:".lazy",container:Ke||E?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},tt=t=>Object.assign({},ms,t),De=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)},Ss=(t,e)=>{if(!!e)if(!e.length)De(t,e);else for(let s=0,r;r=e[s];s+=1)De(t,r)},m="src",ge="srcset",fe="sizes",st="poster",F="llOriginalAttrs",rt="data",ve="loading",it="loaded",ot="applied",ys="entered",we="error",at="native",nt="data-",ct="ll-status",u=(t,e)=>t.getAttribute(nt+e),Es=(t,e,s)=>{var r=nt+e;if(s===null){t.removeAttribute(r);return}t.setAttribute(r,s)},U=t=>u(t,ct),N=(t,e)=>Es(t,ct,e),te=t=>N(t,null),be=t=>U(t)===null,xs=t=>U(t)===ve,Ts=t=>U(t)===we,me=t=>U(t)===at,_s=[ve,it,ot,we],Is=t=>_s.indexOf(U(t))>=0,x=(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)}},A=(t,e)=>{if(Qe){t.classList.add(e);return}t.className+=(t.className?" ":"")+e},w=(t,e)=>{if(Qe){t.classList.remove(e);return}t.className=t.className.replace(new RegExp("(^|\\s+)"+e+"(\\s+|$)")," ").replace(/^\s+/,"").replace(/\s+$/,"")},Cs=t=>{t.llTempImage=document.createElement("IMG")},$s=t=>{delete t.llTempImage},lt=t=>t.llTempImage,se=(t,e)=>{if(!e)return;const s=e._observer;!s||s.unobserve(t)},Ns=t=>{t.disconnect()},Ps=(t,e,s)=>{e.unobserve_entered&&se(t,s)},Se=(t,e)=>{!t||(t.loadingCount+=e)},ks=t=>{!t||(t.toLoadCount-=1)},ht=(t,e)=>{!t||(t.toLoadCount=e)},Rs=t=>t.loadingCount>0,Os=t=>t.toLoadCount>0,dt=t=>{let e=[];for(let s=0,r;r=t.children[s];s+=1)r.tagName==="SOURCE"&&e.push(r);return e},ye=(t,e)=>{const s=t.parentNode;if(!s||s.tagName!=="PICTURE")return;dt(s).forEach(e)},pt=(t,e)=>{dt(t).forEach(e)},re=[m],ut=[m,st],W=[m,ge,fe],gt=[rt],ie=t=>!!t[F],ft=t=>t[F],vt=t=>delete t[F],L=(t,e)=>{if(ie(t))return;const s={};e.forEach(r=>{s[r]=t.getAttribute(r)}),t[F]=s},Ls=t=>{ie(t)||(t[F]={backgroundImage:t.style.backgroundImage})},zs=(t,e,s)=>{if(!s){t.removeAttribute(e);return}t.setAttribute(e,s)},$=(t,e)=>{if(!ie(t))return;const s=ft(t);e.forEach(r=>{zs(t,r,s[r])})},As=t=>{if(!ie(t))return;const e=ft(t);t.style.backgroundImage=e.backgroundImage},wt=(t,e,s)=>{A(t,e.class_applied),N(t,ot),s&&(e.unobserve_completed&&se(t,e),x(e.callback_applied,t,s))},bt=(t,e,s)=>{A(t,e.class_loading),N(t,ve),s&&(Se(s,1),x(e.callback_loading,t,s))},y=(t,e,s)=>{!s||t.setAttribute(e,s)},Me=(t,e)=>{y(t,fe,u(t,e.data_sizes)),y(t,ge,u(t,e.data_srcset)),y(t,m,u(t,e.data_src))},Hs=(t,e)=>{ye(t,s=>{L(s,W),Me(s,e)}),L(t,W),Me(t,e)},Ds=(t,e)=>{L(t,re),y(t,m,u(t,e.data_src))},Ms=(t,e)=>{pt(t,s=>{L(s,re),y(s,m,u(s,e.data_src))}),L(t,ut),y(t,st,u(t,e.data_poster)),y(t,m,u(t,e.data_src)),t.load()},Vs=(t,e)=>{L(t,gt),y(t,rt,u(t,e.data_src))},Bs=(t,e,s)=>{const r=u(t,e.data_bg),i=u(t,e.data_bg_hidpi),o=et&&i?i:r;!o||(t.style.backgroundImage=`url("${o}")`,lt(t).setAttribute(m,o),bt(t,e,s))},Ws=(t,e,s)=>{const r=u(t,e.data_bg_multi),i=u(t,e.data_bg_multi_hidpi),o=et&&i?i:r;!o||(t.style.backgroundImage=o,wt(t,e,s))},Fs=(t,e,s)=>{const r=u(t,e.data_bg_set);if(!r)return;const i=r.split("|");let o=i.map(a=>`image-set(${a})`);t.style.backgroundImage=o.join(),t.style.backgroundImage===""&&(o=i.map(a=>`-webkit-image-set(${a})`),t.style.backgroundImage=o.join()),wt(t,e,s)},mt={IMG:Hs,IFRAME:Ds,VIDEO:Ms,OBJECT:Vs},Us=(t,e)=>{const s=mt[t.tagName];!s||s(t,e)},js=(t,e,s)=>{const r=mt[t.tagName];!r||(r(t,e),bt(t,e,s))},Ys=["IMG","IFRAME","VIDEO","OBJECT"],Gs=t=>Ys.indexOf(t.tagName)>-1,St=(t,e)=>{e&&!Rs(e)&&!Os(e)&&x(t.callback_finish,e)},Ve=(t,e,s)=>{t.addEventListener(e,s),t.llEvLisnrs[e]=s},Xs=(t,e,s)=>{t.removeEventListener(e,s)},Ee=t=>!!t.llEvLisnrs,qs=(t,e,s)=>{Ee(t)||(t.llEvLisnrs={});const r=t.tagName==="VIDEO"?"loadeddata":"load";Ve(t,r,e),Ve(t,"error",s)},pe=t=>{if(!Ee(t))return;const e=t.llEvLisnrs;for(let s in e){const r=e[s];Xs(t,s,r)}delete t.llEvLisnrs},yt=(t,e,s)=>{$s(t),Se(s,-1),ks(s),w(t,e.class_loading),e.unobserve_completed&&se(t,s)},Js=(t,e,s,r)=>{const i=me(e);yt(e,s,r),A(e,s.class_loaded),N(e,it),x(s.callback_loaded,e,r),i||St(s,r)},Ks=(t,e,s,r)=>{const i=me(e);yt(e,s,r),A(e,s.class_error),N(e,we),x(s.callback_error,e,r),s.restore_on_error&&$(e,W),i||St(s,r)},xe=(t,e,s)=>{const r=lt(t)||t;if(Ee(r))return;qs(r,a=>{Js(a,t,e,s),pe(r)},a=>{Ks(a,t,e,s),pe(r)})},Zs=(t,e,s)=>{Cs(t),xe(t,e,s),Ls(t),Bs(t,e,s),Ws(t,e,s),Fs(t,e,s)},Qs=(t,e,s)=>{xe(t,e,s),js(t,e,s)},Te=(t,e,s)=>{Gs(t)?Qs(t,e,s):Zs(t,e,s)},er=(t,e,s)=>{t.setAttribute("loading","lazy"),xe(t,e,s),Us(t,e),N(t,at)},Be=t=>{t.removeAttribute(m),t.removeAttribute(ge),t.removeAttribute(fe)},tr=t=>{ye(t,e=>{Be(e)}),Be(t)},Et=t=>{ye(t,e=>{$(e,W)}),$(t,W)},sr=t=>{pt(t,e=>{$(e,re)}),$(t,ut),t.load()},rr=t=>{$(t,re)},ir=t=>{$(t,gt)},or={IMG:Et,IFRAME:rr,VIDEO:sr,OBJECT:ir},ar=t=>{const e=or[t.tagName];if(!e){As(t);return}e(t)},nr=(t,e)=>{be(t)||me(t)||(w(t,e.class_entered),w(t,e.class_exited),w(t,e.class_applied),w(t,e.class_loading),w(t,e.class_loaded),w(t,e.class_error))},cr=(t,e)=>{ar(t),nr(t,e),te(t),vt(t)},lr=(t,e,s,r)=>{!s.cancel_on_exit||!xs(t)||t.tagName==="IMG"&&(pe(t),tr(t),Et(t),w(t,s.class_loading),Se(r,-1),te(t),x(s.callback_cancel,t,e,r))},hr=(t,e,s,r)=>{const i=Is(t);N(t,ys),A(t,s.class_entered),w(t,s.class_exited),Ps(t,s,r),x(s.callback_enter,t,e,r),!i&&Te(t,s,r)},dr=(t,e,s,r)=>{be(t)||(A(t,s.class_exited),lr(t,e,s,r),x(s.callback_exit,t,e,r))},pr=["IMG","IFRAME","VIDEO"],xt=t=>t.use_native&&"loading"in HTMLImageElement.prototype,ur=(t,e,s)=>{t.forEach(r=>{pr.indexOf(r.tagName)!==-1&&er(r,e,s)}),ht(s,0)},gr=t=>t.isIntersecting||t.intersectionRatio>0,fr=t=>({root:t.container===document?null:t.container,rootMargin:t.thresholds||t.threshold+"px"}),vr=(t,e,s)=>{t.forEach(r=>gr(r)?hr(r.target,r,e,s):dr(r.target,r,e,s))},wr=(t,e)=>{e.forEach(s=>{t.observe(s)})},br=(t,e)=>{Ns(t),wr(t,e)},mr=(t,e)=>{!Ze||xt(t)||(e._observer=new IntersectionObserver(s=>{vr(s,t,e)},fr(t)))},Tt=t=>Array.prototype.slice.call(t),Q=t=>t.container.querySelectorAll(t.elements_selector),Sr=t=>Tt(t).filter(be),yr=t=>Ts(t),Er=t=>Tt(t).filter(yr),We=(t,e)=>Sr(t||Q(e)),xr=(t,e)=>{Er(Q(t)).forEach(r=>{w(r,t.class_error),te(r)}),e.update()},Tr=(t,e)=>{!E||(e._onlineHandler=()=>{xr(t,e)},window.addEventListener("online",e._onlineHandler))},_r=t=>{!E||window.removeEventListener("online",t._onlineHandler)},j=function(t,e){const s=tt(t);this._settings=s,this.loadingCount=0,mr(s,this),Tr(s,this),this.update(e)};j.prototype={update:function(t){const e=this._settings,s=We(t,e);if(ht(this,s.length),Ke||!Ze){this.loadAll(s);return}if(xt(e)){ur(s,e,this);return}br(this._observer,s)},destroy:function(){this._observer&&this._observer.disconnect(),_r(this),Q(this._settings).forEach(t=>{vt(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=>{se(r,this),Te(r,e,this)})},restoreAll:function(){const t=this._settings;Q(t).forEach(e=>{cr(e,t)})}};j.load=(t,e)=>{const s=tt(e);Te(t,s)};j.resetStatus=t=>{te(t)};E&&Ss(j,window.lazyLoadOptions);class _t{constructor({readonly:e,box:s,pages:r,onNewPageIndex:i,onPlay:o}){if(this.pageIndex=0,this.namespace="netless-app-docs-viewer",this.isShowPreview=!1,this.isSmallBox=!1,this.sideEffect=new ee,r.length<=0)throw new Error("[DocsViewer] Empty pages.");this.readonly=e,this.box=s,this.pages=r,this.onNewPageIndex=i,this.onPlay=o,this.render()}mount(){this.box.mountContent(this.$content),this.box.mountFooter(this.$footer),this.sideEffect.add(()=>{const e=new j({container:this.$preview,elements_selector:`.${this.wrapClassName("preview-page>img")}`});return()=>e.destroy()},"preview-lazyload")}unmount(){this.$content.remove(),this.$footer.remove()}setReadonly(e){this.readonly!==e&&(this.readonly=e,this.$content.classList.toggle(this.wrapClassName("readonly"),e),this.$footer.classList.toggle(this.wrapClassName("readonly"),e),this.$pageNumberInput.disabled=e)}destroy(){this.sideEffect.flushAll(),this.unmount()}setPageIndex(e){Number.isNaN(e)||(this.pageIndex=e,this.$pageNumberInput.value=String(e+1))}setSmallBox(e){this.isSmallBox!==e&&(this.isSmallBox=e,this.$footer.classList.toggle(this.wrapClassName("float-footer"),e))}render(){return this.renderContent(),this.renderFooter(),this.$content}renderContent(){if(!this.$content){const e=document.createElement("div");e.className=this.wrapClassName("content"),this.$content=e,this.readonly&&e.classList.add(this.wrapClassName("readonly")),e.appendChild(this.renderPreviewMask()),e.appendChild(this.renderPreview())}return this.$content}renderPreview(){if(!this.$preview){const e=document.createElement("div");e.className=this.wrapClassName("preview")+" tele-fancy-scrollbar",this.$preview=e;const s=this.wrapClassName("preview-page"),r=this.wrapClassName("preview-page-name");this.pages.forEach((i,o)=>{var d;const a=(d=i.thumbnail)!=null?d:i.src.startsWith("ppt")?void 0:i.src;if(!a)return;const n=String(o),c=document.createElement("a");c.className=s+" "+this.wrapClassName(`preview-page-${o}`),c.setAttribute("href","#"),c.dataset.pageIndex=n;const l=document.createElement("span");l.className=r,l.textContent=String(o+1),l.dataset.pageIndex=n;const h=document.createElement("img");h.width=i.width,h.height=i.height,h.dataset.src=a,h.dataset.pageIndex=n,c.appendChild(h),c.appendChild(l),e.appendChild(c)}),this.sideEffect.addEventListener(e,"click",i=>{var a;if(this.readonly)return;const o=(a=i.target.dataset)==null?void 0:a.pageIndex;o&&(i.preventDefault(),i.stopPropagation(),i.stopImmediatePropagation(),this.onNewPageIndex(Number(o)),this.togglePreview(!1))})}return this.$preview}renderPreviewMask(){return this.$previewMask||(this.$previewMask=document.createElement("div"),this.$previewMask.className=this.wrapClassName("preview-mask"),this.sideEffect.addEventListener(this.$previewMask,"click",e=>{this.readonly||e.target===this.$previewMask&&this.togglePreview(!1)})),this.$previewMask}renderFooter(){if(!this.$footer){const e=document.createElement("div");if(e.className=this.wrapClassName("footer"),this.$footer=e,this.readonly&&e.classList.add(this.wrapClassName("readonly")),this.isSmallBox&&e.classList.add(this.wrapClassName("float-footer")),this.pages.some(c=>c.thumbnail||!c.src.startsWith("ppt"))){const c=this.renderFooterBtn("btn-sidebar",gs(this.namespace));this.sideEffect.addEventListener(c,"click",()=>{this.readonly||this.togglePreview()}),this.$footer.appendChild(c)}const s=document.createElement("div");s.className=this.wrapClassName("page-jumps");const r=this.renderFooterBtn("btn-page-back",fs(this.namespace));if(this.sideEffect.addEventListener(r,"click",()=>{this.readonly||this.onNewPageIndex(this.pageIndex-1)}),s.appendChild(r),this.onPlay){const c=this.renderFooterBtn("btn-page-play",ws(this.namespace),bs(this.namespace)),l=()=>{this.sideEffect.setTimeout(()=>{c.classList.toggle(this.wrapClassName("footer-btn-playing"),!1)},500,"returnPlay")};this.sideEffect.addEventListener(c,"click",()=>{this.readonly||(c.classList.toggle(this.wrapClassName("footer-btn-playing"),!0),this.onPlay&&this.onPlay(),l())}),s.appendChild(c)}const i=this.renderFooterBtn("btn-page-next",vs(this.namespace));this.sideEffect.addEventListener(i,"click",()=>{this.readonly||this.onNewPageIndex(this.pageIndex+1)}),s.appendChild(i);const o=document.createElement("div");o.className=this.wrapClassName("page-number");const a=document.createElement("input");a.className=this.wrapClassName("page-number-input"),a.value=String(this.pageIndex+1),this.readonly&&(a.disabled=!0),this.$pageNumberInput=a,this.sideEffect.addEventListener(a,"focus",()=>{a.select()}),this.sideEffect.addEventListener(a,"change",()=>{this.readonly||a.value&&this.onNewPageIndex(Number(a.value)-1)});const n=document.createElement("span");n.textContent=" / "+this.pages.length,o.appendChild(a),o.appendChild(n),this.$footer.appendChild(s),this.$footer.appendChild(o)}return this.$footer}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}togglePreview(e){if(this.isShowPreview=e!=null?e:!this.isShowPreview,this.$content.classList.toggle(this.wrapClassName("preview-active"),this.isShowPreview),this.isShowPreview){const s=this.$preview.querySelector("."+this.wrapClassName(`preview-page-${this.pageIndex}`));s&&this.$preview.scrollTo({top:s.offsetTop-16})}}wrapClassName(e){return`${this.namespace}-${e}`}}function z(t,e,s){return Math.min(Math.max(t,e),s)}function Fe(t){return t.touches?t.touches[0]:t}function It(t){t.stopPropagation(),t.cancelable&&t.preventDefault()}class Ir{constructor(e){var s,r,i;this.velocity=0,this.paused=!0,this._animationFrameID=null,this._loopTimestamp=0,this.looper=o=>{if(this.paused)return;let a=Math.floor((o-this._loopTimestamp)/1e3*60)+1;for(this._loopTimestamp=o;a-- >0;)this.stepper();this.onStep(this.current,this),!this.paused&&this.current!==this.target&&window.requestAnimationFrame(this.looper)},this.current=(s=e.start)!=null?s:0,this.target=this.current,this.stiffness=(r=e.stiffness)!=null?r:170,this.damping=(i=e.damping)!=null?i:26,this.onStep=e.onStep}stepTo(e,s){this.paused&&s!=null&&(this.current=s),this.paused=!1,this.target=e,this.onStep(this.current,this),this._loopTimestamp=Date.now(),window.requestAnimationFrame(this.looper)}pause(){this.paused=!0}destroy(){this.pause()}stepper(){const e=-this.stiffness*(this.current-this.target),s=-this.damping*this.velocity,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.current=i,this.velocity=r)}}class Cr{constructor(e,s,r,i){this.scale=1,this.lastVisit=Date.now(),this.pageOffsetY=0,this.pageOffsetX=0,this.visible=!0,this.index=e,this.page=s,this.scale=r,this.pageOffsetX=(i-s.width)/2;const o=document.createElement("div");o.className="page-renderer-page",o.dataset.index=`${e}`,o.style.width=`${s.width*r}px`,o.style.height=`${s.height*r}px`,s.thumbnail&&(o.style.backgroundImage=`url("${s.thumbnail}")`);const a=document.createElement("img");a.className="page-renderer-page-img",a.width=s.width,a.height=s.height,a.src=s.src,o.appendChild(a),this.$page=o}translateY(e){Math.abs(e-this.pageOffsetY)>=.001&&(this.pageOffsetY=e,this.$page.style.transform=`translate(${this.pageOffsetX*this.scale}px, ${this.pageOffsetY*this.scale}px)`)}setScale(e){Math.abs(e-this.scale)>=.001&&(this.scale=e,this.$page.style.width=`${this.page.width*this.scale}px`,this.$page.style.height=`${this.page.height*this.scale}px`,this.$page.style.transform=`translate(${this.pageOffsetX*this.scale}px, ${this.pageOffsetY*this.scale}px)`)}setVisible(e){e!==this.visible&&(this.visible=e,this.$page.style.opacity=e?"1":"0")}}const $r=window.requestIdleCallback||(t=>window.setTimeout(t,5e3)),Nr=window.cancelIdleCallback||window.clearTimeout;class Pr{constructor(e,s,r){this.pages=e,this.pagesIntrinsicWidth=s,this.scale=r,this.els=new Map,this.maxElCount=200,this.gcTimer=null,this.gc=()=>{if(this.gcTimer=null,this.els.size>this.maxElCount){const i=[...this.els.values()].sort((o,a)=>a.lastVisit-o.lastVisit);for(let o=Math.floor(this.maxElCount/4);o<i.length;o++)this.els.delete(i[o].index)}}}getEl(e){let s=this.els.get(e);return s||(s=new Cr(e,this.pages[e],this.scale,this.pagesIntrinsicWidth),this.els.set(e,s)),s.lastVisit=Date.now(),this.els.size>this.maxElCount&&this.gcTimer===null&&(this.gcTimer=$r(this.gc)),s}setScale(e){e!==this.scale&&(this.scale=e,this.els.forEach(s=>s.setScale(e)))}destroy(){this.els.clear(),this.gcTimer!==null&&(Nr(this.gcTimer),this.gcTimer=null)}}class kr{constructor(e){this._hwaTimeout=NaN,this._turnOffHWA=()=>{window.clearTimeout(this._hwaTimeout),this._hwaTimeout=NaN,this.$pages.classList.toggle("is-hwa",!1)},this.pagesScrollTop=e.pagesScrollTop||0,this.containerWidth=e.containerWidth||1,this.containerHeight=e.containerHeight||1,this.pages=e.pages.map(o=>{if(o.thumbnail)return o;try{const a=new URL(o.src);return a.searchParams.set("x-oss-process","image/resize,l_50"),ce(ne({},o),{thumbnail:a.toString()})}catch(a){return console.error(a),o}});const s=Array(this.pages.length);let r=1/0,i=0;this.pagesIntrinsicHeight=this.pages.reduce((o,a,n)=>(s[n]=o,a.width>i&&(i=a.width),a.height<=r&&(r=a.height),o+a.height),0),this.pagesIntrinsicWidth=i,this.pagesMinHeight=r,this.pagesIntrinsicYs=s,this.scale=this._calcScale(),this.threshold=this._calcThreshold(),this.onPageIndexChanged=e.onPageIndexChanged,this.pageScrollIndex=0,this.pagesScrollTop!==0&&(this.pageScrollIndex=this.findScrollPageIndex(),this.onPageIndexChanged&&this.pageScrollIndex>0&&this.onPageIndexChanged(this.pageScrollIndex)),this.pageElManager=new Pr(this.pages,i,this.scale),this.$pages=this.renderPages()}setContainerSize(e,s){e>0&&s>0&&(e!==this.containerWidth||s!==this.containerHeight)&&(this.containerWidth=e,this.containerHeight=s,this.$pages.style.width=`${this.containerWidth}px`,this.$pages.style.height=`${this.containerHeight}px`,this.scale=this._calcScale(),this.threshold=this._calcThreshold(),this.pageElManager.setScale(this.scale),this.$pages.parentElement&&this.pagesScrollTo(this.pagesScrollTop,!0))}renderPages(){const e=document.createElement("div");return e.className="page-renderer-pages-container",e.style.width=`${this.containerWidth}px`,e.style.height=`${this.containerHeight}px`,e}pagesScrollTo(e,s){if(e=z(e,0,this.pagesIntrinsicHeight-this.containerHeight/this.scale),s||Math.abs(e-this.pagesScrollTop)>=.001){this._turnOnHWA(),this.pagesScrollTop=e;const r=this.findScrollPageIndex(),i=Math.max(r-this.threshold,0),o=Math.min(r+this.threshold,this.pages.length-1);for(let a=0;a<this.$pages.children.length;a++){const n=this.$pages.children[a],c=Number(n.dataset.index);c>=i&&c<=o||(n.remove(),a--)}for(let a=i;a<=o;a++){const n=this.pageElManager.getEl(a);n.$page.parentElement!==this.$pages&&this.$pages.appendChild(n.$page),n.translateY(this.pagesIntrinsicYs[a]-this.pagesScrollTop)}r!==this.pageScrollIndex&&(this.pageScrollIndex=r,this.onPageIndexChanged&&this.onPageIndexChanged(r))}}findScrollPageIndex(){for(let e=0;e<this.pagesIntrinsicYs.length;e++)if(this.pagesIntrinsicYs[e]+this.pages[e].height-this.pagesScrollTop>=.001)return e;return this.pagesIntrinsicYs.length-1}mount(e){e.appendChild(this.$pages),this.pagesScrollTo(this.pagesScrollTop,!0)}unmount(){this.$pages.remove()}destroy(){this.unmount(),this.onPageIndexChanged=void 0,this.pageElManager.destroy(),this._hwaTimeout&&(window.clearTimeout(this._hwaTimeout),this._hwaTimeout=NaN)}_calcScale(){return this.containerWidth/this.pagesIntrinsicWidth||1}_calcThreshold(){return z(Math.ceil(this.containerHeight/this.scale/this.pagesMinHeight/2),1,this.pages.length)}_turnOnHWA(){this._hwaTimeout?window.clearTimeout(this._hwaTimeout):this.$pages.classList.toggle("is-hwa",!0),this._hwaTimeout=window.setTimeout(this._turnOffHWA,1e3)}}const Rr=30;class Or{constructor(e){this.sideEffect=new ee,this.pagesScrollTop=e.pagesScrollTop||0,this.containerWidth=e.containerWidth||1,this.containerHeight=e.containerHeight||1,this.pagesWidth=e.pagesWidth||1,this.pagesHeight=e.pagesHeight||1,this.scale=this._calcScale(),this.scrollbarMinHeight=e.scrollbarMinHeight||Rr,this.scrollbarHeight=this._calcScrollbarHeight(),this.readonly=e.readonly,this.wrapClassName=e.wrapClassName,this.onDragScroll=e.onDragScroll,this.$scrollbar=this.renderScrollbar()}mount(e){e.appendChild(this.$scrollbar),this.pagesScrollTo(this.pagesScrollTop,!0)}unmount(){this.$scrollbar.remove()}setReadonly(e){this.readonly=e}setContainerSize(e,s){e>0&&s>0&&(e!==this.containerWidth||s!==this.containerHeight)&&(this.containerWidth=e,this.containerHeight=s,this.scale=this._calcScale(),this._updateScrollbarHeight(),this.$scrollbar.parentElement&&this.pagesScrollTo(this.pagesScrollTop,!0))}pagesScrollTo(e,s){if(e=z(e,0,this.pagesHeight-this.containerHeight/this.scale),s||Math.abs(e-this.pagesScrollTop)>=.001){this.pagesScrollTop=e;const r=this.pagesScrollTop*this.scale,i=this.pagesHeight*this.scale,o=r/(i-this.containerHeight)*(this.containerHeight-this.scrollbarHeight);window.requestAnimationFrame?window.requestAnimationFrame(()=>{this.$scrollbar.style.transform=`translateY(${o}px)`}):this.$scrollbar.style.transform=`translateY(${o}px)`}}destroy(){this.unmount(),this.onDragScroll=void 0,this.sideEffect.flushAll()}renderScrollbar(){const e=document.createElement("button");e.className=this.wrapClassName("scrollbar"),e.style.minHeight=`${this.scrollbarMinHeight}px`,e.style.height=`${this.scrollbarHeight}px`;const s=r=>{if(this.readonly||r.button!=null&&r.button!==0)return;It(r);const i=this.wrapClassName("scrollbar-dragging");e.classList.toggle(i,!0);const o=this.pagesScrollTop,{clientY:a}=Fe(r),n=l=>{if(this.readonly)return;const{clientY:h}=Fe(l),d=(h-a)/this.scale;Math.abs(d)>0&&this.onDragScroll&&this.onDragScroll(o+d*(this.pagesHeight*this.scale/this.containerHeight))},c=()=>{e.classList.toggle(i,!1),window.removeEventListener("mousemove",n,!0),window.removeEventListener("touchmove",n,!0),window.removeEventListener("mouseup",c,!0),window.removeEventListener("touchend",c,!0),window.removeEventListener("touchcancel",c,!0)};window.addEventListener("mousemove",n,!0),window.addEventListener("touchmove",n,!0),window.addEventListener("mouseup",c,!0),window.addEventListener("touchend",c,!0),window.addEventListener("touchcancel",c,!0)};return this.sideEffect.addEventListener(e,"mousedown",s),this.sideEffect.addEventListener(e,"touchstart",s),e}_calcScale(){return this.containerWidth/this.pagesWidth||1}_calcScrollbarHeight(){return z(this.containerHeight/(this.pagesHeight*this.scale)*this.containerHeight,this.scrollbarMinHeight,this.containerHeight)}_updateScrollbarHeight(){const e=this._calcScrollbarHeight();Math.abs(e-this.scrollbarHeight)>.001&&(this.scrollbarHeight=e,this.$scrollbar.style.height=`${e}px`)}}const Lr=window.ResizeObserver||us,M=640;class zr{constructor({whiteboardView:e,readonly:s,box:r,pages:i,pageScrollTop:o=0,mountWhiteboard:a,onUserScroll:n,baseScenePath:c,appId:l}){this.sideEffect=new ee,this.userScrolling=!1,this.onNewPageIndex=p=>{this.scrollToPage(p)},this.toPdf=async()=>{const p=document.createElement("canvas"),b=p.getContext("2d");if(!b||!this.baseScenePath){this.reportProgress(100,null);return}const oe=`${this.baseScenePath}/1`,T=this.pages[0],{jsPDF:Y}=await Promise.resolve().then(function(){return Lt(require("jspdf"))}),S=new Y({format:[T.width,T.height],orientation:T.width>T.height?"l":"p",compress:!0});for(const[_,G]of this.pages.entries()){const{width:f,height:g,src:k}=G;p.width=f,p.height=g;const R=f>g?"l":"p";_>0&&S.addPage([f,g],R);const ae=await this.getBase64FromUrl(k),D=document.createElement("img");D.src=ae,await new Promise($t=>D.onload=$t),b.drawImage(D,0,0);const X=p.toDataURL("image/jpeg",.6);b.clearRect(0,0,f,g),this.whiteboardView.screenshotToCanvas(b,oe,f,g,{centerX:f/2,centerY:g/2+_*g,scale:1});const Ct=p.toDataURL("image/png");S.addImage(X,"JPEG",0,0,f,g,"","FAST"),S.addImage(Ct,"PNG",0,0,f,g,"","FAST"),b.clearRect(0,0,f,g),Math.ceil((_+1)/this.pages.length*100)<100&&this.reportProgress(Math.ceil((_+1)/this.pages.length*100),null)}const H=S.output("arraybuffer");this.reportProgress(100,{pdf:H,title:this.box.title})},this.whiteboardView=e,this.readonly=s,this.box=r,this.pages=i,this.baseScenePath=c,this.appId=l,this.mountWhiteboard=a,this._onUserScroll=n;const h=this.debounce(()=>{this.userScrolling=!1,this._onUserScroll&&this._onUserScroll(this.pageRenderer.pagesScrollTop)},{wait:80},"debounce-updateUserScroll");this.updateUserScroll=()=>{this.userScrolling=!0,h()},this.viewer=new _t({readonly:s,box:r,pages:i,onNewPageIndex:this.onNewPageIndex});const{width:d,height:P}=this.whiteboardView.size;this.pageRenderer=new kr({pagesScrollTop:o,pages:this.pages,containerWidth:d,containerHeight:P,onPageIndexChanged:this.viewer.setPageIndex.bind(this.viewer)}),this.scrollbar=new Or({pagesScrollTop:this.pageRenderer.pagesScrollTop,containerWidth:d,containerHeight:P,pagesWidth:this.pageRenderer.pagesIntrinsicWidth,pagesHeight:this.pageRenderer.pagesIntrinsicHeight,readonly:this.readonly,wrapClassName:this.wrapClassName.bind(this),onDragScroll:p=>{this.pageScrollTo(p),this.updateUserScroll()}}),this.pageScrollStepper=new Ir({start:this.pageRenderer.pagesScrollTop,onStep:p=>{this.pageScrollTo(p)}}),this.render()}mount(){this.viewer.mount(),this.setupScrollListener();const e=this.debounce(this.renderRatioHeight.bind(this),{wait:80});return this.sideEffect.add(()=>{const s=new Lr(e);return s.observe(this.viewer.$content),()=>s.disconnect()}),this.sideEffect.setTimeout(()=>{this.userScrolling||this.pageScrollTo(this.pageRenderer.pagesScrollTop)},100),this.sideEffect.add(()=>{const s=r=>{r.data.type==="@netless/_request_save_pdf_"&&r.data.appId===this.appId&&this.toPdf().catch(()=>this.reportProgress(100,null))};return window.addEventListener("message",s),()=>{window.removeEventListener("message",s)}}),this}unmount(){return this.viewer.unmount(),this}setReadonly(e){this.readonly!==e&&(this.readonly=e,this.viewer.setReadonly(e),this.scrollbar.setReadonly(e))}destroy(){this.sideEffect.flushAll(),this.pageScrollStepper.destroy(),this._onUserScroll=void 0,this.unmount(),this.viewer.destroy(),this.pageRenderer.destroy(),this.scrollbar.destroy()}syncPageScrollTop(e){!this.userScrolling&&e>=0&&Math.abs(this.pageRenderer.pagesScrollTop-e)>.01&&this.pageScrollStepper.stepTo(e,this.pageRenderer.pagesScrollTop)}render(){this.pageRenderer.mount(this.viewer.$content),this.viewer.$content.appendChild(this.renderWhiteboardView()),this.scrollbar.mount(this.viewer.$content),this.renderRatioHeight()}renderRatioHeight(){const e=this.box.absoluteHeight,s=e<=M;if(this.viewer.setSmallBox(s),s){const r=26/M,i=26/e,o=26/M,a=0,n=Math.max((r+o-(i+a))/2,0);if(this.box.$titleBar){const c=i+n;this.box.$titleBar.style.height=`${c*100}%`}if(this.box.$footer){const c=a+n;this.box.$footer.style.height=`${c*100}%`}}else{if(this.box.$titleBar){const r=Math.max(26/M,26/e);this.box.$titleBar.style.height=`${r*100}%`}if(this.box.$footer){const r=Math.max(26/M,26/e);this.box.$footer.style.height=`${r*100}%`}}}renderWhiteboardView(){return this.$whiteboardView||(this.$whiteboardView=document.createElement("div"),this.$whiteboardView.className=this.wrapClassName("wb-view"),this.mountWhiteboard(this.$whiteboardView),this.sideEffect.addEventListener(this.$whiteboardView,"wheel",e=>{It(e),this.readonly||(this.pageScrollTo(this.pageRenderer.pagesScrollTop+e.deltaY),this.updateUserScroll())},{passive:!1,capture:!0}),this.sideEffect.addEventListener(this.$whiteboardView,"touchmove",e=>{this.readonly||e.touches.length<=1||this.updateUserScroll()},{passive:!0,capture:!0})),this.$whiteboardView}scrollTopPageToEl(e){return e*this.pageRenderer.scale}scrollTopElToPage(e){return e/this.pageRenderer.scale}elScrollTo(e){this.pageScrollTo(this.scrollTopElToPage(e))}pageScrollTo(e){const s=this.scrollTopElToPage(this.whiteboardView.size.height/2);this.whiteboardView.moveCamera({centerY:z(e+s,s,this.pageRenderer.pagesIntrinsicHeight-s),animationMode:"immediately"})}scrollToPage(e){if(!this.readonly&&!Number.isNaN(e)){const s=this.pageRenderer.pagesIntrinsicYs[e];s>=0&&(this.pageScrollTo(s+5/this.pageRenderer.scale),this.updateUserScroll())}}setupScrollListener(){this.sideEffect.add(()=>{const s=r=>{const{width:i,height:o}=this.whiteboardView.size;if(i<=0||o<=0)return;const a=r.centerY-this.pageRenderer.containerHeight/this.pageRenderer.scale/2;this.pageRenderer.pagesScrollTo(a),this.scrollbar.pagesScrollTo(a)};return this.whiteboardView.callbacks.on("onCameraUpdated",s),()=>this.whiteboardView.callbacks.off("onCameraUpdated",s)}),this.sideEffect.add(()=>{const s=({width:r,height:i})=>{if(r<=0||i<=0)return;this.pageRenderer.setContainerSize(r,i),this.scrollbar.setContainerSize(r,i);const{pagesIntrinsicWidth:o,pagesIntrinsicHeight:a}=this.pageRenderer;this.whiteboardView.moveCameraToContain({originX:0,originY:this.pageRenderer.pagesScrollTop,width:o,height:i/this.pageRenderer.scale,animationMode:"immediately"}),this.whiteboardView.setCameraBound({damping:1,maxContentMode:()=>this.pageRenderer.scale,minContentMode:()=>this.pageRenderer.scale,centerX:o/2,centerY:a/2,width:o,height:a})};return this.whiteboardView.callbacks.on("onSizeUpdated",s),()=>{this.whiteboardView.callbacks.off("onSizeUpdated",s)}},"whiteboard-size-update");const e=s=>{if(!s)return!1;const r=s.tagName;return r==="INPUT"||r==="TEXTAREA"||r==="SELECT"};this.sideEffect.addEventListener(window,"keyup",s=>{if(this.readonly||!this.box.focus||this.box.minimized||e(s.target))return;let r=null;switch(s.key){case"PageDown":{r=this.pageRenderer.pagesScrollTop+this.pageRenderer.containerHeight/this.pageRenderer.scale;break}case"PageUp":{r=this.pageRenderer.pagesScrollTop-this.pageRenderer.containerHeight/this.pageRenderer.scale;break}case"ArrowDown":{r=this.pageRenderer.pagesScrollTop+this.pageRenderer.containerHeight/4/this.pageRenderer.scale;break}case"ArrowUp":{r=this.pageRenderer.pagesScrollTop-this.pageRenderer.containerHeight/4/this.pageRenderer.scale;break}}r!==null&&(this._onUserScroll?this._onUserScroll(r):(this.pageScrollTo(r),this.updateUserScroll()))},{capture:!0})}debounce(e,s,r){const i=Ut(e,s);return this.sideEffect.addDisposer(()=>i.cancel(),r),i}wrapClassName(e){return"netless-app-docs-viewer-static-"+e}async getBase64FromUrl(e){const r=await(await fetch(e)).blob();return new Promise(i=>{const o=new FileReader;o.readAsDataURL(r),o.onloadend=()=>{const a=o.result;i(a)}})}reportProgress(e,s){window.postMessage({type:"@netless/_result_save_pdf_",appId:this.appId,progress:e,result:s})}}class Ar{constructor({context:e,whiteboardView:s,box:r,pages:i}){this.sideEffect=new ee,this.onPlayPPT=()=>{const o=this.context.getRoom();o&&o.pptNextStep()},this._scaleDocsToFitImpl=()=>{const o=this.pages[this.getPageIndex()];o&&(this.whiteboardView.moveCameraToContain({originX:-o.width/2,originY:-o.height/2,width:o.width,height:o.height,animationMode:"immediately"}),this.whiteboardView.setCameraBound({damping:1,maxContentMode:()=>this.whiteboardView.camera.scale,minContentMode:()=>this.whiteboardView.camera.scale,centerX:0,centerY:0,width:o.width,height:o.height}))},this._scaleDocsToFitDebounced=()=>{this.sideEffect.setTimeout(this._scaleDocsToFitImpl,1e3,"_scaleDocsToFitDebounced")},this.scaleDocsToFit=()=>{this._scaleDocsToFitImpl(),this._scaleDocsToFitDebounced()},this.onNewPageIndex=o=>{this.jumpToPage(o,!0)},this.context=e,this.whiteboardView=s,this.box=r,this.pages=i,this.displayer=e.getDisplayer(),this.viewer=new _t({readonly:!e.getIsWritable(),box:r,pages:i,onNewPageIndex:this.onNewPageIndex,onPlay:this.onPlayPPT}),this.render(),this.sideEffect.add(()=>{const o=a=>{this.viewer.setReadonly(!a)};return this.context.emitter.on("writableChange",o),()=>this.context.emitter.off("writableChange",o)}),this.sideEffect.add(()=>{const o=a=>{this.jumpToPage(a.index)};return this.context.emitter.on("sceneStateChange",o),()=>this.context.emitter.off("sceneStateChange",o)})}mount(){this.viewer.mount();const e=this.getPageIndex();return e!==0&&this.jumpToPage(e),this.scaleDocsToFit(),this.sideEffect.add(()=>(this.whiteboardView.callbacks.on("onSizeUpdated",this.scaleDocsToFit),()=>{this.whiteboardView.callbacks.off("onSizeUpdated",this.scaleDocsToFit)})),this}unmount(){return this.viewer.unmount(),this}destroy(){this.sideEffect.flushAll(),this.unmount(),this.viewer.destroy()}getPageIndex(){return this.displayer.state.sceneState.index}jumpToPage(e,s){var r,i;if(e=z(e,0,this.pages.length-1),e!==this.getPageIndex()&&this.context.getIsWritable()){const o=this.context.getInitScenePath(),a=(i=(r=this.context.getScenes())==null?void 0:r[e])==null?void 0:i.name;o&&a&&this.context.setScenePath(`${o}/${a}`),this.scaleDocsToFit()}if(e!==this.viewer.pageIndex&&this.viewer.setPageIndex(e),s){const o=this.context.getRoom();if(o){const a=o.state.globalState.__pptState;o.setGlobalState({__pptState:a&&{uuid:a.uuid,pageIndex:e,disableAutoPlay:a.disableAutoPlay}})}}}render(){this.viewer.$content.appendChild(this.renderMask()),this.viewer.$content.appendChild(this.renderWhiteboardView()),this.sideEffect.addEventListener(window,"keydown",e=>{var s;if(this.box.focus)switch(e.key){case"ArrowUp":case"ArrowLeft":{this.jumpToPage(this.getPageIndex()-1,!0);break}case"ArrowRight":case"ArrowDown":{(s=this.context.getRoom())==null||s.pptNextStep();break}}})}renderMask(){if(!this.$mask){const e=document.createElement("div");e.className=this.wrapClassName("mask"),this.$mask=e;const s=document.createElement("button");s.className=this.wrapClassName("back");const r=document.createElement("button");r.className=this.wrapClassName("next")}return this.$mask}renderWhiteboardView(){return this.$whiteboardView||(this.$whiteboardView=document.createElement("div"),this.$whiteboardView.className=this.wrapClassName("wb-view"),this.sideEffect.addEventListener(this.$whiteboardView,"click",e=>{var r;const s=this.context.getRoom();if(s&&s.state.memberState.currentApplianceName==="clicker"){for(let i=e.target;i;i=i.parentElement)if((r=i.classList)!=null&&r.contains("ppt-event-source"))return;s.pptNextStep()}}),this.context.mountView(this.$whiteboardView)),this.$whiteboardView}wrapClassName(e){return"netless-app-docs-viewer-dynamic-"+e}}const Hr="DocsViewer",Dr={kind:Hr,setup(t){const e=t.getBox(),s=t.getScenes();if(!s)throw new Error("[Docs Viewer]: scenes not found.");const r=t.getView();if(!r)throw new Error("[Docs Viewer]: no whiteboard view.");const i=s.map(({ppt:o})=>o?{width:o.width,height:o.height,src:o.src,thumbnail:o.previewURL}:null).filter(o=>Boolean(o));if(i.length<=0)throw new Error("[Docs Viewer]: empty scenes.");e.mountStyles(zt),i[0].src.startsWith("ppt")?Vr(t,r,e,i):Mr(t,r,e,i)}};function Mr(t,e,s,r){var o;e.disableCameraTransform=!t.getIsWritable();const i=new zr({whiteboardView:e,readonly:!t.getIsWritable(),box:s,pages:r,pageScrollTop:(o=t.getAttributes())==null?void 0:o.pageScrollTop,mountWhiteboard:t.mountView.bind(t),onUserScroll:a=>{var n;((n=t.getAttributes())==null?void 0:n.pageScrollTop)!==a&&!s.readonly&&t.updateAttributes(["pageScrollTop"],a)},baseScenePath:t.getInitScenePath(),appId:t.appId}).mount();t.emitter.on("attributesUpdate",a=>{a&&a.pageScrollTop!=null&&i.syncPageScrollTop(a.pageScrollTop)}),t.emitter.on("writableChange",a=>{i.setReadonly(!a),e.disableCameraTransform=!a})}function Vr(t,e,s,r){e.disableCameraTransform=!0;const i=new Ar({context:t,whiteboardView:e,box:s,pages:r}).mount();t.mountView(i.$whiteboardView),t.isAddApp&&e.callbacks.once("onSizeUpdated",({width:o,height:a})=>{if(r.length>0&&s.state!=="maximized"){const{width:n,height:c}=r[0],h=c/n*o-a;h!==0&&t.getIsWritable()&&t.emitter.emit("setBoxSize",{width:s.width,height:s.height+h/s.containerRect.height})}})}exports.default=Dr; | ||
"use strict";var Pt=Object.defineProperty,kt=Object.defineProperties;var Rt=Object.getOwnPropertyDescriptors;var _e=Object.getOwnPropertySymbols;var Ot=Object.prototype.hasOwnProperty,Lt=Object.prototype.propertyIsEnumerable;var Ie=(t,e,s)=>e in t?Pt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,ne=(t,e)=>{for(var s in e||(e={}))Ot.call(e,s)&&Ie(t,s,e[s]);if(_e)for(var s of _e(e))Lt.call(e,s)&&Ie(t,s,e[s]);return t},ce=(t,e)=>kt(t,Rt(e));Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});function zt(t){if(t&&t.__esModule)return t;var e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});return t&&Object.keys(t).forEach(function(s){if(s!=="default"){var r=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(e,s,r.get?r:{enumerable:!0,get:function(){return t[s]}})}}),e.default=t,Object.freeze(e)}var At=(()=>`.netless-app-docs-viewer-content{position:relative;height:100%;overflow:hidden}.netless-app-docs-viewer-preview-mask{display:none;position:absolute;z-index:200;top:0;left:0;width:100%;height:100%}.netless-app-docs-viewer-preview{display:flex;flex-direction:column;align-items:center;position:absolute;z-index:300;top:0;left:0;width:33%;max-width:200px;height:100%;padding-top:10px;transform:translate(-100%);background:rgba(237,237,240,.9);box-shadow:inset -1px 0 #0000001c;transition:transform .4s}.netless-app-docs-viewer-preview-active .netless-app-docs-viewer-preview-mask{display:block}.netless-app-docs-viewer-preview-active .netless-app-docs-viewer-preview{transform:translate(0)}.netless-app-docs-viewer-preview-page{position:relative;display:block;width:55%;margin-bottom:10px;font-size:0;color:transparent;outline:none;border:7px solid transparent;border-radius:4px;transition:border-color .3s;user-select:none}.netless-app-docs-viewer-preview-page:hover,.netless-app-docs-viewer-preview-page.netless-app-docs-viewer-preview-page-active{border-color:#444e601a}.netless-app-docs-viewer-preview-page>img{width:100%;height:auto;box-sizing:border-box;border:1px solid rgba(0,0,0,.5);border-radius:1px;background-color:#fff;box-shadow:0 2px 8px #0000004d}.netless-app-docs-viewer-preview-page-name{position:absolute;top:1px;left:-10px;transform:translate(-100%);text-align:right;font-size:12px;color:#5f5f5f;user-select:none}.netless-app-docs-viewer-footer{box-sizing:border-box;height:26px;display:flex;align-items:center;padding:0 16px;border-top:1px solid #eeeef7;color:#191919}.netless-app-docs-viewer-float-footer{width:100%;min-height:26px;position:absolute;left:0;bottom:0;z-index:2000;background:rgba(249,249,252,.9);transition:opacity .4s}.netless-app-docs-viewer-footer-btn{box-sizing:border-box;width:26px;height:26px;font-size:0;margin:0;padding:3px;border:none;border-radius:1px;outline:none;color:currentColor;background:transparent;transition:background .4s;cursor:pointer;user-select:none;-webkit-tap-highlight-color:rgba(0,0,0,0)}.netless-app-docs-viewer-footer-btn:hover{background:rgba(237,237,240,.9)}@media (hover: none){.netless-app-docs-viewer-footer-btn:hover{background:transparent!important}}.netless-app-docs-viewer-footer-btn>svg{width:100%;height:100%}.netless-app-docs-viewer-footer-btn>svg:nth-of-type(2){display:none}.netless-app-docs-viewer-footer-btn.netless-app-docs-viewer-footer-btn-playing>svg:nth-of-type(1){display:none}.netless-app-docs-viewer-footer-btn.netless-app-docs-viewer-footer-btn-playing>svg:nth-of-type(2){display:initial}.netless-app-docs-viewer-footer-btn~.netless-app-docs-viewer-footer-btn{margin-left:15px}.netless-app-docs-viewer-page-jumps{flex:1;display:flex;justify-content:center;align-items:center}.netless-app-docs-viewer-page-number{margin-left:auto;font-size:13px;user-select:none;white-space:nowrap;word-break:keep-all}.netless-app-docs-viewer-page-number-input{border:none;outline:none;width:3em;margin:0;padding:0 2px;text-align:right;font-size:13px;line-height:1;font-weight:400;font-family:inherit;border-radius:2px;color:currentColor;background:transparent;transition:background .4s;user-select:text;-webkit-tap-highlight-color:rgba(0,0,0,0)}.netless-app-docs-viewer-page-number-input:hover,.netless-app-docs-viewer-page-number-input:focus,.netless-app-docs-viewer-page-number-input:active{background:#fff;box-shadow:#63636333 0 2px 8px}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-footer-btn{cursor:not-allowed}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-footer-btn:hover{background:transparent}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-page-number-input{cursor:not-allowed}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-page-number-input:hover,.netless-app-docs-viewer-readonly .netless-app-docs-viewer-page-number-input:focus,.netless-app-docs-viewer-readonly .netless-app-docs-viewer-page-number-input:active{background:transparent;box-shadow:none}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-page-number-input:disabled{color:inherit}.netless-app-docs-viewer-readonly.netless-app-docs-viewer-float-footer{display:none}.telebox-color-scheme-dark .netless-app-docs-viewer-page-number-input{color:#a6a6a8}.telebox-color-scheme-dark .netless-app-docs-viewer-page-number-input:active,.telebox-color-scheme-dark .netless-app-docs-viewer-page-number-input:focus,.telebox-color-scheme-dark .netless-app-docs-viewer-page-number-input:hover{color:#222}.telebox-color-scheme-dark .netless-app-docs-viewer-footer{color:#a6a6a8;background:#2d2d33;border-top:none}.telebox-color-scheme-dark .netless-app-docs-viewer-footer-btn:hover{background:#212126}.telebox-color-scheme-dark .netless-app-docs-viewer-preview{background:rgba(50,50,50,.9)}.netless-app-docs-viewer-static-scrollbar{position:absolute;top:0;right:0;z-index:2147483647;width:8px;min-height:30px;margin:0;padding:0;border:none;outline:none;border-radius:4px;background:rgba(68,78,96,.4);box-shadow:1px 1px 8px #ffffffb3;opacity:0;transition:background .4s,opacity .4s 3s,transform .2s;user-select:none}.netless-app-docs-viewer-static-scrollbar.netless-app-docs-viewer-static-scrollbar-dragging{background:rgba(68,78,96,.6);opacity:1;transition:background .4s,opacity .4s 3s!important}.netless-app-docs-viewer-static-scrollbar:hover,.netless-app-docs-viewer-static-scrollbar:focus{background:rgba(68,78,96,.5)}.netless-app-docs-viewer-static-scrollbar:active{background:rgba(68,78,96,.6)}.netless-app-docs-viewer-content:hover .netless-app-docs-viewer-static-scrollbar{opacity:1;transition:background .4s,opacity .4s,transform .2s}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-static-scrollbar{display:none}.netless-app-docs-viewer-static-pages:hover .netless-app-docs-viewer-static-scrollbar{opacity:1;transition:background .4s,opacity .4s,transform .2s}.page-renderer-pages-container{position:relative;overflow:hidden}.page-renderer-page{position:absolute;top:0;left:0;background-position:center;background-size:cover;background-repeat:no-repeat}.page-renderer-pages-container.is-hwa .page-renderer-page{will-change:transform}.page-renderer-page-img{display:block;width:100%;height:auto;user-select:none}.netless-app-docs-viewer-static-pages{overflow:hidden;position:relative;height:100%;user-select:none}.netless-app-docs-viewer-static-page{display:block;width:100%;height:auto;user-select:none}.netless-app-docs-viewer-static-wb-view,.netless-app-docs-viewer-dynamic-wb-view{position:absolute;top:0;left:0;width:100%;height:100%;z-index:100;overflow:hidden}.netless-app-docs-viewer-dynamic-wb-view .cursor-clicker .ppt-event-source{cursor:pointer} | ||
`)();const Ht=(t,e,s,r)=>{if(s==="length"||s==="prototype"||s==="arguments"||s==="caller")return;const i=Object.getOwnPropertyDescriptor(t,s),o=Object.getOwnPropertyDescriptor(e,s);!Dt(i,o)&&r||Object.defineProperty(t,s,o)},Dt=function(t,e){return t===void 0||t.configurable||t.writable===e.writable&&t.enumerable===e.enumerable&&t.configurable===e.configurable&&(t.writable||t.value===e.value)},Mt=(t,e)=>{const s=Object.getPrototypeOf(e);s!==Object.getPrototypeOf(t)&&Object.setPrototypeOf(t,s)},Vt=(t,e)=>`/* Wrapped ${t}*/ | ||
${e}`,Bt=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),Wt=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),Ft=(t,e,s)=>{const r=s===""?"":`with ${s.trim()}() `,i=Vt.bind(null,r,e.toString());Object.defineProperty(i,"name",Wt),Object.defineProperty(t,"toString",ce(ne({},Bt),{value:i}))};function Ut(t,e,{ignoreNonConfigurable:s=!1}={}){const{name:r}=t;for(const i of Reflect.ownKeys(e))Ht(t,e,i,s);return Mt(t,e),Ft(t,e,r),t}const jt=(t,e={})=>{if(typeof t!="function")throw new TypeError(`Expected the first argument to be a function, got \`${typeof t}\``);const{wait:s=0,maxWait:r=Number.Infinity,before:i=!1,after:o=!0}=e;if(!i&&!o)throw new Error("Both `before` and `after` are false, function wouldn't be called.");let a,n,c;const l=function(...h){const d=this,P=()=>{a=void 0,n&&(clearTimeout(n),n=void 0),o&&(c=t.apply(d,h))},p=()=>{n=void 0,a&&(clearTimeout(a),a=void 0),o&&(c=t.apply(d,h))},b=i&&!a;return clearTimeout(a),a=setTimeout(P,s),r>0&&r!==Number.Infinity&&!n&&(n=setTimeout(p,r)),b&&(c=t.apply(d,h)),c};return Ut(l,t),l.cancel=()=>{a&&(clearTimeout(a),a=void 0),n&&(clearTimeout(n),n=void 0)},l},Ue="!#%()*+,-./:;=?@[]^_`{|}~ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",Yt=Ue.length,Ce=Array(20),Gt=()=>{for(let t=0;t<20;t++)Ce[t]=Ue.charAt(Math.random()*Yt);return Ce.join("")};function $e(t){try{return t()}catch(e){console.error(e)}}class ee{constructor(){this.disposers=new Map}addDisposer(e,s=this.genUID()){return this.flush(s),this.disposers.set(s,Array.isArray(e)?()=>e.forEach($e):e),s}add(e,s=this.genUID()){return this.addDisposer(e(),s)}addEventListener(e,s,r,i,o=this.genUID()){return e.addEventListener(s,r,i),this.addDisposer(()=>e.removeEventListener(s,r,i),o),o}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($e),this.disposers.clear()}genUID(){let e;do e=Gt();while(this.disposers.has(e));return e}}var I=[],Xt=function(){return I.some(function(t){return t.activeTargets.length>0})},qt=function(){return I.some(function(t){return t.skippedTargets.length>0})},Ne="ResizeObserver loop completed with undelivered notifications.",Jt=function(){var t;typeof ErrorEvent=="function"?t=new ErrorEvent("error",{message:Ne}):(t=document.createEvent("Event"),t.initEvent("error",!1,!1),t.message=Ne),window.dispatchEvent(t)},B;(function(t){t.BORDER_BOX="border-box",t.CONTENT_BOX="content-box",t.DEVICE_PIXEL_CONTENT_BOX="device-pixel-content-box"})(B||(B={}));var C=function(t){return Object.freeze(t)},Kt=function(){function t(e,s){this.inlineSize=e,this.blockSize=s,C(this)}return t}(),je=function(){function t(e,s,r,i){return this.x=e,this.y=s,this.width=r,this.height=i,this.top=this.y,this.left=this.x,this.bottom=this.top+this.height,this.right=this.left+this.width,C(this)}return t.prototype.toJSON=function(){var e=this,s=e.x,r=e.y,i=e.top,o=e.right,a=e.bottom,n=e.left,c=e.width,l=e.height;return{x:s,y:r,top:i,right:o,bottom:a,left:n,width:c,height:l}},t.fromRect=function(e){return new t(e.x,e.y,e.width,e.height)},t}(),ue=function(t){return t instanceof SVGElement&&"getBBox"in t},Ye=function(t){if(ue(t)){var e=t.getBBox(),s=e.width,r=e.height;return!s&&!r}var i=t,o=i.offsetWidth,a=i.offsetHeight;return!(o||a||t.getClientRects().length)},Pe=function(t){var e,s;if(t instanceof Element)return!0;var r=(s=(e=t)===null||e===void 0?void 0:e.ownerDocument)===null||s===void 0?void 0:s.defaultView;return!!(r&&t instanceof r.Element)},Zt=function(t){switch(t.tagName){case"INPUT":if(t.type!=="image")break;case"VIDEO":case"AUDIO":case"EMBED":case"OBJECT":case"CANVAS":case"IFRAME":case"IMG":return!0}return!1},V=typeof window!="undefined"?window:{},q=new WeakMap,ke=/auto|scroll/,Qt=/^tb|vertical/,es=/msie|trident/i.test(V.navigator&&V.navigator.userAgent),v=function(t){return parseFloat(t||"0")},O=function(t,e,s){return t===void 0&&(t=0),e===void 0&&(e=0),s===void 0&&(s=!1),new Kt((s?e:t)||0,(s?t:e)||0)},Re=C({devicePixelContentBoxSize:O(),borderBoxSize:O(),contentBoxSize:O(),contentRect:new je(0,0,0,0)}),Ge=function(t,e){if(e===void 0&&(e=!1),q.has(t)&&!e)return q.get(t);if(Ye(t))return q.set(t,Re),Re;var s=getComputedStyle(t),r=ue(t)&&t.ownerSVGElement&&t.getBBox(),i=!es&&s.boxSizing==="border-box",o=Qt.test(s.writingMode||""),a=!r&&ke.test(s.overflowY||""),n=!r&&ke.test(s.overflowX||""),c=r?0:v(s.paddingTop),l=r?0:v(s.paddingRight),h=r?0:v(s.paddingBottom),d=r?0:v(s.paddingLeft),P=r?0:v(s.borderTopWidth),p=r?0:v(s.borderRightWidth),b=r?0:v(s.borderBottomWidth),oe=r?0:v(s.borderLeftWidth),T=d+l,Y=c+h,S=oe+p,H=P+b,_=n?t.offsetHeight-H-t.clientHeight:0,G=a?t.offsetWidth-S-t.clientWidth:0,f=i?T+S:0,g=i?Y+H:0,k=r?r.width:v(s.width)-f-G,R=r?r.height:v(s.height)-g-_,ae=k+T+G+S,D=R+Y+_+H,X=C({devicePixelContentBoxSize:O(Math.round(k*devicePixelRatio),Math.round(R*devicePixelRatio),o),borderBoxSize:O(ae,D,o),contentBoxSize:O(k,R,o),contentRect:new je(d,c,k,R)});return q.set(t,X),X},Xe=function(t,e,s){var r=Ge(t,s),i=r.borderBoxSize,o=r.contentBoxSize,a=r.devicePixelContentBoxSize;switch(e){case B.DEVICE_PIXEL_CONTENT_BOX:return a;case B.BORDER_BOX:return i;default:return o}},ts=function(){function t(e){var s=Ge(e);this.target=e,this.contentRect=s.contentRect,this.borderBoxSize=C([s.borderBoxSize]),this.contentBoxSize=C([s.contentBoxSize]),this.devicePixelContentBoxSize=C([s.devicePixelContentBoxSize])}return t}(),qe=function(t){if(Ye(t))return 1/0;for(var e=0,s=t.parentNode;s;)e+=1,s=s.parentNode;return e},ss=function(){var t=1/0,e=[];I.forEach(function(a){if(a.activeTargets.length!==0){var n=[];a.activeTargets.forEach(function(l){var h=new ts(l.target),d=qe(l.target);n.push(h),l.lastReportedSize=Xe(l.target,l.observedBox),d<t&&(t=d)}),e.push(function(){a.callback.call(a.observer,n,a.observer)}),a.activeTargets.splice(0,a.activeTargets.length)}});for(var s=0,r=e;s<r.length;s++){var i=r[s];i()}return t},Oe=function(t){I.forEach(function(s){s.activeTargets.splice(0,s.activeTargets.length),s.skippedTargets.splice(0,s.skippedTargets.length),s.observationTargets.forEach(function(i){i.isActive()&&(qe(i.target)>t?s.activeTargets.push(i):s.skippedTargets.push(i))})})},rs=function(){var t=0;for(Oe(t);Xt();)t=ss(),Oe(t);return qt()&&Jt(),t>0},le,Je=[],is=function(){return Je.splice(0).forEach(function(t){return t()})},os=function(t){if(!le){var e=0,s=document.createTextNode(""),r={characterData:!0};new MutationObserver(function(){return is()}).observe(s,r),le=function(){s.textContent=""+(e?e--:e++)}}Je.push(t),le()},as=function(t){os(function(){requestAnimationFrame(t)})},Z=0,ns=function(){return!!Z},cs=250,ls={attributes:!0,characterData:!0,childList:!0,subtree:!0},Le=["resize","load","transitionend","animationend","animationstart","animationiteration","keyup","keydown","mouseup","mousedown","mouseover","mouseout","blur","focus"],ze=function(t){return t===void 0&&(t=0),Date.now()+t},he=!1,hs=function(){function t(){var e=this;this.stopped=!0,this.listener=function(){return e.schedule()}}return t.prototype.run=function(e){var s=this;if(e===void 0&&(e=cs),!he){he=!0;var r=ze(e);as(function(){var i=!1;try{i=rs()}finally{if(he=!1,e=r-ze(),!ns())return;i?s.run(1e3):e>0?s.run(e):s.start()}})}},t.prototype.schedule=function(){this.stop(),this.run()},t.prototype.observe=function(){var e=this,s=function(){return e.observer&&e.observer.observe(document.body,ls)};document.body?s():V.addEventListener("DOMContentLoaded",s)},t.prototype.start=function(){var e=this;this.stopped&&(this.stopped=!1,this.observer=new MutationObserver(this.listener),this.observe(),Le.forEach(function(s){return V.addEventListener(s,e.listener,!0)}))},t.prototype.stop=function(){var e=this;this.stopped||(this.observer&&this.observer.disconnect(),Le.forEach(function(s){return V.removeEventListener(s,e.listener,!0)}),this.stopped=!0)},t}(),de=new hs,Ae=function(t){!Z&&t>0&&de.start(),Z+=t,!Z&&de.stop()},ds=function(t){return!ue(t)&&!Zt(t)&&getComputedStyle(t).display==="inline"},ps=function(){function t(e,s){this.target=e,this.observedBox=s||B.CONTENT_BOX,this.lastReportedSize={inlineSize:0,blockSize:0}}return t.prototype.isActive=function(){var e=Xe(this.target,this.observedBox,!0);return ds(this.target)&&(this.lastReportedSize=e),this.lastReportedSize.inlineSize!==e.inlineSize||this.lastReportedSize.blockSize!==e.blockSize},t}(),us=function(){function t(e,s){this.activeTargets=[],this.skippedTargets=[],this.observationTargets=[],this.observer=e,this.callback=s}return t}(),J=new WeakMap,He=function(t,e){for(var s=0;s<t.length;s+=1)if(t[s].target===e)return s;return-1},K=function(){function t(){}return t.connect=function(e,s){var r=new us(e,s);J.set(e,r)},t.observe=function(e,s,r){var i=J.get(e),o=i.observationTargets.length===0;He(i.observationTargets,s)<0&&(o&&I.push(i),i.observationTargets.push(new ps(s,r&&r.box)),Ae(1),de.schedule())},t.unobserve=function(e,s){var r=J.get(e),i=He(r.observationTargets,s),o=r.observationTargets.length===1;i>=0&&(o&&I.splice(I.indexOf(r),1),r.observationTargets.splice(i,1),Ae(-1))},t.disconnect=function(e){var s=this,r=J.get(e);r.observationTargets.slice().forEach(function(i){return s.unobserve(e,i.target)}),r.activeTargets.splice(0,r.activeTargets.length)},t}(),gs=function(){function t(e){if(arguments.length===0)throw new TypeError("Failed to construct 'ResizeObserver': 1 argument required, but only 0 present.");if(typeof e!="function")throw new TypeError("Failed to construct 'ResizeObserver': The callback provided as parameter 1 is not a function.");K.connect(this,e)}return t.prototype.observe=function(e,s){if(arguments.length===0)throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': 1 argument required, but only 0 present.");if(!Pe(e))throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': parameter 1 is not of type 'Element");K.observe(this,e,s)},t.prototype.unobserve=function(e){if(arguments.length===0)throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': 1 argument required, but only 0 present.");if(!Pe(e))throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': parameter 1 is not of type 'Element");K.unobserve(this,e)},t.prototype.disconnect=function(){K.disconnect(this)},t.toString=function(){return"function ResizeObserver () { [polyfill code] }"},t}();function fs(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 vs(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 ws(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 bs(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 ms(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}const E=typeof window!="undefined",Ke=E&&!("onscroll"in window)||typeof navigator!="undefined"&&/(gle|ing|ro)bot|crawl|spider/i.test(navigator.userAgent),Ze=E&&"IntersectionObserver"in window,Qe=E&&"classList"in document.createElement("p"),et=E&&window.devicePixelRatio>1,Ss={elements_selector:".lazy",container:Ke||E?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},tt=t=>Object.assign({},Ss,t),De=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)},ys=(t,e)=>{if(!!e)if(!e.length)De(t,e);else for(let s=0,r;r=e[s];s+=1)De(t,r)},m="src",ge="srcset",fe="sizes",st="poster",F="llOriginalAttrs",rt="data",ve="loading",it="loaded",ot="applied",Es="entered",we="error",at="native",nt="data-",ct="ll-status",u=(t,e)=>t.getAttribute(nt+e),xs=(t,e,s)=>{var r=nt+e;if(s===null){t.removeAttribute(r);return}t.setAttribute(r,s)},U=t=>u(t,ct),N=(t,e)=>xs(t,ct,e),te=t=>N(t,null),be=t=>U(t)===null,Ts=t=>U(t)===ve,_s=t=>U(t)===we,me=t=>U(t)===at,Is=[ve,it,ot,we],Cs=t=>Is.indexOf(U(t))>=0,x=(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)}},A=(t,e)=>{if(Qe){t.classList.add(e);return}t.className+=(t.className?" ":"")+e},w=(t,e)=>{if(Qe){t.classList.remove(e);return}t.className=t.className.replace(new RegExp("(^|\\s+)"+e+"(\\s+|$)")," ").replace(/^\s+/,"").replace(/\s+$/,"")},$s=t=>{t.llTempImage=document.createElement("IMG")},Ns=t=>{delete t.llTempImage},lt=t=>t.llTempImage,se=(t,e)=>{if(!e)return;const s=e._observer;!s||s.unobserve(t)},Ps=t=>{t.disconnect()},ks=(t,e,s)=>{e.unobserve_entered&&se(t,s)},Se=(t,e)=>{!t||(t.loadingCount+=e)},Rs=t=>{!t||(t.toLoadCount-=1)},ht=(t,e)=>{!t||(t.toLoadCount=e)},Os=t=>t.loadingCount>0,Ls=t=>t.toLoadCount>0,dt=t=>{let e=[];for(let s=0,r;r=t.children[s];s+=1)r.tagName==="SOURCE"&&e.push(r);return e},ye=(t,e)=>{const s=t.parentNode;if(!s||s.tagName!=="PICTURE")return;dt(s).forEach(e)},pt=(t,e)=>{dt(t).forEach(e)},re=[m],ut=[m,st],W=[m,ge,fe],gt=[rt],ie=t=>!!t[F],ft=t=>t[F],vt=t=>delete t[F],L=(t,e)=>{if(ie(t))return;const s={};e.forEach(r=>{s[r]=t.getAttribute(r)}),t[F]=s},zs=t=>{ie(t)||(t[F]={backgroundImage:t.style.backgroundImage})},As=(t,e,s)=>{if(!s){t.removeAttribute(e);return}t.setAttribute(e,s)},$=(t,e)=>{if(!ie(t))return;const s=ft(t);e.forEach(r=>{As(t,r,s[r])})},Hs=t=>{if(!ie(t))return;const e=ft(t);t.style.backgroundImage=e.backgroundImage},wt=(t,e,s)=>{A(t,e.class_applied),N(t,ot),s&&(e.unobserve_completed&&se(t,e),x(e.callback_applied,t,s))},bt=(t,e,s)=>{A(t,e.class_loading),N(t,ve),s&&(Se(s,1),x(e.callback_loading,t,s))},y=(t,e,s)=>{!s||t.setAttribute(e,s)},Me=(t,e)=>{y(t,fe,u(t,e.data_sizes)),y(t,ge,u(t,e.data_srcset)),y(t,m,u(t,e.data_src))},Ds=(t,e)=>{ye(t,s=>{L(s,W),Me(s,e)}),L(t,W),Me(t,e)},Ms=(t,e)=>{L(t,re),y(t,m,u(t,e.data_src))},Vs=(t,e)=>{pt(t,s=>{L(s,re),y(s,m,u(s,e.data_src))}),L(t,ut),y(t,st,u(t,e.data_poster)),y(t,m,u(t,e.data_src)),t.load()},Bs=(t,e)=>{L(t,gt),y(t,rt,u(t,e.data_src))},Ws=(t,e,s)=>{const r=u(t,e.data_bg),i=u(t,e.data_bg_hidpi),o=et&&i?i:r;!o||(t.style.backgroundImage=`url("${o}")`,lt(t).setAttribute(m,o),bt(t,e,s))},Fs=(t,e,s)=>{const r=u(t,e.data_bg_multi),i=u(t,e.data_bg_multi_hidpi),o=et&&i?i:r;!o||(t.style.backgroundImage=o,wt(t,e,s))},Us=(t,e,s)=>{const r=u(t,e.data_bg_set);if(!r)return;const i=r.split("|");let o=i.map(a=>`image-set(${a})`);t.style.backgroundImage=o.join(),t.style.backgroundImage===""&&(o=i.map(a=>`-webkit-image-set(${a})`),t.style.backgroundImage=o.join()),wt(t,e,s)},mt={IMG:Ds,IFRAME:Ms,VIDEO:Vs,OBJECT:Bs},js=(t,e)=>{const s=mt[t.tagName];!s||s(t,e)},Ys=(t,e,s)=>{const r=mt[t.tagName];!r||(r(t,e),bt(t,e,s))},Gs=["IMG","IFRAME","VIDEO","OBJECT"],Xs=t=>Gs.indexOf(t.tagName)>-1,St=(t,e)=>{e&&!Os(e)&&!Ls(e)&&x(t.callback_finish,e)},Ve=(t,e,s)=>{t.addEventListener(e,s),t.llEvLisnrs[e]=s},qs=(t,e,s)=>{t.removeEventListener(e,s)},Ee=t=>!!t.llEvLisnrs,Js=(t,e,s)=>{Ee(t)||(t.llEvLisnrs={});const r=t.tagName==="VIDEO"?"loadeddata":"load";Ve(t,r,e),Ve(t,"error",s)},pe=t=>{if(!Ee(t))return;const e=t.llEvLisnrs;for(let s in e){const r=e[s];qs(t,s,r)}delete t.llEvLisnrs},yt=(t,e,s)=>{Ns(t),Se(s,-1),Rs(s),w(t,e.class_loading),e.unobserve_completed&&se(t,s)},Ks=(t,e,s,r)=>{const i=me(e);yt(e,s,r),A(e,s.class_loaded),N(e,it),x(s.callback_loaded,e,r),i||St(s,r)},Zs=(t,e,s,r)=>{const i=me(e);yt(e,s,r),A(e,s.class_error),N(e,we),x(s.callback_error,e,r),s.restore_on_error&&$(e,W),i||St(s,r)},xe=(t,e,s)=>{const r=lt(t)||t;if(Ee(r))return;Js(r,a=>{Ks(a,t,e,s),pe(r)},a=>{Zs(a,t,e,s),pe(r)})},Qs=(t,e,s)=>{$s(t),xe(t,e,s),zs(t),Ws(t,e,s),Fs(t,e,s),Us(t,e,s)},er=(t,e,s)=>{xe(t,e,s),Ys(t,e,s)},Te=(t,e,s)=>{Xs(t)?er(t,e,s):Qs(t,e,s)},tr=(t,e,s)=>{t.setAttribute("loading","lazy"),xe(t,e,s),js(t,e),N(t,at)},Be=t=>{t.removeAttribute(m),t.removeAttribute(ge),t.removeAttribute(fe)},sr=t=>{ye(t,e=>{Be(e)}),Be(t)},Et=t=>{ye(t,e=>{$(e,W)}),$(t,W)},rr=t=>{pt(t,e=>{$(e,re)}),$(t,ut),t.load()},ir=t=>{$(t,re)},or=t=>{$(t,gt)},ar={IMG:Et,IFRAME:ir,VIDEO:rr,OBJECT:or},nr=t=>{const e=ar[t.tagName];if(!e){Hs(t);return}e(t)},cr=(t,e)=>{be(t)||me(t)||(w(t,e.class_entered),w(t,e.class_exited),w(t,e.class_applied),w(t,e.class_loading),w(t,e.class_loaded),w(t,e.class_error))},lr=(t,e)=>{nr(t),cr(t,e),te(t),vt(t)},hr=(t,e,s,r)=>{!s.cancel_on_exit||!Ts(t)||t.tagName==="IMG"&&(pe(t),sr(t),Et(t),w(t,s.class_loading),Se(r,-1),te(t),x(s.callback_cancel,t,e,r))},dr=(t,e,s,r)=>{const i=Cs(t);N(t,Es),A(t,s.class_entered),w(t,s.class_exited),ks(t,s,r),x(s.callback_enter,t,e,r),!i&&Te(t,s,r)},pr=(t,e,s,r)=>{be(t)||(A(t,s.class_exited),hr(t,e,s,r),x(s.callback_exit,t,e,r))},ur=["IMG","IFRAME","VIDEO"],xt=t=>t.use_native&&"loading"in HTMLImageElement.prototype,gr=(t,e,s)=>{t.forEach(r=>{ur.indexOf(r.tagName)!==-1&&tr(r,e,s)}),ht(s,0)},fr=t=>t.isIntersecting||t.intersectionRatio>0,vr=t=>({root:t.container===document?null:t.container,rootMargin:t.thresholds||t.threshold+"px"}),wr=(t,e,s)=>{t.forEach(r=>fr(r)?dr(r.target,r,e,s):pr(r.target,r,e,s))},br=(t,e)=>{e.forEach(s=>{t.observe(s)})},mr=(t,e)=>{Ps(t),br(t,e)},Sr=(t,e)=>{!Ze||xt(t)||(e._observer=new IntersectionObserver(s=>{wr(s,t,e)},vr(t)))},Tt=t=>Array.prototype.slice.call(t),Q=t=>t.container.querySelectorAll(t.elements_selector),yr=t=>Tt(t).filter(be),Er=t=>_s(t),xr=t=>Tt(t).filter(Er),We=(t,e)=>yr(t||Q(e)),Tr=(t,e)=>{xr(Q(t)).forEach(r=>{w(r,t.class_error),te(r)}),e.update()},_r=(t,e)=>{!E||(e._onlineHandler=()=>{Tr(t,e)},window.addEventListener("online",e._onlineHandler))},Ir=t=>{!E||window.removeEventListener("online",t._onlineHandler)},j=function(t,e){const s=tt(t);this._settings=s,this.loadingCount=0,Sr(s,this),_r(s,this),this.update(e)};j.prototype={update:function(t){const e=this._settings,s=We(t,e);if(ht(this,s.length),Ke||!Ze){this.loadAll(s);return}if(xt(e)){gr(s,e,this);return}mr(this._observer,s)},destroy:function(){this._observer&&this._observer.disconnect(),Ir(this),Q(this._settings).forEach(t=>{vt(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=>{se(r,this),Te(r,e,this)})},restoreAll:function(){const t=this._settings;Q(t).forEach(e=>{lr(e,t)})}};j.load=(t,e)=>{const s=tt(e);Te(t,s)};j.resetStatus=t=>{te(t)};E&&ys(j,window.lazyLoadOptions);class _t{constructor({readonly:e,box:s,pages:r,onNewPageIndex:i,onPlay:o}){if(this.pageIndex=0,this.namespace="netless-app-docs-viewer",this.isShowPreview=!1,this.isSmallBox=!1,this.sideEffect=new ee,r.length<=0)throw new Error("[DocsViewer] Empty pages.");this.readonly=e,this.box=s,this.pages=r,this.onNewPageIndex=i,this.onPlay=o,this.render()}mount(){this.box.mountContent(this.$content),this.box.mountFooter(this.$footer),this.sideEffect.add(()=>{const e=new j({container:this.$preview,elements_selector:`.${this.wrapClassName("preview-page>img")}`});return()=>e.destroy()},"preview-lazyload")}unmount(){this.$content.remove(),this.$footer.remove()}setReadonly(e){this.readonly!==e&&(this.readonly=e,this.$content.classList.toggle(this.wrapClassName("readonly"),e),this.$footer.classList.toggle(this.wrapClassName("readonly"),e),this.$pageNumberInput.disabled=e)}destroy(){this.sideEffect.flushAll(),this.unmount()}setPageIndex(e){Number.isNaN(e)||(this.pageIndex=e,this.$pageNumberInput.value=String(e+1))}setSmallBox(e){this.isSmallBox!==e&&(this.isSmallBox=e,this.$footer.classList.toggle(this.wrapClassName("float-footer"),e))}render(){return this.renderContent(),this.renderFooter(),this.$content}renderContent(){if(!this.$content){const e=document.createElement("div");e.className=this.wrapClassName("content"),this.$content=e,this.readonly&&e.classList.add(this.wrapClassName("readonly")),e.appendChild(this.renderPreviewMask()),e.appendChild(this.renderPreview())}return this.$content}renderPreview(){if(!this.$preview){const e=document.createElement("div");e.className=this.wrapClassName("preview")+" tele-fancy-scrollbar",this.$preview=e;const s=this.wrapClassName("preview-page"),r=this.wrapClassName("preview-page-name");this.pages.forEach((i,o)=>{var d;const a=(d=i.thumbnail)!=null?d:i.src.startsWith("ppt")?void 0:i.src;if(!a)return;const n=String(o),c=document.createElement("a");c.className=s+" "+this.wrapClassName(`preview-page-${o}`),c.setAttribute("href","#"),c.dataset.pageIndex=n;const l=document.createElement("span");l.className=r,l.textContent=String(o+1),l.dataset.pageIndex=n;const h=document.createElement("img");h.width=i.width,h.height=i.height,h.dataset.src=a,h.dataset.pageIndex=n,c.appendChild(h),c.appendChild(l),e.appendChild(c)}),this.sideEffect.addEventListener(e,"click",i=>{var a;if(this.readonly)return;const o=(a=i.target.dataset)==null?void 0:a.pageIndex;o&&(i.preventDefault(),i.stopPropagation(),i.stopImmediatePropagation(),this.onNewPageIndex(Number(o)),this.togglePreview(!1))})}return this.$preview}renderPreviewMask(){return this.$previewMask||(this.$previewMask=document.createElement("div"),this.$previewMask.className=this.wrapClassName("preview-mask"),this.sideEffect.addEventListener(this.$previewMask,"click",e=>{this.readonly||e.target===this.$previewMask&&this.togglePreview(!1)})),this.$previewMask}renderFooter(){if(!this.$footer){const e=document.createElement("div");if(e.className=this.wrapClassName("footer"),this.$footer=e,this.readonly&&e.classList.add(this.wrapClassName("readonly")),this.isSmallBox&&e.classList.add(this.wrapClassName("float-footer")),this.pages.some(c=>c.thumbnail||!c.src.startsWith("ppt"))){const c=this.renderFooterBtn("btn-sidebar",fs(this.namespace));this.sideEffect.addEventListener(c,"click",()=>{this.readonly||this.togglePreview()}),this.$footer.appendChild(c)}const s=document.createElement("div");s.className=this.wrapClassName("page-jumps");const r=this.renderFooterBtn("btn-page-back",vs(this.namespace));if(this.sideEffect.addEventListener(r,"click",()=>{this.readonly||this.onNewPageIndex(this.pageIndex-1)}),s.appendChild(r),this.onPlay){const c=this.renderFooterBtn("btn-page-play",bs(this.namespace),ms(this.namespace)),l=()=>{this.sideEffect.setTimeout(()=>{c.classList.toggle(this.wrapClassName("footer-btn-playing"),!1)},500,"returnPlay")};this.sideEffect.addEventListener(c,"click",()=>{this.readonly||(c.classList.toggle(this.wrapClassName("footer-btn-playing"),!0),this.onPlay&&this.onPlay(),l())}),s.appendChild(c)}const i=this.renderFooterBtn("btn-page-next",ws(this.namespace));this.sideEffect.addEventListener(i,"click",()=>{this.readonly||this.onNewPageIndex(this.pageIndex+1)}),s.appendChild(i);const o=document.createElement("div");o.className=this.wrapClassName("page-number");const a=document.createElement("input");a.className=this.wrapClassName("page-number-input"),a.value=String(this.pageIndex+1),this.readonly&&(a.disabled=!0),this.$pageNumberInput=a,this.sideEffect.addEventListener(a,"focus",()=>{a.select()}),this.sideEffect.addEventListener(a,"change",()=>{this.readonly||a.value&&this.onNewPageIndex(Number(a.value)-1)});const n=document.createElement("span");n.textContent=" / "+this.pages.length,o.appendChild(a),o.appendChild(n),this.$footer.appendChild(s),this.$footer.appendChild(o)}return this.$footer}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}togglePreview(e){if(this.isShowPreview=e!=null?e:!this.isShowPreview,this.$content.classList.toggle(this.wrapClassName("preview-active"),this.isShowPreview),this.isShowPreview){const s=this.$preview.querySelector("."+this.wrapClassName(`preview-page-${this.pageIndex}`));s&&this.$preview.scrollTo({top:s.offsetTop-16})}}wrapClassName(e){return`${this.namespace}-${e}`}}function z(t,e,s){return Math.min(Math.max(t,e),s)}function Fe(t){return t.touches?t.touches[0]:t}function It(t){t.stopPropagation(),t.cancelable&&t.preventDefault()}function Ct(t){if(!t)return!1;const e=t.tagName;return e==="INPUT"||e==="TEXTAREA"||e==="SELECT"}class Cr{constructor(e){var s,r,i;this.velocity=0,this.paused=!0,this._animationFrameID=null,this._loopTimestamp=0,this.looper=o=>{if(this.paused)return;let a=Math.floor((o-this._loopTimestamp)/1e3*60)+1;for(this._loopTimestamp=o;a-- >0;)this.stepper();this.onStep(this.current,this),!this.paused&&this.current!==this.target&&window.requestAnimationFrame(this.looper)},this.current=(s=e.start)!=null?s:0,this.target=this.current,this.stiffness=(r=e.stiffness)!=null?r:170,this.damping=(i=e.damping)!=null?i:26,this.onStep=e.onStep}stepTo(e,s){this.paused&&s!=null&&(this.current=s),this.paused=!1,this.target=e,this.onStep(this.current,this),this._loopTimestamp=Date.now(),window.requestAnimationFrame(this.looper)}pause(){this.paused=!0}destroy(){this.pause()}stepper(){const e=-this.stiffness*(this.current-this.target),s=-this.damping*this.velocity,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.current=i,this.velocity=r)}}class $r{constructor(e,s,r,i){this.scale=1,this.lastVisit=Date.now(),this.pageOffsetY=0,this.pageOffsetX=0,this.visible=!0,this.index=e,this.page=s,this.scale=r,this.pageOffsetX=(i-s.width)/2;const o=document.createElement("div");o.className="page-renderer-page",o.dataset.index=`${e}`,o.style.width=`${s.width*r}px`,o.style.height=`${s.height*r}px`,s.thumbnail&&(o.style.backgroundImage=`url("${s.thumbnail}")`);const a=document.createElement("img");a.className="page-renderer-page-img",a.width=s.width,a.height=s.height,a.src=s.src,o.appendChild(a),this.$page=o}translateY(e){Math.abs(e-this.pageOffsetY)>=.001&&(this.pageOffsetY=e,this.$page.style.transform=`translate(${this.pageOffsetX*this.scale}px, ${this.pageOffsetY*this.scale}px)`)}setScale(e){Math.abs(e-this.scale)>=.001&&(this.scale=e,this.$page.style.width=`${this.page.width*this.scale}px`,this.$page.style.height=`${this.page.height*this.scale}px`,this.$page.style.transform=`translate(${this.pageOffsetX*this.scale}px, ${this.pageOffsetY*this.scale}px)`)}setVisible(e){e!==this.visible&&(this.visible=e,this.$page.style.opacity=e?"1":"0")}}const Nr=window.requestIdleCallback||(t=>window.setTimeout(t,5e3)),Pr=window.cancelIdleCallback||window.clearTimeout;class kr{constructor(e,s,r){this.pages=e,this.pagesIntrinsicWidth=s,this.scale=r,this.els=new Map,this.maxElCount=200,this.gcTimer=null,this.gc=()=>{if(this.gcTimer=null,this.els.size>this.maxElCount){const i=[...this.els.values()].sort((o,a)=>a.lastVisit-o.lastVisit);for(let o=Math.floor(this.maxElCount/4);o<i.length;o++)this.els.delete(i[o].index)}}}getEl(e){let s=this.els.get(e);return s||(s=new $r(e,this.pages[e],this.scale,this.pagesIntrinsicWidth),this.els.set(e,s)),s.lastVisit=Date.now(),this.els.size>this.maxElCount&&this.gcTimer===null&&(this.gcTimer=Nr(this.gc)),s}setScale(e){e!==this.scale&&(this.scale=e,this.els.forEach(s=>s.setScale(e)))}destroy(){this.els.clear(),this.gcTimer!==null&&(Pr(this.gcTimer),this.gcTimer=null)}}class Rr{constructor(e){this._hwaTimeout=NaN,this._turnOffHWA=()=>{window.clearTimeout(this._hwaTimeout),this._hwaTimeout=NaN,this.$pages.classList.toggle("is-hwa",!1)},this.pagesScrollTop=e.pagesScrollTop||0,this.containerWidth=e.containerWidth||1,this.containerHeight=e.containerHeight||1,this.pages=e.pages.map(o=>{if(o.thumbnail)return o;try{const a=new URL(o.src);return a.searchParams.set("x-oss-process","image/resize,l_50"),ce(ne({},o),{thumbnail:a.toString()})}catch(a){return console.error(a),o}});const s=Array(this.pages.length);let r=1/0,i=0;this.pagesIntrinsicHeight=this.pages.reduce((o,a,n)=>(s[n]=o,a.width>i&&(i=a.width),a.height<=r&&(r=a.height),o+a.height),0),this.pagesIntrinsicWidth=i,this.pagesMinHeight=r,this.pagesIntrinsicYs=s,this.scale=this._calcScale(),this.threshold=this._calcThreshold(),this.onPageIndexChanged=e.onPageIndexChanged,this.pageScrollIndex=0,this.pagesScrollTop!==0&&(this.pageScrollIndex=this.findScrollPageIndex(),this.onPageIndexChanged&&this.pageScrollIndex>0&&this.onPageIndexChanged(this.pageScrollIndex)),this.pageElManager=new kr(this.pages,i,this.scale),this.$pages=this.renderPages()}setContainerSize(e,s){e>0&&s>0&&(e!==this.containerWidth||s!==this.containerHeight)&&(this.containerWidth=e,this.containerHeight=s,this.$pages.style.width=`${this.containerWidth}px`,this.$pages.style.height=`${this.containerHeight}px`,this.scale=this._calcScale(),this.threshold=this._calcThreshold(),this.pageElManager.setScale(this.scale),this.$pages.parentElement&&this.pagesScrollTo(this.pagesScrollTop,!0))}renderPages(){const e=document.createElement("div");return e.className="page-renderer-pages-container",e.style.width=`${this.containerWidth}px`,e.style.height=`${this.containerHeight}px`,e}pagesScrollTo(e,s){if(e=z(e,0,this.pagesIntrinsicHeight-this.containerHeight/this.scale),s||Math.abs(e-this.pagesScrollTop)>=.001){this._turnOnHWA(),this.pagesScrollTop=e;const r=this.findScrollPageIndex(),i=Math.max(r-this.threshold,0),o=Math.min(r+this.threshold,this.pages.length-1);for(let a=0;a<this.$pages.children.length;a++){const n=this.$pages.children[a],c=Number(n.dataset.index);c>=i&&c<=o||(n.remove(),a--)}for(let a=i;a<=o;a++){const n=this.pageElManager.getEl(a);n.$page.parentElement!==this.$pages&&this.$pages.appendChild(n.$page),n.translateY(this.pagesIntrinsicYs[a]-this.pagesScrollTop)}r!==this.pageScrollIndex&&(this.pageScrollIndex=r,this.onPageIndexChanged&&this.onPageIndexChanged(r))}}findScrollPageIndex(){for(let e=0;e<this.pagesIntrinsicYs.length;e++)if(this.pagesIntrinsicYs[e]+this.pages[e].height-this.pagesScrollTop>=.001)return e;return this.pagesIntrinsicYs.length-1}mount(e){e.appendChild(this.$pages),this.pagesScrollTo(this.pagesScrollTop,!0)}unmount(){this.$pages.remove()}destroy(){this.unmount(),this.onPageIndexChanged=void 0,this.pageElManager.destroy(),this._hwaTimeout&&(window.clearTimeout(this._hwaTimeout),this._hwaTimeout=NaN)}_calcScale(){return this.containerWidth/this.pagesIntrinsicWidth||1}_calcThreshold(){return z(Math.ceil(this.containerHeight/this.scale/this.pagesMinHeight/2),1,this.pages.length)}_turnOnHWA(){this._hwaTimeout?window.clearTimeout(this._hwaTimeout):this.$pages.classList.toggle("is-hwa",!0),this._hwaTimeout=window.setTimeout(this._turnOffHWA,1e3)}}const Or=30;class Lr{constructor(e){this.sideEffect=new ee,this.pagesScrollTop=e.pagesScrollTop||0,this.containerWidth=e.containerWidth||1,this.containerHeight=e.containerHeight||1,this.pagesWidth=e.pagesWidth||1,this.pagesHeight=e.pagesHeight||1,this.scale=this._calcScale(),this.scrollbarMinHeight=e.scrollbarMinHeight||Or,this.scrollbarHeight=this._calcScrollbarHeight(),this.readonly=e.readonly,this.wrapClassName=e.wrapClassName,this.onDragScroll=e.onDragScroll,this.$scrollbar=this.renderScrollbar()}mount(e){e.appendChild(this.$scrollbar),this.pagesScrollTo(this.pagesScrollTop,!0)}unmount(){this.$scrollbar.remove()}setReadonly(e){this.readonly=e}setContainerSize(e,s){e>0&&s>0&&(e!==this.containerWidth||s!==this.containerHeight)&&(this.containerWidth=e,this.containerHeight=s,this.scale=this._calcScale(),this._updateScrollbarHeight(),this.$scrollbar.parentElement&&this.pagesScrollTo(this.pagesScrollTop,!0))}pagesScrollTo(e,s){if(e=z(e,0,this.pagesHeight-this.containerHeight/this.scale),s||Math.abs(e-this.pagesScrollTop)>=.001){this.pagesScrollTop=e;const r=this.pagesScrollTop*this.scale,i=this.pagesHeight*this.scale,o=r/(i-this.containerHeight)*(this.containerHeight-this.scrollbarHeight);window.requestAnimationFrame?window.requestAnimationFrame(()=>{this.$scrollbar.style.transform=`translateY(${o}px)`}):this.$scrollbar.style.transform=`translateY(${o}px)`}}destroy(){this.unmount(),this.onDragScroll=void 0,this.sideEffect.flushAll()}renderScrollbar(){const e=document.createElement("button");e.className=this.wrapClassName("scrollbar"),e.style.minHeight=`${this.scrollbarMinHeight}px`,e.style.height=`${this.scrollbarHeight}px`;const s=r=>{if(this.readonly||r.button!=null&&r.button!==0)return;It(r);const i=this.wrapClassName("scrollbar-dragging");e.classList.toggle(i,!0);const o=this.pagesScrollTop,{clientY:a}=Fe(r),n=l=>{if(this.readonly)return;const{clientY:h}=Fe(l),d=(h-a)/this.scale;Math.abs(d)>0&&this.onDragScroll&&this.onDragScroll(o+d*(this.pagesHeight*this.scale/this.containerHeight))},c=()=>{e.classList.toggle(i,!1),window.removeEventListener("mousemove",n,!0),window.removeEventListener("touchmove",n,!0),window.removeEventListener("mouseup",c,!0),window.removeEventListener("touchend",c,!0),window.removeEventListener("touchcancel",c,!0)};window.addEventListener("mousemove",n,!0),window.addEventListener("touchmove",n,!0),window.addEventListener("mouseup",c,!0),window.addEventListener("touchend",c,!0),window.addEventListener("touchcancel",c,!0)};return this.sideEffect.addEventListener(e,"mousedown",s),this.sideEffect.addEventListener(e,"touchstart",s),e}_calcScale(){return this.containerWidth/this.pagesWidth||1}_calcScrollbarHeight(){return z(this.containerHeight/(this.pagesHeight*this.scale)*this.containerHeight,this.scrollbarMinHeight,this.containerHeight)}_updateScrollbarHeight(){const e=this._calcScrollbarHeight();Math.abs(e-this.scrollbarHeight)>.001&&(this.scrollbarHeight=e,this.$scrollbar.style.height=`${e}px`)}}const zr=window.ResizeObserver||gs,M=640;class Ar{constructor({whiteboardView:e,readonly:s,box:r,pages:i,pageScrollTop:o=0,mountWhiteboard:a,onUserScroll:n,baseScenePath:c,appId:l}){this.sideEffect=new ee,this.userScrolling=!1,this.onNewPageIndex=p=>{this.scrollToPage(p)},this.toPdf=async()=>{const p=document.createElement("canvas"),b=p.getContext("2d");if(!b||!this.baseScenePath){this.reportProgress(100,null);return}const oe=`${this.baseScenePath}/1`,T=this.pages[0],{jsPDF:Y}=await Promise.resolve().then(function(){return zt(require("jspdf"))}),S=new Y({format:[T.width,T.height],orientation:T.width>T.height?"l":"p",compress:!0});for(const[_,G]of this.pages.entries()){const{width:f,height:g,src:k}=G;p.width=f,p.height=g;const R=f>g?"l":"p";_>0&&S.addPage([f,g],R);const ae=await this.getBase64FromUrl(k),D=document.createElement("img");D.src=ae,await new Promise(Nt=>D.onload=Nt),b.drawImage(D,0,0);const X=p.toDataURL("image/jpeg",.6);b.clearRect(0,0,f,g),this.whiteboardView.screenshotToCanvas(b,oe,f,g,{centerX:f/2,centerY:g/2+_*g,scale:1});const $t=p.toDataURL("image/png");S.addImage(X,"JPEG",0,0,f,g,"","FAST"),S.addImage($t,"PNG",0,0,f,g,"","FAST"),b.clearRect(0,0,f,g),Math.ceil((_+1)/this.pages.length*100)<100&&this.reportProgress(Math.ceil((_+1)/this.pages.length*100),null)}const H=S.output("arraybuffer");this.reportProgress(100,{pdf:H,title:this.box.title})},this.whiteboardView=e,this.readonly=s,this.box=r,this.pages=i,this.baseScenePath=c,this.appId=l,this.mountWhiteboard=a,this._onUserScroll=n;const h=this.debounce(()=>{this.userScrolling=!1,this._onUserScroll&&this._onUserScroll(this.pageRenderer.pagesScrollTop)},{wait:80},"debounce-updateUserScroll");this.updateUserScroll=()=>{this.userScrolling=!0,h()},this.viewer=new _t({readonly:s,box:r,pages:i,onNewPageIndex:this.onNewPageIndex});const{width:d,height:P}=this.whiteboardView.size;this.pageRenderer=new Rr({pagesScrollTop:o,pages:this.pages,containerWidth:d,containerHeight:P,onPageIndexChanged:this.viewer.setPageIndex.bind(this.viewer)}),this.scrollbar=new Lr({pagesScrollTop:this.pageRenderer.pagesScrollTop,containerWidth:d,containerHeight:P,pagesWidth:this.pageRenderer.pagesIntrinsicWidth,pagesHeight:this.pageRenderer.pagesIntrinsicHeight,readonly:this.readonly,wrapClassName:this.wrapClassName.bind(this),onDragScroll:p=>{this.pageScrollTo(p),this.updateUserScroll()}}),this.pageScrollStepper=new Cr({start:this.pageRenderer.pagesScrollTop,onStep:p=>{this.pageScrollTo(p)}}),this.render()}mount(){this.viewer.mount(),this.setupScrollListener();const e=this.debounce(this.renderRatioHeight.bind(this),{wait:80});return this.sideEffect.add(()=>{const s=new zr(e);return s.observe(this.viewer.$content),()=>s.disconnect()}),this.sideEffect.setTimeout(()=>{this.userScrolling||this.pageScrollTo(this.pageRenderer.pagesScrollTop)},100),this.sideEffect.add(()=>{const s=r=>{r.data.type==="@netless/_request_save_pdf_"&&r.data.appId===this.appId&&this.toPdf().catch(()=>this.reportProgress(100,null))};return window.addEventListener("message",s),()=>{window.removeEventListener("message",s)}}),this}unmount(){return this.viewer.unmount(),this}setReadonly(e){this.readonly!==e&&(this.readonly=e,this.viewer.setReadonly(e),this.scrollbar.setReadonly(e))}destroy(){this.sideEffect.flushAll(),this.pageScrollStepper.destroy(),this._onUserScroll=void 0,this.unmount(),this.viewer.destroy(),this.pageRenderer.destroy(),this.scrollbar.destroy()}syncPageScrollTop(e){!this.userScrolling&&e>=0&&Math.abs(this.pageRenderer.pagesScrollTop-e)>.01&&this.pageScrollStepper.stepTo(e,this.pageRenderer.pagesScrollTop)}render(){this.pageRenderer.mount(this.viewer.$content),this.viewer.$content.appendChild(this.renderWhiteboardView()),this.scrollbar.mount(this.viewer.$content),this.renderRatioHeight()}renderRatioHeight(){const e=this.box.absoluteHeight,s=e<=M;if(this.viewer.setSmallBox(s),s){const r=26/M,i=26/e,o=26/M,a=0,n=Math.max((r+o-(i+a))/2,0);if(this.box.$titleBar){const c=i+n;this.box.$titleBar.style.height=`${c*100}%`}if(this.box.$footer){const c=a+n;this.box.$footer.style.height=`${c*100}%`}}else{if(this.box.$titleBar){const r=Math.max(26/M,26/e);this.box.$titleBar.style.height=`${r*100}%`}if(this.box.$footer){const r=Math.max(26/M,26/e);this.box.$footer.style.height=`${r*100}%`}}}renderWhiteboardView(){return this.$whiteboardView||(this.$whiteboardView=document.createElement("div"),this.$whiteboardView.className=this.wrapClassName("wb-view"),this.mountWhiteboard(this.$whiteboardView),this.sideEffect.addEventListener(this.$whiteboardView,"wheel",e=>{It(e),this.readonly||(this.pageScrollTo(this.pageRenderer.pagesScrollTop+e.deltaY),this.updateUserScroll())},{passive:!1,capture:!0}),this.sideEffect.addEventListener(this.$whiteboardView,"touchmove",e=>{this.readonly||e.touches.length<=1||this.updateUserScroll()},{passive:!0,capture:!0})),this.$whiteboardView}scrollTopPageToEl(e){return e*this.pageRenderer.scale}scrollTopElToPage(e){return e/this.pageRenderer.scale}elScrollTo(e){this.pageScrollTo(this.scrollTopElToPage(e))}pageScrollTo(e){const s=this.scrollTopElToPage(this.whiteboardView.size.height/2);this.whiteboardView.moveCamera({centerY:z(e+s,s,this.pageRenderer.pagesIntrinsicHeight-s),animationMode:"immediately"})}scrollToPage(e){if(!this.readonly&&!Number.isNaN(e)){const s=this.pageRenderer.pagesIntrinsicYs[e];s>=0&&(this.pageScrollTo(s+5/this.pageRenderer.scale),this.updateUserScroll())}}setupScrollListener(){this.sideEffect.add(()=>{const e=s=>{const{width:r,height:i}=this.whiteboardView.size;if(r<=0||i<=0)return;const o=s.centerY-this.pageRenderer.containerHeight/this.pageRenderer.scale/2;this.pageRenderer.pagesScrollTo(o),this.scrollbar.pagesScrollTo(o)};return this.whiteboardView.callbacks.on("onCameraUpdated",e),()=>this.whiteboardView.callbacks.off("onCameraUpdated",e)}),this.sideEffect.add(()=>{const e=({width:s,height:r})=>{if(s<=0||r<=0)return;this.pageRenderer.setContainerSize(s,r),this.scrollbar.setContainerSize(s,r);const{pagesIntrinsicWidth:i,pagesIntrinsicHeight:o}=this.pageRenderer;this.whiteboardView.moveCameraToContain({originX:0,originY:this.pageRenderer.pagesScrollTop,width:i,height:r/this.pageRenderer.scale,animationMode:"immediately"}),this.whiteboardView.setCameraBound({damping:1,maxContentMode:()=>this.pageRenderer.scale,minContentMode:()=>this.pageRenderer.scale,centerX:i/2,centerY:o/2,width:i,height:o})};return this.whiteboardView.callbacks.on("onSizeUpdated",e),()=>{this.whiteboardView.callbacks.off("onSizeUpdated",e)}},"whiteboard-size-update"),this.sideEffect.addEventListener(window,"keyup",e=>{if(this.readonly||!this.box.focus||this.box.minimized||Ct(e.target))return;let s=null;switch(e.key){case"PageDown":{s=this.pageRenderer.pagesScrollTop+this.pageRenderer.containerHeight/this.pageRenderer.scale;break}case"PageUp":{s=this.pageRenderer.pagesScrollTop-this.pageRenderer.containerHeight/this.pageRenderer.scale;break}case"ArrowDown":{s=this.pageRenderer.pagesScrollTop+this.pageRenderer.containerHeight/4/this.pageRenderer.scale;break}case"ArrowUp":{s=this.pageRenderer.pagesScrollTop-this.pageRenderer.containerHeight/4/this.pageRenderer.scale;break}}s!==null&&(this._onUserScroll?this._onUserScroll(s):(this.pageScrollTo(s),this.updateUserScroll()))},{capture:!0})}debounce(e,s,r){const i=jt(e,s);return this.sideEffect.addDisposer(()=>i.cancel(),r),i}wrapClassName(e){return"netless-app-docs-viewer-static-"+e}async getBase64FromUrl(e){const r=await(await fetch(e)).blob();return new Promise(i=>{const o=new FileReader;o.readAsDataURL(r),o.onloadend=()=>{const a=o.result;i(a)}})}reportProgress(e,s){window.postMessage({type:"@netless/_result_save_pdf_",appId:this.appId,progress:e,result:s})}}class Hr{constructor({context:e,whiteboardView:s,box:r,pages:i}){this.sideEffect=new ee,this.onPlayPPT=()=>{const o=this.context.getRoom();o&&o.pptNextStep()},this._scaleDocsToFitImpl=()=>{const o=this.pages[this.getPageIndex()];o&&(this.whiteboardView.moveCameraToContain({originX:-o.width/2,originY:-o.height/2,width:o.width,height:o.height,animationMode:"immediately"}),this.whiteboardView.setCameraBound({damping:1,maxContentMode:()=>this.whiteboardView.camera.scale,minContentMode:()=>this.whiteboardView.camera.scale,centerX:0,centerY:0,width:o.width,height:o.height}))},this._scaleDocsToFitDebounced=()=>{this.sideEffect.setTimeout(this._scaleDocsToFitImpl,1e3,"_scaleDocsToFitDebounced")},this.scaleDocsToFit=()=>{this._scaleDocsToFitImpl(),this._scaleDocsToFitDebounced()},this.onNewPageIndex=o=>{this.jumpToPage(o,!0)},this.context=e,this.whiteboardView=s,this.box=r,this.pages=i,this.displayer=e.getDisplayer(),this.viewer=new _t({readonly:!e.getIsWritable(),box:r,pages:i,onNewPageIndex:this.onNewPageIndex,onPlay:this.onPlayPPT}),this.render(),this.sideEffect.add(()=>{const o=a=>{this.viewer.setReadonly(!a)};return this.context.emitter.on("writableChange",o),()=>this.context.emitter.off("writableChange",o)}),this.sideEffect.add(()=>{const o=a=>{this.jumpToPage(a.index)};return this.context.emitter.on("sceneStateChange",o),()=>this.context.emitter.off("sceneStateChange",o)})}mount(){this.viewer.mount();const e=this.getPageIndex();return e!==0&&this.jumpToPage(e),this.scaleDocsToFit(),this.sideEffect.add(()=>(this.whiteboardView.callbacks.on("onSizeUpdated",this.scaleDocsToFit),()=>{this.whiteboardView.callbacks.off("onSizeUpdated",this.scaleDocsToFit)})),this}unmount(){return this.viewer.unmount(),this}destroy(){this.sideEffect.flushAll(),this.unmount(),this.viewer.destroy()}getPageIndex(){return this.displayer.state.sceneState.index}jumpToPage(e,s){var r,i;if(e=z(e,0,this.pages.length-1),e!==this.getPageIndex()&&this.context.getIsWritable()){const o=this.context.getInitScenePath(),a=(i=(r=this.context.getScenes())==null?void 0:r[e])==null?void 0:i.name;o&&a&&this.context.setScenePath(`${o}/${a}`),this.scaleDocsToFit()}if(e!==this.viewer.pageIndex&&this.viewer.setPageIndex(e),s){const o=this.context.getRoom();if(o){const a=o.state.globalState.__pptState;o.setGlobalState({__pptState:a&&{uuid:a.uuid,pageIndex:e,disableAutoPlay:a.disableAutoPlay}})}}}render(){this.viewer.$content.appendChild(this.renderMask()),this.viewer.$content.appendChild(this.renderWhiteboardView()),this.sideEffect.addEventListener(window,"keydown",e=>{var s;if(this.box.focus&&!Ct(e.target))switch(e.key){case"ArrowUp":case"ArrowLeft":{this.jumpToPage(this.getPageIndex()-1,!0);break}case"ArrowRight":case"ArrowDown":{(s=this.context.getRoom())==null||s.pptNextStep();break}}})}renderMask(){if(!this.$mask){const e=document.createElement("div");e.className=this.wrapClassName("mask"),this.$mask=e;const s=document.createElement("button");s.className=this.wrapClassName("back");const r=document.createElement("button");r.className=this.wrapClassName("next")}return this.$mask}renderWhiteboardView(){return this.$whiteboardView||(this.$whiteboardView=document.createElement("div"),this.$whiteboardView.className=this.wrapClassName("wb-view"),this.sideEffect.addEventListener(this.$whiteboardView,"click",e=>{var r;const s=this.context.getRoom();if(s&&s.state.memberState.currentApplianceName==="clicker"){for(let i=e.target;i;i=i.parentElement)if((r=i.classList)!=null&&r.contains("ppt-event-source"))return;s.pptNextStep()}}),this.context.mountView(this.$whiteboardView)),this.$whiteboardView}wrapClassName(e){return"netless-app-docs-viewer-dynamic-"+e}}const Dr="DocsViewer",Mr={kind:Dr,setup(t){const e=t.getBox(),s=t.getScenes();if(!s)throw new Error("[Docs Viewer]: scenes not found.");const r=t.getView();if(!r)throw new Error("[Docs Viewer]: no whiteboard view.");const i=s.map(({ppt:o})=>o?{width:o.width,height:o.height,src:o.src,thumbnail:o.previewURL}:null).filter(o=>Boolean(o));if(i.length<=0)throw new Error("[Docs Viewer]: empty scenes.");e.mountStyles(At),i[0].src.startsWith("ppt")?Br(t,r,e,i):Vr(t,r,e,i)}};function Vr(t,e,s,r){var o;e.disableCameraTransform=!t.getIsWritable();const i=new Ar({whiteboardView:e,readonly:!t.getIsWritable(),box:s,pages:r,pageScrollTop:(o=t.getAttributes())==null?void 0:o.pageScrollTop,mountWhiteboard:t.mountView.bind(t),onUserScroll:a=>{var n;((n=t.getAttributes())==null?void 0:n.pageScrollTop)!==a&&!s.readonly&&t.updateAttributes(["pageScrollTop"],a)},baseScenePath:t.getInitScenePath(),appId:t.appId}).mount();t.emitter.on("attributesUpdate",a=>{a&&a.pageScrollTop!=null&&i.syncPageScrollTop(a.pageScrollTop)}),t.emitter.on("writableChange",a=>{i.setReadonly(!a),e.disableCameraTransform=!a})}function Br(t,e,s,r){e.disableCameraTransform=!0;const i=new Hr({context:t,whiteboardView:e,box:s,pages:r}).mount();t.mountView(i.$whiteboardView),t.isAddApp&&e.callbacks.once("onSizeUpdated",({width:o,height:a})=>{if(r.length>0&&s.state!=="maximized"){const{width:n,height:c}=r[0],h=c/n*o-a;h!==0&&t.getIsWritable()&&t.emitter.emit("setBoxSize",{width:s.width,height:s.height+h/s.containerRect.height})}})}exports.default=Mr; | ||
//# sourceMappingURL=main.cjs.js.map |
@@ -1,4 +0,4 @@ | ||
var NetlessAppDocsViewer=function(f){"use strict";var Rr=Object.defineProperty,Lr=Object.defineProperties;var Or=Object.getOwnPropertyDescriptors;var $t=Object.getOwnPropertySymbols;var zr=Object.prototype.hasOwnProperty,Ar=Object.prototype.propertyIsEnumerable;var Nt=(f,u,v)=>u in f?Rr(f,u,{enumerable:!0,configurable:!0,writable:!0,value:v}):f[u]=v,_e=(f,u)=>{for(var v in u||(u={}))zr.call(u,v)&&Nt(f,v,u[v]);if($t)for(var v of $t(u))Ar.call(u,v)&&Nt(f,v,u[v]);return f},Ce=(f,u)=>Lr(f,Or(u));var u=(()=>`.netless-app-docs-viewer-content{position:relative;height:100%;overflow:hidden}.netless-app-docs-viewer-preview-mask{display:none;position:absolute;z-index:200;top:0;left:0;width:100%;height:100%}.netless-app-docs-viewer-preview{display:flex;flex-direction:column;align-items:center;position:absolute;z-index:300;top:0;left:0;width:33%;max-width:200px;height:100%;padding-top:10px;transform:translate(-100%);background:rgba(237,237,240,.9);box-shadow:inset -1px 0 #0000001c;transition:transform .4s}.netless-app-docs-viewer-preview-active .netless-app-docs-viewer-preview-mask{display:block}.netless-app-docs-viewer-preview-active .netless-app-docs-viewer-preview{transform:translate(0)}.netless-app-docs-viewer-preview-page{position:relative;display:block;width:55%;margin-bottom:10px;font-size:0;color:transparent;outline:none;border:7px solid transparent;border-radius:4px;transition:border-color .3s;user-select:none}.netless-app-docs-viewer-preview-page:hover,.netless-app-docs-viewer-preview-page.netless-app-docs-viewer-preview-page-active{border-color:#444e601a}.netless-app-docs-viewer-preview-page>img{width:100%;height:auto;box-sizing:border-box;border:1px solid rgba(0,0,0,.5);border-radius:1px;background-color:#fff;box-shadow:0 2px 8px #0000004d}.netless-app-docs-viewer-preview-page-name{position:absolute;top:1px;left:-10px;transform:translate(-100%);text-align:right;font-size:12px;color:#5f5f5f;user-select:none}.netless-app-docs-viewer-footer{box-sizing:border-box;height:26px;display:flex;align-items:center;padding:0 16px;border-top:1px solid #eeeef7;color:#191919}.netless-app-docs-viewer-float-footer{width:100%;min-height:26px;position:absolute;left:0;bottom:0;z-index:2000;background:rgba(249,249,252,.9);transition:opacity .4s}.netless-app-docs-viewer-footer-btn{box-sizing:border-box;width:26px;height:26px;font-size:0;margin:0;padding:3px;border:none;border-radius:1px;outline:none;color:currentColor;background:transparent;transition:background .4s;cursor:pointer;user-select:none;-webkit-tap-highlight-color:rgba(0,0,0,0)}.netless-app-docs-viewer-footer-btn:hover{background:rgba(237,237,240,.9)}@media (hover: none){.netless-app-docs-viewer-footer-btn:hover{background:transparent!important}}.netless-app-docs-viewer-footer-btn>svg{width:100%;height:100%}.netless-app-docs-viewer-footer-btn>svg:nth-of-type(2){display:none}.netless-app-docs-viewer-footer-btn.netless-app-docs-viewer-footer-btn-playing>svg:nth-of-type(1){display:none}.netless-app-docs-viewer-footer-btn.netless-app-docs-viewer-footer-btn-playing>svg:nth-of-type(2){display:initial}.netless-app-docs-viewer-footer-btn~.netless-app-docs-viewer-footer-btn{margin-left:15px}.netless-app-docs-viewer-page-jumps{flex:1;display:flex;justify-content:center;align-items:center}.netless-app-docs-viewer-page-number{margin-left:auto;font-size:13px;user-select:none;white-space:nowrap;word-break:keep-all}.netless-app-docs-viewer-page-number-input{border:none;outline:none;width:3em;margin:0;padding:0 2px;text-align:right;font-size:13px;line-height:1;font-weight:400;font-family:inherit;border-radius:2px;color:currentColor;background:transparent;transition:background .4s;user-select:text;-webkit-tap-highlight-color:rgba(0,0,0,0)}.netless-app-docs-viewer-page-number-input:hover,.netless-app-docs-viewer-page-number-input:focus,.netless-app-docs-viewer-page-number-input:active{background:#fff;box-shadow:#63636333 0 2px 8px}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-footer-btn{cursor:not-allowed}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-footer-btn:hover{background:transparent}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-page-number-input{cursor:not-allowed}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-page-number-input:hover,.netless-app-docs-viewer-readonly .netless-app-docs-viewer-page-number-input:focus,.netless-app-docs-viewer-readonly .netless-app-docs-viewer-page-number-input:active{background:transparent;box-shadow:none}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-page-number-input:disabled{color:inherit}.netless-app-docs-viewer-readonly.netless-app-docs-viewer-float-footer{display:none}.telebox-color-scheme-dark .netless-app-docs-viewer-page-number-input{color:#a6a6a8}.telebox-color-scheme-dark .netless-app-docs-viewer-page-number-input:active,.telebox-color-scheme-dark .netless-app-docs-viewer-page-number-input:focus,.telebox-color-scheme-dark .netless-app-docs-viewer-page-number-input:hover{color:#222}.telebox-color-scheme-dark .netless-app-docs-viewer-footer{color:#a6a6a8;background:#2d2d33;border-top:none}.telebox-color-scheme-dark .netless-app-docs-viewer-footer-btn:hover{background:#212126}.telebox-color-scheme-dark .netless-app-docs-viewer-preview{background:rgba(50,50,50,.9)}.netless-app-docs-viewer-static-scrollbar{position:absolute;top:0;right:0;z-index:2147483647;width:8px;min-height:30px;margin:0;padding:0;border:none;outline:none;border-radius:4px;background:rgba(68,78,96,.4);box-shadow:1px 1px 8px #ffffffb3;opacity:0;transition:background .4s,opacity .4s 3s,transform .2s;user-select:none}.netless-app-docs-viewer-static-scrollbar.netless-app-docs-viewer-static-scrollbar-dragging{background:rgba(68,78,96,.6);opacity:1;transition:background .4s,opacity .4s 3s!important}.netless-app-docs-viewer-static-scrollbar:hover,.netless-app-docs-viewer-static-scrollbar:focus{background:rgba(68,78,96,.5)}.netless-app-docs-viewer-static-scrollbar:active{background:rgba(68,78,96,.6)}.netless-app-docs-viewer-content:hover .netless-app-docs-viewer-static-scrollbar{opacity:1;transition:background .4s,opacity .4s,transform .2s}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-static-scrollbar{display:none}.netless-app-docs-viewer-static-pages:hover .netless-app-docs-viewer-static-scrollbar{opacity:1;transition:background .4s,opacity .4s,transform .2s}.page-renderer-pages-container{position:relative;overflow:hidden}.page-renderer-page{position:absolute;top:0;left:0;background-position:center;background-size:cover;background-repeat:no-repeat}.page-renderer-pages-container.is-hwa .page-renderer-page{will-change:transform}.page-renderer-page-img{display:block;width:100%;height:auto;user-select:none}.netless-app-docs-viewer-static-pages{overflow:hidden;position:relative;height:100%;user-select:none}.netless-app-docs-viewer-static-page{display:block;width:100%;height:auto;user-select:none}.netless-app-docs-viewer-static-wb-view,.netless-app-docs-viewer-dynamic-wb-view{position:absolute;top:0;left:0;width:100%;height:100%;z-index:100;overflow:hidden}.netless-app-docs-viewer-dynamic-wb-view .cursor-clicker .ppt-event-source{cursor:pointer} | ||
`)();const v=(t,e,s,r)=>{if(s==="length"||s==="prototype"||s==="arguments"||s==="caller")return;const i=Object.getOwnPropertyDescriptor(t,s),o=Object.getOwnPropertyDescriptor(e,s);!kt(i,o)&&r||Object.defineProperty(t,s,o)},kt=function(t,e){return t===void 0||t.configurable||t.writable===e.writable&&t.enumerable===e.enumerable&&t.configurable===e.configurable&&(t.writable||t.value===e.value)},Pt=(t,e)=>{const s=Object.getPrototypeOf(e);s!==Object.getPrototypeOf(t)&&Object.setPrototypeOf(t,s)},Rt=(t,e)=>`/* Wrapped ${t}*/ | ||
${e}`,Lt=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),Ot=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),zt=(t,e,s)=>{const r=s===""?"":`with ${s.trim()}() `,i=Rt.bind(null,r,e.toString());Object.defineProperty(i,"name",Ot),Object.defineProperty(t,"toString",Ce(_e({},Lt),{value:i}))};function At(t,e,{ignoreNonConfigurable:s=!1}={}){const{name:r}=t;for(const i of Reflect.ownKeys(e))v(t,e,i,s);return Pt(t,e),zt(t,e,r),t}const Ht=(t,e={})=>{if(typeof t!="function")throw new TypeError(`Expected the first argument to be a function, got \`${typeof t}\``);const{wait:s=0,maxWait:r=Number.Infinity,before:i=!1,after:o=!0}=e;if(!i&&!o)throw new Error("Both `before` and `after` are false, function wouldn't be called.");let a,n,c;const l=function(...h){const d=this,H=()=>{a=void 0,n&&(clearTimeout(n),n=void 0),o&&(c=t.apply(d,h))},p=()=>{n=void 0,a&&(clearTimeout(a),a=void 0),o&&(c=t.apply(d,h))},E=i&&!a;return clearTimeout(a),a=setTimeout(H,s),r>0&&r!==Number.Infinity&&!n&&(n=setTimeout(p,r)),E&&(c=t.apply(d,h)),c};return At(l,t),l.cancel=()=>{a&&(clearTimeout(a),a=void 0),n&&(clearTimeout(n),n=void 0)},l},$e="!#%()*+,-./:;=?@[]^_`{|}~ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",Dt=$e.length,Ne=Array(20),Vt=()=>{for(let t=0;t<20;t++)Ne[t]=$e.charAt(Math.random()*Dt);return Ne.join("")};function ke(t){try{return t()}catch(e){console.error(e)}}class q{constructor(){this.disposers=new Map}addDisposer(e,s=this.genUID()){return this.flush(s),this.disposers.set(s,Array.isArray(e)?()=>e.forEach(ke):e),s}add(e,s=this.genUID()){return this.addDisposer(e(),s)}addEventListener(e,s,r,i,o=this.genUID()){return e.addEventListener(s,r,i),this.addDisposer(()=>e.removeEventListener(s,r,i),o),o}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(ke),this.disposers.clear()}genUID(){let e;do e=Vt();while(this.disposers.has(e));return e}}var C=[],Bt=function(){return C.some(function(t){return t.activeTargets.length>0})},Mt=function(){return C.some(function(t){return t.skippedTargets.length>0})},Pe="ResizeObserver loop completed with undelivered notifications.",Wt=function(){var t;typeof ErrorEvent=="function"?t=new ErrorEvent("error",{message:Pe}):(t=document.createEvent("Event"),t.initEvent("error",!1,!1),t.message=Pe),window.dispatchEvent(t)},B;(function(t){t.BORDER_BOX="border-box",t.CONTENT_BOX="content-box",t.DEVICE_PIXEL_CONTENT_BOX="device-pixel-content-box"})(B||(B={}));var $=function(t){return Object.freeze(t)},Ft=function(){function t(e,s){this.inlineSize=e,this.blockSize=s,$(this)}return t}(),Re=function(){function t(e,s,r,i){return this.x=e,this.y=s,this.width=r,this.height=i,this.top=this.y,this.left=this.x,this.bottom=this.top+this.height,this.right=this.left+this.width,$(this)}return t.prototype.toJSON=function(){var e=this,s=e.x,r=e.y,i=e.top,o=e.right,a=e.bottom,n=e.left,c=e.width,l=e.height;return{x:s,y:r,top:i,right:o,bottom:a,left:n,width:c,height:l}},t.fromRect=function(e){return new t(e.x,e.y,e.width,e.height)},t}(),ce=function(t){return t instanceof SVGElement&&"getBBox"in t},Le=function(t){if(ce(t)){var e=t.getBBox(),s=e.width,r=e.height;return!s&&!r}var i=t,o=i.offsetWidth,a=i.offsetHeight;return!(o||a||t.getClientRects().length)},Oe=function(t){var e,s;if(t instanceof Element)return!0;var r=(s=(e=t)===null||e===void 0?void 0:e.ownerDocument)===null||s===void 0?void 0:s.defaultView;return!!(r&&t instanceof r.Element)},Ut=function(t){switch(t.tagName){case"INPUT":if(t.type!=="image")break;case"VIDEO":case"AUDIO":case"EMBED":case"OBJECT":case"CANVAS":case"IFRAME":case"IMG":return!0}return!1},M=typeof window!="undefined"?window:{},J=new WeakMap,ze=/auto|scroll/,Yt=/^tb|vertical/,jt=/msie|trident/i.test(M.navigator&&M.navigator.userAgent),m=function(t){return parseFloat(t||"0")},L=function(t,e,s){return t===void 0&&(t=0),e===void 0&&(e=0),s===void 0&&(s=!1),new Ft((s?e:t)||0,(s?t:e)||0)},Ae=$({devicePixelContentBoxSize:L(),borderBoxSize:L(),contentBoxSize:L(),contentRect:new Re(0,0,0,0)}),He=function(t,e){if(e===void 0&&(e=!1),J.has(t)&&!e)return J.get(t);if(Le(t))return J.set(t,Ae),Ae;var s=getComputedStyle(t),r=ce(t)&&t.ownerSVGElement&&t.getBBox(),i=!jt&&s.boxSizing==="border-box",o=Yt.test(s.writingMode||""),a=!r&&ze.test(s.overflowY||""),n=!r&&ze.test(s.overflowX||""),c=r?0:m(s.paddingTop),l=r?0:m(s.paddingRight),h=r?0:m(s.paddingBottom),d=r?0:m(s.paddingLeft),H=r?0:m(s.borderTopWidth),p=r?0:m(s.borderRightWidth),E=r?0:m(s.borderBottomWidth),Te=r?0:m(s.borderLeftWidth),P=d+l,oe=c+h,_=Te+p,G=H+E,R=n?t.offsetHeight-G-t.clientHeight:0,ae=a?t.offsetWidth-_-t.clientWidth:0,b=i?P+_:0,w=i?oe+G:0,D=r?r.width:m(s.width)-b-ae,V=r?r.height:m(s.height)-w-R,Ie=D+P+ae+_,X=V+oe+R+G,ne=$({devicePixelContentBoxSize:L(Math.round(D*devicePixelRatio),Math.round(V*devicePixelRatio),o),borderBoxSize:L(Ie,X,o),contentBoxSize:L(D,V,o),contentRect:new Re(d,c,D,V)});return J.set(t,ne),ne},De=function(t,e,s){var r=He(t,s),i=r.borderBoxSize,o=r.contentBoxSize,a=r.devicePixelContentBoxSize;switch(e){case B.DEVICE_PIXEL_CONTENT_BOX:return a;case B.BORDER_BOX:return i;default:return o}},Gt=function(){function t(e){var s=He(e);this.target=e,this.contentRect=s.contentRect,this.borderBoxSize=$([s.borderBoxSize]),this.contentBoxSize=$([s.contentBoxSize]),this.devicePixelContentBoxSize=$([s.devicePixelContentBoxSize])}return t}(),Ve=function(t){if(Le(t))return 1/0;for(var e=0,s=t.parentNode;s;)e+=1,s=s.parentNode;return e},Xt=function(){var t=1/0,e=[];C.forEach(function(a){if(a.activeTargets.length!==0){var n=[];a.activeTargets.forEach(function(l){var h=new Gt(l.target),d=Ve(l.target);n.push(h),l.lastReportedSize=De(l.target,l.observedBox),d<t&&(t=d)}),e.push(function(){a.callback.call(a.observer,n,a.observer)}),a.activeTargets.splice(0,a.activeTargets.length)}});for(var s=0,r=e;s<r.length;s++){var i=r[s];i()}return t},Be=function(t){C.forEach(function(s){s.activeTargets.splice(0,s.activeTargets.length),s.skippedTargets.splice(0,s.skippedTargets.length),s.observationTargets.forEach(function(i){i.isActive()&&(Ve(i.target)>t?s.activeTargets.push(i):s.skippedTargets.push(i))})})},qt=function(){var t=0;for(Be(t);Bt();)t=Xt(),Be(t);return Mt()&&Wt(),t>0},le,Me=[],Jt=function(){return Me.splice(0).forEach(function(t){return t()})},Kt=function(t){if(!le){var e=0,s=document.createTextNode(""),r={characterData:!0};new MutationObserver(function(){return Jt()}).observe(s,r),le=function(){s.textContent=""+(e?e--:e++)}}Me.push(t),le()},Zt=function(t){Kt(function(){requestAnimationFrame(t)})},K=0,Qt=function(){return!!K},es=250,ts={attributes:!0,characterData:!0,childList:!0,subtree:!0},We=["resize","load","transitionend","animationend","animationstart","animationiteration","keyup","keydown","mouseup","mousedown","mouseover","mouseout","blur","focus"],Fe=function(t){return t===void 0&&(t=0),Date.now()+t},he=!1,ss=function(){function t(){var e=this;this.stopped=!0,this.listener=function(){return e.schedule()}}return t.prototype.run=function(e){var s=this;if(e===void 0&&(e=es),!he){he=!0;var r=Fe(e);Zt(function(){var i=!1;try{i=qt()}finally{if(he=!1,e=r-Fe(),!Qt())return;i?s.run(1e3):e>0?s.run(e):s.start()}})}},t.prototype.schedule=function(){this.stop(),this.run()},t.prototype.observe=function(){var e=this,s=function(){return e.observer&&e.observer.observe(document.body,ts)};document.body?s():M.addEventListener("DOMContentLoaded",s)},t.prototype.start=function(){var e=this;this.stopped&&(this.stopped=!1,this.observer=new MutationObserver(this.listener),this.observe(),We.forEach(function(s){return M.addEventListener(s,e.listener,!0)}))},t.prototype.stop=function(){var e=this;this.stopped||(this.observer&&this.observer.disconnect(),We.forEach(function(s){return M.removeEventListener(s,e.listener,!0)}),this.stopped=!0)},t}(),de=new ss,Ue=function(t){!K&&t>0&&de.start(),K+=t,!K&&de.stop()},rs=function(t){return!ce(t)&&!Ut(t)&&getComputedStyle(t).display==="inline"},is=function(){function t(e,s){this.target=e,this.observedBox=s||B.CONTENT_BOX,this.lastReportedSize={inlineSize:0,blockSize:0}}return t.prototype.isActive=function(){var e=De(this.target,this.observedBox,!0);return rs(this.target)&&(this.lastReportedSize=e),this.lastReportedSize.inlineSize!==e.inlineSize||this.lastReportedSize.blockSize!==e.blockSize},t}(),os=function(){function t(e,s){this.activeTargets=[],this.skippedTargets=[],this.observationTargets=[],this.observer=e,this.callback=s}return t}(),Z=new WeakMap,Ye=function(t,e){for(var s=0;s<t.length;s+=1)if(t[s].target===e)return s;return-1},Q=function(){function t(){}return t.connect=function(e,s){var r=new os(e,s);Z.set(e,r)},t.observe=function(e,s,r){var i=Z.get(e),o=i.observationTargets.length===0;Ye(i.observationTargets,s)<0&&(o&&C.push(i),i.observationTargets.push(new is(s,r&&r.box)),Ue(1),de.schedule())},t.unobserve=function(e,s){var r=Z.get(e),i=Ye(r.observationTargets,s),o=r.observationTargets.length===1;i>=0&&(o&&C.splice(C.indexOf(r),1),r.observationTargets.splice(i,1),Ue(-1))},t.disconnect=function(e){var s=this,r=Z.get(e);r.observationTargets.slice().forEach(function(i){return s.unobserve(e,i.target)}),r.activeTargets.splice(0,r.activeTargets.length)},t}(),as=function(){function t(e){if(arguments.length===0)throw new TypeError("Failed to construct 'ResizeObserver': 1 argument required, but only 0 present.");if(typeof e!="function")throw new TypeError("Failed to construct 'ResizeObserver': The callback provided as parameter 1 is not a function.");Q.connect(this,e)}return t.prototype.observe=function(e,s){if(arguments.length===0)throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': 1 argument required, but only 0 present.");if(!Oe(e))throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': parameter 1 is not of type 'Element");Q.observe(this,e,s)},t.prototype.unobserve=function(e){if(arguments.length===0)throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': 1 argument required, but only 0 present.");if(!Oe(e))throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': parameter 1 is not of type 'Element");Q.unobserve(this,e)},t.prototype.disconnect=function(){Q.disconnect(this)},t.toString=function(){return"function ResizeObserver () { [polyfill code] }"},t}();function ns(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 cs(t){const e="http://www.w3.org/2000/svg",s=document.createElementNS(e,"svg");s.setAttribute("class",`${t}-footer-icon-arrow-left`),s.setAttribute("viewBox","0 0 500 500");const 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 ls(t){const e="http://www.w3.org/2000/svg",s=document.createElementNS(e,"svg");s.setAttribute("class",`${t}-footer-icon-arrow-right`),s.setAttribute("viewBox","0 0 500 500");const 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 hs(t){const e="http://www.w3.org/2000/svg",s=document.createElementNS(e,"svg");s.setAttribute("class",`${t}-footer-icon-play`),s.setAttribute("viewBox","0 0 500 500");const 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 ds(t){const e="http://www.w3.org/2000/svg",s=document.createElementNS(e,"svg");s.setAttribute("class",`${t}-footer-icon-pause`),s.setAttribute("viewBox","0 0 500 500");const 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}const x=typeof window!="undefined",je=x&&!("onscroll"in window)||typeof navigator!="undefined"&&/(gle|ing|ro)bot|crawl|spider/i.test(navigator.userAgent),Ge=x&&"IntersectionObserver"in window,Xe=x&&"classList"in document.createElement("p"),qe=x&&window.devicePixelRatio>1,ps={elements_selector:".lazy",container:je||x?document:null,threshold:300,thresholds:null,data_src:"src",data_srcset:"srcset",data_sizes:"sizes",data_bg:"bg",data_bg_hidpi:"bg-hidpi",data_bg_multi:"bg-multi",data_bg_multi_hidpi:"bg-multi-hidpi",data_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},Je=t=>Object.assign({},ps,t),Ke=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)},us=(t,e)=>{if(!!e)if(!e.length)Ke(t,e);else for(let s=0,r;r=e[s];s+=1)Ke(t,r)},y="src",pe="srcset",ue="sizes",Ze="poster",W="llOriginalAttrs",Qe="data",ge="loading",et="loaded",tt="applied",gs="entered",fe="error",st="native",rt="data-",it="ll-status",g=(t,e)=>t.getAttribute(rt+e),fs=(t,e,s)=>{var r=rt+e;if(s===null){t.removeAttribute(r);return}t.setAttribute(r,s)},F=t=>g(t,it),N=(t,e)=>fs(t,it,e),ee=t=>N(t,null),ve=t=>F(t)===null,vs=t=>F(t)===ge,ws=t=>F(t)===fe,we=t=>F(t)===st,bs=[ge,et,tt,fe],ms=t=>bs.indexOf(F(t))>=0,T=(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)}},O=(t,e)=>{if(Xe){t.classList.add(e);return}t.className+=(t.className?" ":"")+e},S=(t,e)=>{if(Xe){t.classList.remove(e);return}t.className=t.className.replace(new RegExp("(^|\\s+)"+e+"(\\s+|$)")," ").replace(/^\s+/,"").replace(/\s+$/,"")},Ss=t=>{t.llTempImage=document.createElement("IMG")},ys=t=>{delete t.llTempImage},ot=t=>t.llTempImage,te=(t,e)=>{if(!e)return;const s=e._observer;!s||s.unobserve(t)},Es=t=>{t.disconnect()},xs=(t,e,s)=>{e.unobserve_entered&&te(t,s)},be=(t,e)=>{!t||(t.loadingCount+=e)},Ts=t=>{!t||(t.toLoadCount-=1)},at=(t,e)=>{!t||(t.toLoadCount=e)},Is=t=>t.loadingCount>0,_s=t=>t.toLoadCount>0,nt=t=>{let e=[];for(let s=0,r;r=t.children[s];s+=1)r.tagName==="SOURCE"&&e.push(r);return e},me=(t,e)=>{const s=t.parentNode;if(!s||s.tagName!=="PICTURE")return;nt(s).forEach(e)},ct=(t,e)=>{nt(t).forEach(e)},se=[y],lt=[y,Ze],U=[y,pe,ue],ht=[Qe],re=t=>!!t[W],dt=t=>t[W],pt=t=>delete t[W],z=(t,e)=>{if(re(t))return;const s={};e.forEach(r=>{s[r]=t.getAttribute(r)}),t[W]=s},Cs=t=>{re(t)||(t[W]={backgroundImage:t.style.backgroundImage})},$s=(t,e,s)=>{if(!s){t.removeAttribute(e);return}t.setAttribute(e,s)},k=(t,e)=>{if(!re(t))return;const s=dt(t);e.forEach(r=>{$s(t,r,s[r])})},Ns=t=>{if(!re(t))return;const e=dt(t);t.style.backgroundImage=e.backgroundImage},ut=(t,e,s)=>{O(t,e.class_applied),N(t,tt),s&&(e.unobserve_completed&&te(t,e),T(e.callback_applied,t,s))},gt=(t,e,s)=>{O(t,e.class_loading),N(t,ge),s&&(be(s,1),T(e.callback_loading,t,s))},I=(t,e,s)=>{!s||t.setAttribute(e,s)},ft=(t,e)=>{I(t,ue,g(t,e.data_sizes)),I(t,pe,g(t,e.data_srcset)),I(t,y,g(t,e.data_src))},ks=(t,e)=>{me(t,s=>{z(s,U),ft(s,e)}),z(t,U),ft(t,e)},Ps=(t,e)=>{z(t,se),I(t,y,g(t,e.data_src))},Rs=(t,e)=>{ct(t,s=>{z(s,se),I(s,y,g(s,e.data_src))}),z(t,lt),I(t,Ze,g(t,e.data_poster)),I(t,y,g(t,e.data_src)),t.load()},Ls=(t,e)=>{z(t,ht),I(t,Qe,g(t,e.data_src))},Os=(t,e,s)=>{const r=g(t,e.data_bg),i=g(t,e.data_bg_hidpi),o=qe&&i?i:r;!o||(t.style.backgroundImage=`url("${o}")`,ot(t).setAttribute(y,o),gt(t,e,s))},zs=(t,e,s)=>{const r=g(t,e.data_bg_multi),i=g(t,e.data_bg_multi_hidpi),o=qe&&i?i:r;!o||(t.style.backgroundImage=o,ut(t,e,s))},As=(t,e,s)=>{const r=g(t,e.data_bg_set);if(!r)return;const i=r.split("|");let o=i.map(a=>`image-set(${a})`);t.style.backgroundImage=o.join(),t.style.backgroundImage===""&&(o=i.map(a=>`-webkit-image-set(${a})`),t.style.backgroundImage=o.join()),ut(t,e,s)},vt={IMG:ks,IFRAME:Ps,VIDEO:Rs,OBJECT:Ls},Hs=(t,e)=>{const s=vt[t.tagName];!s||s(t,e)},Ds=(t,e,s)=>{const r=vt[t.tagName];!r||(r(t,e),gt(t,e,s))},Vs=["IMG","IFRAME","VIDEO","OBJECT"],Bs=t=>Vs.indexOf(t.tagName)>-1,wt=(t,e)=>{e&&!Is(e)&&!_s(e)&&T(t.callback_finish,e)},bt=(t,e,s)=>{t.addEventListener(e,s),t.llEvLisnrs[e]=s},Ms=(t,e,s)=>{t.removeEventListener(e,s)},Se=t=>!!t.llEvLisnrs,Ws=(t,e,s)=>{Se(t)||(t.llEvLisnrs={});const r=t.tagName==="VIDEO"?"loadeddata":"load";bt(t,r,e),bt(t,"error",s)},ye=t=>{if(!Se(t))return;const e=t.llEvLisnrs;for(let s in e){const r=e[s];Ms(t,s,r)}delete t.llEvLisnrs},mt=(t,e,s)=>{ys(t),be(s,-1),Ts(s),S(t,e.class_loading),e.unobserve_completed&&te(t,s)},Fs=(t,e,s,r)=>{const i=we(e);mt(e,s,r),O(e,s.class_loaded),N(e,et),T(s.callback_loaded,e,r),i||wt(s,r)},Us=(t,e,s,r)=>{const i=we(e);mt(e,s,r),O(e,s.class_error),N(e,fe),T(s.callback_error,e,r),s.restore_on_error&&k(e,U),i||wt(s,r)},Ee=(t,e,s)=>{const r=ot(t)||t;if(Se(r))return;Ws(r,a=>{Fs(a,t,e,s),ye(r)},a=>{Us(a,t,e,s),ye(r)})},Ys=(t,e,s)=>{Ss(t),Ee(t,e,s),Cs(t),Os(t,e,s),zs(t,e,s),As(t,e,s)},js=(t,e,s)=>{Ee(t,e,s),Ds(t,e,s)},xe=(t,e,s)=>{Bs(t)?js(t,e,s):Ys(t,e,s)},Gs=(t,e,s)=>{t.setAttribute("loading","lazy"),Ee(t,e,s),Hs(t,e),N(t,st)},St=t=>{t.removeAttribute(y),t.removeAttribute(pe),t.removeAttribute(ue)},Xs=t=>{me(t,e=>{St(e)}),St(t)},yt=t=>{me(t,e=>{k(e,U)}),k(t,U)},qs={IMG:yt,IFRAME:t=>{k(t,se)},VIDEO:t=>{ct(t,e=>{k(e,se)}),k(t,lt),t.load()},OBJECT:t=>{k(t,ht)}},Js=t=>{const e=qs[t.tagName];if(!e){Ns(t);return}e(t)},Ks=(t,e)=>{ve(t)||we(t)||(S(t,e.class_entered),S(t,e.class_exited),S(t,e.class_applied),S(t,e.class_loading),S(t,e.class_loaded),S(t,e.class_error))},Zs=(t,e)=>{Js(t),Ks(t,e),ee(t),pt(t)},Qs=(t,e,s,r)=>{!s.cancel_on_exit||!vs(t)||t.tagName==="IMG"&&(ye(t),Xs(t),yt(t),S(t,s.class_loading),be(r,-1),ee(t),T(s.callback_cancel,t,e,r))},er=(t,e,s,r)=>{const i=ms(t);N(t,gs),O(t,s.class_entered),S(t,s.class_exited),xs(t,s,r),T(s.callback_enter,t,e,r),!i&&xe(t,s,r)},tr=(t,e,s,r)=>{ve(t)||(O(t,s.class_exited),Qs(t,e,s,r),T(s.callback_exit,t,e,r))},sr=["IMG","IFRAME","VIDEO"],Et=t=>t.use_native&&"loading"in HTMLImageElement.prototype,rr=(t,e,s)=>{t.forEach(r=>{sr.indexOf(r.tagName)!==-1&&Gs(r,e,s)}),at(s,0)},ir=t=>t.isIntersecting||t.intersectionRatio>0,or=t=>({root:t.container===document?null:t.container,rootMargin:t.thresholds||t.threshold+"px"}),ar=(t,e,s)=>{t.forEach(r=>ir(r)?er(r.target,r,e,s):tr(r.target,r,e,s))},nr=(t,e)=>{e.forEach(s=>{t.observe(s)})},cr=(t,e)=>{Es(t),nr(t,e)},lr=(t,e)=>{!Ge||Et(t)||(e._observer=new IntersectionObserver(s=>{ar(s,t,e)},or(t)))},xt=t=>Array.prototype.slice.call(t),ie=t=>t.container.querySelectorAll(t.elements_selector),hr=t=>xt(t).filter(ve),dr=t=>ws(t),pr=t=>xt(t).filter(dr),Tt=(t,e)=>hr(t||ie(e)),ur=(t,e)=>{pr(ie(t)).forEach(r=>{S(r,t.class_error),ee(r)}),e.update()},gr=(t,e)=>{!x||(e._onlineHandler=()=>{ur(t,e)},window.addEventListener("online",e._onlineHandler))},fr=t=>{!x||window.removeEventListener("online",t._onlineHandler)},Y=function(t,e){const s=Je(t);this._settings=s,this.loadingCount=0,lr(s,this),gr(s,this),this.update(e)};Y.prototype={update:function(t){const e=this._settings,s=Tt(t,e);if(at(this,s.length),je||!Ge){this.loadAll(s);return}if(Et(e)){rr(s,e,this);return}cr(this._observer,s)},destroy:function(){this._observer&&this._observer.disconnect(),fr(this),ie(this._settings).forEach(t=>{pt(t)}),delete this._observer,delete this._settings,delete this._onlineHandler,delete this.loadingCount,delete this.toLoadCount},loadAll:function(t){const e=this._settings;Tt(t,e).forEach(r=>{te(r,this),xe(r,e,this)})},restoreAll:function(){const t=this._settings;ie(t).forEach(e=>{Zs(e,t)})}},Y.load=(t,e)=>{const s=Je(e);xe(t,s)},Y.resetStatus=t=>{ee(t)},x&&us(Y,window.lazyLoadOptions);class It{constructor({readonly:e,box:s,pages:r,onNewPageIndex:i,onPlay:o}){if(this.pageIndex=0,this.namespace="netless-app-docs-viewer",this.isShowPreview=!1,this.isSmallBox=!1,this.sideEffect=new q,r.length<=0)throw new Error("[DocsViewer] Empty pages.");this.readonly=e,this.box=s,this.pages=r,this.onNewPageIndex=i,this.onPlay=o,this.render()}mount(){this.box.mountContent(this.$content),this.box.mountFooter(this.$footer),this.sideEffect.add(()=>{const e=new Y({container:this.$preview,elements_selector:`.${this.wrapClassName("preview-page>img")}`});return()=>e.destroy()},"preview-lazyload")}unmount(){this.$content.remove(),this.$footer.remove()}setReadonly(e){this.readonly!==e&&(this.readonly=e,this.$content.classList.toggle(this.wrapClassName("readonly"),e),this.$footer.classList.toggle(this.wrapClassName("readonly"),e),this.$pageNumberInput.disabled=e)}destroy(){this.sideEffect.flushAll(),this.unmount()}setPageIndex(e){Number.isNaN(e)||(this.pageIndex=e,this.$pageNumberInput.value=String(e+1))}setSmallBox(e){this.isSmallBox!==e&&(this.isSmallBox=e,this.$footer.classList.toggle(this.wrapClassName("float-footer"),e))}render(){return this.renderContent(),this.renderFooter(),this.$content}renderContent(){if(!this.$content){const e=document.createElement("div");e.className=this.wrapClassName("content"),this.$content=e,this.readonly&&e.classList.add(this.wrapClassName("readonly")),e.appendChild(this.renderPreviewMask()),e.appendChild(this.renderPreview())}return this.$content}renderPreview(){if(!this.$preview){const e=document.createElement("div");e.className=this.wrapClassName("preview")+" tele-fancy-scrollbar",this.$preview=e;const s=this.wrapClassName("preview-page"),r=this.wrapClassName("preview-page-name");this.pages.forEach((i,o)=>{var d;const a=(d=i.thumbnail)!=null?d:i.src.startsWith("ppt")?void 0:i.src;if(!a)return;const n=String(o),c=document.createElement("a");c.className=s+" "+this.wrapClassName(`preview-page-${o}`),c.setAttribute("href","#"),c.dataset.pageIndex=n;const l=document.createElement("span");l.className=r,l.textContent=String(o+1),l.dataset.pageIndex=n;const h=document.createElement("img");h.width=i.width,h.height=i.height,h.dataset.src=a,h.dataset.pageIndex=n,c.appendChild(h),c.appendChild(l),e.appendChild(c)}),this.sideEffect.addEventListener(e,"click",i=>{var a;if(this.readonly)return;const o=(a=i.target.dataset)==null?void 0:a.pageIndex;o&&(i.preventDefault(),i.stopPropagation(),i.stopImmediatePropagation(),this.onNewPageIndex(Number(o)),this.togglePreview(!1))})}return this.$preview}renderPreviewMask(){return this.$previewMask||(this.$previewMask=document.createElement("div"),this.$previewMask.className=this.wrapClassName("preview-mask"),this.sideEffect.addEventListener(this.$previewMask,"click",e=>{this.readonly||e.target===this.$previewMask&&this.togglePreview(!1)})),this.$previewMask}renderFooter(){if(!this.$footer){const e=document.createElement("div");if(e.className=this.wrapClassName("footer"),this.$footer=e,this.readonly&&e.classList.add(this.wrapClassName("readonly")),this.isSmallBox&&e.classList.add(this.wrapClassName("float-footer")),this.pages.some(c=>c.thumbnail||!c.src.startsWith("ppt"))){const c=this.renderFooterBtn("btn-sidebar",ns(this.namespace));this.sideEffect.addEventListener(c,"click",()=>{this.readonly||this.togglePreview()}),this.$footer.appendChild(c)}const s=document.createElement("div");s.className=this.wrapClassName("page-jumps");const r=this.renderFooterBtn("btn-page-back",cs(this.namespace));if(this.sideEffect.addEventListener(r,"click",()=>{this.readonly||this.onNewPageIndex(this.pageIndex-1)}),s.appendChild(r),this.onPlay){const c=this.renderFooterBtn("btn-page-play",hs(this.namespace),ds(this.namespace)),l=()=>{this.sideEffect.setTimeout(()=>{c.classList.toggle(this.wrapClassName("footer-btn-playing"),!1)},500,"returnPlay")};this.sideEffect.addEventListener(c,"click",()=>{this.readonly||(c.classList.toggle(this.wrapClassName("footer-btn-playing"),!0),this.onPlay&&this.onPlay(),l())}),s.appendChild(c)}const i=this.renderFooterBtn("btn-page-next",ls(this.namespace));this.sideEffect.addEventListener(i,"click",()=>{this.readonly||this.onNewPageIndex(this.pageIndex+1)}),s.appendChild(i);const o=document.createElement("div");o.className=this.wrapClassName("page-number");const a=document.createElement("input");a.className=this.wrapClassName("page-number-input"),a.value=String(this.pageIndex+1),this.readonly&&(a.disabled=!0),this.$pageNumberInput=a,this.sideEffect.addEventListener(a,"focus",()=>{a.select()}),this.sideEffect.addEventListener(a,"change",()=>{this.readonly||a.value&&this.onNewPageIndex(Number(a.value)-1)});const n=document.createElement("span");n.textContent=" / "+this.pages.length,o.appendChild(a),o.appendChild(n),this.$footer.appendChild(s),this.$footer.appendChild(o)}return this.$footer}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}togglePreview(e){if(this.isShowPreview=e!=null?e:!this.isShowPreview,this.$content.classList.toggle(this.wrapClassName("preview-active"),this.isShowPreview),this.isShowPreview){const s=this.$preview.querySelector("."+this.wrapClassName(`preview-page-${this.pageIndex}`));s&&this.$preview.scrollTo({top:s.offsetTop-16})}}wrapClassName(e){return`${this.namespace}-${e}`}}function A(t,e,s){return Math.min(Math.max(t,e),s)}function _t(t){return t.touches?t.touches[0]:t}function Ct(t){t.stopPropagation(),t.cancelable&&t.preventDefault()}class vr{constructor(e){var s,r,i;this.velocity=0,this.paused=!0,this._animationFrameID=null,this._loopTimestamp=0,this.looper=o=>{if(this.paused)return;let a=Math.floor((o-this._loopTimestamp)/1e3*60)+1;for(this._loopTimestamp=o;a-- >0;)this.stepper();this.onStep(this.current,this),!this.paused&&this.current!==this.target&&window.requestAnimationFrame(this.looper)},this.current=(s=e.start)!=null?s:0,this.target=this.current,this.stiffness=(r=e.stiffness)!=null?r:170,this.damping=(i=e.damping)!=null?i:26,this.onStep=e.onStep}stepTo(e,s){this.paused&&s!=null&&(this.current=s),this.paused=!1,this.target=e,this.onStep(this.current,this),this._loopTimestamp=Date.now(),window.requestAnimationFrame(this.looper)}pause(){this.paused=!0}destroy(){this.pause()}stepper(){const e=-this.stiffness*(this.current-this.target),s=-this.damping*this.velocity,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.current=i,this.velocity=r)}}class wr{constructor(e,s,r,i){this.scale=1,this.lastVisit=Date.now(),this.pageOffsetY=0,this.pageOffsetX=0,this.visible=!0,this.index=e,this.page=s,this.scale=r,this.pageOffsetX=(i-s.width)/2;const o=document.createElement("div");o.className="page-renderer-page",o.dataset.index=`${e}`,o.style.width=`${s.width*r}px`,o.style.height=`${s.height*r}px`,s.thumbnail&&(o.style.backgroundImage=`url("${s.thumbnail}")`);const a=document.createElement("img");a.className="page-renderer-page-img",a.width=s.width,a.height=s.height,a.src=s.src,o.appendChild(a),this.$page=o}translateY(e){Math.abs(e-this.pageOffsetY)>=.001&&(this.pageOffsetY=e,this.$page.style.transform=`translate(${this.pageOffsetX*this.scale}px, ${this.pageOffsetY*this.scale}px)`)}setScale(e){Math.abs(e-this.scale)>=.001&&(this.scale=e,this.$page.style.width=`${this.page.width*this.scale}px`,this.$page.style.height=`${this.page.height*this.scale}px`,this.$page.style.transform=`translate(${this.pageOffsetX*this.scale}px, ${this.pageOffsetY*this.scale}px)`)}setVisible(e){e!==this.visible&&(this.visible=e,this.$page.style.opacity=e?"1":"0")}}const br=window.requestIdleCallback||(t=>window.setTimeout(t,5e3)),mr=window.cancelIdleCallback||window.clearTimeout;class Sr{constructor(e,s,r){this.pages=e,this.pagesIntrinsicWidth=s,this.scale=r,this.els=new Map,this.maxElCount=200,this.gcTimer=null,this.gc=()=>{if(this.gcTimer=null,this.els.size>this.maxElCount){const i=[...this.els.values()].sort((o,a)=>a.lastVisit-o.lastVisit);for(let o=Math.floor(this.maxElCount/4);o<i.length;o++)this.els.delete(i[o].index)}}}getEl(e){let s=this.els.get(e);return s||(s=new wr(e,this.pages[e],this.scale,this.pagesIntrinsicWidth),this.els.set(e,s)),s.lastVisit=Date.now(),this.els.size>this.maxElCount&&this.gcTimer===null&&(this.gcTimer=br(this.gc)),s}setScale(e){e!==this.scale&&(this.scale=e,this.els.forEach(s=>s.setScale(e)))}destroy(){this.els.clear(),this.gcTimer!==null&&(mr(this.gcTimer),this.gcTimer=null)}}class yr{constructor(e){this._hwaTimeout=NaN,this._turnOffHWA=()=>{window.clearTimeout(this._hwaTimeout),this._hwaTimeout=NaN,this.$pages.classList.toggle("is-hwa",!1)},this.pagesScrollTop=e.pagesScrollTop||0,this.containerWidth=e.containerWidth||1,this.containerHeight=e.containerHeight||1,this.pages=e.pages.map(o=>{if(o.thumbnail)return o;try{const a=new URL(o.src);return a.searchParams.set("x-oss-process","image/resize,l_50"),Ce(_e({},o),{thumbnail:a.toString()})}catch(a){return console.error(a),o}});const s=Array(this.pages.length);let r=1/0,i=0;this.pagesIntrinsicHeight=this.pages.reduce((o,a,n)=>(s[n]=o,a.width>i&&(i=a.width),a.height<=r&&(r=a.height),o+a.height),0),this.pagesIntrinsicWidth=i,this.pagesMinHeight=r,this.pagesIntrinsicYs=s,this.scale=this._calcScale(),this.threshold=this._calcThreshold(),this.onPageIndexChanged=e.onPageIndexChanged,this.pageScrollIndex=0,this.pagesScrollTop!==0&&(this.pageScrollIndex=this.findScrollPageIndex(),this.onPageIndexChanged&&this.pageScrollIndex>0&&this.onPageIndexChanged(this.pageScrollIndex)),this.pageElManager=new Sr(this.pages,i,this.scale),this.$pages=this.renderPages()}setContainerSize(e,s){e>0&&s>0&&(e!==this.containerWidth||s!==this.containerHeight)&&(this.containerWidth=e,this.containerHeight=s,this.$pages.style.width=`${this.containerWidth}px`,this.$pages.style.height=`${this.containerHeight}px`,this.scale=this._calcScale(),this.threshold=this._calcThreshold(),this.pageElManager.setScale(this.scale),this.$pages.parentElement&&this.pagesScrollTo(this.pagesScrollTop,!0))}renderPages(){const e=document.createElement("div");return e.className="page-renderer-pages-container",e.style.width=`${this.containerWidth}px`,e.style.height=`${this.containerHeight}px`,e}pagesScrollTo(e,s){if(e=A(e,0,this.pagesIntrinsicHeight-this.containerHeight/this.scale),s||Math.abs(e-this.pagesScrollTop)>=.001){this._turnOnHWA(),this.pagesScrollTop=e;const r=this.findScrollPageIndex(),i=Math.max(r-this.threshold,0),o=Math.min(r+this.threshold,this.pages.length-1);for(let a=0;a<this.$pages.children.length;a++){const n=this.$pages.children[a],c=Number(n.dataset.index);c>=i&&c<=o||(n.remove(),a--)}for(let a=i;a<=o;a++){const n=this.pageElManager.getEl(a);n.$page.parentElement!==this.$pages&&this.$pages.appendChild(n.$page),n.translateY(this.pagesIntrinsicYs[a]-this.pagesScrollTop)}r!==this.pageScrollIndex&&(this.pageScrollIndex=r,this.onPageIndexChanged&&this.onPageIndexChanged(r))}}findScrollPageIndex(){for(let e=0;e<this.pagesIntrinsicYs.length;e++)if(this.pagesIntrinsicYs[e]+this.pages[e].height-this.pagesScrollTop>=.001)return e;return this.pagesIntrinsicYs.length-1}mount(e){e.appendChild(this.$pages),this.pagesScrollTo(this.pagesScrollTop,!0)}unmount(){this.$pages.remove()}destroy(){this.unmount(),this.onPageIndexChanged=void 0,this.pageElManager.destroy(),this._hwaTimeout&&(window.clearTimeout(this._hwaTimeout),this._hwaTimeout=NaN)}_calcScale(){return this.containerWidth/this.pagesIntrinsicWidth||1}_calcThreshold(){return A(Math.ceil(this.containerHeight/this.scale/this.pagesMinHeight/2),1,this.pages.length)}_turnOnHWA(){this._hwaTimeout?window.clearTimeout(this._hwaTimeout):this.$pages.classList.toggle("is-hwa",!0),this._hwaTimeout=window.setTimeout(this._turnOffHWA,1e3)}}const Er=30;class xr{constructor(e){this.sideEffect=new q,this.pagesScrollTop=e.pagesScrollTop||0,this.containerWidth=e.containerWidth||1,this.containerHeight=e.containerHeight||1,this.pagesWidth=e.pagesWidth||1,this.pagesHeight=e.pagesHeight||1,this.scale=this._calcScale(),this.scrollbarMinHeight=e.scrollbarMinHeight||Er,this.scrollbarHeight=this._calcScrollbarHeight(),this.readonly=e.readonly,this.wrapClassName=e.wrapClassName,this.onDragScroll=e.onDragScroll,this.$scrollbar=this.renderScrollbar()}mount(e){e.appendChild(this.$scrollbar),this.pagesScrollTo(this.pagesScrollTop,!0)}unmount(){this.$scrollbar.remove()}setReadonly(e){this.readonly=e}setContainerSize(e,s){e>0&&s>0&&(e!==this.containerWidth||s!==this.containerHeight)&&(this.containerWidth=e,this.containerHeight=s,this.scale=this._calcScale(),this._updateScrollbarHeight(),this.$scrollbar.parentElement&&this.pagesScrollTo(this.pagesScrollTop,!0))}pagesScrollTo(e,s){if(e=A(e,0,this.pagesHeight-this.containerHeight/this.scale),s||Math.abs(e-this.pagesScrollTop)>=.001){this.pagesScrollTop=e;const r=this.pagesScrollTop*this.scale,i=this.pagesHeight*this.scale,o=r/(i-this.containerHeight)*(this.containerHeight-this.scrollbarHeight);window.requestAnimationFrame?window.requestAnimationFrame(()=>{this.$scrollbar.style.transform=`translateY(${o}px)`}):this.$scrollbar.style.transform=`translateY(${o}px)`}}destroy(){this.unmount(),this.onDragScroll=void 0,this.sideEffect.flushAll()}renderScrollbar(){const e=document.createElement("button");e.className=this.wrapClassName("scrollbar"),e.style.minHeight=`${this.scrollbarMinHeight}px`,e.style.height=`${this.scrollbarHeight}px`;const s=r=>{if(this.readonly||r.button!=null&&r.button!==0)return;Ct(r);const i=this.wrapClassName("scrollbar-dragging");e.classList.toggle(i,!0);const o=this.pagesScrollTop,{clientY:a}=_t(r),n=l=>{if(this.readonly)return;const{clientY:h}=_t(l),d=(h-a)/this.scale;Math.abs(d)>0&&this.onDragScroll&&this.onDragScroll(o+d*(this.pagesHeight*this.scale/this.containerHeight))},c=()=>{e.classList.toggle(i,!1),window.removeEventListener("mousemove",n,!0),window.removeEventListener("touchmove",n,!0),window.removeEventListener("mouseup",c,!0),window.removeEventListener("touchend",c,!0),window.removeEventListener("touchcancel",c,!0)};window.addEventListener("mousemove",n,!0),window.addEventListener("touchmove",n,!0),window.addEventListener("mouseup",c,!0),window.addEventListener("touchend",c,!0),window.addEventListener("touchcancel",c,!0)};return this.sideEffect.addEventListener(e,"mousedown",s),this.sideEffect.addEventListener(e,"touchstart",s),e}_calcScale(){return this.containerWidth/this.pagesWidth||1}_calcScrollbarHeight(){return A(this.containerHeight/(this.pagesHeight*this.scale)*this.containerHeight,this.scrollbarMinHeight,this.containerHeight)}_updateScrollbarHeight(){const e=this._calcScrollbarHeight();Math.abs(e-this.scrollbarHeight)>.001&&(this.scrollbarHeight=e,this.$scrollbar.style.height=`${e}px`)}}const Tr=window.ResizeObserver||as,j=640;class Ir{constructor({whiteboardView:e,readonly:s,box:r,pages:i,pageScrollTop:o=0,mountWhiteboard:a,onUserScroll:n,baseScenePath:c,appId:l}){this.sideEffect=new q,this.userScrolling=!1,this.onNewPageIndex=p=>{this.scrollToPage(p)},this.toPdf=async()=>{const p=document.createElement("canvas"),E=p.getContext("2d");if(!E||!this.baseScenePath){this.reportProgress(100,null);return}const Te=`${this.baseScenePath}/1`,P=this.pages[0],{jsPDF:oe}=await import("jspdf"),_=new oe({format:[P.width,P.height],orientation:P.width>P.height?"l":"p",compress:!0});for(const[R,ae]of this.pages.entries()){const{width:b,height:w,src:D}=ae;p.width=b,p.height=w;const V=b>w?"l":"p";R>0&&_.addPage([b,w],V);const Ie=await this.getBase64FromUrl(D),X=document.createElement("img");X.src=Ie,await new Promise(Pr=>X.onload=Pr),E.drawImage(X,0,0);const ne=p.toDataURL("image/jpeg",.6);E.clearRect(0,0,b,w),this.whiteboardView.screenshotToCanvas(E,Te,b,w,{centerX:b/2,centerY:w/2+R*w,scale:1});const kr=p.toDataURL("image/png");_.addImage(ne,"JPEG",0,0,b,w,"","FAST"),_.addImage(kr,"PNG",0,0,b,w,"","FAST"),E.clearRect(0,0,b,w),Math.ceil((R+1)/this.pages.length*100)<100&&this.reportProgress(Math.ceil((R+1)/this.pages.length*100),null)}const G=_.output("arraybuffer");this.reportProgress(100,{pdf:G,title:this.box.title})},this.whiteboardView=e,this.readonly=s,this.box=r,this.pages=i,this.baseScenePath=c,this.appId=l,this.mountWhiteboard=a,this._onUserScroll=n;const h=this.debounce(()=>{this.userScrolling=!1,this._onUserScroll&&this._onUserScroll(this.pageRenderer.pagesScrollTop)},{wait:80},"debounce-updateUserScroll");this.updateUserScroll=()=>{this.userScrolling=!0,h()},this.viewer=new It({readonly:s,box:r,pages:i,onNewPageIndex:this.onNewPageIndex});const{width:d,height:H}=this.whiteboardView.size;this.pageRenderer=new yr({pagesScrollTop:o,pages:this.pages,containerWidth:d,containerHeight:H,onPageIndexChanged:this.viewer.setPageIndex.bind(this.viewer)}),this.scrollbar=new xr({pagesScrollTop:this.pageRenderer.pagesScrollTop,containerWidth:d,containerHeight:H,pagesWidth:this.pageRenderer.pagesIntrinsicWidth,pagesHeight:this.pageRenderer.pagesIntrinsicHeight,readonly:this.readonly,wrapClassName:this.wrapClassName.bind(this),onDragScroll:p=>{this.pageScrollTo(p),this.updateUserScroll()}}),this.pageScrollStepper=new vr({start:this.pageRenderer.pagesScrollTop,onStep:p=>{this.pageScrollTo(p)}}),this.render()}mount(){this.viewer.mount(),this.setupScrollListener();const e=this.debounce(this.renderRatioHeight.bind(this),{wait:80});return this.sideEffect.add(()=>{const s=new Tr(e);return s.observe(this.viewer.$content),()=>s.disconnect()}),this.sideEffect.setTimeout(()=>{this.userScrolling||this.pageScrollTo(this.pageRenderer.pagesScrollTop)},100),this.sideEffect.add(()=>{const s=r=>{r.data.type==="@netless/_request_save_pdf_"&&r.data.appId===this.appId&&this.toPdf().catch(()=>this.reportProgress(100,null))};return window.addEventListener("message",s),()=>{window.removeEventListener("message",s)}}),this}unmount(){return this.viewer.unmount(),this}setReadonly(e){this.readonly!==e&&(this.readonly=e,this.viewer.setReadonly(e),this.scrollbar.setReadonly(e))}destroy(){this.sideEffect.flushAll(),this.pageScrollStepper.destroy(),this._onUserScroll=void 0,this.unmount(),this.viewer.destroy(),this.pageRenderer.destroy(),this.scrollbar.destroy()}syncPageScrollTop(e){!this.userScrolling&&e>=0&&Math.abs(this.pageRenderer.pagesScrollTop-e)>.01&&this.pageScrollStepper.stepTo(e,this.pageRenderer.pagesScrollTop)}render(){this.pageRenderer.mount(this.viewer.$content),this.viewer.$content.appendChild(this.renderWhiteboardView()),this.scrollbar.mount(this.viewer.$content),this.renderRatioHeight()}renderRatioHeight(){const e=this.box.absoluteHeight,s=e<=j;if(this.viewer.setSmallBox(s),s){const r=26/j,i=26/e,o=26/j,a=0,n=Math.max((r+o-(i+a))/2,0);if(this.box.$titleBar){const c=i+n;this.box.$titleBar.style.height=`${c*100}%`}if(this.box.$footer){const c=a+n;this.box.$footer.style.height=`${c*100}%`}}else{if(this.box.$titleBar){const r=Math.max(26/j,26/e);this.box.$titleBar.style.height=`${r*100}%`}if(this.box.$footer){const r=Math.max(26/j,26/e);this.box.$footer.style.height=`${r*100}%`}}}renderWhiteboardView(){return this.$whiteboardView||(this.$whiteboardView=document.createElement("div"),this.$whiteboardView.className=this.wrapClassName("wb-view"),this.mountWhiteboard(this.$whiteboardView),this.sideEffect.addEventListener(this.$whiteboardView,"wheel",e=>{Ct(e),this.readonly||(this.pageScrollTo(this.pageRenderer.pagesScrollTop+e.deltaY),this.updateUserScroll())},{passive:!1,capture:!0}),this.sideEffect.addEventListener(this.$whiteboardView,"touchmove",e=>{this.readonly||e.touches.length<=1||this.updateUserScroll()},{passive:!0,capture:!0})),this.$whiteboardView}scrollTopPageToEl(e){return e*this.pageRenderer.scale}scrollTopElToPage(e){return e/this.pageRenderer.scale}elScrollTo(e){this.pageScrollTo(this.scrollTopElToPage(e))}pageScrollTo(e){const s=this.scrollTopElToPage(this.whiteboardView.size.height/2);this.whiteboardView.moveCamera({centerY:A(e+s,s,this.pageRenderer.pagesIntrinsicHeight-s),animationMode:"immediately"})}scrollToPage(e){if(!this.readonly&&!Number.isNaN(e)){const s=this.pageRenderer.pagesIntrinsicYs[e];s>=0&&(this.pageScrollTo(s+5/this.pageRenderer.scale),this.updateUserScroll())}}setupScrollListener(){this.sideEffect.add(()=>{const s=r=>{const{width:i,height:o}=this.whiteboardView.size;if(i<=0||o<=0)return;const a=r.centerY-this.pageRenderer.containerHeight/this.pageRenderer.scale/2;this.pageRenderer.pagesScrollTo(a),this.scrollbar.pagesScrollTo(a)};return this.whiteboardView.callbacks.on("onCameraUpdated",s),()=>this.whiteboardView.callbacks.off("onCameraUpdated",s)}),this.sideEffect.add(()=>{const s=({width:r,height:i})=>{if(r<=0||i<=0)return;this.pageRenderer.setContainerSize(r,i),this.scrollbar.setContainerSize(r,i);const{pagesIntrinsicWidth:o,pagesIntrinsicHeight:a}=this.pageRenderer;this.whiteboardView.moveCameraToContain({originX:0,originY:this.pageRenderer.pagesScrollTop,width:o,height:i/this.pageRenderer.scale,animationMode:"immediately"}),this.whiteboardView.setCameraBound({damping:1,maxContentMode:()=>this.pageRenderer.scale,minContentMode:()=>this.pageRenderer.scale,centerX:o/2,centerY:a/2,width:o,height:a})};return this.whiteboardView.callbacks.on("onSizeUpdated",s),()=>{this.whiteboardView.callbacks.off("onSizeUpdated",s)}},"whiteboard-size-update");const e=s=>{if(!s)return!1;const r=s.tagName;return r==="INPUT"||r==="TEXTAREA"||r==="SELECT"};this.sideEffect.addEventListener(window,"keyup",s=>{if(this.readonly||!this.box.focus||this.box.minimized||e(s.target))return;let r=null;switch(s.key){case"PageDown":{r=this.pageRenderer.pagesScrollTop+this.pageRenderer.containerHeight/this.pageRenderer.scale;break}case"PageUp":{r=this.pageRenderer.pagesScrollTop-this.pageRenderer.containerHeight/this.pageRenderer.scale;break}case"ArrowDown":{r=this.pageRenderer.pagesScrollTop+this.pageRenderer.containerHeight/4/this.pageRenderer.scale;break}case"ArrowUp":{r=this.pageRenderer.pagesScrollTop-this.pageRenderer.containerHeight/4/this.pageRenderer.scale;break}}r!==null&&(this._onUserScroll?this._onUserScroll(r):(this.pageScrollTo(r),this.updateUserScroll()))},{capture:!0})}debounce(e,s,r){const i=Ht(e,s);return this.sideEffect.addDisposer(()=>i.cancel(),r),i}wrapClassName(e){return"netless-app-docs-viewer-static-"+e}async getBase64FromUrl(e){const r=await(await fetch(e)).blob();return new Promise(i=>{const o=new FileReader;o.readAsDataURL(r),o.onloadend=()=>{const a=o.result;i(a)}})}reportProgress(e,s){window.postMessage({type:"@netless/_result_save_pdf_",appId:this.appId,progress:e,result:s})}}class _r{constructor({context:e,whiteboardView:s,box:r,pages:i}){this.sideEffect=new q,this.onPlayPPT=()=>{const o=this.context.getRoom();o&&o.pptNextStep()},this._scaleDocsToFitImpl=()=>{const o=this.pages[this.getPageIndex()];o&&(this.whiteboardView.moveCameraToContain({originX:-o.width/2,originY:-o.height/2,width:o.width,height:o.height,animationMode:"immediately"}),this.whiteboardView.setCameraBound({damping:1,maxContentMode:()=>this.whiteboardView.camera.scale,minContentMode:()=>this.whiteboardView.camera.scale,centerX:0,centerY:0,width:o.width,height:o.height}))},this._scaleDocsToFitDebounced=()=>{this.sideEffect.setTimeout(this._scaleDocsToFitImpl,1e3,"_scaleDocsToFitDebounced")},this.scaleDocsToFit=()=>{this._scaleDocsToFitImpl(),this._scaleDocsToFitDebounced()},this.onNewPageIndex=o=>{this.jumpToPage(o,!0)},this.context=e,this.whiteboardView=s,this.box=r,this.pages=i,this.displayer=e.getDisplayer(),this.viewer=new It({readonly:!e.getIsWritable(),box:r,pages:i,onNewPageIndex:this.onNewPageIndex,onPlay:this.onPlayPPT}),this.render(),this.sideEffect.add(()=>{const o=a=>{this.viewer.setReadonly(!a)};return this.context.emitter.on("writableChange",o),()=>this.context.emitter.off("writableChange",o)}),this.sideEffect.add(()=>{const o=a=>{this.jumpToPage(a.index)};return this.context.emitter.on("sceneStateChange",o),()=>this.context.emitter.off("sceneStateChange",o)})}mount(){this.viewer.mount();const e=this.getPageIndex();return e!==0&&this.jumpToPage(e),this.scaleDocsToFit(),this.sideEffect.add(()=>(this.whiteboardView.callbacks.on("onSizeUpdated",this.scaleDocsToFit),()=>{this.whiteboardView.callbacks.off("onSizeUpdated",this.scaleDocsToFit)})),this}unmount(){return this.viewer.unmount(),this}destroy(){this.sideEffect.flushAll(),this.unmount(),this.viewer.destroy()}getPageIndex(){return this.displayer.state.sceneState.index}jumpToPage(e,s){var r,i;if(e=A(e,0,this.pages.length-1),e!==this.getPageIndex()&&this.context.getIsWritable()){const o=this.context.getInitScenePath(),a=(i=(r=this.context.getScenes())==null?void 0:r[e])==null?void 0:i.name;o&&a&&this.context.setScenePath(`${o}/${a}`),this.scaleDocsToFit()}if(e!==this.viewer.pageIndex&&this.viewer.setPageIndex(e),s){const o=this.context.getRoom();if(o){const a=o.state.globalState.__pptState;o.setGlobalState({__pptState:a&&{uuid:a.uuid,pageIndex:e,disableAutoPlay:a.disableAutoPlay}})}}}render(){this.viewer.$content.appendChild(this.renderMask()),this.viewer.$content.appendChild(this.renderWhiteboardView()),this.sideEffect.addEventListener(window,"keydown",e=>{var s;if(this.box.focus)switch(e.key){case"ArrowUp":case"ArrowLeft":{this.jumpToPage(this.getPageIndex()-1,!0);break}case"ArrowRight":case"ArrowDown":{(s=this.context.getRoom())==null||s.pptNextStep();break}}})}renderMask(){if(!this.$mask){const e=document.createElement("div");e.className=this.wrapClassName("mask"),this.$mask=e;const s=document.createElement("button");s.className=this.wrapClassName("back");const r=document.createElement("button");r.className=this.wrapClassName("next")}return this.$mask}renderWhiteboardView(){return this.$whiteboardView||(this.$whiteboardView=document.createElement("div"),this.$whiteboardView.className=this.wrapClassName("wb-view"),this.sideEffect.addEventListener(this.$whiteboardView,"click",e=>{var r;const s=this.context.getRoom();if(s&&s.state.memberState.currentApplianceName==="clicker"){for(let i=e.target;i;i=i.parentElement)if((r=i.classList)!=null&&r.contains("ppt-event-source"))return;s.pptNextStep()}}),this.context.mountView(this.$whiteboardView)),this.$whiteboardView}wrapClassName(e){return"netless-app-docs-viewer-dynamic-"+e}}const Cr={kind:"DocsViewer",setup(t){const e=t.getBox(),s=t.getScenes();if(!s)throw new Error("[Docs Viewer]: scenes not found.");const r=t.getView();if(!r)throw new Error("[Docs Viewer]: no whiteboard view.");const i=s.map(({ppt:o})=>o?{width:o.width,height:o.height,src:o.src,thumbnail:o.previewURL}:null).filter(o=>Boolean(o));if(i.length<=0)throw new Error("[Docs Viewer]: empty scenes.");e.mountStyles(u),i[0].src.startsWith("ppt")?Nr(t,r,e,i):$r(t,r,e,i)}};function $r(t,e,s,r){var o;e.disableCameraTransform=!t.getIsWritable();const i=new Ir({whiteboardView:e,readonly:!t.getIsWritable(),box:s,pages:r,pageScrollTop:(o=t.getAttributes())==null?void 0:o.pageScrollTop,mountWhiteboard:t.mountView.bind(t),onUserScroll:a=>{var n;((n=t.getAttributes())==null?void 0:n.pageScrollTop)!==a&&!s.readonly&&t.updateAttributes(["pageScrollTop"],a)},baseScenePath:t.getInitScenePath(),appId:t.appId}).mount();t.emitter.on("attributesUpdate",a=>{a&&a.pageScrollTop!=null&&i.syncPageScrollTop(a.pageScrollTop)}),t.emitter.on("writableChange",a=>{i.setReadonly(!a),e.disableCameraTransform=!a})}function Nr(t,e,s,r){e.disableCameraTransform=!0;const i=new _r({context:t,whiteboardView:e,box:s,pages:r}).mount();t.mountView(i.$whiteboardView),t.isAddApp&&e.callbacks.once("onSizeUpdated",({width:o,height:a})=>{if(r.length>0&&s.state!=="maximized"){const{width:n,height:c}=r[0],h=c/n*o-a;h!==0&&t.getIsWritable()&&t.emitter.emit("setBoxSize",{width:s.width,height:s.height+h/s.containerRect.height})}})}return f.default=Cr,Object.defineProperties(f,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),f}({}); | ||
var NetlessAppDocsViewer=function(f){"use strict";var Lr=Object.defineProperty,Or=Object.defineProperties;var zr=Object.getOwnPropertyDescriptors;var Nt=Object.getOwnPropertySymbols;var Ar=Object.prototype.hasOwnProperty,Hr=Object.prototype.propertyIsEnumerable;var kt=(f,u,v)=>u in f?Lr(f,u,{enumerable:!0,configurable:!0,writable:!0,value:v}):f[u]=v,_e=(f,u)=>{for(var v in u||(u={}))Ar.call(u,v)&&kt(f,v,u[v]);if(Nt)for(var v of Nt(u))Hr.call(u,v)&&kt(f,v,u[v]);return f},Ce=(f,u)=>Or(f,zr(u));var u=(()=>`.netless-app-docs-viewer-content{position:relative;height:100%;overflow:hidden}.netless-app-docs-viewer-preview-mask{display:none;position:absolute;z-index:200;top:0;left:0;width:100%;height:100%}.netless-app-docs-viewer-preview{display:flex;flex-direction:column;align-items:center;position:absolute;z-index:300;top:0;left:0;width:33%;max-width:200px;height:100%;padding-top:10px;transform:translate(-100%);background:rgba(237,237,240,.9);box-shadow:inset -1px 0 #0000001c;transition:transform .4s}.netless-app-docs-viewer-preview-active .netless-app-docs-viewer-preview-mask{display:block}.netless-app-docs-viewer-preview-active .netless-app-docs-viewer-preview{transform:translate(0)}.netless-app-docs-viewer-preview-page{position:relative;display:block;width:55%;margin-bottom:10px;font-size:0;color:transparent;outline:none;border:7px solid transparent;border-radius:4px;transition:border-color .3s;user-select:none}.netless-app-docs-viewer-preview-page:hover,.netless-app-docs-viewer-preview-page.netless-app-docs-viewer-preview-page-active{border-color:#444e601a}.netless-app-docs-viewer-preview-page>img{width:100%;height:auto;box-sizing:border-box;border:1px solid rgba(0,0,0,.5);border-radius:1px;background-color:#fff;box-shadow:0 2px 8px #0000004d}.netless-app-docs-viewer-preview-page-name{position:absolute;top:1px;left:-10px;transform:translate(-100%);text-align:right;font-size:12px;color:#5f5f5f;user-select:none}.netless-app-docs-viewer-footer{box-sizing:border-box;height:26px;display:flex;align-items:center;padding:0 16px;border-top:1px solid #eeeef7;color:#191919}.netless-app-docs-viewer-float-footer{width:100%;min-height:26px;position:absolute;left:0;bottom:0;z-index:2000;background:rgba(249,249,252,.9);transition:opacity .4s}.netless-app-docs-viewer-footer-btn{box-sizing:border-box;width:26px;height:26px;font-size:0;margin:0;padding:3px;border:none;border-radius:1px;outline:none;color:currentColor;background:transparent;transition:background .4s;cursor:pointer;user-select:none;-webkit-tap-highlight-color:rgba(0,0,0,0)}.netless-app-docs-viewer-footer-btn:hover{background:rgba(237,237,240,.9)}@media (hover: none){.netless-app-docs-viewer-footer-btn:hover{background:transparent!important}}.netless-app-docs-viewer-footer-btn>svg{width:100%;height:100%}.netless-app-docs-viewer-footer-btn>svg:nth-of-type(2){display:none}.netless-app-docs-viewer-footer-btn.netless-app-docs-viewer-footer-btn-playing>svg:nth-of-type(1){display:none}.netless-app-docs-viewer-footer-btn.netless-app-docs-viewer-footer-btn-playing>svg:nth-of-type(2){display:initial}.netless-app-docs-viewer-footer-btn~.netless-app-docs-viewer-footer-btn{margin-left:15px}.netless-app-docs-viewer-page-jumps{flex:1;display:flex;justify-content:center;align-items:center}.netless-app-docs-viewer-page-number{margin-left:auto;font-size:13px;user-select:none;white-space:nowrap;word-break:keep-all}.netless-app-docs-viewer-page-number-input{border:none;outline:none;width:3em;margin:0;padding:0 2px;text-align:right;font-size:13px;line-height:1;font-weight:400;font-family:inherit;border-radius:2px;color:currentColor;background:transparent;transition:background .4s;user-select:text;-webkit-tap-highlight-color:rgba(0,0,0,0)}.netless-app-docs-viewer-page-number-input:hover,.netless-app-docs-viewer-page-number-input:focus,.netless-app-docs-viewer-page-number-input:active{background:#fff;box-shadow:#63636333 0 2px 8px}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-footer-btn{cursor:not-allowed}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-footer-btn:hover{background:transparent}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-page-number-input{cursor:not-allowed}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-page-number-input:hover,.netless-app-docs-viewer-readonly .netless-app-docs-viewer-page-number-input:focus,.netless-app-docs-viewer-readonly .netless-app-docs-viewer-page-number-input:active{background:transparent;box-shadow:none}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-page-number-input:disabled{color:inherit}.netless-app-docs-viewer-readonly.netless-app-docs-viewer-float-footer{display:none}.telebox-color-scheme-dark .netless-app-docs-viewer-page-number-input{color:#a6a6a8}.telebox-color-scheme-dark .netless-app-docs-viewer-page-number-input:active,.telebox-color-scheme-dark .netless-app-docs-viewer-page-number-input:focus,.telebox-color-scheme-dark .netless-app-docs-viewer-page-number-input:hover{color:#222}.telebox-color-scheme-dark .netless-app-docs-viewer-footer{color:#a6a6a8;background:#2d2d33;border-top:none}.telebox-color-scheme-dark .netless-app-docs-viewer-footer-btn:hover{background:#212126}.telebox-color-scheme-dark .netless-app-docs-viewer-preview{background:rgba(50,50,50,.9)}.netless-app-docs-viewer-static-scrollbar{position:absolute;top:0;right:0;z-index:2147483647;width:8px;min-height:30px;margin:0;padding:0;border:none;outline:none;border-radius:4px;background:rgba(68,78,96,.4);box-shadow:1px 1px 8px #ffffffb3;opacity:0;transition:background .4s,opacity .4s 3s,transform .2s;user-select:none}.netless-app-docs-viewer-static-scrollbar.netless-app-docs-viewer-static-scrollbar-dragging{background:rgba(68,78,96,.6);opacity:1;transition:background .4s,opacity .4s 3s!important}.netless-app-docs-viewer-static-scrollbar:hover,.netless-app-docs-viewer-static-scrollbar:focus{background:rgba(68,78,96,.5)}.netless-app-docs-viewer-static-scrollbar:active{background:rgba(68,78,96,.6)}.netless-app-docs-viewer-content:hover .netless-app-docs-viewer-static-scrollbar{opacity:1;transition:background .4s,opacity .4s,transform .2s}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-static-scrollbar{display:none}.netless-app-docs-viewer-static-pages:hover .netless-app-docs-viewer-static-scrollbar{opacity:1;transition:background .4s,opacity .4s,transform .2s}.page-renderer-pages-container{position:relative;overflow:hidden}.page-renderer-page{position:absolute;top:0;left:0;background-position:center;background-size:cover;background-repeat:no-repeat}.page-renderer-pages-container.is-hwa .page-renderer-page{will-change:transform}.page-renderer-page-img{display:block;width:100%;height:auto;user-select:none}.netless-app-docs-viewer-static-pages{overflow:hidden;position:relative;height:100%;user-select:none}.netless-app-docs-viewer-static-page{display:block;width:100%;height:auto;user-select:none}.netless-app-docs-viewer-static-wb-view,.netless-app-docs-viewer-dynamic-wb-view{position:absolute;top:0;left:0;width:100%;height:100%;z-index:100;overflow:hidden}.netless-app-docs-viewer-dynamic-wb-view .cursor-clicker .ppt-event-source{cursor:pointer} | ||
`)();const v=(t,e,s,r)=>{if(s==="length"||s==="prototype"||s==="arguments"||s==="caller")return;const i=Object.getOwnPropertyDescriptor(t,s),o=Object.getOwnPropertyDescriptor(e,s);!Pt(i,o)&&r||Object.defineProperty(t,s,o)},Pt=function(t,e){return t===void 0||t.configurable||t.writable===e.writable&&t.enumerable===e.enumerable&&t.configurable===e.configurable&&(t.writable||t.value===e.value)},Rt=(t,e)=>{const s=Object.getPrototypeOf(e);s!==Object.getPrototypeOf(t)&&Object.setPrototypeOf(t,s)},Lt=(t,e)=>`/* Wrapped ${t}*/ | ||
${e}`,Ot=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),zt=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),At=(t,e,s)=>{const r=s===""?"":`with ${s.trim()}() `,i=Lt.bind(null,r,e.toString());Object.defineProperty(i,"name",zt),Object.defineProperty(t,"toString",Ce(_e({},Ot),{value:i}))};function Ht(t,e,{ignoreNonConfigurable:s=!1}={}){const{name:r}=t;for(const i of Reflect.ownKeys(e))v(t,e,i,s);return Rt(t,e),At(t,e,r),t}const Dt=(t,e={})=>{if(typeof t!="function")throw new TypeError(`Expected the first argument to be a function, got \`${typeof t}\``);const{wait:s=0,maxWait:r=Number.Infinity,before:i=!1,after:o=!0}=e;if(!i&&!o)throw new Error("Both `before` and `after` are false, function wouldn't be called.");let a,n,c;const l=function(...h){const d=this,H=()=>{a=void 0,n&&(clearTimeout(n),n=void 0),o&&(c=t.apply(d,h))},p=()=>{n=void 0,a&&(clearTimeout(a),a=void 0),o&&(c=t.apply(d,h))},E=i&&!a;return clearTimeout(a),a=setTimeout(H,s),r>0&&r!==Number.Infinity&&!n&&(n=setTimeout(p,r)),E&&(c=t.apply(d,h)),c};return Ht(l,t),l.cancel=()=>{a&&(clearTimeout(a),a=void 0),n&&(clearTimeout(n),n=void 0)},l},$e="!#%()*+,-./:;=?@[]^_`{|}~ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",Vt=$e.length,Ne=Array(20),Bt=()=>{for(let t=0;t<20;t++)Ne[t]=$e.charAt(Math.random()*Vt);return Ne.join("")};function ke(t){try{return t()}catch(e){console.error(e)}}class q{constructor(){this.disposers=new Map}addDisposer(e,s=this.genUID()){return this.flush(s),this.disposers.set(s,Array.isArray(e)?()=>e.forEach(ke):e),s}add(e,s=this.genUID()){return this.addDisposer(e(),s)}addEventListener(e,s,r,i,o=this.genUID()){return e.addEventListener(s,r,i),this.addDisposer(()=>e.removeEventListener(s,r,i),o),o}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(ke),this.disposers.clear()}genUID(){let e;do e=Bt();while(this.disposers.has(e));return e}}var C=[],Mt=function(){return C.some(function(t){return t.activeTargets.length>0})},Wt=function(){return C.some(function(t){return t.skippedTargets.length>0})},Pe="ResizeObserver loop completed with undelivered notifications.",Ft=function(){var t;typeof ErrorEvent=="function"?t=new ErrorEvent("error",{message:Pe}):(t=document.createEvent("Event"),t.initEvent("error",!1,!1),t.message=Pe),window.dispatchEvent(t)},B;(function(t){t.BORDER_BOX="border-box",t.CONTENT_BOX="content-box",t.DEVICE_PIXEL_CONTENT_BOX="device-pixel-content-box"})(B||(B={}));var $=function(t){return Object.freeze(t)},Ut=function(){function t(e,s){this.inlineSize=e,this.blockSize=s,$(this)}return t}(),Re=function(){function t(e,s,r,i){return this.x=e,this.y=s,this.width=r,this.height=i,this.top=this.y,this.left=this.x,this.bottom=this.top+this.height,this.right=this.left+this.width,$(this)}return t.prototype.toJSON=function(){var e=this,s=e.x,r=e.y,i=e.top,o=e.right,a=e.bottom,n=e.left,c=e.width,l=e.height;return{x:s,y:r,top:i,right:o,bottom:a,left:n,width:c,height:l}},t.fromRect=function(e){return new t(e.x,e.y,e.width,e.height)},t}(),ce=function(t){return t instanceof SVGElement&&"getBBox"in t},Le=function(t){if(ce(t)){var e=t.getBBox(),s=e.width,r=e.height;return!s&&!r}var i=t,o=i.offsetWidth,a=i.offsetHeight;return!(o||a||t.getClientRects().length)},Oe=function(t){var e,s;if(t instanceof Element)return!0;var r=(s=(e=t)===null||e===void 0?void 0:e.ownerDocument)===null||s===void 0?void 0:s.defaultView;return!!(r&&t instanceof r.Element)},Yt=function(t){switch(t.tagName){case"INPUT":if(t.type!=="image")break;case"VIDEO":case"AUDIO":case"EMBED":case"OBJECT":case"CANVAS":case"IFRAME":case"IMG":return!0}return!1},M=typeof window!="undefined"?window:{},J=new WeakMap,ze=/auto|scroll/,jt=/^tb|vertical/,Gt=/msie|trident/i.test(M.navigator&&M.navigator.userAgent),m=function(t){return parseFloat(t||"0")},L=function(t,e,s){return t===void 0&&(t=0),e===void 0&&(e=0),s===void 0&&(s=!1),new Ut((s?e:t)||0,(s?t:e)||0)},Ae=$({devicePixelContentBoxSize:L(),borderBoxSize:L(),contentBoxSize:L(),contentRect:new Re(0,0,0,0)}),He=function(t,e){if(e===void 0&&(e=!1),J.has(t)&&!e)return J.get(t);if(Le(t))return J.set(t,Ae),Ae;var s=getComputedStyle(t),r=ce(t)&&t.ownerSVGElement&&t.getBBox(),i=!Gt&&s.boxSizing==="border-box",o=jt.test(s.writingMode||""),a=!r&&ze.test(s.overflowY||""),n=!r&&ze.test(s.overflowX||""),c=r?0:m(s.paddingTop),l=r?0:m(s.paddingRight),h=r?0:m(s.paddingBottom),d=r?0:m(s.paddingLeft),H=r?0:m(s.borderTopWidth),p=r?0:m(s.borderRightWidth),E=r?0:m(s.borderBottomWidth),Te=r?0:m(s.borderLeftWidth),P=d+l,oe=c+h,_=Te+p,G=H+E,R=n?t.offsetHeight-G-t.clientHeight:0,ae=a?t.offsetWidth-_-t.clientWidth:0,b=i?P+_:0,w=i?oe+G:0,D=r?r.width:m(s.width)-b-ae,V=r?r.height:m(s.height)-w-R,Ie=D+P+ae+_,X=V+oe+R+G,ne=$({devicePixelContentBoxSize:L(Math.round(D*devicePixelRatio),Math.round(V*devicePixelRatio),o),borderBoxSize:L(Ie,X,o),contentBoxSize:L(D,V,o),contentRect:new Re(d,c,D,V)});return J.set(t,ne),ne},De=function(t,e,s){var r=He(t,s),i=r.borderBoxSize,o=r.contentBoxSize,a=r.devicePixelContentBoxSize;switch(e){case B.DEVICE_PIXEL_CONTENT_BOX:return a;case B.BORDER_BOX:return i;default:return o}},Xt=function(){function t(e){var s=He(e);this.target=e,this.contentRect=s.contentRect,this.borderBoxSize=$([s.borderBoxSize]),this.contentBoxSize=$([s.contentBoxSize]),this.devicePixelContentBoxSize=$([s.devicePixelContentBoxSize])}return t}(),Ve=function(t){if(Le(t))return 1/0;for(var e=0,s=t.parentNode;s;)e+=1,s=s.parentNode;return e},qt=function(){var t=1/0,e=[];C.forEach(function(a){if(a.activeTargets.length!==0){var n=[];a.activeTargets.forEach(function(l){var h=new Xt(l.target),d=Ve(l.target);n.push(h),l.lastReportedSize=De(l.target,l.observedBox),d<t&&(t=d)}),e.push(function(){a.callback.call(a.observer,n,a.observer)}),a.activeTargets.splice(0,a.activeTargets.length)}});for(var s=0,r=e;s<r.length;s++){var i=r[s];i()}return t},Be=function(t){C.forEach(function(s){s.activeTargets.splice(0,s.activeTargets.length),s.skippedTargets.splice(0,s.skippedTargets.length),s.observationTargets.forEach(function(i){i.isActive()&&(Ve(i.target)>t?s.activeTargets.push(i):s.skippedTargets.push(i))})})},Jt=function(){var t=0;for(Be(t);Mt();)t=qt(),Be(t);return Wt()&&Ft(),t>0},le,Me=[],Kt=function(){return Me.splice(0).forEach(function(t){return t()})},Zt=function(t){if(!le){var e=0,s=document.createTextNode(""),r={characterData:!0};new MutationObserver(function(){return Kt()}).observe(s,r),le=function(){s.textContent=""+(e?e--:e++)}}Me.push(t),le()},Qt=function(t){Zt(function(){requestAnimationFrame(t)})},K=0,es=function(){return!!K},ts=250,ss={attributes:!0,characterData:!0,childList:!0,subtree:!0},We=["resize","load","transitionend","animationend","animationstart","animationiteration","keyup","keydown","mouseup","mousedown","mouseover","mouseout","blur","focus"],Fe=function(t){return t===void 0&&(t=0),Date.now()+t},he=!1,rs=function(){function t(){var e=this;this.stopped=!0,this.listener=function(){return e.schedule()}}return t.prototype.run=function(e){var s=this;if(e===void 0&&(e=ts),!he){he=!0;var r=Fe(e);Qt(function(){var i=!1;try{i=Jt()}finally{if(he=!1,e=r-Fe(),!es())return;i?s.run(1e3):e>0?s.run(e):s.start()}})}},t.prototype.schedule=function(){this.stop(),this.run()},t.prototype.observe=function(){var e=this,s=function(){return e.observer&&e.observer.observe(document.body,ss)};document.body?s():M.addEventListener("DOMContentLoaded",s)},t.prototype.start=function(){var e=this;this.stopped&&(this.stopped=!1,this.observer=new MutationObserver(this.listener),this.observe(),We.forEach(function(s){return M.addEventListener(s,e.listener,!0)}))},t.prototype.stop=function(){var e=this;this.stopped||(this.observer&&this.observer.disconnect(),We.forEach(function(s){return M.removeEventListener(s,e.listener,!0)}),this.stopped=!0)},t}(),de=new rs,Ue=function(t){!K&&t>0&&de.start(),K+=t,!K&&de.stop()},is=function(t){return!ce(t)&&!Yt(t)&&getComputedStyle(t).display==="inline"},os=function(){function t(e,s){this.target=e,this.observedBox=s||B.CONTENT_BOX,this.lastReportedSize={inlineSize:0,blockSize:0}}return t.prototype.isActive=function(){var e=De(this.target,this.observedBox,!0);return is(this.target)&&(this.lastReportedSize=e),this.lastReportedSize.inlineSize!==e.inlineSize||this.lastReportedSize.blockSize!==e.blockSize},t}(),as=function(){function t(e,s){this.activeTargets=[],this.skippedTargets=[],this.observationTargets=[],this.observer=e,this.callback=s}return t}(),Z=new WeakMap,Ye=function(t,e){for(var s=0;s<t.length;s+=1)if(t[s].target===e)return s;return-1},Q=function(){function t(){}return t.connect=function(e,s){var r=new as(e,s);Z.set(e,r)},t.observe=function(e,s,r){var i=Z.get(e),o=i.observationTargets.length===0;Ye(i.observationTargets,s)<0&&(o&&C.push(i),i.observationTargets.push(new os(s,r&&r.box)),Ue(1),de.schedule())},t.unobserve=function(e,s){var r=Z.get(e),i=Ye(r.observationTargets,s),o=r.observationTargets.length===1;i>=0&&(o&&C.splice(C.indexOf(r),1),r.observationTargets.splice(i,1),Ue(-1))},t.disconnect=function(e){var s=this,r=Z.get(e);r.observationTargets.slice().forEach(function(i){return s.unobserve(e,i.target)}),r.activeTargets.splice(0,r.activeTargets.length)},t}(),ns=function(){function t(e){if(arguments.length===0)throw new TypeError("Failed to construct 'ResizeObserver': 1 argument required, but only 0 present.");if(typeof e!="function")throw new TypeError("Failed to construct 'ResizeObserver': The callback provided as parameter 1 is not a function.");Q.connect(this,e)}return t.prototype.observe=function(e,s){if(arguments.length===0)throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': 1 argument required, but only 0 present.");if(!Oe(e))throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': parameter 1 is not of type 'Element");Q.observe(this,e,s)},t.prototype.unobserve=function(e){if(arguments.length===0)throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': 1 argument required, but only 0 present.");if(!Oe(e))throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': parameter 1 is not of type 'Element");Q.unobserve(this,e)},t.prototype.disconnect=function(){Q.disconnect(this)},t.toString=function(){return"function ResizeObserver () { [polyfill code] }"},t}();function cs(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 ls(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 hs(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 ds(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 ps(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}const x=typeof window!="undefined",je=x&&!("onscroll"in window)||typeof navigator!="undefined"&&/(gle|ing|ro)bot|crawl|spider/i.test(navigator.userAgent),Ge=x&&"IntersectionObserver"in window,Xe=x&&"classList"in document.createElement("p"),qe=x&&window.devicePixelRatio>1,us={elements_selector:".lazy",container:je||x?document:null,threshold:300,thresholds:null,data_src:"src",data_srcset:"srcset",data_sizes:"sizes",data_bg:"bg",data_bg_hidpi:"bg-hidpi",data_bg_multi:"bg-multi",data_bg_multi_hidpi:"bg-multi-hidpi",data_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},Je=t=>Object.assign({},us,t),Ke=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)},gs=(t,e)=>{if(!!e)if(!e.length)Ke(t,e);else for(let s=0,r;r=e[s];s+=1)Ke(t,r)},y="src",pe="srcset",ue="sizes",Ze="poster",W="llOriginalAttrs",Qe="data",ge="loading",et="loaded",tt="applied",fs="entered",fe="error",st="native",rt="data-",it="ll-status",g=(t,e)=>t.getAttribute(rt+e),vs=(t,e,s)=>{var r=rt+e;if(s===null){t.removeAttribute(r);return}t.setAttribute(r,s)},F=t=>g(t,it),N=(t,e)=>vs(t,it,e),ee=t=>N(t,null),ve=t=>F(t)===null,ws=t=>F(t)===ge,bs=t=>F(t)===fe,we=t=>F(t)===st,ms=[ge,et,tt,fe],Ss=t=>ms.indexOf(F(t))>=0,T=(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)}},O=(t,e)=>{if(Xe){t.classList.add(e);return}t.className+=(t.className?" ":"")+e},S=(t,e)=>{if(Xe){t.classList.remove(e);return}t.className=t.className.replace(new RegExp("(^|\\s+)"+e+"(\\s+|$)")," ").replace(/^\s+/,"").replace(/\s+$/,"")},ys=t=>{t.llTempImage=document.createElement("IMG")},Es=t=>{delete t.llTempImage},ot=t=>t.llTempImage,te=(t,e)=>{if(!e)return;const s=e._observer;!s||s.unobserve(t)},xs=t=>{t.disconnect()},Ts=(t,e,s)=>{e.unobserve_entered&&te(t,s)},be=(t,e)=>{!t||(t.loadingCount+=e)},Is=t=>{!t||(t.toLoadCount-=1)},at=(t,e)=>{!t||(t.toLoadCount=e)},_s=t=>t.loadingCount>0,Cs=t=>t.toLoadCount>0,nt=t=>{let e=[];for(let s=0,r;r=t.children[s];s+=1)r.tagName==="SOURCE"&&e.push(r);return e},me=(t,e)=>{const s=t.parentNode;if(!s||s.tagName!=="PICTURE")return;nt(s).forEach(e)},ct=(t,e)=>{nt(t).forEach(e)},se=[y],lt=[y,Ze],U=[y,pe,ue],ht=[Qe],re=t=>!!t[W],dt=t=>t[W],pt=t=>delete t[W],z=(t,e)=>{if(re(t))return;const s={};e.forEach(r=>{s[r]=t.getAttribute(r)}),t[W]=s},$s=t=>{re(t)||(t[W]={backgroundImage:t.style.backgroundImage})},Ns=(t,e,s)=>{if(!s){t.removeAttribute(e);return}t.setAttribute(e,s)},k=(t,e)=>{if(!re(t))return;const s=dt(t);e.forEach(r=>{Ns(t,r,s[r])})},ks=t=>{if(!re(t))return;const e=dt(t);t.style.backgroundImage=e.backgroundImage},ut=(t,e,s)=>{O(t,e.class_applied),N(t,tt),s&&(e.unobserve_completed&&te(t,e),T(e.callback_applied,t,s))},gt=(t,e,s)=>{O(t,e.class_loading),N(t,ge),s&&(be(s,1),T(e.callback_loading,t,s))},I=(t,e,s)=>{!s||t.setAttribute(e,s)},ft=(t,e)=>{I(t,ue,g(t,e.data_sizes)),I(t,pe,g(t,e.data_srcset)),I(t,y,g(t,e.data_src))},Ps=(t,e)=>{me(t,s=>{z(s,U),ft(s,e)}),z(t,U),ft(t,e)},Rs=(t,e)=>{z(t,se),I(t,y,g(t,e.data_src))},Ls=(t,e)=>{ct(t,s=>{z(s,se),I(s,y,g(s,e.data_src))}),z(t,lt),I(t,Ze,g(t,e.data_poster)),I(t,y,g(t,e.data_src)),t.load()},Os=(t,e)=>{z(t,ht),I(t,Qe,g(t,e.data_src))},zs=(t,e,s)=>{const r=g(t,e.data_bg),i=g(t,e.data_bg_hidpi),o=qe&&i?i:r;!o||(t.style.backgroundImage=`url("${o}")`,ot(t).setAttribute(y,o),gt(t,e,s))},As=(t,e,s)=>{const r=g(t,e.data_bg_multi),i=g(t,e.data_bg_multi_hidpi),o=qe&&i?i:r;!o||(t.style.backgroundImage=o,ut(t,e,s))},Hs=(t,e,s)=>{const r=g(t,e.data_bg_set);if(!r)return;const i=r.split("|");let o=i.map(a=>`image-set(${a})`);t.style.backgroundImage=o.join(),t.style.backgroundImage===""&&(o=i.map(a=>`-webkit-image-set(${a})`),t.style.backgroundImage=o.join()),ut(t,e,s)},vt={IMG:Ps,IFRAME:Rs,VIDEO:Ls,OBJECT:Os},Ds=(t,e)=>{const s=vt[t.tagName];!s||s(t,e)},Vs=(t,e,s)=>{const r=vt[t.tagName];!r||(r(t,e),gt(t,e,s))},Bs=["IMG","IFRAME","VIDEO","OBJECT"],Ms=t=>Bs.indexOf(t.tagName)>-1,wt=(t,e)=>{e&&!_s(e)&&!Cs(e)&&T(t.callback_finish,e)},bt=(t,e,s)=>{t.addEventListener(e,s),t.llEvLisnrs[e]=s},Ws=(t,e,s)=>{t.removeEventListener(e,s)},Se=t=>!!t.llEvLisnrs,Fs=(t,e,s)=>{Se(t)||(t.llEvLisnrs={});const r=t.tagName==="VIDEO"?"loadeddata":"load";bt(t,r,e),bt(t,"error",s)},ye=t=>{if(!Se(t))return;const e=t.llEvLisnrs;for(let s in e){const r=e[s];Ws(t,s,r)}delete t.llEvLisnrs},mt=(t,e,s)=>{Es(t),be(s,-1),Is(s),S(t,e.class_loading),e.unobserve_completed&&te(t,s)},Us=(t,e,s,r)=>{const i=we(e);mt(e,s,r),O(e,s.class_loaded),N(e,et),T(s.callback_loaded,e,r),i||wt(s,r)},Ys=(t,e,s,r)=>{const i=we(e);mt(e,s,r),O(e,s.class_error),N(e,fe),T(s.callback_error,e,r),s.restore_on_error&&k(e,U),i||wt(s,r)},Ee=(t,e,s)=>{const r=ot(t)||t;if(Se(r))return;Fs(r,a=>{Us(a,t,e,s),ye(r)},a=>{Ys(a,t,e,s),ye(r)})},js=(t,e,s)=>{ys(t),Ee(t,e,s),$s(t),zs(t,e,s),As(t,e,s),Hs(t,e,s)},Gs=(t,e,s)=>{Ee(t,e,s),Vs(t,e,s)},xe=(t,e,s)=>{Ms(t)?Gs(t,e,s):js(t,e,s)},Xs=(t,e,s)=>{t.setAttribute("loading","lazy"),Ee(t,e,s),Ds(t,e),N(t,st)},St=t=>{t.removeAttribute(y),t.removeAttribute(pe),t.removeAttribute(ue)},qs=t=>{me(t,e=>{St(e)}),St(t)},yt=t=>{me(t,e=>{k(e,U)}),k(t,U)},Js={IMG:yt,IFRAME:t=>{k(t,se)},VIDEO:t=>{ct(t,e=>{k(e,se)}),k(t,lt),t.load()},OBJECT:t=>{k(t,ht)}},Ks=t=>{const e=Js[t.tagName];if(!e){ks(t);return}e(t)},Zs=(t,e)=>{ve(t)||we(t)||(S(t,e.class_entered),S(t,e.class_exited),S(t,e.class_applied),S(t,e.class_loading),S(t,e.class_loaded),S(t,e.class_error))},Qs=(t,e)=>{Ks(t),Zs(t,e),ee(t),pt(t)},er=(t,e,s,r)=>{!s.cancel_on_exit||!ws(t)||t.tagName==="IMG"&&(ye(t),qs(t),yt(t),S(t,s.class_loading),be(r,-1),ee(t),T(s.callback_cancel,t,e,r))},tr=(t,e,s,r)=>{const i=Ss(t);N(t,fs),O(t,s.class_entered),S(t,s.class_exited),Ts(t,s,r),T(s.callback_enter,t,e,r),!i&&xe(t,s,r)},sr=(t,e,s,r)=>{ve(t)||(O(t,s.class_exited),er(t,e,s,r),T(s.callback_exit,t,e,r))},rr=["IMG","IFRAME","VIDEO"],Et=t=>t.use_native&&"loading"in HTMLImageElement.prototype,ir=(t,e,s)=>{t.forEach(r=>{rr.indexOf(r.tagName)!==-1&&Xs(r,e,s)}),at(s,0)},or=t=>t.isIntersecting||t.intersectionRatio>0,ar=t=>({root:t.container===document?null:t.container,rootMargin:t.thresholds||t.threshold+"px"}),nr=(t,e,s)=>{t.forEach(r=>or(r)?tr(r.target,r,e,s):sr(r.target,r,e,s))},cr=(t,e)=>{e.forEach(s=>{t.observe(s)})},lr=(t,e)=>{xs(t),cr(t,e)},hr=(t,e)=>{!Ge||Et(t)||(e._observer=new IntersectionObserver(s=>{nr(s,t,e)},ar(t)))},xt=t=>Array.prototype.slice.call(t),ie=t=>t.container.querySelectorAll(t.elements_selector),dr=t=>xt(t).filter(ve),pr=t=>bs(t),ur=t=>xt(t).filter(pr),Tt=(t,e)=>dr(t||ie(e)),gr=(t,e)=>{ur(ie(t)).forEach(r=>{S(r,t.class_error),ee(r)}),e.update()},fr=(t,e)=>{!x||(e._onlineHandler=()=>{gr(t,e)},window.addEventListener("online",e._onlineHandler))},vr=t=>{!x||window.removeEventListener("online",t._onlineHandler)},Y=function(t,e){const s=Je(t);this._settings=s,this.loadingCount=0,hr(s,this),fr(s,this),this.update(e)};Y.prototype={update:function(t){const e=this._settings,s=Tt(t,e);if(at(this,s.length),je||!Ge){this.loadAll(s);return}if(Et(e)){ir(s,e,this);return}lr(this._observer,s)},destroy:function(){this._observer&&this._observer.disconnect(),vr(this),ie(this._settings).forEach(t=>{pt(t)}),delete this._observer,delete this._settings,delete this._onlineHandler,delete this.loadingCount,delete this.toLoadCount},loadAll:function(t){const e=this._settings;Tt(t,e).forEach(r=>{te(r,this),xe(r,e,this)})},restoreAll:function(){const t=this._settings;ie(t).forEach(e=>{Qs(e,t)})}},Y.load=(t,e)=>{const s=Je(e);xe(t,s)},Y.resetStatus=t=>{ee(t)},x&&gs(Y,window.lazyLoadOptions);class It{constructor({readonly:e,box:s,pages:r,onNewPageIndex:i,onPlay:o}){if(this.pageIndex=0,this.namespace="netless-app-docs-viewer",this.isShowPreview=!1,this.isSmallBox=!1,this.sideEffect=new q,r.length<=0)throw new Error("[DocsViewer] Empty pages.");this.readonly=e,this.box=s,this.pages=r,this.onNewPageIndex=i,this.onPlay=o,this.render()}mount(){this.box.mountContent(this.$content),this.box.mountFooter(this.$footer),this.sideEffect.add(()=>{const e=new Y({container:this.$preview,elements_selector:`.${this.wrapClassName("preview-page>img")}`});return()=>e.destroy()},"preview-lazyload")}unmount(){this.$content.remove(),this.$footer.remove()}setReadonly(e){this.readonly!==e&&(this.readonly=e,this.$content.classList.toggle(this.wrapClassName("readonly"),e),this.$footer.classList.toggle(this.wrapClassName("readonly"),e),this.$pageNumberInput.disabled=e)}destroy(){this.sideEffect.flushAll(),this.unmount()}setPageIndex(e){Number.isNaN(e)||(this.pageIndex=e,this.$pageNumberInput.value=String(e+1))}setSmallBox(e){this.isSmallBox!==e&&(this.isSmallBox=e,this.$footer.classList.toggle(this.wrapClassName("float-footer"),e))}render(){return this.renderContent(),this.renderFooter(),this.$content}renderContent(){if(!this.$content){const e=document.createElement("div");e.className=this.wrapClassName("content"),this.$content=e,this.readonly&&e.classList.add(this.wrapClassName("readonly")),e.appendChild(this.renderPreviewMask()),e.appendChild(this.renderPreview())}return this.$content}renderPreview(){if(!this.$preview){const e=document.createElement("div");e.className=this.wrapClassName("preview")+" tele-fancy-scrollbar",this.$preview=e;const s=this.wrapClassName("preview-page"),r=this.wrapClassName("preview-page-name");this.pages.forEach((i,o)=>{var d;const a=(d=i.thumbnail)!=null?d:i.src.startsWith("ppt")?void 0:i.src;if(!a)return;const n=String(o),c=document.createElement("a");c.className=s+" "+this.wrapClassName(`preview-page-${o}`),c.setAttribute("href","#"),c.dataset.pageIndex=n;const l=document.createElement("span");l.className=r,l.textContent=String(o+1),l.dataset.pageIndex=n;const h=document.createElement("img");h.width=i.width,h.height=i.height,h.dataset.src=a,h.dataset.pageIndex=n,c.appendChild(h),c.appendChild(l),e.appendChild(c)}),this.sideEffect.addEventListener(e,"click",i=>{var a;if(this.readonly)return;const o=(a=i.target.dataset)==null?void 0:a.pageIndex;o&&(i.preventDefault(),i.stopPropagation(),i.stopImmediatePropagation(),this.onNewPageIndex(Number(o)),this.togglePreview(!1))})}return this.$preview}renderPreviewMask(){return this.$previewMask||(this.$previewMask=document.createElement("div"),this.$previewMask.className=this.wrapClassName("preview-mask"),this.sideEffect.addEventListener(this.$previewMask,"click",e=>{this.readonly||e.target===this.$previewMask&&this.togglePreview(!1)})),this.$previewMask}renderFooter(){if(!this.$footer){const e=document.createElement("div");if(e.className=this.wrapClassName("footer"),this.$footer=e,this.readonly&&e.classList.add(this.wrapClassName("readonly")),this.isSmallBox&&e.classList.add(this.wrapClassName("float-footer")),this.pages.some(c=>c.thumbnail||!c.src.startsWith("ppt"))){const c=this.renderFooterBtn("btn-sidebar",cs(this.namespace));this.sideEffect.addEventListener(c,"click",()=>{this.readonly||this.togglePreview()}),this.$footer.appendChild(c)}const s=document.createElement("div");s.className=this.wrapClassName("page-jumps");const r=this.renderFooterBtn("btn-page-back",ls(this.namespace));if(this.sideEffect.addEventListener(r,"click",()=>{this.readonly||this.onNewPageIndex(this.pageIndex-1)}),s.appendChild(r),this.onPlay){const c=this.renderFooterBtn("btn-page-play",ds(this.namespace),ps(this.namespace)),l=()=>{this.sideEffect.setTimeout(()=>{c.classList.toggle(this.wrapClassName("footer-btn-playing"),!1)},500,"returnPlay")};this.sideEffect.addEventListener(c,"click",()=>{this.readonly||(c.classList.toggle(this.wrapClassName("footer-btn-playing"),!0),this.onPlay&&this.onPlay(),l())}),s.appendChild(c)}const i=this.renderFooterBtn("btn-page-next",hs(this.namespace));this.sideEffect.addEventListener(i,"click",()=>{this.readonly||this.onNewPageIndex(this.pageIndex+1)}),s.appendChild(i);const o=document.createElement("div");o.className=this.wrapClassName("page-number");const a=document.createElement("input");a.className=this.wrapClassName("page-number-input"),a.value=String(this.pageIndex+1),this.readonly&&(a.disabled=!0),this.$pageNumberInput=a,this.sideEffect.addEventListener(a,"focus",()=>{a.select()}),this.sideEffect.addEventListener(a,"change",()=>{this.readonly||a.value&&this.onNewPageIndex(Number(a.value)-1)});const n=document.createElement("span");n.textContent=" / "+this.pages.length,o.appendChild(a),o.appendChild(n),this.$footer.appendChild(s),this.$footer.appendChild(o)}return this.$footer}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}togglePreview(e){if(this.isShowPreview=e!=null?e:!this.isShowPreview,this.$content.classList.toggle(this.wrapClassName("preview-active"),this.isShowPreview),this.isShowPreview){const s=this.$preview.querySelector("."+this.wrapClassName(`preview-page-${this.pageIndex}`));s&&this.$preview.scrollTo({top:s.offsetTop-16})}}wrapClassName(e){return`${this.namespace}-${e}`}}function A(t,e,s){return Math.min(Math.max(t,e),s)}function _t(t){return t.touches?t.touches[0]:t}function Ct(t){t.stopPropagation(),t.cancelable&&t.preventDefault()}function $t(t){if(!t)return!1;const e=t.tagName;return e==="INPUT"||e==="TEXTAREA"||e==="SELECT"}class wr{constructor(e){var s,r,i;this.velocity=0,this.paused=!0,this._animationFrameID=null,this._loopTimestamp=0,this.looper=o=>{if(this.paused)return;let a=Math.floor((o-this._loopTimestamp)/1e3*60)+1;for(this._loopTimestamp=o;a-- >0;)this.stepper();this.onStep(this.current,this),!this.paused&&this.current!==this.target&&window.requestAnimationFrame(this.looper)},this.current=(s=e.start)!=null?s:0,this.target=this.current,this.stiffness=(r=e.stiffness)!=null?r:170,this.damping=(i=e.damping)!=null?i:26,this.onStep=e.onStep}stepTo(e,s){this.paused&&s!=null&&(this.current=s),this.paused=!1,this.target=e,this.onStep(this.current,this),this._loopTimestamp=Date.now(),window.requestAnimationFrame(this.looper)}pause(){this.paused=!0}destroy(){this.pause()}stepper(){const e=-this.stiffness*(this.current-this.target),s=-this.damping*this.velocity,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.current=i,this.velocity=r)}}class br{constructor(e,s,r,i){this.scale=1,this.lastVisit=Date.now(),this.pageOffsetY=0,this.pageOffsetX=0,this.visible=!0,this.index=e,this.page=s,this.scale=r,this.pageOffsetX=(i-s.width)/2;const o=document.createElement("div");o.className="page-renderer-page",o.dataset.index=`${e}`,o.style.width=`${s.width*r}px`,o.style.height=`${s.height*r}px`,s.thumbnail&&(o.style.backgroundImage=`url("${s.thumbnail}")`);const a=document.createElement("img");a.className="page-renderer-page-img",a.width=s.width,a.height=s.height,a.src=s.src,o.appendChild(a),this.$page=o}translateY(e){Math.abs(e-this.pageOffsetY)>=.001&&(this.pageOffsetY=e,this.$page.style.transform=`translate(${this.pageOffsetX*this.scale}px, ${this.pageOffsetY*this.scale}px)`)}setScale(e){Math.abs(e-this.scale)>=.001&&(this.scale=e,this.$page.style.width=`${this.page.width*this.scale}px`,this.$page.style.height=`${this.page.height*this.scale}px`,this.$page.style.transform=`translate(${this.pageOffsetX*this.scale}px, ${this.pageOffsetY*this.scale}px)`)}setVisible(e){e!==this.visible&&(this.visible=e,this.$page.style.opacity=e?"1":"0")}}const mr=window.requestIdleCallback||(t=>window.setTimeout(t,5e3)),Sr=window.cancelIdleCallback||window.clearTimeout;class yr{constructor(e,s,r){this.pages=e,this.pagesIntrinsicWidth=s,this.scale=r,this.els=new Map,this.maxElCount=200,this.gcTimer=null,this.gc=()=>{if(this.gcTimer=null,this.els.size>this.maxElCount){const i=[...this.els.values()].sort((o,a)=>a.lastVisit-o.lastVisit);for(let o=Math.floor(this.maxElCount/4);o<i.length;o++)this.els.delete(i[o].index)}}}getEl(e){let s=this.els.get(e);return s||(s=new br(e,this.pages[e],this.scale,this.pagesIntrinsicWidth),this.els.set(e,s)),s.lastVisit=Date.now(),this.els.size>this.maxElCount&&this.gcTimer===null&&(this.gcTimer=mr(this.gc)),s}setScale(e){e!==this.scale&&(this.scale=e,this.els.forEach(s=>s.setScale(e)))}destroy(){this.els.clear(),this.gcTimer!==null&&(Sr(this.gcTimer),this.gcTimer=null)}}class Er{constructor(e){this._hwaTimeout=NaN,this._turnOffHWA=()=>{window.clearTimeout(this._hwaTimeout),this._hwaTimeout=NaN,this.$pages.classList.toggle("is-hwa",!1)},this.pagesScrollTop=e.pagesScrollTop||0,this.containerWidth=e.containerWidth||1,this.containerHeight=e.containerHeight||1,this.pages=e.pages.map(o=>{if(o.thumbnail)return o;try{const a=new URL(o.src);return a.searchParams.set("x-oss-process","image/resize,l_50"),Ce(_e({},o),{thumbnail:a.toString()})}catch(a){return console.error(a),o}});const s=Array(this.pages.length);let r=1/0,i=0;this.pagesIntrinsicHeight=this.pages.reduce((o,a,n)=>(s[n]=o,a.width>i&&(i=a.width),a.height<=r&&(r=a.height),o+a.height),0),this.pagesIntrinsicWidth=i,this.pagesMinHeight=r,this.pagesIntrinsicYs=s,this.scale=this._calcScale(),this.threshold=this._calcThreshold(),this.onPageIndexChanged=e.onPageIndexChanged,this.pageScrollIndex=0,this.pagesScrollTop!==0&&(this.pageScrollIndex=this.findScrollPageIndex(),this.onPageIndexChanged&&this.pageScrollIndex>0&&this.onPageIndexChanged(this.pageScrollIndex)),this.pageElManager=new yr(this.pages,i,this.scale),this.$pages=this.renderPages()}setContainerSize(e,s){e>0&&s>0&&(e!==this.containerWidth||s!==this.containerHeight)&&(this.containerWidth=e,this.containerHeight=s,this.$pages.style.width=`${this.containerWidth}px`,this.$pages.style.height=`${this.containerHeight}px`,this.scale=this._calcScale(),this.threshold=this._calcThreshold(),this.pageElManager.setScale(this.scale),this.$pages.parentElement&&this.pagesScrollTo(this.pagesScrollTop,!0))}renderPages(){const e=document.createElement("div");return e.className="page-renderer-pages-container",e.style.width=`${this.containerWidth}px`,e.style.height=`${this.containerHeight}px`,e}pagesScrollTo(e,s){if(e=A(e,0,this.pagesIntrinsicHeight-this.containerHeight/this.scale),s||Math.abs(e-this.pagesScrollTop)>=.001){this._turnOnHWA(),this.pagesScrollTop=e;const r=this.findScrollPageIndex(),i=Math.max(r-this.threshold,0),o=Math.min(r+this.threshold,this.pages.length-1);for(let a=0;a<this.$pages.children.length;a++){const n=this.$pages.children[a],c=Number(n.dataset.index);c>=i&&c<=o||(n.remove(),a--)}for(let a=i;a<=o;a++){const n=this.pageElManager.getEl(a);n.$page.parentElement!==this.$pages&&this.$pages.appendChild(n.$page),n.translateY(this.pagesIntrinsicYs[a]-this.pagesScrollTop)}r!==this.pageScrollIndex&&(this.pageScrollIndex=r,this.onPageIndexChanged&&this.onPageIndexChanged(r))}}findScrollPageIndex(){for(let e=0;e<this.pagesIntrinsicYs.length;e++)if(this.pagesIntrinsicYs[e]+this.pages[e].height-this.pagesScrollTop>=.001)return e;return this.pagesIntrinsicYs.length-1}mount(e){e.appendChild(this.$pages),this.pagesScrollTo(this.pagesScrollTop,!0)}unmount(){this.$pages.remove()}destroy(){this.unmount(),this.onPageIndexChanged=void 0,this.pageElManager.destroy(),this._hwaTimeout&&(window.clearTimeout(this._hwaTimeout),this._hwaTimeout=NaN)}_calcScale(){return this.containerWidth/this.pagesIntrinsicWidth||1}_calcThreshold(){return A(Math.ceil(this.containerHeight/this.scale/this.pagesMinHeight/2),1,this.pages.length)}_turnOnHWA(){this._hwaTimeout?window.clearTimeout(this._hwaTimeout):this.$pages.classList.toggle("is-hwa",!0),this._hwaTimeout=window.setTimeout(this._turnOffHWA,1e3)}}const xr=30;class Tr{constructor(e){this.sideEffect=new q,this.pagesScrollTop=e.pagesScrollTop||0,this.containerWidth=e.containerWidth||1,this.containerHeight=e.containerHeight||1,this.pagesWidth=e.pagesWidth||1,this.pagesHeight=e.pagesHeight||1,this.scale=this._calcScale(),this.scrollbarMinHeight=e.scrollbarMinHeight||xr,this.scrollbarHeight=this._calcScrollbarHeight(),this.readonly=e.readonly,this.wrapClassName=e.wrapClassName,this.onDragScroll=e.onDragScroll,this.$scrollbar=this.renderScrollbar()}mount(e){e.appendChild(this.$scrollbar),this.pagesScrollTo(this.pagesScrollTop,!0)}unmount(){this.$scrollbar.remove()}setReadonly(e){this.readonly=e}setContainerSize(e,s){e>0&&s>0&&(e!==this.containerWidth||s!==this.containerHeight)&&(this.containerWidth=e,this.containerHeight=s,this.scale=this._calcScale(),this._updateScrollbarHeight(),this.$scrollbar.parentElement&&this.pagesScrollTo(this.pagesScrollTop,!0))}pagesScrollTo(e,s){if(e=A(e,0,this.pagesHeight-this.containerHeight/this.scale),s||Math.abs(e-this.pagesScrollTop)>=.001){this.pagesScrollTop=e;const r=this.pagesScrollTop*this.scale,i=this.pagesHeight*this.scale,o=r/(i-this.containerHeight)*(this.containerHeight-this.scrollbarHeight);window.requestAnimationFrame?window.requestAnimationFrame(()=>{this.$scrollbar.style.transform=`translateY(${o}px)`}):this.$scrollbar.style.transform=`translateY(${o}px)`}}destroy(){this.unmount(),this.onDragScroll=void 0,this.sideEffect.flushAll()}renderScrollbar(){const e=document.createElement("button");e.className=this.wrapClassName("scrollbar"),e.style.minHeight=`${this.scrollbarMinHeight}px`,e.style.height=`${this.scrollbarHeight}px`;const s=r=>{if(this.readonly||r.button!=null&&r.button!==0)return;Ct(r);const i=this.wrapClassName("scrollbar-dragging");e.classList.toggle(i,!0);const o=this.pagesScrollTop,{clientY:a}=_t(r),n=l=>{if(this.readonly)return;const{clientY:h}=_t(l),d=(h-a)/this.scale;Math.abs(d)>0&&this.onDragScroll&&this.onDragScroll(o+d*(this.pagesHeight*this.scale/this.containerHeight))},c=()=>{e.classList.toggle(i,!1),window.removeEventListener("mousemove",n,!0),window.removeEventListener("touchmove",n,!0),window.removeEventListener("mouseup",c,!0),window.removeEventListener("touchend",c,!0),window.removeEventListener("touchcancel",c,!0)};window.addEventListener("mousemove",n,!0),window.addEventListener("touchmove",n,!0),window.addEventListener("mouseup",c,!0),window.addEventListener("touchend",c,!0),window.addEventListener("touchcancel",c,!0)};return this.sideEffect.addEventListener(e,"mousedown",s),this.sideEffect.addEventListener(e,"touchstart",s),e}_calcScale(){return this.containerWidth/this.pagesWidth||1}_calcScrollbarHeight(){return A(this.containerHeight/(this.pagesHeight*this.scale)*this.containerHeight,this.scrollbarMinHeight,this.containerHeight)}_updateScrollbarHeight(){const e=this._calcScrollbarHeight();Math.abs(e-this.scrollbarHeight)>.001&&(this.scrollbarHeight=e,this.$scrollbar.style.height=`${e}px`)}}const Ir=window.ResizeObserver||ns,j=640;class _r{constructor({whiteboardView:e,readonly:s,box:r,pages:i,pageScrollTop:o=0,mountWhiteboard:a,onUserScroll:n,baseScenePath:c,appId:l}){this.sideEffect=new q,this.userScrolling=!1,this.onNewPageIndex=p=>{this.scrollToPage(p)},this.toPdf=async()=>{const p=document.createElement("canvas"),E=p.getContext("2d");if(!E||!this.baseScenePath){this.reportProgress(100,null);return}const Te=`${this.baseScenePath}/1`,P=this.pages[0],{jsPDF:oe}=await import("jspdf"),_=new oe({format:[P.width,P.height],orientation:P.width>P.height?"l":"p",compress:!0});for(const[R,ae]of this.pages.entries()){const{width:b,height:w,src:D}=ae;p.width=b,p.height=w;const V=b>w?"l":"p";R>0&&_.addPage([b,w],V);const Ie=await this.getBase64FromUrl(D),X=document.createElement("img");X.src=Ie,await new Promise(Rr=>X.onload=Rr),E.drawImage(X,0,0);const ne=p.toDataURL("image/jpeg",.6);E.clearRect(0,0,b,w),this.whiteboardView.screenshotToCanvas(E,Te,b,w,{centerX:b/2,centerY:w/2+R*w,scale:1});const Pr=p.toDataURL("image/png");_.addImage(ne,"JPEG",0,0,b,w,"","FAST"),_.addImage(Pr,"PNG",0,0,b,w,"","FAST"),E.clearRect(0,0,b,w),Math.ceil((R+1)/this.pages.length*100)<100&&this.reportProgress(Math.ceil((R+1)/this.pages.length*100),null)}const G=_.output("arraybuffer");this.reportProgress(100,{pdf:G,title:this.box.title})},this.whiteboardView=e,this.readonly=s,this.box=r,this.pages=i,this.baseScenePath=c,this.appId=l,this.mountWhiteboard=a,this._onUserScroll=n;const h=this.debounce(()=>{this.userScrolling=!1,this._onUserScroll&&this._onUserScroll(this.pageRenderer.pagesScrollTop)},{wait:80},"debounce-updateUserScroll");this.updateUserScroll=()=>{this.userScrolling=!0,h()},this.viewer=new It({readonly:s,box:r,pages:i,onNewPageIndex:this.onNewPageIndex});const{width:d,height:H}=this.whiteboardView.size;this.pageRenderer=new Er({pagesScrollTop:o,pages:this.pages,containerWidth:d,containerHeight:H,onPageIndexChanged:this.viewer.setPageIndex.bind(this.viewer)}),this.scrollbar=new Tr({pagesScrollTop:this.pageRenderer.pagesScrollTop,containerWidth:d,containerHeight:H,pagesWidth:this.pageRenderer.pagesIntrinsicWidth,pagesHeight:this.pageRenderer.pagesIntrinsicHeight,readonly:this.readonly,wrapClassName:this.wrapClassName.bind(this),onDragScroll:p=>{this.pageScrollTo(p),this.updateUserScroll()}}),this.pageScrollStepper=new wr({start:this.pageRenderer.pagesScrollTop,onStep:p=>{this.pageScrollTo(p)}}),this.render()}mount(){this.viewer.mount(),this.setupScrollListener();const e=this.debounce(this.renderRatioHeight.bind(this),{wait:80});return this.sideEffect.add(()=>{const s=new Ir(e);return s.observe(this.viewer.$content),()=>s.disconnect()}),this.sideEffect.setTimeout(()=>{this.userScrolling||this.pageScrollTo(this.pageRenderer.pagesScrollTop)},100),this.sideEffect.add(()=>{const s=r=>{r.data.type==="@netless/_request_save_pdf_"&&r.data.appId===this.appId&&this.toPdf().catch(()=>this.reportProgress(100,null))};return window.addEventListener("message",s),()=>{window.removeEventListener("message",s)}}),this}unmount(){return this.viewer.unmount(),this}setReadonly(e){this.readonly!==e&&(this.readonly=e,this.viewer.setReadonly(e),this.scrollbar.setReadonly(e))}destroy(){this.sideEffect.flushAll(),this.pageScrollStepper.destroy(),this._onUserScroll=void 0,this.unmount(),this.viewer.destroy(),this.pageRenderer.destroy(),this.scrollbar.destroy()}syncPageScrollTop(e){!this.userScrolling&&e>=0&&Math.abs(this.pageRenderer.pagesScrollTop-e)>.01&&this.pageScrollStepper.stepTo(e,this.pageRenderer.pagesScrollTop)}render(){this.pageRenderer.mount(this.viewer.$content),this.viewer.$content.appendChild(this.renderWhiteboardView()),this.scrollbar.mount(this.viewer.$content),this.renderRatioHeight()}renderRatioHeight(){const e=this.box.absoluteHeight,s=e<=j;if(this.viewer.setSmallBox(s),s){const r=26/j,i=26/e,o=26/j,a=0,n=Math.max((r+o-(i+a))/2,0);if(this.box.$titleBar){const c=i+n;this.box.$titleBar.style.height=`${c*100}%`}if(this.box.$footer){const c=a+n;this.box.$footer.style.height=`${c*100}%`}}else{if(this.box.$titleBar){const r=Math.max(26/j,26/e);this.box.$titleBar.style.height=`${r*100}%`}if(this.box.$footer){const r=Math.max(26/j,26/e);this.box.$footer.style.height=`${r*100}%`}}}renderWhiteboardView(){return this.$whiteboardView||(this.$whiteboardView=document.createElement("div"),this.$whiteboardView.className=this.wrapClassName("wb-view"),this.mountWhiteboard(this.$whiteboardView),this.sideEffect.addEventListener(this.$whiteboardView,"wheel",e=>{Ct(e),this.readonly||(this.pageScrollTo(this.pageRenderer.pagesScrollTop+e.deltaY),this.updateUserScroll())},{passive:!1,capture:!0}),this.sideEffect.addEventListener(this.$whiteboardView,"touchmove",e=>{this.readonly||e.touches.length<=1||this.updateUserScroll()},{passive:!0,capture:!0})),this.$whiteboardView}scrollTopPageToEl(e){return e*this.pageRenderer.scale}scrollTopElToPage(e){return e/this.pageRenderer.scale}elScrollTo(e){this.pageScrollTo(this.scrollTopElToPage(e))}pageScrollTo(e){const s=this.scrollTopElToPage(this.whiteboardView.size.height/2);this.whiteboardView.moveCamera({centerY:A(e+s,s,this.pageRenderer.pagesIntrinsicHeight-s),animationMode:"immediately"})}scrollToPage(e){if(!this.readonly&&!Number.isNaN(e)){const s=this.pageRenderer.pagesIntrinsicYs[e];s>=0&&(this.pageScrollTo(s+5/this.pageRenderer.scale),this.updateUserScroll())}}setupScrollListener(){this.sideEffect.add(()=>{const e=s=>{const{width:r,height:i}=this.whiteboardView.size;if(r<=0||i<=0)return;const o=s.centerY-this.pageRenderer.containerHeight/this.pageRenderer.scale/2;this.pageRenderer.pagesScrollTo(o),this.scrollbar.pagesScrollTo(o)};return this.whiteboardView.callbacks.on("onCameraUpdated",e),()=>this.whiteboardView.callbacks.off("onCameraUpdated",e)}),this.sideEffect.add(()=>{const e=({width:s,height:r})=>{if(s<=0||r<=0)return;this.pageRenderer.setContainerSize(s,r),this.scrollbar.setContainerSize(s,r);const{pagesIntrinsicWidth:i,pagesIntrinsicHeight:o}=this.pageRenderer;this.whiteboardView.moveCameraToContain({originX:0,originY:this.pageRenderer.pagesScrollTop,width:i,height:r/this.pageRenderer.scale,animationMode:"immediately"}),this.whiteboardView.setCameraBound({damping:1,maxContentMode:()=>this.pageRenderer.scale,minContentMode:()=>this.pageRenderer.scale,centerX:i/2,centerY:o/2,width:i,height:o})};return this.whiteboardView.callbacks.on("onSizeUpdated",e),()=>{this.whiteboardView.callbacks.off("onSizeUpdated",e)}},"whiteboard-size-update"),this.sideEffect.addEventListener(window,"keyup",e=>{if(this.readonly||!this.box.focus||this.box.minimized||$t(e.target))return;let s=null;switch(e.key){case"PageDown":{s=this.pageRenderer.pagesScrollTop+this.pageRenderer.containerHeight/this.pageRenderer.scale;break}case"PageUp":{s=this.pageRenderer.pagesScrollTop-this.pageRenderer.containerHeight/this.pageRenderer.scale;break}case"ArrowDown":{s=this.pageRenderer.pagesScrollTop+this.pageRenderer.containerHeight/4/this.pageRenderer.scale;break}case"ArrowUp":{s=this.pageRenderer.pagesScrollTop-this.pageRenderer.containerHeight/4/this.pageRenderer.scale;break}}s!==null&&(this._onUserScroll?this._onUserScroll(s):(this.pageScrollTo(s),this.updateUserScroll()))},{capture:!0})}debounce(e,s,r){const i=Dt(e,s);return this.sideEffect.addDisposer(()=>i.cancel(),r),i}wrapClassName(e){return"netless-app-docs-viewer-static-"+e}async getBase64FromUrl(e){const r=await(await fetch(e)).blob();return new Promise(i=>{const o=new FileReader;o.readAsDataURL(r),o.onloadend=()=>{const a=o.result;i(a)}})}reportProgress(e,s){window.postMessage({type:"@netless/_result_save_pdf_",appId:this.appId,progress:e,result:s})}}class Cr{constructor({context:e,whiteboardView:s,box:r,pages:i}){this.sideEffect=new q,this.onPlayPPT=()=>{const o=this.context.getRoom();o&&o.pptNextStep()},this._scaleDocsToFitImpl=()=>{const o=this.pages[this.getPageIndex()];o&&(this.whiteboardView.moveCameraToContain({originX:-o.width/2,originY:-o.height/2,width:o.width,height:o.height,animationMode:"immediately"}),this.whiteboardView.setCameraBound({damping:1,maxContentMode:()=>this.whiteboardView.camera.scale,minContentMode:()=>this.whiteboardView.camera.scale,centerX:0,centerY:0,width:o.width,height:o.height}))},this._scaleDocsToFitDebounced=()=>{this.sideEffect.setTimeout(this._scaleDocsToFitImpl,1e3,"_scaleDocsToFitDebounced")},this.scaleDocsToFit=()=>{this._scaleDocsToFitImpl(),this._scaleDocsToFitDebounced()},this.onNewPageIndex=o=>{this.jumpToPage(o,!0)},this.context=e,this.whiteboardView=s,this.box=r,this.pages=i,this.displayer=e.getDisplayer(),this.viewer=new It({readonly:!e.getIsWritable(),box:r,pages:i,onNewPageIndex:this.onNewPageIndex,onPlay:this.onPlayPPT}),this.render(),this.sideEffect.add(()=>{const o=a=>{this.viewer.setReadonly(!a)};return this.context.emitter.on("writableChange",o),()=>this.context.emitter.off("writableChange",o)}),this.sideEffect.add(()=>{const o=a=>{this.jumpToPage(a.index)};return this.context.emitter.on("sceneStateChange",o),()=>this.context.emitter.off("sceneStateChange",o)})}mount(){this.viewer.mount();const e=this.getPageIndex();return e!==0&&this.jumpToPage(e),this.scaleDocsToFit(),this.sideEffect.add(()=>(this.whiteboardView.callbacks.on("onSizeUpdated",this.scaleDocsToFit),()=>{this.whiteboardView.callbacks.off("onSizeUpdated",this.scaleDocsToFit)})),this}unmount(){return this.viewer.unmount(),this}destroy(){this.sideEffect.flushAll(),this.unmount(),this.viewer.destroy()}getPageIndex(){return this.displayer.state.sceneState.index}jumpToPage(e,s){var r,i;if(e=A(e,0,this.pages.length-1),e!==this.getPageIndex()&&this.context.getIsWritable()){const o=this.context.getInitScenePath(),a=(i=(r=this.context.getScenes())==null?void 0:r[e])==null?void 0:i.name;o&&a&&this.context.setScenePath(`${o}/${a}`),this.scaleDocsToFit()}if(e!==this.viewer.pageIndex&&this.viewer.setPageIndex(e),s){const o=this.context.getRoom();if(o){const a=o.state.globalState.__pptState;o.setGlobalState({__pptState:a&&{uuid:a.uuid,pageIndex:e,disableAutoPlay:a.disableAutoPlay}})}}}render(){this.viewer.$content.appendChild(this.renderMask()),this.viewer.$content.appendChild(this.renderWhiteboardView()),this.sideEffect.addEventListener(window,"keydown",e=>{var s;if(this.box.focus&&!$t(e.target))switch(e.key){case"ArrowUp":case"ArrowLeft":{this.jumpToPage(this.getPageIndex()-1,!0);break}case"ArrowRight":case"ArrowDown":{(s=this.context.getRoom())==null||s.pptNextStep();break}}})}renderMask(){if(!this.$mask){const e=document.createElement("div");e.className=this.wrapClassName("mask"),this.$mask=e;const s=document.createElement("button");s.className=this.wrapClassName("back");const r=document.createElement("button");r.className=this.wrapClassName("next")}return this.$mask}renderWhiteboardView(){return this.$whiteboardView||(this.$whiteboardView=document.createElement("div"),this.$whiteboardView.className=this.wrapClassName("wb-view"),this.sideEffect.addEventListener(this.$whiteboardView,"click",e=>{var r;const s=this.context.getRoom();if(s&&s.state.memberState.currentApplianceName==="clicker"){for(let i=e.target;i;i=i.parentElement)if((r=i.classList)!=null&&r.contains("ppt-event-source"))return;s.pptNextStep()}}),this.context.mountView(this.$whiteboardView)),this.$whiteboardView}wrapClassName(e){return"netless-app-docs-viewer-dynamic-"+e}}const $r={kind:"DocsViewer",setup(t){const e=t.getBox(),s=t.getScenes();if(!s)throw new Error("[Docs Viewer]: scenes not found.");const r=t.getView();if(!r)throw new Error("[Docs Viewer]: no whiteboard view.");const i=s.map(({ppt:o})=>o?{width:o.width,height:o.height,src:o.src,thumbnail:o.previewURL}:null).filter(o=>Boolean(o));if(i.length<=0)throw new Error("[Docs Viewer]: empty scenes.");e.mountStyles(u),i[0].src.startsWith("ppt")?kr(t,r,e,i):Nr(t,r,e,i)}};function Nr(t,e,s,r){var o;e.disableCameraTransform=!t.getIsWritable();const i=new _r({whiteboardView:e,readonly:!t.getIsWritable(),box:s,pages:r,pageScrollTop:(o=t.getAttributes())==null?void 0:o.pageScrollTop,mountWhiteboard:t.mountView.bind(t),onUserScroll:a=>{var n;((n=t.getAttributes())==null?void 0:n.pageScrollTop)!==a&&!s.readonly&&t.updateAttributes(["pageScrollTop"],a)},baseScenePath:t.getInitScenePath(),appId:t.appId}).mount();t.emitter.on("attributesUpdate",a=>{a&&a.pageScrollTop!=null&&i.syncPageScrollTop(a.pageScrollTop)}),t.emitter.on("writableChange",a=>{i.setReadonly(!a),e.disableCameraTransform=!a})}function kr(t,e,s,r){e.disableCameraTransform=!0;const i=new Cr({context:t,whiteboardView:e,box:s,pages:r}).mount();t.mountView(i.$whiteboardView),t.isAddApp&&e.callbacks.once("onSizeUpdated",({width:o,height:a})=>{if(r.length>0&&s.state!=="maximized"){const{width:n,height:c}=r[0],h=c/n*o-a;h!==0&&t.getIsWritable()&&t.emitter.emit("setBoxSize",{width:s.width,height:s.height+h/s.containerRect.height})}})}return f.default=$r,Object.defineProperties(f,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),f}({}); | ||
//# sourceMappingURL=main.iife.js.map |
export declare function clamp(value: number, min: number, max: number): number; | ||
export declare function flattenEvent(ev: MouseEvent | TouchEvent): MouseEvent | Touch; | ||
export declare function preventEvent(ev: Event): void; | ||
export declare function isEditable(el: EventTarget | null): boolean; |
{ | ||
"name": "@netless/app-docs-viewer", | ||
"version": "0.2.12", | ||
"version": "0.2.13", | ||
"description": "Netless App Docs Viewer", | ||
@@ -18,8 +18,2 @@ "repository": "netless-io/netless-app", | ||
], | ||
"scripts": { | ||
"types": "cross-env NODE_ENV=production tsc --declaration --emitDeclarationOnly --outDir dist", | ||
"build": "vite build && npm run types", | ||
"build:dev": "vite build --mode development && npm run types", | ||
"cleanup": "rimraf ./dist" | ||
}, | ||
"dependencies": { | ||
@@ -32,4 +26,4 @@ "@juggle/resize-observer": "^3.3.1", | ||
"jspdf": "2.5.1", | ||
"@netless/app-shared": "workspace:*", | ||
"side-effect-manager": "^1.1.0" | ||
"side-effect-manager": "^1.1.0", | ||
"@netless/app-shared": "0.1.2" | ||
}, | ||
@@ -43,3 +37,9 @@ "peerDependencies": { | ||
} | ||
}, | ||
"scripts": { | ||
"types": "cross-env NODE_ENV=production tsc --declaration --emitDeclarationOnly --outDir dist", | ||
"build": "vite build && npm run types", | ||
"build:dev": "vite build --mode development && npm run types", | ||
"cleanup": "rimraf ./dist" | ||
} | ||
} | ||
} |
@@ -12,3 +12,3 @@ import type { | ||
import { DocsViewer } from "../DocsViewer"; | ||
import { clamp } from "../utils/helpers"; | ||
import { clamp, isEditable } from "../utils/helpers"; | ||
@@ -146,3 +146,3 @@ export interface DynamicDocsViewerConfig { | ||
this.sideEffect.addEventListener(window, "keydown", ev => { | ||
if (this.box.focus) { | ||
if (this.box.focus && !isEditable(ev.target)) { | ||
switch (ev.key) { | ||
@@ -149,0 +149,0 @@ case "ArrowUp": |
@@ -9,3 +9,3 @@ import type { AnimationMode, ReadonlyTeleBox } from "@netless/window-manager"; | ||
import { DocsViewer } from "../DocsViewer"; | ||
import { clamp, preventEvent } from "../utils/helpers"; | ||
import { clamp, isEditable, preventEvent } from "../utils/helpers"; | ||
import { Stepper } from "./stepper"; | ||
@@ -378,8 +378,2 @@ import { PageRenderer } from "../PageRenderer"; | ||
const isEditable = (el: EventTarget | null) => { | ||
if (!el) return false; | ||
const tagName = (el as HTMLElement).tagName; | ||
return tagName === "INPUT" || tagName === "TEXTAREA" || tagName === "SELECT"; | ||
}; | ||
this.sideEffect.addEventListener( | ||
@@ -386,0 +380,0 @@ window, |
@@ -15,1 +15,7 @@ export function clamp(value: number, min: number, max: number): number { | ||
} | ||
export function isEditable(el: EventTarget | null) { | ||
if (!el) return false; | ||
const tagName = (el as HTMLElement).tagName; | ||
return tagName === "INPUT" || tagName === "TEXTAREA" || tagName === "SELECT"; | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
888766
54
5425
4
4