@sbseguros/design-system
Version:
A Vue 3 design system with Tailwind CSS and Lucide icons.
102 lines • 2.95 MB
JavaScript
(function(P,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(P=typeof globalThis<"u"?globalThis:P||self,e(P.SBSDesignSystem={},P.Vue))})(this,function(P,e){"use strict";var Ch=Object.defineProperty;var em=P=>{throw TypeError(P)};var Ah=(P,e,wI)=>e in P?Ch(P,e,{enumerable:!0,configurable:!0,writable:!0,value:wI}):P[e]=wI;var S=(P,e,wI)=>Ah(P,typeof e!="symbol"?e+"":e,wI),nb=(P,e,wI)=>e.has(P)||em("Cannot "+wI);var l=(P,e,wI)=>(nb(P,e,"read from private field"),wI?wI.call(P):e.get(P)),Y=(P,e,wI)=>e.has(P)?em("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(P):e.set(P,wI),W=(P,e,wI,Bl)=>(nb(P,e,"write to private field"),Bl?Bl.call(P,wI):e.set(P,wI),wI),a=(P,e,wI)=>(nb(P,e,"access private method"),wI);var mg=(P,e,wI,Bl)=>({set _(Cc){W(P,e,Cc,wI)},get _(){return l(P,e,Bl)}});/*! berea-ui v0.0.20-beta-01 | (c) 2025 SBS Seguros Design System | MIT License | https://github.com/sbs-seguros-col/sbs-common-components */var JC,vc,tb,bd,eA,Vl,Lg,RA,md,pi,Bd,Hc,Rm,xI,ym,Xm,Ls,Hm,Ec,od,Nl,nl,yA,um,Mm,Dm,uc,Fi,Wd,$I,zi,Pc,nI,XA,wd,YI,Mc,Km,Ji,ng,MI,UI,ki,LC,Li,Tg,HA,uA,Ti,tl,hC,fg,el,hd,Yd,ji,ad,YC,MA,Qi,DA,aC,Kc,KA,Vd,SA,Rl,yl,pA,Nd,FI,iI,TC,FA,Xl,nd,td,zA,VC,jC,ed,jg,F,fc,eb,Sm,pm,_c,Fm,zm,Jm,Rb,km,yb,Xb,Lm,Bg,aA,Tm,jm,Hb,Qm,Ts,ub,zI,NC,_g,xi,nC,tg,Ui,tC,wg,QC,Hl,eC,JA,qg,js,qc,ri,ul,Rd,yd,Xd,Hd,ud,OC,Ml,xC,Dl,UC,kA,Om,xm,Um,Kl,$g,mI,vi,LA,Md,Sl,rI,pl,rC,TA,Dd,Fl,eg,Kd,zl,vC,RC,Ei,Pi,Qg,Jl,Sd,Sc,x,Mb,pd,Db,$c,rm,vm,Kb,IG,Sb,Em,Pm,fm,pb,_m,Fb,qm,$m,IB,zb,Qs,kl,Ll,vI,pc,gB,Fd,fi,EC,Fc,_i,Og,CB,AB,lB,gG,zd,Tl,qi,PC,fC,Ig,jl,Ql,z,Ag,Os,OZ,CG,xZ,iB,Jb,UZ,xs,Us,kb,rs,IC,Lb,Tb,jb,Jd,kd,$i,Ld,Td,jd,Qd,IZ,jA,dI,gZ,CZ,Od,Qb,Rg,xd,Ob,nm,QA,hg,Ud,rd,Ol,_C,vd,Ed,xl,AZ,lZ,OA,iZ,Pd,ZZ,Ul,fd,_d,dZ,rl,qd,xA,sZ,qC,ZB,dB,xb,yg,AG,Ub,sB,cB,Jc,vl,$d,Is,gs,Cs,$C,El,vs,UA,gC,IA,Pl,Lc,fl,_l,dg,lG,GB,bB,Es,cZ,iG,gA,yC,GZ,bZ,CA,ql,Ps,rA,vA,$l,gi,mZ,BZ,As,rb,Xg,Xi,mB,BB,oZ,Tc,jc,WZ,wZ,aI,AA,hZ,ls,is,YZ,lA,CC,iA,Zs,ZA,ds,Ci,Ai,sI,ZG,vb,oB,WB,wB,hB,dG,sG,Eb,ss,cs,Gs,bs,ms,li,Bs,Pb,os,Ws,fb,ws,ii,EA,hs,PA,_b,qb,AC,Hg,Ys,Zi,ug,uI,YB,aB,VB,cG,dA,GG,bG,NB,$b,nB,Mg,lC,aZ,VZ,XC,_,di,si,as,Vs,NZ,nZ,fA,Ns,Qc,Oc,KI,fs,tB,eB,RB,yB,XB,HB,tZ,ci,cA,ns,Dg,ts,tI,xc,uB,es,Rs,_A,iC,sg,MB,mG,DB,KB,I0,ys,eZ,ZC,Gi,RZ,SI,Xs,yZ,Hs,us,qA,dC,XZ,Ms,cI,g0,C0,A0,Hi,SB,ml,HZ,Ds,GA,bi,uZ,ag,Ks,Ss,mi,xg,Kg,EI,MZ,bA,gg,DZ,Ug,ps,E,l0,BG,pB,FB,zB,i0,ui,rg,rZ,JB,oG,_s,kB,LB,TB,jB,QB,Bi,Sg,KZ,JI,oi,Wi,$A,Il,gl,wi,gI,Z0,d0,s0,qs,OB,WG,$s,vZ,HC,kI,LI,hi,SZ,cg,PI,vg,Yi,ai,Vi,pZ,wG,Gg,Fs,zs,pg,uC,MC,FZ,zZ,Ni,fI,VA,xB,UB,rB,Uc,vB,ni,lI,c0,sC,EB,PB,G0,hG,fB,_B,qB,b0,m0,$B,Cl,Fg,Al,ll,oI,TI,il,mA,Zl,kZ,BA,ti,DC,Jg,LZ,CI,Ic,gc,YG,aG,VG,B0,NG,Io,ei,TZ,KC,dl,oA,Eg,sl,jZ,Ri,cC,WA,Cg,wA,j,cl,WI,go,pC,o0,W0,nG,bC,bg,yi,Js,rc,Co,SC,w0,Ao,h0;var wI=typeof document<"u"?document.currentScript:null;const Bl=e.defineComponent({__name:"Button",props:{label:{},primary:{type:Boolean,default:!1},size:{},backgroundColor:{}},emits:["click"],setup(m,{emit:I}){const g=m,C=I,A=e.computed(()=>({"storybook-button":!0,"storybook-button--primary":g.primary,"storybook-button--secondary":!g.primary,[`storybook-button--${g.size||"medium"}`]:!0})),i=e.computed(()=>({backgroundColor:g.backgroundColor})),Z=()=>{C("click",1)};return(d,s)=>(e.openBlock(),e.createElementBlock("button",{type:"button",class:e.normalizeClass(A.value),onClick:Z,style:e.normalizeStyle(i.value)},e.toDisplayString(d.label),7))}});/**
* @license lucide-vue-next v0.511.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Cc=m=>m.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),lo=m=>m.replace(/^([A-Z])|[\s-_]+(\w)/g,(I,g,C)=>C?C.toUpperCase():g.toLowerCase()),io=m=>{const I=lo(m);return I.charAt(0).toUpperCase()+I.slice(1)},Zo=(...m)=>m.filter((I,g,C)=>!!I&&I.trim()!==""&&C.indexOf(I)===g).join(" ").trim();/**
* @license lucide-vue-next v0.511.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/var Ac={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linecap":"round","stroke-linejoin":"round"};/**
* @license lucide-vue-next v0.511.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const so=({size:m,strokeWidth:I=2,absoluteStrokeWidth:g,color:C,iconNode:A,name:i,class:Z,...d},{slots:s})=>e.h("svg",{...Ac,width:m||Ac.width,height:m||Ac.height,stroke:C||Ac.stroke,"stroke-width":g?Number(I)*24/Number(m):I,class:Zo("lucide",...i?[`lucide-${Cc(io(i))}-icon`,`lucide-${Cc(i)}`]:["lucide-icon"]),...d},[...A.map(c=>e.h(...c)),...s.default?[s.default()]:[]]);/**
* @license lucide-vue-next v0.511.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const tG=(m,I)=>(g,{slots:C})=>e.h(so,{...g,iconNode:I,name:m},C);/**
* @license lucide-vue-next v0.511.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const co=tG("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/**
* @license lucide-vue-next v0.511.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Go=tG("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/**
* @license lucide-vue-next v0.511.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Y0=tG("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]),bo={class:"h-6 w-6 flex p-[5px] justify-center items-center shrink-0"},mo={class:"text-sm font-medium underline text-grey-grey-900 font-inter"},Bo={class:"inline-flex items-center gap-1 px-4 py-2 rounded bg-fill"},oo={class:"text-sm font-medium text-grey-grey-700 font-inter"},eG=e.defineComponent({__name:"breadcrumb",props:{label:{type:String,required:!0},page:{type:String,default:"Home"},width:{type:String,default:"100%"},path:{type:String,default:""}},emits:["back"],setup(m,{emit:I}){const g=m,C=I,A=e.computed(()=>g.label),i=e.computed(()=>g.page),Z=e.computed(()=>g.width),d=e.computed(()=>{let c;return g.path?c=g.path:typeof window<"u"?c=window.location.pathname:c="/",c.split("/").filter(G=>G).map(G=>G[0].toUpperCase()+G.slice(1))}),s=()=>{console.log("Back button clicked"),C("back")};return(c,G)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(`flex gap-6 w-[${Z.value}px]`)},[e.createElementVNode("button",{onClick:s,class:"flex items-center gap-1"},[e.createElementVNode("span",bo,[e.createVNode(e.unref(co),{class:"w-[14px] h-[14px] shrink-0"})]),e.createElementVNode("span",mo,e.toDisplayString(A.value),1)]),e.createElementVNode("div",Bo,[e.createElementVNode("span",oo,e.toDisplayString(i.value),1),e.createVNode(e.unref(Y0),{class:"w-4 h-4 text-grey-grey-300"}),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(d.value,(B,o)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:B},[e.createElementVNode("span",{class:e.normalizeClass({"text-status-focus":o===d.value.length-1,"text-grey-grey-700":o!==d.value.length-1,"font-inter text-sm font-medium":!0})},e.toDisplayString(B),3),o<d.value.length-1?(e.openBlock(),e.createBlock(e.unref(Y0),{key:0,class:"w-4 h-4 text-grey-grey-300"})):e.createCommentVNode("",!0)],64))),128))])],2))}}),Wo=["src"],wo={class:"font-inter text-[42px] leading-[52px] font-extrabold text-grey-grey-700 flex h-[40.5px] flex-col justify-center self-stretch tracking-[-0.31px]"},ho={class:"self-stretch text-xl font-normal font-inter text-grey-grey-600"},a0=e.defineComponent({__name:"banner",props:{label:{type:String,required:!0},width:{type:String,default:"100%"},page:{type:String,default:"Home"},path:{type:String,default:""},title:{type:String,default:""},description:{type:String,default:""},src:{type:String,default:""},stretch:{type:Boolean,default:!1}},emits:["back"],setup(m,{emit:I}){const g=m,C=I,A=e.computed(()=>g.label),i=e.computed(()=>g.width),Z=e.computed(()=>g.path),d=e.computed(()=>g.title),s=e.computed(()=>g.description),c=e.computed(()=>g.src),G=e.computed(()=>g.page),B=e.computed(()=>g.stretch),o=()=>{C("back")};return(h,N)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["bg-grey-grey-100 w-full left-0 z-[99] absolute top-40 shrink-0 aspect-[18/5]",B.value?"h-[312px]":"h-[400px]"])},[c.value?(e.openBlock(),e.createElementBlock("img",{key:0,src:c.value,alt:"Profile Header",class:"object-contain w-full h-full"},null,8,Wo)):e.createCommentVNode("",!0),e.createVNode(eG,{label:A.value,width:i.value,path:Z.value,page:G.value,class:"absolute top-10 left-[120px] z-[100]",onBack:o},null,8,["label","width","path","page"]),e.createElementVNode("div",{class:e.normalizeClass(["absolute left-[120px] flex flex-col w-[789px] h-[125px] items-start text-left gap-6",{"top-[166px]":!B.value,"top-[120px]":B.value}])},[e.createElementVNode("span",wo,e.toDisplayString(d.value),1),e.createElementVNode("span",ho,e.toDisplayString(s.value),1)],2)],2))}}),Yo={class:"flex flex-col items-center justify-center w-full h-full"},ao=["onClick","aria-expanded","aria-controls"],Vo={class:"w-full h-8 selft-stretch"},No={class:"flex items-center gap-2"},no=["src"],to={key:0,class:"w-6 h-6 shrink-0 aspect-[1/1]"},eo={key:0,class:"flex flex-col self-stretch gap-4 px-10 py-4"},Ro=["onClick"],yo={class:"flex w-[158px] h-[22px] flex-col justify-center font-inter text-sm font-normal"},Xo=e.defineComponent({__name:"collapsed",props:{items:{type:Array,required:!0,validator:m=>m.every(I=>typeof I.key=="string"&&typeof I.name=="string"&&(I.icon===void 0||typeof I.icon=="string"||typeof I.icon=="function")&&(I.icon_active===void 0||typeof I.icon_active=="string"||typeof I.icon_active=="function")&&(I.collapsed===void 0||typeof I.collapsed=="boolean")&&(I.children===void 0||Array.isArray(I.children)))},activeForm:{type:String,required:!0},activeChild:{type:Object,default:null}},emits:["click","child-click"],setup(m,{emit:I}){const g=m,C=I,A=B=>d.value===B.key&&B.icon_active?B.icon_active:B.icon,i=B=>typeof B=="string",Z=e.computed(()=>g.items),d=e.computed(()=>g.activeForm),s=B=>{var h;const o=((h=g.activeChild)==null?void 0:h.parentKey)===B.key;d.value===B.key&&B.collapsed&&!o?C("click",""):C("click",B.key)},c=(B,o)=>{d.value!==o.key&&C("click",o.key),C("child-click",{parentKey:o.key,childKey:B.key})},G=(B,o)=>{var h,N;return((h=g.activeChild)==null?void 0:h.parentKey)===o.key&&((N=g.activeChild)==null?void 0:N.childKey)===B.key};return(B,o)=>(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Z.value,h=>(e.openBlock(),e.createElementBlock("div",Yo,[(e.openBlock(),e.createElementBlock("button",{onClick:N=>s(h),key:h.key,"aria-expanded":m.activeForm===h.key&&h.collapsed,"aria-controls":`submenu-${h.key}`,class:e.normalizeClass(["flex py-2 px-4 flex-col items-start gap-2.5 self-stretch rounded-lg shadow-[0_2px_5px_0_rgba(0,_0,_0,_0.08)]",d.value===h.key?"bg-status-focus":"bg-bandn-white"])},[e.createElementVNode("div",Vo,[e.createElementVNode("div",No,[e.createElementVNode("div",{class:e.normalizeClass(["flex w-8 h-8 py-1 px-0.5 items-center justify-center shrink-0",{"text-grey-grey-900":d.value!==h.key,"text-bandn-white":d.value===h.key}])},[i(A(h))?(e.openBlock(),e.createElementBlock("img",{key:0,src:A(h),alt:"icon",class:e.normalizeClass(["object-contain w-8 h-8 shrink-0",{"brightness-0 invert":d.value===h.key,"opacity-100":d.value===h.key,"opacity-70":d.value!==h.key}])},null,10,no)):(e.openBlock(),e.createBlock(e.resolveDynamicComponent(A(h)),{key:1,class:"w-8 h-8 shrink-0"}))],2),e.createElementVNode("span",{class:e.normalizeClass(["flex-[1_0_0] font-inter text-lg font-semibold text-left",{"text-grey-grey-900":d.value!==h.key,"text-bandn-white":d.value===h.key}])},e.toDisplayString(h.name),3),h.collapsed?(e.openBlock(),e.createElementBlock("div",to,[e.createVNode(e.unref(Go),{class:e.normalizeClass(["transition-transform duration-200",{"text-bandn-white":d.value===h.key,"text-grey-grey-900":d.value!==h.key,"rotate-180":d.value===h.key}])},null,8,["class"])])):e.createCommentVNode("",!0)])])],10,ao)),e.createVNode(e.Transition,{name:"fade-slide",mode:"out-in"},{default:e.withCtx(()=>[e.createElementVNode("div",{class:e.normalizeClass(["overflow-hidden transition-all duration-500 w-[276px]",m.activeForm===h.key&&h.collapsed?"max-h-[1000px]":"max-h-0 hidden"])},[h.children&&h.children.length?(e.openBlock(),e.createElementBlock("div",eo,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(h.children,N=>(e.openBlock(),e.createElementBlock("button",{key:N.key,onClick:V=>c(N,h),class:e.normalizeClass(["flex w-[196px] py-1 text-left px-6 flex-col justify-center items-center border-b-2 border-solid",{"text-status-focus border-b-status-focus ":G(N,h),"text-grey-grey-900 border-b-grey-grey-50":!G(N,h)}])},[e.createElementVNode("span",yo,e.toDisplayString(N.name),1)],10,Ro))),128))])):e.createCommentVNode("",!0)],2)]),_:2},1024)]))),256))}}),lc=(m,I)=>{const g=m.__vccOpts||m;for(const[C,A]of I)g[C]=A;return g},V0=lc(Xo,[["__scopeId","data-v-c3bb137f"]]);var EZ={exports:{}},Ho=EZ.exports,N0;function uo(){return N0||(N0=1,function(m,I){(function(g,C){C(I)})(Ho,function(g){class C{constructor(b,w){this.state={angle:0,area:[],position:{x:0,y:0},hardAngle:0,hardDrawingAngle:0},this.createdDensity=w,this.nowDrawingDensity=this.createdDensity,this.render=b}setDensity(b){this.createdDensity=b,this.nowDrawingDensity=b}setDrawingDensity(b){this.nowDrawingDensity=b}setPosition(b){this.state.position=b}setAngle(b){this.state.angle=b}setArea(b){this.state.area=b}setHardDrawingAngle(b){this.state.hardDrawingAngle=b}setHardAngle(b){this.state.hardAngle=b,this.state.hardDrawingAngle=b}setOrientation(b){this.orientation=b}getDrawingDensity(){return this.nowDrawingDensity}getDensity(){return this.createdDensity}getHardAngle(){return this.state.hardAngle}}class A extends C{constructor(b,w,n){super(b,n),this.image=null,this.isLoad=!1,this.loadingAngle=0,this.image=new Image,this.image.src=w}draw(b){const w=this.render.getContext(),n=this.render.convertToGlobal(this.state.position),y=this.render.getRect().pageWidth,H=this.render.getRect().height;w.save(),w.translate(n.x,n.y),w.beginPath();for(let M of this.state.area)M!==null&&(M=this.render.convertToGlobal(M),w.lineTo(M.x-n.x,M.y-n.y));w.rotate(this.state.angle),w.clip(),this.isLoad?w.drawImage(this.image,0,0,y,H):this.drawLoader(w,{x:0,y:0},y,H),w.restore()}simpleDraw(b){const w=this.render.getRect(),n=this.render.getContext(),y=w.pageWidth,H=w.height,M=b===1?w.left+w.pageWidth:w.left,K=w.top;this.isLoad?n.drawImage(this.image,M,K,y,H):this.drawLoader(n,{x:M,y:K},y,H)}drawLoader(b,w,n,y){b.beginPath(),b.strokeStyle="rgb(200, 200, 200)",b.fillStyle="rgb(255, 255, 255)",b.lineWidth=1,b.rect(w.x+1,w.y+1,n-1,y-1),b.stroke(),b.fill();const H={x:w.x+n/2,y:w.y+y/2};b.beginPath(),b.lineWidth=10,b.arc(H.x,H.y,20,this.loadingAngle,3*Math.PI/2+this.loadingAngle),b.stroke(),b.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 i{constructor(b,w){this.pages=[],this.currentPageIndex=0,this.currentSpreadIndex=0,this.landscapeSpread=[],this.portraitSpread=[],this.render=w,this.app=b,this.currentPageIndex=0,this.isShowCover=this.app.getSettings().showCover}destroy(){this.pages=[]}createSpread(){this.landscapeSpread=[],this.portraitSpread=[];for(let w=0;w<this.pages.length;w++)this.portraitSpread.push([w]);let b=0;this.isShowCover&&(this.pages[0].setDensity("hard"),this.landscapeSpread.push([b]),b++);for(let w=b;w<this.pages.length;w+=2)w<this.pages.length-1?this.landscapeSpread.push([w,w+1]):(this.landscapeSpread.push([w]),this.pages[w].setDensity("hard"))}getSpread(){return this.render.getOrientation()==="landscape"?this.landscapeSpread:this.portraitSpread}getSpreadIndexByPage(b){const w=this.getSpread();for(let n=0;n<w.length;n++)if(b===w[n][0]||b===w[n][1])return n;return null}getPageCount(){return this.pages.length}getPages(){return this.pages}getPage(b){if(b>=0&&b<this.pages.length)return this.pages[b];throw new Error("Invalid page number")}nextBy(b){const w=this.pages.indexOf(b);return w<this.pages.length-1?this.pages[w+1]:null}prevBy(b){const w=this.pages.indexOf(b);return w>0?this.pages[w-1]:null}getFlippingPage(b){const w=this.currentSpreadIndex;if(this.render.getOrientation()==="portrait")return b===0?this.pages[w].newTemporaryCopy():this.pages[w-1];{const n=b===0?this.getSpread()[w+1]:this.getSpread()[w-1];return n.length===1||b===0?this.pages[n[0]]:this.pages[n[1]]}}getBottomPage(b){const w=this.currentSpreadIndex;if(this.render.getOrientation()==="portrait")return b===0?this.pages[w+1]:this.pages[w-1];{const n=b===0?this.getSpread()[w+1]:this.getSpread()[w-1];return n.length===1?this.pages[n[0]]:b===0?this.pages[n[1]]:this.pages[n[0]]}}showNext(){this.currentSpreadIndex<this.getSpread().length&&(this.currentSpreadIndex++,this.showSpread())}showPrev(){this.currentSpreadIndex>0&&(this.currentSpreadIndex--,this.showSpread())}getCurrentPageIndex(){return this.currentPageIndex}show(b=null){if(b===null&&(b=this.currentPageIndex),b<0||b>=this.pages.length)return;const w=this.getSpreadIndexByPage(b);w!==null&&(this.currentSpreadIndex=w,this.showSpread())}getCurrentSpreadIndex(){return this.currentSpreadIndex}setCurrentSpreadIndex(b){if(!(b>=0&&b<this.getSpread().length))throw new Error("Invalid page");this.currentSpreadIndex=b}showSpread(){const b=this.getSpread()[this.currentSpreadIndex];b.length===2?(this.render.setLeftPage(this.pages[b[0]]),this.render.setRightPage(this.pages[b[1]])):this.render.getOrientation()==="landscape"&&b[0]===this.pages.length-1?(this.render.setLeftPage(this.pages[b[0]]),this.render.setRightPage(null)):(this.render.setLeftPage(null),this.render.setRightPage(this.pages[b[0]])),this.currentPageIndex=b[0],this.app.updatePageIndex(this.currentPageIndex)}}class Z extends i{constructor(b,w,n){super(b,w),this.imagesHref=n}load(){for(const b of this.imagesHref){const w=new A(this.render,b,"soft");w.load(),this.pages.push(w)}this.createSpread()}}class d{static GetDistanceBetweenTwoPoint(b,w){return b===null||w===null?1/0:Math.sqrt(Math.pow(w.x-b.x,2)+Math.pow(w.y-b.y,2))}static GetSegmentLength(b){return d.GetDistanceBetweenTwoPoint(b[0],b[1])}static GetAngleBetweenTwoLine(b,w){const n=b[0].y-b[1].y,y=w[0].y-w[1].y,H=b[1].x-b[0].x,M=w[1].x-w[0].x;return Math.acos((n*y+H*M)/(Math.sqrt(n*n+H*H)*Math.sqrt(y*y+M*M)))}static PointInRect(b,w){return w===null?null:w.x>=b.left&&w.x<=b.width+b.left&&w.y>=b.top&&w.y<=b.top+b.height?w:null}static GetRotatedPoint(b,w,n){return{x:b.x*Math.cos(n)+b.y*Math.sin(n)+w.x,y:b.y*Math.cos(n)-b.x*Math.sin(n)+w.y}}static LimitPointToCircle(b,w,n){if(d.GetDistanceBetweenTwoPoint(b,n)<=w)return n;const y=b.x,H=b.y,M=n.x,K=n.y;let D=Math.sqrt(Math.pow(w,2)*Math.pow(y-M,2)/(Math.pow(y-M,2)+Math.pow(H-K,2)))+y;n.x<0&&(D*=-1);let p=(D-y)*(H-K)/(y-M)+H;return y-M+H===0&&(p=w),{x:D,y:p}}static GetIntersectBetweenTwoSegment(b,w,n){return d.PointInRect(b,d.GetIntersectBeetwenTwoLine(w,n))}static GetIntersectBeetwenTwoLine(b,w){const n=b[0].y-b[1].y,y=w[0].y-w[1].y,H=b[1].x-b[0].x,M=w[1].x-w[0].x,K=b[0].x*b[1].y-b[1].x*b[0].y,D=w[0].x*w[1].y-w[1].x*w[0].y,p=n*D-y*K,O=H*D-M*K,U=-(K*M-D*H)/(n*M-y*H),II=-(n*D-y*K)/(n*M-y*H);if(isFinite(U)&&isFinite(II))return{x:U,y:II};if(Math.abs(p-O)<.1)throw new Error("Segment included");return null}static GetCordsFromTwoPoint(b,w){const n=Math.abs(b.x-w.x),y=Math.abs(b.y-w.y),H=Math.max(n,y),M=[b];function K(D,p,O,U,II){return p>D?D+II*(O/U):p<D?D-II*(O/U):D}for(let D=1;D<=H;D+=1)M.push({x:K(b.x,w.x,n,H,D),y:K(b.y,w.y,y,H,D)});return M}}class s extends C{constructor(b,w,n){super(b,n),this.copiedElement=null,this.temporaryCopy=null,this.isLoad=!1,this.element=w,this.element.classList.add("stf__item"),this.element.classList.add("--"+n)}newTemporaryCopy(){return this.nowDrawingDensity==="hard"?this:(this.temporaryCopy===null&&(this.copiedElement=this.element.cloneNode(!0),this.element.parentElement.appendChild(this.copiedElement),this.temporaryCopy=new s(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(b){const w=b||this.nowDrawingDensity,n=this.render.convertToGlobal(this.state.position),y=this.render.getRect().pageWidth,H=this.render.getRect().height;this.element.classList.remove("--simple");const M=`
display: block;
z-index: ${this.element.style.zIndex};
left: 0;
top: 0;
width: ${y}px;
height: ${H}px;
`;w==="hard"?this.drawHard(M):this.drawSoft(n,M)}drawHard(b=""){const w=this.render.getRect().left+this.render.getRect().width/2,n=this.state.hardDrawingAngle,y=b+`
backface-visibility: hidden;
-webkit-backface-visibility: hidden;
clip-path: none;
-webkit-clip-path: none;
`+(this.orientation===0?`transform-origin: ${this.render.getRect().pageWidth}px 0;
transform: translate3d(0, 0, 0) rotateY(${n}deg);`:`transform-origin: 0 0;
transform: translate3d(${w}px, 0, 0) rotateY(${n}deg);`);this.element.style.cssText=y}drawSoft(b,w=""){let n="polygon( ";for(const H of this.state.area)if(H!==null){let M=this.render.getDirection()===1?{x:-H.x+this.state.position.x,y:H.y-this.state.position.y}:{x:H.x-this.state.position.x,y:H.y-this.state.position.y};M=d.GetRotatedPoint(M,{x:0,y:0},this.state.angle),n+=M.x+"px "+M.y+"px, "}n=n.slice(0,-2),n+=")";const y=w+`transform-origin: 0 0; clip-path: ${n}; -webkit-clip-path: ${n};`+(this.render.isSafari()&&this.state.angle===0?`transform: translate(${b.x}px, ${b.y}px);`:`transform: translate3d(${b.x}px, ${b.y}px, 0) rotate(${this.state.angle}rad);`);this.element.style.cssText=y}simpleDraw(b){const w=this.render.getRect(),n=w.pageWidth,y=w.height,H=b===1?w.left+w.pageWidth:w.left,M=w.top;this.element.classList.add("--simple"),this.element.style.cssText=`
position: absolute;
display: block;
height: ${y}px;
left: ${H}px;
top: ${M}px;
width: ${n}px;
z-index: ${this.render.getSettings().startZIndex+1};`}getElement(){return this.element}load(){this.isLoad=!0}setOrientation(b){super.setOrientation(b),this.element.classList.remove("--left","--right"),this.element.classList.add(b===1?"--right":"--left")}setDrawingDensity(b){this.element.classList.remove("--soft","--hard"),this.element.classList.add("--"+b),super.setDrawingDensity(b)}}class c extends i{constructor(b,w,n,y){super(b,w),this.element=n,this.pagesElement=y}load(){for(const b of this.pagesElement){const w=new s(this.render,b,b.dataset.density==="hard"?"hard":"soft");w.load(),this.pages.push(w)}this.createSpread()}}class G{constructor(b,w,n,y){this.direction=b,this.corner=w,this.topIntersectPoint=null,this.sideIntersectPoint=null,this.bottomIntersectPoint=null,this.pageWidth=parseInt(n,10),this.pageHeight=parseInt(y,10)}calc(b){try{return this.position=this.calcAngleAndPosition(b),this.calculateIntersectPoint(this.position),!0}catch{return!1}}getFlippingClipArea(){const b=[];let w=!1;return b.push(this.rect.topLeft),b.push(this.topIntersectPoint),this.sideIntersectPoint===null?w=!0:(b.push(this.sideIntersectPoint),this.bottomIntersectPoint===null&&(w=!1)),b.push(this.bottomIntersectPoint),(w||this.corner==="bottom")&&b.push(this.rect.bottomLeft),b}getBottomClipArea(){const b=[];return b.push(this.topIntersectPoint),this.corner==="top"?b.push({x:this.pageWidth,y:0}):(this.topIntersectPoint!==null&&b.push({x:this.pageWidth,y:0}),b.push({x:this.pageWidth,y:this.pageHeight})),this.sideIntersectPoint!==null?d.GetDistanceBetweenTwoPoint(this.sideIntersectPoint,this.topIntersectPoint)>=10&&b.push(this.sideIntersectPoint):this.corner==="top"&&b.push({x:this.pageWidth,y:this.pageHeight}),b.push(this.bottomIntersectPoint),b.push(this.topIntersectPoint),b}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}getShadowAngle(){const b=d.GetAngleBetweenTwoLine(this.getSegmentToShadowLine(),[{x:0,y:0},{x:this.pageWidth,y:0}]);return this.direction===0?b:Math.PI-b}calcAngleAndPosition(b){let w=b;if(this.updateAngleAndGeometry(w),w=this.corner==="top"?this.checkPositionAtCenterLine(w,{x:0,y:0},{x:0,y:this.pageHeight}):this.checkPositionAtCenterLine(w,{x:0,y:this.pageHeight},{x:0,y:0}),Math.abs(w.x-this.pageWidth)<1&&Math.abs(w.y)<1)throw new Error("Point is too small");return w}updateAngleAndGeometry(b){this.angle=this.calculateAngle(b),this.rect=this.getPageRect(b)}calculateAngle(b){const w=this.pageWidth-b.x+1,n=this.corner==="bottom"?this.pageHeight-b.y:b.y;let y=2*Math.acos(w/Math.sqrt(n*n+w*w));n<0&&(y=-y);const H=Math.PI-y;if(!isFinite(y)||H>=0&&H<.003)throw new Error("The G point is too small");return this.corner==="bottom"&&(y=-y),y}getPageRect(b){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}],b):this.getRectFromBasePoint([{x:0,y:-this.pageHeight},{x:this.pageWidth,y:-this.pageHeight},{x:0,y:0},{x:this.pageWidth,y:0}],b)}getRectFromBasePoint(b,w){return{topLeft:this.getRotatedPoint(b[0],w),topRight:this.getRotatedPoint(b[1],w),bottomLeft:this.getRotatedPoint(b[2],w),bottomRight:this.getRotatedPoint(b[3],w)}}getRotatedPoint(b,w){return{x:b.x*Math.cos(this.angle)+b.y*Math.sin(this.angle)+w.x,y:b.y*Math.cos(this.angle)-b.x*Math.sin(this.angle)+w.y}}calculateIntersectPoint(b){const w={left:-1,top:-1,width:this.pageWidth+2,height:this.pageHeight+2};this.corner==="top"?(this.topIntersectPoint=d.GetIntersectBetweenTwoSegment(w,[b,this.rect.topRight],[{x:0,y:0},{x:this.pageWidth,y:0}]),this.sideIntersectPoint=d.GetIntersectBetweenTwoSegment(w,[b,this.rect.bottomLeft],[{x:this.pageWidth,y:0},{x:this.pageWidth,y:this.pageHeight}]),this.bottomIntersectPoint=d.GetIntersectBetweenTwoSegment(w,[this.rect.bottomLeft,this.rect.bottomRight],[{x:0,y:this.pageHeight},{x:this.pageWidth,y:this.pageHeight}])):(this.topIntersectPoint=d.GetIntersectBetweenTwoSegment(w,[this.rect.topLeft,this.rect.topRight],[{x:0,y:0},{x:this.pageWidth,y:0}]),this.sideIntersectPoint=d.GetIntersectBetweenTwoSegment(w,[b,this.rect.topLeft],[{x:this.pageWidth,y:0},{x:this.pageWidth,y:this.pageHeight}]),this.bottomIntersectPoint=d.GetIntersectBetweenTwoSegment(w,[this.rect.bottomLeft,this.rect.bottomRight],[{x:0,y:this.pageHeight},{x:this.pageWidth,y:this.pageHeight}]))}checkPositionAtCenterLine(b,w,n){let y=b;const H=d.LimitPointToCircle(w,this.pageWidth,y);y!==H&&(y=H,this.updateAngleAndGeometry(y));const M=Math.sqrt(Math.pow(this.pageWidth,2)+Math.pow(this.pageHeight,2));let K=this.rect.bottomRight,D=this.rect.topLeft;if(this.corner==="bottom"&&(K=this.rect.topRight,D=this.rect.bottomLeft),K.x<=0){const p=d.LimitPointToCircle(n,M,D);p!==y&&(y=p,this.updateAngleAndGeometry(y))}return y}getSegmentToShadowLine(){const b=this.getShadowStartPoint();return[b,b!==this.sideIntersectPoint&&this.sideIntersectPoint!==null?this.sideIntersectPoint:this.bottomIntersectPoint]}}class B{constructor(b,w){this.flippingPage=null,this.bottomPage=null,this.calc=null,this.state="read",this.render=b,this.app=w}fold(b){this.setState("user_fold"),this.calc===null&&this.start(b),this.do(this.render.convertToPage(b))}flip(b){if(this.app.getSettings().disableFlipByClick&&!this.isPointOnCorners(b)||(this.calc!==null&&this.render.finishAnimation(),!this.start(b)))return;const w=this.getBoundsRect();this.setState("flipping");const n=w.height/10,y=this.calc.getCorner()==="bottom"?w.height-n:n,H=this.calc.getCorner()==="bottom"?w.height:0;this.calc.calc({x:w.pageWidth-n,y}),this.animateFlippingTo({x:w.pageWidth-n,y},{x:-w.pageWidth,y:H},!0)}start(b){this.reset();const w=this.render.convertToBook(b),n=this.getBoundsRect(),y=this.getDirectionByPoint(w),H=w.y>=n.height/2?"bottom":"top";if(!this.checkDirection(y))return!1;try{if(this.flippingPage=this.app.getPageCollection().getFlippingPage(y),this.bottomPage=this.app.getPageCollection().getBottomPage(y),this.render.getOrientation()==="landscape")if(y===1){const M=this.app.getPageCollection().nextBy(this.flippingPage);M!==null&&this.flippingPage.getDensity()!==M.getDensity()&&(this.flippingPage.setDrawingDensity("hard"),M.setDrawingDensity("hard"))}else{const M=this.app.getPageCollection().prevBy(this.flippingPage);M!==null&&this.flippingPage.getDensity()!==M.getDensity()&&(this.flippingPage.setDrawingDensity("hard"),M.setDrawingDensity("hard"))}return this.render.setDirection(y),this.calc=new G(y,H,n.pageWidth.toString(10),n.height.toString(10)),!0}catch{return!1}}do(b){if(this.calc!==null&&this.calc.calc(b)){const w=this.calc.getFlippingProgress();this.bottomPage.setArea(this.calc.getBottomClipArea()),this.bottomPage.setPosition(this.calc.getBottomPagePosition()),this.bottomPage.setAngle(0),this.bottomPage.setHardAngle(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*w)/100):this.flippingPage.setHardAngle(-90*(200-2*w)/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(),w,this.calc.getDirection())}}flipToPage(b,w){const n=this.app.getPageCollection().getCurrentSpreadIndex(),y=this.app.getPageCollection().getSpreadIndexByPage(b);try{y>n&&(this.app.getPageCollection().setCurrentSpreadIndex(y-1),this.flipNext(w)),y<n&&(this.app.getPageCollection().setCurrentSpreadIndex(y+1),this.flipPrev(w))}catch{}}flipNext(b){this.flip({x:this.render.getRect().left+2*this.render.getRect().pageWidth-10,y:b==="top"?1:this.render.getRect().height-2})}flipPrev(b){this.flip({x:10,y:b==="top"?1:this.render.getRect().height-2})}stopMove(){if(this.calc===null)return;const b=this.calc.getPosition(),w=this.getBoundsRect(),n=this.calc.getCorner()==="bottom"?w.height:0;b.x<=0?this.animateFlippingTo(b,{x:-w.pageWidth,y:n},!0):this.animateFlippingTo(b,{x:w.pageWidth,y:n},!1)}showCorner(b){if(!this.checkState("read","fold_corner"))return;const w=this.getBoundsRect(),n=w.pageWidth;if(this.isPointOnCorners(b))if(this.calc===null){if(!this.start(b))return;this.setState("fold_corner"),this.calc.calc({x:n-1,y:1});const y=50,H=this.calc.getCorner()==="bottom"?w.height-1:1,M=this.calc.getCorner()==="bottom"?w.height-y:y;this.animateFlippingTo({x:n-1,y:H},{x:n-y,y:M},!1,!1)}else this.do(this.render.convertToPage(b));else this.setState("read"),this.render.finishAnimation(),this.stopMove()}animateFlippingTo(b,w,n,y=!0){const H=d.GetCordsFromTwoPoint(b,w),M=[];for(const D of H)M.push(()=>this.do(D));const K=this.getAnimationDuration(H.length);this.render.startAnimation(M,K,()=>{this.calc&&(n&&(this.calc.getDirection()===1?this.app.turnToPrevPage():this.app.turnToNextPage()),y&&(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(b){this.state!==b&&(this.app.updateState(b),this.state=b)}getDirectionByPoint(b){const w=this.getBoundsRect();if(this.render.getOrientation()==="portrait"){if(b.x-w.pageWidth<=w.width/5)return 1}else if(b.x<w.width/2)return 1;return 0}getAnimationDuration(b){const w=this.app.getSettings().flippingTime;return b>=1e3?w:b/1e3*w}checkDirection(b){return b===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(...b){for(const w of b)if(this.state===w)return!0;return!1}isPointOnCorners(b){const w=this.getBoundsRect(),n=w.pageWidth,y=Math.sqrt(Math.pow(n,2)+Math.pow(w.height,2))/5,H=this.render.convertToBook(b);return H.x>0&&H.y>0&&H.x<w.width&&H.y<w.height&&(H.x<y||H.x>w.width-y)&&(H.y<y||H.y>w.height-y)}}class o{constructor(b,w){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=w,this.app=b;const n=new RegExp("Version\\/[\\d\\.]+.*Safari/");this.safari=n.exec(window.navigator.userAgent)!==null}render(b){if(this.animation!==null){const w=Math.round((b-this.animation.startedAt)/this.animation.durationFrame);w<this.animation.frames.length?this.animation.frames[w]():(this.animation.onAnimateEnd(),this.animation=null)}this.timer=b,this.drawFrame()}start(){this.update();const b=w=>{this.render(w),requestAnimationFrame(b)};requestAnimationFrame(b)}startAnimation(b,w,n){this.finishAnimation(),this.animation={frames:b,duration:w,durationFrame:w/b.length,onAnimateEnd:n,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 b=this.calculateBoundsRect();this.orientation!==b&&(this.orientation=b,this.app.updateOrientation(b))}calculateBoundsRect(){let b="landscape";const w=this.getBlockWidth(),n=w/2,y=this.getBlockHeight()/2,H=this.setting.width/this.setting.height;let M=this.setting.width,K=this.setting.height,D=n-M;return this.setting.size==="stretch"?(w<2*this.setting.minWidth&&this.app.getSettings().usePortrait&&(b="portrait"),M=b==="portrait"?this.getBlockWidth():this.getBlockWidth()/2,M>this.setting.maxWidth&&(M=this.setting.maxWidth),K=M/H,K>this.getBlockHeight()&&(K=this.getBlockHeight(),M=K*H),D=b==="portrait"?n-M/2-M:n-M):w<2*M&&this.app.getSettings().usePortrait&&(b="portrait",D=n-M/2-M),this.boundsRect={left:D,top:y-K/2,width:2*M,height:K,pageWidth:M},b}setShadowData(b,w,n,y){if(!this.app.getSettings().drawShadow)return;const H=100*this.getSettings().maxShadowOpacity;this.shadow={pos:b,angle:w,width:3*this.getRect().pageWidth/4*n/100,opacity:(100-n)*H/100/100,direction:y,progress:2*n}}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(b){this.pageRect=b}setDirection(b){this.direction=b}setRightPage(b){b!==null&&b.setOrientation(1),this.rightPage=b}setLeftPage(b){b!==null&&b.setOrientation(0),this.leftPage=b}setBottomPage(b){b!==null&&b.setOrientation(this.direction===1?0:1),this.bottomPage=b}setFlippingPage(b){b!==null&&b.setOrientation(this.direction===0&&this.orientation!=="portrait"?0:1),this.flippingPage=b}convertToBook(b){const w=this.getRect();return{x:b.x-w.left,y:b.y-w.top}}isSafari(){return this.safari}convertToPage(b,w){w||(w=this.direction);const n=this.getRect();return{x:w===0?b.x-n.left-n.width/2:n.width/2-b.x+n.left,y:b.y-n.top}}convertToGlobal(b,w){if(w||(w=this.direction),b==null)return null;const n=this.getRect();return{x:w===0?b.x+n.left+n.width/2:n.width/2-b.x+n.left,y:b.y+n.top}}convertRectToGlobal(b,w){return w||(w=this.direction),{topLeft:this.convertToGlobal(b.topLeft,w),topRight:this.convertToGlobal(b.topRight,w),bottomLeft:this.convertToGlobal(b.bottomLeft,w),bottomRight:this.convertToGlobal(b.bottomRight,w)}}}class h extends o{constructor(b,w,n){super(b,w),this.canvas=n,this.ctx=n.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 b=this.getRect();this.orientation==="portrait"&&(this.ctx.beginPath(),this.ctx.rect(b.left+b.pageWidth,b.top,b.width,b.height),this.ctx.clip())}drawBookShadow(){const b=this.getRect();this.ctx.save(),this.ctx.beginPath();const w=b.width/20;this.ctx.rect(b.left,b.top,b.width,b.height);const n={x:b.left+b.width/2-w/2,y:0};this.ctx.translate(n.x,n.y);const y=this.ctx.createLinearGradient(0,0,w,0);y.addColorStop(0,"rgba(0, 0, 0, 0)"),y.addColorStop(.4,"rgba(0, 0, 0, 0.2)"),y.addColorStop(.49,"rgba(0, 0, 0, 0.1)"),y.addColorStop(.5,"rgba(0, 0, 0, 0.5)"),y.addColorStop(.51,"rgba(0, 0, 0, 0.4)"),y.addColorStop(1,"rgba(0, 0, 0, 0)"),this.ctx.clip(),this.ctx.fillStyle=y,this.ctx.fillRect(0,0,w,2*b.height),this.ctx.restore()}drawOuterShadow(){const b=this.getRect();this.ctx.save(),this.ctx.beginPath(),this.ctx.rect(b.left,b.top,b.width,b.height);const w=this.convertToGlobal({x:this.shadow.pos.x,y:this.shadow.pos.y});this.ctx.translate(w.x,w.y),this.ctx.rotate(Math.PI+this.shadow.angle+Math.PI/2);const n=this.ctx.createLinearGradient(0,0,this.shadow.width,0);this.shadow.direction===0?(this.ctx.translate(0,-100),n.addColorStop(0,"rgba(0, 0, 0, "+this.shadow.opacity+")"),n.addColorStop(1,"rgba(0, 0, 0, 0)")):(this.ctx.translate(-this.shadow.width,-100),n.addColorStop(0,"rgba(0, 0, 0, 0)"),n.addColorStop(1,"rgba(0, 0, 0, "+this.shadow.opacity+")")),this.ctx.clip(),this.ctx.fillStyle=n,this.ctx.fillRect(0,0,this.shadow.width,2*b.height),this.ctx.restore()}drawInnerShadow(){const b=this.getRect();this.ctx.save(),this.ctx.beginPath();const w=this.convertToGlobal({x:this.shadow.pos.x,y:this.shadow.pos.y}),n=this.convertRectToGlobal(this.pageRect);this.ctx.moveTo(n.topLeft.x,n.topLeft.y),this.ctx.lineTo(n.topRight.x,n.topRight.y),this.ctx.lineTo(n.bottomRight.x,n.bottomRight.y),this.ctx.lineTo(n.bottomLeft.x,n.bottomLeft.y),this.ctx.translate(w.x,w.y),this.ctx.rotate(Math.PI+this.shadow.angle+Math.PI/2);const y=3*this.shadow.width/4,H=this.ctx.createLinearGradient(0,0,y,0);this.shadow.direction===0?(this.ctx.translate(-y,-100),H.addColorStop(1,"rgba(0, 0, 0, "+this.shadow.opacity+")"),H.addColorStop(.9,"rgba(0, 0, 0, 0.05)"),H.addColorStop(.7,"rgba(0, 0, 0, "+this.shadow.opacity+")"),H.addColorStop(0,"rgba(0, 0, 0, 0)")):(this.ctx.translate(0,-100),H.addColorStop(0,"rgba(0, 0, 0, "+this.shadow.opacity+")"),H.addColorStop(.1,"rgba(0, 0, 0, 0.05)"),H.addColorStop(.3,"rgba(0, 0, 0, "+this.shadow.opacity+")"),H.addColorStop(1,"rgba(0, 0, 0, 0)")),this.ctx.clip(),this.ctx.fillStyle=H,this.ctx.fillRect(0,0,y,2*b.height),this.ctx.restore()}clear(){this.ctx.fillStyle="white",this.ctx.fillRect(0,0,this.canvas.width,this.canvas.height)}}class N{constructor(b,w,n){this.touchPoint=null,this.swipeTimeout=250,this.onResize=()=>{this.update()},this.onMouseDown=H=>{if(this.checkTarget(H.target)){const M=this.getMousePos(H.clientX,H.clientY);this.app.startUserTouch(M),H.preventDefault()}},this.onTouchStart=H=>{if(this.checkTarget(H.target)&&H.changedTouches.length>0){const M=H.changedTouches[0],K=this.getMousePos(M.clientX,M.clientY);this.touchPoint={point:K,time:Date.now()},setTimeout(()=>{this.touchPoint!==null&&this.app.startUserTouch(K)},this.swipeTimeout),this.app.getSettings().mobileScrollSupport||H.preventDefault()}},this.onMouseUp=H=>{const M=this.getMousePos(H.clientX,H.clientY);this.app.userStop(M)},this.onMouseMove=H=>{const M=this.getMousePos(H.clientX,H.clientY);this.app.userMove(M,!1)},this.onTouchMove=H=>{if(H.changedTouches.length>0){const M=H.changedTouches[0],K=this.getMousePos(M.clientX,M.clientY);this.app.getSettings().mobileScrollSupport?(this.touchPoint!==null&&(Math.abs(this.touchPoint.point.x-K.x)>10||this.app.getState()!=="read")&&H.cancelable&&this.app.userMove(K,!0),this.app.getState()!=="read"&&H.preventDefault()):this.app.userMove(K,!0)}},this.onTouchEnd=H=>{if(H.changedTouches.length>0){const M=H.changedTouches[0],K=this.getMousePos(M.clientX,M.clientY);let D=!1;if(this.touchPoint!==null){const p=K.x-this.touchPoint.point.x,O=Math.abs(K.y-this.touchPoint.point.y);Math.abs(p)>this.swipeDistance&&O<2*this.swipeDistance&&Date.now()-this.touchPoint.time<this.swipeTimeout&&(p>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"),D=!0),this.touchPoint=null}this.app.userStop(K,D)}},this.parentElement=b,b.classList.add("stf__parent"),b.insertAdjacentHTML("afterbegin",'<div class="stf__wrapper"></div>'),this.wrapper=b.querySelector(".stf__wrapper"),this.app=w;const y=this.app.getSettings().usePortrait?1:2;b.style.minWidth=n.minWidth*y+"px",b.style.minHeight=n.minHeight+"px",n.size==="fixed"&&(b.style.minWidth=n.width*y+"px",b.style.minHeight=n.height+"px"),n.autoSize&&(b.style.width="100%",b.style.maxWidth=2*n.maxWidth+"px"),b.style.display="block",window.addEventListener("resize",this.onResize,!1),this.swipeDistance=n.swipeDistance}destroy(){this.app.getSettings().useMouseEvents&&this.removeHandlers(),this.distElement.remove(),this.wrapper.remove()}getDistElement(){return this.distElement}getWrapper(){return this.wrapper}setOrientationStyle(b){this.wrapper.classList.remove("--portrait","--landscape"),b==="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(b,w){const n=this.distElement.getBoundingClientRect();return{x:b-n.left,y:w-n.top}}checkTarget(b){return!this.app.getSettings().clickEventForward||!["a","button"].includes(b.tagName.toLowerCase())}}class V extends N{constructor(b,w,n,y){super(b,w,n),this.wrapper.insertAdjacentHTML("afterbegin",'<div class="stf__block"></div>'),this.distElement=b.querySelector(".stf__block"),this.items=y;for(const H of y)this.distElement.appendChild(H);this.setHandlers()}clear(){for(const b of this.items)this.parentElement.appendChild(b)}updateItems(b){this.removeHandlers(),this.distElement.innerHTML="";for(const w of b)this.distElement.appendChild(w);this.items=b,this.setHandlers()}update(){this.app.getRender().update()}}class t extends N{constructor(b,w,n){super(b,w,n),this.wrapper.innerHTML='<canvas class="stf__canvas"></canvas>',this.canvas=b.querySelectorAll("canvas")[0],this.distElement=this.canvas,this.resizeCanvas(),this.setHandlers()}resizeCanvas(){const b=getComputedStyle(this.canvas),w=parseInt(b.getPropertyValue("width"),10),n=parseInt(b.getPropertyValue("height"),10);this.canvas.width=w,this.canvas.height=n}getCanvas(){return this.canvas}update(){this.resizeCanvas(),this.app.getRender().update()}}class X extends o{constructor(b,w,n){super(b,w),this.outerShadow=null,this.innerShadow=null,this.hardShadow=null,this.hardInnerShadow=null,this.element=n,this.createShadows()}createShadows(){this.element.insertAdjacentHTML("beforeend",`<div class="stf__outerShadow"></div>
<div class="stf__innerShadow"></div>
<div class="stf__hardShadow"></div>
<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 b=this.getRect(),w=this.shadow.progress>100?200-this.shadow.progress:this.shadow.progress;let n=(100-w)*(2.5*b.pageWidth)/100+20;n>b.pageWidth&&(n=b.pageWidth);let y=`
display: block;
z-index: ${(this.getSettings().startZIndex+5).toString(10)};
width: ${n}px;
height: ${b.height}px;
background: linear-gradient(to right,
rgba(0, 0, 0, ${this.shadow.opacity*w/100}) 5%,
rgba(0, 0, 0, 0) 100%);
left: ${b.left+b.width/2}px;
transform-origin: 0 0;
`;y+=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=y}drawHardOuterShadow(){const b=this.getRect();let w=(100-(this.shadow.progress>100?200-this.shadow.progress:this.shadow.progress))*(2.5*b.pageWidth)/100+20;w>b.pageWidth&&(w=b.pageWidth);let n=`
display: block;
z-index: ${(this.getSettings().startZIndex+4).toString(10)};
width: ${w}px;
height: ${b.height}px;
background: linear-gradient(to left, rgba(0, 0, 0, ${this.shadow.opacity}) 5%, rgba(0, 0, 0, 0) 100%);
left: ${b.left+b.width/2}px;
transform-origin: 0 0;
`;n+=this.getDirection()===0&&this.shadow.progress>100||this.getDirection()===1&&this.shadow.progress<=100?"transform: translate3d(0, 0, 0) rotateY(180deg);":"transform: translate3d(0, 0, 0);",this.hardShadow.style.cssText=n}drawInnerShadow(){const b=this.getRect(),w=3*this.shadow.width/4,n=this.getDirection()===0?w:0,y=this.getDirection()===0?"to left":"to right",H=this.convertToGlobal(this.shadow.pos),M=this.shadow.angle+3*Math.PI/2,K=[this.pageRect.topLeft,this.pageRect.topRight,this.pageRect.bottomRight,this.pageRect.bottomLeft];let D="polygon( ";for(const O of K){let U=this.getDirection()===1?{x:-O.x+this.shadow.pos.x,y:O.y-this.shadow.pos.y}:{x:O.x-this.shadow.pos.x,y:O.y-this.shadow.pos.y};U=d.GetRotatedPoint(U,{x:n,y:100},M),D+=U.x+"px "+U.y+"px, "}D=D.slice(0,-2),D+=")";const p=`
display: block;
z-index: ${(this.getSettings().startZIndex+10).toString(10)};
width: ${w}px;
height: ${2*b.height}px;
background: linear-gradient(${y},
rgba(0, 0, 0, ${this.shadow.opacity}) 5%,
rgba(0, 0, 0, 0.05) 15%,
rgba(0, 0, 0, ${this.shadow.opacity}) 35%,
rgba(0, 0, 0, 0) 100%);
transform-origin: ${n}px 100px;
transform: translate3d(${H.x-n}px, ${H.y-100}px, 0) rotate(${M}rad);
clip-path: ${D};
-webkit-clip-path: ${D};
`;this.innerShadow.style.cssText=p}drawOuterShadow(){const b=this.getRect(),w=this.convertToGlobal({x:this.shadow.pos.x,y:this.shadow.pos.y}),n=this.shadow.angle+3*Math.PI/2,y=this.getDirection()===1?this.shadow.width:0,H=this.getDirection()===0?"to right":"to left",M=[{x:0,y:0},{x:b.pageWidth,y:0},{x:b.pageWidth,y:b.height},{x:0,y:b.height}];let K="polygon( ";for(const p of M)if(p!==null){let O=this.getDirection()===1?{x:-p.x+this.shadow.pos.x,y:p.y-this.shadow.pos.y}:{x:p.x-this.shadow.pos.x,y:p.y-this.shadow.pos.y};O=d.GetRotatedPoint(O,{x:y,y:100},n),K+=O.x+"px "+O.y+"px, "}K=K.slice(0,-2),K+=")";const D=`
display: block;
z-index: ${(this.getSettings().startZIndex+10).toString(10)};
width: ${this.shadow.width}px;
height: ${2*b.height}px;
background: linear-gradient(${H}, rgba(0, 0, 0, ${this.shadow.opacity}), rgba(0, 0, 0, 0));
transform-origin: ${y}px 100px;
transform: translate3d(${w.x-y}px, ${w.y-100}px, 0) rotate(${n}rad);
clip-path: ${K};
-webkit-clip-path: ${K};
`;this.outerShadow.style.cssText=D}drawLeftPage(){this.orientation!=="portrait"&&this.leftPage!==null&&(this.direction===1&&