vendor: 8,331 bytes, lines 1-16
1import{n as Y,aD as ut,Z as N,r as d,j as o,O as Q,l as mt,m as xt,t as R,S as K,a1 as ft,X as J,a2 as wt,a3 as yt}from"./index-hXw6ftrS.js";import{p as tt}from"./pdf-DT4xJEv6.js";import{I as Pt}from"./input-CGBE-TqA.js";import{C as St}from"./chevron-up-CHrIJPHc.js";import{Z as bt}from"./zoom-in-DPD55mqx.js";/** 2 * @license lucide-react v0.462.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const vt=Y("Maximize2",[["polyline",{points:"15 3 21 3 21 9",key:"mznyad"}],["polyline",{points:"9 21 3 21 3 15",key:"1avn1i"}],["line",{x1:"21",x2:"14",y1:"3",y2:"10",key:"ota7mn"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);/** 7 * @license lucide-react v0.462.0 - ISC 8 * 9 * This source code is licensed under the ISC license. 10 * See the LICENSE file in the root directory of this source tree. 11 */const Ct=Y("Minimize2",[["polyline",{points:"4 14 10 14 10 20",key:"11kfnr"}],["polyline",{points:"20 10 14 10 14 4",key:"rlmsce"}],["line",{x1:"14",x2:"21",y1:"10",y2:"3",key:"o5lafz"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);/** 12 * @license lucide-react v0.462.0 - ISC 13 * 14 * This source code is licensed under the ISC license. 15 * See the LICENSE file in the root directory of this source tree. 16 */const It=Y("ZoomOut",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]);var Z={exports:{}};(function(c,T){(function(b,w){w(T)})(ut,function(b){class w{constructor(t,e){this.state={angle:0,area:[],position:{x:0,y:0},hardAngle:0,hardDrawingAngle:0},this.createdDensity=e,this.nowDrawingDensity=this.createdDensity,this.render=t}setDensity(t){this.createdDensity=t,this.nowDrawingDensity=t}setDrawingDensity(t){this.nowDrawingDensity=t}setPosition(t){this.state.position=t}setAngle(t){this.state.angle=t}setArea(t){this.state.area=t}setHardDrawingAngle(t){this.state.hardDrawingAngle=t}setHardAngle(t){this.state.hardAngle=t,this.state.hardDrawingAngle=t}setOrientation(t){this.orientation=t}getDrawingDensity(){return this.nowDrawingDensity}getDensity(){return this.createdDensity}getHardAngle(){return this.state.hardAngle}}class x extends w{constructor(t,e,i){super(t,i),this.image=null,this.isLoad=!1,this.loadingAngle=0,this.image=new Image,this.image.src=e}draw(t){const e=this.render.getContext(),i=this.render.convertToGlobal(this.state.position),s=this.render.getRect().pageWidth,n=this.render.getRect().height;e.save(),e.translate(i.x,i.y),e.beginPath();for(let a of this.state.area)a!==null&&(a=this.render.convertToGlobal(a),e.lineTo(a.x-i.x,a.y-i.y));e.rotate(this.state.angle),e.clip(),this.isLoad?e.drawImage(this.image,0,0,s,n):this.drawLoader(e,{x:0,y:0},s,n),e.restore()}simpleDraw(t){const e=this.render.getRect(),i=this.render.getContext(),s=e.pageWidth,n=e.height,a=t===1?e.left+e.pageWidth:e.left,h=e.top;this.isLoad?i.drawImage(this.image,a,h,s,n):this.drawLoader(i,{x:a,y:h},s,n)}drawLoader(t,e,i,s){t.beginPath(),t.strokeStyle="rgb(200, 200, 200)",t.fillStyle="rgb(255, 255, 255)",t.lineWidth=1,t.rect(e.x+1,e.y+1,i-1,s-1),t.stroke(),t.fill();const n={x:e.x+i/2,y:e.y+s/2};t.beginPath(),t.lineWidth=10,t.arc(n.x,n.y,20,this.loadingAngle,3*Math.PI/2+this.loadingAngle),t.stroke(),t.closePath(),this.loadingAngle+=.07,this.loadingAngle>=2*Math.PI&&(this.loadingAngle=0)}load(){this.isLoad||(this.image.onload=()=>{this.isLoad=!0})}newTemporaryCopy(){return this}getTemporaryCopy(){return this}hideTemporaryCopy(){}}class C{constructor(t,e){this.pages=[],this.currentPageIndex=0,this.currentSpreadIndex=0,this.landscapeSpread=[],this.portraitSpread=[],this.render=e,this.app=t,this.currentPageIndex=0,this.isShowCover=this.app.getSettings().showCover}destroy(){this.pages=[]}createSpread(){this.landscapeSpread=[],this.portraitSpread=[];for(let e=0;e<this.pages.length;e++)this.portraitSpread.push([e]);let t=0;this.isShowCover&&(this.pages[0].setDensity("hard"),this.landscapeSpread.push([t]),t++);for(let e=t;e<this.pages.length;e+=2)e<this.pages.length-1?this.landscapeSpread.push([e,e+1]):(this.landscapeSpread.push([e]),this.pages[e].setDensity("hard"))}getSpread(){return this.render.getOrientation()==="landscape"?this.landscapeSpread:this.portraitSpread}getSpreadIndexByPage(t){const e=this.getSpread();for(let i=0;i<e.length;i++)if(t===e[i][0]||t===e[i][1])return i;return null}getPageCount(){return this.pages.length}getPages(){return this.pages}getPage(t){if(t>=0&&t<this.pages.length)return this.pages[t];throw new Error("Invalid page number")}nextBy(t){const e=this.pages.indexOf(t);return e<this.pages.length-1?this.pages[e+1]:null}prevBy(t){const e=this.pages.indexOf(t);return e>0?this.pages[e-1]:null}getFlippingPage(t){const e=this.currentSpreadIndex;if(this.render.getOrientation()==="portrait")return t===0?this.pages[e].newTemporaryCopy():this.pages[e-1];{const i=t===0?this.getSpread()[e+1]:this.getSpread()[e-1];return i.length===1||t===0?this.pages[i[0]]:this.pages[i[1]]}}getBottomPage(t){const e=this.currentSpreadIndex;if(this.render.getOrientation()==="portrait")return t===0?this.pages[e+1]:this.pages[e-1];{const i=t===0?this.getSpread()[e+1]:this.getSpread()[e-1];return i.length===1?this.pages[i[0]]:t===0?this.pages[i[1]]:this.pages[i[0]]}}showNext(){this.currentSpreadIndex<this.getSpread().length&&(this.currentSpreadIndex++,this.showSpread())}showPrev(){this.currentSpreadIndex>0&&(this.currentSpreadIndex--,this.showSpread())}getCurrentPageIndex(){return this.currentPageIndex}show(t=null){if(t===null&&(t=this.currentPageIndex),t<0||t>=this.pages.length)return;const e=this.getSpreadIndexByPage(t);e!==null&&(this.currentSpreadIndex=e,this.showSpread())}getCurrentSpreadIndex(){return this.currentSpreadIndex}setCurrentSpreadIndex(t){if(!(t>=0&&t<this.getSpread().length))throw new Error("Invalid page");this.currentSpreadIndex=t}showSpread(){const t=this.getSpread()[this.currentSpreadIndex];t.length===2?(this.render.setLeftPage(this.pages[t[0]]),this.render.setRightPage(this.pages[t[1]])):this.render.getOrientation()==="landscape"&&t[0]===this.pages.length-1?(this.render.setLeftPage(this.pages[t[0]]),this.render.setRightPage(null)):(this.render.setLeftPage(null),this.render.setRightPage(this.pages[t[0]])),this.currentPageIndex=t[0],this.app.updatePageIndex(this.currentPageIndex)}}class I extends C{constructor(t,e,i){super(t,e),this.imagesHref=i}load(){for(const t of this.imagesHref){const e=new x(this.render,t,"soft");e.load(),this.pages.push(e)}this.createSpread()}}class p{static GetDistanceBetweenTwoPoint(t,e){return t===null||e===null?1/0:Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}static GetSegmentLength(t){return p.GetDistanceBetweenTwoPoint(t[0],t[1])}static GetAngleBetweenTwoLine(t,e){const i=t[0].y-t[1].y,s=e[0].y-e[1].y,n=t[1].x-t[0].x,a=e[1].x-e[0].x;return Math.acos((i*s+n*a)/(Math.sqrt(i*i+n*n)*Math.sqrt(s*s+a*a)))}static PointInRect(t,e){return e===null?null:e.x>=t.left&&e.x<=t.width+t.left&&e.y>=t.top&&e.y<=t.top+t.height?e:null}static GetRotatedPoint(t,e,i){return{x:t.x*Math.cos(i)+t.y*Math.sin(i)+e.x,y:t.y*Math.cos(i)-t.x*Math.sin(i)+e.y}}static LimitPointToCircle(t,e,i){if(p.GetDistanceBetweenTwoPoint(t,i)<=e)return i;const s=t.x,n=t.y,a=i.x,h=i.y;let l=Math.sqrt(Math.pow(e,2)*Math.pow(s-a,2)/(Math.pow(s-a,2)+Math.pow(n-h,2)))+s;i.x<0&&(l*=-1);let u=(l-s)*(n-h)/(s-a)+n;return s-a+n===0&&(u=e),{x:l,y:u}}static GetIntersectBetweenTwoSegment(t,e,i){return p.PointInRect(t,p.GetIntersectBeetwenTwoLine(e,i))}static GetIntersectBeetwenTwoLine(t,e){const i=t[0].y-t[1].y,s=e[0].y-e[1].y,n=t[1].x-t[0].x,a=e[1].x-e[0].x,h=t[0].x*t[1].y-t[1].x*t[0].y,l=e[0].x*e[1].y-e[1].x*e[0].y,u=i*l-s*h,y=n*l-a*h,P=-(h*a-l*n)/(i*a-s*n),L=-(i*l-s*h)/(i*a-s*n);if(isFinite(P)&&isFinite(L))return{x:P,y:L};if(Math.abs(u-y)<.1)throw new Error("Segment included");return null}static GetCordsFromTwoPoint(t,e){const i=Math.abs(t.x-e.x),s=Math.abs(t.y-e.y),n=Math.max(i,s),a=[t];function h(l,u,y,P,L){return u>l?l+L*(y/P):u<l?l-L*(y/P):l}for(let l=1;l<=n;l+=1)a.push({x:h(t.x,e.x,i,n,l),y:h(t.y,e.y,s,n,l)});return a}}class M extends w{constructor(t,e,i){super(t,i),this.copiedElement=null,this.temporaryCopy=null,this.isLoad=!1,this.element=e,this.element.classList.add("stf__item"),this.element.classList.add("--"+i)}
16newTemporaryCopy(){return this.nowDrawingDensity==="hard"?this:(this.temporaryCopy===null&&(this.copiedElement=this.element.cloneNode(!0),this.element.parentElement.appendChild(this.copiedElement),this.temporaryCopy=new M(this.render,this.copiedElement,this.nowDrawingDensity)),this.getTemporaryCopy())}getTemporaryCopy(){return this.temporaryCopy}hideTemporaryCopy(){this.temporaryCopy!==null&&(this.copiedElement.remove(),this.copiedElement=null,this.temporaryCopy=null)}draw(t){const e=t||this.nowDrawingDensity,i=this.render.convertToGlobal(this.state.position),s=this.render.getRect().pageWidth,n=this.render.getRect().height;this.element.classList.remove("--simple");const a=` 17 display: block; 18 z-index: ${this.element.style.zIndex}; 19 left: 0; 20 top: 0; 21 width: ${s}px; 22 height: ${n}px; 23 `;e==="hard"?this.drawHard(a):this.drawSoft(i,a)}drawHard(t=""){const e=this.render.getRect().left+this.render.getRect().width/2,i=this.state.hardDrawingAngle,s=t+` 24 backface-visibility: hidden; 25 -webkit-backface-visibility: hidden; 26 clip-path: none; 27 -webkit-clip-path: none; 28 `+(this.orientation===0?`transform-origin: ${this.render.getRect().pageWidth}px 0; 29 transform: translate3d(0, 0, 0) rotateY(${i}deg);`:`transform-origin: 0 0; 30 transform: translate3d(${e}px, 0, 0) rotateY(${i}deg);`);this.element.style.cssText=s}drawSoft(t,e=""){let i="polygon( ";for(const n of this.state.area)if(n!==null){let a=this.render.getDirection()===1?{x:-n.x+this.state.position.x,y:n.y-this.state.position.y}:{x:n.x-this.state.position.x,y:n.y-this.state.position.y};a=p.GetRotatedPoint(a,{x:0,y:0},this.state.angle),i+=a.x+"px "+a.y+"px, "}i=i.slice(0,-2),i+=")";const s=e+`transform-origin: 0 0; clip-path: ${i}; -webkit-clip-path: ${i};`+(this.render.isSafari()&&this.state.angle===0?`transform: translate(${t.x}px, ${t.y}px);`:`transform: translate3d(${t.x}px, ${t.y}px, 0) rotate(${this.state.angle}rad);`);this.element.style.cssText=s}simpleDraw(t){const e=this.render.getRect(),i=e.pageWidth,s=e.height,n=t===1?e.left+e.pageWidth:e.left,a=e.top;this.element.classList.add("--simple"),this.element.style.cssText=` 31 position: absolute; 32 display: block; 33 height: ${s}px; 34 left: ${n}px; 35 top: ${a}px; 36 width: ${i}px; 37 z-index: ${this.render.getSettings().startZIndex+1};`}getElement(){return this.element}load(){this.isLoad=!0}setOrientation(t){super.setOrientation(t),this.element.classList.remove("--left","--right"),this.element.classList.add(t===1?"--right":"--left")}setDrawingDensity(t){this.element.classList.remove("--soft","--hard"),this.element.classList.add("--"+t),super.setDrawingDensity(t)}}class f extends C{constructor(t,e,i,s){super(t,e),this.element=i,this.pagesElement=s}load(){for(const t of this.pagesElement){const e=new M(this.render,t,t.dataset.density==="hard"?"hard":"soft");e.load(),this.pages.push(e)}this.createSpread()}}class v{constructor(t,e,i,s){this.direction=t,this.corner=e,this.topIntersectPoint=null,this.sideIntersectPoint=null,this.bottomIntersectPoint=null,this.pageWidth=parseInt(i,10),this.pageHeight=parseInt(s,10)}calc(t){try{return this.position=this.calcAngleAndPosition(t),this.calculateIntersectPoint(this.position),!0}catch{return!1}}getFlippingClipArea(){const t=[];let e=!1;return t.push(this.rect.topLeft),t.push(this.topIntersectPoint),this.sideIntersectPoint===null?e=!0:(t.push(this.sideIntersectPoint),this.bottomIntersectPoint===null&&(e=!1)),t.push(this.bottomIntersectPoint),(e||this.corner==="bottom")&&t.push(this.rect.bottomLeft),t}getBottomClipArea(){const t=[];return t.push(this.topIntersectPoint),this.corner==="top"?t.push({x:this.pageWidth,y:0}):(this.topIntersectPoint!==null&&t.push({x:this.pageWidth,y:0}),t.push({x:this.pageWidth,y:this.pageHeight})),this.sideIntersectPoint!==null?p.GetDistanceBetweenTwoPoint(this.sideIntersectPoint,this.topIntersectPoint)>=10&&t.push(this.sideIntersectPoint):this.corner==="top"&&t.push({x:this.pageWidth,y:this.pageHeight}),t.push(this.bottomIntersectPoint),t.push(this.topIntersectPoint),t}getAngle(){return this.direction===0?-this.angle:this.angle}getRect(){return this.rect}getPosition(){return this.position}getActiveCorner(){return this.direction===0?this.rect.topLeft:this.rect.topRight}getDirection(){return this.direction}getFlippingProgress(){return Math.abs((this.position.x-this.pageWidth)/(2*this.pageWidth)*100)}getCorner(){return this.corner}getBottomPagePosition(){return this.direction===1?{x:this.pageWidth,y:0}:{x:0,y:0}}getShadowStartPoint(){return this.corner==="top"?this.topIntersectPoint:this.sideIntersectPoint!==null?this.sideIntersectPoint:this.topIntersectPoint}
37getShadowAngle(){const t=p.GetAngleBetweenTwoLine(this.getSegmentToShadowLine(),[{x:0,y:0},{x:this.pageWidth,y:0}]);return this.direction===0?t:Math.PI-t}calcAngleAndPosition(t){let e=t;if(this.updateAngleAndGeometry(e),e=this.corner==="top"?this.checkPositionAtCenterLine(e,{x:0,y:0},{x:0,y:this.pageHeight}):this.checkPositionAtCenterLine(e,{x:0,y:this.pageHeight},{x:0,y:0}),Math.abs(e.x-this.pageWidth)<1&&Math.abs(e.y)<1)throw new Error("Point is too small");return e}updateAngleAndGeometry(t){this.angle=this.calculateAngle(t),this.rect=this.getPageRect(t)}calculateAngle(t){const e=this.pageWidth-t.x+1,i=this.corner==="bottom"?this.pageHeight-t.y:t.y;let s=2*Math.acos(e/Math.sqrt(i*i+e*e));i<0&&(s=-s);const n=Math.PI-s;if(!isFinite(s)||n>=0&&n<.003)throw new Error("The G point is too small");return this.corner==="bottom"&&(s=-s),s}getPageRect(t){return this.corner==="top"?this.getRectFromBasePoint([{x:0,y:0},{x:this.pageWidth,y:0},{x:0,y:this.pageHeight},{x:this.pageWidth,y:this.pageHeight}],t):this.getRectFromBasePoint([{x:0,y:-this.pageHeight},{x:this.pageWidth,y:-this.pageHeight},{x:0,y:0},{x:this.pageWidth,y:0}],t)}getRectFromBasePoint(t,e){return{topLeft:this.getRotatedPoint(t[0],e),topRight:this.getRotatedPoint(t[1],e),bottomLeft:this.getRotatedPoint(t[2],e),bottomRight:this.getRotatedPoint(t[3],e)}}getRotatedPoint(t,e){return{x:t.x*Math.cos(this.angle)+t.y*Math.sin(this.angle)+e.x,y:t.y*Math.cos(this.angle)-t.x*Math.sin(this.angle)+e.y}}calculateIntersectPoint(t){const e={left:-1,top:-1,width:this.pageWidth+2,height:this.pageHeight+2};this.corner==="top"?(this.topIntersectPoint=p.GetIntersectBetweenTwoSegment(e,[t,this.rect.topRight],[{x:0,y:0},{x:this.pageWidth,y:0}]),this.sideIntersectPoint=p.GetIntersectBetweenTwoSegment(e,[t,this.rect.bottomLeft],[{x:this.pageWidth,y:0},{x:this.pageWidth,y:this.pageHeight}]),this.bottomIntersectPoint=p.GetIntersectBetweenTwoSegment(e,[this.rect.bottomLeft,this.rect.bottomRight],[{x:0,y:this.pageHeight},{x:this.pageWidth,y:this.pageHeight}])):(this.topIntersectPoint=p.GetIntersectBetweenTwoSegment(e,[this.rect.topLeft,this.rect.topRight],[{x:0,y:0},{x:this.pageWidth,y:0}]),this.sideIntersectPoint=p.GetIntersectBetweenTwoSegment(e,[t,this.rect.topLeft],[{x:this.pageWidth,y:0},{x:this.pageWidth,y:this.pageHeight}]),this.bottomIntersectPoint=p.GetIntersectBetweenTwoSegment(e,[this.rect.bottomLeft,this.rect.bottomRight],[{x:0,y:this.pageHeight},{x:this.pageWidth,y:this.pageHeight}]))}checkPositionAtCenterLine(t,e,i){let s=t;const n=p.LimitPointToCircle(e,this.pageWidth,s);s!==n&&(s=n,this.updateAngleAndGeometry(s));const a=Math.sqrt(Math.pow(this.pageWidth,2)+Math.pow(this.pageHeight,2));let h=this.rect.bottomRight,l=this.rect.topLeft;if(this.corner==="bottom"&&(h=this.rect.topRight,l=this.rect.bottomLeft),h.x<=0){const u=p.LimitPointToCircle(i,a,l);u!==s&&(s=u,this.updateAngleAndGeometry(s))}return s}getSegmentToShadowLine(){const t=this.getShadowStartPoint();return[t,t!==this.sideIntersectPoint&&this.sideIntersectPoint!==null?this.sideIntersectPoint:this.bottomIntersectPoint]}}class m{constructor(t,e){this.flippingPage=null,this.bottomPage=null,this.calc=null,this.state="read",this.render=t,this.app=e}fold(t){this.setState("user_fold"),this.calc===null&&this.start(t),this.do(this.render.convertToPage(t))}flip(t){if(this.app.getSettings().disableFlipByClick&&!this.isPointOnCorners(t)||(this.calc!==null&&this.render.finishAnimation(),!this.start(t)))return;const e=this.getBoundsRect();this.setState("flipping");const i=e.height/10,s=this.calc.getCorner()==="bottom"?e.height-i:i,n=this.calc.getCorner()==="bottom"?e.height:0;this.calc.calc({x:e.pageWidth-i,y:s}),this.animateFlippingTo({x:e.pageWidth-i,y:s},{x:-e.pageWidth,y:n},!0)}start(t){this.reset();const e=this.render.convertToBook(t),i=this.getBoundsRect(),s=this.getDirectionByPoint(e),n=e.y>=i.height/2?"bottom":"top";if(!this.checkDirection(s))return!1;try{if(this.flippingPage=this.app.getPageCollection().getFlippingPage(s),this.bottomPage=this.app.getPageCollection().getBottomPage(s),this.render.getOrientation()==="landscape")if(s===1){const a=this.app.getPageCollection().nextBy(this.flippingPage);a!==null&&this.flippingPage.getDensity()!==a.getDensity()&&(this.flippingPage.setDrawingDensity("hard"),a.setDrawingDensity("hard"))}else{const a=this.app.getPageCollection().prevBy(this.flippingPage);a!==null&&this.flippingPage.getDensity()!==a.getDensity()&&(this.flippingPage.setDrawingDensity("hard"),a.setDrawingDensity("hard"))}return this.render.setDirection(s),this.calc=new v(s,n,i.pageWidth.toString(10),i.height.toString(10)),!0}catch{return!1}}do(t){if(this.calc!==null&&this.calc.calc(t)){const e=this.calc.getFlippingProgress();this.bottomPage.setArea(this.calc.getBottomClipArea()),this.bottomPage.setPosition(this.calc.getBottomPagePosition()),this.bottomPage.setAngle(0),this.bottomPage.setHardA
37ngle(0),this.flippingPage.setArea(this.calc.getFlippingClipArea()),this.flippingPage.setPosition(this.calc.getActiveCorner()),this.flippingPage.setAngle(this.calc.getAngle()),this.calc.getDirection()===0?this.flippingPage.setHardAngle(90*(200-2*e)/100):this.flippingPage.setHardAngle(-90*(200-2*e)/100),this.render.setPageRect(this.calc.getRect()),this.render.setBottomPage(this.bottomPage),this.render.setFlippingPage(this.flippingPage),this.render.setShadowData(this.calc.getShadowStartPoint(),this.calc.getShadowAngle(),e,this.calc.getDirection())}}flipToPage(t,e){const i=this.app.getPageCollection().getCurrentSpreadIndex(),s=this.app.getPageCollection().getSpreadIndexByPage(t);try{s>i&&(this.app.getPageCollection().setCurrentSpreadIndex(s-1),this.flipNext(e)),s<i&&(this.app.getPageCollection().setCurrentSpreadIndex(s+1),this.flipPrev(e))}catch{}}flipNext(t){this.flip({x:this.render.getRect().left+2*this.render.getRect().pageWidth-10,y:t==="top"?1:this.render.getRect().height-2})}flipPrev(t){this.flip({x:10,y:t==="top"?1:this.render.getRect().height-2})}stopMove(){if(this.calc===null)return;const t=this.calc.getPosition(),e=this.getBoundsRect(),i=this.calc.getCorner()==="bottom"?e.height:0;t.x<=0?this.animateFlippingTo(t,{x:-e.pageWidth,y:i},!0):this.animateFlippingTo(t,{x:e.pageWidth,y:i},!1)}showCorner(t){if(!this.checkState("read","fold_corner"))return;const e=this.getBoundsRect(),i=e.pageWidth;if(this.isPointOnCorners(t))if(this.calc===null){if(!this.start(t))return;this.setState("fold_corner"),this.calc.calc({x:i-1,y:1});const s=50,n=this.calc.getCorner()==="bottom"?e.height-1:1,a=this.calc.getCorner()==="bottom"?e.height-s:s;this.animateFlippingTo({x:i-1,y:n},{x:i-s,y:a},!1,!1)}else this.do(this.render.convertToPage(t));else this.setState("read"),this.render.finishAnimation(),this.stopMove()}animateFlippingTo(t,e,i,s=!0){const n=p.GetCordsFromTwoPoint(t,e),a=[];for(const l of n)a.push(()=>this.do(l));const h=this.getAnimationDuration(n.length);this.render.startAnimation(a,h,()=>{this.calc&&(i&&(this.calc.getDirection()===1?this.app.turnToPrevPage():this.app.turnToNextPage()),s&&(this.render.setBottomPage(null),this.render.setFlippingPage(null),this.render.clearShadow(),this.setState("read"),this.reset()))})}getCalculation(){return this.calc}getState(){return this.state}setState(t){this.state!==t&&(this.app.updateState(t),this.state=t)}getDirectionByPoint(t){const e=this.getBoundsRect();if(this.render.getOrientation()==="portrait"){if(t.x-e.pageWidth<=e.width/5)return 1}else if(t.x<e.width/2)return 1;return 0}getAnimationDuration(t){const e=this.app.getSettings().flippingTime;return t>=1e3?e:t/1e3*e}checkDirection(t){return t===0?this.app.getCurrentPageIndex()<this.app.getPageCount()-1:this.app.getCurrentPageIndex()>=1}reset(){this.calc=null,this.flippingPage=null,this.bottomPage=null}getBoundsRect(){return this.render.getRect()}checkState(...t){for(const e of t)if(this.state===e)return!0;return!1}isPointOnCorners(t){const e=this.getBoundsRect(),i=e.pageWidth,s=Math.sqrt(Math.pow(i,2)+Math.pow(e.height,2))/5,n=this.render.convertToBook(t);return n.x>0&&n.y>0&&n.x<e.width&&n.y<e.height&&(n.x<s||n.x>e.width-s)&&(n.y<s||n.y>e.height-s)}}class D{constructor(t,e){this.leftPage=null,this.rightPage=null,this.flippingPage=null,this.bottomPage=null,this.direction=null,this.orientation=null,this.shadow=null,this.animation=null,this.pageRect=null,this.boundsRect=null,this.timer=0,this.safari=!1,this.setting=e,this.app=t;const i=new RegExp("Version\\/[\\d\\.]+.*Safari/");this.safari=i.exec(window.navigator.userAgent)!==null}render(t){if(this.animation!==null){const e=Math.round((t-this.animation.startedAt)/this.animation.durationFrame);e<this.animation.frames.length?this.animation.frames[e]():(this.animation.onAnimateEnd(),this.animation=null)}this.timer=t,this.drawFrame()}start(){this.update();const t=e=>{this.render(e),requestAnimationFrame(t)};requestAnimationFrame(t)}startAnimation(t,e,i){this.finishAnimation(),this.animation={frames:t,duration:e,durationFrame:e/t.length,onAnimateEnd:i,startedAt:this.timer}}finishAnimation(){this.animation!==null&&(this.animation.frames[this.animation.frames.length-1](),this.animation.onAnimateEnd!==null&&this.animation.onAnimateEnd()),this.animation=null}update(){this.boundsRect=null;const t=this.calculateBoundsRect();this.orientation!==t&&(this.orientation=t,this.app.updateOrientation(t))}calculateBoundsRect(){let t="landscape";const e=this.getBlockWidth(),i=e/2,s=this.getBlockHeight()/2,n=this.setting.width/this.setting.height;let a=this.setting.width,h=this.setting.height,l=i-a;return this.setting.size==="stretch"?(e<2*this.setting.minWidth&&this.app.getSettings().usePortrait&&(t="portrait"),a=t==="portrait"?this.getBlockWidth():this.getBlockWidth()/2,a>this.setting.maxWidth&&(a=this.setting.maxWidth),h=a/n,h>this.getBlockHeight()&&(h=this.getBlockHeight(),a=h*n),l=t==="portrait"?i-a/2-a:i-a):e<2*a&&this.app.getSettings().usePortrait&&(t="portrait",l=i-a/2-a),this.boundsRect={left:l,top:s-h/2,width:2*a,height:h,pageWidth:a},t}
37setShadowData(t,e,i,s){if(!this.app.getSettings().drawShadow)return;const n=100*this.getSettings().maxShadowOpacity;this.shadow={pos:t,angle:e,width:3*this.getRect().pageWidth/4*i/100,opacity:(100-i)*n/100/100,direction:s,progress:2*i}}clearShadow(){this.shadow=null}getBlockWidth(){return this.app.getUI().getDistElement().offsetWidth}getBlockHeight(){return this.app.getUI().getDistElement().offsetHeight}getDirection(){return this.direction}getRect(){return this.boundsRect===null&&this.calculateBoundsRect(),this.boundsRect}getSettings(){return this.app.getSettings()}getOrientation(){return this.orientation}setPageRect(t){this.pageRect=t}setDirection(t){this.direction=t}setRightPage(t){t!==null&&t.setOrientation(1),this.rightPage=t}setLeftPage(t){t!==null&&t.setOrientation(0),this.leftPage=t}setBottomPage(t){t!==null&&t.setOrientation(this.direction===1?0:1),this.bottomPage=t}setFlippingPage(t){t!==null&&t.setOrientation(this.direction===0&&this.orientation!=="portrait"?0:1),this.flippingPage=t}convertToBook(t){const e=this.getRect();return{x:t.x-e.left,y:t.y-e.top}}isSafari(){return this.safari}convertToPage(t,e){e||(e=this.direction);const i=this.getRect();return{x:e===0?t.x-i.left-i.width/2:i.width/2-t.x+i.left,y:t.y-i.top}}convertToGlobal(t,e){if(e||(e=this.direction),t==null)return null;const i=this.getRect();return{x:e===0?t.x+i.left+i.width/2:i.width/2-t.x+i.left,y:t.y+i.top}}convertRectToGlobal(t,e){return e||(e=this.direction),{topLeft:this.convertToGlobal(t.topLeft,e),topRight:this.convertToGlobal(t.topRight,e),bottomLeft:this.convertToGlobal(t.bottomLeft,e),bottomRight:this.convertToGlobal(t.bottomRight,e)}}}class _ extends D{constructor(t,e,i){super(t,e),this.canvas=i,this.ctx=i.getContext("2d")}getContext(){return this.ctx}reload(){}drawFrame(){this.clear(),this.orientation!=="portrait"&&this.leftPage!=null&&this.leftPage.simpleDraw(0),this.rightPage!=null&&this.rightPage.simpleDraw(1),this.bottomPage!=null&&this.bottomPage.draw(),this.drawBookShadow(),this.flippingPage!=null&&this.flippingPage.draw(),this.shadow!=null&&(this.drawOuterShadow(),this.drawInnerShadow());const t=this.getRect();this.orientation==="portrait"&&(this.ctx.beginPath(),this.ctx.rect(t.left+t.pageWidth,t.top,t.width,t.height),this.ctx.clip())}drawBookShadow(){const t=this.getRect();this.ctx.save(),this.ctx.beginPath();const e=t.width/20;this.ctx.rect(t.left,t.top,t.width,t.height);const i={x:t.left+t.width/2-e/2,y:0};this.ctx.translate(i.x,i.y);const s=this.ctx.createLinearGradient(0,0,e,0);s.addColorStop(0,"rgba(0, 0, 0, 0)"),s.addColorStop(.4,"rgba(0, 0, 0, 0.2)"),s.addColorStop(.49,"rgba(0, 0, 0, 0.1)"),s.addColorStop(.5,"rgba(0, 0, 0, 0.5)"),s.addColorStop(.51,"rgba(0, 0, 0, 0.4)"),s.addColorStop(1,"rgba(0, 0, 0, 0)"),this.ctx.clip(),this.ctx.fillStyle=s,this.ctx.fillRect(0,0,e,2*t.height),this.ctx.restore()}drawOuterShadow(){const t=this.getRect();this.ctx.save(),this.ctx.beginPath(),this.ctx.rect(t.left,t.top,t.width,t.height);const e=this.convertToGlobal({x:this.shadow.pos.x,y:this.shadow.pos.y});this.ctx.translate(e.x,e.y),this.ctx.rotate(Math.PI+this.shadow.angle+Math.PI/2);const i=this.ctx.createLinearGradient(0,0,this.shadow.width,0);this.shadow.direction===0?(this.ctx.translate(0,-100),i.addColorStop(0,"rgba(0, 0, 0, "+this.shadow.opacity+")"),i.addColorStop(1,"rgba(0, 0, 0, 0)")):(this.ctx.translate(-this.shadow.width,-100),i.addColorStop(0,"rgba(0, 0, 0, 0)"),i.addColorStop(1,"rgba(0, 0, 0, "+this.shadow.opacity+")")),this.ctx.clip(),this.ctx.fillStyle=i,this.ctx.fillRect(0,0,this.shadow.width,2*t.height),this.ctx.restore()}drawInnerShadow(){const t=this.getRect();this.ctx.save(),this.ctx.beginPath();const e=this.convertToGlobal({x:this.shadow.pos.x,y:this.shadow.pos.y}),i=this.convertRectToGlobal(this.pageRect);this.ctx.moveTo(i.topLeft.x,i.topLeft.y),this.ctx.lineTo(i.topRight.x,i.topRight.y),this.ctx.lineTo(i.bottomRight.x,i.bottomRight.y),this.ctx.lineTo(i.bottomLeft.x,i.bottomLeft.y),this.ctx.translate(e.x,e.y),this.ctx.rotate(Math.PI+this.shadow.angle+Math.PI/2);const s=3*this.shadow.width/4,n=this.ctx.createLinearGradient(0,0,s,0
vendor: 8,315 bytes, lines 37-58
37);this.shadow.direction===0?(this.ctx.translate(-s,-100),n.addColorStop(1,"rgba(0, 0, 0, "+this.shadow.opacity+")"),n.addColorStop(.9,"rgba(0, 0, 0, 0.05)"),n.addColorStop(.7,"rgba(0, 0, 0, "+this.shadow.opacity+")"),n.addColorStop(0,"rgba(0, 0, 0, 0)")):(this.ctx.translate(0,-100),n.addColorStop(0,"rgba(0, 0, 0, "+this.shadow.opacity+")"),n.addColorStop(.1,"rgba(0, 0, 0, 0.05)"),n.addColorStop(.3,"rgba(0, 0, 0, "+this.shadow.opacity+")"),n.addColorStop(1,"rgba(0, 0, 0, 0)")),this.ctx.clip(),this.ctx.fillStyle=n,this.ctx.fillRect(0,0,s,2*t.height),this.ctx.restore()}clear(){this.ctx.fillStyle="white",this.ctx.fillRect(0,0,this.canvas.width,this.canvas.height)}}class A{constructor(t,e,i){this.touchPoint=null,this.swipeTimeout=250,this.onResize=()=>{this.update()},this.onMouseDown=n=>{if(this.checkTarget(n.target)){const a=this.getMousePos(n.clientX,n.clientY);this.app.startUserTouch(a),n.preventDefault()}},this.onTouchStart=n=>{if(this.checkTarget(n.target)&&n.changedTouches.length>0){const a=n.changedTouches[0],h=this.getMousePos(a.clientX,a.clientY);this.touchPoint={point:h,time:Date.now()},setTimeout(()=>{this.touchPoint!==null&&this.app.startUserTouch(h)},this.swipeTimeout),this.app.getSettings().mobileScrollSupport||n.preventDefault()}},this.onMouseUp=n=>{const a=this.getMousePos(n.clientX,n.clientY);this.app.userStop(a)},this.onMouseMove=n=>{const a=this.getMousePos(n.clientX,n.clientY);this.app.userMove(a,!1)},this.onTouchMove=n=>{if(n.changedTouches.length>0){const a=n.changedTouches[0],h=this.getMousePos(a.clientX,a.clientY);this.app.getSettings().mobileScrollSupport?(this.touchPoint!==null&&(Math.abs(this.touchPoint.point.x-h.x)>10||this.app.getState()!=="read")&&n.cancelable&&this.app.userMove(h,!0),this.app.getState()!=="read"&&n.preventDefault()):this.app.userMove(h,!0)}},this.onTouchEnd=n=>{if(n.changedTouches.length>0){const a=n.changedTouches[0],h=this.getMousePos(a.clientX,a.clientY);let l=!1;if(this.touchPoint!==null){const u=h.x-this.touchPoint.point.x,y=Math.abs(h.y-this.touchPoint.point.y);Math.abs(u)>this.swipeDistance&&y<2*this.swipeDistance&&Date.now()-this.touchPoint.time<this.swipeTimeout&&(u>0?this.app.flipPrev(this.touchPoint.point.y<this.app.getRender().getRect().height/2?"top":"bottom"):this.app.flipNext(this.touchPoint.point.y<this.app.getRender().getRect().height/2?"top":"bottom"),l=!0),this.touchPoint=null}this.app.userStop(h,l)}},this.parentElement=t,t.classList.add("stf__parent"),t.insertAdjacentHTML("afterbegin",'<div class="stf__wrapper"></div>'),this.wrapper=t.querySelector(".stf__wrapper"),this.app=e;const s=this.app.getSettings().usePortrait?1:2;t.style.minWidth=i.minWidth*s+"px",t.style.minHeight=i.minHeight+"px",i.size==="fixed"&&(t.style.minWidth=i.width*s+"px",t.style.minHeight=i.height+"px"),i.autoSize&&(t.style.width="100%",t.style.maxWidth=2*i.maxWidth+"px"),t.style.display="block",window.addEventListener("resize",this.onResize,!1),this.swipeDistance=i.swipeDistance}destroy(){this.app.getSettings().useMouseEvents&&this.removeHandlers(),this.distElement.remove(),this.wrapper.remove()}getDistElement(){return this.distElement}getWrapper(){return this.wrapper}setOrientationStyle(t){this.wrapper.classList.remove("--portrait","--landscape"),t==="portrait"?(this.app.getSettings().autoSize&&(this.wrapper.style.paddingBottom=this.app.getSettings().height/this.app.getSettings().width*100+"%"),this.wrapper.classList.add("--portrait")):(this.app.getSettings().autoSize&&(this.wrapper.style.paddingBottom=this.app.getSettings().height/(2*this.app.getSettings().width)*100+"%"),this.wrapper.classList.add("--landscape")),this.update()}removeHandlers(){window.removeEventListener("resize",this.onResize),this.distElement.removeEventListener("mousedown",this.onMouseDown),this.distElement.removeEventListener("touchstart",this.onTouchStart),window.removeEventListener("mousemove",this.onMouseMove),window.removeEventListener("touchmove",this.onTouchMove),window.removeEventListener("mouseup",this.onMouseUp),window.removeEventListener("touchend",this.onTouchEnd)}setHandlers(){window.addEventListener("resize",this.onResize,!1),this.app.getSettings().useMouseEvents&&(this.distElement.addEventListener("mousedown",this.onMouseDown),this.distElement.addEventListener("touchstart",this.onTouchStart),window.addEventListener("mousemove",this.onMouseMove),window.addEventListener("touchmove",this.onTouchMove,{passive:!this.app.getSettings().mobileScrollSupport}),window.addEventListener("mouseup",this.onMouseUp),window.addEventListener("touchend",this.onTouchEnd))}getMousePos(t,e){const i=this.distElement.getBoundingClientRect();return{x:t-i.left,y:e-i.top}}checkTarget(t){return!this.app.getSettings().clickEventForward||!["a","button"].includes(t.tagName.toLowerCase())}}class G extends A{constructor(t,e,i,s){super(t,e,i),this.wrapper.insertAdjacentHTML("afterbegin",'<div class="stf__block"></div>'),this.distElement=t.querySelector(".stf__block"),this.items=s;for(const n of s)this.distElement.appendChild(n);this.setHandlers()}clear(){for(const t of this.items)this.parentElement.appendChild(t)}updateItems(t){this.removeHandlers(),this.distElement.innerHTML="";for(const e of t)this.distElement.appendChild(e);this.items=t,this.setHandlers()}update(){this.app.getRender().update()}}class B extends A{constructor(t,e,i){super(t,e,i),this.wrapper.innerHTML='<canvas class="stf__canvas"></canvas>',this.canvas=t.querySelectorAll("canvas")[0],this.distElement=this.canvas,this.resizeCanvas(),this.setHandlers()}resizeCanvas(){const t=getComputedStyle(this.canvas),e=parseInt(t.getPropertyValue("width"),10),i=parseInt(t.getPropertyValue("height"),10);this.canvas.width=e,this.canvas.height=i}getCanvas(){return this.canvas}update(){this.resizeCanvas(),this.app.getRender().update()}}class U extends D{constructor(t,e,i){super(t,e),this.outerShadow=null,this.innerShadow=null,this.hardShadow=null,this.hardInnerShadow=null,this.element=i,this.createShadows()}createShadows(){this.element.insertAdjacentHTML("beforeend",`<div class="stf__outerShadow"></div> 38 <div class="stf__innerShadow"></div> 39 <div class="stf__hardShadow"></div> 40 <div class="stf__hardInnerShadow"></div>`),this.outerShadow=this.element.querySelector(".stf__outerShadow"),this.innerShadow=this.element.querySelector(".stf__innerShadow"),this.hardShadow=this.element.querySelector(".stf__hardShadow"),this.hardInnerShadow=this.element.querySelector(".stf__hardInnerShadow")}clearShadow(){super.clearShadow(),this.outerShadow.style.cssText="display: none",this.innerShadow.style.cssText="display: none",this.hardShadow.style.cssText="display: none",this.hardInnerShadow.style.cssText="display: none"}reload(){this.element.querySelector(".stf__outerShadow")||this.createShadows()}drawHardInnerShadow(){const t=this.getRect(),e=this.shadow.progress>100?200-this.shadow.progress:this.shadow.progress;let i=(100-e)*(2.5*t.pageWidth)/100+20;i>t.pageWidth&&(i=t.pageWidth);let s=` 41 display: block; 42 z-index: ${(this.getSettings().startZIndex+5).toString(10)}; 43 width: ${i}px; 44 height: ${t.height}px; 45 background: linear-gradient(to right, 46 rgba(0, 0, 0, ${this.shadow.opacity*e/100}) 5%, 47 rgba(0, 0, 0, 0) 100%); 48 left: ${t.left+t.width/2}px; 49 transform-origin: 0 0; 50 `;s+=this.getDirection()===0&&this.shadow.progress>100||this.getDirection()===1&&this.shadow.progress<=100?"transform: translate3d(0, 0, 0);":"transform: translate3d(0, 0, 0) rotateY(180deg);",this.hardInnerShadow.style.cssText=s}drawHardOuterShadow(){const t=this.getRect();let e=(100-(this.shadow.progress>100?200-this.shadow.progress:this.shadow.progress))*(2.5*t.pageWidth)/100+20;e>t.pageWidth&&(e=t.pageWidth);let i=` 51 display: block; 52 z-index: ${(this.getSettings().startZIndex+4).toString(10)}; 53 width: ${e}px; 54 height: ${t.height}px; 55 background: linear-gradient(to left, rgba(0, 0, 0, ${this.shadow.opacity}) 5%, rgba(0, 0, 0, 0) 100%); 56 left: ${t.left+t.width/2}px; 57 transform-origin: 0 0; 58 `;i+=this.getDirection()===0&&this.shadow.progress>100||this.getDirection()===1&&this.shadow.progress<=100?"transform: translate3d(0, 0, 0) rotateY(180deg);
58":"transform: translate3d(0, 0, 0);",this.hardShadow.style.cssText=i}drawInnerShadow(){const t=this.getRect(),e=3*this.shadow.width/4,i=this.getDirection()===0?e:0,s=this.getDirection()===0?"to left":"to right",n=this.convertToGlobal(this.shadow.pos),a=this.shadow.angle+3*Math.PI/2,h=[this.pageRect.topLeft,this.pageRect.topRight,this.pageRect.bottomRight,this.pageRect.bottomLeft];let l="polygon( ";for(const y of h){let P=this.getDirection()===1?{x:-y.x+this.shadow.pos.x,y:y.y-this.shadow.pos.y}:{x:y.x-this.shadow.pos.x,y:y.y-this.shadow.pos.y};P=p.GetRotatedPoint(P,{x:i,y:100},a),l+=P.x+"px "+P.y+"px, "}l=l.slice(0,-2),l+=")";const u=` 59 display: block; 60 z-index: ${(this.getSettings().startZIndex+10).toString(10)}; 61 width: ${e}px; 62 height: ${2*t.height}px; 63 background: linear-gradient(${s}, 64 rgba(0, 0, 0, ${this.shadow.opacity}) 5%, 65 rgba(0, 0, 0, 0.05) 15%, 66 rgba(0, 0, 0, ${this.shadow.opacity}) 35%, 67 rgba(0, 0, 0, 0) 100%); 68 transform-origin: ${i}px 100px; 69 transform: translate3d(${n.x-i}px, ${n.y-100}px, 0) rotate(${a}rad); 70 clip-path: ${l}; 71 -webkit-clip-path: ${l}; 72 `;this.innerShadow.style.cssText=u}drawOuterShadow(){const t=this.getRect(),e=this.convertToGlobal({x:this.shadow.pos.x,y:this.shadow.pos.y}),i=this.shadow.angle+3*Math.PI/2,s=this.getDirection()===1?this.shadow.width:0,n=this.getDirection()===0?"to right":"to left",a=[{x:0,y:0},{x:t.pageWidth,y:0},{x:t.pageWidth,y:t.height},{x:0,y:t.height}];let h="polygon( ";for(const u of a)if(u!==null){let y=this.getDirection()===1?{x:-u.x+this.shadow.pos.x,y:u.y-this.shadow.pos.y}:{x:u.x-this.shadow.pos.x,y:u.y-this.shadow.pos.y};y=p.GetRotatedPoint(y,{x:s,y:100},i),h+=y.x+"px "+y.y+"px, "}h=h.slice(0,-2),h+=")";const l=` 73 display: block; 74 z-index: ${(this.getSettings().startZIndex+10).toString(10)}; 75 width: ${this.shadow.width}px; 76 height: ${2*t.height}px; 77 background: linear-gradient(${n}, rgba(0, 0, 0, ${this.shadow.opacity}), rgba(0, 0, 0, 0)); 78 transform-origin: ${s}px 100px; 79 transform: translate3d(${e.x-s}px, ${e.y-100}px, 0) rotate(${i}rad); 80 clip-path: ${h}; 81 -webkit-clip-path: ${h}; 82 `;this.outerShadow.style.cssText=l}drawLeftPage(){this.orientation!=="portrait"&&this.leftPage!==null&&(this.direction===1&&this.flippingPage!==null&&this.flippingPage.getDrawingDensity()==="hard"?(this.leftPage.getElement().style.zIndex=(this.getSettings().startZIndex+5).toString(10),this.leftPage.setHardDrawingAngle(180+this.flippingPage.getHardAngle()),this.leftPage.draw(this.flippingPage.getDrawingDensity())):this.leftPage.simpleDraw(0))}drawRightPage(){this.rightPage!==null&&(this.direction===0&&this.flippingPage!==null&&this.flippingPage.getDrawingDensity()==="hard"?(this.rightPage.getElement().style.zIndex=(this.getSettings().startZIndex+5).toString(10),this.rightPage.setHardDrawingAngle(180+this.flippingPage.getHardAngle()),this.rightPage.draw(this.flippingPage.getDrawingDensity())):this.rightPage.simpleDraw(1))}drawBottomPage(){if(this.bottomPage===null)return;const t=this.flippingPage!=null?this.flippingPage.getDrawingDensity():null;this.orientation==="portrait"&&this.direction===1||(this.bottomPage.getElement().style.zIndex=(this.getSettings().startZIndex+3).toString(10),this.bottomPage.draw(t))}drawFrame(){this.clear(),this.drawLeftPage(),this.drawRightPage(),this.drawBottomPage(),this.flippingPage!=null&&(this.flippingPage.getElement().style.zIndex=(this.getSettings().startZIndex+5).toString(10),this.flippingPage.draw()),this.shadow!=null&&this.flippingPage!==null&&(this.flippingPage.getDrawingDensity()==="soft"?(this.drawOuterShadow(),this.drawInnerShadow()):(this.drawHardOuterShadow(),this.drawHardInnerShadow()))}clear(){for(const t of this.app.getPageCollection().getPages())t!==this.leftPage&&t!==this.rightPage&&t!==this.flippingPage&&t!==this.bottomPage&&(t.getElement().style.cssText="display: none"),t.getTemporaryCopy()!==this.flippingPage&&t.hideTemporaryCopy()}
82update(){super.update(),this.rightPage!==null&&this.rightPage.setOrientation(1),this.leftPage!==null&&this.leftPage.setOrientation(0)}}class F{constructor(){this._default={startPage:0,size:"fixed",width:0,height:0,minWidth:0,maxWidth:0,minHeight:0,maxHeight:0,drawShadow:!0,flippingTime:1e3,usePortrait:!0,startZIndex:0,autoSize:!0,maxShadowOpacity:1,showCover:!1,mobileScrollSupport:!0,swipeDistance:30,clickEventForward:!0,useMouseEvents:!0,showPageCorners:!0,disableFlipByClick:!1}}getSettings(t){const e=this._default;if(Object.assign(e,t),e.size!=="stretch"&&e.size!=="fixed")throw new Error('Invalid size type. Available only "fixed" and "stretch" value');if(e.width<=0||e.height<=0)throw new Error("Invalid width or height");if(e.flippingTime<=0)throw new Error("Invalid flipping time");return e.size==="stretch"?(e.minWidth<=0&&(e.minWidth=100),e.maxWidth<e.minWidth&&(e.maxWidth=2e3),e.minHeight<=0&&(e.minHeight=100),e.maxHeight<e.minHeight&&(e.maxHeight=2e3)):(e.minWidth=e.width,e.maxWidth=e.width,e.minHeight=e.height,e.maxHeight=e.height),e}}(function(r,t){t===void 0&&(t={});var e=t.insertAt;if(typeof document<"u"){var i=document.head||document.getElementsByTagName("head")[0],s=document.createElement("style");s.type="text/css",e==="top"&&i.firstChild?i.insertBefore(s,i.firstChild):i.appendChild(s),s.styleSheet?s.styleSheet.cssText=r:s.appendChild(document.createTextNode(r))}})(`.stf__parent { 83 position: relative; 84 display: block; 85 box-sizing: border-box; 86 transform: translateZ(0); 87 88 -ms-touch-action: pan-y; 89 touch-action: pan-y; 90} 91 92.sft__wrapper { 93 position: relative; 94 width: 100%; 95 box-sizing: border-box; 96} 97 98.stf__parent canvas { 99 position: absolute; 100 width: 100%; 101 height: 100%; 102 left: 0; 103 top: 0; 104} 105 106.stf__block { 107 position: absolute; 108 width: 100%; 109 height: 100%; 110 box-sizing: border-box; 111 perspective: 2000px; 112} 113 114.stf__item { 115 display: none; 116 position: absolute; 117 transform-style: preserve-3d; 118} 119 120.stf__outerShadow { 121 position: absolute; 122 left: 0; 123 top: 0; 124} 125 126.stf__innerShadow { 127 position: absolute; 128 left: 0; 129 top: 0; 130} 131 132.stf__hardShadow { 133 position: absolute; 134 left: 0; 135 top: 0; 136} 137 138.stf__hardInnerShadow { 139 position: absolute; 140 left: 0; 141 top: 0; 142}`),b.PageFlip=class extends class{constructor(){this.events=new Map}on(r,t){return this.events.has(r)?this.events.get(r).push(t):this.events.set(r,[t]),this}off(r){this.events.delete(r)}trigger(r,t,e=null){if(this.events.has(r))for(const i of this.events.get(r))i({data:e,object:t})}}{constructor(r,t){super(),this.isUserTouch=!1,this.isUserMove=!1,this.setting=null,this.pages=null,this.setting=new F().getSettings(t),this.block=r}destroy(){this.ui.destroy(),this.block.remove()}update(){this.render.update(),this.pages.show()}loadFromImages(r){this.ui=new B(this.block,this,this.setting);const t=this.ui.getCanvas();this.render=new _(this,this.setting,t),this.flipController=new m(this.render,this),this.pages=new I(this,this.render,r),this.pages.load(),this.render.start(),this.pages.show(this.setting.startPage),setTimeout(()=>{this.ui.update(),this.trigger("init",this,{page:this.setting.startPage,mode:this.render.getOrientation()})},1)}loadFromHTML(r){this.ui=new G(this.block,this,this.setting,r),this.render=new U(this,this.setting,this.ui.getDistElement()),this.flipController=new m(this.render,this),this.pages=new f(this,this.render,this.ui.getDistElement(),r),this.pages.load(),this.render.start(),this.pages.show(this.setting.startPage),setTimeout(()=>{this.ui.update(),this.trigger("init",this,{page:this.setting.startPage,mode:this.render.getOrientation()})},1)}updateFromImages(r){const t=this.pages.getCurrentPageIndex();this.pages.destroy(),this.pages=new I(this,this.render,r),this.pages.load(),this.pages.show(t),this.trigger("update",this,{page:t,mode:this.render.getOrientation()})}updateFromHtml(r){const t=this.pages.getCurrentPageIndex();this.pages.destroy(),this.pages=new f(this,this.render,this.ui.getDistElement(),r),this.pages.load(),this.ui.updateItems(r),this.render.reload(),this.pages.show(t),this.trigger("update",this,{page:t,mode:this.render.getOrientation()})}clear(){this.pages.destroy(),this.ui.clear()}turnToPrevPage(){this.pages.showPrev()}turnToNextPage(){this.pages.showNext()}turnToPage(r){this.pages.show(r)}
142flipNext(r="top"){this.flipController.flipNext(r)}flipPrev(r="top"){this.flipController.flipPrev(r)}flip(r,t="top"){this.flipController.flipToPage(r,t)}updateState(r){this.trigger("changeState",this,r)}updatePageIndex(r){this.trigger("flip",this,r)}updateOrientation(r){this.ui.setOrientationStyle(r),this.update(),this.trigger("changeOrientation",this,r)}getPageCount(){return this.pages.getPageCount()}getCurrentPageIndex(){return this.pages.getCurrentPageIndex()}getPage(r){return this.pages.getPage(r)}getRender(){return this.render}getFlipController(){return this.flipController}getOrientation(){return this.render.getOrientation()}getBoundsRect(){return this.render.getRect()}getSettings(){return this.setting}getUI(){return this.ui}getState(){return this.flipController.getState()}getPageCollection(){return this.pages}startUserTouch(r){this.mousePosition=r,this.isUserTouch=!0,this.isUserMove=!1}userMove(r,t){this.isUserTouch||t||!this.setting.showPageCorners?this.isUserTouch&&p.GetDistanceBetweenTwoPoint(this.mousePosition,r)>5&&(this.isUserMove=!0,this.flipController.fold(r)):this.flipController.showCorner(r)}userStop(r,t=!1){this.isUserTouch&&(this.isUserTouch=!1,t||(this.isUserMove?this.flipController.stopMove():this.flipController.flip(r)))}},Object.defineProperty(b,"__esModule",{value:!0})})})(Z,Z.exports);var Tt=Z.exports;const Rt=N.forwardRef((c,T)=>{const b=d.useRef(null),w=d.useRef([]),x=d.useRef(),[C,I]=d.useState([]);d.useImperativeHandle(T,()=>({pageFlip:()=>x.current}));const p=d.useCallback(()=>{x.current&&x.current.clear()},[]),M=d.useCallback(()=>{const f=x.current;f&&(f.off("flip"),f.off("changeOrientation"),f.off("changeState"),f.off("init"),f.off("update"))},[]);return d.useEffect(()=>{if(w.current=[],c.children){const f=N.Children.map(c.children,v=>N.cloneElement(v,{ref:m=>{m&&w.current.push(m)}}));(!c.renderOnlyPageLengthChange||C.length!==f.length)&&(f.length<C.length&&p(),I(f))}},[c.children]),d.useEffect(()=>{const f=()=>{const v=x.current;v&&(c.onFlip&&v.on("flip",m=>c.onFlip(m)),c.onChangeOrientation&&v.on("changeOrientation",m=>c.onChangeOrientation(m)),c.onChangeState&&v.on("changeState",m=>c.onChangeState(m)),c.onInit&&v.on("init",m=>c.onInit(m)),c.onUpdate&&v.on("update",m=>c.onUpdate(m)))};C.length>0&&w.current.length>0&&(M(),b.current&&!x.current&&(x.current=new Tt.PageFlip(b.current,c)),x.current.getFlipController()?x.current.updateFromHtml(w.current):x.current.loadFromHTML(w.current),f())},[C]),N.createElement("div",{ref:b,className:c.className,style:c.style},C)}),Dt=N.memo(Rt);tt.GlobalWorkerOptions.workerSrc="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/3.11.174/pdf.worker.min.js";const Mt=(c,T,b,w)=>{c.save(),c.globalAlpha=.06,c.fillStyle="#000000";const x=Math.round(T/30);c.font=`${x}px sans-serif`,c.textAlign="center",c.textBaseline="middle";const C=c.measureText(w).width,I=Math.PI/6,p=C*Math.cos(I)+x*Math.sin(I),M=C*Math.sin(I)+x*Math.cos(I),f=p*1.6,v=M*1.6;c.translate(T/2,b/2),c.rotate(-I);for(let m=-b*.7;m<=b*.7;m+=v)for(let D=-T*.7;D<=T*.7;D+=f)c.fillText(w,D,m);c.restore()},et=N.forwardRef(({pageImage:c,pageNumber:T,searchHighlight:b},w)=>o.jsxs("div",{ref:w,className:`page bg-white shadow-lg relative ${b?"ring-4 ring-primary":""}`,children:[o.jsx("div",{className:"page-content w-full h-full flex items-center justify-center",children:o.jsx("img",{src:c,alt:`Page ${T}`,className:"w-full h-full object-contain",draggable:!1})}),b&&o.jsx("div",{className:"absolute top-2 right-2 bg-primary text-primary-foreground text-xs px-2 py-1 rounded",children:"Hasil Pencarian"})]}));et.displayName="Page";const jt=({pdfUrl:c,title:T,onClose:b,watermarkText:w})=>{const[x,C]=d.useState([]),[I,p]=d.useState([]),[M,f]=d.useState(!0),[v,m]=d.useState(!1),[D,_]=d.useState(0),[A,G]=d.useState(0),[B,U]=d.useState(0),[F,r]=d.useState(!1),[t,e]=d.useState(1),[i,s]=d.useState(""),[n,a]=d.useState([]),[h,l]=d.useState(0),[u,y]=d.useState(!1),P=d.useRef(null),L=d.useRef(null),X=d.useCallback(async()=>{try{f(!0),m(!1);const S=await tt.getDocument(c).promise,$=S.numPages;U($);const E=[],W=[];for(let k=1;k<=$;k++){const j=await S.getPage(k),z=j.getViewport({scale:2}),H=document.createElement("canvas"),q=H.getContext("2d");if(q){H.width=z.width,H.height=z.height,await j.render({canvasContext:q,viewport:z}).promise,w&&Mt(q,H.width,H.height,w),E.push(H.toDataURL("image/jpeg",.8));try{const dt=(await j.getTextContent()).items.map(pt=>pt.str).join(" ");W.push({pageNumber:k,text:dt})}catch{W.push({pageNumber:k,text:""})}_(Math.round(k/$*100))}}C(E),p(W),f(!1)}catch(g){console.error("Error loading PDF:",g),m(!0),f(!1)}},[c,w]);d.useEffect(()=>{X()},[X]);const V=d.useCallback(()=>
142{if(!i.trim()){a([]);return}const g=i.toLowerCase(),S=[];I.forEach(({pageNumber:$,text:E})=>{if(E.toLowerCase().includes(g)){const W=E.toLowerCase().indexOf(g),k=Math.max(0,W-30),j=Math.min(E.length,W+g.length+30),z=(k>0?"...":"")+E.slice(k,j)+(j<E.length?"...":"");S.push({pageNumber:$,snippet:z})}}),a(S),l(0),S.length>0?(O(S[0].pageNumber-1),Q.success(`Ditemukan ${S.length} hasil pencarian`)):Q.error("Tidak ditemukan hasil pencarian")},[i,I]),O=g=>{P.current&&P.current.pageFlip().flip(g)},it=()=>{if(n.length===0)return;const g=(h+1)%n.length;l(g),O(n[g].pageNumber-1)},st=()=>{if(n.length===0)return;const g=(h-1+n.length)%n.length;l(g),O(n[g].pageNumber-1)},nt=()=>{P.current&&P.current.pageFlip().flipNext()},at=()=>{P.current&&P.current.pageFlip().flipPrev()},rt=g=>{G(g.data)},ot=()=>{var g;document.fullscreenElement?(document.exitFullscreen(),r(!1)):((g=L.current)==null||g.requestFullscreen(),r(!0))},ht=()=>{e(g=>Math.min(g+.2,2))},lt=()=>{e(g=>Math.max(g-.2,.6))};d.useEffect(()=>{const g=()=>{r(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",g),()=>document.removeEventListener("fullscreenchange",g)},[]);const gt=g=>n.some(S=>S.pageNumber===g+1);return M?o.jsxs("div",{className:"flex flex-col items-center justify-center min-h-[60vh] bg-muted/20 rounded-xl",children:[o.jsx(mt,{className:"w-12 h-12 text-primary animate-spin mb-4"}),o.jsx("p",{className:"text-lg font-medium text-foreground mb-2",children:"Memuat Buku..."}),o.jsx("div",{className:"w-64 h-2 bg-muted rounded-full overflow-hidden",children:o.jsx(xt.div,{className:"h-full bg-primary",initial:{width:0},animate:{width:`${D}%`}})}),o.jsxs("p",{className:"text-sm text-muted-foreground mt-2",children:[D,"% - ",B>0?`${Math.round(D*B/100)}/${B} halaman`:"Mengunduh..."]})]}):v?o.jsxs("div",{className:"flex flex-col items-center justify-center min-h-[40vh] bg-muted/20 rounded-xl p-6 text-center",children:[o.jsx("p",{className:"text-base font-medium text-foreground mb-1",children:"Pratinjau tidak dapat dimuat"}),o.jsx("p",{className:"text-sm text-muted-foreground",children:"Anda tetap bisa mengunduh file PDF-nya langsung."})]}):o.jsxs("div",{ref:L,className:`flipbook-container ${F?"fixed inset-0 z-50 bg-background":"relative"}`,children:[o.jsxs("div",{className:"flex items-center justify-between p-4 bg-card border-b border-border gap-2 flex-wrap",children:[o.jsx("h2",{className:"font-serif font-bold text-foreground truncate max-w-[30%] text-sm md:text-base",children:T}),o.jsx("div",{className:"flex items-center gap-2 flex-1 max-w-md",children:u?o.jsxs("div",{className:"flex items-center gap-1 flex-1",children:[o.jsx(Pt,{type:"text",placeholder:"Cari teks...",value:i,onChange:g=>s(g.target.value),onKeyDown:g=>g.key==="Enter"&&V(),className:"h-8 text-sm"}),o.jsx(R,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:V,children:o.jsx(K,{className:"w-4 h-4"})}),n.length>0&&o.jsxs(o.Fragment,{children:[o.jsxs("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:[h+1,"/",n.length]}),o.jsx(R,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:st,children:o.jsx(St,{className:"w-4 h-4"})}),o.jsx(R,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:it,children:o.jsx(ft,{className:"w-4 h-4"})})]}),o.jsx(R,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>{y(!1),s(""),a([])},children:o.jsx(J,{className:"w-4 h-4"})})]}):o.jsxs(R,{variant:"ghost",size:"sm",onClick:()=>y(!0),className:"gap-2",children:[o.jsx(K,{className:"w-4 h-4"}),o.jsx("span",{className:"hidden sm:inline",children:"Cari"})]})}),o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx(R,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:lt,disabled:t<=.6,children:o.jsx(It,{className:"w-4 h-4"})}),o.jsxs("span",{className:"text-xs text-muted-foreground min-w-[2.5rem] text-center",children:[Math.round(t*100),"%"]}),o.jsx(R,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:ht,disabled:t>=2,children:o.jsx(bt,{className:"w-4 h-4"})}),o.jsx(R,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:ot,children:F?o.jsx(Ct,{className:"w-4 h-4"}):o.jsx(vt,{className:"w-4 h-4"})}),b&&o.jsx(R,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:b,children:o.jsx(J,{className:"w-4 h-4"})})]})]}),n.length>0&&o.jsxs("div",{className:"bg-primary/5 border-b border-primary/20 p-3",children:[o.jsxs("p",{className:"text-sm text-primary font-medium mb-2",children:['Hasil Pencarian: "',i,'" - ',n.length," ditemukan"]}),o.jsx("div",{className:"flex gap-2 overflow-x-auto pb-2",children:n.map((g,S)=>o.jsx("button",{onClick:()=>{l(S),O(g.pageNumber-1)},className:`flex-shrink-0 px-3 py-2 text-xs rounded-lg border transition-colors ${S===h?"bg-primary text-primary-foreground border-primary":"bg-card border-border hover:border-primary"}`,children:o.jsxs("span",{className:"font-medium",children:["Hal. ",g.pageNumber]})},S))})]}),o.jsx("div",{className:"flex items-center justify-center py-8 bg-gradient-to-br from-muted/30 to-muted/10 overflow-auto",style:{minHeight:F?"calc(100vh - 180px)":"60vh"},children:o.jsx("div",{style:{transform:`scale(${t})`,transformOrigin:"center center",transition:"transform 0.3s ease"},children:o.jsx(Dt,{ref:P,width:400,height:550,size:"stretch",minWidth:300,maxWidth:600,minHeight:400,maxHeight:800,showCover:!0,mobileScrollSupport:!0,onFlip:rt,className:"flipbook-shadow",style:{},startPage:0,drawShadow:!0,flippingTime:600,usePortrait:!0,startZIndex:0,autoSize:!0,maxShadowOpacity:.5,showPageCorners:!0,disableFlipByClick:!1,swipeDistance:30,clickEventForward:!0,useMouseEvents:!0,children:x.map((g,S)=>o.jsx(et,{pageImage:g,pageNumber:S+1,searchHighlight:gt(S)},S))})})}),o.jsxs("div",{className:"flex items-center justify-center gap-4 p-4 bg-card border-t border-border",children:[o.jsx(R,{variant:"outline",size:"icon",onClick:at,disabled:A===0,children:o.jsx(wt,{className:"w-5 h-5"})}),o.jsxs("span",{className:"text-sm text-muted-foreground min-w-[120px] text-center",children:["Halaman ",A+1," - ",Math.min(A+2,x.length)," dari ",x.length]}),o.jsx(R,{variant:"outline",size:"icon",onClick:nt,disabled:A>=x.length-2,children:o.jsx(yt,{className:"w-5 h-5"})})]})]})};export{jt as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.