@sbseguros/design-system
Version:
A Vue 3 design system with Tailwind CSS and Lucide icons.
95 lines • 2.95 MB
JavaScript
var SBSDesignSystem=function(P,t){"use strict";var ph=Object.defineProperty;var um=P=>{throw TypeError(P)};var Fh=(P,t,wI)=>t in P?ph(P,t,{enumerable:!0,configurable:!0,writable:!0,value:wI}):P[t]=wI;var S=(P,t,wI)=>Fh(P,typeof t!="symbol"?t+"":t,wI),nb=(P,t,wI)=>t.has(P)||um("Cannot "+wI);var l=(P,t,wI)=>(nb(P,t,"read from private field"),wI?wI.call(P):t.get(P)),Y=(P,t,wI)=>t.has(P)?um("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(P):t.set(P,wI),W=(P,t,wI,Bl)=>(nb(P,t,"write to private field"),Bl?Bl.call(P,wI):t.set(P,wI),wI),a=(P,t,wI)=>(nb(P,t,"access private method"),wI);var mg=(P,t,wI,Bl)=>({set _(Ac){W(P,t,Ac,wI)},get _(){return l(P,t,Bl)}});/*! berea-ui v0.0.39 | (c) 2025 SBS Seguros Design System | MIT License | https://github.com/sbs-seguros-col/sbs-common-components */var JC,vc,eb,ms,eA,Vl,Lg,yA,Bs,Fi,os,Hc,Mm,xI,Dm,Km,Td,Sm,Ec,Ws,Nl,tl,RA,pm,Fm,zm,uc,zi,ws,$I,Ji,Pc,tI,XA,hs,YI,Mc,Jm,ki,tg,MI,rI,Li,LC,Ti,Tg,HA,uA,ji,nl,hC,fg,el,Ys,as,Qi,Vs,YC,MA,Oi,DA,aC,Kc,KA,Ns,SA,yl,Rl,pA,ts,FI,iI,TC,FA,Xl,ns,es,zA,VC,jC,ys,jg,F,fc,yb,km,Lm,_c,Tm,jm,Qm,Rb,Om,Xb,Hb,xm,Bg,aA,rm,Um,ub,vm,jd,Mb,zI,NC,_g,ri,tC,ng,Ui,nC,wg,QC,Hl,eC,JA,qg,Qd,qc,vi,ul,Rs,Xs,Hs,us,Ms,OC,Ml,xC,Dl,rC,kA,Em,Pm,fm,Kl,$g,mI,Ei,LA,Ds,Sl,UI,pl,UC,TA,Ks,Fl,eg,Ss,zl,vC,yC,Pi,fi,Qg,Jl,ps,Sc,x,Db,Fs,Kb,$c,_m,qm,Sb,IG,pb,$m,IB,gB,Fb,CB,zb,AB,lB,iB,Jb,Od,kl,Ll,vI,pc,ZB,zs,_i,EC,Fc,qi,Og,sB,dB,cB,gG,Js,Tl,$i,PC,fC,Ig,jl,Ql,z,Ag,xd,xZ,CG,rZ,GB,kb,UZ,rd,Ud,Lb,vd,IC,Tb,jb,Qb,ks,Ls,IZ,Ts,js,Qs,Os,gZ,jA,sI,CZ,AZ,xs,Ob,yg,rs,xb,Xm,QA,hg,Us,vs,Ol,_C,Es,Ps,xl,lZ,iZ,OA,ZZ,fs,sZ,rl,_s,qs,dZ,Ul,$s,xA,cZ,qC,bB,mB,rb,Rg,AG,Ub,BB,oB,Jc,vl,Id,gd,Cd,Ad,$C,El,Ed,rA,gC,IA,Pl,Lc,fl,_l,sg,lG,WB,wB,Pd,GZ,iG,gA,RC,bZ,mZ,CA,ql,fd,UA,vA,$l,gi,BZ,oZ,ld,vb,Xg,Xi,hB,YB,WZ,Tc,jc,wZ,hZ,aI,AA,YZ,id,Zd,aZ,lA,CC,iA,sd,ZA,dd,Ci,Ai,dI,ZG,Eb,aB,VB,NB,tB,sG,dG,Pb,cd,Gd,bd,md,Bd,li,od,fb,Wd,wd,_b,hd,ii,EA,Yd,PA,qb,$b,AC,Hg,ad,Zi,ug,uI,nB,eB,yB,cG,sA,GG,bG,RB,I0,XB,Mg,lC,VZ,NZ,XC,_,si,di,Vd,Nd,tZ,nZ,fA,td,Qc,Oc,KI,_d,HB,uB,MB,DB,KB,SB,eZ,ci,cA,nd,Dg,ed,nI,xc,pB,yd,Rd,_A,iC,dg,FB,mG,zB,JB,g0,Xd,yZ,ZC,Gi,RZ,SI,Hd,XZ,ud,Md,qA,sC,HZ,Dd,cI,C0,A0,l0,Hi,kB,ml,uZ,Kd,GA,bi,MZ,ag,Sd,pd,mi,xg,Kg,EI,DZ,bA,gg,KZ,rg,Fd,E,i0,BG,LB,TB,jB,Z0,ui,Ug,vZ,QB,oG,qd,OB,xB,rB,UB,vB,Bi,Sg,SZ,JI,oi,Wi,$A,Il,gl,wi,gI,s0,d0,c0,$d,EB,WG,Ic,EZ,HC,kI,LI,hi,pZ,cg,PI,vg,Yi,ai,Vi,FZ,wG,Gg,zd,Jd,pg,uC,MC,zZ,JZ,Ni,fI,VA,PB,fB,_B,rc,qB,ti,lI,G0,dC,$B,Io,b0,hG,go,Co,Ao,m0,B0,lo,Cl,Fg,Al,ll,oI,TI,il,mA,Zl,LZ,BA,ni,DC,Jg,TZ,CI,gc,Cc,YG,aG,VG,o0,NG,io,ei,jZ,KC,sl,oA,Eg,dl,QZ,yi,cC,WA,Cg,wA,j,cl,WI,Zo,pC,W0,w0,tG,bC,bg,Ri,kd,Uc,so,SC,h0,co,Y0;var wI=typeof document<"u"?document.currentScript:null;const Bl=t.defineComponent({__name:"Button",props:{label:{},primary:{type:Boolean,default:!1},size:{},backgroundColor:{}},emits:["click"],setup(m,{emit:I}){const g=m,C=I,A=t.computed(()=>({"storybook-button":!0,"storybook-button--primary":g.primary,"storybook-button--secondary":!g.primary,[`storybook-button--${g.size||"medium"}`]:!0})),i=t.computed(()=>({backgroundColor:g.backgroundColor})),Z=()=>{C("click",1)};return(s,d)=>(t.openBlock(),t.createElementBlock("button",{type:"button",class:t.normalizeClass(A.value),onClick:Z,style:t.normalizeStyle(i.value)},t.toDisplayString(s.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 Ac=m=>m.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Go=m=>m.replace(/^([A-Z])|[\s-_]+(\w)/g,(I,g,C)=>C?C.toUpperCase():g.toLowerCase()),bo=m=>{const I=Go(m);return I.charAt(0).toUpperCase()+I.slice(1)},mo=(...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 lc={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 Bo=({size:m,strokeWidth:I=2,absoluteStrokeWidth:g,color:C,iconNode:A,name:i,class:Z,...s},{slots:d})=>t.h("svg",{...lc,width:m||lc.width,height:m||lc.height,stroke:C||lc.stroke,"stroke-width":g?Number(I)*24/Number(m):I,class:mo("lucide",...i?[`lucide-${Ac(bo(i))}-icon`,`lucide-${Ac(i)}`]:["lucide-icon"]),...s},[...A.map(c=>t.h(...c)),...d.default?[d.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 nG=(m,I)=>(g,{slots:C})=>t.h(Bo,{...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 oo=nG("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 a0=nG("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 eG=nG("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]),Wo={class:"h-6 w-6 flex p-[5px] justify-center items-center shrink-0"},wo={class:"text-sm font-medium leading-6 underline text-grey-grey-900 font-inter"},ho={class:"inline-flex items-center gap-1 px-4 py-2 rounded bg-fill min-w-[161px]"},Yo={class:"text-sm font-medium leading-6 text-grey-grey-700 font-inter"},yG=t.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=t.computed(()=>g.label),i=t.computed(()=>g.page),Z=t.computed(()=>g.width),s=t.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))}),d=()=>{console.log("Back button clicked"),C("back")};return(c,G)=>(t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(`flex gap-10 w-[${Z.value}]`)},[t.createElementVNode("button",{onClick:d,class:"flex items-center gap-1"},[t.createElementVNode("span",Wo,[t.createVNode(t.unref(oo),{class:"w-6 h-6 shrink-0"})]),t.createElementVNode("span",wo,t.toDisplayString(A.value),1)]),t.createElementVNode("div",ho,[t.createElementVNode("span",Yo,t.toDisplayString(i.value),1),t.createVNode(t.unref(eG),{class:"w-4 h-4 text-grey-grey-300"}),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(s.value,(B,o)=>(t.openBlock(),t.createElementBlock(t.Fragment,{key:B},[t.createElementVNode("span",{class:t.normalizeClass({"text-status-focus":o===s.value.length-1,"text-grey-grey-700":o!==s.value.length-1,"font-inter text-sm font-medium leading-6 flex-[1_0_0]":!0})},t.toDisplayString(B),3),o<s.value.length-1?(t.openBlock(),t.createBlock(t.unref(eG),{key:0,class:"w-4 h-4 text-grey-grey-300"})):t.createCommentVNode("",!0)],64))),128))])],2))}}),ao=["src"],Vo={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]"},No={class:"self-stretch text-xl font-normal leading-[30px] font-inter text-grey-grey-600 mr-2"},V0=t.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},contract:{type:Boolean,default:!1}},emits:["back"],setup(m,{emit:I}){const g=m;console.log("Banner props:",g);const C=I,A=t.computed(()=>g.label),i=t.computed(()=>g.width),Z=t.computed(()=>g.path),s=t.computed(()=>g.title),d=t.computed(()=>g.description),c=t.computed(()=>g.src),G=t.computed(()=>g.page),B=t.computed(()=>g.stretch),o=t.computed(()=>g.contract),h=()=>{C("back")};return(V,N)=>(t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(["bg-grey-grey-100 w-full left-0 z-[99] absolute top-40 shrink-0 aspect-[18/5]",B.value?"h-[312px]":"h-[399px]"])},[c.value?(t.openBlock(),t.createElementBlock("img",{key:0,src:c.value,alt:"Profile Header",class:"object-contain w-full h-full"},null,8,ao)):t.createCommentVNode("",!0),t.createVNode(yG,{label:A.value,width:i.value,path:Z.value,page:G.value,class:"absolute top-10 left-[120px] z-[100]",onBack:h},null,8,["label","width","path","page"]),t.createElementVNode("div",{class:t.normalizeClass(["absolute left-[119.2px] flex flex-col h-[125px] items-start text-left gap-4",{"top-[166px] w-[789px]":!B.value&&!o.value,"top-[138px] w-[719px]":o.value,"top-[120px] w-[789px]":B.value}])},[t.createElementVNode("span",Vo,t.toDisplayString(s.value),1),t.createElementVNode("span",No,t.toDisplayString(d.value),1)],2)],2))}}),to={class:"flex flex-col w-full gap-8"},no=["onClick","aria-expanded","aria-controls","aria-label"],eo={class:"self-stretch w-full h-8"},yo={class:"flex items-center gap-2"},Ro=["src"],Xo={key:0,class:"w-6 h-6"},Ho=["id"],uo={class:"flex flex-col self-stretch gap-4 px-10 py-4"},Mo=["onClick","aria-label"],Do=t.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)&&I.children.every(g=>typeof g.key=="string"&&typeof g.name=="string")))},activeForm:{type:String,required:!0},activeChild:{type:Object,default:null}},emits:["click","child-click"],setup(m,{emit:I}){const g=m,C=I,A=o=>d.value===o.key&&o.icon_active?o.icon_active:o.icon,i=o=>{const h=A(o);return typeof h=="string"?h:void 0},Z=o=>typeof o=="string",s=t.computed(()=>g.items),d=t.computed(()=>g.activeForm),c=o=>{var V;const h=((V=g.activeChild)==null?void 0:V.parentKey)===o.key;d.value===o.key&&o.collapsed&&!h?C("click",""):C("click",o.key)},G=(o,h)=>{d.value!==h.key&&C("click",h.key),C("child-click",{parentKey:h.key,childKey:o.key})},B=(o,h)=>{var V,N;return((V=g.activeChild)==null?void 0:V.parentKey)===h.key&&((N=g.activeChild)==null?void 0:N.childKey)===o.key};return(o,h)=>(t.openBlock(),t.createElementBlock("div",to,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(s.value,V=>(t.openBlock(),t.createElementBlock("div",{key:V.key,class:"flex flex-col items-center justify-center w-full h-full"},[t.createElementVNode("button",{type:"button",onClick:N=>c(V),"aria-expanded":m.activeForm===V.key&&V.collapsed,"aria-controls":`submenu-${V.key}`,"aria-label":`Toggle ${V.name} menu`,class:t.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===V.key?"bg-status-focus":"bg-bandn-white"])},[t.createElementVNode("div",eo,[t.createElementVNode("div",yo,[t.createElementVNode("div",{class:t.normalizeClass(["flex w-8 h-8 py-1 px-0.5 items-center justify-center",{"text-grey-grey-900":d.value!==V.key,"text-bandn-white":d.value===V.key}])},[Z(A(V))?(t.openBlock(),t.createElementBlock("img",{key:0,src:i(V),alt:"",class:t.normalizeClass(["object-contain w-8 h-8",{"brightness-0 invert":d.value===V.key,"opacity-100":d.value===V.key,"opacity-70":d.value!==V.key}])},null,10,Ro)):(t.openBlock(),t.createBlock(t.resolveDynamicComponent(A(V)),{key:1,class:t.normalizeClass(["w-8 h-8",{"text-grey-grey-900":d.value!==V.key,"text-bandn-white":d.value===V.key}])},null,8,["class"]))],2),t.createElementVNode("span",{class:t.normalizeClass(["flex-[1_0_0] font-inter text-lg font-semibold text-left",{"text-grey-grey-900":d.value!==V.key,"text-bandn-white":d.value===V.key}])},t.toDisplayString(V.name),3),V.collapsed?(t.openBlock(),t.createElementBlock("div",Xo,[t.createVNode(t.unref(a0),{class:t.normalizeClass(["transition-transform duration-200",{"text-bandn-white":d.value===V.key,"text-grey-grey-900":d.value!==V.key,"rotate-180":d.value===V.key&&V.collapsed}])},null,8,["class"])])):t.createCommentVNode("",!0)])])],10,no),t.createVNode(t.Transition,{name:"fade-slide",mode:"out-in"},{default:t.withCtx(()=>[V.children&&V.children.length?(t.openBlock(),t.createElementBlock("div",{key:0,id:`submenu-${V.key}`,class:t.normalizeClass(["overflow-hidden transition-all duration-500 w-[276px]",m.activeForm===V.key&&V.collapsed?"max-h-[500px]":"max-h-0"])},[t.createElementVNode("div",uo,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(V.children,N=>(t.openBlock(),t.createElementBlock("button",{type:"button",key:N.key,onClick:e=>G(N,V),"aria-label":N.name,class:t.normalizeClass(["flex w-[196px] py-1 text-left px-6 flex-col justify-center items-center border-b border-solid",{"text-status-focus border-status-focus":B(N,V),"text-grey-grey-900 border-grey-grey-50":!B(N,V)}])},[t.createElementVNode("span",{class:t.normalizeClass(["flex w-[158px] min-h-[22px] flex-col justify-center font-inter text-sm leading-[22px]",{"font-semibold":B(N,V),"font-normal":!B(N,V)}])},t.toDisplayString(N.name),3)],10,Mo))),128))])],10,Ho)):t.createCommentVNode("",!0)]),_:2},1024)]))),128))]))}}),Mi=(m,I)=>{const g=m.__vccOpts||m;for(const[C,A]of I)g[C]=A;return g},N0=Mi(Do,[["__scopeId","data-v-62b8d769"]]);var PZ={exports:{}},Ko=PZ.exports,t0;function So(){return t0||(t0=1,function(m,I){(function(g,C){C(I)})(Ko,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),R=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,R,H):this.drawLoader(w,{x:0,y:0},R,H),w.restore()}simpleDraw(b){const w=this.render.getRect(),n=this.render.getContext(),R=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,R,H):this.drawLoader(n,{x:M,y:K},R,H)}drawLoader(b,w,n,R){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,R-1),b.stroke(),b.fill();const H={x:w.x+n/2,y:w.y+R/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 s{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 s.GetDistanceBetweenTwoPoint(b[0],b[1])}static GetAngleBetweenTwoLine(b,w){const n=b[0].y-b[1].y,R=w[0].y-w[1].y,H=b[1].x-b[0].x,M=w[1].x-w[0].x;return Math.acos((n*R+H*M)/(Math.sqrt(n*n+H*H)*Math.sqrt(R*R+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(s.GetDistanceBetweenTwoPoint(b,n)<=w)return n;const R=b.x,H=b.y,M=n.x,K=n.y;let D=Math.sqrt(Math.pow(w,2)*Math.pow(R-M,2)/(Math.pow(R-M,2)+Math.pow(H-K,2)))+R;n.x<0&&(D*=-1);let p=(D-R)*(H-K)/(R-M)+H;return R-M+H===0&&(p=w),{x:D,y:p}}static GetIntersectBetweenTwoSegment(b,w,n){return s.PointInRect(b,s.GetIntersectBeetwenTwoLine(w,n))}static GetIntersectBeetwenTwoLine(b,w){const n=b[0].y-b[1].y,R=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-R*K,O=H*D-M*K,r=-(K*M-D*H)/(n*M-R*H),II=-(n*D-R*K)/(n*M-R*H);if(isFinite(r)&&isFinite(II))return{x:r,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),R=Math.abs(b.y-w.y),H=Math.max(n,R),M=[b];function K(D,p,O,r,II){return p>D?D+II*(O/r):p<D?D-II*(O/r):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,R,H,D)});return M}}class d 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 d(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),R=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: ${R}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,R=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=R}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=s.GetRotatedPoint(M,{x:0,y:0},this.state.angle),n+=M.x+"px "+M.y+"px, "}n=n.slice(0,-2),n+=")";const R=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=R}simpleDraw(b){const w=this.render.getRect(),n=w.pageWidth,R=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: ${R}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,R){super(b,w),this.element=n,this.pagesElement=R}load(){for(const b of this.pagesElement){const w=new d(this.render,b,b.dataset.density==="hard"?"hard":"soft");w.load(),this.pages.push(w)}this.createSpread()}}class G{constructor(b,w,n,R){this.direction=b,this.corner=w,this.topIntersectPoint=null,this.sideIntersectPoint=null,this.bottomIntersectPoint=null,this.pageWidth=parseInt(n,10),this.pageHeight=parseInt(R,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?s.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=s.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 R=2*Math.acos(w/Math.sqrt(n*n+w*w));n<0&&(R=-R);const H=Math.PI-R;if(!isFinite(R)||H>=0&&H<.003)throw new Error("The G point is too small");return this.corner==="bottom"&&(R=-R),R}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=s.GetIntersectBetweenTwoSegment(w,[b,this.rect.topRight],[{x:0,y:0},{x:this.pageWidth,y:0}]),this.sideIntersectPoint=s.GetIntersectBetweenTwoSegment(w,[b,this.rect.bottomLeft],[{x:this.pageWidth,y:0},{x:this.pageWidth,y:this.pageHeight}]),this.bottomIntersectPoint=s.GetIntersectBetweenTwoSegment(w,[this.rect.bottomLeft,this.rect.bottomRight],[{x:0,y:this.pageHeight},{x:this.pageWidth,y:this.pageHeight}])):(this.topIntersectPoint=s.GetIntersectBetweenTwoSegment(w,[this.rect.topLeft,this.rect.topRight],[{x:0,y:0},{x:this.pageWidth,y:0}]),this.sideIntersectPoint=s.GetIntersectBetweenTwoSegment(w,[b,this.rect.topLeft],[{x:this.pageWidth,y:0},{x:this.pageWidth,y:this.pageHeight}]),this.bottomIntersectPoint=s.GetIntersectBetweenTwoSegment(w,[this.rect.bottomLeft,this.rect.bottomRight],[{x:0,y:this.pageHeight},{x:this.pageWidth,y:this.pageHeight}]))}checkPositionAtCenterLine(b,w,n){let R=b;const H=s.LimitPointToCircle(w,this.pageWidth,R);R!==H&&(R=H,this.updateAngleAndGeometry(R));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=s.LimitPointToCircle(n,M,D);p!==R&&(R=p,this.updateAngleAndGeometry(R))}return R}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,R=this.calc.getCorner()==="bottom"?w.height-n:n,H=this.calc.getCorner()==="bottom"?w.height:0;this.calc.calc({x:w.pageWidth-n,y:R}),this.animateFlippingTo({x:w.pageWidth-n,y:R},{x:-w.pageWidth,y:H},!0)}start(b){this.reset();const w=this.render.convertToBook(b),n=this.getBoundsRect(),R=this.getDirectionByPoint(w),H=w.y>=n.height/2?"bottom":"top";if(!this.checkDirection(R))return!1;try{if(this.flippingPage=this.app.getPageCollection().getFlippingPage(R),this.bottomPage=this.app.getPageCollection().getBottomPage(R),this.render.getOrientation()==="landscape")if(R===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(R),this.calc=new G(R,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(),R=this.app.getPageCollection().getSpreadIndexByPage(b);try{R>n&&(this.app.getPageCollection().setCurrentSpreadIndex(R-1),this.flipNext(w)),R<n&&(this.app.getPageCollection().setCurrentSpreadIndex(R+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 R=50,H=this.calc.getCorner()==="bottom"?w.height-1:1,M=this.calc.getCorner()==="bottom"?w.height-R:R;this.animateFlippingTo({x:n-1,y:H},{x:n-R,y:M},!1,!1)}else this.do(this.render.convertToPage(b));else this.setState("read"),this.render.finishAnimation(),this.stopMove()}animateFlippingTo(b,w,n,R=!0){const H=s.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()),R&&(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,R=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<R||H.x>w.width-R)&&(H.y<R||H.y>w.height-R)}}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,R=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:R-K/2,width:2*M,height:K,pageWidth:M},b}setShadowData(b,w,n,R){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:R,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 R=this.ctx.createLinearGradient(0,0,w,0);R.addColorStop(0,"rgba(0, 0, 0, 0)"),R.addColorStop(.4,"rgba(0, 0, 0, 0.2)"),R.addColorStop(.49,"rgba(0, 0, 0, 0.1)"),R.addColorStop(.5,"rgba(0, 0, 0, 0.5)"),R.addColorStop(.51,"rgba(0, 0, 0, 0.4)"),R.addColorStop(1,"rgba(0, 0, 0, 0)"),this.ctx.clip(),this.ctx.fillStyle=R,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 R=3*this.shadow.width/4,H=this.ctx.createLinearGradient(0,0,R,0);this.shadow.direction===0?(this.ctx.translate(-R,-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,R,2*b.height),this.ctx.restore()}clear(){this.ctx.fillStyle="white",this.ctx.fillRect(0,0,this.canvas.width,this.canvas.height)}}class V{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 R=this.app.getSettings().usePortrait?1:2;b.style.minWidth=n.minWidth*R+"px",b.style.minHeight=n.minHeight+"px",n.size==="fixed"&&(b.style.minWidth=n.width*R+"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 N extends V{constructor(b,w,n,R){super(b,w,n),this.wrapper.insertAdjacentHTML("afterbegin",'<div class="stf__block"></div>'),this.distElement=b.querySelector(".stf__block"),this.items=R;for(const H of R)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 e extends V{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 R=`
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;
`;R+=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=R}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,R=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 r=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};r=s.GetRotatedPoint(r,{x:n,y:100},M),D+=r.x+"px "+r.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(${R},
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,R=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=s.GetRotatedPoint(O,{x:R,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