pdf-factory 0.8.11 → 0.8.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dist/parser.cjs +11 -11
- package/dist/parser.cjs.map +1 -1
- package/dist/parser.js +372 -380
- package/dist/parser.js.map +1 -1
- package/dist/pdf-factory.cjs +3 -3
- package/dist/pdf-factory.cjs.map +1 -1
- package/dist/pdf-factory.js +51 -51
- package/dist/pdf-factory.js.map +1 -1
- package/dist/{rolldown-runtime-C6qsp3rV.cjs → rolldown-runtime-CYJQrBu7.cjs} +1 -1
- package/package.json +10 -6
package/dist/pdf-factory.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./rolldown-runtime-C6qsp3rV.cjs");let t=require("jspdf");t=e.n(t,1);let n=require("jspdf-autotable");n=e.n(n,1);var r={F:`Final`,SF:`Semi-Finals`,QF:`Quarter-Finals`,R16:`Round of 16`,R32:`Round of 32`,R64:`Round of 64`,R128:`Round of 128`},i={F:`Final`,SF:`Semi-Finals`,QF:`Quarter-Finals`,R16:`Fourth Round`,R32:`Third Round`,R64:`Second Round`,R128:`First Round`},a={F:`Final`,SF:`Semifinals`,QF:`Quarterfinals`,R16:`Round 4`,R32:`Round 3`,R64:`Round 2`,R128:`Round 1`},o={F:`Final`,SF:`Semifinals`,QF:`Quarterfinals`,R16:`Round of 16`,R32:`Round of 32`,R64:`Round of 64`,R128:`Round of 128`},s={F:`FINALE`,SF:`1/2 FINALE`,QF:`1/4 FINALE`,R16:`1/8 FINALE`,R32:`3eme TOUR`,R64:`2eme TOUR`,R128:`1er TOUR`},c={pageSize:`a4`,orientation:`auto`,margins:{top:15,right:10,bottom:15,left:10}},l=`LAST, First`,u=`bare`,d=`before-position`,f=`brackets`,p=`-`,m=`traditional-lines`,h={wimbledon:{nameFormat:l,nationalityFormat:u,seedPosition:d,seedFormat:f,entryFormat:`parens`,gameScoreSeparator:p,setScoreSeparator:` `,retirementLabel:`Ret.`,walkoverLabel:`w/o`,roundLabels:i,renderStyle:m,page:{...c}},usOpen:{nameFormat:l,nationalityFormat:u,seedPosition:d,seedFormat:f,entryFormat:`parens`,gameScoreSeparator:p,setScoreSeparator:` | `,retirementLabel:`Ret.`,walkoverLabel:`w/o`,roundLabels:a,renderStyle:m,page:{...c}},rolandGarros:{nameFormat:`LAST First`,nationalityFormat:u,seedPosition:`after-country`,seedFormat:f,entryFormat:`parens`,gameScoreSeparator:`/`,setScoreSeparator:` `,retirementLabel:`Ab`,walkoverLabel:`w/o`,roundLabels:s,renderStyle:m,page:{...c}},australianOpen:{nameFormat:l,nationalityFormat:`parens`,seedPosition:`after-name`,seedFormat:f,entryFormat:`hyphen`,gameScoreSeparator:`/`,setScoreSeparator:` `,retirementLabel:`Ret.`,walkoverLabel:`w/o`,roundLabels:r,renderStyle:m,page:{...c,pageSize:`letter`,orientation:`portrait`}},atp:{nameFormat:l,nationalityFormat:u,seedPosition:d,seedFormat:`bare`,entryFormat:`bare`,gameScoreSeparator:`none`,setScoreSeparator:` `,retirementLabel:`RET`,walkoverLabel:`W/O`,roundLabels:r,renderStyle:m,page:{...c}},wta:{nameFormat:l,nationalityFormat:u,seedPosition:d,seedFormat:`bare`,entryFormat:`bare`,gameScoreSeparator:`none`,setScoreSeparator:` `,retirementLabel:`RET`,walkoverLabel:`W/O`,roundLabels:r,renderStyle:m,page:{...c}},atpFinals:{nameFormat:l,nationalityFormat:`parens`,seedPosition:d,seedFormat:f,entryFormat:`bare`,gameScoreSeparator:p,setScoreSeparator:` `,retirementLabel:`RET`,walkoverLabel:`W/O`,roundLabels:r,renderStyle:`round-robin`,page:{...c,orientation:`landscape`}},itfJunior:{nameFormat:l,nationalityFormat:u,seedPosition:d,seedFormat:f,entryFormat:`bare`,gameScoreSeparator:p,setScoreSeparator:` `,retirementLabel:`Ret.`,walkoverLabel:`w/o`,roundLabels:r,renderStyle:m,page:{...c}},lta:{nameFormat:l,nationalityFormat:u,seedPosition:d,seedFormat:f,entryFormat:`bare`,gameScoreSeparator:p,setScoreSeparator:` `,retirementLabel:`Ret.`,walkoverLabel:`w/o`,roundLabels:o,renderStyle:m,page:{...c}},usta:{nameFormat:l,nationalityFormat:u,seedPosition:d,seedFormat:f,entryFormat:`bare`,gameScoreSeparator:p,setScoreSeparator:` `,retirementLabel:`Ret.`,walkoverLabel:`W/O`,roundLabels:r,renderStyle:m,page:{...c}}};function g(e){return h[e]||h.itfJunior}function _(e,t){return{...g(e),...t}}var v=`itfJunior`,y=`combined-tour`,b=`grand-slam`,x=`officials-signoff`,S={[b]:{id:b,name:`Grand Slam`,description:`Minimal chrome — large tournament name, timestamp footer`,category:b,tier:1,header:{layout:b},footer:{layout:`standard`,showPageNumbers:!0,showTimestamp:!0},drawFormatPreset:`wimbledon`},wimbledon:{id:`wimbledon`,name:`Wimbledon`,description:`Green/purple Grand Slam style with crest`,category:b,tier:1,header:{layout:b},footer:{layout:`standard`,showPageNumbers:!0,showTimestamp:!0},drawFormatPreset:`wimbledon`},"australian-open":{id:`australian-open`,name:`Australian Open`,description:`Grand Slam with seedings + prize money footer`,category:b,tier:2,header:{layout:b},footer:{layout:y,showPageNumbers:!0,showTimestamp:!0},drawFormatPreset:`australianOpen`},"wta-500":{id:`wta-500`,name:`WTA 500`,description:`Tour header with logos, seedings + prize money footer`,category:`tour`,tier:2,header:{layout:`wta-tour`},footer:{layout:y,showPageNumbers:!1,showTimestamp:!0},drawFormatPreset:v},"wta-1000":{id:`wta-1000`,name:`WTA 1000`,description:`Tour header with logos, full footer with officials`,category:`tour`,tier:2,header:{layout:`wta-tour`},footer:{layout:y,showPageNumbers:!1,showTimestamp:!0},drawFormatPreset:v},"atp-250":{id:`atp-250`,name:`ATP 250`,description:`ATP tour header, seedings + prize money footer with sign-off`,category:`tour`,tier:2,header:{layout:`wta-tour`},footer:{layout:y,showPageNumbers:!1,showTimestamp:!0},drawFormatPreset:v},"atp-finals":{id:`atp-finals`,name:`ATP Finals`,description:`Full official sign-off with signature lines`,category:`tour`,tier:3,header:{layout:b},footer:{layout:x,showTimestamp:!0},drawFormatPreset:v},"itf-junior":{id:`itf-junior`,name:`ITF Junior`,description:`ITF header with metadata row, officials sign-off footer`,category:`itf`,tier:3,header:{layout:`itf`},footer:{layout:x,showPageNumbers:!0,showTimestamp:!0},drawFormatPreset:v},"itf-pro-circuit":{id:`itf-pro-circuit`,name:`ITF Pro Circuit`,description:`ITF header, seedings + officials footer`,category:`itf`,tier:2,header:{layout:`itf`},footer:{layout:y,showPageNumbers:!0,showTimestamp:!0},drawFormatPreset:v},"national-federation":{id:`national-federation`,name:`National Federation`,description:`Detailed metadata header, full sign-off footer with ceremony date`,category:`national`,tier:3,header:{layout:`national-federation`},footer:{layout:x,showPageNumbers:!0,showTimestamp:!0},drawFormatPreset:`usta`},"collegiate-ncaa":{id:`collegiate-ncaa`,name:`NCAA Collegiate`,description:`Mirrored bracket layout, team logos, minimal footer`,category:`collegiate`,tier:1,header:{layout:b},footer:{layout:`standard`,showPageNumbers:!0,showTimestamp:!0},drawFormatPreset:v},"club-basic":{id:`club-basic`,name:`Club Basic`,description:`Minimal header, standard footer — clean and simple`,category:`club`,tier:1,header:{layout:`minimal`},footer:{layout:`standard`,showPageNumbers:!0,showTimestamp:!0},drawFormatPreset:v}};function C(e){return S[e]}function ee(e){let t=Object.values(S);return e?t.filter(t=>t.category===e):t}function te(e,t,n){let r=S[e]||S[`club-basic`];return{header:{...r.header,...t},footer:{...r.footer,...n}}}var w=`tournament-header`,T=`contacts`,E=`events`,D=`entry-info`,O=`venue-info`,k=`accommodation`,A=`transportation`,j=`hospitality`,ne=`medical`,re=`regulations`,ie=`prize-money`,ae=`officials`,oe=`sponsors`,se=`social-events`,ce=`custom-notes`;function M(e,t=!0,n){return{type:e,enabled:t,...n&&{title:n}}}var le=[M(w),M(T),M(E),M(D),M(O),M(k),M(A),M(j),M(ne),M(re),M(ie),M(ae),M(oe),M(se),M(ce)],ue={"itf-junior":{id:`itf-junior`,name:`ITF Junior`,description:`Full fact sheet with all sections — ITF header style`,category:`itf`,headerLayout:`itf`,sections:le},"itf-pro-circuit":{id:`itf-pro-circuit`,name:`ITF Pro Circuit`,description:`Pro circuit fact sheet — contacts, events, entry, venue, prize money, officials`,category:`itf`,headerLayout:`itf`,sections:[M(w),M(T),M(E),M(D),M(O),M(ie),M(ae),M(re),M(ce)]},"national-federation":{id:`national-federation`,name:`National Federation`,description:`Detailed national federation fact sheet with all logistics`,category:`national`,headerLayout:`national-federation`,sections:le},"tour-atp-wta":{id:`tour-atp-wta`,name:`ATP/WTA Tour`,description:`Tour-level fact sheet — contacts, events, prize money, officials, sponsors`,category:`tour`,headerLayout:`wta-tour`,sections:[M(w),M(T),M(E),M(ie),M(ae),M(oe),M(k),M(A),M(se),M(ce)]},"club-basic":{id:`club-basic`,name:`Club Basic`,description:`Simple club-level fact sheet — essentials only`,category:`club`,headerLayout:`minimal`,sections:[M(w),M(T),M(E),M(D),M(O),M(ce)]}};function de(e){return ue[e]}function fe(e){let t=Object.values(ue);return e?t.filter(t=>t.category===e):t}function N(e){let t=e.roundMatchUps||{},n=e.roundProfile||{},r=Object.keys(t).map(Number).sort((e,t)=>e-t),i=new Map;for(let e of r)for(let n of t[e]||[])for(let e of n.sides||[])if(e?.drawPosition&&!i.has(e.drawPosition)){let t=e.entryStatus||e.participant?.entryStatus,n=t&&t!==`DIRECT_ACCEPTANCE`?t:void 0;i.set(e.drawPosition,{drawPosition:e.drawPosition,participantName:e.participant?.participantName||``,nationality:e.participant?.nationalityCode||``,seedValue:e.seedValue,entryStatus:n,isBye:e.bye===!0})}let a=[];for(let e of r)for(let n of t[e]||[])a.push({roundNumber:n.roundNumber,roundPosition:n.roundPosition,drawPositions:n.drawPositions||[],score:n.score?.scoreStringSide1||``,winningSide:n.winningSide,matchUpStatus:n.matchUpStatus});let o={};for(let e of r){let t=n[e];o[e]=t?.abbreviatedRoundName||t?.roundName||`R${e}`}let s=r.length>0?Math.max(...r):0,c=[...i.values()].sort((e,t)=>e.drawPosition-t.drawPosition),l=e.stage===`QUALIFYING`,u=t[s]?.length||0,d=l||u>1;return{drawName:e.structureName||``,drawSize:c.length,drawType:`SINGLE_ELIMINATION`,totalRounds:s,noWinnerColumn:d,slots:c,matchUps:a,seedAssignments:(e.seedAssignments||[]).filter(e=>e.participantName).map(e=>({seedValue:e.seedValue,participantName:e.participantName||``,nationality:e.nationalityCode||``})),roundLabelMap:o}}function P(e,t){return e?.[0]?.structures?.find(e=>e.stage===t)}var pe={REGULAR:`helvetica`,BOLD:`helvetica`},F={NORMAL:`normal`,BOLD:`bold`,ITALIC:`italic`},I={TITLE:16,SUBTITLE:12,HEADING:10,BODY:8,SMALL:7,TINY:6},me=new WeakMap,he=[`normal`,`bold`,`italic`,`bolditalic`];function ge(e,t){if(!t?.family||!t?.normal)return pe.REGULAR;for(let n of he){let r=t[n]??t.normal,i=`${t.family}-${n}.ttf`;e.addFileToVFS(i,r),e.addFont(i,t.family,n)}return me.set(e,t.family),t.family}function _e(e){return me.get(e)??pe.REGULAR}var ve;function ye(e){ve=e}function be(){return ve}function L(e){return ve?ge(e,ve):pe.REGULAR}function R(e,t,n=F.NORMAL){e.setFont(_e(e),n),e.setFontSize(t)}function xe(e,n){let r=e.orientation;r===`auto`&&(r=n&&n>=32?`landscape`:`portrait`);let i=new t.default({orientation:r,format:e.pageSize,unit:`mm`});return e.font?ge(i,e.font):L(i),i}function z(e,t,n,r){let i=e.internal.pageSize.getWidth(),a=e.internal.pageSize.getHeight(),{margins:o}=t;return{headerHeight:n,footerHeight:r,contentY:o.top+n,contentHeight:a-o.top-o.bottom-n-r,contentWidth:i-o.left-o.right,pageWidth:i,pageHeight:a}}function Se(){return{pageSize:`a4`,orientation:`auto`,margins:{top:15,right:10,bottom:15,left:10}}}function B(e,t,n){switch(t.layout){case`grand-slam`:return Ce(e,t,n);case`itf`:return we(e,t,n);case`minimal`:return Te(e,t,n);case`wta-tour`:return Ee(e,t,n);case`national-federation`:return De(e,t,n);case`none`:return 0}}function Ce(e,t,n){let{margins:r}=n,i=e.internal.pageSize.getWidth(),a=i-r.right,o=r.top;R(e,18,F.BOLD),e.text(t.tournamentName.toUpperCase(),i/2,o,{align:`center`}),o+=7,t.subtitle&&(R(e,12,F.BOLD),e.text(t.subtitle.toUpperCase(),i/2,o,{align:`center`}),o+=6),R(e,I.BODY,F.NORMAL);let s=[];if(t.startDate){let e=t.endDate?`${t.startDate} - ${t.endDate}`:t.startDate;s.push(e)}return t.location&&s.push(t.location),s.forEach((t,n)=>{e.text(t,a,r.top+n*4,{align:`right`})}),o+=2,e.setDrawColor(0),e.setLineWidth(.5),e.line(r.left,o,a,o),o+=3,o-r.top}function we(e,t,n){let{margins:r}=n,i=e.internal.pageSize.getWidth()-r.right,a=r.top;R(e,I.TITLE,F.BOLD),e.text(t.tournamentName,r.left,a),a+=6,t.subtitle&&(R(e,I.SUBTITLE,F.BOLD),e.text(t.subtitle,r.left,a),a+=5),R(e,I.SMALL,F.NORMAL);let o=[];t.grade&&o.push(`Grade: ${t.grade}`),t.surface&&o.push(`Surface: ${t.surface}`),t.supervisor&&o.push(`Supervisor: ${t.supervisor}`),o.forEach((t,n)=>{e.text(t,i,r.top+n*3.5,{align:`right`})}),R(e,I.BODY,F.NORMAL);let s=[];return t.startDate&&s.push(t.startDate),t.location&&s.push(t.location),t.organizer&&s.push(t.organizer),s.length&&(e.text(s.join(` | `),r.left,a),a+=4),a+=1,e.setDrawColor(0),e.setLineWidth(.3),e.line(r.left,a,i,a),a+=3,a-r.top}function Te(e,t,n){let{margins:r}=n,i=r.top;R(e,I.SUBTITLE,F.BOLD),e.text(t.tournamentName,r.left,i);let a=e.getTextWidth(t.tournamentName);return t.subtitle&&(R(e,I.BODY,F.NORMAL),e.text(` - ${t.subtitle}`,r.left+a,i)),i+=6,i-r.top}function Ee(e,t,n){let{margins:r}=n,i=e.internal.pageSize.getWidth(),a=i-r.right,o=i/2,s=r.top;if(t.leftLogoBase64)try{e.addImage(t.leftLogoBase64,`PNG`,r.left,s-2,12,12)}catch{}if(t.rightLogoBase64)try{e.addImage(t.rightLogoBase64,`PNG`,a-12,s-2,12,12)}catch{}R(e,14,F.BOLD),e.text(t.tournamentName,o,s,{align:`center`}),s+=5;let c=[t.city,t.country].filter(Boolean).join(`, `);c&&(R(e,I.BODY,F.NORMAL),e.setTextColor(80),e.text(c.toUpperCase(),o,s,{align:`center`}),e.setTextColor(0),s+=4);let l=[];if(t.startDate){let e=t.endDate?`${t.startDate} - ${t.endDate}`:t.startDate;l.push(e)}if(t.prizeMoney){let e=t.currency?`${t.currency} ${t.prizeMoney}`:t.prizeMoney;l.push(e)}return t.surface&&l.push(t.surface),l.length&&(R(e,I.SMALL,F.NORMAL),e.text(l.join(` | `),o,s,{align:`center`}),s+=4),t.sectionLabel&&(R(e,I.SMALL,F.BOLD),e.text(t.sectionLabel.toUpperCase(),a,s,{align:`right`}),s+=3),s+=1,e.setDrawColor(0),e.setLineWidth(.3),e.line(r.left,s,a,s),s+=3,s-r.top}function De(e,t,n){let{margins:r}=n,i=e.internal.pageSize.getWidth()-r.right,a=r.top;if(t.rightLogoBase64)try{e.addImage(t.rightLogoBase64,`PNG`,i-14,a-2,14,14)}catch{}R(e,I.TITLE,F.BOLD),e.text(t.tournamentName,r.left,a),a+=6,t.subtitle&&(R(e,I.HEADING,F.BOLD),e.text(t.subtitle,r.left,a),a+=4),R(e,I.TINY,F.NORMAL),e.setTextColor(80);let o=[];return t.startDate&&o.push(t.startDate),t.organizer&&o.push(t.organizer),(t.city||t.country)&&o.push([t.city,t.country].filter(Boolean).join(`, `)),t.tournamentId&&o.push(`ID: ${t.tournamentId}`),t.grade&&o.push(`Grade: ${t.grade}`),t.chiefUmpire&&o.push(`Umpire: ${t.chiefUmpire}`),o.length&&(e.text(o.join(` | `),r.left,a),a+=3),e.setTextColor(0),a+=1,e.setDrawColor(0),e.setLineWidth(.3),e.line(r.left,a,i,a),a+=3,a-r.top}function Oe(e){let t=e.person;if(t?.standardFamilyName){let e=t.standardGivenName||``;return e?t.standardFamilyName+`, `+e:t.standardFamilyName}return e.participantName||``}function ke(e,t){return e.find(e=>e.participantRole===t)}function Ae(e,t){return e.find(e=>e.participantRole===`OFFICIAL`&&e.participantRoleResponsibilities?.some(e=>e.toUpperCase().includes(t.toUpperCase())))}function je(e){let t=(e.venues?.[0])?.addresses?.[0],n=[];return t?.city&&n.push(t.city),t?.state&&n.push(t.state),(t?.countryCode||e.hostCountryCode)&&n.push(t?.countryCode||e.hostCountryCode||``),n.join(`, `)}function Me(e){return e.venues?.[0]?.addresses?.[0]?.city}function Ne(e){return e.venues?.[0]?.addresses?.[0]?.countryCode||e.hostCountryCode}function Pe(e){if(e.tournamentTier){let t=e.tournamentTier;return t.system?t.system+` `+(t.value||``):t.value}return e.tournamentLevel}function Fe(e){let t=e.totalPrizeMoney?.[0];if(t)return String(t.amount)}function Ie(e){return e.totalPrizeMoney?.[0]?.currencyCode}function Le(e,t={}){let{layout:n=`itf`,sectionLabel:r,overrides:i}=t,a=e.participants||[],o=ke(a,`DIRECTOR`),s=Ae(a,`REFEREE`),c=Ae(a,`CHIEF_UMPIRE`)||Ae(a,`UMPIRE`),l=Ae(a,`SUPERVISOR`)||s;return{layout:n,tournamentName:e.formalName||e.tournamentName||``,startDate:e.startDate,endDate:e.endDate,location:je(e),city:Me(e),country:Ne(e),surface:e.surfaceCategory,grade:Pe(e),tournamentId:e.tournamentId,organizer:o?Oe(o):void 0,supervisor:l?Oe(l):void 0,chiefUmpire:c?Oe(c):void 0,prizeMoney:Fe(e),currency:Ie(e),sectionLabel:r,...i}}function Re(e,t={}){let{layout:n=`standard`,seedAssignments:r,prizeMoney:i,overrides:a}=t,o=(e.participants||[]).filter(e=>e.participantRole===`OFFICIAL`||e.participantRole===`DIRECTOR`).map(e=>({role:e.participantRoleResponsibilities?.[0]||e.participantRole||`Official`,name:Oe(e)}));return{layout:n,showPageNumbers:!0,showTimestamp:!0,...o.length&&{signatureLines:o},...r?.length&&{seedAssignments:r},...i?.length&&{prizeMoney:i},...e.registrationProfile?.drawCeremonyDate&&{drawCeremonyDate:e.registrationProfile.drawCeremonyDate},...a}}function ze(e,t,n,r){switch(t.layout){case`standard`:return Be(e,t,n,r);case`seedings`:case`seedings-table`:return Ve(e,t,n,r);case`prize-money`:return He(e,t,n,r);case`officials`:case`officials-signoff`:return Ue(e,t,n,r);case`combined-tour`:return We(e,t,n,r);case`none`:return 0}}function V(e){switch(e.layout){case`standard`:return 8+(e.notes?.length||0)*3;case`seedings`:case`seedings-table`:return 12+Math.ceil((e.seedAssignments?.length||0)/2)*3;case`prize-money`:return 12+(e.prizeMoney?.length||0)*2.5;case`officials`:case`officials-signoff`:return 12+(e.signatureLines?.length||e.officials?.length||0)*5;case`combined-tour`:{let t=Math.ceil((e.seedAssignments?.length||0)/2),n=e.prizeMoney?.length||0;return 16+Math.max(t*3,n*2.5)+(e.withdrawals?.length?6:0)}case`none`:return 0}}function Be(e,t,n,r){let i=e.internal.pageSize.getWidth(),a=e.internal.pageSize.getHeight(),{margins:o}=n,s=i-o.right,c=a-o.bottom;if(R(e,I.TINY,F.NORMAL),e.setTextColor(120),t.showTimestamp&&e.text(`Generated ${new Date().toLocaleDateString()}`,o.left,c),t.showPageNumbers&&r!==void 0&&e.text(`Page ${r}`,s,c,{align:`right`}),e.setTextColor(0),c-=3,e.setDrawColor(180),e.setLineWidth(.2),e.line(o.left,c,s,c),c-=2,t.notes?.length){R(e,I.TINY,F.ITALIC),e.setTextColor(100);for(let n=t.notes.length-1;n>=0;n--)e.text(t.notes[n],o.left,c),c-=3;e.setTextColor(0)}return V(t)}function Ve(e,t,n,r){let i=e.internal.pageSize.getWidth(),a=e.internal.pageSize.getHeight(),{margins:o}=n,s=i-o.right,c=V(t),l=a-o.bottom-c+4;e.setDrawColor(180),e.setLineWidth(.2),e.line(o.left,l,s,l),l+=3,R(e,I.SMALL,F.BOLD),e.text(`Seeded Players`,o.left,l),l+=3;let u=t.seedAssignments||[],d=(s-o.left)/2;R(e,I.TINY,F.NORMAL);for(let t=0;t<u.length;t++){let n=t<Math.ceil(u.length/2)?0:1,r=n===0?t:t-Math.ceil(u.length/2),i=o.left+n*d,a=l+r*3,s=u[t],c=s.ranking?` (${s.ranking})`:``;e.text(`${s.seedValue}. ${s.participantName}${c}`,i,a)}let f=Math.ceil(u.length/2);return l+=f*3+2,Ge(e,t,n,r,l),c}function He(e,t,n,r){let i=e.internal.pageSize.getWidth(),a=e.internal.pageSize.getHeight(),{margins:o}=n,s=i-o.right,c=V(t),l=a-o.bottom-c+4;e.setDrawColor(180),e.setLineWidth(.2),e.line(o.left,l,s,l),l+=3,R(e,I.SMALL,F.BOLD),e.text(`Prize Money`,o.left,l),l+=3;let u=t.prizeMoney||[];R(e,I.TINY,F.NORMAL);for(let t of u){let n=[t.round];t.amount&&n.push(t.amount),t.points&&n.push(`${t.points} pts`),e.text(n.join(` — `),o.left,l),l+=2.5}return l+=2,Ge(e,t,n,r,l),c}function Ue(e,t,n,r){let i=e.internal.pageSize.getWidth(),a=e.internal.pageSize.getHeight(),{margins:o}=n,s=i-o.right,c=V(t),l=a-o.bottom-c+4;e.setDrawColor(180),e.setLineWidth(.2),e.line(o.left,l,s,l),l+=4,t.drawCeremonyDate&&(R(e,I.TINY,F.ITALIC),e.setTextColor(80),e.text(`Draw ceremony: ${t.drawCeremonyDate}`,o.left,l),e.setTextColor(0),l+=3),t.releaseDate&&(R(e,I.TINY,F.ITALIC),e.setTextColor(80),e.text(`Released: ${t.releaseDate}`,o.left,l),e.setTextColor(0),l+=3);let u=t.signatureLines||(t.officials||[]).map(e=>({role:e})),d=(s-o.left)/Math.min(u.length,3);for(let t=0;t<u.length;t++){let n=t%3,r=Math.floor(t/3),i=o.left+n*d,a=l+r*10;R(e,I.TINY,F.ITALIC),e.setTextColor(100),e.text(u[t].role,i,a),e.setTextColor(0);let s=u[t].name;s&&(R(e,I.TINY,F.BOLD),e.text(s,i,a+3)),e.setDrawColor(150),e.setLineWidth(.15),e.line(i,a+5,i+d-8,a+5)}let f=Math.ceil(u.length/3);return l+=f*10+2,Ge(e,t,n,r,l),c}function We(e,t,n,r){let i=e.internal.pageSize.getWidth(),a=e.internal.pageSize.getHeight(),{margins:o}=n,s=i-o.right,c=V(t),l=a-o.bottom-c+4;e.setDrawColor(180),e.setLineWidth(.2),e.line(o.left,l,s,l),l+=3;let u=s-o.left,d=o.left,f=o.left+u*.55,p=l,m=l,h=t.seedAssignments||[];if(h.length){R(e,I.SMALL,F.BOLD),e.text(`Seeded Players`,d,p),p+=3,R(e,I.TINY,F.NORMAL);for(let t of h){let n=t.ranking?` (${t.ranking})`:``;e.text(`${t.seedValue}. ${t.participantName}${n}`,d,p),p+=2.5}}let g=t.prizeMoney||[];if(g.length){R(e,I.SMALL,F.BOLD),e.text(`Prize Money`,f,m),m+=3,R(e,I.TINY,F.NORMAL);for(let t of g){let n=[t.round];t.amount&&n.push(t.amount),t.points&&n.push(`${t.points} pts`),e.text(n.join(` — `),f,m),m+=2.5}}if(l=Math.max(p,m)+2,t.withdrawals?.length){R(e,I.TINY,F.ITALIC),e.setTextColor(80);let n=t.withdrawals.map(e=>e.reason?`${e.name} (${e.reason})`:e.name).join(`, `);e.text(`Withdrawals: ${n}`,o.left,l,{maxWidth:u}),e.setTextColor(0),l+=3}return t.luckyLosers?.length&&(R(e,I.TINY,F.ITALIC),e.setTextColor(80),e.text(`Lucky Losers: ${t.luckyLosers.join(`, `)}`,o.left,l,{maxWidth:u}),e.setTextColor(0),l+=3),t.officials?.length&&(R(e,I.TINY,F.NORMAL),e.setTextColor(80),e.text(t.officials.join(` | `),o.left,l),e.setTextColor(0),l+=3),Ge(e,t,n,r,l),c}function Ge(e,t,n,r,i){let a=e.internal.pageSize.getWidth(),o=e.internal.pageSize.getHeight(),{margins:s}=n,c=a-s.right,l=o-s.bottom+2;if(R(e,I.TINY,F.NORMAL),e.setTextColor(120),t.showTimestamp&&e.text(`Generated ${new Date().toLocaleDateString()}`,s.left,l),t.releaseDate){let n=t.showTimestamp?s.left+50:s.left;e.text(`Released: ${t.releaseDate}`,n,l)}t.showPageNumbers&&r!==void 0&&e.text(`Page ${r}`,c,l,{align:`right`}),e.setTextColor(0)}var Ke=5,qe=2.5;function Je(e,t,n,r){let i=t.seedAssignments;if(!i.length)return r;let a=n.page.margins,o=e.internal.pageSize.getWidth()-a.left-a.right;R(e,6,F.BOLD),e.text(`Seeded players`,a.left,r),e.setDrawColor(150),e.setLineWidth(.15),e.line(a.left,r+1,a.left+o*.5,r+1),r+=3;let s=Math.ceil(i.length/2),c=i.slice(0,s),l=i.slice(s),u=o*.25,d=r;for(let t=0;t<Math.max(c.length,l.length);t++)c[t]&&Ye(e,c[t],a.left,d,u),l[t]&&Ye(e,l[t],a.left+u+4,d,u),d+=qe;return d}function Ye(e,t,n,r,i){R(e,Ke,F.BOLD),e.text(`${t.seedValue}`,n+4,r,{align:`right`}),R(e,Ke,F.NORMAL),e.text(t.participantName,n+6,r),e.setTextColor(100),e.text(t.nationality,n+45,r),e.setTextColor(0)}function Xe(e){return e===0?0:4+Math.ceil(e/2)*qe}function H(e){if(!e)return``;if(e.person){let{standardFamilyName:t,standardGivenName:n}=e.person;if(t)return`${t.toUpperCase()}, ${n||``}`.trim()}return e.participantName||``}function U(e){return e&&e.person?.nationalityCode||``}function Ze(e){return e?`[${e}]`:``}function Qe(e){return e?{DIRECT_ACCEPTANCE:`DA`,WILDCARD:`WC`,LUCKY_LOSER:`LL`,QUALIFIER:`Q`,ALTERNATE:`A`,SPECIAL_EXEMPT:`SE`}[e]||e:``}function $e(e){return e?typeof e==`string`?e:e.scoreStringSide1?e.scoreStringSide1:``:``}function et(e){return e?new Date(e+`T00:00:00`).toLocaleDateString(`en-US`,{day:`2-digit`,month:`short`,year:`numeric`}):``}function tt(e){if(!e)return``;let[t,n]=e.split(`:`),r=parseInt(t),i=r>=12?`PM`:`AM`,a=r;return r===0?a=12:r>12&&(a=r-12),`${a}:${n} ${i}`}function nt(e){return e?e.split(/\s+/).map(e=>e[0]).join(``).toUpperCase():``}function rt(e,t){let n=t-e+1;return n===1?`F`:n===2?`SF`:n===3?`QF`:`R${2**n}`}function it(e){let{matchUps:t=[],venues:n=[],scheduledDate:r=``}=e,i=new Set;n.forEach(e=>{(e.courts||[]).forEach(e=>{i.add(e.courtName||`Court ${e.courtId}`)})});let a=new Map;n.forEach(e=>{(e.courts||[]).forEach(e=>{a.set(e.courtId,e.courtName||`Court ${e.courtId}`)})});let o=t.filter(e=>e.schedule?.scheduledDate===r||!r),s=new Map;for(let e of o){let t=e.schedule||{},n=t.scheduledTime||`00:00`,r=t.venueCourtId||t.courtId||``,o=a.get(r)||r;o&&i.add(o);let c=e.sides||[],l=at(c[0]),u=at(c[1]),d={courtName:o,scheduledTime:tt(n),eventName:e.eventName||e.event?.eventName||``,eventAbbr:nt(e.eventName||e.event?.eventName||``),roundName:e.roundName||``,side1:l,side2:u,score:$e(e.score),matchUpStatus:e.matchUpStatus,notBeforeTime:t.notBeforeTime?tt(t.notBeforeTime):void 0},f=t.notBeforeTime||n;s.has(f)||s.set(f,[]),s.get(f).push(d)}let c=[...s.keys()].sort().map(e=>({time:e,label:tt(e)||`TBD`,matches:s.get(e)||[]}));return{scheduledDate:r,courts:[...i].sort(),timeSlots:c}}function at(e){if(!e)return{name:``,nationality:``};let t=e.participant;return t?{name:H(t),nationality:U(t)}:{name:``,nationality:``}}function ot(e){let{participants:t=[],eventEntries:n=[]}=e,r=new Map;for(let{eventName:e,entries:t}of n)for(let n of t){let t=n.participantId;r.has(t)||r.set(t,{events:[],entryStatus:``,seedValue:void 0});let i=r.get(t);if(i.events.push(e),n.entryStatus&&(i.entryStatus=n.entryStatus),n.seedValue!==void 0&&i.seedValue===void 0){let e=Number(n.seedValue);Number.isNaN(e)||(i.seedValue=e)}}return t.filter(e=>e.participantType===`INDIVIDUAL`).map(e=>{let t=r.get(e.participantId);return{name:H(e),nationality:U(e),ranking:st(e),seedValue:t?.seedValue,entryStatus:Qe(t?.entryStatus||``),events:t?.events||[],signedIn:e.signInStatus===`SIGNED_IN`}}).sort((e,t)=>e.name.localeCompare(t.name))}function st(e){for(let t of[e.rankings,e.ratings])if(!(!t||typeof t!=`object`))for(let e of Object.values(t)){let t=e?.[0]?.scaleValue;if(t!=null&&t!==``)return String(t)}return``}function ct(e){let{matchUps:t=[],venues:n=[]}=e,r=new Map;n.forEach(e=>{(e.courts||[]).forEach(t=>{r.set(t.courtId,{courtName:t.courtName||`Court ${t.courtId}`,venueName:e.venueName||``})})});let i=new Map;for(let e of t){let t=e.schedule?.venueCourtId||e.schedule?.courtId;t&&(i.has(t)||i.set(t,[]),i.get(t).push(e))}let a=[];for(let[e,t]of i){let n=r.get(e)||{courtName:e,venueName:``};t.sort((e,t)=>{let n=e.schedule?.scheduledTime||``,r=t.schedule?.scheduledTime||``;return n.localeCompare(r)});let i=new Set([`COMPLETED`,`RETIRED`,`WALKOVER`,`DEFAULTED`,`ABANDONED`]),o=t.find(e=>e.matchUpStatus===`IN_PROGRESS`),s=t.filter(e=>!i.has(e.matchUpStatus)),c=t.filter(e=>i.has(e.matchUpStatus)),l=o||s[0]||c.at(-1),u;o?u=s[0]:s.length>1&&(u=s[1]),a.push({courtName:n.courtName,venueName:n.venueName,currentMatch:l?lt(l):void 0,nextMatch:u?lt(u):void 0})}return a.sort((e,t)=>e.courtName.localeCompare(t.courtName))}function lt(e){let t=e.sides||[];return{eventName:e.eventName||e.event?.eventName||``,roundName:e.roundName||``,scheduledTime:e.schedule?.scheduledTime?tt(e.schedule.scheduledTime):void 0,side1:ut(t[0]),side2:ut(t[1])}}function ut(e){return e?.participant?{name:H(e.participant),nationality:U(e.participant)}:{name:`TBD`,nationality:``}}function dt(e,t={}){let n=e.courts.length>=4,r={pageSize:t.page?.pageSize||`a4`,orientation:t.page?.orientation||(n?`landscape`:`portrait`),margins:t.page?.margins||{top:12,right:8,bottom:10,left:8}},i=xe(r),a=t.footer||{layout:`standard`,showTimestamp:!0,showPageNumbers:!0},o=V(a)+(t.notes?.length?t.notes.length*3:0),s=r.margins.top;if(t.header){let e=B(i,t.header,r);s=r.margins.top+e}t.alertBanner&&(s=ft(i,t.alertBanner,r,s)),pt(i,e,r,s,t);let c=i.internal.pageSize.getHeight();if(t.notes?.length){let e=c-r.margins.bottom-o+2;R(i,I.TINY,F.ITALIC),i.setTextColor(80);for(let n of t.notes)i.text(n,r.margins.left,e),e+=3;i.setTextColor(0)}if(t.officials?.length){let e=c-r.margins.bottom-6;_t(i,t.officials,r,e)}return ze(i,a,r,1),i}function ft(e,t,n,r){let{margins:i}=n,a=e.internal.pageSize.getWidth(),o=a-i.left-i.right;return e.setFillColor(200,30,30),e.rect(i.left,r,o,7,`F`),R(e,I.SMALL,F.BOLD),e.setTextColor(255,255,255),e.text(t,a/2,r+4.5,{align:`center`}),e.setTextColor(0),r+9}function pt(e,t,r,i,a){let{margins:o}=r,s=t.courts,c=a.cellStyle===`compact`,l=[{header:``,dataKey:`slot`}];for(let e of s)l.push({header:e,dataKey:e});let u=[];t.timeSlots.forEach((e,t)=>{let n=[],r=mt(e,t);n.push({content:r,styles:{fontStyle:`bold`,valign:`top`,cellWidth:12}});for(let t of s){let r=e.matches.filter(e=>e.courtName===t),i=r.length>0?r.map(e=>ht(e,c)).join(`
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./rolldown-runtime-CYJQrBu7.cjs");let t=require("jspdf");t=e.n(t,1);let n=require("jspdf-autotable");n=e.n(n,1);var r={F:`Final`,SF:`Semi-Finals`,QF:`Quarter-Finals`,R16:`Round of 16`,R32:`Round of 32`,R64:`Round of 64`,R128:`Round of 128`},i={F:`Final`,SF:`Semi-Finals`,QF:`Quarter-Finals`,R16:`Fourth Round`,R32:`Third Round`,R64:`Second Round`,R128:`First Round`},a={F:`Final`,SF:`Semifinals`,QF:`Quarterfinals`,R16:`Round 4`,R32:`Round 3`,R64:`Round 2`,R128:`Round 1`},o={F:`Final`,SF:`Semifinals`,QF:`Quarterfinals`,R16:`Round of 16`,R32:`Round of 32`,R64:`Round of 64`,R128:`Round of 128`},s={F:`FINALE`,SF:`1/2 FINALE`,QF:`1/4 FINALE`,R16:`1/8 FINALE`,R32:`3eme TOUR`,R64:`2eme TOUR`,R128:`1er TOUR`},c={pageSize:`a4`,orientation:`auto`,margins:{top:15,right:10,bottom:15,left:10}},l=`LAST, First`,u=`bare`,d=`before-position`,f=`brackets`,p=`-`,m=`traditional-lines`,h={wimbledon:{nameFormat:l,nationalityFormat:u,seedPosition:d,seedFormat:f,entryFormat:`parens`,gameScoreSeparator:p,setScoreSeparator:` `,retirementLabel:`Ret.`,walkoverLabel:`w/o`,roundLabels:i,renderStyle:m,page:{...c}},usOpen:{nameFormat:l,nationalityFormat:u,seedPosition:d,seedFormat:f,entryFormat:`parens`,gameScoreSeparator:p,setScoreSeparator:` | `,retirementLabel:`Ret.`,walkoverLabel:`w/o`,roundLabels:a,renderStyle:m,page:{...c}},rolandGarros:{nameFormat:`LAST First`,nationalityFormat:u,seedPosition:`after-country`,seedFormat:f,entryFormat:`parens`,gameScoreSeparator:`/`,setScoreSeparator:` `,retirementLabel:`Ab`,walkoverLabel:`w/o`,roundLabels:s,renderStyle:m,page:{...c}},australianOpen:{nameFormat:l,nationalityFormat:`parens`,seedPosition:`after-name`,seedFormat:f,entryFormat:`hyphen`,gameScoreSeparator:`/`,setScoreSeparator:` `,retirementLabel:`Ret.`,walkoverLabel:`w/o`,roundLabels:r,renderStyle:m,page:{...c,pageSize:`letter`,orientation:`portrait`}},atp:{nameFormat:l,nationalityFormat:u,seedPosition:d,seedFormat:`bare`,entryFormat:`bare`,gameScoreSeparator:`none`,setScoreSeparator:` `,retirementLabel:`RET`,walkoverLabel:`W/O`,roundLabels:r,renderStyle:m,page:{...c}},wta:{nameFormat:l,nationalityFormat:u,seedPosition:d,seedFormat:`bare`,entryFormat:`bare`,gameScoreSeparator:`none`,setScoreSeparator:` `,retirementLabel:`RET`,walkoverLabel:`W/O`,roundLabels:r,renderStyle:m,page:{...c}},atpFinals:{nameFormat:l,nationalityFormat:`parens`,seedPosition:d,seedFormat:f,entryFormat:`bare`,gameScoreSeparator:p,setScoreSeparator:` `,retirementLabel:`RET`,walkoverLabel:`W/O`,roundLabels:r,renderStyle:`round-robin`,page:{...c,orientation:`landscape`}},itfJunior:{nameFormat:l,nationalityFormat:u,seedPosition:d,seedFormat:f,entryFormat:`bare`,gameScoreSeparator:p,setScoreSeparator:` `,retirementLabel:`Ret.`,walkoverLabel:`w/o`,roundLabels:r,renderStyle:m,page:{...c}},lta:{nameFormat:l,nationalityFormat:u,seedPosition:d,seedFormat:f,entryFormat:`bare`,gameScoreSeparator:p,setScoreSeparator:` `,retirementLabel:`Ret.`,walkoverLabel:`w/o`,roundLabels:o,renderStyle:m,page:{...c}},usta:{nameFormat:l,nationalityFormat:u,seedPosition:d,seedFormat:f,entryFormat:`bare`,gameScoreSeparator:p,setScoreSeparator:` `,retirementLabel:`Ret.`,walkoverLabel:`W/O`,roundLabels:r,renderStyle:m,page:{...c}}};function g(e){return h[e]||h.itfJunior}function _(e,t){return{...g(e),...t}}var v=`itfJunior`,y=`combined-tour`,b=`grand-slam`,x=`officials-signoff`,S={[b]:{id:b,name:`Grand Slam`,description:`Minimal chrome — large tournament name, timestamp footer`,category:b,tier:1,header:{layout:b},footer:{layout:`standard`,showPageNumbers:!0,showTimestamp:!0},drawFormatPreset:`wimbledon`},wimbledon:{id:`wimbledon`,name:`Wimbledon`,description:`Green/purple Grand Slam style with crest`,category:b,tier:1,header:{layout:b},footer:{layout:`standard`,showPageNumbers:!0,showTimestamp:!0},drawFormatPreset:`wimbledon`},"australian-open":{id:`australian-open`,name:`Australian Open`,description:`Grand Slam with seedings + prize money footer`,category:b,tier:2,header:{layout:b},footer:{layout:y,showPageNumbers:!0,showTimestamp:!0},drawFormatPreset:`australianOpen`},"wta-500":{id:`wta-500`,name:`WTA 500`,description:`Tour header with logos, seedings + prize money footer`,category:`tour`,tier:2,header:{layout:`wta-tour`},footer:{layout:y,showPageNumbers:!1,showTimestamp:!0},drawFormatPreset:v},"wta-1000":{id:`wta-1000`,name:`WTA 1000`,description:`Tour header with logos, full footer with officials`,category:`tour`,tier:2,header:{layout:`wta-tour`},footer:{layout:y,showPageNumbers:!1,showTimestamp:!0},drawFormatPreset:v},"atp-250":{id:`atp-250`,name:`ATP 250`,description:`ATP tour header, seedings + prize money footer with sign-off`,category:`tour`,tier:2,header:{layout:`wta-tour`},footer:{layout:y,showPageNumbers:!1,showTimestamp:!0},drawFormatPreset:v},"atp-finals":{id:`atp-finals`,name:`ATP Finals`,description:`Full official sign-off with signature lines`,category:`tour`,tier:3,header:{layout:b},footer:{layout:x,showTimestamp:!0},drawFormatPreset:v},"itf-junior":{id:`itf-junior`,name:`ITF Junior`,description:`ITF header with metadata row, officials sign-off footer`,category:`itf`,tier:3,header:{layout:`itf`},footer:{layout:x,showPageNumbers:!0,showTimestamp:!0},drawFormatPreset:v},"itf-pro-circuit":{id:`itf-pro-circuit`,name:`ITF Pro Circuit`,description:`ITF header, seedings + officials footer`,category:`itf`,tier:2,header:{layout:`itf`},footer:{layout:y,showPageNumbers:!0,showTimestamp:!0},drawFormatPreset:v},"national-federation":{id:`national-federation`,name:`National Federation`,description:`Detailed metadata header, full sign-off footer with ceremony date`,category:`national`,tier:3,header:{layout:`national-federation`},footer:{layout:x,showPageNumbers:!0,showTimestamp:!0},drawFormatPreset:`usta`},"collegiate-ncaa":{id:`collegiate-ncaa`,name:`NCAA Collegiate`,description:`Mirrored bracket layout, team logos, minimal footer`,category:`collegiate`,tier:1,header:{layout:b},footer:{layout:`standard`,showPageNumbers:!0,showTimestamp:!0},drawFormatPreset:v},"club-basic":{id:`club-basic`,name:`Club Basic`,description:`Minimal header, standard footer — clean and simple`,category:`club`,tier:1,header:{layout:`minimal`},footer:{layout:`standard`,showPageNumbers:!0,showTimestamp:!0},drawFormatPreset:v}};function C(e){return S[e]}function ee(e){let t=Object.values(S);return e?t.filter(t=>t.category===e):t}function te(e,t,n){let r=S[e]||S[`club-basic`];return{header:{...r.header,...t},footer:{...r.footer,...n}}}var w=`tournament-header`,T=`contacts`,E=`events`,D=`entry-info`,O=`venue-info`,k=`accommodation`,A=`transportation`,j=`hospitality`,ne=`medical`,re=`regulations`,ie=`prize-money`,ae=`officials`,oe=`sponsors`,se=`social-events`,ce=`custom-notes`;function M(e,t=!0,n){return{type:e,enabled:t,...n&&{title:n}}}var le=[M(w),M(T),M(E),M(D),M(O),M(k),M(A),M(j),M(ne),M(re),M(ie),M(ae),M(oe),M(se),M(ce)],ue={"itf-junior":{id:`itf-junior`,name:`ITF Junior`,description:`Full fact sheet with all sections — ITF header style`,category:`itf`,headerLayout:`itf`,sections:le},"itf-pro-circuit":{id:`itf-pro-circuit`,name:`ITF Pro Circuit`,description:`Pro circuit fact sheet — contacts, events, entry, venue, prize money, officials`,category:`itf`,headerLayout:`itf`,sections:[M(w),M(T),M(E),M(D),M(O),M(ie),M(ae),M(re),M(ce)]},"national-federation":{id:`national-federation`,name:`National Federation`,description:`Detailed national federation fact sheet with all logistics`,category:`national`,headerLayout:`national-federation`,sections:le},"tour-atp-wta":{id:`tour-atp-wta`,name:`ATP/WTA Tour`,description:`Tour-level fact sheet — contacts, events, prize money, officials, sponsors`,category:`tour`,headerLayout:`wta-tour`,sections:[M(w),M(T),M(E),M(ie),M(ae),M(oe),M(k),M(A),M(se),M(ce)]},"club-basic":{id:`club-basic`,name:`Club Basic`,description:`Simple club-level fact sheet — essentials only`,category:`club`,headerLayout:`minimal`,sections:[M(w),M(T),M(E),M(D),M(O),M(ce)]}};function de(e){return ue[e]}function fe(e){let t=Object.values(ue);return e?t.filter(t=>t.category===e):t}function N(e){let t=e.roundMatchUps||{},n=e.roundProfile||{},r=Object.keys(t).map(Number).sort((e,t)=>e-t),i=new Map;for(let e of r)for(let n of t[e]||[])for(let e of n.sides||[])if(e?.drawPosition&&!i.has(e.drawPosition)){let t=e.entryStatus||e.participant?.entryStatus,n=t&&t!==`DIRECT_ACCEPTANCE`?t:void 0;i.set(e.drawPosition,{drawPosition:e.drawPosition,participantName:e.participant?.participantName||``,nationality:e.participant?.nationalityCode||``,seedValue:e.seedValue,entryStatus:n,isBye:e.bye===!0})}let a=[];for(let e of r)for(let n of t[e]||[])a.push({roundNumber:n.roundNumber,roundPosition:n.roundPosition,drawPositions:n.drawPositions||[],score:n.score?.scoreStringSide1||``,winningSide:n.winningSide,matchUpStatus:n.matchUpStatus});let o={};for(let e of r){let t=n[e];o[e]=t?.abbreviatedRoundName||t?.roundName||`R${e}`}let s=r.length>0?Math.max(...r):0,c=[...i.values()].sort((e,t)=>e.drawPosition-t.drawPosition),l=e.stage===`QUALIFYING`,u=t[s]?.length||0,d=l||u>1;return{drawName:e.structureName||``,drawSize:c.length,drawType:`SINGLE_ELIMINATION`,totalRounds:s,noWinnerColumn:d,slots:c,matchUps:a,seedAssignments:(e.seedAssignments||[]).filter(e=>e.participantName).map(e=>({seedValue:e.seedValue,participantName:e.participantName||``,nationality:e.nationalityCode||``})),roundLabelMap:o}}function P(e,t){return e?.[0]?.structures?.find(e=>e.stage===t)}var pe={REGULAR:`helvetica`,BOLD:`helvetica`},F={NORMAL:`normal`,BOLD:`bold`,ITALIC:`italic`},I={TITLE:16,SUBTITLE:12,HEADING:10,BODY:8,SMALL:7,TINY:6},me=new WeakMap,he=[`normal`,`bold`,`italic`,`bolditalic`];function ge(e,t){if(!t?.family||!t?.normal)return pe.REGULAR;for(let n of he){let r=t[n]??t.normal,i=`${t.family}-${n}.ttf`;e.addFileToVFS(i,r),e.addFont(i,t.family,n)}return me.set(e,t.family),t.family}function _e(e){return me.get(e)??pe.REGULAR}var ve;function ye(e){ve=e}function be(){return ve}function L(e){return ve?ge(e,ve):pe.REGULAR}function R(e,t,n=F.NORMAL){e.setFont(_e(e),n),e.setFontSize(t)}function xe(e,n){let r=e.orientation;r===`auto`&&(r=n&&n>=32?`landscape`:`portrait`);let i=new t.default({orientation:r,format:e.pageSize,unit:`mm`});return e.font?ge(i,e.font):L(i),i}function z(e,t,n,r){let i=e.internal.pageSize.getWidth(),a=e.internal.pageSize.getHeight(),{margins:o}=t;return{headerHeight:n,footerHeight:r,contentY:o.top+n,contentHeight:a-o.top-o.bottom-n-r,contentWidth:i-o.left-o.right,pageWidth:i,pageHeight:a}}function Se(){return{pageSize:`a4`,orientation:`auto`,margins:{top:15,right:10,bottom:15,left:10}}}function B(e,t,n){switch(t.layout){case`grand-slam`:return Ce(e,t,n);case`itf`:return we(e,t,n);case`minimal`:return Te(e,t,n);case`wta-tour`:return Ee(e,t,n);case`national-federation`:return De(e,t,n);case`none`:return 0}}function Ce(e,t,n){let{margins:r}=n,i=e.internal.pageSize.getWidth(),a=i-r.right,o=r.top;R(e,18,F.BOLD),e.text(t.tournamentName.toUpperCase(),i/2,o,{align:`center`}),o+=7,t.subtitle&&(R(e,12,F.BOLD),e.text(t.subtitle.toUpperCase(),i/2,o,{align:`center`}),o+=6),R(e,I.BODY,F.NORMAL);let s=[];if(t.startDate){let e=t.endDate?`${t.startDate} - ${t.endDate}`:t.startDate;s.push(e)}return t.location&&s.push(t.location),s.forEach((t,n)=>{e.text(t,a,r.top+n*4,{align:`right`})}),o+=2,e.setDrawColor(0),e.setLineWidth(.5),e.line(r.left,o,a,o),o+=3,o-r.top}function we(e,t,n){let{margins:r}=n,i=e.internal.pageSize.getWidth()-r.right,a=r.top;R(e,I.TITLE,F.BOLD),e.text(t.tournamentName,r.left,a),a+=6,t.subtitle&&(R(e,I.SUBTITLE,F.BOLD),e.text(t.subtitle,r.left,a),a+=5),R(e,I.SMALL,F.NORMAL);let o=[];t.grade&&o.push(`Grade: ${t.grade}`),t.surface&&o.push(`Surface: ${t.surface}`),t.supervisor&&o.push(`Supervisor: ${t.supervisor}`),o.forEach((t,n)=>{e.text(t,i,r.top+n*3.5,{align:`right`})}),R(e,I.BODY,F.NORMAL);let s=[];return t.startDate&&s.push(t.startDate),t.location&&s.push(t.location),t.organizer&&s.push(t.organizer),s.length&&(e.text(s.join(` | `),r.left,a),a+=4),a+=1,e.setDrawColor(0),e.setLineWidth(.3),e.line(r.left,a,i,a),a+=3,a-r.top}function Te(e,t,n){let{margins:r}=n,i=r.top;R(e,I.SUBTITLE,F.BOLD),e.text(t.tournamentName,r.left,i);let a=e.getTextWidth(t.tournamentName);return t.subtitle&&(R(e,I.BODY,F.NORMAL),e.text(` - ${t.subtitle}`,r.left+a,i)),i+=6,i-r.top}function Ee(e,t,n){let{margins:r}=n,i=e.internal.pageSize.getWidth(),a=i-r.right,o=i/2,s=r.top;if(t.leftLogoBase64)try{e.addImage(t.leftLogoBase64,`PNG`,r.left,s-2,12,12)}catch{}if(t.rightLogoBase64)try{e.addImage(t.rightLogoBase64,`PNG`,a-12,s-2,12,12)}catch{}R(e,14,F.BOLD),e.text(t.tournamentName,o,s,{align:`center`}),s+=5;let c=[t.city,t.country].filter(Boolean).join(`, `);c&&(R(e,I.BODY,F.NORMAL),e.setTextColor(80),e.text(c.toUpperCase(),o,s,{align:`center`}),e.setTextColor(0),s+=4);let l=[];if(t.startDate){let e=t.endDate?`${t.startDate} - ${t.endDate}`:t.startDate;l.push(e)}if(t.prizeMoney){let e=t.currency?`${t.currency} ${t.prizeMoney}`:t.prizeMoney;l.push(e)}return t.surface&&l.push(t.surface),l.length&&(R(e,I.SMALL,F.NORMAL),e.text(l.join(` | `),o,s,{align:`center`}),s+=4),t.sectionLabel&&(R(e,I.SMALL,F.BOLD),e.text(t.sectionLabel.toUpperCase(),a,s,{align:`right`}),s+=3),s+=1,e.setDrawColor(0),e.setLineWidth(.3),e.line(r.left,s,a,s),s+=3,s-r.top}function De(e,t,n){let{margins:r}=n,i=e.internal.pageSize.getWidth()-r.right,a=r.top;if(t.rightLogoBase64)try{e.addImage(t.rightLogoBase64,`PNG`,i-14,a-2,14,14)}catch{}R(e,I.TITLE,F.BOLD),e.text(t.tournamentName,r.left,a),a+=6,t.subtitle&&(R(e,I.HEADING,F.BOLD),e.text(t.subtitle,r.left,a),a+=4),R(e,I.TINY,F.NORMAL),e.setTextColor(80);let o=[];return t.startDate&&o.push(t.startDate),t.organizer&&o.push(t.organizer),(t.city||t.country)&&o.push([t.city,t.country].filter(Boolean).join(`, `)),t.tournamentId&&o.push(`ID: ${t.tournamentId}`),t.grade&&o.push(`Grade: ${t.grade}`),t.chiefUmpire&&o.push(`Umpire: ${t.chiefUmpire}`),o.length&&(e.text(o.join(` | `),r.left,a),a+=3),e.setTextColor(0),a+=1,e.setDrawColor(0),e.setLineWidth(.3),e.line(r.left,a,i,a),a+=3,a-r.top}function Oe(e){let t=e.person;if(t?.standardFamilyName){let e=t.standardGivenName||``;return e?t.standardFamilyName+`, `+e:t.standardFamilyName}return e.participantName||``}function ke(e,t){return e.find(e=>e.participantRole===t)}function Ae(e,t){return e.find(e=>e.participantRole===`OFFICIAL`&&e.participantRoleResponsibilities?.some(e=>e.toUpperCase().includes(t.toUpperCase())))}function je(e){let t=(e.venues?.[0])?.addresses?.[0],n=[];return t?.city&&n.push(t.city),t?.state&&n.push(t.state),(t?.countryCode||e.hostCountryCode)&&n.push(t?.countryCode||e.hostCountryCode||``),n.join(`, `)}function Me(e){return e.venues?.[0]?.addresses?.[0]?.city}function Ne(e){return e.venues?.[0]?.addresses?.[0]?.countryCode||e.hostCountryCode}function Pe(e){if(e.tournamentTier){let t=e.tournamentTier;return t.system?t.system+` `+(t.value||``):t.value}return e.tournamentLevel}function Fe(e){let t=e.totalPrizeMoney?.[0];if(t)return String(t.amount)}function Ie(e){return e.totalPrizeMoney?.[0]?.currencyCode}function Le(e,t={}){let{layout:n=`itf`,sectionLabel:r,overrides:i}=t,a=e.participants||[],o=ke(a,`DIRECTOR`),s=Ae(a,`REFEREE`),c=Ae(a,`CHIEF_UMPIRE`)||Ae(a,`UMPIRE`),l=Ae(a,`SUPERVISOR`)||s;return{layout:n,tournamentName:e.formalName||e.tournamentName||``,startDate:e.startDate,endDate:e.endDate,location:je(e),city:Me(e),country:Ne(e),surface:e.surfaceCategory,grade:Pe(e),tournamentId:e.tournamentId,organizer:o?Oe(o):void 0,supervisor:l?Oe(l):void 0,chiefUmpire:c?Oe(c):void 0,prizeMoney:Fe(e),currency:Ie(e),sectionLabel:r,...i}}function Re(e,t={}){let{layout:n=`standard`,seedAssignments:r,prizeMoney:i,overrides:a}=t,o=(e.participants||[]).filter(e=>e.participantRole===`OFFICIAL`||e.participantRole===`DIRECTOR`).map(e=>({role:e.participantRoleResponsibilities?.[0]||e.participantRole||`Official`,name:Oe(e)}));return{layout:n,showPageNumbers:!0,showTimestamp:!0,...o.length&&{signatureLines:o},...r?.length&&{seedAssignments:r},...i?.length&&{prizeMoney:i},...e.registrationProfile?.drawCeremonyDate&&{drawCeremonyDate:e.registrationProfile.drawCeremonyDate},...a}}function ze(e,t,n,r){switch(t.layout){case`standard`:return Be(e,t,n,r);case`seedings`:case`seedings-table`:return Ve(e,t,n,r);case`prize-money`:return He(e,t,n,r);case`officials`:case`officials-signoff`:return Ue(e,t,n,r);case`combined-tour`:return We(e,t,n,r);case`none`:return 0}}function V(e){switch(e.layout){case`standard`:return 8+(e.notes?.length||0)*3;case`seedings`:case`seedings-table`:return 12+Math.ceil((e.seedAssignments?.length||0)/2)*3;case`prize-money`:return 12+(e.prizeMoney?.length||0)*2.5;case`officials`:case`officials-signoff`:return 12+(e.signatureLines?.length||e.officials?.length||0)*5;case`combined-tour`:{let t=Math.ceil((e.seedAssignments?.length||0)/2),n=e.prizeMoney?.length||0;return 16+Math.max(t*3,n*2.5)+(e.withdrawals?.length?6:0)}case`none`:return 0}}function Be(e,t,n,r){let i=e.internal.pageSize.getWidth(),a=e.internal.pageSize.getHeight(),{margins:o}=n,s=i-o.right,c=a-o.bottom;if(R(e,I.TINY,F.NORMAL),e.setTextColor(120),t.showTimestamp&&e.text(`Generated ${new Date().toLocaleDateString()}`,o.left,c),t.showPageNumbers&&r!==void 0&&e.text(`Page ${r}`,s,c,{align:`right`}),e.setTextColor(0),c-=3,e.setDrawColor(180),e.setLineWidth(.2),e.line(o.left,c,s,c),c-=2,t.notes?.length){R(e,I.TINY,F.ITALIC),e.setTextColor(100);for(let n=t.notes.length-1;n>=0;n--)e.text(t.notes[n],o.left,c),c-=3;e.setTextColor(0)}return V(t)}function Ve(e,t,n,r){let i=e.internal.pageSize.getWidth(),a=e.internal.pageSize.getHeight(),{margins:o}=n,s=i-o.right,c=V(t),l=a-o.bottom-c+4;e.setDrawColor(180),e.setLineWidth(.2),e.line(o.left,l,s,l),l+=3,R(e,I.SMALL,F.BOLD),e.text(`Seeded Players`,o.left,l),l+=3;let u=t.seedAssignments||[],d=(s-o.left)/2;R(e,I.TINY,F.NORMAL);for(let t=0;t<u.length;t++){let n=t<Math.ceil(u.length/2)?0:1,r=n===0?t:t-Math.ceil(u.length/2),i=o.left+n*d,a=l+r*3,s=u[t],c=s.ranking?` (${s.ranking})`:``;e.text(`${s.seedValue}. ${s.participantName}${c}`,i,a)}let f=Math.ceil(u.length/2);return l+=f*3+2,Ge(e,t,n,r,l),c}function He(e,t,n,r){let i=e.internal.pageSize.getWidth(),a=e.internal.pageSize.getHeight(),{margins:o}=n,s=i-o.right,c=V(t),l=a-o.bottom-c+4;e.setDrawColor(180),e.setLineWidth(.2),e.line(o.left,l,s,l),l+=3,R(e,I.SMALL,F.BOLD),e.text(`Prize Money`,o.left,l),l+=3;let u=t.prizeMoney||[];R(e,I.TINY,F.NORMAL);for(let t of u){let n=[t.round];t.amount&&n.push(t.amount),t.points&&n.push(`${t.points} pts`),e.text(n.join(` — `),o.left,l),l+=2.5}return l+=2,Ge(e,t,n,r,l),c}function Ue(e,t,n,r){let i=e.internal.pageSize.getWidth(),a=e.internal.pageSize.getHeight(),{margins:o}=n,s=i-o.right,c=V(t),l=a-o.bottom-c+4;e.setDrawColor(180),e.setLineWidth(.2),e.line(o.left,l,s,l),l+=4,t.drawCeremonyDate&&(R(e,I.TINY,F.ITALIC),e.setTextColor(80),e.text(`Draw ceremony: ${t.drawCeremonyDate}`,o.left,l),e.setTextColor(0),l+=3),t.releaseDate&&(R(e,I.TINY,F.ITALIC),e.setTextColor(80),e.text(`Released: ${t.releaseDate}`,o.left,l),e.setTextColor(0),l+=3);let u=t.signatureLines||(t.officials||[]).map(e=>({role:e})),d=(s-o.left)/Math.min(u.length,3);for(let t=0;t<u.length;t++){let n=t%3,r=Math.floor(t/3),i=o.left+n*d,a=l+r*10;R(e,I.TINY,F.ITALIC),e.setTextColor(100),e.text(u[t].role,i,a),e.setTextColor(0);let s=u[t].name;s&&(R(e,I.TINY,F.BOLD),e.text(s,i,a+3)),e.setDrawColor(150),e.setLineWidth(.15),e.line(i,a+5,i+d-8,a+5)}let f=Math.ceil(u.length/3);return l+=f*10+2,Ge(e,t,n,r,l),c}function We(e,t,n,r){let i=e.internal.pageSize.getWidth(),a=e.internal.pageSize.getHeight(),{margins:o}=n,s=i-o.right,c=V(t),l=a-o.bottom-c+4;e.setDrawColor(180),e.setLineWidth(.2),e.line(o.left,l,s,l),l+=3;let u=s-o.left,d=o.left,f=o.left+u*.55,p=l,m=l,h=t.seedAssignments||[];if(h.length){R(e,I.SMALL,F.BOLD),e.text(`Seeded Players`,d,p),p+=3,R(e,I.TINY,F.NORMAL);for(let t of h){let n=t.ranking?` (${t.ranking})`:``;e.text(`${t.seedValue}. ${t.participantName}${n}`,d,p),p+=2.5}}let g=t.prizeMoney||[];if(g.length){R(e,I.SMALL,F.BOLD),e.text(`Prize Money`,f,m),m+=3,R(e,I.TINY,F.NORMAL);for(let t of g){let n=[t.round];t.amount&&n.push(t.amount),t.points&&n.push(`${t.points} pts`),e.text(n.join(` — `),f,m),m+=2.5}}if(l=Math.max(p,m)+2,t.withdrawals?.length){R(e,I.TINY,F.ITALIC),e.setTextColor(80);let n=t.withdrawals.map(e=>e.reason?`${e.name} (${e.reason})`:e.name).join(`, `);e.text(`Withdrawals: ${n}`,o.left,l,{maxWidth:u}),e.setTextColor(0),l+=3}return t.luckyLosers?.length&&(R(e,I.TINY,F.ITALIC),e.setTextColor(80),e.text(`Lucky Losers: ${t.luckyLosers.join(`, `)}`,o.left,l,{maxWidth:u}),e.setTextColor(0),l+=3),t.officials?.length&&(R(e,I.TINY,F.NORMAL),e.setTextColor(80),e.text(t.officials.join(` | `),o.left,l),e.setTextColor(0),l+=3),Ge(e,t,n,r,l),c}function Ge(e,t,n,r,i){let a=e.internal.pageSize.getWidth(),o=e.internal.pageSize.getHeight(),{margins:s}=n,c=a-s.right,l=o-s.bottom+2;if(R(e,I.TINY,F.NORMAL),e.setTextColor(120),t.showTimestamp&&e.text(`Generated ${new Date().toLocaleDateString()}`,s.left,l),t.releaseDate){let n=t.showTimestamp?s.left+50:s.left;e.text(`Released: ${t.releaseDate}`,n,l)}t.showPageNumbers&&r!==void 0&&e.text(`Page ${r}`,c,l,{align:`right`}),e.setTextColor(0)}var Ke=5,qe=2.5;function Je(e,t,n,r){let i=t.seedAssignments;if(!i.length)return r;let a=n.page.margins,o=e.internal.pageSize.getWidth()-a.left-a.right;R(e,6,F.BOLD),e.text(`Seeded players`,a.left,r),e.setDrawColor(150),e.setLineWidth(.15),e.line(a.left,r+1,a.left+o*.5,r+1),r+=3;let s=Math.ceil(i.length/2),c=i.slice(0,s),l=i.slice(s),u=o*.25,d=r;for(let t=0;t<Math.max(c.length,l.length);t++)c[t]&&Ye(e,c[t],a.left,d,u),l[t]&&Ye(e,l[t],a.left+u+4,d,u),d+=qe;return d}function Ye(e,t,n,r,i){R(e,Ke,F.BOLD),e.text(`${t.seedValue}`,n+4,r,{align:`right`}),R(e,Ke,F.NORMAL),e.text(t.participantName,n+6,r),e.setTextColor(100),e.text(t.nationality,n+45,r),e.setTextColor(0)}function Xe(e){return e===0?0:4+Math.ceil(e/2)*qe}function H(e){if(!e)return``;if(e.person){let{standardFamilyName:t,standardGivenName:n}=e.person;if(t)return`${t.toUpperCase()}, ${n||``}`.trim()}return e.participantName||``}function U(e){return e&&e.person?.nationalityCode||``}function Ze(e){return e?`[${e}]`:``}function Qe(e){return e?{DIRECT_ACCEPTANCE:`DA`,WILDCARD:`WC`,LUCKY_LOSER:`LL`,QUALIFIER:`Q`,ALTERNATE:`A`,SPECIAL_EXEMPT:`SE`}[e]||e:``}function $e(e){return e?typeof e==`string`?e:e.scoreStringSide1?e.scoreStringSide1:``:``}function et(e){return e?new Date(e+`T00:00:00`).toLocaleDateString(`en-US`,{day:`2-digit`,month:`short`,year:`numeric`}):``}function tt(e){if(!e)return``;let[t,n]=e.split(`:`),r=parseInt(t),i=r>=12?`PM`:`AM`,a=r;return r===0?a=12:r>12&&(a=r-12),`${a}:${n} ${i}`}function nt(e){return e?e.split(/\s+/).map(e=>e[0]).join(``).toUpperCase():``}function rt(e,t){let n=t-e+1;return n===1?`F`:n===2?`SF`:n===3?`QF`:`R${2**n}`}function it(e){let{matchUps:t=[],venues:n=[],scheduledDate:r=``}=e,i=new Set;n.forEach(e=>{(e.courts||[]).forEach(e=>{i.add(e.courtName||`Court ${e.courtId}`)})});let a=new Map;n.forEach(e=>{(e.courts||[]).forEach(e=>{a.set(e.courtId,e.courtName||`Court ${e.courtId}`)})});let o=t.filter(e=>e.schedule?.scheduledDate===r||!r),s=new Map;for(let e of o){let t=e.schedule||{},n=t.scheduledTime||`00:00`,r=t.venueCourtId||t.courtId||``,o=a.get(r)||r;o&&i.add(o);let c=e.sides||[],l=at(c[0]),u=at(c[1]),d={courtName:o,scheduledTime:tt(n),eventName:e.eventName||e.event?.eventName||``,eventAbbr:nt(e.eventName||e.event?.eventName||``),roundName:e.roundName||``,side1:l,side2:u,score:$e(e.score),matchUpStatus:e.matchUpStatus,notBeforeTime:t.notBeforeTime?tt(t.notBeforeTime):void 0},f=t.notBeforeTime||n;s.has(f)||s.set(f,[]),s.get(f).push(d)}let c=[...s.keys()].sort().map(e=>({time:e,label:tt(e)||`TBD`,matches:s.get(e)||[]}));return{scheduledDate:r,courts:[...i].sort(),timeSlots:c}}function at(e){if(!e)return{name:``,nationality:``};let t=e.participant;return t?{name:H(t),nationality:U(t)}:{name:``,nationality:``}}function ot(e){let{participants:t=[],eventEntries:n=[]}=e,r=new Map;for(let{eventName:e,entries:t}of n)for(let n of t){let t=n.participantId;r.has(t)||r.set(t,{events:[],entryStatus:``,seedValue:void 0});let i=r.get(t);if(i.events.push(e),n.entryStatus&&(i.entryStatus=n.entryStatus),n.seedValue!==void 0&&i.seedValue===void 0){let e=Number(n.seedValue);Number.isNaN(e)||(i.seedValue=e)}}return t.filter(e=>e.participantType===`INDIVIDUAL`).map(e=>{let t=r.get(e.participantId);return{name:H(e),nationality:U(e),ranking:st(e),seedValue:t?.seedValue,entryStatus:Qe(t?.entryStatus||``),events:t?.events||[],signedIn:e.signInStatus===`SIGNED_IN`}}).sort((e,t)=>e.name.localeCompare(t.name))}function st(e){for(let t of[e.rankings,e.ratings])if(!(!t||typeof t!=`object`))for(let e of Object.values(t)){let t=e?.[0]?.scaleValue;if(t!=null&&t!==``)return String(t)}return``}function ct(e){let{matchUps:t=[],venues:n=[]}=e,r=new Map;n.forEach(e=>{(e.courts||[]).forEach(t=>{r.set(t.courtId,{courtName:t.courtName||`Court ${t.courtId}`,venueName:e.venueName||``})})});let i=new Map;for(let e of t){let t=e.schedule?.venueCourtId||e.schedule?.courtId;t&&(i.has(t)||i.set(t,[]),i.get(t).push(e))}let a=[];for(let[e,t]of i){let n=r.get(e)||{courtName:e,venueName:``};t.sort((e,t)=>{let n=e.schedule?.scheduledTime||``,r=t.schedule?.scheduledTime||``;return n.localeCompare(r)});let i=new Set([`COMPLETED`,`RETIRED`,`WALKOVER`,`DEFAULTED`,`ABANDONED`]),o=t.find(e=>e.matchUpStatus===`IN_PROGRESS`),s=t.filter(e=>!i.has(e.matchUpStatus)),c=t.filter(e=>i.has(e.matchUpStatus)),l=o||s[0]||c.at(-1),u;o?u=s[0]:s.length>1&&(u=s[1]),a.push({courtName:n.courtName,venueName:n.venueName,currentMatch:l?lt(l):void 0,nextMatch:u?lt(u):void 0})}return a.sort((e,t)=>e.courtName.localeCompare(t.courtName))}function lt(e){let t=e.sides||[];return{eventName:e.eventName||e.event?.eventName||``,roundName:e.roundName||``,scheduledTime:e.schedule?.scheduledTime?tt(e.schedule.scheduledTime):void 0,side1:ut(t[0]),side2:ut(t[1])}}function ut(e){return e?.participant?{name:H(e.participant),nationality:U(e.participant)}:{name:`TBD`,nationality:``}}function dt(e,t={}){let n=e.courts.length>=4,r={pageSize:t.page?.pageSize||`a4`,orientation:t.page?.orientation||(n?`landscape`:`portrait`),margins:t.page?.margins||{top:12,right:8,bottom:10,left:8}},i=xe(r),a=t.footer||{layout:`standard`,showTimestamp:!0,showPageNumbers:!0},o=V(a)+(t.notes?.length?t.notes.length*3:0),s=r.margins.top;if(t.header){let e=B(i,t.header,r);s=r.margins.top+e}t.alertBanner&&(s=ft(i,t.alertBanner,r,s)),pt(i,e,r,s,t);let c=i.internal.pageSize.getHeight();if(t.notes?.length){let e=c-r.margins.bottom-o+2;R(i,I.TINY,F.ITALIC),i.setTextColor(80);for(let n of t.notes)i.text(n,r.margins.left,e),e+=3;i.setTextColor(0)}if(t.officials?.length){let e=c-r.margins.bottom-6;_t(i,t.officials,r,e)}return ze(i,a,r,1),i}function ft(e,t,n,r){let{margins:i}=n,a=e.internal.pageSize.getWidth(),o=a-i.left-i.right;return e.setFillColor(200,30,30),e.rect(i.left,r,o,7,`F`),R(e,I.SMALL,F.BOLD),e.setTextColor(255,255,255),e.text(t,a/2,r+4.5,{align:`center`}),e.setTextColor(0),r+9}function pt(e,t,r,i,a){let{margins:o}=r,s=t.courts,c=a.cellStyle===`compact`,l=[{header:``,dataKey:`slot`}];for(let e of s)l.push({header:e,dataKey:e});let u=[];t.timeSlots.forEach((e,t)=>{let n=[],r=mt(e,t);n.push({content:r,styles:{fontStyle:`bold`,valign:`top`,cellWidth:12}});for(let t of s){let r=e.matches.filter(e=>e.courtName===t),i=r.length>0?r.map(e=>ht(e,c)).join(`
|
|
2
2
|
---
|
|
3
3
|
`):``;n.push(i)}u.push(n)}),(0,n.default)(e,{startY:i,head:[l.map(e=>e.header)],body:u,styles:{fontSize:c?6:6.5,cellPadding:c?1.5:2,lineWidth:.3,lineColor:[80,80,80],valign:`top`,overflow:`linebreak`},headStyles:{fillColor:[255,255,255],textColor:[0,0,0],fontStyle:`bold`,fontSize:7,halign:`center`,lineWidth:.5,lineColor:[0,0,0]},columnStyles:{0:{cellWidth:14,fontStyle:`bold`}},alternateRowStyles:{fillColor:[252,252,252]},margin:{left:o.left,right:o.right},tableWidth:`auto`,didParseCell:t=>{if(t.column.index>0&&t.section===`body`){let n=e.internal.pageSize.getWidth()-o.left-o.right-14;t.cell.styles.cellWidth=n/s.length,t.cell.styles.halign=`center`,t.cell.styles.valign=`middle`}}})}function mt(e,t){return`${t+1}`}function ht(e,t){let n=[];e.notBeforeTime?n.push(`NB ${e.notBeforeTime}`):e.scheduledTime&&n.push(e.scheduledTime),(e.eventAbbr||e.roundName)&&n.push(`${e.eventAbbr} ${e.roundName}`.trim());let r=gt(e.side1,t);r&&n.push(r),n.push(`vs.`);let i=gt(e.side2,t);return i&&n.push(i),e.score?n.push(e.score):e.matchUpStatus===`IN_PROGRESS`&&n.push(`In progress`),n.join(`
|
|
4
|
-
`)}function gt(e,t){return e.name?t||e.nationality?`${e.name} (${e.nationality})`:e.name:`TBD`}function _t(e,t,n,r){let{margins:i}=n,a=e.internal.pageSize.getWidth();e.setDrawColor(120),e.setLineWidth(.2),e.line(i.left,r-2,a-i.right,r-2),R(e,I.TINY,F.NORMAL);let o=(a-i.left-i.right)/t.length;t.forEach((t,n)=>{let a=i.left+n*o;R(e,I.TINY,F.ITALIC),e.setTextColor(100),e.text(t.role,a,r),R(e,I.TINY,F.BOLD),e.setTextColor(0),e.text(t.name,a,r+3)})}function W(e,t,n=15){let r=e.internal.pageSize.getWidth(),i=n;R(e,I.TITLE,F.BOLD),e.text(t.tournamentName,15,i),i+=7,t.subtitle&&(R(e,I.SUBTITLE,F.BOLD),e.text(t.subtitle,15,i),i+=6),R(e,I.BODY,F.NORMAL);let a=[];if(t.startDate){let e=t.endDate?`${t.startDate} - ${t.endDate}`:t.startDate;a.push(e)}return t.location&&a.push(t.location),t.organizer&&a.push(t.organizer),a.forEach((t,i)=>{e.text(t,r-15,n+i*4,{align:`right`})}),i+=2,e.setDrawColor(0),e.setLineWidth(.5),e.line(15,i,r-15,i),i+=5,i}function G(e,t,n){let r=e.internal.pageSize.getWidth(),i=e.internal.pageSize.getHeight();R(e,I.SMALL,F.ITALIC),e.setTextColor(120),e.text(t,15,i-10),n!==void 0&&e.text(`Page ${n}`,r-15,i-10,{align:`right`}),e.setTextColor(0)}var vt={compact:{styles:{fontSize:7,cellPadding:1.5,lineWidth:.1,lineColor:[200,200,200]},headStyles:{fillColor:[50,50,50],textColor:[255,255,255],fontStyle:`bold`,fontSize:7},alternateRowStyles:{fillColor:[245,245,245]}},schedule:{styles:{fontSize:7,cellPadding:2,lineWidth:.2,lineColor:[180,180,180],valign:`top`},headStyles:{fillColor:[30,60,120],textColor:[255,255,255],fontStyle:`bold`,fontSize:8,halign:`center`},alternateRowStyles:{fillColor:[240,244,250]}},playerList:{styles:{fontSize:8,cellPadding:2,lineWidth:.1,lineColor:[200,200,200]},headStyles:{fillColor:[40,80,40],textColor:[255,255,255],fontStyle:`bold`,fontSize:8},alternateRowStyles:{fillColor:[242,248,242]}},report:{styles:{fontSize:8,cellPadding:2,lineWidth:.1,lineColor:[200,200,200]},headStyles:{fillColor:[35,55,90],textColor:[255,255,255],fontStyle:`bold`,fontSize:8},alternateRowStyles:{fillColor:[244,246,250]}},courtCard:{styles:{fontSize:14,cellPadding:6,lineWidth:.3,lineColor:[100,100,100],halign:`center`},headStyles:{fillColor:[20,20,80],textColor:[255,255,255],fontStyle:`bold`,fontSize:16}}};function yt(e,r={}){let{header:i,includeRanking:a=!0,includeEvents:o=!0}=r,s=new t.default({orientation:`portrait`,format:`a4`});L(s);let c=15;i&&(c=W(s,{...i,subtitle:i.subtitle||`Player List`}));let l=[{header:`#`,dataKey:`index`},{header:`Name`,dataKey:`name`},{header:`Nat.`,dataKey:`nationality`}];a&&l.push({header:`Rank`,dataKey:`ranking`}),l.push({header:`Seed`,dataKey:`seed`}),l.push({header:`Entry`,dataKey:`entryStatus`}),o&&l.push({header:`Events`,dataKey:`events`});let u=e.map((e,t)=>({index:t+1,name:e.name,nationality:e.nationality,ranking:e.ranking||``,seed:e.seedValue?.toString()||``,entryStatus:e.entryStatus,events:e.events.join(`, `)}));return(0,n.default)(s,{...vt.playerList,startY:c,columns:l,body:u,columnStyles:{index:{cellWidth:10,halign:`center`},name:{cellWidth:`auto`,fontStyle:`bold`},nationality:{cellWidth:15,halign:`center`},ranking:{cellWidth:15,halign:`center`},seed:{cellWidth:12,halign:`center`},entryStatus:{cellWidth:15,halign:`center`},events:{cellWidth:`auto`}},didDrawPage:e=>{G(s,`Generated ${new Date().toLocaleDateString()}`,e.pageNumber)}}),s}function bt(e,r={}){let{header:i,eventName:a,signInDate:o,signInTime:s}=r,c=new t.default({orientation:`portrait`,format:`a4`});L(c);let l=15;if(i&&(l=W(c,{...i,subtitle:i.subtitle||`Player Sign-In Sheet`})),a||o){R(c,I.BODY,F.NORMAL);let e=[];a&&e.push(`Event: ${a}`),o&&e.push(`Date: ${o}`),s&&e.push(`Time: ${s}`),c.text(e.join(` | `),15,l),l+=6}let u=[{header:`#`,dataKey:`index`},{header:`Player Name`,dataKey:`name`},{header:`Nat.`,dataKey:`nationality`},{header:`Rank`,dataKey:`ranking`},{header:`Seed`,dataKey:`seed`},{header:`Entry`,dataKey:`entry`},{header:`Signature`,dataKey:`signature`},{header:`Time`,dataKey:`time`}],d=e.map((e,t)=>({index:t+1,name:e.name,nationality:e.nationality,ranking:e.ranking||``,seed:e.seedValue?.toString()||``,entry:e.entryStatus,signature:``,time:``}));return(0,n.default)(c,{startY:l,columns:u,body:d,styles:{fontSize:8,cellPadding:1.5,lineWidth:.2,lineColor:[150,150,150]},headStyles:{fillColor:[40,60,100],textColor:[255,255,255],fontStyle:`bold`,fontSize:7,cellPadding:2},alternateRowStyles:{fillColor:[245,247,250]},columnStyles:{index:{cellWidth:10,halign:`center`},name:{cellWidth:`auto`,fontStyle:`bold`},nationality:{cellWidth:14,halign:`center`},ranking:{cellWidth:14,halign:`center`},seed:{cellWidth:14,halign:`center`},entry:{cellWidth:14,halign:`center`},signature:{cellWidth:35},time:{cellWidth:15}}}),c}function xt(e,n={}){let{tournamentName:r=``,pageSize:i=`a5`,cardsPerPage:a=1}=n,o=new t.default({orientation:`landscape`,format:i});return L(o),e.forEach((e,t)=>{t>0&&o.addPage(),St(o,e,r,a)}),o}function St(e,t,r,i){let a=e.internal.pageSize.getWidth(),o=a/2,s=15;if(r&&(R(e,I.BODY,F.NORMAL),e.setTextColor(100),e.text(r,o,s,{align:`center`}),e.setTextColor(0),s+=8),R(e,28,F.BOLD),e.text(t.courtName,o,s,{align:`center`}),s+=5,t.venueName&&(R(e,I.HEADING,F.NORMAL),e.setTextColor(100),e.text(t.venueName,o,s,{align:`center`}),e.setTextColor(0)),s+=8,e.setDrawColor(0),e.setLineWidth(1),e.line(30,s,a-30,s),s+=8,t.currentMatch&&(R(e,I.HEADING,F.BOLD),e.setTextColor(30,60,120),e.text(`NOW PLAYING`,o,s,{align:`center`}),e.setTextColor(0),s+=6,R(e,I.BODY,F.ITALIC),e.text(`${t.currentMatch.eventName} - ${t.currentMatch.roundName}`,o,s,{align:`center`}),s+=8,(0,n.default)(e,{startY:s,margin:{left:25,right:25},theme:`plain`,styles:{halign:`center`,fontSize:16,cellPadding:4},body:[[{content:`${t.currentMatch.side1.name} (${t.currentMatch.side1.nationality})`,styles:{fontStyle:`bold`}}],[{content:`vs.`,styles:{fontSize:12,textColor:[120,120,120]}}],[{content:`${t.currentMatch.side2.name} (${t.currentMatch.side2.nationality})`,styles:{fontStyle:`bold`}}]]}),s=e.lastAutoTable?.finalY||s+40,s+=8),t.nextMatch){e.setDrawColor(180),e.setLineWidth(.3),e.line(50,s,a-50,s),s+=6,R(e,I.BODY,F.BOLD),e.setTextColor(100);let n=t.nextMatch.scheduledTime?`UP NEXT (${t.nextMatch.scheduledTime})`:`UP NEXT`;e.text(n,o,s,{align:`center`}),e.setTextColor(0),s+=5,R(e,I.BODY,F.NORMAL),e.text(`${t.nextMatch.eventName} - ${t.nextMatch.roundName}`,o,s,{align:`center`}),s+=5,R(e,I.HEADING,F.NORMAL),e.text(`${t.nextMatch.side1.name} vs. ${t.nextMatch.side2.name}`,o,s,{align:`center`})}}function Ct(e,n={}){let{cardsPerPage:r=2,includeScoreBoxes:i=!0}=n,a=new t.default({orientation:`landscape`,format:`a5`});return L(a),e.forEach((e,t)=>{t>0&&(r===1||t%r===0)&&a.addPage();let n=r===2&&t%2==1?a.internal.pageSize.getHeight()/2:5;wt(a,e,n,i)}),a}function wt(e,t,n,r){let i=e.internal.pageSize.getWidth(),a=i/2,o=n;if(t.tournamentName&&(R(e,I.BODY,F.NORMAL),e.setTextColor(100),e.text(t.tournamentName,a,o,{align:`center`}),e.setTextColor(0),o+=5),R(e,I.HEADING,F.BOLD),e.text(`${t.eventName} - ${t.roundName}`,a,o,{align:`center`}),o+=5,t.courtName||t.scheduledTime){R(e,I.BODY,F.NORMAL);let n=[];t.courtName&&n.push(`Court: ${t.courtName}`),t.scheduledTime&&n.push(`Time: ${t.scheduledTime}`),e.text(n.join(` `),a,o,{align:`center`}),o+=5}if(e.setDrawColor(0),e.setLineWidth(.5),e.line(10,o,i-10,o),o+=6,Tt(e,t.side1,10,o,i),o+=8,R(e,I.BODY,F.ITALIC),e.setTextColor(120),e.text(`vs.`,a,o,{align:`center`}),e.setTextColor(0),o+=6,Tt(e,t.side2,10,o,i),o+=8,r){e.setDrawColor(0),e.setLineWidth(.5),e.line(10,o,i-10,o),o+=4,R(e,I.SMALL,F.BOLD),e.text(`Score:`,10,o);for(let t=0;t<5;t++){let n=28+t*15;e.rect(n,o-4,12,8),R(e,I.TINY,F.NORMAL),e.setTextColor(150),e.text(`Set ${t+1}`,n+12/2,o-5,{align:`center`}),e.setTextColor(0)}o+=14,R(e,I.SMALL,F.NORMAL),e.text(`Umpire:`,10,o),e.setDrawColor(150),e.setLineWidth(.3),e.line(30,o,90,o),e.text(`Signature:`,i-10-70,o),e.line(i-10-40,o,i-10,o)}}function Tt(e,t,n,r,i){R(e,14,F.BOLD);let a=t.seedValue?`[${t.seedValue}] `:``;e.text(`${a}${t.name}`,n,r),R(e,I.HEADING,F.NORMAL),e.setTextColor(80),e.text(t.nationality,i-n,r,{align:`right`}),e.setTextColor(0)}function Et(e){let{drawDefinition:t,participants:n=[]}=e;if(!t)return Ot();let r=e.structureId?t.structures?.find(t=>t.structureId===e.structureId):t.structures?.[0];if(!r)return Ot();let i=new Map;n.forEach(e=>i.set(e.participantId,e));let a=r.positionAssignments||[],o=(r.matchUps||[]).reduce((e,t)=>Math.max(e,t.roundNumber||0),0),s=e.structureId?a.length:t.drawSize||a.length,c=e.structureId?o:Math.log2(s),l=r.seedAssignments||[],u=a.map(e=>{let t=e.participantId?i.get(e.participantId):void 0,n=l.find(t=>t.participantId===e.participantId);return{drawPosition:e.drawPosition,participantName:t?H(t):``,nationality:t?U(t):``,seedValue:n?.seedValue,entryStatus:e.entryStatus,isBye:e.bye===!0}}),d=(r.matchUps||[]).map(e=>({roundNumber:e.roundNumber,roundPosition:e.roundPosition,drawPositions:e.drawPositions||[],score:$e(e.score),winningSide:e.winningSide,matchUpStatus:e.matchUpStatus})),f=l.filter(e=>e.participantId).map(e=>{let t=i.get(e.participantId);return{seedValue:e.seedValue,participantName:t?H(t):``,nationality:t?U(t):``}}).sort((e,t)=>e.seedValue-t.seedValue),p=Dt(d,c,e.processedMatchUps);return{drawName:t.drawName||``,drawSize:s,drawType:t.drawType||`SINGLE_ELIMINATION`,totalRounds:c,slots:u,matchUps:d,seedAssignments:f,roundLabelMap:p}}function K(e,t){return rt(e,t)}function Dt(e,t,n){if(n?.length){let e={};for(let t of n)t.roundNumber&&!e[t.roundNumber]&&(e[t.roundNumber]=t.abbreviatedRoundName||t.roundName||`R${t.roundNumber}`);if(Object.keys(e).length>0)return e}let r=new Map;for(let t of e)r.set(t.roundNumber,(r.get(t.roundNumber)||0)+1);let i=[...r.keys()].sort((e,t)=>e-t);if(i.length>0&&i.every((e,t)=>{if(t===0)return!0;let n=r.get(i[t-1])||0;return(r.get(e)||0)<=Math.ceil(n/2)})){let e={};for(let n of i)e[n]=rt(n,t);return e}let a={};for(let e of i)a[e]=`R${e}`;return a}function Ot(){return{drawName:``,drawSize:0,drawType:``,totalRounds:0,slots:[],matchUps:[],seedAssignments:[]}}function kt(e,t){if(e.isBye)return`Bye`;if(!e.participantName)return``;let n=jt(e.participantName,t),r=Mt(e.nationality,t),i=e.seedValue?Nt(e.seedValue,t):``,a=e.entryStatus?Ft(e.entryStatus,t):``,o=[];return t.seedPosition===`before-position`&&i&&o.push(i),o.push(n),t.seedPosition===`after-name`&&i&&o.push(i),r&&o.push(r),t.seedPosition===`after-country`&&i&&o.push(i),a&&o.push(a),o.join(` `)}function At(e,t){if(e.isBye)return{name:`Bye`,nationality:``};if(!e.participantName)return{name:``,nationality:``};let n=jt(e.participantName,t),r=e.seedValue?Nt(e.seedValue,t):``,i=e.entryStatus?Ft(e.entryStatus,t):``,a=[];return t.seedPosition===`before-position`&&r&&a.push(r),a.push(n),t.seedPosition===`after-name`&&r&&a.push(r),t.seedPosition===`after-country`&&r&&a.push(r),i&&a.push(i),{name:a.join(` `),nationality:e.nationality||``}}function jt(e,t){if(t.nameFormat===`LAST First`)return e.replace(`,`,``);if(t.nameFormat===`F. LAST`){let t=e.match(/^([^,]+),\s*(.+)/);if(t)return`${t[2][0]}. ${t[1]}`}return e}function Mt(e,t){if(!e)return``;switch(t.nationalityFormat){case`parens`:return`(${e})`;case`hyphen`:return`-${e}`;default:return e}}function Nt(e,t){switch(t.seedFormat){case`parens`:return`(${e})`;case`bare`:return`${e}`;default:return`[${e}]`}}var Pt={DIRECT_ACCEPTANCE:``,WILDCARD:`WC`,QUALIFIER:`Q`,LUCKY_LOSER:`LL`,SPECIAL_EXEMPT:`SE`,ALTERNATE:`ALT`,PROTECTED_RANKING:`PR`,JUNIOR_EXEMPT:`JE`,ORGANISER_ACCEPTANCE:`OA`};function Ft(e,t){if(!e)return``;let n=Pt[e];if(n===void 0)return e;if(!n)return``;switch(t.entryFormat){case`parens`:return`(${n})`;case`hyphen`:return`-${n}`;default:return n}}function q(e,t){if(!e)return``;switch(t.gameScoreSeparator){case`/`:return e.replace(/(\d)-(\d)/g,`$1/$2`);case`none`:return e.replace(/(\d)-(\d)/g,`$1$2`);default:return e}}function It(e,t,n){let r=n||Math.log2(e),i=(t.contentHeight-9)/e,a=i<3.5,o=a?.8:1.5,s=r,c=o*(s+1),l=i<2,u=a?.18:.3,d=Math.min(a?38:65,t.contentWidth*u),f=t.contentWidth-d-c,p=l?8:0,m=f-p,h=Math.min(65,Math.max(8,m/Math.max(1,s))),g=h+p,_=I.SMALL;return i<2.5?_=5:i<3.5&&(_=I.TINY),{lineHeight:i,roundColumnWidth:h,firstRoundWidth:d,secondRoundWidth:g,connectorGap:o,fontSize:_,scoreFontSize:a?5:I.TINY}}function J(e,t,n,r,i=0,a){Lt(t.matchUps)?Rt(e,t,n,r):Xt(e,t,n,r,i,a)}function Lt(e){let t=new Map;for(let n of e)t.set(n.roundNumber,(t.get(n.roundNumber)||0)+1);let n=[...t.keys()].sort((e,t)=>e-t);for(let e=1;e<n.length;e++){let r=t.get(n[e-1])||0;if((t.get(n[e])||0)>=r)return!0}return!1}function Rt(e,t,n,r){let i=n.page.margins,a=r.contentY+9,o=r.contentHeight-9,s=zt(t.matchUps),c=[...s.keys()].sort((e,t)=>e-t),l=c.length,u=new Map(t.slots.map(e=>[e.drawPosition,e])),d=Bt(c,s),{feedConfig:f,connectorGap:p,firstRoundWidth:m,roundColumnWidth:h,fontSize:g,scoreFontSize:_}=Vt(o,s,c,l,r),v=e=>e===0?i.left:i.left+m+p+(e-1)*(h+p);Yt(e,c,t,f,n,r,v,l,h);let y=Ht(c,l,s,d,a,o,f.lineHeight);Ut(e,c,l,s,y,d,u,f,n,v,m,h,p,_),Jt(e,t,c,l,s,y,u,v,a,o,h,g,_,n)}function zt(e){let t=new Map;for(let n of e)t.has(n.roundNumber)||t.set(n.roundNumber,[]),t.get(n.roundNumber).push(n);for(let[,e]of t)e.sort((e,t)=>e.roundPosition-t.roundPosition);return t}function Bt(e,t){let n=new Set;for(let r=1;r<e.length;r++){let i=t.get(e[r-1])?.length||0;(t.get(e[r])?.length||0)>=i&&n.add(e[r])}return n}function Vt(e,t,n,r,i){let a=1.5,o=e/((t.get(n[0])?.length||1)*2),s=o<3.5,c=Math.min(s?50:60,i.contentWidth*.25),l=i.contentWidth-c-a*(r+1),u=Math.max(8,l/Math.max(1,r)),d=I.SMALL;o<2.5?d=5:o<3.5&&(d=I.TINY);let f=s?5:I.TINY;return{feedConfig:{lineHeight:o,roundColumnWidth:u,firstRoundWidth:c,secondRoundWidth:u,connectorGap:a,fontSize:d,scoreFontSize:f},connectorGap:a,firstRoundWidth:c,roundColumnWidth:u,fontSize:d,scoreFontSize:f}}function Ht(e,t,n,r,i,a,o){let s=new Map;for(let c=0;c<t;c++){let t=e[c],l=n.get(t)?.length||0;if(r.has(t)){let n=e[c-1],r=(s.get(n)||[]).slice(0,l).map(e=>e.bottomY-e.topY>o*2?{topY:e.midY-o,bottomY:e.midY+o,midY:e.midY}:{topY:e.topY,bottomY:e.bottomY,midY:e.midY});s.set(t,r)}else if(c===0){let e=a/(l*2+1),n=[];for(let t=0;t<l;t++){let r=i+e*(t*2+1),a=i+e*(t*2+2);n.push({topY:r,bottomY:a,midY:(r+a)/2})}s.set(t,n)}else{let n=e[c-1],r=s.get(n)||[],i=[];for(let e=0;e<l;e++){let t=r[e*2],n=r[e*2+1];if(t&&n){let e=t.midY,r=n.midY;i.push({topY:e,bottomY:r,midY:(e+r)/2})}}s.set(t,i)}}return s}function Ut(e,t,n,r,i,a,o,s,c,l,u,d,f,p){for(let m=0;m<n;m++){let h=t[m],g=r.get(h)||[],_=i.get(h)||[],v=l(m),y=m===0?u:d,b=a.has(h),x=v+y,S=m<n-1&&a.has(t[m+1]);for(let i=0;i<g.length;i++){let a=g[i],h=_[i];if(h){if(e.setDrawColor(40),e.setLineWidth(.25),m===0?Wt(e,a,h,o,c,s,v,u,x,f,S):b?Gt(e,a,h,o,r,t,m,c,s,v,d,x,f,S):Kt(e,a,h,o,c,s,v,d,x,f,S),m<n-1){let t=l(m+1);S?e.line(x,h.midY,t,h.midY):e.line(x+f,h.midY,t,h.midY)}if(a.score){let t=q(a.score,c);R(e,p,F.NORMAL),e.setTextColor(60,60,160);let n=h.midY+p*.12;e.text(t,x-1,n,{align:`right`}),e.setTextColor(0)}}}}}function Wt(e,t,n,r,i,a,o,s,c,l,u){t.drawPositions[0]&&rn(e,r.get(t.drawPositions[0]),t.drawPositions[0],i,a,o,n.topY,s),t.drawPositions[1]&&rn(e,r.get(t.drawPositions[1]),t.drawPositions[1],i,a,o,n.bottomY,s),qt(e,n,c,l,u)}function Gt(e,t,n,r,i,a,o,s,c,l,u,d,f,p){let m=a[o-1],h=i.get(m)||[],g=new Set;for(let e of h)e.winningSide&&g.add(e.drawPositions[e.winningSide-1]);let _=t.drawPositions.find(e=>e&&g.has(e)),v=t.drawPositions.find(e=>e&&e!==_);if(e.line(l,n.midY,l,n.bottomY),v?rn(e,r.get(v),v,s,c,l,n.topY,u):e.line(l,n.topY,l+u,n.topY),e.line(l,n.bottomY,l+u,n.bottomY),_){let t=r.get(_);t?.participantName&&an(e,t,s,c,l,n.bottomY)}qt(e,n,d,f,p)}function Kt(e,t,n,r,i,a,o,s,c,l,u){if(e.line(o,n.topY,o+s,n.topY),e.line(o,n.bottomY,o+s,n.bottomY),t.drawPositions[0]){let s=r.get(t.drawPositions[0]);s?.participantName&&an(e,s,i,a,o,n.topY)}if(t.drawPositions[1]){let s=r.get(t.drawPositions[1]);s?.participantName&&an(e,s,i,a,o,n.bottomY)}qt(e,n,c,l,u)}function qt(e,t,n,r,i){i?e.line(n,t.topY,n,t.bottomY):(e.line(n+r,t.topY,n+r,t.bottomY),e.line(n,t.topY,n+r,t.topY),e.line(n,t.bottomY,n+r,t.bottomY))}function Jt(e,t,n,r,i,a,o,s,c,l,u,d,f,p){if(t.noWinnerColumn)return;let m=s(r),h=n.at(-1),g=(a.get(h)||[])[0]?.midY||c+l/2;e.setDrawColor(40),e.setLineWidth(.25),e.line(m,g,m+Math.min(65,u),g);let _=(i.get(h)||[])[0];if(_?.winningSide){let t=_.drawPositions[_.winningSide-1],n=o.get(t);if(n){R(e,d+1,F.BOLD);let{name:t}=At(n,p);if(e.text(t,m+1,g-.5),_.score){let t=q(_.score,p);R(e,f,F.NORMAL),e.setTextColor(60,60,160),e.text(t,m+1,g+f*.4),e.setTextColor(0)}}}}function Yt(e,t,n,r,i,a,o,s,c){R(e,r.fontSize<=I.TINY?5.5:I.SMALL,F.BOLD),e.setTextColor(40);for(let l=0;l<s;l++){let s=t[l],u=K(s,n.totalRounds),d=n.roundLabelMap?.[s]||i.roundLabels[u]||u,f=o(l),p=l===0?r.firstRoundWidth:c;e.text(d,f+p/2,a.contentY+2,{align:`center`}),e.setDrawColor(160),e.setLineWidth(.15),e.line(f+2,a.contentY+3.5,f+p-2,a.contentY+3.5)}let l=o(s);e.text(`Winner`,l+c/2,a.contentY+2,{align:`center`}),e.setDrawColor(160),e.line(l+2,a.contentY+3.5,l+c-2,a.contentY+3.5),e.setTextColor(0)}function Xt(e,t,n,r,i=0,a){let o=a||t.drawSize,s=t.totalRounds||Math.ceil(Math.log2(o)),c=Math.log2(o),l=Number.isInteger(c)?Math.min(c,s):s,u=It(o,r,l),d=n.page.margins.left,f=r.contentY+9;en(e,l,t.totalRounds,u,n,d,r.contentY+2,t.roundLabelMap,t.noWinnerColumn);for(let r=0;r<l;r++)Zt(e,t,n,u,o,r,l,d,f,i);t.noWinnerColumn||$t(e,t,n,u,l,d,f)}function Zt(e,t,n,r,i,a,o,s,c,l){let u=i/2**(a+1),d=r.lineHeight*2**a,f=nn(a,r,s),p=(2**a-1)*r.lineHeight/2,m=2**(a+1)*r.lineHeight;for(let i=0;i<u;i++){let u=c+p+i*m,h=u+d,g=(u+h)/2;if(a===0){let a=l+i*2+1,o=l+i*2+2;rn(e,sn(t.slots,a),a,n,r,f,u),rn(e,sn(t.slots,o),o,n,r,f,h)}else{let t=tn(a,r);e.setDrawColor(40),e.setLineWidth(.25),e.line(f,u,f+t,u),e.line(f,h,f+t,h)}let _=a===o-1,v=f+tn(a,r);if(e.setDrawColor(40),e.setLineWidth(.25),e.line(v+r.connectorGap,u,v+r.connectorGap,h),e.line(v,u,v+r.connectorGap,u),e.line(v,h,v+r.connectorGap,h),!_||!t.noWinnerColumn){let t=nn(a+1,r,s);e.line(v+r.connectorGap,g,t,g)}let y=cn(t.matchUps,a+1,i+1);if(_&&t.noWinnerColumn){let i=ln(y,t.slots);i&&(e.setDrawColor(40),e.setLineWidth(.25),e.line(v+r.connectorGap,g,v+r.connectorGap+r.roundColumnWidth,g),an(e,i,n,r,v+r.connectorGap,g),y?.score&&Qt(e,y,n,r,d,v+r.connectorGap,a,g))}else if(!_){let i=ln(y,t.slots);if(i){let t=nn(a+1,r,s);an(e,i,n,r,t,g),y?.score&&Qt(e,y,n,r,d,t,a,g)}}}}function Qt(e,t,n,r,i,a,o,s){let c=q(t.score,n);if(R(e,r.scoreFontSize,F.NORMAL),e.setTextColor(60,60,160),i*2<r.scoreFontSize*1.2){let t=a+tn(o+1,r)-1;e.text(c,t,s-.5,{align:`right`})}else{let t=r.scoreFontSize*.4;e.text(c,a+1,s-.5+t)}e.setTextColor(0)}function $t(e,t,n,r,i,a,o){let s=nn(i,r,a),c=(2**(i-1)-1)*r.lineHeight/2,l=r.lineHeight*2**(i-1),u=o+c+l/2;e.setDrawColor(40),e.setLineWidth(.25),e.line(s,u,s+r.roundColumnWidth,u);let d=cn(t.matchUps,i,1);if(d?.winningSide){let i=d.drawPositions[d.winningSide-1],a=sn(t.slots,i);if(a){R(e,r.fontSize+1,F.BOLD);let{name:t}=At(a,n);if(e.text(t,s+1,u-.5),d.score){let t=q(d.score,n);R(e,r.scoreFontSize,F.NORMAL),e.setTextColor(60,60,160),e.text(t,s+1,u+r.scoreFontSize*.4),e.setTextColor(0)}}}}function en(e,t,n,r,i,a,o,s,c){R(e,r.fontSize<=I.TINY?5.5:I.SMALL,F.BOLD),e.setTextColor(40);for(let c=0;c<t;c++){let l=n-t+c+1,u=K(l,n),d=s?.[l]||i.roundLabels[u]||u,f=nn(c,r,a),p=tn(c,r),m=f+p/2;e.text(d,m,o,{align:`center`}),e.setDrawColor(160),e.setLineWidth(.15),e.line(f+2,o+1.5,f+p-2,o+1.5)}if(!c){let n=nn(t,r,a);e.text(`Winner`,n+r.roundColumnWidth/2,o,{align:`center`}),e.setDrawColor(160),e.setLineWidth(.15),e.line(n+2,o+1.5,n+r.roundColumnWidth-2,o+1.5)}e.setTextColor(0)}function tn(e,t){return e===0?t.firstRoundWidth:e===1?t.secondRoundWidth:t.roundColumnWidth}function nn(e,t,n){if(e===0)return n;let r=n+t.firstRoundWidth+t.connectorGap;for(let n=1;n<e;n++)r+=tn(n,t)+t.connectorGap;return r}function rn(e,t,n,r,i,a,o,s){let c=i.fontSize<=5?4:5,l=i.fontSize<=5?5:6,u=s||i.firstRoundWidth,d=i.lineHeight<2?.15:.3;R(e,i.scoreFontSize,F.NORMAL),e.setTextColor(120),e.text(`${n}`,a,o-d,{align:`left`}),e.setTextColor(0),t?.nationality&&(R(e,i.scoreFontSize,F.NORMAL),e.setTextColor(100),e.text(t.nationality,a+c+l-1,o-d,{align:`right`}),e.setTextColor(0));let f=a+c+l,p=a+u;if(e.setDrawColor(40),e.setLineWidth(.25),e.line(f,o,p,o),!t)return;let{name:m}=At(t,r);if(!m)return;R(e,i.fontSize,t.isBye?F.ITALIC:F.NORMAL),t.isBye&&e.setTextColor(150);let h=p-f-2,g=m;e.getTextWidth(m)>h&&(g=on(t.participantName));let _=i.lineHeight<2?.2:.5;e.text(g,f+1,o-_),t.isBye&&e.setTextColor(0)}function an(e,t,n,r,i,a){let o=on(t.participantName),s=``;if(t.seedValue)switch(n.seedFormat){case`parens`:s=`(${t.seedValue})`;break;case`bare`:s=`${t.seedValue}`;break;default:s=`[${t.seedValue}]`}let c=s?`${o} ${s}`:o;R(e,r.fontSize,F.BOLD),e.text(c,i+1,a-.5)}function on(e){let t=e.match(/^([^,]+),\s*(.+)/);if(t)return`${t[2][0]}. ${t[1]}`;let n=e.match(/^(\S+)\s+(.+)/);return n?`${n[1][0]}. ${n[2]}`:e}function sn(e,t){return e.find(e=>e.drawPosition===t)}function cn(e,t,n){return e.find(e=>e.roundNumber===t&&e.roundPosition===n)}function ln(e,t){if(e){if(e.winningSide){let n=e.drawPositions[e.winningSide-1];return sn(t,n)}if(e.matchUpStatus===`BYE`)for(let n of e.drawPositions){let e=sn(t,n);if(e&&!e.isBye&&e.participantName)return e}}}function un(e,t,n,r){let i=n.page.margins,a=r.contentY+9,o=r.contentHeight-9,s=t.drawSize/2,c=Math.log2(s),l=r.contentWidth,u=Math.min(30,l*.08),d=(l-u)/2,f=i.left+d,p=o/s,m=p<3.5,h=m?.8:1.5,g=Math.min(m?30:50,d*.22),_=c,v=d-g-h*(_+1),y=Math.max(8,v/Math.max(1,_)),b=I.SMALL;p<2.5?b=5:m&&(b=I.TINY);let x=m?5:I.TINY,S={lineHeight:p,roundColumnWidth:y,firstRoundWidth:g,connectorGap:h,fontSize:b,scoreFontSize:x},C=t.slots.filter(e=>e.drawPosition<=s),ee=t.slots.filter(e=>e.drawPosition>s),te=t.matchUps.filter(e=>e.drawPositions.every(e=>e<=s)),w=t.matchUps.filter(e=>e.drawPositions.every(e=>e>s)),T=ee.map(e=>({...e,drawPosition:e.drawPosition-s})),E=new Map;for(let e of w)E.has(e.roundNumber)||E.set(e.roundNumber,[]),E.get(e.roundNumber).push(e);let D=[];for(let[,e]of E)e.sort((e,t)=>e.roundPosition-t.roundPosition),e.forEach((e,t)=>{D.push({...e,drawPositions:e.drawPositions.map(e=>e-s),roundPosition:t+1})});let O=new Map;for(let e of te)O.has(e.roundNumber)||O.set(e.roundNumber,[]),O.get(e.roundNumber).push(e);let k=[];for(let[,e]of O)e.sort((e,t)=>e.roundPosition-t.roundPosition),e.forEach((e,t)=>{k.push({...e,roundPosition:t+1})});pn(e,c,t.totalRounds,S,n,i.left,i.left+l,r.contentY+2,t.roundLabelMap),R(e,m?5.5:I.SMALL,F.BOLD),e.setTextColor(40),e.text(`Winner`,f+u/2,r.contentY+2,{align:`center`}),e.setDrawColor(160),e.setLineWidth(.15),e.line(f+2,r.contentY+3.5,f+u-2,r.contentY+3.5),e.setTextColor(0),dn(e,C,k,c,S,n,i.left,a,t.totalRounds),fn(e,T,D,c,S,n,i.left+l,a,t.totalRounds);let A=t.matchUps.find(e=>e.roundNumber===t.totalRounds);if(A){let r=a+o/2;if(e.setDrawColor(40),e.setLineWidth(.25),e.line(f+2,r,f+u-2,r),A.winningSide){let i=A.drawPositions[A.winningSide-1],a=t.slots.find(e=>e.drawPosition===i);if(a){let{name:t}=At(a,n);R(e,b+1,F.BOLD),e.text(t,f+u/2,r-1,{align:`center`})}}A.score&&(R(e,x,F.NORMAL),e.setTextColor(60,60,160),e.text(q(A.score,n),f+u/2,r+x*.4,{align:`center`}),e.setTextColor(0))}}function dn(e,t,n,r,i,a,o,s,c){let l=new Map(t.map(e=>[e.drawPosition,e])),u=t.length;for(let t=0;t<r;t++){let c=u/2**(t+1),d=i.lineHeight*2**t,f=(2**t-1)*i.lineHeight/2,p=2**(t+1)*i.lineHeight,m=mn(t,i,o),h=t===0?i.firstRoundWidth:i.roundColumnWidth;for(let u=0;u<c;u++){let c=s+f+u*p,g=c+d,_=(c+g)/2;if(t===0){let t=u*2+1,n=u*2+2;gn(e,l.get(t),i,m,c,h,`ltr`),gn(e,l.get(n),i,m,g,h,`ltr`)}else e.setDrawColor(40),e.setLineWidth(.25),e.line(m,c,m+h,c),e.line(m,g,m+h,g);let v=m+h,y=mn(t+1,i,o);e.setDrawColor(40),e.setLineWidth(.25),e.line(v+i.connectorGap,c,v+i.connectorGap,g),e.line(v,c,v+i.connectorGap,c),e.line(v,g,v+i.connectorGap,g),e.line(v+i.connectorGap,_,y,_);let b=vn(n,t+1,u+1);if(t<r-1&&b?.winningSide){let t=b.drawPositions[b.winningSide-1],n=l.get(t);if(n){R(e,i.fontSize,F.BOLD);let t=n.participantName;e.getTextWidth(t)>i.roundColumnWidth-2&&(t=_n(t)),e.text(t,y+1,_-.5)}}b?.score&&t<r-1&&(R(e,i.scoreFontSize,F.NORMAL),e.setTextColor(60,60,160),e.text(q(b.score,a),y+1,_-.5+i.scoreFontSize*.4),e.setTextColor(0))}}}function fn(e,t,n,r,i,a,o,s,c){let l=new Map(t.map(e=>[e.drawPosition,e])),u=t.length;for(let t=0;t<r;t++){let c=u/2**(t+1),d=i.lineHeight*2**t,f=(2**t-1)*i.lineHeight/2,p=2**(t+1)*i.lineHeight,m=hn(t,i,o),h=t===0?i.firstRoundWidth:i.roundColumnWidth;for(let u=0;u<c;u++){let c=s+f+u*p,g=c+d,_=(c+g)/2;if(t===0){let t=u*2+1,n=u*2+2;gn(e,l.get(t),i,m,c,h,`rtl`),gn(e,l.get(n),i,m,g,h,`rtl`)}else e.setDrawColor(40),e.setLineWidth(.25),e.line(m,c,m+h,c),e.line(m,g,m+h,g);let v=m,y=hn(t+1,i,o);e.setDrawColor(40),e.setLineWidth(.25),e.line(v-i.connectorGap,c,v-i.connectorGap,g),e.line(v,c,v-i.connectorGap,c),e.line(v,g,v-i.connectorGap,g),e.line(v-i.connectorGap,_,y+i.roundColumnWidth,_);let b=vn(n,t+1,u+1);if(t<r-1&&b?.winningSide){let t=b.drawPositions[b.winningSide-1],n=l.get(t);if(n){R(e,i.fontSize,F.BOLD);let t=n.participantName;e.getTextWidth(t)>i.roundColumnWidth-2&&(t=_n(t));let r=y;e.text(t,r+i.roundColumnWidth-1,_-.5,{align:`right`})}}if(b?.score&&t<r-1){let t=y;R(e,i.scoreFontSize,F.NORMAL),e.setTextColor(60,60,160),e.text(q(b.score,a),t+i.roundColumnWidth-1,_-.5+i.scoreFontSize*.4,{align:`right`}),e.setTextColor(0)}}}}function pn(e,t,n,r,i,a,o,s,c){R(e,r.fontSize<=I.TINY?5.5:I.SMALL,F.BOLD),e.setTextColor(40);for(let l=0;l<t;l++){let u=n-t+l+1,d=K(u,n),f=c?.[u]||i.roundLabels[d]||d,p=l===0?r.firstRoundWidth:r.roundColumnWidth,m=mn(l,r,a);e.text(f,m+p/2,s,{align:`center`}),e.setDrawColor(160),e.setLineWidth(.15),e.line(m+2,s+1.5,m+p-2,s+1.5);let h=hn(l,r,o);e.text(f,h+p/2,s,{align:`center`}),e.line(h+2,s+1.5,h+p-2,s+1.5)}e.setTextColor(0)}function mn(e,t,n){return e===0?n:n+t.firstRoundWidth+t.connectorGap+(e-1)*(t.roundColumnWidth+t.connectorGap)}function hn(e,t,n){return e===0?n-t.firstRoundWidth:n-t.firstRoundWidth-t.connectorGap-(e-1)*(t.roundColumnWidth+t.connectorGap)-t.roundColumnWidth}function gn(e,t,n,r,i,a,o){if(e.setDrawColor(40),e.setLineWidth(.25),e.line(r,i,r+a,i),!t||t.isBye){t?.isBye&&(R(e,n.fontSize,F.ITALIC),e.setTextColor(150),o===`ltr`?e.text(`Bye`,r+1,i-.3):e.text(`Bye`,r+a-1,i-.3,{align:`right`}),e.setTextColor(0));return}let s=t.seedValue?`[${t.seedValue}]`:``;R(e,n.fontSize,F.NORMAL);let c=t.participantName,l=s?`${s} ${c}`:c;e.getTextWidth(l)>a-2&&(c=_n(t.participantName),l=s?`${s} ${c}`:c),o===`ltr`?e.text(l,r+1,i-.3):e.text(l,r+a-1,i-.3,{align:`right`})}function _n(e){let t=e.match(/^([^,]+),\s*(.+)/);if(t)return`${t[2][0]}. ${t[1]}`;let n=e.match(/^(\S+)\s+(.+)/);return n?`${n[1][0]}. ${n[2]}`:e}function vn(e,t,n){return e.find(e=>e.roundNumber===t&&e.roundPosition===n)}function yn(e,t,n,r){let i=n.page.margins,a=r.contentY+9,o=r.contentHeight-9,s=r.contentWidth,c=t.mainDraw.matchUps,l=t.mainDraw.slots,u=t.consolation.matchUps,d=t.consolation.slots,f=new Map(l.map(e=>[e.drawPosition,e])),p=new Map(d.map(e=>[e.drawPosition,e])),m=c.filter(e=>e.roundNumber===1).sort((e,t)=>e.roundPosition-t.roundPosition),h=m.length,g=h*2,_=Math.max(...c.map(e=>e.roundNumber)),v=_-1,y=u.length>0?Math.max(...u.map(e=>e.roundNumber)):0,b=1.5,x=s-28-b*4,S=v+1,C=Math.max(y+1,1),ee=x*(S/(S+C)),te=x-ee,w=i.left+te+b,T=S>0?(ee-b*S)/S:0,E=w+28+b,D=C>0?(te-b*C)/C:0,O=i.left+te,k=o/g,A=k<3.5,j=I.SMALL;k<2.5?j=5:A&&(j=I.TINY);let ne=A?5:I.TINY;On(e,_,y,t,n,w,28,E,T,O,D,b,r.contentY+2,j),bn(e,m,h,f,w,28,b,E,O,a,k,j,y),Sn(e,c,f,_,h,E,T,b,a,k,j,ne,n,t.mainDraw.roundLabelMap),Cn(e,u,p,y,O,D,b,a,k,h,j,ne,n,t.consolation.roundLabelMap)}function bn(e,t,n,r,i,a,o,s,c,l,u,d,f){for(let p=0;p<n;p++){let n=t[p],m=l+p*u*2,h=m+u,g=(m+h)/2,_=n.drawPositions[0],v=n.drawPositions[1],y=u*.9;e.setDrawColor(40),e.setLineWidth(.3),e.rect(i,m,a,y),e.rect(i,h,a,y);let b=_?r.get(_):void 0,x=v?r.get(v):void 0;R(e,d,F.NORMAL),_&&xn(e,_,b,n.winningSide===1,i,m,y,a,d),v&&xn(e,v,x,n.winningSide===2,i,h,y,a,d),e.setDrawColor(40),e.setLineWidth(.25),e.line(i+a,m+y/2,i+a+o,m+y/2),e.line(i+a,h+y/2,i+a+o,h+y/2),e.line(i+a+o,m+y/2,i+a+o,h+y/2),e.line(i+a+o,g,s,g),f>0&&(e.line(i,m+y/2,i-o,m+y/2),e.line(i,h+y/2,i-o,h+y/2),e.line(i-o,m+y/2,i-o,h+y/2),e.line(i-o,g,c,g))}}function xn(e,t,n,r,i,a,o,s,c){if(e.setTextColor(120),R(e,c,F.NORMAL),e.text(`${t}`,i+1,a+o/2+c*.12),e.setTextColor(0),n?.participantName){let t=kn(n.participantName);R(e,c,r?F.BOLD:F.NORMAL),e.text(t,i+5,a+o/2+c*.12,{maxWidth:s-6})}}function Sn(e,t,n,r,i,a,o,s,c,l,u,d,f,p){for(let i=0;i<r-1;i++){let p=i+2,m=t.filter(e=>e.roundNumber===p).sort((e,t)=>e.roundPosition-t.roundPosition),h=l*2**(i+1),g=(2**(i+1)-1)*l/2,_=a+i*(o+s);for(let t=0;t<m.length;t++){let l=m[t],p=c+g+t*h*2,v=p+h,y=(p+v)/2;if(e.setDrawColor(40),e.setLineWidth(.25),e.line(_,p,_+o,p),e.line(_,v,_+o,v),Dn(e,l,n,_,p,v,o,u,f),i<r-2){let t=_+o;e.line(t+s,p,t+s,v),e.line(t,p,t+s,p),e.line(t,v,t+s,v),e.line(t+s,y,_+o+s+o+s>0?a+(i+1)*(o+s):t+s+5,y)}l.score&&(R(e,d,F.NORMAL),e.setTextColor(60,60,160),e.text(q(l.score,f),_+o-1,y+d*.12,{align:`right`}),e.setTextColor(0))}}let m=a+(r-2)*(o+s)+o+s,h=c+(2**(r-1)-1)*l/2+l*2**(r-2);e.setDrawColor(40),e.setLineWidth(.25),e.line(m,h,m+o,h);let g=t.find(e=>e.roundNumber===r);if(g?.winningSide){let t=n.get(g.drawPositions[g.winningSide-1]);if(t){let{name:n}=At(t,f);R(e,u+1,F.BOLD),e.text(n,m+1,h-.5)}}}function Cn(e,t,n,r,i,a,o,s,c,l,u,d,f,p){for(let l=0;l<r;l++)wn(e,t,n,l,r,i,a,o,s,c,u,d,f);En(e,t,n,r,i,a,o,s,c,u,f)}function wn(e,t,n,r,i,a,o,s,c,l,u,d,f){let p=r+1,m=t.filter(e=>e.roundNumber===p).sort((e,t)=>e.roundPosition-t.roundPosition),h=l*2**(r+1),g=(2**(r+1)-1)*l/2,_=a-(r+1)*(o+s);for(let t=0;t<m.length;t++){let l=m[t],p=c+g+t*h*2,v=p+h,y=(p+v)/2;if(e.setDrawColor(40),e.setLineWidth(.25),e.line(_,p,_+o,p),e.line(_,v,_+o,v),Tn(e,l.drawPositions[0],n,u,_,o,p),Tn(e,l.drawPositions[1],n,u,_,o,v),r<i-1){e.line(_-s,p,_-s,v),e.line(_,p,_-s,p),e.line(_,v,_-s,v);let t=a-(r+2)*(o+s);e.line(_-s,y,t+o,y)}l.score&&(R(e,d,F.NORMAL),e.setTextColor(60,60,160),e.text(q(l.score,f),_+1,y+d*.12),e.setTextColor(0))}}function Tn(e,t,n,r,i,a,o){if(!t)return;let s=n.get(t);if(!s?.participantName)return;R(e,r,F.BOLD);let c=s.participantName;e.getTextWidth(c)>a-2&&(c=kn(c)),e.text(c,i+a-1,o-.3,{align:`right`})}function En(e,t,n,r,i,a,o,s,c,l,u){if(r<=0)return;let d=i-(r+1)*(a+o),f=s+(2**r-1)*c/2+c*2**(r-1);e.setDrawColor(40),e.setLineWidth(.25),e.line(d,f,d+a,f);let p=t.find(e=>e.roundNumber===r);if(p?.winningSide){let t=n.get(p.drawPositions[p.winningSide-1]);if(t){let{name:n}=At(t,u);R(e,l+1,F.BOLD),e.text(n,d+a-1,f-.5,{align:`right`})}}}function Dn(e,t,n,r,i,a,o,s,c){if(t.drawPositions[0]){let a=n.get(t.drawPositions[0]);if(a?.participantName){R(e,s,F.BOLD);let t=a.participantName;e.getTextWidth(t)>o-2&&(t=kn(t)),e.text(t,r+1,i-.3)}}if(t.drawPositions[1]){let i=n.get(t.drawPositions[1]);if(i?.participantName){R(e,s,F.BOLD);let t=i.participantName;e.getTextWidth(t)>o-2&&(t=kn(t)),e.text(t,r+1,a-.3)}}}function On(e,t,n,r,i,a,o,s,c,l,u,d,f,p){R(e,p<=I.TINY?5.5:I.SMALL,F.BOLD),e.setTextColor(40);let m=r.mainDraw.roundLabelMap?.[1]||`R1`;e.text(m,a+o/2,f,{align:`center`});for(let n=0;n<t-1;n++){let t=n+2,i=r.mainDraw.roundLabelMap?.[t]||`R${t}`,a=s+n*(c+d);e.text(i,a+c/2,f,{align:`center`})}for(let t=0;t<n;t++){let n=t+1,i=r.consolation.roundLabelMap?.[n]||`C-R${n}`,a=l-(t+1)*(u+d);e.text(i,a+u/2,f,{align:`center`})}e.setTextColor(0)}function kn(e){let t=e.match(/^([^,]+),\s*(.+)/);if(t)return`${t[2][0]}. ${t[1]}`;let n=e.match(/^(\S+)\s+(.+)/);return n?`${n[1][0]}. ${n[2]}`:e}var An=[`E`,`W`,`N`,`S`,`NE`,`NW`,`SE`,`SW`];function jn(e,t,n,r){let i=n.page.margins,a=[...t.structures].sort((e,t)=>An.indexOf(e.abbreviation)-An.indexOf(t.abbreviation)),o=r.contentY+3;for(let s of a){if(s.drawSize===0)continue;let a=Mn(s,r);o+a>r.contentY+r.contentHeight&&(e.addPage(),o=r.contentY);let c=s.abbreviation===`E`;R(e,c?I.HEADING:I.BODY,F.BOLD),c||e.setTextColor(30,60,120);let l=c?`Main Draw (${s.name})`:`${s.name} Draw`;e.text(l,i.left,o),c||e.setTextColor(0),o+=c?5:4;let u={...r,contentY:o,contentHeight:a-6};J(e,Nn(s,t.drawName),n,u),o+=a+3}}function Mn(e,t){let n=t.contentHeight*.7,r=Math.max(5,Math.min(8,n/e.drawSize));return e.drawSize*r+10}function Nn(e,t){return{drawName:`${t} - ${e.name}`,drawSize:e.drawSize,drawType:`SINGLE_ELIMINATION`,totalRounds:e.totalRounds,slots:e.slots,matchUps:e.matchUps,seedAssignments:[]}}function Pn(e){let{drawDefinition:t,participants:n=[]}=e;if(!t?.structures)return[];let r=new Map;return n.forEach(e=>r.set(e.participantId,e)),t.structures.map(t=>{let n=t.positionAssignments||[],i=t.seedAssignments||[],a=n.length,o=n.map(e=>{let t=e.participantId?r.get(e.participantId):void 0,n=i.find(t=>t.participantId===e.participantId);return{drawPosition:e.drawPosition,participantName:t?H(t):``,nationality:t?U(t):``,seedValue:n?.seedValue,isBye:e.bye===!0}}),s=(t.matchUps||[]).map(e=>({roundNumber:e.roundNumber,roundPosition:e.roundPosition,drawPositions:e.drawPositions||[],score:e.score?.scoreStringSide1||``,winningSide:e.winningSide,matchUpStatus:e.matchUpStatus})),c=t.stage||`MAIN`,l=c===`MAIN`,u=t.structureName||(l?`Main Draw`:`Consolation`),d=s.reduce((e,t)=>Math.max(e,t.roundNumber||0),0),f=(e.processedMatchUps||[]).filter(e=>e.structureId===t.structureId),p;if(f.length){p={};for(let e of f)e.roundNumber&&!p[e.roundNumber]&&(p[e.roundNumber]=e.abbreviatedRoundName||e.roundName||`R${e.roundNumber}`)}return{name:u,stage:c,drawData:{drawName:u,drawSize:a,drawType:`SINGLE_ELIMINATION`,totalRounds:d,slots:o,matchUps:s,seedAssignments:i.filter(e=>e.participantId).map(e=>{let t=r.get(e.participantId);return{seedValue:e.seedValue,participantName:t?H(t):``,nationality:t?U(t):``}}),roundLabelMap:p}}})}function Fn(e,t,n,r){let i=n.page.margins,a=r.contentY,o={MAIN:0,CONSOLATION:1,PLAY_OFF:2},s=[...t].filter(e=>e.drawData.drawSize>0).sort((e,t)=>(o[e.stage]??9)-(o[t.stage]??9));for(let t of s){let o=t.stage===`MAIN`,s=t.drawData.drawSize*3.5+8;a+s>r.contentY+r.contentHeight&&a>r.contentY+10&&(e.addPage(),a=r.contentY),a+=3,R(e,o?I.HEADING:I.BODY,F.BOLD),o||e.setTextColor(120,40,40),e.text(t.name,i.left,a),o||e.setTextColor(0),a+=o?4:3;let c={...r,contentY:a,contentHeight:Math.min(s,r.contentY+r.contentHeight-a)};J(e,t.drawData,n,c),a+=s+4}}function In(e,t,n,r){let i=n.page.margins,a=r.contentHeight,o=a*.44,s=a*.44,c=r.contentWidth-30-8,l=Ln(t.winnersBracket),u=r.contentY+3;R(e,I.BODY,F.BOLD),e.setTextColor(30,80,30),e.text(`Winner's Bracket`,i.left,u),e.setTextColor(0),u+=3,J(e,l,n,{...r,contentY:u,contentHeight:o-6,contentWidth:c}),u=r.contentY+o+6,R(e,I.BODY,F.BOLD),e.setTextColor(140,40,40),e.text(`Loser's Bracket (Backdraw)`,i.left,u),e.setTextColor(0),u+=3;let d={...r,contentY:u,contentHeight:s-6,contentWidth:c};J(e,t.losersBracket,n,d);let f=i.left+c+8,p=r.contentY+a/2;if(R(e,I.SMALL,F.BOLD),e.text(`Decider`,f+28/2,p-14-4,{align:`center`}),e.setDrawColor(60),e.setLineWidth(.5),e.rect(f,p-14-1,28,14),e.setLineWidth(.2),e.line(f,p-14/2-1,f+28,p-14/2-1),t.deciderMatch?.matchUps?.length){let n=t.deciderMatch.matchUps[0],r=new Map(t.deciderMatch.slots.map(e=>[e.drawPosition,e]));if(n.drawPositions[0]){let t=r.get(n.drawPositions[0]);if(t?.participantName){let r=n.winningSide===1;R(e,I.TINY,r?F.BOLD:F.NORMAL),e.text(t.participantName,f+1,p-14/2-3,{maxWidth:26})}}if(n.drawPositions[1]){let t=r.get(n.drawPositions[1]);if(t?.participantName){let r=n.winningSide===2;R(e,I.TINY,r?F.BOLD:F.NORMAL),e.text(t.participantName,f+1,p-3,{maxWidth:26})}}n.score&&(R(e,I.TINY,F.NORMAL),e.setTextColor(60,60,160),e.text(n.score,f+28-1,p-14+2,{align:`right`}),e.setTextColor(0))}}function Ln(e){let t={...e.roundLabelMap||{}};for(let e of Object.keys(t))t[Number(e)]===`F-Q`&&(t[Number(e)]=`SF`);return{...e,roundLabelMap:t}}var Rn=1,zn=16,Bn=1;function Vn(e,t,n,r){let i=n.page.margins,a=new Map;for(let e of t.matchUps)a.has(e.roundNumber)||a.set(e.roundNumber,[]),a.get(e.roundNumber).push(e);let o=new Map(t.slots.map(e=>[e.drawPosition,e])),s=[...a.keys()].sort((e,t)=>e-t),c=s.length,l=r.contentY+7,u=r.contentHeight-7,d=Math.min(55,(r.contentWidth-(c-1)*6)/c),f=a.get(s[0])?.length||1,p=Math.min(zn,(u-(f+1)*Bn)/f);R(e,I.SMALL,F.BOLD),e.setTextColor(30,60,120);for(let a=0;a<c;a++){let o=s[a],c=n.roundLabels[K(o,t.totalRounds)]||K(o,t.totalRounds),l=i.left+a*(d+6);e.text(c,l+d/2,r.contentY+3,{align:`center`})}e.setTextColor(0);for(let t=0;t<c;t++){let r=s[t],c=a.get(r)||[],f=c.length,m=i.left+t*(d+6),h=f*p,g=f>1?(u-h)/(f+1):(u-p)/2;for(let t=0;t<f;t++){let r=l+g+t*(p+g);Hn(e,c[t],o,n,m,r,d,p)}}}function Hn(e,t,n,r,i,a,o,s){let c=s<10?5:I.TINY;e.setDrawColor(100),e.setLineWidth(.3),e.rect(i,a,o,s);let l=a+s/2;e.setLineWidth(.15),e.line(i,l,i+o,l);let u=t.drawPositions[0]?n.get(t.drawPositions[0]):void 0;if(u){let n=kt(u,r);R(e,c,t.winningSide===1?F.BOLD:F.NORMAL),e.text(n,i+Rn,l-c*.15,{maxWidth:o-2*Rn})}let d=t.drawPositions[1]?n.get(t.drawPositions[1]):void 0;if(d){let n=kt(d,r);R(e,c,t.winningSide===2?F.BOLD:F.NORMAL),e.text(n,i+Rn,l+c*.55,{maxWidth:o-2*Rn})}if(t.score){let n=q(t.score,r);R(e,c,F.NORMAL),e.setTextColor(60,60,160),e.text(n,i+o-Rn,a+c*.5,{align:`right`}),e.setTextColor(0)}}var Un={maxPositionsPerPage:64,includeOverlapRounds:!0,summaryPage:!0};function Wn(e,t=Un){let{drawSize:n,slots:r,matchUps:i,totalRounds:a}=e;if(n<=t.maxPositionsPerPage)return[{label:`Full Draw`,startPosition:1,endPosition:n,slots:r,matchUps:i,segmentRounds:a}];let o=t.maxPositionsPerPage,s=Math.ceil(n/o),c=Math.log2(o),l=[];for(let e=0;e<s;e++)l.push(Gn(e,o,s,c,n,r,i));return t.summaryPage&&s>1&&l.push(Kn(e)),l}function Gn(e,t,n,r,i,a,o){let s=e*t+1,c=Math.min((e+1)*t,i),l=`Section ${e+1}`;n===2&&(l=e===0?`Top Half`:`Bottom Half`);let u=a.filter(e=>e.drawPosition>=s&&e.drawPosition<=c),d=qn(o.filter(e=>e.roundNumber>r?!1:e.drawPositions.every(e=>e>=s&&e<=c)));return{label:l,startPosition:s,endPosition:c,slots:u,matchUps:d,segmentRounds:r,noWinnerColumn:!0}}function Kn(e){let{slots:t,matchUps:n,totalRounds:r,roundLabelMap:i}=e,a=Math.max(1,r-5+1),o=r-a+1,s=a-1,c=n.filter(e=>e.roundNumber===a).sort((e,t)=>e.roundPosition-t.roundPosition),l=c.length*2,u=Jn(c),d=qn(n.filter(e=>e.roundNumber>=a).map(e=>({...e,roundNumber:e.roundNumber-s,roundPosition:e.roundNumber===a?c.findIndex(t=>t.roundPosition===e.roundPosition)+1:e.roundPosition,drawPositions:e.drawPositions.map(e=>u.get(e)||e)}))),f=[];for(let[e,n]of u){let r=t.find(t=>t.drawPosition===e);r&&f.push({...r,drawPosition:n})}return f.sort((e,t)=>e.drawPosition-t.drawPosition),{label:`Final Rounds`,startPosition:1,endPosition:l,slots:f,matchUps:d,segmentRounds:o,roundLabelMap:i?Object.fromEntries(Object.entries(i).filter(([e])=>Number(e)>=a).map(([e,t])=>[Number(e)-s,t])):void 0}}function qn(e){let t=new Map;for(let n of e)t.has(n.roundNumber)||t.set(n.roundNumber,[]),t.get(n.roundNumber).push(n);let n=[];for(let[,e]of t)e.sort((e,t)=>e.roundPosition-t.roundPosition),e.forEach((e,t)=>{n.push({...e,roundPosition:t+1})});return n}function Jn(e){let t=new Map,n=1;for(let r of e)for(let e of r.drawPositions)e&&!t.has(e)&&t.set(e,n++);return t}function Yn(e,t={}){return Xn(e.matchUps)?$n(e,t):Zn(e,t)}function Xn(e){let t=new Map;for(let n of e)t.set(n.roundNumber,(t.get(n.roundNumber)||0)+1);let n=[...t.keys()].sort((e,t)=>e-t);for(let e=1;e<n.length;e++){let r=t.get(n[e-1])||0;if((t.get(n[e])||0)>=r)return!0}return!1}function Zn(e,t={}){if(e.drawSize>=256)return Qn(e,{...t,maxPositionsPerPage:64});let n=Y(e.drawSize,t),r=z(n.doc,n.pageConfig,n.headerH,n.footerH);return J(n.doc,e,n.format,r),X(n),n.doc}function Qn(e,t={}){let n=Y(e.drawSize,t),r=Wn(e,{maxPositionsPerPage:t.maxPositionsPerPage||32,includeOverlapRounds:!0,summaryPage:!0});for(let t=0;t<r.length;t++){t>0&&n.doc.addPage();let i=B(n.doc,{...n.headerConfig,subtitle:r[t].label},n.pageConfig),a=z(n.doc,n.pageConfig,i,n.footerH);if(r[t].slots.length>0||r[t].matchUps.length>0){let i=r[t],o=i.endPosition-i.startPosition+1,s={...e,slots:i.slots,matchUps:i.matchUps,noWinnerColumn:i.noWinnerColumn,roundLabelMap:i.roundLabelMap||e.roundLabelMap,drawSize:o,totalRounds:i.segmentRounds};J(n.doc,s,n.format,a,i.startPosition-1,o)}}return X(n),n.doc}function $n(e,t={}){let n=e.totalRounds>=5||e.slots.length>=12,r=Y(e.drawSize,t,n),i=z(r.doc,r.pageConfig,r.headerH,r.footerH);return J(r.doc,e,r.format,i),X(r),r.doc}function er(e,t={}){let n=Y(Math.max(...e.map(e=>e.drawData.drawSize),8),t),r=z(n.doc,n.pageConfig,n.headerH,n.footerH);return Fn(n.doc,e,n.format,r),or(n,1),X(n),n.doc}function tr(e,t={}){let n=Y(e.mainStructure?.drawSize||8,t),r=z(n.doc,n.pageConfig,n.headerH,n.footerH);return jn(n.doc,e,n.format,r),or(n,1),X(n),n.doc}function nr(e,t={}){let n=Y(e.drawSize,t,!0),r=z(n.doc,n.pageConfig,n.headerH,n.footerH);return un(n.doc,e,n.format,r),X(n),n.doc}function rr(e,t={}){let n=Y(e.mainDraw.drawSize,t,!0),r=z(n.doc,n.pageConfig,n.headerH,n.footerH);return yn(n.doc,e,n.format,r),X(n),n.doc}function ir(e,t={}){let n=Y(Math.max(e.winnersBracket.drawSize,e.losersBracket.drawSize,8),t,!0),r=z(n.doc,n.pageConfig,n.headerH,n.footerH);return In(n.doc,e,n.format,r),X(n),n.doc}function ar(e,t={}){let n=Y(e.drawSize,t),r=z(n.doc,n.pageConfig,n.headerH,n.footerH);return Vn(n.doc,e,n.format,r),X(n),n.doc}function Y(e,t,n){let r=t.format||g(t.preset||`itfJunior`),i={...r.page,...t.page,orientation:n?`landscape`:t.page?.orientation||r.page.orientation},a=t.header||{layout:`none`,tournamentName:``},o=t.footer||{layout:`standard`,showPageNumbers:!0,showTimestamp:!0},s=xe(i,e),c=V(o);return{doc:s,pageConfig:i,headerConfig:a,footerConfig:o,format:r,headerH:B(s,a,i),footerH:c}}function or(e,t){let n=e.doc.getNumberOfPages();for(let r=t+1;r<=n;r++)e.doc.setPage(r),B(e.doc,e.headerConfig,e.pageConfig)}function X(e){let t=e.doc.getNumberOfPages();for(let n=1;n<=t;n++)e.doc.setPage(n),ze(e.doc,e.footerConfig,e.pageConfig,n);e.doc.setPage(t)}function sr(e){let t=e.header?{...e.header,layout:e.header.layout??`itf`,tournamentName:e.header.tournamentName??``}:void 0,n=e.footer?{...e.footer,layout:e.footer.layout??`standard`}:void 0,r=e.content?.schedule;return{header:t,footer:n,page:e.page,cellStyle:r?.cellStyle??`detailed`,showMatchNumbers:r?.showMatchNumbers,alertBanner:r?.alertBanner}}function cr(e,t){if(!e?.type)return{success:!1,error:`Missing request type`};if(!e.composition)return{success:!1,error:`Missing composition config`};if(!t?.tournamentEngine)return{success:!1,error:`Missing tournamentEngine in context`};switch(e.type){case`schedule`:return wr(e,t);case`playerList`:return yr(e,t);case`signInSheet`:return br(e,t);case`courtCards`:return xr(e,t);case`matchCard`:return Cr(e,t);case`draw`:return lr(e,t)}}function lr(e,t){if(!e.drawId)return{success:!1,error:`PrintDrawRequest requires drawId`};let n=t.tournamentEngine;if(typeof n.getEventData!=`function`)return{success:!1,error:`engine.getEventData is not a function`};let{eventData:r}=n.getEventData({drawId:e.drawId})??{};if(!r?.drawsData?.length)return{success:!1,error:`No draw data found for drawId "${e.drawId}"`};let i=r.tournamentInfo??{},a=r.eventInfo??{},o=r.drawsData[0].structures??[],s=o.find(e=>e.stage===`MAIN`),c=o.some(e=>e.stage===`CONSOLATION`),l=o.some(e=>e.stage===`PLAY_OFF`),u=gr(e.composition,`draw`)?.splitStrategy??`single-page`,d={header:pr(e.composition,i,a),footer:mr(e.composition),page:e.composition.page,preset:void 0},f;try{if(c&&l)f=ir({winnersBracket:s?N(s):ur(),losersBracket:dr(r),deciderMatch:fr(r)},d);else if(c)f=er(o.map(e=>({name:e.structureName,stage:e.stage,drawData:N(e)})),d);else if(s){let e=N(s);f=u===`single-page`?Zn(e,d):Qn(e,d)}}catch(e){return{success:!1,error:`draw generator failed: ${e instanceof Error?e.message:String(e)}`}}if(!f)return{success:!1,error:`No matching draw renderer for this structure`};let p=(a.eventName||i.tournamentName||`draw`).replace(/[^a-z0-9]/gi,`_`).toLowerCase();return{success:!0,doc:f,blob:f.output(`blob`),filename:`draw-${p}.pdf`}}function ur(){return{drawName:``,drawSize:0,drawType:``,totalRounds:0,slots:[],matchUps:[],seedAssignments:[]}}function dr(e){let t=P(e.drawsData,`CONSOLATION`);return t?N(t):ur()}function fr(e){let t=P(e.drawsData,`PLAY_OFF`);return t?N(t):void 0}function pr(e,t,n){if(e.header?.layout===`none`)return;let r=e.header??{};return{layout:r.layout??`itf`,tournamentName:r.tournamentName??t?.tournamentName??n?.eventName??`Tournament`,subtitle:r.subtitle??n?.eventName,startDate:r.startDate??t?.startDate,endDate:r.endDate??t?.endDate,location:r.location??t?.venues?.[0]?.venueName,organizer:r.organizer,surface:r.surface??n?.surfaceCategory,grade:r.grade,supervisor:r.supervisor,city:r.city,country:r.country??t?.hostCountryCode,prizeMoney:r.prizeMoney,currency:r.currency,tournamentId:r.tournamentId,sectionLabel:r.sectionLabel,leftLogoBase64:r.leftLogoBase64,rightLogoBase64:r.rightLogoBase64,chiefUmpire:r.chiefUmpire}}function mr(e){if(e.footer?.layout===`none`)return;let t=e.footer??{};return{layout:t.layout??`standard`,showPageNumbers:t.showPageNumbers??!0,showTimestamp:t.showTimestamp??!0,notes:t.notes,officials:t.officials,seedAssignments:t.seedAssignments,prizeMoney:t.prizeMoney,signatureLines:t.signatureLines,drawCeremonyDate:t.drawCeremonyDate,releaseDate:t.releaseDate,withdrawals:t.withdrawals,luckyLosers:t.luckyLosers}}function hr(e){let t=e.header;if(!(!t||t.layout===`none`))return{tournamentName:t.tournamentName??``,subtitle:t.subtitle,startDate:t.startDate,endDate:t.endDate,location:t.location,organizer:t.organizer}}function gr(e,t){return e.content?.[t]}function _r(e,t){if(typeof e.getParticipants!=`function`)return{success:!1,error:`engine.getParticipants is not a function`};let{participants:n=[]}=e.getParticipants({participantFilters:{participantTypes:[`INDIVIDUAL`]},withScaleValues:!0,withSeeding:!0})??{};if(t){if(typeof e.getEvent!=`function`)return{success:!1,error:`engine.getEvent is not a function`};let{event:r}=e.getEvent({eventId:t})??{};if(!r)return{success:!1,error:`Event "${t}" not found`};let i=new Set((r.entries??[]).map(e=>e.participantId));return{success:!0,participants:n.filter(e=>i.has(e.participantId)),eventEntries:[{eventName:r.eventName??``,entries:vr(r)}],eventName:r.eventName??``}}return{success:!0,participants:n,eventEntries:(e.getEvents?.()?.events??[]).map(e=>({eventName:e.eventName??``,entries:vr(e)})),eventName:``}}function vr(e){let t=e.entries??[],n=new Map;for(let t of e.drawDefinitions??[])for(let e of t.structures??[])if(!(e.stage&&e.stage!==`MAIN`))for(let t of e.seedAssignments??[]){if(!t?.participantId||t.seedValue===void 0)continue;let e=Number(t.seedValue);!Number.isNaN(e)&&!n.has(t.participantId)&&n.set(t.participantId,e)}return n.size===0?t:t.map(e=>n.has(e.participantId)?{...e,seedValue:n.get(e.participantId)}:e)}function yr(e,t){let n=_r(t.tournamentEngine,e.eventId);if(!n.success)return n;let r=ot({participants:n.participants,eventEntries:n.eventEntries}),i=gr(e.composition,`playerList`),a;try{a=yt(r,{header:hr(e.composition),includeRanking:i?.includeRanking,includeEvents:i?.includeEvents,groupByEvent:i?.groupByEvent})}catch(e){return{success:!1,error:`generatePlayerListPDF failed: ${e instanceof Error?e.message:String(e)}`}}let o=(n.eventName||`all`).replace(/[^a-z0-9]/gi,`_`).toLowerCase();return{success:!0,doc:a,blob:a.output(`blob`),filename:`player-list-${o}.pdf`}}function br(e,t){if(!e.eventId)return{success:!1,error:`PrintSignInSheetRequest requires eventId`};let n=_r(t.tournamentEngine,e.eventId);if(!n.success)return n;let r=ot({participants:n.participants,eventEntries:n.eventEntries}),i;try{i=bt(r,{header:hr(e.composition),eventName:n.eventName})}catch(e){return{success:!1,error:`generateSignInSheetPDF failed: ${e instanceof Error?e.message:String(e)}`}}let a=(n.eventName||`all`).replace(/[^a-z0-9]/gi,`_`).toLowerCase();return{success:!0,doc:i,blob:i.output(`blob`),filename:`sign-in-sheet-${a}.pdf`}}function xr(e,t){let n=t.tournamentEngine,r=Tr(n,e.venueId);if(!r.success)return r;let i=ct({matchUps:r.matchUps,venues:r.venues,scheduledDate:e.scheduledDate}),a=Sr(e.composition,n),o=gr(e.composition,`courtCard`),s;try{s=xt(i,{tournamentName:a,cardsPerPage:o?.cardsPerPage})}catch(e){return{success:!1,error:`generateCourtCardPDF failed: ${e instanceof Error?e.message:String(e)}`}}let c=e.scheduledDate?`-${e.scheduledDate}`:``;return{success:!0,doc:s,blob:s.output(`blob`),filename:`court-cards${c}.pdf`}}function Sr(e,t){return e.header?.tournamentName||(typeof t.getTournamentInfo==`function`?t.getTournamentInfo()?.tournamentInfo?.tournamentName??``:``)}function Cr(e,t){if(!Array.isArray(e.matchUpIds)||e.matchUpIds.length===0)return{success:!1,error:`PrintMatchCardRequest requires non-empty matchUpIds`};let n=t.tournamentEngine;if(typeof n.allTournamentMatchUps!=`function`)return{success:!1,error:`engine.allTournamentMatchUps is not a function`};let{matchUps:r=[]}=n.allTournamentMatchUps()??{},i=new Set(e.matchUpIds),a=r.filter(e=>i.has(e.matchUpId));if(a.length===0)return{success:!1,error:`No matchUps match the requested matchUpIds`};let o=Sr(e.composition,n),s=a.map(e=>({tournamentName:o,eventName:e.eventName??``,roundName:e.roundName??e.abbreviatedRoundName??``,matchUpId:e.matchUpId,courtName:e.schedule?.courtName,scheduledTime:e.schedule?.scheduledTime,side1:{name:e.sides?.[0]?.participant?.participantName??`TBD`,nationality:e.sides?.[0]?.participant?.nationalityCode??``,seedValue:e.sides?.[0]?.seedValue},side2:{name:e.sides?.[1]?.participant?.participantName??`TBD`,nationality:e.sides?.[1]?.participant?.nationalityCode??``,seedValue:e.sides?.[1]?.seedValue}})),c;try{c=Ct(s,{cardsPerPage:2,includeScoreBoxes:!0})}catch(e){return{success:!1,error:`generateMatchCardPDF failed: ${e instanceof Error?e.message:String(e)}`}}return{success:!0,doc:c,blob:c.output(`blob`),filename:`match-cards-${s.length}.pdf`}}function wr(e,t){if(!e.scheduledDate)return{success:!1,error:`PrintScheduleRequest requires scheduledDate`};let n=t.tournamentEngine,r=Tr(n,e.venueId);if(!r.success)return r;let i=it({matchUps:r.matchUps,venues:r.venues,scheduledDate:e.scheduledDate}),a=sr(e.composition),o;try{o=dt(i,a)}catch(e){return{success:!1,error:`generateOrderOfPlayPDF failed: ${e instanceof Error?e.message:String(e)}`}}return{success:!0,doc:o,blob:o.output(`blob`),filename:`order-of-play-${e.scheduledDate}.pdf`}}function Tr(e,t){if(typeof e.competitionScheduleMatchUps!=`function`)return{success:!1,error:`engine.competitionScheduleMatchUps is not a function`};if(typeof e.getVenuesAndCourts!=`function`)return{success:!1,error:`engine.getVenuesAndCourts is not a function`};let n=e.competitionScheduleMatchUps()??{},r=[...n.dateMatchUps??[],...n.completedMatchUps??[]],i=t?r.filter(e=>e?.schedule?.venueId===t):r,a=(e.getVenuesAndCourts()??{}).venues??[];return{success:!0,matchUps:i,venues:t?a.filter(e=>e.venueId===t):a}}var Er=[{value:`grand-slam`,label:`Grand Slam`,description:`Centered tournament name, uppercase, date/location right`},{value:`itf`,label:`ITF/Professional`,description:`Left-aligned name, grade/supervisor on right, separator line`},{value:`minimal`,label:`Minimal`,description:`Single line with tournament name and subtitle`},{value:`none`,label:`No Header`,description:`Skip header entirely`}],Dr=[{value:`standard`,label:`Standard`,description:`Timestamp, page number, optional notes`},{value:`seedings`,label:`Seedings Table`,description:`Seeded players list in compact columns`},{value:`officials`,label:`Officials`,description:`Tournament officials with roles`},{value:`none`,label:`No Footer`,description:`Skip footer entirely`}],Or=[{value:`a4`,label:`A4 (210 × 297mm)`},{value:`letter`,label:`US Letter (216 × 279mm)`}],kr=[{value:`auto`,label:`Auto (landscape for large draws)`},{value:`landscape`,label:`Landscape`},{value:`portrait`,label:`Portrait`}],Ar=[{value:`single-page`,label:`Single Page (dense)`},{value:`halves`,label:`Two Halves (64+64)`},{value:`quarters`,label:`Four Quarters (32×4)`}],jr=[{id:`content`,label:`Content`,fields:[{id:`includeSeedings`,label:`Include seedings`,type:`checkbox`,defaultValue:!0,configPath:`content.draw.includeSeedings`},{id:`includeScores`,label:`Include scores`,type:`checkbox`,defaultValue:!0,configPath:`content.draw.includeScores`},{id:`showDrawPositions`,label:`Show draw positions`,type:`checkbox`,defaultValue:!0,configPath:`content.draw.showDrawPositions`},{id:`showByes`,label:`Show byes`,type:`checkbox`,defaultValue:!0,configPath:`content.draw.showByes`},{id:`splitStrategy`,label:`Split strategy`,type:`select`,options:[{value:`single-page`,label:`Single page`},{value:`halves`,label:`Split in halves`},{value:`quarters`,label:`Split in quarters`}],defaultValue:`single-page`,configPath:`content.draw.splitStrategy`}]},{id:`layout`,label:`Layout`,fields:[{id:`headerLayout`,label:`Header style`,type:`select`,options:[{value:`itf`,label:`ITF`},{value:`minimal`,label:`Minimal`},{value:`branded`,label:`Branded`}],defaultValue:`itf`,configPath:`header.layout`},{id:`orientation`,label:`Orientation`,type:`select`,options:[{value:`landscape`,label:`Landscape`},{value:`portrait`,label:`Portrait`}],defaultValue:`landscape`,configPath:`page.orientation`}]}],Mr=[{id:`content`,label:`Content`,fields:[{id:`cellStyle`,label:`Cell style`,type:`select`,options:[{value:`detailed`,label:`Detailed`},{value:`compact`,label:`Compact`}],defaultValue:`detailed`,configPath:`content.schedule.cellStyle`},{id:`showMatchNumbers`,label:`Show match numbers`,type:`checkbox`,defaultValue:!1,configPath:`content.schedule.showMatchNumbers`},{id:`alertBanner`,label:`Alert banner text`,type:`text`,configPath:`content.schedule.alertBanner`}]},{id:`layout`,label:`Layout`,fields:[{id:`headerLayout`,label:`Header style`,type:`select`,options:[{value:`itf`,label:`ITF`},{value:`minimal`,label:`Minimal`},{value:`branded`,label:`Branded`}],defaultValue:`itf`,configPath:`header.layout`}]}];function Nr(e){let{structure:t,participants:n=[]}=e;if(!t)return[];let r=new Map;n.forEach(e=>r.set(e.participantId,e));let i=t.structures||[];return i.length?i.map((e,t)=>{let n=e.positionAssignments||[],i=e.seedAssignments||[],a=n.filter(e=>e.participantId).map(e=>{let t=r.get(e.participantId),n=i.find(t=>t.participantId===e.participantId);return{participantName:t?H(t):``,nationality:t?U(t):``,seedValue:n?.seedValue,groupPosition:e.drawPosition}}).sort((e,t)=>e.groupPosition-t.groupPosition),o=[];for(let t of e.matchUps||[]){if(!t.drawPositions||t.drawPositions.length<2)continue;let[e,n]=t.drawPositions,r=$e(t.score);r&&o.push({rowPosition:e,colPosition:n,score:r,winningSide:t.winningSide})}return{groupName:e.structureName||`Group ${t+1}`,participants:a,results:o}}):[]}var Pr=[200,200,200],Fr=[20,80,20],Ir=[160,40,40],Lr=[50,50,50];function Rr(e,t,r,i,a){let o=r.page.margins,s=t.participants.length;R(e,I.HEADING,F.BOLD),e.text(t.groupName,o.left,a),a+=5;let c=[`#`,`Player`,`Nat.`];for(let e=0;e<s;e++)c.push(`${e+1}`);c.push(`W`,`L`);let l=zr(t,r),u=t.participants.map((e,t)=>{let n=[{content:`${t+1}`,styles:{fontStyle:`bold`,halign:`center`}},{content:e.participantName+(e.seedValue?` [${e.seedValue}]`:``),styles:{fontStyle:`bold`}},{content:e.nationality,styles:{halign:`center`}}];for(let e=0;e<s;e++)if(t===e)n.push({content:``,styles:{fillColor:Pr}});else{let r=l[t]?.[e];if(r){let e=r.isWin?Fr:Ir;n.push({content:r.score,styles:{halign:`center`,textColor:e}})}else n.push({content:``,styles:{halign:`center`}})}let r=l[t]?.filter(e=>e?.isWin).length||0,i=l[t]?.filter(e=>e&&!e.isWin).length||0;return n.push({content:`${r}`,styles:{halign:`center`,fontStyle:`bold`}}),n.push({content:`${i}`,styles:{halign:`center`}}),n});return(0,n.default)(e,{startY:a,head:[c],body:u,styles:{fontSize:7,cellPadding:1.5,lineWidth:.2,lineColor:[150,150,150]},headStyles:{fillColor:Lr,textColor:[255,255,255],fontStyle:`bold`,halign:`center`,fontSize:7},columnStyles:{0:{cellWidth:8},1:{cellWidth:`auto`},2:{cellWidth:12}},margin:{left:o.left,right:o.right}}),e.lastAutoTable?.finalY||a+40}function zr(e,t){let n=e.participants.length,r=Array.from({length:n},()=>Array(n).fill(null)),i=new Map;e.participants.forEach((e,t)=>i.set(e.groupPosition,t));for(let n of e.results){let e=i.get(n.rowPosition),a=i.get(n.colPosition);if(e===void 0||a===void 0)continue;let o=q(n.score,t),s=n.winningSide===1;r[e][a]={score:o,isWin:s},r[a][e]={score:Br(o),isWin:!s}}return r}function Br(e){return e.split(/\s+/).map(e=>{let t=e.match(/^(\d+)([/-])(\d+)(\(\d+\))?$/);return t?`${t[3]}${t[2]}${t[1]}${t[4]||``}`:e}).join(` `)}var Vr={East:{name:`East`,abbreviation:`E`},West:{name:`West`,abbreviation:`W`},North:{name:`North`,abbreviation:`N`},South:{name:`South`,abbreviation:`S`},Northeast:{name:`Northeast`,abbreviation:`NE`},Northwest:{name:`Northwest`,abbreviation:`NW`},Southeast:{name:`Southeast`,abbreviation:`SE`},Southwest:{name:`Southwest`,abbreviation:`SW`}};function Hr(e){let{drawDefinition:t,participants:n=[]}=e;if(!t)return{drawName:``,structures:[]};let r=new Map;n.forEach(e=>r.set(e.participantId,e));let i=[];for(let e of t.structures||[]){let t=e.structureName||``,n=Vr[t]||{name:t,abbreviation:t},a=e.positionAssignments||[],o=e.seedAssignments||[],s=a.length||0,c=a.map(e=>{let t=e.participantId?r.get(e.participantId):void 0,n=o.find(t=>t.participantId===e.participantId);return{drawPosition:e.drawPosition,participantName:t?H(t):``,nationality:t?U(t):``,seedValue:n?.seedValue,isBye:e.bye===!0}}),l=(e.matchUps||[]).map(e=>({roundNumber:e.roundNumber,roundPosition:e.roundPosition,drawPositions:e.drawPositions||[],score:e.score?.scoreStringSide1||``,winningSide:e.winningSide,matchUpStatus:e.matchUpStatus}));i.push({name:n.name,abbreviation:n.abbreviation,drawSize:s,slots:c,matchUps:l,totalRounds:s>0?Math.log2(s):0})}let a=i.find(e=>e.abbreviation===`E`);return{drawName:t.drawName||``,structures:i,mainStructure:a}}var Ur={slotWidth:90,slotHeight:14,roundGap:20,verticalGap:4,startX:15,startY:10};function Wr(e,t=Ur,n){let r=Math.log2(e),i=[],a=e,o=t.slotHeight+t.verticalGap;n&&a*o>n&&(o=n/a);let s=Math.max(o*.7,5);for(let n=0;n<r;n++){let r=e/2**(n+1),a=[];for(let e=0;e<r;e++){let r=2**n*o,i=t.startY+r/2-o/2+e*r*2,c=i+r,l=t.startX+n*(t.slotWidth+t.roundGap);a.push({x:l,y:i,width:t.slotWidth,height:s},{x:l,y:c,width:t.slotWidth,height:s})}i.push(a)}return i}function Gr(e,t){if(e.setDrawColor(150),e.setLineWidth(.3),e.rect(t.x,t.y,t.width,t.height),t.isBye){R(e,I.SMALL,F.ITALIC),e.setTextColor(150),e.text(`Bye`,t.x+2,t.y+t.height/2+1.5),e.setTextColor(0);return}t.participantName&&(t.seed?(R(e,I.TINY,F.BOLD),e.text(`[${t.seed}]`,t.x+1,t.y+t.height/2+1),R(e,I.SMALL,F.NORMAL),e.text(t.participantName,t.x+9,t.y+t.height/2+1)):(R(e,I.SMALL,F.NORMAL),e.text(t.participantName,t.x+2,t.y+t.height/2+1)),t.nationality&&(R(e,I.TINY,F.NORMAL),e.setTextColor(100),e.text(t.nationality,t.x+t.width-2,t.y+t.height/2+1,{align:`right`}),e.setTextColor(0)))}function Kr(e,t,n){e.setDrawColor(100),e.setLineWidth(.3);for(let r=0;r<t.length-1;r++){let i=t[r],a=t[r+1];for(let t=0;t<i.length;t+=2){let r=i[t],o=i[t+1],s=a[Math.floor(t/2)];if(!r||!o||!s)continue;let c=r.x+r.width,l=c+n.roundGap/2,u=r.y+r.height/2,d=o.y+o.height/2,f=s.y+s.height/2;e.line(c,u,l,u),e.line(c,d,l,d),e.line(l,u,l,d),e.line(l,f,s.x,f)}}}function qr(e,t,n,r){R(e,I.TINY,F.NORMAL),e.setTextColor(60,60,180),e.text(t,n,r),e.setTextColor(0)}function Jr(e,n={}){let{header:r,includeSeedings:i=!0,includeScores:a=!0}=n,o=new t.default({orientation:e.drawSize>=32?`landscape`:`portrait`,format:`a4`});L(o);let s=15;if(r){let t=`${e.drawName} - ${e.drawType.replace(/_/g,` `)} (${e.drawSize})`;s=W(o,{...r,subtitle:t})}return s=e.drawSize<=64&&e.drawSize>0?Yr(o,e,s,a):Xr(o,e,s),i&&e.seedAssignments.length>0&&Zr(o,e,s+8),G(o,`Generated ${new Date().toLocaleDateString()}`),o}function Yr(e,t,n,r){let i=e.internal.pageSize.getWidth(),a=e.internal.pageSize.getHeight(),o=i-30,s=a-n-30,c=t.totalRounds,l=Math.min(90,(o-c*10)/c),u=Math.min(14,s/t.drawSize),d={...Ur,slotWidth:l,slotHeight:u,verticalGap:Math.max(1,u*.3),startX:15,startY:n},f=Wr(t.drawSize,d,s),p=new Map(t.slots.map(e=>[e.drawPosition,e]));R(e,I.SMALL,F.BOLD);for(let t=0;t<c;t++){let r=d.startX+t*(d.slotWidth+d.roundGap),i=K(t+1,c);e.text(i,r+d.slotWidth/2,n-2,{align:`center`})}if(f.length>0){let n=f[0];for(let e=0;e<n.length;e++){let t=e+1,r=p.get(t);r&&(n[e].participantName=r.participantName,n[e].nationality=r.nationality,n[e].seed=r.seedValue,n[e].isBye=r.isBye)}for(let t of f)for(let n of t)Gr(e,n);if(Kr(e,f,d),r)for(let n of t.matchUps){if(!n.score)continue;let t=n.roundNumber-1;if(t<f.length){let r=(n.roundPosition-1)*2,i=f[t]?.[r];i&&qr(e,n.score,i.x+i.width+2,i.y+i.height+3)}}let i=f[0][f[0].length-1];return i.y+i.height+5}return n}function Xr(e,t,r){let i=[{header:`Pos`,dataKey:`pos`},{header:`Seed`,dataKey:`seed`},{header:`Player`,dataKey:`name`},{header:`Nat.`,dataKey:`nat`},{header:`Entry`,dataKey:`entry`}],a=t.slots.map(e=>({pos:e.drawPosition,seed:e.seedValue?.toString()||``,name:e.isBye?`Bye`:e.participantName,nat:e.nationality,entry:e.entryStatus||``}));return(0,n.default)(e,{...vt.compact,startY:r,columns:i,body:a,columnStyles:{pos:{cellWidth:12,halign:`center`},seed:{cellWidth:12,halign:`center`},name:{cellWidth:`auto`},nat:{cellWidth:15,halign:`center`},entry:{cellWidth:15,halign:`center`}}}),e.lastAutoTable?.finalY||r+20}function Zr(e,t,r){R(e,I.HEADING,F.BOLD),e.text(`Seeded Players`,15,r),r+=4;let i=[{header:`Seed`,dataKey:`seed`},{header:`Player`,dataKey:`name`},{header:`Nat.`,dataKey:`nat`}],a=t.seedAssignments.map(e=>({seed:e.seedValue,name:e.participantName,nat:e.nationality}));return(0,n.default)(e,{...vt.compact,startY:r,columns:i,body:a,tableWidth:120,columnStyles:{seed:{cellWidth:15,halign:`center`,fontStyle:`bold`},name:{cellWidth:`auto`},nat:{cellWidth:20,halign:`center`}}}),e.lastAutoTable?.finalY||r+20}function Qr(e,r={}){let{header:i,fullCourtNames:a=!0,notes:o}=r,s=new t.default({orientation:(r.landscape===`auto`?e.courts.length>=5:r.landscape)?`landscape`:`portrait`,format:`a4`});L(s);let c=15;if(i){let t=e.scheduledDate?`Order of Play - ${e.scheduledDate}`:`Order of Play`;c=W(s,{...i,subtitle:t})}let l=e.courts,u=a?l:l.map(ei);for(let t of e.timeSlots){R(s,I.BODY,F.BOLD),s.setTextColor(30,60,120),s.text(t.label,15,c),s.setTextColor(0),c+=4;let e=u.map(e=>({header:e,dataKey:e})),r=new Map;l.forEach(e=>r.set(e,[]));for(let e of t.matches){let t=$r(e),n=r.get(e.courtName)||[];n.push(t),r.set(e.courtName,n)}let o=Math.max(1,...Array.from(r.values()).map(e=>e.length)),d=[];for(let e=0;e<o;e++){let t={};l.forEach((n,i)=>{let o=r.get(n)||[],s=a?n:u[i];t[s]=o[e]||``}),d.push(t)}(0,n.default)(s,{...vt.schedule,startY:c,columns:e,body:d,tableWidth:`auto`,didDrawPage:e=>{G(s,i?.tournamentName||``,e.pageNumber)}}),c=s.lastAutoTable?.finalY+6||c+20}if(o?.length){c+=4,R(s,I.SMALL,F.ITALIC),s.setTextColor(80);for(let e of o)s.text(e,15,c),c+=4;s.setTextColor(0)}return s}function $r(e){let t=[];return t.push(`${e.eventAbbr} ${e.roundName}`),t.push(`${e.side1.name} (${e.side1.nationality})`),t.push(`vs ${e.side2.name} (${e.side2.nationality})`),e.score&&t.push(e.score),t.join(`
|
|
5
|
-
`)}function ei(e){return e.replace(/^Court\s*/i,`Ct `)}var ti=`print`;function ni(e){let{providerConfig:t,tournamentRecord:n,printType:r,runtime:i}=e;return ri(ri(t?.providerConfigSettings?.policies?.printPolicies?.[r]??{},(n?.extensions?.find(e=>e.name===ti))?.value?.[r]??{}),i??{})}function ri(e,t){let n={...e};for(let e of Object.keys(t)){let r=t[e];if(r===void 0)continue;let i=n[e];ii(i)&&ii(r)?n[e]=ri(i,r):n[e]=r}return n}function ii(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getPrototypeOf(e)===Object.prototype}var ai=[120,50,140];function oi(e,t={}){let n={pageSize:t.page?.pageSize||`a4`,orientation:t.page?.orientation||`portrait`,margins:t.page?.margins||{top:12,right:15,bottom:12,left:15}},r=xe(n),{margins:i}=n,a=r.internal.pageSize.getWidth(),o=r.internal.pageSize.getHeight(),s=a-i.left-i.right,c=t.accentColor||ai,l=t.footer||{layout:`none`},u=V(l),d=i.top;t.header&&(d=i.top+B(r,t.header,n)+3);let f=di(e);for(let[e,a]of f){d+30>o-i.bottom-u&&(fi(r,t,n,l),r.addPage(),d=i.top),d=si(r,e,i.left,d,s);let f=``;for(let e of a){let a=e.scheduledTime||e.notBeforeTime||``;a&&a!==f&&(d+25>o-i.bottom-u&&(fi(r,t,n,l),r.addPage(),d=i.top),d=ci(r,a,!!e.notBeforeTime,i.left,d,s,c),f=a),d+22>o-i.bottom-u&&(fi(r,t,n,l),r.addPage(),d=i.top),d=li(r,e,i.left,d,s)}d+=4}return t.disclaimer&&(d+=2,R(r,I.TINY,F.ITALIC),r.setTextColor(100),r.text(t.disclaimer,a/2,d,{align:`center`}),r.setTextColor(0)),fi(r,t,n,l),r}function si(e,t,n,r,i){return R(e,I.HEADING,F.BOLD),e.setTextColor(40),e.text(t.toUpperCase(),n+i/2,r,{align:`center`}),e.setTextColor(0),r+7}function ci(e,t,n,r,i,a,o){let s=n?`Not before ${t}`:`Starting at ${t}`;return e.setFillColor(o[0],o[1],o[2]),e.rect(r+20,i,a-40,5,`F`),R(e,I.SMALL,F.ITALIC),e.setTextColor(255,255,255),e.text(s,r+a/2,i+3.5,{align:`center`}),e.setTextColor(0),i+7}function li(e,t,n,r,i){let a=n+15,o=i-30,s=r;R(e,I.TINY,F.ITALIC),e.setTextColor(100);let c=t.eventAbbr?`${t.eventAbbr} ${t.roundName}`:t.roundName;e.text(c,a+o-2,r+3,{align:`right`}),e.setTextColor(0),t.score&&(R(e,I.SMALL,F.BOLD),e.setTextColor(120,50,140),e.text(t.score,a+o/2,r+3,{align:`center`}),e.setTextColor(0),r+=4),r+=2,r=ui(e,t.side1,a,r,o),R(e,I.TINY,F.ITALIC),e.setTextColor(120),e.text(`vs`,a+o/2,r+2.5,{align:`center`}),e.setTextColor(0),r+=4,r=ui(e,t.side2,a,r,o),r+=2;let l=r-s;return e.setDrawColor(180),e.setLineWidth(.3),e.rect(a,s,o,l),r+2}function ui(e,t,n,r,i){if(!t.name||t.name===`TBD`)return R(e,I.BODY,F.ITALIC),e.setTextColor(150),e.text(`TBD`,n+10,r+3),e.setTextColor(0),r+4;R(e,I.BODY,F.NORMAL);let a=t.nationality?`${t.name} ${t.nationality}`:t.name;return e.text(a,n+10,r+3),r+4}function di(e){let t=new Map;for(let n of e.courts)t.set(n,[]);for(let n of e.timeSlots)for(let e of n.matches)t.has(e.courtName)||t.set(e.courtName,[]),t.get(e.courtName).push(e);for(let[e,n]of t)n.length===0&&t.delete(e);return t}function fi(e,t,n,r){let{margins:i}=n,a=e.internal.pageSize.getWidth(),o=e.internal.pageSize.getHeight();if(t.officials?.length){let n=o-i.bottom-10;e.setDrawColor(120),e.setLineWidth(.2),e.line(i.left,n-2,a-i.right,n-2);let r=(a-i.left-i.right)/t.officials.length;t.officials.forEach((t,a)=>{let o=i.left+a*r;R(e,I.TINY,F.BOLD),e.text(t.role,o,n),R(e,I.TINY,F.NORMAL),e.text(t.name,o,n+3)})}ze(e,r,n)}var pi=.2645833;function mi(e){let t={};for(let n of e){let e={};n.type===`number`&&(e.halign=`right`),n.width?e.cellWidth=Math.round(n.width*pi*10)/10:n.fitData&&(e.cellWidth=`wrap`),Object.keys(e).length&&(t[n.key]=e)}return t}function hi(e,r,i={}){let a=new t.default({orientation:i.orientation||`landscape`,format:`a4`});L(a);let o=15;if(i.header?o=W(a,{...i.header,subtitle:i.header.subtitle||i.title}):i.title&&(R(a,I.SUBTITLE,F.BOLD),a.text(i.title,15,o),o+=8),e.length===0)return R(a,I.BODY,F.ITALIC),a.text(`No columns defined`,15,o),G(a,`Generated ${new Date().toLocaleDateString()}`,1),a;let s=e.map(e=>({header:e.title,dataKey:e.key})),c=r.map(t=>{let n={};for(let r of e){let e=t[r.key];n[r.key]=e==null?``:String(e)}return n}),l=mi(e);return(0,n.default)(a,{...vt.report,startY:o,columns:s,body:c,columnStyles:l,didDrawPage:e=>{G(a,`Generated ${new Date().toLocaleDateString()}`,e.pageNumber)}}),a}var Z=15;function gi(e){if(typeof document<`u`){let t=document.createElement(`div`);return t.innerHTML=e,t.textContent||``}let t=``,n=!1;for(let r of e){if(r===`<`){n=!0;continue}if(r===`>`){n=!1;continue}n||(t+=r)}return t.trim()}function Q(e,t,n){return R(e,I.HEADING,F.BOLD),e.setTextColor(40),e.text(t.toUpperCase(),Z,n),e.setTextColor(0),n+=1.5,e.setDrawColor(180),e.setLineWidth(.2),e.line(Z,n,e.internal.pageSize.getWidth()-Z,n),n+=4,n}function _i(e,t,n,r){R(e,I.BODY,F.NORMAL);let i=r||e.internal.pageSize.getWidth()-Z*2,a=e.splitTextToSize(t,i);return e.text(a,Z,n),n+a.length*3.2}function $(e,t,n){let r=e.internal.pageSize.getHeight();return t+n>r-20?(e.addPage(),20):t}function vi(e,t,n){let r={pageSize:`a4`,orientation:`portrait`,margins:{top:n,right:Z,bottom:15,left:Z}};return n+B(e,Le(t,{layout:`itf`}),r)}function yi(e,t,r){let i=(t.participants||[]).filter(e=>e.participantRole&&e.participantRole!==`COMPETITOR`);if(!i.length)return r;r=$(e,r,20),r=Q(e,`Tournament Contacts`,r);let a=i.map(e=>{let t=e.person||{},n=[t.standardGivenName,t.standardFamilyName].filter(Boolean).join(` `)||e.participantName||``,r=e.participantRoleResponsibilities?.[0]||e.participantRole||``,i=t.contacts?.[0]||{};return[n,r,[i.emailAddress,i.telephone||i.mobileTelephone].filter(Boolean).join(` | `)]});return(0,n.default)(e,{startY:r,head:[[`Name`,`Role`,`Contact`]],body:a,margin:{left:Z,right:Z},styles:{fontSize:7,cellPadding:1.5},headStyles:{fillColor:[60,60,60],textColor:255,fontStyle:`bold`},theme:`grid`}),e.lastAutoTable.finalY+6}function bi(e,t,r){let i=t.events||[];if(!i.length)return r;r=$(e,r,20),r=Q(e,`Events`,r);let a=i.map(e=>{let t=e.drawDefinitions?.[0]?.drawSize||``;return[e.eventName||``,e.eventType||``,e.matchUpFormat||``,String(t)]});return(0,n.default)(e,{startY:r,head:[[`Event`,`Type`,`Format`,`Draw Size`]],body:a,margin:{left:Z,right:Z},styles:{fontSize:7,cellPadding:1.5},headStyles:{fillColor:[60,60,60],textColor:255,fontStyle:`bold`},theme:`grid`}),e.lastAutoTable.finalY+6}function xi(e,t,n){let r=t.registrationProfile;if(!r)return n;let i=[];if(r.entriesOpen&&i.push(`Entries Open: `+r.entriesOpen),r.entriesClose&&i.push(`Entries Close: `+r.entriesClose),r.withdrawalDeadline&&i.push(`Withdrawal Deadline: `+r.withdrawalDeadline),r.entryMethod&&i.push(`Entry Method: `+r.entryMethod),r.entryUrl&&i.push(`Entry URL: `+r.entryUrl),r.eligibilityNotes&&i.push(`Eligibility: `+r.eligibilityNotes),r.entryFees?.length){let e=r.entryFees.map(e=>(e.eventType?e.eventType+`: `:``)+e.currencyCode+` `+e.amount).join(`, `);i.push(`Entry Fees: `+e)}if(!i.length)return n;n=$(e,n,10+i.length*3.5),n=Q(e,`Entry Information`,n),R(e,I.BODY,F.NORMAL);for(let t of i)e.text(t,Z,n),n+=3.5;return n+3}function Si(e,t,n){let r=t.venues||[];if(!r.length)return n;n=$(e,n,15),n=Q(e,`Venue`,n),R(e,I.BODY,F.NORMAL);for(let t of r){R(e,I.BODY,F.BOLD),e.text(t.venueName||`Venue`,Z,n),n+=3.5,R(e,I.BODY,F.NORMAL);let r=t.addresses?.[0];if(r){let t=[r.street,r.city,r.state,r.postalCode,r.countryCode].filter(Boolean);t.length&&(e.text(t.join(`, `),Z,n),n+=3.5)}let i=t.courts?.length;i&&(e.text(`Courts: `+i,Z,n),n+=3.5)}return n+3}function Ci(e,t,r,i){if(!r)return i;let a=r.options?.length,o=r.notes&&gi(r.notes);if(!a&&!o)return i;if(i=$(e,i,15),i=Q(e,t,i),a){let t=r.options.map(e=>{let t=[e.phone,e.email,e.priceRange].filter(Boolean).join(` | `);return[e.name,e.address||``,t]});(0,n.default)(e,{startY:i,head:[[`Name`,`Address`,`Details`]],body:t,margin:{left:Z,right:Z},styles:{fontSize:7,cellPadding:1.5},headStyles:{fillColor:[60,60,60],textColor:255,fontStyle:`bold`},theme:`grid`}),i=e.lastAutoTable.finalY+3}return o&&(i=_i(e,gi(r.notes),i)),i+3}function wi(e,t,n){let r=t.totalPrizeMoney;if(!r?.length)return n;n=$(e,n,10),n=Q(e,`Prize Money`,n),R(e,I.BODY,F.NORMAL);for(let t of r)e.text(t.currencyCode+` `+t.amount.toLocaleString(),Z,n),n+=3.5;return n+3}function Ti(e,t,r){let i=(t.participants||[]).filter(e=>e.participantRole===`OFFICIAL`||e.participantRole===`DIRECTOR`);if(!i.length)return r;r=$(e,r,15),r=Q(e,`Officials`,r);let a=i.map(e=>{let t=e.person||{};return[[t.standardGivenName,t.standardFamilyName].filter(Boolean).join(` `)||e.participantName||``,e.participantRoleResponsibilities?.[0]||e.participantRole||``]});return(0,n.default)(e,{startY:r,head:[[`Name`,`Role`]],body:a,margin:{left:Z,right:Z},styles:{fontSize:7,cellPadding:1.5},headStyles:{fillColor:[60,60,60],textColor:255,fontStyle:`bold`},theme:`grid`}),e.lastAutoTable.finalY+6}function Ei(e,t,n){let r=t.registrationProfile;if(!r)return n;let i=[];if(r.codeOfConduct){let e=r.codeOfConduct;i.push(`Code of Conduct: `+(e.name||``)+(e.url?` — `+e.url:``))}if(r.regulations?.length)for(let e of r.regulations)i.push((e.name||`Regulation`)+(e.url?` — `+e.url:``));if(r.dressCode&&i.push(`Dress Code: `+r.dressCode),r.contingencyPlan&&i.push(`Contingency: `+r.contingencyPlan),!i.length)return n;n=$(e,n,10+i.length*3.5),n=Q(e,`Regulations`,n),R(e,I.BODY,F.NORMAL);for(let t of i)e.text(t,Z,n),n+=3.5;return n+3}function Di(e,t,n){let r=t.registrationProfile?.sponsors;if(!r?.length)return n;n=$(e,n,10),n=Q(e,`Sponsors`,n),R(e,I.BODY,F.NORMAL);for(let t of r){let r=t.tier?` [`+t.tier+`]`:``;e.text(t.name+r,Z,n),n+=3.5}return n+3}function Oi(e,t,n){let r=t.registrationProfile?.socialEvents;if(!r?.length)return n;let i=t.registrationProfile;n=$(e,n,15),n=Q(e,`Social Events & Ceremonies`,n),R(e,I.BODY,F.NORMAL),i?.drawCeremonyDate&&(e.text(`Draw Ceremony: `+i.drawCeremonyDate,Z,n),n+=3.5),i?.awardsCeremonyDate&&(e.text(`Awards Ceremony: `+i.awardsCeremonyDate,Z,n),n+=3.5);for(let t of r){R(e,I.BODY,F.BOLD),e.text(t.name,Z,n),n+=3.5,R(e,I.BODY,F.NORMAL);let r=[t.date,t.time,t.location].filter(Boolean).join(` | `);r&&(e.text(r,Z,n),n+=3.5),t.description&&(e.text(t.description,Z,n),n+=3.5)}return n+3}function ki(e,t,n){let r=t.notes;if(!r)return n;let i=gi(r);return i?(n=$(e,n,15),n=Q(e,`Additional Information`,n),n=_i(e,i,n),n+3):n}var Ai={"tournament-header":vi,contacts:yi,events:bi,"entry-info":xi,"venue-info":Si,accommodation:(e,t,n)=>Ci(e,`Accommodation`,t.registrationProfile?.accommodation,n),transportation:(e,t,n)=>Ci(e,`Transportation`,t.registrationProfile?.transportation,n),hospitality:(e,t,n)=>Ci(e,`Hospitality`,t.registrationProfile?.hospitality,n),medical:(e,t,n)=>Ci(e,`Medical`,t.registrationProfile?.medicalInfo,n),regulations:Ei,"prize-money":wi,officials:Ti,sponsors:Di,"social-events":Oi,"custom-notes":ki};function ji(e,n={}){let{templateId:r=`itf-junior`}=n,i=de(r)?.sections||de(`itf-junior`).sections,a=n.enabledSections?new Set(n.enabledSections):null,o=new t.default({orientation:`portrait`,format:`a4`});L(o);let s=Z;for(let t of i){if(!t.enabled||a&&!a.has(t.type))continue;let n=Ai[t.type];n&&(s=n(o,e,s))}let c=o.getNumberOfPages();for(let e=1;e<=c;e++)o.setPage(e),G(o,`Generated `+new Date().toLocaleDateString(),e);return o}function Mi(e,t={}){let n=e?.drawsData||[],r=e?.tournamentInfo||{},i=e?.eventInfo||{},a=C(t.catalogPreset||`club-basic`),o=g(a?.drawFormatPreset||`itfJunior`),s={layout:`itf`,tournamentName:r.tournamentName||`Tournament`,...a?.header,subtitle:i.eventName||a?.header?.subtitle,startDate:r.startDate,endDate:r.endDate,location:r.venues?.[0]?.venueName,city:r.venues?.[0]?.city,country:r.hostCountryCode,surface:i.surfaceCategory,...t.headerOverrides},c={layout:`standard`,showPageNumbers:!0,showTimestamp:!0,...a?.footer,...t.footerOverrides},l=n?.[0]?.structures||[],u=l.some(e=>e.stage===`CONSOLATION`),d=l.some(e=>e.stage===`PLAY_OFF`),f=l.find(e=>e.stage===`MAIN`),p={header:s,footer:c,format:o};if(u&&d)return ir({winnersBracket:f?N(f):Ni(),losersBracket:P(n,`CONSOLATION`)?N(P(n,`CONSOLATION`)):Ni(),deciderMatch:P(n,`PLAY_OFF`)?N(P(n,`PLAY_OFF`)):void 0},p);if(u)return er(l.map(e=>({name:e.structureName,stage:e.stage,drawData:N(e)})),p);let m=t.structureId&&l.find(e=>e.structureId===t.structureId)||f;if(!m)return xe({pageSize:`a4`,orientation:`portrait`,margins:{top:12,right:15,bottom:12,left:15}});let h=N(m);return t.mirrored?nr(h,p):t.splitPages||h.drawSize>=256?Qn(h,{...p,maxPositionsPerPage:t.maxPositionsPerPage||32}):Zn(h,p)}function Ni(){return{drawName:``,drawSize:0,drawType:``,totalRounds:0,slots:[],matchUps:[],seedAssignments:[]}}exports.COMPOSITION_CATALOG=S,exports.DRAW_MODAL_TABS=jr,exports.FACT_SHEET_CATALOG=ue,exports.FONT=pe,exports.FOOTER_LAYOUT_OPTIONS=Dr,exports.HEADER_LAYOUT_OPTIONS=Er,exports.ORIENTATION_OPTIONS=kr,exports.PAGE_SIZE_OPTIONS=Or,exports.PRESETS=h,exports.SCHEDULE_MODAL_TABS=Mr,exports.SIZE=I,exports.SPLIT_STRATEGY_OPTIONS=Ar,exports.STYLE=F,exports.TABLE_STYLES=vt,exports.activeFontFamily=_e,exports.applyDefaultFont=L,exports.buildFooterFromTournament=Re,exports.buildHeaderFromTournament=Le,exports.calculateBracketPositions=Wr,exports.createDoc=xe,exports.drawBracketConnectors=Kr,exports.drawBracketSlot=Gr,exports.drawPageFooter=G,exports.drawTournamentHeader=W,exports.entryStatusDisplay=Qe,exports.eventAbbreviation=nt,exports.executePrint=cr,exports.extractCompassData=Hr,exports.extractConsolationStructures=Pn,exports.extractCourtCardData=ct,exports.extractDrawData=Et,exports.extractParticipantData=ot,exports.extractRoundRobinData=Nr,exports.extractScheduleData=it,exports.findStructure=P,exports.formatDate=et,exports.formatMatchScore=q,exports.formatPlayerEntry=kt,exports.formatScore=$e,exports.formatTime=tt,exports.generateBackdrawPDF=rr,exports.generateCompassDrawPDF=tr,exports.generateConsolationDrawPDF=er,exports.generateCourtCardPDF=xt,exports.generateDoubleEliminationPDF=ir,exports.generateDrawPDF=Yn,exports.generateDrawSheetPDF=Jr,exports.generateFactSheet=ji,exports.generateFeedInDrawPDF=$n,exports.generateFromEventData=Mi,exports.generateLuckyDrawPDF=ar,exports.generateMatchCardPDF=Ct,exports.generateMirroredDrawPDF=nr,exports.generateOrderOfPlayPDF=dt,exports.generateScheduleV2PDF=dt,exports.generatePlayerListPDF=yt,exports.generateReportPDF=hi,exports.generateSchedulePDF=Qr,exports.generateSequentialOOP=oi,exports.generateSignInSheetPDF=bt,exports.generateSplitDrawPDF=Qn,exports.generateTraditionalDrawPDF=Zn,exports.getCatalogPreset=C,exports.getDefaultFont=be,exports.getDefaultPageConfig=Se,exports.getFactSheetTemplate=de,exports.getPageRegions=z,exports.getPreset=g,exports.getRoundLabel=K,exports.listCatalogPresets=ee,exports.listFactSheetTemplates=fe,exports.measureFooterHeight=V,exports.measureSeedingsHeight=Xe,exports.mergeCatalogPreset=te,exports.mergePreset=_,exports.nationality=U,exports.participantName=H,exports.registerFont=ge,exports.renderCompassDraw=jn,exports.renderConsolationDraw=Fn,exports.renderDoubleEliminationDraw=In,exports.renderFooter=ze,exports.renderHeader=B,exports.renderLuckyDraw=Vn,exports.renderRoundRobinGroup=Rr,exports.renderSeedingsFooter=Je,exports.renderTraditionalDraw=J,exports.resolveCompositionConfig=ni,exports.roundName=rt,exports.seedDisplay=Ze,exports.setDefaultFont=ye,exports.setFont=R,exports.splitDraw=Wn,exports.structureToDrawData=N;
|
|
4
|
+
`)}function gt(e,t){return e.name?t||e.nationality?`${e.name} (${e.nationality})`:e.name:`TBD`}function _t(e,t,n,r){let{margins:i}=n,a=e.internal.pageSize.getWidth();e.setDrawColor(120),e.setLineWidth(.2),e.line(i.left,r-2,a-i.right,r-2),R(e,I.TINY,F.NORMAL);let o=(a-i.left-i.right)/t.length;t.forEach((t,n)=>{let a=i.left+n*o;R(e,I.TINY,F.ITALIC),e.setTextColor(100),e.text(t.role,a,r),R(e,I.TINY,F.BOLD),e.setTextColor(0),e.text(t.name,a,r+3)})}function W(e,t,n=15){let r=e.internal.pageSize.getWidth(),i=n;R(e,I.TITLE,F.BOLD),e.text(t.tournamentName,15,i),i+=7,t.subtitle&&(R(e,I.SUBTITLE,F.BOLD),e.text(t.subtitle,15,i),i+=6),R(e,I.BODY,F.NORMAL);let a=[];if(t.startDate){let e=t.endDate?`${t.startDate} - ${t.endDate}`:t.startDate;a.push(e)}return t.location&&a.push(t.location),t.organizer&&a.push(t.organizer),a.forEach((t,i)=>{e.text(t,r-15,n+i*4,{align:`right`})}),i+=2,e.setDrawColor(0),e.setLineWidth(.5),e.line(15,i,r-15,i),i+=5,i}function G(e,t,n){let r=e.internal.pageSize.getWidth(),i=e.internal.pageSize.getHeight();R(e,I.SMALL,F.ITALIC),e.setTextColor(120),e.text(t,15,i-10),n!==void 0&&e.text(`Page ${n}`,r-15,i-10,{align:`right`}),e.setTextColor(0)}var vt={compact:{styles:{fontSize:7,cellPadding:1.5,lineWidth:.1,lineColor:[200,200,200]},headStyles:{fillColor:[50,50,50],textColor:[255,255,255],fontStyle:`bold`,fontSize:7},alternateRowStyles:{fillColor:[245,245,245]}},schedule:{styles:{fontSize:7,cellPadding:2,lineWidth:.2,lineColor:[180,180,180],valign:`top`},headStyles:{fillColor:[30,60,120],textColor:[255,255,255],fontStyle:`bold`,fontSize:8,halign:`center`},alternateRowStyles:{fillColor:[240,244,250]}},playerList:{styles:{fontSize:8,cellPadding:2,lineWidth:.1,lineColor:[200,200,200]},headStyles:{fillColor:[40,80,40],textColor:[255,255,255],fontStyle:`bold`,fontSize:8},alternateRowStyles:{fillColor:[242,248,242]}},report:{styles:{fontSize:8,cellPadding:2,lineWidth:.1,lineColor:[200,200,200]},headStyles:{fillColor:[35,55,90],textColor:[255,255,255],fontStyle:`bold`,fontSize:8},alternateRowStyles:{fillColor:[244,246,250]}},courtCard:{styles:{fontSize:14,cellPadding:6,lineWidth:.3,lineColor:[100,100,100],halign:`center`},headStyles:{fillColor:[20,20,80],textColor:[255,255,255],fontStyle:`bold`,fontSize:16}}};function yt(e,r={}){let{header:i,includeRanking:a=!0,includeEvents:o=!0}=r,s=new t.default({orientation:`portrait`,format:`a4`});L(s);let c=15;i&&(c=W(s,{...i,subtitle:i.subtitle||`Player List`}));let l=[{header:`#`,dataKey:`index`},{header:`Name`,dataKey:`name`},{header:`Nat.`,dataKey:`nationality`}];a&&l.push({header:`Rank`,dataKey:`ranking`}),l.push({header:`Seed`,dataKey:`seed`}),l.push({header:`Entry`,dataKey:`entryStatus`}),o&&l.push({header:`Events`,dataKey:`events`});let u=e.map((e,t)=>({index:t+1,name:e.name,nationality:e.nationality,ranking:e.ranking||``,seed:e.seedValue?.toString()||``,entryStatus:e.entryStatus,events:e.events.join(`, `)}));return(0,n.default)(s,{...vt.playerList,startY:c,columns:l,body:u,columnStyles:{index:{cellWidth:10,halign:`center`},name:{cellWidth:`auto`,fontStyle:`bold`},nationality:{cellWidth:15,halign:`center`},ranking:{cellWidth:15,halign:`center`},seed:{cellWidth:12,halign:`center`},entryStatus:{cellWidth:15,halign:`center`},events:{cellWidth:`auto`}},didDrawPage:e=>{G(s,`Generated ${new Date().toLocaleDateString()}`,e.pageNumber)}}),s}function bt(e,r={}){let{header:i,eventName:a,signInDate:o,signInTime:s}=r,c=new t.default({orientation:`portrait`,format:`a4`});L(c);let l=15;if(i&&(l=W(c,{...i,subtitle:i.subtitle||`Player Sign-In Sheet`})),a||o){R(c,I.BODY,F.NORMAL);let e=[];a&&e.push(`Event: ${a}`),o&&e.push(`Date: ${o}`),s&&e.push(`Time: ${s}`),c.text(e.join(` | `),15,l),l+=6}let u=[{header:`#`,dataKey:`index`},{header:`Player Name`,dataKey:`name`},{header:`Nat.`,dataKey:`nationality`},{header:`Rank`,dataKey:`ranking`},{header:`Seed`,dataKey:`seed`},{header:`Entry`,dataKey:`entry`},{header:`Signature`,dataKey:`signature`},{header:`Time`,dataKey:`time`}],d=e.map((e,t)=>({index:t+1,name:e.name,nationality:e.nationality,ranking:e.ranking||``,seed:e.seedValue?.toString()||``,entry:e.entryStatus,signature:``,time:``}));return(0,n.default)(c,{startY:l,columns:u,body:d,styles:{fontSize:8,cellPadding:1.5,lineWidth:.2,lineColor:[150,150,150]},headStyles:{fillColor:[40,60,100],textColor:[255,255,255],fontStyle:`bold`,fontSize:7,cellPadding:2},alternateRowStyles:{fillColor:[245,247,250]},columnStyles:{index:{cellWidth:10,halign:`center`},name:{cellWidth:`auto`,fontStyle:`bold`},nationality:{cellWidth:14,halign:`center`},ranking:{cellWidth:14,halign:`center`},seed:{cellWidth:14,halign:`center`},entry:{cellWidth:14,halign:`center`},signature:{cellWidth:35},time:{cellWidth:15}}}),c}function xt(e,n={}){let{tournamentName:r=``,pageSize:i=`a5`,cardsPerPage:a=1}=n,o=new t.default({orientation:`landscape`,format:i});return L(o),e.forEach((e,t)=>{t>0&&o.addPage(),St(o,e,r,a)}),o}function St(e,t,r,i){let a=e.internal.pageSize.getWidth(),o=a/2,s=15;if(r&&(R(e,I.BODY,F.NORMAL),e.setTextColor(100),e.text(r,o,s,{align:`center`}),e.setTextColor(0),s+=8),R(e,28,F.BOLD),e.text(t.courtName,o,s,{align:`center`}),s+=5,t.venueName&&(R(e,I.HEADING,F.NORMAL),e.setTextColor(100),e.text(t.venueName,o,s,{align:`center`}),e.setTextColor(0)),s+=8,e.setDrawColor(0),e.setLineWidth(1),e.line(30,s,a-30,s),s+=8,t.currentMatch&&(R(e,I.HEADING,F.BOLD),e.setTextColor(30,60,120),e.text(`NOW PLAYING`,o,s,{align:`center`}),e.setTextColor(0),s+=6,R(e,I.BODY,F.ITALIC),e.text(`${t.currentMatch.eventName} - ${t.currentMatch.roundName}`,o,s,{align:`center`}),s+=8,(0,n.default)(e,{startY:s,margin:{left:25,right:25},theme:`plain`,styles:{halign:`center`,fontSize:16,cellPadding:4},body:[[{content:`${t.currentMatch.side1.name} (${t.currentMatch.side1.nationality})`,styles:{fontStyle:`bold`}}],[{content:`vs.`,styles:{fontSize:12,textColor:[120,120,120]}}],[{content:`${t.currentMatch.side2.name} (${t.currentMatch.side2.nationality})`,styles:{fontStyle:`bold`}}]]}),s=e.lastAutoTable?.finalY||s+40,s+=8),t.nextMatch){e.setDrawColor(180),e.setLineWidth(.3),e.line(50,s,a-50,s),s+=6,R(e,I.BODY,F.BOLD),e.setTextColor(100);let n=t.nextMatch.scheduledTime?`UP NEXT (${t.nextMatch.scheduledTime})`:`UP NEXT`;e.text(n,o,s,{align:`center`}),e.setTextColor(0),s+=5,R(e,I.BODY,F.NORMAL),e.text(`${t.nextMatch.eventName} - ${t.nextMatch.roundName}`,o,s,{align:`center`}),s+=5,R(e,I.HEADING,F.NORMAL),e.text(`${t.nextMatch.side1.name} vs. ${t.nextMatch.side2.name}`,o,s,{align:`center`})}}function Ct(e,n={}){let{cardsPerPage:r=2,includeScoreBoxes:i=!0}=n,a=new t.default({orientation:`landscape`,format:`a5`});return L(a),e.forEach((e,t)=>{t>0&&(r===1||t%r===0)&&a.addPage();let n=r===2&&t%2==1?a.internal.pageSize.getHeight()/2:5;wt(a,e,n,i)}),a}function wt(e,t,n,r){let i=e.internal.pageSize.getWidth(),a=i/2,o=n;if(t.tournamentName&&(R(e,I.BODY,F.NORMAL),e.setTextColor(100),e.text(t.tournamentName,a,o,{align:`center`}),e.setTextColor(0),o+=5),R(e,I.HEADING,F.BOLD),e.text(`${t.eventName} - ${t.roundName}`,a,o,{align:`center`}),o+=5,t.courtName||t.scheduledTime){R(e,I.BODY,F.NORMAL);let n=[];t.courtName&&n.push(`Court: ${t.courtName}`),t.scheduledTime&&n.push(`Time: ${t.scheduledTime}`),e.text(n.join(` `),a,o,{align:`center`}),o+=5}if(e.setDrawColor(0),e.setLineWidth(.5),e.line(10,o,i-10,o),o+=6,Tt(e,t.side1,10,o,i),o+=8,R(e,I.BODY,F.ITALIC),e.setTextColor(120),e.text(`vs.`,a,o,{align:`center`}),e.setTextColor(0),o+=6,Tt(e,t.side2,10,o,i),o+=8,r){e.setDrawColor(0),e.setLineWidth(.5),e.line(10,o,i-10,o),o+=4,R(e,I.SMALL,F.BOLD),e.text(`Score:`,10,o);for(let t=0;t<5;t++){let n=28+t*15;e.rect(n,o-4,12,8),R(e,I.TINY,F.NORMAL),e.setTextColor(150),e.text(`Set ${t+1}`,n+6,o-5,{align:`center`}),e.setTextColor(0)}o+=14,R(e,I.SMALL,F.NORMAL),e.text(`Umpire:`,10,o),e.setDrawColor(150),e.setLineWidth(.3),e.line(30,o,90,o),e.text(`Signature:`,i-10-70,o),e.line(i-10-40,o,i-10,o)}}function Tt(e,t,n,r,i){R(e,14,F.BOLD);let a=t.seedValue?`[${t.seedValue}] `:``;e.text(`${a}${t.name}`,n,r),R(e,I.HEADING,F.NORMAL),e.setTextColor(80),e.text(t.nationality,i-n,r,{align:`right`}),e.setTextColor(0)}function Et(e){let{drawDefinition:t,participants:n=[]}=e;if(!t)return Ot();let r=e.structureId?t.structures?.find(t=>t.structureId===e.structureId):t.structures?.[0];if(!r)return Ot();let i=new Map;n.forEach(e=>i.set(e.participantId,e));let a=r.positionAssignments||[],o=(r.matchUps||[]).reduce((e,t)=>Math.max(e,t.roundNumber||0),0),s=e.structureId?a.length:t.drawSize||a.length,c=e.structureId?o:Math.log2(s),l=r.seedAssignments||[],u=a.map(e=>{let t=e.participantId?i.get(e.participantId):void 0,n=l.find(t=>t.participantId===e.participantId);return{drawPosition:e.drawPosition,participantName:t?H(t):``,nationality:t?U(t):``,seedValue:n?.seedValue,entryStatus:e.entryStatus,isBye:e.bye===!0}}),d=(r.matchUps||[]).map(e=>({roundNumber:e.roundNumber,roundPosition:e.roundPosition,drawPositions:e.drawPositions||[],score:$e(e.score),winningSide:e.winningSide,matchUpStatus:e.matchUpStatus})),f=l.filter(e=>e.participantId).map(e=>{let t=i.get(e.participantId);return{seedValue:e.seedValue,participantName:t?H(t):``,nationality:t?U(t):``}}).sort((e,t)=>e.seedValue-t.seedValue),p=Dt(d,c,e.processedMatchUps);return{drawName:t.drawName||``,drawSize:s,drawType:t.drawType||`SINGLE_ELIMINATION`,totalRounds:c,slots:u,matchUps:d,seedAssignments:f,roundLabelMap:p}}function K(e,t){return rt(e,t)}function Dt(e,t,n){if(n?.length){let e={};for(let t of n)t.roundNumber&&!e[t.roundNumber]&&(e[t.roundNumber]=t.abbreviatedRoundName||t.roundName||`R${t.roundNumber}`);if(Object.keys(e).length>0)return e}let r=new Map;for(let t of e)r.set(t.roundNumber,(r.get(t.roundNumber)||0)+1);let i=[...r.keys()].sort((e,t)=>e-t);if(i.length>0&&i.every((e,t)=>{if(t===0)return!0;let n=r.get(i[t-1])||0;return(r.get(e)||0)<=Math.ceil(n/2)})){let e={};for(let n of i)e[n]=rt(n,t);return e}let a={};for(let e of i)a[e]=`R${e}`;return a}function Ot(){return{drawName:``,drawSize:0,drawType:``,totalRounds:0,slots:[],matchUps:[],seedAssignments:[]}}function kt(e,t){if(e.isBye)return`Bye`;if(!e.participantName)return``;let n=jt(e.participantName,t),r=Mt(e.nationality,t),i=e.seedValue?Nt(e.seedValue,t):``,a=e.entryStatus?Ft(e.entryStatus,t):``,o=[];return t.seedPosition===`before-position`&&i&&o.push(i),o.push(n),t.seedPosition===`after-name`&&i&&o.push(i),r&&o.push(r),t.seedPosition===`after-country`&&i&&o.push(i),a&&o.push(a),o.join(` `)}function At(e,t){if(e.isBye)return{name:`Bye`,nationality:``};if(!e.participantName)return{name:``,nationality:``};let n=jt(e.participantName,t),r=e.seedValue?Nt(e.seedValue,t):``,i=e.entryStatus?Ft(e.entryStatus,t):``,a=[];return t.seedPosition===`before-position`&&r&&a.push(r),a.push(n),t.seedPosition===`after-name`&&r&&a.push(r),t.seedPosition===`after-country`&&r&&a.push(r),i&&a.push(i),{name:a.join(` `),nationality:e.nationality||``}}function jt(e,t){if(t.nameFormat===`LAST First`)return e.replace(`,`,``);if(t.nameFormat===`F. LAST`){let t=e.match(/^([^,]+),\s*(.+)/);if(t)return`${t[2][0]}. ${t[1]}`}return e}function Mt(e,t){if(!e)return``;switch(t.nationalityFormat){case`parens`:return`(${e})`;case`hyphen`:return`-${e}`;default:return e}}function Nt(e,t){switch(t.seedFormat){case`parens`:return`(${e})`;case`bare`:return`${e}`;default:return`[${e}]`}}var Pt={DIRECT_ACCEPTANCE:``,WILDCARD:`WC`,QUALIFIER:`Q`,LUCKY_LOSER:`LL`,SPECIAL_EXEMPT:`SE`,ALTERNATE:`ALT`,PROTECTED_RANKING:`PR`,JUNIOR_EXEMPT:`JE`,ORGANISER_ACCEPTANCE:`OA`};function Ft(e,t){if(!e)return``;let n=Pt[e];if(n===void 0)return e;if(!n)return``;switch(t.entryFormat){case`parens`:return`(${n})`;case`hyphen`:return`-${n}`;default:return n}}function q(e,t){if(!e)return``;switch(t.gameScoreSeparator){case`/`:return e.replace(/(\d)-(\d)/g,`$1/$2`);case`none`:return e.replace(/(\d)-(\d)/g,`$1$2`);default:return e}}function It(e,t,n){let r=n||Math.log2(e),i=(t.contentHeight-9)/e,a=i<3.5,o=a?.8:1.5,s=r,c=o*(s+1),l=i<2,u=a?.18:.3,d=Math.min(a?38:65,t.contentWidth*u),f=t.contentWidth-d-c,p=l?8:0,m=f-p,h=Math.min(65,Math.max(8,m/Math.max(1,s))),g=h+p,_=I.SMALL;return i<2.5?_=5:i<3.5&&(_=I.TINY),{lineHeight:i,roundColumnWidth:h,firstRoundWidth:d,secondRoundWidth:g,connectorGap:o,fontSize:_,scoreFontSize:a?5:I.TINY}}function J(e,t,n,r,i=0,a){Lt(t.matchUps)?Rt(e,t,n,r):Xt(e,t,n,r,i,a)}function Lt(e){let t=new Map;for(let n of e)t.set(n.roundNumber,(t.get(n.roundNumber)||0)+1);let n=[...t.keys()].sort((e,t)=>e-t);for(let e=1;e<n.length;e++){let r=t.get(n[e-1])||0;if((t.get(n[e])||0)>=r)return!0}return!1}function Rt(e,t,n,r){let i=n.page.margins,a=r.contentY+9,o=r.contentHeight-9,s=zt(t.matchUps),c=[...s.keys()].sort((e,t)=>e-t),l=c.length,u=new Map(t.slots.map(e=>[e.drawPosition,e])),d=Bt(c,s),{feedConfig:f,connectorGap:p,firstRoundWidth:m,roundColumnWidth:h,fontSize:g,scoreFontSize:_}=Vt(o,s,c,l,r),v=e=>e===0?i.left:i.left+m+p+(e-1)*(h+p);Yt(e,c,t,f,n,r,v,l,h);let y=Ht(c,l,s,d,a,o,f.lineHeight);Ut(e,c,l,s,y,d,u,f,n,v,m,h,p,_),Jt(e,t,c,l,s,y,u,v,a,o,h,g,_,n)}function zt(e){let t=new Map;for(let n of e)t.has(n.roundNumber)||t.set(n.roundNumber,[]),t.get(n.roundNumber).push(n);for(let[,e]of t)e.sort((e,t)=>e.roundPosition-t.roundPosition);return t}function Bt(e,t){let n=new Set;for(let r=1;r<e.length;r++){let i=t.get(e[r-1])?.length||0;(t.get(e[r])?.length||0)>=i&&n.add(e[r])}return n}function Vt(e,t,n,r,i){let a=1.5,o=e/((t.get(n[0])?.length||1)*2),s=o<3.5,c=Math.min(s?50:60,i.contentWidth*.25),l=i.contentWidth-c-a*(r+1),u=Math.max(8,l/Math.max(1,r)),d=I.SMALL;o<2.5?d=5:o<3.5&&(d=I.TINY);let f=s?5:I.TINY;return{feedConfig:{lineHeight:o,roundColumnWidth:u,firstRoundWidth:c,secondRoundWidth:u,connectorGap:a,fontSize:d,scoreFontSize:f},connectorGap:a,firstRoundWidth:c,roundColumnWidth:u,fontSize:d,scoreFontSize:f}}function Ht(e,t,n,r,i,a,o){let s=new Map;for(let c=0;c<t;c++){let t=e[c],l=n.get(t)?.length||0;if(r.has(t)){let n=e[c-1],r=(s.get(n)||[]).slice(0,l).map(e=>e.bottomY-e.topY>o*2?{topY:e.midY-o,bottomY:e.midY+o,midY:e.midY}:{topY:e.topY,bottomY:e.bottomY,midY:e.midY});s.set(t,r)}else if(c===0){let e=a/(l*2+1),n=[];for(let t=0;t<l;t++){let r=i+e*(t*2+1),a=i+e*(t*2+2);n.push({topY:r,bottomY:a,midY:(r+a)/2})}s.set(t,n)}else{let n=e[c-1],r=s.get(n)||[],i=[];for(let e=0;e<l;e++){let t=r[e*2],n=r[e*2+1];if(t&&n){let e=t.midY,r=n.midY;i.push({topY:e,bottomY:r,midY:(e+r)/2})}}s.set(t,i)}}return s}function Ut(e,t,n,r,i,a,o,s,c,l,u,d,f,p){for(let m=0;m<n;m++){let h=t[m],g=r.get(h)||[],_=i.get(h)||[],v=l(m),y=m===0?u:d,b=a.has(h),x=v+y,S=m<n-1&&a.has(t[m+1]);for(let i=0;i<g.length;i++){let a=g[i],h=_[i];if(h){if(e.setDrawColor(40),e.setLineWidth(.25),m===0?Wt(e,a,h,o,c,s,v,u,x,f,S):b?Gt(e,a,h,o,r,t,m,c,s,v,d,x,f,S):Kt(e,a,h,o,c,s,v,d,x,f,S),m<n-1){let t=l(m+1);S?e.line(x,h.midY,t,h.midY):e.line(x+f,h.midY,t,h.midY)}if(a.score){let t=q(a.score,c);R(e,p,F.NORMAL),e.setTextColor(60,60,160);let n=h.midY+p*.12;e.text(t,x-1,n,{align:`right`}),e.setTextColor(0)}}}}}function Wt(e,t,n,r,i,a,o,s,c,l,u){t.drawPositions[0]&&rn(e,r.get(t.drawPositions[0]),t.drawPositions[0],i,a,o,n.topY,s),t.drawPositions[1]&&rn(e,r.get(t.drawPositions[1]),t.drawPositions[1],i,a,o,n.bottomY,s),qt(e,n,c,l,u)}function Gt(e,t,n,r,i,a,o,s,c,l,u,d,f,p){let m=a[o-1],h=i.get(m)||[],g=new Set;for(let e of h)e.winningSide&&g.add(e.drawPositions[e.winningSide-1]);let _=t.drawPositions.find(e=>e&&g.has(e)),v=t.drawPositions.find(e=>e&&e!==_);if(e.line(l,n.midY,l,n.bottomY),v?rn(e,r.get(v),v,s,c,l,n.topY,u):e.line(l,n.topY,l+u,n.topY),e.line(l,n.bottomY,l+u,n.bottomY),_){let t=r.get(_);t?.participantName&&an(e,t,s,c,l,n.bottomY)}qt(e,n,d,f,p)}function Kt(e,t,n,r,i,a,o,s,c,l,u){if(e.line(o,n.topY,o+s,n.topY),e.line(o,n.bottomY,o+s,n.bottomY),t.drawPositions[0]){let s=r.get(t.drawPositions[0]);s?.participantName&&an(e,s,i,a,o,n.topY)}if(t.drawPositions[1]){let s=r.get(t.drawPositions[1]);s?.participantName&&an(e,s,i,a,o,n.bottomY)}qt(e,n,c,l,u)}function qt(e,t,n,r,i){i?e.line(n,t.topY,n,t.bottomY):(e.line(n+r,t.topY,n+r,t.bottomY),e.line(n,t.topY,n+r,t.topY),e.line(n,t.bottomY,n+r,t.bottomY))}function Jt(e,t,n,r,i,a,o,s,c,l,u,d,f,p){if(t.noWinnerColumn)return;let m=s(r),h=n.at(-1),g=(a.get(h)||[])[0]?.midY||c+l/2;e.setDrawColor(40),e.setLineWidth(.25),e.line(m,g,m+Math.min(65,u),g);let _=(i.get(h)||[])[0];if(_?.winningSide){let t=_.drawPositions[_.winningSide-1],n=o.get(t);if(n){R(e,d+1,F.BOLD);let{name:t}=At(n,p);if(e.text(t,m+1,g-.5),_.score){let t=q(_.score,p);R(e,f,F.NORMAL),e.setTextColor(60,60,160),e.text(t,m+1,g+f*.4),e.setTextColor(0)}}}}function Yt(e,t,n,r,i,a,o,s,c){R(e,r.fontSize<=I.TINY?5.5:I.SMALL,F.BOLD),e.setTextColor(40);for(let l=0;l<s;l++){let s=t[l],u=K(s,n.totalRounds),d=n.roundLabelMap?.[s]||i.roundLabels[u]||u,f=o(l),p=l===0?r.firstRoundWidth:c;e.text(d,f+p/2,a.contentY+2,{align:`center`}),e.setDrawColor(160),e.setLineWidth(.15),e.line(f+2,a.contentY+3.5,f+p-2,a.contentY+3.5)}let l=o(s);e.text(`Winner`,l+c/2,a.contentY+2,{align:`center`}),e.setDrawColor(160),e.line(l+2,a.contentY+3.5,l+c-2,a.contentY+3.5),e.setTextColor(0)}function Xt(e,t,n,r,i=0,a){let o=a||t.drawSize,s=t.totalRounds||Math.ceil(Math.log2(o)),c=Math.log2(o),l=Number.isInteger(c)?Math.min(c,s):s,u=It(o,r,l),d=n.page.margins.left,f=r.contentY+9;en(e,l,t.totalRounds,u,n,d,r.contentY+2,t.roundLabelMap,t.noWinnerColumn);for(let r=0;r<l;r++)Zt(e,t,n,u,o,r,l,d,f,i);t.noWinnerColumn||$t(e,t,n,u,l,d,f)}function Zt(e,t,n,r,i,a,o,s,c,l){let u=i/2**(a+1),d=r.lineHeight*2**a,f=nn(a,r,s),p=(2**a-1)*r.lineHeight/2,m=2**(a+1)*r.lineHeight;for(let i=0;i<u;i++){let u=c+p+i*m,h=u+d,g=(u+h)/2;if(a===0){let a=l+i*2+1,o=l+i*2+2;rn(e,sn(t.slots,a),a,n,r,f,u),rn(e,sn(t.slots,o),o,n,r,f,h)}else{let t=tn(a,r);e.setDrawColor(40),e.setLineWidth(.25),e.line(f,u,f+t,u),e.line(f,h,f+t,h)}let _=a===o-1,v=f+tn(a,r);if(e.setDrawColor(40),e.setLineWidth(.25),e.line(v+r.connectorGap,u,v+r.connectorGap,h),e.line(v,u,v+r.connectorGap,u),e.line(v,h,v+r.connectorGap,h),!_||!t.noWinnerColumn){let t=nn(a+1,r,s);e.line(v+r.connectorGap,g,t,g)}let y=cn(t.matchUps,a+1,i+1);if(_&&t.noWinnerColumn){let i=ln(y,t.slots);i&&(e.setDrawColor(40),e.setLineWidth(.25),e.line(v+r.connectorGap,g,v+r.connectorGap+r.roundColumnWidth,g),an(e,i,n,r,v+r.connectorGap,g),y?.score&&Qt(e,y,n,r,d,v+r.connectorGap,a,g))}else if(!_){let i=ln(y,t.slots);if(i){let t=nn(a+1,r,s);an(e,i,n,r,t,g),y?.score&&Qt(e,y,n,r,d,t,a,g)}}}}function Qt(e,t,n,r,i,a,o,s){let c=q(t.score,n);if(R(e,r.scoreFontSize,F.NORMAL),e.setTextColor(60,60,160),i*2<r.scoreFontSize*1.2){let t=a+tn(o+1,r)-1;e.text(c,t,s-.5,{align:`right`})}else{let t=r.scoreFontSize*.4;e.text(c,a+1,s-.5+t)}e.setTextColor(0)}function $t(e,t,n,r,i,a,o){let s=nn(i,r,a),c=(2**(i-1)-1)*r.lineHeight/2,l=r.lineHeight*2**(i-1),u=o+c+l/2;e.setDrawColor(40),e.setLineWidth(.25),e.line(s,u,s+r.roundColumnWidth,u);let d=cn(t.matchUps,i,1);if(d?.winningSide){let i=d.drawPositions[d.winningSide-1],a=sn(t.slots,i);if(a){R(e,r.fontSize+1,F.BOLD);let{name:t}=At(a,n);if(e.text(t,s+1,u-.5),d.score){let t=q(d.score,n);R(e,r.scoreFontSize,F.NORMAL),e.setTextColor(60,60,160),e.text(t,s+1,u+r.scoreFontSize*.4),e.setTextColor(0)}}}}function en(e,t,n,r,i,a,o,s,c){R(e,r.fontSize<=I.TINY?5.5:I.SMALL,F.BOLD),e.setTextColor(40);for(let c=0;c<t;c++){let l=n-t+c+1,u=K(l,n),d=s?.[l]||i.roundLabels[u]||u,f=nn(c,r,a),p=tn(c,r),m=f+p/2;e.text(d,m,o,{align:`center`}),e.setDrawColor(160),e.setLineWidth(.15),e.line(f+2,o+1.5,f+p-2,o+1.5)}if(!c){let n=nn(t,r,a);e.text(`Winner`,n+r.roundColumnWidth/2,o,{align:`center`}),e.setDrawColor(160),e.setLineWidth(.15),e.line(n+2,o+1.5,n+r.roundColumnWidth-2,o+1.5)}e.setTextColor(0)}function tn(e,t){return e===0?t.firstRoundWidth:e===1?t.secondRoundWidth:t.roundColumnWidth}function nn(e,t,n){if(e===0)return n;let r=n+t.firstRoundWidth+t.connectorGap;for(let n=1;n<e;n++)r+=tn(n,t)+t.connectorGap;return r}function rn(e,t,n,r,i,a,o,s){let c=i.fontSize<=5?4:5,l=i.fontSize<=5?5:6,u=s||i.firstRoundWidth,d=i.lineHeight<2?.15:.3;R(e,i.scoreFontSize,F.NORMAL),e.setTextColor(120),e.text(`${n}`,a,o-d,{align:`left`}),e.setTextColor(0),t?.nationality&&(R(e,i.scoreFontSize,F.NORMAL),e.setTextColor(100),e.text(t.nationality,a+c+l-1,o-d,{align:`right`}),e.setTextColor(0));let f=a+c+l,p=a+u;if(e.setDrawColor(40),e.setLineWidth(.25),e.line(f,o,p,o),!t)return;let{name:m}=At(t,r);if(!m)return;R(e,i.fontSize,t.isBye?F.ITALIC:F.NORMAL),t.isBye&&e.setTextColor(150);let h=p-f-2,g=m;e.getTextWidth(m)>h&&(g=on(t.participantName));let _=i.lineHeight<2?.2:.5;e.text(g,f+1,o-_),t.isBye&&e.setTextColor(0)}function an(e,t,n,r,i,a){let o=on(t.participantName),s=``;if(t.seedValue)switch(n.seedFormat){case`parens`:s=`(${t.seedValue})`;break;case`bare`:s=`${t.seedValue}`;break;default:s=`[${t.seedValue}]`}let c=s?`${o} ${s}`:o;R(e,r.fontSize,F.BOLD),e.text(c,i+1,a-.5)}function on(e){let t=e.match(/^([^,]+),\s*(.+)/);if(t)return`${t[2][0]}. ${t[1]}`;let n=e.match(/^(\S+)\s+(.+)/);return n?`${n[1][0]}. ${n[2]}`:e}function sn(e,t){return e.find(e=>e.drawPosition===t)}function cn(e,t,n){return e.find(e=>e.roundNumber===t&&e.roundPosition===n)}function ln(e,t){if(e){if(e.winningSide){let n=e.drawPositions[e.winningSide-1];return sn(t,n)}if(e.matchUpStatus===`BYE`)for(let n of e.drawPositions){let e=sn(t,n);if(e&&!e.isBye&&e.participantName)return e}}}function un(e,t,n,r){let i=n.page.margins,a=r.contentY+9,o=r.contentHeight-9,s=t.drawSize/2,c=Math.log2(s),l=r.contentWidth,u=Math.min(30,l*.08),d=(l-u)/2,f=i.left+d,p=o/s,m=p<3.5,h=m?.8:1.5,g=Math.min(m?30:50,d*.22),_=c,v=d-g-h*(_+1),y=Math.max(8,v/Math.max(1,_)),b=I.SMALL;p<2.5?b=5:m&&(b=I.TINY);let x=m?5:I.TINY,S={lineHeight:p,roundColumnWidth:y,firstRoundWidth:g,connectorGap:h,fontSize:b,scoreFontSize:x},C=t.slots.filter(e=>e.drawPosition<=s),ee=t.slots.filter(e=>e.drawPosition>s),te=t.matchUps.filter(e=>e.drawPositions.every(e=>e<=s)),w=t.matchUps.filter(e=>e.drawPositions.every(e=>e>s)),T=ee.map(e=>({...e,drawPosition:e.drawPosition-s})),E=new Map;for(let e of w)E.has(e.roundNumber)||E.set(e.roundNumber,[]),E.get(e.roundNumber).push(e);let D=[];for(let[,e]of E)e.sort((e,t)=>e.roundPosition-t.roundPosition),e.forEach((e,t)=>{D.push({...e,drawPositions:e.drawPositions.map(e=>e-s),roundPosition:t+1})});let O=new Map;for(let e of te)O.has(e.roundNumber)||O.set(e.roundNumber,[]),O.get(e.roundNumber).push(e);let k=[];for(let[,e]of O)e.sort((e,t)=>e.roundPosition-t.roundPosition),e.forEach((e,t)=>{k.push({...e,roundPosition:t+1})});pn(e,c,t.totalRounds,S,n,i.left,i.left+l,r.contentY+2,t.roundLabelMap),R(e,m?5.5:I.SMALL,F.BOLD),e.setTextColor(40),e.text(`Winner`,f+u/2,r.contentY+2,{align:`center`}),e.setDrawColor(160),e.setLineWidth(.15),e.line(f+2,r.contentY+3.5,f+u-2,r.contentY+3.5),e.setTextColor(0),dn(e,C,k,c,S,n,i.left,a,t.totalRounds),fn(e,T,D,c,S,n,i.left+l,a,t.totalRounds);let A=t.matchUps.find(e=>e.roundNumber===t.totalRounds);if(A){let r=a+o/2;if(e.setDrawColor(40),e.setLineWidth(.25),e.line(f+2,r,f+u-2,r),A.winningSide){let i=A.drawPositions[A.winningSide-1],a=t.slots.find(e=>e.drawPosition===i);if(a){let{name:t}=At(a,n);R(e,b+1,F.BOLD),e.text(t,f+u/2,r-1,{align:`center`})}}A.score&&(R(e,x,F.NORMAL),e.setTextColor(60,60,160),e.text(q(A.score,n),f+u/2,r+x*.4,{align:`center`}),e.setTextColor(0))}}function dn(e,t,n,r,i,a,o,s,c){let l=new Map(t.map(e=>[e.drawPosition,e])),u=t.length;for(let t=0;t<r;t++){let c=u/2**(t+1),d=i.lineHeight*2**t,f=(2**t-1)*i.lineHeight/2,p=2**(t+1)*i.lineHeight,m=mn(t,i,o),h=t===0?i.firstRoundWidth:i.roundColumnWidth;for(let u=0;u<c;u++){let c=s+f+u*p,g=c+d,_=(c+g)/2;if(t===0){let t=u*2+1,n=u*2+2;gn(e,l.get(t),i,m,c,h,`ltr`),gn(e,l.get(n),i,m,g,h,`ltr`)}else e.setDrawColor(40),e.setLineWidth(.25),e.line(m,c,m+h,c),e.line(m,g,m+h,g);let v=m+h,y=mn(t+1,i,o);e.setDrawColor(40),e.setLineWidth(.25),e.line(v+i.connectorGap,c,v+i.connectorGap,g),e.line(v,c,v+i.connectorGap,c),e.line(v,g,v+i.connectorGap,g),e.line(v+i.connectorGap,_,y,_);let b=vn(n,t+1,u+1);if(t<r-1&&b?.winningSide){let t=b.drawPositions[b.winningSide-1],n=l.get(t);if(n){R(e,i.fontSize,F.BOLD);let t=n.participantName;e.getTextWidth(t)>i.roundColumnWidth-2&&(t=_n(t)),e.text(t,y+1,_-.5)}}b?.score&&t<r-1&&(R(e,i.scoreFontSize,F.NORMAL),e.setTextColor(60,60,160),e.text(q(b.score,a),y+1,_-.5+i.scoreFontSize*.4),e.setTextColor(0))}}}function fn(e,t,n,r,i,a,o,s,c){let l=new Map(t.map(e=>[e.drawPosition,e])),u=t.length;for(let t=0;t<r;t++){let c=u/2**(t+1),d=i.lineHeight*2**t,f=(2**t-1)*i.lineHeight/2,p=2**(t+1)*i.lineHeight,m=hn(t,i,o),h=t===0?i.firstRoundWidth:i.roundColumnWidth;for(let u=0;u<c;u++){let c=s+f+u*p,g=c+d,_=(c+g)/2;if(t===0){let t=u*2+1,n=u*2+2;gn(e,l.get(t),i,m,c,h,`rtl`),gn(e,l.get(n),i,m,g,h,`rtl`)}else e.setDrawColor(40),e.setLineWidth(.25),e.line(m,c,m+h,c),e.line(m,g,m+h,g);let v=m,y=hn(t+1,i,o);e.setDrawColor(40),e.setLineWidth(.25),e.line(v-i.connectorGap,c,v-i.connectorGap,g),e.line(v,c,v-i.connectorGap,c),e.line(v,g,v-i.connectorGap,g),e.line(v-i.connectorGap,_,y+i.roundColumnWidth,_);let b=vn(n,t+1,u+1);if(t<r-1&&b?.winningSide){let t=b.drawPositions[b.winningSide-1],n=l.get(t);if(n){R(e,i.fontSize,F.BOLD);let t=n.participantName;e.getTextWidth(t)>i.roundColumnWidth-2&&(t=_n(t));let r=y;e.text(t,r+i.roundColumnWidth-1,_-.5,{align:`right`})}}if(b?.score&&t<r-1){let t=y;R(e,i.scoreFontSize,F.NORMAL),e.setTextColor(60,60,160),e.text(q(b.score,a),t+i.roundColumnWidth-1,_-.5+i.scoreFontSize*.4,{align:`right`}),e.setTextColor(0)}}}}function pn(e,t,n,r,i,a,o,s,c){R(e,r.fontSize<=I.TINY?5.5:I.SMALL,F.BOLD),e.setTextColor(40);for(let l=0;l<t;l++){let u=n-t+l+1,d=K(u,n),f=c?.[u]||i.roundLabels[d]||d,p=l===0?r.firstRoundWidth:r.roundColumnWidth,m=mn(l,r,a);e.text(f,m+p/2,s,{align:`center`}),e.setDrawColor(160),e.setLineWidth(.15),e.line(m+2,s+1.5,m+p-2,s+1.5);let h=hn(l,r,o);e.text(f,h+p/2,s,{align:`center`}),e.line(h+2,s+1.5,h+p-2,s+1.5)}e.setTextColor(0)}function mn(e,t,n){return e===0?n:n+t.firstRoundWidth+t.connectorGap+(e-1)*(t.roundColumnWidth+t.connectorGap)}function hn(e,t,n){return e===0?n-t.firstRoundWidth:n-t.firstRoundWidth-t.connectorGap-(e-1)*(t.roundColumnWidth+t.connectorGap)-t.roundColumnWidth}function gn(e,t,n,r,i,a,o){if(e.setDrawColor(40),e.setLineWidth(.25),e.line(r,i,r+a,i),!t||t.isBye){t?.isBye&&(R(e,n.fontSize,F.ITALIC),e.setTextColor(150),o===`ltr`?e.text(`Bye`,r+1,i-.3):e.text(`Bye`,r+a-1,i-.3,{align:`right`}),e.setTextColor(0));return}let s=t.seedValue?`[${t.seedValue}]`:``;R(e,n.fontSize,F.NORMAL);let c=t.participantName,l=s?`${s} ${c}`:c;e.getTextWidth(l)>a-2&&(c=_n(t.participantName),l=s?`${s} ${c}`:c),o===`ltr`?e.text(l,r+1,i-.3):e.text(l,r+a-1,i-.3,{align:`right`})}function _n(e){let t=e.match(/^([^,]+),\s*(.+)/);if(t)return`${t[2][0]}. ${t[1]}`;let n=e.match(/^(\S+)\s+(.+)/);return n?`${n[1][0]}. ${n[2]}`:e}function vn(e,t,n){return e.find(e=>e.roundNumber===t&&e.roundPosition===n)}function yn(e,t,n,r){let i=n.page.margins,a=r.contentY+9,o=r.contentHeight-9,s=r.contentWidth,c=t.mainDraw.matchUps,l=t.mainDraw.slots,u=t.consolation.matchUps,d=t.consolation.slots,f=new Map(l.map(e=>[e.drawPosition,e])),p=new Map(d.map(e=>[e.drawPosition,e])),m=c.filter(e=>e.roundNumber===1).sort((e,t)=>e.roundPosition-t.roundPosition),h=m.length,g=h*2,_=Math.max(...c.map(e=>e.roundNumber)),v=_-1,y=u.length>0?Math.max(...u.map(e=>e.roundNumber)):0,b=1.5,x=s-28-b*4,S=v+1,C=Math.max(y+1,1),ee=x*(S/(S+C)),te=x-ee,w=i.left+te+b,T=S>0?(ee-b*S)/S:0,E=w+28+b,D=C>0?(te-b*C)/C:0,O=i.left+te,k=o/g,A=k<3.5,j=I.SMALL;k<2.5?j=5:A&&(j=I.TINY);let ne=A?5:I.TINY;On(e,_,y,t,n,w,28,E,T,O,D,b,r.contentY+2,j),bn(e,m,h,f,w,28,b,E,O,a,k,j,y),Sn(e,c,f,_,h,E,T,b,a,k,j,ne,n,t.mainDraw.roundLabelMap),Cn(e,u,p,y,O,D,b,a,k,h,j,ne,n,t.consolation.roundLabelMap)}function bn(e,t,n,r,i,a,o,s,c,l,u,d,f){for(let p=0;p<n;p++){let n=t[p],m=l+p*u*2,h=m+u,g=(m+h)/2,_=n.drawPositions[0],v=n.drawPositions[1],y=u*.9;e.setDrawColor(40),e.setLineWidth(.3),e.rect(i,m,a,y),e.rect(i,h,a,y);let b=_?r.get(_):void 0,x=v?r.get(v):void 0;R(e,d,F.NORMAL),_&&xn(e,_,b,n.winningSide===1,i,m,y,a,d),v&&xn(e,v,x,n.winningSide===2,i,h,y,a,d),e.setDrawColor(40),e.setLineWidth(.25),e.line(i+a,m+y/2,i+a+o,m+y/2),e.line(i+a,h+y/2,i+a+o,h+y/2),e.line(i+a+o,m+y/2,i+a+o,h+y/2),e.line(i+a+o,g,s,g),f>0&&(e.line(i,m+y/2,i-o,m+y/2),e.line(i,h+y/2,i-o,h+y/2),e.line(i-o,m+y/2,i-o,h+y/2),e.line(i-o,g,c,g))}}function xn(e,t,n,r,i,a,o,s,c){if(e.setTextColor(120),R(e,c,F.NORMAL),e.text(`${t}`,i+1,a+o/2+c*.12),e.setTextColor(0),n?.participantName){let t=kn(n.participantName);R(e,c,r?F.BOLD:F.NORMAL),e.text(t,i+5,a+o/2+c*.12,{maxWidth:s-6})}}function Sn(e,t,n,r,i,a,o,s,c,l,u,d,f,p){for(let i=0;i<r-1;i++){let p=i+2,m=t.filter(e=>e.roundNumber===p).sort((e,t)=>e.roundPosition-t.roundPosition),h=l*2**(i+1),g=(2**(i+1)-1)*l/2,_=a+i*(o+s);for(let t=0;t<m.length;t++){let l=m[t],p=c+g+t*h*2,v=p+h,y=(p+v)/2;if(e.setDrawColor(40),e.setLineWidth(.25),e.line(_,p,_+o,p),e.line(_,v,_+o,v),Dn(e,l,n,_,p,v,o,u,f),i<r-2){let t=_+o;e.line(t+s,p,t+s,v),e.line(t,p,t+s,p),e.line(t,v,t+s,v),e.line(t+s,y,_+o+s+o+s>0?a+(i+1)*(o+s):t+s+5,y)}l.score&&(R(e,d,F.NORMAL),e.setTextColor(60,60,160),e.text(q(l.score,f),_+o-1,y+d*.12,{align:`right`}),e.setTextColor(0))}}let m=a+(r-2)*(o+s)+o+s,h=c+(2**(r-1)-1)*l/2+l*2**(r-2);e.setDrawColor(40),e.setLineWidth(.25),e.line(m,h,m+o,h);let g=t.find(e=>e.roundNumber===r);if(g?.winningSide){let t=n.get(g.drawPositions[g.winningSide-1]);if(t){let{name:n}=At(t,f);R(e,u+1,F.BOLD),e.text(n,m+1,h-.5)}}}function Cn(e,t,n,r,i,a,o,s,c,l,u,d,f,p){for(let l=0;l<r;l++)wn(e,t,n,l,r,i,a,o,s,c,u,d,f);En(e,t,n,r,i,a,o,s,c,u,f)}function wn(e,t,n,r,i,a,o,s,c,l,u,d,f){let p=r+1,m=t.filter(e=>e.roundNumber===p).sort((e,t)=>e.roundPosition-t.roundPosition),h=l*2**(r+1),g=(2**(r+1)-1)*l/2,_=a-(r+1)*(o+s);for(let t=0;t<m.length;t++){let l=m[t],p=c+g+t*h*2,v=p+h,y=(p+v)/2;if(e.setDrawColor(40),e.setLineWidth(.25),e.line(_,p,_+o,p),e.line(_,v,_+o,v),Tn(e,l.drawPositions[0],n,u,_,o,p),Tn(e,l.drawPositions[1],n,u,_,o,v),r<i-1){e.line(_-s,p,_-s,v),e.line(_,p,_-s,p),e.line(_,v,_-s,v);let t=a-(r+2)*(o+s);e.line(_-s,y,t+o,y)}l.score&&(R(e,d,F.NORMAL),e.setTextColor(60,60,160),e.text(q(l.score,f),_+1,y+d*.12),e.setTextColor(0))}}function Tn(e,t,n,r,i,a,o){if(!t)return;let s=n.get(t);if(!s?.participantName)return;R(e,r,F.BOLD);let c=s.participantName;e.getTextWidth(c)>a-2&&(c=kn(c)),e.text(c,i+a-1,o-.3,{align:`right`})}function En(e,t,n,r,i,a,o,s,c,l,u){if(r<=0)return;let d=i-(r+1)*(a+o),f=s+(2**r-1)*c/2+c*2**(r-1);e.setDrawColor(40),e.setLineWidth(.25),e.line(d,f,d+a,f);let p=t.find(e=>e.roundNumber===r);if(p?.winningSide){let t=n.get(p.drawPositions[p.winningSide-1]);if(t){let{name:n}=At(t,u);R(e,l+1,F.BOLD),e.text(n,d+a-1,f-.5,{align:`right`})}}}function Dn(e,t,n,r,i,a,o,s,c){if(t.drawPositions[0]){let a=n.get(t.drawPositions[0]);if(a?.participantName){R(e,s,F.BOLD);let t=a.participantName;e.getTextWidth(t)>o-2&&(t=kn(t)),e.text(t,r+1,i-.3)}}if(t.drawPositions[1]){let i=n.get(t.drawPositions[1]);if(i?.participantName){R(e,s,F.BOLD);let t=i.participantName;e.getTextWidth(t)>o-2&&(t=kn(t)),e.text(t,r+1,a-.3)}}}function On(e,t,n,r,i,a,o,s,c,l,u,d,f,p){R(e,p<=I.TINY?5.5:I.SMALL,F.BOLD),e.setTextColor(40);let m=r.mainDraw.roundLabelMap?.[1]||`R1`;e.text(m,a+o/2,f,{align:`center`});for(let n=0;n<t-1;n++){let t=n+2,i=r.mainDraw.roundLabelMap?.[t]||`R${t}`,a=s+n*(c+d);e.text(i,a+c/2,f,{align:`center`})}for(let t=0;t<n;t++){let n=t+1,i=r.consolation.roundLabelMap?.[n]||`C-R${n}`,a=l-(t+1)*(u+d);e.text(i,a+u/2,f,{align:`center`})}e.setTextColor(0)}function kn(e){let t=e.match(/^([^,]+),\s*(.+)/);if(t)return`${t[2][0]}. ${t[1]}`;let n=e.match(/^(\S+)\s+(.+)/);return n?`${n[1][0]}. ${n[2]}`:e}var An=[`E`,`W`,`N`,`S`,`NE`,`NW`,`SE`,`SW`];function jn(e,t,n,r){let i=n.page.margins,a=[...t.structures].sort((e,t)=>An.indexOf(e.abbreviation)-An.indexOf(t.abbreviation)),o=r.contentY+3;for(let s of a){if(s.drawSize===0)continue;let a=Mn(s,r);o+a>r.contentY+r.contentHeight&&(e.addPage(),o=r.contentY);let c=s.abbreviation===`E`;R(e,c?I.HEADING:I.BODY,F.BOLD),c||e.setTextColor(30,60,120);let l=c?`Main Draw (${s.name})`:`${s.name} Draw`;e.text(l,i.left,o),c||e.setTextColor(0),o+=c?5:4;let u={...r,contentY:o,contentHeight:a-6};J(e,Nn(s,t.drawName),n,u),o+=a+3}}function Mn(e,t){let n=t.contentHeight*.7,r=Math.max(5,Math.min(8,n/e.drawSize));return e.drawSize*r+10}function Nn(e,t){return{drawName:`${t} - ${e.name}`,drawSize:e.drawSize,drawType:`SINGLE_ELIMINATION`,totalRounds:e.totalRounds,slots:e.slots,matchUps:e.matchUps,seedAssignments:[]}}function Pn(e){let{drawDefinition:t,participants:n=[]}=e;if(!t?.structures)return[];let r=new Map;return n.forEach(e=>r.set(e.participantId,e)),t.structures.map(t=>{let n=t.positionAssignments||[],i=t.seedAssignments||[],a=n.length,o=n.map(e=>{let t=e.participantId?r.get(e.participantId):void 0,n=i.find(t=>t.participantId===e.participantId);return{drawPosition:e.drawPosition,participantName:t?H(t):``,nationality:t?U(t):``,seedValue:n?.seedValue,isBye:e.bye===!0}}),s=(t.matchUps||[]).map(e=>({roundNumber:e.roundNumber,roundPosition:e.roundPosition,drawPositions:e.drawPositions||[],score:e.score?.scoreStringSide1||``,winningSide:e.winningSide,matchUpStatus:e.matchUpStatus})),c=t.stage||`MAIN`,l=c===`MAIN`,u=t.structureName||(l?`Main Draw`:`Consolation`),d=s.reduce((e,t)=>Math.max(e,t.roundNumber||0),0),f=(e.processedMatchUps||[]).filter(e=>e.structureId===t.structureId),p;if(f.length){p={};for(let e of f)e.roundNumber&&!p[e.roundNumber]&&(p[e.roundNumber]=e.abbreviatedRoundName||e.roundName||`R${e.roundNumber}`)}return{name:u,stage:c,drawData:{drawName:u,drawSize:a,drawType:`SINGLE_ELIMINATION`,totalRounds:d,slots:o,matchUps:s,seedAssignments:i.filter(e=>e.participantId).map(e=>{let t=r.get(e.participantId);return{seedValue:e.seedValue,participantName:t?H(t):``,nationality:t?U(t):``}}),roundLabelMap:p}}})}function Fn(e,t,n,r){let i=n.page.margins,a=r.contentY,o={MAIN:0,CONSOLATION:1,PLAY_OFF:2},s=[...t].filter(e=>e.drawData.drawSize>0).sort((e,t)=>(o[e.stage]??9)-(o[t.stage]??9));for(let t of s){let o=t.stage===`MAIN`,s=t.drawData.drawSize*3.5+8;a+s>r.contentY+r.contentHeight&&a>r.contentY+10&&(e.addPage(),a=r.contentY),a+=3,R(e,o?I.HEADING:I.BODY,F.BOLD),o||e.setTextColor(120,40,40),e.text(t.name,i.left,a),o||e.setTextColor(0),a+=o?4:3;let c={...r,contentY:a,contentHeight:Math.min(s,r.contentY+r.contentHeight-a)};J(e,t.drawData,n,c),a+=s+4}}function In(e,t,n,r){let i=n.page.margins,a=r.contentHeight,o=a*.44,s=a*.44,c=r.contentWidth-30-8,l=Ln(t.winnersBracket),u=r.contentY+3;R(e,I.BODY,F.BOLD),e.setTextColor(30,80,30),e.text(`Winner's Bracket`,i.left,u),e.setTextColor(0),u+=3,J(e,l,n,{...r,contentY:u,contentHeight:o-6,contentWidth:c}),u=r.contentY+o+6,R(e,I.BODY,F.BOLD),e.setTextColor(140,40,40),e.text(`Loser's Bracket (Backdraw)`,i.left,u),e.setTextColor(0),u+=3;let d={...r,contentY:u,contentHeight:s-6,contentWidth:c};J(e,t.losersBracket,n,d);let f=i.left+c+8,p=r.contentY+a/2;if(R(e,I.SMALL,F.BOLD),e.text(`Decider`,f+14,p-14-4,{align:`center`}),e.setDrawColor(60),e.setLineWidth(.5),e.rect(f,p-14-1,28,14),e.setLineWidth(.2),e.line(f,p-7-1,f+28,p-7-1),t.deciderMatch?.matchUps?.length){let n=t.deciderMatch.matchUps[0],r=new Map(t.deciderMatch.slots.map(e=>[e.drawPosition,e]));if(n.drawPositions[0]){let t=r.get(n.drawPositions[0]);if(t?.participantName){let r=n.winningSide===1;R(e,I.TINY,r?F.BOLD:F.NORMAL),e.text(t.participantName,f+1,p-7-3,{maxWidth:26})}}if(n.drawPositions[1]){let t=r.get(n.drawPositions[1]);if(t?.participantName){let r=n.winningSide===2;R(e,I.TINY,r?F.BOLD:F.NORMAL),e.text(t.participantName,f+1,p-3,{maxWidth:26})}}n.score&&(R(e,I.TINY,F.NORMAL),e.setTextColor(60,60,160),e.text(n.score,f+28-1,p-14+2,{align:`right`}),e.setTextColor(0))}}function Ln(e){let t={...e.roundLabelMap||{}};for(let e of Object.keys(t))t[Number(e)]===`F-Q`&&(t[Number(e)]=`SF`);return{...e,roundLabelMap:t}}var Rn=1,zn=16,Bn=1;function Vn(e,t,n,r){let i=n.page.margins,a=new Map;for(let e of t.matchUps)a.has(e.roundNumber)||a.set(e.roundNumber,[]),a.get(e.roundNumber).push(e);let o=new Map(t.slots.map(e=>[e.drawPosition,e])),s=[...a.keys()].sort((e,t)=>e-t),c=s.length,l=r.contentY+7,u=r.contentHeight-7,d=Math.min(55,(r.contentWidth-(c-1)*6)/c),f=a.get(s[0])?.length||1,p=Math.min(zn,(u-(f+1)*Bn)/f);R(e,I.SMALL,F.BOLD),e.setTextColor(30,60,120);for(let a=0;a<c;a++){let o=s[a],c=n.roundLabels[K(o,t.totalRounds)]||K(o,t.totalRounds),l=i.left+a*(d+6);e.text(c,l+d/2,r.contentY+3,{align:`center`})}e.setTextColor(0);for(let t=0;t<c;t++){let r=s[t],c=a.get(r)||[],f=c.length,m=i.left+t*(d+6),h=f*p,g=f>1?(u-h)/(f+1):(u-p)/2;for(let t=0;t<f;t++){let r=l+g+t*(p+g);Hn(e,c[t],o,n,m,r,d,p)}}}function Hn(e,t,n,r,i,a,o,s){let c=s<10?5:I.TINY;e.setDrawColor(100),e.setLineWidth(.3),e.rect(i,a,o,s);let l=a+s/2;e.setLineWidth(.15),e.line(i,l,i+o,l);let u=t.drawPositions[0]?n.get(t.drawPositions[0]):void 0;if(u){let n=kt(u,r);R(e,c,t.winningSide===1?F.BOLD:F.NORMAL),e.text(n,i+Rn,l-c*.15,{maxWidth:o-2})}let d=t.drawPositions[1]?n.get(t.drawPositions[1]):void 0;if(d){let n=kt(d,r);R(e,c,t.winningSide===2?F.BOLD:F.NORMAL),e.text(n,i+Rn,l+c*.55,{maxWidth:o-2})}if(t.score){let n=q(t.score,r);R(e,c,F.NORMAL),e.setTextColor(60,60,160),e.text(n,i+o-Rn,a+c*.5,{align:`right`}),e.setTextColor(0)}}var Un={maxPositionsPerPage:64,includeOverlapRounds:!0,summaryPage:!0};function Wn(e,t=Un){let{drawSize:n,slots:r,matchUps:i,totalRounds:a}=e;if(n<=t.maxPositionsPerPage)return[{label:`Full Draw`,startPosition:1,endPosition:n,slots:r,matchUps:i,segmentRounds:a}];let o=t.maxPositionsPerPage,s=Math.ceil(n/o),c=Math.log2(o),l=[];for(let e=0;e<s;e++)l.push(Gn(e,o,s,c,n,r,i));return t.summaryPage&&s>1&&l.push(Kn(e)),l}function Gn(e,t,n,r,i,a,o){let s=e*t+1,c=Math.min((e+1)*t,i),l=`Section ${e+1}`;n===2&&(l=e===0?`Top Half`:`Bottom Half`);let u=a.filter(e=>e.drawPosition>=s&&e.drawPosition<=c),d=qn(o.filter(e=>e.roundNumber>r?!1:e.drawPositions.every(e=>e>=s&&e<=c)));return{label:l,startPosition:s,endPosition:c,slots:u,matchUps:d,segmentRounds:r,noWinnerColumn:!0}}function Kn(e){let{slots:t,matchUps:n,totalRounds:r,roundLabelMap:i}=e,a=Math.max(1,r-5+1),o=r-a+1,s=a-1,c=n.filter(e=>e.roundNumber===a).sort((e,t)=>e.roundPosition-t.roundPosition),l=c.length*2,u=Jn(c),d=qn(n.filter(e=>e.roundNumber>=a).map(e=>({...e,roundNumber:e.roundNumber-s,roundPosition:e.roundNumber===a?c.findIndex(t=>t.roundPosition===e.roundPosition)+1:e.roundPosition,drawPositions:e.drawPositions.map(e=>u.get(e)||e)}))),f=[];for(let[e,n]of u){let r=t.find(t=>t.drawPosition===e);r&&f.push({...r,drawPosition:n})}return f.sort((e,t)=>e.drawPosition-t.drawPosition),{label:`Final Rounds`,startPosition:1,endPosition:l,slots:f,matchUps:d,segmentRounds:o,roundLabelMap:i?Object.fromEntries(Object.entries(i).filter(([e])=>Number(e)>=a).map(([e,t])=>[Number(e)-s,t])):void 0}}function qn(e){let t=new Map;for(let n of e)t.has(n.roundNumber)||t.set(n.roundNumber,[]),t.get(n.roundNumber).push(n);let n=[];for(let[,e]of t)e.sort((e,t)=>e.roundPosition-t.roundPosition),e.forEach((e,t)=>{n.push({...e,roundPosition:t+1})});return n}function Jn(e){let t=new Map,n=1;for(let r of e)for(let e of r.drawPositions)e&&!t.has(e)&&t.set(e,n++);return t}function Yn(e,t={}){return Xn(e.matchUps)?$n(e,t):Zn(e,t)}function Xn(e){let t=new Map;for(let n of e)t.set(n.roundNumber,(t.get(n.roundNumber)||0)+1);let n=[...t.keys()].sort((e,t)=>e-t);for(let e=1;e<n.length;e++){let r=t.get(n[e-1])||0;if((t.get(n[e])||0)>=r)return!0}return!1}function Zn(e,t={}){if(e.drawSize>=256)return Qn(e,{...t,maxPositionsPerPage:64});let n=Y(e.drawSize,t),r=z(n.doc,n.pageConfig,n.headerH,n.footerH);return J(n.doc,e,n.format,r),X(n),n.doc}function Qn(e,t={}){let n=Y(e.drawSize,t),r=Wn(e,{maxPositionsPerPage:t.maxPositionsPerPage||32,includeOverlapRounds:!0,summaryPage:!0});for(let t=0;t<r.length;t++){t>0&&n.doc.addPage();let i=B(n.doc,{...n.headerConfig,subtitle:r[t].label},n.pageConfig),a=z(n.doc,n.pageConfig,i,n.footerH);if(r[t].slots.length>0||r[t].matchUps.length>0){let i=r[t],o=i.endPosition-i.startPosition+1,s={...e,slots:i.slots,matchUps:i.matchUps,noWinnerColumn:i.noWinnerColumn,roundLabelMap:i.roundLabelMap||e.roundLabelMap,drawSize:o,totalRounds:i.segmentRounds};J(n.doc,s,n.format,a,i.startPosition-1,o)}}return X(n),n.doc}function $n(e,t={}){let n=e.totalRounds>=5||e.slots.length>=12,r=Y(e.drawSize,t,n),i=z(r.doc,r.pageConfig,r.headerH,r.footerH);return J(r.doc,e,r.format,i),X(r),r.doc}function er(e,t={}){let n=Y(Math.max(...e.map(e=>e.drawData.drawSize),8),t),r=z(n.doc,n.pageConfig,n.headerH,n.footerH);return Fn(n.doc,e,n.format,r),or(n,1),X(n),n.doc}function tr(e,t={}){let n=Y(e.mainStructure?.drawSize||8,t),r=z(n.doc,n.pageConfig,n.headerH,n.footerH);return jn(n.doc,e,n.format,r),or(n,1),X(n),n.doc}function nr(e,t={}){let n=Y(e.drawSize,t,!0),r=z(n.doc,n.pageConfig,n.headerH,n.footerH);return un(n.doc,e,n.format,r),X(n),n.doc}function rr(e,t={}){let n=Y(e.mainDraw.drawSize,t,!0),r=z(n.doc,n.pageConfig,n.headerH,n.footerH);return yn(n.doc,e,n.format,r),X(n),n.doc}function ir(e,t={}){let n=Y(Math.max(e.winnersBracket.drawSize,e.losersBracket.drawSize,8),t,!0),r=z(n.doc,n.pageConfig,n.headerH,n.footerH);return In(n.doc,e,n.format,r),X(n),n.doc}function ar(e,t={}){let n=Y(e.drawSize,t),r=z(n.doc,n.pageConfig,n.headerH,n.footerH);return Vn(n.doc,e,n.format,r),X(n),n.doc}function Y(e,t,n){let r=t.format||g(t.preset||`itfJunior`),i={...r.page,...t.page,orientation:n?`landscape`:t.page?.orientation||r.page.orientation},a=t.header||{layout:`none`,tournamentName:``},o=t.footer||{layout:`standard`,showPageNumbers:!0,showTimestamp:!0},s=xe(i,e),c=V(o);return{doc:s,pageConfig:i,headerConfig:a,footerConfig:o,format:r,headerH:B(s,a,i),footerH:c}}function or(e,t){let n=e.doc.getNumberOfPages();for(let r=t+1;r<=n;r++)e.doc.setPage(r),B(e.doc,e.headerConfig,e.pageConfig)}function X(e){let t=e.doc.getNumberOfPages();for(let n=1;n<=t;n++)e.doc.setPage(n),ze(e.doc,e.footerConfig,e.pageConfig,n);e.doc.setPage(t)}function sr(e){let t=e.header?{...e.header,layout:e.header.layout??`itf`,tournamentName:e.header.tournamentName??``}:void 0,n=e.footer?{...e.footer,layout:e.footer.layout??`standard`}:void 0,r=e.content?.schedule;return{header:t,footer:n,page:e.page,cellStyle:r?.cellStyle??`detailed`,showMatchNumbers:r?.showMatchNumbers,alertBanner:r?.alertBanner}}function cr(e,t){if(!e?.type)return{success:!1,error:`Missing request type`};if(!e.composition)return{success:!1,error:`Missing composition config`};if(!t?.tournamentEngine)return{success:!1,error:`Missing tournamentEngine in context`};switch(e.type){case`schedule`:return wr(e,t);case`playerList`:return yr(e,t);case`signInSheet`:return br(e,t);case`courtCards`:return xr(e,t);case`matchCard`:return Cr(e,t);case`draw`:return lr(e,t)}}function lr(e,t){if(!e.drawId)return{success:!1,error:`PrintDrawRequest requires drawId`};let n=t.tournamentEngine;if(typeof n.getEventData!=`function`)return{success:!1,error:`engine.getEventData is not a function`};let{eventData:r}=n.getEventData({drawId:e.drawId})??{};if(!r?.drawsData?.length)return{success:!1,error:`No draw data found for drawId "${e.drawId}"`};let i=r.tournamentInfo??{},a=r.eventInfo??{},o=r.drawsData[0].structures??[],s=o.find(e=>e.stage===`MAIN`),c=o.some(e=>e.stage===`CONSOLATION`),l=o.some(e=>e.stage===`PLAY_OFF`),u=gr(e.composition,`draw`)?.splitStrategy??`single-page`,d={header:pr(e.composition,i,a),footer:mr(e.composition),page:e.composition.page,preset:void 0},f;try{if(c&&l)f=ir({winnersBracket:s?N(s):ur(),losersBracket:dr(r),deciderMatch:fr(r)},d);else if(c)f=er(o.map(e=>({name:e.structureName,stage:e.stage,drawData:N(e)})),d);else if(s){let e=N(s);f=u===`single-page`?Zn(e,d):Qn(e,d)}}catch(e){return{success:!1,error:`draw generator failed: ${e instanceof Error?e.message:String(e)}`}}if(!f)return{success:!1,error:`No matching draw renderer for this structure`};let p=(a.eventName||i.tournamentName||`draw`).replace(/[^a-z0-9]/gi,`_`).toLowerCase();return{success:!0,doc:f,blob:f.output(`blob`),filename:`draw-${p}.pdf`}}function ur(){return{drawName:``,drawSize:0,drawType:``,totalRounds:0,slots:[],matchUps:[],seedAssignments:[]}}function dr(e){let t=P(e.drawsData,`CONSOLATION`);return t?N(t):ur()}function fr(e){let t=P(e.drawsData,`PLAY_OFF`);return t?N(t):void 0}function pr(e,t,n){if(e.header?.layout===`none`)return;let r=e.header??{};return{layout:r.layout??`itf`,tournamentName:r.tournamentName??t?.tournamentName??n?.eventName??`Tournament`,subtitle:r.subtitle??n?.eventName,startDate:r.startDate??t?.startDate,endDate:r.endDate??t?.endDate,location:r.location??t?.venues?.[0]?.venueName,organizer:r.organizer,surface:r.surface??n?.surfaceCategory,grade:r.grade,supervisor:r.supervisor,city:r.city,country:r.country??t?.hostCountryCode,prizeMoney:r.prizeMoney,currency:r.currency,tournamentId:r.tournamentId,sectionLabel:r.sectionLabel,leftLogoBase64:r.leftLogoBase64,rightLogoBase64:r.rightLogoBase64,chiefUmpire:r.chiefUmpire}}function mr(e){if(e.footer?.layout===`none`)return;let t=e.footer??{};return{layout:t.layout??`standard`,showPageNumbers:t.showPageNumbers??!0,showTimestamp:t.showTimestamp??!0,notes:t.notes,officials:t.officials,seedAssignments:t.seedAssignments,prizeMoney:t.prizeMoney,signatureLines:t.signatureLines,drawCeremonyDate:t.drawCeremonyDate,releaseDate:t.releaseDate,withdrawals:t.withdrawals,luckyLosers:t.luckyLosers}}function hr(e){let t=e.header;if(!(!t||t.layout===`none`))return{tournamentName:t.tournamentName??``,subtitle:t.subtitle,startDate:t.startDate,endDate:t.endDate,location:t.location,organizer:t.organizer}}function gr(e,t){return e.content?.[t]}function _r(e,t){if(typeof e.getParticipants!=`function`)return{success:!1,error:`engine.getParticipants is not a function`};let{participants:n=[]}=e.getParticipants({participantFilters:{participantTypes:[`INDIVIDUAL`]},withScaleValues:!0,withSeeding:!0})??{};if(t){if(typeof e.getEvent!=`function`)return{success:!1,error:`engine.getEvent is not a function`};let{event:r}=e.getEvent({eventId:t})??{};if(!r)return{success:!1,error:`Event "${t}" not found`};let i=new Set((r.entries??[]).map(e=>e.participantId));return{success:!0,participants:n.filter(e=>i.has(e.participantId)),eventEntries:[{eventName:r.eventName??``,entries:vr(r)}],eventName:r.eventName??``}}return{success:!0,participants:n,eventEntries:(e.getEvents?.()?.events??[]).map(e=>({eventName:e.eventName??``,entries:vr(e)})),eventName:``}}function vr(e){let t=e.entries??[],n=new Map;for(let t of e.drawDefinitions??[])for(let e of t.structures??[])if(!(e.stage&&e.stage!==`MAIN`))for(let t of e.seedAssignments??[]){if(!t?.participantId||t.seedValue===void 0)continue;let e=Number(t.seedValue);!Number.isNaN(e)&&!n.has(t.participantId)&&n.set(t.participantId,e)}return n.size===0?t:t.map(e=>n.has(e.participantId)?{...e,seedValue:n.get(e.participantId)}:e)}function yr(e,t){let n=_r(t.tournamentEngine,e.eventId);if(!n.success)return n;let r=ot({participants:n.participants,eventEntries:n.eventEntries}),i=gr(e.composition,`playerList`),a;try{a=yt(r,{header:hr(e.composition),includeRanking:i?.includeRanking,includeEvents:i?.includeEvents,groupByEvent:i?.groupByEvent})}catch(e){return{success:!1,error:`generatePlayerListPDF failed: ${e instanceof Error?e.message:String(e)}`}}let o=(n.eventName||`all`).replace(/[^a-z0-9]/gi,`_`).toLowerCase();return{success:!0,doc:a,blob:a.output(`blob`),filename:`player-list-${o}.pdf`}}function br(e,t){if(!e.eventId)return{success:!1,error:`PrintSignInSheetRequest requires eventId`};let n=_r(t.tournamentEngine,e.eventId);if(!n.success)return n;let r=ot({participants:n.participants,eventEntries:n.eventEntries}),i;try{i=bt(r,{header:hr(e.composition),eventName:n.eventName})}catch(e){return{success:!1,error:`generateSignInSheetPDF failed: ${e instanceof Error?e.message:String(e)}`}}let a=(n.eventName||`all`).replace(/[^a-z0-9]/gi,`_`).toLowerCase();return{success:!0,doc:i,blob:i.output(`blob`),filename:`sign-in-sheet-${a}.pdf`}}function xr(e,t){let n=t.tournamentEngine,r=Tr(n,e.venueId);if(!r.success)return r;let i=ct({matchUps:r.matchUps,venues:r.venues,scheduledDate:e.scheduledDate}),a=Sr(e.composition,n),o=gr(e.composition,`courtCard`),s;try{s=xt(i,{tournamentName:a,cardsPerPage:o?.cardsPerPage})}catch(e){return{success:!1,error:`generateCourtCardPDF failed: ${e instanceof Error?e.message:String(e)}`}}let c=e.scheduledDate?`-${e.scheduledDate}`:``;return{success:!0,doc:s,blob:s.output(`blob`),filename:`court-cards${c}.pdf`}}function Sr(e,t){return e.header?.tournamentName||(typeof t.getTournamentInfo==`function`?t.getTournamentInfo()?.tournamentInfo?.tournamentName??``:``)}function Cr(e,t){if(!Array.isArray(e.matchUpIds)||e.matchUpIds.length===0)return{success:!1,error:`PrintMatchCardRequest requires non-empty matchUpIds`};let n=t.tournamentEngine;if(typeof n.allTournamentMatchUps!=`function`)return{success:!1,error:`engine.allTournamentMatchUps is not a function`};let{matchUps:r=[]}=n.allTournamentMatchUps()??{},i=new Set(e.matchUpIds),a=r.filter(e=>i.has(e.matchUpId));if(a.length===0)return{success:!1,error:`No matchUps match the requested matchUpIds`};let o=Sr(e.composition,n),s=a.map(e=>({tournamentName:o,eventName:e.eventName??``,roundName:e.roundName??e.abbreviatedRoundName??``,matchUpId:e.matchUpId,courtName:e.schedule?.courtName,scheduledTime:e.schedule?.scheduledTime,side1:{name:e.sides?.[0]?.participant?.participantName??`TBD`,nationality:e.sides?.[0]?.participant?.nationalityCode??``,seedValue:e.sides?.[0]?.seedValue},side2:{name:e.sides?.[1]?.participant?.participantName??`TBD`,nationality:e.sides?.[1]?.participant?.nationalityCode??``,seedValue:e.sides?.[1]?.seedValue}})),c;try{c=Ct(s,{cardsPerPage:2,includeScoreBoxes:!0})}catch(e){return{success:!1,error:`generateMatchCardPDF failed: ${e instanceof Error?e.message:String(e)}`}}return{success:!0,doc:c,blob:c.output(`blob`),filename:`match-cards-${s.length}.pdf`}}function wr(e,t){if(!e.scheduledDate)return{success:!1,error:`PrintScheduleRequest requires scheduledDate`};let n=t.tournamentEngine,r=Tr(n,e.venueId);if(!r.success)return r;let i=it({matchUps:r.matchUps,venues:r.venues,scheduledDate:e.scheduledDate}),a=sr(e.composition),o;try{o=dt(i,a)}catch(e){return{success:!1,error:`generateOrderOfPlayPDF failed: ${e instanceof Error?e.message:String(e)}`}}return{success:!0,doc:o,blob:o.output(`blob`),filename:`order-of-play-${e.scheduledDate}.pdf`}}function Tr(e,t){if(typeof e.competitionScheduleMatchUps!=`function`)return{success:!1,error:`engine.competitionScheduleMatchUps is not a function`};if(typeof e.getVenuesAndCourts!=`function`)return{success:!1,error:`engine.getVenuesAndCourts is not a function`};let n=e.competitionScheduleMatchUps()??{},r=[...n.dateMatchUps??[],...n.completedMatchUps??[]],i=t?r.filter(e=>e?.schedule?.venueId===t):r,a=(e.getVenuesAndCourts()??{}).venues??[];return{success:!0,matchUps:i,venues:t?a.filter(e=>e.venueId===t):a}}var Er=[{value:`grand-slam`,label:`Grand Slam`,description:`Centered tournament name, uppercase, date/location right`},{value:`itf`,label:`ITF/Professional`,description:`Left-aligned name, grade/supervisor on right, separator line`},{value:`minimal`,label:`Minimal`,description:`Single line with tournament name and subtitle`},{value:`none`,label:`No Header`,description:`Skip header entirely`}],Dr=[{value:`standard`,label:`Standard`,description:`Timestamp, page number, optional notes`},{value:`seedings`,label:`Seedings Table`,description:`Seeded players list in compact columns`},{value:`officials`,label:`Officials`,description:`Tournament officials with roles`},{value:`none`,label:`No Footer`,description:`Skip footer entirely`}],Or=[{value:`a4`,label:`A4 (210 × 297mm)`},{value:`letter`,label:`US Letter (216 × 279mm)`}],kr=[{value:`auto`,label:`Auto (landscape for large draws)`},{value:`landscape`,label:`Landscape`},{value:`portrait`,label:`Portrait`}],Ar=[{value:`single-page`,label:`Single Page (dense)`},{value:`halves`,label:`Two Halves (64+64)`},{value:`quarters`,label:`Four Quarters (32×4)`}],jr=[{id:`content`,label:`Content`,fields:[{id:`includeSeedings`,label:`Include seedings`,type:`checkbox`,defaultValue:!0,configPath:`content.draw.includeSeedings`},{id:`includeScores`,label:`Include scores`,type:`checkbox`,defaultValue:!0,configPath:`content.draw.includeScores`},{id:`showDrawPositions`,label:`Show draw positions`,type:`checkbox`,defaultValue:!0,configPath:`content.draw.showDrawPositions`},{id:`showByes`,label:`Show byes`,type:`checkbox`,defaultValue:!0,configPath:`content.draw.showByes`},{id:`splitStrategy`,label:`Split strategy`,type:`select`,options:[{value:`single-page`,label:`Single page`},{value:`halves`,label:`Split in halves`},{value:`quarters`,label:`Split in quarters`}],defaultValue:`single-page`,configPath:`content.draw.splitStrategy`}]},{id:`layout`,label:`Layout`,fields:[{id:`headerLayout`,label:`Header style`,type:`select`,options:[{value:`itf`,label:`ITF`},{value:`minimal`,label:`Minimal`},{value:`branded`,label:`Branded`}],defaultValue:`itf`,configPath:`header.layout`},{id:`orientation`,label:`Orientation`,type:`select`,options:[{value:`landscape`,label:`Landscape`},{value:`portrait`,label:`Portrait`}],defaultValue:`landscape`,configPath:`page.orientation`}]}],Mr=[{id:`content`,label:`Content`,fields:[{id:`cellStyle`,label:`Cell style`,type:`select`,options:[{value:`detailed`,label:`Detailed`},{value:`compact`,label:`Compact`}],defaultValue:`detailed`,configPath:`content.schedule.cellStyle`},{id:`showMatchNumbers`,label:`Show match numbers`,type:`checkbox`,defaultValue:!1,configPath:`content.schedule.showMatchNumbers`},{id:`alertBanner`,label:`Alert banner text`,type:`text`,configPath:`content.schedule.alertBanner`}]},{id:`layout`,label:`Layout`,fields:[{id:`headerLayout`,label:`Header style`,type:`select`,options:[{value:`itf`,label:`ITF`},{value:`minimal`,label:`Minimal`},{value:`branded`,label:`Branded`}],defaultValue:`itf`,configPath:`header.layout`}]}];function Nr(e){let{structure:t,participants:n=[]}=e;if(!t)return[];let r=new Map;n.forEach(e=>r.set(e.participantId,e));let i=t.structures||[];return i.length?i.map((e,t)=>{let n=e.positionAssignments||[],i=e.seedAssignments||[],a=n.filter(e=>e.participantId).map(e=>{let t=r.get(e.participantId),n=i.find(t=>t.participantId===e.participantId);return{participantName:t?H(t):``,nationality:t?U(t):``,seedValue:n?.seedValue,groupPosition:e.drawPosition}}).sort((e,t)=>e.groupPosition-t.groupPosition),o=[];for(let t of e.matchUps||[]){if(!t.drawPositions||t.drawPositions.length<2)continue;let[e,n]=t.drawPositions,r=$e(t.score);r&&o.push({rowPosition:e,colPosition:n,score:r,winningSide:t.winningSide})}return{groupName:e.structureName||`Group ${t+1}`,participants:a,results:o}}):[]}var Pr=[200,200,200],Fr=[20,80,20],Ir=[160,40,40],Lr=[50,50,50];function Rr(e,t,r,i,a){let o=r.page.margins,s=t.participants.length;R(e,I.HEADING,F.BOLD),e.text(t.groupName,o.left,a),a+=5;let c=[`#`,`Player`,`Nat.`];for(let e=0;e<s;e++)c.push(`${e+1}`);c.push(`W`,`L`);let l=zr(t,r),u=t.participants.map((e,t)=>{let n=[{content:`${t+1}`,styles:{fontStyle:`bold`,halign:`center`}},{content:e.participantName+(e.seedValue?` [${e.seedValue}]`:``),styles:{fontStyle:`bold`}},{content:e.nationality,styles:{halign:`center`}}];for(let e=0;e<s;e++)if(t===e)n.push({content:``,styles:{fillColor:Pr}});else{let r=l[t]?.[e];if(r){let e=r.isWin?Fr:Ir;n.push({content:r.score,styles:{halign:`center`,textColor:e}})}else n.push({content:``,styles:{halign:`center`}})}let r=l[t]?.filter(e=>e?.isWin).length||0,i=l[t]?.filter(e=>e&&!e.isWin).length||0;return n.push({content:`${r}`,styles:{halign:`center`,fontStyle:`bold`}}),n.push({content:`${i}`,styles:{halign:`center`}}),n});return(0,n.default)(e,{startY:a,head:[c],body:u,styles:{fontSize:7,cellPadding:1.5,lineWidth:.2,lineColor:[150,150,150]},headStyles:{fillColor:Lr,textColor:[255,255,255],fontStyle:`bold`,halign:`center`,fontSize:7},columnStyles:{0:{cellWidth:8},1:{cellWidth:`auto`},2:{cellWidth:12}},margin:{left:o.left,right:o.right}}),e.lastAutoTable?.finalY||a+40}function zr(e,t){let n=e.participants.length,r=Array.from({length:n},()=>Array(n).fill(null)),i=new Map;e.participants.forEach((e,t)=>i.set(e.groupPosition,t));for(let n of e.results){let e=i.get(n.rowPosition),a=i.get(n.colPosition);if(e===void 0||a===void 0)continue;let o=q(n.score,t),s=n.winningSide===1;r[e][a]={score:o,isWin:s},r[a][e]={score:Br(o),isWin:!s}}return r}function Br(e){return e.split(/\s+/).map(e=>{let t=e.match(/^(\d+)([/-])(\d+)(\(\d+\))?$/);return t?`${t[3]}${t[2]}${t[1]}${t[4]||``}`:e}).join(` `)}var Vr={East:{name:`East`,abbreviation:`E`},West:{name:`West`,abbreviation:`W`},North:{name:`North`,abbreviation:`N`},South:{name:`South`,abbreviation:`S`},Northeast:{name:`Northeast`,abbreviation:`NE`},Northwest:{name:`Northwest`,abbreviation:`NW`},Southeast:{name:`Southeast`,abbreviation:`SE`},Southwest:{name:`Southwest`,abbreviation:`SW`}};function Hr(e){let{drawDefinition:t,participants:n=[]}=e;if(!t)return{drawName:``,structures:[]};let r=new Map;n.forEach(e=>r.set(e.participantId,e));let i=[];for(let e of t.structures||[]){let t=e.structureName||``,n=Vr[t]||{name:t,abbreviation:t},a=e.positionAssignments||[],o=e.seedAssignments||[],s=a.length||0,c=a.map(e=>{let t=e.participantId?r.get(e.participantId):void 0,n=o.find(t=>t.participantId===e.participantId);return{drawPosition:e.drawPosition,participantName:t?H(t):``,nationality:t?U(t):``,seedValue:n?.seedValue,isBye:e.bye===!0}}),l=(e.matchUps||[]).map(e=>({roundNumber:e.roundNumber,roundPosition:e.roundPosition,drawPositions:e.drawPositions||[],score:e.score?.scoreStringSide1||``,winningSide:e.winningSide,matchUpStatus:e.matchUpStatus}));i.push({name:n.name,abbreviation:n.abbreviation,drawSize:s,slots:c,matchUps:l,totalRounds:s>0?Math.log2(s):0})}let a=i.find(e=>e.abbreviation===`E`);return{drawName:t.drawName||``,structures:i,mainStructure:a}}var Ur={slotWidth:90,slotHeight:14,roundGap:20,verticalGap:4,startX:15,startY:10};function Wr(e,t=Ur,n){let r=Math.log2(e),i=[],a=e,o=t.slotHeight+t.verticalGap;n&&a*o>n&&(o=n/a);let s=Math.max(o*.7,5);for(let n=0;n<r;n++){let r=e/2**(n+1),a=[];for(let e=0;e<r;e++){let r=2**n*o,i=t.startY+r/2-o/2+e*r*2,c=i+r,l=t.startX+n*(t.slotWidth+t.roundGap);a.push({x:l,y:i,width:t.slotWidth,height:s},{x:l,y:c,width:t.slotWidth,height:s})}i.push(a)}return i}function Gr(e,t){if(e.setDrawColor(150),e.setLineWidth(.3),e.rect(t.x,t.y,t.width,t.height),t.isBye){R(e,I.SMALL,F.ITALIC),e.setTextColor(150),e.text(`Bye`,t.x+2,t.y+t.height/2+1.5),e.setTextColor(0);return}t.participantName&&(t.seed?(R(e,I.TINY,F.BOLD),e.text(`[${t.seed}]`,t.x+1,t.y+t.height/2+1),R(e,I.SMALL,F.NORMAL),e.text(t.participantName,t.x+9,t.y+t.height/2+1)):(R(e,I.SMALL,F.NORMAL),e.text(t.participantName,t.x+2,t.y+t.height/2+1)),t.nationality&&(R(e,I.TINY,F.NORMAL),e.setTextColor(100),e.text(t.nationality,t.x+t.width-2,t.y+t.height/2+1,{align:`right`}),e.setTextColor(0)))}function Kr(e,t,n){e.setDrawColor(100),e.setLineWidth(.3);for(let r=0;r<t.length-1;r++){let i=t[r],a=t[r+1];for(let t=0;t<i.length;t+=2){let r=i[t],o=i[t+1],s=a[Math.floor(t/2)];if(!r||!o||!s)continue;let c=r.x+r.width,l=c+n.roundGap/2,u=r.y+r.height/2,d=o.y+o.height/2,f=s.y+s.height/2;e.line(c,u,l,u),e.line(c,d,l,d),e.line(l,u,l,d),e.line(l,f,s.x,f)}}}function qr(e,t,n,r){R(e,I.TINY,F.NORMAL),e.setTextColor(60,60,180),e.text(t,n,r),e.setTextColor(0)}function Jr(e,n={}){let{header:r,includeSeedings:i=!0,includeScores:a=!0}=n,o=e.drawSize>=32,s=new t.default({orientation:o?`landscape`:`portrait`,format:`a4`});L(s);let c=15;if(r){let t=`${e.drawName} - ${e.drawType.replace(/_/g,` `)} (${e.drawSize})`;c=W(s,{...r,subtitle:t})}return c=e.drawSize<=64&&e.drawSize>0?Yr(s,e,c,a):Xr(s,e,c),i&&e.seedAssignments.length>0&&Zr(s,e,c+8),G(s,`Generated ${new Date().toLocaleDateString()}`),s}function Yr(e,t,n,r){let i=e.internal.pageSize.getWidth(),a=e.internal.pageSize.getHeight(),o=i-30,s=a-n-30,c=t.totalRounds,l=Math.min(90,(o-c*10)/c),u=Math.min(14,s/t.drawSize),d={...Ur,slotWidth:l,slotHeight:u,verticalGap:Math.max(1,u*.3),startX:15,startY:n},f=Wr(t.drawSize,d,s),p=new Map(t.slots.map(e=>[e.drawPosition,e]));R(e,I.SMALL,F.BOLD);for(let t=0;t<c;t++){let r=d.startX+t*(d.slotWidth+d.roundGap),i=K(t+1,c);e.text(i,r+d.slotWidth/2,n-2,{align:`center`})}if(f.length>0){let n=f[0];for(let e=0;e<n.length;e++){let t=e+1,r=p.get(t);r&&(n[e].participantName=r.participantName,n[e].nationality=r.nationality,n[e].seed=r.seedValue,n[e].isBye=r.isBye)}for(let t of f)for(let n of t)Gr(e,n);if(Kr(e,f,d),r)for(let n of t.matchUps){if(!n.score)continue;let t=n.roundNumber-1;if(t<f.length){let r=(n.roundPosition-1)*2,i=f[t]?.[r];i&&qr(e,n.score,i.x+i.width+2,i.y+i.height+3)}}let i=f[0][f[0].length-1];return i.y+i.height+5}return n}function Xr(e,t,r){let i=[{header:`Pos`,dataKey:`pos`},{header:`Seed`,dataKey:`seed`},{header:`Player`,dataKey:`name`},{header:`Nat.`,dataKey:`nat`},{header:`Entry`,dataKey:`entry`}],a=t.slots.map(e=>({pos:e.drawPosition,seed:e.seedValue?.toString()||``,name:e.isBye?`Bye`:e.participantName,nat:e.nationality,entry:e.entryStatus||``}));return(0,n.default)(e,{...vt.compact,startY:r,columns:i,body:a,columnStyles:{pos:{cellWidth:12,halign:`center`},seed:{cellWidth:12,halign:`center`},name:{cellWidth:`auto`},nat:{cellWidth:15,halign:`center`},entry:{cellWidth:15,halign:`center`}}}),e.lastAutoTable?.finalY||r+20}function Zr(e,t,r){R(e,I.HEADING,F.BOLD),e.text(`Seeded Players`,15,r),r+=4;let i=[{header:`Seed`,dataKey:`seed`},{header:`Player`,dataKey:`name`},{header:`Nat.`,dataKey:`nat`}],a=t.seedAssignments.map(e=>({seed:e.seedValue,name:e.participantName,nat:e.nationality}));return(0,n.default)(e,{...vt.compact,startY:r,columns:i,body:a,tableWidth:120,columnStyles:{seed:{cellWidth:15,halign:`center`,fontStyle:`bold`},name:{cellWidth:`auto`},nat:{cellWidth:20,halign:`center`}}}),e.lastAutoTable?.finalY||r+20}function Qr(e,r={}){let{header:i,fullCourtNames:a=!0,notes:o}=r,s=(r.landscape===`auto`?e.courts.length>=5:r.landscape)?`landscape`:`portrait`,c=new t.default({orientation:s,format:`a4`});L(c);let l=15;if(i){let t=e.scheduledDate?`Order of Play - ${e.scheduledDate}`:`Order of Play`;l=W(c,{...i,subtitle:t})}let u=e.courts,d=a?u:u.map(ei);for(let t of e.timeSlots){R(c,I.BODY,F.BOLD),c.setTextColor(30,60,120),c.text(t.label,15,l),c.setTextColor(0),l+=4;let e=d.map(e=>({header:e,dataKey:e})),r=new Map;u.forEach(e=>r.set(e,[]));for(let e of t.matches){let t=$r(e),n=r.get(e.courtName)||[];n.push(t),r.set(e.courtName,n)}let o=Math.max(1,...Array.from(r.values()).map(e=>e.length)),s=[];for(let e=0;e<o;e++){let t={};u.forEach((n,i)=>{let o=r.get(n)||[],s=a?n:d[i];t[s]=o[e]||``}),s.push(t)}(0,n.default)(c,{...vt.schedule,startY:l,columns:e,body:s,tableWidth:`auto`,didDrawPage:e=>{G(c,i?.tournamentName||``,e.pageNumber)}}),l=c.lastAutoTable?.finalY+6||l+20}if(o?.length){l+=4,R(c,I.SMALL,F.ITALIC),c.setTextColor(80);for(let e of o)c.text(e,15,l),l+=4;c.setTextColor(0)}return c}function $r(e){let t=[];return t.push(`${e.eventAbbr} ${e.roundName}`),t.push(`${e.side1.name} (${e.side1.nationality})`),t.push(`vs ${e.side2.name} (${e.side2.nationality})`),e.score&&t.push(e.score),t.join(`
|
|
5
|
+
`)}function ei(e){return e.replace(/^Court\s*/i,`Ct `)}var ti=`print`;function ni(e){let{providerConfig:t,tournamentRecord:n,printType:r,runtime:i}=e;return ri(ri(t?.providerConfigSettings?.policies?.printPolicies?.[r]??{},(n?.extensions?.find(e=>e.name===ti))?.value?.[r]??{}),i??{})}function ri(e,t){let n={...e};for(let e of Object.keys(t)){let r=t[e];if(r===void 0)continue;let i=n[e];n[e]=ii(i)&&ii(r)?ri(i,r):r}return n}function ii(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getPrototypeOf(e)===Object.prototype}var ai=[120,50,140];function oi(e,t={}){let n={pageSize:t.page?.pageSize||`a4`,orientation:t.page?.orientation||`portrait`,margins:t.page?.margins||{top:12,right:15,bottom:12,left:15}},r=xe(n),{margins:i}=n,a=r.internal.pageSize.getWidth(),o=r.internal.pageSize.getHeight(),s=a-i.left-i.right,c=t.accentColor||ai,l=t.footer||{layout:`none`},u=V(l),d=i.top;t.header&&(d=i.top+B(r,t.header,n)+3);let f=di(e);for(let[e,a]of f){d+30>o-i.bottom-u&&(fi(r,t,n,l),r.addPage(),d=i.top),d=si(r,e,i.left,d,s);let f=``;for(let e of a){let a=e.scheduledTime||e.notBeforeTime||``;a&&a!==f&&(d+25>o-i.bottom-u&&(fi(r,t,n,l),r.addPage(),d=i.top),d=ci(r,a,!!e.notBeforeTime,i.left,d,s,c),f=a),d+22>o-i.bottom-u&&(fi(r,t,n,l),r.addPage(),d=i.top),d=li(r,e,i.left,d,s)}d+=4}return t.disclaimer&&(d+=2,R(r,I.TINY,F.ITALIC),r.setTextColor(100),r.text(t.disclaimer,a/2,d,{align:`center`}),r.setTextColor(0)),fi(r,t,n,l),r}function si(e,t,n,r,i){return R(e,I.HEADING,F.BOLD),e.setTextColor(40),e.text(t.toUpperCase(),n+i/2,r,{align:`center`}),e.setTextColor(0),r+7}function ci(e,t,n,r,i,a,o){let s=n?`Not before ${t}`:`Starting at ${t}`;return e.setFillColor(o[0],o[1],o[2]),e.rect(r+20,i,a-40,5,`F`),R(e,I.SMALL,F.ITALIC),e.setTextColor(255,255,255),e.text(s,r+a/2,i+3.5,{align:`center`}),e.setTextColor(0),i+7}function li(e,t,n,r,i){let a=n+15,o=i-30,s=r;R(e,I.TINY,F.ITALIC),e.setTextColor(100);let c=t.eventAbbr?`${t.eventAbbr} ${t.roundName}`:t.roundName;e.text(c,a+o-2,r+3,{align:`right`}),e.setTextColor(0),t.score&&(R(e,I.SMALL,F.BOLD),e.setTextColor(120,50,140),e.text(t.score,a+o/2,r+3,{align:`center`}),e.setTextColor(0),r+=4),r+=2,r=ui(e,t.side1,a,r,o),R(e,I.TINY,F.ITALIC),e.setTextColor(120),e.text(`vs`,a+o/2,r+2.5,{align:`center`}),e.setTextColor(0),r+=4,r=ui(e,t.side2,a,r,o),r+=2;let l=r-s;return e.setDrawColor(180),e.setLineWidth(.3),e.rect(a,s,o,l),r+2}function ui(e,t,n,r,i){if(!t.name||t.name===`TBD`)return R(e,I.BODY,F.ITALIC),e.setTextColor(150),e.text(`TBD`,n+10,r+3),e.setTextColor(0),r+4;R(e,I.BODY,F.NORMAL);let a=t.nationality?`${t.name} ${t.nationality}`:t.name;return e.text(a,n+10,r+3),r+4}function di(e){let t=new Map;for(let n of e.courts)t.set(n,[]);for(let n of e.timeSlots)for(let e of n.matches)t.has(e.courtName)||t.set(e.courtName,[]),t.get(e.courtName).push(e);for(let[e,n]of t)n.length===0&&t.delete(e);return t}function fi(e,t,n,r){let{margins:i}=n,a=e.internal.pageSize.getWidth(),o=e.internal.pageSize.getHeight();if(t.officials?.length){let n=o-i.bottom-10;e.setDrawColor(120),e.setLineWidth(.2),e.line(i.left,n-2,a-i.right,n-2);let r=(a-i.left-i.right)/t.officials.length;t.officials.forEach((t,a)=>{let o=i.left+a*r;R(e,I.TINY,F.BOLD),e.text(t.role,o,n),R(e,I.TINY,F.NORMAL),e.text(t.name,o,n+3)})}ze(e,r,n)}var pi=.2645833;function mi(e){let t={};for(let n of e){let e={};n.type===`number`&&(e.halign=`right`),n.width?e.cellWidth=Math.round(n.width*pi*10)/10:n.fitData&&(e.cellWidth=`wrap`),Object.keys(e).length&&(t[n.key]=e)}return t}function hi(e,r,i={}){let a=i.orientation||`landscape`,o=new t.default({orientation:a,format:`a4`});L(o);let s=15;if(i.header?s=W(o,{...i.header,subtitle:i.header.subtitle||i.title}):i.title&&(R(o,I.SUBTITLE,F.BOLD),o.text(i.title,15,s),s+=8),e.length===0)return R(o,I.BODY,F.ITALIC),o.text(`No columns defined`,15,s),G(o,`Generated ${new Date().toLocaleDateString()}`,1),o;let c=e.map(e=>({header:e.title,dataKey:e.key})),l=r.map(t=>{let n={};for(let r of e){let e=t[r.key];n[r.key]=e==null?``:String(e)}return n}),u=mi(e);return(0,n.default)(o,{...vt.report,startY:s,columns:c,body:l,columnStyles:u,didDrawPage:e=>{G(o,`Generated ${new Date().toLocaleDateString()}`,e.pageNumber)}}),o}var Z=15;function gi(e){if(typeof document<`u`){let t=document.createElement(`div`);return t.innerHTML=e,t.textContent||``}let t=``,n=!1;for(let r of e){if(r===`<`){n=!0;continue}if(r===`>`){n=!1;continue}n||(t+=r)}return t.trim()}function Q(e,t,n){return R(e,I.HEADING,F.BOLD),e.setTextColor(40),e.text(t.toUpperCase(),Z,n),e.setTextColor(0),n+=1.5,e.setDrawColor(180),e.setLineWidth(.2),e.line(Z,n,e.internal.pageSize.getWidth()-Z,n),n+=4,n}function _i(e,t,n,r){R(e,I.BODY,F.NORMAL);let i=r||e.internal.pageSize.getWidth()-30,a=e.splitTextToSize(t,i);return e.text(a,Z,n),n+a.length*3.2}function $(e,t,n){let r=e.internal.pageSize.getHeight();return t+n>r-20?(e.addPage(),20):t}function vi(e,t,n){let r={pageSize:`a4`,orientation:`portrait`,margins:{top:n,right:Z,bottom:15,left:Z}};return n+B(e,Le(t,{layout:`itf`}),r)}function yi(e,t,r){let i=(t.participants||[]).filter(e=>e.participantRole&&e.participantRole!==`COMPETITOR`);if(!i.length)return r;r=$(e,r,20),r=Q(e,`Tournament Contacts`,r);let a=i.map(e=>{let t=e.person||{},n=[t.standardGivenName,t.standardFamilyName].filter(Boolean).join(` `)||e.participantName||``,r=e.participantRoleResponsibilities?.[0]||e.participantRole||``,i=t.contacts?.[0]||{};return[n,r,[i.emailAddress,i.telephone||i.mobileTelephone].filter(Boolean).join(` | `)]});return(0,n.default)(e,{startY:r,head:[[`Name`,`Role`,`Contact`]],body:a,margin:{left:Z,right:Z},styles:{fontSize:7,cellPadding:1.5},headStyles:{fillColor:[60,60,60],textColor:255,fontStyle:`bold`},theme:`grid`}),e.lastAutoTable.finalY+6}function bi(e,t,r){let i=t.events||[];if(!i.length)return r;r=$(e,r,20),r=Q(e,`Events`,r);let a=i.map(e=>{let t=e.drawDefinitions?.[0]?.drawSize||``;return[e.eventName||``,e.eventType||``,e.matchUpFormat||``,String(t)]});return(0,n.default)(e,{startY:r,head:[[`Event`,`Type`,`Format`,`Draw Size`]],body:a,margin:{left:Z,right:Z},styles:{fontSize:7,cellPadding:1.5},headStyles:{fillColor:[60,60,60],textColor:255,fontStyle:`bold`},theme:`grid`}),e.lastAutoTable.finalY+6}function xi(e,t,n){let r=t.registrationProfile;if(!r)return n;let i=[];if(r.entriesOpen&&i.push(`Entries Open: `+r.entriesOpen),r.entriesClose&&i.push(`Entries Close: `+r.entriesClose),r.withdrawalDeadline&&i.push(`Withdrawal Deadline: `+r.withdrawalDeadline),r.entryMethod&&i.push(`Entry Method: `+r.entryMethod),r.entryUrl&&i.push(`Entry URL: `+r.entryUrl),r.eligibilityNotes&&i.push(`Eligibility: `+r.eligibilityNotes),r.entryFees?.length){let e=r.entryFees.map(e=>(e.eventType?e.eventType+`: `:``)+e.currencyCode+` `+e.amount).join(`, `);i.push(`Entry Fees: `+e)}if(!i.length)return n;n=$(e,n,10+i.length*3.5),n=Q(e,`Entry Information`,n),R(e,I.BODY,F.NORMAL);for(let t of i)e.text(t,Z,n),n+=3.5;return n+3}function Si(e,t,n){let r=t.venues||[];if(!r.length)return n;n=$(e,n,15),n=Q(e,`Venue`,n),R(e,I.BODY,F.NORMAL);for(let t of r){R(e,I.BODY,F.BOLD),e.text(t.venueName||`Venue`,Z,n),n+=3.5,R(e,I.BODY,F.NORMAL);let r=t.addresses?.[0];if(r){let t=[r.street,r.city,r.state,r.postalCode,r.countryCode].filter(Boolean);t.length&&(e.text(t.join(`, `),Z,n),n+=3.5)}let i=t.courts?.length;i&&(e.text(`Courts: `+i,Z,n),n+=3.5)}return n+3}function Ci(e,t,r,i){if(!r)return i;let a=r.options?.length,o=r.notes&&gi(r.notes);if(!a&&!o)return i;if(i=$(e,i,15),i=Q(e,t,i),a){let t=r.options.map(e=>{let t=[e.phone,e.email,e.priceRange].filter(Boolean).join(` | `);return[e.name,e.address||``,t]});(0,n.default)(e,{startY:i,head:[[`Name`,`Address`,`Details`]],body:t,margin:{left:Z,right:Z},styles:{fontSize:7,cellPadding:1.5},headStyles:{fillColor:[60,60,60],textColor:255,fontStyle:`bold`},theme:`grid`}),i=e.lastAutoTable.finalY+3}return o&&(i=_i(e,gi(r.notes),i)),i+3}function wi(e,t,n){let r=t.totalPrizeMoney;if(!r?.length)return n;n=$(e,n,10),n=Q(e,`Prize Money`,n),R(e,I.BODY,F.NORMAL);for(let t of r)e.text(t.currencyCode+` `+t.amount.toLocaleString(),Z,n),n+=3.5;return n+3}function Ti(e,t,r){let i=(t.participants||[]).filter(e=>e.participantRole===`OFFICIAL`||e.participantRole===`DIRECTOR`);if(!i.length)return r;r=$(e,r,15),r=Q(e,`Officials`,r);let a=i.map(e=>{let t=e.person||{};return[[t.standardGivenName,t.standardFamilyName].filter(Boolean).join(` `)||e.participantName||``,e.participantRoleResponsibilities?.[0]||e.participantRole||``]});return(0,n.default)(e,{startY:r,head:[[`Name`,`Role`]],body:a,margin:{left:Z,right:Z},styles:{fontSize:7,cellPadding:1.5},headStyles:{fillColor:[60,60,60],textColor:255,fontStyle:`bold`},theme:`grid`}),e.lastAutoTable.finalY+6}function Ei(e,t,n){let r=t.registrationProfile;if(!r)return n;let i=[];if(r.codeOfConduct){let e=r.codeOfConduct;i.push(`Code of Conduct: `+(e.name||``)+(e.url?` — `+e.url:``))}if(r.regulations?.length)for(let e of r.regulations)i.push((e.name||`Regulation`)+(e.url?` — `+e.url:``));if(r.dressCode&&i.push(`Dress Code: `+r.dressCode),r.contingencyPlan&&i.push(`Contingency: `+r.contingencyPlan),!i.length)return n;n=$(e,n,10+i.length*3.5),n=Q(e,`Regulations`,n),R(e,I.BODY,F.NORMAL);for(let t of i)e.text(t,Z,n),n+=3.5;return n+3}function Di(e,t,n){let r=t.registrationProfile?.sponsors;if(!r?.length)return n;n=$(e,n,10),n=Q(e,`Sponsors`,n),R(e,I.BODY,F.NORMAL);for(let t of r){let r=t.tier?` [`+t.tier+`]`:``;e.text(t.name+r,Z,n),n+=3.5}return n+3}function Oi(e,t,n){let r=t.registrationProfile?.socialEvents;if(!r?.length)return n;let i=t.registrationProfile;n=$(e,n,15),n=Q(e,`Social Events & Ceremonies`,n),R(e,I.BODY,F.NORMAL),i?.drawCeremonyDate&&(e.text(`Draw Ceremony: `+i.drawCeremonyDate,Z,n),n+=3.5),i?.awardsCeremonyDate&&(e.text(`Awards Ceremony: `+i.awardsCeremonyDate,Z,n),n+=3.5);for(let t of r){R(e,I.BODY,F.BOLD),e.text(t.name,Z,n),n+=3.5,R(e,I.BODY,F.NORMAL);let r=[t.date,t.time,t.location].filter(Boolean).join(` | `);r&&(e.text(r,Z,n),n+=3.5),t.description&&(e.text(t.description,Z,n),n+=3.5)}return n+3}function ki(e,t,n){let r=t.notes;if(!r)return n;let i=gi(r);return i?(n=$(e,n,15),n=Q(e,`Additional Information`,n),n=_i(e,i,n),n+3):n}var Ai={"tournament-header":vi,contacts:yi,events:bi,"entry-info":xi,"venue-info":Si,accommodation:(e,t,n)=>Ci(e,`Accommodation`,t.registrationProfile?.accommodation,n),transportation:(e,t,n)=>Ci(e,`Transportation`,t.registrationProfile?.transportation,n),hospitality:(e,t,n)=>Ci(e,`Hospitality`,t.registrationProfile?.hospitality,n),medical:(e,t,n)=>Ci(e,`Medical`,t.registrationProfile?.medicalInfo,n),regulations:Ei,"prize-money":wi,officials:Ti,sponsors:Di,"social-events":Oi,"custom-notes":ki};function ji(e,n={}){let{templateId:r=`itf-junior`}=n,i=de(r)?.sections||de(`itf-junior`).sections,a=n.enabledSections?new Set(n.enabledSections):null,o=new t.default({orientation:`portrait`,format:`a4`});L(o);let s=Z;for(let t of i){if(!t.enabled||a&&!a.has(t.type))continue;let n=Ai[t.type];n&&(s=n(o,e,s))}let c=o.getNumberOfPages();for(let e=1;e<=c;e++)o.setPage(e),G(o,`Generated `+new Date().toLocaleDateString(),e);return o}function Mi(e,t={}){let n=e?.drawsData||[],r=e?.tournamentInfo||{},i=e?.eventInfo||{},a=C(t.catalogPreset||`club-basic`),o=g(a?.drawFormatPreset||`itfJunior`),s={layout:`itf`,tournamentName:r.tournamentName||`Tournament`,...a?.header,subtitle:i.eventName||a?.header?.subtitle,startDate:r.startDate,endDate:r.endDate,location:r.venues?.[0]?.venueName,city:r.venues?.[0]?.city,country:r.hostCountryCode,surface:i.surfaceCategory,...t.headerOverrides},c={layout:`standard`,showPageNumbers:!0,showTimestamp:!0,...a?.footer,...t.footerOverrides},l=n?.[0]?.structures||[],u=l.some(e=>e.stage===`CONSOLATION`),d=l.some(e=>e.stage===`PLAY_OFF`),f=l.find(e=>e.stage===`MAIN`),p={header:s,footer:c,format:o};if(u&&d)return ir({winnersBracket:f?N(f):Ni(),losersBracket:P(n,`CONSOLATION`)?N(P(n,`CONSOLATION`)):Ni(),deciderMatch:P(n,`PLAY_OFF`)?N(P(n,`PLAY_OFF`)):void 0},p);if(u)return er(l.map(e=>({name:e.structureName,stage:e.stage,drawData:N(e)})),p);let m=t.structureId&&l.find(e=>e.structureId===t.structureId)||f;if(!m)return xe({pageSize:`a4`,orientation:`portrait`,margins:{top:12,right:15,bottom:12,left:15}});let h=N(m);return t.mirrored?nr(h,p):t.splitPages||h.drawSize>=256?Qn(h,{...p,maxPositionsPerPage:t.maxPositionsPerPage||32}):Zn(h,p)}function Ni(){return{drawName:``,drawSize:0,drawType:``,totalRounds:0,slots:[],matchUps:[],seedAssignments:[]}}exports.COMPOSITION_CATALOG=S,exports.DRAW_MODAL_TABS=jr,exports.FACT_SHEET_CATALOG=ue,exports.FONT=pe,exports.FOOTER_LAYOUT_OPTIONS=Dr,exports.HEADER_LAYOUT_OPTIONS=Er,exports.ORIENTATION_OPTIONS=kr,exports.PAGE_SIZE_OPTIONS=Or,exports.PRESETS=h,exports.SCHEDULE_MODAL_TABS=Mr,exports.SIZE=I,exports.SPLIT_STRATEGY_OPTIONS=Ar,exports.STYLE=F,exports.TABLE_STYLES=vt,exports.activeFontFamily=_e,exports.applyDefaultFont=L,exports.buildFooterFromTournament=Re,exports.buildHeaderFromTournament=Le,exports.calculateBracketPositions=Wr,exports.createDoc=xe,exports.drawBracketConnectors=Kr,exports.drawBracketSlot=Gr,exports.drawPageFooter=G,exports.drawTournamentHeader=W,exports.entryStatusDisplay=Qe,exports.eventAbbreviation=nt,exports.executePrint=cr,exports.extractCompassData=Hr,exports.extractConsolationStructures=Pn,exports.extractCourtCardData=ct,exports.extractDrawData=Et,exports.extractParticipantData=ot,exports.extractRoundRobinData=Nr,exports.extractScheduleData=it,exports.findStructure=P,exports.formatDate=et,exports.formatMatchScore=q,exports.formatPlayerEntry=kt,exports.formatScore=$e,exports.formatTime=tt,exports.generateBackdrawPDF=rr,exports.generateCompassDrawPDF=tr,exports.generateConsolationDrawPDF=er,exports.generateCourtCardPDF=xt,exports.generateDoubleEliminationPDF=ir,exports.generateDrawPDF=Yn,exports.generateDrawSheetPDF=Jr,exports.generateFactSheet=ji,exports.generateFeedInDrawPDF=$n,exports.generateFromEventData=Mi,exports.generateLuckyDrawPDF=ar,exports.generateMatchCardPDF=Ct,exports.generateMirroredDrawPDF=nr,exports.generateOrderOfPlayPDF=dt,exports.generateScheduleV2PDF=dt,exports.generatePlayerListPDF=yt,exports.generateReportPDF=hi,exports.generateSchedulePDF=Qr,exports.generateSequentialOOP=oi,exports.generateSignInSheetPDF=bt,exports.generateSplitDrawPDF=Qn,exports.generateTraditionalDrawPDF=Zn,exports.getCatalogPreset=C,exports.getDefaultFont=be,exports.getDefaultPageConfig=Se,exports.getFactSheetTemplate=de,exports.getPageRegions=z,exports.getPreset=g,exports.getRoundLabel=K,exports.listCatalogPresets=ee,exports.listFactSheetTemplates=fe,exports.measureFooterHeight=V,exports.measureSeedingsHeight=Xe,exports.mergeCatalogPreset=te,exports.mergePreset=_,exports.nationality=U,exports.participantName=H,exports.registerFont=ge,exports.renderCompassDraw=jn,exports.renderConsolationDraw=Fn,exports.renderDoubleEliminationDraw=In,exports.renderFooter=ze,exports.renderHeader=B,exports.renderLuckyDraw=Vn,exports.renderRoundRobinGroup=Rr,exports.renderSeedingsFooter=Je,exports.renderTraditionalDraw=J,exports.resolveCompositionConfig=ni,exports.roundName=rt,exports.seedDisplay=Ze,exports.setDefaultFont=ye,exports.setFont=R,exports.splitDraw=Wn,exports.structureToDrawData=N;
|
|
6
6
|
//# sourceMappingURL=pdf-factory.cjs.map
|