pdf.js 655 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905
  1. /**
  2. * @licstart The following is the entire license notice for the
  3. * JavaScript code in this page
  4. *
  5. * Copyright 2023 Mozilla Foundation
  6. *
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. *
  19. * @licend The above is the entire license notice for the
  20. * JavaScript code in this page
  21. */
  22. (function webpackUniversalModuleDefinition(root, factory) {
  23. if(typeof exports === 'object' && typeof module === 'object')
  24. module.exports = factory();
  25. else if(typeof define === 'function' && define.amd)
  26. define("pdfjs-dist/build/pdf", [], factory);
  27. else if(typeof exports === 'object')
  28. exports["pdfjs-dist/build/pdf"] = factory();
  29. else
  30. root["pdfjs-dist/build/pdf"] = root.pdfjsLib = factory();
  31. })(globalThis, () => {
  32. return /******/ (() => { // webpackBootstrap
  33. /******/ var __webpack_modules__ = ([
  34. /* 0 */,
  35. /* 1 */
  36. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  37. "use strict";
  38. Object.defineProperty(exports, "__esModule", ({
  39. value: true
  40. }));
  41. exports.VerbosityLevel = exports.Util = exports.UnknownErrorException = exports.UnexpectedResponseException = exports.UNSUPPORTED_FEATURES = exports.TextRenderingMode = exports.RenderingIntentFlag = exports.PermissionFlag = exports.PasswordResponses = exports.PasswordException = exports.PageActionEventType = exports.OPS = exports.MissingPDFException = exports.LINE_FACTOR = exports.LINE_DESCENT_FACTOR = exports.InvalidPDFException = exports.ImageKind = exports.IDENTITY_MATRIX = exports.FormatError = exports.FeatureTest = exports.FONT_IDENTITY_MATRIX = exports.DocumentActionEventType = exports.CMapCompressionType = exports.BaseException = exports.BASELINE_FACTOR = exports.AnnotationType = exports.AnnotationStateModelType = exports.AnnotationReviewState = exports.AnnotationReplyType = exports.AnnotationMode = exports.AnnotationMarkedState = exports.AnnotationFlag = exports.AnnotationFieldFlag = exports.AnnotationEditorType = exports.AnnotationEditorPrefix = exports.AnnotationEditorParamsType = exports.AnnotationBorderStyleType = exports.AnnotationActionEventType = exports.AbortException = void 0;
  42. exports.assert = assert;
  43. exports.bytesToString = bytesToString;
  44. exports.createPromiseCapability = createPromiseCapability;
  45. exports.createValidAbsoluteUrl = createValidAbsoluteUrl;
  46. exports.getModificationDate = getModificationDate;
  47. exports.getVerbosityLevel = getVerbosityLevel;
  48. exports.info = info;
  49. exports.isArrayBuffer = isArrayBuffer;
  50. exports.isArrayEqual = isArrayEqual;
  51. exports.objectFromMap = objectFromMap;
  52. exports.objectSize = objectSize;
  53. exports.setVerbosityLevel = setVerbosityLevel;
  54. exports.shadow = shadow;
  55. exports.string32 = string32;
  56. exports.stringToBytes = stringToBytes;
  57. exports.stringToPDFString = stringToPDFString;
  58. exports.stringToUTF8String = stringToUTF8String;
  59. exports.unreachable = unreachable;
  60. exports.utf8StringToString = utf8StringToString;
  61. exports.warn = warn;
  62. if (!globalThis._pdfjsCompatibilityChecked) {
  63. globalThis._pdfjsCompatibilityChecked = true;
  64. __w_pdfjs_require__(2);
  65. }
  66. const IDENTITY_MATRIX = [1, 0, 0, 1, 0, 0];
  67. exports.IDENTITY_MATRIX = IDENTITY_MATRIX;
  68. const FONT_IDENTITY_MATRIX = [0.001, 0, 0, 0.001, 0, 0];
  69. exports.FONT_IDENTITY_MATRIX = FONT_IDENTITY_MATRIX;
  70. const LINE_FACTOR = 1.35;
  71. exports.LINE_FACTOR = LINE_FACTOR;
  72. const LINE_DESCENT_FACTOR = 0.35;
  73. exports.LINE_DESCENT_FACTOR = LINE_DESCENT_FACTOR;
  74. const BASELINE_FACTOR = LINE_DESCENT_FACTOR / LINE_FACTOR;
  75. exports.BASELINE_FACTOR = BASELINE_FACTOR;
  76. const RenderingIntentFlag = {
  77. ANY: 0x01,
  78. DISPLAY: 0x02,
  79. PRINT: 0x04,
  80. SAVE: 0x08,
  81. ANNOTATIONS_FORMS: 0x10,
  82. ANNOTATIONS_STORAGE: 0x20,
  83. ANNOTATIONS_DISABLE: 0x40,
  84. OPLIST: 0x100
  85. };
  86. exports.RenderingIntentFlag = RenderingIntentFlag;
  87. const AnnotationMode = {
  88. DISABLE: 0,
  89. ENABLE: 1,
  90. ENABLE_FORMS: 2,
  91. ENABLE_STORAGE: 3
  92. };
  93. exports.AnnotationMode = AnnotationMode;
  94. const AnnotationEditorPrefix = "pdfjs_internal_editor_";
  95. exports.AnnotationEditorPrefix = AnnotationEditorPrefix;
  96. const AnnotationEditorType = {
  97. DISABLE: -1,
  98. NONE: 0,
  99. FREETEXT: 3,
  100. INK: 15
  101. };
  102. exports.AnnotationEditorType = AnnotationEditorType;
  103. const AnnotationEditorParamsType = {
  104. FREETEXT_SIZE: 1,
  105. FREETEXT_COLOR: 2,
  106. FREETEXT_OPACITY: 3,
  107. INK_COLOR: 11,
  108. INK_THICKNESS: 12,
  109. INK_OPACITY: 13
  110. };
  111. exports.AnnotationEditorParamsType = AnnotationEditorParamsType;
  112. const PermissionFlag = {
  113. PRINT: 0x04,
  114. MODIFY_CONTENTS: 0x08,
  115. COPY: 0x10,
  116. MODIFY_ANNOTATIONS: 0x20,
  117. FILL_INTERACTIVE_FORMS: 0x100,
  118. COPY_FOR_ACCESSIBILITY: 0x200,
  119. ASSEMBLE: 0x400,
  120. PRINT_HIGH_QUALITY: 0x800
  121. };
  122. exports.PermissionFlag = PermissionFlag;
  123. const TextRenderingMode = {
  124. FILL: 0,
  125. STROKE: 1,
  126. FILL_STROKE: 2,
  127. INVISIBLE: 3,
  128. FILL_ADD_TO_PATH: 4,
  129. STROKE_ADD_TO_PATH: 5,
  130. FILL_STROKE_ADD_TO_PATH: 6,
  131. ADD_TO_PATH: 7,
  132. FILL_STROKE_MASK: 3,
  133. ADD_TO_PATH_FLAG: 4
  134. };
  135. exports.TextRenderingMode = TextRenderingMode;
  136. const ImageKind = {
  137. GRAYSCALE_1BPP: 1,
  138. RGB_24BPP: 2,
  139. RGBA_32BPP: 3
  140. };
  141. exports.ImageKind = ImageKind;
  142. const AnnotationType = {
  143. TEXT: 1,
  144. LINK: 2,
  145. FREETEXT: 3,
  146. LINE: 4,
  147. SQUARE: 5,
  148. CIRCLE: 6,
  149. POLYGON: 7,
  150. POLYLINE: 8,
  151. HIGHLIGHT: 9,
  152. UNDERLINE: 10,
  153. SQUIGGLY: 11,
  154. STRIKEOUT: 12,
  155. STAMP: 13,
  156. CARET: 14,
  157. INK: 15,
  158. POPUP: 16,
  159. FILEATTACHMENT: 17,
  160. SOUND: 18,
  161. MOVIE: 19,
  162. WIDGET: 20,
  163. SCREEN: 21,
  164. PRINTERMARK: 22,
  165. TRAPNET: 23,
  166. WATERMARK: 24,
  167. THREED: 25,
  168. REDACT: 26
  169. };
  170. exports.AnnotationType = AnnotationType;
  171. const AnnotationStateModelType = {
  172. MARKED: "Marked",
  173. REVIEW: "Review"
  174. };
  175. exports.AnnotationStateModelType = AnnotationStateModelType;
  176. const AnnotationMarkedState = {
  177. MARKED: "Marked",
  178. UNMARKED: "Unmarked"
  179. };
  180. exports.AnnotationMarkedState = AnnotationMarkedState;
  181. const AnnotationReviewState = {
  182. ACCEPTED: "Accepted",
  183. REJECTED: "Rejected",
  184. CANCELLED: "Cancelled",
  185. COMPLETED: "Completed",
  186. NONE: "None"
  187. };
  188. exports.AnnotationReviewState = AnnotationReviewState;
  189. const AnnotationReplyType = {
  190. GROUP: "Group",
  191. REPLY: "R"
  192. };
  193. exports.AnnotationReplyType = AnnotationReplyType;
  194. const AnnotationFlag = {
  195. INVISIBLE: 0x01,
  196. HIDDEN: 0x02,
  197. PRINT: 0x04,
  198. NOZOOM: 0x08,
  199. NOROTATE: 0x10,
  200. NOVIEW: 0x20,
  201. READONLY: 0x40,
  202. LOCKED: 0x80,
  203. TOGGLENOVIEW: 0x100,
  204. LOCKEDCONTENTS: 0x200
  205. };
  206. exports.AnnotationFlag = AnnotationFlag;
  207. const AnnotationFieldFlag = {
  208. READONLY: 0x0000001,
  209. REQUIRED: 0x0000002,
  210. NOEXPORT: 0x0000004,
  211. MULTILINE: 0x0001000,
  212. PASSWORD: 0x0002000,
  213. NOTOGGLETOOFF: 0x0004000,
  214. RADIO: 0x0008000,
  215. PUSHBUTTON: 0x0010000,
  216. COMBO: 0x0020000,
  217. EDIT: 0x0040000,
  218. SORT: 0x0080000,
  219. FILESELECT: 0x0100000,
  220. MULTISELECT: 0x0200000,
  221. DONOTSPELLCHECK: 0x0400000,
  222. DONOTSCROLL: 0x0800000,
  223. COMB: 0x1000000,
  224. RICHTEXT: 0x2000000,
  225. RADIOSINUNISON: 0x2000000,
  226. COMMITONSELCHANGE: 0x4000000
  227. };
  228. exports.AnnotationFieldFlag = AnnotationFieldFlag;
  229. const AnnotationBorderStyleType = {
  230. SOLID: 1,
  231. DASHED: 2,
  232. BEVELED: 3,
  233. INSET: 4,
  234. UNDERLINE: 5
  235. };
  236. exports.AnnotationBorderStyleType = AnnotationBorderStyleType;
  237. const AnnotationActionEventType = {
  238. E: "Mouse Enter",
  239. X: "Mouse Exit",
  240. D: "Mouse Down",
  241. U: "Mouse Up",
  242. Fo: "Focus",
  243. Bl: "Blur",
  244. PO: "PageOpen",
  245. PC: "PageClose",
  246. PV: "PageVisible",
  247. PI: "PageInvisible",
  248. K: "Keystroke",
  249. F: "Format",
  250. V: "Validate",
  251. C: "Calculate"
  252. };
  253. exports.AnnotationActionEventType = AnnotationActionEventType;
  254. const DocumentActionEventType = {
  255. WC: "WillClose",
  256. WS: "WillSave",
  257. DS: "DidSave",
  258. WP: "WillPrint",
  259. DP: "DidPrint"
  260. };
  261. exports.DocumentActionEventType = DocumentActionEventType;
  262. const PageActionEventType = {
  263. O: "PageOpen",
  264. C: "PageClose"
  265. };
  266. exports.PageActionEventType = PageActionEventType;
  267. const VerbosityLevel = {
  268. ERRORS: 0,
  269. WARNINGS: 1,
  270. INFOS: 5
  271. };
  272. exports.VerbosityLevel = VerbosityLevel;
  273. const CMapCompressionType = {
  274. NONE: 0,
  275. BINARY: 1
  276. };
  277. exports.CMapCompressionType = CMapCompressionType;
  278. const OPS = {
  279. dependency: 1,
  280. setLineWidth: 2,
  281. setLineCap: 3,
  282. setLineJoin: 4,
  283. setMiterLimit: 5,
  284. setDash: 6,
  285. setRenderingIntent: 7,
  286. setFlatness: 8,
  287. setGState: 9,
  288. save: 10,
  289. restore: 11,
  290. transform: 12,
  291. moveTo: 13,
  292. lineTo: 14,
  293. curveTo: 15,
  294. curveTo2: 16,
  295. curveTo3: 17,
  296. closePath: 18,
  297. rectangle: 19,
  298. stroke: 20,
  299. closeStroke: 21,
  300. fill: 22,
  301. eoFill: 23,
  302. fillStroke: 24,
  303. eoFillStroke: 25,
  304. closeFillStroke: 26,
  305. closeEOFillStroke: 27,
  306. endPath: 28,
  307. clip: 29,
  308. eoClip: 30,
  309. beginText: 31,
  310. endText: 32,
  311. setCharSpacing: 33,
  312. setWordSpacing: 34,
  313. setHScale: 35,
  314. setLeading: 36,
  315. setFont: 37,
  316. setTextRenderingMode: 38,
  317. setTextRise: 39,
  318. moveText: 40,
  319. setLeadingMoveText: 41,
  320. setTextMatrix: 42,
  321. nextLine: 43,
  322. showText: 44,
  323. showSpacedText: 45,
  324. nextLineShowText: 46,
  325. nextLineSetSpacingShowText: 47,
  326. setCharWidth: 48,
  327. setCharWidthAndBounds: 49,
  328. setStrokeColorSpace: 50,
  329. setFillColorSpace: 51,
  330. setStrokeColor: 52,
  331. setStrokeColorN: 53,
  332. setFillColor: 54,
  333. setFillColorN: 55,
  334. setStrokeGray: 56,
  335. setFillGray: 57,
  336. setStrokeRGBColor: 58,
  337. setFillRGBColor: 59,
  338. setStrokeCMYKColor: 60,
  339. setFillCMYKColor: 61,
  340. shadingFill: 62,
  341. beginInlineImage: 63,
  342. beginImageData: 64,
  343. endInlineImage: 65,
  344. paintXObject: 66,
  345. markPoint: 67,
  346. markPointProps: 68,
  347. beginMarkedContent: 69,
  348. beginMarkedContentProps: 70,
  349. endMarkedContent: 71,
  350. beginCompat: 72,
  351. endCompat: 73,
  352. paintFormXObjectBegin: 74,
  353. paintFormXObjectEnd: 75,
  354. beginGroup: 76,
  355. endGroup: 77,
  356. beginAnnotation: 80,
  357. endAnnotation: 81,
  358. paintImageMaskXObject: 83,
  359. paintImageMaskXObjectGroup: 84,
  360. paintImageXObject: 85,
  361. paintInlineImageXObject: 86,
  362. paintInlineImageXObjectGroup: 87,
  363. paintImageXObjectRepeat: 88,
  364. paintImageMaskXObjectRepeat: 89,
  365. paintSolidColorImageMask: 90,
  366. constructPath: 91
  367. };
  368. exports.OPS = OPS;
  369. const UNSUPPORTED_FEATURES = {
  370. forms: "forms",
  371. javaScript: "javaScript",
  372. signatures: "signatures",
  373. smask: "smask",
  374. shadingPattern: "shadingPattern",
  375. errorTilingPattern: "errorTilingPattern",
  376. errorExtGState: "errorExtGState",
  377. errorXObject: "errorXObject",
  378. errorFontLoadType3: "errorFontLoadType3",
  379. errorFontState: "errorFontState",
  380. errorFontMissing: "errorFontMissing",
  381. errorFontTranslate: "errorFontTranslate",
  382. errorColorSpace: "errorColorSpace",
  383. errorOperatorList: "errorOperatorList",
  384. errorFontToUnicode: "errorFontToUnicode",
  385. errorFontLoadNative: "errorFontLoadNative",
  386. errorFontBuildPath: "errorFontBuildPath",
  387. errorFontGetPath: "errorFontGetPath",
  388. errorMarkedContent: "errorMarkedContent",
  389. errorContentSubStream: "errorContentSubStream"
  390. };
  391. exports.UNSUPPORTED_FEATURES = UNSUPPORTED_FEATURES;
  392. const PasswordResponses = {
  393. NEED_PASSWORD: 1,
  394. INCORRECT_PASSWORD: 2
  395. };
  396. exports.PasswordResponses = PasswordResponses;
  397. let verbosity = VerbosityLevel.WARNINGS;
  398. function setVerbosityLevel(level) {
  399. if (Number.isInteger(level)) {
  400. verbosity = level;
  401. }
  402. }
  403. function getVerbosityLevel() {
  404. return verbosity;
  405. }
  406. function info(msg) {
  407. if (verbosity >= VerbosityLevel.INFOS) {
  408. console.log(`Info: ${msg}`);
  409. }
  410. }
  411. function warn(msg) {
  412. if (verbosity >= VerbosityLevel.WARNINGS) {
  413. console.log(`Warning: ${msg}`);
  414. }
  415. }
  416. function unreachable(msg) {
  417. throw new Error(msg);
  418. }
  419. function assert(cond, msg) {
  420. if (!cond) {
  421. unreachable(msg);
  422. }
  423. }
  424. function _isValidProtocol(url) {
  425. if (!url) {
  426. return false;
  427. }
  428. switch (url.protocol) {
  429. case "http:":
  430. case "https:":
  431. case "ftp:":
  432. case "mailto:":
  433. case "tel:":
  434. return true;
  435. default:
  436. return false;
  437. }
  438. }
  439. function createValidAbsoluteUrl(url) {
  440. let baseUrl = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  441. let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  442. if (!url) {
  443. return null;
  444. }
  445. try {
  446. if (options && typeof url === "string") {
  447. if (options.addDefaultProtocol && url.startsWith("www.")) {
  448. const dots = url.match(/\./g);
  449. if (dots && dots.length >= 2) {
  450. url = `http://${url}`;
  451. }
  452. }
  453. if (options.tryConvertEncoding) {
  454. try {
  455. url = stringToUTF8String(url);
  456. } catch (ex) {}
  457. }
  458. }
  459. const absoluteUrl = baseUrl ? new URL(url, baseUrl) : new URL(url);
  460. if (_isValidProtocol(absoluteUrl)) {
  461. return absoluteUrl;
  462. }
  463. } catch (ex) {}
  464. return null;
  465. }
  466. function shadow(obj, prop, value) {
  467. let nonSerializable = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  468. Object.defineProperty(obj, prop, {
  469. value,
  470. enumerable: !nonSerializable,
  471. configurable: true,
  472. writable: false
  473. });
  474. return value;
  475. }
  476. const BaseException = function BaseExceptionClosure() {
  477. function BaseException(message, name) {
  478. if (this.constructor === BaseException) {
  479. unreachable("Cannot initialize BaseException.");
  480. }
  481. this.message = message;
  482. this.name = name;
  483. }
  484. BaseException.prototype = new Error();
  485. BaseException.constructor = BaseException;
  486. return BaseException;
  487. }();
  488. exports.BaseException = BaseException;
  489. class PasswordException extends BaseException {
  490. constructor(msg, code) {
  491. super(msg, "PasswordException");
  492. this.code = code;
  493. }
  494. }
  495. exports.PasswordException = PasswordException;
  496. class UnknownErrorException extends BaseException {
  497. constructor(msg, details) {
  498. super(msg, "UnknownErrorException");
  499. this.details = details;
  500. }
  501. }
  502. exports.UnknownErrorException = UnknownErrorException;
  503. class InvalidPDFException extends BaseException {
  504. constructor(msg) {
  505. super(msg, "InvalidPDFException");
  506. }
  507. }
  508. exports.InvalidPDFException = InvalidPDFException;
  509. class MissingPDFException extends BaseException {
  510. constructor(msg) {
  511. super(msg, "MissingPDFException");
  512. }
  513. }
  514. exports.MissingPDFException = MissingPDFException;
  515. class UnexpectedResponseException extends BaseException {
  516. constructor(msg, status) {
  517. super(msg, "UnexpectedResponseException");
  518. this.status = status;
  519. }
  520. }
  521. exports.UnexpectedResponseException = UnexpectedResponseException;
  522. class FormatError extends BaseException {
  523. constructor(msg) {
  524. super(msg, "FormatError");
  525. }
  526. }
  527. exports.FormatError = FormatError;
  528. class AbortException extends BaseException {
  529. constructor(msg) {
  530. super(msg, "AbortException");
  531. }
  532. }
  533. exports.AbortException = AbortException;
  534. function bytesToString(bytes) {
  535. if (typeof bytes !== "object" || bytes === null || bytes.length === undefined) {
  536. unreachable("Invalid argument for bytesToString");
  537. }
  538. const length = bytes.length;
  539. const MAX_ARGUMENT_COUNT = 8192;
  540. if (length < MAX_ARGUMENT_COUNT) {
  541. return String.fromCharCode.apply(null, bytes);
  542. }
  543. const strBuf = [];
  544. for (let i = 0; i < length; i += MAX_ARGUMENT_COUNT) {
  545. const chunkEnd = Math.min(i + MAX_ARGUMENT_COUNT, length);
  546. const chunk = bytes.subarray(i, chunkEnd);
  547. strBuf.push(String.fromCharCode.apply(null, chunk));
  548. }
  549. return strBuf.join("");
  550. }
  551. function stringToBytes(str) {
  552. if (typeof str !== "string") {
  553. unreachable("Invalid argument for stringToBytes");
  554. }
  555. const length = str.length;
  556. const bytes = new Uint8Array(length);
  557. for (let i = 0; i < length; ++i) {
  558. bytes[i] = str.charCodeAt(i) & 0xff;
  559. }
  560. return bytes;
  561. }
  562. function string32(value) {
  563. return String.fromCharCode(value >> 24 & 0xff, value >> 16 & 0xff, value >> 8 & 0xff, value & 0xff);
  564. }
  565. function objectSize(obj) {
  566. return Object.keys(obj).length;
  567. }
  568. function objectFromMap(map) {
  569. const obj = Object.create(null);
  570. for (const [key, value] of map) {
  571. obj[key] = value;
  572. }
  573. return obj;
  574. }
  575. function isLittleEndian() {
  576. const buffer8 = new Uint8Array(4);
  577. buffer8[0] = 1;
  578. const view32 = new Uint32Array(buffer8.buffer, 0, 1);
  579. return view32[0] === 1;
  580. }
  581. function isEvalSupported() {
  582. try {
  583. new Function("");
  584. return true;
  585. } catch (e) {
  586. return false;
  587. }
  588. }
  589. class FeatureTest {
  590. static get isLittleEndian() {
  591. return shadow(this, "isLittleEndian", isLittleEndian());
  592. }
  593. static get isEvalSupported() {
  594. return shadow(this, "isEvalSupported", isEvalSupported());
  595. }
  596. static get isOffscreenCanvasSupported() {
  597. return shadow(this, "isOffscreenCanvasSupported", typeof OffscreenCanvas !== "undefined");
  598. }
  599. static get platform() {
  600. if (typeof navigator === "undefined") {
  601. return shadow(this, "platform", {
  602. isWin: false,
  603. isMac: false
  604. });
  605. }
  606. return shadow(this, "platform", {
  607. isWin: navigator.platform.includes("Win"),
  608. isMac: navigator.platform.includes("Mac")
  609. });
  610. }
  611. }
  612. exports.FeatureTest = FeatureTest;
  613. const hexNumbers = [...Array(256).keys()].map(n => n.toString(16).padStart(2, "0"));
  614. class Util {
  615. static makeHexColor(r, g, b) {
  616. return `#${hexNumbers[r]}${hexNumbers[g]}${hexNumbers[b]}`;
  617. }
  618. static scaleMinMax(transform, minMax) {
  619. let temp;
  620. if (transform[0]) {
  621. if (transform[0] < 0) {
  622. temp = minMax[0];
  623. minMax[0] = minMax[1];
  624. minMax[1] = temp;
  625. }
  626. minMax[0] *= transform[0];
  627. minMax[1] *= transform[0];
  628. if (transform[3] < 0) {
  629. temp = minMax[2];
  630. minMax[2] = minMax[3];
  631. minMax[3] = temp;
  632. }
  633. minMax[2] *= transform[3];
  634. minMax[3] *= transform[3];
  635. } else {
  636. temp = minMax[0];
  637. minMax[0] = minMax[2];
  638. minMax[2] = temp;
  639. temp = minMax[1];
  640. minMax[1] = minMax[3];
  641. minMax[3] = temp;
  642. if (transform[1] < 0) {
  643. temp = minMax[2];
  644. minMax[2] = minMax[3];
  645. minMax[3] = temp;
  646. }
  647. minMax[2] *= transform[1];
  648. minMax[3] *= transform[1];
  649. if (transform[2] < 0) {
  650. temp = minMax[0];
  651. minMax[0] = minMax[1];
  652. minMax[1] = temp;
  653. }
  654. minMax[0] *= transform[2];
  655. minMax[1] *= transform[2];
  656. }
  657. minMax[0] += transform[4];
  658. minMax[1] += transform[4];
  659. minMax[2] += transform[5];
  660. minMax[3] += transform[5];
  661. }
  662. static transform(m1, m2) {
  663. return [m1[0] * m2[0] + m1[2] * m2[1], m1[1] * m2[0] + m1[3] * m2[1], m1[0] * m2[2] + m1[2] * m2[3], m1[1] * m2[2] + m1[3] * m2[3], m1[0] * m2[4] + m1[2] * m2[5] + m1[4], m1[1] * m2[4] + m1[3] * m2[5] + m1[5]];
  664. }
  665. static applyTransform(p, m) {
  666. const xt = p[0] * m[0] + p[1] * m[2] + m[4];
  667. const yt = p[0] * m[1] + p[1] * m[3] + m[5];
  668. return [xt, yt];
  669. }
  670. static applyInverseTransform(p, m) {
  671. const d = m[0] * m[3] - m[1] * m[2];
  672. const xt = (p[0] * m[3] - p[1] * m[2] + m[2] * m[5] - m[4] * m[3]) / d;
  673. const yt = (-p[0] * m[1] + p[1] * m[0] + m[4] * m[1] - m[5] * m[0]) / d;
  674. return [xt, yt];
  675. }
  676. static getAxialAlignedBoundingBox(r, m) {
  677. const p1 = Util.applyTransform(r, m);
  678. const p2 = Util.applyTransform(r.slice(2, 4), m);
  679. const p3 = Util.applyTransform([r[0], r[3]], m);
  680. const p4 = Util.applyTransform([r[2], r[1]], m);
  681. return [Math.min(p1[0], p2[0], p3[0], p4[0]), Math.min(p1[1], p2[1], p3[1], p4[1]), Math.max(p1[0], p2[0], p3[0], p4[0]), Math.max(p1[1], p2[1], p3[1], p4[1])];
  682. }
  683. static inverseTransform(m) {
  684. const d = m[0] * m[3] - m[1] * m[2];
  685. return [m[3] / d, -m[1] / d, -m[2] / d, m[0] / d, (m[2] * m[5] - m[4] * m[3]) / d, (m[4] * m[1] - m[5] * m[0]) / d];
  686. }
  687. static singularValueDecompose2dScale(m) {
  688. const transpose = [m[0], m[2], m[1], m[3]];
  689. const a = m[0] * transpose[0] + m[1] * transpose[2];
  690. const b = m[0] * transpose[1] + m[1] * transpose[3];
  691. const c = m[2] * transpose[0] + m[3] * transpose[2];
  692. const d = m[2] * transpose[1] + m[3] * transpose[3];
  693. const first = (a + d) / 2;
  694. const second = Math.sqrt((a + d) ** 2 - 4 * (a * d - c * b)) / 2;
  695. const sx = first + second || 1;
  696. const sy = first - second || 1;
  697. return [Math.sqrt(sx), Math.sqrt(sy)];
  698. }
  699. static normalizeRect(rect) {
  700. const r = rect.slice(0);
  701. if (rect[0] > rect[2]) {
  702. r[0] = rect[2];
  703. r[2] = rect[0];
  704. }
  705. if (rect[1] > rect[3]) {
  706. r[1] = rect[3];
  707. r[3] = rect[1];
  708. }
  709. return r;
  710. }
  711. static intersect(rect1, rect2) {
  712. const xLow = Math.max(Math.min(rect1[0], rect1[2]), Math.min(rect2[0], rect2[2]));
  713. const xHigh = Math.min(Math.max(rect1[0], rect1[2]), Math.max(rect2[0], rect2[2]));
  714. if (xLow > xHigh) {
  715. return null;
  716. }
  717. const yLow = Math.max(Math.min(rect1[1], rect1[3]), Math.min(rect2[1], rect2[3]));
  718. const yHigh = Math.min(Math.max(rect1[1], rect1[3]), Math.max(rect2[1], rect2[3]));
  719. if (yLow > yHigh) {
  720. return null;
  721. }
  722. return [xLow, yLow, xHigh, yHigh];
  723. }
  724. static bezierBoundingBox(x0, y0, x1, y1, x2, y2, x3, y3) {
  725. const tvalues = [],
  726. bounds = [[], []];
  727. let a, b, c, t, t1, t2, b2ac, sqrtb2ac;
  728. for (let i = 0; i < 2; ++i) {
  729. if (i === 0) {
  730. b = 6 * x0 - 12 * x1 + 6 * x2;
  731. a = -3 * x0 + 9 * x1 - 9 * x2 + 3 * x3;
  732. c = 3 * x1 - 3 * x0;
  733. } else {
  734. b = 6 * y0 - 12 * y1 + 6 * y2;
  735. a = -3 * y0 + 9 * y1 - 9 * y2 + 3 * y3;
  736. c = 3 * y1 - 3 * y0;
  737. }
  738. if (Math.abs(a) < 1e-12) {
  739. if (Math.abs(b) < 1e-12) {
  740. continue;
  741. }
  742. t = -c / b;
  743. if (0 < t && t < 1) {
  744. tvalues.push(t);
  745. }
  746. continue;
  747. }
  748. b2ac = b * b - 4 * c * a;
  749. sqrtb2ac = Math.sqrt(b2ac);
  750. if (b2ac < 0) {
  751. continue;
  752. }
  753. t1 = (-b + sqrtb2ac) / (2 * a);
  754. if (0 < t1 && t1 < 1) {
  755. tvalues.push(t1);
  756. }
  757. t2 = (-b - sqrtb2ac) / (2 * a);
  758. if (0 < t2 && t2 < 1) {
  759. tvalues.push(t2);
  760. }
  761. }
  762. let j = tvalues.length,
  763. mt;
  764. const jlen = j;
  765. while (j--) {
  766. t = tvalues[j];
  767. mt = 1 - t;
  768. bounds[0][j] = mt * mt * mt * x0 + 3 * mt * mt * t * x1 + 3 * mt * t * t * x2 + t * t * t * x3;
  769. bounds[1][j] = mt * mt * mt * y0 + 3 * mt * mt * t * y1 + 3 * mt * t * t * y2 + t * t * t * y3;
  770. }
  771. bounds[0][jlen] = x0;
  772. bounds[1][jlen] = y0;
  773. bounds[0][jlen + 1] = x3;
  774. bounds[1][jlen + 1] = y3;
  775. bounds[0].length = bounds[1].length = jlen + 2;
  776. return [Math.min(...bounds[0]), Math.min(...bounds[1]), Math.max(...bounds[0]), Math.max(...bounds[1])];
  777. }
  778. }
  779. exports.Util = Util;
  780. const PDFStringTranslateTable = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x2d8, 0x2c7, 0x2c6, 0x2d9, 0x2dd, 0x2db, 0x2da, 0x2dc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x2022, 0x2020, 0x2021, 0x2026, 0x2014, 0x2013, 0x192, 0x2044, 0x2039, 0x203a, 0x2212, 0x2030, 0x201e, 0x201c, 0x201d, 0x2018, 0x2019, 0x201a, 0x2122, 0xfb01, 0xfb02, 0x141, 0x152, 0x160, 0x178, 0x17d, 0x131, 0x142, 0x153, 0x161, 0x17e, 0, 0x20ac];
  781. function stringToPDFString(str) {
  782. if (str[0] >= "\xEF") {
  783. let encoding;
  784. if (str[0] === "\xFE" && str[1] === "\xFF") {
  785. encoding = "utf-16be";
  786. } else if (str[0] === "\xFF" && str[1] === "\xFE") {
  787. encoding = "utf-16le";
  788. } else if (str[0] === "\xEF" && str[1] === "\xBB" && str[2] === "\xBF") {
  789. encoding = "utf-8";
  790. }
  791. if (encoding) {
  792. try {
  793. const decoder = new TextDecoder(encoding, {
  794. fatal: true
  795. });
  796. const buffer = stringToBytes(str);
  797. return decoder.decode(buffer);
  798. } catch (ex) {
  799. warn(`stringToPDFString: "${ex}".`);
  800. }
  801. }
  802. }
  803. const strBuf = [];
  804. for (let i = 0, ii = str.length; i < ii; i++) {
  805. const code = PDFStringTranslateTable[str.charCodeAt(i)];
  806. strBuf.push(code ? String.fromCharCode(code) : str.charAt(i));
  807. }
  808. return strBuf.join("");
  809. }
  810. function stringToUTF8String(str) {
  811. return decodeURIComponent(escape(str));
  812. }
  813. function utf8StringToString(str) {
  814. return unescape(encodeURIComponent(str));
  815. }
  816. function isArrayBuffer(v) {
  817. return typeof v === "object" && v !== null && v.byteLength !== undefined;
  818. }
  819. function isArrayEqual(arr1, arr2) {
  820. if (arr1.length !== arr2.length) {
  821. return false;
  822. }
  823. for (let i = 0, ii = arr1.length; i < ii; i++) {
  824. if (arr1[i] !== arr2[i]) {
  825. return false;
  826. }
  827. }
  828. return true;
  829. }
  830. function getModificationDate() {
  831. let date = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Date();
  832. const buffer = [date.getUTCFullYear().toString(), (date.getUTCMonth() + 1).toString().padStart(2, "0"), date.getUTCDate().toString().padStart(2, "0"), date.getUTCHours().toString().padStart(2, "0"), date.getUTCMinutes().toString().padStart(2, "0"), date.getUTCSeconds().toString().padStart(2, "0")];
  833. return buffer.join("");
  834. }
  835. function createPromiseCapability() {
  836. const capability = Object.create(null);
  837. let isSettled = false;
  838. Object.defineProperty(capability, "settled", {
  839. get() {
  840. return isSettled;
  841. }
  842. });
  843. capability.promise = new Promise(function (resolve, reject) {
  844. capability.resolve = function (data) {
  845. isSettled = true;
  846. resolve(data);
  847. };
  848. capability.reject = function (reason) {
  849. isSettled = true;
  850. reject(reason);
  851. };
  852. });
  853. return capability;
  854. }
  855. /***/ }),
  856. /* 2 */
  857. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  858. "use strict";
  859. var _is_node = __w_pdfjs_require__(3);
  860. (function checkNodeBtoa() {
  861. if (globalThis.btoa || !_is_node.isNodeJS) {
  862. return;
  863. }
  864. globalThis.btoa = function (chars) {
  865. return Buffer.from(chars, "binary").toString("base64");
  866. };
  867. })();
  868. (function checkNodeAtob() {
  869. if (globalThis.atob || !_is_node.isNodeJS) {
  870. return;
  871. }
  872. globalThis.atob = function (input) {
  873. return Buffer.from(input, "base64").toString("binary");
  874. };
  875. })();
  876. (function checkDOMMatrix() {
  877. if (globalThis.DOMMatrix || !_is_node.isNodeJS) {
  878. return;
  879. }
  880. globalThis.DOMMatrix = require("canvas").DOMMatrix;
  881. })();
  882. (function checkPath2D() {
  883. if (globalThis.Path2D || !_is_node.isNodeJS) {
  884. return;
  885. }
  886. const {
  887. CanvasRenderingContext2D
  888. } = require("canvas");
  889. const {
  890. polyfillPath2D
  891. } = require("path2d-polyfill");
  892. globalThis.CanvasRenderingContext2D = CanvasRenderingContext2D;
  893. polyfillPath2D(globalThis);
  894. })();
  895. (function checkReadableStream() {
  896. if (globalThis.ReadableStream || !_is_node.isNodeJS) {
  897. return;
  898. }
  899. globalThis.ReadableStream = require("web-streams-polyfill/dist/ponyfill.js").ReadableStream;
  900. })();
  901. (function checkArrayAt() {
  902. if (Array.prototype.at) {
  903. return;
  904. }
  905. __w_pdfjs_require__(4);
  906. })();
  907. (function checkTypedArrayAt() {
  908. if (Uint8Array.prototype.at) {
  909. return;
  910. }
  911. __w_pdfjs_require__(78);
  912. })();
  913. (function checkStructuredClone() {
  914. if (globalThis.structuredClone) {
  915. return;
  916. }
  917. __w_pdfjs_require__(88);
  918. })();
  919. /***/ }),
  920. /* 3 */
  921. /***/ ((__unused_webpack_module, exports) => {
  922. "use strict";
  923. Object.defineProperty(exports, "__esModule", ({
  924. value: true
  925. }));
  926. exports.isNodeJS = void 0;
  927. const isNodeJS = typeof process === "object" && process + "" === "[object process]" && !process.versions.nw && !(process.versions.electron && process.type && process.type !== "browser");
  928. exports.isNodeJS = isNodeJS;
  929. /***/ }),
  930. /* 4 */
  931. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  932. __w_pdfjs_require__(5);
  933. var entryUnbind = __w_pdfjs_require__(77);
  934. module.exports = entryUnbind('Array', 'at');
  935. /***/ }),
  936. /* 5 */
  937. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  938. "use strict";
  939. var $ = __w_pdfjs_require__(6);
  940. var toObject = __w_pdfjs_require__(43);
  941. var lengthOfArrayLike = __w_pdfjs_require__(67);
  942. var toIntegerOrInfinity = __w_pdfjs_require__(65);
  943. var addToUnscopables = __w_pdfjs_require__(72);
  944. $({
  945. target: 'Array',
  946. proto: true
  947. }, {
  948. at: function at(index) {
  949. var O = toObject(this);
  950. var len = lengthOfArrayLike(O);
  951. var relativeIndex = toIntegerOrInfinity(index);
  952. var k = relativeIndex >= 0 ? relativeIndex : len + relativeIndex;
  953. return k < 0 || k >= len ? undefined : O[k];
  954. }
  955. });
  956. addToUnscopables('at');
  957. /***/ }),
  958. /* 6 */
  959. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  960. var global = __w_pdfjs_require__(7);
  961. var getOwnPropertyDescriptor = (__w_pdfjs_require__(8).f);
  962. var createNonEnumerableProperty = __w_pdfjs_require__(47);
  963. var defineBuiltIn = __w_pdfjs_require__(51);
  964. var defineGlobalProperty = __w_pdfjs_require__(41);
  965. var copyConstructorProperties = __w_pdfjs_require__(59);
  966. var isForced = __w_pdfjs_require__(71);
  967. module.exports = function (options, source) {
  968. var TARGET = options.target;
  969. var GLOBAL = options.global;
  970. var STATIC = options.stat;
  971. var FORCED, target, key, targetProperty, sourceProperty, descriptor;
  972. if (GLOBAL) {
  973. target = global;
  974. } else if (STATIC) {
  975. target = global[TARGET] || defineGlobalProperty(TARGET, {});
  976. } else {
  977. target = (global[TARGET] || {}).prototype;
  978. }
  979. if (target)
  980. for (key in source) {
  981. sourceProperty = source[key];
  982. if (options.dontCallGetSet) {
  983. descriptor = getOwnPropertyDescriptor(target, key);
  984. targetProperty = descriptor && descriptor.value;
  985. } else
  986. targetProperty = target[key];
  987. FORCED = isForced(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced);
  988. if (!FORCED && targetProperty !== undefined) {
  989. if (typeof sourceProperty == typeof targetProperty)
  990. continue;
  991. copyConstructorProperties(sourceProperty, targetProperty);
  992. }
  993. if (options.sham || targetProperty && targetProperty.sham) {
  994. createNonEnumerableProperty(sourceProperty, 'sham', true);
  995. }
  996. defineBuiltIn(target, key, sourceProperty, options);
  997. }
  998. };
  999. /***/ }),
  1000. /* 7 */
  1001. /***/ ((module) => {
  1002. var check = function (it) {
  1003. return it && it.Math == Math && it;
  1004. };
  1005. module.exports = check(typeof globalThis == 'object' && globalThis) || check(typeof window == 'object' && window) || check(typeof self == 'object' && self) || check(typeof global == 'object' && global) || (function () {
  1006. return this;
  1007. }()) || Function('return this')();
  1008. /***/ }),
  1009. /* 8 */
  1010. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  1011. var DESCRIPTORS = __w_pdfjs_require__(9);
  1012. var call = __w_pdfjs_require__(11);
  1013. var propertyIsEnumerableModule = __w_pdfjs_require__(13);
  1014. var createPropertyDescriptor = __w_pdfjs_require__(14);
  1015. var toIndexedObject = __w_pdfjs_require__(15);
  1016. var toPropertyKey = __w_pdfjs_require__(21);
  1017. var hasOwn = __w_pdfjs_require__(42);
  1018. var IE8_DOM_DEFINE = __w_pdfjs_require__(45);
  1019. var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  1020. exports.f = DESCRIPTORS ? $getOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) {
  1021. O = toIndexedObject(O);
  1022. P = toPropertyKey(P);
  1023. if (IE8_DOM_DEFINE)
  1024. try {
  1025. return $getOwnPropertyDescriptor(O, P);
  1026. } catch (error) {
  1027. }
  1028. if (hasOwn(O, P))
  1029. return createPropertyDescriptor(!call(propertyIsEnumerableModule.f, O, P), O[P]);
  1030. };
  1031. /***/ }),
  1032. /* 9 */
  1033. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1034. var fails = __w_pdfjs_require__(10);
  1035. module.exports = !fails(function () {
  1036. return Object.defineProperty({}, 1, {
  1037. get: function () {
  1038. return 7;
  1039. }
  1040. })[1] != 7;
  1041. });
  1042. /***/ }),
  1043. /* 10 */
  1044. /***/ ((module) => {
  1045. module.exports = function (exec) {
  1046. try {
  1047. return !!exec();
  1048. } catch (error) {
  1049. return true;
  1050. }
  1051. };
  1052. /***/ }),
  1053. /* 11 */
  1054. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1055. var NATIVE_BIND = __w_pdfjs_require__(12);
  1056. var call = Function.prototype.call;
  1057. module.exports = NATIVE_BIND ? call.bind(call) : function () {
  1058. return call.apply(call, arguments);
  1059. };
  1060. /***/ }),
  1061. /* 12 */
  1062. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1063. var fails = __w_pdfjs_require__(10);
  1064. module.exports = !fails(function () {
  1065. var test = function () {
  1066. }.bind();
  1067. return typeof test != 'function' || test.hasOwnProperty('prototype');
  1068. });
  1069. /***/ }),
  1070. /* 13 */
  1071. /***/ ((__unused_webpack_module, exports) => {
  1072. "use strict";
  1073. var $propertyIsEnumerable = {}.propertyIsEnumerable;
  1074. var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  1075. var NASHORN_BUG = getOwnPropertyDescriptor && !$propertyIsEnumerable.call({ 1: 2 }, 1);
  1076. exports.f = NASHORN_BUG ? function propertyIsEnumerable(V) {
  1077. var descriptor = getOwnPropertyDescriptor(this, V);
  1078. return !!descriptor && descriptor.enumerable;
  1079. } : $propertyIsEnumerable;
  1080. /***/ }),
  1081. /* 14 */
  1082. /***/ ((module) => {
  1083. module.exports = function (bitmap, value) {
  1084. return {
  1085. enumerable: !(bitmap & 1),
  1086. configurable: !(bitmap & 2),
  1087. writable: !(bitmap & 4),
  1088. value: value
  1089. };
  1090. };
  1091. /***/ }),
  1092. /* 15 */
  1093. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1094. var IndexedObject = __w_pdfjs_require__(16);
  1095. var requireObjectCoercible = __w_pdfjs_require__(19);
  1096. module.exports = function (it) {
  1097. return IndexedObject(requireObjectCoercible(it));
  1098. };
  1099. /***/ }),
  1100. /* 16 */
  1101. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1102. var uncurryThis = __w_pdfjs_require__(17);
  1103. var fails = __w_pdfjs_require__(10);
  1104. var classof = __w_pdfjs_require__(18);
  1105. var $Object = Object;
  1106. var split = uncurryThis(''.split);
  1107. module.exports = fails(function () {
  1108. return !$Object('z').propertyIsEnumerable(0);
  1109. }) ? function (it) {
  1110. return classof(it) == 'String' ? split(it, '') : $Object(it);
  1111. } : $Object;
  1112. /***/ }),
  1113. /* 17 */
  1114. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1115. var NATIVE_BIND = __w_pdfjs_require__(12);
  1116. var FunctionPrototype = Function.prototype;
  1117. var call = FunctionPrototype.call;
  1118. var uncurryThisWithBind = NATIVE_BIND && FunctionPrototype.bind.bind(call, call);
  1119. module.exports = NATIVE_BIND ? uncurryThisWithBind : function (fn) {
  1120. return function () {
  1121. return call.apply(fn, arguments);
  1122. };
  1123. };
  1124. /***/ }),
  1125. /* 18 */
  1126. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1127. var uncurryThis = __w_pdfjs_require__(17);
  1128. var toString = uncurryThis({}.toString);
  1129. var stringSlice = uncurryThis(''.slice);
  1130. module.exports = function (it) {
  1131. return stringSlice(toString(it), 8, -1);
  1132. };
  1133. /***/ }),
  1134. /* 19 */
  1135. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1136. var isNullOrUndefined = __w_pdfjs_require__(20);
  1137. var $TypeError = TypeError;
  1138. module.exports = function (it) {
  1139. if (isNullOrUndefined(it))
  1140. throw $TypeError("Can't call method on " + it);
  1141. return it;
  1142. };
  1143. /***/ }),
  1144. /* 20 */
  1145. /***/ ((module) => {
  1146. module.exports = function (it) {
  1147. return it === null || it === undefined;
  1148. };
  1149. /***/ }),
  1150. /* 21 */
  1151. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1152. var toPrimitive = __w_pdfjs_require__(22);
  1153. var isSymbol = __w_pdfjs_require__(26);
  1154. module.exports = function (argument) {
  1155. var key = toPrimitive(argument, 'string');
  1156. return isSymbol(key) ? key : key + '';
  1157. };
  1158. /***/ }),
  1159. /* 22 */
  1160. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1161. var call = __w_pdfjs_require__(11);
  1162. var isObject = __w_pdfjs_require__(23);
  1163. var isSymbol = __w_pdfjs_require__(26);
  1164. var getMethod = __w_pdfjs_require__(33);
  1165. var ordinaryToPrimitive = __w_pdfjs_require__(36);
  1166. var wellKnownSymbol = __w_pdfjs_require__(37);
  1167. var $TypeError = TypeError;
  1168. var TO_PRIMITIVE = wellKnownSymbol('toPrimitive');
  1169. module.exports = function (input, pref) {
  1170. if (!isObject(input) || isSymbol(input))
  1171. return input;
  1172. var exoticToPrim = getMethod(input, TO_PRIMITIVE);
  1173. var result;
  1174. if (exoticToPrim) {
  1175. if (pref === undefined)
  1176. pref = 'default';
  1177. result = call(exoticToPrim, input, pref);
  1178. if (!isObject(result) || isSymbol(result))
  1179. return result;
  1180. throw $TypeError("Can't convert object to primitive value");
  1181. }
  1182. if (pref === undefined)
  1183. pref = 'number';
  1184. return ordinaryToPrimitive(input, pref);
  1185. };
  1186. /***/ }),
  1187. /* 23 */
  1188. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1189. var isCallable = __w_pdfjs_require__(24);
  1190. var $documentAll = __w_pdfjs_require__(25);
  1191. var documentAll = $documentAll.all;
  1192. module.exports = $documentAll.IS_HTMLDDA ? function (it) {
  1193. return typeof it == 'object' ? it !== null : isCallable(it) || it === documentAll;
  1194. } : function (it) {
  1195. return typeof it == 'object' ? it !== null : isCallable(it);
  1196. };
  1197. /***/ }),
  1198. /* 24 */
  1199. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1200. var $documentAll = __w_pdfjs_require__(25);
  1201. var documentAll = $documentAll.all;
  1202. module.exports = $documentAll.IS_HTMLDDA ? function (argument) {
  1203. return typeof argument == 'function' || argument === documentAll;
  1204. } : function (argument) {
  1205. return typeof argument == 'function';
  1206. };
  1207. /***/ }),
  1208. /* 25 */
  1209. /***/ ((module) => {
  1210. var documentAll = typeof document == 'object' && document.all;
  1211. var IS_HTMLDDA = typeof documentAll == 'undefined' && documentAll !== undefined;
  1212. module.exports = {
  1213. all: documentAll,
  1214. IS_HTMLDDA: IS_HTMLDDA
  1215. };
  1216. /***/ }),
  1217. /* 26 */
  1218. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1219. var getBuiltIn = __w_pdfjs_require__(27);
  1220. var isCallable = __w_pdfjs_require__(24);
  1221. var isPrototypeOf = __w_pdfjs_require__(28);
  1222. var USE_SYMBOL_AS_UID = __w_pdfjs_require__(29);
  1223. var $Object = Object;
  1224. module.exports = USE_SYMBOL_AS_UID ? function (it) {
  1225. return typeof it == 'symbol';
  1226. } : function (it) {
  1227. var $Symbol = getBuiltIn('Symbol');
  1228. return isCallable($Symbol) && isPrototypeOf($Symbol.prototype, $Object(it));
  1229. };
  1230. /***/ }),
  1231. /* 27 */
  1232. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1233. var global = __w_pdfjs_require__(7);
  1234. var isCallable = __w_pdfjs_require__(24);
  1235. var aFunction = function (argument) {
  1236. return isCallable(argument) ? argument : undefined;
  1237. };
  1238. module.exports = function (namespace, method) {
  1239. return arguments.length < 2 ? aFunction(global[namespace]) : global[namespace] && global[namespace][method];
  1240. };
  1241. /***/ }),
  1242. /* 28 */
  1243. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1244. var uncurryThis = __w_pdfjs_require__(17);
  1245. module.exports = uncurryThis({}.isPrototypeOf);
  1246. /***/ }),
  1247. /* 29 */
  1248. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1249. var NATIVE_SYMBOL = __w_pdfjs_require__(30);
  1250. module.exports = NATIVE_SYMBOL && !Symbol.sham && typeof Symbol.iterator == 'symbol';
  1251. /***/ }),
  1252. /* 30 */
  1253. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1254. var V8_VERSION = __w_pdfjs_require__(31);
  1255. var fails = __w_pdfjs_require__(10);
  1256. module.exports = !!Object.getOwnPropertySymbols && !fails(function () {
  1257. var symbol = Symbol();
  1258. return !String(symbol) || !(Object(symbol) instanceof Symbol) || !Symbol.sham && V8_VERSION && V8_VERSION < 41;
  1259. });
  1260. /***/ }),
  1261. /* 31 */
  1262. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1263. var global = __w_pdfjs_require__(7);
  1264. var userAgent = __w_pdfjs_require__(32);
  1265. var process = global.process;
  1266. var Deno = global.Deno;
  1267. var versions = process && process.versions || Deno && Deno.version;
  1268. var v8 = versions && versions.v8;
  1269. var match, version;
  1270. if (v8) {
  1271. match = v8.split('.');
  1272. version = match[0] > 0 && match[0] < 4 ? 1 : +(match[0] + match[1]);
  1273. }
  1274. if (!version && userAgent) {
  1275. match = userAgent.match(/Edge\/(\d+)/);
  1276. if (!match || match[1] >= 74) {
  1277. match = userAgent.match(/Chrome\/(\d+)/);
  1278. if (match)
  1279. version = +match[1];
  1280. }
  1281. }
  1282. module.exports = version;
  1283. /***/ }),
  1284. /* 32 */
  1285. /***/ ((module) => {
  1286. module.exports = typeof navigator != 'undefined' && String(navigator.userAgent) || '';
  1287. /***/ }),
  1288. /* 33 */
  1289. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1290. var aCallable = __w_pdfjs_require__(34);
  1291. var isNullOrUndefined = __w_pdfjs_require__(20);
  1292. module.exports = function (V, P) {
  1293. var func = V[P];
  1294. return isNullOrUndefined(func) ? undefined : aCallable(func);
  1295. };
  1296. /***/ }),
  1297. /* 34 */
  1298. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1299. var isCallable = __w_pdfjs_require__(24);
  1300. var tryToString = __w_pdfjs_require__(35);
  1301. var $TypeError = TypeError;
  1302. module.exports = function (argument) {
  1303. if (isCallable(argument))
  1304. return argument;
  1305. throw $TypeError(tryToString(argument) + ' is not a function');
  1306. };
  1307. /***/ }),
  1308. /* 35 */
  1309. /***/ ((module) => {
  1310. var $String = String;
  1311. module.exports = function (argument) {
  1312. try {
  1313. return $String(argument);
  1314. } catch (error) {
  1315. return 'Object';
  1316. }
  1317. };
  1318. /***/ }),
  1319. /* 36 */
  1320. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1321. var call = __w_pdfjs_require__(11);
  1322. var isCallable = __w_pdfjs_require__(24);
  1323. var isObject = __w_pdfjs_require__(23);
  1324. var $TypeError = TypeError;
  1325. module.exports = function (input, pref) {
  1326. var fn, val;
  1327. if (pref === 'string' && isCallable(fn = input.toString) && !isObject(val = call(fn, input)))
  1328. return val;
  1329. if (isCallable(fn = input.valueOf) && !isObject(val = call(fn, input)))
  1330. return val;
  1331. if (pref !== 'string' && isCallable(fn = input.toString) && !isObject(val = call(fn, input)))
  1332. return val;
  1333. throw $TypeError("Can't convert object to primitive value");
  1334. };
  1335. /***/ }),
  1336. /* 37 */
  1337. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1338. var global = __w_pdfjs_require__(7);
  1339. var shared = __w_pdfjs_require__(38);
  1340. var hasOwn = __w_pdfjs_require__(42);
  1341. var uid = __w_pdfjs_require__(44);
  1342. var NATIVE_SYMBOL = __w_pdfjs_require__(30);
  1343. var USE_SYMBOL_AS_UID = __w_pdfjs_require__(29);
  1344. var Symbol = global.Symbol;
  1345. var WellKnownSymbolsStore = shared('wks');
  1346. var createWellKnownSymbol = USE_SYMBOL_AS_UID ? Symbol['for'] || Symbol : Symbol && Symbol.withoutSetter || uid;
  1347. module.exports = function (name) {
  1348. if (!hasOwn(WellKnownSymbolsStore, name)) {
  1349. WellKnownSymbolsStore[name] = NATIVE_SYMBOL && hasOwn(Symbol, name) ? Symbol[name] : createWellKnownSymbol('Symbol.' + name);
  1350. }
  1351. return WellKnownSymbolsStore[name];
  1352. };
  1353. /***/ }),
  1354. /* 38 */
  1355. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1356. var IS_PURE = __w_pdfjs_require__(39);
  1357. var store = __w_pdfjs_require__(40);
  1358. (module.exports = function (key, value) {
  1359. return store[key] || (store[key] = value !== undefined ? value : {});
  1360. })('versions', []).push({
  1361. version: '3.27.2',
  1362. mode: IS_PURE ? 'pure' : 'global',
  1363. copyright: '© 2014-2023 Denis Pushkarev (zloirock.ru)',
  1364. license: 'https://github.com/zloirock/core-js/blob/v3.27.2/LICENSE',
  1365. source: 'https://github.com/zloirock/core-js'
  1366. });
  1367. /***/ }),
  1368. /* 39 */
  1369. /***/ ((module) => {
  1370. module.exports = false;
  1371. /***/ }),
  1372. /* 40 */
  1373. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1374. var global = __w_pdfjs_require__(7);
  1375. var defineGlobalProperty = __w_pdfjs_require__(41);
  1376. var SHARED = '__core-js_shared__';
  1377. var store = global[SHARED] || defineGlobalProperty(SHARED, {});
  1378. module.exports = store;
  1379. /***/ }),
  1380. /* 41 */
  1381. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1382. var global = __w_pdfjs_require__(7);
  1383. var defineProperty = Object.defineProperty;
  1384. module.exports = function (key, value) {
  1385. try {
  1386. defineProperty(global, key, {
  1387. value: value,
  1388. configurable: true,
  1389. writable: true
  1390. });
  1391. } catch (error) {
  1392. global[key] = value;
  1393. }
  1394. return value;
  1395. };
  1396. /***/ }),
  1397. /* 42 */
  1398. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1399. var uncurryThis = __w_pdfjs_require__(17);
  1400. var toObject = __w_pdfjs_require__(43);
  1401. var hasOwnProperty = uncurryThis({}.hasOwnProperty);
  1402. module.exports = Object.hasOwn || function hasOwn(it, key) {
  1403. return hasOwnProperty(toObject(it), key);
  1404. };
  1405. /***/ }),
  1406. /* 43 */
  1407. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1408. var requireObjectCoercible = __w_pdfjs_require__(19);
  1409. var $Object = Object;
  1410. module.exports = function (argument) {
  1411. return $Object(requireObjectCoercible(argument));
  1412. };
  1413. /***/ }),
  1414. /* 44 */
  1415. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1416. var uncurryThis = __w_pdfjs_require__(17);
  1417. var id = 0;
  1418. var postfix = Math.random();
  1419. var toString = uncurryThis(1.0.toString);
  1420. module.exports = function (key) {
  1421. return 'Symbol(' + (key === undefined ? '' : key) + ')_' + toString(++id + postfix, 36);
  1422. };
  1423. /***/ }),
  1424. /* 45 */
  1425. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1426. var DESCRIPTORS = __w_pdfjs_require__(9);
  1427. var fails = __w_pdfjs_require__(10);
  1428. var createElement = __w_pdfjs_require__(46);
  1429. module.exports = !DESCRIPTORS && !fails(function () {
  1430. return Object.defineProperty(createElement('div'), 'a', {
  1431. get: function () {
  1432. return 7;
  1433. }
  1434. }).a != 7;
  1435. });
  1436. /***/ }),
  1437. /* 46 */
  1438. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1439. var global = __w_pdfjs_require__(7);
  1440. var isObject = __w_pdfjs_require__(23);
  1441. var document = global.document;
  1442. var EXISTS = isObject(document) && isObject(document.createElement);
  1443. module.exports = function (it) {
  1444. return EXISTS ? document.createElement(it) : {};
  1445. };
  1446. /***/ }),
  1447. /* 47 */
  1448. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1449. var DESCRIPTORS = __w_pdfjs_require__(9);
  1450. var definePropertyModule = __w_pdfjs_require__(48);
  1451. var createPropertyDescriptor = __w_pdfjs_require__(14);
  1452. module.exports = DESCRIPTORS ? function (object, key, value) {
  1453. return definePropertyModule.f(object, key, createPropertyDescriptor(1, value));
  1454. } : function (object, key, value) {
  1455. object[key] = value;
  1456. return object;
  1457. };
  1458. /***/ }),
  1459. /* 48 */
  1460. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  1461. var DESCRIPTORS = __w_pdfjs_require__(9);
  1462. var IE8_DOM_DEFINE = __w_pdfjs_require__(45);
  1463. var V8_PROTOTYPE_DEFINE_BUG = __w_pdfjs_require__(49);
  1464. var anObject = __w_pdfjs_require__(50);
  1465. var toPropertyKey = __w_pdfjs_require__(21);
  1466. var $TypeError = TypeError;
  1467. var $defineProperty = Object.defineProperty;
  1468. var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  1469. var ENUMERABLE = 'enumerable';
  1470. var CONFIGURABLE = 'configurable';
  1471. var WRITABLE = 'writable';
  1472. exports.f = DESCRIPTORS ? V8_PROTOTYPE_DEFINE_BUG ? function defineProperty(O, P, Attributes) {
  1473. anObject(O);
  1474. P = toPropertyKey(P);
  1475. anObject(Attributes);
  1476. if (typeof O === 'function' && P === 'prototype' && 'value' in Attributes && WRITABLE in Attributes && !Attributes[WRITABLE]) {
  1477. var current = $getOwnPropertyDescriptor(O, P);
  1478. if (current && current[WRITABLE]) {
  1479. O[P] = Attributes.value;
  1480. Attributes = {
  1481. configurable: CONFIGURABLE in Attributes ? Attributes[CONFIGURABLE] : current[CONFIGURABLE],
  1482. enumerable: ENUMERABLE in Attributes ? Attributes[ENUMERABLE] : current[ENUMERABLE],
  1483. writable: false
  1484. };
  1485. }
  1486. }
  1487. return $defineProperty(O, P, Attributes);
  1488. } : $defineProperty : function defineProperty(O, P, Attributes) {
  1489. anObject(O);
  1490. P = toPropertyKey(P);
  1491. anObject(Attributes);
  1492. if (IE8_DOM_DEFINE)
  1493. try {
  1494. return $defineProperty(O, P, Attributes);
  1495. } catch (error) {
  1496. }
  1497. if ('get' in Attributes || 'set' in Attributes)
  1498. throw $TypeError('Accessors not supported');
  1499. if ('value' in Attributes)
  1500. O[P] = Attributes.value;
  1501. return O;
  1502. };
  1503. /***/ }),
  1504. /* 49 */
  1505. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1506. var DESCRIPTORS = __w_pdfjs_require__(9);
  1507. var fails = __w_pdfjs_require__(10);
  1508. module.exports = DESCRIPTORS && fails(function () {
  1509. return Object.defineProperty(function () {
  1510. }, 'prototype', {
  1511. value: 42,
  1512. writable: false
  1513. }).prototype != 42;
  1514. });
  1515. /***/ }),
  1516. /* 50 */
  1517. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1518. var isObject = __w_pdfjs_require__(23);
  1519. var $String = String;
  1520. var $TypeError = TypeError;
  1521. module.exports = function (argument) {
  1522. if (isObject(argument))
  1523. return argument;
  1524. throw $TypeError($String(argument) + ' is not an object');
  1525. };
  1526. /***/ }),
  1527. /* 51 */
  1528. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1529. var isCallable = __w_pdfjs_require__(24);
  1530. var definePropertyModule = __w_pdfjs_require__(48);
  1531. var makeBuiltIn = __w_pdfjs_require__(52);
  1532. var defineGlobalProperty = __w_pdfjs_require__(41);
  1533. module.exports = function (O, key, value, options) {
  1534. if (!options)
  1535. options = {};
  1536. var simple = options.enumerable;
  1537. var name = options.name !== undefined ? options.name : key;
  1538. if (isCallable(value))
  1539. makeBuiltIn(value, name, options);
  1540. if (options.global) {
  1541. if (simple)
  1542. O[key] = value;
  1543. else
  1544. defineGlobalProperty(key, value);
  1545. } else {
  1546. try {
  1547. if (!options.unsafe)
  1548. delete O[key];
  1549. else if (O[key])
  1550. simple = true;
  1551. } catch (error) {
  1552. }
  1553. if (simple)
  1554. O[key] = value;
  1555. else
  1556. definePropertyModule.f(O, key, {
  1557. value: value,
  1558. enumerable: false,
  1559. configurable: !options.nonConfigurable,
  1560. writable: !options.nonWritable
  1561. });
  1562. }
  1563. return O;
  1564. };
  1565. /***/ }),
  1566. /* 52 */
  1567. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1568. var uncurryThis = __w_pdfjs_require__(17);
  1569. var fails = __w_pdfjs_require__(10);
  1570. var isCallable = __w_pdfjs_require__(24);
  1571. var hasOwn = __w_pdfjs_require__(42);
  1572. var DESCRIPTORS = __w_pdfjs_require__(9);
  1573. var CONFIGURABLE_FUNCTION_NAME = (__w_pdfjs_require__(53).CONFIGURABLE);
  1574. var inspectSource = __w_pdfjs_require__(54);
  1575. var InternalStateModule = __w_pdfjs_require__(55);
  1576. var enforceInternalState = InternalStateModule.enforce;
  1577. var getInternalState = InternalStateModule.get;
  1578. var $String = String;
  1579. var defineProperty = Object.defineProperty;
  1580. var stringSlice = uncurryThis(''.slice);
  1581. var replace = uncurryThis(''.replace);
  1582. var join = uncurryThis([].join);
  1583. var CONFIGURABLE_LENGTH = DESCRIPTORS && !fails(function () {
  1584. return defineProperty(function () {
  1585. }, 'length', { value: 8 }).length !== 8;
  1586. });
  1587. var TEMPLATE = String(String).split('String');
  1588. var makeBuiltIn = module.exports = function (value, name, options) {
  1589. if (stringSlice($String(name), 0, 7) === 'Symbol(') {
  1590. name = '[' + replace($String(name), /^Symbol\(([^)]*)\)/, '$1') + ']';
  1591. }
  1592. if (options && options.getter)
  1593. name = 'get ' + name;
  1594. if (options && options.setter)
  1595. name = 'set ' + name;
  1596. if (!hasOwn(value, 'name') || CONFIGURABLE_FUNCTION_NAME && value.name !== name) {
  1597. if (DESCRIPTORS)
  1598. defineProperty(value, 'name', {
  1599. value: name,
  1600. configurable: true
  1601. });
  1602. else
  1603. value.name = name;
  1604. }
  1605. if (CONFIGURABLE_LENGTH && options && hasOwn(options, 'arity') && value.length !== options.arity) {
  1606. defineProperty(value, 'length', { value: options.arity });
  1607. }
  1608. try {
  1609. if (options && hasOwn(options, 'constructor') && options.constructor) {
  1610. if (DESCRIPTORS)
  1611. defineProperty(value, 'prototype', { writable: false });
  1612. } else if (value.prototype)
  1613. value.prototype = undefined;
  1614. } catch (error) {
  1615. }
  1616. var state = enforceInternalState(value);
  1617. if (!hasOwn(state, 'source')) {
  1618. state.source = join(TEMPLATE, typeof name == 'string' ? name : '');
  1619. }
  1620. return value;
  1621. };
  1622. Function.prototype.toString = makeBuiltIn(function toString() {
  1623. return isCallable(this) && getInternalState(this).source || inspectSource(this);
  1624. }, 'toString');
  1625. /***/ }),
  1626. /* 53 */
  1627. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1628. var DESCRIPTORS = __w_pdfjs_require__(9);
  1629. var hasOwn = __w_pdfjs_require__(42);
  1630. var FunctionPrototype = Function.prototype;
  1631. var getDescriptor = DESCRIPTORS && Object.getOwnPropertyDescriptor;
  1632. var EXISTS = hasOwn(FunctionPrototype, 'name');
  1633. var PROPER = EXISTS && function something() {
  1634. }.name === 'something';
  1635. var CONFIGURABLE = EXISTS && (!DESCRIPTORS || DESCRIPTORS && getDescriptor(FunctionPrototype, 'name').configurable);
  1636. module.exports = {
  1637. EXISTS: EXISTS,
  1638. PROPER: PROPER,
  1639. CONFIGURABLE: CONFIGURABLE
  1640. };
  1641. /***/ }),
  1642. /* 54 */
  1643. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1644. var uncurryThis = __w_pdfjs_require__(17);
  1645. var isCallable = __w_pdfjs_require__(24);
  1646. var store = __w_pdfjs_require__(40);
  1647. var functionToString = uncurryThis(Function.toString);
  1648. if (!isCallable(store.inspectSource)) {
  1649. store.inspectSource = function (it) {
  1650. return functionToString(it);
  1651. };
  1652. }
  1653. module.exports = store.inspectSource;
  1654. /***/ }),
  1655. /* 55 */
  1656. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1657. var NATIVE_WEAK_MAP = __w_pdfjs_require__(56);
  1658. var global = __w_pdfjs_require__(7);
  1659. var isObject = __w_pdfjs_require__(23);
  1660. var createNonEnumerableProperty = __w_pdfjs_require__(47);
  1661. var hasOwn = __w_pdfjs_require__(42);
  1662. var shared = __w_pdfjs_require__(40);
  1663. var sharedKey = __w_pdfjs_require__(57);
  1664. var hiddenKeys = __w_pdfjs_require__(58);
  1665. var OBJECT_ALREADY_INITIALIZED = 'Object already initialized';
  1666. var TypeError = global.TypeError;
  1667. var WeakMap = global.WeakMap;
  1668. var set, get, has;
  1669. var enforce = function (it) {
  1670. return has(it) ? get(it) : set(it, {});
  1671. };
  1672. var getterFor = function (TYPE) {
  1673. return function (it) {
  1674. var state;
  1675. if (!isObject(it) || (state = get(it)).type !== TYPE) {
  1676. throw TypeError('Incompatible receiver, ' + TYPE + ' required');
  1677. }
  1678. return state;
  1679. };
  1680. };
  1681. if (NATIVE_WEAK_MAP || shared.state) {
  1682. var store = shared.state || (shared.state = new WeakMap());
  1683. store.get = store.get;
  1684. store.has = store.has;
  1685. store.set = store.set;
  1686. set = function (it, metadata) {
  1687. if (store.has(it))
  1688. throw TypeError(OBJECT_ALREADY_INITIALIZED);
  1689. metadata.facade = it;
  1690. store.set(it, metadata);
  1691. return metadata;
  1692. };
  1693. get = function (it) {
  1694. return store.get(it) || {};
  1695. };
  1696. has = function (it) {
  1697. return store.has(it);
  1698. };
  1699. } else {
  1700. var STATE = sharedKey('state');
  1701. hiddenKeys[STATE] = true;
  1702. set = function (it, metadata) {
  1703. if (hasOwn(it, STATE))
  1704. throw TypeError(OBJECT_ALREADY_INITIALIZED);
  1705. metadata.facade = it;
  1706. createNonEnumerableProperty(it, STATE, metadata);
  1707. return metadata;
  1708. };
  1709. get = function (it) {
  1710. return hasOwn(it, STATE) ? it[STATE] : {};
  1711. };
  1712. has = function (it) {
  1713. return hasOwn(it, STATE);
  1714. };
  1715. }
  1716. module.exports = {
  1717. set: set,
  1718. get: get,
  1719. has: has,
  1720. enforce: enforce,
  1721. getterFor: getterFor
  1722. };
  1723. /***/ }),
  1724. /* 56 */
  1725. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1726. var global = __w_pdfjs_require__(7);
  1727. var isCallable = __w_pdfjs_require__(24);
  1728. var WeakMap = global.WeakMap;
  1729. module.exports = isCallable(WeakMap) && /native code/.test(String(WeakMap));
  1730. /***/ }),
  1731. /* 57 */
  1732. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1733. var shared = __w_pdfjs_require__(38);
  1734. var uid = __w_pdfjs_require__(44);
  1735. var keys = shared('keys');
  1736. module.exports = function (key) {
  1737. return keys[key] || (keys[key] = uid(key));
  1738. };
  1739. /***/ }),
  1740. /* 58 */
  1741. /***/ ((module) => {
  1742. module.exports = {};
  1743. /***/ }),
  1744. /* 59 */
  1745. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1746. var hasOwn = __w_pdfjs_require__(42);
  1747. var ownKeys = __w_pdfjs_require__(60);
  1748. var getOwnPropertyDescriptorModule = __w_pdfjs_require__(8);
  1749. var definePropertyModule = __w_pdfjs_require__(48);
  1750. module.exports = function (target, source, exceptions) {
  1751. var keys = ownKeys(source);
  1752. var defineProperty = definePropertyModule.f;
  1753. var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
  1754. for (var i = 0; i < keys.length; i++) {
  1755. var key = keys[i];
  1756. if (!hasOwn(target, key) && !(exceptions && hasOwn(exceptions, key))) {
  1757. defineProperty(target, key, getOwnPropertyDescriptor(source, key));
  1758. }
  1759. }
  1760. };
  1761. /***/ }),
  1762. /* 60 */
  1763. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1764. var getBuiltIn = __w_pdfjs_require__(27);
  1765. var uncurryThis = __w_pdfjs_require__(17);
  1766. var getOwnPropertyNamesModule = __w_pdfjs_require__(61);
  1767. var getOwnPropertySymbolsModule = __w_pdfjs_require__(70);
  1768. var anObject = __w_pdfjs_require__(50);
  1769. var concat = uncurryThis([].concat);
  1770. module.exports = getBuiltIn('Reflect', 'ownKeys') || function ownKeys(it) {
  1771. var keys = getOwnPropertyNamesModule.f(anObject(it));
  1772. var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
  1773. return getOwnPropertySymbols ? concat(keys, getOwnPropertySymbols(it)) : keys;
  1774. };
  1775. /***/ }),
  1776. /* 61 */
  1777. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  1778. var internalObjectKeys = __w_pdfjs_require__(62);
  1779. var enumBugKeys = __w_pdfjs_require__(69);
  1780. var hiddenKeys = enumBugKeys.concat('length', 'prototype');
  1781. exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
  1782. return internalObjectKeys(O, hiddenKeys);
  1783. };
  1784. /***/ }),
  1785. /* 62 */
  1786. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1787. var uncurryThis = __w_pdfjs_require__(17);
  1788. var hasOwn = __w_pdfjs_require__(42);
  1789. var toIndexedObject = __w_pdfjs_require__(15);
  1790. var indexOf = (__w_pdfjs_require__(63).indexOf);
  1791. var hiddenKeys = __w_pdfjs_require__(58);
  1792. var push = uncurryThis([].push);
  1793. module.exports = function (object, names) {
  1794. var O = toIndexedObject(object);
  1795. var i = 0;
  1796. var result = [];
  1797. var key;
  1798. for (key in O)
  1799. !hasOwn(hiddenKeys, key) && hasOwn(O, key) && push(result, key);
  1800. while (names.length > i)
  1801. if (hasOwn(O, key = names[i++])) {
  1802. ~indexOf(result, key) || push(result, key);
  1803. }
  1804. return result;
  1805. };
  1806. /***/ }),
  1807. /* 63 */
  1808. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1809. var toIndexedObject = __w_pdfjs_require__(15);
  1810. var toAbsoluteIndex = __w_pdfjs_require__(64);
  1811. var lengthOfArrayLike = __w_pdfjs_require__(67);
  1812. var createMethod = function (IS_INCLUDES) {
  1813. return function ($this, el, fromIndex) {
  1814. var O = toIndexedObject($this);
  1815. var length = lengthOfArrayLike(O);
  1816. var index = toAbsoluteIndex(fromIndex, length);
  1817. var value;
  1818. if (IS_INCLUDES && el != el)
  1819. while (length > index) {
  1820. value = O[index++];
  1821. if (value != value)
  1822. return true;
  1823. }
  1824. else
  1825. for (; length > index; index++) {
  1826. if ((IS_INCLUDES || index in O) && O[index] === el)
  1827. return IS_INCLUDES || index || 0;
  1828. }
  1829. return !IS_INCLUDES && -1;
  1830. };
  1831. };
  1832. module.exports = {
  1833. includes: createMethod(true),
  1834. indexOf: createMethod(false)
  1835. };
  1836. /***/ }),
  1837. /* 64 */
  1838. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1839. var toIntegerOrInfinity = __w_pdfjs_require__(65);
  1840. var max = Math.max;
  1841. var min = Math.min;
  1842. module.exports = function (index, length) {
  1843. var integer = toIntegerOrInfinity(index);
  1844. return integer < 0 ? max(integer + length, 0) : min(integer, length);
  1845. };
  1846. /***/ }),
  1847. /* 65 */
  1848. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1849. var trunc = __w_pdfjs_require__(66);
  1850. module.exports = function (argument) {
  1851. var number = +argument;
  1852. return number !== number || number === 0 ? 0 : trunc(number);
  1853. };
  1854. /***/ }),
  1855. /* 66 */
  1856. /***/ ((module) => {
  1857. var ceil = Math.ceil;
  1858. var floor = Math.floor;
  1859. module.exports = Math.trunc || function trunc(x) {
  1860. var n = +x;
  1861. return (n > 0 ? floor : ceil)(n);
  1862. };
  1863. /***/ }),
  1864. /* 67 */
  1865. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1866. var toLength = __w_pdfjs_require__(68);
  1867. module.exports = function (obj) {
  1868. return toLength(obj.length);
  1869. };
  1870. /***/ }),
  1871. /* 68 */
  1872. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1873. var toIntegerOrInfinity = __w_pdfjs_require__(65);
  1874. var min = Math.min;
  1875. module.exports = function (argument) {
  1876. return argument > 0 ? min(toIntegerOrInfinity(argument), 0x1FFFFFFFFFFFFF) : 0;
  1877. };
  1878. /***/ }),
  1879. /* 69 */
  1880. /***/ ((module) => {
  1881. module.exports = [
  1882. 'constructor',
  1883. 'hasOwnProperty',
  1884. 'isPrototypeOf',
  1885. 'propertyIsEnumerable',
  1886. 'toLocaleString',
  1887. 'toString',
  1888. 'valueOf'
  1889. ];
  1890. /***/ }),
  1891. /* 70 */
  1892. /***/ ((__unused_webpack_module, exports) => {
  1893. exports.f = Object.getOwnPropertySymbols;
  1894. /***/ }),
  1895. /* 71 */
  1896. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1897. var fails = __w_pdfjs_require__(10);
  1898. var isCallable = __w_pdfjs_require__(24);
  1899. var replacement = /#|\.prototype\./;
  1900. var isForced = function (feature, detection) {
  1901. var value = data[normalize(feature)];
  1902. return value == POLYFILL ? true : value == NATIVE ? false : isCallable(detection) ? fails(detection) : !!detection;
  1903. };
  1904. var normalize = isForced.normalize = function (string) {
  1905. return String(string).replace(replacement, '.').toLowerCase();
  1906. };
  1907. var data = isForced.data = {};
  1908. var NATIVE = isForced.NATIVE = 'N';
  1909. var POLYFILL = isForced.POLYFILL = 'P';
  1910. module.exports = isForced;
  1911. /***/ }),
  1912. /* 72 */
  1913. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1914. var wellKnownSymbol = __w_pdfjs_require__(37);
  1915. var create = __w_pdfjs_require__(73);
  1916. var defineProperty = (__w_pdfjs_require__(48).f);
  1917. var UNSCOPABLES = wellKnownSymbol('unscopables');
  1918. var ArrayPrototype = Array.prototype;
  1919. if (ArrayPrototype[UNSCOPABLES] == undefined) {
  1920. defineProperty(ArrayPrototype, UNSCOPABLES, {
  1921. configurable: true,
  1922. value: create(null)
  1923. });
  1924. }
  1925. module.exports = function (key) {
  1926. ArrayPrototype[UNSCOPABLES][key] = true;
  1927. };
  1928. /***/ }),
  1929. /* 73 */
  1930. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1931. var anObject = __w_pdfjs_require__(50);
  1932. var definePropertiesModule = __w_pdfjs_require__(74);
  1933. var enumBugKeys = __w_pdfjs_require__(69);
  1934. var hiddenKeys = __w_pdfjs_require__(58);
  1935. var html = __w_pdfjs_require__(76);
  1936. var documentCreateElement = __w_pdfjs_require__(46);
  1937. var sharedKey = __w_pdfjs_require__(57);
  1938. var GT = '>';
  1939. var LT = '<';
  1940. var PROTOTYPE = 'prototype';
  1941. var SCRIPT = 'script';
  1942. var IE_PROTO = sharedKey('IE_PROTO');
  1943. var EmptyConstructor = function () {
  1944. };
  1945. var scriptTag = function (content) {
  1946. return LT + SCRIPT + GT + content + LT + '/' + SCRIPT + GT;
  1947. };
  1948. var NullProtoObjectViaActiveX = function (activeXDocument) {
  1949. activeXDocument.write(scriptTag(''));
  1950. activeXDocument.close();
  1951. var temp = activeXDocument.parentWindow.Object;
  1952. activeXDocument = null;
  1953. return temp;
  1954. };
  1955. var NullProtoObjectViaIFrame = function () {
  1956. var iframe = documentCreateElement('iframe');
  1957. var JS = 'java' + SCRIPT + ':';
  1958. var iframeDocument;
  1959. iframe.style.display = 'none';
  1960. html.appendChild(iframe);
  1961. iframe.src = String(JS);
  1962. iframeDocument = iframe.contentWindow.document;
  1963. iframeDocument.open();
  1964. iframeDocument.write(scriptTag('document.F=Object'));
  1965. iframeDocument.close();
  1966. return iframeDocument.F;
  1967. };
  1968. var activeXDocument;
  1969. var NullProtoObject = function () {
  1970. try {
  1971. activeXDocument = new ActiveXObject('htmlfile');
  1972. } catch (error) {
  1973. }
  1974. NullProtoObject = typeof document != 'undefined' ? document.domain && activeXDocument ? NullProtoObjectViaActiveX(activeXDocument) : NullProtoObjectViaIFrame() : NullProtoObjectViaActiveX(activeXDocument);
  1975. var length = enumBugKeys.length;
  1976. while (length--)
  1977. delete NullProtoObject[PROTOTYPE][enumBugKeys[length]];
  1978. return NullProtoObject();
  1979. };
  1980. hiddenKeys[IE_PROTO] = true;
  1981. module.exports = Object.create || function create(O, Properties) {
  1982. var result;
  1983. if (O !== null) {
  1984. EmptyConstructor[PROTOTYPE] = anObject(O);
  1985. result = new EmptyConstructor();
  1986. EmptyConstructor[PROTOTYPE] = null;
  1987. result[IE_PROTO] = O;
  1988. } else
  1989. result = NullProtoObject();
  1990. return Properties === undefined ? result : definePropertiesModule.f(result, Properties);
  1991. };
  1992. /***/ }),
  1993. /* 74 */
  1994. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  1995. var DESCRIPTORS = __w_pdfjs_require__(9);
  1996. var V8_PROTOTYPE_DEFINE_BUG = __w_pdfjs_require__(49);
  1997. var definePropertyModule = __w_pdfjs_require__(48);
  1998. var anObject = __w_pdfjs_require__(50);
  1999. var toIndexedObject = __w_pdfjs_require__(15);
  2000. var objectKeys = __w_pdfjs_require__(75);
  2001. exports.f = DESCRIPTORS && !V8_PROTOTYPE_DEFINE_BUG ? Object.defineProperties : function defineProperties(O, Properties) {
  2002. anObject(O);
  2003. var props = toIndexedObject(Properties);
  2004. var keys = objectKeys(Properties);
  2005. var length = keys.length;
  2006. var index = 0;
  2007. var key;
  2008. while (length > index)
  2009. definePropertyModule.f(O, key = keys[index++], props[key]);
  2010. return O;
  2011. };
  2012. /***/ }),
  2013. /* 75 */
  2014. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2015. var internalObjectKeys = __w_pdfjs_require__(62);
  2016. var enumBugKeys = __w_pdfjs_require__(69);
  2017. module.exports = Object.keys || function keys(O) {
  2018. return internalObjectKeys(O, enumBugKeys);
  2019. };
  2020. /***/ }),
  2021. /* 76 */
  2022. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2023. var getBuiltIn = __w_pdfjs_require__(27);
  2024. module.exports = getBuiltIn('document', 'documentElement');
  2025. /***/ }),
  2026. /* 77 */
  2027. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2028. var global = __w_pdfjs_require__(7);
  2029. var uncurryThis = __w_pdfjs_require__(17);
  2030. module.exports = function (CONSTRUCTOR, METHOD) {
  2031. return uncurryThis(global[CONSTRUCTOR].prototype[METHOD]);
  2032. };
  2033. /***/ }),
  2034. /* 78 */
  2035. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2036. __w_pdfjs_require__(79);
  2037. /***/ }),
  2038. /* 79 */
  2039. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2040. "use strict";
  2041. var ArrayBufferViewCore = __w_pdfjs_require__(80);
  2042. var lengthOfArrayLike = __w_pdfjs_require__(67);
  2043. var toIntegerOrInfinity = __w_pdfjs_require__(65);
  2044. var aTypedArray = ArrayBufferViewCore.aTypedArray;
  2045. var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;
  2046. exportTypedArrayMethod('at', function at(index) {
  2047. var O = aTypedArray(this);
  2048. var len = lengthOfArrayLike(O);
  2049. var relativeIndex = toIntegerOrInfinity(index);
  2050. var k = relativeIndex >= 0 ? relativeIndex : len + relativeIndex;
  2051. return k < 0 || k >= len ? undefined : O[k];
  2052. });
  2053. /***/ }),
  2054. /* 80 */
  2055. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2056. "use strict";
  2057. var NATIVE_ARRAY_BUFFER = __w_pdfjs_require__(81);
  2058. var DESCRIPTORS = __w_pdfjs_require__(9);
  2059. var global = __w_pdfjs_require__(7);
  2060. var isCallable = __w_pdfjs_require__(24);
  2061. var isObject = __w_pdfjs_require__(23);
  2062. var hasOwn = __w_pdfjs_require__(42);
  2063. var classof = __w_pdfjs_require__(82);
  2064. var tryToString = __w_pdfjs_require__(35);
  2065. var createNonEnumerableProperty = __w_pdfjs_require__(47);
  2066. var defineBuiltIn = __w_pdfjs_require__(51);
  2067. var defineProperty = (__w_pdfjs_require__(48).f);
  2068. var isPrototypeOf = __w_pdfjs_require__(28);
  2069. var getPrototypeOf = __w_pdfjs_require__(84);
  2070. var setPrototypeOf = __w_pdfjs_require__(86);
  2071. var wellKnownSymbol = __w_pdfjs_require__(37);
  2072. var uid = __w_pdfjs_require__(44);
  2073. var InternalStateModule = __w_pdfjs_require__(55);
  2074. var enforceInternalState = InternalStateModule.enforce;
  2075. var getInternalState = InternalStateModule.get;
  2076. var Int8Array = global.Int8Array;
  2077. var Int8ArrayPrototype = Int8Array && Int8Array.prototype;
  2078. var Uint8ClampedArray = global.Uint8ClampedArray;
  2079. var Uint8ClampedArrayPrototype = Uint8ClampedArray && Uint8ClampedArray.prototype;
  2080. var TypedArray = Int8Array && getPrototypeOf(Int8Array);
  2081. var TypedArrayPrototype = Int8ArrayPrototype && getPrototypeOf(Int8ArrayPrototype);
  2082. var ObjectPrototype = Object.prototype;
  2083. var TypeError = global.TypeError;
  2084. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  2085. var TYPED_ARRAY_TAG = uid('TYPED_ARRAY_TAG');
  2086. var TYPED_ARRAY_CONSTRUCTOR = 'TypedArrayConstructor';
  2087. var NATIVE_ARRAY_BUFFER_VIEWS = NATIVE_ARRAY_BUFFER && !!setPrototypeOf && classof(global.opera) !== 'Opera';
  2088. var TYPED_ARRAY_TAG_REQUIRED = false;
  2089. var NAME, Constructor, Prototype;
  2090. var TypedArrayConstructorsList = {
  2091. Int8Array: 1,
  2092. Uint8Array: 1,
  2093. Uint8ClampedArray: 1,
  2094. Int16Array: 2,
  2095. Uint16Array: 2,
  2096. Int32Array: 4,
  2097. Uint32Array: 4,
  2098. Float32Array: 4,
  2099. Float64Array: 8
  2100. };
  2101. var BigIntArrayConstructorsList = {
  2102. BigInt64Array: 8,
  2103. BigUint64Array: 8
  2104. };
  2105. var isView = function isView(it) {
  2106. if (!isObject(it))
  2107. return false;
  2108. var klass = classof(it);
  2109. return klass === 'DataView' || hasOwn(TypedArrayConstructorsList, klass) || hasOwn(BigIntArrayConstructorsList, klass);
  2110. };
  2111. var getTypedArrayConstructor = function (it) {
  2112. var proto = getPrototypeOf(it);
  2113. if (!isObject(proto))
  2114. return;
  2115. var state = getInternalState(proto);
  2116. return state && hasOwn(state, TYPED_ARRAY_CONSTRUCTOR) ? state[TYPED_ARRAY_CONSTRUCTOR] : getTypedArrayConstructor(proto);
  2117. };
  2118. var isTypedArray = function (it) {
  2119. if (!isObject(it))
  2120. return false;
  2121. var klass = classof(it);
  2122. return hasOwn(TypedArrayConstructorsList, klass) || hasOwn(BigIntArrayConstructorsList, klass);
  2123. };
  2124. var aTypedArray = function (it) {
  2125. if (isTypedArray(it))
  2126. return it;
  2127. throw TypeError('Target is not a typed array');
  2128. };
  2129. var aTypedArrayConstructor = function (C) {
  2130. if (isCallable(C) && (!setPrototypeOf || isPrototypeOf(TypedArray, C)))
  2131. return C;
  2132. throw TypeError(tryToString(C) + ' is not a typed array constructor');
  2133. };
  2134. var exportTypedArrayMethod = function (KEY, property, forced, options) {
  2135. if (!DESCRIPTORS)
  2136. return;
  2137. if (forced)
  2138. for (var ARRAY in TypedArrayConstructorsList) {
  2139. var TypedArrayConstructor = global[ARRAY];
  2140. if (TypedArrayConstructor && hasOwn(TypedArrayConstructor.prototype, KEY))
  2141. try {
  2142. delete TypedArrayConstructor.prototype[KEY];
  2143. } catch (error) {
  2144. try {
  2145. TypedArrayConstructor.prototype[KEY] = property;
  2146. } catch (error2) {
  2147. }
  2148. }
  2149. }
  2150. if (!TypedArrayPrototype[KEY] || forced) {
  2151. defineBuiltIn(TypedArrayPrototype, KEY, forced ? property : NATIVE_ARRAY_BUFFER_VIEWS && Int8ArrayPrototype[KEY] || property, options);
  2152. }
  2153. };
  2154. var exportTypedArrayStaticMethod = function (KEY, property, forced) {
  2155. var ARRAY, TypedArrayConstructor;
  2156. if (!DESCRIPTORS)
  2157. return;
  2158. if (setPrototypeOf) {
  2159. if (forced)
  2160. for (ARRAY in TypedArrayConstructorsList) {
  2161. TypedArrayConstructor = global[ARRAY];
  2162. if (TypedArrayConstructor && hasOwn(TypedArrayConstructor, KEY))
  2163. try {
  2164. delete TypedArrayConstructor[KEY];
  2165. } catch (error) {
  2166. }
  2167. }
  2168. if (!TypedArray[KEY] || forced) {
  2169. try {
  2170. return defineBuiltIn(TypedArray, KEY, forced ? property : NATIVE_ARRAY_BUFFER_VIEWS && TypedArray[KEY] || property);
  2171. } catch (error) {
  2172. }
  2173. } else
  2174. return;
  2175. }
  2176. for (ARRAY in TypedArrayConstructorsList) {
  2177. TypedArrayConstructor = global[ARRAY];
  2178. if (TypedArrayConstructor && (!TypedArrayConstructor[KEY] || forced)) {
  2179. defineBuiltIn(TypedArrayConstructor, KEY, property);
  2180. }
  2181. }
  2182. };
  2183. for (NAME in TypedArrayConstructorsList) {
  2184. Constructor = global[NAME];
  2185. Prototype = Constructor && Constructor.prototype;
  2186. if (Prototype)
  2187. enforceInternalState(Prototype)[TYPED_ARRAY_CONSTRUCTOR] = Constructor;
  2188. else
  2189. NATIVE_ARRAY_BUFFER_VIEWS = false;
  2190. }
  2191. for (NAME in BigIntArrayConstructorsList) {
  2192. Constructor = global[NAME];
  2193. Prototype = Constructor && Constructor.prototype;
  2194. if (Prototype)
  2195. enforceInternalState(Prototype)[TYPED_ARRAY_CONSTRUCTOR] = Constructor;
  2196. }
  2197. if (!NATIVE_ARRAY_BUFFER_VIEWS || !isCallable(TypedArray) || TypedArray === Function.prototype) {
  2198. TypedArray = function TypedArray() {
  2199. throw TypeError('Incorrect invocation');
  2200. };
  2201. if (NATIVE_ARRAY_BUFFER_VIEWS)
  2202. for (NAME in TypedArrayConstructorsList) {
  2203. if (global[NAME])
  2204. setPrototypeOf(global[NAME], TypedArray);
  2205. }
  2206. }
  2207. if (!NATIVE_ARRAY_BUFFER_VIEWS || !TypedArrayPrototype || TypedArrayPrototype === ObjectPrototype) {
  2208. TypedArrayPrototype = TypedArray.prototype;
  2209. if (NATIVE_ARRAY_BUFFER_VIEWS)
  2210. for (NAME in TypedArrayConstructorsList) {
  2211. if (global[NAME])
  2212. setPrototypeOf(global[NAME].prototype, TypedArrayPrototype);
  2213. }
  2214. }
  2215. if (NATIVE_ARRAY_BUFFER_VIEWS && getPrototypeOf(Uint8ClampedArrayPrototype) !== TypedArrayPrototype) {
  2216. setPrototypeOf(Uint8ClampedArrayPrototype, TypedArrayPrototype);
  2217. }
  2218. if (DESCRIPTORS && !hasOwn(TypedArrayPrototype, TO_STRING_TAG)) {
  2219. TYPED_ARRAY_TAG_REQUIRED = true;
  2220. defineProperty(TypedArrayPrototype, TO_STRING_TAG, {
  2221. get: function () {
  2222. return isObject(this) ? this[TYPED_ARRAY_TAG] : undefined;
  2223. }
  2224. });
  2225. for (NAME in TypedArrayConstructorsList)
  2226. if (global[NAME]) {
  2227. createNonEnumerableProperty(global[NAME], TYPED_ARRAY_TAG, NAME);
  2228. }
  2229. }
  2230. module.exports = {
  2231. NATIVE_ARRAY_BUFFER_VIEWS: NATIVE_ARRAY_BUFFER_VIEWS,
  2232. TYPED_ARRAY_TAG: TYPED_ARRAY_TAG_REQUIRED && TYPED_ARRAY_TAG,
  2233. aTypedArray: aTypedArray,
  2234. aTypedArrayConstructor: aTypedArrayConstructor,
  2235. exportTypedArrayMethod: exportTypedArrayMethod,
  2236. exportTypedArrayStaticMethod: exportTypedArrayStaticMethod,
  2237. getTypedArrayConstructor: getTypedArrayConstructor,
  2238. isView: isView,
  2239. isTypedArray: isTypedArray,
  2240. TypedArray: TypedArray,
  2241. TypedArrayPrototype: TypedArrayPrototype
  2242. };
  2243. /***/ }),
  2244. /* 81 */
  2245. /***/ ((module) => {
  2246. module.exports = typeof ArrayBuffer != 'undefined' && typeof DataView != 'undefined';
  2247. /***/ }),
  2248. /* 82 */
  2249. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2250. var TO_STRING_TAG_SUPPORT = __w_pdfjs_require__(83);
  2251. var isCallable = __w_pdfjs_require__(24);
  2252. var classofRaw = __w_pdfjs_require__(18);
  2253. var wellKnownSymbol = __w_pdfjs_require__(37);
  2254. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  2255. var $Object = Object;
  2256. var CORRECT_ARGUMENTS = classofRaw((function () {
  2257. return arguments;
  2258. }())) == 'Arguments';
  2259. var tryGet = function (it, key) {
  2260. try {
  2261. return it[key];
  2262. } catch (error) {
  2263. }
  2264. };
  2265. module.exports = TO_STRING_TAG_SUPPORT ? classofRaw : function (it) {
  2266. var O, tag, result;
  2267. return it === undefined ? 'Undefined' : it === null ? 'Null' : typeof (tag = tryGet(O = $Object(it), TO_STRING_TAG)) == 'string' ? tag : CORRECT_ARGUMENTS ? classofRaw(O) : (result = classofRaw(O)) == 'Object' && isCallable(O.callee) ? 'Arguments' : result;
  2268. };
  2269. /***/ }),
  2270. /* 83 */
  2271. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2272. var wellKnownSymbol = __w_pdfjs_require__(37);
  2273. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  2274. var test = {};
  2275. test[TO_STRING_TAG] = 'z';
  2276. module.exports = String(test) === '[object z]';
  2277. /***/ }),
  2278. /* 84 */
  2279. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2280. var hasOwn = __w_pdfjs_require__(42);
  2281. var isCallable = __w_pdfjs_require__(24);
  2282. var toObject = __w_pdfjs_require__(43);
  2283. var sharedKey = __w_pdfjs_require__(57);
  2284. var CORRECT_PROTOTYPE_GETTER = __w_pdfjs_require__(85);
  2285. var IE_PROTO = sharedKey('IE_PROTO');
  2286. var $Object = Object;
  2287. var ObjectPrototype = $Object.prototype;
  2288. module.exports = CORRECT_PROTOTYPE_GETTER ? $Object.getPrototypeOf : function (O) {
  2289. var object = toObject(O);
  2290. if (hasOwn(object, IE_PROTO))
  2291. return object[IE_PROTO];
  2292. var constructor = object.constructor;
  2293. if (isCallable(constructor) && object instanceof constructor) {
  2294. return constructor.prototype;
  2295. }
  2296. return object instanceof $Object ? ObjectPrototype : null;
  2297. };
  2298. /***/ }),
  2299. /* 85 */
  2300. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2301. var fails = __w_pdfjs_require__(10);
  2302. module.exports = !fails(function () {
  2303. function F() {
  2304. }
  2305. F.prototype.constructor = null;
  2306. return Object.getPrototypeOf(new F()) !== F.prototype;
  2307. });
  2308. /***/ }),
  2309. /* 86 */
  2310. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2311. var uncurryThis = __w_pdfjs_require__(17);
  2312. var anObject = __w_pdfjs_require__(50);
  2313. var aPossiblePrototype = __w_pdfjs_require__(87);
  2314. module.exports = Object.setPrototypeOf || ('__proto__' in {} ? (function () {
  2315. var CORRECT_SETTER = false;
  2316. var test = {};
  2317. var setter;
  2318. try {
  2319. setter = uncurryThis(Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').set);
  2320. setter(test, []);
  2321. CORRECT_SETTER = test instanceof Array;
  2322. } catch (error) {
  2323. }
  2324. return function setPrototypeOf(O, proto) {
  2325. anObject(O);
  2326. aPossiblePrototype(proto);
  2327. if (CORRECT_SETTER)
  2328. setter(O, proto);
  2329. else
  2330. O.__proto__ = proto;
  2331. return O;
  2332. };
  2333. }()) : undefined);
  2334. /***/ }),
  2335. /* 87 */
  2336. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2337. var isCallable = __w_pdfjs_require__(24);
  2338. var $String = String;
  2339. var $TypeError = TypeError;
  2340. module.exports = function (argument) {
  2341. if (typeof argument == 'object' || isCallable(argument))
  2342. return argument;
  2343. throw $TypeError("Can't set " + $String(argument) + ' as a prototype');
  2344. };
  2345. /***/ }),
  2346. /* 88 */
  2347. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2348. __w_pdfjs_require__(89);
  2349. __w_pdfjs_require__(96);
  2350. __w_pdfjs_require__(98);
  2351. __w_pdfjs_require__(121);
  2352. __w_pdfjs_require__(123);
  2353. var path = __w_pdfjs_require__(134);
  2354. module.exports = path.structuredClone;
  2355. /***/ }),
  2356. /* 89 */
  2357. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2358. "use strict";
  2359. var toIndexedObject = __w_pdfjs_require__(15);
  2360. var addToUnscopables = __w_pdfjs_require__(72);
  2361. var Iterators = __w_pdfjs_require__(90);
  2362. var InternalStateModule = __w_pdfjs_require__(55);
  2363. var defineProperty = (__w_pdfjs_require__(48).f);
  2364. var defineIterator = __w_pdfjs_require__(91);
  2365. var createIterResultObject = __w_pdfjs_require__(95);
  2366. var IS_PURE = __w_pdfjs_require__(39);
  2367. var DESCRIPTORS = __w_pdfjs_require__(9);
  2368. var ARRAY_ITERATOR = 'Array Iterator';
  2369. var setInternalState = InternalStateModule.set;
  2370. var getInternalState = InternalStateModule.getterFor(ARRAY_ITERATOR);
  2371. module.exports = defineIterator(Array, 'Array', function (iterated, kind) {
  2372. setInternalState(this, {
  2373. type: ARRAY_ITERATOR,
  2374. target: toIndexedObject(iterated),
  2375. index: 0,
  2376. kind: kind
  2377. });
  2378. }, function () {
  2379. var state = getInternalState(this);
  2380. var target = state.target;
  2381. var kind = state.kind;
  2382. var index = state.index++;
  2383. if (!target || index >= target.length) {
  2384. state.target = undefined;
  2385. return createIterResultObject(undefined, true);
  2386. }
  2387. if (kind == 'keys')
  2388. return createIterResultObject(index, false);
  2389. if (kind == 'values')
  2390. return createIterResultObject(target[index], false);
  2391. return createIterResultObject([
  2392. index,
  2393. target[index]
  2394. ], false);
  2395. }, 'values');
  2396. var values = Iterators.Arguments = Iterators.Array;
  2397. addToUnscopables('keys');
  2398. addToUnscopables('values');
  2399. addToUnscopables('entries');
  2400. if (!IS_PURE && DESCRIPTORS && values.name !== 'values')
  2401. try {
  2402. defineProperty(values, 'name', { value: 'values' });
  2403. } catch (error) {
  2404. }
  2405. /***/ }),
  2406. /* 90 */
  2407. /***/ ((module) => {
  2408. module.exports = {};
  2409. /***/ }),
  2410. /* 91 */
  2411. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2412. "use strict";
  2413. var $ = __w_pdfjs_require__(6);
  2414. var call = __w_pdfjs_require__(11);
  2415. var IS_PURE = __w_pdfjs_require__(39);
  2416. var FunctionName = __w_pdfjs_require__(53);
  2417. var isCallable = __w_pdfjs_require__(24);
  2418. var createIteratorConstructor = __w_pdfjs_require__(92);
  2419. var getPrototypeOf = __w_pdfjs_require__(84);
  2420. var setPrototypeOf = __w_pdfjs_require__(86);
  2421. var setToStringTag = __w_pdfjs_require__(94);
  2422. var createNonEnumerableProperty = __w_pdfjs_require__(47);
  2423. var defineBuiltIn = __w_pdfjs_require__(51);
  2424. var wellKnownSymbol = __w_pdfjs_require__(37);
  2425. var Iterators = __w_pdfjs_require__(90);
  2426. var IteratorsCore = __w_pdfjs_require__(93);
  2427. var PROPER_FUNCTION_NAME = FunctionName.PROPER;
  2428. var CONFIGURABLE_FUNCTION_NAME = FunctionName.CONFIGURABLE;
  2429. var IteratorPrototype = IteratorsCore.IteratorPrototype;
  2430. var BUGGY_SAFARI_ITERATORS = IteratorsCore.BUGGY_SAFARI_ITERATORS;
  2431. var ITERATOR = wellKnownSymbol('iterator');
  2432. var KEYS = 'keys';
  2433. var VALUES = 'values';
  2434. var ENTRIES = 'entries';
  2435. var returnThis = function () {
  2436. return this;
  2437. };
  2438. module.exports = function (Iterable, NAME, IteratorConstructor, next, DEFAULT, IS_SET, FORCED) {
  2439. createIteratorConstructor(IteratorConstructor, NAME, next);
  2440. var getIterationMethod = function (KIND) {
  2441. if (KIND === DEFAULT && defaultIterator)
  2442. return defaultIterator;
  2443. if (!BUGGY_SAFARI_ITERATORS && KIND in IterablePrototype)
  2444. return IterablePrototype[KIND];
  2445. switch (KIND) {
  2446. case KEYS:
  2447. return function keys() {
  2448. return new IteratorConstructor(this, KIND);
  2449. };
  2450. case VALUES:
  2451. return function values() {
  2452. return new IteratorConstructor(this, KIND);
  2453. };
  2454. case ENTRIES:
  2455. return function entries() {
  2456. return new IteratorConstructor(this, KIND);
  2457. };
  2458. }
  2459. return function () {
  2460. return new IteratorConstructor(this);
  2461. };
  2462. };
  2463. var TO_STRING_TAG = NAME + ' Iterator';
  2464. var INCORRECT_VALUES_NAME = false;
  2465. var IterablePrototype = Iterable.prototype;
  2466. var nativeIterator = IterablePrototype[ITERATOR] || IterablePrototype['@@iterator'] || DEFAULT && IterablePrototype[DEFAULT];
  2467. var defaultIterator = !BUGGY_SAFARI_ITERATORS && nativeIterator || getIterationMethod(DEFAULT);
  2468. var anyNativeIterator = NAME == 'Array' ? IterablePrototype.entries || nativeIterator : nativeIterator;
  2469. var CurrentIteratorPrototype, methods, KEY;
  2470. if (anyNativeIterator) {
  2471. CurrentIteratorPrototype = getPrototypeOf(anyNativeIterator.call(new Iterable()));
  2472. if (CurrentIteratorPrototype !== Object.prototype && CurrentIteratorPrototype.next) {
  2473. if (!IS_PURE && getPrototypeOf(CurrentIteratorPrototype) !== IteratorPrototype) {
  2474. if (setPrototypeOf) {
  2475. setPrototypeOf(CurrentIteratorPrototype, IteratorPrototype);
  2476. } else if (!isCallable(CurrentIteratorPrototype[ITERATOR])) {
  2477. defineBuiltIn(CurrentIteratorPrototype, ITERATOR, returnThis);
  2478. }
  2479. }
  2480. setToStringTag(CurrentIteratorPrototype, TO_STRING_TAG, true, true);
  2481. if (IS_PURE)
  2482. Iterators[TO_STRING_TAG] = returnThis;
  2483. }
  2484. }
  2485. if (PROPER_FUNCTION_NAME && DEFAULT == VALUES && nativeIterator && nativeIterator.name !== VALUES) {
  2486. if (!IS_PURE && CONFIGURABLE_FUNCTION_NAME) {
  2487. createNonEnumerableProperty(IterablePrototype, 'name', VALUES);
  2488. } else {
  2489. INCORRECT_VALUES_NAME = true;
  2490. defaultIterator = function values() {
  2491. return call(nativeIterator, this);
  2492. };
  2493. }
  2494. }
  2495. if (DEFAULT) {
  2496. methods = {
  2497. values: getIterationMethod(VALUES),
  2498. keys: IS_SET ? defaultIterator : getIterationMethod(KEYS),
  2499. entries: getIterationMethod(ENTRIES)
  2500. };
  2501. if (FORCED)
  2502. for (KEY in methods) {
  2503. if (BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME || !(KEY in IterablePrototype)) {
  2504. defineBuiltIn(IterablePrototype, KEY, methods[KEY]);
  2505. }
  2506. }
  2507. else
  2508. $({
  2509. target: NAME,
  2510. proto: true,
  2511. forced: BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME
  2512. }, methods);
  2513. }
  2514. if ((!IS_PURE || FORCED) && IterablePrototype[ITERATOR] !== defaultIterator) {
  2515. defineBuiltIn(IterablePrototype, ITERATOR, defaultIterator, { name: DEFAULT });
  2516. }
  2517. Iterators[NAME] = defaultIterator;
  2518. return methods;
  2519. };
  2520. /***/ }),
  2521. /* 92 */
  2522. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2523. "use strict";
  2524. var IteratorPrototype = (__w_pdfjs_require__(93).IteratorPrototype);
  2525. var create = __w_pdfjs_require__(73);
  2526. var createPropertyDescriptor = __w_pdfjs_require__(14);
  2527. var setToStringTag = __w_pdfjs_require__(94);
  2528. var Iterators = __w_pdfjs_require__(90);
  2529. var returnThis = function () {
  2530. return this;
  2531. };
  2532. module.exports = function (IteratorConstructor, NAME, next, ENUMERABLE_NEXT) {
  2533. var TO_STRING_TAG = NAME + ' Iterator';
  2534. IteratorConstructor.prototype = create(IteratorPrototype, { next: createPropertyDescriptor(+!ENUMERABLE_NEXT, next) });
  2535. setToStringTag(IteratorConstructor, TO_STRING_TAG, false, true);
  2536. Iterators[TO_STRING_TAG] = returnThis;
  2537. return IteratorConstructor;
  2538. };
  2539. /***/ }),
  2540. /* 93 */
  2541. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2542. "use strict";
  2543. var fails = __w_pdfjs_require__(10);
  2544. var isCallable = __w_pdfjs_require__(24);
  2545. var isObject = __w_pdfjs_require__(23);
  2546. var create = __w_pdfjs_require__(73);
  2547. var getPrototypeOf = __w_pdfjs_require__(84);
  2548. var defineBuiltIn = __w_pdfjs_require__(51);
  2549. var wellKnownSymbol = __w_pdfjs_require__(37);
  2550. var IS_PURE = __w_pdfjs_require__(39);
  2551. var ITERATOR = wellKnownSymbol('iterator');
  2552. var BUGGY_SAFARI_ITERATORS = false;
  2553. var IteratorPrototype, PrototypeOfArrayIteratorPrototype, arrayIterator;
  2554. if ([].keys) {
  2555. arrayIterator = [].keys();
  2556. if (!('next' in arrayIterator))
  2557. BUGGY_SAFARI_ITERATORS = true;
  2558. else {
  2559. PrototypeOfArrayIteratorPrototype = getPrototypeOf(getPrototypeOf(arrayIterator));
  2560. if (PrototypeOfArrayIteratorPrototype !== Object.prototype)
  2561. IteratorPrototype = PrototypeOfArrayIteratorPrototype;
  2562. }
  2563. }
  2564. var NEW_ITERATOR_PROTOTYPE = !isObject(IteratorPrototype) || fails(function () {
  2565. var test = {};
  2566. return IteratorPrototype[ITERATOR].call(test) !== test;
  2567. });
  2568. if (NEW_ITERATOR_PROTOTYPE)
  2569. IteratorPrototype = {};
  2570. else if (IS_PURE)
  2571. IteratorPrototype = create(IteratorPrototype);
  2572. if (!isCallable(IteratorPrototype[ITERATOR])) {
  2573. defineBuiltIn(IteratorPrototype, ITERATOR, function () {
  2574. return this;
  2575. });
  2576. }
  2577. module.exports = {
  2578. IteratorPrototype: IteratorPrototype,
  2579. BUGGY_SAFARI_ITERATORS: BUGGY_SAFARI_ITERATORS
  2580. };
  2581. /***/ }),
  2582. /* 94 */
  2583. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2584. var defineProperty = (__w_pdfjs_require__(48).f);
  2585. var hasOwn = __w_pdfjs_require__(42);
  2586. var wellKnownSymbol = __w_pdfjs_require__(37);
  2587. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  2588. module.exports = function (target, TAG, STATIC) {
  2589. if (target && !STATIC)
  2590. target = target.prototype;
  2591. if (target && !hasOwn(target, TO_STRING_TAG)) {
  2592. defineProperty(target, TO_STRING_TAG, {
  2593. configurable: true,
  2594. value: TAG
  2595. });
  2596. }
  2597. };
  2598. /***/ }),
  2599. /* 95 */
  2600. /***/ ((module) => {
  2601. module.exports = function (value, done) {
  2602. return {
  2603. value: value,
  2604. done: done
  2605. };
  2606. };
  2607. /***/ }),
  2608. /* 96 */
  2609. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2610. var TO_STRING_TAG_SUPPORT = __w_pdfjs_require__(83);
  2611. var defineBuiltIn = __w_pdfjs_require__(51);
  2612. var toString = __w_pdfjs_require__(97);
  2613. if (!TO_STRING_TAG_SUPPORT) {
  2614. defineBuiltIn(Object.prototype, 'toString', toString, { unsafe: true });
  2615. }
  2616. /***/ }),
  2617. /* 97 */
  2618. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2619. "use strict";
  2620. var TO_STRING_TAG_SUPPORT = __w_pdfjs_require__(83);
  2621. var classof = __w_pdfjs_require__(82);
  2622. module.exports = TO_STRING_TAG_SUPPORT ? {}.toString : function toString() {
  2623. return '[object ' + classof(this) + ']';
  2624. };
  2625. /***/ }),
  2626. /* 98 */
  2627. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2628. __w_pdfjs_require__(99);
  2629. /***/ }),
  2630. /* 99 */
  2631. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2632. "use strict";
  2633. var collection = __w_pdfjs_require__(100);
  2634. var collectionStrong = __w_pdfjs_require__(118);
  2635. collection('Map', function (init) {
  2636. return function Map() {
  2637. return init(this, arguments.length ? arguments[0] : undefined);
  2638. };
  2639. }, collectionStrong);
  2640. /***/ }),
  2641. /* 100 */
  2642. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2643. "use strict";
  2644. var $ = __w_pdfjs_require__(6);
  2645. var global = __w_pdfjs_require__(7);
  2646. var uncurryThis = __w_pdfjs_require__(17);
  2647. var isForced = __w_pdfjs_require__(71);
  2648. var defineBuiltIn = __w_pdfjs_require__(51);
  2649. var InternalMetadataModule = __w_pdfjs_require__(101);
  2650. var iterate = __w_pdfjs_require__(108);
  2651. var anInstance = __w_pdfjs_require__(115);
  2652. var isCallable = __w_pdfjs_require__(24);
  2653. var isNullOrUndefined = __w_pdfjs_require__(20);
  2654. var isObject = __w_pdfjs_require__(23);
  2655. var fails = __w_pdfjs_require__(10);
  2656. var checkCorrectnessOfIteration = __w_pdfjs_require__(116);
  2657. var setToStringTag = __w_pdfjs_require__(94);
  2658. var inheritIfRequired = __w_pdfjs_require__(117);
  2659. module.exports = function (CONSTRUCTOR_NAME, wrapper, common) {
  2660. var IS_MAP = CONSTRUCTOR_NAME.indexOf('Map') !== -1;
  2661. var IS_WEAK = CONSTRUCTOR_NAME.indexOf('Weak') !== -1;
  2662. var ADDER = IS_MAP ? 'set' : 'add';
  2663. var NativeConstructor = global[CONSTRUCTOR_NAME];
  2664. var NativePrototype = NativeConstructor && NativeConstructor.prototype;
  2665. var Constructor = NativeConstructor;
  2666. var exported = {};
  2667. var fixMethod = function (KEY) {
  2668. var uncurriedNativeMethod = uncurryThis(NativePrototype[KEY]);
  2669. defineBuiltIn(NativePrototype, KEY, KEY == 'add' ? function add(value) {
  2670. uncurriedNativeMethod(this, value === 0 ? 0 : value);
  2671. return this;
  2672. } : KEY == 'delete' ? function (key) {
  2673. return IS_WEAK && !isObject(key) ? false : uncurriedNativeMethod(this, key === 0 ? 0 : key);
  2674. } : KEY == 'get' ? function get(key) {
  2675. return IS_WEAK && !isObject(key) ? undefined : uncurriedNativeMethod(this, key === 0 ? 0 : key);
  2676. } : KEY == 'has' ? function has(key) {
  2677. return IS_WEAK && !isObject(key) ? false : uncurriedNativeMethod(this, key === 0 ? 0 : key);
  2678. } : function set(key, value) {
  2679. uncurriedNativeMethod(this, key === 0 ? 0 : key, value);
  2680. return this;
  2681. });
  2682. };
  2683. var REPLACE = isForced(CONSTRUCTOR_NAME, !isCallable(NativeConstructor) || !(IS_WEAK || NativePrototype.forEach && !fails(function () {
  2684. new NativeConstructor().entries().next();
  2685. })));
  2686. if (REPLACE) {
  2687. Constructor = common.getConstructor(wrapper, CONSTRUCTOR_NAME, IS_MAP, ADDER);
  2688. InternalMetadataModule.enable();
  2689. } else if (isForced(CONSTRUCTOR_NAME, true)) {
  2690. var instance = new Constructor();
  2691. var HASNT_CHAINING = instance[ADDER](IS_WEAK ? {} : -0, 1) != instance;
  2692. var THROWS_ON_PRIMITIVES = fails(function () {
  2693. instance.has(1);
  2694. });
  2695. var ACCEPT_ITERABLES = checkCorrectnessOfIteration(function (iterable) {
  2696. new NativeConstructor(iterable);
  2697. });
  2698. var BUGGY_ZERO = !IS_WEAK && fails(function () {
  2699. var $instance = new NativeConstructor();
  2700. var index = 5;
  2701. while (index--)
  2702. $instance[ADDER](index, index);
  2703. return !$instance.has(-0);
  2704. });
  2705. if (!ACCEPT_ITERABLES) {
  2706. Constructor = wrapper(function (dummy, iterable) {
  2707. anInstance(dummy, NativePrototype);
  2708. var that = inheritIfRequired(new NativeConstructor(), dummy, Constructor);
  2709. if (!isNullOrUndefined(iterable))
  2710. iterate(iterable, that[ADDER], {
  2711. that: that,
  2712. AS_ENTRIES: IS_MAP
  2713. });
  2714. return that;
  2715. });
  2716. Constructor.prototype = NativePrototype;
  2717. NativePrototype.constructor = Constructor;
  2718. }
  2719. if (THROWS_ON_PRIMITIVES || BUGGY_ZERO) {
  2720. fixMethod('delete');
  2721. fixMethod('has');
  2722. IS_MAP && fixMethod('get');
  2723. }
  2724. if (BUGGY_ZERO || HASNT_CHAINING)
  2725. fixMethod(ADDER);
  2726. if (IS_WEAK && NativePrototype.clear)
  2727. delete NativePrototype.clear;
  2728. }
  2729. exported[CONSTRUCTOR_NAME] = Constructor;
  2730. $({
  2731. global: true,
  2732. constructor: true,
  2733. forced: Constructor != NativeConstructor
  2734. }, exported);
  2735. setToStringTag(Constructor, CONSTRUCTOR_NAME);
  2736. if (!IS_WEAK)
  2737. common.setStrong(Constructor, CONSTRUCTOR_NAME, IS_MAP);
  2738. return Constructor;
  2739. };
  2740. /***/ }),
  2741. /* 101 */
  2742. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2743. var $ = __w_pdfjs_require__(6);
  2744. var uncurryThis = __w_pdfjs_require__(17);
  2745. var hiddenKeys = __w_pdfjs_require__(58);
  2746. var isObject = __w_pdfjs_require__(23);
  2747. var hasOwn = __w_pdfjs_require__(42);
  2748. var defineProperty = (__w_pdfjs_require__(48).f);
  2749. var getOwnPropertyNamesModule = __w_pdfjs_require__(61);
  2750. var getOwnPropertyNamesExternalModule = __w_pdfjs_require__(102);
  2751. var isExtensible = __w_pdfjs_require__(105);
  2752. var uid = __w_pdfjs_require__(44);
  2753. var FREEZING = __w_pdfjs_require__(107);
  2754. var REQUIRED = false;
  2755. var METADATA = uid('meta');
  2756. var id = 0;
  2757. var setMetadata = function (it) {
  2758. defineProperty(it, METADATA, {
  2759. value: {
  2760. objectID: 'O' + id++,
  2761. weakData: {}
  2762. }
  2763. });
  2764. };
  2765. var fastKey = function (it, create) {
  2766. if (!isObject(it))
  2767. return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it;
  2768. if (!hasOwn(it, METADATA)) {
  2769. if (!isExtensible(it))
  2770. return 'F';
  2771. if (!create)
  2772. return 'E';
  2773. setMetadata(it);
  2774. }
  2775. return it[METADATA].objectID;
  2776. };
  2777. var getWeakData = function (it, create) {
  2778. if (!hasOwn(it, METADATA)) {
  2779. if (!isExtensible(it))
  2780. return true;
  2781. if (!create)
  2782. return false;
  2783. setMetadata(it);
  2784. }
  2785. return it[METADATA].weakData;
  2786. };
  2787. var onFreeze = function (it) {
  2788. if (FREEZING && REQUIRED && isExtensible(it) && !hasOwn(it, METADATA))
  2789. setMetadata(it);
  2790. return it;
  2791. };
  2792. var enable = function () {
  2793. meta.enable = function () {
  2794. };
  2795. REQUIRED = true;
  2796. var getOwnPropertyNames = getOwnPropertyNamesModule.f;
  2797. var splice = uncurryThis([].splice);
  2798. var test = {};
  2799. test[METADATA] = 1;
  2800. if (getOwnPropertyNames(test).length) {
  2801. getOwnPropertyNamesModule.f = function (it) {
  2802. var result = getOwnPropertyNames(it);
  2803. for (var i = 0, length = result.length; i < length; i++) {
  2804. if (result[i] === METADATA) {
  2805. splice(result, i, 1);
  2806. break;
  2807. }
  2808. }
  2809. return result;
  2810. };
  2811. $({
  2812. target: 'Object',
  2813. stat: true,
  2814. forced: true
  2815. }, { getOwnPropertyNames: getOwnPropertyNamesExternalModule.f });
  2816. }
  2817. };
  2818. var meta = module.exports = {
  2819. enable: enable,
  2820. fastKey: fastKey,
  2821. getWeakData: getWeakData,
  2822. onFreeze: onFreeze
  2823. };
  2824. hiddenKeys[METADATA] = true;
  2825. /***/ }),
  2826. /* 102 */
  2827. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2828. var classof = __w_pdfjs_require__(18);
  2829. var toIndexedObject = __w_pdfjs_require__(15);
  2830. var $getOwnPropertyNames = (__w_pdfjs_require__(61).f);
  2831. var arraySlice = __w_pdfjs_require__(103);
  2832. var windowNames = typeof window == 'object' && window && Object.getOwnPropertyNames ? Object.getOwnPropertyNames(window) : [];
  2833. var getWindowNames = function (it) {
  2834. try {
  2835. return $getOwnPropertyNames(it);
  2836. } catch (error) {
  2837. return arraySlice(windowNames);
  2838. }
  2839. };
  2840. module.exports.f = function getOwnPropertyNames(it) {
  2841. return windowNames && classof(it) == 'Window' ? getWindowNames(it) : $getOwnPropertyNames(toIndexedObject(it));
  2842. };
  2843. /***/ }),
  2844. /* 103 */
  2845. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2846. var toAbsoluteIndex = __w_pdfjs_require__(64);
  2847. var lengthOfArrayLike = __w_pdfjs_require__(67);
  2848. var createProperty = __w_pdfjs_require__(104);
  2849. var $Array = Array;
  2850. var max = Math.max;
  2851. module.exports = function (O, start, end) {
  2852. var length = lengthOfArrayLike(O);
  2853. var k = toAbsoluteIndex(start, length);
  2854. var fin = toAbsoluteIndex(end === undefined ? length : end, length);
  2855. var result = $Array(max(fin - k, 0));
  2856. for (var n = 0; k < fin; k++, n++)
  2857. createProperty(result, n, O[k]);
  2858. result.length = n;
  2859. return result;
  2860. };
  2861. /***/ }),
  2862. /* 104 */
  2863. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2864. "use strict";
  2865. var toPropertyKey = __w_pdfjs_require__(21);
  2866. var definePropertyModule = __w_pdfjs_require__(48);
  2867. var createPropertyDescriptor = __w_pdfjs_require__(14);
  2868. module.exports = function (object, key, value) {
  2869. var propertyKey = toPropertyKey(key);
  2870. if (propertyKey in object)
  2871. definePropertyModule.f(object, propertyKey, createPropertyDescriptor(0, value));
  2872. else
  2873. object[propertyKey] = value;
  2874. };
  2875. /***/ }),
  2876. /* 105 */
  2877. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2878. var fails = __w_pdfjs_require__(10);
  2879. var isObject = __w_pdfjs_require__(23);
  2880. var classof = __w_pdfjs_require__(18);
  2881. var ARRAY_BUFFER_NON_EXTENSIBLE = __w_pdfjs_require__(106);
  2882. var $isExtensible = Object.isExtensible;
  2883. var FAILS_ON_PRIMITIVES = fails(function () {
  2884. $isExtensible(1);
  2885. });
  2886. module.exports = FAILS_ON_PRIMITIVES || ARRAY_BUFFER_NON_EXTENSIBLE ? function isExtensible(it) {
  2887. if (!isObject(it))
  2888. return false;
  2889. if (ARRAY_BUFFER_NON_EXTENSIBLE && classof(it) == 'ArrayBuffer')
  2890. return false;
  2891. return $isExtensible ? $isExtensible(it) : true;
  2892. } : $isExtensible;
  2893. /***/ }),
  2894. /* 106 */
  2895. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2896. var fails = __w_pdfjs_require__(10);
  2897. module.exports = fails(function () {
  2898. if (typeof ArrayBuffer == 'function') {
  2899. var buffer = new ArrayBuffer(8);
  2900. if (Object.isExtensible(buffer))
  2901. Object.defineProperty(buffer, 'a', { value: 8 });
  2902. }
  2903. });
  2904. /***/ }),
  2905. /* 107 */
  2906. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2907. var fails = __w_pdfjs_require__(10);
  2908. module.exports = !fails(function () {
  2909. return Object.isExtensible(Object.preventExtensions({}));
  2910. });
  2911. /***/ }),
  2912. /* 108 */
  2913. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2914. var bind = __w_pdfjs_require__(109);
  2915. var call = __w_pdfjs_require__(11);
  2916. var anObject = __w_pdfjs_require__(50);
  2917. var tryToString = __w_pdfjs_require__(35);
  2918. var isArrayIteratorMethod = __w_pdfjs_require__(111);
  2919. var lengthOfArrayLike = __w_pdfjs_require__(67);
  2920. var isPrototypeOf = __w_pdfjs_require__(28);
  2921. var getIterator = __w_pdfjs_require__(112);
  2922. var getIteratorMethod = __w_pdfjs_require__(113);
  2923. var iteratorClose = __w_pdfjs_require__(114);
  2924. var $TypeError = TypeError;
  2925. var Result = function (stopped, result) {
  2926. this.stopped = stopped;
  2927. this.result = result;
  2928. };
  2929. var ResultPrototype = Result.prototype;
  2930. module.exports = function (iterable, unboundFunction, options) {
  2931. var that = options && options.that;
  2932. var AS_ENTRIES = !!(options && options.AS_ENTRIES);
  2933. var IS_RECORD = !!(options && options.IS_RECORD);
  2934. var IS_ITERATOR = !!(options && options.IS_ITERATOR);
  2935. var INTERRUPTED = !!(options && options.INTERRUPTED);
  2936. var fn = bind(unboundFunction, that);
  2937. var iterator, iterFn, index, length, result, next, step;
  2938. var stop = function (condition) {
  2939. if (iterator)
  2940. iteratorClose(iterator, 'normal', condition);
  2941. return new Result(true, condition);
  2942. };
  2943. var callFn = function (value) {
  2944. if (AS_ENTRIES) {
  2945. anObject(value);
  2946. return INTERRUPTED ? fn(value[0], value[1], stop) : fn(value[0], value[1]);
  2947. }
  2948. return INTERRUPTED ? fn(value, stop) : fn(value);
  2949. };
  2950. if (IS_RECORD) {
  2951. iterator = iterable.iterator;
  2952. } else if (IS_ITERATOR) {
  2953. iterator = iterable;
  2954. } else {
  2955. iterFn = getIteratorMethod(iterable);
  2956. if (!iterFn)
  2957. throw $TypeError(tryToString(iterable) + ' is not iterable');
  2958. if (isArrayIteratorMethod(iterFn)) {
  2959. for (index = 0, length = lengthOfArrayLike(iterable); length > index; index++) {
  2960. result = callFn(iterable[index]);
  2961. if (result && isPrototypeOf(ResultPrototype, result))
  2962. return result;
  2963. }
  2964. return new Result(false);
  2965. }
  2966. iterator = getIterator(iterable, iterFn);
  2967. }
  2968. next = IS_RECORD ? iterable.next : iterator.next;
  2969. while (!(step = call(next, iterator)).done) {
  2970. try {
  2971. result = callFn(step.value);
  2972. } catch (error) {
  2973. iteratorClose(iterator, 'throw', error);
  2974. }
  2975. if (typeof result == 'object' && result && isPrototypeOf(ResultPrototype, result))
  2976. return result;
  2977. }
  2978. return new Result(false);
  2979. };
  2980. /***/ }),
  2981. /* 109 */
  2982. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2983. var uncurryThis = __w_pdfjs_require__(110);
  2984. var aCallable = __w_pdfjs_require__(34);
  2985. var NATIVE_BIND = __w_pdfjs_require__(12);
  2986. var bind = uncurryThis(uncurryThis.bind);
  2987. module.exports = function (fn, that) {
  2988. aCallable(fn);
  2989. return that === undefined ? fn : NATIVE_BIND ? bind(fn, that) : function () {
  2990. return fn.apply(that, arguments);
  2991. };
  2992. };
  2993. /***/ }),
  2994. /* 110 */
  2995. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2996. var classofRaw = __w_pdfjs_require__(18);
  2997. var uncurryThis = __w_pdfjs_require__(17);
  2998. module.exports = function (fn) {
  2999. if (classofRaw(fn) === 'Function')
  3000. return uncurryThis(fn);
  3001. };
  3002. /***/ }),
  3003. /* 111 */
  3004. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  3005. var wellKnownSymbol = __w_pdfjs_require__(37);
  3006. var Iterators = __w_pdfjs_require__(90);
  3007. var ITERATOR = wellKnownSymbol('iterator');
  3008. var ArrayPrototype = Array.prototype;
  3009. module.exports = function (it) {
  3010. return it !== undefined && (Iterators.Array === it || ArrayPrototype[ITERATOR] === it);
  3011. };
  3012. /***/ }),
  3013. /* 112 */
  3014. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  3015. var call = __w_pdfjs_require__(11);
  3016. var aCallable = __w_pdfjs_require__(34);
  3017. var anObject = __w_pdfjs_require__(50);
  3018. var tryToString = __w_pdfjs_require__(35);
  3019. var getIteratorMethod = __w_pdfjs_require__(113);
  3020. var $TypeError = TypeError;
  3021. module.exports = function (argument, usingIterator) {
  3022. var iteratorMethod = arguments.length < 2 ? getIteratorMethod(argument) : usingIterator;
  3023. if (aCallable(iteratorMethod))
  3024. return anObject(call(iteratorMethod, argument));
  3025. throw $TypeError(tryToString(argument) + ' is not iterable');
  3026. };
  3027. /***/ }),
  3028. /* 113 */
  3029. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  3030. var classof = __w_pdfjs_require__(82);
  3031. var getMethod = __w_pdfjs_require__(33);
  3032. var isNullOrUndefined = __w_pdfjs_require__(20);
  3033. var Iterators = __w_pdfjs_require__(90);
  3034. var wellKnownSymbol = __w_pdfjs_require__(37);
  3035. var ITERATOR = wellKnownSymbol('iterator');
  3036. module.exports = function (it) {
  3037. if (!isNullOrUndefined(it))
  3038. return getMethod(it, ITERATOR) || getMethod(it, '@@iterator') || Iterators[classof(it)];
  3039. };
  3040. /***/ }),
  3041. /* 114 */
  3042. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  3043. var call = __w_pdfjs_require__(11);
  3044. var anObject = __w_pdfjs_require__(50);
  3045. var getMethod = __w_pdfjs_require__(33);
  3046. module.exports = function (iterator, kind, value) {
  3047. var innerResult, innerError;
  3048. anObject(iterator);
  3049. try {
  3050. innerResult = getMethod(iterator, 'return');
  3051. if (!innerResult) {
  3052. if (kind === 'throw')
  3053. throw value;
  3054. return value;
  3055. }
  3056. innerResult = call(innerResult, iterator);
  3057. } catch (error) {
  3058. innerError = true;
  3059. innerResult = error;
  3060. }
  3061. if (kind === 'throw')
  3062. throw value;
  3063. if (innerError)
  3064. throw innerResult;
  3065. anObject(innerResult);
  3066. return value;
  3067. };
  3068. /***/ }),
  3069. /* 115 */
  3070. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  3071. var isPrototypeOf = __w_pdfjs_require__(28);
  3072. var $TypeError = TypeError;
  3073. module.exports = function (it, Prototype) {
  3074. if (isPrototypeOf(Prototype, it))
  3075. return it;
  3076. throw $TypeError('Incorrect invocation');
  3077. };
  3078. /***/ }),
  3079. /* 116 */
  3080. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  3081. var wellKnownSymbol = __w_pdfjs_require__(37);
  3082. var ITERATOR = wellKnownSymbol('iterator');
  3083. var SAFE_CLOSING = false;
  3084. try {
  3085. var called = 0;
  3086. var iteratorWithReturn = {
  3087. next: function () {
  3088. return { done: !!called++ };
  3089. },
  3090. 'return': function () {
  3091. SAFE_CLOSING = true;
  3092. }
  3093. };
  3094. iteratorWithReturn[ITERATOR] = function () {
  3095. return this;
  3096. };
  3097. Array.from(iteratorWithReturn, function () {
  3098. throw 2;
  3099. });
  3100. } catch (error) {
  3101. }
  3102. module.exports = function (exec, SKIP_CLOSING) {
  3103. if (!SKIP_CLOSING && !SAFE_CLOSING)
  3104. return false;
  3105. var ITERATION_SUPPORT = false;
  3106. try {
  3107. var object = {};
  3108. object[ITERATOR] = function () {
  3109. return {
  3110. next: function () {
  3111. return { done: ITERATION_SUPPORT = true };
  3112. }
  3113. };
  3114. };
  3115. exec(object);
  3116. } catch (error) {
  3117. }
  3118. return ITERATION_SUPPORT;
  3119. };
  3120. /***/ }),
  3121. /* 117 */
  3122. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  3123. var isCallable = __w_pdfjs_require__(24);
  3124. var isObject = __w_pdfjs_require__(23);
  3125. var setPrototypeOf = __w_pdfjs_require__(86);
  3126. module.exports = function ($this, dummy, Wrapper) {
  3127. var NewTarget, NewTargetPrototype;
  3128. if (setPrototypeOf && isCallable(NewTarget = dummy.constructor) && NewTarget !== Wrapper && isObject(NewTargetPrototype = NewTarget.prototype) && NewTargetPrototype !== Wrapper.prototype)
  3129. setPrototypeOf($this, NewTargetPrototype);
  3130. return $this;
  3131. };
  3132. /***/ }),
  3133. /* 118 */
  3134. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  3135. "use strict";
  3136. var defineProperty = (__w_pdfjs_require__(48).f);
  3137. var create = __w_pdfjs_require__(73);
  3138. var defineBuiltIns = __w_pdfjs_require__(119);
  3139. var bind = __w_pdfjs_require__(109);
  3140. var anInstance = __w_pdfjs_require__(115);
  3141. var isNullOrUndefined = __w_pdfjs_require__(20);
  3142. var iterate = __w_pdfjs_require__(108);
  3143. var defineIterator = __w_pdfjs_require__(91);
  3144. var createIterResultObject = __w_pdfjs_require__(95);
  3145. var setSpecies = __w_pdfjs_require__(120);
  3146. var DESCRIPTORS = __w_pdfjs_require__(9);
  3147. var fastKey = (__w_pdfjs_require__(101).fastKey);
  3148. var InternalStateModule = __w_pdfjs_require__(55);
  3149. var setInternalState = InternalStateModule.set;
  3150. var internalStateGetterFor = InternalStateModule.getterFor;
  3151. module.exports = {
  3152. getConstructor: function (wrapper, CONSTRUCTOR_NAME, IS_MAP, ADDER) {
  3153. var Constructor = wrapper(function (that, iterable) {
  3154. anInstance(that, Prototype);
  3155. setInternalState(that, {
  3156. type: CONSTRUCTOR_NAME,
  3157. index: create(null),
  3158. first: undefined,
  3159. last: undefined,
  3160. size: 0
  3161. });
  3162. if (!DESCRIPTORS)
  3163. that.size = 0;
  3164. if (!isNullOrUndefined(iterable))
  3165. iterate(iterable, that[ADDER], {
  3166. that: that,
  3167. AS_ENTRIES: IS_MAP
  3168. });
  3169. });
  3170. var Prototype = Constructor.prototype;
  3171. var getInternalState = internalStateGetterFor(CONSTRUCTOR_NAME);
  3172. var define = function (that, key, value) {
  3173. var state = getInternalState(that);
  3174. var entry = getEntry(that, key);
  3175. var previous, index;
  3176. if (entry) {
  3177. entry.value = value;
  3178. } else {
  3179. state.last = entry = {
  3180. index: index = fastKey(key, true),
  3181. key: key,
  3182. value: value,
  3183. previous: previous = state.last,
  3184. next: undefined,
  3185. removed: false
  3186. };
  3187. if (!state.first)
  3188. state.first = entry;
  3189. if (previous)
  3190. previous.next = entry;
  3191. if (DESCRIPTORS)
  3192. state.size++;
  3193. else
  3194. that.size++;
  3195. if (index !== 'F')
  3196. state.index[index] = entry;
  3197. }
  3198. return that;
  3199. };
  3200. var getEntry = function (that, key) {
  3201. var state = getInternalState(that);
  3202. var index = fastKey(key);
  3203. var entry;
  3204. if (index !== 'F')
  3205. return state.index[index];
  3206. for (entry = state.first; entry; entry = entry.next) {
  3207. if (entry.key == key)
  3208. return entry;
  3209. }
  3210. };
  3211. defineBuiltIns(Prototype, {
  3212. clear: function clear() {
  3213. var that = this;
  3214. var state = getInternalState(that);
  3215. var data = state.index;
  3216. var entry = state.first;
  3217. while (entry) {
  3218. entry.removed = true;
  3219. if (entry.previous)
  3220. entry.previous = entry.previous.next = undefined;
  3221. delete data[entry.index];
  3222. entry = entry.next;
  3223. }
  3224. state.first = state.last = undefined;
  3225. if (DESCRIPTORS)
  3226. state.size = 0;
  3227. else
  3228. that.size = 0;
  3229. },
  3230. 'delete': function (key) {
  3231. var that = this;
  3232. var state = getInternalState(that);
  3233. var entry = getEntry(that, key);
  3234. if (entry) {
  3235. var next = entry.next;
  3236. var prev = entry.previous;
  3237. delete state.index[entry.index];
  3238. entry.removed = true;
  3239. if (prev)
  3240. prev.next = next;
  3241. if (next)
  3242. next.previous = prev;
  3243. if (state.first == entry)
  3244. state.first = next;
  3245. if (state.last == entry)
  3246. state.last = prev;
  3247. if (DESCRIPTORS)
  3248. state.size--;
  3249. else
  3250. that.size--;
  3251. }
  3252. return !!entry;
  3253. },
  3254. forEach: function forEach(callbackfn) {
  3255. var state = getInternalState(this);
  3256. var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  3257. var entry;
  3258. while (entry = entry ? entry.next : state.first) {
  3259. boundFunction(entry.value, entry.key, this);
  3260. while (entry && entry.removed)
  3261. entry = entry.previous;
  3262. }
  3263. },
  3264. has: function has(key) {
  3265. return !!getEntry(this, key);
  3266. }
  3267. });
  3268. defineBuiltIns(Prototype, IS_MAP ? {
  3269. get: function get(key) {
  3270. var entry = getEntry(this, key);
  3271. return entry && entry.value;
  3272. },
  3273. set: function set(key, value) {
  3274. return define(this, key === 0 ? 0 : key, value);
  3275. }
  3276. } : {
  3277. add: function add(value) {
  3278. return define(this, value = value === 0 ? 0 : value, value);
  3279. }
  3280. });
  3281. if (DESCRIPTORS)
  3282. defineProperty(Prototype, 'size', {
  3283. get: function () {
  3284. return getInternalState(this).size;
  3285. }
  3286. });
  3287. return Constructor;
  3288. },
  3289. setStrong: function (Constructor, CONSTRUCTOR_NAME, IS_MAP) {
  3290. var ITERATOR_NAME = CONSTRUCTOR_NAME + ' Iterator';
  3291. var getInternalCollectionState = internalStateGetterFor(CONSTRUCTOR_NAME);
  3292. var getInternalIteratorState = internalStateGetterFor(ITERATOR_NAME);
  3293. defineIterator(Constructor, CONSTRUCTOR_NAME, function (iterated, kind) {
  3294. setInternalState(this, {
  3295. type: ITERATOR_NAME,
  3296. target: iterated,
  3297. state: getInternalCollectionState(iterated),
  3298. kind: kind,
  3299. last: undefined
  3300. });
  3301. }, function () {
  3302. var state = getInternalIteratorState(this);
  3303. var kind = state.kind;
  3304. var entry = state.last;
  3305. while (entry && entry.removed)
  3306. entry = entry.previous;
  3307. if (!state.target || !(state.last = entry = entry ? entry.next : state.state.first)) {
  3308. state.target = undefined;
  3309. return createIterResultObject(undefined, true);
  3310. }
  3311. if (kind == 'keys')
  3312. return createIterResultObject(entry.key, false);
  3313. if (kind == 'values')
  3314. return createIterResultObject(entry.value, false);
  3315. return createIterResultObject([
  3316. entry.key,
  3317. entry.value
  3318. ], false);
  3319. }, IS_MAP ? 'entries' : 'values', !IS_MAP, true);
  3320. setSpecies(CONSTRUCTOR_NAME);
  3321. }
  3322. };
  3323. /***/ }),
  3324. /* 119 */
  3325. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  3326. var defineBuiltIn = __w_pdfjs_require__(51);
  3327. module.exports = function (target, src, options) {
  3328. for (var key in src)
  3329. defineBuiltIn(target, key, src[key], options);
  3330. return target;
  3331. };
  3332. /***/ }),
  3333. /* 120 */
  3334. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  3335. "use strict";
  3336. var getBuiltIn = __w_pdfjs_require__(27);
  3337. var definePropertyModule = __w_pdfjs_require__(48);
  3338. var wellKnownSymbol = __w_pdfjs_require__(37);
  3339. var DESCRIPTORS = __w_pdfjs_require__(9);
  3340. var SPECIES = wellKnownSymbol('species');
  3341. module.exports = function (CONSTRUCTOR_NAME) {
  3342. var Constructor = getBuiltIn(CONSTRUCTOR_NAME);
  3343. var defineProperty = definePropertyModule.f;
  3344. if (DESCRIPTORS && Constructor && !Constructor[SPECIES]) {
  3345. defineProperty(Constructor, SPECIES, {
  3346. configurable: true,
  3347. get: function () {
  3348. return this;
  3349. }
  3350. });
  3351. }
  3352. };
  3353. /***/ }),
  3354. /* 121 */
  3355. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  3356. __w_pdfjs_require__(122);
  3357. /***/ }),
  3358. /* 122 */
  3359. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  3360. "use strict";
  3361. var collection = __w_pdfjs_require__(100);
  3362. var collectionStrong = __w_pdfjs_require__(118);
  3363. collection('Set', function (init) {
  3364. return function Set() {
  3365. return init(this, arguments.length ? arguments[0] : undefined);
  3366. };
  3367. }, collectionStrong);
  3368. /***/ }),
  3369. /* 123 */
  3370. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  3371. var IS_PURE = __w_pdfjs_require__(39);
  3372. var $ = __w_pdfjs_require__(6);
  3373. var global = __w_pdfjs_require__(7);
  3374. var getBuiltin = __w_pdfjs_require__(27);
  3375. var uncurryThis = __w_pdfjs_require__(17);
  3376. var fails = __w_pdfjs_require__(10);
  3377. var uid = __w_pdfjs_require__(44);
  3378. var isCallable = __w_pdfjs_require__(24);
  3379. var isConstructor = __w_pdfjs_require__(124);
  3380. var isNullOrUndefined = __w_pdfjs_require__(20);
  3381. var isObject = __w_pdfjs_require__(23);
  3382. var isSymbol = __w_pdfjs_require__(26);
  3383. var iterate = __w_pdfjs_require__(108);
  3384. var anObject = __w_pdfjs_require__(50);
  3385. var classof = __w_pdfjs_require__(82);
  3386. var hasOwn = __w_pdfjs_require__(42);
  3387. var createProperty = __w_pdfjs_require__(104);
  3388. var createNonEnumerableProperty = __w_pdfjs_require__(47);
  3389. var lengthOfArrayLike = __w_pdfjs_require__(67);
  3390. var validateArgumentsLength = __w_pdfjs_require__(125);
  3391. var getRegExpFlags = __w_pdfjs_require__(126);
  3392. var MapHelpers = __w_pdfjs_require__(128);
  3393. var SetHelpers = __w_pdfjs_require__(129);
  3394. var ERROR_STACK_INSTALLABLE = __w_pdfjs_require__(130);
  3395. var V8 = __w_pdfjs_require__(31);
  3396. var IS_BROWSER = __w_pdfjs_require__(131);
  3397. var IS_DENO = __w_pdfjs_require__(132);
  3398. var IS_NODE = __w_pdfjs_require__(133);
  3399. var Object = global.Object;
  3400. var Array = global.Array;
  3401. var Date = global.Date;
  3402. var Error = global.Error;
  3403. var EvalError = global.EvalError;
  3404. var RangeError = global.RangeError;
  3405. var ReferenceError = global.ReferenceError;
  3406. var SyntaxError = global.SyntaxError;
  3407. var TypeError = global.TypeError;
  3408. var URIError = global.URIError;
  3409. var PerformanceMark = global.PerformanceMark;
  3410. var WebAssembly = global.WebAssembly;
  3411. var CompileError = WebAssembly && WebAssembly.CompileError || Error;
  3412. var LinkError = WebAssembly && WebAssembly.LinkError || Error;
  3413. var RuntimeError = WebAssembly && WebAssembly.RuntimeError || Error;
  3414. var DOMException = getBuiltin('DOMException');
  3415. var Map = MapHelpers.Map;
  3416. var mapHas = MapHelpers.has;
  3417. var mapGet = MapHelpers.get;
  3418. var mapSet = MapHelpers.set;
  3419. var Set = SetHelpers.Set;
  3420. var setAdd = SetHelpers.add;
  3421. var objectKeys = getBuiltin('Object', 'keys');
  3422. var push = uncurryThis([].push);
  3423. var thisBooleanValue = uncurryThis(true.valueOf);
  3424. var thisNumberValue = uncurryThis(1.0.valueOf);
  3425. var thisStringValue = uncurryThis(''.valueOf);
  3426. var thisTimeValue = uncurryThis(Date.prototype.getTime);
  3427. var PERFORMANCE_MARK = uid('structuredClone');
  3428. var DATA_CLONE_ERROR = 'DataCloneError';
  3429. var TRANSFERRING = 'Transferring';
  3430. var checkBasicSemantic = function (structuredCloneImplementation) {
  3431. return !fails(function () {
  3432. var set1 = new global.Set([7]);
  3433. var set2 = structuredCloneImplementation(set1);
  3434. var number = structuredCloneImplementation(Object(7));
  3435. return set2 == set1 || !set2.has(7) || typeof number != 'object' || number != 7;
  3436. }) && structuredCloneImplementation;
  3437. };
  3438. var checkErrorsCloning = function (structuredCloneImplementation, $Error) {
  3439. return !fails(function () {
  3440. var error = new $Error();
  3441. var test = structuredCloneImplementation({
  3442. a: error,
  3443. b: error
  3444. });
  3445. return !(test && test.a === test.b && test.a instanceof $Error && test.a.stack === error.stack);
  3446. });
  3447. };
  3448. var checkNewErrorsCloningSemantic = function (structuredCloneImplementation) {
  3449. return !fails(function () {
  3450. var test = structuredCloneImplementation(new global.AggregateError([1], PERFORMANCE_MARK, { cause: 3 }));
  3451. return test.name != 'AggregateError' || test.errors[0] != 1 || test.message != PERFORMANCE_MARK || test.cause != 3;
  3452. });
  3453. };
  3454. var nativeStructuredClone = global.structuredClone;
  3455. var FORCED_REPLACEMENT = IS_PURE || !checkErrorsCloning(nativeStructuredClone, Error) || !checkErrorsCloning(nativeStructuredClone, DOMException) || !checkNewErrorsCloningSemantic(nativeStructuredClone);
  3456. var structuredCloneFromMark = !nativeStructuredClone && checkBasicSemantic(function (value) {
  3457. return new PerformanceMark(PERFORMANCE_MARK, { detail: value }).detail;
  3458. });
  3459. var nativeRestrictedStructuredClone = checkBasicSemantic(nativeStructuredClone) || structuredCloneFromMark;
  3460. var throwUncloneable = function (type) {
  3461. throw new DOMException('Uncloneable type: ' + type, DATA_CLONE_ERROR);
  3462. };
  3463. var throwUnpolyfillable = function (type, action) {
  3464. throw new DOMException((action || 'Cloning') + ' of ' + type + ' cannot be properly polyfilled in this engine', DATA_CLONE_ERROR);
  3465. };
  3466. var createDataTransfer = function () {
  3467. var dataTransfer;
  3468. try {
  3469. dataTransfer = new global.DataTransfer();
  3470. } catch (error) {
  3471. try {
  3472. dataTransfer = new global.ClipboardEvent('').clipboardData;
  3473. } catch (error2) {
  3474. }
  3475. }
  3476. return dataTransfer && dataTransfer.items && dataTransfer.files ? dataTransfer : null;
  3477. };
  3478. var structuredCloneInternal = function (value, map) {
  3479. if (isSymbol(value))
  3480. throwUncloneable('Symbol');
  3481. if (!isObject(value))
  3482. return value;
  3483. if (map) {
  3484. if (mapHas(map, value))
  3485. return mapGet(map, value);
  3486. } else
  3487. map = new Map();
  3488. var type = classof(value);
  3489. var deep = false;
  3490. var C, name, cloned, dataTransfer, i, length, keys, key, source, target;
  3491. switch (type) {
  3492. case 'Array':
  3493. cloned = Array(lengthOfArrayLike(value));
  3494. deep = true;
  3495. break;
  3496. case 'Object':
  3497. cloned = {};
  3498. deep = true;
  3499. break;
  3500. case 'Map':
  3501. cloned = new Map();
  3502. deep = true;
  3503. break;
  3504. case 'Set':
  3505. cloned = new Set();
  3506. deep = true;
  3507. break;
  3508. case 'RegExp':
  3509. cloned = new RegExp(value.source, getRegExpFlags(value));
  3510. break;
  3511. case 'Error':
  3512. name = value.name;
  3513. switch (name) {
  3514. case 'AggregateError':
  3515. cloned = getBuiltin('AggregateError')([]);
  3516. break;
  3517. case 'EvalError':
  3518. cloned = EvalError();
  3519. break;
  3520. case 'RangeError':
  3521. cloned = RangeError();
  3522. break;
  3523. case 'ReferenceError':
  3524. cloned = ReferenceError();
  3525. break;
  3526. case 'SyntaxError':
  3527. cloned = SyntaxError();
  3528. break;
  3529. case 'TypeError':
  3530. cloned = TypeError();
  3531. break;
  3532. case 'URIError':
  3533. cloned = URIError();
  3534. break;
  3535. case 'CompileError':
  3536. cloned = CompileError();
  3537. break;
  3538. case 'LinkError':
  3539. cloned = LinkError();
  3540. break;
  3541. case 'RuntimeError':
  3542. cloned = RuntimeError();
  3543. break;
  3544. default:
  3545. cloned = Error();
  3546. }
  3547. deep = true;
  3548. break;
  3549. case 'DOMException':
  3550. cloned = new DOMException(value.message, value.name);
  3551. deep = true;
  3552. break;
  3553. case 'DataView':
  3554. case 'Int8Array':
  3555. case 'Uint8Array':
  3556. case 'Uint8ClampedArray':
  3557. case 'Int16Array':
  3558. case 'Uint16Array':
  3559. case 'Int32Array':
  3560. case 'Uint32Array':
  3561. case 'Float32Array':
  3562. case 'Float64Array':
  3563. case 'BigInt64Array':
  3564. case 'BigUint64Array':
  3565. C = global[type];
  3566. if (!isObject(C))
  3567. throwUnpolyfillable(type);
  3568. cloned = new C(structuredCloneInternal(value.buffer, map), value.byteOffset, type === 'DataView' ? value.byteLength : value.length);
  3569. break;
  3570. case 'DOMQuad':
  3571. try {
  3572. cloned = new DOMQuad(structuredCloneInternal(value.p1, map), structuredCloneInternal(value.p2, map), structuredCloneInternal(value.p3, map), structuredCloneInternal(value.p4, map));
  3573. } catch (error) {
  3574. if (nativeRestrictedStructuredClone) {
  3575. cloned = nativeRestrictedStructuredClone(value);
  3576. } else
  3577. throwUnpolyfillable(type);
  3578. }
  3579. break;
  3580. case 'FileList':
  3581. dataTransfer = createDataTransfer();
  3582. if (dataTransfer) {
  3583. for (i = 0, length = lengthOfArrayLike(value); i < length; i++) {
  3584. dataTransfer.items.add(structuredCloneInternal(value[i], map));
  3585. }
  3586. cloned = dataTransfer.files;
  3587. } else if (nativeRestrictedStructuredClone) {
  3588. cloned = nativeRestrictedStructuredClone(value);
  3589. } else
  3590. throwUnpolyfillable(type);
  3591. break;
  3592. case 'ImageData':
  3593. try {
  3594. cloned = new ImageData(structuredCloneInternal(value.data, map), value.width, value.height, { colorSpace: value.colorSpace });
  3595. } catch (error) {
  3596. if (nativeRestrictedStructuredClone) {
  3597. cloned = nativeRestrictedStructuredClone(value);
  3598. } else
  3599. throwUnpolyfillable(type);
  3600. }
  3601. break;
  3602. default:
  3603. if (nativeRestrictedStructuredClone) {
  3604. cloned = nativeRestrictedStructuredClone(value);
  3605. } else
  3606. switch (type) {
  3607. case 'BigInt':
  3608. cloned = Object(value.valueOf());
  3609. break;
  3610. case 'Boolean':
  3611. cloned = Object(thisBooleanValue(value));
  3612. break;
  3613. case 'Number':
  3614. cloned = Object(thisNumberValue(value));
  3615. break;
  3616. case 'String':
  3617. cloned = Object(thisStringValue(value));
  3618. break;
  3619. case 'Date':
  3620. cloned = new Date(thisTimeValue(value));
  3621. break;
  3622. case 'ArrayBuffer':
  3623. C = global.DataView;
  3624. if (!C && typeof value.slice != 'function')
  3625. throwUnpolyfillable(type);
  3626. try {
  3627. if (typeof value.slice == 'function') {
  3628. cloned = value.slice(0);
  3629. } else {
  3630. length = value.byteLength;
  3631. cloned = new ArrayBuffer(length);
  3632. source = new C(value);
  3633. target = new C(cloned);
  3634. for (i = 0; i < length; i++) {
  3635. target.setUint8(i, source.getUint8(i));
  3636. }
  3637. }
  3638. } catch (error) {
  3639. throw new DOMException('ArrayBuffer is detached', DATA_CLONE_ERROR);
  3640. }
  3641. break;
  3642. case 'SharedArrayBuffer':
  3643. cloned = value;
  3644. break;
  3645. case 'Blob':
  3646. try {
  3647. cloned = value.slice(0, value.size, value.type);
  3648. } catch (error) {
  3649. throwUnpolyfillable(type);
  3650. }
  3651. break;
  3652. case 'DOMPoint':
  3653. case 'DOMPointReadOnly':
  3654. C = global[type];
  3655. try {
  3656. cloned = C.fromPoint ? C.fromPoint(value) : new C(value.x, value.y, value.z, value.w);
  3657. } catch (error) {
  3658. throwUnpolyfillable(type);
  3659. }
  3660. break;
  3661. case 'DOMRect':
  3662. case 'DOMRectReadOnly':
  3663. C = global[type];
  3664. try {
  3665. cloned = C.fromRect ? C.fromRect(value) : new C(value.x, value.y, value.width, value.height);
  3666. } catch (error) {
  3667. throwUnpolyfillable(type);
  3668. }
  3669. break;
  3670. case 'DOMMatrix':
  3671. case 'DOMMatrixReadOnly':
  3672. C = global[type];
  3673. try {
  3674. cloned = C.fromMatrix ? C.fromMatrix(value) : new C(value);
  3675. } catch (error) {
  3676. throwUnpolyfillable(type);
  3677. }
  3678. break;
  3679. case 'AudioData':
  3680. case 'VideoFrame':
  3681. if (!isCallable(value.clone))
  3682. throwUnpolyfillable(type);
  3683. try {
  3684. cloned = value.clone();
  3685. } catch (error) {
  3686. throwUncloneable(type);
  3687. }
  3688. break;
  3689. case 'File':
  3690. try {
  3691. cloned = new File([value], value.name, value);
  3692. } catch (error) {
  3693. throwUnpolyfillable(type);
  3694. }
  3695. break;
  3696. case 'CropTarget':
  3697. case 'CryptoKey':
  3698. case 'FileSystemDirectoryHandle':
  3699. case 'FileSystemFileHandle':
  3700. case 'FileSystemHandle':
  3701. case 'GPUCompilationInfo':
  3702. case 'GPUCompilationMessage':
  3703. case 'ImageBitmap':
  3704. case 'RTCCertificate':
  3705. case 'WebAssembly.Module':
  3706. throwUnpolyfillable(type);
  3707. default:
  3708. throwUncloneable(type);
  3709. }
  3710. }
  3711. mapSet(map, value, cloned);
  3712. if (deep)
  3713. switch (type) {
  3714. case 'Array':
  3715. case 'Object':
  3716. keys = objectKeys(value);
  3717. for (i = 0, length = lengthOfArrayLike(keys); i < length; i++) {
  3718. key = keys[i];
  3719. createProperty(cloned, key, structuredCloneInternal(value[key], map));
  3720. }
  3721. break;
  3722. case 'Map':
  3723. value.forEach(function (v, k) {
  3724. mapSet(cloned, structuredCloneInternal(k, map), structuredCloneInternal(v, map));
  3725. });
  3726. break;
  3727. case 'Set':
  3728. value.forEach(function (v) {
  3729. setAdd(cloned, structuredCloneInternal(v, map));
  3730. });
  3731. break;
  3732. case 'Error':
  3733. createNonEnumerableProperty(cloned, 'message', structuredCloneInternal(value.message, map));
  3734. if (hasOwn(value, 'cause')) {
  3735. createNonEnumerableProperty(cloned, 'cause', structuredCloneInternal(value.cause, map));
  3736. }
  3737. if (name == 'AggregateError') {
  3738. cloned.errors = structuredCloneInternal(value.errors, map);
  3739. }
  3740. case 'DOMException':
  3741. if (ERROR_STACK_INSTALLABLE) {
  3742. createNonEnumerableProperty(cloned, 'stack', structuredCloneInternal(value.stack, map));
  3743. }
  3744. }
  3745. return cloned;
  3746. };
  3747. var PROPER_TRANSFER = nativeStructuredClone && !fails(function () {
  3748. if (IS_DENO && V8 > 92 || IS_NODE && V8 > 94 || IS_BROWSER && V8 > 97)
  3749. return false;
  3750. var buffer = new ArrayBuffer(8);
  3751. var clone = nativeStructuredClone(buffer, { transfer: [buffer] });
  3752. return buffer.byteLength != 0 || clone.byteLength != 8;
  3753. });
  3754. var tryToTransfer = function (rawTransfer, map) {
  3755. if (!isObject(rawTransfer))
  3756. throw TypeError('Transfer option cannot be converted to a sequence');
  3757. var transfer = [];
  3758. iterate(rawTransfer, function (value) {
  3759. push(transfer, anObject(value));
  3760. });
  3761. var i = 0;
  3762. var length = lengthOfArrayLike(transfer);
  3763. var value, type, C, transferredArray, transferred, canvas, context;
  3764. if (PROPER_TRANSFER) {
  3765. transferredArray = nativeStructuredClone(transfer, { transfer: transfer });
  3766. while (i < length)
  3767. mapSet(map, transfer[i], transferredArray[i++]);
  3768. } else
  3769. while (i < length) {
  3770. value = transfer[i++];
  3771. if (mapHas(map, value))
  3772. throw new DOMException('Duplicate transferable', DATA_CLONE_ERROR);
  3773. type = classof(value);
  3774. switch (type) {
  3775. case 'ImageBitmap':
  3776. C = global.OffscreenCanvas;
  3777. if (!isConstructor(C))
  3778. throwUnpolyfillable(type, TRANSFERRING);
  3779. try {
  3780. canvas = new C(value.width, value.height);
  3781. context = canvas.getContext('bitmaprenderer');
  3782. context.transferFromImageBitmap(value);
  3783. transferred = canvas.transferToImageBitmap();
  3784. } catch (error) {
  3785. }
  3786. break;
  3787. case 'AudioData':
  3788. case 'VideoFrame':
  3789. if (!isCallable(value.clone) || !isCallable(value.close))
  3790. throwUnpolyfillable(type, TRANSFERRING);
  3791. try {
  3792. transferred = value.clone();
  3793. value.close();
  3794. } catch (error) {
  3795. }
  3796. break;
  3797. case 'ArrayBuffer':
  3798. case 'MediaSourceHandle':
  3799. case 'MessagePort':
  3800. case 'OffscreenCanvas':
  3801. case 'ReadableStream':
  3802. case 'TransformStream':
  3803. case 'WritableStream':
  3804. throwUnpolyfillable(type, TRANSFERRING);
  3805. }
  3806. if (transferred === undefined)
  3807. throw new DOMException('This object cannot be transferred: ' + type, DATA_CLONE_ERROR);
  3808. mapSet(map, value, transferred);
  3809. }
  3810. };
  3811. $({
  3812. global: true,
  3813. enumerable: true,
  3814. sham: !PROPER_TRANSFER,
  3815. forced: FORCED_REPLACEMENT
  3816. }, {
  3817. structuredClone: function structuredClone(value) {
  3818. var options = validateArgumentsLength(arguments.length, 1) > 1 && !isNullOrUndefined(arguments[1]) ? anObject(arguments[1]) : undefined;
  3819. var transfer = options ? options.transfer : undefined;
  3820. var map;
  3821. if (transfer !== undefined) {
  3822. map = new Map();
  3823. tryToTransfer(transfer, map);
  3824. }
  3825. return structuredCloneInternal(value, map);
  3826. }
  3827. });
  3828. /***/ }),
  3829. /* 124 */
  3830. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  3831. var uncurryThis = __w_pdfjs_require__(17);
  3832. var fails = __w_pdfjs_require__(10);
  3833. var isCallable = __w_pdfjs_require__(24);
  3834. var classof = __w_pdfjs_require__(82);
  3835. var getBuiltIn = __w_pdfjs_require__(27);
  3836. var inspectSource = __w_pdfjs_require__(54);
  3837. var noop = function () {
  3838. };
  3839. var empty = [];
  3840. var construct = getBuiltIn('Reflect', 'construct');
  3841. var constructorRegExp = /^\s*(?:class|function)\b/;
  3842. var exec = uncurryThis(constructorRegExp.exec);
  3843. var INCORRECT_TO_STRING = !constructorRegExp.exec(noop);
  3844. var isConstructorModern = function isConstructor(argument) {
  3845. if (!isCallable(argument))
  3846. return false;
  3847. try {
  3848. construct(noop, empty, argument);
  3849. return true;
  3850. } catch (error) {
  3851. return false;
  3852. }
  3853. };
  3854. var isConstructorLegacy = function isConstructor(argument) {
  3855. if (!isCallable(argument))
  3856. return false;
  3857. switch (classof(argument)) {
  3858. case 'AsyncFunction':
  3859. case 'GeneratorFunction':
  3860. case 'AsyncGeneratorFunction':
  3861. return false;
  3862. }
  3863. try {
  3864. return INCORRECT_TO_STRING || !!exec(constructorRegExp, inspectSource(argument));
  3865. } catch (error) {
  3866. return true;
  3867. }
  3868. };
  3869. isConstructorLegacy.sham = true;
  3870. module.exports = !construct || fails(function () {
  3871. var called;
  3872. return isConstructorModern(isConstructorModern.call) || !isConstructorModern(Object) || !isConstructorModern(function () {
  3873. called = true;
  3874. }) || called;
  3875. }) ? isConstructorLegacy : isConstructorModern;
  3876. /***/ }),
  3877. /* 125 */
  3878. /***/ ((module) => {
  3879. var $TypeError = TypeError;
  3880. module.exports = function (passed, required) {
  3881. if (passed < required)
  3882. throw $TypeError('Not enough arguments');
  3883. return passed;
  3884. };
  3885. /***/ }),
  3886. /* 126 */
  3887. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  3888. var call = __w_pdfjs_require__(11);
  3889. var hasOwn = __w_pdfjs_require__(42);
  3890. var isPrototypeOf = __w_pdfjs_require__(28);
  3891. var regExpFlags = __w_pdfjs_require__(127);
  3892. var RegExpPrototype = RegExp.prototype;
  3893. module.exports = function (R) {
  3894. var flags = R.flags;
  3895. return flags === undefined && !('flags' in RegExpPrototype) && !hasOwn(R, 'flags') && isPrototypeOf(RegExpPrototype, R) ? call(regExpFlags, R) : flags;
  3896. };
  3897. /***/ }),
  3898. /* 127 */
  3899. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  3900. "use strict";
  3901. var anObject = __w_pdfjs_require__(50);
  3902. module.exports = function () {
  3903. var that = anObject(this);
  3904. var result = '';
  3905. if (that.hasIndices)
  3906. result += 'd';
  3907. if (that.global)
  3908. result += 'g';
  3909. if (that.ignoreCase)
  3910. result += 'i';
  3911. if (that.multiline)
  3912. result += 'm';
  3913. if (that.dotAll)
  3914. result += 's';
  3915. if (that.unicode)
  3916. result += 'u';
  3917. if (that.unicodeSets)
  3918. result += 'v';
  3919. if (that.sticky)
  3920. result += 'y';
  3921. return result;
  3922. };
  3923. /***/ }),
  3924. /* 128 */
  3925. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  3926. var uncurryThis = __w_pdfjs_require__(17);
  3927. var MapPrototype = Map.prototype;
  3928. module.exports = {
  3929. Map: Map,
  3930. set: uncurryThis(MapPrototype.set),
  3931. get: uncurryThis(MapPrototype.get),
  3932. has: uncurryThis(MapPrototype.has),
  3933. remove: uncurryThis(MapPrototype['delete']),
  3934. proto: MapPrototype
  3935. };
  3936. /***/ }),
  3937. /* 129 */
  3938. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  3939. var uncurryThis = __w_pdfjs_require__(17);
  3940. var SetPrototype = Set.prototype;
  3941. module.exports = {
  3942. Set: Set,
  3943. add: uncurryThis(SetPrototype.add),
  3944. has: uncurryThis(SetPrototype.has),
  3945. remove: uncurryThis(SetPrototype['delete']),
  3946. proto: SetPrototype,
  3947. $has: SetPrototype.has,
  3948. $keys: SetPrototype.keys
  3949. };
  3950. /***/ }),
  3951. /* 130 */
  3952. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  3953. var fails = __w_pdfjs_require__(10);
  3954. var createPropertyDescriptor = __w_pdfjs_require__(14);
  3955. module.exports = !fails(function () {
  3956. var error = Error('a');
  3957. if (!('stack' in error))
  3958. return true;
  3959. Object.defineProperty(error, 'stack', createPropertyDescriptor(1, 7));
  3960. return error.stack !== 7;
  3961. });
  3962. /***/ }),
  3963. /* 131 */
  3964. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  3965. var IS_DENO = __w_pdfjs_require__(132);
  3966. var IS_NODE = __w_pdfjs_require__(133);
  3967. module.exports = !IS_DENO && !IS_NODE && typeof window == 'object' && typeof document == 'object';
  3968. /***/ }),
  3969. /* 132 */
  3970. /***/ ((module) => {
  3971. module.exports = typeof Deno == 'object' && Deno && typeof Deno.version == 'object';
  3972. /***/ }),
  3973. /* 133 */
  3974. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  3975. var classof = __w_pdfjs_require__(18);
  3976. module.exports = typeof process != 'undefined' && classof(process) == 'process';
  3977. /***/ }),
  3978. /* 134 */
  3979. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  3980. var global = __w_pdfjs_require__(7);
  3981. module.exports = global;
  3982. /***/ }),
  3983. /* 135 */
  3984. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  3985. "use strict";
  3986. Object.defineProperty(exports, "__esModule", ({
  3987. value: true
  3988. }));
  3989. exports.build = exports.RenderTask = exports.PDFWorkerUtil = exports.PDFWorker = exports.PDFPageProxy = exports.PDFDocumentProxy = exports.PDFDocumentLoadingTask = exports.PDFDataRangeTransport = exports.LoopbackPort = exports.DefaultStandardFontDataFactory = exports.DefaultCanvasFactory = exports.DefaultCMapReaderFactory = void 0;
  3990. exports.getDocument = getDocument;
  3991. exports.version = void 0;
  3992. var _util = __w_pdfjs_require__(1);
  3993. var _annotation_storage = __w_pdfjs_require__(136);
  3994. var _display_utils = __w_pdfjs_require__(139);
  3995. var _font_loader = __w_pdfjs_require__(142);
  3996. var _canvas = __w_pdfjs_require__(143);
  3997. var _worker_options = __w_pdfjs_require__(146);
  3998. var _is_node = __w_pdfjs_require__(3);
  3999. var _message_handler = __w_pdfjs_require__(147);
  4000. var _metadata = __w_pdfjs_require__(148);
  4001. var _optional_content_config = __w_pdfjs_require__(149);
  4002. var _transport_stream = __w_pdfjs_require__(150);
  4003. var _xfa_text = __w_pdfjs_require__(151);
  4004. function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
  4005. function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }
  4006. function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
  4007. function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
  4008. function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
  4009. function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
  4010. function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
  4011. function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
  4012. function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
  4013. const DEFAULT_RANGE_CHUNK_SIZE = 65536;
  4014. const RENDERING_CANCELLED_TIMEOUT = 100;
  4015. let DefaultCanvasFactory = _display_utils.DOMCanvasFactory;
  4016. exports.DefaultCanvasFactory = DefaultCanvasFactory;
  4017. let DefaultCMapReaderFactory = _display_utils.DOMCMapReaderFactory;
  4018. exports.DefaultCMapReaderFactory = DefaultCMapReaderFactory;
  4019. let DefaultStandardFontDataFactory = _display_utils.DOMStandardFontDataFactory;
  4020. exports.DefaultStandardFontDataFactory = DefaultStandardFontDataFactory;
  4021. if (_is_node.isNodeJS) {
  4022. const {
  4023. NodeCanvasFactory,
  4024. NodeCMapReaderFactory,
  4025. NodeStandardFontDataFactory
  4026. } = __w_pdfjs_require__(152);
  4027. exports.DefaultCanvasFactory = DefaultCanvasFactory = NodeCanvasFactory;
  4028. exports.DefaultCMapReaderFactory = DefaultCMapReaderFactory = NodeCMapReaderFactory;
  4029. exports.DefaultStandardFontDataFactory = DefaultStandardFontDataFactory = NodeStandardFontDataFactory;
  4030. }
  4031. let createPDFNetworkStream;
  4032. {
  4033. if (_is_node.isNodeJS) {
  4034. const {
  4035. PDFNodeStream
  4036. } = __w_pdfjs_require__(153);
  4037. createPDFNetworkStream = params => {
  4038. return new PDFNodeStream(params);
  4039. };
  4040. } else {
  4041. const {
  4042. PDFNetworkStream
  4043. } = __w_pdfjs_require__(156);
  4044. const {
  4045. PDFFetchStream
  4046. } = __w_pdfjs_require__(157);
  4047. createPDFNetworkStream = params => {
  4048. return (0, _display_utils.isValidFetchUrl)(params.url) ? new PDFFetchStream(params) : new PDFNetworkStream(params);
  4049. };
  4050. }
  4051. }
  4052. function getDocument(src) {
  4053. if (typeof src === "string" || src instanceof URL) {
  4054. src = {
  4055. url: src
  4056. };
  4057. } else if ((0, _util.isArrayBuffer)(src)) {
  4058. src = {
  4059. data: src
  4060. };
  4061. } else if (src instanceof PDFDataRangeTransport) {
  4062. (0, _display_utils.deprecated)("`PDFDataRangeTransport`-instance, " + "please use a parameter object with `range`-property instead.");
  4063. src = {
  4064. range: src
  4065. };
  4066. } else {
  4067. if (typeof src !== "object") {
  4068. throw new Error("Invalid parameter in getDocument, " + "need either string, URL, TypedArray, or parameter object.");
  4069. }
  4070. }
  4071. if (!src.url && !src.data && !src.range) {
  4072. throw new Error("Invalid parameter object: need either .data, .range or .url");
  4073. }
  4074. const task = new PDFDocumentLoadingTask();
  4075. const url = src.url ? getUrlProp(src.url) : null;
  4076. const data = src.data ? getDataProp(src.data) : null;
  4077. const httpHeaders = src.httpHeaders || null;
  4078. const withCredentials = src.withCredentials === true;
  4079. const password = src.password ?? null;
  4080. const rangeTransport = src.range instanceof PDFDataRangeTransport ? src.range : null;
  4081. const rangeChunkSize = Number.isInteger(src.rangeChunkSize) && src.rangeChunkSize > 0 ? src.rangeChunkSize : DEFAULT_RANGE_CHUNK_SIZE;
  4082. let worker = src.worker instanceof PDFWorker ? src.worker : null;
  4083. const verbosity = src.verbosity;
  4084. const docBaseUrl = typeof src.docBaseUrl === "string" && !(0, _display_utils.isDataScheme)(src.docBaseUrl) ? src.docBaseUrl : null;
  4085. const cMapUrl = typeof src.cMapUrl === "string" ? src.cMapUrl : null;
  4086. const cMapPacked = src.cMapPacked !== false;
  4087. const CMapReaderFactory = src.CMapReaderFactory || DefaultCMapReaderFactory;
  4088. const standardFontDataUrl = typeof src.standardFontDataUrl === "string" ? src.standardFontDataUrl : null;
  4089. const StandardFontDataFactory = src.StandardFontDataFactory || DefaultStandardFontDataFactory;
  4090. const ignoreErrors = src.stopAtErrors !== true;
  4091. const maxImageSize = Number.isInteger(src.maxImageSize) && src.maxImageSize > -1 ? src.maxImageSize : -1;
  4092. const isEvalSupported = src.isEvalSupported !== false;
  4093. const isOffscreenCanvasSupported = typeof src.isOffscreenCanvasSupported === "boolean" ? src.isOffscreenCanvasSupported : !_is_node.isNodeJS;
  4094. const disableFontFace = typeof src.disableFontFace === "boolean" ? src.disableFontFace : _is_node.isNodeJS;
  4095. const fontExtraProperties = src.fontExtraProperties === true;
  4096. const enableXfa = src.enableXfa === true;
  4097. const ownerDocument = src.ownerDocument || globalThis.document;
  4098. const disableRange = src.disableRange === true;
  4099. const disableStream = src.disableStream === true;
  4100. const disableAutoFetch = src.disableAutoFetch === true;
  4101. const pdfBug = src.pdfBug === true;
  4102. const length = rangeTransport ? rangeTransport.length : src.length ?? NaN;
  4103. const useSystemFonts = typeof src.useSystemFonts === "boolean" ? src.useSystemFonts : !_is_node.isNodeJS && !disableFontFace;
  4104. const useWorkerFetch = typeof src.useWorkerFetch === "boolean" ? src.useWorkerFetch : CMapReaderFactory === _display_utils.DOMCMapReaderFactory && StandardFontDataFactory === _display_utils.DOMStandardFontDataFactory && (0, _display_utils.isValidFetchUrl)(cMapUrl, document.baseURI) && (0, _display_utils.isValidFetchUrl)(standardFontDataUrl, document.baseURI);
  4105. const styleElement = null;
  4106. (0, _util.setVerbosityLevel)(verbosity);
  4107. const transportFactory = useWorkerFetch ? null : {
  4108. cMapReaderFactory: new CMapReaderFactory({
  4109. baseUrl: cMapUrl,
  4110. isCompressed: cMapPacked
  4111. }),
  4112. standardFontDataFactory: new StandardFontDataFactory({
  4113. baseUrl: standardFontDataUrl
  4114. })
  4115. };
  4116. if (!worker) {
  4117. const workerParams = {
  4118. verbosity,
  4119. port: _worker_options.GlobalWorkerOptions.workerPort
  4120. };
  4121. worker = workerParams.port ? PDFWorker.fromPort(workerParams) : new PDFWorker(workerParams);
  4122. task._worker = worker;
  4123. }
  4124. const docId = task.docId;
  4125. const fetchDocParams = {
  4126. docId,
  4127. apiVersion: '3.4.120',
  4128. data,
  4129. password,
  4130. disableAutoFetch,
  4131. rangeChunkSize,
  4132. length,
  4133. docBaseUrl,
  4134. enableXfa,
  4135. evaluatorOptions: {
  4136. maxImageSize,
  4137. disableFontFace,
  4138. ignoreErrors,
  4139. isEvalSupported,
  4140. isOffscreenCanvasSupported,
  4141. fontExtraProperties,
  4142. useSystemFonts,
  4143. cMapUrl: useWorkerFetch ? cMapUrl : null,
  4144. standardFontDataUrl: useWorkerFetch ? standardFontDataUrl : null
  4145. }
  4146. };
  4147. const transportParams = {
  4148. ignoreErrors,
  4149. isEvalSupported,
  4150. disableFontFace,
  4151. fontExtraProperties,
  4152. enableXfa,
  4153. ownerDocument,
  4154. disableAutoFetch,
  4155. pdfBug,
  4156. styleElement
  4157. };
  4158. worker.promise.then(function () {
  4159. if (task.destroyed) {
  4160. throw new Error("Loading aborted");
  4161. }
  4162. const workerIdPromise = _fetchDocument(worker, fetchDocParams);
  4163. const networkStreamPromise = new Promise(function (resolve) {
  4164. let networkStream;
  4165. if (rangeTransport) {
  4166. networkStream = new _transport_stream.PDFDataTransportStream({
  4167. length,
  4168. initialData: rangeTransport.initialData,
  4169. progressiveDone: rangeTransport.progressiveDone,
  4170. contentDispositionFilename: rangeTransport.contentDispositionFilename,
  4171. disableRange,
  4172. disableStream
  4173. }, rangeTransport);
  4174. } else if (!data) {
  4175. networkStream = createPDFNetworkStream({
  4176. url,
  4177. length,
  4178. httpHeaders,
  4179. withCredentials,
  4180. rangeChunkSize,
  4181. disableRange,
  4182. disableStream
  4183. });
  4184. }
  4185. resolve(networkStream);
  4186. });
  4187. return Promise.all([workerIdPromise, networkStreamPromise]).then(function (_ref) {
  4188. let [workerId, networkStream] = _ref;
  4189. if (task.destroyed) {
  4190. throw new Error("Loading aborted");
  4191. }
  4192. const messageHandler = new _message_handler.MessageHandler(docId, workerId, worker.port);
  4193. const transport = new WorkerTransport(messageHandler, task, networkStream, transportParams, transportFactory);
  4194. task._transport = transport;
  4195. messageHandler.send("Ready", null);
  4196. });
  4197. }).catch(task._capability.reject);
  4198. return task;
  4199. }
  4200. async function _fetchDocument(worker, source) {
  4201. if (worker.destroyed) {
  4202. throw new Error("Worker was destroyed");
  4203. }
  4204. const workerId = await worker.messageHandler.sendWithPromise("GetDocRequest", source, source.data ? [source.data.buffer] : null);
  4205. if (worker.destroyed) {
  4206. throw new Error("Worker was destroyed");
  4207. }
  4208. return workerId;
  4209. }
  4210. function getUrlProp(val) {
  4211. if (val instanceof URL) {
  4212. return val.href;
  4213. }
  4214. try {
  4215. return new URL(val, window.location).href;
  4216. } catch (ex) {
  4217. if (_is_node.isNodeJS && typeof val === "string") {
  4218. return val;
  4219. }
  4220. }
  4221. throw new Error("Invalid PDF url data: " + "either string or URL-object is expected in the url property.");
  4222. }
  4223. function getDataProp(val) {
  4224. if (_is_node.isNodeJS && typeof Buffer !== "undefined" && val instanceof Buffer) {
  4225. (0, _display_utils.deprecated)("Please provide binary data as `Uint8Array`, rather than `Buffer`.");
  4226. return new Uint8Array(val);
  4227. }
  4228. if (val instanceof Uint8Array && val.byteLength === val.buffer.byteLength) {
  4229. return val;
  4230. }
  4231. if (typeof val === "string") {
  4232. return (0, _util.stringToBytes)(val);
  4233. }
  4234. if (typeof val === "object" && !isNaN(val === null || val === void 0 ? void 0 : val.length) || (0, _util.isArrayBuffer)(val)) {
  4235. return new Uint8Array(val);
  4236. }
  4237. throw new Error("Invalid PDF binary data: either TypedArray, " + "string, or array-like object is expected in the data property.");
  4238. }
  4239. class PDFDocumentLoadingTask {
  4240. static #docId = 0;
  4241. #onUnsupportedFeature = null;
  4242. constructor() {
  4243. this._capability = (0, _util.createPromiseCapability)();
  4244. this._transport = null;
  4245. this._worker = null;
  4246. this.docId = `d${PDFDocumentLoadingTask.#docId++}`;
  4247. this.destroyed = false;
  4248. this.onPassword = null;
  4249. this.onProgress = null;
  4250. }
  4251. get onUnsupportedFeature() {
  4252. return this.#onUnsupportedFeature;
  4253. }
  4254. set onUnsupportedFeature(callback) {
  4255. (0, _display_utils.deprecated)("The PDFDocumentLoadingTask onUnsupportedFeature property will be removed in the future.");
  4256. this.#onUnsupportedFeature = callback;
  4257. }
  4258. get promise() {
  4259. return this._capability.promise;
  4260. }
  4261. async destroy() {
  4262. var _this$_transport;
  4263. this.destroyed = true;
  4264. await ((_this$_transport = this._transport) === null || _this$_transport === void 0 ? void 0 : _this$_transport.destroy());
  4265. this._transport = null;
  4266. if (this._worker) {
  4267. this._worker.destroy();
  4268. this._worker = null;
  4269. }
  4270. }
  4271. }
  4272. exports.PDFDocumentLoadingTask = PDFDocumentLoadingTask;
  4273. class PDFDataRangeTransport {
  4274. constructor(length, initialData) {
  4275. let progressiveDone = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  4276. let contentDispositionFilename = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
  4277. this.length = length;
  4278. this.initialData = initialData;
  4279. this.progressiveDone = progressiveDone;
  4280. this.contentDispositionFilename = contentDispositionFilename;
  4281. this._rangeListeners = [];
  4282. this._progressListeners = [];
  4283. this._progressiveReadListeners = [];
  4284. this._progressiveDoneListeners = [];
  4285. this._readyCapability = (0, _util.createPromiseCapability)();
  4286. }
  4287. addRangeListener(listener) {
  4288. this._rangeListeners.push(listener);
  4289. }
  4290. addProgressListener(listener) {
  4291. this._progressListeners.push(listener);
  4292. }
  4293. addProgressiveReadListener(listener) {
  4294. this._progressiveReadListeners.push(listener);
  4295. }
  4296. addProgressiveDoneListener(listener) {
  4297. this._progressiveDoneListeners.push(listener);
  4298. }
  4299. onDataRange(begin, chunk) {
  4300. for (const listener of this._rangeListeners) {
  4301. listener(begin, chunk);
  4302. }
  4303. }
  4304. onDataProgress(loaded, total) {
  4305. this._readyCapability.promise.then(() => {
  4306. for (const listener of this._progressListeners) {
  4307. listener(loaded, total);
  4308. }
  4309. });
  4310. }
  4311. onDataProgressiveRead(chunk) {
  4312. this._readyCapability.promise.then(() => {
  4313. for (const listener of this._progressiveReadListeners) {
  4314. listener(chunk);
  4315. }
  4316. });
  4317. }
  4318. onDataProgressiveDone() {
  4319. this._readyCapability.promise.then(() => {
  4320. for (const listener of this._progressiveDoneListeners) {
  4321. listener();
  4322. }
  4323. });
  4324. }
  4325. transportReady() {
  4326. this._readyCapability.resolve();
  4327. }
  4328. requestDataRange(begin, end) {
  4329. (0, _util.unreachable)("Abstract method PDFDataRangeTransport.requestDataRange");
  4330. }
  4331. abort() {}
  4332. }
  4333. exports.PDFDataRangeTransport = PDFDataRangeTransport;
  4334. class PDFDocumentProxy {
  4335. constructor(pdfInfo, transport) {
  4336. this._pdfInfo = pdfInfo;
  4337. this._transport = transport;
  4338. }
  4339. get annotationStorage() {
  4340. return this._transport.annotationStorage;
  4341. }
  4342. get numPages() {
  4343. return this._pdfInfo.numPages;
  4344. }
  4345. get fingerprints() {
  4346. return this._pdfInfo.fingerprints;
  4347. }
  4348. get isPureXfa() {
  4349. return (0, _util.shadow)(this, "isPureXfa", !!this._transport._htmlForXfa);
  4350. }
  4351. get allXfaHtml() {
  4352. return this._transport._htmlForXfa;
  4353. }
  4354. getPage(pageNumber) {
  4355. return this._transport.getPage(pageNumber);
  4356. }
  4357. getPageIndex(ref) {
  4358. return this._transport.getPageIndex(ref);
  4359. }
  4360. getDestinations() {
  4361. return this._transport.getDestinations();
  4362. }
  4363. getDestination(id) {
  4364. return this._transport.getDestination(id);
  4365. }
  4366. getPageLabels() {
  4367. return this._transport.getPageLabels();
  4368. }
  4369. getPageLayout() {
  4370. return this._transport.getPageLayout();
  4371. }
  4372. getPageMode() {
  4373. return this._transport.getPageMode();
  4374. }
  4375. getViewerPreferences() {
  4376. return this._transport.getViewerPreferences();
  4377. }
  4378. getOpenAction() {
  4379. return this._transport.getOpenAction();
  4380. }
  4381. getAttachments() {
  4382. return this._transport.getAttachments();
  4383. }
  4384. getJavaScript() {
  4385. return this._transport.getJavaScript();
  4386. }
  4387. getJSActions() {
  4388. return this._transport.getDocJSActions();
  4389. }
  4390. getOutline() {
  4391. return this._transport.getOutline();
  4392. }
  4393. getOptionalContentConfig() {
  4394. return this._transport.getOptionalContentConfig();
  4395. }
  4396. getPermissions() {
  4397. return this._transport.getPermissions();
  4398. }
  4399. getMetadata() {
  4400. return this._transport.getMetadata();
  4401. }
  4402. getMarkInfo() {
  4403. return this._transport.getMarkInfo();
  4404. }
  4405. getData() {
  4406. return this._transport.getData();
  4407. }
  4408. saveDocument() {
  4409. return this._transport.saveDocument();
  4410. }
  4411. getDownloadInfo() {
  4412. return this._transport.downloadInfoCapability.promise;
  4413. }
  4414. cleanup() {
  4415. let keepLoadedFonts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  4416. return this._transport.startCleanup(keepLoadedFonts || this.isPureXfa);
  4417. }
  4418. destroy() {
  4419. return this.loadingTask.destroy();
  4420. }
  4421. get loadingParams() {
  4422. return this._transport.loadingParams;
  4423. }
  4424. get loadingTask() {
  4425. return this._transport.loadingTask;
  4426. }
  4427. getFieldObjects() {
  4428. return this._transport.getFieldObjects();
  4429. }
  4430. hasJSActions() {
  4431. return this._transport.hasJSActions();
  4432. }
  4433. getCalculationOrderIds() {
  4434. return this._transport.getCalculationOrderIds();
  4435. }
  4436. }
  4437. exports.PDFDocumentProxy = PDFDocumentProxy;
  4438. class PDFPageProxy {
  4439. constructor(pageIndex, pageInfo, transport, ownerDocument) {
  4440. let pdfBug = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
  4441. this._pageIndex = pageIndex;
  4442. this._pageInfo = pageInfo;
  4443. this._ownerDocument = ownerDocument;
  4444. this._transport = transport;
  4445. this._stats = pdfBug ? new _display_utils.StatTimer() : null;
  4446. this._pdfBug = pdfBug;
  4447. this.commonObjs = transport.commonObjs;
  4448. this.objs = new PDFObjects();
  4449. this.cleanupAfterRender = false;
  4450. this.pendingCleanup = false;
  4451. this._intentStates = new Map();
  4452. this.destroyed = false;
  4453. }
  4454. get pageNumber() {
  4455. return this._pageIndex + 1;
  4456. }
  4457. get rotate() {
  4458. return this._pageInfo.rotate;
  4459. }
  4460. get ref() {
  4461. return this._pageInfo.ref;
  4462. }
  4463. get userUnit() {
  4464. return this._pageInfo.userUnit;
  4465. }
  4466. get view() {
  4467. return this._pageInfo.view;
  4468. }
  4469. getViewport() {
  4470. let {
  4471. scale,
  4472. rotation = this.rotate,
  4473. offsetX = 0,
  4474. offsetY = 0,
  4475. dontFlip = false
  4476. } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  4477. return new _display_utils.PageViewport({
  4478. viewBox: this.view,
  4479. scale,
  4480. rotation,
  4481. offsetX,
  4482. offsetY,
  4483. dontFlip
  4484. });
  4485. }
  4486. getAnnotations() {
  4487. let {
  4488. intent = "display"
  4489. } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  4490. const intentArgs = this._transport.getRenderingIntent(intent);
  4491. return this._transport.getAnnotations(this._pageIndex, intentArgs.renderingIntent);
  4492. }
  4493. getJSActions() {
  4494. return this._transport.getPageJSActions(this._pageIndex);
  4495. }
  4496. get isPureXfa() {
  4497. return (0, _util.shadow)(this, "isPureXfa", !!this._transport._htmlForXfa);
  4498. }
  4499. async getXfa() {
  4500. var _this$_transport$_htm;
  4501. return ((_this$_transport$_htm = this._transport._htmlForXfa) === null || _this$_transport$_htm === void 0 ? void 0 : _this$_transport$_htm.children[this._pageIndex]) || null;
  4502. }
  4503. render(_ref2) {
  4504. var _this$_stats, _intentState;
  4505. let {
  4506. canvasContext,
  4507. viewport,
  4508. intent = "display",
  4509. annotationMode = _util.AnnotationMode.ENABLE,
  4510. transform = null,
  4511. canvasFactory = null,
  4512. background = null,
  4513. optionalContentConfigPromise = null,
  4514. annotationCanvasMap = null,
  4515. pageColors = null,
  4516. printAnnotationStorage = null
  4517. } = _ref2;
  4518. (_this$_stats = this._stats) === null || _this$_stats === void 0 ? void 0 : _this$_stats.time("Overall");
  4519. const intentArgs = this._transport.getRenderingIntent(intent, annotationMode, printAnnotationStorage);
  4520. this.pendingCleanup = false;
  4521. if (!optionalContentConfigPromise) {
  4522. optionalContentConfigPromise = this._transport.getOptionalContentConfig();
  4523. }
  4524. let intentState = this._intentStates.get(intentArgs.cacheKey);
  4525. if (!intentState) {
  4526. intentState = Object.create(null);
  4527. this._intentStates.set(intentArgs.cacheKey, intentState);
  4528. }
  4529. if (intentState.streamReaderCancelTimeout) {
  4530. clearTimeout(intentState.streamReaderCancelTimeout);
  4531. intentState.streamReaderCancelTimeout = null;
  4532. }
  4533. const canvasFactoryInstance = canvasFactory || new DefaultCanvasFactory({
  4534. ownerDocument: this._ownerDocument
  4535. });
  4536. const intentPrint = !!(intentArgs.renderingIntent & _util.RenderingIntentFlag.PRINT);
  4537. if (!intentState.displayReadyCapability) {
  4538. var _this$_stats2;
  4539. intentState.displayReadyCapability = (0, _util.createPromiseCapability)();
  4540. intentState.operatorList = {
  4541. fnArray: [],
  4542. argsArray: [],
  4543. lastChunk: false,
  4544. separateAnnots: null
  4545. };
  4546. (_this$_stats2 = this._stats) === null || _this$_stats2 === void 0 ? void 0 : _this$_stats2.time("Page Request");
  4547. this._pumpOperatorList(intentArgs);
  4548. }
  4549. const complete = error => {
  4550. var _this$_stats3, _this$_stats4;
  4551. intentState.renderTasks.delete(internalRenderTask);
  4552. if (this.cleanupAfterRender || intentPrint) {
  4553. this.pendingCleanup = true;
  4554. }
  4555. this._tryCleanup();
  4556. if (error) {
  4557. internalRenderTask.capability.reject(error);
  4558. this._abortOperatorList({
  4559. intentState,
  4560. reason: error instanceof Error ? error : new Error(error)
  4561. });
  4562. } else {
  4563. internalRenderTask.capability.resolve();
  4564. }
  4565. (_this$_stats3 = this._stats) === null || _this$_stats3 === void 0 ? void 0 : _this$_stats3.timeEnd("Rendering");
  4566. (_this$_stats4 = this._stats) === null || _this$_stats4 === void 0 ? void 0 : _this$_stats4.timeEnd("Overall");
  4567. };
  4568. const internalRenderTask = new InternalRenderTask({
  4569. callback: complete,
  4570. params: {
  4571. canvasContext,
  4572. viewport,
  4573. transform,
  4574. background
  4575. },
  4576. objs: this.objs,
  4577. commonObjs: this.commonObjs,
  4578. annotationCanvasMap,
  4579. operatorList: intentState.operatorList,
  4580. pageIndex: this._pageIndex,
  4581. canvasFactory: canvasFactoryInstance,
  4582. useRequestAnimationFrame: !intentPrint,
  4583. pdfBug: this._pdfBug,
  4584. pageColors
  4585. });
  4586. ((_intentState = intentState).renderTasks || (_intentState.renderTasks = new Set())).add(internalRenderTask);
  4587. const renderTask = internalRenderTask.task;
  4588. Promise.all([intentState.displayReadyCapability.promise, optionalContentConfigPromise]).then(_ref3 => {
  4589. var _this$_stats5;
  4590. let [transparency, optionalContentConfig] = _ref3;
  4591. if (this.pendingCleanup) {
  4592. complete();
  4593. return;
  4594. }
  4595. (_this$_stats5 = this._stats) === null || _this$_stats5 === void 0 ? void 0 : _this$_stats5.time("Rendering");
  4596. internalRenderTask.initializeGraphics({
  4597. transparency,
  4598. optionalContentConfig
  4599. });
  4600. internalRenderTask.operatorListChanged();
  4601. }).catch(complete);
  4602. return renderTask;
  4603. }
  4604. getOperatorList() {
  4605. let {
  4606. intent = "display",
  4607. annotationMode = _util.AnnotationMode.ENABLE,
  4608. printAnnotationStorage = null
  4609. } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  4610. function operatorListChanged() {
  4611. if (intentState.operatorList.lastChunk) {
  4612. intentState.opListReadCapability.resolve(intentState.operatorList);
  4613. intentState.renderTasks.delete(opListTask);
  4614. }
  4615. }
  4616. const intentArgs = this._transport.getRenderingIntent(intent, annotationMode, printAnnotationStorage, true);
  4617. let intentState = this._intentStates.get(intentArgs.cacheKey);
  4618. if (!intentState) {
  4619. intentState = Object.create(null);
  4620. this._intentStates.set(intentArgs.cacheKey, intentState);
  4621. }
  4622. let opListTask;
  4623. if (!intentState.opListReadCapability) {
  4624. var _intentState2, _this$_stats6;
  4625. opListTask = Object.create(null);
  4626. opListTask.operatorListChanged = operatorListChanged;
  4627. intentState.opListReadCapability = (0, _util.createPromiseCapability)();
  4628. ((_intentState2 = intentState).renderTasks || (_intentState2.renderTasks = new Set())).add(opListTask);
  4629. intentState.operatorList = {
  4630. fnArray: [],
  4631. argsArray: [],
  4632. lastChunk: false,
  4633. separateAnnots: null
  4634. };
  4635. (_this$_stats6 = this._stats) === null || _this$_stats6 === void 0 ? void 0 : _this$_stats6.time("Page Request");
  4636. this._pumpOperatorList(intentArgs);
  4637. }
  4638. return intentState.opListReadCapability.promise;
  4639. }
  4640. streamTextContent() {
  4641. let {
  4642. disableCombineTextItems = false,
  4643. includeMarkedContent = false
  4644. } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  4645. const TEXT_CONTENT_CHUNK_SIZE = 100;
  4646. return this._transport.messageHandler.sendWithStream("GetTextContent", {
  4647. pageIndex: this._pageIndex,
  4648. combineTextItems: disableCombineTextItems !== true,
  4649. includeMarkedContent: includeMarkedContent === true
  4650. }, {
  4651. highWaterMark: TEXT_CONTENT_CHUNK_SIZE,
  4652. size(textContent) {
  4653. return textContent.items.length;
  4654. }
  4655. });
  4656. }
  4657. getTextContent() {
  4658. let params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  4659. if (this._transport._htmlForXfa) {
  4660. return this.getXfa().then(xfa => {
  4661. return _xfa_text.XfaText.textContent(xfa);
  4662. });
  4663. }
  4664. const readableStream = this.streamTextContent(params);
  4665. return new Promise(function (resolve, reject) {
  4666. function pump() {
  4667. reader.read().then(function (_ref4) {
  4668. let {
  4669. value,
  4670. done
  4671. } = _ref4;
  4672. if (done) {
  4673. resolve(textContent);
  4674. return;
  4675. }
  4676. Object.assign(textContent.styles, value.styles);
  4677. textContent.items.push(...value.items);
  4678. pump();
  4679. }, reject);
  4680. }
  4681. const reader = readableStream.getReader();
  4682. const textContent = {
  4683. items: [],
  4684. styles: Object.create(null)
  4685. };
  4686. pump();
  4687. });
  4688. }
  4689. getStructTree() {
  4690. return this._transport.getStructTree(this._pageIndex);
  4691. }
  4692. _destroy() {
  4693. this.destroyed = true;
  4694. const waitOn = [];
  4695. for (const intentState of this._intentStates.values()) {
  4696. this._abortOperatorList({
  4697. intentState,
  4698. reason: new Error("Page was destroyed."),
  4699. force: true
  4700. });
  4701. if (intentState.opListReadCapability) {
  4702. continue;
  4703. }
  4704. for (const internalRenderTask of intentState.renderTasks) {
  4705. waitOn.push(internalRenderTask.completed);
  4706. internalRenderTask.cancel();
  4707. }
  4708. }
  4709. this.objs.clear();
  4710. this.pendingCleanup = false;
  4711. return Promise.all(waitOn);
  4712. }
  4713. cleanup() {
  4714. let resetStats = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  4715. this.pendingCleanup = true;
  4716. return this._tryCleanup(resetStats);
  4717. }
  4718. _tryCleanup() {
  4719. let resetStats = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  4720. if (!this.pendingCleanup) {
  4721. return false;
  4722. }
  4723. for (const {
  4724. renderTasks,
  4725. operatorList
  4726. } of this._intentStates.values()) {
  4727. if (renderTasks.size > 0 || !operatorList.lastChunk) {
  4728. return false;
  4729. }
  4730. }
  4731. this._intentStates.clear();
  4732. this.objs.clear();
  4733. if (resetStats && this._stats) {
  4734. this._stats = new _display_utils.StatTimer();
  4735. }
  4736. this.pendingCleanup = false;
  4737. return true;
  4738. }
  4739. _startRenderPage(transparency, cacheKey) {
  4740. var _this$_stats7, _intentState$displayR;
  4741. const intentState = this._intentStates.get(cacheKey);
  4742. if (!intentState) {
  4743. return;
  4744. }
  4745. (_this$_stats7 = this._stats) === null || _this$_stats7 === void 0 ? void 0 : _this$_stats7.timeEnd("Page Request");
  4746. (_intentState$displayR = intentState.displayReadyCapability) === null || _intentState$displayR === void 0 ? void 0 : _intentState$displayR.resolve(transparency);
  4747. }
  4748. _renderPageChunk(operatorListChunk, intentState) {
  4749. for (let i = 0, ii = operatorListChunk.length; i < ii; i++) {
  4750. intentState.operatorList.fnArray.push(operatorListChunk.fnArray[i]);
  4751. intentState.operatorList.argsArray.push(operatorListChunk.argsArray[i]);
  4752. }
  4753. intentState.operatorList.lastChunk = operatorListChunk.lastChunk;
  4754. intentState.operatorList.separateAnnots = operatorListChunk.separateAnnots;
  4755. for (const internalRenderTask of intentState.renderTasks) {
  4756. internalRenderTask.operatorListChanged();
  4757. }
  4758. if (operatorListChunk.lastChunk) {
  4759. this._tryCleanup();
  4760. }
  4761. }
  4762. _pumpOperatorList(_ref5) {
  4763. let {
  4764. renderingIntent,
  4765. cacheKey,
  4766. annotationStorageMap
  4767. } = _ref5;
  4768. const readableStream = this._transport.messageHandler.sendWithStream("GetOperatorList", {
  4769. pageIndex: this._pageIndex,
  4770. intent: renderingIntent,
  4771. cacheKey,
  4772. annotationStorage: annotationStorageMap
  4773. });
  4774. const reader = readableStream.getReader();
  4775. const intentState = this._intentStates.get(cacheKey);
  4776. intentState.streamReader = reader;
  4777. const pump = () => {
  4778. reader.read().then(_ref6 => {
  4779. let {
  4780. value,
  4781. done
  4782. } = _ref6;
  4783. if (done) {
  4784. intentState.streamReader = null;
  4785. return;
  4786. }
  4787. if (this._transport.destroyed) {
  4788. return;
  4789. }
  4790. this._renderPageChunk(value, intentState);
  4791. pump();
  4792. }, reason => {
  4793. intentState.streamReader = null;
  4794. if (this._transport.destroyed) {
  4795. return;
  4796. }
  4797. if (intentState.operatorList) {
  4798. intentState.operatorList.lastChunk = true;
  4799. for (const internalRenderTask of intentState.renderTasks) {
  4800. internalRenderTask.operatorListChanged();
  4801. }
  4802. this._tryCleanup();
  4803. }
  4804. if (intentState.displayReadyCapability) {
  4805. intentState.displayReadyCapability.reject(reason);
  4806. } else if (intentState.opListReadCapability) {
  4807. intentState.opListReadCapability.reject(reason);
  4808. } else {
  4809. throw reason;
  4810. }
  4811. });
  4812. };
  4813. pump();
  4814. }
  4815. _abortOperatorList(_ref7) {
  4816. let {
  4817. intentState,
  4818. reason,
  4819. force = false
  4820. } = _ref7;
  4821. if (!intentState.streamReader) {
  4822. return;
  4823. }
  4824. if (intentState.streamReaderCancelTimeout) {
  4825. clearTimeout(intentState.streamReaderCancelTimeout);
  4826. intentState.streamReaderCancelTimeout = null;
  4827. }
  4828. if (!force) {
  4829. if (intentState.renderTasks.size > 0) {
  4830. return;
  4831. }
  4832. if (reason instanceof _display_utils.RenderingCancelledException) {
  4833. let delay = RENDERING_CANCELLED_TIMEOUT;
  4834. if (reason.extraDelay > 0 && reason.extraDelay < 1000) {
  4835. delay += reason.extraDelay;
  4836. }
  4837. intentState.streamReaderCancelTimeout = setTimeout(() => {
  4838. intentState.streamReaderCancelTimeout = null;
  4839. this._abortOperatorList({
  4840. intentState,
  4841. reason,
  4842. force: true
  4843. });
  4844. }, delay);
  4845. return;
  4846. }
  4847. }
  4848. intentState.streamReader.cancel(new _util.AbortException(reason.message)).catch(() => {});
  4849. intentState.streamReader = null;
  4850. if (this._transport.destroyed) {
  4851. return;
  4852. }
  4853. for (const [curCacheKey, curIntentState] of this._intentStates) {
  4854. if (curIntentState === intentState) {
  4855. this._intentStates.delete(curCacheKey);
  4856. break;
  4857. }
  4858. }
  4859. this.cleanup();
  4860. }
  4861. get stats() {
  4862. return this._stats;
  4863. }
  4864. }
  4865. exports.PDFPageProxy = PDFPageProxy;
  4866. class LoopbackPort {
  4867. #listeners = new Set();
  4868. #deferred = Promise.resolve();
  4869. postMessage(obj, transfers) {
  4870. const event = {
  4871. data: structuredClone(obj, transfers)
  4872. };
  4873. this.#deferred.then(() => {
  4874. for (const listener of this.#listeners) {
  4875. listener.call(this, event);
  4876. }
  4877. });
  4878. }
  4879. addEventListener(name, listener) {
  4880. this.#listeners.add(listener);
  4881. }
  4882. removeEventListener(name, listener) {
  4883. this.#listeners.delete(listener);
  4884. }
  4885. terminate() {
  4886. this.#listeners.clear();
  4887. }
  4888. }
  4889. exports.LoopbackPort = LoopbackPort;
  4890. const PDFWorkerUtil = {
  4891. isWorkerDisabled: false,
  4892. fallbackWorkerSrc: null,
  4893. fakeWorkerId: 0
  4894. };
  4895. exports.PDFWorkerUtil = PDFWorkerUtil;
  4896. {
  4897. if (_is_node.isNodeJS && typeof require === "function") {
  4898. PDFWorkerUtil.isWorkerDisabled = true;
  4899. PDFWorkerUtil.fallbackWorkerSrc = "./pdf.worker.js";
  4900. } else if (typeof document === "object") {
  4901. var _document, _document$currentScri;
  4902. const pdfjsFilePath = (_document = document) === null || _document === void 0 ? void 0 : (_document$currentScri = _document.currentScript) === null || _document$currentScri === void 0 ? void 0 : _document$currentScri.src;
  4903. if (pdfjsFilePath) {
  4904. PDFWorkerUtil.fallbackWorkerSrc = pdfjsFilePath.replace(/(\.(?:min\.)?js)(\?.*)?$/i, ".worker$1$2");
  4905. }
  4906. }
  4907. PDFWorkerUtil.isSameOrigin = function (baseUrl, otherUrl) {
  4908. let base;
  4909. try {
  4910. base = new URL(baseUrl);
  4911. if (!base.origin || base.origin === "null") {
  4912. return false;
  4913. }
  4914. } catch (e) {
  4915. return false;
  4916. }
  4917. const other = new URL(otherUrl, base);
  4918. return base.origin === other.origin;
  4919. };
  4920. PDFWorkerUtil.createCDNWrapper = function (url) {
  4921. const wrapper = `importScripts("${url}");`;
  4922. return URL.createObjectURL(new Blob([wrapper]));
  4923. };
  4924. }
  4925. class PDFWorker {
  4926. static #workerPorts = new WeakMap();
  4927. constructor() {
  4928. let {
  4929. name = null,
  4930. port = null,
  4931. verbosity = (0, _util.getVerbosityLevel)()
  4932. } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  4933. if (port && PDFWorker.#workerPorts.has(port)) {
  4934. throw new Error("Cannot use more than one PDFWorker per port.");
  4935. }
  4936. this.name = name;
  4937. this.destroyed = false;
  4938. this.verbosity = verbosity;
  4939. this._readyCapability = (0, _util.createPromiseCapability)();
  4940. this._port = null;
  4941. this._webWorker = null;
  4942. this._messageHandler = null;
  4943. if (port) {
  4944. PDFWorker.#workerPorts.set(port, this);
  4945. this._initializeFromPort(port);
  4946. return;
  4947. }
  4948. this._initialize();
  4949. }
  4950. get promise() {
  4951. return this._readyCapability.promise;
  4952. }
  4953. get port() {
  4954. return this._port;
  4955. }
  4956. get messageHandler() {
  4957. return this._messageHandler;
  4958. }
  4959. _initializeFromPort(port) {
  4960. this._port = port;
  4961. this._messageHandler = new _message_handler.MessageHandler("main", "worker", port);
  4962. this._messageHandler.on("ready", function () {});
  4963. this._readyCapability.resolve();
  4964. this._messageHandler.send("configure", {
  4965. verbosity: this.verbosity
  4966. });
  4967. }
  4968. _initialize() {
  4969. if (!PDFWorkerUtil.isWorkerDisabled && !PDFWorker._mainThreadWorkerMessageHandler) {
  4970. let {
  4971. workerSrc
  4972. } = PDFWorker;
  4973. try {
  4974. if (!PDFWorkerUtil.isSameOrigin(window.location.href, workerSrc)) {
  4975. workerSrc = PDFWorkerUtil.createCDNWrapper(new URL(workerSrc, window.location).href);
  4976. }
  4977. const worker = new Worker(workerSrc);
  4978. const messageHandler = new _message_handler.MessageHandler("main", "worker", worker);
  4979. const terminateEarly = () => {
  4980. worker.removeEventListener("error", onWorkerError);
  4981. messageHandler.destroy();
  4982. worker.terminate();
  4983. if (this.destroyed) {
  4984. this._readyCapability.reject(new Error("Worker was destroyed"));
  4985. } else {
  4986. this._setupFakeWorker();
  4987. }
  4988. };
  4989. const onWorkerError = () => {
  4990. if (!this._webWorker) {
  4991. terminateEarly();
  4992. }
  4993. };
  4994. worker.addEventListener("error", onWorkerError);
  4995. messageHandler.on("test", data => {
  4996. worker.removeEventListener("error", onWorkerError);
  4997. if (this.destroyed) {
  4998. terminateEarly();
  4999. return;
  5000. }
  5001. if (data) {
  5002. this._messageHandler = messageHandler;
  5003. this._port = worker;
  5004. this._webWorker = worker;
  5005. this._readyCapability.resolve();
  5006. messageHandler.send("configure", {
  5007. verbosity: this.verbosity
  5008. });
  5009. } else {
  5010. this._setupFakeWorker();
  5011. messageHandler.destroy();
  5012. worker.terminate();
  5013. }
  5014. });
  5015. messageHandler.on("ready", data => {
  5016. worker.removeEventListener("error", onWorkerError);
  5017. if (this.destroyed) {
  5018. terminateEarly();
  5019. return;
  5020. }
  5021. try {
  5022. sendTest();
  5023. } catch (e) {
  5024. this._setupFakeWorker();
  5025. }
  5026. });
  5027. const sendTest = () => {
  5028. const testObj = new Uint8Array();
  5029. messageHandler.send("test", testObj, [testObj.buffer]);
  5030. };
  5031. sendTest();
  5032. return;
  5033. } catch (e) {
  5034. (0, _util.info)("The worker has been disabled.");
  5035. }
  5036. }
  5037. this._setupFakeWorker();
  5038. }
  5039. _setupFakeWorker() {
  5040. if (!PDFWorkerUtil.isWorkerDisabled) {
  5041. (0, _util.warn)("Setting up fake worker.");
  5042. PDFWorkerUtil.isWorkerDisabled = true;
  5043. }
  5044. PDFWorker._setupFakeWorkerGlobal.then(WorkerMessageHandler => {
  5045. if (this.destroyed) {
  5046. this._readyCapability.reject(new Error("Worker was destroyed"));
  5047. return;
  5048. }
  5049. const port = new LoopbackPort();
  5050. this._port = port;
  5051. const id = `fake${PDFWorkerUtil.fakeWorkerId++}`;
  5052. const workerHandler = new _message_handler.MessageHandler(id + "_worker", id, port);
  5053. WorkerMessageHandler.setup(workerHandler, port);
  5054. const messageHandler = new _message_handler.MessageHandler(id, id + "_worker", port);
  5055. this._messageHandler = messageHandler;
  5056. this._readyCapability.resolve();
  5057. messageHandler.send("configure", {
  5058. verbosity: this.verbosity
  5059. });
  5060. }).catch(reason => {
  5061. this._readyCapability.reject(new Error(`Setting up fake worker failed: "${reason.message}".`));
  5062. });
  5063. }
  5064. destroy() {
  5065. this.destroyed = true;
  5066. if (this._webWorker) {
  5067. this._webWorker.terminate();
  5068. this._webWorker = null;
  5069. }
  5070. PDFWorker.#workerPorts.delete(this._port);
  5071. this._port = null;
  5072. if (this._messageHandler) {
  5073. this._messageHandler.destroy();
  5074. this._messageHandler = null;
  5075. }
  5076. }
  5077. static fromPort(params) {
  5078. if (!(params !== null && params !== void 0 && params.port)) {
  5079. throw new Error("PDFWorker.fromPort - invalid method signature.");
  5080. }
  5081. if (this.#workerPorts.has(params.port)) {
  5082. return this.#workerPorts.get(params.port);
  5083. }
  5084. return new PDFWorker(params);
  5085. }
  5086. static get workerSrc() {
  5087. if (_worker_options.GlobalWorkerOptions.workerSrc) {
  5088. return _worker_options.GlobalWorkerOptions.workerSrc;
  5089. }
  5090. if (PDFWorkerUtil.fallbackWorkerSrc !== null) {
  5091. if (!_is_node.isNodeJS) {
  5092. (0, _display_utils.deprecated)('No "GlobalWorkerOptions.workerSrc" specified.');
  5093. }
  5094. return PDFWorkerUtil.fallbackWorkerSrc;
  5095. }
  5096. throw new Error('No "GlobalWorkerOptions.workerSrc" specified.');
  5097. }
  5098. static get _mainThreadWorkerMessageHandler() {
  5099. try {
  5100. var _globalThis$pdfjsWork;
  5101. return ((_globalThis$pdfjsWork = globalThis.pdfjsWorker) === null || _globalThis$pdfjsWork === void 0 ? void 0 : _globalThis$pdfjsWork.WorkerMessageHandler) || null;
  5102. } catch (ex) {
  5103. return null;
  5104. }
  5105. }
  5106. static get _setupFakeWorkerGlobal() {
  5107. const loader = async () => {
  5108. const mainWorkerMessageHandler = this._mainThreadWorkerMessageHandler;
  5109. if (mainWorkerMessageHandler) {
  5110. return mainWorkerMessageHandler;
  5111. }
  5112. if (_is_node.isNodeJS && typeof require === "function") {
  5113. const worker = eval("require")(this.workerSrc);
  5114. return worker.WorkerMessageHandler;
  5115. }
  5116. await (0, _display_utils.loadScript)(this.workerSrc);
  5117. return window.pdfjsWorker.WorkerMessageHandler;
  5118. };
  5119. return (0, _util.shadow)(this, "_setupFakeWorkerGlobal", loader());
  5120. }
  5121. }
  5122. exports.PDFWorker = PDFWorker;
  5123. var _methodPromises = /*#__PURE__*/new WeakMap();
  5124. var _pageCache = /*#__PURE__*/new WeakMap();
  5125. var _pagePromises = /*#__PURE__*/new WeakMap();
  5126. var _cacheSimpleMethod = /*#__PURE__*/new WeakSet();
  5127. class WorkerTransport {
  5128. constructor(messageHandler, loadingTask, networkStream, params, factory) {
  5129. _classPrivateMethodInitSpec(this, _cacheSimpleMethod);
  5130. _classPrivateFieldInitSpec(this, _methodPromises, {
  5131. writable: true,
  5132. value: new Map()
  5133. });
  5134. _classPrivateFieldInitSpec(this, _pageCache, {
  5135. writable: true,
  5136. value: new Map()
  5137. });
  5138. _classPrivateFieldInitSpec(this, _pagePromises, {
  5139. writable: true,
  5140. value: new Map()
  5141. });
  5142. this.messageHandler = messageHandler;
  5143. this.loadingTask = loadingTask;
  5144. this.commonObjs = new PDFObjects();
  5145. this.fontLoader = new _font_loader.FontLoader({
  5146. onUnsupportedFeature: this._onUnsupportedFeature.bind(this),
  5147. ownerDocument: params.ownerDocument,
  5148. styleElement: params.styleElement
  5149. });
  5150. this._params = params;
  5151. this.cMapReaderFactory = factory === null || factory === void 0 ? void 0 : factory.cMapReaderFactory;
  5152. this.standardFontDataFactory = factory === null || factory === void 0 ? void 0 : factory.standardFontDataFactory;
  5153. this.destroyed = false;
  5154. this.destroyCapability = null;
  5155. this._passwordCapability = null;
  5156. this._networkStream = networkStream;
  5157. this._fullReader = null;
  5158. this._lastProgress = null;
  5159. this.downloadInfoCapability = (0, _util.createPromiseCapability)();
  5160. this.setupMessageHandler();
  5161. }
  5162. get annotationStorage() {
  5163. return (0, _util.shadow)(this, "annotationStorage", new _annotation_storage.AnnotationStorage());
  5164. }
  5165. getRenderingIntent(intent) {
  5166. let annotationMode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _util.AnnotationMode.ENABLE;
  5167. let printAnnotationStorage = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  5168. let isOpList = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  5169. let renderingIntent = _util.RenderingIntentFlag.DISPLAY;
  5170. let annotationMap = null;
  5171. switch (intent) {
  5172. case "any":
  5173. renderingIntent = _util.RenderingIntentFlag.ANY;
  5174. break;
  5175. case "display":
  5176. break;
  5177. case "print":
  5178. renderingIntent = _util.RenderingIntentFlag.PRINT;
  5179. break;
  5180. default:
  5181. (0, _util.warn)(`getRenderingIntent - invalid intent: ${intent}`);
  5182. }
  5183. switch (annotationMode) {
  5184. case _util.AnnotationMode.DISABLE:
  5185. renderingIntent += _util.RenderingIntentFlag.ANNOTATIONS_DISABLE;
  5186. break;
  5187. case _util.AnnotationMode.ENABLE:
  5188. break;
  5189. case _util.AnnotationMode.ENABLE_FORMS:
  5190. renderingIntent += _util.RenderingIntentFlag.ANNOTATIONS_FORMS;
  5191. break;
  5192. case _util.AnnotationMode.ENABLE_STORAGE:
  5193. renderingIntent += _util.RenderingIntentFlag.ANNOTATIONS_STORAGE;
  5194. const annotationStorage = renderingIntent & _util.RenderingIntentFlag.PRINT && printAnnotationStorage instanceof _annotation_storage.PrintAnnotationStorage ? printAnnotationStorage : this.annotationStorage;
  5195. annotationMap = annotationStorage.serializable;
  5196. break;
  5197. default:
  5198. (0, _util.warn)(`getRenderingIntent - invalid annotationMode: ${annotationMode}`);
  5199. }
  5200. if (isOpList) {
  5201. renderingIntent += _util.RenderingIntentFlag.OPLIST;
  5202. }
  5203. return {
  5204. renderingIntent,
  5205. cacheKey: `${renderingIntent}_${_annotation_storage.AnnotationStorage.getHash(annotationMap)}`,
  5206. annotationStorageMap: annotationMap
  5207. };
  5208. }
  5209. destroy() {
  5210. if (this.destroyCapability) {
  5211. return this.destroyCapability.promise;
  5212. }
  5213. this.destroyed = true;
  5214. this.destroyCapability = (0, _util.createPromiseCapability)();
  5215. if (this._passwordCapability) {
  5216. this._passwordCapability.reject(new Error("Worker was destroyed during onPassword callback"));
  5217. }
  5218. const waitOn = [];
  5219. for (const page of _classPrivateFieldGet(this, _pageCache).values()) {
  5220. waitOn.push(page._destroy());
  5221. }
  5222. _classPrivateFieldGet(this, _pageCache).clear();
  5223. _classPrivateFieldGet(this, _pagePromises).clear();
  5224. if (this.hasOwnProperty("annotationStorage")) {
  5225. this.annotationStorage.resetModified();
  5226. }
  5227. const terminated = this.messageHandler.sendWithPromise("Terminate", null);
  5228. waitOn.push(terminated);
  5229. Promise.all(waitOn).then(() => {
  5230. this.commonObjs.clear();
  5231. this.fontLoader.clear();
  5232. _classPrivateFieldGet(this, _methodPromises).clear();
  5233. if (this._networkStream) {
  5234. this._networkStream.cancelAllRequests(new _util.AbortException("Worker was terminated."));
  5235. }
  5236. if (this.messageHandler) {
  5237. this.messageHandler.destroy();
  5238. this.messageHandler = null;
  5239. }
  5240. this.destroyCapability.resolve();
  5241. }, this.destroyCapability.reject);
  5242. return this.destroyCapability.promise;
  5243. }
  5244. setupMessageHandler() {
  5245. const {
  5246. messageHandler,
  5247. loadingTask
  5248. } = this;
  5249. messageHandler.on("GetReader", (data, sink) => {
  5250. (0, _util.assert)(this._networkStream, "GetReader - no `IPDFStream` instance available.");
  5251. this._fullReader = this._networkStream.getFullReader();
  5252. this._fullReader.onProgress = evt => {
  5253. this._lastProgress = {
  5254. loaded: evt.loaded,
  5255. total: evt.total
  5256. };
  5257. };
  5258. sink.onPull = () => {
  5259. this._fullReader.read().then(function (_ref8) {
  5260. let {
  5261. value,
  5262. done
  5263. } = _ref8;
  5264. if (done) {
  5265. sink.close();
  5266. return;
  5267. }
  5268. (0, _util.assert)(value instanceof ArrayBuffer, "GetReader - expected an ArrayBuffer.");
  5269. sink.enqueue(new Uint8Array(value), 1, [value]);
  5270. }).catch(reason => {
  5271. sink.error(reason);
  5272. });
  5273. };
  5274. sink.onCancel = reason => {
  5275. this._fullReader.cancel(reason);
  5276. sink.ready.catch(readyReason => {
  5277. if (this.destroyed) {
  5278. return;
  5279. }
  5280. throw readyReason;
  5281. });
  5282. };
  5283. });
  5284. messageHandler.on("ReaderHeadersReady", data => {
  5285. const headersCapability = (0, _util.createPromiseCapability)();
  5286. const fullReader = this._fullReader;
  5287. fullReader.headersReady.then(() => {
  5288. if (!fullReader.isStreamingSupported || !fullReader.isRangeSupported) {
  5289. if (this._lastProgress) {
  5290. var _loadingTask$onProgre;
  5291. (_loadingTask$onProgre = loadingTask.onProgress) === null || _loadingTask$onProgre === void 0 ? void 0 : _loadingTask$onProgre.call(loadingTask, this._lastProgress);
  5292. }
  5293. fullReader.onProgress = evt => {
  5294. var _loadingTask$onProgre2;
  5295. (_loadingTask$onProgre2 = loadingTask.onProgress) === null || _loadingTask$onProgre2 === void 0 ? void 0 : _loadingTask$onProgre2.call(loadingTask, {
  5296. loaded: evt.loaded,
  5297. total: evt.total
  5298. });
  5299. };
  5300. }
  5301. headersCapability.resolve({
  5302. isStreamingSupported: fullReader.isStreamingSupported,
  5303. isRangeSupported: fullReader.isRangeSupported,
  5304. contentLength: fullReader.contentLength
  5305. });
  5306. }, headersCapability.reject);
  5307. return headersCapability.promise;
  5308. });
  5309. messageHandler.on("GetRangeReader", (data, sink) => {
  5310. (0, _util.assert)(this._networkStream, "GetRangeReader - no `IPDFStream` instance available.");
  5311. const rangeReader = this._networkStream.getRangeReader(data.begin, data.end);
  5312. if (!rangeReader) {
  5313. sink.close();
  5314. return;
  5315. }
  5316. sink.onPull = () => {
  5317. rangeReader.read().then(function (_ref9) {
  5318. let {
  5319. value,
  5320. done
  5321. } = _ref9;
  5322. if (done) {
  5323. sink.close();
  5324. return;
  5325. }
  5326. (0, _util.assert)(value instanceof ArrayBuffer, "GetRangeReader - expected an ArrayBuffer.");
  5327. sink.enqueue(new Uint8Array(value), 1, [value]);
  5328. }).catch(reason => {
  5329. sink.error(reason);
  5330. });
  5331. };
  5332. sink.onCancel = reason => {
  5333. rangeReader.cancel(reason);
  5334. sink.ready.catch(readyReason => {
  5335. if (this.destroyed) {
  5336. return;
  5337. }
  5338. throw readyReason;
  5339. });
  5340. };
  5341. });
  5342. messageHandler.on("GetDoc", _ref10 => {
  5343. let {
  5344. pdfInfo
  5345. } = _ref10;
  5346. this._numPages = pdfInfo.numPages;
  5347. this._htmlForXfa = pdfInfo.htmlForXfa;
  5348. delete pdfInfo.htmlForXfa;
  5349. loadingTask._capability.resolve(new PDFDocumentProxy(pdfInfo, this));
  5350. });
  5351. messageHandler.on("DocException", function (ex) {
  5352. let reason;
  5353. switch (ex.name) {
  5354. case "PasswordException":
  5355. reason = new _util.PasswordException(ex.message, ex.code);
  5356. break;
  5357. case "InvalidPDFException":
  5358. reason = new _util.InvalidPDFException(ex.message);
  5359. break;
  5360. case "MissingPDFException":
  5361. reason = new _util.MissingPDFException(ex.message);
  5362. break;
  5363. case "UnexpectedResponseException":
  5364. reason = new _util.UnexpectedResponseException(ex.message, ex.status);
  5365. break;
  5366. case "UnknownErrorException":
  5367. reason = new _util.UnknownErrorException(ex.message, ex.details);
  5368. break;
  5369. default:
  5370. (0, _util.unreachable)("DocException - expected a valid Error.");
  5371. }
  5372. loadingTask._capability.reject(reason);
  5373. });
  5374. messageHandler.on("PasswordRequest", exception => {
  5375. this._passwordCapability = (0, _util.createPromiseCapability)();
  5376. if (loadingTask.onPassword) {
  5377. const updatePassword = password => {
  5378. if (password instanceof Error) {
  5379. this._passwordCapability.reject(password);
  5380. } else {
  5381. this._passwordCapability.resolve({
  5382. password
  5383. });
  5384. }
  5385. };
  5386. try {
  5387. loadingTask.onPassword(updatePassword, exception.code);
  5388. } catch (ex) {
  5389. this._passwordCapability.reject(ex);
  5390. }
  5391. } else {
  5392. this._passwordCapability.reject(new _util.PasswordException(exception.message, exception.code));
  5393. }
  5394. return this._passwordCapability.promise;
  5395. });
  5396. messageHandler.on("DataLoaded", data => {
  5397. var _loadingTask$onProgre3;
  5398. (_loadingTask$onProgre3 = loadingTask.onProgress) === null || _loadingTask$onProgre3 === void 0 ? void 0 : _loadingTask$onProgre3.call(loadingTask, {
  5399. loaded: data.length,
  5400. total: data.length
  5401. });
  5402. this.downloadInfoCapability.resolve(data);
  5403. });
  5404. messageHandler.on("StartRenderPage", data => {
  5405. if (this.destroyed) {
  5406. return;
  5407. }
  5408. const page = _classPrivateFieldGet(this, _pageCache).get(data.pageIndex);
  5409. page._startRenderPage(data.transparency, data.cacheKey);
  5410. });
  5411. messageHandler.on("commonobj", _ref11 => {
  5412. var _globalThis$FontInspe;
  5413. let [id, type, exportedData] = _ref11;
  5414. if (this.destroyed) {
  5415. return;
  5416. }
  5417. if (this.commonObjs.has(id)) {
  5418. return;
  5419. }
  5420. switch (type) {
  5421. case "Font":
  5422. const params = this._params;
  5423. if ("error" in exportedData) {
  5424. const exportedError = exportedData.error;
  5425. (0, _util.warn)(`Error during font loading: ${exportedError}`);
  5426. this.commonObjs.resolve(id, exportedError);
  5427. break;
  5428. }
  5429. let fontRegistry = null;
  5430. if (params.pdfBug && (_globalThis$FontInspe = globalThis.FontInspector) !== null && _globalThis$FontInspe !== void 0 && _globalThis$FontInspe.enabled) {
  5431. fontRegistry = {
  5432. registerFont(font, url) {
  5433. globalThis.FontInspector.fontAdded(font, url);
  5434. }
  5435. };
  5436. }
  5437. const font = new _font_loader.FontFaceObject(exportedData, {
  5438. isEvalSupported: params.isEvalSupported,
  5439. disableFontFace: params.disableFontFace,
  5440. ignoreErrors: params.ignoreErrors,
  5441. onUnsupportedFeature: this._onUnsupportedFeature.bind(this),
  5442. fontRegistry
  5443. });
  5444. this.fontLoader.bind(font).catch(reason => {
  5445. return messageHandler.sendWithPromise("FontFallback", {
  5446. id
  5447. });
  5448. }).finally(() => {
  5449. if (!params.fontExtraProperties && font.data) {
  5450. font.data = null;
  5451. }
  5452. this.commonObjs.resolve(id, font);
  5453. });
  5454. break;
  5455. case "FontPath":
  5456. case "Image":
  5457. this.commonObjs.resolve(id, exportedData);
  5458. break;
  5459. default:
  5460. throw new Error(`Got unknown common object type ${type}`);
  5461. }
  5462. });
  5463. messageHandler.on("obj", _ref12 => {
  5464. let [id, pageIndex, type, imageData] = _ref12;
  5465. if (this.destroyed) {
  5466. return;
  5467. }
  5468. const pageProxy = _classPrivateFieldGet(this, _pageCache).get(pageIndex);
  5469. if (pageProxy.objs.has(id)) {
  5470. return;
  5471. }
  5472. switch (type) {
  5473. case "Image":
  5474. pageProxy.objs.resolve(id, imageData);
  5475. const MAX_IMAGE_SIZE_TO_STORE = 8000000;
  5476. if (imageData) {
  5477. let length;
  5478. if (imageData.bitmap) {
  5479. const {
  5480. width,
  5481. height
  5482. } = imageData;
  5483. length = width * height * 4;
  5484. } else {
  5485. var _imageData$data;
  5486. length = ((_imageData$data = imageData.data) === null || _imageData$data === void 0 ? void 0 : _imageData$data.length) || 0;
  5487. }
  5488. if (length > MAX_IMAGE_SIZE_TO_STORE) {
  5489. pageProxy.cleanupAfterRender = true;
  5490. }
  5491. }
  5492. break;
  5493. case "Pattern":
  5494. pageProxy.objs.resolve(id, imageData);
  5495. break;
  5496. default:
  5497. throw new Error(`Got unknown object type ${type}`);
  5498. }
  5499. });
  5500. messageHandler.on("DocProgress", data => {
  5501. var _loadingTask$onProgre4;
  5502. if (this.destroyed) {
  5503. return;
  5504. }
  5505. (_loadingTask$onProgre4 = loadingTask.onProgress) === null || _loadingTask$onProgre4 === void 0 ? void 0 : _loadingTask$onProgre4.call(loadingTask, {
  5506. loaded: data.loaded,
  5507. total: data.total
  5508. });
  5509. });
  5510. messageHandler.on("UnsupportedFeature", this._onUnsupportedFeature.bind(this));
  5511. messageHandler.on("FetchBuiltInCMap", data => {
  5512. if (this.destroyed) {
  5513. return Promise.reject(new Error("Worker was destroyed."));
  5514. }
  5515. if (!this.cMapReaderFactory) {
  5516. return Promise.reject(new Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter."));
  5517. }
  5518. return this.cMapReaderFactory.fetch(data);
  5519. });
  5520. messageHandler.on("FetchStandardFontData", data => {
  5521. if (this.destroyed) {
  5522. return Promise.reject(new Error("Worker was destroyed."));
  5523. }
  5524. if (!this.standardFontDataFactory) {
  5525. return Promise.reject(new Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter."));
  5526. }
  5527. return this.standardFontDataFactory.fetch(data);
  5528. });
  5529. }
  5530. _onUnsupportedFeature(_ref13) {
  5531. var _this$loadingTask$onU, _this$loadingTask;
  5532. let {
  5533. featureId
  5534. } = _ref13;
  5535. if (this.destroyed) {
  5536. return;
  5537. }
  5538. (_this$loadingTask$onU = (_this$loadingTask = this.loadingTask).onUnsupportedFeature) === null || _this$loadingTask$onU === void 0 ? void 0 : _this$loadingTask$onU.call(_this$loadingTask, featureId);
  5539. }
  5540. getData() {
  5541. return this.messageHandler.sendWithPromise("GetData", null);
  5542. }
  5543. saveDocument() {
  5544. var _this$_fullReader;
  5545. if (this.annotationStorage.size <= 0) {
  5546. (0, _util.warn)("saveDocument called while `annotationStorage` is empty, " + "please use the getData-method instead.");
  5547. }
  5548. return this.messageHandler.sendWithPromise("SaveDocument", {
  5549. isPureXfa: !!this._htmlForXfa,
  5550. numPages: this._numPages,
  5551. annotationStorage: this.annotationStorage.serializable,
  5552. filename: ((_this$_fullReader = this._fullReader) === null || _this$_fullReader === void 0 ? void 0 : _this$_fullReader.filename) ?? null
  5553. }).finally(() => {
  5554. this.annotationStorage.resetModified();
  5555. });
  5556. }
  5557. getPage(pageNumber) {
  5558. if (!Number.isInteger(pageNumber) || pageNumber <= 0 || pageNumber > this._numPages) {
  5559. return Promise.reject(new Error("Invalid page request."));
  5560. }
  5561. const pageIndex = pageNumber - 1,
  5562. cachedPromise = _classPrivateFieldGet(this, _pagePromises).get(pageIndex);
  5563. if (cachedPromise) {
  5564. return cachedPromise;
  5565. }
  5566. const promise = this.messageHandler.sendWithPromise("GetPage", {
  5567. pageIndex
  5568. }).then(pageInfo => {
  5569. if (this.destroyed) {
  5570. throw new Error("Transport destroyed");
  5571. }
  5572. const page = new PDFPageProxy(pageIndex, pageInfo, this, this._params.ownerDocument, this._params.pdfBug);
  5573. _classPrivateFieldGet(this, _pageCache).set(pageIndex, page);
  5574. return page;
  5575. });
  5576. _classPrivateFieldGet(this, _pagePromises).set(pageIndex, promise);
  5577. return promise;
  5578. }
  5579. getPageIndex(ref) {
  5580. if (typeof ref !== "object" || ref === null || !Number.isInteger(ref.num) || ref.num < 0 || !Number.isInteger(ref.gen) || ref.gen < 0) {
  5581. return Promise.reject(new Error("Invalid pageIndex request."));
  5582. }
  5583. return this.messageHandler.sendWithPromise("GetPageIndex", {
  5584. num: ref.num,
  5585. gen: ref.gen
  5586. });
  5587. }
  5588. getAnnotations(pageIndex, intent) {
  5589. return this.messageHandler.sendWithPromise("GetAnnotations", {
  5590. pageIndex,
  5591. intent
  5592. });
  5593. }
  5594. getFieldObjects() {
  5595. return _classPrivateMethodGet(this, _cacheSimpleMethod, _cacheSimpleMethod2).call(this, "GetFieldObjects");
  5596. }
  5597. hasJSActions() {
  5598. return _classPrivateMethodGet(this, _cacheSimpleMethod, _cacheSimpleMethod2).call(this, "HasJSActions");
  5599. }
  5600. getCalculationOrderIds() {
  5601. return this.messageHandler.sendWithPromise("GetCalculationOrderIds", null);
  5602. }
  5603. getDestinations() {
  5604. return this.messageHandler.sendWithPromise("GetDestinations", null);
  5605. }
  5606. getDestination(id) {
  5607. if (typeof id !== "string") {
  5608. return Promise.reject(new Error("Invalid destination request."));
  5609. }
  5610. return this.messageHandler.sendWithPromise("GetDestination", {
  5611. id
  5612. });
  5613. }
  5614. getPageLabels() {
  5615. return this.messageHandler.sendWithPromise("GetPageLabels", null);
  5616. }
  5617. getPageLayout() {
  5618. return this.messageHandler.sendWithPromise("GetPageLayout", null);
  5619. }
  5620. getPageMode() {
  5621. return this.messageHandler.sendWithPromise("GetPageMode", null);
  5622. }
  5623. getViewerPreferences() {
  5624. return this.messageHandler.sendWithPromise("GetViewerPreferences", null);
  5625. }
  5626. getOpenAction() {
  5627. return this.messageHandler.sendWithPromise("GetOpenAction", null);
  5628. }
  5629. getAttachments() {
  5630. return this.messageHandler.sendWithPromise("GetAttachments", null);
  5631. }
  5632. getJavaScript() {
  5633. return this.messageHandler.sendWithPromise("GetJavaScript", null);
  5634. }
  5635. getDocJSActions() {
  5636. return this.messageHandler.sendWithPromise("GetDocJSActions", null);
  5637. }
  5638. getPageJSActions(pageIndex) {
  5639. return this.messageHandler.sendWithPromise("GetPageJSActions", {
  5640. pageIndex
  5641. });
  5642. }
  5643. getStructTree(pageIndex) {
  5644. return this.messageHandler.sendWithPromise("GetStructTree", {
  5645. pageIndex
  5646. });
  5647. }
  5648. getOutline() {
  5649. return this.messageHandler.sendWithPromise("GetOutline", null);
  5650. }
  5651. getOptionalContentConfig() {
  5652. return this.messageHandler.sendWithPromise("GetOptionalContentConfig", null).then(results => {
  5653. return new _optional_content_config.OptionalContentConfig(results);
  5654. });
  5655. }
  5656. getPermissions() {
  5657. return this.messageHandler.sendWithPromise("GetPermissions", null);
  5658. }
  5659. getMetadata() {
  5660. const name = "GetMetadata",
  5661. cachedPromise = _classPrivateFieldGet(this, _methodPromises).get(name);
  5662. if (cachedPromise) {
  5663. return cachedPromise;
  5664. }
  5665. const promise = this.messageHandler.sendWithPromise(name, null).then(results => {
  5666. var _this$_fullReader2, _this$_fullReader3;
  5667. return {
  5668. info: results[0],
  5669. metadata: results[1] ? new _metadata.Metadata(results[1]) : null,
  5670. contentDispositionFilename: ((_this$_fullReader2 = this._fullReader) === null || _this$_fullReader2 === void 0 ? void 0 : _this$_fullReader2.filename) ?? null,
  5671. contentLength: ((_this$_fullReader3 = this._fullReader) === null || _this$_fullReader3 === void 0 ? void 0 : _this$_fullReader3.contentLength) ?? null
  5672. };
  5673. });
  5674. _classPrivateFieldGet(this, _methodPromises).set(name, promise);
  5675. return promise;
  5676. }
  5677. getMarkInfo() {
  5678. return this.messageHandler.sendWithPromise("GetMarkInfo", null);
  5679. }
  5680. async startCleanup() {
  5681. let keepLoadedFonts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  5682. if (this.destroyed) {
  5683. return;
  5684. }
  5685. await this.messageHandler.sendWithPromise("Cleanup", null);
  5686. for (const page of _classPrivateFieldGet(this, _pageCache).values()) {
  5687. const cleanupSuccessful = page.cleanup();
  5688. if (!cleanupSuccessful) {
  5689. throw new Error(`startCleanup: Page ${page.pageNumber} is currently rendering.`);
  5690. }
  5691. }
  5692. this.commonObjs.clear();
  5693. if (!keepLoadedFonts) {
  5694. this.fontLoader.clear();
  5695. }
  5696. _classPrivateFieldGet(this, _methodPromises).clear();
  5697. }
  5698. get loadingParams() {
  5699. const {
  5700. disableAutoFetch,
  5701. enableXfa
  5702. } = this._params;
  5703. return (0, _util.shadow)(this, "loadingParams", {
  5704. disableAutoFetch,
  5705. enableXfa
  5706. });
  5707. }
  5708. }
  5709. function _cacheSimpleMethod2(name) {
  5710. let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  5711. const cachedPromise = _classPrivateFieldGet(this, _methodPromises).get(name);
  5712. if (cachedPromise) {
  5713. return cachedPromise;
  5714. }
  5715. const promise = this.messageHandler.sendWithPromise(name, data);
  5716. _classPrivateFieldGet(this, _methodPromises).set(name, promise);
  5717. return promise;
  5718. }
  5719. var _objs = /*#__PURE__*/new WeakMap();
  5720. var _ensureObj = /*#__PURE__*/new WeakSet();
  5721. class PDFObjects {
  5722. constructor() {
  5723. _classPrivateMethodInitSpec(this, _ensureObj);
  5724. _classPrivateFieldInitSpec(this, _objs, {
  5725. writable: true,
  5726. value: Object.create(null)
  5727. });
  5728. }
  5729. get(objId) {
  5730. let callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  5731. if (callback) {
  5732. const obj = _classPrivateMethodGet(this, _ensureObj, _ensureObj2).call(this, objId);
  5733. obj.capability.promise.then(() => callback(obj.data));
  5734. return null;
  5735. }
  5736. const obj = _classPrivateFieldGet(this, _objs)[objId];
  5737. if (!(obj !== null && obj !== void 0 && obj.capability.settled)) {
  5738. throw new Error(`Requesting object that isn't resolved yet ${objId}.`);
  5739. }
  5740. return obj.data;
  5741. }
  5742. has(objId) {
  5743. const obj = _classPrivateFieldGet(this, _objs)[objId];
  5744. return (obj === null || obj === void 0 ? void 0 : obj.capability.settled) || false;
  5745. }
  5746. resolve(objId) {
  5747. let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  5748. const obj = _classPrivateMethodGet(this, _ensureObj, _ensureObj2).call(this, objId);
  5749. obj.data = data;
  5750. obj.capability.resolve();
  5751. }
  5752. clear() {
  5753. for (const objId in _classPrivateFieldGet(this, _objs)) {
  5754. var _data$bitmap;
  5755. const {
  5756. data
  5757. } = _classPrivateFieldGet(this, _objs)[objId];
  5758. data === null || data === void 0 ? void 0 : (_data$bitmap = data.bitmap) === null || _data$bitmap === void 0 ? void 0 : _data$bitmap.close();
  5759. }
  5760. _classPrivateFieldSet(this, _objs, Object.create(null));
  5761. }
  5762. }
  5763. function _ensureObj2(objId) {
  5764. const obj = _classPrivateFieldGet(this, _objs)[objId];
  5765. if (obj) {
  5766. return obj;
  5767. }
  5768. return _classPrivateFieldGet(this, _objs)[objId] = {
  5769. capability: (0, _util.createPromiseCapability)(),
  5770. data: null
  5771. };
  5772. }
  5773. class RenderTask {
  5774. #internalRenderTask = null;
  5775. constructor(internalRenderTask) {
  5776. this.#internalRenderTask = internalRenderTask;
  5777. this.onContinue = null;
  5778. }
  5779. get promise() {
  5780. return this.#internalRenderTask.capability.promise;
  5781. }
  5782. cancel() {
  5783. let extraDelay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  5784. this.#internalRenderTask.cancel(null, extraDelay);
  5785. }
  5786. get separateAnnots() {
  5787. const {
  5788. separateAnnots
  5789. } = this.#internalRenderTask.operatorList;
  5790. if (!separateAnnots) {
  5791. return false;
  5792. }
  5793. const {
  5794. annotationCanvasMap
  5795. } = this.#internalRenderTask;
  5796. return separateAnnots.form || separateAnnots.canvas && (annotationCanvasMap === null || annotationCanvasMap === void 0 ? void 0 : annotationCanvasMap.size) > 0;
  5797. }
  5798. }
  5799. exports.RenderTask = RenderTask;
  5800. class InternalRenderTask {
  5801. static #canvasInUse = new WeakSet();
  5802. constructor(_ref14) {
  5803. let {
  5804. callback,
  5805. params,
  5806. objs,
  5807. commonObjs,
  5808. annotationCanvasMap,
  5809. operatorList,
  5810. pageIndex,
  5811. canvasFactory,
  5812. useRequestAnimationFrame = false,
  5813. pdfBug = false,
  5814. pageColors = null
  5815. } = _ref14;
  5816. this.callback = callback;
  5817. this.params = params;
  5818. this.objs = objs;
  5819. this.commonObjs = commonObjs;
  5820. this.annotationCanvasMap = annotationCanvasMap;
  5821. this.operatorListIdx = null;
  5822. this.operatorList = operatorList;
  5823. this._pageIndex = pageIndex;
  5824. this.canvasFactory = canvasFactory;
  5825. this._pdfBug = pdfBug;
  5826. this.pageColors = pageColors;
  5827. this.running = false;
  5828. this.graphicsReadyCallback = null;
  5829. this.graphicsReady = false;
  5830. this._useRequestAnimationFrame = useRequestAnimationFrame === true && typeof window !== "undefined";
  5831. this.cancelled = false;
  5832. this.capability = (0, _util.createPromiseCapability)();
  5833. this.task = new RenderTask(this);
  5834. this._cancelBound = this.cancel.bind(this);
  5835. this._continueBound = this._continue.bind(this);
  5836. this._scheduleNextBound = this._scheduleNext.bind(this);
  5837. this._nextBound = this._next.bind(this);
  5838. this._canvas = params.canvasContext.canvas;
  5839. }
  5840. get completed() {
  5841. return this.capability.promise.catch(function () {});
  5842. }
  5843. initializeGraphics(_ref15) {
  5844. var _globalThis$StepperMa, _this$graphicsReadyCa;
  5845. let {
  5846. transparency = false,
  5847. optionalContentConfig
  5848. } = _ref15;
  5849. if (this.cancelled) {
  5850. return;
  5851. }
  5852. if (this._canvas) {
  5853. if (InternalRenderTask.#canvasInUse.has(this._canvas)) {
  5854. throw new Error("Cannot use the same canvas during multiple render() operations. " + "Use different canvas or ensure previous operations were " + "cancelled or completed.");
  5855. }
  5856. InternalRenderTask.#canvasInUse.add(this._canvas);
  5857. }
  5858. if (this._pdfBug && (_globalThis$StepperMa = globalThis.StepperManager) !== null && _globalThis$StepperMa !== void 0 && _globalThis$StepperMa.enabled) {
  5859. this.stepper = globalThis.StepperManager.create(this._pageIndex);
  5860. this.stepper.init(this.operatorList);
  5861. this.stepper.nextBreakPoint = this.stepper.getNextBreakPoint();
  5862. }
  5863. const {
  5864. canvasContext,
  5865. viewport,
  5866. transform,
  5867. background
  5868. } = this.params;
  5869. this.gfx = new _canvas.CanvasGraphics(canvasContext, this.commonObjs, this.objs, this.canvasFactory, {
  5870. optionalContentConfig
  5871. }, this.annotationCanvasMap, this.pageColors);
  5872. this.gfx.beginDrawing({
  5873. transform,
  5874. viewport,
  5875. transparency,
  5876. background
  5877. });
  5878. this.operatorListIdx = 0;
  5879. this.graphicsReady = true;
  5880. (_this$graphicsReadyCa = this.graphicsReadyCallback) === null || _this$graphicsReadyCa === void 0 ? void 0 : _this$graphicsReadyCa.call(this);
  5881. }
  5882. cancel() {
  5883. var _this$gfx;
  5884. let error = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  5885. let extraDelay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  5886. this.running = false;
  5887. this.cancelled = true;
  5888. (_this$gfx = this.gfx) === null || _this$gfx === void 0 ? void 0 : _this$gfx.endDrawing();
  5889. if (this._canvas) {
  5890. InternalRenderTask.#canvasInUse.delete(this._canvas);
  5891. }
  5892. this.callback(error || new _display_utils.RenderingCancelledException(`Rendering cancelled, page ${this._pageIndex + 1}`, "canvas", extraDelay));
  5893. }
  5894. operatorListChanged() {
  5895. var _this$stepper;
  5896. if (!this.graphicsReady) {
  5897. if (!this.graphicsReadyCallback) {
  5898. this.graphicsReadyCallback = this._continueBound;
  5899. }
  5900. return;
  5901. }
  5902. (_this$stepper = this.stepper) === null || _this$stepper === void 0 ? void 0 : _this$stepper.updateOperatorList(this.operatorList);
  5903. if (this.running) {
  5904. return;
  5905. }
  5906. this._continue();
  5907. }
  5908. _continue() {
  5909. this.running = true;
  5910. if (this.cancelled) {
  5911. return;
  5912. }
  5913. if (this.task.onContinue) {
  5914. this.task.onContinue(this._scheduleNextBound);
  5915. } else {
  5916. this._scheduleNext();
  5917. }
  5918. }
  5919. _scheduleNext() {
  5920. if (this._useRequestAnimationFrame) {
  5921. window.requestAnimationFrame(() => {
  5922. this._nextBound().catch(this._cancelBound);
  5923. });
  5924. } else {
  5925. Promise.resolve().then(this._nextBound).catch(this._cancelBound);
  5926. }
  5927. }
  5928. async _next() {
  5929. if (this.cancelled) {
  5930. return;
  5931. }
  5932. this.operatorListIdx = this.gfx.executeOperatorList(this.operatorList, this.operatorListIdx, this._continueBound, this.stepper);
  5933. if (this.operatorListIdx === this.operatorList.argsArray.length) {
  5934. this.running = false;
  5935. if (this.operatorList.lastChunk) {
  5936. this.gfx.endDrawing();
  5937. if (this._canvas) {
  5938. InternalRenderTask.#canvasInUse.delete(this._canvas);
  5939. }
  5940. this.callback();
  5941. }
  5942. }
  5943. }
  5944. }
  5945. const version = '3.4.120';
  5946. exports.version = version;
  5947. const build = 'af6414988';
  5948. exports.build = build;
  5949. /***/ }),
  5950. /* 136 */
  5951. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  5952. "use strict";
  5953. Object.defineProperty(exports, "__esModule", ({
  5954. value: true
  5955. }));
  5956. exports.PrintAnnotationStorage = exports.AnnotationStorage = void 0;
  5957. var _util = __w_pdfjs_require__(1);
  5958. var _editor = __w_pdfjs_require__(137);
  5959. var _murmurhash = __w_pdfjs_require__(141);
  5960. function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
  5961. function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
  5962. function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
  5963. function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
  5964. function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }
  5965. function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
  5966. function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
  5967. function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
  5968. function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
  5969. var _modified = /*#__PURE__*/new WeakMap();
  5970. var _storage = /*#__PURE__*/new WeakMap();
  5971. var _setModified = /*#__PURE__*/new WeakSet();
  5972. class AnnotationStorage {
  5973. constructor() {
  5974. _classPrivateMethodInitSpec(this, _setModified);
  5975. _classPrivateFieldInitSpec(this, _modified, {
  5976. writable: true,
  5977. value: false
  5978. });
  5979. _classPrivateFieldInitSpec(this, _storage, {
  5980. writable: true,
  5981. value: new Map()
  5982. });
  5983. this.onSetModified = null;
  5984. this.onResetModified = null;
  5985. this.onAnnotationEditor = null;
  5986. }
  5987. getValue(key, defaultValue) {
  5988. const value = _classPrivateFieldGet(this, _storage).get(key);
  5989. if (value === undefined) {
  5990. return defaultValue;
  5991. }
  5992. return Object.assign(defaultValue, value);
  5993. }
  5994. getRawValue(key) {
  5995. return _classPrivateFieldGet(this, _storage).get(key);
  5996. }
  5997. remove(key) {
  5998. _classPrivateFieldGet(this, _storage).delete(key);
  5999. if (_classPrivateFieldGet(this, _storage).size === 0) {
  6000. this.resetModified();
  6001. }
  6002. if (typeof this.onAnnotationEditor === "function") {
  6003. for (const value of _classPrivateFieldGet(this, _storage).values()) {
  6004. if (value instanceof _editor.AnnotationEditor) {
  6005. return;
  6006. }
  6007. }
  6008. this.onAnnotationEditor(null);
  6009. }
  6010. }
  6011. setValue(key, value) {
  6012. const obj = _classPrivateFieldGet(this, _storage).get(key);
  6013. let modified = false;
  6014. if (obj !== undefined) {
  6015. for (const [entry, val] of Object.entries(value)) {
  6016. if (obj[entry] !== val) {
  6017. modified = true;
  6018. obj[entry] = val;
  6019. }
  6020. }
  6021. } else {
  6022. modified = true;
  6023. _classPrivateFieldGet(this, _storage).set(key, value);
  6024. }
  6025. if (modified) {
  6026. _classPrivateMethodGet(this, _setModified, _setModified2).call(this);
  6027. }
  6028. if (value instanceof _editor.AnnotationEditor && typeof this.onAnnotationEditor === "function") {
  6029. this.onAnnotationEditor(value.constructor._type);
  6030. }
  6031. }
  6032. has(key) {
  6033. return _classPrivateFieldGet(this, _storage).has(key);
  6034. }
  6035. getAll() {
  6036. return _classPrivateFieldGet(this, _storage).size > 0 ? (0, _util.objectFromMap)(_classPrivateFieldGet(this, _storage)) : null;
  6037. }
  6038. setAll(obj) {
  6039. for (const [key, val] of Object.entries(obj)) {
  6040. this.setValue(key, val);
  6041. }
  6042. }
  6043. get size() {
  6044. return _classPrivateFieldGet(this, _storage).size;
  6045. }
  6046. resetModified() {
  6047. if (_classPrivateFieldGet(this, _modified)) {
  6048. _classPrivateFieldSet(this, _modified, false);
  6049. if (typeof this.onResetModified === "function") {
  6050. this.onResetModified();
  6051. }
  6052. }
  6053. }
  6054. get print() {
  6055. return new PrintAnnotationStorage(this);
  6056. }
  6057. get serializable() {
  6058. if (_classPrivateFieldGet(this, _storage).size === 0) {
  6059. return null;
  6060. }
  6061. const clone = new Map();
  6062. for (const [key, val] of _classPrivateFieldGet(this, _storage)) {
  6063. const serialized = val instanceof _editor.AnnotationEditor ? val.serialize() : val;
  6064. if (serialized) {
  6065. clone.set(key, serialized);
  6066. }
  6067. }
  6068. return clone;
  6069. }
  6070. static getHash(map) {
  6071. if (!map) {
  6072. return "";
  6073. }
  6074. const hash = new _murmurhash.MurmurHash3_64();
  6075. for (const [key, val] of map) {
  6076. hash.update(`${key}:${JSON.stringify(val)}`);
  6077. }
  6078. return hash.hexdigest();
  6079. }
  6080. }
  6081. exports.AnnotationStorage = AnnotationStorage;
  6082. function _setModified2() {
  6083. if (!_classPrivateFieldGet(this, _modified)) {
  6084. _classPrivateFieldSet(this, _modified, true);
  6085. if (typeof this.onSetModified === "function") {
  6086. this.onSetModified();
  6087. }
  6088. }
  6089. }
  6090. class PrintAnnotationStorage extends AnnotationStorage {
  6091. #serializable = null;
  6092. constructor(parent) {
  6093. super();
  6094. this.#serializable = structuredClone(parent.serializable);
  6095. }
  6096. get print() {
  6097. (0, _util.unreachable)("Should not call PrintAnnotationStorage.print");
  6098. }
  6099. get serializable() {
  6100. return this.#serializable;
  6101. }
  6102. }
  6103. exports.PrintAnnotationStorage = PrintAnnotationStorage;
  6104. /***/ }),
  6105. /* 137 */
  6106. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  6107. "use strict";
  6108. Object.defineProperty(exports, "__esModule", ({
  6109. value: true
  6110. }));
  6111. exports.AnnotationEditor = void 0;
  6112. var _tools = __w_pdfjs_require__(138);
  6113. var _util = __w_pdfjs_require__(1);
  6114. class AnnotationEditor {
  6115. #boundFocusin = this.focusin.bind(this);
  6116. #boundFocusout = this.focusout.bind(this);
  6117. #hasBeenSelected = false;
  6118. #isEditing = false;
  6119. #isInEditMode = false;
  6120. _uiManager = null;
  6121. #zIndex = AnnotationEditor._zIndex++;
  6122. static _colorManager = new _tools.ColorManager();
  6123. static _zIndex = 1;
  6124. constructor(parameters) {
  6125. if (this.constructor === AnnotationEditor) {
  6126. (0, _util.unreachable)("Cannot initialize AnnotationEditor.");
  6127. }
  6128. this.parent = parameters.parent;
  6129. this.id = parameters.id;
  6130. this.width = this.height = null;
  6131. this.pageIndex = parameters.parent.pageIndex;
  6132. this.name = parameters.name;
  6133. this.div = null;
  6134. this._uiManager = parameters.uiManager;
  6135. const {
  6136. rotation,
  6137. rawDims: {
  6138. pageWidth,
  6139. pageHeight,
  6140. pageX,
  6141. pageY
  6142. }
  6143. } = this.parent.viewport;
  6144. this.rotation = rotation;
  6145. this.pageDimensions = [pageWidth, pageHeight];
  6146. this.pageTranslation = [pageX, pageY];
  6147. const [width, height] = this.parentDimensions;
  6148. this.x = parameters.x / width;
  6149. this.y = parameters.y / height;
  6150. this.isAttachedToDOM = false;
  6151. }
  6152. static get _defaultLineColor() {
  6153. return (0, _util.shadow)(this, "_defaultLineColor", this._colorManager.getHexCode("CanvasText"));
  6154. }
  6155. addCommands(params) {
  6156. this._uiManager.addCommands(params);
  6157. }
  6158. get currentLayer() {
  6159. return this._uiManager.currentLayer;
  6160. }
  6161. setInBackground() {
  6162. this.div.style.zIndex = 0;
  6163. }
  6164. setInForeground() {
  6165. this.div.style.zIndex = this.#zIndex;
  6166. }
  6167. setParent(parent) {
  6168. if (parent !== null) {
  6169. this.pageIndex = parent.pageIndex;
  6170. this.pageDimensions = parent.pageDimensions;
  6171. }
  6172. this.parent = parent;
  6173. }
  6174. focusin(event) {
  6175. if (!this.#hasBeenSelected) {
  6176. this.parent.setSelected(this);
  6177. } else {
  6178. this.#hasBeenSelected = false;
  6179. }
  6180. }
  6181. focusout(event) {
  6182. var _this$parent;
  6183. if (!this.isAttachedToDOM) {
  6184. return;
  6185. }
  6186. const target = event.relatedTarget;
  6187. if (target !== null && target !== void 0 && target.closest(`#${this.id}`)) {
  6188. return;
  6189. }
  6190. event.preventDefault();
  6191. if (!((_this$parent = this.parent) !== null && _this$parent !== void 0 && _this$parent.isMultipleSelection)) {
  6192. this.commitOrRemove();
  6193. }
  6194. }
  6195. commitOrRemove() {
  6196. if (this.isEmpty()) {
  6197. this.remove();
  6198. } else {
  6199. this.commit();
  6200. }
  6201. }
  6202. commit() {
  6203. this.addToAnnotationStorage();
  6204. }
  6205. addToAnnotationStorage() {
  6206. this._uiManager.addToAnnotationStorage(this);
  6207. }
  6208. dragstart(event) {
  6209. const rect = this.parent.div.getBoundingClientRect();
  6210. this.startX = event.clientX - rect.x;
  6211. this.startY = event.clientY - rect.y;
  6212. event.dataTransfer.setData("text/plain", this.id);
  6213. event.dataTransfer.effectAllowed = "move";
  6214. }
  6215. setAt(x, y, tx, ty) {
  6216. const [width, height] = this.parentDimensions;
  6217. [tx, ty] = this.screenToPageTranslation(tx, ty);
  6218. this.x = (x + tx) / width;
  6219. this.y = (y + ty) / height;
  6220. this.div.style.left = `${100 * this.x}%`;
  6221. this.div.style.top = `${100 * this.y}%`;
  6222. }
  6223. translate(x, y) {
  6224. const [width, height] = this.parentDimensions;
  6225. [x, y] = this.screenToPageTranslation(x, y);
  6226. this.x += x / width;
  6227. this.y += y / height;
  6228. this.div.style.left = `${100 * this.x}%`;
  6229. this.div.style.top = `${100 * this.y}%`;
  6230. }
  6231. screenToPageTranslation(x, y) {
  6232. switch (this.parentRotation) {
  6233. case 90:
  6234. return [y, -x];
  6235. case 180:
  6236. return [-x, -y];
  6237. case 270:
  6238. return [-y, x];
  6239. default:
  6240. return [x, y];
  6241. }
  6242. }
  6243. get parentScale() {
  6244. return this._uiManager.viewParameters.realScale;
  6245. }
  6246. get parentRotation() {
  6247. return this._uiManager.viewParameters.rotation;
  6248. }
  6249. get parentDimensions() {
  6250. const {
  6251. realScale
  6252. } = this._uiManager.viewParameters;
  6253. const [pageWidth, pageHeight] = this.pageDimensions;
  6254. return [pageWidth * realScale, pageHeight * realScale];
  6255. }
  6256. setDims(width, height) {
  6257. const [parentWidth, parentHeight] = this.parentDimensions;
  6258. this.div.style.width = `${100 * width / parentWidth}%`;
  6259. this.div.style.height = `${100 * height / parentHeight}%`;
  6260. }
  6261. fixDims() {
  6262. const {
  6263. style
  6264. } = this.div;
  6265. const {
  6266. height,
  6267. width
  6268. } = style;
  6269. const widthPercent = width.endsWith("%");
  6270. const heightPercent = height.endsWith("%");
  6271. if (widthPercent && heightPercent) {
  6272. return;
  6273. }
  6274. const [parentWidth, parentHeight] = this.parentDimensions;
  6275. if (!widthPercent) {
  6276. style.width = `${100 * parseFloat(width) / parentWidth}%`;
  6277. }
  6278. if (!heightPercent) {
  6279. style.height = `${100 * parseFloat(height) / parentHeight}%`;
  6280. }
  6281. }
  6282. getInitialTranslation() {
  6283. return [0, 0];
  6284. }
  6285. render() {
  6286. this.div = document.createElement("div");
  6287. this.div.setAttribute("data-editor-rotation", (360 - this.rotation) % 360);
  6288. this.div.className = this.name;
  6289. this.div.setAttribute("id", this.id);
  6290. this.div.setAttribute("tabIndex", 0);
  6291. this.setInForeground();
  6292. this.div.addEventListener("focusin", this.#boundFocusin);
  6293. this.div.addEventListener("focusout", this.#boundFocusout);
  6294. const [tx, ty] = this.getInitialTranslation();
  6295. this.translate(tx, ty);
  6296. (0, _tools.bindEvents)(this, this.div, ["dragstart", "pointerdown"]);
  6297. return this.div;
  6298. }
  6299. pointerdown(event) {
  6300. const {
  6301. isMac
  6302. } = _util.FeatureTest.platform;
  6303. if (event.button !== 0 || event.ctrlKey && isMac) {
  6304. event.preventDefault();
  6305. return;
  6306. }
  6307. if (event.ctrlKey && !isMac || event.shiftKey || event.metaKey && isMac) {
  6308. this.parent.toggleSelected(this);
  6309. } else {
  6310. this.parent.setSelected(this);
  6311. }
  6312. this.#hasBeenSelected = true;
  6313. }
  6314. getRect(tx, ty) {
  6315. const scale = this.parentScale;
  6316. const [pageWidth, pageHeight] = this.pageDimensions;
  6317. const [pageX, pageY] = this.pageTranslation;
  6318. const shiftX = tx / scale;
  6319. const shiftY = ty / scale;
  6320. const x = this.x * pageWidth;
  6321. const y = this.y * pageHeight;
  6322. const width = this.width * pageWidth;
  6323. const height = this.height * pageHeight;
  6324. switch (this.rotation) {
  6325. case 0:
  6326. return [x + shiftX + pageX, pageHeight - y - shiftY - height + pageY, x + shiftX + width + pageX, pageHeight - y - shiftY + pageY];
  6327. case 90:
  6328. return [x + shiftY + pageX, pageHeight - y + shiftX + pageY, x + shiftY + height + pageX, pageHeight - y + shiftX + width + pageY];
  6329. case 180:
  6330. return [x - shiftX - width + pageX, pageHeight - y + shiftY + pageY, x - shiftX + pageX, pageHeight - y + shiftY + height + pageY];
  6331. case 270:
  6332. return [x - shiftY - height + pageX, pageHeight - y - shiftX - width + pageY, x - shiftY + pageX, pageHeight - y - shiftX + pageY];
  6333. default:
  6334. throw new Error("Invalid rotation");
  6335. }
  6336. }
  6337. getRectInCurrentCoords(rect, pageHeight) {
  6338. const [x1, y1, x2, y2] = rect;
  6339. const width = x2 - x1;
  6340. const height = y2 - y1;
  6341. switch (this.rotation) {
  6342. case 0:
  6343. return [x1, pageHeight - y2, width, height];
  6344. case 90:
  6345. return [x1, pageHeight - y1, height, width];
  6346. case 180:
  6347. return [x2, pageHeight - y1, width, height];
  6348. case 270:
  6349. return [x2, pageHeight - y2, height, width];
  6350. default:
  6351. throw new Error("Invalid rotation");
  6352. }
  6353. }
  6354. onceAdded() {}
  6355. isEmpty() {
  6356. return false;
  6357. }
  6358. enableEditMode() {
  6359. this.#isInEditMode = true;
  6360. }
  6361. disableEditMode() {
  6362. this.#isInEditMode = false;
  6363. }
  6364. isInEditMode() {
  6365. return this.#isInEditMode;
  6366. }
  6367. shouldGetKeyboardEvents() {
  6368. return false;
  6369. }
  6370. needsToBeRebuilt() {
  6371. return this.div && !this.isAttachedToDOM;
  6372. }
  6373. rebuild() {
  6374. var _this$div;
  6375. (_this$div = this.div) === null || _this$div === void 0 ? void 0 : _this$div.addEventListener("focusin", this.#boundFocusin);
  6376. }
  6377. serialize() {
  6378. (0, _util.unreachable)("An editor must be serializable");
  6379. }
  6380. static deserialize(data, parent, uiManager) {
  6381. const editor = new this.prototype.constructor({
  6382. parent,
  6383. id: parent.getNextId(),
  6384. uiManager
  6385. });
  6386. editor.rotation = data.rotation;
  6387. const [pageWidth, pageHeight] = editor.pageDimensions;
  6388. const [x, y, width, height] = editor.getRectInCurrentCoords(data.rect, pageHeight);
  6389. editor.x = x / pageWidth;
  6390. editor.y = y / pageHeight;
  6391. editor.width = width / pageWidth;
  6392. editor.height = height / pageHeight;
  6393. return editor;
  6394. }
  6395. remove() {
  6396. this.div.removeEventListener("focusin", this.#boundFocusin);
  6397. this.div.removeEventListener("focusout", this.#boundFocusout);
  6398. if (!this.isEmpty()) {
  6399. this.commit();
  6400. }
  6401. this.parent.remove(this);
  6402. }
  6403. select() {
  6404. var _this$div2;
  6405. (_this$div2 = this.div) === null || _this$div2 === void 0 ? void 0 : _this$div2.classList.add("selectedEditor");
  6406. }
  6407. unselect() {
  6408. var _this$div3;
  6409. (_this$div3 = this.div) === null || _this$div3 === void 0 ? void 0 : _this$div3.classList.remove("selectedEditor");
  6410. }
  6411. updateParams(type, value) {}
  6412. disableEditing() {}
  6413. enableEditing() {}
  6414. get propertiesToUpdate() {
  6415. return {};
  6416. }
  6417. get contentDiv() {
  6418. return this.div;
  6419. }
  6420. get isEditing() {
  6421. return this.#isEditing;
  6422. }
  6423. set isEditing(value) {
  6424. this.#isEditing = value;
  6425. if (value) {
  6426. this.parent.setSelected(this);
  6427. this.parent.setActiveEditor(this);
  6428. } else {
  6429. this.parent.setActiveEditor(null);
  6430. }
  6431. }
  6432. }
  6433. exports.AnnotationEditor = AnnotationEditor;
  6434. /***/ }),
  6435. /* 138 */
  6436. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  6437. "use strict";
  6438. Object.defineProperty(exports, "__esModule", ({
  6439. value: true
  6440. }));
  6441. exports.KeyboardManager = exports.CommandManager = exports.ColorManager = exports.AnnotationEditorUIManager = void 0;
  6442. exports.bindEvents = bindEvents;
  6443. exports.opacityToHex = opacityToHex;
  6444. var _util = __w_pdfjs_require__(1);
  6445. var _display_utils = __w_pdfjs_require__(139);
  6446. function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  6447. function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
  6448. function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
  6449. function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
  6450. function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
  6451. function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
  6452. function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
  6453. function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
  6454. function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }
  6455. function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
  6456. function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
  6457. function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
  6458. function bindEvents(obj, element, names) {
  6459. for (const name of names) {
  6460. element.addEventListener(name, obj[name].bind(obj));
  6461. }
  6462. }
  6463. function opacityToHex(opacity) {
  6464. return Math.round(Math.min(255, Math.max(1, 255 * opacity))).toString(16).padStart(2, "0");
  6465. }
  6466. class IdManager {
  6467. #id = 0;
  6468. getId() {
  6469. return `${_util.AnnotationEditorPrefix}${this.#id++}`;
  6470. }
  6471. }
  6472. class CommandManager {
  6473. #commands = [];
  6474. #locked = false;
  6475. #maxSize;
  6476. #position = -1;
  6477. constructor() {
  6478. let maxSize = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 128;
  6479. this.#maxSize = maxSize;
  6480. }
  6481. add(_ref) {
  6482. let {
  6483. cmd,
  6484. undo,
  6485. mustExec,
  6486. type = NaN,
  6487. overwriteIfSameType = false,
  6488. keepUndo = false
  6489. } = _ref;
  6490. if (mustExec) {
  6491. cmd();
  6492. }
  6493. if (this.#locked) {
  6494. return;
  6495. }
  6496. const save = {
  6497. cmd,
  6498. undo,
  6499. type
  6500. };
  6501. if (this.#position === -1) {
  6502. if (this.#commands.length > 0) {
  6503. this.#commands.length = 0;
  6504. }
  6505. this.#position = 0;
  6506. this.#commands.push(save);
  6507. return;
  6508. }
  6509. if (overwriteIfSameType && this.#commands[this.#position].type === type) {
  6510. if (keepUndo) {
  6511. save.undo = this.#commands[this.#position].undo;
  6512. }
  6513. this.#commands[this.#position] = save;
  6514. return;
  6515. }
  6516. const next = this.#position + 1;
  6517. if (next === this.#maxSize) {
  6518. this.#commands.splice(0, 1);
  6519. } else {
  6520. this.#position = next;
  6521. if (next < this.#commands.length) {
  6522. this.#commands.splice(next);
  6523. }
  6524. }
  6525. this.#commands.push(save);
  6526. }
  6527. undo() {
  6528. if (this.#position === -1) {
  6529. return;
  6530. }
  6531. this.#locked = true;
  6532. this.#commands[this.#position].undo();
  6533. this.#locked = false;
  6534. this.#position -= 1;
  6535. }
  6536. redo() {
  6537. if (this.#position < this.#commands.length - 1) {
  6538. this.#position += 1;
  6539. this.#locked = true;
  6540. this.#commands[this.#position].cmd();
  6541. this.#locked = false;
  6542. }
  6543. }
  6544. hasSomethingToUndo() {
  6545. return this.#position !== -1;
  6546. }
  6547. hasSomethingToRedo() {
  6548. return this.#position < this.#commands.length - 1;
  6549. }
  6550. destroy() {
  6551. this.#commands = null;
  6552. }
  6553. }
  6554. exports.CommandManager = CommandManager;
  6555. var _serialize = /*#__PURE__*/new WeakSet();
  6556. class KeyboardManager {
  6557. constructor(callbacks) {
  6558. _classPrivateMethodInitSpec(this, _serialize);
  6559. this.buffer = [];
  6560. this.callbacks = new Map();
  6561. this.allKeys = new Set();
  6562. const {
  6563. isMac
  6564. } = _util.FeatureTest.platform;
  6565. for (const [keys, callback] of callbacks) {
  6566. for (const key of keys) {
  6567. const isMacKey = key.startsWith("mac+");
  6568. if (isMac && isMacKey) {
  6569. this.callbacks.set(key.slice(4), callback);
  6570. this.allKeys.add(key.split("+").at(-1));
  6571. } else if (!isMac && !isMacKey) {
  6572. this.callbacks.set(key, callback);
  6573. this.allKeys.add(key.split("+").at(-1));
  6574. }
  6575. }
  6576. }
  6577. }
  6578. exec(self, event) {
  6579. if (!this.allKeys.has(event.key)) {
  6580. return;
  6581. }
  6582. const callback = this.callbacks.get(_classPrivateMethodGet(this, _serialize, _serialize2).call(this, event));
  6583. if (!callback) {
  6584. return;
  6585. }
  6586. callback.bind(self)();
  6587. event.stopPropagation();
  6588. event.preventDefault();
  6589. }
  6590. }
  6591. exports.KeyboardManager = KeyboardManager;
  6592. function _serialize2(event) {
  6593. if (event.altKey) {
  6594. this.buffer.push("alt");
  6595. }
  6596. if (event.ctrlKey) {
  6597. this.buffer.push("ctrl");
  6598. }
  6599. if (event.metaKey) {
  6600. this.buffer.push("meta");
  6601. }
  6602. if (event.shiftKey) {
  6603. this.buffer.push("shift");
  6604. }
  6605. this.buffer.push(event.key);
  6606. const str = this.buffer.join("+");
  6607. this.buffer.length = 0;
  6608. return str;
  6609. }
  6610. class ColorManager {
  6611. static _colorsMapping = new Map([["CanvasText", [0, 0, 0]], ["Canvas", [255, 255, 255]]]);
  6612. get _colors() {
  6613. const colors = new Map([["CanvasText", null], ["Canvas", null]]);
  6614. (0, _display_utils.getColorValues)(colors);
  6615. return (0, _util.shadow)(this, "_colors", colors);
  6616. }
  6617. convert(color) {
  6618. const rgb = (0, _display_utils.getRGB)(color);
  6619. if (!window.matchMedia("(forced-colors: active)").matches) {
  6620. return rgb;
  6621. }
  6622. for (const [name, RGB] of this._colors) {
  6623. if (RGB.every((x, i) => x === rgb[i])) {
  6624. return ColorManager._colorsMapping.get(name);
  6625. }
  6626. }
  6627. return rgb;
  6628. }
  6629. getHexCode(name) {
  6630. const rgb = this._colors.get(name);
  6631. if (!rgb) {
  6632. return name;
  6633. }
  6634. return _util.Util.makeHexColor(...rgb);
  6635. }
  6636. }
  6637. exports.ColorManager = ColorManager;
  6638. var _activeEditor = /*#__PURE__*/new WeakMap();
  6639. var _allEditors = /*#__PURE__*/new WeakMap();
  6640. var _allLayers = /*#__PURE__*/new WeakMap();
  6641. var _annotationStorage = /*#__PURE__*/new WeakMap();
  6642. var _commandManager = /*#__PURE__*/new WeakMap();
  6643. var _currentPageIndex = /*#__PURE__*/new WeakMap();
  6644. var _editorTypes = /*#__PURE__*/new WeakMap();
  6645. var _editorsToRescale = /*#__PURE__*/new WeakMap();
  6646. var _eventBus = /*#__PURE__*/new WeakMap();
  6647. var _idManager = /*#__PURE__*/new WeakMap();
  6648. var _isEnabled = /*#__PURE__*/new WeakMap();
  6649. var _mode = /*#__PURE__*/new WeakMap();
  6650. var _selectedEditors = /*#__PURE__*/new WeakMap();
  6651. var _boundCopy = /*#__PURE__*/new WeakMap();
  6652. var _boundCut = /*#__PURE__*/new WeakMap();
  6653. var _boundPaste = /*#__PURE__*/new WeakMap();
  6654. var _boundKeydown = /*#__PURE__*/new WeakMap();
  6655. var _boundOnEditingAction = /*#__PURE__*/new WeakMap();
  6656. var _boundOnPageChanging = /*#__PURE__*/new WeakMap();
  6657. var _boundOnScaleChanging = /*#__PURE__*/new WeakMap();
  6658. var _boundOnRotationChanging = /*#__PURE__*/new WeakMap();
  6659. var _previousStates = /*#__PURE__*/new WeakMap();
  6660. var _container = /*#__PURE__*/new WeakMap();
  6661. var _addKeyboardManager = /*#__PURE__*/new WeakSet();
  6662. var _removeKeyboardManager = /*#__PURE__*/new WeakSet();
  6663. var _addCopyPasteListeners = /*#__PURE__*/new WeakSet();
  6664. var _removeCopyPasteListeners = /*#__PURE__*/new WeakSet();
  6665. var _dispatchUpdateStates = /*#__PURE__*/new WeakSet();
  6666. var _dispatchUpdateUI = /*#__PURE__*/new WeakSet();
  6667. var _enableAll = /*#__PURE__*/new WeakSet();
  6668. var _disableAll = /*#__PURE__*/new WeakSet();
  6669. var _addEditorToLayer = /*#__PURE__*/new WeakSet();
  6670. var _isEmpty = /*#__PURE__*/new WeakSet();
  6671. var _selectEditors = /*#__PURE__*/new WeakSet();
  6672. class AnnotationEditorUIManager {
  6673. constructor(container, eventBus, annotationStorage) {
  6674. _classPrivateMethodInitSpec(this, _selectEditors);
  6675. _classPrivateMethodInitSpec(this, _isEmpty);
  6676. _classPrivateMethodInitSpec(this, _addEditorToLayer);
  6677. _classPrivateMethodInitSpec(this, _disableAll);
  6678. _classPrivateMethodInitSpec(this, _enableAll);
  6679. _classPrivateMethodInitSpec(this, _dispatchUpdateUI);
  6680. _classPrivateMethodInitSpec(this, _dispatchUpdateStates);
  6681. _classPrivateMethodInitSpec(this, _removeCopyPasteListeners);
  6682. _classPrivateMethodInitSpec(this, _addCopyPasteListeners);
  6683. _classPrivateMethodInitSpec(this, _removeKeyboardManager);
  6684. _classPrivateMethodInitSpec(this, _addKeyboardManager);
  6685. _classPrivateFieldInitSpec(this, _activeEditor, {
  6686. writable: true,
  6687. value: null
  6688. });
  6689. _classPrivateFieldInitSpec(this, _allEditors, {
  6690. writable: true,
  6691. value: new Map()
  6692. });
  6693. _classPrivateFieldInitSpec(this, _allLayers, {
  6694. writable: true,
  6695. value: new Map()
  6696. });
  6697. _classPrivateFieldInitSpec(this, _annotationStorage, {
  6698. writable: true,
  6699. value: null
  6700. });
  6701. _classPrivateFieldInitSpec(this, _commandManager, {
  6702. writable: true,
  6703. value: new CommandManager()
  6704. });
  6705. _classPrivateFieldInitSpec(this, _currentPageIndex, {
  6706. writable: true,
  6707. value: 0
  6708. });
  6709. _classPrivateFieldInitSpec(this, _editorTypes, {
  6710. writable: true,
  6711. value: null
  6712. });
  6713. _classPrivateFieldInitSpec(this, _editorsToRescale, {
  6714. writable: true,
  6715. value: new Set()
  6716. });
  6717. _classPrivateFieldInitSpec(this, _eventBus, {
  6718. writable: true,
  6719. value: null
  6720. });
  6721. _classPrivateFieldInitSpec(this, _idManager, {
  6722. writable: true,
  6723. value: new IdManager()
  6724. });
  6725. _classPrivateFieldInitSpec(this, _isEnabled, {
  6726. writable: true,
  6727. value: false
  6728. });
  6729. _classPrivateFieldInitSpec(this, _mode, {
  6730. writable: true,
  6731. value: _util.AnnotationEditorType.NONE
  6732. });
  6733. _classPrivateFieldInitSpec(this, _selectedEditors, {
  6734. writable: true,
  6735. value: new Set()
  6736. });
  6737. _classPrivateFieldInitSpec(this, _boundCopy, {
  6738. writable: true,
  6739. value: this.copy.bind(this)
  6740. });
  6741. _classPrivateFieldInitSpec(this, _boundCut, {
  6742. writable: true,
  6743. value: this.cut.bind(this)
  6744. });
  6745. _classPrivateFieldInitSpec(this, _boundPaste, {
  6746. writable: true,
  6747. value: this.paste.bind(this)
  6748. });
  6749. _classPrivateFieldInitSpec(this, _boundKeydown, {
  6750. writable: true,
  6751. value: this.keydown.bind(this)
  6752. });
  6753. _classPrivateFieldInitSpec(this, _boundOnEditingAction, {
  6754. writable: true,
  6755. value: this.onEditingAction.bind(this)
  6756. });
  6757. _classPrivateFieldInitSpec(this, _boundOnPageChanging, {
  6758. writable: true,
  6759. value: this.onPageChanging.bind(this)
  6760. });
  6761. _classPrivateFieldInitSpec(this, _boundOnScaleChanging, {
  6762. writable: true,
  6763. value: this.onScaleChanging.bind(this)
  6764. });
  6765. _classPrivateFieldInitSpec(this, _boundOnRotationChanging, {
  6766. writable: true,
  6767. value: this.onRotationChanging.bind(this)
  6768. });
  6769. _classPrivateFieldInitSpec(this, _previousStates, {
  6770. writable: true,
  6771. value: {
  6772. isEditing: false,
  6773. isEmpty: true,
  6774. hasSomethingToUndo: false,
  6775. hasSomethingToRedo: false,
  6776. hasSelectedEditor: false
  6777. }
  6778. });
  6779. _classPrivateFieldInitSpec(this, _container, {
  6780. writable: true,
  6781. value: null
  6782. });
  6783. _classPrivateFieldSet(this, _container, container);
  6784. _classPrivateFieldSet(this, _eventBus, eventBus);
  6785. _classPrivateFieldGet(this, _eventBus)._on("editingaction", _classPrivateFieldGet(this, _boundOnEditingAction));
  6786. _classPrivateFieldGet(this, _eventBus)._on("pagechanging", _classPrivateFieldGet(this, _boundOnPageChanging));
  6787. _classPrivateFieldGet(this, _eventBus)._on("scalechanging", _classPrivateFieldGet(this, _boundOnScaleChanging));
  6788. _classPrivateFieldGet(this, _eventBus)._on("rotationchanging", _classPrivateFieldGet(this, _boundOnRotationChanging));
  6789. _classPrivateFieldSet(this, _annotationStorage, annotationStorage);
  6790. this.viewParameters = {
  6791. realScale: _display_utils.PixelsPerInch.PDF_TO_CSS_UNITS,
  6792. rotation: 0
  6793. };
  6794. }
  6795. destroy() {
  6796. _classPrivateMethodGet(this, _removeKeyboardManager, _removeKeyboardManager2).call(this);
  6797. _classPrivateFieldGet(this, _eventBus)._off("editingaction", _classPrivateFieldGet(this, _boundOnEditingAction));
  6798. _classPrivateFieldGet(this, _eventBus)._off("pagechanging", _classPrivateFieldGet(this, _boundOnPageChanging));
  6799. _classPrivateFieldGet(this, _eventBus)._off("scalechanging", _classPrivateFieldGet(this, _boundOnScaleChanging));
  6800. _classPrivateFieldGet(this, _eventBus)._off("rotationchanging", _classPrivateFieldGet(this, _boundOnRotationChanging));
  6801. for (const layer of _classPrivateFieldGet(this, _allLayers).values()) {
  6802. layer.destroy();
  6803. }
  6804. _classPrivateFieldGet(this, _allLayers).clear();
  6805. _classPrivateFieldGet(this, _allEditors).clear();
  6806. _classPrivateFieldGet(this, _editorsToRescale).clear();
  6807. _classPrivateFieldSet(this, _activeEditor, null);
  6808. _classPrivateFieldGet(this, _selectedEditors).clear();
  6809. _classPrivateFieldGet(this, _commandManager).destroy();
  6810. }
  6811. onPageChanging(_ref2) {
  6812. let {
  6813. pageNumber
  6814. } = _ref2;
  6815. _classPrivateFieldSet(this, _currentPageIndex, pageNumber - 1);
  6816. }
  6817. focusMainContainer() {
  6818. _classPrivateFieldGet(this, _container).focus();
  6819. }
  6820. addShouldRescale(editor) {
  6821. _classPrivateFieldGet(this, _editorsToRescale).add(editor);
  6822. }
  6823. removeShouldRescale(editor) {
  6824. _classPrivateFieldGet(this, _editorsToRescale).delete(editor);
  6825. }
  6826. onScaleChanging(_ref3) {
  6827. let {
  6828. scale
  6829. } = _ref3;
  6830. this.commitOrRemove();
  6831. this.viewParameters.realScale = scale * _display_utils.PixelsPerInch.PDF_TO_CSS_UNITS;
  6832. for (const editor of _classPrivateFieldGet(this, _editorsToRescale)) {
  6833. editor.onScaleChanging();
  6834. }
  6835. }
  6836. onRotationChanging(_ref4) {
  6837. let {
  6838. pagesRotation
  6839. } = _ref4;
  6840. this.commitOrRemove();
  6841. this.viewParameters.rotation = pagesRotation;
  6842. }
  6843. addToAnnotationStorage(editor) {
  6844. if (!editor.isEmpty() && _classPrivateFieldGet(this, _annotationStorage) && !_classPrivateFieldGet(this, _annotationStorage).has(editor.id)) {
  6845. _classPrivateFieldGet(this, _annotationStorage).setValue(editor.id, editor);
  6846. }
  6847. }
  6848. copy(event) {
  6849. event.preventDefault();
  6850. if (_classPrivateFieldGet(this, _activeEditor)) {
  6851. _classPrivateFieldGet(this, _activeEditor).commitOrRemove();
  6852. }
  6853. if (!this.hasSelection) {
  6854. return;
  6855. }
  6856. const editors = [];
  6857. for (const editor of _classPrivateFieldGet(this, _selectedEditors)) {
  6858. if (!editor.isEmpty()) {
  6859. editors.push(editor.serialize());
  6860. }
  6861. }
  6862. if (editors.length === 0) {
  6863. return;
  6864. }
  6865. event.clipboardData.setData("application/pdfjs", JSON.stringify(editors));
  6866. }
  6867. cut(event) {
  6868. this.copy(event);
  6869. this.delete();
  6870. }
  6871. paste(event) {
  6872. event.preventDefault();
  6873. let data = event.clipboardData.getData("application/pdfjs");
  6874. if (!data) {
  6875. return;
  6876. }
  6877. try {
  6878. data = JSON.parse(data);
  6879. } catch (ex) {
  6880. (0, _util.warn)(`paste: "${ex.message}".`);
  6881. return;
  6882. }
  6883. if (!Array.isArray(data)) {
  6884. return;
  6885. }
  6886. this.unselectAll();
  6887. const layer = _classPrivateFieldGet(this, _allLayers).get(_classPrivateFieldGet(this, _currentPageIndex));
  6888. try {
  6889. const newEditors = [];
  6890. for (const editor of data) {
  6891. const deserializedEditor = layer.deserialize(editor);
  6892. if (!deserializedEditor) {
  6893. return;
  6894. }
  6895. newEditors.push(deserializedEditor);
  6896. }
  6897. const cmd = () => {
  6898. for (const editor of newEditors) {
  6899. _classPrivateMethodGet(this, _addEditorToLayer, _addEditorToLayer2).call(this, editor);
  6900. }
  6901. _classPrivateMethodGet(this, _selectEditors, _selectEditors2).call(this, newEditors);
  6902. };
  6903. const undo = () => {
  6904. for (const editor of newEditors) {
  6905. editor.remove();
  6906. }
  6907. };
  6908. this.addCommands({
  6909. cmd,
  6910. undo,
  6911. mustExec: true
  6912. });
  6913. } catch (ex) {
  6914. (0, _util.warn)(`paste: "${ex.message}".`);
  6915. }
  6916. }
  6917. keydown(event) {
  6918. var _this$getActive;
  6919. if (!((_this$getActive = this.getActive()) !== null && _this$getActive !== void 0 && _this$getActive.shouldGetKeyboardEvents())) {
  6920. AnnotationEditorUIManager._keyboardManager.exec(this, event);
  6921. }
  6922. }
  6923. onEditingAction(details) {
  6924. if (["undo", "redo", "delete", "selectAll"].includes(details.name)) {
  6925. this[details.name]();
  6926. }
  6927. }
  6928. setEditingState(isEditing) {
  6929. if (isEditing) {
  6930. _classPrivateMethodGet(this, _addKeyboardManager, _addKeyboardManager2).call(this);
  6931. _classPrivateMethodGet(this, _addCopyPasteListeners, _addCopyPasteListeners2).call(this);
  6932. _classPrivateMethodGet(this, _dispatchUpdateStates, _dispatchUpdateStates2).call(this, {
  6933. isEditing: _classPrivateFieldGet(this, _mode) !== _util.AnnotationEditorType.NONE,
  6934. isEmpty: _classPrivateMethodGet(this, _isEmpty, _isEmpty2).call(this),
  6935. hasSomethingToUndo: _classPrivateFieldGet(this, _commandManager).hasSomethingToUndo(),
  6936. hasSomethingToRedo: _classPrivateFieldGet(this, _commandManager).hasSomethingToRedo(),
  6937. hasSelectedEditor: false
  6938. });
  6939. } else {
  6940. _classPrivateMethodGet(this, _removeKeyboardManager, _removeKeyboardManager2).call(this);
  6941. _classPrivateMethodGet(this, _removeCopyPasteListeners, _removeCopyPasteListeners2).call(this);
  6942. _classPrivateMethodGet(this, _dispatchUpdateStates, _dispatchUpdateStates2).call(this, {
  6943. isEditing: false
  6944. });
  6945. }
  6946. }
  6947. registerEditorTypes(types) {
  6948. if (_classPrivateFieldGet(this, _editorTypes)) {
  6949. return;
  6950. }
  6951. _classPrivateFieldSet(this, _editorTypes, types);
  6952. for (const editorType of _classPrivateFieldGet(this, _editorTypes)) {
  6953. _classPrivateMethodGet(this, _dispatchUpdateUI, _dispatchUpdateUI2).call(this, editorType.defaultPropertiesToUpdate);
  6954. }
  6955. }
  6956. getId() {
  6957. return _classPrivateFieldGet(this, _idManager).getId();
  6958. }
  6959. get currentLayer() {
  6960. return _classPrivateFieldGet(this, _allLayers).get(_classPrivateFieldGet(this, _currentPageIndex));
  6961. }
  6962. get currentPageIndex() {
  6963. return _classPrivateFieldGet(this, _currentPageIndex);
  6964. }
  6965. addLayer(layer) {
  6966. _classPrivateFieldGet(this, _allLayers).set(layer.pageIndex, layer);
  6967. if (_classPrivateFieldGet(this, _isEnabled)) {
  6968. layer.enable();
  6969. } else {
  6970. layer.disable();
  6971. }
  6972. }
  6973. removeLayer(layer) {
  6974. _classPrivateFieldGet(this, _allLayers).delete(layer.pageIndex);
  6975. }
  6976. updateMode(mode) {
  6977. _classPrivateFieldSet(this, _mode, mode);
  6978. if (mode === _util.AnnotationEditorType.NONE) {
  6979. this.setEditingState(false);
  6980. _classPrivateMethodGet(this, _disableAll, _disableAll2).call(this);
  6981. } else {
  6982. this.setEditingState(true);
  6983. _classPrivateMethodGet(this, _enableAll, _enableAll2).call(this);
  6984. for (const layer of _classPrivateFieldGet(this, _allLayers).values()) {
  6985. layer.updateMode(mode);
  6986. }
  6987. }
  6988. }
  6989. updateToolbar(mode) {
  6990. if (mode === _classPrivateFieldGet(this, _mode)) {
  6991. return;
  6992. }
  6993. _classPrivateFieldGet(this, _eventBus).dispatch("switchannotationeditormode", {
  6994. source: this,
  6995. mode
  6996. });
  6997. }
  6998. updateParams(type, value) {
  6999. if (!_classPrivateFieldGet(this, _editorTypes)) {
  7000. return;
  7001. }
  7002. for (const editor of _classPrivateFieldGet(this, _selectedEditors)) {
  7003. editor.updateParams(type, value);
  7004. }
  7005. for (const editorType of _classPrivateFieldGet(this, _editorTypes)) {
  7006. editorType.updateDefaultParams(type, value);
  7007. }
  7008. }
  7009. getEditors(pageIndex) {
  7010. const editors = [];
  7011. for (const editor of _classPrivateFieldGet(this, _allEditors).values()) {
  7012. if (editor.pageIndex === pageIndex) {
  7013. editors.push(editor);
  7014. }
  7015. }
  7016. return editors;
  7017. }
  7018. getEditor(id) {
  7019. return _classPrivateFieldGet(this, _allEditors).get(id);
  7020. }
  7021. addEditor(editor) {
  7022. _classPrivateFieldGet(this, _allEditors).set(editor.id, editor);
  7023. }
  7024. removeEditor(editor) {
  7025. var _classPrivateFieldGet2;
  7026. _classPrivateFieldGet(this, _allEditors).delete(editor.id);
  7027. this.unselect(editor);
  7028. (_classPrivateFieldGet2 = _classPrivateFieldGet(this, _annotationStorage)) === null || _classPrivateFieldGet2 === void 0 ? void 0 : _classPrivateFieldGet2.remove(editor.id);
  7029. }
  7030. setActiveEditor(editor) {
  7031. if (_classPrivateFieldGet(this, _activeEditor) === editor) {
  7032. return;
  7033. }
  7034. _classPrivateFieldSet(this, _activeEditor, editor);
  7035. if (editor) {
  7036. _classPrivateMethodGet(this, _dispatchUpdateUI, _dispatchUpdateUI2).call(this, editor.propertiesToUpdate);
  7037. }
  7038. }
  7039. toggleSelected(editor) {
  7040. if (_classPrivateFieldGet(this, _selectedEditors).has(editor)) {
  7041. _classPrivateFieldGet(this, _selectedEditors).delete(editor);
  7042. editor.unselect();
  7043. _classPrivateMethodGet(this, _dispatchUpdateStates, _dispatchUpdateStates2).call(this, {
  7044. hasSelectedEditor: this.hasSelection
  7045. });
  7046. return;
  7047. }
  7048. _classPrivateFieldGet(this, _selectedEditors).add(editor);
  7049. editor.select();
  7050. _classPrivateMethodGet(this, _dispatchUpdateUI, _dispatchUpdateUI2).call(this, editor.propertiesToUpdate);
  7051. _classPrivateMethodGet(this, _dispatchUpdateStates, _dispatchUpdateStates2).call(this, {
  7052. hasSelectedEditor: true
  7053. });
  7054. }
  7055. setSelected(editor) {
  7056. for (const ed of _classPrivateFieldGet(this, _selectedEditors)) {
  7057. if (ed !== editor) {
  7058. ed.unselect();
  7059. }
  7060. }
  7061. _classPrivateFieldGet(this, _selectedEditors).clear();
  7062. _classPrivateFieldGet(this, _selectedEditors).add(editor);
  7063. editor.select();
  7064. _classPrivateMethodGet(this, _dispatchUpdateUI, _dispatchUpdateUI2).call(this, editor.propertiesToUpdate);
  7065. _classPrivateMethodGet(this, _dispatchUpdateStates, _dispatchUpdateStates2).call(this, {
  7066. hasSelectedEditor: true
  7067. });
  7068. }
  7069. isSelected(editor) {
  7070. return _classPrivateFieldGet(this, _selectedEditors).has(editor);
  7071. }
  7072. unselect(editor) {
  7073. editor.unselect();
  7074. _classPrivateFieldGet(this, _selectedEditors).delete(editor);
  7075. _classPrivateMethodGet(this, _dispatchUpdateStates, _dispatchUpdateStates2).call(this, {
  7076. hasSelectedEditor: this.hasSelection
  7077. });
  7078. }
  7079. get hasSelection() {
  7080. return _classPrivateFieldGet(this, _selectedEditors).size !== 0;
  7081. }
  7082. undo() {
  7083. _classPrivateFieldGet(this, _commandManager).undo();
  7084. _classPrivateMethodGet(this, _dispatchUpdateStates, _dispatchUpdateStates2).call(this, {
  7085. hasSomethingToUndo: _classPrivateFieldGet(this, _commandManager).hasSomethingToUndo(),
  7086. hasSomethingToRedo: true,
  7087. isEmpty: _classPrivateMethodGet(this, _isEmpty, _isEmpty2).call(this)
  7088. });
  7089. }
  7090. redo() {
  7091. _classPrivateFieldGet(this, _commandManager).redo();
  7092. _classPrivateMethodGet(this, _dispatchUpdateStates, _dispatchUpdateStates2).call(this, {
  7093. hasSomethingToUndo: true,
  7094. hasSomethingToRedo: _classPrivateFieldGet(this, _commandManager).hasSomethingToRedo(),
  7095. isEmpty: _classPrivateMethodGet(this, _isEmpty, _isEmpty2).call(this)
  7096. });
  7097. }
  7098. addCommands(params) {
  7099. _classPrivateFieldGet(this, _commandManager).add(params);
  7100. _classPrivateMethodGet(this, _dispatchUpdateStates, _dispatchUpdateStates2).call(this, {
  7101. hasSomethingToUndo: true,
  7102. hasSomethingToRedo: false,
  7103. isEmpty: _classPrivateMethodGet(this, _isEmpty, _isEmpty2).call(this)
  7104. });
  7105. }
  7106. delete() {
  7107. this.commitOrRemove();
  7108. if (!this.hasSelection) {
  7109. return;
  7110. }
  7111. const editors = [..._classPrivateFieldGet(this, _selectedEditors)];
  7112. const cmd = () => {
  7113. for (const editor of editors) {
  7114. editor.remove();
  7115. }
  7116. };
  7117. const undo = () => {
  7118. for (const editor of editors) {
  7119. _classPrivateMethodGet(this, _addEditorToLayer, _addEditorToLayer2).call(this, editor);
  7120. }
  7121. };
  7122. this.addCommands({
  7123. cmd,
  7124. undo,
  7125. mustExec: true
  7126. });
  7127. }
  7128. commitOrRemove() {
  7129. var _classPrivateFieldGet3;
  7130. (_classPrivateFieldGet3 = _classPrivateFieldGet(this, _activeEditor)) === null || _classPrivateFieldGet3 === void 0 ? void 0 : _classPrivateFieldGet3.commitOrRemove();
  7131. }
  7132. selectAll() {
  7133. for (const editor of _classPrivateFieldGet(this, _selectedEditors)) {
  7134. editor.commit();
  7135. }
  7136. _classPrivateMethodGet(this, _selectEditors, _selectEditors2).call(this, _classPrivateFieldGet(this, _allEditors).values());
  7137. }
  7138. unselectAll() {
  7139. if (_classPrivateFieldGet(this, _activeEditor)) {
  7140. _classPrivateFieldGet(this, _activeEditor).commitOrRemove();
  7141. return;
  7142. }
  7143. if (_classPrivateFieldGet(this, _selectedEditors).size === 0) {
  7144. return;
  7145. }
  7146. for (const editor of _classPrivateFieldGet(this, _selectedEditors)) {
  7147. editor.unselect();
  7148. }
  7149. _classPrivateFieldGet(this, _selectedEditors).clear();
  7150. _classPrivateMethodGet(this, _dispatchUpdateStates, _dispatchUpdateStates2).call(this, {
  7151. hasSelectedEditor: false
  7152. });
  7153. }
  7154. isActive(editor) {
  7155. return _classPrivateFieldGet(this, _activeEditor) === editor;
  7156. }
  7157. getActive() {
  7158. return _classPrivateFieldGet(this, _activeEditor);
  7159. }
  7160. getMode() {
  7161. return _classPrivateFieldGet(this, _mode);
  7162. }
  7163. }
  7164. exports.AnnotationEditorUIManager = AnnotationEditorUIManager;
  7165. function _addKeyboardManager2() {
  7166. _classPrivateFieldGet(this, _container).addEventListener("keydown", _classPrivateFieldGet(this, _boundKeydown));
  7167. }
  7168. function _removeKeyboardManager2() {
  7169. _classPrivateFieldGet(this, _container).removeEventListener("keydown", _classPrivateFieldGet(this, _boundKeydown));
  7170. }
  7171. function _addCopyPasteListeners2() {
  7172. document.addEventListener("copy", _classPrivateFieldGet(this, _boundCopy));
  7173. document.addEventListener("cut", _classPrivateFieldGet(this, _boundCut));
  7174. document.addEventListener("paste", _classPrivateFieldGet(this, _boundPaste));
  7175. }
  7176. function _removeCopyPasteListeners2() {
  7177. document.removeEventListener("copy", _classPrivateFieldGet(this, _boundCopy));
  7178. document.removeEventListener("cut", _classPrivateFieldGet(this, _boundCut));
  7179. document.removeEventListener("paste", _classPrivateFieldGet(this, _boundPaste));
  7180. }
  7181. function _dispatchUpdateStates2(details) {
  7182. const hasChanged = Object.entries(details).some(_ref5 => {
  7183. let [key, value] = _ref5;
  7184. return _classPrivateFieldGet(this, _previousStates)[key] !== value;
  7185. });
  7186. if (hasChanged) {
  7187. _classPrivateFieldGet(this, _eventBus).dispatch("annotationeditorstateschanged", {
  7188. source: this,
  7189. details: Object.assign(_classPrivateFieldGet(this, _previousStates), details)
  7190. });
  7191. }
  7192. }
  7193. function _dispatchUpdateUI2(details) {
  7194. _classPrivateFieldGet(this, _eventBus).dispatch("annotationeditorparamschanged", {
  7195. source: this,
  7196. details
  7197. });
  7198. }
  7199. function _enableAll2() {
  7200. if (!_classPrivateFieldGet(this, _isEnabled)) {
  7201. _classPrivateFieldSet(this, _isEnabled, true);
  7202. for (const layer of _classPrivateFieldGet(this, _allLayers).values()) {
  7203. layer.enable();
  7204. }
  7205. }
  7206. }
  7207. function _disableAll2() {
  7208. this.unselectAll();
  7209. if (_classPrivateFieldGet(this, _isEnabled)) {
  7210. _classPrivateFieldSet(this, _isEnabled, false);
  7211. for (const layer of _classPrivateFieldGet(this, _allLayers).values()) {
  7212. layer.disable();
  7213. }
  7214. }
  7215. }
  7216. function _addEditorToLayer2(editor) {
  7217. const layer = _classPrivateFieldGet(this, _allLayers).get(editor.pageIndex);
  7218. if (layer) {
  7219. layer.addOrRebuild(editor);
  7220. } else {
  7221. this.addEditor(editor);
  7222. }
  7223. }
  7224. function _isEmpty2() {
  7225. if (_classPrivateFieldGet(this, _allEditors).size === 0) {
  7226. return true;
  7227. }
  7228. if (_classPrivateFieldGet(this, _allEditors).size === 1) {
  7229. for (const editor of _classPrivateFieldGet(this, _allEditors).values()) {
  7230. return editor.isEmpty();
  7231. }
  7232. }
  7233. return false;
  7234. }
  7235. function _selectEditors2(editors) {
  7236. _classPrivateFieldGet(this, _selectedEditors).clear();
  7237. for (const editor of editors) {
  7238. if (editor.isEmpty()) {
  7239. continue;
  7240. }
  7241. _classPrivateFieldGet(this, _selectedEditors).add(editor);
  7242. editor.select();
  7243. }
  7244. _classPrivateMethodGet(this, _dispatchUpdateStates, _dispatchUpdateStates2).call(this, {
  7245. hasSelectedEditor: true
  7246. });
  7247. }
  7248. _defineProperty(AnnotationEditorUIManager, "_keyboardManager", new KeyboardManager([[["ctrl+a", "mac+meta+a"], AnnotationEditorUIManager.prototype.selectAll], [["ctrl+z", "mac+meta+z"], AnnotationEditorUIManager.prototype.undo], [["ctrl+y", "ctrl+shift+Z", "mac+meta+shift+Z"], AnnotationEditorUIManager.prototype.redo], [["Backspace", "alt+Backspace", "ctrl+Backspace", "shift+Backspace", "mac+Backspace", "mac+alt+Backspace", "mac+ctrl+Backspace", "Delete", "ctrl+Delete", "shift+Delete"], AnnotationEditorUIManager.prototype.delete], [["Escape", "mac+Escape"], AnnotationEditorUIManager.prototype.unselectAll]]));
  7249. /***/ }),
  7250. /* 139 */
  7251. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  7252. "use strict";
  7253. Object.defineProperty(exports, "__esModule", ({
  7254. value: true
  7255. }));
  7256. exports.StatTimer = exports.RenderingCancelledException = exports.PixelsPerInch = exports.PageViewport = exports.PDFDateString = exports.DOMStandardFontDataFactory = exports.DOMSVGFactory = exports.DOMCanvasFactory = exports.DOMCMapReaderFactory = exports.AnnotationPrefix = void 0;
  7257. exports.deprecated = deprecated;
  7258. exports.getColorValues = getColorValues;
  7259. exports.getCurrentTransform = getCurrentTransform;
  7260. exports.getCurrentTransformInverse = getCurrentTransformInverse;
  7261. exports.getFilenameFromUrl = getFilenameFromUrl;
  7262. exports.getPdfFilenameFromUrl = getPdfFilenameFromUrl;
  7263. exports.getRGB = getRGB;
  7264. exports.getXfaPageViewport = getXfaPageViewport;
  7265. exports.isDataScheme = isDataScheme;
  7266. exports.isPdfFile = isPdfFile;
  7267. exports.isValidFetchUrl = isValidFetchUrl;
  7268. exports.loadScript = loadScript;
  7269. exports.setLayerDimensions = setLayerDimensions;
  7270. var _base_factory = __w_pdfjs_require__(140);
  7271. var _util = __w_pdfjs_require__(1);
  7272. const SVG_NS = "http://www.w3.org/2000/svg";
  7273. const AnnotationPrefix = "pdfjs_internal_id_";
  7274. exports.AnnotationPrefix = AnnotationPrefix;
  7275. class PixelsPerInch {
  7276. static CSS = 96.0;
  7277. static PDF = 72.0;
  7278. static PDF_TO_CSS_UNITS = this.CSS / this.PDF;
  7279. }
  7280. exports.PixelsPerInch = PixelsPerInch;
  7281. class DOMCanvasFactory extends _base_factory.BaseCanvasFactory {
  7282. constructor() {
  7283. let {
  7284. ownerDocument = globalThis.document
  7285. } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  7286. super();
  7287. this._document = ownerDocument;
  7288. }
  7289. _createCanvas(width, height) {
  7290. const canvas = this._document.createElement("canvas");
  7291. canvas.width = width;
  7292. canvas.height = height;
  7293. return canvas;
  7294. }
  7295. }
  7296. exports.DOMCanvasFactory = DOMCanvasFactory;
  7297. async function fetchData(url) {
  7298. let asTypedArray = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  7299. if (isValidFetchUrl(url, document.baseURI)) {
  7300. const response = await fetch(url);
  7301. if (!response.ok) {
  7302. throw new Error(response.statusText);
  7303. }
  7304. return asTypedArray ? new Uint8Array(await response.arrayBuffer()) : (0, _util.stringToBytes)(await response.text());
  7305. }
  7306. return new Promise((resolve, reject) => {
  7307. const request = new XMLHttpRequest();
  7308. request.open("GET", url, true);
  7309. if (asTypedArray) {
  7310. request.responseType = "arraybuffer";
  7311. }
  7312. request.onreadystatechange = () => {
  7313. if (request.readyState !== XMLHttpRequest.DONE) {
  7314. return;
  7315. }
  7316. if (request.status === 200 || request.status === 0) {
  7317. let data;
  7318. if (asTypedArray && request.response) {
  7319. data = new Uint8Array(request.response);
  7320. } else if (!asTypedArray && request.responseText) {
  7321. data = (0, _util.stringToBytes)(request.responseText);
  7322. }
  7323. if (data) {
  7324. resolve(data);
  7325. return;
  7326. }
  7327. }
  7328. reject(new Error(request.statusText));
  7329. };
  7330. request.send(null);
  7331. });
  7332. }
  7333. class DOMCMapReaderFactory extends _base_factory.BaseCMapReaderFactory {
  7334. _fetchData(url, compressionType) {
  7335. return fetchData(url, this.isCompressed).then(data => {
  7336. return {
  7337. cMapData: data,
  7338. compressionType
  7339. };
  7340. });
  7341. }
  7342. }
  7343. exports.DOMCMapReaderFactory = DOMCMapReaderFactory;
  7344. class DOMStandardFontDataFactory extends _base_factory.BaseStandardFontDataFactory {
  7345. _fetchData(url) {
  7346. return fetchData(url, true);
  7347. }
  7348. }
  7349. exports.DOMStandardFontDataFactory = DOMStandardFontDataFactory;
  7350. class DOMSVGFactory extends _base_factory.BaseSVGFactory {
  7351. _createSVG(type) {
  7352. return document.createElementNS(SVG_NS, type);
  7353. }
  7354. }
  7355. exports.DOMSVGFactory = DOMSVGFactory;
  7356. class PageViewport {
  7357. constructor(_ref) {
  7358. let {
  7359. viewBox,
  7360. scale,
  7361. rotation,
  7362. offsetX = 0,
  7363. offsetY = 0,
  7364. dontFlip = false
  7365. } = _ref;
  7366. this.viewBox = viewBox;
  7367. this.scale = scale;
  7368. this.rotation = rotation;
  7369. this.offsetX = offsetX;
  7370. this.offsetY = offsetY;
  7371. const centerX = (viewBox[2] + viewBox[0]) / 2;
  7372. const centerY = (viewBox[3] + viewBox[1]) / 2;
  7373. let rotateA, rotateB, rotateC, rotateD;
  7374. rotation %= 360;
  7375. if (rotation < 0) {
  7376. rotation += 360;
  7377. }
  7378. switch (rotation) {
  7379. case 180:
  7380. rotateA = -1;
  7381. rotateB = 0;
  7382. rotateC = 0;
  7383. rotateD = 1;
  7384. break;
  7385. case 90:
  7386. rotateA = 0;
  7387. rotateB = 1;
  7388. rotateC = 1;
  7389. rotateD = 0;
  7390. break;
  7391. case 270:
  7392. rotateA = 0;
  7393. rotateB = -1;
  7394. rotateC = -1;
  7395. rotateD = 0;
  7396. break;
  7397. case 0:
  7398. rotateA = 1;
  7399. rotateB = 0;
  7400. rotateC = 0;
  7401. rotateD = -1;
  7402. break;
  7403. default:
  7404. throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.");
  7405. }
  7406. if (dontFlip) {
  7407. rotateC = -rotateC;
  7408. rotateD = -rotateD;
  7409. }
  7410. let offsetCanvasX, offsetCanvasY;
  7411. let width, height;
  7412. if (rotateA === 0) {
  7413. offsetCanvasX = Math.abs(centerY - viewBox[1]) * scale + offsetX;
  7414. offsetCanvasY = Math.abs(centerX - viewBox[0]) * scale + offsetY;
  7415. width = (viewBox[3] - viewBox[1]) * scale;
  7416. height = (viewBox[2] - viewBox[0]) * scale;
  7417. } else {
  7418. offsetCanvasX = Math.abs(centerX - viewBox[0]) * scale + offsetX;
  7419. offsetCanvasY = Math.abs(centerY - viewBox[1]) * scale + offsetY;
  7420. width = (viewBox[2] - viewBox[0]) * scale;
  7421. height = (viewBox[3] - viewBox[1]) * scale;
  7422. }
  7423. this.transform = [rotateA * scale, rotateB * scale, rotateC * scale, rotateD * scale, offsetCanvasX - rotateA * scale * centerX - rotateC * scale * centerY, offsetCanvasY - rotateB * scale * centerX - rotateD * scale * centerY];
  7424. this.width = width;
  7425. this.height = height;
  7426. }
  7427. get rawDims() {
  7428. const {
  7429. viewBox
  7430. } = this;
  7431. return (0, _util.shadow)(this, "rawDims", {
  7432. pageWidth: viewBox[2] - viewBox[0],
  7433. pageHeight: viewBox[3] - viewBox[1],
  7434. pageX: viewBox[0],
  7435. pageY: viewBox[1]
  7436. });
  7437. }
  7438. clone() {
  7439. let {
  7440. scale = this.scale,
  7441. rotation = this.rotation,
  7442. offsetX = this.offsetX,
  7443. offsetY = this.offsetY,
  7444. dontFlip = false
  7445. } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  7446. return new PageViewport({
  7447. viewBox: this.viewBox.slice(),
  7448. scale,
  7449. rotation,
  7450. offsetX,
  7451. offsetY,
  7452. dontFlip
  7453. });
  7454. }
  7455. convertToViewportPoint(x, y) {
  7456. return _util.Util.applyTransform([x, y], this.transform);
  7457. }
  7458. convertToViewportRectangle(rect) {
  7459. const topLeft = _util.Util.applyTransform([rect[0], rect[1]], this.transform);
  7460. const bottomRight = _util.Util.applyTransform([rect[2], rect[3]], this.transform);
  7461. return [topLeft[0], topLeft[1], bottomRight[0], bottomRight[1]];
  7462. }
  7463. convertToPdfPoint(x, y) {
  7464. return _util.Util.applyInverseTransform([x, y], this.transform);
  7465. }
  7466. }
  7467. exports.PageViewport = PageViewport;
  7468. class RenderingCancelledException extends _util.BaseException {
  7469. constructor(msg, type) {
  7470. let extraDelay = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
  7471. super(msg, "RenderingCancelledException");
  7472. this.type = type;
  7473. this.extraDelay = extraDelay;
  7474. }
  7475. }
  7476. exports.RenderingCancelledException = RenderingCancelledException;
  7477. function isDataScheme(url) {
  7478. const ii = url.length;
  7479. let i = 0;
  7480. while (i < ii && url[i].trim() === "") {
  7481. i++;
  7482. }
  7483. return url.substring(i, i + 5).toLowerCase() === "data:";
  7484. }
  7485. function isPdfFile(filename) {
  7486. return typeof filename === "string" && /\.pdf$/i.test(filename);
  7487. }
  7488. function getFilenameFromUrl(url) {
  7489. let onlyStripPath = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  7490. if (!onlyStripPath) {
  7491. [url] = url.split(/[#?]/, 1);
  7492. }
  7493. return url.substring(url.lastIndexOf("/") + 1);
  7494. }
  7495. function getPdfFilenameFromUrl(url) {
  7496. let defaultFilename = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "document.pdf";
  7497. if (typeof url !== "string") {
  7498. return defaultFilename;
  7499. }
  7500. if (isDataScheme(url)) {
  7501. (0, _util.warn)('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.');
  7502. return defaultFilename;
  7503. }
  7504. const reURI = /^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/;
  7505. const reFilename = /[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i;
  7506. const splitURI = reURI.exec(url);
  7507. let suggestedFilename = reFilename.exec(splitURI[1]) || reFilename.exec(splitURI[2]) || reFilename.exec(splitURI[3]);
  7508. if (suggestedFilename) {
  7509. suggestedFilename = suggestedFilename[0];
  7510. if (suggestedFilename.includes("%")) {
  7511. try {
  7512. suggestedFilename = reFilename.exec(decodeURIComponent(suggestedFilename))[0];
  7513. } catch (ex) {}
  7514. }
  7515. }
  7516. return suggestedFilename || defaultFilename;
  7517. }
  7518. class StatTimer {
  7519. started = Object.create(null);
  7520. times = [];
  7521. time(name) {
  7522. if (name in this.started) {
  7523. (0, _util.warn)(`Timer is already running for ${name}`);
  7524. }
  7525. this.started[name] = Date.now();
  7526. }
  7527. timeEnd(name) {
  7528. if (!(name in this.started)) {
  7529. (0, _util.warn)(`Timer has not been started for ${name}`);
  7530. }
  7531. this.times.push({
  7532. name,
  7533. start: this.started[name],
  7534. end: Date.now()
  7535. });
  7536. delete this.started[name];
  7537. }
  7538. toString() {
  7539. const outBuf = [];
  7540. let longest = 0;
  7541. for (const {
  7542. name
  7543. } of this.times) {
  7544. longest = Math.max(name.length, longest);
  7545. }
  7546. for (const {
  7547. name,
  7548. start,
  7549. end
  7550. } of this.times) {
  7551. outBuf.push(`${name.padEnd(longest)} ${end - start}ms\n`);
  7552. }
  7553. return outBuf.join("");
  7554. }
  7555. }
  7556. exports.StatTimer = StatTimer;
  7557. function isValidFetchUrl(url, baseUrl) {
  7558. try {
  7559. const {
  7560. protocol
  7561. } = baseUrl ? new URL(url, baseUrl) : new URL(url);
  7562. return protocol === "http:" || protocol === "https:";
  7563. } catch (ex) {
  7564. return false;
  7565. }
  7566. }
  7567. function loadScript(src) {
  7568. let removeScriptElement = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  7569. return new Promise((resolve, reject) => {
  7570. const script = document.createElement("script");
  7571. script.src = src;
  7572. script.onload = function (evt) {
  7573. if (removeScriptElement) {
  7574. script.remove();
  7575. }
  7576. resolve(evt);
  7577. };
  7578. script.onerror = function () {
  7579. reject(new Error(`Cannot load script at: ${script.src}`));
  7580. };
  7581. (document.head || document.documentElement).append(script);
  7582. });
  7583. }
  7584. function deprecated(details) {
  7585. console.log("Deprecated API usage: " + details);
  7586. }
  7587. let pdfDateStringRegex;
  7588. class PDFDateString {
  7589. static toDateObject(input) {
  7590. if (!input || typeof input !== "string") {
  7591. return null;
  7592. }
  7593. if (!pdfDateStringRegex) {
  7594. pdfDateStringRegex = new RegExp("^D:" + "(\\d{4})" + "(\\d{2})?" + "(\\d{2})?" + "(\\d{2})?" + "(\\d{2})?" + "(\\d{2})?" + "([Z|+|-])?" + "(\\d{2})?" + "'?" + "(\\d{2})?" + "'?");
  7595. }
  7596. const matches = pdfDateStringRegex.exec(input);
  7597. if (!matches) {
  7598. return null;
  7599. }
  7600. const year = parseInt(matches[1], 10);
  7601. let month = parseInt(matches[2], 10);
  7602. month = month >= 1 && month <= 12 ? month - 1 : 0;
  7603. let day = parseInt(matches[3], 10);
  7604. day = day >= 1 && day <= 31 ? day : 1;
  7605. let hour = parseInt(matches[4], 10);
  7606. hour = hour >= 0 && hour <= 23 ? hour : 0;
  7607. let minute = parseInt(matches[5], 10);
  7608. minute = minute >= 0 && minute <= 59 ? minute : 0;
  7609. let second = parseInt(matches[6], 10);
  7610. second = second >= 0 && second <= 59 ? second : 0;
  7611. const universalTimeRelation = matches[7] || "Z";
  7612. let offsetHour = parseInt(matches[8], 10);
  7613. offsetHour = offsetHour >= 0 && offsetHour <= 23 ? offsetHour : 0;
  7614. let offsetMinute = parseInt(matches[9], 10) || 0;
  7615. offsetMinute = offsetMinute >= 0 && offsetMinute <= 59 ? offsetMinute : 0;
  7616. if (universalTimeRelation === "-") {
  7617. hour += offsetHour;
  7618. minute += offsetMinute;
  7619. } else if (universalTimeRelation === "+") {
  7620. hour -= offsetHour;
  7621. minute -= offsetMinute;
  7622. }
  7623. return new Date(Date.UTC(year, month, day, hour, minute, second));
  7624. }
  7625. }
  7626. exports.PDFDateString = PDFDateString;
  7627. function getXfaPageViewport(xfaPage, _ref2) {
  7628. let {
  7629. scale = 1,
  7630. rotation = 0
  7631. } = _ref2;
  7632. const {
  7633. width,
  7634. height
  7635. } = xfaPage.attributes.style;
  7636. const viewBox = [0, 0, parseInt(width), parseInt(height)];
  7637. return new PageViewport({
  7638. viewBox,
  7639. scale,
  7640. rotation
  7641. });
  7642. }
  7643. function getRGB(color) {
  7644. if (color.startsWith("#")) {
  7645. const colorRGB = parseInt(color.slice(1), 16);
  7646. return [(colorRGB & 0xff0000) >> 16, (colorRGB & 0x00ff00) >> 8, colorRGB & 0x0000ff];
  7647. }
  7648. if (color.startsWith("rgb(")) {
  7649. return color.slice(4, -1).split(",").map(x => parseInt(x));
  7650. }
  7651. if (color.startsWith("rgba(")) {
  7652. return color.slice(5, -1).split(",").map(x => parseInt(x)).slice(0, 3);
  7653. }
  7654. (0, _util.warn)(`Not a valid color format: "${color}"`);
  7655. return [0, 0, 0];
  7656. }
  7657. function getColorValues(colors) {
  7658. const span = document.createElement("span");
  7659. span.style.visibility = "hidden";
  7660. document.body.append(span);
  7661. for (const name of colors.keys()) {
  7662. span.style.color = name;
  7663. const computedColor = window.getComputedStyle(span).color;
  7664. colors.set(name, getRGB(computedColor));
  7665. }
  7666. span.remove();
  7667. }
  7668. function getCurrentTransform(ctx) {
  7669. const {
  7670. a,
  7671. b,
  7672. c,
  7673. d,
  7674. e,
  7675. f
  7676. } = ctx.getTransform();
  7677. return [a, b, c, d, e, f];
  7678. }
  7679. function getCurrentTransformInverse(ctx) {
  7680. const {
  7681. a,
  7682. b,
  7683. c,
  7684. d,
  7685. e,
  7686. f
  7687. } = ctx.getTransform().invertSelf();
  7688. return [a, b, c, d, e, f];
  7689. }
  7690. function setLayerDimensions(div, viewport) {
  7691. let mustFlip = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  7692. let mustRotate = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
  7693. if (viewport instanceof PageViewport) {
  7694. const {
  7695. pageWidth,
  7696. pageHeight
  7697. } = viewport.rawDims;
  7698. const {
  7699. style
  7700. } = div;
  7701. const widthStr = `calc(var(--scale-factor) * ${pageWidth}px)`;
  7702. const heightStr = `calc(var(--scale-factor) * ${pageHeight}px)`;
  7703. if (!mustFlip || viewport.rotation % 180 === 0) {
  7704. style.width = widthStr;
  7705. style.height = heightStr;
  7706. } else {
  7707. style.width = heightStr;
  7708. style.height = widthStr;
  7709. }
  7710. }
  7711. if (mustRotate) {
  7712. div.setAttribute("data-main-rotation", viewport.rotation);
  7713. }
  7714. }
  7715. /***/ }),
  7716. /* 140 */
  7717. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  7718. "use strict";
  7719. Object.defineProperty(exports, "__esModule", ({
  7720. value: true
  7721. }));
  7722. exports.BaseStandardFontDataFactory = exports.BaseSVGFactory = exports.BaseCanvasFactory = exports.BaseCMapReaderFactory = void 0;
  7723. var _util = __w_pdfjs_require__(1);
  7724. class BaseCanvasFactory {
  7725. constructor() {
  7726. if (this.constructor === BaseCanvasFactory) {
  7727. (0, _util.unreachable)("Cannot initialize BaseCanvasFactory.");
  7728. }
  7729. }
  7730. create(width, height) {
  7731. if (width <= 0 || height <= 0) {
  7732. throw new Error("Invalid canvas size");
  7733. }
  7734. const canvas = this._createCanvas(width, height);
  7735. return {
  7736. canvas,
  7737. context: canvas.getContext("2d")
  7738. };
  7739. }
  7740. reset(canvasAndContext, width, height) {
  7741. if (!canvasAndContext.canvas) {
  7742. throw new Error("Canvas is not specified");
  7743. }
  7744. if (width <= 0 || height <= 0) {
  7745. throw new Error("Invalid canvas size");
  7746. }
  7747. canvasAndContext.canvas.width = width;
  7748. canvasAndContext.canvas.height = height;
  7749. }
  7750. destroy(canvasAndContext) {
  7751. if (!canvasAndContext.canvas) {
  7752. throw new Error("Canvas is not specified");
  7753. }
  7754. canvasAndContext.canvas.width = 0;
  7755. canvasAndContext.canvas.height = 0;
  7756. canvasAndContext.canvas = null;
  7757. canvasAndContext.context = null;
  7758. }
  7759. _createCanvas(width, height) {
  7760. (0, _util.unreachable)("Abstract method `_createCanvas` called.");
  7761. }
  7762. }
  7763. exports.BaseCanvasFactory = BaseCanvasFactory;
  7764. class BaseCMapReaderFactory {
  7765. constructor(_ref) {
  7766. let {
  7767. baseUrl = null,
  7768. isCompressed = true
  7769. } = _ref;
  7770. if (this.constructor === BaseCMapReaderFactory) {
  7771. (0, _util.unreachable)("Cannot initialize BaseCMapReaderFactory.");
  7772. }
  7773. this.baseUrl = baseUrl;
  7774. this.isCompressed = isCompressed;
  7775. }
  7776. async fetch(_ref2) {
  7777. let {
  7778. name
  7779. } = _ref2;
  7780. if (!this.baseUrl) {
  7781. throw new Error('The CMap "baseUrl" parameter must be specified, ensure that ' + 'the "cMapUrl" and "cMapPacked" API parameters are provided.');
  7782. }
  7783. if (!name) {
  7784. throw new Error("CMap name must be specified.");
  7785. }
  7786. const url = this.baseUrl + name + (this.isCompressed ? ".bcmap" : "");
  7787. const compressionType = this.isCompressed ? _util.CMapCompressionType.BINARY : _util.CMapCompressionType.NONE;
  7788. return this._fetchData(url, compressionType).catch(reason => {
  7789. throw new Error(`Unable to load ${this.isCompressed ? "binary " : ""}CMap at: ${url}`);
  7790. });
  7791. }
  7792. _fetchData(url, compressionType) {
  7793. (0, _util.unreachable)("Abstract method `_fetchData` called.");
  7794. }
  7795. }
  7796. exports.BaseCMapReaderFactory = BaseCMapReaderFactory;
  7797. class BaseStandardFontDataFactory {
  7798. constructor(_ref3) {
  7799. let {
  7800. baseUrl = null
  7801. } = _ref3;
  7802. if (this.constructor === BaseStandardFontDataFactory) {
  7803. (0, _util.unreachable)("Cannot initialize BaseStandardFontDataFactory.");
  7804. }
  7805. this.baseUrl = baseUrl;
  7806. }
  7807. async fetch(_ref4) {
  7808. let {
  7809. filename
  7810. } = _ref4;
  7811. if (!this.baseUrl) {
  7812. throw new Error('The standard font "baseUrl" parameter must be specified, ensure that ' + 'the "standardFontDataUrl" API parameter is provided.');
  7813. }
  7814. if (!filename) {
  7815. throw new Error("Font filename must be specified.");
  7816. }
  7817. const url = `${this.baseUrl}${filename}`;
  7818. return this._fetchData(url).catch(reason => {
  7819. throw new Error(`Unable to load font data at: ${url}`);
  7820. });
  7821. }
  7822. _fetchData(url) {
  7823. (0, _util.unreachable)("Abstract method `_fetchData` called.");
  7824. }
  7825. }
  7826. exports.BaseStandardFontDataFactory = BaseStandardFontDataFactory;
  7827. class BaseSVGFactory {
  7828. constructor() {
  7829. if (this.constructor === BaseSVGFactory) {
  7830. (0, _util.unreachable)("Cannot initialize BaseSVGFactory.");
  7831. }
  7832. }
  7833. create(width, height) {
  7834. let skipDimensions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  7835. if (width <= 0 || height <= 0) {
  7836. throw new Error("Invalid SVG dimensions");
  7837. }
  7838. const svg = this._createSVG("svg:svg");
  7839. svg.setAttribute("version", "1.1");
  7840. if (!skipDimensions) {
  7841. svg.setAttribute("width", `${width}px`);
  7842. svg.setAttribute("height", `${height}px`);
  7843. }
  7844. svg.setAttribute("preserveAspectRatio", "none");
  7845. svg.setAttribute("viewBox", `0 0 ${width} ${height}`);
  7846. return svg;
  7847. }
  7848. createElement(type) {
  7849. if (typeof type !== "string") {
  7850. throw new Error("Invalid SVG element type");
  7851. }
  7852. return this._createSVG(type);
  7853. }
  7854. _createSVG(type) {
  7855. (0, _util.unreachable)("Abstract method `_createSVG` called.");
  7856. }
  7857. }
  7858. exports.BaseSVGFactory = BaseSVGFactory;
  7859. /***/ }),
  7860. /* 141 */
  7861. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  7862. "use strict";
  7863. Object.defineProperty(exports, "__esModule", ({
  7864. value: true
  7865. }));
  7866. exports.MurmurHash3_64 = void 0;
  7867. var _util = __w_pdfjs_require__(1);
  7868. const SEED = 0xc3d2e1f0;
  7869. const MASK_HIGH = 0xffff0000;
  7870. const MASK_LOW = 0xffff;
  7871. class MurmurHash3_64 {
  7872. constructor(seed) {
  7873. this.h1 = seed ? seed & 0xffffffff : SEED;
  7874. this.h2 = seed ? seed & 0xffffffff : SEED;
  7875. }
  7876. update(input) {
  7877. let data, length;
  7878. if (typeof input === "string") {
  7879. data = new Uint8Array(input.length * 2);
  7880. length = 0;
  7881. for (let i = 0, ii = input.length; i < ii; i++) {
  7882. const code = input.charCodeAt(i);
  7883. if (code <= 0xff) {
  7884. data[length++] = code;
  7885. } else {
  7886. data[length++] = code >>> 8;
  7887. data[length++] = code & 0xff;
  7888. }
  7889. }
  7890. } else if ((0, _util.isArrayBuffer)(input)) {
  7891. data = input.slice();
  7892. length = data.byteLength;
  7893. } else {
  7894. throw new Error("Wrong data format in MurmurHash3_64_update. " + "Input must be a string or array.");
  7895. }
  7896. const blockCounts = length >> 2;
  7897. const tailLength = length - blockCounts * 4;
  7898. const dataUint32 = new Uint32Array(data.buffer, 0, blockCounts);
  7899. let k1 = 0,
  7900. k2 = 0;
  7901. let h1 = this.h1,
  7902. h2 = this.h2;
  7903. const C1 = 0xcc9e2d51,
  7904. C2 = 0x1b873593;
  7905. const C1_LOW = C1 & MASK_LOW,
  7906. C2_LOW = C2 & MASK_LOW;
  7907. for (let i = 0; i < blockCounts; i++) {
  7908. if (i & 1) {
  7909. k1 = dataUint32[i];
  7910. k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW;
  7911. k1 = k1 << 15 | k1 >>> 17;
  7912. k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW;
  7913. h1 ^= k1;
  7914. h1 = h1 << 13 | h1 >>> 19;
  7915. h1 = h1 * 5 + 0xe6546b64;
  7916. } else {
  7917. k2 = dataUint32[i];
  7918. k2 = k2 * C1 & MASK_HIGH | k2 * C1_LOW & MASK_LOW;
  7919. k2 = k2 << 15 | k2 >>> 17;
  7920. k2 = k2 * C2 & MASK_HIGH | k2 * C2_LOW & MASK_LOW;
  7921. h2 ^= k2;
  7922. h2 = h2 << 13 | h2 >>> 19;
  7923. h2 = h2 * 5 + 0xe6546b64;
  7924. }
  7925. }
  7926. k1 = 0;
  7927. switch (tailLength) {
  7928. case 3:
  7929. k1 ^= data[blockCounts * 4 + 2] << 16;
  7930. case 2:
  7931. k1 ^= data[blockCounts * 4 + 1] << 8;
  7932. case 1:
  7933. k1 ^= data[blockCounts * 4];
  7934. k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW;
  7935. k1 = k1 << 15 | k1 >>> 17;
  7936. k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW;
  7937. if (blockCounts & 1) {
  7938. h1 ^= k1;
  7939. } else {
  7940. h2 ^= k1;
  7941. }
  7942. }
  7943. this.h1 = h1;
  7944. this.h2 = h2;
  7945. }
  7946. hexdigest() {
  7947. let h1 = this.h1,
  7948. h2 = this.h2;
  7949. h1 ^= h2 >>> 1;
  7950. h1 = h1 * 0xed558ccd & MASK_HIGH | h1 * 0x8ccd & MASK_LOW;
  7951. h2 = h2 * 0xff51afd7 & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 0xafd7ed55 & MASK_HIGH) >>> 16;
  7952. h1 ^= h2 >>> 1;
  7953. h1 = h1 * 0x1a85ec53 & MASK_HIGH | h1 * 0xec53 & MASK_LOW;
  7954. h2 = h2 * 0xc4ceb9fe & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 0xb9fe1a85 & MASK_HIGH) >>> 16;
  7955. h1 ^= h2 >>> 1;
  7956. return (h1 >>> 0).toString(16).padStart(8, "0") + (h2 >>> 0).toString(16).padStart(8, "0");
  7957. }
  7958. }
  7959. exports.MurmurHash3_64 = MurmurHash3_64;
  7960. /***/ }),
  7961. /* 142 */
  7962. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  7963. "use strict";
  7964. Object.defineProperty(exports, "__esModule", ({
  7965. value: true
  7966. }));
  7967. exports.FontLoader = exports.FontFaceObject = void 0;
  7968. var _util = __w_pdfjs_require__(1);
  7969. var _is_node = __w_pdfjs_require__(3);
  7970. class FontLoader {
  7971. constructor(_ref) {
  7972. let {
  7973. onUnsupportedFeature,
  7974. ownerDocument = globalThis.document,
  7975. styleElement = null
  7976. } = _ref;
  7977. this._onUnsupportedFeature = onUnsupportedFeature;
  7978. this._document = ownerDocument;
  7979. this.nativeFontFaces = [];
  7980. this.styleElement = null;
  7981. this.loadingRequests = [];
  7982. this.loadTestFontId = 0;
  7983. }
  7984. addNativeFontFace(nativeFontFace) {
  7985. this.nativeFontFaces.push(nativeFontFace);
  7986. this._document.fonts.add(nativeFontFace);
  7987. }
  7988. insertRule(rule) {
  7989. if (!this.styleElement) {
  7990. this.styleElement = this._document.createElement("style");
  7991. this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement);
  7992. }
  7993. const styleSheet = this.styleElement.sheet;
  7994. styleSheet.insertRule(rule, styleSheet.cssRules.length);
  7995. }
  7996. clear() {
  7997. for (const nativeFontFace of this.nativeFontFaces) {
  7998. this._document.fonts.delete(nativeFontFace);
  7999. }
  8000. this.nativeFontFaces.length = 0;
  8001. if (this.styleElement) {
  8002. this.styleElement.remove();
  8003. this.styleElement = null;
  8004. }
  8005. }
  8006. async bind(font) {
  8007. if (font.attached || font.missingFile) {
  8008. return;
  8009. }
  8010. font.attached = true;
  8011. if (this.isFontLoadingAPISupported) {
  8012. const nativeFontFace = font.createNativeFontFace();
  8013. if (nativeFontFace) {
  8014. this.addNativeFontFace(nativeFontFace);
  8015. try {
  8016. await nativeFontFace.loaded;
  8017. } catch (ex) {
  8018. this._onUnsupportedFeature({
  8019. featureId: _util.UNSUPPORTED_FEATURES.errorFontLoadNative
  8020. });
  8021. (0, _util.warn)(`Failed to load font '${nativeFontFace.family}': '${ex}'.`);
  8022. font.disableFontFace = true;
  8023. throw ex;
  8024. }
  8025. }
  8026. return;
  8027. }
  8028. const rule = font.createFontFaceRule();
  8029. if (rule) {
  8030. this.insertRule(rule);
  8031. if (this.isSyncFontLoadingSupported) {
  8032. return;
  8033. }
  8034. await new Promise(resolve => {
  8035. const request = this._queueLoadingCallback(resolve);
  8036. this._prepareFontLoadEvent(font, request);
  8037. });
  8038. }
  8039. }
  8040. get isFontLoadingAPISupported() {
  8041. var _this$_document;
  8042. const hasFonts = !!((_this$_document = this._document) !== null && _this$_document !== void 0 && _this$_document.fonts);
  8043. return (0, _util.shadow)(this, "isFontLoadingAPISupported", hasFonts);
  8044. }
  8045. get isSyncFontLoadingSupported() {
  8046. let supported = false;
  8047. if (_is_node.isNodeJS) {
  8048. supported = true;
  8049. } else if (typeof navigator !== "undefined" && /Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent)) {
  8050. supported = true;
  8051. }
  8052. return (0, _util.shadow)(this, "isSyncFontLoadingSupported", supported);
  8053. }
  8054. _queueLoadingCallback(callback) {
  8055. function completeRequest() {
  8056. (0, _util.assert)(!request.done, "completeRequest() cannot be called twice.");
  8057. request.done = true;
  8058. while (loadingRequests.length > 0 && loadingRequests[0].done) {
  8059. const otherRequest = loadingRequests.shift();
  8060. setTimeout(otherRequest.callback, 0);
  8061. }
  8062. }
  8063. const {
  8064. loadingRequests
  8065. } = this;
  8066. const request = {
  8067. done: false,
  8068. complete: completeRequest,
  8069. callback
  8070. };
  8071. loadingRequests.push(request);
  8072. return request;
  8073. }
  8074. get _loadTestFont() {
  8075. const testFont = atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQA" + "FQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAA" + "ALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgA" + "AAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1" + "AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD" + "6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACM" + "AooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4D" + "IP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAA" + "AAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUA" + "AQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgAB" + "AAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABY" + "AAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAA" + "AC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + "AAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAA" + "AAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQAC" + "AQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3" + "Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTj" + "FQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");
  8076. return (0, _util.shadow)(this, "_loadTestFont", testFont);
  8077. }
  8078. _prepareFontLoadEvent(font, request) {
  8079. function int32(data, offset) {
  8080. return data.charCodeAt(offset) << 24 | data.charCodeAt(offset + 1) << 16 | data.charCodeAt(offset + 2) << 8 | data.charCodeAt(offset + 3) & 0xff;
  8081. }
  8082. function spliceString(s, offset, remove, insert) {
  8083. const chunk1 = s.substring(0, offset);
  8084. const chunk2 = s.substring(offset + remove);
  8085. return chunk1 + insert + chunk2;
  8086. }
  8087. let i, ii;
  8088. const canvas = this._document.createElement("canvas");
  8089. canvas.width = 1;
  8090. canvas.height = 1;
  8091. const ctx = canvas.getContext("2d");
  8092. let called = 0;
  8093. function isFontReady(name, callback) {
  8094. if (++called > 30) {
  8095. (0, _util.warn)("Load test font never loaded.");
  8096. callback();
  8097. return;
  8098. }
  8099. ctx.font = "30px " + name;
  8100. ctx.fillText(".", 0, 20);
  8101. const imageData = ctx.getImageData(0, 0, 1, 1);
  8102. if (imageData.data[3] > 0) {
  8103. callback();
  8104. return;
  8105. }
  8106. setTimeout(isFontReady.bind(null, name, callback));
  8107. }
  8108. const loadTestFontId = `lt${Date.now()}${this.loadTestFontId++}`;
  8109. let data = this._loadTestFont;
  8110. const COMMENT_OFFSET = 976;
  8111. data = spliceString(data, COMMENT_OFFSET, loadTestFontId.length, loadTestFontId);
  8112. const CFF_CHECKSUM_OFFSET = 16;
  8113. const XXXX_VALUE = 0x58585858;
  8114. let checksum = int32(data, CFF_CHECKSUM_OFFSET);
  8115. for (i = 0, ii = loadTestFontId.length - 3; i < ii; i += 4) {
  8116. checksum = checksum - XXXX_VALUE + int32(loadTestFontId, i) | 0;
  8117. }
  8118. if (i < loadTestFontId.length) {
  8119. checksum = checksum - XXXX_VALUE + int32(loadTestFontId + "XXX", i) | 0;
  8120. }
  8121. data = spliceString(data, CFF_CHECKSUM_OFFSET, 4, (0, _util.string32)(checksum));
  8122. const url = `url(data:font/opentype;base64,${btoa(data)});`;
  8123. const rule = `@font-face {font-family:"${loadTestFontId}";src:${url}}`;
  8124. this.insertRule(rule);
  8125. const div = this._document.createElement("div");
  8126. div.style.visibility = "hidden";
  8127. div.style.width = div.style.height = "10px";
  8128. div.style.position = "absolute";
  8129. div.style.top = div.style.left = "0px";
  8130. for (const name of [font.loadedName, loadTestFontId]) {
  8131. const span = this._document.createElement("span");
  8132. span.textContent = "Hi";
  8133. span.style.fontFamily = name;
  8134. div.append(span);
  8135. }
  8136. this._document.body.append(div);
  8137. isFontReady(loadTestFontId, () => {
  8138. div.remove();
  8139. request.complete();
  8140. });
  8141. }
  8142. }
  8143. exports.FontLoader = FontLoader;
  8144. class FontFaceObject {
  8145. constructor(translatedData, _ref2) {
  8146. let {
  8147. isEvalSupported = true,
  8148. disableFontFace = false,
  8149. ignoreErrors = false,
  8150. onUnsupportedFeature,
  8151. fontRegistry = null
  8152. } = _ref2;
  8153. this.compiledGlyphs = Object.create(null);
  8154. for (const i in translatedData) {
  8155. this[i] = translatedData[i];
  8156. }
  8157. this.isEvalSupported = isEvalSupported !== false;
  8158. this.disableFontFace = disableFontFace === true;
  8159. this.ignoreErrors = ignoreErrors === true;
  8160. this._onUnsupportedFeature = onUnsupportedFeature;
  8161. this.fontRegistry = fontRegistry;
  8162. }
  8163. createNativeFontFace() {
  8164. var _this$fontRegistry;
  8165. if (!this.data || this.disableFontFace) {
  8166. return null;
  8167. }
  8168. let nativeFontFace;
  8169. if (!this.cssFontInfo) {
  8170. nativeFontFace = new FontFace(this.loadedName, this.data, {});
  8171. } else {
  8172. const css = {
  8173. weight: this.cssFontInfo.fontWeight
  8174. };
  8175. if (this.cssFontInfo.italicAngle) {
  8176. css.style = `oblique ${this.cssFontInfo.italicAngle}deg`;
  8177. }
  8178. nativeFontFace = new FontFace(this.cssFontInfo.fontFamily, this.data, css);
  8179. }
  8180. (_this$fontRegistry = this.fontRegistry) === null || _this$fontRegistry === void 0 ? void 0 : _this$fontRegistry.registerFont(this);
  8181. return nativeFontFace;
  8182. }
  8183. createFontFaceRule() {
  8184. var _this$fontRegistry2;
  8185. if (!this.data || this.disableFontFace) {
  8186. return null;
  8187. }
  8188. const data = (0, _util.bytesToString)(this.data);
  8189. const url = `url(data:${this.mimetype};base64,${btoa(data)});`;
  8190. let rule;
  8191. if (!this.cssFontInfo) {
  8192. rule = `@font-face {font-family:"${this.loadedName}";src:${url}}`;
  8193. } else {
  8194. let css = `font-weight: ${this.cssFontInfo.fontWeight};`;
  8195. if (this.cssFontInfo.italicAngle) {
  8196. css += `font-style: oblique ${this.cssFontInfo.italicAngle}deg;`;
  8197. }
  8198. rule = `@font-face {font-family:"${this.cssFontInfo.fontFamily}";${css}src:${url}}`;
  8199. }
  8200. (_this$fontRegistry2 = this.fontRegistry) === null || _this$fontRegistry2 === void 0 ? void 0 : _this$fontRegistry2.registerFont(this, url);
  8201. return rule;
  8202. }
  8203. getPathGenerator(objs, character) {
  8204. if (this.compiledGlyphs[character] !== undefined) {
  8205. return this.compiledGlyphs[character];
  8206. }
  8207. let cmds;
  8208. try {
  8209. cmds = objs.get(this.loadedName + "_path_" + character);
  8210. } catch (ex) {
  8211. if (!this.ignoreErrors) {
  8212. throw ex;
  8213. }
  8214. this._onUnsupportedFeature({
  8215. featureId: _util.UNSUPPORTED_FEATURES.errorFontGetPath
  8216. });
  8217. (0, _util.warn)(`getPathGenerator - ignoring character: "${ex}".`);
  8218. return this.compiledGlyphs[character] = function (c, size) {};
  8219. }
  8220. if (this.isEvalSupported && _util.FeatureTest.isEvalSupported) {
  8221. const jsBuf = [];
  8222. for (const current of cmds) {
  8223. const args = current.args !== undefined ? current.args.join(",") : "";
  8224. jsBuf.push("c.", current.cmd, "(", args, ");\n");
  8225. }
  8226. return this.compiledGlyphs[character] = new Function("c", "size", jsBuf.join(""));
  8227. }
  8228. return this.compiledGlyphs[character] = function (c, size) {
  8229. for (const current of cmds) {
  8230. if (current.cmd === "scale") {
  8231. current.args = [size, -size];
  8232. }
  8233. c[current.cmd].apply(c, current.args);
  8234. }
  8235. };
  8236. }
  8237. }
  8238. exports.FontFaceObject = FontFaceObject;
  8239. /***/ }),
  8240. /* 143 */
  8241. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  8242. "use strict";
  8243. Object.defineProperty(exports, "__esModule", ({
  8244. value: true
  8245. }));
  8246. exports.CanvasGraphics = void 0;
  8247. var _util = __w_pdfjs_require__(1);
  8248. var _display_utils = __w_pdfjs_require__(139);
  8249. var _pattern_helper = __w_pdfjs_require__(144);
  8250. var _image_utils = __w_pdfjs_require__(145);
  8251. function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
  8252. function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
  8253. function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
  8254. const MIN_FONT_SIZE = 16;
  8255. const MAX_FONT_SIZE = 100;
  8256. const MAX_GROUP_SIZE = 4096;
  8257. const EXECUTION_TIME = 15;
  8258. const EXECUTION_STEPS = 10;
  8259. const MAX_SIZE_TO_COMPILE = 1000;
  8260. const FULL_CHUNK_HEIGHT = 16;
  8261. function mirrorContextOperations(ctx, destCtx) {
  8262. if (ctx._removeMirroring) {
  8263. throw new Error("Context is already forwarding operations.");
  8264. }
  8265. ctx.__originalSave = ctx.save;
  8266. ctx.__originalRestore = ctx.restore;
  8267. ctx.__originalRotate = ctx.rotate;
  8268. ctx.__originalScale = ctx.scale;
  8269. ctx.__originalTranslate = ctx.translate;
  8270. ctx.__originalTransform = ctx.transform;
  8271. ctx.__originalSetTransform = ctx.setTransform;
  8272. ctx.__originalResetTransform = ctx.resetTransform;
  8273. ctx.__originalClip = ctx.clip;
  8274. ctx.__originalMoveTo = ctx.moveTo;
  8275. ctx.__originalLineTo = ctx.lineTo;
  8276. ctx.__originalBezierCurveTo = ctx.bezierCurveTo;
  8277. ctx.__originalRect = ctx.rect;
  8278. ctx.__originalClosePath = ctx.closePath;
  8279. ctx.__originalBeginPath = ctx.beginPath;
  8280. ctx._removeMirroring = () => {
  8281. ctx.save = ctx.__originalSave;
  8282. ctx.restore = ctx.__originalRestore;
  8283. ctx.rotate = ctx.__originalRotate;
  8284. ctx.scale = ctx.__originalScale;
  8285. ctx.translate = ctx.__originalTranslate;
  8286. ctx.transform = ctx.__originalTransform;
  8287. ctx.setTransform = ctx.__originalSetTransform;
  8288. ctx.resetTransform = ctx.__originalResetTransform;
  8289. ctx.clip = ctx.__originalClip;
  8290. ctx.moveTo = ctx.__originalMoveTo;
  8291. ctx.lineTo = ctx.__originalLineTo;
  8292. ctx.bezierCurveTo = ctx.__originalBezierCurveTo;
  8293. ctx.rect = ctx.__originalRect;
  8294. ctx.closePath = ctx.__originalClosePath;
  8295. ctx.beginPath = ctx.__originalBeginPath;
  8296. delete ctx._removeMirroring;
  8297. };
  8298. ctx.save = function ctxSave() {
  8299. destCtx.save();
  8300. this.__originalSave();
  8301. };
  8302. ctx.restore = function ctxRestore() {
  8303. destCtx.restore();
  8304. this.__originalRestore();
  8305. };
  8306. ctx.translate = function ctxTranslate(x, y) {
  8307. destCtx.translate(x, y);
  8308. this.__originalTranslate(x, y);
  8309. };
  8310. ctx.scale = function ctxScale(x, y) {
  8311. destCtx.scale(x, y);
  8312. this.__originalScale(x, y);
  8313. };
  8314. ctx.transform = function ctxTransform(a, b, c, d, e, f) {
  8315. destCtx.transform(a, b, c, d, e, f);
  8316. this.__originalTransform(a, b, c, d, e, f);
  8317. };
  8318. ctx.setTransform = function ctxSetTransform(a, b, c, d, e, f) {
  8319. destCtx.setTransform(a, b, c, d, e, f);
  8320. this.__originalSetTransform(a, b, c, d, e, f);
  8321. };
  8322. ctx.resetTransform = function ctxResetTransform() {
  8323. destCtx.resetTransform();
  8324. this.__originalResetTransform();
  8325. };
  8326. ctx.rotate = function ctxRotate(angle) {
  8327. destCtx.rotate(angle);
  8328. this.__originalRotate(angle);
  8329. };
  8330. ctx.clip = function ctxRotate(rule) {
  8331. destCtx.clip(rule);
  8332. this.__originalClip(rule);
  8333. };
  8334. ctx.moveTo = function (x, y) {
  8335. destCtx.moveTo(x, y);
  8336. this.__originalMoveTo(x, y);
  8337. };
  8338. ctx.lineTo = function (x, y) {
  8339. destCtx.lineTo(x, y);
  8340. this.__originalLineTo(x, y);
  8341. };
  8342. ctx.bezierCurveTo = function (cp1x, cp1y, cp2x, cp2y, x, y) {
  8343. destCtx.bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y);
  8344. this.__originalBezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y);
  8345. };
  8346. ctx.rect = function (x, y, width, height) {
  8347. destCtx.rect(x, y, width, height);
  8348. this.__originalRect(x, y, width, height);
  8349. };
  8350. ctx.closePath = function () {
  8351. destCtx.closePath();
  8352. this.__originalClosePath();
  8353. };
  8354. ctx.beginPath = function () {
  8355. destCtx.beginPath();
  8356. this.__originalBeginPath();
  8357. };
  8358. }
  8359. class CachedCanvases {
  8360. constructor(canvasFactory) {
  8361. this.canvasFactory = canvasFactory;
  8362. this.cache = Object.create(null);
  8363. }
  8364. getCanvas(id, width, height) {
  8365. let canvasEntry;
  8366. if (this.cache[id] !== undefined) {
  8367. canvasEntry = this.cache[id];
  8368. this.canvasFactory.reset(canvasEntry, width, height);
  8369. } else {
  8370. canvasEntry = this.canvasFactory.create(width, height);
  8371. this.cache[id] = canvasEntry;
  8372. }
  8373. return canvasEntry;
  8374. }
  8375. delete(id) {
  8376. delete this.cache[id];
  8377. }
  8378. clear() {
  8379. for (const id in this.cache) {
  8380. const canvasEntry = this.cache[id];
  8381. this.canvasFactory.destroy(canvasEntry);
  8382. delete this.cache[id];
  8383. }
  8384. }
  8385. }
  8386. function drawImageAtIntegerCoords(ctx, srcImg, srcX, srcY, srcW, srcH, destX, destY, destW, destH) {
  8387. const [a, b, c, d, tx, ty] = (0, _display_utils.getCurrentTransform)(ctx);
  8388. if (b === 0 && c === 0) {
  8389. const tlX = destX * a + tx;
  8390. const rTlX = Math.round(tlX);
  8391. const tlY = destY * d + ty;
  8392. const rTlY = Math.round(tlY);
  8393. const brX = (destX + destW) * a + tx;
  8394. const rWidth = Math.abs(Math.round(brX) - rTlX) || 1;
  8395. const brY = (destY + destH) * d + ty;
  8396. const rHeight = Math.abs(Math.round(brY) - rTlY) || 1;
  8397. ctx.setTransform(Math.sign(a), 0, 0, Math.sign(d), rTlX, rTlY);
  8398. ctx.drawImage(srcImg, srcX, srcY, srcW, srcH, 0, 0, rWidth, rHeight);
  8399. ctx.setTransform(a, b, c, d, tx, ty);
  8400. return [rWidth, rHeight];
  8401. }
  8402. if (a === 0 && d === 0) {
  8403. const tlX = destY * c + tx;
  8404. const rTlX = Math.round(tlX);
  8405. const tlY = destX * b + ty;
  8406. const rTlY = Math.round(tlY);
  8407. const brX = (destY + destH) * c + tx;
  8408. const rWidth = Math.abs(Math.round(brX) - rTlX) || 1;
  8409. const brY = (destX + destW) * b + ty;
  8410. const rHeight = Math.abs(Math.round(brY) - rTlY) || 1;
  8411. ctx.setTransform(0, Math.sign(b), Math.sign(c), 0, rTlX, rTlY);
  8412. ctx.drawImage(srcImg, srcX, srcY, srcW, srcH, 0, 0, rHeight, rWidth);
  8413. ctx.setTransform(a, b, c, d, tx, ty);
  8414. return [rHeight, rWidth];
  8415. }
  8416. ctx.drawImage(srcImg, srcX, srcY, srcW, srcH, destX, destY, destW, destH);
  8417. const scaleX = Math.hypot(a, b);
  8418. const scaleY = Math.hypot(c, d);
  8419. return [scaleX * destW, scaleY * destH];
  8420. }
  8421. function compileType3Glyph(imgData) {
  8422. const {
  8423. width,
  8424. height
  8425. } = imgData;
  8426. if (width > MAX_SIZE_TO_COMPILE || height > MAX_SIZE_TO_COMPILE) {
  8427. return null;
  8428. }
  8429. const POINT_TO_PROCESS_LIMIT = 1000;
  8430. const POINT_TYPES = new Uint8Array([0, 2, 4, 0, 1, 0, 5, 4, 8, 10, 0, 8, 0, 2, 1, 0]);
  8431. const width1 = width + 1;
  8432. let points = new Uint8Array(width1 * (height + 1));
  8433. let i, j, j0;
  8434. const lineSize = width + 7 & ~7;
  8435. let data = new Uint8Array(lineSize * height),
  8436. pos = 0;
  8437. for (const elem of imgData.data) {
  8438. let mask = 128;
  8439. while (mask > 0) {
  8440. data[pos++] = elem & mask ? 0 : 255;
  8441. mask >>= 1;
  8442. }
  8443. }
  8444. let count = 0;
  8445. pos = 0;
  8446. if (data[pos] !== 0) {
  8447. points[0] = 1;
  8448. ++count;
  8449. }
  8450. for (j = 1; j < width; j++) {
  8451. if (data[pos] !== data[pos + 1]) {
  8452. points[j] = data[pos] ? 2 : 1;
  8453. ++count;
  8454. }
  8455. pos++;
  8456. }
  8457. if (data[pos] !== 0) {
  8458. points[j] = 2;
  8459. ++count;
  8460. }
  8461. for (i = 1; i < height; i++) {
  8462. pos = i * lineSize;
  8463. j0 = i * width1;
  8464. if (data[pos - lineSize] !== data[pos]) {
  8465. points[j0] = data[pos] ? 1 : 8;
  8466. ++count;
  8467. }
  8468. let sum = (data[pos] ? 4 : 0) + (data[pos - lineSize] ? 8 : 0);
  8469. for (j = 1; j < width; j++) {
  8470. sum = (sum >> 2) + (data[pos + 1] ? 4 : 0) + (data[pos - lineSize + 1] ? 8 : 0);
  8471. if (POINT_TYPES[sum]) {
  8472. points[j0 + j] = POINT_TYPES[sum];
  8473. ++count;
  8474. }
  8475. pos++;
  8476. }
  8477. if (data[pos - lineSize] !== data[pos]) {
  8478. points[j0 + j] = data[pos] ? 2 : 4;
  8479. ++count;
  8480. }
  8481. if (count > POINT_TO_PROCESS_LIMIT) {
  8482. return null;
  8483. }
  8484. }
  8485. pos = lineSize * (height - 1);
  8486. j0 = i * width1;
  8487. if (data[pos] !== 0) {
  8488. points[j0] = 8;
  8489. ++count;
  8490. }
  8491. for (j = 1; j < width; j++) {
  8492. if (data[pos] !== data[pos + 1]) {
  8493. points[j0 + j] = data[pos] ? 4 : 8;
  8494. ++count;
  8495. }
  8496. pos++;
  8497. }
  8498. if (data[pos] !== 0) {
  8499. points[j0 + j] = 4;
  8500. ++count;
  8501. }
  8502. if (count > POINT_TO_PROCESS_LIMIT) {
  8503. return null;
  8504. }
  8505. const steps = new Int32Array([0, width1, -1, 0, -width1, 0, 0, 0, 1]);
  8506. const path = new Path2D();
  8507. for (i = 0; count && i <= height; i++) {
  8508. let p = i * width1;
  8509. const end = p + width;
  8510. while (p < end && !points[p]) {
  8511. p++;
  8512. }
  8513. if (p === end) {
  8514. continue;
  8515. }
  8516. path.moveTo(p % width1, i);
  8517. const p0 = p;
  8518. let type = points[p];
  8519. do {
  8520. const step = steps[type];
  8521. do {
  8522. p += step;
  8523. } while (!points[p]);
  8524. const pp = points[p];
  8525. if (pp !== 5 && pp !== 10) {
  8526. type = pp;
  8527. points[p] = 0;
  8528. } else {
  8529. type = pp & 0x33 * type >> 4;
  8530. points[p] &= type >> 2 | type << 2;
  8531. }
  8532. path.lineTo(p % width1, p / width1 | 0);
  8533. if (!points[p]) {
  8534. --count;
  8535. }
  8536. } while (p0 !== p);
  8537. --i;
  8538. }
  8539. data = null;
  8540. points = null;
  8541. const drawOutline = function (c) {
  8542. c.save();
  8543. c.scale(1 / width, -1 / height);
  8544. c.translate(0, -height);
  8545. c.fill(path);
  8546. c.beginPath();
  8547. c.restore();
  8548. };
  8549. return drawOutline;
  8550. }
  8551. class CanvasExtraState {
  8552. constructor(width, height) {
  8553. this.alphaIsShape = false;
  8554. this.fontSize = 0;
  8555. this.fontSizeScale = 1;
  8556. this.textMatrix = _util.IDENTITY_MATRIX;
  8557. this.textMatrixScale = 1;
  8558. this.fontMatrix = _util.FONT_IDENTITY_MATRIX;
  8559. this.leading = 0;
  8560. this.x = 0;
  8561. this.y = 0;
  8562. this.lineX = 0;
  8563. this.lineY = 0;
  8564. this.charSpacing = 0;
  8565. this.wordSpacing = 0;
  8566. this.textHScale = 1;
  8567. this.textRenderingMode = _util.TextRenderingMode.FILL;
  8568. this.textRise = 0;
  8569. this.fillColor = "#000000";
  8570. this.strokeColor = "#000000";
  8571. this.patternFill = false;
  8572. this.fillAlpha = 1;
  8573. this.strokeAlpha = 1;
  8574. this.lineWidth = 1;
  8575. this.activeSMask = null;
  8576. this.transferMaps = null;
  8577. this.startNewPathAndClipBox([0, 0, width, height]);
  8578. }
  8579. clone() {
  8580. const clone = Object.create(this);
  8581. clone.clipBox = this.clipBox.slice();
  8582. return clone;
  8583. }
  8584. setCurrentPoint(x, y) {
  8585. this.x = x;
  8586. this.y = y;
  8587. }
  8588. updatePathMinMax(transform, x, y) {
  8589. [x, y] = _util.Util.applyTransform([x, y], transform);
  8590. this.minX = Math.min(this.minX, x);
  8591. this.minY = Math.min(this.minY, y);
  8592. this.maxX = Math.max(this.maxX, x);
  8593. this.maxY = Math.max(this.maxY, y);
  8594. }
  8595. updateRectMinMax(transform, rect) {
  8596. const p1 = _util.Util.applyTransform(rect, transform);
  8597. const p2 = _util.Util.applyTransform(rect.slice(2), transform);
  8598. this.minX = Math.min(this.minX, p1[0], p2[0]);
  8599. this.minY = Math.min(this.minY, p1[1], p2[1]);
  8600. this.maxX = Math.max(this.maxX, p1[0], p2[0]);
  8601. this.maxY = Math.max(this.maxY, p1[1], p2[1]);
  8602. }
  8603. updateScalingPathMinMax(transform, minMax) {
  8604. _util.Util.scaleMinMax(transform, minMax);
  8605. this.minX = Math.min(this.minX, minMax[0]);
  8606. this.maxX = Math.max(this.maxX, minMax[1]);
  8607. this.minY = Math.min(this.minY, minMax[2]);
  8608. this.maxY = Math.max(this.maxY, minMax[3]);
  8609. }
  8610. updateCurvePathMinMax(transform, x0, y0, x1, y1, x2, y2, x3, y3, minMax) {
  8611. const box = _util.Util.bezierBoundingBox(x0, y0, x1, y1, x2, y2, x3, y3);
  8612. if (minMax) {
  8613. minMax[0] = Math.min(minMax[0], box[0], box[2]);
  8614. minMax[1] = Math.max(minMax[1], box[0], box[2]);
  8615. minMax[2] = Math.min(minMax[2], box[1], box[3]);
  8616. minMax[3] = Math.max(minMax[3], box[1], box[3]);
  8617. return;
  8618. }
  8619. this.updateRectMinMax(transform, box);
  8620. }
  8621. getPathBoundingBox() {
  8622. let pathType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _pattern_helper.PathType.FILL;
  8623. let transform = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  8624. const box = [this.minX, this.minY, this.maxX, this.maxY];
  8625. if (pathType === _pattern_helper.PathType.STROKE) {
  8626. if (!transform) {
  8627. (0, _util.unreachable)("Stroke bounding box must include transform.");
  8628. }
  8629. const scale = _util.Util.singularValueDecompose2dScale(transform);
  8630. const xStrokePad = scale[0] * this.lineWidth / 2;
  8631. const yStrokePad = scale[1] * this.lineWidth / 2;
  8632. box[0] -= xStrokePad;
  8633. box[1] -= yStrokePad;
  8634. box[2] += xStrokePad;
  8635. box[3] += yStrokePad;
  8636. }
  8637. return box;
  8638. }
  8639. updateClipFromPath() {
  8640. const intersect = _util.Util.intersect(this.clipBox, this.getPathBoundingBox());
  8641. this.startNewPathAndClipBox(intersect || [0, 0, 0, 0]);
  8642. }
  8643. isEmptyClip() {
  8644. return this.minX === Infinity;
  8645. }
  8646. startNewPathAndClipBox(box) {
  8647. this.clipBox = box;
  8648. this.minX = Infinity;
  8649. this.minY = Infinity;
  8650. this.maxX = 0;
  8651. this.maxY = 0;
  8652. }
  8653. getClippedPathBoundingBox() {
  8654. let pathType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _pattern_helper.PathType.FILL;
  8655. let transform = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  8656. return _util.Util.intersect(this.clipBox, this.getPathBoundingBox(pathType, transform));
  8657. }
  8658. }
  8659. function putBinaryImageData(ctx, imgData) {
  8660. let transferMaps = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  8661. if (typeof ImageData !== "undefined" && imgData instanceof ImageData) {
  8662. ctx.putImageData(imgData, 0, 0);
  8663. return;
  8664. }
  8665. const height = imgData.height,
  8666. width = imgData.width;
  8667. const partialChunkHeight = height % FULL_CHUNK_HEIGHT;
  8668. const fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
  8669. const totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
  8670. const chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
  8671. let srcPos = 0,
  8672. destPos;
  8673. const src = imgData.data;
  8674. const dest = chunkImgData.data;
  8675. let i, j, thisChunkHeight, elemsInThisChunk;
  8676. let transferMapRed, transferMapGreen, transferMapBlue, transferMapGray;
  8677. if (transferMaps) {
  8678. switch (transferMaps.length) {
  8679. case 1:
  8680. transferMapRed = transferMaps[0];
  8681. transferMapGreen = transferMaps[0];
  8682. transferMapBlue = transferMaps[0];
  8683. transferMapGray = transferMaps[0];
  8684. break;
  8685. case 4:
  8686. transferMapRed = transferMaps[0];
  8687. transferMapGreen = transferMaps[1];
  8688. transferMapBlue = transferMaps[2];
  8689. transferMapGray = transferMaps[3];
  8690. break;
  8691. }
  8692. }
  8693. if (imgData.kind === _util.ImageKind.GRAYSCALE_1BPP) {
  8694. const srcLength = src.byteLength;
  8695. const dest32 = new Uint32Array(dest.buffer, 0, dest.byteLength >> 2);
  8696. const dest32DataLength = dest32.length;
  8697. const fullSrcDiff = width + 7 >> 3;
  8698. let white = 0xffffffff;
  8699. let black = _util.FeatureTest.isLittleEndian ? 0xff000000 : 0x000000ff;
  8700. if (transferMapGray) {
  8701. if (transferMapGray[0] === 0xff && transferMapGray[0xff] === 0) {
  8702. [white, black] = [black, white];
  8703. }
  8704. }
  8705. for (i = 0; i < totalChunks; i++) {
  8706. thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
  8707. destPos = 0;
  8708. for (j = 0; j < thisChunkHeight; j++) {
  8709. const srcDiff = srcLength - srcPos;
  8710. let k = 0;
  8711. const kEnd = srcDiff > fullSrcDiff ? width : srcDiff * 8 - 7;
  8712. const kEndUnrolled = kEnd & ~7;
  8713. let mask = 0;
  8714. let srcByte = 0;
  8715. for (; k < kEndUnrolled; k += 8) {
  8716. srcByte = src[srcPos++];
  8717. dest32[destPos++] = srcByte & 128 ? white : black;
  8718. dest32[destPos++] = srcByte & 64 ? white : black;
  8719. dest32[destPos++] = srcByte & 32 ? white : black;
  8720. dest32[destPos++] = srcByte & 16 ? white : black;
  8721. dest32[destPos++] = srcByte & 8 ? white : black;
  8722. dest32[destPos++] = srcByte & 4 ? white : black;
  8723. dest32[destPos++] = srcByte & 2 ? white : black;
  8724. dest32[destPos++] = srcByte & 1 ? white : black;
  8725. }
  8726. for (; k < kEnd; k++) {
  8727. if (mask === 0) {
  8728. srcByte = src[srcPos++];
  8729. mask = 128;
  8730. }
  8731. dest32[destPos++] = srcByte & mask ? white : black;
  8732. mask >>= 1;
  8733. }
  8734. }
  8735. while (destPos < dest32DataLength) {
  8736. dest32[destPos++] = 0;
  8737. }
  8738. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  8739. }
  8740. } else if (imgData.kind === _util.ImageKind.RGBA_32BPP) {
  8741. const hasTransferMaps = !!(transferMapRed || transferMapGreen || transferMapBlue);
  8742. j = 0;
  8743. elemsInThisChunk = width * FULL_CHUNK_HEIGHT * 4;
  8744. for (i = 0; i < fullChunks; i++) {
  8745. dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
  8746. srcPos += elemsInThisChunk;
  8747. if (hasTransferMaps) {
  8748. for (let k = 0; k < elemsInThisChunk; k += 4) {
  8749. if (transferMapRed) {
  8750. dest[k + 0] = transferMapRed[dest[k + 0]];
  8751. }
  8752. if (transferMapGreen) {
  8753. dest[k + 1] = transferMapGreen[dest[k + 1]];
  8754. }
  8755. if (transferMapBlue) {
  8756. dest[k + 2] = transferMapBlue[dest[k + 2]];
  8757. }
  8758. }
  8759. }
  8760. ctx.putImageData(chunkImgData, 0, j);
  8761. j += FULL_CHUNK_HEIGHT;
  8762. }
  8763. if (i < totalChunks) {
  8764. elemsInThisChunk = width * partialChunkHeight * 4;
  8765. dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
  8766. if (hasTransferMaps) {
  8767. for (let k = 0; k < elemsInThisChunk; k += 4) {
  8768. if (transferMapRed) {
  8769. dest[k + 0] = transferMapRed[dest[k + 0]];
  8770. }
  8771. if (transferMapGreen) {
  8772. dest[k + 1] = transferMapGreen[dest[k + 1]];
  8773. }
  8774. if (transferMapBlue) {
  8775. dest[k + 2] = transferMapBlue[dest[k + 2]];
  8776. }
  8777. }
  8778. }
  8779. ctx.putImageData(chunkImgData, 0, j);
  8780. }
  8781. } else if (imgData.kind === _util.ImageKind.RGB_24BPP) {
  8782. const hasTransferMaps = !!(transferMapRed || transferMapGreen || transferMapBlue);
  8783. thisChunkHeight = FULL_CHUNK_HEIGHT;
  8784. elemsInThisChunk = width * thisChunkHeight;
  8785. for (i = 0; i < totalChunks; i++) {
  8786. if (i >= fullChunks) {
  8787. thisChunkHeight = partialChunkHeight;
  8788. elemsInThisChunk = width * thisChunkHeight;
  8789. }
  8790. destPos = 0;
  8791. for (j = elemsInThisChunk; j--;) {
  8792. dest[destPos++] = src[srcPos++];
  8793. dest[destPos++] = src[srcPos++];
  8794. dest[destPos++] = src[srcPos++];
  8795. dest[destPos++] = 255;
  8796. }
  8797. if (hasTransferMaps) {
  8798. for (let k = 0; k < destPos; k += 4) {
  8799. if (transferMapRed) {
  8800. dest[k + 0] = transferMapRed[dest[k + 0]];
  8801. }
  8802. if (transferMapGreen) {
  8803. dest[k + 1] = transferMapGreen[dest[k + 1]];
  8804. }
  8805. if (transferMapBlue) {
  8806. dest[k + 2] = transferMapBlue[dest[k + 2]];
  8807. }
  8808. }
  8809. }
  8810. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  8811. }
  8812. } else {
  8813. throw new Error(`bad image kind: ${imgData.kind}`);
  8814. }
  8815. }
  8816. function putBinaryImageMask(ctx, imgData) {
  8817. if (imgData.bitmap) {
  8818. ctx.drawImage(imgData.bitmap, 0, 0);
  8819. return;
  8820. }
  8821. const height = imgData.height,
  8822. width = imgData.width;
  8823. const partialChunkHeight = height % FULL_CHUNK_HEIGHT;
  8824. const fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
  8825. const totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
  8826. const chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
  8827. let srcPos = 0;
  8828. const src = imgData.data;
  8829. const dest = chunkImgData.data;
  8830. for (let i = 0; i < totalChunks; i++) {
  8831. const thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
  8832. ({
  8833. srcPos
  8834. } = (0, _image_utils.applyMaskImageData)({
  8835. src,
  8836. srcPos,
  8837. dest,
  8838. width,
  8839. height: thisChunkHeight
  8840. }));
  8841. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  8842. }
  8843. }
  8844. function copyCtxState(sourceCtx, destCtx) {
  8845. const properties = ["strokeStyle", "fillStyle", "fillRule", "globalAlpha", "lineWidth", "lineCap", "lineJoin", "miterLimit", "globalCompositeOperation", "font"];
  8846. for (const property of properties) {
  8847. if (sourceCtx[property] !== undefined) {
  8848. destCtx[property] = sourceCtx[property];
  8849. }
  8850. }
  8851. if (sourceCtx.setLineDash !== undefined) {
  8852. destCtx.setLineDash(sourceCtx.getLineDash());
  8853. destCtx.lineDashOffset = sourceCtx.lineDashOffset;
  8854. }
  8855. }
  8856. function resetCtxToDefault(ctx, foregroundColor) {
  8857. ctx.strokeStyle = ctx.fillStyle = foregroundColor || "#000000";
  8858. ctx.fillRule = "nonzero";
  8859. ctx.globalAlpha = 1;
  8860. ctx.lineWidth = 1;
  8861. ctx.lineCap = "butt";
  8862. ctx.lineJoin = "miter";
  8863. ctx.miterLimit = 10;
  8864. ctx.globalCompositeOperation = "source-over";
  8865. ctx.font = "10px sans-serif";
  8866. if (ctx.setLineDash !== undefined) {
  8867. ctx.setLineDash([]);
  8868. ctx.lineDashOffset = 0;
  8869. }
  8870. }
  8871. function composeSMaskBackdrop(bytes, r0, g0, b0) {
  8872. const length = bytes.length;
  8873. for (let i = 3; i < length; i += 4) {
  8874. const alpha = bytes[i];
  8875. if (alpha === 0) {
  8876. bytes[i - 3] = r0;
  8877. bytes[i - 2] = g0;
  8878. bytes[i - 1] = b0;
  8879. } else if (alpha < 255) {
  8880. const alpha_ = 255 - alpha;
  8881. bytes[i - 3] = bytes[i - 3] * alpha + r0 * alpha_ >> 8;
  8882. bytes[i - 2] = bytes[i - 2] * alpha + g0 * alpha_ >> 8;
  8883. bytes[i - 1] = bytes[i - 1] * alpha + b0 * alpha_ >> 8;
  8884. }
  8885. }
  8886. }
  8887. function composeSMaskAlpha(maskData, layerData, transferMap) {
  8888. const length = maskData.length;
  8889. const scale = 1 / 255;
  8890. for (let i = 3; i < length; i += 4) {
  8891. const alpha = transferMap ? transferMap[maskData[i]] : maskData[i];
  8892. layerData[i] = layerData[i] * alpha * scale | 0;
  8893. }
  8894. }
  8895. function composeSMaskLuminosity(maskData, layerData, transferMap) {
  8896. const length = maskData.length;
  8897. for (let i = 3; i < length; i += 4) {
  8898. const y = maskData[i - 3] * 77 + maskData[i - 2] * 152 + maskData[i - 1] * 28;
  8899. layerData[i] = transferMap ? layerData[i] * transferMap[y >> 8] >> 8 : layerData[i] * y >> 16;
  8900. }
  8901. }
  8902. function genericComposeSMask(maskCtx, layerCtx, width, height, subtype, backdrop, transferMap, layerOffsetX, layerOffsetY, maskOffsetX, maskOffsetY) {
  8903. const hasBackdrop = !!backdrop;
  8904. const r0 = hasBackdrop ? backdrop[0] : 0;
  8905. const g0 = hasBackdrop ? backdrop[1] : 0;
  8906. const b0 = hasBackdrop ? backdrop[2] : 0;
  8907. let composeFn;
  8908. if (subtype === "Luminosity") {
  8909. composeFn = composeSMaskLuminosity;
  8910. } else {
  8911. composeFn = composeSMaskAlpha;
  8912. }
  8913. const PIXELS_TO_PROCESS = 1048576;
  8914. const chunkSize = Math.min(height, Math.ceil(PIXELS_TO_PROCESS / width));
  8915. for (let row = 0; row < height; row += chunkSize) {
  8916. const chunkHeight = Math.min(chunkSize, height - row);
  8917. const maskData = maskCtx.getImageData(layerOffsetX - maskOffsetX, row + (layerOffsetY - maskOffsetY), width, chunkHeight);
  8918. const layerData = layerCtx.getImageData(layerOffsetX, row + layerOffsetY, width, chunkHeight);
  8919. if (hasBackdrop) {
  8920. composeSMaskBackdrop(maskData.data, r0, g0, b0);
  8921. }
  8922. composeFn(maskData.data, layerData.data, transferMap);
  8923. layerCtx.putImageData(layerData, layerOffsetX, row + layerOffsetY);
  8924. }
  8925. }
  8926. function composeSMask(ctx, smask, layerCtx, layerBox) {
  8927. const layerOffsetX = layerBox[0];
  8928. const layerOffsetY = layerBox[1];
  8929. const layerWidth = layerBox[2] - layerOffsetX;
  8930. const layerHeight = layerBox[3] - layerOffsetY;
  8931. if (layerWidth === 0 || layerHeight === 0) {
  8932. return;
  8933. }
  8934. genericComposeSMask(smask.context, layerCtx, layerWidth, layerHeight, smask.subtype, smask.backdrop, smask.transferMap, layerOffsetX, layerOffsetY, smask.offsetX, smask.offsetY);
  8935. ctx.save();
  8936. ctx.globalAlpha = 1;
  8937. ctx.globalCompositeOperation = "source-over";
  8938. ctx.setTransform(1, 0, 0, 1, 0, 0);
  8939. ctx.drawImage(layerCtx.canvas, 0, 0);
  8940. ctx.restore();
  8941. }
  8942. function getImageSmoothingEnabled(transform, interpolate) {
  8943. const scale = _util.Util.singularValueDecompose2dScale(transform);
  8944. scale[0] = Math.fround(scale[0]);
  8945. scale[1] = Math.fround(scale[1]);
  8946. const actualScale = Math.fround((globalThis.devicePixelRatio || 1) * _display_utils.PixelsPerInch.PDF_TO_CSS_UNITS);
  8947. if (interpolate !== undefined) {
  8948. return interpolate;
  8949. } else if (scale[0] <= actualScale || scale[1] <= actualScale) {
  8950. return true;
  8951. }
  8952. return false;
  8953. }
  8954. const LINE_CAP_STYLES = ["butt", "round", "square"];
  8955. const LINE_JOIN_STYLES = ["miter", "round", "bevel"];
  8956. const NORMAL_CLIP = {};
  8957. const EO_CLIP = {};
  8958. var _restoreInitialState = /*#__PURE__*/new WeakSet();
  8959. class CanvasGraphics {
  8960. constructor(canvasCtx, commonObjs, objs, canvasFactory, _ref, annotationCanvasMap, pageColors) {
  8961. let {
  8962. optionalContentConfig,
  8963. markedContentStack = null
  8964. } = _ref;
  8965. _classPrivateMethodInitSpec(this, _restoreInitialState);
  8966. this.ctx = canvasCtx;
  8967. this.current = new CanvasExtraState(this.ctx.canvas.width, this.ctx.canvas.height);
  8968. this.stateStack = [];
  8969. this.pendingClip = null;
  8970. this.pendingEOFill = false;
  8971. this.res = null;
  8972. this.xobjs = null;
  8973. this.commonObjs = commonObjs;
  8974. this.objs = objs;
  8975. this.canvasFactory = canvasFactory;
  8976. this.groupStack = [];
  8977. this.processingType3 = null;
  8978. this.baseTransform = null;
  8979. this.baseTransformStack = [];
  8980. this.groupLevel = 0;
  8981. this.smaskStack = [];
  8982. this.smaskCounter = 0;
  8983. this.tempSMask = null;
  8984. this.suspendedCtx = null;
  8985. this.contentVisible = true;
  8986. this.markedContentStack = markedContentStack || [];
  8987. this.optionalContentConfig = optionalContentConfig;
  8988. this.cachedCanvases = new CachedCanvases(this.canvasFactory);
  8989. this.cachedPatterns = new Map();
  8990. this.annotationCanvasMap = annotationCanvasMap;
  8991. this.viewportScale = 1;
  8992. this.outputScaleX = 1;
  8993. this.outputScaleY = 1;
  8994. this.backgroundColor = (pageColors === null || pageColors === void 0 ? void 0 : pageColors.background) || null;
  8995. this.foregroundColor = (pageColors === null || pageColors === void 0 ? void 0 : pageColors.foreground) || null;
  8996. this._cachedScaleForStroking = null;
  8997. this._cachedGetSinglePixelWidth = null;
  8998. this._cachedBitmapsMap = new Map();
  8999. }
  9000. getObject(data) {
  9001. let fallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  9002. if (typeof data === "string") {
  9003. return data.startsWith("g_") ? this.commonObjs.get(data) : this.objs.get(data);
  9004. }
  9005. return fallback;
  9006. }
  9007. beginDrawing(_ref2) {
  9008. let {
  9009. transform,
  9010. viewport,
  9011. transparency = false,
  9012. background = null
  9013. } = _ref2;
  9014. const width = this.ctx.canvas.width;
  9015. const height = this.ctx.canvas.height;
  9016. const defaultBackgroundColor = background || "#ffffff";
  9017. this.ctx.save();
  9018. if (this.foregroundColor && this.backgroundColor) {
  9019. this.ctx.fillStyle = this.foregroundColor;
  9020. const fg = this.foregroundColor = this.ctx.fillStyle;
  9021. this.ctx.fillStyle = this.backgroundColor;
  9022. const bg = this.backgroundColor = this.ctx.fillStyle;
  9023. let isValidDefaultBg = true;
  9024. let defaultBg = defaultBackgroundColor;
  9025. this.ctx.fillStyle = defaultBackgroundColor;
  9026. defaultBg = this.ctx.fillStyle;
  9027. isValidDefaultBg = typeof defaultBg === "string" && /^#[0-9A-Fa-f]{6}$/.test(defaultBg);
  9028. if (fg === "#000000" && bg === "#ffffff" || fg === bg || !isValidDefaultBg) {
  9029. this.foregroundColor = this.backgroundColor = null;
  9030. } else {
  9031. const [rB, gB, bB] = (0, _display_utils.getRGB)(defaultBg);
  9032. const newComp = x => {
  9033. x /= 255;
  9034. return x <= 0.03928 ? x / 12.92 : ((x + 0.055) / 1.055) ** 2.4;
  9035. };
  9036. const lumB = Math.round(0.2126 * newComp(rB) + 0.7152 * newComp(gB) + 0.0722 * newComp(bB));
  9037. this.selectColor = (r, g, b) => {
  9038. const lumC = 0.2126 * newComp(r) + 0.7152 * newComp(g) + 0.0722 * newComp(b);
  9039. return Math.round(lumC) === lumB ? bg : fg;
  9040. };
  9041. }
  9042. }
  9043. this.ctx.fillStyle = this.backgroundColor || defaultBackgroundColor;
  9044. this.ctx.fillRect(0, 0, width, height);
  9045. this.ctx.restore();
  9046. if (transparency) {
  9047. const transparentCanvas = this.cachedCanvases.getCanvas("transparent", width, height);
  9048. this.compositeCtx = this.ctx;
  9049. this.transparentCanvas = transparentCanvas.canvas;
  9050. this.ctx = transparentCanvas.context;
  9051. this.ctx.save();
  9052. this.ctx.transform(...(0, _display_utils.getCurrentTransform)(this.compositeCtx));
  9053. }
  9054. this.ctx.save();
  9055. resetCtxToDefault(this.ctx, this.foregroundColor);
  9056. if (transform) {
  9057. this.ctx.transform(...transform);
  9058. this.outputScaleX = transform[0];
  9059. this.outputScaleY = transform[0];
  9060. }
  9061. this.ctx.transform(...viewport.transform);
  9062. this.viewportScale = viewport.scale;
  9063. this.baseTransform = (0, _display_utils.getCurrentTransform)(this.ctx);
  9064. }
  9065. executeOperatorList(operatorList, executionStartIdx, continueCallback, stepper) {
  9066. const argsArray = operatorList.argsArray;
  9067. const fnArray = operatorList.fnArray;
  9068. let i = executionStartIdx || 0;
  9069. const argsArrayLen = argsArray.length;
  9070. if (argsArrayLen === i) {
  9071. return i;
  9072. }
  9073. const chunkOperations = argsArrayLen - i > EXECUTION_STEPS && typeof continueCallback === "function";
  9074. const endTime = chunkOperations ? Date.now() + EXECUTION_TIME : 0;
  9075. let steps = 0;
  9076. const commonObjs = this.commonObjs;
  9077. const objs = this.objs;
  9078. let fnId;
  9079. while (true) {
  9080. if (stepper !== undefined && i === stepper.nextBreakPoint) {
  9081. stepper.breakIt(i, continueCallback);
  9082. return i;
  9083. }
  9084. fnId = fnArray[i];
  9085. if (fnId !== _util.OPS.dependency) {
  9086. this[fnId].apply(this, argsArray[i]);
  9087. } else {
  9088. for (const depObjId of argsArray[i]) {
  9089. const objsPool = depObjId.startsWith("g_") ? commonObjs : objs;
  9090. if (!objsPool.has(depObjId)) {
  9091. objsPool.get(depObjId, continueCallback);
  9092. return i;
  9093. }
  9094. }
  9095. }
  9096. i++;
  9097. if (i === argsArrayLen) {
  9098. return i;
  9099. }
  9100. if (chunkOperations && ++steps > EXECUTION_STEPS) {
  9101. if (Date.now() > endTime) {
  9102. continueCallback();
  9103. return i;
  9104. }
  9105. steps = 0;
  9106. }
  9107. }
  9108. }
  9109. endDrawing() {
  9110. _classPrivateMethodGet(this, _restoreInitialState, _restoreInitialState2).call(this);
  9111. this.cachedCanvases.clear();
  9112. this.cachedPatterns.clear();
  9113. for (const cache of this._cachedBitmapsMap.values()) {
  9114. for (const canvas of cache.values()) {
  9115. if (typeof HTMLCanvasElement !== "undefined" && canvas instanceof HTMLCanvasElement) {
  9116. canvas.width = canvas.height = 0;
  9117. }
  9118. }
  9119. cache.clear();
  9120. }
  9121. this._cachedBitmapsMap.clear();
  9122. }
  9123. _scaleImage(img, inverseTransform) {
  9124. const width = img.width;
  9125. const height = img.height;
  9126. let widthScale = Math.max(Math.hypot(inverseTransform[0], inverseTransform[1]), 1);
  9127. let heightScale = Math.max(Math.hypot(inverseTransform[2], inverseTransform[3]), 1);
  9128. let paintWidth = width,
  9129. paintHeight = height;
  9130. let tmpCanvasId = "prescale1";
  9131. let tmpCanvas, tmpCtx;
  9132. while (widthScale > 2 && paintWidth > 1 || heightScale > 2 && paintHeight > 1) {
  9133. let newWidth = paintWidth,
  9134. newHeight = paintHeight;
  9135. if (widthScale > 2 && paintWidth > 1) {
  9136. newWidth = Math.ceil(paintWidth / 2);
  9137. widthScale /= paintWidth / newWidth;
  9138. }
  9139. if (heightScale > 2 && paintHeight > 1) {
  9140. newHeight = Math.ceil(paintHeight / 2);
  9141. heightScale /= paintHeight / newHeight;
  9142. }
  9143. tmpCanvas = this.cachedCanvases.getCanvas(tmpCanvasId, newWidth, newHeight);
  9144. tmpCtx = tmpCanvas.context;
  9145. tmpCtx.clearRect(0, 0, newWidth, newHeight);
  9146. tmpCtx.drawImage(img, 0, 0, paintWidth, paintHeight, 0, 0, newWidth, newHeight);
  9147. img = tmpCanvas.canvas;
  9148. paintWidth = newWidth;
  9149. paintHeight = newHeight;
  9150. tmpCanvasId = tmpCanvasId === "prescale1" ? "prescale2" : "prescale1";
  9151. }
  9152. return {
  9153. img,
  9154. paintWidth,
  9155. paintHeight
  9156. };
  9157. }
  9158. _createMaskCanvas(img) {
  9159. const ctx = this.ctx;
  9160. const {
  9161. width,
  9162. height
  9163. } = img;
  9164. const fillColor = this.current.fillColor;
  9165. const isPatternFill = this.current.patternFill;
  9166. const currentTransform = (0, _display_utils.getCurrentTransform)(ctx);
  9167. let cache, cacheKey, scaled, maskCanvas;
  9168. if ((img.bitmap || img.data) && img.count > 1) {
  9169. const mainKey = img.bitmap || img.data.buffer;
  9170. cacheKey = JSON.stringify(isPatternFill ? currentTransform : [currentTransform.slice(0, 4), fillColor]);
  9171. cache = this._cachedBitmapsMap.get(mainKey);
  9172. if (!cache) {
  9173. cache = new Map();
  9174. this._cachedBitmapsMap.set(mainKey, cache);
  9175. }
  9176. const cachedImage = cache.get(cacheKey);
  9177. if (cachedImage && !isPatternFill) {
  9178. const offsetX = Math.round(Math.min(currentTransform[0], currentTransform[2]) + currentTransform[4]);
  9179. const offsetY = Math.round(Math.min(currentTransform[1], currentTransform[3]) + currentTransform[5]);
  9180. return {
  9181. canvas: cachedImage,
  9182. offsetX,
  9183. offsetY
  9184. };
  9185. }
  9186. scaled = cachedImage;
  9187. }
  9188. if (!scaled) {
  9189. maskCanvas = this.cachedCanvases.getCanvas("maskCanvas", width, height);
  9190. putBinaryImageMask(maskCanvas.context, img);
  9191. }
  9192. let maskToCanvas = _util.Util.transform(currentTransform, [1 / width, 0, 0, -1 / height, 0, 0]);
  9193. maskToCanvas = _util.Util.transform(maskToCanvas, [1, 0, 0, 1, 0, -height]);
  9194. const cord1 = _util.Util.applyTransform([0, 0], maskToCanvas);
  9195. const cord2 = _util.Util.applyTransform([width, height], maskToCanvas);
  9196. const rect = _util.Util.normalizeRect([cord1[0], cord1[1], cord2[0], cord2[1]]);
  9197. const drawnWidth = Math.round(rect[2] - rect[0]) || 1;
  9198. const drawnHeight = Math.round(rect[3] - rect[1]) || 1;
  9199. const fillCanvas = this.cachedCanvases.getCanvas("fillCanvas", drawnWidth, drawnHeight);
  9200. const fillCtx = fillCanvas.context;
  9201. const offsetX = Math.min(cord1[0], cord2[0]);
  9202. const offsetY = Math.min(cord1[1], cord2[1]);
  9203. fillCtx.translate(-offsetX, -offsetY);
  9204. fillCtx.transform(...maskToCanvas);
  9205. if (!scaled) {
  9206. scaled = this._scaleImage(maskCanvas.canvas, (0, _display_utils.getCurrentTransformInverse)(fillCtx));
  9207. scaled = scaled.img;
  9208. if (cache && isPatternFill) {
  9209. cache.set(cacheKey, scaled);
  9210. }
  9211. }
  9212. fillCtx.imageSmoothingEnabled = getImageSmoothingEnabled((0, _display_utils.getCurrentTransform)(fillCtx), img.interpolate);
  9213. drawImageAtIntegerCoords(fillCtx, scaled, 0, 0, scaled.width, scaled.height, 0, 0, width, height);
  9214. fillCtx.globalCompositeOperation = "source-in";
  9215. const inverse = _util.Util.transform((0, _display_utils.getCurrentTransformInverse)(fillCtx), [1, 0, 0, 1, -offsetX, -offsetY]);
  9216. fillCtx.fillStyle = isPatternFill ? fillColor.getPattern(ctx, this, inverse, _pattern_helper.PathType.FILL) : fillColor;
  9217. fillCtx.fillRect(0, 0, width, height);
  9218. if (cache && !isPatternFill) {
  9219. this.cachedCanvases.delete("fillCanvas");
  9220. cache.set(cacheKey, fillCanvas.canvas);
  9221. }
  9222. return {
  9223. canvas: fillCanvas.canvas,
  9224. offsetX: Math.round(offsetX),
  9225. offsetY: Math.round(offsetY)
  9226. };
  9227. }
  9228. setLineWidth(width) {
  9229. if (width !== this.current.lineWidth) {
  9230. this._cachedScaleForStroking = null;
  9231. }
  9232. this.current.lineWidth = width;
  9233. this.ctx.lineWidth = width;
  9234. }
  9235. setLineCap(style) {
  9236. this.ctx.lineCap = LINE_CAP_STYLES[style];
  9237. }
  9238. setLineJoin(style) {
  9239. this.ctx.lineJoin = LINE_JOIN_STYLES[style];
  9240. }
  9241. setMiterLimit(limit) {
  9242. this.ctx.miterLimit = limit;
  9243. }
  9244. setDash(dashArray, dashPhase) {
  9245. const ctx = this.ctx;
  9246. if (ctx.setLineDash !== undefined) {
  9247. ctx.setLineDash(dashArray);
  9248. ctx.lineDashOffset = dashPhase;
  9249. }
  9250. }
  9251. setRenderingIntent(intent) {}
  9252. setFlatness(flatness) {}
  9253. setGState(states) {
  9254. for (const [key, value] of states) {
  9255. switch (key) {
  9256. case "LW":
  9257. this.setLineWidth(value);
  9258. break;
  9259. case "LC":
  9260. this.setLineCap(value);
  9261. break;
  9262. case "LJ":
  9263. this.setLineJoin(value);
  9264. break;
  9265. case "ML":
  9266. this.setMiterLimit(value);
  9267. break;
  9268. case "D":
  9269. this.setDash(value[0], value[1]);
  9270. break;
  9271. case "RI":
  9272. this.setRenderingIntent(value);
  9273. break;
  9274. case "FL":
  9275. this.setFlatness(value);
  9276. break;
  9277. case "Font":
  9278. this.setFont(value[0], value[1]);
  9279. break;
  9280. case "CA":
  9281. this.current.strokeAlpha = value;
  9282. break;
  9283. case "ca":
  9284. this.current.fillAlpha = value;
  9285. this.ctx.globalAlpha = value;
  9286. break;
  9287. case "BM":
  9288. this.ctx.globalCompositeOperation = value;
  9289. break;
  9290. case "SMask":
  9291. this.current.activeSMask = value ? this.tempSMask : null;
  9292. this.tempSMask = null;
  9293. this.checkSMaskState();
  9294. break;
  9295. case "TR":
  9296. this.current.transferMaps = value;
  9297. }
  9298. }
  9299. }
  9300. get inSMaskMode() {
  9301. return !!this.suspendedCtx;
  9302. }
  9303. checkSMaskState() {
  9304. const inSMaskMode = this.inSMaskMode;
  9305. if (this.current.activeSMask && !inSMaskMode) {
  9306. this.beginSMaskMode();
  9307. } else if (!this.current.activeSMask && inSMaskMode) {
  9308. this.endSMaskMode();
  9309. }
  9310. }
  9311. beginSMaskMode() {
  9312. if (this.inSMaskMode) {
  9313. throw new Error("beginSMaskMode called while already in smask mode");
  9314. }
  9315. const drawnWidth = this.ctx.canvas.width;
  9316. const drawnHeight = this.ctx.canvas.height;
  9317. const cacheId = "smaskGroupAt" + this.groupLevel;
  9318. const scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight);
  9319. this.suspendedCtx = this.ctx;
  9320. this.ctx = scratchCanvas.context;
  9321. const ctx = this.ctx;
  9322. ctx.setTransform(...(0, _display_utils.getCurrentTransform)(this.suspendedCtx));
  9323. copyCtxState(this.suspendedCtx, ctx);
  9324. mirrorContextOperations(ctx, this.suspendedCtx);
  9325. this.setGState([["BM", "source-over"], ["ca", 1], ["CA", 1]]);
  9326. }
  9327. endSMaskMode() {
  9328. if (!this.inSMaskMode) {
  9329. throw new Error("endSMaskMode called while not in smask mode");
  9330. }
  9331. this.ctx._removeMirroring();
  9332. copyCtxState(this.ctx, this.suspendedCtx);
  9333. this.ctx = this.suspendedCtx;
  9334. this.suspendedCtx = null;
  9335. }
  9336. compose(dirtyBox) {
  9337. if (!this.current.activeSMask) {
  9338. return;
  9339. }
  9340. if (!dirtyBox) {
  9341. dirtyBox = [0, 0, this.ctx.canvas.width, this.ctx.canvas.height];
  9342. } else {
  9343. dirtyBox[0] = Math.floor(dirtyBox[0]);
  9344. dirtyBox[1] = Math.floor(dirtyBox[1]);
  9345. dirtyBox[2] = Math.ceil(dirtyBox[2]);
  9346. dirtyBox[3] = Math.ceil(dirtyBox[3]);
  9347. }
  9348. const smask = this.current.activeSMask;
  9349. const suspendedCtx = this.suspendedCtx;
  9350. composeSMask(suspendedCtx, smask, this.ctx, dirtyBox);
  9351. this.ctx.save();
  9352. this.ctx.setTransform(1, 0, 0, 1, 0, 0);
  9353. this.ctx.clearRect(0, 0, this.ctx.canvas.width, this.ctx.canvas.height);
  9354. this.ctx.restore();
  9355. }
  9356. save() {
  9357. if (this.inSMaskMode) {
  9358. copyCtxState(this.ctx, this.suspendedCtx);
  9359. this.suspendedCtx.save();
  9360. } else {
  9361. this.ctx.save();
  9362. }
  9363. const old = this.current;
  9364. this.stateStack.push(old);
  9365. this.current = old.clone();
  9366. }
  9367. restore() {
  9368. if (this.stateStack.length === 0 && this.inSMaskMode) {
  9369. this.endSMaskMode();
  9370. }
  9371. if (this.stateStack.length !== 0) {
  9372. this.current = this.stateStack.pop();
  9373. if (this.inSMaskMode) {
  9374. this.suspendedCtx.restore();
  9375. copyCtxState(this.suspendedCtx, this.ctx);
  9376. } else {
  9377. this.ctx.restore();
  9378. }
  9379. this.checkSMaskState();
  9380. this.pendingClip = null;
  9381. this._cachedScaleForStroking = null;
  9382. this._cachedGetSinglePixelWidth = null;
  9383. }
  9384. }
  9385. transform(a, b, c, d, e, f) {
  9386. this.ctx.transform(a, b, c, d, e, f);
  9387. this._cachedScaleForStroking = null;
  9388. this._cachedGetSinglePixelWidth = null;
  9389. }
  9390. constructPath(ops, args, minMax) {
  9391. const ctx = this.ctx;
  9392. const current = this.current;
  9393. let x = current.x,
  9394. y = current.y;
  9395. let startX, startY;
  9396. const currentTransform = (0, _display_utils.getCurrentTransform)(ctx);
  9397. const isScalingMatrix = currentTransform[0] === 0 && currentTransform[3] === 0 || currentTransform[1] === 0 && currentTransform[2] === 0;
  9398. const minMaxForBezier = isScalingMatrix ? minMax.slice(0) : null;
  9399. for (let i = 0, j = 0, ii = ops.length; i < ii; i++) {
  9400. switch (ops[i] | 0) {
  9401. case _util.OPS.rectangle:
  9402. x = args[j++];
  9403. y = args[j++];
  9404. const width = args[j++];
  9405. const height = args[j++];
  9406. const xw = x + width;
  9407. const yh = y + height;
  9408. ctx.moveTo(x, y);
  9409. if (width === 0 || height === 0) {
  9410. ctx.lineTo(xw, yh);
  9411. } else {
  9412. ctx.lineTo(xw, y);
  9413. ctx.lineTo(xw, yh);
  9414. ctx.lineTo(x, yh);
  9415. }
  9416. if (!isScalingMatrix) {
  9417. current.updateRectMinMax(currentTransform, [x, y, xw, yh]);
  9418. }
  9419. ctx.closePath();
  9420. break;
  9421. case _util.OPS.moveTo:
  9422. x = args[j++];
  9423. y = args[j++];
  9424. ctx.moveTo(x, y);
  9425. if (!isScalingMatrix) {
  9426. current.updatePathMinMax(currentTransform, x, y);
  9427. }
  9428. break;
  9429. case _util.OPS.lineTo:
  9430. x = args[j++];
  9431. y = args[j++];
  9432. ctx.lineTo(x, y);
  9433. if (!isScalingMatrix) {
  9434. current.updatePathMinMax(currentTransform, x, y);
  9435. }
  9436. break;
  9437. case _util.OPS.curveTo:
  9438. startX = x;
  9439. startY = y;
  9440. x = args[j + 4];
  9441. y = args[j + 5];
  9442. ctx.bezierCurveTo(args[j], args[j + 1], args[j + 2], args[j + 3], x, y);
  9443. current.updateCurvePathMinMax(currentTransform, startX, startY, args[j], args[j + 1], args[j + 2], args[j + 3], x, y, minMaxForBezier);
  9444. j += 6;
  9445. break;
  9446. case _util.OPS.curveTo2:
  9447. startX = x;
  9448. startY = y;
  9449. ctx.bezierCurveTo(x, y, args[j], args[j + 1], args[j + 2], args[j + 3]);
  9450. current.updateCurvePathMinMax(currentTransform, startX, startY, x, y, args[j], args[j + 1], args[j + 2], args[j + 3], minMaxForBezier);
  9451. x = args[j + 2];
  9452. y = args[j + 3];
  9453. j += 4;
  9454. break;
  9455. case _util.OPS.curveTo3:
  9456. startX = x;
  9457. startY = y;
  9458. x = args[j + 2];
  9459. y = args[j + 3];
  9460. ctx.bezierCurveTo(args[j], args[j + 1], x, y, x, y);
  9461. current.updateCurvePathMinMax(currentTransform, startX, startY, args[j], args[j + 1], x, y, x, y, minMaxForBezier);
  9462. j += 4;
  9463. break;
  9464. case _util.OPS.closePath:
  9465. ctx.closePath();
  9466. break;
  9467. }
  9468. }
  9469. if (isScalingMatrix) {
  9470. current.updateScalingPathMinMax(currentTransform, minMaxForBezier);
  9471. }
  9472. current.setCurrentPoint(x, y);
  9473. }
  9474. closePath() {
  9475. this.ctx.closePath();
  9476. }
  9477. stroke() {
  9478. let consumePath = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  9479. const ctx = this.ctx;
  9480. const strokeColor = this.current.strokeColor;
  9481. ctx.globalAlpha = this.current.strokeAlpha;
  9482. if (this.contentVisible) {
  9483. if (typeof strokeColor === "object" && strokeColor !== null && strokeColor !== void 0 && strokeColor.getPattern) {
  9484. ctx.save();
  9485. ctx.strokeStyle = strokeColor.getPattern(ctx, this, (0, _display_utils.getCurrentTransformInverse)(ctx), _pattern_helper.PathType.STROKE);
  9486. this.rescaleAndStroke(false);
  9487. ctx.restore();
  9488. } else {
  9489. this.rescaleAndStroke(true);
  9490. }
  9491. }
  9492. if (consumePath) {
  9493. this.consumePath(this.current.getClippedPathBoundingBox());
  9494. }
  9495. ctx.globalAlpha = this.current.fillAlpha;
  9496. }
  9497. closeStroke() {
  9498. this.closePath();
  9499. this.stroke();
  9500. }
  9501. fill() {
  9502. let consumePath = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  9503. const ctx = this.ctx;
  9504. const fillColor = this.current.fillColor;
  9505. const isPatternFill = this.current.patternFill;
  9506. let needRestore = false;
  9507. if (isPatternFill) {
  9508. ctx.save();
  9509. ctx.fillStyle = fillColor.getPattern(ctx, this, (0, _display_utils.getCurrentTransformInverse)(ctx), _pattern_helper.PathType.FILL);
  9510. needRestore = true;
  9511. }
  9512. const intersect = this.current.getClippedPathBoundingBox();
  9513. if (this.contentVisible && intersect !== null) {
  9514. if (this.pendingEOFill) {
  9515. ctx.fill("evenodd");
  9516. this.pendingEOFill = false;
  9517. } else {
  9518. ctx.fill();
  9519. }
  9520. }
  9521. if (needRestore) {
  9522. ctx.restore();
  9523. }
  9524. if (consumePath) {
  9525. this.consumePath(intersect);
  9526. }
  9527. }
  9528. eoFill() {
  9529. this.pendingEOFill = true;
  9530. this.fill();
  9531. }
  9532. fillStroke() {
  9533. this.fill(false);
  9534. this.stroke(false);
  9535. this.consumePath();
  9536. }
  9537. eoFillStroke() {
  9538. this.pendingEOFill = true;
  9539. this.fillStroke();
  9540. }
  9541. closeFillStroke() {
  9542. this.closePath();
  9543. this.fillStroke();
  9544. }
  9545. closeEOFillStroke() {
  9546. this.pendingEOFill = true;
  9547. this.closePath();
  9548. this.fillStroke();
  9549. }
  9550. endPath() {
  9551. this.consumePath();
  9552. }
  9553. clip() {
  9554. this.pendingClip = NORMAL_CLIP;
  9555. }
  9556. eoClip() {
  9557. this.pendingClip = EO_CLIP;
  9558. }
  9559. beginText() {
  9560. this.current.textMatrix = _util.IDENTITY_MATRIX;
  9561. this.current.textMatrixScale = 1;
  9562. this.current.x = this.current.lineX = 0;
  9563. this.current.y = this.current.lineY = 0;
  9564. }
  9565. endText() {
  9566. const paths = this.pendingTextPaths;
  9567. const ctx = this.ctx;
  9568. if (paths === undefined) {
  9569. ctx.beginPath();
  9570. return;
  9571. }
  9572. ctx.save();
  9573. ctx.beginPath();
  9574. for (const path of paths) {
  9575. ctx.setTransform(...path.transform);
  9576. ctx.translate(path.x, path.y);
  9577. path.addToPath(ctx, path.fontSize);
  9578. }
  9579. ctx.restore();
  9580. ctx.clip();
  9581. ctx.beginPath();
  9582. delete this.pendingTextPaths;
  9583. }
  9584. setCharSpacing(spacing) {
  9585. this.current.charSpacing = spacing;
  9586. }
  9587. setWordSpacing(spacing) {
  9588. this.current.wordSpacing = spacing;
  9589. }
  9590. setHScale(scale) {
  9591. this.current.textHScale = scale / 100;
  9592. }
  9593. setLeading(leading) {
  9594. this.current.leading = -leading;
  9595. }
  9596. setFont(fontRefName, size) {
  9597. const fontObj = this.commonObjs.get(fontRefName);
  9598. const current = this.current;
  9599. if (!fontObj) {
  9600. throw new Error(`Can't find font for ${fontRefName}`);
  9601. }
  9602. current.fontMatrix = fontObj.fontMatrix || _util.FONT_IDENTITY_MATRIX;
  9603. if (current.fontMatrix[0] === 0 || current.fontMatrix[3] === 0) {
  9604. (0, _util.warn)("Invalid font matrix for font " + fontRefName);
  9605. }
  9606. if (size < 0) {
  9607. size = -size;
  9608. current.fontDirection = -1;
  9609. } else {
  9610. current.fontDirection = 1;
  9611. }
  9612. this.current.font = fontObj;
  9613. this.current.fontSize = size;
  9614. if (fontObj.isType3Font) {
  9615. return;
  9616. }
  9617. const name = fontObj.loadedName || "sans-serif";
  9618. let bold = "normal";
  9619. if (fontObj.black) {
  9620. bold = "900";
  9621. } else if (fontObj.bold) {
  9622. bold = "bold";
  9623. }
  9624. const italic = fontObj.italic ? "italic" : "normal";
  9625. const typeface = `"${name}", ${fontObj.fallbackName}`;
  9626. let browserFontSize = size;
  9627. if (size < MIN_FONT_SIZE) {
  9628. browserFontSize = MIN_FONT_SIZE;
  9629. } else if (size > MAX_FONT_SIZE) {
  9630. browserFontSize = MAX_FONT_SIZE;
  9631. }
  9632. this.current.fontSizeScale = size / browserFontSize;
  9633. this.ctx.font = `${italic} ${bold} ${browserFontSize}px ${typeface}`;
  9634. }
  9635. setTextRenderingMode(mode) {
  9636. this.current.textRenderingMode = mode;
  9637. }
  9638. setTextRise(rise) {
  9639. this.current.textRise = rise;
  9640. }
  9641. moveText(x, y) {
  9642. this.current.x = this.current.lineX += x;
  9643. this.current.y = this.current.lineY += y;
  9644. }
  9645. setLeadingMoveText(x, y) {
  9646. this.setLeading(-y);
  9647. this.moveText(x, y);
  9648. }
  9649. setTextMatrix(a, b, c, d, e, f) {
  9650. this.current.textMatrix = [a, b, c, d, e, f];
  9651. this.current.textMatrixScale = Math.hypot(a, b);
  9652. this.current.x = this.current.lineX = 0;
  9653. this.current.y = this.current.lineY = 0;
  9654. }
  9655. nextLine() {
  9656. this.moveText(0, this.current.leading);
  9657. }
  9658. paintChar(character, x, y, patternTransform) {
  9659. const ctx = this.ctx;
  9660. const current = this.current;
  9661. const font = current.font;
  9662. const textRenderingMode = current.textRenderingMode;
  9663. const fontSize = current.fontSize / current.fontSizeScale;
  9664. const fillStrokeMode = textRenderingMode & _util.TextRenderingMode.FILL_STROKE_MASK;
  9665. const isAddToPathSet = !!(textRenderingMode & _util.TextRenderingMode.ADD_TO_PATH_FLAG);
  9666. const patternFill = current.patternFill && !font.missingFile;
  9667. let addToPath;
  9668. if (font.disableFontFace || isAddToPathSet || patternFill) {
  9669. addToPath = font.getPathGenerator(this.commonObjs, character);
  9670. }
  9671. if (font.disableFontFace || patternFill) {
  9672. ctx.save();
  9673. ctx.translate(x, y);
  9674. ctx.beginPath();
  9675. addToPath(ctx, fontSize);
  9676. if (patternTransform) {
  9677. ctx.setTransform(...patternTransform);
  9678. }
  9679. if (fillStrokeMode === _util.TextRenderingMode.FILL || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
  9680. ctx.fill();
  9681. }
  9682. if (fillStrokeMode === _util.TextRenderingMode.STROKE || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
  9683. ctx.stroke();
  9684. }
  9685. ctx.restore();
  9686. } else {
  9687. if (fillStrokeMode === _util.TextRenderingMode.FILL || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
  9688. ctx.fillText(character, x, y);
  9689. }
  9690. if (fillStrokeMode === _util.TextRenderingMode.STROKE || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
  9691. ctx.strokeText(character, x, y);
  9692. }
  9693. }
  9694. if (isAddToPathSet) {
  9695. const paths = this.pendingTextPaths || (this.pendingTextPaths = []);
  9696. paths.push({
  9697. transform: (0, _display_utils.getCurrentTransform)(ctx),
  9698. x,
  9699. y,
  9700. fontSize,
  9701. addToPath
  9702. });
  9703. }
  9704. }
  9705. get isFontSubpixelAAEnabled() {
  9706. const {
  9707. context: ctx
  9708. } = this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled", 10, 10);
  9709. ctx.scale(1.5, 1);
  9710. ctx.fillText("I", 0, 10);
  9711. const data = ctx.getImageData(0, 0, 10, 10).data;
  9712. let enabled = false;
  9713. for (let i = 3; i < data.length; i += 4) {
  9714. if (data[i] > 0 && data[i] < 255) {
  9715. enabled = true;
  9716. break;
  9717. }
  9718. }
  9719. return (0, _util.shadow)(this, "isFontSubpixelAAEnabled", enabled);
  9720. }
  9721. showText(glyphs) {
  9722. const current = this.current;
  9723. const font = current.font;
  9724. if (font.isType3Font) {
  9725. return this.showType3Text(glyphs);
  9726. }
  9727. const fontSize = current.fontSize;
  9728. if (fontSize === 0) {
  9729. return undefined;
  9730. }
  9731. const ctx = this.ctx;
  9732. const fontSizeScale = current.fontSizeScale;
  9733. const charSpacing = current.charSpacing;
  9734. const wordSpacing = current.wordSpacing;
  9735. const fontDirection = current.fontDirection;
  9736. const textHScale = current.textHScale * fontDirection;
  9737. const glyphsLength = glyphs.length;
  9738. const vertical = font.vertical;
  9739. const spacingDir = vertical ? 1 : -1;
  9740. const defaultVMetrics = font.defaultVMetrics;
  9741. const widthAdvanceScale = fontSize * current.fontMatrix[0];
  9742. const simpleFillText = current.textRenderingMode === _util.TextRenderingMode.FILL && !font.disableFontFace && !current.patternFill;
  9743. ctx.save();
  9744. ctx.transform(...current.textMatrix);
  9745. ctx.translate(current.x, current.y + current.textRise);
  9746. if (fontDirection > 0) {
  9747. ctx.scale(textHScale, -1);
  9748. } else {
  9749. ctx.scale(textHScale, 1);
  9750. }
  9751. let patternTransform;
  9752. if (current.patternFill) {
  9753. ctx.save();
  9754. const pattern = current.fillColor.getPattern(ctx, this, (0, _display_utils.getCurrentTransformInverse)(ctx), _pattern_helper.PathType.FILL);
  9755. patternTransform = (0, _display_utils.getCurrentTransform)(ctx);
  9756. ctx.restore();
  9757. ctx.fillStyle = pattern;
  9758. }
  9759. let lineWidth = current.lineWidth;
  9760. const scale = current.textMatrixScale;
  9761. if (scale === 0 || lineWidth === 0) {
  9762. const fillStrokeMode = current.textRenderingMode & _util.TextRenderingMode.FILL_STROKE_MASK;
  9763. if (fillStrokeMode === _util.TextRenderingMode.STROKE || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
  9764. lineWidth = this.getSinglePixelWidth();
  9765. }
  9766. } else {
  9767. lineWidth /= scale;
  9768. }
  9769. if (fontSizeScale !== 1.0) {
  9770. ctx.scale(fontSizeScale, fontSizeScale);
  9771. lineWidth /= fontSizeScale;
  9772. }
  9773. ctx.lineWidth = lineWidth;
  9774. if (font.isInvalidPDFjsFont) {
  9775. const chars = [];
  9776. let width = 0;
  9777. for (const glyph of glyphs) {
  9778. chars.push(glyph.unicode);
  9779. width += glyph.width;
  9780. }
  9781. ctx.fillText(chars.join(""), 0, 0);
  9782. current.x += width * widthAdvanceScale * textHScale;
  9783. ctx.restore();
  9784. this.compose();
  9785. return undefined;
  9786. }
  9787. let x = 0,
  9788. i;
  9789. for (i = 0; i < glyphsLength; ++i) {
  9790. const glyph = glyphs[i];
  9791. if (typeof glyph === "number") {
  9792. x += spacingDir * glyph * fontSize / 1000;
  9793. continue;
  9794. }
  9795. let restoreNeeded = false;
  9796. const spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  9797. const character = glyph.fontChar;
  9798. const accent = glyph.accent;
  9799. let scaledX, scaledY;
  9800. let width = glyph.width;
  9801. if (vertical) {
  9802. const vmetric = glyph.vmetric || defaultVMetrics;
  9803. const vx = -(glyph.vmetric ? vmetric[1] : width * 0.5) * widthAdvanceScale;
  9804. const vy = vmetric[2] * widthAdvanceScale;
  9805. width = vmetric ? -vmetric[0] : width;
  9806. scaledX = vx / fontSizeScale;
  9807. scaledY = (x + vy) / fontSizeScale;
  9808. } else {
  9809. scaledX = x / fontSizeScale;
  9810. scaledY = 0;
  9811. }
  9812. if (font.remeasure && width > 0) {
  9813. const measuredWidth = ctx.measureText(character).width * 1000 / fontSize * fontSizeScale;
  9814. if (width < measuredWidth && this.isFontSubpixelAAEnabled) {
  9815. const characterScaleX = width / measuredWidth;
  9816. restoreNeeded = true;
  9817. ctx.save();
  9818. ctx.scale(characterScaleX, 1);
  9819. scaledX /= characterScaleX;
  9820. } else if (width !== measuredWidth) {
  9821. scaledX += (width - measuredWidth) / 2000 * fontSize / fontSizeScale;
  9822. }
  9823. }
  9824. if (this.contentVisible && (glyph.isInFont || font.missingFile)) {
  9825. if (simpleFillText && !accent) {
  9826. ctx.fillText(character, scaledX, scaledY);
  9827. } else {
  9828. this.paintChar(character, scaledX, scaledY, patternTransform);
  9829. if (accent) {
  9830. const scaledAccentX = scaledX + fontSize * accent.offset.x / fontSizeScale;
  9831. const scaledAccentY = scaledY - fontSize * accent.offset.y / fontSizeScale;
  9832. this.paintChar(accent.fontChar, scaledAccentX, scaledAccentY, patternTransform);
  9833. }
  9834. }
  9835. }
  9836. let charWidth;
  9837. if (vertical) {
  9838. charWidth = width * widthAdvanceScale - spacing * fontDirection;
  9839. } else {
  9840. charWidth = width * widthAdvanceScale + spacing * fontDirection;
  9841. }
  9842. x += charWidth;
  9843. if (restoreNeeded) {
  9844. ctx.restore();
  9845. }
  9846. }
  9847. if (vertical) {
  9848. current.y -= x;
  9849. } else {
  9850. current.x += x * textHScale;
  9851. }
  9852. ctx.restore();
  9853. this.compose();
  9854. return undefined;
  9855. }
  9856. showType3Text(glyphs) {
  9857. const ctx = this.ctx;
  9858. const current = this.current;
  9859. const font = current.font;
  9860. const fontSize = current.fontSize;
  9861. const fontDirection = current.fontDirection;
  9862. const spacingDir = font.vertical ? 1 : -1;
  9863. const charSpacing = current.charSpacing;
  9864. const wordSpacing = current.wordSpacing;
  9865. const textHScale = current.textHScale * fontDirection;
  9866. const fontMatrix = current.fontMatrix || _util.FONT_IDENTITY_MATRIX;
  9867. const glyphsLength = glyphs.length;
  9868. const isTextInvisible = current.textRenderingMode === _util.TextRenderingMode.INVISIBLE;
  9869. let i, glyph, width, spacingLength;
  9870. if (isTextInvisible || fontSize === 0) {
  9871. return;
  9872. }
  9873. this._cachedScaleForStroking = null;
  9874. this._cachedGetSinglePixelWidth = null;
  9875. ctx.save();
  9876. ctx.transform(...current.textMatrix);
  9877. ctx.translate(current.x, current.y);
  9878. ctx.scale(textHScale, fontDirection);
  9879. for (i = 0; i < glyphsLength; ++i) {
  9880. glyph = glyphs[i];
  9881. if (typeof glyph === "number") {
  9882. spacingLength = spacingDir * glyph * fontSize / 1000;
  9883. this.ctx.translate(spacingLength, 0);
  9884. current.x += spacingLength * textHScale;
  9885. continue;
  9886. }
  9887. const spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  9888. const operatorList = font.charProcOperatorList[glyph.operatorListId];
  9889. if (!operatorList) {
  9890. (0, _util.warn)(`Type3 character "${glyph.operatorListId}" is not available.`);
  9891. continue;
  9892. }
  9893. if (this.contentVisible) {
  9894. this.processingType3 = glyph;
  9895. this.save();
  9896. ctx.scale(fontSize, fontSize);
  9897. ctx.transform(...fontMatrix);
  9898. this.executeOperatorList(operatorList);
  9899. this.restore();
  9900. }
  9901. const transformed = _util.Util.applyTransform([glyph.width, 0], fontMatrix);
  9902. width = transformed[0] * fontSize + spacing;
  9903. ctx.translate(width, 0);
  9904. current.x += width * textHScale;
  9905. }
  9906. ctx.restore();
  9907. this.processingType3 = null;
  9908. }
  9909. setCharWidth(xWidth, yWidth) {}
  9910. setCharWidthAndBounds(xWidth, yWidth, llx, lly, urx, ury) {
  9911. this.ctx.rect(llx, lly, urx - llx, ury - lly);
  9912. this.ctx.clip();
  9913. this.endPath();
  9914. }
  9915. getColorN_Pattern(IR) {
  9916. let pattern;
  9917. if (IR[0] === "TilingPattern") {
  9918. const color = IR[1];
  9919. const baseTransform = this.baseTransform || (0, _display_utils.getCurrentTransform)(this.ctx);
  9920. const canvasGraphicsFactory = {
  9921. createCanvasGraphics: ctx => {
  9922. return new CanvasGraphics(ctx, this.commonObjs, this.objs, this.canvasFactory, {
  9923. optionalContentConfig: this.optionalContentConfig,
  9924. markedContentStack: this.markedContentStack
  9925. });
  9926. }
  9927. };
  9928. pattern = new _pattern_helper.TilingPattern(IR, color, this.ctx, canvasGraphicsFactory, baseTransform);
  9929. } else {
  9930. pattern = this._getPattern(IR[1], IR[2]);
  9931. }
  9932. return pattern;
  9933. }
  9934. setStrokeColorN() {
  9935. this.current.strokeColor = this.getColorN_Pattern(arguments);
  9936. }
  9937. setFillColorN() {
  9938. this.current.fillColor = this.getColorN_Pattern(arguments);
  9939. this.current.patternFill = true;
  9940. }
  9941. setStrokeRGBColor(r, g, b) {
  9942. var _this$selectColor;
  9943. const color = ((_this$selectColor = this.selectColor) === null || _this$selectColor === void 0 ? void 0 : _this$selectColor.call(this, r, g, b)) || _util.Util.makeHexColor(r, g, b);
  9944. this.ctx.strokeStyle = color;
  9945. this.current.strokeColor = color;
  9946. }
  9947. setFillRGBColor(r, g, b) {
  9948. var _this$selectColor2;
  9949. const color = ((_this$selectColor2 = this.selectColor) === null || _this$selectColor2 === void 0 ? void 0 : _this$selectColor2.call(this, r, g, b)) || _util.Util.makeHexColor(r, g, b);
  9950. this.ctx.fillStyle = color;
  9951. this.current.fillColor = color;
  9952. this.current.patternFill = false;
  9953. }
  9954. _getPattern(objId) {
  9955. let matrix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  9956. let pattern;
  9957. if (this.cachedPatterns.has(objId)) {
  9958. pattern = this.cachedPatterns.get(objId);
  9959. } else {
  9960. pattern = (0, _pattern_helper.getShadingPattern)(this.objs.get(objId));
  9961. this.cachedPatterns.set(objId, pattern);
  9962. }
  9963. if (matrix) {
  9964. pattern.matrix = matrix;
  9965. }
  9966. return pattern;
  9967. }
  9968. shadingFill(objId) {
  9969. if (!this.contentVisible) {
  9970. return;
  9971. }
  9972. const ctx = this.ctx;
  9973. this.save();
  9974. const pattern = this._getPattern(objId);
  9975. ctx.fillStyle = pattern.getPattern(ctx, this, (0, _display_utils.getCurrentTransformInverse)(ctx), _pattern_helper.PathType.SHADING);
  9976. const inv = (0, _display_utils.getCurrentTransformInverse)(ctx);
  9977. if (inv) {
  9978. const canvas = ctx.canvas;
  9979. const width = canvas.width;
  9980. const height = canvas.height;
  9981. const bl = _util.Util.applyTransform([0, 0], inv);
  9982. const br = _util.Util.applyTransform([0, height], inv);
  9983. const ul = _util.Util.applyTransform([width, 0], inv);
  9984. const ur = _util.Util.applyTransform([width, height], inv);
  9985. const x0 = Math.min(bl[0], br[0], ul[0], ur[0]);
  9986. const y0 = Math.min(bl[1], br[1], ul[1], ur[1]);
  9987. const x1 = Math.max(bl[0], br[0], ul[0], ur[0]);
  9988. const y1 = Math.max(bl[1], br[1], ul[1], ur[1]);
  9989. this.ctx.fillRect(x0, y0, x1 - x0, y1 - y0);
  9990. } else {
  9991. this.ctx.fillRect(-1e10, -1e10, 2e10, 2e10);
  9992. }
  9993. this.compose(this.current.getClippedPathBoundingBox());
  9994. this.restore();
  9995. }
  9996. beginInlineImage() {
  9997. (0, _util.unreachable)("Should not call beginInlineImage");
  9998. }
  9999. beginImageData() {
  10000. (0, _util.unreachable)("Should not call beginImageData");
  10001. }
  10002. paintFormXObjectBegin(matrix, bbox) {
  10003. if (!this.contentVisible) {
  10004. return;
  10005. }
  10006. this.save();
  10007. this.baseTransformStack.push(this.baseTransform);
  10008. if (Array.isArray(matrix) && matrix.length === 6) {
  10009. this.transform(...matrix);
  10010. }
  10011. this.baseTransform = (0, _display_utils.getCurrentTransform)(this.ctx);
  10012. if (bbox) {
  10013. const width = bbox[2] - bbox[0];
  10014. const height = bbox[3] - bbox[1];
  10015. this.ctx.rect(bbox[0], bbox[1], width, height);
  10016. this.current.updateRectMinMax((0, _display_utils.getCurrentTransform)(this.ctx), bbox);
  10017. this.clip();
  10018. this.endPath();
  10019. }
  10020. }
  10021. paintFormXObjectEnd() {
  10022. if (!this.contentVisible) {
  10023. return;
  10024. }
  10025. this.restore();
  10026. this.baseTransform = this.baseTransformStack.pop();
  10027. }
  10028. beginGroup(group) {
  10029. if (!this.contentVisible) {
  10030. return;
  10031. }
  10032. this.save();
  10033. if (this.inSMaskMode) {
  10034. this.endSMaskMode();
  10035. this.current.activeSMask = null;
  10036. }
  10037. const currentCtx = this.ctx;
  10038. if (!group.isolated) {
  10039. (0, _util.info)("TODO: Support non-isolated groups.");
  10040. }
  10041. if (group.knockout) {
  10042. (0, _util.warn)("Knockout groups not supported.");
  10043. }
  10044. const currentTransform = (0, _display_utils.getCurrentTransform)(currentCtx);
  10045. if (group.matrix) {
  10046. currentCtx.transform(...group.matrix);
  10047. }
  10048. if (!group.bbox) {
  10049. throw new Error("Bounding box is required.");
  10050. }
  10051. let bounds = _util.Util.getAxialAlignedBoundingBox(group.bbox, (0, _display_utils.getCurrentTransform)(currentCtx));
  10052. const canvasBounds = [0, 0, currentCtx.canvas.width, currentCtx.canvas.height];
  10053. bounds = _util.Util.intersect(bounds, canvasBounds) || [0, 0, 0, 0];
  10054. const offsetX = Math.floor(bounds[0]);
  10055. const offsetY = Math.floor(bounds[1]);
  10056. let drawnWidth = Math.max(Math.ceil(bounds[2]) - offsetX, 1);
  10057. let drawnHeight = Math.max(Math.ceil(bounds[3]) - offsetY, 1);
  10058. let scaleX = 1,
  10059. scaleY = 1;
  10060. if (drawnWidth > MAX_GROUP_SIZE) {
  10061. scaleX = drawnWidth / MAX_GROUP_SIZE;
  10062. drawnWidth = MAX_GROUP_SIZE;
  10063. }
  10064. if (drawnHeight > MAX_GROUP_SIZE) {
  10065. scaleY = drawnHeight / MAX_GROUP_SIZE;
  10066. drawnHeight = MAX_GROUP_SIZE;
  10067. }
  10068. this.current.startNewPathAndClipBox([0, 0, drawnWidth, drawnHeight]);
  10069. let cacheId = "groupAt" + this.groupLevel;
  10070. if (group.smask) {
  10071. cacheId += "_smask_" + this.smaskCounter++ % 2;
  10072. }
  10073. const scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight);
  10074. const groupCtx = scratchCanvas.context;
  10075. groupCtx.scale(1 / scaleX, 1 / scaleY);
  10076. groupCtx.translate(-offsetX, -offsetY);
  10077. groupCtx.transform(...currentTransform);
  10078. if (group.smask) {
  10079. this.smaskStack.push({
  10080. canvas: scratchCanvas.canvas,
  10081. context: groupCtx,
  10082. offsetX,
  10083. offsetY,
  10084. scaleX,
  10085. scaleY,
  10086. subtype: group.smask.subtype,
  10087. backdrop: group.smask.backdrop,
  10088. transferMap: group.smask.transferMap || null,
  10089. startTransformInverse: null
  10090. });
  10091. } else {
  10092. currentCtx.setTransform(1, 0, 0, 1, 0, 0);
  10093. currentCtx.translate(offsetX, offsetY);
  10094. currentCtx.scale(scaleX, scaleY);
  10095. currentCtx.save();
  10096. }
  10097. copyCtxState(currentCtx, groupCtx);
  10098. this.ctx = groupCtx;
  10099. this.setGState([["BM", "source-over"], ["ca", 1], ["CA", 1]]);
  10100. this.groupStack.push(currentCtx);
  10101. this.groupLevel++;
  10102. }
  10103. endGroup(group) {
  10104. if (!this.contentVisible) {
  10105. return;
  10106. }
  10107. this.groupLevel--;
  10108. const groupCtx = this.ctx;
  10109. const ctx = this.groupStack.pop();
  10110. this.ctx = ctx;
  10111. this.ctx.imageSmoothingEnabled = false;
  10112. if (group.smask) {
  10113. this.tempSMask = this.smaskStack.pop();
  10114. this.restore();
  10115. } else {
  10116. this.ctx.restore();
  10117. const currentMtx = (0, _display_utils.getCurrentTransform)(this.ctx);
  10118. this.restore();
  10119. this.ctx.save();
  10120. this.ctx.setTransform(...currentMtx);
  10121. const dirtyBox = _util.Util.getAxialAlignedBoundingBox([0, 0, groupCtx.canvas.width, groupCtx.canvas.height], currentMtx);
  10122. this.ctx.drawImage(groupCtx.canvas, 0, 0);
  10123. this.ctx.restore();
  10124. this.compose(dirtyBox);
  10125. }
  10126. }
  10127. beginAnnotation(id, rect, transform, matrix, hasOwnCanvas) {
  10128. _classPrivateMethodGet(this, _restoreInitialState, _restoreInitialState2).call(this);
  10129. resetCtxToDefault(this.ctx, this.foregroundColor);
  10130. this.ctx.save();
  10131. this.save();
  10132. if (this.baseTransform) {
  10133. this.ctx.setTransform(...this.baseTransform);
  10134. }
  10135. if (Array.isArray(rect) && rect.length === 4) {
  10136. const width = rect[2] - rect[0];
  10137. const height = rect[3] - rect[1];
  10138. if (hasOwnCanvas && this.annotationCanvasMap) {
  10139. transform = transform.slice();
  10140. transform[4] -= rect[0];
  10141. transform[5] -= rect[1];
  10142. rect = rect.slice();
  10143. rect[0] = rect[1] = 0;
  10144. rect[2] = width;
  10145. rect[3] = height;
  10146. const [scaleX, scaleY] = _util.Util.singularValueDecompose2dScale((0, _display_utils.getCurrentTransform)(this.ctx));
  10147. const {
  10148. viewportScale
  10149. } = this;
  10150. const canvasWidth = Math.ceil(width * this.outputScaleX * viewportScale);
  10151. const canvasHeight = Math.ceil(height * this.outputScaleY * viewportScale);
  10152. this.annotationCanvas = this.canvasFactory.create(canvasWidth, canvasHeight);
  10153. const {
  10154. canvas,
  10155. context
  10156. } = this.annotationCanvas;
  10157. this.annotationCanvasMap.set(id, canvas);
  10158. this.annotationCanvas.savedCtx = this.ctx;
  10159. this.ctx = context;
  10160. this.ctx.setTransform(scaleX, 0, 0, -scaleY, 0, height * scaleY);
  10161. resetCtxToDefault(this.ctx, this.foregroundColor);
  10162. } else {
  10163. resetCtxToDefault(this.ctx, this.foregroundColor);
  10164. this.ctx.rect(rect[0], rect[1], width, height);
  10165. this.ctx.clip();
  10166. this.endPath();
  10167. }
  10168. }
  10169. this.current = new CanvasExtraState(this.ctx.canvas.width, this.ctx.canvas.height);
  10170. this.transform(...transform);
  10171. this.transform(...matrix);
  10172. }
  10173. endAnnotation() {
  10174. if (this.annotationCanvas) {
  10175. this.ctx = this.annotationCanvas.savedCtx;
  10176. delete this.annotationCanvas.savedCtx;
  10177. delete this.annotationCanvas;
  10178. }
  10179. }
  10180. paintImageMaskXObject(img) {
  10181. if (!this.contentVisible) {
  10182. return;
  10183. }
  10184. const count = img.count;
  10185. img = this.getObject(img.data, img);
  10186. img.count = count;
  10187. const ctx = this.ctx;
  10188. const glyph = this.processingType3;
  10189. if (glyph) {
  10190. if (glyph.compiled === undefined) {
  10191. glyph.compiled = compileType3Glyph(img);
  10192. }
  10193. if (glyph.compiled) {
  10194. glyph.compiled(ctx);
  10195. return;
  10196. }
  10197. }
  10198. const mask = this._createMaskCanvas(img);
  10199. const maskCanvas = mask.canvas;
  10200. ctx.save();
  10201. ctx.setTransform(1, 0, 0, 1, 0, 0);
  10202. ctx.drawImage(maskCanvas, mask.offsetX, mask.offsetY);
  10203. ctx.restore();
  10204. this.compose();
  10205. }
  10206. paintImageMaskXObjectRepeat(img, scaleX) {
  10207. let skewX = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
  10208. let skewY = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
  10209. let scaleY = arguments.length > 4 ? arguments[4] : undefined;
  10210. let positions = arguments.length > 5 ? arguments[5] : undefined;
  10211. if (!this.contentVisible) {
  10212. return;
  10213. }
  10214. img = this.getObject(img.data, img);
  10215. const ctx = this.ctx;
  10216. ctx.save();
  10217. const currentTransform = (0, _display_utils.getCurrentTransform)(ctx);
  10218. ctx.transform(scaleX, skewX, skewY, scaleY, 0, 0);
  10219. const mask = this._createMaskCanvas(img);
  10220. ctx.setTransform(1, 0, 0, 1, mask.offsetX - currentTransform[4], mask.offsetY - currentTransform[5]);
  10221. for (let i = 0, ii = positions.length; i < ii; i += 2) {
  10222. const trans = _util.Util.transform(currentTransform, [scaleX, skewX, skewY, scaleY, positions[i], positions[i + 1]]);
  10223. const [x, y] = _util.Util.applyTransform([0, 0], trans);
  10224. ctx.drawImage(mask.canvas, x, y);
  10225. }
  10226. ctx.restore();
  10227. this.compose();
  10228. }
  10229. paintImageMaskXObjectGroup(images) {
  10230. if (!this.contentVisible) {
  10231. return;
  10232. }
  10233. const ctx = this.ctx;
  10234. const fillColor = this.current.fillColor;
  10235. const isPatternFill = this.current.patternFill;
  10236. for (const image of images) {
  10237. const {
  10238. data,
  10239. width,
  10240. height,
  10241. transform
  10242. } = image;
  10243. const maskCanvas = this.cachedCanvases.getCanvas("maskCanvas", width, height);
  10244. const maskCtx = maskCanvas.context;
  10245. maskCtx.save();
  10246. const img = this.getObject(data, image);
  10247. putBinaryImageMask(maskCtx, img);
  10248. maskCtx.globalCompositeOperation = "source-in";
  10249. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this, (0, _display_utils.getCurrentTransformInverse)(ctx), _pattern_helper.PathType.FILL) : fillColor;
  10250. maskCtx.fillRect(0, 0, width, height);
  10251. maskCtx.restore();
  10252. ctx.save();
  10253. ctx.transform(...transform);
  10254. ctx.scale(1, -1);
  10255. drawImageAtIntegerCoords(ctx, maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
  10256. ctx.restore();
  10257. }
  10258. this.compose();
  10259. }
  10260. paintImageXObject(objId) {
  10261. if (!this.contentVisible) {
  10262. return;
  10263. }
  10264. const imgData = this.getObject(objId);
  10265. if (!imgData) {
  10266. (0, _util.warn)("Dependent image isn't ready yet");
  10267. return;
  10268. }
  10269. this.paintInlineImageXObject(imgData);
  10270. }
  10271. paintImageXObjectRepeat(objId, scaleX, scaleY, positions) {
  10272. if (!this.contentVisible) {
  10273. return;
  10274. }
  10275. const imgData = this.getObject(objId);
  10276. if (!imgData) {
  10277. (0, _util.warn)("Dependent image isn't ready yet");
  10278. return;
  10279. }
  10280. const width = imgData.width;
  10281. const height = imgData.height;
  10282. const map = [];
  10283. for (let i = 0, ii = positions.length; i < ii; i += 2) {
  10284. map.push({
  10285. transform: [scaleX, 0, 0, scaleY, positions[i], positions[i + 1]],
  10286. x: 0,
  10287. y: 0,
  10288. w: width,
  10289. h: height
  10290. });
  10291. }
  10292. this.paintInlineImageXObjectGroup(imgData, map);
  10293. }
  10294. paintInlineImageXObject(imgData) {
  10295. if (!this.contentVisible) {
  10296. return;
  10297. }
  10298. const width = imgData.width;
  10299. const height = imgData.height;
  10300. const ctx = this.ctx;
  10301. this.save();
  10302. ctx.scale(1 / width, -1 / height);
  10303. let imgToPaint;
  10304. if (typeof HTMLElement === "function" && imgData instanceof HTMLElement || !imgData.data) {
  10305. imgToPaint = imgData;
  10306. } else {
  10307. const tmpCanvas = this.cachedCanvases.getCanvas("inlineImage", width, height);
  10308. const tmpCtx = tmpCanvas.context;
  10309. putBinaryImageData(tmpCtx, imgData, this.current.transferMaps);
  10310. imgToPaint = tmpCanvas.canvas;
  10311. }
  10312. const scaled = this._scaleImage(imgToPaint, (0, _display_utils.getCurrentTransformInverse)(ctx));
  10313. ctx.imageSmoothingEnabled = getImageSmoothingEnabled((0, _display_utils.getCurrentTransform)(ctx), imgData.interpolate);
  10314. drawImageAtIntegerCoords(ctx, scaled.img, 0, 0, scaled.paintWidth, scaled.paintHeight, 0, -height, width, height);
  10315. this.compose();
  10316. this.restore();
  10317. }
  10318. paintInlineImageXObjectGroup(imgData, map) {
  10319. if (!this.contentVisible) {
  10320. return;
  10321. }
  10322. const ctx = this.ctx;
  10323. const w = imgData.width;
  10324. const h = imgData.height;
  10325. const tmpCanvas = this.cachedCanvases.getCanvas("inlineImage", w, h);
  10326. const tmpCtx = tmpCanvas.context;
  10327. putBinaryImageData(tmpCtx, imgData, this.current.transferMaps);
  10328. for (const entry of map) {
  10329. ctx.save();
  10330. ctx.transform(...entry.transform);
  10331. ctx.scale(1, -1);
  10332. drawImageAtIntegerCoords(ctx, tmpCanvas.canvas, entry.x, entry.y, entry.w, entry.h, 0, -1, 1, 1);
  10333. ctx.restore();
  10334. }
  10335. this.compose();
  10336. }
  10337. paintSolidColorImageMask() {
  10338. if (!this.contentVisible) {
  10339. return;
  10340. }
  10341. this.ctx.fillRect(0, 0, 1, 1);
  10342. this.compose();
  10343. }
  10344. markPoint(tag) {}
  10345. markPointProps(tag, properties) {}
  10346. beginMarkedContent(tag) {
  10347. this.markedContentStack.push({
  10348. visible: true
  10349. });
  10350. }
  10351. beginMarkedContentProps(tag, properties) {
  10352. if (tag === "OC") {
  10353. this.markedContentStack.push({
  10354. visible: this.optionalContentConfig.isVisible(properties)
  10355. });
  10356. } else {
  10357. this.markedContentStack.push({
  10358. visible: true
  10359. });
  10360. }
  10361. this.contentVisible = this.isContentVisible();
  10362. }
  10363. endMarkedContent() {
  10364. this.markedContentStack.pop();
  10365. this.contentVisible = this.isContentVisible();
  10366. }
  10367. beginCompat() {}
  10368. endCompat() {}
  10369. consumePath(clipBox) {
  10370. const isEmpty = this.current.isEmptyClip();
  10371. if (this.pendingClip) {
  10372. this.current.updateClipFromPath();
  10373. }
  10374. if (!this.pendingClip) {
  10375. this.compose(clipBox);
  10376. }
  10377. const ctx = this.ctx;
  10378. if (this.pendingClip) {
  10379. if (!isEmpty) {
  10380. if (this.pendingClip === EO_CLIP) {
  10381. ctx.clip("evenodd");
  10382. } else {
  10383. ctx.clip();
  10384. }
  10385. }
  10386. this.pendingClip = null;
  10387. }
  10388. this.current.startNewPathAndClipBox(this.current.clipBox);
  10389. ctx.beginPath();
  10390. }
  10391. getSinglePixelWidth() {
  10392. if (!this._cachedGetSinglePixelWidth) {
  10393. const m = (0, _display_utils.getCurrentTransform)(this.ctx);
  10394. if (m[1] === 0 && m[2] === 0) {
  10395. this._cachedGetSinglePixelWidth = 1 / Math.min(Math.abs(m[0]), Math.abs(m[3]));
  10396. } else {
  10397. const absDet = Math.abs(m[0] * m[3] - m[2] * m[1]);
  10398. const normX = Math.hypot(m[0], m[2]);
  10399. const normY = Math.hypot(m[1], m[3]);
  10400. this._cachedGetSinglePixelWidth = Math.max(normX, normY) / absDet;
  10401. }
  10402. }
  10403. return this._cachedGetSinglePixelWidth;
  10404. }
  10405. getScaleForStroking() {
  10406. if (!this._cachedScaleForStroking) {
  10407. const {
  10408. lineWidth
  10409. } = this.current;
  10410. const m = (0, _display_utils.getCurrentTransform)(this.ctx);
  10411. let scaleX, scaleY;
  10412. if (m[1] === 0 && m[2] === 0) {
  10413. const normX = Math.abs(m[0]);
  10414. const normY = Math.abs(m[3]);
  10415. if (lineWidth === 0) {
  10416. scaleX = 1 / normX;
  10417. scaleY = 1 / normY;
  10418. } else {
  10419. const scaledXLineWidth = normX * lineWidth;
  10420. const scaledYLineWidth = normY * lineWidth;
  10421. scaleX = scaledXLineWidth < 1 ? 1 / scaledXLineWidth : 1;
  10422. scaleY = scaledYLineWidth < 1 ? 1 / scaledYLineWidth : 1;
  10423. }
  10424. } else {
  10425. const absDet = Math.abs(m[0] * m[3] - m[2] * m[1]);
  10426. const normX = Math.hypot(m[0], m[1]);
  10427. const normY = Math.hypot(m[2], m[3]);
  10428. if (lineWidth === 0) {
  10429. scaleX = normY / absDet;
  10430. scaleY = normX / absDet;
  10431. } else {
  10432. const baseArea = lineWidth * absDet;
  10433. scaleX = normY > baseArea ? normY / baseArea : 1;
  10434. scaleY = normX > baseArea ? normX / baseArea : 1;
  10435. }
  10436. }
  10437. this._cachedScaleForStroking = [scaleX, scaleY];
  10438. }
  10439. return this._cachedScaleForStroking;
  10440. }
  10441. rescaleAndStroke(saveRestore) {
  10442. const {
  10443. ctx
  10444. } = this;
  10445. const {
  10446. lineWidth
  10447. } = this.current;
  10448. const [scaleX, scaleY] = this.getScaleForStroking();
  10449. ctx.lineWidth = lineWidth || 1;
  10450. if (scaleX === 1 && scaleY === 1) {
  10451. ctx.stroke();
  10452. return;
  10453. }
  10454. let savedMatrix, savedDashes, savedDashOffset;
  10455. if (saveRestore) {
  10456. savedMatrix = (0, _display_utils.getCurrentTransform)(ctx);
  10457. savedDashes = ctx.getLineDash().slice();
  10458. savedDashOffset = ctx.lineDashOffset;
  10459. }
  10460. ctx.scale(scaleX, scaleY);
  10461. const scale = Math.max(scaleX, scaleY);
  10462. ctx.setLineDash(ctx.getLineDash().map(x => x / scale));
  10463. ctx.lineDashOffset /= scale;
  10464. ctx.stroke();
  10465. if (saveRestore) {
  10466. ctx.setTransform(...savedMatrix);
  10467. ctx.setLineDash(savedDashes);
  10468. ctx.lineDashOffset = savedDashOffset;
  10469. }
  10470. }
  10471. isContentVisible() {
  10472. for (let i = this.markedContentStack.length - 1; i >= 0; i--) {
  10473. if (!this.markedContentStack[i].visible) {
  10474. return false;
  10475. }
  10476. }
  10477. return true;
  10478. }
  10479. }
  10480. exports.CanvasGraphics = CanvasGraphics;
  10481. function _restoreInitialState2() {
  10482. while (this.stateStack.length || this.inSMaskMode) {
  10483. this.restore();
  10484. }
  10485. this.ctx.restore();
  10486. if (this.transparentCanvas) {
  10487. this.ctx = this.compositeCtx;
  10488. this.ctx.save();
  10489. this.ctx.setTransform(1, 0, 0, 1, 0, 0);
  10490. this.ctx.drawImage(this.transparentCanvas, 0, 0);
  10491. this.ctx.restore();
  10492. this.transparentCanvas = null;
  10493. }
  10494. }
  10495. for (const op in _util.OPS) {
  10496. if (CanvasGraphics.prototype[op] !== undefined) {
  10497. CanvasGraphics.prototype[_util.OPS[op]] = CanvasGraphics.prototype[op];
  10498. }
  10499. }
  10500. /***/ }),
  10501. /* 144 */
  10502. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  10503. "use strict";
  10504. Object.defineProperty(exports, "__esModule", ({
  10505. value: true
  10506. }));
  10507. exports.TilingPattern = exports.PathType = void 0;
  10508. exports.getShadingPattern = getShadingPattern;
  10509. var _util = __w_pdfjs_require__(1);
  10510. var _display_utils = __w_pdfjs_require__(139);
  10511. const PathType = {
  10512. FILL: "Fill",
  10513. STROKE: "Stroke",
  10514. SHADING: "Shading"
  10515. };
  10516. exports.PathType = PathType;
  10517. function applyBoundingBox(ctx, bbox) {
  10518. if (!bbox) {
  10519. return;
  10520. }
  10521. const width = bbox[2] - bbox[0];
  10522. const height = bbox[3] - bbox[1];
  10523. const region = new Path2D();
  10524. region.rect(bbox[0], bbox[1], width, height);
  10525. ctx.clip(region);
  10526. }
  10527. class BaseShadingPattern {
  10528. constructor() {
  10529. if (this.constructor === BaseShadingPattern) {
  10530. (0, _util.unreachable)("Cannot initialize BaseShadingPattern.");
  10531. }
  10532. }
  10533. getPattern() {
  10534. (0, _util.unreachable)("Abstract method `getPattern` called.");
  10535. }
  10536. }
  10537. class RadialAxialShadingPattern extends BaseShadingPattern {
  10538. constructor(IR) {
  10539. super();
  10540. this._type = IR[1];
  10541. this._bbox = IR[2];
  10542. this._colorStops = IR[3];
  10543. this._p0 = IR[4];
  10544. this._p1 = IR[5];
  10545. this._r0 = IR[6];
  10546. this._r1 = IR[7];
  10547. this.matrix = null;
  10548. }
  10549. _createGradient(ctx) {
  10550. let grad;
  10551. if (this._type === "axial") {
  10552. grad = ctx.createLinearGradient(this._p0[0], this._p0[1], this._p1[0], this._p1[1]);
  10553. } else if (this._type === "radial") {
  10554. grad = ctx.createRadialGradient(this._p0[0], this._p0[1], this._r0, this._p1[0], this._p1[1], this._r1);
  10555. }
  10556. for (const colorStop of this._colorStops) {
  10557. grad.addColorStop(colorStop[0], colorStop[1]);
  10558. }
  10559. return grad;
  10560. }
  10561. getPattern(ctx, owner, inverse, pathType) {
  10562. let pattern;
  10563. if (pathType === PathType.STROKE || pathType === PathType.FILL) {
  10564. const ownerBBox = owner.current.getClippedPathBoundingBox(pathType, (0, _display_utils.getCurrentTransform)(ctx)) || [0, 0, 0, 0];
  10565. const width = Math.ceil(ownerBBox[2] - ownerBBox[0]) || 1;
  10566. const height = Math.ceil(ownerBBox[3] - ownerBBox[1]) || 1;
  10567. const tmpCanvas = owner.cachedCanvases.getCanvas("pattern", width, height, true);
  10568. const tmpCtx = tmpCanvas.context;
  10569. tmpCtx.clearRect(0, 0, tmpCtx.canvas.width, tmpCtx.canvas.height);
  10570. tmpCtx.beginPath();
  10571. tmpCtx.rect(0, 0, tmpCtx.canvas.width, tmpCtx.canvas.height);
  10572. tmpCtx.translate(-ownerBBox[0], -ownerBBox[1]);
  10573. inverse = _util.Util.transform(inverse, [1, 0, 0, 1, ownerBBox[0], ownerBBox[1]]);
  10574. tmpCtx.transform(...owner.baseTransform);
  10575. if (this.matrix) {
  10576. tmpCtx.transform(...this.matrix);
  10577. }
  10578. applyBoundingBox(tmpCtx, this._bbox);
  10579. tmpCtx.fillStyle = this._createGradient(tmpCtx);
  10580. tmpCtx.fill();
  10581. pattern = ctx.createPattern(tmpCanvas.canvas, "no-repeat");
  10582. const domMatrix = new DOMMatrix(inverse);
  10583. pattern.setTransform(domMatrix);
  10584. } else {
  10585. applyBoundingBox(ctx, this._bbox);
  10586. pattern = this._createGradient(ctx);
  10587. }
  10588. return pattern;
  10589. }
  10590. }
  10591. function drawTriangle(data, context, p1, p2, p3, c1, c2, c3) {
  10592. const coords = context.coords,
  10593. colors = context.colors;
  10594. const bytes = data.data,
  10595. rowSize = data.width * 4;
  10596. let tmp;
  10597. if (coords[p1 + 1] > coords[p2 + 1]) {
  10598. tmp = p1;
  10599. p1 = p2;
  10600. p2 = tmp;
  10601. tmp = c1;
  10602. c1 = c2;
  10603. c2 = tmp;
  10604. }
  10605. if (coords[p2 + 1] > coords[p3 + 1]) {
  10606. tmp = p2;
  10607. p2 = p3;
  10608. p3 = tmp;
  10609. tmp = c2;
  10610. c2 = c3;
  10611. c3 = tmp;
  10612. }
  10613. if (coords[p1 + 1] > coords[p2 + 1]) {
  10614. tmp = p1;
  10615. p1 = p2;
  10616. p2 = tmp;
  10617. tmp = c1;
  10618. c1 = c2;
  10619. c2 = tmp;
  10620. }
  10621. const x1 = (coords[p1] + context.offsetX) * context.scaleX;
  10622. const y1 = (coords[p1 + 1] + context.offsetY) * context.scaleY;
  10623. const x2 = (coords[p2] + context.offsetX) * context.scaleX;
  10624. const y2 = (coords[p2 + 1] + context.offsetY) * context.scaleY;
  10625. const x3 = (coords[p3] + context.offsetX) * context.scaleX;
  10626. const y3 = (coords[p3 + 1] + context.offsetY) * context.scaleY;
  10627. if (y1 >= y3) {
  10628. return;
  10629. }
  10630. const c1r = colors[c1],
  10631. c1g = colors[c1 + 1],
  10632. c1b = colors[c1 + 2];
  10633. const c2r = colors[c2],
  10634. c2g = colors[c2 + 1],
  10635. c2b = colors[c2 + 2];
  10636. const c3r = colors[c3],
  10637. c3g = colors[c3 + 1],
  10638. c3b = colors[c3 + 2];
  10639. const minY = Math.round(y1),
  10640. maxY = Math.round(y3);
  10641. let xa, car, cag, cab;
  10642. let xb, cbr, cbg, cbb;
  10643. for (let y = minY; y <= maxY; y++) {
  10644. if (y < y2) {
  10645. let k;
  10646. if (y < y1) {
  10647. k = 0;
  10648. } else {
  10649. k = (y1 - y) / (y1 - y2);
  10650. }
  10651. xa = x1 - (x1 - x2) * k;
  10652. car = c1r - (c1r - c2r) * k;
  10653. cag = c1g - (c1g - c2g) * k;
  10654. cab = c1b - (c1b - c2b) * k;
  10655. } else {
  10656. let k;
  10657. if (y > y3) {
  10658. k = 1;
  10659. } else if (y2 === y3) {
  10660. k = 0;
  10661. } else {
  10662. k = (y2 - y) / (y2 - y3);
  10663. }
  10664. xa = x2 - (x2 - x3) * k;
  10665. car = c2r - (c2r - c3r) * k;
  10666. cag = c2g - (c2g - c3g) * k;
  10667. cab = c2b - (c2b - c3b) * k;
  10668. }
  10669. let k;
  10670. if (y < y1) {
  10671. k = 0;
  10672. } else if (y > y3) {
  10673. k = 1;
  10674. } else {
  10675. k = (y1 - y) / (y1 - y3);
  10676. }
  10677. xb = x1 - (x1 - x3) * k;
  10678. cbr = c1r - (c1r - c3r) * k;
  10679. cbg = c1g - (c1g - c3g) * k;
  10680. cbb = c1b - (c1b - c3b) * k;
  10681. const x1_ = Math.round(Math.min(xa, xb));
  10682. const x2_ = Math.round(Math.max(xa, xb));
  10683. let j = rowSize * y + x1_ * 4;
  10684. for (let x = x1_; x <= x2_; x++) {
  10685. k = (xa - x) / (xa - xb);
  10686. if (k < 0) {
  10687. k = 0;
  10688. } else if (k > 1) {
  10689. k = 1;
  10690. }
  10691. bytes[j++] = car - (car - cbr) * k | 0;
  10692. bytes[j++] = cag - (cag - cbg) * k | 0;
  10693. bytes[j++] = cab - (cab - cbb) * k | 0;
  10694. bytes[j++] = 255;
  10695. }
  10696. }
  10697. }
  10698. function drawFigure(data, figure, context) {
  10699. const ps = figure.coords;
  10700. const cs = figure.colors;
  10701. let i, ii;
  10702. switch (figure.type) {
  10703. case "lattice":
  10704. const verticesPerRow = figure.verticesPerRow;
  10705. const rows = Math.floor(ps.length / verticesPerRow) - 1;
  10706. const cols = verticesPerRow - 1;
  10707. for (i = 0; i < rows; i++) {
  10708. let q = i * verticesPerRow;
  10709. for (let j = 0; j < cols; j++, q++) {
  10710. drawTriangle(data, context, ps[q], ps[q + 1], ps[q + verticesPerRow], cs[q], cs[q + 1], cs[q + verticesPerRow]);
  10711. drawTriangle(data, context, ps[q + verticesPerRow + 1], ps[q + 1], ps[q + verticesPerRow], cs[q + verticesPerRow + 1], cs[q + 1], cs[q + verticesPerRow]);
  10712. }
  10713. }
  10714. break;
  10715. case "triangles":
  10716. for (i = 0, ii = ps.length; i < ii; i += 3) {
  10717. drawTriangle(data, context, ps[i], ps[i + 1], ps[i + 2], cs[i], cs[i + 1], cs[i + 2]);
  10718. }
  10719. break;
  10720. default:
  10721. throw new Error("illegal figure");
  10722. }
  10723. }
  10724. class MeshShadingPattern extends BaseShadingPattern {
  10725. constructor(IR) {
  10726. super();
  10727. this._coords = IR[2];
  10728. this._colors = IR[3];
  10729. this._figures = IR[4];
  10730. this._bounds = IR[5];
  10731. this._bbox = IR[7];
  10732. this._background = IR[8];
  10733. this.matrix = null;
  10734. }
  10735. _createMeshCanvas(combinedScale, backgroundColor, cachedCanvases) {
  10736. const EXPECTED_SCALE = 1.1;
  10737. const MAX_PATTERN_SIZE = 3000;
  10738. const BORDER_SIZE = 2;
  10739. const offsetX = Math.floor(this._bounds[0]);
  10740. const offsetY = Math.floor(this._bounds[1]);
  10741. const boundsWidth = Math.ceil(this._bounds[2]) - offsetX;
  10742. const boundsHeight = Math.ceil(this._bounds[3]) - offsetY;
  10743. const width = Math.min(Math.ceil(Math.abs(boundsWidth * combinedScale[0] * EXPECTED_SCALE)), MAX_PATTERN_SIZE);
  10744. const height = Math.min(Math.ceil(Math.abs(boundsHeight * combinedScale[1] * EXPECTED_SCALE)), MAX_PATTERN_SIZE);
  10745. const scaleX = boundsWidth / width;
  10746. const scaleY = boundsHeight / height;
  10747. const context = {
  10748. coords: this._coords,
  10749. colors: this._colors,
  10750. offsetX: -offsetX,
  10751. offsetY: -offsetY,
  10752. scaleX: 1 / scaleX,
  10753. scaleY: 1 / scaleY
  10754. };
  10755. const paddedWidth = width + BORDER_SIZE * 2;
  10756. const paddedHeight = height + BORDER_SIZE * 2;
  10757. const tmpCanvas = cachedCanvases.getCanvas("mesh", paddedWidth, paddedHeight, false);
  10758. const tmpCtx = tmpCanvas.context;
  10759. const data = tmpCtx.createImageData(width, height);
  10760. if (backgroundColor) {
  10761. const bytes = data.data;
  10762. for (let i = 0, ii = bytes.length; i < ii; i += 4) {
  10763. bytes[i] = backgroundColor[0];
  10764. bytes[i + 1] = backgroundColor[1];
  10765. bytes[i + 2] = backgroundColor[2];
  10766. bytes[i + 3] = 255;
  10767. }
  10768. }
  10769. for (const figure of this._figures) {
  10770. drawFigure(data, figure, context);
  10771. }
  10772. tmpCtx.putImageData(data, BORDER_SIZE, BORDER_SIZE);
  10773. const canvas = tmpCanvas.canvas;
  10774. return {
  10775. canvas,
  10776. offsetX: offsetX - BORDER_SIZE * scaleX,
  10777. offsetY: offsetY - BORDER_SIZE * scaleY,
  10778. scaleX,
  10779. scaleY
  10780. };
  10781. }
  10782. getPattern(ctx, owner, inverse, pathType) {
  10783. applyBoundingBox(ctx, this._bbox);
  10784. let scale;
  10785. if (pathType === PathType.SHADING) {
  10786. scale = _util.Util.singularValueDecompose2dScale((0, _display_utils.getCurrentTransform)(ctx));
  10787. } else {
  10788. scale = _util.Util.singularValueDecompose2dScale(owner.baseTransform);
  10789. if (this.matrix) {
  10790. const matrixScale = _util.Util.singularValueDecompose2dScale(this.matrix);
  10791. scale = [scale[0] * matrixScale[0], scale[1] * matrixScale[1]];
  10792. }
  10793. }
  10794. const temporaryPatternCanvas = this._createMeshCanvas(scale, pathType === PathType.SHADING ? null : this._background, owner.cachedCanvases);
  10795. if (pathType !== PathType.SHADING) {
  10796. ctx.setTransform(...owner.baseTransform);
  10797. if (this.matrix) {
  10798. ctx.transform(...this.matrix);
  10799. }
  10800. }
  10801. ctx.translate(temporaryPatternCanvas.offsetX, temporaryPatternCanvas.offsetY);
  10802. ctx.scale(temporaryPatternCanvas.scaleX, temporaryPatternCanvas.scaleY);
  10803. return ctx.createPattern(temporaryPatternCanvas.canvas, "no-repeat");
  10804. }
  10805. }
  10806. class DummyShadingPattern extends BaseShadingPattern {
  10807. getPattern() {
  10808. return "hotpink";
  10809. }
  10810. }
  10811. function getShadingPattern(IR) {
  10812. switch (IR[0]) {
  10813. case "RadialAxial":
  10814. return new RadialAxialShadingPattern(IR);
  10815. case "Mesh":
  10816. return new MeshShadingPattern(IR);
  10817. case "Dummy":
  10818. return new DummyShadingPattern();
  10819. }
  10820. throw new Error(`Unknown IR type: ${IR[0]}`);
  10821. }
  10822. const PaintType = {
  10823. COLORED: 1,
  10824. UNCOLORED: 2
  10825. };
  10826. class TilingPattern {
  10827. static get MAX_PATTERN_SIZE() {
  10828. return (0, _util.shadow)(this, "MAX_PATTERN_SIZE", 3000);
  10829. }
  10830. constructor(IR, color, ctx, canvasGraphicsFactory, baseTransform) {
  10831. this.operatorList = IR[2];
  10832. this.matrix = IR[3] || [1, 0, 0, 1, 0, 0];
  10833. this.bbox = IR[4];
  10834. this.xstep = IR[5];
  10835. this.ystep = IR[6];
  10836. this.paintType = IR[7];
  10837. this.tilingType = IR[8];
  10838. this.color = color;
  10839. this.ctx = ctx;
  10840. this.canvasGraphicsFactory = canvasGraphicsFactory;
  10841. this.baseTransform = baseTransform;
  10842. }
  10843. createPatternCanvas(owner) {
  10844. const operatorList = this.operatorList;
  10845. const bbox = this.bbox;
  10846. const xstep = this.xstep;
  10847. const ystep = this.ystep;
  10848. const paintType = this.paintType;
  10849. const tilingType = this.tilingType;
  10850. const color = this.color;
  10851. const canvasGraphicsFactory = this.canvasGraphicsFactory;
  10852. (0, _util.info)("TilingType: " + tilingType);
  10853. const x0 = bbox[0],
  10854. y0 = bbox[1],
  10855. x1 = bbox[2],
  10856. y1 = bbox[3];
  10857. const matrixScale = _util.Util.singularValueDecompose2dScale(this.matrix);
  10858. const curMatrixScale = _util.Util.singularValueDecompose2dScale(this.baseTransform);
  10859. const combinedScale = [matrixScale[0] * curMatrixScale[0], matrixScale[1] * curMatrixScale[1]];
  10860. const dimx = this.getSizeAndScale(xstep, this.ctx.canvas.width, combinedScale[0]);
  10861. const dimy = this.getSizeAndScale(ystep, this.ctx.canvas.height, combinedScale[1]);
  10862. const tmpCanvas = owner.cachedCanvases.getCanvas("pattern", dimx.size, dimy.size, true);
  10863. const tmpCtx = tmpCanvas.context;
  10864. const graphics = canvasGraphicsFactory.createCanvasGraphics(tmpCtx);
  10865. graphics.groupLevel = owner.groupLevel;
  10866. this.setFillAndStrokeStyleToContext(graphics, paintType, color);
  10867. let adjustedX0 = x0;
  10868. let adjustedY0 = y0;
  10869. let adjustedX1 = x1;
  10870. let adjustedY1 = y1;
  10871. if (x0 < 0) {
  10872. adjustedX0 = 0;
  10873. adjustedX1 += Math.abs(x0);
  10874. }
  10875. if (y0 < 0) {
  10876. adjustedY0 = 0;
  10877. adjustedY1 += Math.abs(y0);
  10878. }
  10879. tmpCtx.translate(-(dimx.scale * adjustedX0), -(dimy.scale * adjustedY0));
  10880. graphics.transform(dimx.scale, 0, 0, dimy.scale, 0, 0);
  10881. tmpCtx.save();
  10882. this.clipBbox(graphics, adjustedX0, adjustedY0, adjustedX1, adjustedY1);
  10883. graphics.baseTransform = (0, _display_utils.getCurrentTransform)(graphics.ctx);
  10884. graphics.executeOperatorList(operatorList);
  10885. graphics.endDrawing();
  10886. return {
  10887. canvas: tmpCanvas.canvas,
  10888. scaleX: dimx.scale,
  10889. scaleY: dimy.scale,
  10890. offsetX: adjustedX0,
  10891. offsetY: adjustedY0
  10892. };
  10893. }
  10894. getSizeAndScale(step, realOutputSize, scale) {
  10895. step = Math.abs(step);
  10896. const maxSize = Math.max(TilingPattern.MAX_PATTERN_SIZE, realOutputSize);
  10897. let size = Math.ceil(step * scale);
  10898. if (size >= maxSize) {
  10899. size = maxSize;
  10900. } else {
  10901. scale = size / step;
  10902. }
  10903. return {
  10904. scale,
  10905. size
  10906. };
  10907. }
  10908. clipBbox(graphics, x0, y0, x1, y1) {
  10909. const bboxWidth = x1 - x0;
  10910. const bboxHeight = y1 - y0;
  10911. graphics.ctx.rect(x0, y0, bboxWidth, bboxHeight);
  10912. graphics.current.updateRectMinMax((0, _display_utils.getCurrentTransform)(graphics.ctx), [x0, y0, x1, y1]);
  10913. graphics.clip();
  10914. graphics.endPath();
  10915. }
  10916. setFillAndStrokeStyleToContext(graphics, paintType, color) {
  10917. const context = graphics.ctx,
  10918. current = graphics.current;
  10919. switch (paintType) {
  10920. case PaintType.COLORED:
  10921. const ctx = this.ctx;
  10922. context.fillStyle = ctx.fillStyle;
  10923. context.strokeStyle = ctx.strokeStyle;
  10924. current.fillColor = ctx.fillStyle;
  10925. current.strokeColor = ctx.strokeStyle;
  10926. break;
  10927. case PaintType.UNCOLORED:
  10928. const cssColor = _util.Util.makeHexColor(color[0], color[1], color[2]);
  10929. context.fillStyle = cssColor;
  10930. context.strokeStyle = cssColor;
  10931. current.fillColor = cssColor;
  10932. current.strokeColor = cssColor;
  10933. break;
  10934. default:
  10935. throw new _util.FormatError(`Unsupported paint type: ${paintType}`);
  10936. }
  10937. }
  10938. getPattern(ctx, owner, inverse, pathType) {
  10939. let matrix = inverse;
  10940. if (pathType !== PathType.SHADING) {
  10941. matrix = _util.Util.transform(matrix, owner.baseTransform);
  10942. if (this.matrix) {
  10943. matrix = _util.Util.transform(matrix, this.matrix);
  10944. }
  10945. }
  10946. const temporaryPatternCanvas = this.createPatternCanvas(owner);
  10947. let domMatrix = new DOMMatrix(matrix);
  10948. domMatrix = domMatrix.translate(temporaryPatternCanvas.offsetX, temporaryPatternCanvas.offsetY);
  10949. domMatrix = domMatrix.scale(1 / temporaryPatternCanvas.scaleX, 1 / temporaryPatternCanvas.scaleY);
  10950. const pattern = ctx.createPattern(temporaryPatternCanvas.canvas, "repeat");
  10951. pattern.setTransform(domMatrix);
  10952. return pattern;
  10953. }
  10954. }
  10955. exports.TilingPattern = TilingPattern;
  10956. /***/ }),
  10957. /* 145 */
  10958. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  10959. "use strict";
  10960. Object.defineProperty(exports, "__esModule", ({
  10961. value: true
  10962. }));
  10963. exports.applyMaskImageData = applyMaskImageData;
  10964. var _util = __w_pdfjs_require__(1);
  10965. function applyMaskImageData(_ref) {
  10966. let {
  10967. src,
  10968. srcPos = 0,
  10969. dest,
  10970. destPos = 0,
  10971. width,
  10972. height,
  10973. inverseDecode = false
  10974. } = _ref;
  10975. const opaque = _util.FeatureTest.isLittleEndian ? 0xff000000 : 0x000000ff;
  10976. const [zeroMapping, oneMapping] = !inverseDecode ? [opaque, 0] : [0, opaque];
  10977. const widthInSource = width >> 3;
  10978. const widthRemainder = width & 7;
  10979. const srcLength = src.length;
  10980. dest = new Uint32Array(dest.buffer);
  10981. for (let i = 0; i < height; i++) {
  10982. for (const max = srcPos + widthInSource; srcPos < max; srcPos++) {
  10983. const elem = srcPos < srcLength ? src[srcPos] : 255;
  10984. dest[destPos++] = elem & 0b10000000 ? oneMapping : zeroMapping;
  10985. dest[destPos++] = elem & 0b1000000 ? oneMapping : zeroMapping;
  10986. dest[destPos++] = elem & 0b100000 ? oneMapping : zeroMapping;
  10987. dest[destPos++] = elem & 0b10000 ? oneMapping : zeroMapping;
  10988. dest[destPos++] = elem & 0b1000 ? oneMapping : zeroMapping;
  10989. dest[destPos++] = elem & 0b100 ? oneMapping : zeroMapping;
  10990. dest[destPos++] = elem & 0b10 ? oneMapping : zeroMapping;
  10991. dest[destPos++] = elem & 0b1 ? oneMapping : zeroMapping;
  10992. }
  10993. if (widthRemainder === 0) {
  10994. continue;
  10995. }
  10996. const elem = srcPos < srcLength ? src[srcPos++] : 255;
  10997. for (let j = 0; j < widthRemainder; j++) {
  10998. dest[destPos++] = elem & 1 << 7 - j ? oneMapping : zeroMapping;
  10999. }
  11000. }
  11001. return {
  11002. srcPos,
  11003. destPos
  11004. };
  11005. }
  11006. /***/ }),
  11007. /* 146 */
  11008. /***/ ((__unused_webpack_module, exports) => {
  11009. "use strict";
  11010. Object.defineProperty(exports, "__esModule", ({
  11011. value: true
  11012. }));
  11013. exports.GlobalWorkerOptions = void 0;
  11014. const GlobalWorkerOptions = Object.create(null);
  11015. exports.GlobalWorkerOptions = GlobalWorkerOptions;
  11016. GlobalWorkerOptions.workerPort = null;
  11017. GlobalWorkerOptions.workerSrc = "";
  11018. /***/ }),
  11019. /* 147 */
  11020. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  11021. "use strict";
  11022. Object.defineProperty(exports, "__esModule", ({
  11023. value: true
  11024. }));
  11025. exports.MessageHandler = void 0;
  11026. var _util = __w_pdfjs_require__(1);
  11027. const CallbackKind = {
  11028. UNKNOWN: 0,
  11029. DATA: 1,
  11030. ERROR: 2
  11031. };
  11032. const StreamKind = {
  11033. UNKNOWN: 0,
  11034. CANCEL: 1,
  11035. CANCEL_COMPLETE: 2,
  11036. CLOSE: 3,
  11037. ENQUEUE: 4,
  11038. ERROR: 5,
  11039. PULL: 6,
  11040. PULL_COMPLETE: 7,
  11041. START_COMPLETE: 8
  11042. };
  11043. function wrapReason(reason) {
  11044. if (!(reason instanceof Error || typeof reason === "object" && reason !== null)) {
  11045. (0, _util.unreachable)('wrapReason: Expected "reason" to be a (possibly cloned) Error.');
  11046. }
  11047. switch (reason.name) {
  11048. case "AbortException":
  11049. return new _util.AbortException(reason.message);
  11050. case "MissingPDFException":
  11051. return new _util.MissingPDFException(reason.message);
  11052. case "PasswordException":
  11053. return new _util.PasswordException(reason.message, reason.code);
  11054. case "UnexpectedResponseException":
  11055. return new _util.UnexpectedResponseException(reason.message, reason.status);
  11056. case "UnknownErrorException":
  11057. return new _util.UnknownErrorException(reason.message, reason.details);
  11058. default:
  11059. return new _util.UnknownErrorException(reason.message, reason.toString());
  11060. }
  11061. }
  11062. class MessageHandler {
  11063. constructor(sourceName, targetName, comObj) {
  11064. this.sourceName = sourceName;
  11065. this.targetName = targetName;
  11066. this.comObj = comObj;
  11067. this.callbackId = 1;
  11068. this.streamId = 1;
  11069. this.streamSinks = Object.create(null);
  11070. this.streamControllers = Object.create(null);
  11071. this.callbackCapabilities = Object.create(null);
  11072. this.actionHandler = Object.create(null);
  11073. this._onComObjOnMessage = event => {
  11074. const data = event.data;
  11075. if (data.targetName !== this.sourceName) {
  11076. return;
  11077. }
  11078. if (data.stream) {
  11079. this._processStreamMessage(data);
  11080. return;
  11081. }
  11082. if (data.callback) {
  11083. const callbackId = data.callbackId;
  11084. const capability = this.callbackCapabilities[callbackId];
  11085. if (!capability) {
  11086. throw new Error(`Cannot resolve callback ${callbackId}`);
  11087. }
  11088. delete this.callbackCapabilities[callbackId];
  11089. if (data.callback === CallbackKind.DATA) {
  11090. capability.resolve(data.data);
  11091. } else if (data.callback === CallbackKind.ERROR) {
  11092. capability.reject(wrapReason(data.reason));
  11093. } else {
  11094. throw new Error("Unexpected callback case");
  11095. }
  11096. return;
  11097. }
  11098. const action = this.actionHandler[data.action];
  11099. if (!action) {
  11100. throw new Error(`Unknown action from worker: ${data.action}`);
  11101. }
  11102. if (data.callbackId) {
  11103. const cbSourceName = this.sourceName;
  11104. const cbTargetName = data.sourceName;
  11105. new Promise(function (resolve) {
  11106. resolve(action(data.data));
  11107. }).then(function (result) {
  11108. comObj.postMessage({
  11109. sourceName: cbSourceName,
  11110. targetName: cbTargetName,
  11111. callback: CallbackKind.DATA,
  11112. callbackId: data.callbackId,
  11113. data: result
  11114. });
  11115. }, function (reason) {
  11116. comObj.postMessage({
  11117. sourceName: cbSourceName,
  11118. targetName: cbTargetName,
  11119. callback: CallbackKind.ERROR,
  11120. callbackId: data.callbackId,
  11121. reason: wrapReason(reason)
  11122. });
  11123. });
  11124. return;
  11125. }
  11126. if (data.streamId) {
  11127. this._createStreamSink(data);
  11128. return;
  11129. }
  11130. action(data.data);
  11131. };
  11132. comObj.addEventListener("message", this._onComObjOnMessage);
  11133. }
  11134. on(actionName, handler) {
  11135. const ah = this.actionHandler;
  11136. if (ah[actionName]) {
  11137. throw new Error(`There is already an actionName called "${actionName}"`);
  11138. }
  11139. ah[actionName] = handler;
  11140. }
  11141. send(actionName, data, transfers) {
  11142. this.comObj.postMessage({
  11143. sourceName: this.sourceName,
  11144. targetName: this.targetName,
  11145. action: actionName,
  11146. data
  11147. }, transfers);
  11148. }
  11149. sendWithPromise(actionName, data, transfers) {
  11150. const callbackId = this.callbackId++;
  11151. const capability = (0, _util.createPromiseCapability)();
  11152. this.callbackCapabilities[callbackId] = capability;
  11153. try {
  11154. this.comObj.postMessage({
  11155. sourceName: this.sourceName,
  11156. targetName: this.targetName,
  11157. action: actionName,
  11158. callbackId,
  11159. data
  11160. }, transfers);
  11161. } catch (ex) {
  11162. capability.reject(ex);
  11163. }
  11164. return capability.promise;
  11165. }
  11166. sendWithStream(actionName, data, queueingStrategy, transfers) {
  11167. const streamId = this.streamId++,
  11168. sourceName = this.sourceName,
  11169. targetName = this.targetName,
  11170. comObj = this.comObj;
  11171. return new ReadableStream({
  11172. start: controller => {
  11173. const startCapability = (0, _util.createPromiseCapability)();
  11174. this.streamControllers[streamId] = {
  11175. controller,
  11176. startCall: startCapability,
  11177. pullCall: null,
  11178. cancelCall: null,
  11179. isClosed: false
  11180. };
  11181. comObj.postMessage({
  11182. sourceName,
  11183. targetName,
  11184. action: actionName,
  11185. streamId,
  11186. data,
  11187. desiredSize: controller.desiredSize
  11188. }, transfers);
  11189. return startCapability.promise;
  11190. },
  11191. pull: controller => {
  11192. const pullCapability = (0, _util.createPromiseCapability)();
  11193. this.streamControllers[streamId].pullCall = pullCapability;
  11194. comObj.postMessage({
  11195. sourceName,
  11196. targetName,
  11197. stream: StreamKind.PULL,
  11198. streamId,
  11199. desiredSize: controller.desiredSize
  11200. });
  11201. return pullCapability.promise;
  11202. },
  11203. cancel: reason => {
  11204. (0, _util.assert)(reason instanceof Error, "cancel must have a valid reason");
  11205. const cancelCapability = (0, _util.createPromiseCapability)();
  11206. this.streamControllers[streamId].cancelCall = cancelCapability;
  11207. this.streamControllers[streamId].isClosed = true;
  11208. comObj.postMessage({
  11209. sourceName,
  11210. targetName,
  11211. stream: StreamKind.CANCEL,
  11212. streamId,
  11213. reason: wrapReason(reason)
  11214. });
  11215. return cancelCapability.promise;
  11216. }
  11217. }, queueingStrategy);
  11218. }
  11219. _createStreamSink(data) {
  11220. const streamId = data.streamId,
  11221. sourceName = this.sourceName,
  11222. targetName = data.sourceName,
  11223. comObj = this.comObj;
  11224. const self = this,
  11225. action = this.actionHandler[data.action];
  11226. const streamSink = {
  11227. enqueue(chunk) {
  11228. let size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
  11229. let transfers = arguments.length > 2 ? arguments[2] : undefined;
  11230. if (this.isCancelled) {
  11231. return;
  11232. }
  11233. const lastDesiredSize = this.desiredSize;
  11234. this.desiredSize -= size;
  11235. if (lastDesiredSize > 0 && this.desiredSize <= 0) {
  11236. this.sinkCapability = (0, _util.createPromiseCapability)();
  11237. this.ready = this.sinkCapability.promise;
  11238. }
  11239. comObj.postMessage({
  11240. sourceName,
  11241. targetName,
  11242. stream: StreamKind.ENQUEUE,
  11243. streamId,
  11244. chunk
  11245. }, transfers);
  11246. },
  11247. close() {
  11248. if (this.isCancelled) {
  11249. return;
  11250. }
  11251. this.isCancelled = true;
  11252. comObj.postMessage({
  11253. sourceName,
  11254. targetName,
  11255. stream: StreamKind.CLOSE,
  11256. streamId
  11257. });
  11258. delete self.streamSinks[streamId];
  11259. },
  11260. error(reason) {
  11261. (0, _util.assert)(reason instanceof Error, "error must have a valid reason");
  11262. if (this.isCancelled) {
  11263. return;
  11264. }
  11265. this.isCancelled = true;
  11266. comObj.postMessage({
  11267. sourceName,
  11268. targetName,
  11269. stream: StreamKind.ERROR,
  11270. streamId,
  11271. reason: wrapReason(reason)
  11272. });
  11273. },
  11274. sinkCapability: (0, _util.createPromiseCapability)(),
  11275. onPull: null,
  11276. onCancel: null,
  11277. isCancelled: false,
  11278. desiredSize: data.desiredSize,
  11279. ready: null
  11280. };
  11281. streamSink.sinkCapability.resolve();
  11282. streamSink.ready = streamSink.sinkCapability.promise;
  11283. this.streamSinks[streamId] = streamSink;
  11284. new Promise(function (resolve) {
  11285. resolve(action(data.data, streamSink));
  11286. }).then(function () {
  11287. comObj.postMessage({
  11288. sourceName,
  11289. targetName,
  11290. stream: StreamKind.START_COMPLETE,
  11291. streamId,
  11292. success: true
  11293. });
  11294. }, function (reason) {
  11295. comObj.postMessage({
  11296. sourceName,
  11297. targetName,
  11298. stream: StreamKind.START_COMPLETE,
  11299. streamId,
  11300. reason: wrapReason(reason)
  11301. });
  11302. });
  11303. }
  11304. _processStreamMessage(data) {
  11305. const streamId = data.streamId,
  11306. sourceName = this.sourceName,
  11307. targetName = data.sourceName,
  11308. comObj = this.comObj;
  11309. const streamController = this.streamControllers[streamId],
  11310. streamSink = this.streamSinks[streamId];
  11311. switch (data.stream) {
  11312. case StreamKind.START_COMPLETE:
  11313. if (data.success) {
  11314. streamController.startCall.resolve();
  11315. } else {
  11316. streamController.startCall.reject(wrapReason(data.reason));
  11317. }
  11318. break;
  11319. case StreamKind.PULL_COMPLETE:
  11320. if (data.success) {
  11321. streamController.pullCall.resolve();
  11322. } else {
  11323. streamController.pullCall.reject(wrapReason(data.reason));
  11324. }
  11325. break;
  11326. case StreamKind.PULL:
  11327. if (!streamSink) {
  11328. comObj.postMessage({
  11329. sourceName,
  11330. targetName,
  11331. stream: StreamKind.PULL_COMPLETE,
  11332. streamId,
  11333. success: true
  11334. });
  11335. break;
  11336. }
  11337. if (streamSink.desiredSize <= 0 && data.desiredSize > 0) {
  11338. streamSink.sinkCapability.resolve();
  11339. }
  11340. streamSink.desiredSize = data.desiredSize;
  11341. new Promise(function (resolve) {
  11342. resolve(streamSink.onPull && streamSink.onPull());
  11343. }).then(function () {
  11344. comObj.postMessage({
  11345. sourceName,
  11346. targetName,
  11347. stream: StreamKind.PULL_COMPLETE,
  11348. streamId,
  11349. success: true
  11350. });
  11351. }, function (reason) {
  11352. comObj.postMessage({
  11353. sourceName,
  11354. targetName,
  11355. stream: StreamKind.PULL_COMPLETE,
  11356. streamId,
  11357. reason: wrapReason(reason)
  11358. });
  11359. });
  11360. break;
  11361. case StreamKind.ENQUEUE:
  11362. (0, _util.assert)(streamController, "enqueue should have stream controller");
  11363. if (streamController.isClosed) {
  11364. break;
  11365. }
  11366. streamController.controller.enqueue(data.chunk);
  11367. break;
  11368. case StreamKind.CLOSE:
  11369. (0, _util.assert)(streamController, "close should have stream controller");
  11370. if (streamController.isClosed) {
  11371. break;
  11372. }
  11373. streamController.isClosed = true;
  11374. streamController.controller.close();
  11375. this._deleteStreamController(streamController, streamId);
  11376. break;
  11377. case StreamKind.ERROR:
  11378. (0, _util.assert)(streamController, "error should have stream controller");
  11379. streamController.controller.error(wrapReason(data.reason));
  11380. this._deleteStreamController(streamController, streamId);
  11381. break;
  11382. case StreamKind.CANCEL_COMPLETE:
  11383. if (data.success) {
  11384. streamController.cancelCall.resolve();
  11385. } else {
  11386. streamController.cancelCall.reject(wrapReason(data.reason));
  11387. }
  11388. this._deleteStreamController(streamController, streamId);
  11389. break;
  11390. case StreamKind.CANCEL:
  11391. if (!streamSink) {
  11392. break;
  11393. }
  11394. new Promise(function (resolve) {
  11395. resolve(streamSink.onCancel && streamSink.onCancel(wrapReason(data.reason)));
  11396. }).then(function () {
  11397. comObj.postMessage({
  11398. sourceName,
  11399. targetName,
  11400. stream: StreamKind.CANCEL_COMPLETE,
  11401. streamId,
  11402. success: true
  11403. });
  11404. }, function (reason) {
  11405. comObj.postMessage({
  11406. sourceName,
  11407. targetName,
  11408. stream: StreamKind.CANCEL_COMPLETE,
  11409. streamId,
  11410. reason: wrapReason(reason)
  11411. });
  11412. });
  11413. streamSink.sinkCapability.reject(wrapReason(data.reason));
  11414. streamSink.isCancelled = true;
  11415. delete this.streamSinks[streamId];
  11416. break;
  11417. default:
  11418. throw new Error("Unexpected stream case");
  11419. }
  11420. }
  11421. async _deleteStreamController(streamController, streamId) {
  11422. await Promise.allSettled([streamController.startCall && streamController.startCall.promise, streamController.pullCall && streamController.pullCall.promise, streamController.cancelCall && streamController.cancelCall.promise]);
  11423. delete this.streamControllers[streamId];
  11424. }
  11425. destroy() {
  11426. this.comObj.removeEventListener("message", this._onComObjOnMessage);
  11427. }
  11428. }
  11429. exports.MessageHandler = MessageHandler;
  11430. /***/ }),
  11431. /* 148 */
  11432. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  11433. "use strict";
  11434. Object.defineProperty(exports, "__esModule", ({
  11435. value: true
  11436. }));
  11437. exports.Metadata = void 0;
  11438. var _util = __w_pdfjs_require__(1);
  11439. class Metadata {
  11440. #metadataMap;
  11441. #data;
  11442. constructor(_ref) {
  11443. let {
  11444. parsedData,
  11445. rawData
  11446. } = _ref;
  11447. this.#metadataMap = parsedData;
  11448. this.#data = rawData;
  11449. }
  11450. getRaw() {
  11451. return this.#data;
  11452. }
  11453. get(name) {
  11454. return this.#metadataMap.get(name) ?? null;
  11455. }
  11456. getAll() {
  11457. return (0, _util.objectFromMap)(this.#metadataMap);
  11458. }
  11459. has(name) {
  11460. return this.#metadataMap.has(name);
  11461. }
  11462. }
  11463. exports.Metadata = Metadata;
  11464. /***/ }),
  11465. /* 149 */
  11466. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  11467. "use strict";
  11468. Object.defineProperty(exports, "__esModule", ({
  11469. value: true
  11470. }));
  11471. exports.OptionalContentConfig = void 0;
  11472. var _util = __w_pdfjs_require__(1);
  11473. var _murmurhash = __w_pdfjs_require__(141);
  11474. function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
  11475. function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
  11476. function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
  11477. function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
  11478. function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
  11479. function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
  11480. function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
  11481. function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
  11482. function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }
  11483. const INTERNAL = Symbol("INTERNAL");
  11484. class OptionalContentGroup {
  11485. #visible = true;
  11486. constructor(name, intent) {
  11487. this.name = name;
  11488. this.intent = intent;
  11489. }
  11490. get visible() {
  11491. return this.#visible;
  11492. }
  11493. _setVisible(internal, visible) {
  11494. if (internal !== INTERNAL) {
  11495. (0, _util.unreachable)("Internal method `_setVisible` called.");
  11496. }
  11497. this.#visible = visible;
  11498. }
  11499. }
  11500. var _cachedGetHash = /*#__PURE__*/new WeakMap();
  11501. var _groups = /*#__PURE__*/new WeakMap();
  11502. var _initialHash = /*#__PURE__*/new WeakMap();
  11503. var _order = /*#__PURE__*/new WeakMap();
  11504. var _evaluateVisibilityExpression = /*#__PURE__*/new WeakSet();
  11505. class OptionalContentConfig {
  11506. constructor(data) {
  11507. _classPrivateMethodInitSpec(this, _evaluateVisibilityExpression);
  11508. _classPrivateFieldInitSpec(this, _cachedGetHash, {
  11509. writable: true,
  11510. value: null
  11511. });
  11512. _classPrivateFieldInitSpec(this, _groups, {
  11513. writable: true,
  11514. value: new Map()
  11515. });
  11516. _classPrivateFieldInitSpec(this, _initialHash, {
  11517. writable: true,
  11518. value: null
  11519. });
  11520. _classPrivateFieldInitSpec(this, _order, {
  11521. writable: true,
  11522. value: null
  11523. });
  11524. this.name = null;
  11525. this.creator = null;
  11526. if (data === null) {
  11527. return;
  11528. }
  11529. this.name = data.name;
  11530. this.creator = data.creator;
  11531. _classPrivateFieldSet(this, _order, data.order);
  11532. for (const group of data.groups) {
  11533. _classPrivateFieldGet(this, _groups).set(group.id, new OptionalContentGroup(group.name, group.intent));
  11534. }
  11535. if (data.baseState === "OFF") {
  11536. for (const group of _classPrivateFieldGet(this, _groups).values()) {
  11537. group._setVisible(INTERNAL, false);
  11538. }
  11539. }
  11540. for (const on of data.on) {
  11541. _classPrivateFieldGet(this, _groups).get(on)._setVisible(INTERNAL, true);
  11542. }
  11543. for (const off of data.off) {
  11544. _classPrivateFieldGet(this, _groups).get(off)._setVisible(INTERNAL, false);
  11545. }
  11546. _classPrivateFieldSet(this, _initialHash, this.getHash());
  11547. }
  11548. isVisible(group) {
  11549. if (_classPrivateFieldGet(this, _groups).size === 0) {
  11550. return true;
  11551. }
  11552. if (!group) {
  11553. (0, _util.warn)("Optional content group not defined.");
  11554. return true;
  11555. }
  11556. if (group.type === "OCG") {
  11557. if (!_classPrivateFieldGet(this, _groups).has(group.id)) {
  11558. (0, _util.warn)(`Optional content group not found: ${group.id}`);
  11559. return true;
  11560. }
  11561. return _classPrivateFieldGet(this, _groups).get(group.id).visible;
  11562. } else if (group.type === "OCMD") {
  11563. if (group.expression) {
  11564. return _classPrivateMethodGet(this, _evaluateVisibilityExpression, _evaluateVisibilityExpression2).call(this, group.expression);
  11565. }
  11566. if (!group.policy || group.policy === "AnyOn") {
  11567. for (const id of group.ids) {
  11568. if (!_classPrivateFieldGet(this, _groups).has(id)) {
  11569. (0, _util.warn)(`Optional content group not found: ${id}`);
  11570. return true;
  11571. }
  11572. if (_classPrivateFieldGet(this, _groups).get(id).visible) {
  11573. return true;
  11574. }
  11575. }
  11576. return false;
  11577. } else if (group.policy === "AllOn") {
  11578. for (const id of group.ids) {
  11579. if (!_classPrivateFieldGet(this, _groups).has(id)) {
  11580. (0, _util.warn)(`Optional content group not found: ${id}`);
  11581. return true;
  11582. }
  11583. if (!_classPrivateFieldGet(this, _groups).get(id).visible) {
  11584. return false;
  11585. }
  11586. }
  11587. return true;
  11588. } else if (group.policy === "AnyOff") {
  11589. for (const id of group.ids) {
  11590. if (!_classPrivateFieldGet(this, _groups).has(id)) {
  11591. (0, _util.warn)(`Optional content group not found: ${id}`);
  11592. return true;
  11593. }
  11594. if (!_classPrivateFieldGet(this, _groups).get(id).visible) {
  11595. return true;
  11596. }
  11597. }
  11598. return false;
  11599. } else if (group.policy === "AllOff") {
  11600. for (const id of group.ids) {
  11601. if (!_classPrivateFieldGet(this, _groups).has(id)) {
  11602. (0, _util.warn)(`Optional content group not found: ${id}`);
  11603. return true;
  11604. }
  11605. if (_classPrivateFieldGet(this, _groups).get(id).visible) {
  11606. return false;
  11607. }
  11608. }
  11609. return true;
  11610. }
  11611. (0, _util.warn)(`Unknown optional content policy ${group.policy}.`);
  11612. return true;
  11613. }
  11614. (0, _util.warn)(`Unknown group type ${group.type}.`);
  11615. return true;
  11616. }
  11617. setVisibility(id) {
  11618. let visible = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  11619. if (!_classPrivateFieldGet(this, _groups).has(id)) {
  11620. (0, _util.warn)(`Optional content group not found: ${id}`);
  11621. return;
  11622. }
  11623. _classPrivateFieldGet(this, _groups).get(id)._setVisible(INTERNAL, !!visible);
  11624. _classPrivateFieldSet(this, _cachedGetHash, null);
  11625. }
  11626. get hasInitialVisibility() {
  11627. return this.getHash() === _classPrivateFieldGet(this, _initialHash);
  11628. }
  11629. getOrder() {
  11630. if (!_classPrivateFieldGet(this, _groups).size) {
  11631. return null;
  11632. }
  11633. if (_classPrivateFieldGet(this, _order)) {
  11634. return _classPrivateFieldGet(this, _order).slice();
  11635. }
  11636. return [..._classPrivateFieldGet(this, _groups).keys()];
  11637. }
  11638. getGroups() {
  11639. return _classPrivateFieldGet(this, _groups).size > 0 ? (0, _util.objectFromMap)(_classPrivateFieldGet(this, _groups)) : null;
  11640. }
  11641. getGroup(id) {
  11642. return _classPrivateFieldGet(this, _groups).get(id) || null;
  11643. }
  11644. getHash() {
  11645. if (_classPrivateFieldGet(this, _cachedGetHash) !== null) {
  11646. return _classPrivateFieldGet(this, _cachedGetHash);
  11647. }
  11648. const hash = new _murmurhash.MurmurHash3_64();
  11649. for (const [id, group] of _classPrivateFieldGet(this, _groups)) {
  11650. hash.update(`${id}:${group.visible}`);
  11651. }
  11652. return _classPrivateFieldSet(this, _cachedGetHash, hash.hexdigest());
  11653. }
  11654. }
  11655. exports.OptionalContentConfig = OptionalContentConfig;
  11656. function _evaluateVisibilityExpression2(array) {
  11657. const length = array.length;
  11658. if (length < 2) {
  11659. return true;
  11660. }
  11661. const operator = array[0];
  11662. for (let i = 1; i < length; i++) {
  11663. const element = array[i];
  11664. let state;
  11665. if (Array.isArray(element)) {
  11666. state = _classPrivateMethodGet(this, _evaluateVisibilityExpression, _evaluateVisibilityExpression2).call(this, element);
  11667. } else if (_classPrivateFieldGet(this, _groups).has(element)) {
  11668. state = _classPrivateFieldGet(this, _groups).get(element).visible;
  11669. } else {
  11670. (0, _util.warn)(`Optional content group not found: ${element}`);
  11671. return true;
  11672. }
  11673. switch (operator) {
  11674. case "And":
  11675. if (!state) {
  11676. return false;
  11677. }
  11678. break;
  11679. case "Or":
  11680. if (state) {
  11681. return true;
  11682. }
  11683. break;
  11684. case "Not":
  11685. return !state;
  11686. default:
  11687. return true;
  11688. }
  11689. }
  11690. return operator === "And";
  11691. }
  11692. /***/ }),
  11693. /* 150 */
  11694. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  11695. "use strict";
  11696. Object.defineProperty(exports, "__esModule", ({
  11697. value: true
  11698. }));
  11699. exports.PDFDataTransportStream = void 0;
  11700. var _util = __w_pdfjs_require__(1);
  11701. var _display_utils = __w_pdfjs_require__(139);
  11702. class PDFDataTransportStream {
  11703. constructor(_ref, pdfDataRangeTransport) {
  11704. let {
  11705. length,
  11706. initialData,
  11707. progressiveDone = false,
  11708. contentDispositionFilename = null,
  11709. disableRange = false,
  11710. disableStream = false
  11711. } = _ref;
  11712. (0, _util.assert)(pdfDataRangeTransport, 'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');
  11713. this._queuedChunks = [];
  11714. this._progressiveDone = progressiveDone;
  11715. this._contentDispositionFilename = contentDispositionFilename;
  11716. if ((initialData === null || initialData === void 0 ? void 0 : initialData.length) > 0) {
  11717. const buffer = initialData instanceof Uint8Array && initialData.byteLength === initialData.buffer.byteLength ? initialData.buffer : new Uint8Array(initialData).buffer;
  11718. this._queuedChunks.push(buffer);
  11719. }
  11720. this._pdfDataRangeTransport = pdfDataRangeTransport;
  11721. this._isStreamingSupported = !disableStream;
  11722. this._isRangeSupported = !disableRange;
  11723. this._contentLength = length;
  11724. this._fullRequestReader = null;
  11725. this._rangeReaders = [];
  11726. this._pdfDataRangeTransport.addRangeListener((begin, chunk) => {
  11727. this._onReceiveData({
  11728. begin,
  11729. chunk
  11730. });
  11731. });
  11732. this._pdfDataRangeTransport.addProgressListener((loaded, total) => {
  11733. this._onProgress({
  11734. loaded,
  11735. total
  11736. });
  11737. });
  11738. this._pdfDataRangeTransport.addProgressiveReadListener(chunk => {
  11739. this._onReceiveData({
  11740. chunk
  11741. });
  11742. });
  11743. this._pdfDataRangeTransport.addProgressiveDoneListener(() => {
  11744. this._onProgressiveDone();
  11745. });
  11746. this._pdfDataRangeTransport.transportReady();
  11747. }
  11748. _onReceiveData(_ref2) {
  11749. let {
  11750. begin,
  11751. chunk
  11752. } = _ref2;
  11753. const buffer = chunk instanceof Uint8Array && chunk.byteLength === chunk.buffer.byteLength ? chunk.buffer : new Uint8Array(chunk).buffer;
  11754. if (begin === undefined) {
  11755. if (this._fullRequestReader) {
  11756. this._fullRequestReader._enqueue(buffer);
  11757. } else {
  11758. this._queuedChunks.push(buffer);
  11759. }
  11760. } else {
  11761. const found = this._rangeReaders.some(function (rangeReader) {
  11762. if (rangeReader._begin !== begin) {
  11763. return false;
  11764. }
  11765. rangeReader._enqueue(buffer);
  11766. return true;
  11767. });
  11768. (0, _util.assert)(found, "_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.");
  11769. }
  11770. }
  11771. get _progressiveDataLength() {
  11772. var _this$_fullRequestRea;
  11773. return ((_this$_fullRequestRea = this._fullRequestReader) === null || _this$_fullRequestRea === void 0 ? void 0 : _this$_fullRequestRea._loaded) ?? 0;
  11774. }
  11775. _onProgress(evt) {
  11776. if (evt.total === undefined) {
  11777. var _this$_rangeReaders$, _this$_rangeReaders$$;
  11778. (_this$_rangeReaders$ = this._rangeReaders[0]) === null || _this$_rangeReaders$ === void 0 ? void 0 : (_this$_rangeReaders$$ = _this$_rangeReaders$.onProgress) === null || _this$_rangeReaders$$ === void 0 ? void 0 : _this$_rangeReaders$$.call(_this$_rangeReaders$, {
  11779. loaded: evt.loaded
  11780. });
  11781. } else {
  11782. var _this$_fullRequestRea2, _this$_fullRequestRea3;
  11783. (_this$_fullRequestRea2 = this._fullRequestReader) === null || _this$_fullRequestRea2 === void 0 ? void 0 : (_this$_fullRequestRea3 = _this$_fullRequestRea2.onProgress) === null || _this$_fullRequestRea3 === void 0 ? void 0 : _this$_fullRequestRea3.call(_this$_fullRequestRea2, {
  11784. loaded: evt.loaded,
  11785. total: evt.total
  11786. });
  11787. }
  11788. }
  11789. _onProgressiveDone() {
  11790. var _this$_fullRequestRea4;
  11791. (_this$_fullRequestRea4 = this._fullRequestReader) === null || _this$_fullRequestRea4 === void 0 ? void 0 : _this$_fullRequestRea4.progressiveDone();
  11792. this._progressiveDone = true;
  11793. }
  11794. _removeRangeReader(reader) {
  11795. const i = this._rangeReaders.indexOf(reader);
  11796. if (i >= 0) {
  11797. this._rangeReaders.splice(i, 1);
  11798. }
  11799. }
  11800. getFullReader() {
  11801. (0, _util.assert)(!this._fullRequestReader, "PDFDataTransportStream.getFullReader can only be called once.");
  11802. const queuedChunks = this._queuedChunks;
  11803. this._queuedChunks = null;
  11804. return new PDFDataTransportStreamReader(this, queuedChunks, this._progressiveDone, this._contentDispositionFilename);
  11805. }
  11806. getRangeReader(begin, end) {
  11807. if (end <= this._progressiveDataLength) {
  11808. return null;
  11809. }
  11810. const reader = new PDFDataTransportStreamRangeReader(this, begin, end);
  11811. this._pdfDataRangeTransport.requestDataRange(begin, end);
  11812. this._rangeReaders.push(reader);
  11813. return reader;
  11814. }
  11815. cancelAllRequests(reason) {
  11816. var _this$_fullRequestRea5;
  11817. (_this$_fullRequestRea5 = this._fullRequestReader) === null || _this$_fullRequestRea5 === void 0 ? void 0 : _this$_fullRequestRea5.cancel(reason);
  11818. for (const reader of this._rangeReaders.slice(0)) {
  11819. reader.cancel(reason);
  11820. }
  11821. this._pdfDataRangeTransport.abort();
  11822. }
  11823. }
  11824. exports.PDFDataTransportStream = PDFDataTransportStream;
  11825. class PDFDataTransportStreamReader {
  11826. constructor(stream, queuedChunks) {
  11827. let progressiveDone = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  11828. let contentDispositionFilename = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
  11829. this._stream = stream;
  11830. this._done = progressiveDone || false;
  11831. this._filename = (0, _display_utils.isPdfFile)(contentDispositionFilename) ? contentDispositionFilename : null;
  11832. this._queuedChunks = queuedChunks || [];
  11833. this._loaded = 0;
  11834. for (const chunk of this._queuedChunks) {
  11835. this._loaded += chunk.byteLength;
  11836. }
  11837. this._requests = [];
  11838. this._headersReady = Promise.resolve();
  11839. stream._fullRequestReader = this;
  11840. this.onProgress = null;
  11841. }
  11842. _enqueue(chunk) {
  11843. if (this._done) {
  11844. return;
  11845. }
  11846. if (this._requests.length > 0) {
  11847. const requestCapability = this._requests.shift();
  11848. requestCapability.resolve({
  11849. value: chunk,
  11850. done: false
  11851. });
  11852. } else {
  11853. this._queuedChunks.push(chunk);
  11854. }
  11855. this._loaded += chunk.byteLength;
  11856. }
  11857. get headersReady() {
  11858. return this._headersReady;
  11859. }
  11860. get filename() {
  11861. return this._filename;
  11862. }
  11863. get isRangeSupported() {
  11864. return this._stream._isRangeSupported;
  11865. }
  11866. get isStreamingSupported() {
  11867. return this._stream._isStreamingSupported;
  11868. }
  11869. get contentLength() {
  11870. return this._stream._contentLength;
  11871. }
  11872. async read() {
  11873. if (this._queuedChunks.length > 0) {
  11874. const chunk = this._queuedChunks.shift();
  11875. return {
  11876. value: chunk,
  11877. done: false
  11878. };
  11879. }
  11880. if (this._done) {
  11881. return {
  11882. value: undefined,
  11883. done: true
  11884. };
  11885. }
  11886. const requestCapability = (0, _util.createPromiseCapability)();
  11887. this._requests.push(requestCapability);
  11888. return requestCapability.promise;
  11889. }
  11890. cancel(reason) {
  11891. this._done = true;
  11892. for (const requestCapability of this._requests) {
  11893. requestCapability.resolve({
  11894. value: undefined,
  11895. done: true
  11896. });
  11897. }
  11898. this._requests.length = 0;
  11899. }
  11900. progressiveDone() {
  11901. if (this._done) {
  11902. return;
  11903. }
  11904. this._done = true;
  11905. }
  11906. }
  11907. class PDFDataTransportStreamRangeReader {
  11908. constructor(stream, begin, end) {
  11909. this._stream = stream;
  11910. this._begin = begin;
  11911. this._end = end;
  11912. this._queuedChunk = null;
  11913. this._requests = [];
  11914. this._done = false;
  11915. this.onProgress = null;
  11916. }
  11917. _enqueue(chunk) {
  11918. if (this._done) {
  11919. return;
  11920. }
  11921. if (this._requests.length === 0) {
  11922. this._queuedChunk = chunk;
  11923. } else {
  11924. const requestsCapability = this._requests.shift();
  11925. requestsCapability.resolve({
  11926. value: chunk,
  11927. done: false
  11928. });
  11929. for (const requestCapability of this._requests) {
  11930. requestCapability.resolve({
  11931. value: undefined,
  11932. done: true
  11933. });
  11934. }
  11935. this._requests.length = 0;
  11936. }
  11937. this._done = true;
  11938. this._stream._removeRangeReader(this);
  11939. }
  11940. get isStreamingSupported() {
  11941. return false;
  11942. }
  11943. async read() {
  11944. if (this._queuedChunk) {
  11945. const chunk = this._queuedChunk;
  11946. this._queuedChunk = null;
  11947. return {
  11948. value: chunk,
  11949. done: false
  11950. };
  11951. }
  11952. if (this._done) {
  11953. return {
  11954. value: undefined,
  11955. done: true
  11956. };
  11957. }
  11958. const requestCapability = (0, _util.createPromiseCapability)();
  11959. this._requests.push(requestCapability);
  11960. return requestCapability.promise;
  11961. }
  11962. cancel(reason) {
  11963. this._done = true;
  11964. for (const requestCapability of this._requests) {
  11965. requestCapability.resolve({
  11966. value: undefined,
  11967. done: true
  11968. });
  11969. }
  11970. this._requests.length = 0;
  11971. this._stream._removeRangeReader(this);
  11972. }
  11973. }
  11974. /***/ }),
  11975. /* 151 */
  11976. /***/ ((__unused_webpack_module, exports) => {
  11977. "use strict";
  11978. Object.defineProperty(exports, "__esModule", ({
  11979. value: true
  11980. }));
  11981. exports.XfaText = void 0;
  11982. class XfaText {
  11983. static textContent(xfa) {
  11984. const items = [];
  11985. const output = {
  11986. items,
  11987. styles: Object.create(null)
  11988. };
  11989. function walk(node) {
  11990. var _node$attributes;
  11991. if (!node) {
  11992. return;
  11993. }
  11994. let str = null;
  11995. const name = node.name;
  11996. if (name === "#text") {
  11997. str = node.value;
  11998. } else if (!XfaText.shouldBuildText(name)) {
  11999. return;
  12000. } else if (node !== null && node !== void 0 && (_node$attributes = node.attributes) !== null && _node$attributes !== void 0 && _node$attributes.textContent) {
  12001. str = node.attributes.textContent;
  12002. } else if (node.value) {
  12003. str = node.value;
  12004. }
  12005. if (str !== null) {
  12006. items.push({
  12007. str
  12008. });
  12009. }
  12010. if (!node.children) {
  12011. return;
  12012. }
  12013. for (const child of node.children) {
  12014. walk(child);
  12015. }
  12016. }
  12017. walk(xfa);
  12018. return output;
  12019. }
  12020. static shouldBuildText(name) {
  12021. return !(name === "textarea" || name === "input" || name === "option" || name === "select");
  12022. }
  12023. }
  12024. exports.XfaText = XfaText;
  12025. /***/ }),
  12026. /* 152 */
  12027. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  12028. "use strict";
  12029. Object.defineProperty(exports, "__esModule", ({
  12030. value: true
  12031. }));
  12032. exports.NodeStandardFontDataFactory = exports.NodeCanvasFactory = exports.NodeCMapReaderFactory = void 0;
  12033. var _base_factory = __w_pdfjs_require__(140);
  12034. ;
  12035. const fetchData = function (url) {
  12036. return new Promise((resolve, reject) => {
  12037. const fs = require("fs");
  12038. fs.readFile(url, (error, data) => {
  12039. if (error || !data) {
  12040. reject(new Error(error));
  12041. return;
  12042. }
  12043. resolve(new Uint8Array(data));
  12044. });
  12045. });
  12046. };
  12047. class NodeCanvasFactory extends _base_factory.BaseCanvasFactory {
  12048. _createCanvas(width, height) {
  12049. const Canvas = require("canvas");
  12050. return Canvas.createCanvas(width, height);
  12051. }
  12052. }
  12053. exports.NodeCanvasFactory = NodeCanvasFactory;
  12054. class NodeCMapReaderFactory extends _base_factory.BaseCMapReaderFactory {
  12055. _fetchData(url, compressionType) {
  12056. return fetchData(url).then(data => {
  12057. return {
  12058. cMapData: data,
  12059. compressionType
  12060. };
  12061. });
  12062. }
  12063. }
  12064. exports.NodeCMapReaderFactory = NodeCMapReaderFactory;
  12065. class NodeStandardFontDataFactory extends _base_factory.BaseStandardFontDataFactory {
  12066. _fetchData(url) {
  12067. return fetchData(url);
  12068. }
  12069. }
  12070. exports.NodeStandardFontDataFactory = NodeStandardFontDataFactory;
  12071. /***/ }),
  12072. /* 153 */
  12073. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  12074. "use strict";
  12075. Object.defineProperty(exports, "__esModule", ({
  12076. value: true
  12077. }));
  12078. exports.PDFNodeStream = void 0;
  12079. var _util = __w_pdfjs_require__(1);
  12080. var _network_utils = __w_pdfjs_require__(154);
  12081. ;
  12082. const fs = require("fs");
  12083. const http = require("http");
  12084. const https = require("https");
  12085. const url = require("url");
  12086. const fileUriRegex = /^file:\/\/\/[a-zA-Z]:\//;
  12087. function parseUrl(sourceUrl) {
  12088. const parsedUrl = url.parse(sourceUrl);
  12089. if (parsedUrl.protocol === "file:" || parsedUrl.host) {
  12090. return parsedUrl;
  12091. }
  12092. if (/^[a-z]:[/\\]/i.test(sourceUrl)) {
  12093. return url.parse(`file:///${sourceUrl}`);
  12094. }
  12095. if (!parsedUrl.host) {
  12096. parsedUrl.protocol = "file:";
  12097. }
  12098. return parsedUrl;
  12099. }
  12100. class PDFNodeStream {
  12101. constructor(source) {
  12102. this.source = source;
  12103. this.url = parseUrl(source.url);
  12104. this.isHttp = this.url.protocol === "http:" || this.url.protocol === "https:";
  12105. this.isFsUrl = this.url.protocol === "file:";
  12106. this.httpHeaders = this.isHttp && source.httpHeaders || {};
  12107. this._fullRequestReader = null;
  12108. this._rangeRequestReaders = [];
  12109. }
  12110. get _progressiveDataLength() {
  12111. var _this$_fullRequestRea;
  12112. return ((_this$_fullRequestRea = this._fullRequestReader) === null || _this$_fullRequestRea === void 0 ? void 0 : _this$_fullRequestRea._loaded) ?? 0;
  12113. }
  12114. getFullReader() {
  12115. (0, _util.assert)(!this._fullRequestReader, "PDFNodeStream.getFullReader can only be called once.");
  12116. this._fullRequestReader = this.isFsUrl ? new PDFNodeStreamFsFullReader(this) : new PDFNodeStreamFullReader(this);
  12117. return this._fullRequestReader;
  12118. }
  12119. getRangeReader(start, end) {
  12120. if (end <= this._progressiveDataLength) {
  12121. return null;
  12122. }
  12123. const rangeReader = this.isFsUrl ? new PDFNodeStreamFsRangeReader(this, start, end) : new PDFNodeStreamRangeReader(this, start, end);
  12124. this._rangeRequestReaders.push(rangeReader);
  12125. return rangeReader;
  12126. }
  12127. cancelAllRequests(reason) {
  12128. var _this$_fullRequestRea2;
  12129. (_this$_fullRequestRea2 = this._fullRequestReader) === null || _this$_fullRequestRea2 === void 0 ? void 0 : _this$_fullRequestRea2.cancel(reason);
  12130. for (const reader of this._rangeRequestReaders.slice(0)) {
  12131. reader.cancel(reason);
  12132. }
  12133. }
  12134. }
  12135. exports.PDFNodeStream = PDFNodeStream;
  12136. class BaseFullReader {
  12137. constructor(stream) {
  12138. this._url = stream.url;
  12139. this._done = false;
  12140. this._storedError = null;
  12141. this.onProgress = null;
  12142. const source = stream.source;
  12143. this._contentLength = source.length;
  12144. this._loaded = 0;
  12145. this._filename = null;
  12146. this._disableRange = source.disableRange || false;
  12147. this._rangeChunkSize = source.rangeChunkSize;
  12148. if (!this._rangeChunkSize && !this._disableRange) {
  12149. this._disableRange = true;
  12150. }
  12151. this._isStreamingSupported = !source.disableStream;
  12152. this._isRangeSupported = !source.disableRange;
  12153. this._readableStream = null;
  12154. this._readCapability = (0, _util.createPromiseCapability)();
  12155. this._headersCapability = (0, _util.createPromiseCapability)();
  12156. }
  12157. get headersReady() {
  12158. return this._headersCapability.promise;
  12159. }
  12160. get filename() {
  12161. return this._filename;
  12162. }
  12163. get contentLength() {
  12164. return this._contentLength;
  12165. }
  12166. get isRangeSupported() {
  12167. return this._isRangeSupported;
  12168. }
  12169. get isStreamingSupported() {
  12170. return this._isStreamingSupported;
  12171. }
  12172. async read() {
  12173. var _this$onProgress;
  12174. await this._readCapability.promise;
  12175. if (this._done) {
  12176. return {
  12177. value: undefined,
  12178. done: true
  12179. };
  12180. }
  12181. if (this._storedError) {
  12182. throw this._storedError;
  12183. }
  12184. const chunk = this._readableStream.read();
  12185. if (chunk === null) {
  12186. this._readCapability = (0, _util.createPromiseCapability)();
  12187. return this.read();
  12188. }
  12189. this._loaded += chunk.length;
  12190. (_this$onProgress = this.onProgress) === null || _this$onProgress === void 0 ? void 0 : _this$onProgress.call(this, {
  12191. loaded: this._loaded,
  12192. total: this._contentLength
  12193. });
  12194. const buffer = new Uint8Array(chunk).buffer;
  12195. return {
  12196. value: buffer,
  12197. done: false
  12198. };
  12199. }
  12200. cancel(reason) {
  12201. if (!this._readableStream) {
  12202. this._error(reason);
  12203. return;
  12204. }
  12205. this._readableStream.destroy(reason);
  12206. }
  12207. _error(reason) {
  12208. this._storedError = reason;
  12209. this._readCapability.resolve();
  12210. }
  12211. _setReadableStream(readableStream) {
  12212. this._readableStream = readableStream;
  12213. readableStream.on("readable", () => {
  12214. this._readCapability.resolve();
  12215. });
  12216. readableStream.on("end", () => {
  12217. readableStream.destroy();
  12218. this._done = true;
  12219. this._readCapability.resolve();
  12220. });
  12221. readableStream.on("error", reason => {
  12222. this._error(reason);
  12223. });
  12224. if (!this._isStreamingSupported && this._isRangeSupported) {
  12225. this._error(new _util.AbortException("streaming is disabled"));
  12226. }
  12227. if (this._storedError) {
  12228. this._readableStream.destroy(this._storedError);
  12229. }
  12230. }
  12231. }
  12232. class BaseRangeReader {
  12233. constructor(stream) {
  12234. this._url = stream.url;
  12235. this._done = false;
  12236. this._storedError = null;
  12237. this.onProgress = null;
  12238. this._loaded = 0;
  12239. this._readableStream = null;
  12240. this._readCapability = (0, _util.createPromiseCapability)();
  12241. const source = stream.source;
  12242. this._isStreamingSupported = !source.disableStream;
  12243. }
  12244. get isStreamingSupported() {
  12245. return this._isStreamingSupported;
  12246. }
  12247. async read() {
  12248. var _this$onProgress2;
  12249. await this._readCapability.promise;
  12250. if (this._done) {
  12251. return {
  12252. value: undefined,
  12253. done: true
  12254. };
  12255. }
  12256. if (this._storedError) {
  12257. throw this._storedError;
  12258. }
  12259. const chunk = this._readableStream.read();
  12260. if (chunk === null) {
  12261. this._readCapability = (0, _util.createPromiseCapability)();
  12262. return this.read();
  12263. }
  12264. this._loaded += chunk.length;
  12265. (_this$onProgress2 = this.onProgress) === null || _this$onProgress2 === void 0 ? void 0 : _this$onProgress2.call(this, {
  12266. loaded: this._loaded
  12267. });
  12268. const buffer = new Uint8Array(chunk).buffer;
  12269. return {
  12270. value: buffer,
  12271. done: false
  12272. };
  12273. }
  12274. cancel(reason) {
  12275. if (!this._readableStream) {
  12276. this._error(reason);
  12277. return;
  12278. }
  12279. this._readableStream.destroy(reason);
  12280. }
  12281. _error(reason) {
  12282. this._storedError = reason;
  12283. this._readCapability.resolve();
  12284. }
  12285. _setReadableStream(readableStream) {
  12286. this._readableStream = readableStream;
  12287. readableStream.on("readable", () => {
  12288. this._readCapability.resolve();
  12289. });
  12290. readableStream.on("end", () => {
  12291. readableStream.destroy();
  12292. this._done = true;
  12293. this._readCapability.resolve();
  12294. });
  12295. readableStream.on("error", reason => {
  12296. this._error(reason);
  12297. });
  12298. if (this._storedError) {
  12299. this._readableStream.destroy(this._storedError);
  12300. }
  12301. }
  12302. }
  12303. function createRequestOptions(parsedUrl, headers) {
  12304. return {
  12305. protocol: parsedUrl.protocol,
  12306. auth: parsedUrl.auth,
  12307. host: parsedUrl.hostname,
  12308. port: parsedUrl.port,
  12309. path: parsedUrl.path,
  12310. method: "GET",
  12311. headers
  12312. };
  12313. }
  12314. class PDFNodeStreamFullReader extends BaseFullReader {
  12315. constructor(stream) {
  12316. super(stream);
  12317. const handleResponse = response => {
  12318. if (response.statusCode === 404) {
  12319. const error = new _util.MissingPDFException(`Missing PDF "${this._url}".`);
  12320. this._storedError = error;
  12321. this._headersCapability.reject(error);
  12322. return;
  12323. }
  12324. this._headersCapability.resolve();
  12325. this._setReadableStream(response);
  12326. const getResponseHeader = name => {
  12327. return this._readableStream.headers[name.toLowerCase()];
  12328. };
  12329. const {
  12330. allowRangeRequests,
  12331. suggestedLength
  12332. } = (0, _network_utils.validateRangeRequestCapabilities)({
  12333. getResponseHeader,
  12334. isHttp: stream.isHttp,
  12335. rangeChunkSize: this._rangeChunkSize,
  12336. disableRange: this._disableRange
  12337. });
  12338. this._isRangeSupported = allowRangeRequests;
  12339. this._contentLength = suggestedLength || this._contentLength;
  12340. this._filename = (0, _network_utils.extractFilenameFromHeader)(getResponseHeader);
  12341. };
  12342. this._request = null;
  12343. if (this._url.protocol === "http:") {
  12344. this._request = http.request(createRequestOptions(this._url, stream.httpHeaders), handleResponse);
  12345. } else {
  12346. this._request = https.request(createRequestOptions(this._url, stream.httpHeaders), handleResponse);
  12347. }
  12348. this._request.on("error", reason => {
  12349. this._storedError = reason;
  12350. this._headersCapability.reject(reason);
  12351. });
  12352. this._request.end();
  12353. }
  12354. }
  12355. class PDFNodeStreamRangeReader extends BaseRangeReader {
  12356. constructor(stream, start, end) {
  12357. super(stream);
  12358. this._httpHeaders = {};
  12359. for (const property in stream.httpHeaders) {
  12360. const value = stream.httpHeaders[property];
  12361. if (value === undefined) {
  12362. continue;
  12363. }
  12364. this._httpHeaders[property] = value;
  12365. }
  12366. this._httpHeaders.Range = `bytes=${start}-${end - 1}`;
  12367. const handleResponse = response => {
  12368. if (response.statusCode === 404) {
  12369. const error = new _util.MissingPDFException(`Missing PDF "${this._url}".`);
  12370. this._storedError = error;
  12371. return;
  12372. }
  12373. this._setReadableStream(response);
  12374. };
  12375. this._request = null;
  12376. if (this._url.protocol === "http:") {
  12377. this._request = http.request(createRequestOptions(this._url, this._httpHeaders), handleResponse);
  12378. } else {
  12379. this._request = https.request(createRequestOptions(this._url, this._httpHeaders), handleResponse);
  12380. }
  12381. this._request.on("error", reason => {
  12382. this._storedError = reason;
  12383. });
  12384. this._request.end();
  12385. }
  12386. }
  12387. class PDFNodeStreamFsFullReader extends BaseFullReader {
  12388. constructor(stream) {
  12389. super(stream);
  12390. let path = decodeURIComponent(this._url.path);
  12391. if (fileUriRegex.test(this._url.href)) {
  12392. path = path.replace(/^\//, "");
  12393. }
  12394. fs.lstat(path, (error, stat) => {
  12395. if (error) {
  12396. if (error.code === "ENOENT") {
  12397. error = new _util.MissingPDFException(`Missing PDF "${path}".`);
  12398. }
  12399. this._storedError = error;
  12400. this._headersCapability.reject(error);
  12401. return;
  12402. }
  12403. this._contentLength = stat.size;
  12404. this._setReadableStream(fs.createReadStream(path));
  12405. this._headersCapability.resolve();
  12406. });
  12407. }
  12408. }
  12409. class PDFNodeStreamFsRangeReader extends BaseRangeReader {
  12410. constructor(stream, start, end) {
  12411. super(stream);
  12412. let path = decodeURIComponent(this._url.path);
  12413. if (fileUriRegex.test(this._url.href)) {
  12414. path = path.replace(/^\//, "");
  12415. }
  12416. this._setReadableStream(fs.createReadStream(path, {
  12417. start,
  12418. end: end - 1
  12419. }));
  12420. }
  12421. }
  12422. /***/ }),
  12423. /* 154 */
  12424. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  12425. "use strict";
  12426. Object.defineProperty(exports, "__esModule", ({
  12427. value: true
  12428. }));
  12429. exports.createResponseStatusError = createResponseStatusError;
  12430. exports.extractFilenameFromHeader = extractFilenameFromHeader;
  12431. exports.validateRangeRequestCapabilities = validateRangeRequestCapabilities;
  12432. exports.validateResponseStatus = validateResponseStatus;
  12433. var _util = __w_pdfjs_require__(1);
  12434. var _content_disposition = __w_pdfjs_require__(155);
  12435. var _display_utils = __w_pdfjs_require__(139);
  12436. function validateRangeRequestCapabilities(_ref) {
  12437. let {
  12438. getResponseHeader,
  12439. isHttp,
  12440. rangeChunkSize,
  12441. disableRange
  12442. } = _ref;
  12443. const returnValues = {
  12444. allowRangeRequests: false,
  12445. suggestedLength: undefined
  12446. };
  12447. const length = parseInt(getResponseHeader("Content-Length"), 10);
  12448. if (!Number.isInteger(length)) {
  12449. return returnValues;
  12450. }
  12451. returnValues.suggestedLength = length;
  12452. if (length <= 2 * rangeChunkSize) {
  12453. return returnValues;
  12454. }
  12455. if (disableRange || !isHttp) {
  12456. return returnValues;
  12457. }
  12458. if (getResponseHeader("Accept-Ranges") !== "bytes") {
  12459. return returnValues;
  12460. }
  12461. const contentEncoding = getResponseHeader("Content-Encoding") || "identity";
  12462. if (contentEncoding !== "identity") {
  12463. return returnValues;
  12464. }
  12465. returnValues.allowRangeRequests = true;
  12466. return returnValues;
  12467. }
  12468. function extractFilenameFromHeader(getResponseHeader) {
  12469. const contentDisposition = getResponseHeader("Content-Disposition");
  12470. if (contentDisposition) {
  12471. let filename = (0, _content_disposition.getFilenameFromContentDispositionHeader)(contentDisposition);
  12472. if (filename.includes("%")) {
  12473. try {
  12474. filename = decodeURIComponent(filename);
  12475. } catch (ex) {}
  12476. }
  12477. if ((0, _display_utils.isPdfFile)(filename)) {
  12478. return filename;
  12479. }
  12480. }
  12481. return null;
  12482. }
  12483. function createResponseStatusError(status, url) {
  12484. if (status === 404 || status === 0 && url.startsWith("file:")) {
  12485. return new _util.MissingPDFException('Missing PDF "' + url + '".');
  12486. }
  12487. return new _util.UnexpectedResponseException(`Unexpected server response (${status}) while retrieving PDF "${url}".`, status);
  12488. }
  12489. function validateResponseStatus(status) {
  12490. return status === 200 || status === 206;
  12491. }
  12492. /***/ }),
  12493. /* 155 */
  12494. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  12495. "use strict";
  12496. Object.defineProperty(exports, "__esModule", ({
  12497. value: true
  12498. }));
  12499. exports.getFilenameFromContentDispositionHeader = getFilenameFromContentDispositionHeader;
  12500. var _util = __w_pdfjs_require__(1);
  12501. function getFilenameFromContentDispositionHeader(contentDisposition) {
  12502. let needsEncodingFixup = true;
  12503. let tmp = toParamRegExp("filename\\*", "i").exec(contentDisposition);
  12504. if (tmp) {
  12505. tmp = tmp[1];
  12506. let filename = rfc2616unquote(tmp);
  12507. filename = unescape(filename);
  12508. filename = rfc5987decode(filename);
  12509. filename = rfc2047decode(filename);
  12510. return fixupEncoding(filename);
  12511. }
  12512. tmp = rfc2231getparam(contentDisposition);
  12513. if (tmp) {
  12514. const filename = rfc2047decode(tmp);
  12515. return fixupEncoding(filename);
  12516. }
  12517. tmp = toParamRegExp("filename", "i").exec(contentDisposition);
  12518. if (tmp) {
  12519. tmp = tmp[1];
  12520. let filename = rfc2616unquote(tmp);
  12521. filename = rfc2047decode(filename);
  12522. return fixupEncoding(filename);
  12523. }
  12524. function toParamRegExp(attributePattern, flags) {
  12525. return new RegExp("(?:^|;)\\s*" + attributePattern + "\\s*=\\s*" + "(" + '[^";\\s][^;\\s]*' + "|" + '"(?:[^"\\\\]|\\\\"?)+"?' + ")", flags);
  12526. }
  12527. function textdecode(encoding, value) {
  12528. if (encoding) {
  12529. if (!/^[\x00-\xFF]+$/.test(value)) {
  12530. return value;
  12531. }
  12532. try {
  12533. const decoder = new TextDecoder(encoding, {
  12534. fatal: true
  12535. });
  12536. const buffer = (0, _util.stringToBytes)(value);
  12537. value = decoder.decode(buffer);
  12538. needsEncodingFixup = false;
  12539. } catch (e) {}
  12540. }
  12541. return value;
  12542. }
  12543. function fixupEncoding(value) {
  12544. if (needsEncodingFixup && /[\x80-\xff]/.test(value)) {
  12545. value = textdecode("utf-8", value);
  12546. if (needsEncodingFixup) {
  12547. value = textdecode("iso-8859-1", value);
  12548. }
  12549. }
  12550. return value;
  12551. }
  12552. function rfc2231getparam(contentDispositionStr) {
  12553. const matches = [];
  12554. let match;
  12555. const iter = toParamRegExp("filename\\*((?!0\\d)\\d+)(\\*?)", "ig");
  12556. while ((match = iter.exec(contentDispositionStr)) !== null) {
  12557. let [, n, quot, part] = match;
  12558. n = parseInt(n, 10);
  12559. if (n in matches) {
  12560. if (n === 0) {
  12561. break;
  12562. }
  12563. continue;
  12564. }
  12565. matches[n] = [quot, part];
  12566. }
  12567. const parts = [];
  12568. for (let n = 0; n < matches.length; ++n) {
  12569. if (!(n in matches)) {
  12570. break;
  12571. }
  12572. let [quot, part] = matches[n];
  12573. part = rfc2616unquote(part);
  12574. if (quot) {
  12575. part = unescape(part);
  12576. if (n === 0) {
  12577. part = rfc5987decode(part);
  12578. }
  12579. }
  12580. parts.push(part);
  12581. }
  12582. return parts.join("");
  12583. }
  12584. function rfc2616unquote(value) {
  12585. if (value.startsWith('"')) {
  12586. const parts = value.slice(1).split('\\"');
  12587. for (let i = 0; i < parts.length; ++i) {
  12588. const quotindex = parts[i].indexOf('"');
  12589. if (quotindex !== -1) {
  12590. parts[i] = parts[i].slice(0, quotindex);
  12591. parts.length = i + 1;
  12592. }
  12593. parts[i] = parts[i].replace(/\\(.)/g, "$1");
  12594. }
  12595. value = parts.join('"');
  12596. }
  12597. return value;
  12598. }
  12599. function rfc5987decode(extvalue) {
  12600. const encodingend = extvalue.indexOf("'");
  12601. if (encodingend === -1) {
  12602. return extvalue;
  12603. }
  12604. const encoding = extvalue.slice(0, encodingend);
  12605. const langvalue = extvalue.slice(encodingend + 1);
  12606. const value = langvalue.replace(/^[^']*'/, "");
  12607. return textdecode(encoding, value);
  12608. }
  12609. function rfc2047decode(value) {
  12610. if (!value.startsWith("=?") || /[\x00-\x19\x80-\xff]/.test(value)) {
  12611. return value;
  12612. }
  12613. return value.replace(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g, function (matches, charset, encoding, text) {
  12614. if (encoding === "q" || encoding === "Q") {
  12615. text = text.replace(/_/g, " ");
  12616. text = text.replace(/=([0-9a-fA-F]{2})/g, function (match, hex) {
  12617. return String.fromCharCode(parseInt(hex, 16));
  12618. });
  12619. return textdecode(charset, text);
  12620. }
  12621. try {
  12622. text = atob(text);
  12623. } catch (e) {}
  12624. return textdecode(charset, text);
  12625. });
  12626. }
  12627. return "";
  12628. }
  12629. /***/ }),
  12630. /* 156 */
  12631. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  12632. "use strict";
  12633. Object.defineProperty(exports, "__esModule", ({
  12634. value: true
  12635. }));
  12636. exports.PDFNetworkStream = void 0;
  12637. var _util = __w_pdfjs_require__(1);
  12638. var _network_utils = __w_pdfjs_require__(154);
  12639. ;
  12640. const OK_RESPONSE = 200;
  12641. const PARTIAL_CONTENT_RESPONSE = 206;
  12642. function getArrayBuffer(xhr) {
  12643. const data = xhr.response;
  12644. if (typeof data !== "string") {
  12645. return data;
  12646. }
  12647. return (0, _util.stringToBytes)(data).buffer;
  12648. }
  12649. class NetworkManager {
  12650. constructor(url) {
  12651. let args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  12652. this.url = url;
  12653. this.isHttp = /^https?:/i.test(url);
  12654. this.httpHeaders = this.isHttp && args.httpHeaders || Object.create(null);
  12655. this.withCredentials = args.withCredentials || false;
  12656. this.getXhr = args.getXhr || function NetworkManager_getXhr() {
  12657. return new XMLHttpRequest();
  12658. };
  12659. this.currXhrId = 0;
  12660. this.pendingRequests = Object.create(null);
  12661. }
  12662. requestRange(begin, end, listeners) {
  12663. const args = {
  12664. begin,
  12665. end
  12666. };
  12667. for (const prop in listeners) {
  12668. args[prop] = listeners[prop];
  12669. }
  12670. return this.request(args);
  12671. }
  12672. requestFull(listeners) {
  12673. return this.request(listeners);
  12674. }
  12675. request(args) {
  12676. const xhr = this.getXhr();
  12677. const xhrId = this.currXhrId++;
  12678. const pendingRequest = this.pendingRequests[xhrId] = {
  12679. xhr
  12680. };
  12681. xhr.open("GET", this.url);
  12682. xhr.withCredentials = this.withCredentials;
  12683. for (const property in this.httpHeaders) {
  12684. const value = this.httpHeaders[property];
  12685. if (value === undefined) {
  12686. continue;
  12687. }
  12688. xhr.setRequestHeader(property, value);
  12689. }
  12690. if (this.isHttp && "begin" in args && "end" in args) {
  12691. xhr.setRequestHeader("Range", `bytes=${args.begin}-${args.end - 1}`);
  12692. pendingRequest.expectedStatus = PARTIAL_CONTENT_RESPONSE;
  12693. } else {
  12694. pendingRequest.expectedStatus = OK_RESPONSE;
  12695. }
  12696. xhr.responseType = "arraybuffer";
  12697. if (args.onError) {
  12698. xhr.onerror = function (evt) {
  12699. args.onError(xhr.status);
  12700. };
  12701. }
  12702. xhr.onreadystatechange = this.onStateChange.bind(this, xhrId);
  12703. xhr.onprogress = this.onProgress.bind(this, xhrId);
  12704. pendingRequest.onHeadersReceived = args.onHeadersReceived;
  12705. pendingRequest.onDone = args.onDone;
  12706. pendingRequest.onError = args.onError;
  12707. pendingRequest.onProgress = args.onProgress;
  12708. xhr.send(null);
  12709. return xhrId;
  12710. }
  12711. onProgress(xhrId, evt) {
  12712. var _pendingRequest$onPro;
  12713. const pendingRequest = this.pendingRequests[xhrId];
  12714. if (!pendingRequest) {
  12715. return;
  12716. }
  12717. (_pendingRequest$onPro = pendingRequest.onProgress) === null || _pendingRequest$onPro === void 0 ? void 0 : _pendingRequest$onPro.call(pendingRequest, evt);
  12718. }
  12719. onStateChange(xhrId, evt) {
  12720. const pendingRequest = this.pendingRequests[xhrId];
  12721. if (!pendingRequest) {
  12722. return;
  12723. }
  12724. const xhr = pendingRequest.xhr;
  12725. if (xhr.readyState >= 2 && pendingRequest.onHeadersReceived) {
  12726. pendingRequest.onHeadersReceived();
  12727. delete pendingRequest.onHeadersReceived;
  12728. }
  12729. if (xhr.readyState !== 4) {
  12730. return;
  12731. }
  12732. if (!(xhrId in this.pendingRequests)) {
  12733. return;
  12734. }
  12735. delete this.pendingRequests[xhrId];
  12736. if (xhr.status === 0 && this.isHttp) {
  12737. var _pendingRequest$onErr;
  12738. (_pendingRequest$onErr = pendingRequest.onError) === null || _pendingRequest$onErr === void 0 ? void 0 : _pendingRequest$onErr.call(pendingRequest, xhr.status);
  12739. return;
  12740. }
  12741. const xhrStatus = xhr.status || OK_RESPONSE;
  12742. const ok_response_on_range_request = xhrStatus === OK_RESPONSE && pendingRequest.expectedStatus === PARTIAL_CONTENT_RESPONSE;
  12743. if (!ok_response_on_range_request && xhrStatus !== pendingRequest.expectedStatus) {
  12744. var _pendingRequest$onErr2;
  12745. (_pendingRequest$onErr2 = pendingRequest.onError) === null || _pendingRequest$onErr2 === void 0 ? void 0 : _pendingRequest$onErr2.call(pendingRequest, xhr.status);
  12746. return;
  12747. }
  12748. const chunk = getArrayBuffer(xhr);
  12749. if (xhrStatus === PARTIAL_CONTENT_RESPONSE) {
  12750. const rangeHeader = xhr.getResponseHeader("Content-Range");
  12751. const matches = /bytes (\d+)-(\d+)\/(\d+)/.exec(rangeHeader);
  12752. pendingRequest.onDone({
  12753. begin: parseInt(matches[1], 10),
  12754. chunk
  12755. });
  12756. } else if (chunk) {
  12757. pendingRequest.onDone({
  12758. begin: 0,
  12759. chunk
  12760. });
  12761. } else {
  12762. var _pendingRequest$onErr3;
  12763. (_pendingRequest$onErr3 = pendingRequest.onError) === null || _pendingRequest$onErr3 === void 0 ? void 0 : _pendingRequest$onErr3.call(pendingRequest, xhr.status);
  12764. }
  12765. }
  12766. getRequestXhr(xhrId) {
  12767. return this.pendingRequests[xhrId].xhr;
  12768. }
  12769. isPendingRequest(xhrId) {
  12770. return xhrId in this.pendingRequests;
  12771. }
  12772. abortRequest(xhrId) {
  12773. const xhr = this.pendingRequests[xhrId].xhr;
  12774. delete this.pendingRequests[xhrId];
  12775. xhr.abort();
  12776. }
  12777. }
  12778. class PDFNetworkStream {
  12779. constructor(source) {
  12780. this._source = source;
  12781. this._manager = new NetworkManager(source.url, {
  12782. httpHeaders: source.httpHeaders,
  12783. withCredentials: source.withCredentials
  12784. });
  12785. this._rangeChunkSize = source.rangeChunkSize;
  12786. this._fullRequestReader = null;
  12787. this._rangeRequestReaders = [];
  12788. }
  12789. _onRangeRequestReaderClosed(reader) {
  12790. const i = this._rangeRequestReaders.indexOf(reader);
  12791. if (i >= 0) {
  12792. this._rangeRequestReaders.splice(i, 1);
  12793. }
  12794. }
  12795. getFullReader() {
  12796. (0, _util.assert)(!this._fullRequestReader, "PDFNetworkStream.getFullReader can only be called once.");
  12797. this._fullRequestReader = new PDFNetworkStreamFullRequestReader(this._manager, this._source);
  12798. return this._fullRequestReader;
  12799. }
  12800. getRangeReader(begin, end) {
  12801. const reader = new PDFNetworkStreamRangeRequestReader(this._manager, begin, end);
  12802. reader.onClosed = this._onRangeRequestReaderClosed.bind(this);
  12803. this._rangeRequestReaders.push(reader);
  12804. return reader;
  12805. }
  12806. cancelAllRequests(reason) {
  12807. var _this$_fullRequestRea;
  12808. (_this$_fullRequestRea = this._fullRequestReader) === null || _this$_fullRequestRea === void 0 ? void 0 : _this$_fullRequestRea.cancel(reason);
  12809. for (const reader of this._rangeRequestReaders.slice(0)) {
  12810. reader.cancel(reason);
  12811. }
  12812. }
  12813. }
  12814. exports.PDFNetworkStream = PDFNetworkStream;
  12815. class PDFNetworkStreamFullRequestReader {
  12816. constructor(manager, source) {
  12817. this._manager = manager;
  12818. const args = {
  12819. onHeadersReceived: this._onHeadersReceived.bind(this),
  12820. onDone: this._onDone.bind(this),
  12821. onError: this._onError.bind(this),
  12822. onProgress: this._onProgress.bind(this)
  12823. };
  12824. this._url = source.url;
  12825. this._fullRequestId = manager.requestFull(args);
  12826. this._headersReceivedCapability = (0, _util.createPromiseCapability)();
  12827. this._disableRange = source.disableRange || false;
  12828. this._contentLength = source.length;
  12829. this._rangeChunkSize = source.rangeChunkSize;
  12830. if (!this._rangeChunkSize && !this._disableRange) {
  12831. this._disableRange = true;
  12832. }
  12833. this._isStreamingSupported = false;
  12834. this._isRangeSupported = false;
  12835. this._cachedChunks = [];
  12836. this._requests = [];
  12837. this._done = false;
  12838. this._storedError = undefined;
  12839. this._filename = null;
  12840. this.onProgress = null;
  12841. }
  12842. _onHeadersReceived() {
  12843. const fullRequestXhrId = this._fullRequestId;
  12844. const fullRequestXhr = this._manager.getRequestXhr(fullRequestXhrId);
  12845. const getResponseHeader = name => {
  12846. return fullRequestXhr.getResponseHeader(name);
  12847. };
  12848. const {
  12849. allowRangeRequests,
  12850. suggestedLength
  12851. } = (0, _network_utils.validateRangeRequestCapabilities)({
  12852. getResponseHeader,
  12853. isHttp: this._manager.isHttp,
  12854. rangeChunkSize: this._rangeChunkSize,
  12855. disableRange: this._disableRange
  12856. });
  12857. if (allowRangeRequests) {
  12858. this._isRangeSupported = true;
  12859. }
  12860. this._contentLength = suggestedLength || this._contentLength;
  12861. this._filename = (0, _network_utils.extractFilenameFromHeader)(getResponseHeader);
  12862. if (this._isRangeSupported) {
  12863. this._manager.abortRequest(fullRequestXhrId);
  12864. }
  12865. this._headersReceivedCapability.resolve();
  12866. }
  12867. _onDone(data) {
  12868. if (data) {
  12869. if (this._requests.length > 0) {
  12870. const requestCapability = this._requests.shift();
  12871. requestCapability.resolve({
  12872. value: data.chunk,
  12873. done: false
  12874. });
  12875. } else {
  12876. this._cachedChunks.push(data.chunk);
  12877. }
  12878. }
  12879. this._done = true;
  12880. if (this._cachedChunks.length > 0) {
  12881. return;
  12882. }
  12883. for (const requestCapability of this._requests) {
  12884. requestCapability.resolve({
  12885. value: undefined,
  12886. done: true
  12887. });
  12888. }
  12889. this._requests.length = 0;
  12890. }
  12891. _onError(status) {
  12892. this._storedError = (0, _network_utils.createResponseStatusError)(status, this._url);
  12893. this._headersReceivedCapability.reject(this._storedError);
  12894. for (const requestCapability of this._requests) {
  12895. requestCapability.reject(this._storedError);
  12896. }
  12897. this._requests.length = 0;
  12898. this._cachedChunks.length = 0;
  12899. }
  12900. _onProgress(evt) {
  12901. var _this$onProgress;
  12902. (_this$onProgress = this.onProgress) === null || _this$onProgress === void 0 ? void 0 : _this$onProgress.call(this, {
  12903. loaded: evt.loaded,
  12904. total: evt.lengthComputable ? evt.total : this._contentLength
  12905. });
  12906. }
  12907. get filename() {
  12908. return this._filename;
  12909. }
  12910. get isRangeSupported() {
  12911. return this._isRangeSupported;
  12912. }
  12913. get isStreamingSupported() {
  12914. return this._isStreamingSupported;
  12915. }
  12916. get contentLength() {
  12917. return this._contentLength;
  12918. }
  12919. get headersReady() {
  12920. return this._headersReceivedCapability.promise;
  12921. }
  12922. async read() {
  12923. if (this._storedError) {
  12924. throw this._storedError;
  12925. }
  12926. if (this._cachedChunks.length > 0) {
  12927. const chunk = this._cachedChunks.shift();
  12928. return {
  12929. value: chunk,
  12930. done: false
  12931. };
  12932. }
  12933. if (this._done) {
  12934. return {
  12935. value: undefined,
  12936. done: true
  12937. };
  12938. }
  12939. const requestCapability = (0, _util.createPromiseCapability)();
  12940. this._requests.push(requestCapability);
  12941. return requestCapability.promise;
  12942. }
  12943. cancel(reason) {
  12944. this._done = true;
  12945. this._headersReceivedCapability.reject(reason);
  12946. for (const requestCapability of this._requests) {
  12947. requestCapability.resolve({
  12948. value: undefined,
  12949. done: true
  12950. });
  12951. }
  12952. this._requests.length = 0;
  12953. if (this._manager.isPendingRequest(this._fullRequestId)) {
  12954. this._manager.abortRequest(this._fullRequestId);
  12955. }
  12956. this._fullRequestReader = null;
  12957. }
  12958. }
  12959. class PDFNetworkStreamRangeRequestReader {
  12960. constructor(manager, begin, end) {
  12961. this._manager = manager;
  12962. const args = {
  12963. onDone: this._onDone.bind(this),
  12964. onError: this._onError.bind(this),
  12965. onProgress: this._onProgress.bind(this)
  12966. };
  12967. this._url = manager.url;
  12968. this._requestId = manager.requestRange(begin, end, args);
  12969. this._requests = [];
  12970. this._queuedChunk = null;
  12971. this._done = false;
  12972. this._storedError = undefined;
  12973. this.onProgress = null;
  12974. this.onClosed = null;
  12975. }
  12976. _close() {
  12977. var _this$onClosed;
  12978. (_this$onClosed = this.onClosed) === null || _this$onClosed === void 0 ? void 0 : _this$onClosed.call(this, this);
  12979. }
  12980. _onDone(data) {
  12981. const chunk = data.chunk;
  12982. if (this._requests.length > 0) {
  12983. const requestCapability = this._requests.shift();
  12984. requestCapability.resolve({
  12985. value: chunk,
  12986. done: false
  12987. });
  12988. } else {
  12989. this._queuedChunk = chunk;
  12990. }
  12991. this._done = true;
  12992. for (const requestCapability of this._requests) {
  12993. requestCapability.resolve({
  12994. value: undefined,
  12995. done: true
  12996. });
  12997. }
  12998. this._requests.length = 0;
  12999. this._close();
  13000. }
  13001. _onError(status) {
  13002. this._storedError = (0, _network_utils.createResponseStatusError)(status, this._url);
  13003. for (const requestCapability of this._requests) {
  13004. requestCapability.reject(this._storedError);
  13005. }
  13006. this._requests.length = 0;
  13007. this._queuedChunk = null;
  13008. }
  13009. _onProgress(evt) {
  13010. if (!this.isStreamingSupported) {
  13011. var _this$onProgress2;
  13012. (_this$onProgress2 = this.onProgress) === null || _this$onProgress2 === void 0 ? void 0 : _this$onProgress2.call(this, {
  13013. loaded: evt.loaded
  13014. });
  13015. }
  13016. }
  13017. get isStreamingSupported() {
  13018. return false;
  13019. }
  13020. async read() {
  13021. if (this._storedError) {
  13022. throw this._storedError;
  13023. }
  13024. if (this._queuedChunk !== null) {
  13025. const chunk = this._queuedChunk;
  13026. this._queuedChunk = null;
  13027. return {
  13028. value: chunk,
  13029. done: false
  13030. };
  13031. }
  13032. if (this._done) {
  13033. return {
  13034. value: undefined,
  13035. done: true
  13036. };
  13037. }
  13038. const requestCapability = (0, _util.createPromiseCapability)();
  13039. this._requests.push(requestCapability);
  13040. return requestCapability.promise;
  13041. }
  13042. cancel(reason) {
  13043. this._done = true;
  13044. for (const requestCapability of this._requests) {
  13045. requestCapability.resolve({
  13046. value: undefined,
  13047. done: true
  13048. });
  13049. }
  13050. this._requests.length = 0;
  13051. if (this._manager.isPendingRequest(this._requestId)) {
  13052. this._manager.abortRequest(this._requestId);
  13053. }
  13054. this._close();
  13055. }
  13056. }
  13057. /***/ }),
  13058. /* 157 */
  13059. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  13060. "use strict";
  13061. Object.defineProperty(exports, "__esModule", ({
  13062. value: true
  13063. }));
  13064. exports.PDFFetchStream = void 0;
  13065. var _util = __w_pdfjs_require__(1);
  13066. var _network_utils = __w_pdfjs_require__(154);
  13067. ;
  13068. function createFetchOptions(headers, withCredentials, abortController) {
  13069. return {
  13070. method: "GET",
  13071. headers,
  13072. signal: abortController.signal,
  13073. mode: "cors",
  13074. credentials: withCredentials ? "include" : "same-origin",
  13075. redirect: "follow"
  13076. };
  13077. }
  13078. function createHeaders(httpHeaders) {
  13079. const headers = new Headers();
  13080. for (const property in httpHeaders) {
  13081. const value = httpHeaders[property];
  13082. if (value === undefined) {
  13083. continue;
  13084. }
  13085. headers.append(property, value);
  13086. }
  13087. return headers;
  13088. }
  13089. function getArrayBuffer(val) {
  13090. if (val instanceof Uint8Array) {
  13091. return val.buffer;
  13092. }
  13093. if (val instanceof ArrayBuffer) {
  13094. return val;
  13095. }
  13096. (0, _util.warn)(`getArrayBuffer - unexpected data format: ${val}`);
  13097. return new Uint8Array(val).buffer;
  13098. }
  13099. class PDFFetchStream {
  13100. constructor(source) {
  13101. this.source = source;
  13102. this.isHttp = /^https?:/i.test(source.url);
  13103. this.httpHeaders = this.isHttp && source.httpHeaders || {};
  13104. this._fullRequestReader = null;
  13105. this._rangeRequestReaders = [];
  13106. }
  13107. get _progressiveDataLength() {
  13108. var _this$_fullRequestRea;
  13109. return ((_this$_fullRequestRea = this._fullRequestReader) === null || _this$_fullRequestRea === void 0 ? void 0 : _this$_fullRequestRea._loaded) ?? 0;
  13110. }
  13111. getFullReader() {
  13112. (0, _util.assert)(!this._fullRequestReader, "PDFFetchStream.getFullReader can only be called once.");
  13113. this._fullRequestReader = new PDFFetchStreamReader(this);
  13114. return this._fullRequestReader;
  13115. }
  13116. getRangeReader(begin, end) {
  13117. if (end <= this._progressiveDataLength) {
  13118. return null;
  13119. }
  13120. const reader = new PDFFetchStreamRangeReader(this, begin, end);
  13121. this._rangeRequestReaders.push(reader);
  13122. return reader;
  13123. }
  13124. cancelAllRequests(reason) {
  13125. var _this$_fullRequestRea2;
  13126. (_this$_fullRequestRea2 = this._fullRequestReader) === null || _this$_fullRequestRea2 === void 0 ? void 0 : _this$_fullRequestRea2.cancel(reason);
  13127. for (const reader of this._rangeRequestReaders.slice(0)) {
  13128. reader.cancel(reason);
  13129. }
  13130. }
  13131. }
  13132. exports.PDFFetchStream = PDFFetchStream;
  13133. class PDFFetchStreamReader {
  13134. constructor(stream) {
  13135. this._stream = stream;
  13136. this._reader = null;
  13137. this._loaded = 0;
  13138. this._filename = null;
  13139. const source = stream.source;
  13140. this._withCredentials = source.withCredentials || false;
  13141. this._contentLength = source.length;
  13142. this._headersCapability = (0, _util.createPromiseCapability)();
  13143. this._disableRange = source.disableRange || false;
  13144. this._rangeChunkSize = source.rangeChunkSize;
  13145. if (!this._rangeChunkSize && !this._disableRange) {
  13146. this._disableRange = true;
  13147. }
  13148. this._abortController = new AbortController();
  13149. this._isStreamingSupported = !source.disableStream;
  13150. this._isRangeSupported = !source.disableRange;
  13151. this._headers = createHeaders(this._stream.httpHeaders);
  13152. const url = source.url;
  13153. fetch(url, createFetchOptions(this._headers, this._withCredentials, this._abortController)).then(response => {
  13154. if (!(0, _network_utils.validateResponseStatus)(response.status)) {
  13155. throw (0, _network_utils.createResponseStatusError)(response.status, url);
  13156. }
  13157. this._reader = response.body.getReader();
  13158. this._headersCapability.resolve();
  13159. const getResponseHeader = name => {
  13160. return response.headers.get(name);
  13161. };
  13162. const {
  13163. allowRangeRequests,
  13164. suggestedLength
  13165. } = (0, _network_utils.validateRangeRequestCapabilities)({
  13166. getResponseHeader,
  13167. isHttp: this._stream.isHttp,
  13168. rangeChunkSize: this._rangeChunkSize,
  13169. disableRange: this._disableRange
  13170. });
  13171. this._isRangeSupported = allowRangeRequests;
  13172. this._contentLength = suggestedLength || this._contentLength;
  13173. this._filename = (0, _network_utils.extractFilenameFromHeader)(getResponseHeader);
  13174. if (!this._isStreamingSupported && this._isRangeSupported) {
  13175. this.cancel(new _util.AbortException("Streaming is disabled."));
  13176. }
  13177. }).catch(this._headersCapability.reject);
  13178. this.onProgress = null;
  13179. }
  13180. get headersReady() {
  13181. return this._headersCapability.promise;
  13182. }
  13183. get filename() {
  13184. return this._filename;
  13185. }
  13186. get contentLength() {
  13187. return this._contentLength;
  13188. }
  13189. get isRangeSupported() {
  13190. return this._isRangeSupported;
  13191. }
  13192. get isStreamingSupported() {
  13193. return this._isStreamingSupported;
  13194. }
  13195. async read() {
  13196. var _this$onProgress;
  13197. await this._headersCapability.promise;
  13198. const {
  13199. value,
  13200. done
  13201. } = await this._reader.read();
  13202. if (done) {
  13203. return {
  13204. value,
  13205. done
  13206. };
  13207. }
  13208. this._loaded += value.byteLength;
  13209. (_this$onProgress = this.onProgress) === null || _this$onProgress === void 0 ? void 0 : _this$onProgress.call(this, {
  13210. loaded: this._loaded,
  13211. total: this._contentLength
  13212. });
  13213. return {
  13214. value: getArrayBuffer(value),
  13215. done: false
  13216. };
  13217. }
  13218. cancel(reason) {
  13219. var _this$_reader;
  13220. (_this$_reader = this._reader) === null || _this$_reader === void 0 ? void 0 : _this$_reader.cancel(reason);
  13221. this._abortController.abort();
  13222. }
  13223. }
  13224. class PDFFetchStreamRangeReader {
  13225. constructor(stream, begin, end) {
  13226. this._stream = stream;
  13227. this._reader = null;
  13228. this._loaded = 0;
  13229. const source = stream.source;
  13230. this._withCredentials = source.withCredentials || false;
  13231. this._readCapability = (0, _util.createPromiseCapability)();
  13232. this._isStreamingSupported = !source.disableStream;
  13233. this._abortController = new AbortController();
  13234. this._headers = createHeaders(this._stream.httpHeaders);
  13235. this._headers.append("Range", `bytes=${begin}-${end - 1}`);
  13236. const url = source.url;
  13237. fetch(url, createFetchOptions(this._headers, this._withCredentials, this._abortController)).then(response => {
  13238. if (!(0, _network_utils.validateResponseStatus)(response.status)) {
  13239. throw (0, _network_utils.createResponseStatusError)(response.status, url);
  13240. }
  13241. this._readCapability.resolve();
  13242. this._reader = response.body.getReader();
  13243. }).catch(this._readCapability.reject);
  13244. this.onProgress = null;
  13245. }
  13246. get isStreamingSupported() {
  13247. return this._isStreamingSupported;
  13248. }
  13249. async read() {
  13250. var _this$onProgress2;
  13251. await this._readCapability.promise;
  13252. const {
  13253. value,
  13254. done
  13255. } = await this._reader.read();
  13256. if (done) {
  13257. return {
  13258. value,
  13259. done
  13260. };
  13261. }
  13262. this._loaded += value.byteLength;
  13263. (_this$onProgress2 = this.onProgress) === null || _this$onProgress2 === void 0 ? void 0 : _this$onProgress2.call(this, {
  13264. loaded: this._loaded
  13265. });
  13266. return {
  13267. value: getArrayBuffer(value),
  13268. done: false
  13269. };
  13270. }
  13271. cancel(reason) {
  13272. var _this$_reader2;
  13273. (_this$_reader2 = this._reader) === null || _this$_reader2 === void 0 ? void 0 : _this$_reader2.cancel(reason);
  13274. this._abortController.abort();
  13275. }
  13276. }
  13277. /***/ }),
  13278. /* 158 */
  13279. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  13280. "use strict";
  13281. Object.defineProperty(exports, "__esModule", ({
  13282. value: true
  13283. }));
  13284. exports.TextLayerRenderTask = void 0;
  13285. exports.renderTextLayer = renderTextLayer;
  13286. exports.updateTextLayer = updateTextLayer;
  13287. var _util = __w_pdfjs_require__(1);
  13288. var _display_utils = __w_pdfjs_require__(139);
  13289. const MAX_TEXT_DIVS_TO_RENDER = 100000;
  13290. const DEFAULT_FONT_SIZE = 30;
  13291. const DEFAULT_FONT_ASCENT = 0.8;
  13292. const ascentCache = new Map();
  13293. function getCtx(size, isOffscreenCanvasSupported) {
  13294. let ctx;
  13295. if (isOffscreenCanvasSupported && _util.FeatureTest.isOffscreenCanvasSupported) {
  13296. ctx = new OffscreenCanvas(size, size).getContext("2d", {
  13297. alpha: false
  13298. });
  13299. } else {
  13300. const canvas = document.createElement("canvas");
  13301. canvas.width = canvas.height = size;
  13302. ctx = canvas.getContext("2d", {
  13303. alpha: false
  13304. });
  13305. }
  13306. return ctx;
  13307. }
  13308. function getAscent(fontFamily, isOffscreenCanvasSupported) {
  13309. const cachedAscent = ascentCache.get(fontFamily);
  13310. if (cachedAscent) {
  13311. return cachedAscent;
  13312. }
  13313. const ctx = getCtx(DEFAULT_FONT_SIZE, isOffscreenCanvasSupported);
  13314. ctx.font = `${DEFAULT_FONT_SIZE}px ${fontFamily}`;
  13315. const metrics = ctx.measureText("");
  13316. let ascent = metrics.fontBoundingBoxAscent;
  13317. let descent = Math.abs(metrics.fontBoundingBoxDescent);
  13318. if (ascent) {
  13319. const ratio = ascent / (ascent + descent);
  13320. ascentCache.set(fontFamily, ratio);
  13321. ctx.canvas.width = ctx.canvas.height = 0;
  13322. return ratio;
  13323. }
  13324. ctx.strokeStyle = "red";
  13325. ctx.clearRect(0, 0, DEFAULT_FONT_SIZE, DEFAULT_FONT_SIZE);
  13326. ctx.strokeText("g", 0, 0);
  13327. let pixels = ctx.getImageData(0, 0, DEFAULT_FONT_SIZE, DEFAULT_FONT_SIZE).data;
  13328. descent = 0;
  13329. for (let i = pixels.length - 1 - 3; i >= 0; i -= 4) {
  13330. if (pixels[i] > 0) {
  13331. descent = Math.ceil(i / 4 / DEFAULT_FONT_SIZE);
  13332. break;
  13333. }
  13334. }
  13335. ctx.clearRect(0, 0, DEFAULT_FONT_SIZE, DEFAULT_FONT_SIZE);
  13336. ctx.strokeText("A", 0, DEFAULT_FONT_SIZE);
  13337. pixels = ctx.getImageData(0, 0, DEFAULT_FONT_SIZE, DEFAULT_FONT_SIZE).data;
  13338. ascent = 0;
  13339. for (let i = 0, ii = pixels.length; i < ii; i += 4) {
  13340. if (pixels[i] > 0) {
  13341. ascent = DEFAULT_FONT_SIZE - Math.floor(i / 4 / DEFAULT_FONT_SIZE);
  13342. break;
  13343. }
  13344. }
  13345. ctx.canvas.width = ctx.canvas.height = 0;
  13346. if (ascent) {
  13347. const ratio = ascent / (ascent + descent);
  13348. ascentCache.set(fontFamily, ratio);
  13349. return ratio;
  13350. }
  13351. ascentCache.set(fontFamily, DEFAULT_FONT_ASCENT);
  13352. return DEFAULT_FONT_ASCENT;
  13353. }
  13354. function appendText(task, geom, styles) {
  13355. const textDiv = document.createElement("span");
  13356. const textDivProperties = {
  13357. angle: 0,
  13358. canvasWidth: 0,
  13359. hasText: geom.str !== "",
  13360. hasEOL: geom.hasEOL,
  13361. fontSize: 0
  13362. };
  13363. task._textDivs.push(textDiv);
  13364. const tx = _util.Util.transform(task._transform, geom.transform);
  13365. let angle = Math.atan2(tx[1], tx[0]);
  13366. const style = styles[geom.fontName];
  13367. if (style.vertical) {
  13368. angle += Math.PI / 2;
  13369. }
  13370. const fontHeight = Math.hypot(tx[2], tx[3]);
  13371. const fontAscent = fontHeight * getAscent(style.fontFamily, task._isOffscreenCanvasSupported);
  13372. let left, top;
  13373. if (angle === 0) {
  13374. left = tx[4];
  13375. top = tx[5] - fontAscent;
  13376. } else {
  13377. left = tx[4] + fontAscent * Math.sin(angle);
  13378. top = tx[5] - fontAscent * Math.cos(angle);
  13379. }
  13380. const scaleFactorStr = "calc(var(--scale-factor)*";
  13381. const divStyle = textDiv.style;
  13382. if (task._container === task._rootContainer) {
  13383. divStyle.left = `${(100 * left / task._pageWidth).toFixed(2)}%`;
  13384. divStyle.top = `${(100 * top / task._pageHeight).toFixed(2)}%`;
  13385. } else {
  13386. divStyle.left = `${scaleFactorStr}${left.toFixed(2)}px)`;
  13387. divStyle.top = `${scaleFactorStr}${top.toFixed(2)}px)`;
  13388. }
  13389. divStyle.fontSize = `${scaleFactorStr}${fontHeight.toFixed(2)}px)`;
  13390. divStyle.fontFamily = style.fontFamily;
  13391. textDivProperties.fontSize = fontHeight;
  13392. textDiv.setAttribute("role", "presentation");
  13393. textDiv.textContent = geom.str;
  13394. textDiv.dir = geom.dir;
  13395. if (task._fontInspectorEnabled) {
  13396. textDiv.dataset.fontName = geom.fontName;
  13397. }
  13398. if (angle !== 0) {
  13399. textDivProperties.angle = angle * (180 / Math.PI);
  13400. }
  13401. let shouldScaleText = false;
  13402. if (geom.str.length > 1) {
  13403. shouldScaleText = true;
  13404. } else if (geom.str !== " " && geom.transform[0] !== geom.transform[3]) {
  13405. const absScaleX = Math.abs(geom.transform[0]),
  13406. absScaleY = Math.abs(geom.transform[3]);
  13407. if (absScaleX !== absScaleY && Math.max(absScaleX, absScaleY) / Math.min(absScaleX, absScaleY) > 1.5) {
  13408. shouldScaleText = true;
  13409. }
  13410. }
  13411. if (shouldScaleText) {
  13412. textDivProperties.canvasWidth = style.vertical ? geom.height : geom.width;
  13413. }
  13414. task._textDivProperties.set(textDiv, textDivProperties);
  13415. if (task._isReadableStream) {
  13416. task._layoutText(textDiv);
  13417. }
  13418. }
  13419. function layout(params) {
  13420. const {
  13421. div,
  13422. scale,
  13423. properties,
  13424. ctx,
  13425. prevFontSize,
  13426. prevFontFamily
  13427. } = params;
  13428. const {
  13429. style
  13430. } = div;
  13431. let transform = "";
  13432. if (properties.canvasWidth !== 0 && properties.hasText) {
  13433. const {
  13434. fontFamily
  13435. } = style;
  13436. const {
  13437. canvasWidth,
  13438. fontSize
  13439. } = properties;
  13440. if (prevFontSize !== fontSize || prevFontFamily !== fontFamily) {
  13441. ctx.font = `${fontSize * scale}px ${fontFamily}`;
  13442. params.prevFontSize = fontSize;
  13443. params.prevFontFamily = fontFamily;
  13444. }
  13445. const {
  13446. width
  13447. } = ctx.measureText(div.textContent);
  13448. if (width > 0) {
  13449. transform = `scaleX(${canvasWidth * scale / width})`;
  13450. }
  13451. }
  13452. if (properties.angle !== 0) {
  13453. transform = `rotate(${properties.angle}deg) ${transform}`;
  13454. }
  13455. if (transform.length > 0) {
  13456. style.transform = transform;
  13457. }
  13458. }
  13459. function render(task) {
  13460. if (task._canceled) {
  13461. return;
  13462. }
  13463. const textDivs = task._textDivs;
  13464. const capability = task._capability;
  13465. const textDivsLength = textDivs.length;
  13466. if (textDivsLength > MAX_TEXT_DIVS_TO_RENDER) {
  13467. capability.resolve();
  13468. return;
  13469. }
  13470. if (!task._isReadableStream) {
  13471. for (const textDiv of textDivs) {
  13472. task._layoutText(textDiv);
  13473. }
  13474. }
  13475. capability.resolve();
  13476. }
  13477. class TextLayerRenderTask {
  13478. constructor(_ref) {
  13479. var _globalThis$FontInspe;
  13480. let {
  13481. textContentSource,
  13482. container,
  13483. viewport,
  13484. textDivs,
  13485. textDivProperties,
  13486. textContentItemsStr,
  13487. isOffscreenCanvasSupported
  13488. } = _ref;
  13489. this._textContentSource = textContentSource;
  13490. this._isReadableStream = textContentSource instanceof ReadableStream;
  13491. this._container = this._rootContainer = container;
  13492. this._textDivs = textDivs || [];
  13493. this._textContentItemsStr = textContentItemsStr || [];
  13494. this._isOffscreenCanvasSupported = isOffscreenCanvasSupported;
  13495. this._fontInspectorEnabled = !!((_globalThis$FontInspe = globalThis.FontInspector) !== null && _globalThis$FontInspe !== void 0 && _globalThis$FontInspe.enabled);
  13496. this._reader = null;
  13497. this._textDivProperties = textDivProperties || new WeakMap();
  13498. this._canceled = false;
  13499. this._capability = (0, _util.createPromiseCapability)();
  13500. this._layoutTextParams = {
  13501. prevFontSize: null,
  13502. prevFontFamily: null,
  13503. div: null,
  13504. scale: viewport.scale * (globalThis.devicePixelRatio || 1),
  13505. properties: null,
  13506. ctx: getCtx(0, isOffscreenCanvasSupported)
  13507. };
  13508. const {
  13509. pageWidth,
  13510. pageHeight,
  13511. pageX,
  13512. pageY
  13513. } = viewport.rawDims;
  13514. this._transform = [1, 0, 0, -1, -pageX, pageY + pageHeight];
  13515. this._pageWidth = pageWidth;
  13516. this._pageHeight = pageHeight;
  13517. (0, _display_utils.setLayerDimensions)(container, viewport);
  13518. this._capability.promise.finally(() => {
  13519. this._layoutTextParams = null;
  13520. }).catch(() => {});
  13521. }
  13522. get promise() {
  13523. return this._capability.promise;
  13524. }
  13525. cancel() {
  13526. this._canceled = true;
  13527. if (this._reader) {
  13528. this._reader.cancel(new _util.AbortException("TextLayer task cancelled.")).catch(() => {});
  13529. this._reader = null;
  13530. }
  13531. this._capability.reject(new _util.AbortException("TextLayer task cancelled."));
  13532. }
  13533. _processItems(items, styleCache) {
  13534. for (const item of items) {
  13535. if (item.str === undefined) {
  13536. if (item.type === "beginMarkedContentProps" || item.type === "beginMarkedContent") {
  13537. const parent = this._container;
  13538. this._container = document.createElement("span");
  13539. this._container.classList.add("markedContent");
  13540. if (item.id !== null) {
  13541. this._container.setAttribute("id", `${item.id}`);
  13542. }
  13543. parent.append(this._container);
  13544. } else if (item.type === "endMarkedContent") {
  13545. this._container = this._container.parentNode;
  13546. }
  13547. continue;
  13548. }
  13549. this._textContentItemsStr.push(item.str);
  13550. appendText(this, item, styleCache);
  13551. }
  13552. }
  13553. _layoutText(textDiv) {
  13554. const textDivProperties = this._layoutTextParams.properties = this._textDivProperties.get(textDiv);
  13555. this._layoutTextParams.div = textDiv;
  13556. layout(this._layoutTextParams);
  13557. if (textDivProperties.hasText) {
  13558. this._container.append(textDiv);
  13559. }
  13560. if (textDivProperties.hasEOL) {
  13561. const br = document.createElement("br");
  13562. br.setAttribute("role", "presentation");
  13563. this._container.append(br);
  13564. }
  13565. }
  13566. _render() {
  13567. const capability = (0, _util.createPromiseCapability)();
  13568. let styleCache = Object.create(null);
  13569. if (this._isReadableStream) {
  13570. const pump = () => {
  13571. this._reader.read().then(_ref2 => {
  13572. let {
  13573. value,
  13574. done
  13575. } = _ref2;
  13576. if (done) {
  13577. capability.resolve();
  13578. return;
  13579. }
  13580. Object.assign(styleCache, value.styles);
  13581. this._processItems(value.items, styleCache);
  13582. pump();
  13583. }, capability.reject);
  13584. };
  13585. this._reader = this._textContentSource.getReader();
  13586. pump();
  13587. } else if (this._textContentSource) {
  13588. const {
  13589. items,
  13590. styles
  13591. } = this._textContentSource;
  13592. this._processItems(items, styles);
  13593. capability.resolve();
  13594. } else {
  13595. throw new Error('No "textContentSource" parameter specified.');
  13596. }
  13597. capability.promise.then(() => {
  13598. styleCache = null;
  13599. render(this);
  13600. }, this._capability.reject);
  13601. }
  13602. }
  13603. exports.TextLayerRenderTask = TextLayerRenderTask;
  13604. function renderTextLayer(params) {
  13605. if (!params.textContentSource && (params.textContent || params.textContentStream)) {
  13606. (0, _display_utils.deprecated)("The TextLayerRender `textContent`/`textContentStream` parameters " + "will be removed in the future, please use `textContentSource` instead.");
  13607. params.textContentSource = params.textContent || params.textContentStream;
  13608. }
  13609. const task = new TextLayerRenderTask(params);
  13610. task._render();
  13611. return task;
  13612. }
  13613. function updateTextLayer(_ref3) {
  13614. let {
  13615. container,
  13616. viewport,
  13617. textDivs,
  13618. textDivProperties,
  13619. isOffscreenCanvasSupported,
  13620. mustRotate = true,
  13621. mustRescale = true
  13622. } = _ref3;
  13623. if (mustRotate) {
  13624. (0, _display_utils.setLayerDimensions)(container, {
  13625. rotation: viewport.rotation
  13626. });
  13627. }
  13628. if (mustRescale) {
  13629. const ctx = getCtx(0, isOffscreenCanvasSupported);
  13630. const scale = viewport.scale * (globalThis.devicePixelRatio || 1);
  13631. const params = {
  13632. prevFontSize: null,
  13633. prevFontFamily: null,
  13634. div: null,
  13635. scale,
  13636. properties: null,
  13637. ctx
  13638. };
  13639. for (const div of textDivs) {
  13640. params.properties = textDivProperties.get(div);
  13641. params.div = div;
  13642. layout(params);
  13643. }
  13644. }
  13645. }
  13646. /***/ }),
  13647. /* 159 */
  13648. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  13649. "use strict";
  13650. Object.defineProperty(exports, "__esModule", ({
  13651. value: true
  13652. }));
  13653. exports.AnnotationEditorLayer = void 0;
  13654. var _util = __w_pdfjs_require__(1);
  13655. var _tools = __w_pdfjs_require__(138);
  13656. var _freetext = __w_pdfjs_require__(160);
  13657. var _ink = __w_pdfjs_require__(161);
  13658. var _display_utils = __w_pdfjs_require__(139);
  13659. function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
  13660. function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  13661. function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
  13662. function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
  13663. function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
  13664. function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
  13665. function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
  13666. function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
  13667. function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
  13668. function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
  13669. function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
  13670. function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }
  13671. var _accessibilityManager = /*#__PURE__*/new WeakMap();
  13672. var _allowClick = /*#__PURE__*/new WeakMap();
  13673. var _boundPointerup = /*#__PURE__*/new WeakMap();
  13674. var _boundPointerdown = /*#__PURE__*/new WeakMap();
  13675. var _editors = /*#__PURE__*/new WeakMap();
  13676. var _hadPointerDown = /*#__PURE__*/new WeakMap();
  13677. var _isCleaningUp = /*#__PURE__*/new WeakMap();
  13678. var _uiManager = /*#__PURE__*/new WeakMap();
  13679. var _changeParent = /*#__PURE__*/new WeakSet();
  13680. var _createNewEditor = /*#__PURE__*/new WeakSet();
  13681. var _createAndAddNewEditor = /*#__PURE__*/new WeakSet();
  13682. var _cleanup = /*#__PURE__*/new WeakSet();
  13683. class AnnotationEditorLayer {
  13684. constructor(options) {
  13685. _classPrivateMethodInitSpec(this, _cleanup);
  13686. _classPrivateMethodInitSpec(this, _createAndAddNewEditor);
  13687. _classPrivateMethodInitSpec(this, _createNewEditor);
  13688. _classPrivateMethodInitSpec(this, _changeParent);
  13689. _classPrivateFieldInitSpec(this, _accessibilityManager, {
  13690. writable: true,
  13691. value: void 0
  13692. });
  13693. _classPrivateFieldInitSpec(this, _allowClick, {
  13694. writable: true,
  13695. value: false
  13696. });
  13697. _classPrivateFieldInitSpec(this, _boundPointerup, {
  13698. writable: true,
  13699. value: this.pointerup.bind(this)
  13700. });
  13701. _classPrivateFieldInitSpec(this, _boundPointerdown, {
  13702. writable: true,
  13703. value: this.pointerdown.bind(this)
  13704. });
  13705. _classPrivateFieldInitSpec(this, _editors, {
  13706. writable: true,
  13707. value: new Map()
  13708. });
  13709. _classPrivateFieldInitSpec(this, _hadPointerDown, {
  13710. writable: true,
  13711. value: false
  13712. });
  13713. _classPrivateFieldInitSpec(this, _isCleaningUp, {
  13714. writable: true,
  13715. value: false
  13716. });
  13717. _classPrivateFieldInitSpec(this, _uiManager, {
  13718. writable: true,
  13719. value: void 0
  13720. });
  13721. if (!AnnotationEditorLayer._initialized) {
  13722. AnnotationEditorLayer._initialized = true;
  13723. _freetext.FreeTextEditor.initialize(options.l10n);
  13724. _ink.InkEditor.initialize(options.l10n);
  13725. }
  13726. options.uiManager.registerEditorTypes([_freetext.FreeTextEditor, _ink.InkEditor]);
  13727. _classPrivateFieldSet(this, _uiManager, options.uiManager);
  13728. this.pageIndex = options.pageIndex;
  13729. this.div = options.div;
  13730. _classPrivateFieldSet(this, _accessibilityManager, options.accessibilityManager);
  13731. _classPrivateFieldGet(this, _uiManager).addLayer(this);
  13732. }
  13733. get isEmpty() {
  13734. return _classPrivateFieldGet(this, _editors).size === 0;
  13735. }
  13736. updateToolbar(mode) {
  13737. _classPrivateFieldGet(this, _uiManager).updateToolbar(mode);
  13738. }
  13739. updateMode() {
  13740. let mode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _classPrivateFieldGet(this, _uiManager).getMode();
  13741. _classPrivateMethodGet(this, _cleanup, _cleanup2).call(this);
  13742. if (mode === _util.AnnotationEditorType.INK) {
  13743. this.addInkEditorIfNeeded(false);
  13744. this.disableClick();
  13745. } else {
  13746. this.enableClick();
  13747. }
  13748. _classPrivateFieldGet(this, _uiManager).unselectAll();
  13749. if (mode !== _util.AnnotationEditorType.NONE) {
  13750. this.div.classList.toggle("freeTextEditing", mode === _util.AnnotationEditorType.FREETEXT);
  13751. this.div.classList.toggle("inkEditing", mode === _util.AnnotationEditorType.INK);
  13752. this.div.hidden = false;
  13753. }
  13754. }
  13755. addInkEditorIfNeeded(isCommitting) {
  13756. if (!isCommitting && _classPrivateFieldGet(this, _uiManager).getMode() !== _util.AnnotationEditorType.INK) {
  13757. return;
  13758. }
  13759. if (!isCommitting) {
  13760. for (const editor of _classPrivateFieldGet(this, _editors).values()) {
  13761. if (editor.isEmpty()) {
  13762. editor.setInBackground();
  13763. return;
  13764. }
  13765. }
  13766. }
  13767. const editor = _classPrivateMethodGet(this, _createAndAddNewEditor, _createAndAddNewEditor2).call(this, {
  13768. offsetX: 0,
  13769. offsetY: 0
  13770. });
  13771. editor.setInBackground();
  13772. }
  13773. setEditingState(isEditing) {
  13774. _classPrivateFieldGet(this, _uiManager).setEditingState(isEditing);
  13775. }
  13776. addCommands(params) {
  13777. _classPrivateFieldGet(this, _uiManager).addCommands(params);
  13778. }
  13779. enable() {
  13780. this.div.style.pointerEvents = "auto";
  13781. for (const editor of _classPrivateFieldGet(this, _editors).values()) {
  13782. editor.enableEditing();
  13783. }
  13784. }
  13785. disable() {
  13786. this.div.style.pointerEvents = "none";
  13787. for (const editor of _classPrivateFieldGet(this, _editors).values()) {
  13788. editor.disableEditing();
  13789. }
  13790. _classPrivateMethodGet(this, _cleanup, _cleanup2).call(this);
  13791. if (this.isEmpty) {
  13792. this.div.hidden = true;
  13793. }
  13794. }
  13795. setActiveEditor(editor) {
  13796. const currentActive = _classPrivateFieldGet(this, _uiManager).getActive();
  13797. if (currentActive === editor) {
  13798. return;
  13799. }
  13800. _classPrivateFieldGet(this, _uiManager).setActiveEditor(editor);
  13801. }
  13802. enableClick() {
  13803. this.div.addEventListener("pointerdown", _classPrivateFieldGet(this, _boundPointerdown));
  13804. this.div.addEventListener("pointerup", _classPrivateFieldGet(this, _boundPointerup));
  13805. }
  13806. disableClick() {
  13807. this.div.removeEventListener("pointerdown", _classPrivateFieldGet(this, _boundPointerdown));
  13808. this.div.removeEventListener("pointerup", _classPrivateFieldGet(this, _boundPointerup));
  13809. }
  13810. attach(editor) {
  13811. _classPrivateFieldGet(this, _editors).set(editor.id, editor);
  13812. }
  13813. detach(editor) {
  13814. var _classPrivateFieldGet2;
  13815. _classPrivateFieldGet(this, _editors).delete(editor.id);
  13816. (_classPrivateFieldGet2 = _classPrivateFieldGet(this, _accessibilityManager)) === null || _classPrivateFieldGet2 === void 0 ? void 0 : _classPrivateFieldGet2.removePointerInTextLayer(editor.contentDiv);
  13817. }
  13818. remove(editor) {
  13819. _classPrivateFieldGet(this, _uiManager).removeEditor(editor);
  13820. this.detach(editor);
  13821. editor.div.style.display = "none";
  13822. setTimeout(() => {
  13823. editor.div.style.display = "";
  13824. editor.div.remove();
  13825. editor.isAttachedToDOM = false;
  13826. if (document.activeElement === document.body) {
  13827. _classPrivateFieldGet(this, _uiManager).focusMainContainer();
  13828. }
  13829. }, 0);
  13830. if (!_classPrivateFieldGet(this, _isCleaningUp)) {
  13831. this.addInkEditorIfNeeded(false);
  13832. }
  13833. }
  13834. add(editor) {
  13835. _classPrivateMethodGet(this, _changeParent, _changeParent2).call(this, editor);
  13836. _classPrivateFieldGet(this, _uiManager).addEditor(editor);
  13837. this.attach(editor);
  13838. if (!editor.isAttachedToDOM) {
  13839. const div = editor.render();
  13840. this.div.append(div);
  13841. editor.isAttachedToDOM = true;
  13842. }
  13843. this.moveEditorInDOM(editor);
  13844. editor.onceAdded();
  13845. _classPrivateFieldGet(this, _uiManager).addToAnnotationStorage(editor);
  13846. }
  13847. moveEditorInDOM(editor) {
  13848. var _classPrivateFieldGet3;
  13849. (_classPrivateFieldGet3 = _classPrivateFieldGet(this, _accessibilityManager)) === null || _classPrivateFieldGet3 === void 0 ? void 0 : _classPrivateFieldGet3.moveElementInDOM(this.div, editor.div, editor.contentDiv, true);
  13850. }
  13851. addOrRebuild(editor) {
  13852. if (editor.needsToBeRebuilt()) {
  13853. editor.rebuild();
  13854. } else {
  13855. this.add(editor);
  13856. }
  13857. }
  13858. addANewEditor(editor) {
  13859. const cmd = () => {
  13860. this.addOrRebuild(editor);
  13861. };
  13862. const undo = () => {
  13863. editor.remove();
  13864. };
  13865. this.addCommands({
  13866. cmd,
  13867. undo,
  13868. mustExec: true
  13869. });
  13870. }
  13871. addUndoableEditor(editor) {
  13872. const cmd = () => {
  13873. this.addOrRebuild(editor);
  13874. };
  13875. const undo = () => {
  13876. editor.remove();
  13877. };
  13878. this.addCommands({
  13879. cmd,
  13880. undo,
  13881. mustExec: false
  13882. });
  13883. }
  13884. getNextId() {
  13885. return _classPrivateFieldGet(this, _uiManager).getId();
  13886. }
  13887. deserialize(data) {
  13888. switch (data.annotationType) {
  13889. case _util.AnnotationEditorType.FREETEXT:
  13890. return _freetext.FreeTextEditor.deserialize(data, this, _classPrivateFieldGet(this, _uiManager));
  13891. case _util.AnnotationEditorType.INK:
  13892. return _ink.InkEditor.deserialize(data, this, _classPrivateFieldGet(this, _uiManager));
  13893. }
  13894. return null;
  13895. }
  13896. setSelected(editor) {
  13897. _classPrivateFieldGet(this, _uiManager).setSelected(editor);
  13898. }
  13899. toggleSelected(editor) {
  13900. _classPrivateFieldGet(this, _uiManager).toggleSelected(editor);
  13901. }
  13902. isSelected(editor) {
  13903. return _classPrivateFieldGet(this, _uiManager).isSelected(editor);
  13904. }
  13905. unselect(editor) {
  13906. _classPrivateFieldGet(this, _uiManager).unselect(editor);
  13907. }
  13908. pointerup(event) {
  13909. const {
  13910. isMac
  13911. } = _util.FeatureTest.platform;
  13912. if (event.button !== 0 || event.ctrlKey && isMac) {
  13913. return;
  13914. }
  13915. if (event.target !== this.div) {
  13916. return;
  13917. }
  13918. if (!_classPrivateFieldGet(this, _hadPointerDown)) {
  13919. return;
  13920. }
  13921. _classPrivateFieldSet(this, _hadPointerDown, false);
  13922. if (!_classPrivateFieldGet(this, _allowClick)) {
  13923. _classPrivateFieldSet(this, _allowClick, true);
  13924. return;
  13925. }
  13926. _classPrivateMethodGet(this, _createAndAddNewEditor, _createAndAddNewEditor2).call(this, event);
  13927. }
  13928. pointerdown(event) {
  13929. const {
  13930. isMac
  13931. } = _util.FeatureTest.platform;
  13932. if (event.button !== 0 || event.ctrlKey && isMac) {
  13933. return;
  13934. }
  13935. if (event.target !== this.div) {
  13936. return;
  13937. }
  13938. _classPrivateFieldSet(this, _hadPointerDown, true);
  13939. const editor = _classPrivateFieldGet(this, _uiManager).getActive();
  13940. _classPrivateFieldSet(this, _allowClick, !editor || editor.isEmpty());
  13941. }
  13942. drop(event) {
  13943. const id = event.dataTransfer.getData("text/plain");
  13944. const editor = _classPrivateFieldGet(this, _uiManager).getEditor(id);
  13945. if (!editor) {
  13946. return;
  13947. }
  13948. event.preventDefault();
  13949. event.dataTransfer.dropEffect = "move";
  13950. _classPrivateMethodGet(this, _changeParent, _changeParent2).call(this, editor);
  13951. const rect = this.div.getBoundingClientRect();
  13952. const endX = event.clientX - rect.x;
  13953. const endY = event.clientY - rect.y;
  13954. editor.translate(endX - editor.startX, endY - editor.startY);
  13955. this.moveEditorInDOM(editor);
  13956. editor.div.focus();
  13957. }
  13958. dragover(event) {
  13959. event.preventDefault();
  13960. }
  13961. destroy() {
  13962. var _classPrivateFieldGet4;
  13963. if (((_classPrivateFieldGet4 = _classPrivateFieldGet(this, _uiManager).getActive()) === null || _classPrivateFieldGet4 === void 0 ? void 0 : _classPrivateFieldGet4.parent) === this) {
  13964. _classPrivateFieldGet(this, _uiManager).setActiveEditor(null);
  13965. }
  13966. for (const editor of _classPrivateFieldGet(this, _editors).values()) {
  13967. var _classPrivateFieldGet5;
  13968. (_classPrivateFieldGet5 = _classPrivateFieldGet(this, _accessibilityManager)) === null || _classPrivateFieldGet5 === void 0 ? void 0 : _classPrivateFieldGet5.removePointerInTextLayer(editor.contentDiv);
  13969. editor.setParent(null);
  13970. editor.isAttachedToDOM = false;
  13971. editor.div.remove();
  13972. }
  13973. this.div = null;
  13974. _classPrivateFieldGet(this, _editors).clear();
  13975. _classPrivateFieldGet(this, _uiManager).removeLayer(this);
  13976. }
  13977. render(_ref) {
  13978. let {
  13979. viewport
  13980. } = _ref;
  13981. this.viewport = viewport;
  13982. (0, _display_utils.setLayerDimensions)(this.div, viewport);
  13983. (0, _tools.bindEvents)(this, this.div, ["dragover", "drop"]);
  13984. for (const editor of _classPrivateFieldGet(this, _uiManager).getEditors(this.pageIndex)) {
  13985. this.add(editor);
  13986. }
  13987. this.updateMode();
  13988. }
  13989. update(_ref2) {
  13990. let {
  13991. viewport
  13992. } = _ref2;
  13993. _classPrivateFieldGet(this, _uiManager).commitOrRemove();
  13994. this.viewport = viewport;
  13995. (0, _display_utils.setLayerDimensions)(this.div, {
  13996. rotation: viewport.rotation
  13997. });
  13998. this.updateMode();
  13999. }
  14000. get pageDimensions() {
  14001. const {
  14002. pageWidth,
  14003. pageHeight
  14004. } = this.viewport.rawDims;
  14005. return [pageWidth, pageHeight];
  14006. }
  14007. }
  14008. exports.AnnotationEditorLayer = AnnotationEditorLayer;
  14009. function _changeParent2(editor) {
  14010. var _editor$parent;
  14011. if (editor.parent === this) {
  14012. return;
  14013. }
  14014. this.attach(editor);
  14015. (_editor$parent = editor.parent) === null || _editor$parent === void 0 ? void 0 : _editor$parent.detach(editor);
  14016. editor.setParent(this);
  14017. if (editor.div && editor.isAttachedToDOM) {
  14018. editor.div.remove();
  14019. this.div.append(editor.div);
  14020. }
  14021. }
  14022. function _createNewEditor2(params) {
  14023. switch (_classPrivateFieldGet(this, _uiManager).getMode()) {
  14024. case _util.AnnotationEditorType.FREETEXT:
  14025. return new _freetext.FreeTextEditor(params);
  14026. case _util.AnnotationEditorType.INK:
  14027. return new _ink.InkEditor(params);
  14028. }
  14029. return null;
  14030. }
  14031. function _createAndAddNewEditor2(event) {
  14032. const id = this.getNextId();
  14033. const editor = _classPrivateMethodGet(this, _createNewEditor, _createNewEditor2).call(this, {
  14034. parent: this,
  14035. id,
  14036. x: event.offsetX,
  14037. y: event.offsetY,
  14038. uiManager: _classPrivateFieldGet(this, _uiManager)
  14039. });
  14040. if (editor) {
  14041. this.add(editor);
  14042. }
  14043. return editor;
  14044. }
  14045. function _cleanup2() {
  14046. _classPrivateFieldSet(this, _isCleaningUp, true);
  14047. for (const editor of _classPrivateFieldGet(this, _editors).values()) {
  14048. if (editor.isEmpty()) {
  14049. editor.remove();
  14050. }
  14051. }
  14052. _classPrivateFieldSet(this, _isCleaningUp, false);
  14053. }
  14054. _defineProperty(AnnotationEditorLayer, "_initialized", false);
  14055. /***/ }),
  14056. /* 160 */
  14057. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  14058. "use strict";
  14059. Object.defineProperty(exports, "__esModule", ({
  14060. value: true
  14061. }));
  14062. exports.FreeTextEditor = void 0;
  14063. var _util = __w_pdfjs_require__(1);
  14064. var _tools = __w_pdfjs_require__(138);
  14065. var _editor = __w_pdfjs_require__(137);
  14066. function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
  14067. function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  14068. function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
  14069. function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
  14070. function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
  14071. function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
  14072. function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
  14073. function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
  14074. function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
  14075. function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
  14076. function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
  14077. function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }
  14078. var _boundEditorDivBlur = /*#__PURE__*/new WeakMap();
  14079. var _boundEditorDivFocus = /*#__PURE__*/new WeakMap();
  14080. var _boundEditorDivInput = /*#__PURE__*/new WeakMap();
  14081. var _boundEditorDivKeydown = /*#__PURE__*/new WeakMap();
  14082. var _color = /*#__PURE__*/new WeakMap();
  14083. var _content = /*#__PURE__*/new WeakMap();
  14084. var _editorDivId = /*#__PURE__*/new WeakMap();
  14085. var _hasAlreadyBeenCommitted = /*#__PURE__*/new WeakMap();
  14086. var _fontSize = /*#__PURE__*/new WeakMap();
  14087. var _updateFontSize = /*#__PURE__*/new WeakSet();
  14088. var _updateColor = /*#__PURE__*/new WeakSet();
  14089. var _extractText = /*#__PURE__*/new WeakSet();
  14090. var _setEditorDimensions = /*#__PURE__*/new WeakSet();
  14091. class FreeTextEditor extends _editor.AnnotationEditor {
  14092. constructor(params) {
  14093. super({
  14094. ...params,
  14095. name: "freeTextEditor"
  14096. });
  14097. _classPrivateMethodInitSpec(this, _setEditorDimensions);
  14098. _classPrivateMethodInitSpec(this, _extractText);
  14099. _classPrivateMethodInitSpec(this, _updateColor);
  14100. _classPrivateMethodInitSpec(this, _updateFontSize);
  14101. _classPrivateFieldInitSpec(this, _boundEditorDivBlur, {
  14102. writable: true,
  14103. value: this.editorDivBlur.bind(this)
  14104. });
  14105. _classPrivateFieldInitSpec(this, _boundEditorDivFocus, {
  14106. writable: true,
  14107. value: this.editorDivFocus.bind(this)
  14108. });
  14109. _classPrivateFieldInitSpec(this, _boundEditorDivInput, {
  14110. writable: true,
  14111. value: this.editorDivInput.bind(this)
  14112. });
  14113. _classPrivateFieldInitSpec(this, _boundEditorDivKeydown, {
  14114. writable: true,
  14115. value: this.editorDivKeydown.bind(this)
  14116. });
  14117. _classPrivateFieldInitSpec(this, _color, {
  14118. writable: true,
  14119. value: void 0
  14120. });
  14121. _classPrivateFieldInitSpec(this, _content, {
  14122. writable: true,
  14123. value: ""
  14124. });
  14125. _classPrivateFieldInitSpec(this, _editorDivId, {
  14126. writable: true,
  14127. value: `${this.id}-editor`
  14128. });
  14129. _classPrivateFieldInitSpec(this, _hasAlreadyBeenCommitted, {
  14130. writable: true,
  14131. value: false
  14132. });
  14133. _classPrivateFieldInitSpec(this, _fontSize, {
  14134. writable: true,
  14135. value: void 0
  14136. });
  14137. _classPrivateFieldSet(this, _color, params.color || FreeTextEditor._defaultColor || _editor.AnnotationEditor._defaultLineColor);
  14138. _classPrivateFieldSet(this, _fontSize, params.fontSize || FreeTextEditor._defaultFontSize);
  14139. }
  14140. static initialize(l10n) {
  14141. this._l10nPromise = new Map(["free_text2_default_content", "editor_free_text2_aria_label"].map(str => [str, l10n.get(str)]));
  14142. const style = getComputedStyle(document.documentElement);
  14143. this._internalPadding = parseFloat(style.getPropertyValue("--freetext-padding"));
  14144. }
  14145. static updateDefaultParams(type, value) {
  14146. switch (type) {
  14147. case _util.AnnotationEditorParamsType.FREETEXT_SIZE:
  14148. FreeTextEditor._defaultFontSize = value;
  14149. break;
  14150. case _util.AnnotationEditorParamsType.FREETEXT_COLOR:
  14151. FreeTextEditor._defaultColor = value;
  14152. break;
  14153. }
  14154. }
  14155. updateParams(type, value) {
  14156. switch (type) {
  14157. case _util.AnnotationEditorParamsType.FREETEXT_SIZE:
  14158. _classPrivateMethodGet(this, _updateFontSize, _updateFontSize2).call(this, value);
  14159. break;
  14160. case _util.AnnotationEditorParamsType.FREETEXT_COLOR:
  14161. _classPrivateMethodGet(this, _updateColor, _updateColor2).call(this, value);
  14162. break;
  14163. }
  14164. }
  14165. static get defaultPropertiesToUpdate() {
  14166. return [[_util.AnnotationEditorParamsType.FREETEXT_SIZE, FreeTextEditor._defaultFontSize], [_util.AnnotationEditorParamsType.FREETEXT_COLOR, FreeTextEditor._defaultColor || _editor.AnnotationEditor._defaultLineColor]];
  14167. }
  14168. get propertiesToUpdate() {
  14169. return [[_util.AnnotationEditorParamsType.FREETEXT_SIZE, _classPrivateFieldGet(this, _fontSize)], [_util.AnnotationEditorParamsType.FREETEXT_COLOR, _classPrivateFieldGet(this, _color)]];
  14170. }
  14171. getInitialTranslation() {
  14172. const scale = this.parentScale;
  14173. return [-FreeTextEditor._internalPadding * scale, -(FreeTextEditor._internalPadding + _classPrivateFieldGet(this, _fontSize)) * scale];
  14174. }
  14175. rebuild() {
  14176. super.rebuild();
  14177. if (this.div === null) {
  14178. return;
  14179. }
  14180. if (!this.isAttachedToDOM) {
  14181. this.parent.add(this);
  14182. }
  14183. }
  14184. enableEditMode() {
  14185. if (this.isInEditMode()) {
  14186. return;
  14187. }
  14188. this.parent.setEditingState(false);
  14189. this.parent.updateToolbar(_util.AnnotationEditorType.FREETEXT);
  14190. super.enableEditMode();
  14191. this.overlayDiv.classList.remove("enabled");
  14192. this.editorDiv.contentEditable = true;
  14193. this.div.draggable = false;
  14194. this.div.removeAttribute("aria-activedescendant");
  14195. this.editorDiv.addEventListener("keydown", _classPrivateFieldGet(this, _boundEditorDivKeydown));
  14196. this.editorDiv.addEventListener("focus", _classPrivateFieldGet(this, _boundEditorDivFocus));
  14197. this.editorDiv.addEventListener("blur", _classPrivateFieldGet(this, _boundEditorDivBlur));
  14198. this.editorDiv.addEventListener("input", _classPrivateFieldGet(this, _boundEditorDivInput));
  14199. }
  14200. disableEditMode() {
  14201. if (!this.isInEditMode()) {
  14202. return;
  14203. }
  14204. this.parent.setEditingState(true);
  14205. super.disableEditMode();
  14206. this.overlayDiv.classList.add("enabled");
  14207. this.editorDiv.contentEditable = false;
  14208. this.div.setAttribute("aria-activedescendant", _classPrivateFieldGet(this, _editorDivId));
  14209. this.div.draggable = true;
  14210. this.editorDiv.removeEventListener("keydown", _classPrivateFieldGet(this, _boundEditorDivKeydown));
  14211. this.editorDiv.removeEventListener("focus", _classPrivateFieldGet(this, _boundEditorDivFocus));
  14212. this.editorDiv.removeEventListener("blur", _classPrivateFieldGet(this, _boundEditorDivBlur));
  14213. this.editorDiv.removeEventListener("input", _classPrivateFieldGet(this, _boundEditorDivInput));
  14214. this.div.focus({
  14215. preventScroll: true
  14216. });
  14217. this.isEditing = false;
  14218. this.parent.div.classList.add("freeTextEditing");
  14219. }
  14220. focusin(event) {
  14221. super.focusin(event);
  14222. if (event.target !== this.editorDiv) {
  14223. this.editorDiv.focus();
  14224. }
  14225. }
  14226. onceAdded() {
  14227. if (this.width) {
  14228. return;
  14229. }
  14230. this.enableEditMode();
  14231. this.editorDiv.focus();
  14232. }
  14233. isEmpty() {
  14234. return !this.editorDiv || this.editorDiv.innerText.trim() === "";
  14235. }
  14236. remove() {
  14237. this.isEditing = false;
  14238. this.parent.setEditingState(true);
  14239. this.parent.div.classList.add("freeTextEditing");
  14240. super.remove();
  14241. }
  14242. commit() {
  14243. if (!this.isInEditMode()) {
  14244. return;
  14245. }
  14246. super.commit();
  14247. if (!_classPrivateFieldGet(this, _hasAlreadyBeenCommitted)) {
  14248. _classPrivateFieldSet(this, _hasAlreadyBeenCommitted, true);
  14249. this.parent.addUndoableEditor(this);
  14250. }
  14251. this.disableEditMode();
  14252. _classPrivateFieldSet(this, _content, _classPrivateMethodGet(this, _extractText, _extractText2).call(this).trimEnd());
  14253. _classPrivateMethodGet(this, _setEditorDimensions, _setEditorDimensions2).call(this);
  14254. }
  14255. shouldGetKeyboardEvents() {
  14256. return this.isInEditMode();
  14257. }
  14258. dblclick(event) {
  14259. this.enableEditMode();
  14260. this.editorDiv.focus();
  14261. }
  14262. keydown(event) {
  14263. if (event.target === this.div && event.key === "Enter") {
  14264. this.enableEditMode();
  14265. this.editorDiv.focus();
  14266. }
  14267. }
  14268. editorDivKeydown(event) {
  14269. FreeTextEditor._keyboardManager.exec(this, event);
  14270. }
  14271. editorDivFocus(event) {
  14272. this.isEditing = true;
  14273. }
  14274. editorDivBlur(event) {
  14275. this.isEditing = false;
  14276. }
  14277. editorDivInput(event) {
  14278. this.parent.div.classList.toggle("freeTextEditing", this.isEmpty());
  14279. }
  14280. disableEditing() {
  14281. this.editorDiv.setAttribute("role", "comment");
  14282. this.editorDiv.removeAttribute("aria-multiline");
  14283. }
  14284. enableEditing() {
  14285. this.editorDiv.setAttribute("role", "textbox");
  14286. this.editorDiv.setAttribute("aria-multiline", true);
  14287. }
  14288. render() {
  14289. if (this.div) {
  14290. return this.div;
  14291. }
  14292. let baseX, baseY;
  14293. if (this.width) {
  14294. baseX = this.x;
  14295. baseY = this.y;
  14296. }
  14297. super.render();
  14298. this.editorDiv = document.createElement("div");
  14299. this.editorDiv.className = "internal";
  14300. this.editorDiv.setAttribute("id", _classPrivateFieldGet(this, _editorDivId));
  14301. this.enableEditing();
  14302. FreeTextEditor._l10nPromise.get("editor_free_text2_aria_label").then(msg => {
  14303. var _this$editorDiv;
  14304. return (_this$editorDiv = this.editorDiv) === null || _this$editorDiv === void 0 ? void 0 : _this$editorDiv.setAttribute("aria-label", msg);
  14305. });
  14306. FreeTextEditor._l10nPromise.get("free_text2_default_content").then(msg => {
  14307. var _this$editorDiv2;
  14308. return (_this$editorDiv2 = this.editorDiv) === null || _this$editorDiv2 === void 0 ? void 0 : _this$editorDiv2.setAttribute("default-content", msg);
  14309. });
  14310. this.editorDiv.contentEditable = true;
  14311. const {
  14312. style
  14313. } = this.editorDiv;
  14314. style.fontSize = `calc(${_classPrivateFieldGet(this, _fontSize)}px * var(--scale-factor))`;
  14315. style.color = _classPrivateFieldGet(this, _color);
  14316. this.div.append(this.editorDiv);
  14317. this.overlayDiv = document.createElement("div");
  14318. this.overlayDiv.classList.add("overlay", "enabled");
  14319. this.div.append(this.overlayDiv);
  14320. (0, _tools.bindEvents)(this, this.div, ["dblclick", "keydown"]);
  14321. if (this.width) {
  14322. const [parentWidth, parentHeight] = this.parentDimensions;
  14323. this.setAt(baseX * parentWidth, baseY * parentHeight, this.width * parentWidth, this.height * parentHeight);
  14324. for (const line of _classPrivateFieldGet(this, _content).split("\n")) {
  14325. const div = document.createElement("div");
  14326. div.append(line ? document.createTextNode(line) : document.createElement("br"));
  14327. this.editorDiv.append(div);
  14328. }
  14329. this.div.draggable = true;
  14330. this.editorDiv.contentEditable = false;
  14331. } else {
  14332. this.div.draggable = false;
  14333. this.editorDiv.contentEditable = true;
  14334. }
  14335. return this.div;
  14336. }
  14337. get contentDiv() {
  14338. return this.editorDiv;
  14339. }
  14340. static deserialize(data, parent, uiManager) {
  14341. const editor = super.deserialize(data, parent, uiManager);
  14342. _classPrivateFieldSet(editor, _fontSize, data.fontSize);
  14343. _classPrivateFieldSet(editor, _color, _util.Util.makeHexColor(...data.color));
  14344. _classPrivateFieldSet(editor, _content, data.value);
  14345. return editor;
  14346. }
  14347. serialize() {
  14348. if (this.isEmpty()) {
  14349. return null;
  14350. }
  14351. const padding = FreeTextEditor._internalPadding * this.parentScale;
  14352. const rect = this.getRect(padding, padding);
  14353. const color = _editor.AnnotationEditor._colorManager.convert(this.isAttachedToDOM ? getComputedStyle(this.editorDiv).color : _classPrivateFieldGet(this, _color));
  14354. return {
  14355. annotationType: _util.AnnotationEditorType.FREETEXT,
  14356. color,
  14357. fontSize: _classPrivateFieldGet(this, _fontSize),
  14358. value: _classPrivateFieldGet(this, _content),
  14359. pageIndex: this.pageIndex,
  14360. rect,
  14361. rotation: this.rotation
  14362. };
  14363. }
  14364. }
  14365. exports.FreeTextEditor = FreeTextEditor;
  14366. function _updateFontSize2(fontSize) {
  14367. const setFontsize = size => {
  14368. this.editorDiv.style.fontSize = `calc(${size}px * var(--scale-factor))`;
  14369. this.translate(0, -(size - _classPrivateFieldGet(this, _fontSize)) * this.parentScale);
  14370. _classPrivateFieldSet(this, _fontSize, size);
  14371. _classPrivateMethodGet(this, _setEditorDimensions, _setEditorDimensions2).call(this);
  14372. };
  14373. const savedFontsize = _classPrivateFieldGet(this, _fontSize);
  14374. this.addCommands({
  14375. cmd: () => {
  14376. setFontsize(fontSize);
  14377. },
  14378. undo: () => {
  14379. setFontsize(savedFontsize);
  14380. },
  14381. mustExec: true,
  14382. type: _util.AnnotationEditorParamsType.FREETEXT_SIZE,
  14383. overwriteIfSameType: true,
  14384. keepUndo: true
  14385. });
  14386. }
  14387. function _updateColor2(color) {
  14388. const savedColor = _classPrivateFieldGet(this, _color);
  14389. this.addCommands({
  14390. cmd: () => {
  14391. _classPrivateFieldSet(this, _color, this.editorDiv.style.color = color);
  14392. },
  14393. undo: () => {
  14394. _classPrivateFieldSet(this, _color, this.editorDiv.style.color = savedColor);
  14395. },
  14396. mustExec: true,
  14397. type: _util.AnnotationEditorParamsType.FREETEXT_COLOR,
  14398. overwriteIfSameType: true,
  14399. keepUndo: true
  14400. });
  14401. }
  14402. function _extractText2() {
  14403. const divs = this.editorDiv.getElementsByTagName("div");
  14404. if (divs.length === 0) {
  14405. return this.editorDiv.innerText;
  14406. }
  14407. const buffer = [];
  14408. for (const div of divs) {
  14409. buffer.push(div.innerText.replace(/\r\n?|\n/, ""));
  14410. }
  14411. return buffer.join("\n");
  14412. }
  14413. function _setEditorDimensions2() {
  14414. const [parentWidth, parentHeight] = this.parentDimensions;
  14415. let rect;
  14416. if (this.isAttachedToDOM) {
  14417. rect = this.div.getBoundingClientRect();
  14418. } else {
  14419. const {
  14420. currentLayer,
  14421. div
  14422. } = this;
  14423. const savedDisplay = div.style.display;
  14424. div.style.display = "hidden";
  14425. currentLayer.div.append(this.div);
  14426. rect = div.getBoundingClientRect();
  14427. div.remove();
  14428. div.style.display = savedDisplay;
  14429. }
  14430. this.width = rect.width / parentWidth;
  14431. this.height = rect.height / parentHeight;
  14432. }
  14433. _defineProperty(FreeTextEditor, "_freeTextDefaultContent", "");
  14434. _defineProperty(FreeTextEditor, "_l10nPromise", void 0);
  14435. _defineProperty(FreeTextEditor, "_internalPadding", 0);
  14436. _defineProperty(FreeTextEditor, "_defaultColor", null);
  14437. _defineProperty(FreeTextEditor, "_defaultFontSize", 10);
  14438. _defineProperty(FreeTextEditor, "_keyboardManager", new _tools.KeyboardManager([[["ctrl+Enter", "mac+meta+Enter", "Escape", "mac+Escape"], FreeTextEditor.prototype.commitOrRemove]]));
  14439. _defineProperty(FreeTextEditor, "_type", "freetext");
  14440. /***/ }),
  14441. /* 161 */
  14442. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  14443. "use strict";
  14444. Object.defineProperty(exports, "__esModule", ({
  14445. value: true
  14446. }));
  14447. exports.InkEditor = void 0;
  14448. Object.defineProperty(exports, "fitCurve", ({
  14449. enumerable: true,
  14450. get: function () {
  14451. return _pdfjsFitCurve.fitCurve;
  14452. }
  14453. }));
  14454. var _util = __w_pdfjs_require__(1);
  14455. var _editor = __w_pdfjs_require__(137);
  14456. var _pdfjsFitCurve = __w_pdfjs_require__(162);
  14457. var _tools = __w_pdfjs_require__(138);
  14458. function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
  14459. function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  14460. function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
  14461. function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
  14462. function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
  14463. function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
  14464. function _classStaticPrivateMethodGet(receiver, classConstructor, method) { _classCheckPrivateStaticAccess(receiver, classConstructor); return method; }
  14465. function _classCheckPrivateStaticAccess(receiver, classConstructor) { if (receiver !== classConstructor) { throw new TypeError("Private static access of wrong provenance"); } }
  14466. function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
  14467. function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }
  14468. function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
  14469. function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
  14470. function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
  14471. function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
  14472. const RESIZER_SIZE = 16;
  14473. const TIME_TO_WAIT_BEFORE_FIXING_DIMS = 100;
  14474. var _aspectRatio = /*#__PURE__*/new WeakMap();
  14475. var _baseHeight = /*#__PURE__*/new WeakMap();
  14476. var _baseWidth = /*#__PURE__*/new WeakMap();
  14477. var _boundCanvasPointermove = /*#__PURE__*/new WeakMap();
  14478. var _boundCanvasPointerleave = /*#__PURE__*/new WeakMap();
  14479. var _boundCanvasPointerup = /*#__PURE__*/new WeakMap();
  14480. var _boundCanvasPointerdown = /*#__PURE__*/new WeakMap();
  14481. var _disableEditing = /*#__PURE__*/new WeakMap();
  14482. var _isCanvasInitialized = /*#__PURE__*/new WeakMap();
  14483. var _lastPoint = /*#__PURE__*/new WeakMap();
  14484. var _observer = /*#__PURE__*/new WeakMap();
  14485. var _realWidth = /*#__PURE__*/new WeakMap();
  14486. var _realHeight = /*#__PURE__*/new WeakMap();
  14487. var _requestFrameCallback = /*#__PURE__*/new WeakMap();
  14488. var _updateThickness = /*#__PURE__*/new WeakSet();
  14489. var _updateColor = /*#__PURE__*/new WeakSet();
  14490. var _updateOpacity = /*#__PURE__*/new WeakSet();
  14491. var _getInitialBBox = /*#__PURE__*/new WeakSet();
  14492. var _setStroke = /*#__PURE__*/new WeakSet();
  14493. var _startDrawing = /*#__PURE__*/new WeakSet();
  14494. var _draw = /*#__PURE__*/new WeakSet();
  14495. var _stopDrawing = /*#__PURE__*/new WeakSet();
  14496. var _redraw = /*#__PURE__*/new WeakSet();
  14497. var _endDrawing = /*#__PURE__*/new WeakSet();
  14498. var _createCanvas = /*#__PURE__*/new WeakSet();
  14499. var _createObserver = /*#__PURE__*/new WeakSet();
  14500. var _setCanvasDims = /*#__PURE__*/new WeakSet();
  14501. var _setScaleFactor = /*#__PURE__*/new WeakSet();
  14502. var _updateTransform = /*#__PURE__*/new WeakSet();
  14503. var _serializePaths = /*#__PURE__*/new WeakSet();
  14504. var _extractPointsOnBezier = /*#__PURE__*/new WeakSet();
  14505. var _isAlmostFlat = /*#__PURE__*/new WeakSet();
  14506. var _getBbox = /*#__PURE__*/new WeakSet();
  14507. var _getPadding = /*#__PURE__*/new WeakSet();
  14508. var _fitToContent = /*#__PURE__*/new WeakSet();
  14509. var _setMinDims = /*#__PURE__*/new WeakSet();
  14510. class InkEditor extends _editor.AnnotationEditor {
  14511. constructor(params) {
  14512. super({
  14513. ...params,
  14514. name: "inkEditor"
  14515. });
  14516. _classPrivateMethodInitSpec(this, _setMinDims);
  14517. _classPrivateMethodInitSpec(this, _fitToContent);
  14518. _classPrivateMethodInitSpec(this, _getPadding);
  14519. _classPrivateMethodInitSpec(this, _getBbox);
  14520. _classPrivateMethodInitSpec(this, _isAlmostFlat);
  14521. _classPrivateMethodInitSpec(this, _extractPointsOnBezier);
  14522. _classPrivateMethodInitSpec(this, _serializePaths);
  14523. _classPrivateMethodInitSpec(this, _updateTransform);
  14524. _classPrivateMethodInitSpec(this, _setScaleFactor);
  14525. _classPrivateMethodInitSpec(this, _setCanvasDims);
  14526. _classPrivateMethodInitSpec(this, _createObserver);
  14527. _classPrivateMethodInitSpec(this, _createCanvas);
  14528. _classPrivateMethodInitSpec(this, _endDrawing);
  14529. _classPrivateMethodInitSpec(this, _redraw);
  14530. _classPrivateMethodInitSpec(this, _stopDrawing);
  14531. _classPrivateMethodInitSpec(this, _draw);
  14532. _classPrivateMethodInitSpec(this, _startDrawing);
  14533. _classPrivateMethodInitSpec(this, _setStroke);
  14534. _classPrivateMethodInitSpec(this, _getInitialBBox);
  14535. _classPrivateMethodInitSpec(this, _updateOpacity);
  14536. _classPrivateMethodInitSpec(this, _updateColor);
  14537. _classPrivateMethodInitSpec(this, _updateThickness);
  14538. _classPrivateFieldInitSpec(this, _aspectRatio, {
  14539. writable: true,
  14540. value: 0
  14541. });
  14542. _classPrivateFieldInitSpec(this, _baseHeight, {
  14543. writable: true,
  14544. value: 0
  14545. });
  14546. _classPrivateFieldInitSpec(this, _baseWidth, {
  14547. writable: true,
  14548. value: 0
  14549. });
  14550. _classPrivateFieldInitSpec(this, _boundCanvasPointermove, {
  14551. writable: true,
  14552. value: this.canvasPointermove.bind(this)
  14553. });
  14554. _classPrivateFieldInitSpec(this, _boundCanvasPointerleave, {
  14555. writable: true,
  14556. value: this.canvasPointerleave.bind(this)
  14557. });
  14558. _classPrivateFieldInitSpec(this, _boundCanvasPointerup, {
  14559. writable: true,
  14560. value: this.canvasPointerup.bind(this)
  14561. });
  14562. _classPrivateFieldInitSpec(this, _boundCanvasPointerdown, {
  14563. writable: true,
  14564. value: this.canvasPointerdown.bind(this)
  14565. });
  14566. _classPrivateFieldInitSpec(this, _disableEditing, {
  14567. writable: true,
  14568. value: false
  14569. });
  14570. _classPrivateFieldInitSpec(this, _isCanvasInitialized, {
  14571. writable: true,
  14572. value: false
  14573. });
  14574. _classPrivateFieldInitSpec(this, _lastPoint, {
  14575. writable: true,
  14576. value: null
  14577. });
  14578. _classPrivateFieldInitSpec(this, _observer, {
  14579. writable: true,
  14580. value: null
  14581. });
  14582. _classPrivateFieldInitSpec(this, _realWidth, {
  14583. writable: true,
  14584. value: 0
  14585. });
  14586. _classPrivateFieldInitSpec(this, _realHeight, {
  14587. writable: true,
  14588. value: 0
  14589. });
  14590. _classPrivateFieldInitSpec(this, _requestFrameCallback, {
  14591. writable: true,
  14592. value: null
  14593. });
  14594. this.color = params.color || null;
  14595. this.thickness = params.thickness || null;
  14596. this.opacity = params.opacity || null;
  14597. this.paths = [];
  14598. this.bezierPath2D = [];
  14599. this.currentPath = [];
  14600. this.scaleFactor = 1;
  14601. this.translationX = this.translationY = 0;
  14602. this.x = 0;
  14603. this.y = 0;
  14604. }
  14605. static initialize(l10n) {
  14606. this._l10nPromise = new Map(["editor_ink_canvas_aria_label", "editor_ink2_aria_label"].map(str => [str, l10n.get(str)]));
  14607. }
  14608. static updateDefaultParams(type, value) {
  14609. switch (type) {
  14610. case _util.AnnotationEditorParamsType.INK_THICKNESS:
  14611. InkEditor._defaultThickness = value;
  14612. break;
  14613. case _util.AnnotationEditorParamsType.INK_COLOR:
  14614. InkEditor._defaultColor = value;
  14615. break;
  14616. case _util.AnnotationEditorParamsType.INK_OPACITY:
  14617. InkEditor._defaultOpacity = value / 100;
  14618. break;
  14619. }
  14620. }
  14621. updateParams(type, value) {
  14622. switch (type) {
  14623. case _util.AnnotationEditorParamsType.INK_THICKNESS:
  14624. _classPrivateMethodGet(this, _updateThickness, _updateThickness2).call(this, value);
  14625. break;
  14626. case _util.AnnotationEditorParamsType.INK_COLOR:
  14627. _classPrivateMethodGet(this, _updateColor, _updateColor2).call(this, value);
  14628. break;
  14629. case _util.AnnotationEditorParamsType.INK_OPACITY:
  14630. _classPrivateMethodGet(this, _updateOpacity, _updateOpacity2).call(this, value);
  14631. break;
  14632. }
  14633. }
  14634. static get defaultPropertiesToUpdate() {
  14635. return [[_util.AnnotationEditorParamsType.INK_THICKNESS, InkEditor._defaultThickness], [_util.AnnotationEditorParamsType.INK_COLOR, InkEditor._defaultColor || _editor.AnnotationEditor._defaultLineColor], [_util.AnnotationEditorParamsType.INK_OPACITY, Math.round(InkEditor._defaultOpacity * 100)]];
  14636. }
  14637. get propertiesToUpdate() {
  14638. return [[_util.AnnotationEditorParamsType.INK_THICKNESS, this.thickness || InkEditor._defaultThickness], [_util.AnnotationEditorParamsType.INK_COLOR, this.color || InkEditor._defaultColor || _editor.AnnotationEditor._defaultLineColor], [_util.AnnotationEditorParamsType.INK_OPACITY, Math.round(100 * (this.opacity ?? InkEditor._defaultOpacity))]];
  14639. }
  14640. rebuild() {
  14641. super.rebuild();
  14642. if (this.div === null) {
  14643. return;
  14644. }
  14645. if (!this.canvas) {
  14646. _classPrivateMethodGet(this, _createCanvas, _createCanvas2).call(this);
  14647. _classPrivateMethodGet(this, _createObserver, _createObserver2).call(this);
  14648. }
  14649. if (!this.isAttachedToDOM) {
  14650. this.parent.add(this);
  14651. _classPrivateMethodGet(this, _setCanvasDims, _setCanvasDims2).call(this);
  14652. }
  14653. _classPrivateMethodGet(this, _fitToContent, _fitToContent2).call(this);
  14654. }
  14655. remove() {
  14656. if (this.canvas === null) {
  14657. return;
  14658. }
  14659. if (!this.isEmpty()) {
  14660. this.commit();
  14661. }
  14662. this.canvas.width = this.canvas.height = 0;
  14663. this.canvas.remove();
  14664. this.canvas = null;
  14665. _classPrivateFieldGet(this, _observer).disconnect();
  14666. _classPrivateFieldSet(this, _observer, null);
  14667. super.remove();
  14668. }
  14669. setParent(parent) {
  14670. if (!this.parent && parent) {
  14671. this._uiManager.removeShouldRescale(this);
  14672. } else if (this.parent && parent === null) {
  14673. this._uiManager.addShouldRescale(this);
  14674. }
  14675. super.setParent(parent);
  14676. }
  14677. onScaleChanging() {
  14678. const [parentWidth, parentHeight] = this.parentDimensions;
  14679. const width = this.width * parentWidth;
  14680. const height = this.height * parentHeight;
  14681. this.setDimensions(width, height);
  14682. }
  14683. enableEditMode() {
  14684. if (_classPrivateFieldGet(this, _disableEditing) || this.canvas === null) {
  14685. return;
  14686. }
  14687. super.enableEditMode();
  14688. this.div.draggable = false;
  14689. this.canvas.addEventListener("pointerdown", _classPrivateFieldGet(this, _boundCanvasPointerdown));
  14690. this.canvas.addEventListener("pointerup", _classPrivateFieldGet(this, _boundCanvasPointerup));
  14691. }
  14692. disableEditMode() {
  14693. if (!this.isInEditMode() || this.canvas === null) {
  14694. return;
  14695. }
  14696. super.disableEditMode();
  14697. this.div.draggable = !this.isEmpty();
  14698. this.div.classList.remove("editing");
  14699. this.canvas.removeEventListener("pointerdown", _classPrivateFieldGet(this, _boundCanvasPointerdown));
  14700. this.canvas.removeEventListener("pointerup", _classPrivateFieldGet(this, _boundCanvasPointerup));
  14701. }
  14702. onceAdded() {
  14703. this.div.draggable = !this.isEmpty();
  14704. }
  14705. isEmpty() {
  14706. return this.paths.length === 0 || this.paths.length === 1 && this.paths[0].length === 0;
  14707. }
  14708. commit() {
  14709. if (_classPrivateFieldGet(this, _disableEditing)) {
  14710. return;
  14711. }
  14712. super.commit();
  14713. this.isEditing = false;
  14714. this.disableEditMode();
  14715. this.setInForeground();
  14716. _classPrivateFieldSet(this, _disableEditing, true);
  14717. this.div.classList.add("disabled");
  14718. _classPrivateMethodGet(this, _fitToContent, _fitToContent2).call(this, true);
  14719. this.parent.addInkEditorIfNeeded(true);
  14720. this.parent.moveEditorInDOM(this);
  14721. this.div.focus({
  14722. preventScroll: true
  14723. });
  14724. }
  14725. focusin(event) {
  14726. super.focusin(event);
  14727. this.enableEditMode();
  14728. }
  14729. canvasPointerdown(event) {
  14730. if (event.button !== 0 || !this.isInEditMode() || _classPrivateFieldGet(this, _disableEditing)) {
  14731. return;
  14732. }
  14733. this.setInForeground();
  14734. if (event.type !== "mouse") {
  14735. this.div.focus();
  14736. }
  14737. event.stopPropagation();
  14738. this.canvas.addEventListener("pointerleave", _classPrivateFieldGet(this, _boundCanvasPointerleave));
  14739. this.canvas.addEventListener("pointermove", _classPrivateFieldGet(this, _boundCanvasPointermove));
  14740. _classPrivateMethodGet(this, _startDrawing, _startDrawing2).call(this, event.offsetX, event.offsetY);
  14741. }
  14742. canvasPointermove(event) {
  14743. event.stopPropagation();
  14744. _classPrivateMethodGet(this, _draw, _draw2).call(this, event.offsetX, event.offsetY);
  14745. }
  14746. canvasPointerup(event) {
  14747. if (event.button !== 0) {
  14748. return;
  14749. }
  14750. if (this.isInEditMode() && this.currentPath.length !== 0) {
  14751. event.stopPropagation();
  14752. _classPrivateMethodGet(this, _endDrawing, _endDrawing2).call(this, event);
  14753. this.setInBackground();
  14754. }
  14755. }
  14756. canvasPointerleave(event) {
  14757. _classPrivateMethodGet(this, _endDrawing, _endDrawing2).call(this, event);
  14758. this.setInBackground();
  14759. }
  14760. render() {
  14761. if (this.div) {
  14762. return this.div;
  14763. }
  14764. let baseX, baseY;
  14765. if (this.width) {
  14766. baseX = this.x;
  14767. baseY = this.y;
  14768. }
  14769. super.render();
  14770. InkEditor._l10nPromise.get("editor_ink2_aria_label").then(msg => {
  14771. var _this$div;
  14772. return (_this$div = this.div) === null || _this$div === void 0 ? void 0 : _this$div.setAttribute("aria-label", msg);
  14773. });
  14774. const [x, y, w, h] = _classPrivateMethodGet(this, _getInitialBBox, _getInitialBBox2).call(this);
  14775. this.setAt(x, y, 0, 0);
  14776. this.setDims(w, h);
  14777. _classPrivateMethodGet(this, _createCanvas, _createCanvas2).call(this);
  14778. if (this.width) {
  14779. const [parentWidth, parentHeight] = this.parentDimensions;
  14780. this.setAt(baseX * parentWidth, baseY * parentHeight, this.width * parentWidth, this.height * parentHeight);
  14781. _classPrivateFieldSet(this, _isCanvasInitialized, true);
  14782. _classPrivateMethodGet(this, _setCanvasDims, _setCanvasDims2).call(this);
  14783. this.setDims(this.width * parentWidth, this.height * parentHeight);
  14784. _classPrivateMethodGet(this, _redraw, _redraw2).call(this);
  14785. _classPrivateMethodGet(this, _setMinDims, _setMinDims2).call(this);
  14786. this.div.classList.add("disabled");
  14787. } else {
  14788. this.div.classList.add("editing");
  14789. this.enableEditMode();
  14790. }
  14791. _classPrivateMethodGet(this, _createObserver, _createObserver2).call(this);
  14792. return this.div;
  14793. }
  14794. setDimensions(width, height) {
  14795. const roundedWidth = Math.round(width);
  14796. const roundedHeight = Math.round(height);
  14797. if (_classPrivateFieldGet(this, _realWidth) === roundedWidth && _classPrivateFieldGet(this, _realHeight) === roundedHeight) {
  14798. return;
  14799. }
  14800. _classPrivateFieldSet(this, _realWidth, roundedWidth);
  14801. _classPrivateFieldSet(this, _realHeight, roundedHeight);
  14802. this.canvas.style.visibility = "hidden";
  14803. if (_classPrivateFieldGet(this, _aspectRatio) && Math.abs(_classPrivateFieldGet(this, _aspectRatio) - width / height) > 1e-2) {
  14804. height = Math.ceil(width / _classPrivateFieldGet(this, _aspectRatio));
  14805. this.setDims(width, height);
  14806. }
  14807. const [parentWidth, parentHeight] = this.parentDimensions;
  14808. this.width = width / parentWidth;
  14809. this.height = height / parentHeight;
  14810. if (_classPrivateFieldGet(this, _disableEditing)) {
  14811. _classPrivateMethodGet(this, _setScaleFactor, _setScaleFactor2).call(this, width, height);
  14812. }
  14813. _classPrivateMethodGet(this, _setCanvasDims, _setCanvasDims2).call(this);
  14814. _classPrivateMethodGet(this, _redraw, _redraw2).call(this);
  14815. this.canvas.style.visibility = "visible";
  14816. }
  14817. static deserialize(data, parent, uiManager) {
  14818. const editor = super.deserialize(data, parent, uiManager);
  14819. editor.thickness = data.thickness;
  14820. editor.color = _util.Util.makeHexColor(...data.color);
  14821. editor.opacity = data.opacity;
  14822. const [pageWidth, pageHeight] = editor.pageDimensions;
  14823. const width = editor.width * pageWidth;
  14824. const height = editor.height * pageHeight;
  14825. const scaleFactor = editor.parentScale;
  14826. const padding = data.thickness / 2;
  14827. _classPrivateFieldSet(editor, _aspectRatio, width / height);
  14828. _classPrivateFieldSet(editor, _disableEditing, true);
  14829. _classPrivateFieldSet(editor, _realWidth, Math.round(width));
  14830. _classPrivateFieldSet(editor, _realHeight, Math.round(height));
  14831. for (const {
  14832. bezier
  14833. } of data.paths) {
  14834. const path = [];
  14835. editor.paths.push(path);
  14836. let p0 = scaleFactor * (bezier[0] - padding);
  14837. let p1 = scaleFactor * (height - bezier[1] - padding);
  14838. for (let i = 2, ii = bezier.length; i < ii; i += 6) {
  14839. const p10 = scaleFactor * (bezier[i] - padding);
  14840. const p11 = scaleFactor * (height - bezier[i + 1] - padding);
  14841. const p20 = scaleFactor * (bezier[i + 2] - padding);
  14842. const p21 = scaleFactor * (height - bezier[i + 3] - padding);
  14843. const p30 = scaleFactor * (bezier[i + 4] - padding);
  14844. const p31 = scaleFactor * (height - bezier[i + 5] - padding);
  14845. path.push([[p0, p1], [p10, p11], [p20, p21], [p30, p31]]);
  14846. p0 = p30;
  14847. p1 = p31;
  14848. }
  14849. const path2D = _classStaticPrivateMethodGet(this, InkEditor, _buildPath2D).call(this, path);
  14850. editor.bezierPath2D.push(path2D);
  14851. }
  14852. const bbox = _classPrivateMethodGet(editor, _getBbox, _getBbox2).call(editor);
  14853. _classPrivateFieldSet(editor, _baseWidth, Math.max(RESIZER_SIZE, bbox[2] - bbox[0]));
  14854. _classPrivateFieldSet(editor, _baseHeight, Math.max(RESIZER_SIZE, bbox[3] - bbox[1]));
  14855. _classPrivateMethodGet(editor, _setScaleFactor, _setScaleFactor2).call(editor, width, height);
  14856. return editor;
  14857. }
  14858. serialize() {
  14859. if (this.isEmpty()) {
  14860. return null;
  14861. }
  14862. const rect = this.getRect(0, 0);
  14863. const height = this.rotation % 180 === 0 ? rect[3] - rect[1] : rect[2] - rect[0];
  14864. const color = _editor.AnnotationEditor._colorManager.convert(this.ctx.strokeStyle);
  14865. return {
  14866. annotationType: _util.AnnotationEditorType.INK,
  14867. color,
  14868. thickness: this.thickness,
  14869. opacity: this.opacity,
  14870. paths: _classPrivateMethodGet(this, _serializePaths, _serializePaths2).call(this, this.scaleFactor / this.parentScale, this.translationX, this.translationY, height),
  14871. pageIndex: this.pageIndex,
  14872. rect,
  14873. rotation: this.rotation
  14874. };
  14875. }
  14876. }
  14877. exports.InkEditor = InkEditor;
  14878. function _updateThickness2(thickness) {
  14879. const savedThickness = this.thickness;
  14880. this.addCommands({
  14881. cmd: () => {
  14882. this.thickness = thickness;
  14883. _classPrivateMethodGet(this, _fitToContent, _fitToContent2).call(this);
  14884. },
  14885. undo: () => {
  14886. this.thickness = savedThickness;
  14887. _classPrivateMethodGet(this, _fitToContent, _fitToContent2).call(this);
  14888. },
  14889. mustExec: true,
  14890. type: _util.AnnotationEditorParamsType.INK_THICKNESS,
  14891. overwriteIfSameType: true,
  14892. keepUndo: true
  14893. });
  14894. }
  14895. function _updateColor2(color) {
  14896. const savedColor = this.color;
  14897. this.addCommands({
  14898. cmd: () => {
  14899. this.color = color;
  14900. _classPrivateMethodGet(this, _redraw, _redraw2).call(this);
  14901. },
  14902. undo: () => {
  14903. this.color = savedColor;
  14904. _classPrivateMethodGet(this, _redraw, _redraw2).call(this);
  14905. },
  14906. mustExec: true,
  14907. type: _util.AnnotationEditorParamsType.INK_COLOR,
  14908. overwriteIfSameType: true,
  14909. keepUndo: true
  14910. });
  14911. }
  14912. function _updateOpacity2(opacity) {
  14913. opacity /= 100;
  14914. const savedOpacity = this.opacity;
  14915. this.addCommands({
  14916. cmd: () => {
  14917. this.opacity = opacity;
  14918. _classPrivateMethodGet(this, _redraw, _redraw2).call(this);
  14919. },
  14920. undo: () => {
  14921. this.opacity = savedOpacity;
  14922. _classPrivateMethodGet(this, _redraw, _redraw2).call(this);
  14923. },
  14924. mustExec: true,
  14925. type: _util.AnnotationEditorParamsType.INK_OPACITY,
  14926. overwriteIfSameType: true,
  14927. keepUndo: true
  14928. });
  14929. }
  14930. function _getInitialBBox2() {
  14931. const {
  14932. parentRotation,
  14933. parentDimensions: [width, height]
  14934. } = this;
  14935. switch (parentRotation) {
  14936. case 90:
  14937. return [0, height, height, width];
  14938. case 180:
  14939. return [width, height, width, height];
  14940. case 270:
  14941. return [width, 0, height, width];
  14942. default:
  14943. return [0, 0, width, height];
  14944. }
  14945. }
  14946. function _setStroke2() {
  14947. const {
  14948. ctx,
  14949. color,
  14950. opacity,
  14951. thickness,
  14952. parentScale,
  14953. scaleFactor
  14954. } = this;
  14955. ctx.lineWidth = thickness * parentScale / scaleFactor;
  14956. ctx.lineCap = "round";
  14957. ctx.lineJoin = "round";
  14958. ctx.miterLimit = 10;
  14959. ctx.strokeStyle = `${color}${(0, _tools.opacityToHex)(opacity)}`;
  14960. }
  14961. function _startDrawing2(x, y) {
  14962. this.isEditing = true;
  14963. if (!_classPrivateFieldGet(this, _isCanvasInitialized)) {
  14964. _classPrivateFieldSet(this, _isCanvasInitialized, true);
  14965. _classPrivateMethodGet(this, _setCanvasDims, _setCanvasDims2).call(this);
  14966. this.thickness || (this.thickness = InkEditor._defaultThickness);
  14967. this.color || (this.color = InkEditor._defaultColor || _editor.AnnotationEditor._defaultLineColor);
  14968. this.opacity ?? (this.opacity = InkEditor._defaultOpacity);
  14969. }
  14970. this.currentPath.push([x, y]);
  14971. _classPrivateFieldSet(this, _lastPoint, null);
  14972. _classPrivateMethodGet(this, _setStroke, _setStroke2).call(this);
  14973. this.ctx.beginPath();
  14974. this.ctx.moveTo(x, y);
  14975. _classPrivateFieldSet(this, _requestFrameCallback, () => {
  14976. if (!_classPrivateFieldGet(this, _requestFrameCallback)) {
  14977. return;
  14978. }
  14979. if (_classPrivateFieldGet(this, _lastPoint)) {
  14980. if (this.isEmpty()) {
  14981. this.ctx.setTransform(1, 0, 0, 1, 0, 0);
  14982. this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
  14983. } else {
  14984. _classPrivateMethodGet(this, _redraw, _redraw2).call(this);
  14985. }
  14986. this.ctx.lineTo(..._classPrivateFieldGet(this, _lastPoint));
  14987. _classPrivateFieldSet(this, _lastPoint, null);
  14988. this.ctx.stroke();
  14989. }
  14990. window.requestAnimationFrame(_classPrivateFieldGet(this, _requestFrameCallback));
  14991. });
  14992. window.requestAnimationFrame(_classPrivateFieldGet(this, _requestFrameCallback));
  14993. }
  14994. function _draw2(x, y) {
  14995. const [lastX, lastY] = this.currentPath.at(-1);
  14996. if (x === lastX && y === lastY) {
  14997. return;
  14998. }
  14999. this.currentPath.push([x, y]);
  15000. _classPrivateFieldSet(this, _lastPoint, [x, y]);
  15001. }
  15002. function _stopDrawing2(x, y) {
  15003. this.ctx.closePath();
  15004. _classPrivateFieldSet(this, _requestFrameCallback, null);
  15005. x = Math.min(Math.max(x, 0), this.canvas.width);
  15006. y = Math.min(Math.max(y, 0), this.canvas.height);
  15007. const [lastX, lastY] = this.currentPath.at(-1);
  15008. if (x !== lastX || y !== lastY) {
  15009. this.currentPath.push([x, y]);
  15010. }
  15011. let bezier;
  15012. if (this.currentPath.length !== 1) {
  15013. bezier = (0, _pdfjsFitCurve.fitCurve)(this.currentPath, 30, null);
  15014. } else {
  15015. const xy = [x, y];
  15016. bezier = [[xy, xy.slice(), xy.slice(), xy]];
  15017. }
  15018. const path2D = _classStaticPrivateMethodGet(InkEditor, InkEditor, _buildPath2D).call(InkEditor, bezier);
  15019. this.currentPath.length = 0;
  15020. const cmd = () => {
  15021. this.paths.push(bezier);
  15022. this.bezierPath2D.push(path2D);
  15023. this.rebuild();
  15024. };
  15025. const undo = () => {
  15026. this.paths.pop();
  15027. this.bezierPath2D.pop();
  15028. if (this.paths.length === 0) {
  15029. this.remove();
  15030. } else {
  15031. if (!this.canvas) {
  15032. _classPrivateMethodGet(this, _createCanvas, _createCanvas2).call(this);
  15033. _classPrivateMethodGet(this, _createObserver, _createObserver2).call(this);
  15034. }
  15035. _classPrivateMethodGet(this, _fitToContent, _fitToContent2).call(this);
  15036. }
  15037. };
  15038. this.addCommands({
  15039. cmd,
  15040. undo,
  15041. mustExec: true
  15042. });
  15043. }
  15044. function _redraw2() {
  15045. if (this.isEmpty()) {
  15046. _classPrivateMethodGet(this, _updateTransform, _updateTransform2).call(this);
  15047. return;
  15048. }
  15049. _classPrivateMethodGet(this, _setStroke, _setStroke2).call(this);
  15050. const {
  15051. canvas,
  15052. ctx
  15053. } = this;
  15054. ctx.setTransform(1, 0, 0, 1, 0, 0);
  15055. ctx.clearRect(0, 0, canvas.width, canvas.height);
  15056. _classPrivateMethodGet(this, _updateTransform, _updateTransform2).call(this);
  15057. for (const path of this.bezierPath2D) {
  15058. ctx.stroke(path);
  15059. }
  15060. }
  15061. function _endDrawing2(event) {
  15062. _classPrivateMethodGet(this, _stopDrawing, _stopDrawing2).call(this, event.offsetX, event.offsetY);
  15063. this.canvas.removeEventListener("pointerleave", _classPrivateFieldGet(this, _boundCanvasPointerleave));
  15064. this.canvas.removeEventListener("pointermove", _classPrivateFieldGet(this, _boundCanvasPointermove));
  15065. this.addToAnnotationStorage();
  15066. }
  15067. function _createCanvas2() {
  15068. this.canvas = document.createElement("canvas");
  15069. this.canvas.width = this.canvas.height = 0;
  15070. this.canvas.className = "inkEditorCanvas";
  15071. InkEditor._l10nPromise.get("editor_ink_canvas_aria_label").then(msg => {
  15072. var _this$canvas;
  15073. return (_this$canvas = this.canvas) === null || _this$canvas === void 0 ? void 0 : _this$canvas.setAttribute("aria-label", msg);
  15074. });
  15075. this.div.append(this.canvas);
  15076. this.ctx = this.canvas.getContext("2d");
  15077. }
  15078. function _createObserver2() {
  15079. let timeoutId = null;
  15080. _classPrivateFieldSet(this, _observer, new ResizeObserver(entries => {
  15081. const rect = entries[0].contentRect;
  15082. if (rect.width && rect.height) {
  15083. if (timeoutId !== null) {
  15084. clearTimeout(timeoutId);
  15085. }
  15086. timeoutId = setTimeout(() => {
  15087. this.fixDims();
  15088. timeoutId = null;
  15089. }, TIME_TO_WAIT_BEFORE_FIXING_DIMS);
  15090. this.setDimensions(rect.width, rect.height);
  15091. }
  15092. }));
  15093. _classPrivateFieldGet(this, _observer).observe(this.div);
  15094. }
  15095. function _setCanvasDims2() {
  15096. if (!_classPrivateFieldGet(this, _isCanvasInitialized)) {
  15097. return;
  15098. }
  15099. const [parentWidth, parentHeight] = this.parentDimensions;
  15100. this.canvas.width = Math.ceil(this.width * parentWidth);
  15101. this.canvas.height = Math.ceil(this.height * parentHeight);
  15102. _classPrivateMethodGet(this, _updateTransform, _updateTransform2).call(this);
  15103. }
  15104. function _setScaleFactor2(width, height) {
  15105. const padding = _classPrivateMethodGet(this, _getPadding, _getPadding2).call(this);
  15106. const scaleFactorW = (width - padding) / _classPrivateFieldGet(this, _baseWidth);
  15107. const scaleFactorH = (height - padding) / _classPrivateFieldGet(this, _baseHeight);
  15108. this.scaleFactor = Math.min(scaleFactorW, scaleFactorH);
  15109. }
  15110. function _updateTransform2() {
  15111. const padding = _classPrivateMethodGet(this, _getPadding, _getPadding2).call(this) / 2;
  15112. this.ctx.setTransform(this.scaleFactor, 0, 0, this.scaleFactor, this.translationX * this.scaleFactor + padding, this.translationY * this.scaleFactor + padding);
  15113. }
  15114. function _buildPath2D(bezier) {
  15115. const path2D = new Path2D();
  15116. for (let i = 0, ii = bezier.length; i < ii; i++) {
  15117. const [first, control1, control2, second] = bezier[i];
  15118. if (i === 0) {
  15119. path2D.moveTo(...first);
  15120. }
  15121. path2D.bezierCurveTo(control1[0], control1[1], control2[0], control2[1], second[0], second[1]);
  15122. }
  15123. return path2D;
  15124. }
  15125. function _serializePaths2(s, tx, ty, h) {
  15126. const NUMBER_OF_POINTS_ON_BEZIER_CURVE = 4;
  15127. const paths = [];
  15128. const padding = this.thickness / 2;
  15129. let buffer, points;
  15130. for (const bezier of this.paths) {
  15131. buffer = [];
  15132. points = [];
  15133. for (let i = 0, ii = bezier.length; i < ii; i++) {
  15134. const [first, control1, control2, second] = bezier[i];
  15135. const p10 = s * (first[0] + tx) + padding;
  15136. const p11 = h - s * (first[1] + ty) - padding;
  15137. const p20 = s * (control1[0] + tx) + padding;
  15138. const p21 = h - s * (control1[1] + ty) - padding;
  15139. const p30 = s * (control2[0] + tx) + padding;
  15140. const p31 = h - s * (control2[1] + ty) - padding;
  15141. const p40 = s * (second[0] + tx) + padding;
  15142. const p41 = h - s * (second[1] + ty) - padding;
  15143. if (i === 0) {
  15144. buffer.push(p10, p11);
  15145. points.push(p10, p11);
  15146. }
  15147. buffer.push(p20, p21, p30, p31, p40, p41);
  15148. _classPrivateMethodGet(this, _extractPointsOnBezier, _extractPointsOnBezier2).call(this, p10, p11, p20, p21, p30, p31, p40, p41, NUMBER_OF_POINTS_ON_BEZIER_CURVE, points);
  15149. }
  15150. paths.push({
  15151. bezier: buffer,
  15152. points
  15153. });
  15154. }
  15155. return paths;
  15156. }
  15157. function _extractPointsOnBezier2(p10, p11, p20, p21, p30, p31, p40, p41, n, points) {
  15158. if (_classPrivateMethodGet(this, _isAlmostFlat, _isAlmostFlat2).call(this, p10, p11, p20, p21, p30, p31, p40, p41)) {
  15159. points.push(p40, p41);
  15160. return;
  15161. }
  15162. for (let i = 1; i < n - 1; i++) {
  15163. const t = i / n;
  15164. const mt = 1 - t;
  15165. let q10 = t * p10 + mt * p20;
  15166. let q11 = t * p11 + mt * p21;
  15167. let q20 = t * p20 + mt * p30;
  15168. let q21 = t * p21 + mt * p31;
  15169. const q30 = t * p30 + mt * p40;
  15170. const q31 = t * p31 + mt * p41;
  15171. q10 = t * q10 + mt * q20;
  15172. q11 = t * q11 + mt * q21;
  15173. q20 = t * q20 + mt * q30;
  15174. q21 = t * q21 + mt * q31;
  15175. q10 = t * q10 + mt * q20;
  15176. q11 = t * q11 + mt * q21;
  15177. points.push(q10, q11);
  15178. }
  15179. points.push(p40, p41);
  15180. }
  15181. function _isAlmostFlat2(p10, p11, p20, p21, p30, p31, p40, p41) {
  15182. const tol = 10;
  15183. const ax = (3 * p20 - 2 * p10 - p40) ** 2;
  15184. const ay = (3 * p21 - 2 * p11 - p41) ** 2;
  15185. const bx = (3 * p30 - p10 - 2 * p40) ** 2;
  15186. const by = (3 * p31 - p11 - 2 * p41) ** 2;
  15187. return Math.max(ax, bx) + Math.max(ay, by) <= tol;
  15188. }
  15189. function _getBbox2() {
  15190. let xMin = Infinity;
  15191. let xMax = -Infinity;
  15192. let yMin = Infinity;
  15193. let yMax = -Infinity;
  15194. for (const path of this.paths) {
  15195. for (const [first, control1, control2, second] of path) {
  15196. const bbox = _util.Util.bezierBoundingBox(...first, ...control1, ...control2, ...second);
  15197. xMin = Math.min(xMin, bbox[0]);
  15198. yMin = Math.min(yMin, bbox[1]);
  15199. xMax = Math.max(xMax, bbox[2]);
  15200. yMax = Math.max(yMax, bbox[3]);
  15201. }
  15202. }
  15203. return [xMin, yMin, xMax, yMax];
  15204. }
  15205. function _getPadding2() {
  15206. return _classPrivateFieldGet(this, _disableEditing) ? Math.ceil(this.thickness * this.parentScale) : 0;
  15207. }
  15208. function _fitToContent2() {
  15209. let firstTime = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  15210. if (this.isEmpty()) {
  15211. return;
  15212. }
  15213. if (!_classPrivateFieldGet(this, _disableEditing)) {
  15214. _classPrivateMethodGet(this, _redraw, _redraw2).call(this);
  15215. return;
  15216. }
  15217. const bbox = _classPrivateMethodGet(this, _getBbox, _getBbox2).call(this);
  15218. const padding = _classPrivateMethodGet(this, _getPadding, _getPadding2).call(this);
  15219. _classPrivateFieldSet(this, _baseWidth, Math.max(RESIZER_SIZE, bbox[2] - bbox[0]));
  15220. _classPrivateFieldSet(this, _baseHeight, Math.max(RESIZER_SIZE, bbox[3] - bbox[1]));
  15221. const width = Math.ceil(padding + _classPrivateFieldGet(this, _baseWidth) * this.scaleFactor);
  15222. const height = Math.ceil(padding + _classPrivateFieldGet(this, _baseHeight) * this.scaleFactor);
  15223. const [parentWidth, parentHeight] = this.parentDimensions;
  15224. this.width = width / parentWidth;
  15225. this.height = height / parentHeight;
  15226. _classPrivateFieldSet(this, _aspectRatio, width / height);
  15227. _classPrivateMethodGet(this, _setMinDims, _setMinDims2).call(this);
  15228. const prevTranslationX = this.translationX;
  15229. const prevTranslationY = this.translationY;
  15230. this.translationX = -bbox[0];
  15231. this.translationY = -bbox[1];
  15232. _classPrivateMethodGet(this, _setCanvasDims, _setCanvasDims2).call(this);
  15233. _classPrivateMethodGet(this, _redraw, _redraw2).call(this);
  15234. _classPrivateFieldSet(this, _realWidth, width);
  15235. _classPrivateFieldSet(this, _realHeight, height);
  15236. this.setDims(width, height);
  15237. const unscaledPadding = firstTime ? padding / this.scaleFactor / 2 : 0;
  15238. this.translate(prevTranslationX - this.translationX - unscaledPadding, prevTranslationY - this.translationY - unscaledPadding);
  15239. }
  15240. function _setMinDims2() {
  15241. const {
  15242. style
  15243. } = this.div;
  15244. if (_classPrivateFieldGet(this, _aspectRatio) >= 1) {
  15245. style.minHeight = `${RESIZER_SIZE}px`;
  15246. style.minWidth = `${Math.round(_classPrivateFieldGet(this, _aspectRatio) * RESIZER_SIZE)}px`;
  15247. } else {
  15248. style.minWidth = `${RESIZER_SIZE}px`;
  15249. style.minHeight = `${Math.round(RESIZER_SIZE / _classPrivateFieldGet(this, _aspectRatio))}px`;
  15250. }
  15251. }
  15252. _defineProperty(InkEditor, "_defaultColor", null);
  15253. _defineProperty(InkEditor, "_defaultOpacity", 1);
  15254. _defineProperty(InkEditor, "_defaultThickness", 1);
  15255. _defineProperty(InkEditor, "_l10nPromise", void 0);
  15256. _defineProperty(InkEditor, "_type", "ink");
  15257. /***/ }),
  15258. /* 162 */
  15259. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  15260. "use strict";
  15261. Object.defineProperty(exports, "__esModule", ({
  15262. value: true
  15263. }));
  15264. exports.fitCurve = void 0;
  15265. const fitCurve = __w_pdfjs_require__(163);
  15266. exports.fitCurve = fitCurve;
  15267. /***/ }),
  15268. /* 163 */
  15269. /***/ ((module) => {
  15270. "use strict";
  15271. function fitCurve(points, maxError, progressCallback) {
  15272. if (!Array.isArray(points)) {
  15273. throw new TypeError("First argument should be an array");
  15274. }
  15275. points.forEach(point => {
  15276. if (!Array.isArray(point) || point.some(item => typeof item !== 'number') || point.length !== points[0].length) {
  15277. throw Error("Each point should be an array of numbers. Each point should have the same amount of numbers.");
  15278. }
  15279. });
  15280. points = points.filter((point, i) => i === 0 || !point.every((val, j) => val === points[i - 1][j]));
  15281. if (points.length < 2) {
  15282. return [];
  15283. }
  15284. const len = points.length;
  15285. const leftTangent = createTangent(points[1], points[0]);
  15286. const rightTangent = createTangent(points[len - 2], points[len - 1]);
  15287. return fitCubic(points, leftTangent, rightTangent, maxError, progressCallback);
  15288. }
  15289. function fitCubic(points, leftTangent, rightTangent, error, progressCallback) {
  15290. const MaxIterations = 20;
  15291. var bezCurve, u, uPrime, maxError, prevErr, splitPoint, prevSplit, centerVector, toCenterTangent, fromCenterTangent, beziers, dist, i;
  15292. if (points.length === 2) {
  15293. dist = maths.vectorLen(maths.subtract(points[0], points[1])) / 3.0;
  15294. bezCurve = [points[0], maths.addArrays(points[0], maths.mulItems(leftTangent, dist)), maths.addArrays(points[1], maths.mulItems(rightTangent, dist)), points[1]];
  15295. return [bezCurve];
  15296. }
  15297. u = chordLengthParameterize(points);
  15298. [bezCurve, maxError, splitPoint] = generateAndReport(points, u, u, leftTangent, rightTangent, progressCallback);
  15299. if (maxError === 0 || maxError < error) {
  15300. return [bezCurve];
  15301. }
  15302. if (maxError < error * error) {
  15303. uPrime = u;
  15304. prevErr = maxError;
  15305. prevSplit = splitPoint;
  15306. for (i = 0; i < MaxIterations; i++) {
  15307. uPrime = reparameterize(bezCurve, points, uPrime);
  15308. [bezCurve, maxError, splitPoint] = generateAndReport(points, u, uPrime, leftTangent, rightTangent, progressCallback);
  15309. if (maxError < error) {
  15310. return [bezCurve];
  15311. } else if (splitPoint === prevSplit) {
  15312. let errChange = maxError / prevErr;
  15313. if (errChange > .9999 && errChange < 1.0001) {
  15314. break;
  15315. }
  15316. }
  15317. prevErr = maxError;
  15318. prevSplit = splitPoint;
  15319. }
  15320. }
  15321. beziers = [];
  15322. centerVector = maths.subtract(points[splitPoint - 1], points[splitPoint + 1]);
  15323. if (centerVector.every(val => val === 0)) {
  15324. centerVector = maths.subtract(points[splitPoint - 1], points[splitPoint]);
  15325. [centerVector[0], centerVector[1]] = [-centerVector[1], centerVector[0]];
  15326. }
  15327. toCenterTangent = maths.normalize(centerVector);
  15328. fromCenterTangent = maths.mulItems(toCenterTangent, -1);
  15329. beziers = beziers.concat(fitCubic(points.slice(0, splitPoint + 1), leftTangent, toCenterTangent, error, progressCallback));
  15330. beziers = beziers.concat(fitCubic(points.slice(splitPoint), fromCenterTangent, rightTangent, error, progressCallback));
  15331. return beziers;
  15332. }
  15333. ;
  15334. function generateAndReport(points, paramsOrig, paramsPrime, leftTangent, rightTangent, progressCallback) {
  15335. var bezCurve, maxError, splitPoint;
  15336. bezCurve = generateBezier(points, paramsPrime, leftTangent, rightTangent, progressCallback);
  15337. [maxError, splitPoint] = computeMaxError(points, bezCurve, paramsOrig);
  15338. if (progressCallback) {
  15339. progressCallback({
  15340. bez: bezCurve,
  15341. points: points,
  15342. params: paramsOrig,
  15343. maxErr: maxError,
  15344. maxPoint: splitPoint
  15345. });
  15346. }
  15347. return [bezCurve, maxError, splitPoint];
  15348. }
  15349. function generateBezier(points, parameters, leftTangent, rightTangent) {
  15350. var bezCurve,
  15351. A,
  15352. a,
  15353. C,
  15354. X,
  15355. det_C0_C1,
  15356. det_C0_X,
  15357. det_X_C1,
  15358. alpha_l,
  15359. alpha_r,
  15360. epsilon,
  15361. segLength,
  15362. i,
  15363. len,
  15364. tmp,
  15365. u,
  15366. ux,
  15367. firstPoint = points[0],
  15368. lastPoint = points[points.length - 1];
  15369. bezCurve = [firstPoint, null, null, lastPoint];
  15370. A = maths.zeros_Xx2x2(parameters.length);
  15371. for (i = 0, len = parameters.length; i < len; i++) {
  15372. u = parameters[i];
  15373. ux = 1 - u;
  15374. a = A[i];
  15375. a[0] = maths.mulItems(leftTangent, 3 * u * (ux * ux));
  15376. a[1] = maths.mulItems(rightTangent, 3 * ux * (u * u));
  15377. }
  15378. C = [[0, 0], [0, 0]];
  15379. X = [0, 0];
  15380. for (i = 0, len = points.length; i < len; i++) {
  15381. u = parameters[i];
  15382. a = A[i];
  15383. C[0][0] += maths.dot(a[0], a[0]);
  15384. C[0][1] += maths.dot(a[0], a[1]);
  15385. C[1][0] += maths.dot(a[0], a[1]);
  15386. C[1][1] += maths.dot(a[1], a[1]);
  15387. tmp = maths.subtract(points[i], bezier.q([firstPoint, firstPoint, lastPoint, lastPoint], u));
  15388. X[0] += maths.dot(a[0], tmp);
  15389. X[1] += maths.dot(a[1], tmp);
  15390. }
  15391. det_C0_C1 = C[0][0] * C[1][1] - C[1][0] * C[0][1];
  15392. det_C0_X = C[0][0] * X[1] - C[1][0] * X[0];
  15393. det_X_C1 = X[0] * C[1][1] - X[1] * C[0][1];
  15394. alpha_l = det_C0_C1 === 0 ? 0 : det_X_C1 / det_C0_C1;
  15395. alpha_r = det_C0_C1 === 0 ? 0 : det_C0_X / det_C0_C1;
  15396. segLength = maths.vectorLen(maths.subtract(firstPoint, lastPoint));
  15397. epsilon = 1.0e-6 * segLength;
  15398. if (alpha_l < epsilon || alpha_r < epsilon) {
  15399. bezCurve[1] = maths.addArrays(firstPoint, maths.mulItems(leftTangent, segLength / 3.0));
  15400. bezCurve[2] = maths.addArrays(lastPoint, maths.mulItems(rightTangent, segLength / 3.0));
  15401. } else {
  15402. bezCurve[1] = maths.addArrays(firstPoint, maths.mulItems(leftTangent, alpha_l));
  15403. bezCurve[2] = maths.addArrays(lastPoint, maths.mulItems(rightTangent, alpha_r));
  15404. }
  15405. return bezCurve;
  15406. }
  15407. ;
  15408. function reparameterize(bezier, points, parameters) {
  15409. return parameters.map((p, i) => newtonRaphsonRootFind(bezier, points[i], p));
  15410. }
  15411. ;
  15412. function newtonRaphsonRootFind(bez, point, u) {
  15413. var d = maths.subtract(bezier.q(bez, u), point),
  15414. qprime = bezier.qprime(bez, u),
  15415. numerator = maths.mulMatrix(d, qprime),
  15416. denominator = maths.sum(maths.squareItems(qprime)) + 2 * maths.mulMatrix(d, bezier.qprimeprime(bez, u));
  15417. if (denominator === 0) {
  15418. return u;
  15419. } else {
  15420. return u - numerator / denominator;
  15421. }
  15422. }
  15423. ;
  15424. function chordLengthParameterize(points) {
  15425. var u = [],
  15426. currU,
  15427. prevU,
  15428. prevP;
  15429. points.forEach((p, i) => {
  15430. currU = i ? prevU + maths.vectorLen(maths.subtract(p, prevP)) : 0;
  15431. u.push(currU);
  15432. prevU = currU;
  15433. prevP = p;
  15434. });
  15435. u = u.map(x => x / prevU);
  15436. return u;
  15437. }
  15438. ;
  15439. function computeMaxError(points, bez, parameters) {
  15440. var dist, maxDist, splitPoint, v, i, count, point, t;
  15441. maxDist = 0;
  15442. splitPoint = Math.floor(points.length / 2);
  15443. const t_distMap = mapTtoRelativeDistances(bez, 10);
  15444. for (i = 0, count = points.length; i < count; i++) {
  15445. point = points[i];
  15446. t = find_t(bez, parameters[i], t_distMap, 10);
  15447. v = maths.subtract(bezier.q(bez, t), point);
  15448. dist = v[0] * v[0] + v[1] * v[1];
  15449. if (dist > maxDist) {
  15450. maxDist = dist;
  15451. splitPoint = i;
  15452. }
  15453. }
  15454. return [maxDist, splitPoint];
  15455. }
  15456. ;
  15457. var mapTtoRelativeDistances = function (bez, B_parts) {
  15458. var B_t_curr;
  15459. var B_t_dist = [0];
  15460. var B_t_prev = bez[0];
  15461. var sumLen = 0;
  15462. for (var i = 1; i <= B_parts; i++) {
  15463. B_t_curr = bezier.q(bez, i / B_parts);
  15464. sumLen += maths.vectorLen(maths.subtract(B_t_curr, B_t_prev));
  15465. B_t_dist.push(sumLen);
  15466. B_t_prev = B_t_curr;
  15467. }
  15468. B_t_dist = B_t_dist.map(x => x / sumLen);
  15469. return B_t_dist;
  15470. };
  15471. function find_t(bez, param, t_distMap, B_parts) {
  15472. if (param < 0) {
  15473. return 0;
  15474. }
  15475. if (param > 1) {
  15476. return 1;
  15477. }
  15478. var lenMax, lenMin, tMax, tMin, t;
  15479. for (var i = 1; i <= B_parts; i++) {
  15480. if (param <= t_distMap[i]) {
  15481. tMin = (i - 1) / B_parts;
  15482. tMax = i / B_parts;
  15483. lenMin = t_distMap[i - 1];
  15484. lenMax = t_distMap[i];
  15485. t = (param - lenMin) / (lenMax - lenMin) * (tMax - tMin) + tMin;
  15486. break;
  15487. }
  15488. }
  15489. return t;
  15490. }
  15491. function createTangent(pointA, pointB) {
  15492. return maths.normalize(maths.subtract(pointA, pointB));
  15493. }
  15494. class maths {
  15495. static zeros_Xx2x2(x) {
  15496. var zs = [];
  15497. while (x--) {
  15498. zs.push([0, 0]);
  15499. }
  15500. return zs;
  15501. }
  15502. static mulItems(items, multiplier) {
  15503. return items.map(x => x * multiplier);
  15504. }
  15505. static mulMatrix(m1, m2) {
  15506. return m1.reduce((sum, x1, i) => sum + x1 * m2[i], 0);
  15507. }
  15508. static subtract(arr1, arr2) {
  15509. return arr1.map((x1, i) => x1 - arr2[i]);
  15510. }
  15511. static addArrays(arr1, arr2) {
  15512. return arr1.map((x1, i) => x1 + arr2[i]);
  15513. }
  15514. static addItems(items, addition) {
  15515. return items.map(x => x + addition);
  15516. }
  15517. static sum(items) {
  15518. return items.reduce((sum, x) => sum + x);
  15519. }
  15520. static dot(m1, m2) {
  15521. return maths.mulMatrix(m1, m2);
  15522. }
  15523. static vectorLen(v) {
  15524. return Math.hypot(...v);
  15525. }
  15526. static divItems(items, divisor) {
  15527. return items.map(x => x / divisor);
  15528. }
  15529. static squareItems(items) {
  15530. return items.map(x => x * x);
  15531. }
  15532. static normalize(v) {
  15533. return this.divItems(v, this.vectorLen(v));
  15534. }
  15535. }
  15536. class bezier {
  15537. static q(ctrlPoly, t) {
  15538. var tx = 1.0 - t;
  15539. var pA = maths.mulItems(ctrlPoly[0], tx * tx * tx),
  15540. pB = maths.mulItems(ctrlPoly[1], 3 * tx * tx * t),
  15541. pC = maths.mulItems(ctrlPoly[2], 3 * tx * t * t),
  15542. pD = maths.mulItems(ctrlPoly[3], t * t * t);
  15543. return maths.addArrays(maths.addArrays(pA, pB), maths.addArrays(pC, pD));
  15544. }
  15545. static qprime(ctrlPoly, t) {
  15546. var tx = 1.0 - t;
  15547. var pA = maths.mulItems(maths.subtract(ctrlPoly[1], ctrlPoly[0]), 3 * tx * tx),
  15548. pB = maths.mulItems(maths.subtract(ctrlPoly[2], ctrlPoly[1]), 6 * tx * t),
  15549. pC = maths.mulItems(maths.subtract(ctrlPoly[3], ctrlPoly[2]), 3 * t * t);
  15550. return maths.addArrays(maths.addArrays(pA, pB), pC);
  15551. }
  15552. static qprimeprime(ctrlPoly, t) {
  15553. return maths.addArrays(maths.mulItems(maths.addArrays(maths.subtract(ctrlPoly[2], maths.mulItems(ctrlPoly[1], 2)), ctrlPoly[0]), 6 * (1.0 - t)), maths.mulItems(maths.addArrays(maths.subtract(ctrlPoly[3], maths.mulItems(ctrlPoly[2], 2)), ctrlPoly[1]), 6 * t));
  15554. }
  15555. }
  15556. module.exports = fitCurve;
  15557. module.exports.fitCubic = fitCubic;
  15558. module.exports.createTangent = createTangent;
  15559. /***/ }),
  15560. /* 164 */
  15561. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  15562. "use strict";
  15563. Object.defineProperty(exports, "__esModule", ({
  15564. value: true
  15565. }));
  15566. exports.AnnotationLayer = void 0;
  15567. var _util = __w_pdfjs_require__(1);
  15568. var _display_utils = __w_pdfjs_require__(139);
  15569. var _annotation_storage = __w_pdfjs_require__(136);
  15570. var _scripting_utils = __w_pdfjs_require__(165);
  15571. var _xfa_layer = __w_pdfjs_require__(166);
  15572. function _classStaticPrivateMethodGet(receiver, classConstructor, method) { _classCheckPrivateStaticAccess(receiver, classConstructor); return method; }
  15573. function _classCheckPrivateStaticAccess(receiver, classConstructor) { if (receiver !== classConstructor) { throw new TypeError("Private static access of wrong provenance"); } }
  15574. function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
  15575. function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
  15576. function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
  15577. const DEFAULT_TAB_INDEX = 1000;
  15578. const DEFAULT_FONT_SIZE = 9;
  15579. const GetElementsByNameSet = new WeakSet();
  15580. function getRectDims(rect) {
  15581. return {
  15582. width: rect[2] - rect[0],
  15583. height: rect[3] - rect[1]
  15584. };
  15585. }
  15586. class AnnotationElementFactory {
  15587. static create(parameters) {
  15588. const subtype = parameters.data.annotationType;
  15589. switch (subtype) {
  15590. case _util.AnnotationType.LINK:
  15591. return new LinkAnnotationElement(parameters);
  15592. case _util.AnnotationType.TEXT:
  15593. return new TextAnnotationElement(parameters);
  15594. case _util.AnnotationType.WIDGET:
  15595. const fieldType = parameters.data.fieldType;
  15596. switch (fieldType) {
  15597. case "Tx":
  15598. return new TextWidgetAnnotationElement(parameters);
  15599. case "Btn":
  15600. if (parameters.data.radioButton) {
  15601. return new RadioButtonWidgetAnnotationElement(parameters);
  15602. } else if (parameters.data.checkBox) {
  15603. return new CheckboxWidgetAnnotationElement(parameters);
  15604. }
  15605. return new PushButtonWidgetAnnotationElement(parameters);
  15606. case "Ch":
  15607. return new ChoiceWidgetAnnotationElement(parameters);
  15608. }
  15609. return new WidgetAnnotationElement(parameters);
  15610. case _util.AnnotationType.POPUP:
  15611. return new PopupAnnotationElement(parameters);
  15612. case _util.AnnotationType.FREETEXT:
  15613. return new FreeTextAnnotationElement(parameters);
  15614. case _util.AnnotationType.LINE:
  15615. return new LineAnnotationElement(parameters);
  15616. case _util.AnnotationType.SQUARE:
  15617. return new SquareAnnotationElement(parameters);
  15618. case _util.AnnotationType.CIRCLE:
  15619. return new CircleAnnotationElement(parameters);
  15620. case _util.AnnotationType.POLYLINE:
  15621. return new PolylineAnnotationElement(parameters);
  15622. case _util.AnnotationType.CARET:
  15623. return new CaretAnnotationElement(parameters);
  15624. case _util.AnnotationType.INK:
  15625. return new InkAnnotationElement(parameters);
  15626. case _util.AnnotationType.POLYGON:
  15627. return new PolygonAnnotationElement(parameters);
  15628. case _util.AnnotationType.HIGHLIGHT:
  15629. return new HighlightAnnotationElement(parameters);
  15630. case _util.AnnotationType.UNDERLINE:
  15631. return new UnderlineAnnotationElement(parameters);
  15632. case _util.AnnotationType.SQUIGGLY:
  15633. return new SquigglyAnnotationElement(parameters);
  15634. case _util.AnnotationType.STRIKEOUT:
  15635. return new StrikeOutAnnotationElement(parameters);
  15636. case _util.AnnotationType.STAMP:
  15637. return new StampAnnotationElement(parameters);
  15638. case _util.AnnotationType.FILEATTACHMENT:
  15639. return new FileAttachmentAnnotationElement(parameters);
  15640. default:
  15641. return new AnnotationElement(parameters);
  15642. }
  15643. }
  15644. }
  15645. class AnnotationElement {
  15646. constructor(parameters) {
  15647. let {
  15648. isRenderable = false,
  15649. ignoreBorder = false,
  15650. createQuadrilaterals = false
  15651. } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  15652. this.isRenderable = isRenderable;
  15653. this.data = parameters.data;
  15654. this.layer = parameters.layer;
  15655. this.page = parameters.page;
  15656. this.viewport = parameters.viewport;
  15657. this.linkService = parameters.linkService;
  15658. this.downloadManager = parameters.downloadManager;
  15659. this.imageResourcesPath = parameters.imageResourcesPath;
  15660. this.renderForms = parameters.renderForms;
  15661. this.svgFactory = parameters.svgFactory;
  15662. this.annotationStorage = parameters.annotationStorage;
  15663. this.enableScripting = parameters.enableScripting;
  15664. this.hasJSActions = parameters.hasJSActions;
  15665. this._fieldObjects = parameters.fieldObjects;
  15666. if (isRenderable) {
  15667. this.container = this._createContainer(ignoreBorder);
  15668. }
  15669. if (createQuadrilaterals) {
  15670. this.quadrilaterals = this._createQuadrilaterals(ignoreBorder);
  15671. }
  15672. }
  15673. _createContainer() {
  15674. let ignoreBorder = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  15675. const {
  15676. data,
  15677. page,
  15678. viewport
  15679. } = this;
  15680. const container = document.createElement("section");
  15681. container.setAttribute("data-annotation-id", data.id);
  15682. const {
  15683. pageWidth,
  15684. pageHeight,
  15685. pageX,
  15686. pageY
  15687. } = viewport.rawDims;
  15688. const {
  15689. width,
  15690. height
  15691. } = getRectDims(data.rect);
  15692. const rect = _util.Util.normalizeRect([data.rect[0], page.view[3] - data.rect[1] + page.view[1], data.rect[2], page.view[3] - data.rect[3] + page.view[1]]);
  15693. if (!ignoreBorder && data.borderStyle.width > 0) {
  15694. container.style.borderWidth = `${data.borderStyle.width}px`;
  15695. const horizontalRadius = data.borderStyle.horizontalCornerRadius;
  15696. const verticalRadius = data.borderStyle.verticalCornerRadius;
  15697. if (horizontalRadius > 0 || verticalRadius > 0) {
  15698. const radius = `calc(${horizontalRadius}px * var(--scale-factor)) / calc(${verticalRadius}px * var(--scale-factor))`;
  15699. container.style.borderRadius = radius;
  15700. } else if (this instanceof RadioButtonWidgetAnnotationElement) {
  15701. const radius = `calc(${width}px * var(--scale-factor)) / calc(${height}px * var(--scale-factor))`;
  15702. container.style.borderRadius = radius;
  15703. }
  15704. switch (data.borderStyle.style) {
  15705. case _util.AnnotationBorderStyleType.SOLID:
  15706. container.style.borderStyle = "solid";
  15707. break;
  15708. case _util.AnnotationBorderStyleType.DASHED:
  15709. container.style.borderStyle = "dashed";
  15710. break;
  15711. case _util.AnnotationBorderStyleType.BEVELED:
  15712. (0, _util.warn)("Unimplemented border style: beveled");
  15713. break;
  15714. case _util.AnnotationBorderStyleType.INSET:
  15715. (0, _util.warn)("Unimplemented border style: inset");
  15716. break;
  15717. case _util.AnnotationBorderStyleType.UNDERLINE:
  15718. container.style.borderBottomStyle = "solid";
  15719. break;
  15720. default:
  15721. break;
  15722. }
  15723. const borderColor = data.borderColor || null;
  15724. if (borderColor) {
  15725. container.style.borderColor = _util.Util.makeHexColor(borderColor[0] | 0, borderColor[1] | 0, borderColor[2] | 0);
  15726. } else {
  15727. container.style.borderWidth = 0;
  15728. }
  15729. }
  15730. container.style.left = `${100 * (rect[0] - pageX) / pageWidth}%`;
  15731. container.style.top = `${100 * (rect[1] - pageY) / pageHeight}%`;
  15732. const {
  15733. rotation
  15734. } = data;
  15735. if (data.hasOwnCanvas || rotation === 0) {
  15736. container.style.width = `${100 * width / pageWidth}%`;
  15737. container.style.height = `${100 * height / pageHeight}%`;
  15738. } else {
  15739. this.setRotation(rotation, container);
  15740. }
  15741. return container;
  15742. }
  15743. setRotation(angle) {
  15744. let container = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.container;
  15745. const {
  15746. pageWidth,
  15747. pageHeight
  15748. } = this.viewport.rawDims;
  15749. const {
  15750. width,
  15751. height
  15752. } = getRectDims(this.data.rect);
  15753. let elementWidth, elementHeight;
  15754. if (angle % 180 === 0) {
  15755. elementWidth = 100 * width / pageWidth;
  15756. elementHeight = 100 * height / pageHeight;
  15757. } else {
  15758. elementWidth = 100 * height / pageWidth;
  15759. elementHeight = 100 * width / pageHeight;
  15760. }
  15761. container.style.width = `${elementWidth}%`;
  15762. container.style.height = `${elementHeight}%`;
  15763. container.setAttribute("data-main-rotation", (360 - angle) % 360);
  15764. }
  15765. get _commonActions() {
  15766. const setColor = (jsName, styleName, event) => {
  15767. const color = event.detail[jsName];
  15768. event.target.style[styleName] = _scripting_utils.ColorConverters[`${color[0]}_HTML`](color.slice(1));
  15769. };
  15770. return (0, _util.shadow)(this, "_commonActions", {
  15771. display: event => {
  15772. const hidden = event.detail.display % 2 === 1;
  15773. this.container.style.visibility = hidden ? "hidden" : "visible";
  15774. this.annotationStorage.setValue(this.data.id, {
  15775. hidden,
  15776. print: event.detail.display === 0 || event.detail.display === 3
  15777. });
  15778. },
  15779. print: event => {
  15780. this.annotationStorage.setValue(this.data.id, {
  15781. print: event.detail.print
  15782. });
  15783. },
  15784. hidden: event => {
  15785. this.container.style.visibility = event.detail.hidden ? "hidden" : "visible";
  15786. this.annotationStorage.setValue(this.data.id, {
  15787. hidden: event.detail.hidden
  15788. });
  15789. },
  15790. focus: event => {
  15791. setTimeout(() => event.target.focus({
  15792. preventScroll: false
  15793. }), 0);
  15794. },
  15795. userName: event => {
  15796. event.target.title = event.detail.userName;
  15797. },
  15798. readonly: event => {
  15799. if (event.detail.readonly) {
  15800. event.target.setAttribute("readonly", "");
  15801. } else {
  15802. event.target.removeAttribute("readonly");
  15803. }
  15804. },
  15805. required: event => {
  15806. this._setRequired(event.target, event.detail.required);
  15807. },
  15808. bgColor: event => {
  15809. setColor("bgColor", "backgroundColor", event);
  15810. },
  15811. fillColor: event => {
  15812. setColor("fillColor", "backgroundColor", event);
  15813. },
  15814. fgColor: event => {
  15815. setColor("fgColor", "color", event);
  15816. },
  15817. textColor: event => {
  15818. setColor("textColor", "color", event);
  15819. },
  15820. borderColor: event => {
  15821. setColor("borderColor", "borderColor", event);
  15822. },
  15823. strokeColor: event => {
  15824. setColor("strokeColor", "borderColor", event);
  15825. },
  15826. rotation: event => {
  15827. const angle = event.detail.rotation;
  15828. this.setRotation(angle);
  15829. this.annotationStorage.setValue(this.data.id, {
  15830. rotation: angle
  15831. });
  15832. }
  15833. });
  15834. }
  15835. _dispatchEventFromSandbox(actions, jsEvent) {
  15836. const commonActions = this._commonActions;
  15837. for (const name of Object.keys(jsEvent.detail)) {
  15838. const action = actions[name] || commonActions[name];
  15839. action === null || action === void 0 ? void 0 : action(jsEvent);
  15840. }
  15841. }
  15842. _setDefaultPropertiesFromJS(element) {
  15843. if (!this.enableScripting) {
  15844. return;
  15845. }
  15846. const storedData = this.annotationStorage.getRawValue(this.data.id);
  15847. if (!storedData) {
  15848. return;
  15849. }
  15850. const commonActions = this._commonActions;
  15851. for (const [actionName, detail] of Object.entries(storedData)) {
  15852. const action = commonActions[actionName];
  15853. if (action) {
  15854. const eventProxy = {
  15855. detail: {
  15856. [actionName]: detail
  15857. },
  15858. target: element
  15859. };
  15860. action(eventProxy);
  15861. delete storedData[actionName];
  15862. }
  15863. }
  15864. }
  15865. _createQuadrilaterals() {
  15866. let ignoreBorder = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  15867. if (!this.data.quadPoints) {
  15868. return null;
  15869. }
  15870. const quadrilaterals = [];
  15871. const savedRect = this.data.rect;
  15872. for (const quadPoint of this.data.quadPoints) {
  15873. this.data.rect = [quadPoint[2].x, quadPoint[2].y, quadPoint[1].x, quadPoint[1].y];
  15874. quadrilaterals.push(this._createContainer(ignoreBorder));
  15875. }
  15876. this.data.rect = savedRect;
  15877. return quadrilaterals;
  15878. }
  15879. _createPopup(trigger, data) {
  15880. let container = this.container;
  15881. if (this.quadrilaterals) {
  15882. trigger = trigger || this.quadrilaterals;
  15883. container = this.quadrilaterals[0];
  15884. }
  15885. if (!trigger) {
  15886. trigger = document.createElement("div");
  15887. trigger.className = "popupTriggerArea";
  15888. container.append(trigger);
  15889. }
  15890. const popupElement = new PopupElement({
  15891. container,
  15892. trigger,
  15893. color: data.color,
  15894. titleObj: data.titleObj,
  15895. modificationDate: data.modificationDate,
  15896. contentsObj: data.contentsObj,
  15897. richText: data.richText,
  15898. hideWrapper: true
  15899. });
  15900. const popup = popupElement.render();
  15901. popup.style.left = "100%";
  15902. container.append(popup);
  15903. }
  15904. _renderQuadrilaterals(className) {
  15905. for (const quadrilateral of this.quadrilaterals) {
  15906. quadrilateral.className = className;
  15907. }
  15908. return this.quadrilaterals;
  15909. }
  15910. render() {
  15911. (0, _util.unreachable)("Abstract method `AnnotationElement.render` called");
  15912. }
  15913. _getElementsByName(name) {
  15914. let skipId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  15915. const fields = [];
  15916. if (this._fieldObjects) {
  15917. const fieldObj = this._fieldObjects[name];
  15918. if (fieldObj) {
  15919. for (const {
  15920. page,
  15921. id,
  15922. exportValues
  15923. } of fieldObj) {
  15924. if (page === -1) {
  15925. continue;
  15926. }
  15927. if (id === skipId) {
  15928. continue;
  15929. }
  15930. const exportValue = typeof exportValues === "string" ? exportValues : null;
  15931. const domElement = document.querySelector(`[data-element-id="${id}"]`);
  15932. if (domElement && !GetElementsByNameSet.has(domElement)) {
  15933. (0, _util.warn)(`_getElementsByName - element not allowed: ${id}`);
  15934. continue;
  15935. }
  15936. fields.push({
  15937. id,
  15938. exportValue,
  15939. domElement
  15940. });
  15941. }
  15942. }
  15943. return fields;
  15944. }
  15945. for (const domElement of document.getElementsByName(name)) {
  15946. const {
  15947. exportValue
  15948. } = domElement;
  15949. const id = domElement.getAttribute("data-element-id");
  15950. if (id === skipId) {
  15951. continue;
  15952. }
  15953. if (!GetElementsByNameSet.has(domElement)) {
  15954. continue;
  15955. }
  15956. fields.push({
  15957. id,
  15958. exportValue,
  15959. domElement
  15960. });
  15961. }
  15962. return fields;
  15963. }
  15964. }
  15965. var _setInternalLink = /*#__PURE__*/new WeakSet();
  15966. var _bindSetOCGState = /*#__PURE__*/new WeakSet();
  15967. class LinkAnnotationElement extends AnnotationElement {
  15968. constructor(parameters) {
  15969. let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  15970. super(parameters, {
  15971. isRenderable: true,
  15972. ignoreBorder: !!(options !== null && options !== void 0 && options.ignoreBorder),
  15973. createQuadrilaterals: true
  15974. });
  15975. _classPrivateMethodInitSpec(this, _bindSetOCGState);
  15976. _classPrivateMethodInitSpec(this, _setInternalLink);
  15977. this.isTooltipOnly = parameters.data.isTooltipOnly;
  15978. }
  15979. render() {
  15980. const {
  15981. data,
  15982. linkService
  15983. } = this;
  15984. const link = document.createElement("a");
  15985. link.setAttribute("data-element-id", data.id);
  15986. let isBound = false;
  15987. if (data.url) {
  15988. linkService.addLinkAttributes(link, data.url, data.newWindow);
  15989. isBound = true;
  15990. } else if (data.action) {
  15991. this._bindNamedAction(link, data.action);
  15992. isBound = true;
  15993. } else if (data.attachment) {
  15994. this._bindAttachment(link, data.attachment);
  15995. isBound = true;
  15996. } else if (data.setOCGState) {
  15997. _classPrivateMethodGet(this, _bindSetOCGState, _bindSetOCGState2).call(this, link, data.setOCGState);
  15998. isBound = true;
  15999. } else if (data.dest) {
  16000. this._bindLink(link, data.dest);
  16001. isBound = true;
  16002. } else {
  16003. if (data.actions && (data.actions.Action || data.actions["Mouse Up"] || data.actions["Mouse Down"]) && this.enableScripting && this.hasJSActions) {
  16004. this._bindJSAction(link, data);
  16005. isBound = true;
  16006. }
  16007. if (data.resetForm) {
  16008. this._bindResetFormAction(link, data.resetForm);
  16009. isBound = true;
  16010. } else if (this.isTooltipOnly && !isBound) {
  16011. this._bindLink(link, "");
  16012. isBound = true;
  16013. }
  16014. }
  16015. if (this.quadrilaterals) {
  16016. return this._renderQuadrilaterals("linkAnnotation").map((quadrilateral, index) => {
  16017. const linkElement = index === 0 ? link : link.cloneNode();
  16018. quadrilateral.append(linkElement);
  16019. return quadrilateral;
  16020. });
  16021. }
  16022. this.container.className = "linkAnnotation";
  16023. if (isBound) {
  16024. this.container.append(link);
  16025. }
  16026. return this.container;
  16027. }
  16028. _bindLink(link, destination) {
  16029. link.href = this.linkService.getDestinationHash(destination);
  16030. link.onclick = () => {
  16031. if (destination) {
  16032. this.linkService.goToDestination(destination);
  16033. }
  16034. return false;
  16035. };
  16036. if (destination || destination === "") {
  16037. _classPrivateMethodGet(this, _setInternalLink, _setInternalLink2).call(this);
  16038. }
  16039. }
  16040. _bindNamedAction(link, action) {
  16041. link.href = this.linkService.getAnchorUrl("");
  16042. link.onclick = () => {
  16043. this.linkService.executeNamedAction(action);
  16044. return false;
  16045. };
  16046. _classPrivateMethodGet(this, _setInternalLink, _setInternalLink2).call(this);
  16047. }
  16048. _bindAttachment(link, attachment) {
  16049. link.href = this.linkService.getAnchorUrl("");
  16050. link.onclick = () => {
  16051. var _this$downloadManager;
  16052. (_this$downloadManager = this.downloadManager) === null || _this$downloadManager === void 0 ? void 0 : _this$downloadManager.openOrDownloadData(this.container, attachment.content, attachment.filename);
  16053. return false;
  16054. };
  16055. _classPrivateMethodGet(this, _setInternalLink, _setInternalLink2).call(this);
  16056. }
  16057. _bindJSAction(link, data) {
  16058. link.href = this.linkService.getAnchorUrl("");
  16059. const map = new Map([["Action", "onclick"], ["Mouse Up", "onmouseup"], ["Mouse Down", "onmousedown"]]);
  16060. for (const name of Object.keys(data.actions)) {
  16061. const jsName = map.get(name);
  16062. if (!jsName) {
  16063. continue;
  16064. }
  16065. link[jsName] = () => {
  16066. var _this$linkService$eve;
  16067. (_this$linkService$eve = this.linkService.eventBus) === null || _this$linkService$eve === void 0 ? void 0 : _this$linkService$eve.dispatch("dispatcheventinsandbox", {
  16068. source: this,
  16069. detail: {
  16070. id: data.id,
  16071. name
  16072. }
  16073. });
  16074. return false;
  16075. };
  16076. }
  16077. if (!link.onclick) {
  16078. link.onclick = () => false;
  16079. }
  16080. _classPrivateMethodGet(this, _setInternalLink, _setInternalLink2).call(this);
  16081. }
  16082. _bindResetFormAction(link, resetForm) {
  16083. const otherClickAction = link.onclick;
  16084. if (!otherClickAction) {
  16085. link.href = this.linkService.getAnchorUrl("");
  16086. }
  16087. _classPrivateMethodGet(this, _setInternalLink, _setInternalLink2).call(this);
  16088. if (!this._fieldObjects) {
  16089. (0, _util.warn)(`_bindResetFormAction - "resetForm" action not supported, ` + "ensure that the `fieldObjects` parameter is provided.");
  16090. if (!otherClickAction) {
  16091. link.onclick = () => false;
  16092. }
  16093. return;
  16094. }
  16095. link.onclick = () => {
  16096. otherClickAction === null || otherClickAction === void 0 ? void 0 : otherClickAction();
  16097. const {
  16098. fields: resetFormFields,
  16099. refs: resetFormRefs,
  16100. include
  16101. } = resetForm;
  16102. const allFields = [];
  16103. if (resetFormFields.length !== 0 || resetFormRefs.length !== 0) {
  16104. const fieldIds = new Set(resetFormRefs);
  16105. for (const fieldName of resetFormFields) {
  16106. const fields = this._fieldObjects[fieldName] || [];
  16107. for (const {
  16108. id
  16109. } of fields) {
  16110. fieldIds.add(id);
  16111. }
  16112. }
  16113. for (const fields of Object.values(this._fieldObjects)) {
  16114. for (const field of fields) {
  16115. if (fieldIds.has(field.id) === include) {
  16116. allFields.push(field);
  16117. }
  16118. }
  16119. }
  16120. } else {
  16121. for (const fields of Object.values(this._fieldObjects)) {
  16122. allFields.push(...fields);
  16123. }
  16124. }
  16125. const storage = this.annotationStorage;
  16126. const allIds = [];
  16127. for (const field of allFields) {
  16128. const {
  16129. id
  16130. } = field;
  16131. allIds.push(id);
  16132. switch (field.type) {
  16133. case "text":
  16134. {
  16135. const value = field.defaultValue || "";
  16136. storage.setValue(id, {
  16137. value
  16138. });
  16139. break;
  16140. }
  16141. case "checkbox":
  16142. case "radiobutton":
  16143. {
  16144. const value = field.defaultValue === field.exportValues;
  16145. storage.setValue(id, {
  16146. value
  16147. });
  16148. break;
  16149. }
  16150. case "combobox":
  16151. case "listbox":
  16152. {
  16153. const value = field.defaultValue || "";
  16154. storage.setValue(id, {
  16155. value
  16156. });
  16157. break;
  16158. }
  16159. default:
  16160. continue;
  16161. }
  16162. const domElement = document.querySelector(`[data-element-id="${id}"]`);
  16163. if (!domElement) {
  16164. continue;
  16165. } else if (!GetElementsByNameSet.has(domElement)) {
  16166. (0, _util.warn)(`_bindResetFormAction - element not allowed: ${id}`);
  16167. continue;
  16168. }
  16169. domElement.dispatchEvent(new Event("resetform"));
  16170. }
  16171. if (this.enableScripting) {
  16172. var _this$linkService$eve2;
  16173. (_this$linkService$eve2 = this.linkService.eventBus) === null || _this$linkService$eve2 === void 0 ? void 0 : _this$linkService$eve2.dispatch("dispatcheventinsandbox", {
  16174. source: this,
  16175. detail: {
  16176. id: "app",
  16177. ids: allIds,
  16178. name: "ResetForm"
  16179. }
  16180. });
  16181. }
  16182. return false;
  16183. };
  16184. }
  16185. }
  16186. function _setInternalLink2() {
  16187. this.container.setAttribute("data-internal-link", "");
  16188. }
  16189. function _bindSetOCGState2(link, action) {
  16190. link.href = this.linkService.getAnchorUrl("");
  16191. link.onclick = () => {
  16192. this.linkService.executeSetOCGState(action);
  16193. return false;
  16194. };
  16195. _classPrivateMethodGet(this, _setInternalLink, _setInternalLink2).call(this);
  16196. }
  16197. class TextAnnotationElement extends AnnotationElement {
  16198. constructor(parameters) {
  16199. var _parameters$data$titl, _parameters$data$cont, _parameters$data$rich;
  16200. const isRenderable = !!(parameters.data.hasPopup || (_parameters$data$titl = parameters.data.titleObj) !== null && _parameters$data$titl !== void 0 && _parameters$data$titl.str || (_parameters$data$cont = parameters.data.contentsObj) !== null && _parameters$data$cont !== void 0 && _parameters$data$cont.str || (_parameters$data$rich = parameters.data.richText) !== null && _parameters$data$rich !== void 0 && _parameters$data$rich.str);
  16201. super(parameters, {
  16202. isRenderable
  16203. });
  16204. }
  16205. render() {
  16206. this.container.className = "textAnnotation";
  16207. const image = document.createElement("img");
  16208. image.src = this.imageResourcesPath + "annotation-" + this.data.name.toLowerCase() + ".svg";
  16209. image.alt = "[{{type}} Annotation]";
  16210. image.dataset.l10nId = "text_annotation_type";
  16211. image.dataset.l10nArgs = JSON.stringify({
  16212. type: this.data.name
  16213. });
  16214. if (!this.data.hasPopup) {
  16215. this._createPopup(image, this.data);
  16216. }
  16217. this.container.append(image);
  16218. return this.container;
  16219. }
  16220. }
  16221. class WidgetAnnotationElement extends AnnotationElement {
  16222. render() {
  16223. if (this.data.alternativeText) {
  16224. this.container.title = this.data.alternativeText;
  16225. }
  16226. return this.container;
  16227. }
  16228. _getKeyModifier(event) {
  16229. const {
  16230. isWin,
  16231. isMac
  16232. } = _util.FeatureTest.platform;
  16233. return isWin && event.ctrlKey || isMac && event.metaKey;
  16234. }
  16235. _setEventListener(element, baseName, eventName, valueGetter) {
  16236. if (baseName.includes("mouse")) {
  16237. element.addEventListener(baseName, event => {
  16238. var _this$linkService$eve3;
  16239. (_this$linkService$eve3 = this.linkService.eventBus) === null || _this$linkService$eve3 === void 0 ? void 0 : _this$linkService$eve3.dispatch("dispatcheventinsandbox", {
  16240. source: this,
  16241. detail: {
  16242. id: this.data.id,
  16243. name: eventName,
  16244. value: valueGetter(event),
  16245. shift: event.shiftKey,
  16246. modifier: this._getKeyModifier(event)
  16247. }
  16248. });
  16249. });
  16250. } else {
  16251. element.addEventListener(baseName, event => {
  16252. var _this$linkService$eve4;
  16253. (_this$linkService$eve4 = this.linkService.eventBus) === null || _this$linkService$eve4 === void 0 ? void 0 : _this$linkService$eve4.dispatch("dispatcheventinsandbox", {
  16254. source: this,
  16255. detail: {
  16256. id: this.data.id,
  16257. name: eventName,
  16258. value: valueGetter(event)
  16259. }
  16260. });
  16261. });
  16262. }
  16263. }
  16264. _setEventListeners(element, names, getter) {
  16265. for (const [baseName, eventName] of names) {
  16266. var _this$data$actions;
  16267. if (eventName === "Action" || (_this$data$actions = this.data.actions) !== null && _this$data$actions !== void 0 && _this$data$actions[eventName]) {
  16268. this._setEventListener(element, baseName, eventName, getter);
  16269. }
  16270. }
  16271. }
  16272. _setBackgroundColor(element) {
  16273. const color = this.data.backgroundColor || null;
  16274. element.style.backgroundColor = color === null ? "transparent" : _util.Util.makeHexColor(color[0], color[1], color[2]);
  16275. }
  16276. _setTextStyle(element) {
  16277. const TEXT_ALIGNMENT = ["left", "center", "right"];
  16278. const {
  16279. fontColor
  16280. } = this.data.defaultAppearanceData;
  16281. const fontSize = this.data.defaultAppearanceData.fontSize || DEFAULT_FONT_SIZE;
  16282. const style = element.style;
  16283. let computedFontSize;
  16284. const BORDER_SIZE = 2;
  16285. const roundToOneDecimal = x => Math.round(10 * x) / 10;
  16286. if (this.data.multiLine) {
  16287. const height = Math.abs(this.data.rect[3] - this.data.rect[1] - BORDER_SIZE);
  16288. const numberOfLines = Math.round(height / (_util.LINE_FACTOR * fontSize)) || 1;
  16289. const lineHeight = height / numberOfLines;
  16290. computedFontSize = Math.min(fontSize, roundToOneDecimal(lineHeight / _util.LINE_FACTOR));
  16291. } else {
  16292. const height = Math.abs(this.data.rect[3] - this.data.rect[1] - BORDER_SIZE);
  16293. computedFontSize = Math.min(fontSize, roundToOneDecimal(height / _util.LINE_FACTOR));
  16294. }
  16295. style.fontSize = `calc(${computedFontSize}px * var(--scale-factor))`;
  16296. style.color = _util.Util.makeHexColor(fontColor[0], fontColor[1], fontColor[2]);
  16297. if (this.data.textAlignment !== null) {
  16298. style.textAlign = TEXT_ALIGNMENT[this.data.textAlignment];
  16299. }
  16300. }
  16301. _setRequired(element, isRequired) {
  16302. if (isRequired) {
  16303. element.setAttribute("required", true);
  16304. } else {
  16305. element.removeAttribute("required");
  16306. }
  16307. element.setAttribute("aria-required", isRequired);
  16308. }
  16309. }
  16310. class TextWidgetAnnotationElement extends WidgetAnnotationElement {
  16311. constructor(parameters) {
  16312. const isRenderable = parameters.renderForms || !parameters.data.hasAppearance && !!parameters.data.fieldValue;
  16313. super(parameters, {
  16314. isRenderable
  16315. });
  16316. }
  16317. setPropertyOnSiblings(base, key, value, keyInStorage) {
  16318. const storage = this.annotationStorage;
  16319. for (const element of this._getElementsByName(base.name, base.id)) {
  16320. if (element.domElement) {
  16321. element.domElement[key] = value;
  16322. }
  16323. storage.setValue(element.id, {
  16324. [keyInStorage]: value
  16325. });
  16326. }
  16327. }
  16328. render() {
  16329. const storage = this.annotationStorage;
  16330. const id = this.data.id;
  16331. this.container.className = "textWidgetAnnotation";
  16332. let element = null;
  16333. if (this.renderForms) {
  16334. const storedData = storage.getValue(id, {
  16335. value: this.data.fieldValue
  16336. });
  16337. let textContent = storedData.formattedValue || storedData.value || "";
  16338. const maxLen = storage.getValue(id, {
  16339. charLimit: this.data.maxLen
  16340. }).charLimit;
  16341. if (maxLen && textContent.length > maxLen) {
  16342. textContent = textContent.slice(0, maxLen);
  16343. }
  16344. const elementData = {
  16345. userValue: textContent,
  16346. formattedValue: null,
  16347. lastCommittedValue: null,
  16348. commitKey: 1
  16349. };
  16350. if (this.data.multiLine) {
  16351. element = document.createElement("textarea");
  16352. element.textContent = textContent;
  16353. if (this.data.doNotScroll) {
  16354. element.style.overflowY = "hidden";
  16355. }
  16356. } else {
  16357. element = document.createElement("input");
  16358. element.type = "text";
  16359. element.setAttribute("value", textContent);
  16360. if (this.data.doNotScroll) {
  16361. element.style.overflowX = "hidden";
  16362. }
  16363. }
  16364. GetElementsByNameSet.add(element);
  16365. element.setAttribute("data-element-id", id);
  16366. element.disabled = this.data.readOnly;
  16367. element.name = this.data.fieldName;
  16368. element.tabIndex = DEFAULT_TAB_INDEX;
  16369. this._setRequired(element, this.data.required);
  16370. if (maxLen) {
  16371. element.maxLength = maxLen;
  16372. }
  16373. element.addEventListener("input", event => {
  16374. storage.setValue(id, {
  16375. value: event.target.value
  16376. });
  16377. this.setPropertyOnSiblings(element, "value", event.target.value, "value");
  16378. });
  16379. element.addEventListener("resetform", event => {
  16380. const defaultValue = this.data.defaultFieldValue ?? "";
  16381. element.value = elementData.userValue = defaultValue;
  16382. elementData.formattedValue = null;
  16383. });
  16384. let blurListener = event => {
  16385. const {
  16386. formattedValue
  16387. } = elementData;
  16388. if (formattedValue !== null && formattedValue !== undefined) {
  16389. event.target.value = formattedValue;
  16390. }
  16391. event.target.scrollLeft = 0;
  16392. };
  16393. if (this.enableScripting && this.hasJSActions) {
  16394. var _this$data$actions2;
  16395. element.addEventListener("focus", event => {
  16396. const {
  16397. target
  16398. } = event;
  16399. if (elementData.userValue) {
  16400. target.value = elementData.userValue;
  16401. }
  16402. elementData.lastCommittedValue = target.value;
  16403. elementData.commitKey = 1;
  16404. });
  16405. element.addEventListener("updatefromsandbox", jsEvent => {
  16406. const actions = {
  16407. value(event) {
  16408. elementData.userValue = event.detail.value ?? "";
  16409. storage.setValue(id, {
  16410. value: elementData.userValue.toString()
  16411. });
  16412. event.target.value = elementData.userValue;
  16413. },
  16414. formattedValue(event) {
  16415. const {
  16416. formattedValue
  16417. } = event.detail;
  16418. elementData.formattedValue = formattedValue;
  16419. if (formattedValue !== null && formattedValue !== undefined && event.target !== document.activeElement) {
  16420. event.target.value = formattedValue;
  16421. }
  16422. storage.setValue(id, {
  16423. formattedValue
  16424. });
  16425. },
  16426. selRange(event) {
  16427. event.target.setSelectionRange(...event.detail.selRange);
  16428. },
  16429. charLimit: event => {
  16430. var _this$linkService$eve5;
  16431. const {
  16432. charLimit
  16433. } = event.detail;
  16434. const {
  16435. target
  16436. } = event;
  16437. if (charLimit === 0) {
  16438. target.removeAttribute("maxLength");
  16439. return;
  16440. }
  16441. target.setAttribute("maxLength", charLimit);
  16442. let value = elementData.userValue;
  16443. if (!value || value.length <= charLimit) {
  16444. return;
  16445. }
  16446. value = value.slice(0, charLimit);
  16447. target.value = elementData.userValue = value;
  16448. storage.setValue(id, {
  16449. value
  16450. });
  16451. (_this$linkService$eve5 = this.linkService.eventBus) === null || _this$linkService$eve5 === void 0 ? void 0 : _this$linkService$eve5.dispatch("dispatcheventinsandbox", {
  16452. source: this,
  16453. detail: {
  16454. id,
  16455. name: "Keystroke",
  16456. value,
  16457. willCommit: true,
  16458. commitKey: 1,
  16459. selStart: target.selectionStart,
  16460. selEnd: target.selectionEnd
  16461. }
  16462. });
  16463. }
  16464. };
  16465. this._dispatchEventFromSandbox(actions, jsEvent);
  16466. });
  16467. element.addEventListener("keydown", event => {
  16468. var _this$linkService$eve6;
  16469. elementData.commitKey = 1;
  16470. let commitKey = -1;
  16471. if (event.key === "Escape") {
  16472. commitKey = 0;
  16473. } else if (event.key === "Enter" && !this.data.multiLine) {
  16474. commitKey = 2;
  16475. } else if (event.key === "Tab") {
  16476. elementData.commitKey = 3;
  16477. }
  16478. if (commitKey === -1) {
  16479. return;
  16480. }
  16481. const {
  16482. value
  16483. } = event.target;
  16484. if (elementData.lastCommittedValue === value) {
  16485. return;
  16486. }
  16487. elementData.lastCommittedValue = value;
  16488. elementData.userValue = value;
  16489. (_this$linkService$eve6 = this.linkService.eventBus) === null || _this$linkService$eve6 === void 0 ? void 0 : _this$linkService$eve6.dispatch("dispatcheventinsandbox", {
  16490. source: this,
  16491. detail: {
  16492. id,
  16493. name: "Keystroke",
  16494. value,
  16495. willCommit: true,
  16496. commitKey,
  16497. selStart: event.target.selectionStart,
  16498. selEnd: event.target.selectionEnd
  16499. }
  16500. });
  16501. });
  16502. const _blurListener = blurListener;
  16503. blurListener = null;
  16504. element.addEventListener("blur", event => {
  16505. if (!event.relatedTarget) {
  16506. return;
  16507. }
  16508. const {
  16509. value
  16510. } = event.target;
  16511. elementData.userValue = value;
  16512. if (elementData.lastCommittedValue !== value) {
  16513. var _this$linkService$eve7;
  16514. (_this$linkService$eve7 = this.linkService.eventBus) === null || _this$linkService$eve7 === void 0 ? void 0 : _this$linkService$eve7.dispatch("dispatcheventinsandbox", {
  16515. source: this,
  16516. detail: {
  16517. id,
  16518. name: "Keystroke",
  16519. value,
  16520. willCommit: true,
  16521. commitKey: elementData.commitKey,
  16522. selStart: event.target.selectionStart,
  16523. selEnd: event.target.selectionEnd
  16524. }
  16525. });
  16526. }
  16527. _blurListener(event);
  16528. });
  16529. if ((_this$data$actions2 = this.data.actions) !== null && _this$data$actions2 !== void 0 && _this$data$actions2.Keystroke) {
  16530. element.addEventListener("beforeinput", event => {
  16531. var _this$linkService$eve8;
  16532. elementData.lastCommittedValue = null;
  16533. const {
  16534. data,
  16535. target
  16536. } = event;
  16537. const {
  16538. value,
  16539. selectionStart,
  16540. selectionEnd
  16541. } = target;
  16542. let selStart = selectionStart,
  16543. selEnd = selectionEnd;
  16544. switch (event.inputType) {
  16545. case "deleteWordBackward":
  16546. {
  16547. const match = value.substring(0, selectionStart).match(/\w*[^\w]*$/);
  16548. if (match) {
  16549. selStart -= match[0].length;
  16550. }
  16551. break;
  16552. }
  16553. case "deleteWordForward":
  16554. {
  16555. const match = value.substring(selectionStart).match(/^[^\w]*\w*/);
  16556. if (match) {
  16557. selEnd += match[0].length;
  16558. }
  16559. break;
  16560. }
  16561. case "deleteContentBackward":
  16562. if (selectionStart === selectionEnd) {
  16563. selStart -= 1;
  16564. }
  16565. break;
  16566. case "deleteContentForward":
  16567. if (selectionStart === selectionEnd) {
  16568. selEnd += 1;
  16569. }
  16570. break;
  16571. }
  16572. event.preventDefault();
  16573. (_this$linkService$eve8 = this.linkService.eventBus) === null || _this$linkService$eve8 === void 0 ? void 0 : _this$linkService$eve8.dispatch("dispatcheventinsandbox", {
  16574. source: this,
  16575. detail: {
  16576. id,
  16577. name: "Keystroke",
  16578. value,
  16579. change: data || "",
  16580. willCommit: false,
  16581. selStart,
  16582. selEnd
  16583. }
  16584. });
  16585. });
  16586. }
  16587. this._setEventListeners(element, [["focus", "Focus"], ["blur", "Blur"], ["mousedown", "Mouse Down"], ["mouseenter", "Mouse Enter"], ["mouseleave", "Mouse Exit"], ["mouseup", "Mouse Up"]], event => event.target.value);
  16588. }
  16589. if (blurListener) {
  16590. element.addEventListener("blur", blurListener);
  16591. }
  16592. if (this.data.comb) {
  16593. const fieldWidth = this.data.rect[2] - this.data.rect[0];
  16594. const combWidth = fieldWidth / maxLen;
  16595. element.classList.add("comb");
  16596. element.style.letterSpacing = `calc(${combWidth}px * var(--scale-factor) - 1ch)`;
  16597. }
  16598. } else {
  16599. element = document.createElement("div");
  16600. element.textContent = this.data.fieldValue;
  16601. element.style.verticalAlign = "middle";
  16602. element.style.display = "table-cell";
  16603. }
  16604. this._setTextStyle(element);
  16605. this._setBackgroundColor(element);
  16606. this._setDefaultPropertiesFromJS(element);
  16607. this.container.append(element);
  16608. return this.container;
  16609. }
  16610. }
  16611. class CheckboxWidgetAnnotationElement extends WidgetAnnotationElement {
  16612. constructor(parameters) {
  16613. super(parameters, {
  16614. isRenderable: parameters.renderForms
  16615. });
  16616. }
  16617. render() {
  16618. const storage = this.annotationStorage;
  16619. const data = this.data;
  16620. const id = data.id;
  16621. let value = storage.getValue(id, {
  16622. value: data.exportValue === data.fieldValue
  16623. }).value;
  16624. if (typeof value === "string") {
  16625. value = value !== "Off";
  16626. storage.setValue(id, {
  16627. value
  16628. });
  16629. }
  16630. this.container.className = "buttonWidgetAnnotation checkBox";
  16631. const element = document.createElement("input");
  16632. GetElementsByNameSet.add(element);
  16633. element.setAttribute("data-element-id", id);
  16634. element.disabled = data.readOnly;
  16635. this._setRequired(element, this.data.required);
  16636. element.type = "checkbox";
  16637. element.name = data.fieldName;
  16638. if (value) {
  16639. element.setAttribute("checked", true);
  16640. }
  16641. element.setAttribute("exportValue", data.exportValue);
  16642. element.tabIndex = DEFAULT_TAB_INDEX;
  16643. element.addEventListener("change", event => {
  16644. const {
  16645. name,
  16646. checked
  16647. } = event.target;
  16648. for (const checkbox of this._getElementsByName(name, id)) {
  16649. const curChecked = checked && checkbox.exportValue === data.exportValue;
  16650. if (checkbox.domElement) {
  16651. checkbox.domElement.checked = curChecked;
  16652. }
  16653. storage.setValue(checkbox.id, {
  16654. value: curChecked
  16655. });
  16656. }
  16657. storage.setValue(id, {
  16658. value: checked
  16659. });
  16660. });
  16661. element.addEventListener("resetform", event => {
  16662. const defaultValue = data.defaultFieldValue || "Off";
  16663. event.target.checked = defaultValue === data.exportValue;
  16664. });
  16665. if (this.enableScripting && this.hasJSActions) {
  16666. element.addEventListener("updatefromsandbox", jsEvent => {
  16667. const actions = {
  16668. value(event) {
  16669. event.target.checked = event.detail.value !== "Off";
  16670. storage.setValue(id, {
  16671. value: event.target.checked
  16672. });
  16673. }
  16674. };
  16675. this._dispatchEventFromSandbox(actions, jsEvent);
  16676. });
  16677. this._setEventListeners(element, [["change", "Validate"], ["change", "Action"], ["focus", "Focus"], ["blur", "Blur"], ["mousedown", "Mouse Down"], ["mouseenter", "Mouse Enter"], ["mouseleave", "Mouse Exit"], ["mouseup", "Mouse Up"]], event => event.target.checked);
  16678. }
  16679. this._setBackgroundColor(element);
  16680. this._setDefaultPropertiesFromJS(element);
  16681. this.container.append(element);
  16682. return this.container;
  16683. }
  16684. }
  16685. class RadioButtonWidgetAnnotationElement extends WidgetAnnotationElement {
  16686. constructor(parameters) {
  16687. super(parameters, {
  16688. isRenderable: parameters.renderForms
  16689. });
  16690. }
  16691. render() {
  16692. this.container.className = "buttonWidgetAnnotation radioButton";
  16693. const storage = this.annotationStorage;
  16694. const data = this.data;
  16695. const id = data.id;
  16696. let value = storage.getValue(id, {
  16697. value: data.fieldValue === data.buttonValue
  16698. }).value;
  16699. if (typeof value === "string") {
  16700. value = value !== data.buttonValue;
  16701. storage.setValue(id, {
  16702. value
  16703. });
  16704. }
  16705. const element = document.createElement("input");
  16706. GetElementsByNameSet.add(element);
  16707. element.setAttribute("data-element-id", id);
  16708. element.disabled = data.readOnly;
  16709. this._setRequired(element, this.data.required);
  16710. element.type = "radio";
  16711. element.name = data.fieldName;
  16712. if (value) {
  16713. element.setAttribute("checked", true);
  16714. }
  16715. element.tabIndex = DEFAULT_TAB_INDEX;
  16716. element.addEventListener("change", event => {
  16717. const {
  16718. name,
  16719. checked
  16720. } = event.target;
  16721. for (const radio of this._getElementsByName(name, id)) {
  16722. storage.setValue(radio.id, {
  16723. value: false
  16724. });
  16725. }
  16726. storage.setValue(id, {
  16727. value: checked
  16728. });
  16729. });
  16730. element.addEventListener("resetform", event => {
  16731. const defaultValue = data.defaultFieldValue;
  16732. event.target.checked = defaultValue !== null && defaultValue !== undefined && defaultValue === data.buttonValue;
  16733. });
  16734. if (this.enableScripting && this.hasJSActions) {
  16735. const pdfButtonValue = data.buttonValue;
  16736. element.addEventListener("updatefromsandbox", jsEvent => {
  16737. const actions = {
  16738. value: event => {
  16739. const checked = pdfButtonValue === event.detail.value;
  16740. for (const radio of this._getElementsByName(event.target.name)) {
  16741. const curChecked = checked && radio.id === id;
  16742. if (radio.domElement) {
  16743. radio.domElement.checked = curChecked;
  16744. }
  16745. storage.setValue(radio.id, {
  16746. value: curChecked
  16747. });
  16748. }
  16749. }
  16750. };
  16751. this._dispatchEventFromSandbox(actions, jsEvent);
  16752. });
  16753. this._setEventListeners(element, [["change", "Validate"], ["change", "Action"], ["focus", "Focus"], ["blur", "Blur"], ["mousedown", "Mouse Down"], ["mouseenter", "Mouse Enter"], ["mouseleave", "Mouse Exit"], ["mouseup", "Mouse Up"]], event => event.target.checked);
  16754. }
  16755. this._setBackgroundColor(element);
  16756. this._setDefaultPropertiesFromJS(element);
  16757. this.container.append(element);
  16758. return this.container;
  16759. }
  16760. }
  16761. class PushButtonWidgetAnnotationElement extends LinkAnnotationElement {
  16762. constructor(parameters) {
  16763. super(parameters, {
  16764. ignoreBorder: parameters.data.hasAppearance
  16765. });
  16766. }
  16767. render() {
  16768. const container = super.render();
  16769. container.className = "buttonWidgetAnnotation pushButton";
  16770. if (this.data.alternativeText) {
  16771. container.title = this.data.alternativeText;
  16772. }
  16773. const linkElement = container.lastChild;
  16774. if (this.enableScripting && this.hasJSActions && linkElement) {
  16775. this._setDefaultPropertiesFromJS(linkElement);
  16776. linkElement.addEventListener("updatefromsandbox", jsEvent => {
  16777. this._dispatchEventFromSandbox({}, jsEvent);
  16778. });
  16779. }
  16780. return container;
  16781. }
  16782. }
  16783. class ChoiceWidgetAnnotationElement extends WidgetAnnotationElement {
  16784. constructor(parameters) {
  16785. super(parameters, {
  16786. isRenderable: parameters.renderForms
  16787. });
  16788. }
  16789. render() {
  16790. this.container.className = "choiceWidgetAnnotation";
  16791. const storage = this.annotationStorage;
  16792. const id = this.data.id;
  16793. const storedData = storage.getValue(id, {
  16794. value: this.data.fieldValue
  16795. });
  16796. const selectElement = document.createElement("select");
  16797. GetElementsByNameSet.add(selectElement);
  16798. selectElement.setAttribute("data-element-id", id);
  16799. selectElement.disabled = this.data.readOnly;
  16800. this._setRequired(selectElement, this.data.required);
  16801. selectElement.name = this.data.fieldName;
  16802. selectElement.tabIndex = DEFAULT_TAB_INDEX;
  16803. let addAnEmptyEntry = this.data.combo && this.data.options.length > 0;
  16804. if (!this.data.combo) {
  16805. selectElement.size = this.data.options.length;
  16806. if (this.data.multiSelect) {
  16807. selectElement.multiple = true;
  16808. }
  16809. }
  16810. selectElement.addEventListener("resetform", event => {
  16811. const defaultValue = this.data.defaultFieldValue;
  16812. for (const option of selectElement.options) {
  16813. option.selected = option.value === defaultValue;
  16814. }
  16815. });
  16816. for (const option of this.data.options) {
  16817. const optionElement = document.createElement("option");
  16818. optionElement.textContent = option.displayValue;
  16819. optionElement.value = option.exportValue;
  16820. if (storedData.value.includes(option.exportValue)) {
  16821. optionElement.setAttribute("selected", true);
  16822. addAnEmptyEntry = false;
  16823. }
  16824. selectElement.append(optionElement);
  16825. }
  16826. let removeEmptyEntry = null;
  16827. if (addAnEmptyEntry) {
  16828. const noneOptionElement = document.createElement("option");
  16829. noneOptionElement.value = " ";
  16830. noneOptionElement.setAttribute("hidden", true);
  16831. noneOptionElement.setAttribute("selected", true);
  16832. selectElement.prepend(noneOptionElement);
  16833. removeEmptyEntry = () => {
  16834. noneOptionElement.remove();
  16835. selectElement.removeEventListener("input", removeEmptyEntry);
  16836. removeEmptyEntry = null;
  16837. };
  16838. selectElement.addEventListener("input", removeEmptyEntry);
  16839. }
  16840. const getValue = isExport => {
  16841. const name = isExport ? "value" : "textContent";
  16842. const {
  16843. options,
  16844. multiple
  16845. } = selectElement;
  16846. if (!multiple) {
  16847. return options.selectedIndex === -1 ? null : options[options.selectedIndex][name];
  16848. }
  16849. return Array.prototype.filter.call(options, option => option.selected).map(option => option[name]);
  16850. };
  16851. let selectedValues = getValue(false);
  16852. const getItems = event => {
  16853. const options = event.target.options;
  16854. return Array.prototype.map.call(options, option => {
  16855. return {
  16856. displayValue: option.textContent,
  16857. exportValue: option.value
  16858. };
  16859. });
  16860. };
  16861. if (this.enableScripting && this.hasJSActions) {
  16862. selectElement.addEventListener("updatefromsandbox", jsEvent => {
  16863. const actions = {
  16864. value(event) {
  16865. var _removeEmptyEntry;
  16866. (_removeEmptyEntry = removeEmptyEntry) === null || _removeEmptyEntry === void 0 ? void 0 : _removeEmptyEntry();
  16867. const value = event.detail.value;
  16868. const values = new Set(Array.isArray(value) ? value : [value]);
  16869. for (const option of selectElement.options) {
  16870. option.selected = values.has(option.value);
  16871. }
  16872. storage.setValue(id, {
  16873. value: getValue(true)
  16874. });
  16875. selectedValues = getValue(false);
  16876. },
  16877. multipleSelection(event) {
  16878. selectElement.multiple = true;
  16879. },
  16880. remove(event) {
  16881. const options = selectElement.options;
  16882. const index = event.detail.remove;
  16883. options[index].selected = false;
  16884. selectElement.remove(index);
  16885. if (options.length > 0) {
  16886. const i = Array.prototype.findIndex.call(options, option => option.selected);
  16887. if (i === -1) {
  16888. options[0].selected = true;
  16889. }
  16890. }
  16891. storage.setValue(id, {
  16892. value: getValue(true),
  16893. items: getItems(event)
  16894. });
  16895. selectedValues = getValue(false);
  16896. },
  16897. clear(event) {
  16898. while (selectElement.length !== 0) {
  16899. selectElement.remove(0);
  16900. }
  16901. storage.setValue(id, {
  16902. value: null,
  16903. items: []
  16904. });
  16905. selectedValues = getValue(false);
  16906. },
  16907. insert(event) {
  16908. const {
  16909. index,
  16910. displayValue,
  16911. exportValue
  16912. } = event.detail.insert;
  16913. const selectChild = selectElement.children[index];
  16914. const optionElement = document.createElement("option");
  16915. optionElement.textContent = displayValue;
  16916. optionElement.value = exportValue;
  16917. if (selectChild) {
  16918. selectChild.before(optionElement);
  16919. } else {
  16920. selectElement.append(optionElement);
  16921. }
  16922. storage.setValue(id, {
  16923. value: getValue(true),
  16924. items: getItems(event)
  16925. });
  16926. selectedValues = getValue(false);
  16927. },
  16928. items(event) {
  16929. const {
  16930. items
  16931. } = event.detail;
  16932. while (selectElement.length !== 0) {
  16933. selectElement.remove(0);
  16934. }
  16935. for (const item of items) {
  16936. const {
  16937. displayValue,
  16938. exportValue
  16939. } = item;
  16940. const optionElement = document.createElement("option");
  16941. optionElement.textContent = displayValue;
  16942. optionElement.value = exportValue;
  16943. selectElement.append(optionElement);
  16944. }
  16945. if (selectElement.options.length > 0) {
  16946. selectElement.options[0].selected = true;
  16947. }
  16948. storage.setValue(id, {
  16949. value: getValue(true),
  16950. items: getItems(event)
  16951. });
  16952. selectedValues = getValue(false);
  16953. },
  16954. indices(event) {
  16955. const indices = new Set(event.detail.indices);
  16956. for (const option of event.target.options) {
  16957. option.selected = indices.has(option.index);
  16958. }
  16959. storage.setValue(id, {
  16960. value: getValue(true)
  16961. });
  16962. selectedValues = getValue(false);
  16963. },
  16964. editable(event) {
  16965. event.target.disabled = !event.detail.editable;
  16966. }
  16967. };
  16968. this._dispatchEventFromSandbox(actions, jsEvent);
  16969. });
  16970. selectElement.addEventListener("input", event => {
  16971. var _this$linkService$eve9;
  16972. const exportValue = getValue(true);
  16973. storage.setValue(id, {
  16974. value: exportValue
  16975. });
  16976. event.preventDefault();
  16977. (_this$linkService$eve9 = this.linkService.eventBus) === null || _this$linkService$eve9 === void 0 ? void 0 : _this$linkService$eve9.dispatch("dispatcheventinsandbox", {
  16978. source: this,
  16979. detail: {
  16980. id,
  16981. name: "Keystroke",
  16982. value: selectedValues,
  16983. changeEx: exportValue,
  16984. willCommit: false,
  16985. commitKey: 1,
  16986. keyDown: false
  16987. }
  16988. });
  16989. });
  16990. this._setEventListeners(selectElement, [["focus", "Focus"], ["blur", "Blur"], ["mousedown", "Mouse Down"], ["mouseenter", "Mouse Enter"], ["mouseleave", "Mouse Exit"], ["mouseup", "Mouse Up"], ["input", "Action"], ["input", "Validate"]], event => event.target.value);
  16991. } else {
  16992. selectElement.addEventListener("input", function (event) {
  16993. storage.setValue(id, {
  16994. value: getValue(true)
  16995. });
  16996. });
  16997. }
  16998. if (this.data.combo) {
  16999. this._setTextStyle(selectElement);
  17000. } else {}
  17001. this._setBackgroundColor(selectElement);
  17002. this._setDefaultPropertiesFromJS(selectElement);
  17003. this.container.append(selectElement);
  17004. return this.container;
  17005. }
  17006. }
  17007. class PopupAnnotationElement extends AnnotationElement {
  17008. static IGNORE_TYPES = new Set(["Line", "Square", "Circle", "PolyLine", "Polygon", "Ink"]);
  17009. constructor(parameters) {
  17010. var _data$titleObj, _data$contentsObj, _data$richText;
  17011. const {
  17012. data
  17013. } = parameters;
  17014. const isRenderable = !PopupAnnotationElement.IGNORE_TYPES.has(data.parentType) && !!((_data$titleObj = data.titleObj) !== null && _data$titleObj !== void 0 && _data$titleObj.str || (_data$contentsObj = data.contentsObj) !== null && _data$contentsObj !== void 0 && _data$contentsObj.str || (_data$richText = data.richText) !== null && _data$richText !== void 0 && _data$richText.str);
  17015. super(parameters, {
  17016. isRenderable
  17017. });
  17018. }
  17019. render() {
  17020. this.container.className = "popupAnnotation";
  17021. const parentElements = this.layer.querySelectorAll(`[data-annotation-id="${this.data.parentId}"]`);
  17022. if (parentElements.length === 0) {
  17023. return this.container;
  17024. }
  17025. const popup = new PopupElement({
  17026. container: this.container,
  17027. trigger: Array.from(parentElements),
  17028. color: this.data.color,
  17029. titleObj: this.data.titleObj,
  17030. modificationDate: this.data.modificationDate,
  17031. contentsObj: this.data.contentsObj,
  17032. richText: this.data.richText
  17033. });
  17034. const page = this.page;
  17035. const rect = _util.Util.normalizeRect([this.data.parentRect[0], page.view[3] - this.data.parentRect[1] + page.view[1], this.data.parentRect[2], page.view[3] - this.data.parentRect[3] + page.view[1]]);
  17036. const popupLeft = rect[0] + this.data.parentRect[2] - this.data.parentRect[0];
  17037. const popupTop = rect[1];
  17038. const {
  17039. pageWidth,
  17040. pageHeight,
  17041. pageX,
  17042. pageY
  17043. } = this.viewport.rawDims;
  17044. this.container.style.left = `${100 * (popupLeft - pageX) / pageWidth}%`;
  17045. this.container.style.top = `${100 * (popupTop - pageY) / pageHeight}%`;
  17046. this.container.append(popup.render());
  17047. return this.container;
  17048. }
  17049. }
  17050. class PopupElement {
  17051. constructor(parameters) {
  17052. this.container = parameters.container;
  17053. this.trigger = parameters.trigger;
  17054. this.color = parameters.color;
  17055. this.titleObj = parameters.titleObj;
  17056. this.modificationDate = parameters.modificationDate;
  17057. this.contentsObj = parameters.contentsObj;
  17058. this.richText = parameters.richText;
  17059. this.hideWrapper = parameters.hideWrapper || false;
  17060. this.pinned = false;
  17061. }
  17062. render() {
  17063. var _this$richText, _this$contentsObj;
  17064. const BACKGROUND_ENLIGHT = 0.7;
  17065. const wrapper = document.createElement("div");
  17066. wrapper.className = "popupWrapper";
  17067. this.hideElement = this.hideWrapper ? wrapper : this.container;
  17068. this.hideElement.hidden = true;
  17069. const popup = document.createElement("div");
  17070. popup.className = "popup";
  17071. const color = this.color;
  17072. if (color) {
  17073. const r = BACKGROUND_ENLIGHT * (255 - color[0]) + color[0];
  17074. const g = BACKGROUND_ENLIGHT * (255 - color[1]) + color[1];
  17075. const b = BACKGROUND_ENLIGHT * (255 - color[2]) + color[2];
  17076. popup.style.backgroundColor = _util.Util.makeHexColor(r | 0, g | 0, b | 0);
  17077. }
  17078. const title = document.createElement("h1");
  17079. title.dir = this.titleObj.dir;
  17080. title.textContent = this.titleObj.str;
  17081. popup.append(title);
  17082. const dateObject = _display_utils.PDFDateString.toDateObject(this.modificationDate);
  17083. if (dateObject) {
  17084. const modificationDate = document.createElement("span");
  17085. modificationDate.className = "popupDate";
  17086. modificationDate.textContent = "{{date}}, {{time}}";
  17087. modificationDate.dataset.l10nId = "annotation_date_string";
  17088. modificationDate.dataset.l10nArgs = JSON.stringify({
  17089. date: dateObject.toLocaleDateString(),
  17090. time: dateObject.toLocaleTimeString()
  17091. });
  17092. popup.append(modificationDate);
  17093. }
  17094. if ((_this$richText = this.richText) !== null && _this$richText !== void 0 && _this$richText.str && (!((_this$contentsObj = this.contentsObj) !== null && _this$contentsObj !== void 0 && _this$contentsObj.str) || this.contentsObj.str === this.richText.str)) {
  17095. _xfa_layer.XfaLayer.render({
  17096. xfaHtml: this.richText.html,
  17097. intent: "richText",
  17098. div: popup
  17099. });
  17100. popup.lastChild.className = "richText popupContent";
  17101. } else {
  17102. const contents = this._formatContents(this.contentsObj);
  17103. popup.append(contents);
  17104. }
  17105. if (!Array.isArray(this.trigger)) {
  17106. this.trigger = [this.trigger];
  17107. }
  17108. for (const element of this.trigger) {
  17109. element.addEventListener("click", this._toggle.bind(this));
  17110. element.addEventListener("mouseover", this._show.bind(this, false));
  17111. element.addEventListener("mouseout", this._hide.bind(this, false));
  17112. }
  17113. popup.addEventListener("click", this._hide.bind(this, true));
  17114. wrapper.append(popup);
  17115. return wrapper;
  17116. }
  17117. _formatContents(_ref) {
  17118. let {
  17119. str,
  17120. dir
  17121. } = _ref;
  17122. const p = document.createElement("p");
  17123. p.className = "popupContent";
  17124. p.dir = dir;
  17125. const lines = str.split(/(?:\r\n?|\n)/);
  17126. for (let i = 0, ii = lines.length; i < ii; ++i) {
  17127. const line = lines[i];
  17128. p.append(document.createTextNode(line));
  17129. if (i < ii - 1) {
  17130. p.append(document.createElement("br"));
  17131. }
  17132. }
  17133. return p;
  17134. }
  17135. _toggle() {
  17136. if (this.pinned) {
  17137. this._hide(true);
  17138. } else {
  17139. this._show(true);
  17140. }
  17141. }
  17142. _show() {
  17143. let pin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  17144. if (pin) {
  17145. this.pinned = true;
  17146. }
  17147. if (this.hideElement.hidden) {
  17148. this.hideElement.hidden = false;
  17149. this.container.style.zIndex = parseInt(this.container.style.zIndex) + 1000;
  17150. }
  17151. }
  17152. _hide() {
  17153. let unpin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  17154. if (unpin) {
  17155. this.pinned = false;
  17156. }
  17157. if (!this.hideElement.hidden && !this.pinned) {
  17158. this.hideElement.hidden = true;
  17159. this.container.style.zIndex = parseInt(this.container.style.zIndex) - 1000;
  17160. }
  17161. }
  17162. }
  17163. class FreeTextAnnotationElement extends AnnotationElement {
  17164. constructor(parameters) {
  17165. var _parameters$data$titl2, _parameters$data$cont2, _parameters$data$rich2;
  17166. const isRenderable = !!(parameters.data.hasPopup || (_parameters$data$titl2 = parameters.data.titleObj) !== null && _parameters$data$titl2 !== void 0 && _parameters$data$titl2.str || (_parameters$data$cont2 = parameters.data.contentsObj) !== null && _parameters$data$cont2 !== void 0 && _parameters$data$cont2.str || (_parameters$data$rich2 = parameters.data.richText) !== null && _parameters$data$rich2 !== void 0 && _parameters$data$rich2.str);
  17167. super(parameters, {
  17168. isRenderable,
  17169. ignoreBorder: true
  17170. });
  17171. this.textContent = parameters.data.textContent;
  17172. }
  17173. render() {
  17174. this.container.className = "freeTextAnnotation";
  17175. if (this.textContent) {
  17176. const content = document.createElement("div");
  17177. content.className = "annotationTextContent";
  17178. content.setAttribute("role", "comment");
  17179. for (const line of this.textContent) {
  17180. const lineSpan = document.createElement("span");
  17181. lineSpan.textContent = line;
  17182. content.append(lineSpan);
  17183. }
  17184. this.container.append(content);
  17185. }
  17186. if (!this.data.hasPopup) {
  17187. this._createPopup(null, this.data);
  17188. }
  17189. return this.container;
  17190. }
  17191. }
  17192. class LineAnnotationElement extends AnnotationElement {
  17193. constructor(parameters) {
  17194. var _parameters$data$titl3, _parameters$data$cont3, _parameters$data$rich3;
  17195. const isRenderable = !!(parameters.data.hasPopup || (_parameters$data$titl3 = parameters.data.titleObj) !== null && _parameters$data$titl3 !== void 0 && _parameters$data$titl3.str || (_parameters$data$cont3 = parameters.data.contentsObj) !== null && _parameters$data$cont3 !== void 0 && _parameters$data$cont3.str || (_parameters$data$rich3 = parameters.data.richText) !== null && _parameters$data$rich3 !== void 0 && _parameters$data$rich3.str);
  17196. super(parameters, {
  17197. isRenderable,
  17198. ignoreBorder: true
  17199. });
  17200. }
  17201. render() {
  17202. this.container.className = "lineAnnotation";
  17203. const data = this.data;
  17204. const {
  17205. width,
  17206. height
  17207. } = getRectDims(data.rect);
  17208. const svg = this.svgFactory.create(width, height, true);
  17209. const line = this.svgFactory.createElement("svg:line");
  17210. line.setAttribute("x1", data.rect[2] - data.lineCoordinates[0]);
  17211. line.setAttribute("y1", data.rect[3] - data.lineCoordinates[1]);
  17212. line.setAttribute("x2", data.rect[2] - data.lineCoordinates[2]);
  17213. line.setAttribute("y2", data.rect[3] - data.lineCoordinates[3]);
  17214. line.setAttribute("stroke-width", data.borderStyle.width || 1);
  17215. line.setAttribute("stroke", "transparent");
  17216. line.setAttribute("fill", "transparent");
  17217. svg.append(line);
  17218. this.container.append(svg);
  17219. this._createPopup(line, data);
  17220. return this.container;
  17221. }
  17222. }
  17223. class SquareAnnotationElement extends AnnotationElement {
  17224. constructor(parameters) {
  17225. var _parameters$data$titl4, _parameters$data$cont4, _parameters$data$rich4;
  17226. const isRenderable = !!(parameters.data.hasPopup || (_parameters$data$titl4 = parameters.data.titleObj) !== null && _parameters$data$titl4 !== void 0 && _parameters$data$titl4.str || (_parameters$data$cont4 = parameters.data.contentsObj) !== null && _parameters$data$cont4 !== void 0 && _parameters$data$cont4.str || (_parameters$data$rich4 = parameters.data.richText) !== null && _parameters$data$rich4 !== void 0 && _parameters$data$rich4.str);
  17227. super(parameters, {
  17228. isRenderable,
  17229. ignoreBorder: true
  17230. });
  17231. }
  17232. render() {
  17233. this.container.className = "squareAnnotation";
  17234. const data = this.data;
  17235. const {
  17236. width,
  17237. height
  17238. } = getRectDims(data.rect);
  17239. const svg = this.svgFactory.create(width, height, true);
  17240. const borderWidth = data.borderStyle.width;
  17241. const square = this.svgFactory.createElement("svg:rect");
  17242. square.setAttribute("x", borderWidth / 2);
  17243. square.setAttribute("y", borderWidth / 2);
  17244. square.setAttribute("width", width - borderWidth);
  17245. square.setAttribute("height", height - borderWidth);
  17246. square.setAttribute("stroke-width", borderWidth || 1);
  17247. square.setAttribute("stroke", "transparent");
  17248. square.setAttribute("fill", "transparent");
  17249. svg.append(square);
  17250. this.container.append(svg);
  17251. this._createPopup(square, data);
  17252. return this.container;
  17253. }
  17254. }
  17255. class CircleAnnotationElement extends AnnotationElement {
  17256. constructor(parameters) {
  17257. var _parameters$data$titl5, _parameters$data$cont5, _parameters$data$rich5;
  17258. const isRenderable = !!(parameters.data.hasPopup || (_parameters$data$titl5 = parameters.data.titleObj) !== null && _parameters$data$titl5 !== void 0 && _parameters$data$titl5.str || (_parameters$data$cont5 = parameters.data.contentsObj) !== null && _parameters$data$cont5 !== void 0 && _parameters$data$cont5.str || (_parameters$data$rich5 = parameters.data.richText) !== null && _parameters$data$rich5 !== void 0 && _parameters$data$rich5.str);
  17259. super(parameters, {
  17260. isRenderable,
  17261. ignoreBorder: true
  17262. });
  17263. }
  17264. render() {
  17265. this.container.className = "circleAnnotation";
  17266. const data = this.data;
  17267. const {
  17268. width,
  17269. height
  17270. } = getRectDims(data.rect);
  17271. const svg = this.svgFactory.create(width, height, true);
  17272. const borderWidth = data.borderStyle.width;
  17273. const circle = this.svgFactory.createElement("svg:ellipse");
  17274. circle.setAttribute("cx", width / 2);
  17275. circle.setAttribute("cy", height / 2);
  17276. circle.setAttribute("rx", width / 2 - borderWidth / 2);
  17277. circle.setAttribute("ry", height / 2 - borderWidth / 2);
  17278. circle.setAttribute("stroke-width", borderWidth || 1);
  17279. circle.setAttribute("stroke", "transparent");
  17280. circle.setAttribute("fill", "transparent");
  17281. svg.append(circle);
  17282. this.container.append(svg);
  17283. this._createPopup(circle, data);
  17284. return this.container;
  17285. }
  17286. }
  17287. class PolylineAnnotationElement extends AnnotationElement {
  17288. constructor(parameters) {
  17289. var _parameters$data$titl6, _parameters$data$cont6, _parameters$data$rich6;
  17290. const isRenderable = !!(parameters.data.hasPopup || (_parameters$data$titl6 = parameters.data.titleObj) !== null && _parameters$data$titl6 !== void 0 && _parameters$data$titl6.str || (_parameters$data$cont6 = parameters.data.contentsObj) !== null && _parameters$data$cont6 !== void 0 && _parameters$data$cont6.str || (_parameters$data$rich6 = parameters.data.richText) !== null && _parameters$data$rich6 !== void 0 && _parameters$data$rich6.str);
  17291. super(parameters, {
  17292. isRenderable,
  17293. ignoreBorder: true
  17294. });
  17295. this.containerClassName = "polylineAnnotation";
  17296. this.svgElementName = "svg:polyline";
  17297. }
  17298. render() {
  17299. this.container.className = this.containerClassName;
  17300. const data = this.data;
  17301. const {
  17302. width,
  17303. height
  17304. } = getRectDims(data.rect);
  17305. const svg = this.svgFactory.create(width, height, true);
  17306. let points = [];
  17307. for (const coordinate of data.vertices) {
  17308. const x = coordinate.x - data.rect[0];
  17309. const y = data.rect[3] - coordinate.y;
  17310. points.push(x + "," + y);
  17311. }
  17312. points = points.join(" ");
  17313. const polyline = this.svgFactory.createElement(this.svgElementName);
  17314. polyline.setAttribute("points", points);
  17315. polyline.setAttribute("stroke-width", data.borderStyle.width || 1);
  17316. polyline.setAttribute("stroke", "transparent");
  17317. polyline.setAttribute("fill", "transparent");
  17318. svg.append(polyline);
  17319. this.container.append(svg);
  17320. this._createPopup(polyline, data);
  17321. return this.container;
  17322. }
  17323. }
  17324. class PolygonAnnotationElement extends PolylineAnnotationElement {
  17325. constructor(parameters) {
  17326. super(parameters);
  17327. this.containerClassName = "polygonAnnotation";
  17328. this.svgElementName = "svg:polygon";
  17329. }
  17330. }
  17331. class CaretAnnotationElement extends AnnotationElement {
  17332. constructor(parameters) {
  17333. var _parameters$data$titl7, _parameters$data$cont7, _parameters$data$rich7;
  17334. const isRenderable = !!(parameters.data.hasPopup || (_parameters$data$titl7 = parameters.data.titleObj) !== null && _parameters$data$titl7 !== void 0 && _parameters$data$titl7.str || (_parameters$data$cont7 = parameters.data.contentsObj) !== null && _parameters$data$cont7 !== void 0 && _parameters$data$cont7.str || (_parameters$data$rich7 = parameters.data.richText) !== null && _parameters$data$rich7 !== void 0 && _parameters$data$rich7.str);
  17335. super(parameters, {
  17336. isRenderable,
  17337. ignoreBorder: true
  17338. });
  17339. }
  17340. render() {
  17341. this.container.className = "caretAnnotation";
  17342. if (!this.data.hasPopup) {
  17343. this._createPopup(null, this.data);
  17344. }
  17345. return this.container;
  17346. }
  17347. }
  17348. class InkAnnotationElement extends AnnotationElement {
  17349. constructor(parameters) {
  17350. var _parameters$data$titl8, _parameters$data$cont8, _parameters$data$rich8;
  17351. const isRenderable = !!(parameters.data.hasPopup || (_parameters$data$titl8 = parameters.data.titleObj) !== null && _parameters$data$titl8 !== void 0 && _parameters$data$titl8.str || (_parameters$data$cont8 = parameters.data.contentsObj) !== null && _parameters$data$cont8 !== void 0 && _parameters$data$cont8.str || (_parameters$data$rich8 = parameters.data.richText) !== null && _parameters$data$rich8 !== void 0 && _parameters$data$rich8.str);
  17352. super(parameters, {
  17353. isRenderable,
  17354. ignoreBorder: true
  17355. });
  17356. this.containerClassName = "inkAnnotation";
  17357. this.svgElementName = "svg:polyline";
  17358. }
  17359. render() {
  17360. this.container.className = this.containerClassName;
  17361. const data = this.data;
  17362. const {
  17363. width,
  17364. height
  17365. } = getRectDims(data.rect);
  17366. const svg = this.svgFactory.create(width, height, true);
  17367. for (const inkList of data.inkLists) {
  17368. let points = [];
  17369. for (const coordinate of inkList) {
  17370. const x = coordinate.x - data.rect[0];
  17371. const y = data.rect[3] - coordinate.y;
  17372. points.push(`${x},${y}`);
  17373. }
  17374. points = points.join(" ");
  17375. const polyline = this.svgFactory.createElement(this.svgElementName);
  17376. polyline.setAttribute("points", points);
  17377. polyline.setAttribute("stroke-width", data.borderStyle.width || 1);
  17378. polyline.setAttribute("stroke", "transparent");
  17379. polyline.setAttribute("fill", "transparent");
  17380. this._createPopup(polyline, data);
  17381. svg.append(polyline);
  17382. }
  17383. this.container.append(svg);
  17384. return this.container;
  17385. }
  17386. }
  17387. class HighlightAnnotationElement extends AnnotationElement {
  17388. constructor(parameters) {
  17389. var _parameters$data$titl9, _parameters$data$cont9, _parameters$data$rich9;
  17390. const isRenderable = !!(parameters.data.hasPopup || (_parameters$data$titl9 = parameters.data.titleObj) !== null && _parameters$data$titl9 !== void 0 && _parameters$data$titl9.str || (_parameters$data$cont9 = parameters.data.contentsObj) !== null && _parameters$data$cont9 !== void 0 && _parameters$data$cont9.str || (_parameters$data$rich9 = parameters.data.richText) !== null && _parameters$data$rich9 !== void 0 && _parameters$data$rich9.str);
  17391. super(parameters, {
  17392. isRenderable,
  17393. ignoreBorder: true,
  17394. createQuadrilaterals: true
  17395. });
  17396. }
  17397. render() {
  17398. if (!this.data.hasPopup) {
  17399. this._createPopup(null, this.data);
  17400. }
  17401. if (this.quadrilaterals) {
  17402. return this._renderQuadrilaterals("highlightAnnotation");
  17403. }
  17404. this.container.className = "highlightAnnotation";
  17405. return this.container;
  17406. }
  17407. }
  17408. class UnderlineAnnotationElement extends AnnotationElement {
  17409. constructor(parameters) {
  17410. var _parameters$data$titl10, _parameters$data$cont10, _parameters$data$rich10;
  17411. const isRenderable = !!(parameters.data.hasPopup || (_parameters$data$titl10 = parameters.data.titleObj) !== null && _parameters$data$titl10 !== void 0 && _parameters$data$titl10.str || (_parameters$data$cont10 = parameters.data.contentsObj) !== null && _parameters$data$cont10 !== void 0 && _parameters$data$cont10.str || (_parameters$data$rich10 = parameters.data.richText) !== null && _parameters$data$rich10 !== void 0 && _parameters$data$rich10.str);
  17412. super(parameters, {
  17413. isRenderable,
  17414. ignoreBorder: true,
  17415. createQuadrilaterals: true
  17416. });
  17417. }
  17418. render() {
  17419. if (!this.data.hasPopup) {
  17420. this._createPopup(null, this.data);
  17421. }
  17422. if (this.quadrilaterals) {
  17423. return this._renderQuadrilaterals("underlineAnnotation");
  17424. }
  17425. this.container.className = "underlineAnnotation";
  17426. return this.container;
  17427. }
  17428. }
  17429. class SquigglyAnnotationElement extends AnnotationElement {
  17430. constructor(parameters) {
  17431. var _parameters$data$titl11, _parameters$data$cont11, _parameters$data$rich11;
  17432. const isRenderable = !!(parameters.data.hasPopup || (_parameters$data$titl11 = parameters.data.titleObj) !== null && _parameters$data$titl11 !== void 0 && _parameters$data$titl11.str || (_parameters$data$cont11 = parameters.data.contentsObj) !== null && _parameters$data$cont11 !== void 0 && _parameters$data$cont11.str || (_parameters$data$rich11 = parameters.data.richText) !== null && _parameters$data$rich11 !== void 0 && _parameters$data$rich11.str);
  17433. super(parameters, {
  17434. isRenderable,
  17435. ignoreBorder: true,
  17436. createQuadrilaterals: true
  17437. });
  17438. }
  17439. render() {
  17440. if (!this.data.hasPopup) {
  17441. this._createPopup(null, this.data);
  17442. }
  17443. if (this.quadrilaterals) {
  17444. return this._renderQuadrilaterals("squigglyAnnotation");
  17445. }
  17446. this.container.className = "squigglyAnnotation";
  17447. return this.container;
  17448. }
  17449. }
  17450. class StrikeOutAnnotationElement extends AnnotationElement {
  17451. constructor(parameters) {
  17452. var _parameters$data$titl12, _parameters$data$cont12, _parameters$data$rich12;
  17453. const isRenderable = !!(parameters.data.hasPopup || (_parameters$data$titl12 = parameters.data.titleObj) !== null && _parameters$data$titl12 !== void 0 && _parameters$data$titl12.str || (_parameters$data$cont12 = parameters.data.contentsObj) !== null && _parameters$data$cont12 !== void 0 && _parameters$data$cont12.str || (_parameters$data$rich12 = parameters.data.richText) !== null && _parameters$data$rich12 !== void 0 && _parameters$data$rich12.str);
  17454. super(parameters, {
  17455. isRenderable,
  17456. ignoreBorder: true,
  17457. createQuadrilaterals: true
  17458. });
  17459. }
  17460. render() {
  17461. if (!this.data.hasPopup) {
  17462. this._createPopup(null, this.data);
  17463. }
  17464. if (this.quadrilaterals) {
  17465. return this._renderQuadrilaterals("strikeoutAnnotation");
  17466. }
  17467. this.container.className = "strikeoutAnnotation";
  17468. return this.container;
  17469. }
  17470. }
  17471. class StampAnnotationElement extends AnnotationElement {
  17472. constructor(parameters) {
  17473. var _parameters$data$titl13, _parameters$data$cont13, _parameters$data$rich13;
  17474. const isRenderable = !!(parameters.data.hasPopup || (_parameters$data$titl13 = parameters.data.titleObj) !== null && _parameters$data$titl13 !== void 0 && _parameters$data$titl13.str || (_parameters$data$cont13 = parameters.data.contentsObj) !== null && _parameters$data$cont13 !== void 0 && _parameters$data$cont13.str || (_parameters$data$rich13 = parameters.data.richText) !== null && _parameters$data$rich13 !== void 0 && _parameters$data$rich13.str);
  17475. super(parameters, {
  17476. isRenderable,
  17477. ignoreBorder: true
  17478. });
  17479. }
  17480. render() {
  17481. this.container.className = "stampAnnotation";
  17482. if (!this.data.hasPopup) {
  17483. this._createPopup(null, this.data);
  17484. }
  17485. return this.container;
  17486. }
  17487. }
  17488. class FileAttachmentAnnotationElement extends AnnotationElement {
  17489. constructor(parameters) {
  17490. var _this$linkService$eve10;
  17491. super(parameters, {
  17492. isRenderable: true
  17493. });
  17494. const {
  17495. filename,
  17496. content
  17497. } = this.data.file;
  17498. this.filename = (0, _display_utils.getFilenameFromUrl)(filename, true);
  17499. this.content = content;
  17500. (_this$linkService$eve10 = this.linkService.eventBus) === null || _this$linkService$eve10 === void 0 ? void 0 : _this$linkService$eve10.dispatch("fileattachmentannotation", {
  17501. source: this,
  17502. filename,
  17503. content
  17504. });
  17505. }
  17506. render() {
  17507. var _this$data$titleObj, _this$data$contentsOb;
  17508. this.container.className = "fileAttachmentAnnotation";
  17509. let trigger;
  17510. if (this.data.hasAppearance) {
  17511. trigger = document.createElement("div");
  17512. } else {
  17513. trigger = document.createElement("img");
  17514. trigger.src = `${this.imageResourcesPath}annotation-${/paperclip/i.test(this.data.name) ? "paperclip" : "pushpin"}.svg`;
  17515. }
  17516. trigger.className = "popupTriggerArea";
  17517. trigger.addEventListener("dblclick", this._download.bind(this));
  17518. if (!this.data.hasPopup && ((_this$data$titleObj = this.data.titleObj) !== null && _this$data$titleObj !== void 0 && _this$data$titleObj.str || (_this$data$contentsOb = this.data.contentsObj) !== null && _this$data$contentsOb !== void 0 && _this$data$contentsOb.str || this.data.richText)) {
  17519. this._createPopup(trigger, this.data);
  17520. }
  17521. this.container.append(trigger);
  17522. return this.container;
  17523. }
  17524. _download() {
  17525. var _this$downloadManager2;
  17526. (_this$downloadManager2 = this.downloadManager) === null || _this$downloadManager2 === void 0 ? void 0 : _this$downloadManager2.openOrDownloadData(this.container, this.content, this.filename);
  17527. }
  17528. }
  17529. class AnnotationLayer {
  17530. static render(params) {
  17531. const {
  17532. annotations,
  17533. div,
  17534. viewport,
  17535. accessibilityManager
  17536. } = params;
  17537. (0, _display_utils.setLayerDimensions)(div, viewport);
  17538. const elementParams = {
  17539. data: null,
  17540. layer: div,
  17541. page: params.page,
  17542. viewport,
  17543. linkService: params.linkService,
  17544. downloadManager: params.downloadManager,
  17545. imageResourcesPath: params.imageResourcesPath || "",
  17546. renderForms: params.renderForms !== false,
  17547. svgFactory: new _display_utils.DOMSVGFactory(),
  17548. annotationStorage: params.annotationStorage || new _annotation_storage.AnnotationStorage(),
  17549. enableScripting: params.enableScripting === true,
  17550. hasJSActions: params.hasJSActions,
  17551. fieldObjects: params.fieldObjects
  17552. };
  17553. let zIndex = 0;
  17554. for (const data of annotations) {
  17555. if (data.annotationType !== _util.AnnotationType.POPUP) {
  17556. const {
  17557. width,
  17558. height
  17559. } = getRectDims(data.rect);
  17560. if (width <= 0 || height <= 0) {
  17561. continue;
  17562. }
  17563. }
  17564. elementParams.data = data;
  17565. const element = AnnotationElementFactory.create(elementParams);
  17566. if (!element.isRenderable) {
  17567. continue;
  17568. }
  17569. const rendered = element.render();
  17570. if (data.hidden) {
  17571. rendered.style.visibility = "hidden";
  17572. }
  17573. if (Array.isArray(rendered)) {
  17574. for (const renderedElement of rendered) {
  17575. renderedElement.style.zIndex = zIndex++;
  17576. _classStaticPrivateMethodGet(AnnotationLayer, AnnotationLayer, _appendElement).call(AnnotationLayer, renderedElement, data.id, div, accessibilityManager);
  17577. }
  17578. } else {
  17579. rendered.style.zIndex = zIndex++;
  17580. if (element instanceof PopupAnnotationElement) {
  17581. div.prepend(rendered);
  17582. } else {
  17583. _classStaticPrivateMethodGet(AnnotationLayer, AnnotationLayer, _appendElement).call(AnnotationLayer, rendered, data.id, div, accessibilityManager);
  17584. }
  17585. }
  17586. }
  17587. _classStaticPrivateMethodGet(this, AnnotationLayer, _setAnnotationCanvasMap).call(this, div, params.annotationCanvasMap);
  17588. }
  17589. static update(params) {
  17590. const {
  17591. annotationCanvasMap,
  17592. div,
  17593. viewport
  17594. } = params;
  17595. (0, _display_utils.setLayerDimensions)(div, {
  17596. rotation: viewport.rotation
  17597. });
  17598. _classStaticPrivateMethodGet(this, AnnotationLayer, _setAnnotationCanvasMap).call(this, div, annotationCanvasMap);
  17599. div.hidden = false;
  17600. }
  17601. }
  17602. exports.AnnotationLayer = AnnotationLayer;
  17603. function _appendElement(element, id, div, accessibilityManager) {
  17604. const contentElement = element.firstChild || element;
  17605. contentElement.id = `${_display_utils.AnnotationPrefix}${id}`;
  17606. div.append(element);
  17607. accessibilityManager === null || accessibilityManager === void 0 ? void 0 : accessibilityManager.moveElementInDOM(div, element, contentElement, false);
  17608. }
  17609. function _setAnnotationCanvasMap(div, annotationCanvasMap) {
  17610. if (!annotationCanvasMap) {
  17611. return;
  17612. }
  17613. for (const [id, canvas] of annotationCanvasMap) {
  17614. const element = div.querySelector(`[data-annotation-id="${id}"]`);
  17615. if (!element) {
  17616. continue;
  17617. }
  17618. const {
  17619. firstChild
  17620. } = element;
  17621. if (!firstChild) {
  17622. element.append(canvas);
  17623. } else if (firstChild.nodeName === "CANVAS") {
  17624. firstChild.replaceWith(canvas);
  17625. } else {
  17626. firstChild.before(canvas);
  17627. }
  17628. }
  17629. annotationCanvasMap.clear();
  17630. }
  17631. /***/ }),
  17632. /* 165 */
  17633. /***/ ((__unused_webpack_module, exports) => {
  17634. "use strict";
  17635. Object.defineProperty(exports, "__esModule", ({
  17636. value: true
  17637. }));
  17638. exports.ColorConverters = void 0;
  17639. function makeColorComp(n) {
  17640. return Math.floor(Math.max(0, Math.min(1, n)) * 255).toString(16).padStart(2, "0");
  17641. }
  17642. class ColorConverters {
  17643. static CMYK_G(_ref) {
  17644. let [c, y, m, k] = _ref;
  17645. return ["G", 1 - Math.min(1, 0.3 * c + 0.59 * m + 0.11 * y + k)];
  17646. }
  17647. static G_CMYK(_ref2) {
  17648. let [g] = _ref2;
  17649. return ["CMYK", 0, 0, 0, 1 - g];
  17650. }
  17651. static G_RGB(_ref3) {
  17652. let [g] = _ref3;
  17653. return ["RGB", g, g, g];
  17654. }
  17655. static G_HTML(_ref4) {
  17656. let [g] = _ref4;
  17657. const G = makeColorComp(g);
  17658. return `#${G}${G}${G}`;
  17659. }
  17660. static RGB_G(_ref5) {
  17661. let [r, g, b] = _ref5;
  17662. return ["G", 0.3 * r + 0.59 * g + 0.11 * b];
  17663. }
  17664. static RGB_HTML(_ref6) {
  17665. let [r, g, b] = _ref6;
  17666. const R = makeColorComp(r);
  17667. const G = makeColorComp(g);
  17668. const B = makeColorComp(b);
  17669. return `#${R}${G}${B}`;
  17670. }
  17671. static T_HTML() {
  17672. return "#00000000";
  17673. }
  17674. static CMYK_RGB(_ref7) {
  17675. let [c, y, m, k] = _ref7;
  17676. return ["RGB", 1 - Math.min(1, c + k), 1 - Math.min(1, m + k), 1 - Math.min(1, y + k)];
  17677. }
  17678. static CMYK_HTML(components) {
  17679. const rgb = this.CMYK_RGB(components).slice(1);
  17680. return this.RGB_HTML(rgb);
  17681. }
  17682. static RGB_CMYK(_ref8) {
  17683. let [r, g, b] = _ref8;
  17684. const c = 1 - r;
  17685. const m = 1 - g;
  17686. const y = 1 - b;
  17687. const k = Math.min(c, m, y);
  17688. return ["CMYK", c, m, y, k];
  17689. }
  17690. }
  17691. exports.ColorConverters = ColorConverters;
  17692. /***/ }),
  17693. /* 166 */
  17694. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  17695. "use strict";
  17696. Object.defineProperty(exports, "__esModule", ({
  17697. value: true
  17698. }));
  17699. exports.XfaLayer = void 0;
  17700. var _xfa_text = __w_pdfjs_require__(151);
  17701. class XfaLayer {
  17702. static setupStorage(html, id, element, storage, intent) {
  17703. const storedData = storage.getValue(id, {
  17704. value: null
  17705. });
  17706. switch (element.name) {
  17707. case "textarea":
  17708. if (storedData.value !== null) {
  17709. html.textContent = storedData.value;
  17710. }
  17711. if (intent === "print") {
  17712. break;
  17713. }
  17714. html.addEventListener("input", event => {
  17715. storage.setValue(id, {
  17716. value: event.target.value
  17717. });
  17718. });
  17719. break;
  17720. case "input":
  17721. if (element.attributes.type === "radio" || element.attributes.type === "checkbox") {
  17722. if (storedData.value === element.attributes.xfaOn) {
  17723. html.setAttribute("checked", true);
  17724. } else if (storedData.value === element.attributes.xfaOff) {
  17725. html.removeAttribute("checked");
  17726. }
  17727. if (intent === "print") {
  17728. break;
  17729. }
  17730. html.addEventListener("change", event => {
  17731. storage.setValue(id, {
  17732. value: event.target.checked ? event.target.getAttribute("xfaOn") : event.target.getAttribute("xfaOff")
  17733. });
  17734. });
  17735. } else {
  17736. if (storedData.value !== null) {
  17737. html.setAttribute("value", storedData.value);
  17738. }
  17739. if (intent === "print") {
  17740. break;
  17741. }
  17742. html.addEventListener("input", event => {
  17743. storage.setValue(id, {
  17744. value: event.target.value
  17745. });
  17746. });
  17747. }
  17748. break;
  17749. case "select":
  17750. if (storedData.value !== null) {
  17751. for (const option of element.children) {
  17752. if (option.attributes.value === storedData.value) {
  17753. option.attributes.selected = true;
  17754. }
  17755. }
  17756. }
  17757. html.addEventListener("input", event => {
  17758. const options = event.target.options;
  17759. const value = options.selectedIndex === -1 ? "" : options[options.selectedIndex].value;
  17760. storage.setValue(id, {
  17761. value
  17762. });
  17763. });
  17764. break;
  17765. }
  17766. }
  17767. static setAttributes(_ref) {
  17768. let {
  17769. html,
  17770. element,
  17771. storage = null,
  17772. intent,
  17773. linkService
  17774. } = _ref;
  17775. const {
  17776. attributes
  17777. } = element;
  17778. const isHTMLAnchorElement = html instanceof HTMLAnchorElement;
  17779. if (attributes.type === "radio") {
  17780. attributes.name = `${attributes.name}-${intent}`;
  17781. }
  17782. for (const [key, value] of Object.entries(attributes)) {
  17783. if (value === null || value === undefined) {
  17784. continue;
  17785. }
  17786. switch (key) {
  17787. case "class":
  17788. if (value.length) {
  17789. html.setAttribute(key, value.join(" "));
  17790. }
  17791. break;
  17792. case "dataId":
  17793. break;
  17794. case "id":
  17795. html.setAttribute("data-element-id", value);
  17796. break;
  17797. case "style":
  17798. Object.assign(html.style, value);
  17799. break;
  17800. case "textContent":
  17801. html.textContent = value;
  17802. break;
  17803. default:
  17804. if (!isHTMLAnchorElement || key !== "href" && key !== "newWindow") {
  17805. html.setAttribute(key, value);
  17806. }
  17807. }
  17808. }
  17809. if (isHTMLAnchorElement) {
  17810. linkService.addLinkAttributes(html, attributes.href, attributes.newWindow);
  17811. }
  17812. if (storage && attributes.dataId) {
  17813. this.setupStorage(html, attributes.dataId, element, storage);
  17814. }
  17815. }
  17816. static render(parameters) {
  17817. const storage = parameters.annotationStorage;
  17818. const linkService = parameters.linkService;
  17819. const root = parameters.xfaHtml;
  17820. const intent = parameters.intent || "display";
  17821. const rootHtml = document.createElement(root.name);
  17822. if (root.attributes) {
  17823. this.setAttributes({
  17824. html: rootHtml,
  17825. element: root,
  17826. intent,
  17827. linkService
  17828. });
  17829. }
  17830. const stack = [[root, -1, rootHtml]];
  17831. const rootDiv = parameters.div;
  17832. rootDiv.append(rootHtml);
  17833. if (parameters.viewport) {
  17834. const transform = `matrix(${parameters.viewport.transform.join(",")})`;
  17835. rootDiv.style.transform = transform;
  17836. }
  17837. if (intent !== "richText") {
  17838. rootDiv.setAttribute("class", "xfaLayer xfaFont");
  17839. }
  17840. const textDivs = [];
  17841. while (stack.length > 0) {
  17842. var _child$attributes;
  17843. const [parent, i, html] = stack.at(-1);
  17844. if (i + 1 === parent.children.length) {
  17845. stack.pop();
  17846. continue;
  17847. }
  17848. const child = parent.children[++stack.at(-1)[1]];
  17849. if (child === null) {
  17850. continue;
  17851. }
  17852. const {
  17853. name
  17854. } = child;
  17855. if (name === "#text") {
  17856. const node = document.createTextNode(child.value);
  17857. textDivs.push(node);
  17858. html.append(node);
  17859. continue;
  17860. }
  17861. let childHtml;
  17862. if (child !== null && child !== void 0 && (_child$attributes = child.attributes) !== null && _child$attributes !== void 0 && _child$attributes.xmlns) {
  17863. childHtml = document.createElementNS(child.attributes.xmlns, name);
  17864. } else {
  17865. childHtml = document.createElement(name);
  17866. }
  17867. html.append(childHtml);
  17868. if (child.attributes) {
  17869. this.setAttributes({
  17870. html: childHtml,
  17871. element: child,
  17872. storage,
  17873. intent,
  17874. linkService
  17875. });
  17876. }
  17877. if (child.children && child.children.length > 0) {
  17878. stack.push([child, -1, childHtml]);
  17879. } else if (child.value) {
  17880. const node = document.createTextNode(child.value);
  17881. if (_xfa_text.XfaText.shouldBuildText(name)) {
  17882. textDivs.push(node);
  17883. }
  17884. childHtml.append(node);
  17885. }
  17886. }
  17887. for (const el of rootDiv.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea")) {
  17888. el.setAttribute("readOnly", true);
  17889. }
  17890. return {
  17891. textDivs
  17892. };
  17893. }
  17894. static update(parameters) {
  17895. const transform = `matrix(${parameters.viewport.transform.join(",")})`;
  17896. parameters.div.style.transform = transform;
  17897. parameters.div.hidden = false;
  17898. }
  17899. }
  17900. exports.XfaLayer = XfaLayer;
  17901. /***/ }),
  17902. /* 167 */
  17903. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  17904. "use strict";
  17905. Object.defineProperty(exports, "__esModule", ({
  17906. value: true
  17907. }));
  17908. exports.SVGGraphics = void 0;
  17909. var _display_utils = __w_pdfjs_require__(139);
  17910. var _util = __w_pdfjs_require__(1);
  17911. var _is_node = __w_pdfjs_require__(3);
  17912. let SVGGraphics = class {
  17913. constructor() {
  17914. (0, _util.unreachable)("Not implemented: SVGGraphics");
  17915. }
  17916. };
  17917. exports.SVGGraphics = SVGGraphics;
  17918. {
  17919. const SVG_DEFAULTS = {
  17920. fontStyle: "normal",
  17921. fontWeight: "normal",
  17922. fillColor: "#000000"
  17923. };
  17924. const XML_NS = "http://www.w3.org/XML/1998/namespace";
  17925. const XLINK_NS = "http://www.w3.org/1999/xlink";
  17926. const LINE_CAP_STYLES = ["butt", "round", "square"];
  17927. const LINE_JOIN_STYLES = ["miter", "round", "bevel"];
  17928. const createObjectURL = function (data) {
  17929. let contentType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
  17930. let forceDataSchema = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  17931. if (URL.createObjectURL && typeof Blob !== "undefined" && !forceDataSchema) {
  17932. return URL.createObjectURL(new Blob([data], {
  17933. type: contentType
  17934. }));
  17935. }
  17936. const digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
  17937. let buffer = `data:${contentType};base64,`;
  17938. for (let i = 0, ii = data.length; i < ii; i += 3) {
  17939. const b1 = data[i] & 0xff;
  17940. const b2 = data[i + 1] & 0xff;
  17941. const b3 = data[i + 2] & 0xff;
  17942. const d1 = b1 >> 2,
  17943. d2 = (b1 & 3) << 4 | b2 >> 4;
  17944. const d3 = i + 1 < ii ? (b2 & 0xf) << 2 | b3 >> 6 : 64;
  17945. const d4 = i + 2 < ii ? b3 & 0x3f : 64;
  17946. buffer += digits[d1] + digits[d2] + digits[d3] + digits[d4];
  17947. }
  17948. return buffer;
  17949. };
  17950. const convertImgDataToPng = function () {
  17951. const PNG_HEADER = new Uint8Array([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]);
  17952. const CHUNK_WRAPPER_SIZE = 12;
  17953. const crcTable = new Int32Array(256);
  17954. for (let i = 0; i < 256; i++) {
  17955. let c = i;
  17956. for (let h = 0; h < 8; h++) {
  17957. if (c & 1) {
  17958. c = 0xedb88320 ^ c >> 1 & 0x7fffffff;
  17959. } else {
  17960. c = c >> 1 & 0x7fffffff;
  17961. }
  17962. }
  17963. crcTable[i] = c;
  17964. }
  17965. function crc32(data, start, end) {
  17966. let crc = -1;
  17967. for (let i = start; i < end; i++) {
  17968. const a = (crc ^ data[i]) & 0xff;
  17969. const b = crcTable[a];
  17970. crc = crc >>> 8 ^ b;
  17971. }
  17972. return crc ^ -1;
  17973. }
  17974. function writePngChunk(type, body, data, offset) {
  17975. let p = offset;
  17976. const len = body.length;
  17977. data[p] = len >> 24 & 0xff;
  17978. data[p + 1] = len >> 16 & 0xff;
  17979. data[p + 2] = len >> 8 & 0xff;
  17980. data[p + 3] = len & 0xff;
  17981. p += 4;
  17982. data[p] = type.charCodeAt(0) & 0xff;
  17983. data[p + 1] = type.charCodeAt(1) & 0xff;
  17984. data[p + 2] = type.charCodeAt(2) & 0xff;
  17985. data[p + 3] = type.charCodeAt(3) & 0xff;
  17986. p += 4;
  17987. data.set(body, p);
  17988. p += body.length;
  17989. const crc = crc32(data, offset + 4, p);
  17990. data[p] = crc >> 24 & 0xff;
  17991. data[p + 1] = crc >> 16 & 0xff;
  17992. data[p + 2] = crc >> 8 & 0xff;
  17993. data[p + 3] = crc & 0xff;
  17994. }
  17995. function adler32(data, start, end) {
  17996. let a = 1;
  17997. let b = 0;
  17998. for (let i = start; i < end; ++i) {
  17999. a = (a + (data[i] & 0xff)) % 65521;
  18000. b = (b + a) % 65521;
  18001. }
  18002. return b << 16 | a;
  18003. }
  18004. function deflateSync(literals) {
  18005. if (!_is_node.isNodeJS) {
  18006. return deflateSyncUncompressed(literals);
  18007. }
  18008. try {
  18009. let input;
  18010. if (parseInt(process.versions.node) >= 8) {
  18011. input = literals;
  18012. } else {
  18013. input = Buffer.from(literals);
  18014. }
  18015. const output = require("zlib").deflateSync(input, {
  18016. level: 9
  18017. });
  18018. return output instanceof Uint8Array ? output : new Uint8Array(output);
  18019. } catch (e) {
  18020. (0, _util.warn)("Not compressing PNG because zlib.deflateSync is unavailable: " + e);
  18021. }
  18022. return deflateSyncUncompressed(literals);
  18023. }
  18024. function deflateSyncUncompressed(literals) {
  18025. let len = literals.length;
  18026. const maxBlockLength = 0xffff;
  18027. const deflateBlocks = Math.ceil(len / maxBlockLength);
  18028. const idat = new Uint8Array(2 + len + deflateBlocks * 5 + 4);
  18029. let pi = 0;
  18030. idat[pi++] = 0x78;
  18031. idat[pi++] = 0x9c;
  18032. let pos = 0;
  18033. while (len > maxBlockLength) {
  18034. idat[pi++] = 0x00;
  18035. idat[pi++] = 0xff;
  18036. idat[pi++] = 0xff;
  18037. idat[pi++] = 0x00;
  18038. idat[pi++] = 0x00;
  18039. idat.set(literals.subarray(pos, pos + maxBlockLength), pi);
  18040. pi += maxBlockLength;
  18041. pos += maxBlockLength;
  18042. len -= maxBlockLength;
  18043. }
  18044. idat[pi++] = 0x01;
  18045. idat[pi++] = len & 0xff;
  18046. idat[pi++] = len >> 8 & 0xff;
  18047. idat[pi++] = ~len & 0xffff & 0xff;
  18048. idat[pi++] = (~len & 0xffff) >> 8 & 0xff;
  18049. idat.set(literals.subarray(pos), pi);
  18050. pi += literals.length - pos;
  18051. const adler = adler32(literals, 0, literals.length);
  18052. idat[pi++] = adler >> 24 & 0xff;
  18053. idat[pi++] = adler >> 16 & 0xff;
  18054. idat[pi++] = adler >> 8 & 0xff;
  18055. idat[pi++] = adler & 0xff;
  18056. return idat;
  18057. }
  18058. function encode(imgData, kind, forceDataSchema, isMask) {
  18059. const width = imgData.width;
  18060. const height = imgData.height;
  18061. let bitDepth, colorType, lineSize;
  18062. const bytes = imgData.data;
  18063. switch (kind) {
  18064. case _util.ImageKind.GRAYSCALE_1BPP:
  18065. colorType = 0;
  18066. bitDepth = 1;
  18067. lineSize = width + 7 >> 3;
  18068. break;
  18069. case _util.ImageKind.RGB_24BPP:
  18070. colorType = 2;
  18071. bitDepth = 8;
  18072. lineSize = width * 3;
  18073. break;
  18074. case _util.ImageKind.RGBA_32BPP:
  18075. colorType = 6;
  18076. bitDepth = 8;
  18077. lineSize = width * 4;
  18078. break;
  18079. default:
  18080. throw new Error("invalid format");
  18081. }
  18082. const literals = new Uint8Array((1 + lineSize) * height);
  18083. let offsetLiterals = 0,
  18084. offsetBytes = 0;
  18085. for (let y = 0; y < height; ++y) {
  18086. literals[offsetLiterals++] = 0;
  18087. literals.set(bytes.subarray(offsetBytes, offsetBytes + lineSize), offsetLiterals);
  18088. offsetBytes += lineSize;
  18089. offsetLiterals += lineSize;
  18090. }
  18091. if (kind === _util.ImageKind.GRAYSCALE_1BPP && isMask) {
  18092. offsetLiterals = 0;
  18093. for (let y = 0; y < height; y++) {
  18094. offsetLiterals++;
  18095. for (let i = 0; i < lineSize; i++) {
  18096. literals[offsetLiterals++] ^= 0xff;
  18097. }
  18098. }
  18099. }
  18100. const ihdr = new Uint8Array([width >> 24 & 0xff, width >> 16 & 0xff, width >> 8 & 0xff, width & 0xff, height >> 24 & 0xff, height >> 16 & 0xff, height >> 8 & 0xff, height & 0xff, bitDepth, colorType, 0x00, 0x00, 0x00]);
  18101. const idat = deflateSync(literals);
  18102. const pngLength = PNG_HEADER.length + CHUNK_WRAPPER_SIZE * 3 + ihdr.length + idat.length;
  18103. const data = new Uint8Array(pngLength);
  18104. let offset = 0;
  18105. data.set(PNG_HEADER, offset);
  18106. offset += PNG_HEADER.length;
  18107. writePngChunk("IHDR", ihdr, data, offset);
  18108. offset += CHUNK_WRAPPER_SIZE + ihdr.length;
  18109. writePngChunk("IDATA", idat, data, offset);
  18110. offset += CHUNK_WRAPPER_SIZE + idat.length;
  18111. writePngChunk("IEND", new Uint8Array(0), data, offset);
  18112. return createObjectURL(data, "image/png", forceDataSchema);
  18113. }
  18114. return function convertImgDataToPng(imgData, forceDataSchema, isMask) {
  18115. const kind = imgData.kind === undefined ? _util.ImageKind.GRAYSCALE_1BPP : imgData.kind;
  18116. return encode(imgData, kind, forceDataSchema, isMask);
  18117. };
  18118. }();
  18119. class SVGExtraState {
  18120. constructor() {
  18121. this.fontSizeScale = 1;
  18122. this.fontWeight = SVG_DEFAULTS.fontWeight;
  18123. this.fontSize = 0;
  18124. this.textMatrix = _util.IDENTITY_MATRIX;
  18125. this.fontMatrix = _util.FONT_IDENTITY_MATRIX;
  18126. this.leading = 0;
  18127. this.textRenderingMode = _util.TextRenderingMode.FILL;
  18128. this.textMatrixScale = 1;
  18129. this.x = 0;
  18130. this.y = 0;
  18131. this.lineX = 0;
  18132. this.lineY = 0;
  18133. this.charSpacing = 0;
  18134. this.wordSpacing = 0;
  18135. this.textHScale = 1;
  18136. this.textRise = 0;
  18137. this.fillColor = SVG_DEFAULTS.fillColor;
  18138. this.strokeColor = "#000000";
  18139. this.fillAlpha = 1;
  18140. this.strokeAlpha = 1;
  18141. this.lineWidth = 1;
  18142. this.lineJoin = "";
  18143. this.lineCap = "";
  18144. this.miterLimit = 0;
  18145. this.dashArray = [];
  18146. this.dashPhase = 0;
  18147. this.dependencies = [];
  18148. this.activeClipUrl = null;
  18149. this.clipGroup = null;
  18150. this.maskId = "";
  18151. }
  18152. clone() {
  18153. return Object.create(this);
  18154. }
  18155. setCurrentPoint(x, y) {
  18156. this.x = x;
  18157. this.y = y;
  18158. }
  18159. }
  18160. function opListToTree(opList) {
  18161. let opTree = [];
  18162. const tmp = [];
  18163. for (const opListElement of opList) {
  18164. if (opListElement.fn === "save") {
  18165. opTree.push({
  18166. fnId: 92,
  18167. fn: "group",
  18168. items: []
  18169. });
  18170. tmp.push(opTree);
  18171. opTree = opTree.at(-1).items;
  18172. continue;
  18173. }
  18174. if (opListElement.fn === "restore") {
  18175. opTree = tmp.pop();
  18176. } else {
  18177. opTree.push(opListElement);
  18178. }
  18179. }
  18180. return opTree;
  18181. }
  18182. function pf(value) {
  18183. if (Number.isInteger(value)) {
  18184. return value.toString();
  18185. }
  18186. const s = value.toFixed(10);
  18187. let i = s.length - 1;
  18188. if (s[i] !== "0") {
  18189. return s;
  18190. }
  18191. do {
  18192. i--;
  18193. } while (s[i] === "0");
  18194. return s.substring(0, s[i] === "." ? i : i + 1);
  18195. }
  18196. function pm(m) {
  18197. if (m[4] === 0 && m[5] === 0) {
  18198. if (m[1] === 0 && m[2] === 0) {
  18199. if (m[0] === 1 && m[3] === 1) {
  18200. return "";
  18201. }
  18202. return `scale(${pf(m[0])} ${pf(m[3])})`;
  18203. }
  18204. if (m[0] === m[3] && m[1] === -m[2]) {
  18205. const a = Math.acos(m[0]) * 180 / Math.PI;
  18206. return `rotate(${pf(a)})`;
  18207. }
  18208. } else {
  18209. if (m[0] === 1 && m[1] === 0 && m[2] === 0 && m[3] === 1) {
  18210. return `translate(${pf(m[4])} ${pf(m[5])})`;
  18211. }
  18212. }
  18213. return `matrix(${pf(m[0])} ${pf(m[1])} ${pf(m[2])} ${pf(m[3])} ${pf(m[4])} ` + `${pf(m[5])})`;
  18214. }
  18215. let clipCount = 0;
  18216. let maskCount = 0;
  18217. let shadingCount = 0;
  18218. exports.SVGGraphics = SVGGraphics = class {
  18219. constructor(commonObjs, objs) {
  18220. let forceDataSchema = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  18221. (0, _display_utils.deprecated)("The SVG back-end is no longer maintained and *may* be removed in the future.");
  18222. this.svgFactory = new _display_utils.DOMSVGFactory();
  18223. this.current = new SVGExtraState();
  18224. this.transformMatrix = _util.IDENTITY_MATRIX;
  18225. this.transformStack = [];
  18226. this.extraStack = [];
  18227. this.commonObjs = commonObjs;
  18228. this.objs = objs;
  18229. this.pendingClip = null;
  18230. this.pendingEOFill = false;
  18231. this.embedFonts = false;
  18232. this.embeddedFonts = Object.create(null);
  18233. this.cssStyle = null;
  18234. this.forceDataSchema = !!forceDataSchema;
  18235. this._operatorIdMapping = [];
  18236. for (const op in _util.OPS) {
  18237. this._operatorIdMapping[_util.OPS[op]] = op;
  18238. }
  18239. }
  18240. getObject(data) {
  18241. let fallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  18242. if (typeof data === "string") {
  18243. return data.startsWith("g_") ? this.commonObjs.get(data) : this.objs.get(data);
  18244. }
  18245. return fallback;
  18246. }
  18247. save() {
  18248. this.transformStack.push(this.transformMatrix);
  18249. const old = this.current;
  18250. this.extraStack.push(old);
  18251. this.current = old.clone();
  18252. }
  18253. restore() {
  18254. this.transformMatrix = this.transformStack.pop();
  18255. this.current = this.extraStack.pop();
  18256. this.pendingClip = null;
  18257. this.tgrp = null;
  18258. }
  18259. group(items) {
  18260. this.save();
  18261. this.executeOpTree(items);
  18262. this.restore();
  18263. }
  18264. loadDependencies(operatorList) {
  18265. const fnArray = operatorList.fnArray;
  18266. const argsArray = operatorList.argsArray;
  18267. for (let i = 0, ii = fnArray.length; i < ii; i++) {
  18268. if (fnArray[i] !== _util.OPS.dependency) {
  18269. continue;
  18270. }
  18271. for (const obj of argsArray[i]) {
  18272. const objsPool = obj.startsWith("g_") ? this.commonObjs : this.objs;
  18273. const promise = new Promise(resolve => {
  18274. objsPool.get(obj, resolve);
  18275. });
  18276. this.current.dependencies.push(promise);
  18277. }
  18278. }
  18279. return Promise.all(this.current.dependencies);
  18280. }
  18281. transform(a, b, c, d, e, f) {
  18282. const transformMatrix = [a, b, c, d, e, f];
  18283. this.transformMatrix = _util.Util.transform(this.transformMatrix, transformMatrix);
  18284. this.tgrp = null;
  18285. }
  18286. getSVG(operatorList, viewport) {
  18287. this.viewport = viewport;
  18288. const svgElement = this._initialize(viewport);
  18289. return this.loadDependencies(operatorList).then(() => {
  18290. this.transformMatrix = _util.IDENTITY_MATRIX;
  18291. this.executeOpTree(this.convertOpList(operatorList));
  18292. return svgElement;
  18293. });
  18294. }
  18295. convertOpList(operatorList) {
  18296. const operatorIdMapping = this._operatorIdMapping;
  18297. const argsArray = operatorList.argsArray;
  18298. const fnArray = operatorList.fnArray;
  18299. const opList = [];
  18300. for (let i = 0, ii = fnArray.length; i < ii; i++) {
  18301. const fnId = fnArray[i];
  18302. opList.push({
  18303. fnId,
  18304. fn: operatorIdMapping[fnId],
  18305. args: argsArray[i]
  18306. });
  18307. }
  18308. return opListToTree(opList);
  18309. }
  18310. executeOpTree(opTree) {
  18311. for (const opTreeElement of opTree) {
  18312. const fn = opTreeElement.fn;
  18313. const fnId = opTreeElement.fnId;
  18314. const args = opTreeElement.args;
  18315. switch (fnId | 0) {
  18316. case _util.OPS.beginText:
  18317. this.beginText();
  18318. break;
  18319. case _util.OPS.dependency:
  18320. break;
  18321. case _util.OPS.setLeading:
  18322. this.setLeading(args);
  18323. break;
  18324. case _util.OPS.setLeadingMoveText:
  18325. this.setLeadingMoveText(args[0], args[1]);
  18326. break;
  18327. case _util.OPS.setFont:
  18328. this.setFont(args);
  18329. break;
  18330. case _util.OPS.showText:
  18331. this.showText(args[0]);
  18332. break;
  18333. case _util.OPS.showSpacedText:
  18334. this.showText(args[0]);
  18335. break;
  18336. case _util.OPS.endText:
  18337. this.endText();
  18338. break;
  18339. case _util.OPS.moveText:
  18340. this.moveText(args[0], args[1]);
  18341. break;
  18342. case _util.OPS.setCharSpacing:
  18343. this.setCharSpacing(args[0]);
  18344. break;
  18345. case _util.OPS.setWordSpacing:
  18346. this.setWordSpacing(args[0]);
  18347. break;
  18348. case _util.OPS.setHScale:
  18349. this.setHScale(args[0]);
  18350. break;
  18351. case _util.OPS.setTextMatrix:
  18352. this.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  18353. break;
  18354. case _util.OPS.setTextRise:
  18355. this.setTextRise(args[0]);
  18356. break;
  18357. case _util.OPS.setTextRenderingMode:
  18358. this.setTextRenderingMode(args[0]);
  18359. break;
  18360. case _util.OPS.setLineWidth:
  18361. this.setLineWidth(args[0]);
  18362. break;
  18363. case _util.OPS.setLineJoin:
  18364. this.setLineJoin(args[0]);
  18365. break;
  18366. case _util.OPS.setLineCap:
  18367. this.setLineCap(args[0]);
  18368. break;
  18369. case _util.OPS.setMiterLimit:
  18370. this.setMiterLimit(args[0]);
  18371. break;
  18372. case _util.OPS.setFillRGBColor:
  18373. this.setFillRGBColor(args[0], args[1], args[2]);
  18374. break;
  18375. case _util.OPS.setStrokeRGBColor:
  18376. this.setStrokeRGBColor(args[0], args[1], args[2]);
  18377. break;
  18378. case _util.OPS.setStrokeColorN:
  18379. this.setStrokeColorN(args);
  18380. break;
  18381. case _util.OPS.setFillColorN:
  18382. this.setFillColorN(args);
  18383. break;
  18384. case _util.OPS.shadingFill:
  18385. this.shadingFill(args[0]);
  18386. break;
  18387. case _util.OPS.setDash:
  18388. this.setDash(args[0], args[1]);
  18389. break;
  18390. case _util.OPS.setRenderingIntent:
  18391. this.setRenderingIntent(args[0]);
  18392. break;
  18393. case _util.OPS.setFlatness:
  18394. this.setFlatness(args[0]);
  18395. break;
  18396. case _util.OPS.setGState:
  18397. this.setGState(args[0]);
  18398. break;
  18399. case _util.OPS.fill:
  18400. this.fill();
  18401. break;
  18402. case _util.OPS.eoFill:
  18403. this.eoFill();
  18404. break;
  18405. case _util.OPS.stroke:
  18406. this.stroke();
  18407. break;
  18408. case _util.OPS.fillStroke:
  18409. this.fillStroke();
  18410. break;
  18411. case _util.OPS.eoFillStroke:
  18412. this.eoFillStroke();
  18413. break;
  18414. case _util.OPS.clip:
  18415. this.clip("nonzero");
  18416. break;
  18417. case _util.OPS.eoClip:
  18418. this.clip("evenodd");
  18419. break;
  18420. case _util.OPS.paintSolidColorImageMask:
  18421. this.paintSolidColorImageMask();
  18422. break;
  18423. case _util.OPS.paintImageXObject:
  18424. this.paintImageXObject(args[0]);
  18425. break;
  18426. case _util.OPS.paintInlineImageXObject:
  18427. this.paintInlineImageXObject(args[0]);
  18428. break;
  18429. case _util.OPS.paintImageMaskXObject:
  18430. this.paintImageMaskXObject(args[0]);
  18431. break;
  18432. case _util.OPS.paintFormXObjectBegin:
  18433. this.paintFormXObjectBegin(args[0], args[1]);
  18434. break;
  18435. case _util.OPS.paintFormXObjectEnd:
  18436. this.paintFormXObjectEnd();
  18437. break;
  18438. case _util.OPS.closePath:
  18439. this.closePath();
  18440. break;
  18441. case _util.OPS.closeStroke:
  18442. this.closeStroke();
  18443. break;
  18444. case _util.OPS.closeFillStroke:
  18445. this.closeFillStroke();
  18446. break;
  18447. case _util.OPS.closeEOFillStroke:
  18448. this.closeEOFillStroke();
  18449. break;
  18450. case _util.OPS.nextLine:
  18451. this.nextLine();
  18452. break;
  18453. case _util.OPS.transform:
  18454. this.transform(args[0], args[1], args[2], args[3], args[4], args[5]);
  18455. break;
  18456. case _util.OPS.constructPath:
  18457. this.constructPath(args[0], args[1]);
  18458. break;
  18459. case _util.OPS.endPath:
  18460. this.endPath();
  18461. break;
  18462. case 92:
  18463. this.group(opTreeElement.items);
  18464. break;
  18465. default:
  18466. (0, _util.warn)(`Unimplemented operator ${fn}`);
  18467. break;
  18468. }
  18469. }
  18470. }
  18471. setWordSpacing(wordSpacing) {
  18472. this.current.wordSpacing = wordSpacing;
  18473. }
  18474. setCharSpacing(charSpacing) {
  18475. this.current.charSpacing = charSpacing;
  18476. }
  18477. nextLine() {
  18478. this.moveText(0, this.current.leading);
  18479. }
  18480. setTextMatrix(a, b, c, d, e, f) {
  18481. const current = this.current;
  18482. current.textMatrix = current.lineMatrix = [a, b, c, d, e, f];
  18483. current.textMatrixScale = Math.hypot(a, b);
  18484. current.x = current.lineX = 0;
  18485. current.y = current.lineY = 0;
  18486. current.xcoords = [];
  18487. current.ycoords = [];
  18488. current.tspan = this.svgFactory.createElement("svg:tspan");
  18489. current.tspan.setAttributeNS(null, "font-family", current.fontFamily);
  18490. current.tspan.setAttributeNS(null, "font-size", `${pf(current.fontSize)}px`);
  18491. current.tspan.setAttributeNS(null, "y", pf(-current.y));
  18492. current.txtElement = this.svgFactory.createElement("svg:text");
  18493. current.txtElement.append(current.tspan);
  18494. }
  18495. beginText() {
  18496. const current = this.current;
  18497. current.x = current.lineX = 0;
  18498. current.y = current.lineY = 0;
  18499. current.textMatrix = _util.IDENTITY_MATRIX;
  18500. current.lineMatrix = _util.IDENTITY_MATRIX;
  18501. current.textMatrixScale = 1;
  18502. current.tspan = this.svgFactory.createElement("svg:tspan");
  18503. current.txtElement = this.svgFactory.createElement("svg:text");
  18504. current.txtgrp = this.svgFactory.createElement("svg:g");
  18505. current.xcoords = [];
  18506. current.ycoords = [];
  18507. }
  18508. moveText(x, y) {
  18509. const current = this.current;
  18510. current.x = current.lineX += x;
  18511. current.y = current.lineY += y;
  18512. current.xcoords = [];
  18513. current.ycoords = [];
  18514. current.tspan = this.svgFactory.createElement("svg:tspan");
  18515. current.tspan.setAttributeNS(null, "font-family", current.fontFamily);
  18516. current.tspan.setAttributeNS(null, "font-size", `${pf(current.fontSize)}px`);
  18517. current.tspan.setAttributeNS(null, "y", pf(-current.y));
  18518. }
  18519. showText(glyphs) {
  18520. const current = this.current;
  18521. const font = current.font;
  18522. const fontSize = current.fontSize;
  18523. if (fontSize === 0) {
  18524. return;
  18525. }
  18526. const fontSizeScale = current.fontSizeScale;
  18527. const charSpacing = current.charSpacing;
  18528. const wordSpacing = current.wordSpacing;
  18529. const fontDirection = current.fontDirection;
  18530. const textHScale = current.textHScale * fontDirection;
  18531. const vertical = font.vertical;
  18532. const spacingDir = vertical ? 1 : -1;
  18533. const defaultVMetrics = font.defaultVMetrics;
  18534. const widthAdvanceScale = fontSize * current.fontMatrix[0];
  18535. let x = 0;
  18536. for (const glyph of glyphs) {
  18537. if (glyph === null) {
  18538. x += fontDirection * wordSpacing;
  18539. continue;
  18540. } else if (typeof glyph === "number") {
  18541. x += spacingDir * glyph * fontSize / 1000;
  18542. continue;
  18543. }
  18544. const spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  18545. const character = glyph.fontChar;
  18546. let scaledX, scaledY;
  18547. let width = glyph.width;
  18548. if (vertical) {
  18549. let vx;
  18550. const vmetric = glyph.vmetric || defaultVMetrics;
  18551. vx = glyph.vmetric ? vmetric[1] : width * 0.5;
  18552. vx = -vx * widthAdvanceScale;
  18553. const vy = vmetric[2] * widthAdvanceScale;
  18554. width = vmetric ? -vmetric[0] : width;
  18555. scaledX = vx / fontSizeScale;
  18556. scaledY = (x + vy) / fontSizeScale;
  18557. } else {
  18558. scaledX = x / fontSizeScale;
  18559. scaledY = 0;
  18560. }
  18561. if (glyph.isInFont || font.missingFile) {
  18562. current.xcoords.push(current.x + scaledX);
  18563. if (vertical) {
  18564. current.ycoords.push(-current.y + scaledY);
  18565. }
  18566. current.tspan.textContent += character;
  18567. } else {}
  18568. let charWidth;
  18569. if (vertical) {
  18570. charWidth = width * widthAdvanceScale - spacing * fontDirection;
  18571. } else {
  18572. charWidth = width * widthAdvanceScale + spacing * fontDirection;
  18573. }
  18574. x += charWidth;
  18575. }
  18576. current.tspan.setAttributeNS(null, "x", current.xcoords.map(pf).join(" "));
  18577. if (vertical) {
  18578. current.tspan.setAttributeNS(null, "y", current.ycoords.map(pf).join(" "));
  18579. } else {
  18580. current.tspan.setAttributeNS(null, "y", pf(-current.y));
  18581. }
  18582. if (vertical) {
  18583. current.y -= x;
  18584. } else {
  18585. current.x += x * textHScale;
  18586. }
  18587. current.tspan.setAttributeNS(null, "font-family", current.fontFamily);
  18588. current.tspan.setAttributeNS(null, "font-size", `${pf(current.fontSize)}px`);
  18589. if (current.fontStyle !== SVG_DEFAULTS.fontStyle) {
  18590. current.tspan.setAttributeNS(null, "font-style", current.fontStyle);
  18591. }
  18592. if (current.fontWeight !== SVG_DEFAULTS.fontWeight) {
  18593. current.tspan.setAttributeNS(null, "font-weight", current.fontWeight);
  18594. }
  18595. const fillStrokeMode = current.textRenderingMode & _util.TextRenderingMode.FILL_STROKE_MASK;
  18596. if (fillStrokeMode === _util.TextRenderingMode.FILL || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
  18597. if (current.fillColor !== SVG_DEFAULTS.fillColor) {
  18598. current.tspan.setAttributeNS(null, "fill", current.fillColor);
  18599. }
  18600. if (current.fillAlpha < 1) {
  18601. current.tspan.setAttributeNS(null, "fill-opacity", current.fillAlpha);
  18602. }
  18603. } else if (current.textRenderingMode === _util.TextRenderingMode.ADD_TO_PATH) {
  18604. current.tspan.setAttributeNS(null, "fill", "transparent");
  18605. } else {
  18606. current.tspan.setAttributeNS(null, "fill", "none");
  18607. }
  18608. if (fillStrokeMode === _util.TextRenderingMode.STROKE || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
  18609. const lineWidthScale = 1 / (current.textMatrixScale || 1);
  18610. this._setStrokeAttributes(current.tspan, lineWidthScale);
  18611. }
  18612. let textMatrix = current.textMatrix;
  18613. if (current.textRise !== 0) {
  18614. textMatrix = textMatrix.slice();
  18615. textMatrix[5] += current.textRise;
  18616. }
  18617. current.txtElement.setAttributeNS(null, "transform", `${pm(textMatrix)} scale(${pf(textHScale)}, -1)`);
  18618. current.txtElement.setAttributeNS(XML_NS, "xml:space", "preserve");
  18619. current.txtElement.append(current.tspan);
  18620. current.txtgrp.append(current.txtElement);
  18621. this._ensureTransformGroup().append(current.txtElement);
  18622. }
  18623. setLeadingMoveText(x, y) {
  18624. this.setLeading(-y);
  18625. this.moveText(x, y);
  18626. }
  18627. addFontStyle(fontObj) {
  18628. if (!fontObj.data) {
  18629. throw new Error("addFontStyle: No font data available, " + 'ensure that the "fontExtraProperties" API parameter is set.');
  18630. }
  18631. if (!this.cssStyle) {
  18632. this.cssStyle = this.svgFactory.createElement("svg:style");
  18633. this.cssStyle.setAttributeNS(null, "type", "text/css");
  18634. this.defs.append(this.cssStyle);
  18635. }
  18636. const url = createObjectURL(fontObj.data, fontObj.mimetype, this.forceDataSchema);
  18637. this.cssStyle.textContent += `@font-face { font-family: "${fontObj.loadedName}";` + ` src: url(${url}); }\n`;
  18638. }
  18639. setFont(details) {
  18640. const current = this.current;
  18641. const fontObj = this.commonObjs.get(details[0]);
  18642. let size = details[1];
  18643. current.font = fontObj;
  18644. if (this.embedFonts && !fontObj.missingFile && !this.embeddedFonts[fontObj.loadedName]) {
  18645. this.addFontStyle(fontObj);
  18646. this.embeddedFonts[fontObj.loadedName] = fontObj;
  18647. }
  18648. current.fontMatrix = fontObj.fontMatrix || _util.FONT_IDENTITY_MATRIX;
  18649. let bold = "normal";
  18650. if (fontObj.black) {
  18651. bold = "900";
  18652. } else if (fontObj.bold) {
  18653. bold = "bold";
  18654. }
  18655. const italic = fontObj.italic ? "italic" : "normal";
  18656. if (size < 0) {
  18657. size = -size;
  18658. current.fontDirection = -1;
  18659. } else {
  18660. current.fontDirection = 1;
  18661. }
  18662. current.fontSize = size;
  18663. current.fontFamily = fontObj.loadedName;
  18664. current.fontWeight = bold;
  18665. current.fontStyle = italic;
  18666. current.tspan = this.svgFactory.createElement("svg:tspan");
  18667. current.tspan.setAttributeNS(null, "y", pf(-current.y));
  18668. current.xcoords = [];
  18669. current.ycoords = [];
  18670. }
  18671. endText() {
  18672. var _current$txtElement;
  18673. const current = this.current;
  18674. if (current.textRenderingMode & _util.TextRenderingMode.ADD_TO_PATH_FLAG && (_current$txtElement = current.txtElement) !== null && _current$txtElement !== void 0 && _current$txtElement.hasChildNodes()) {
  18675. current.element = current.txtElement;
  18676. this.clip("nonzero");
  18677. this.endPath();
  18678. }
  18679. }
  18680. setLineWidth(width) {
  18681. if (width > 0) {
  18682. this.current.lineWidth = width;
  18683. }
  18684. }
  18685. setLineCap(style) {
  18686. this.current.lineCap = LINE_CAP_STYLES[style];
  18687. }
  18688. setLineJoin(style) {
  18689. this.current.lineJoin = LINE_JOIN_STYLES[style];
  18690. }
  18691. setMiterLimit(limit) {
  18692. this.current.miterLimit = limit;
  18693. }
  18694. setStrokeAlpha(strokeAlpha) {
  18695. this.current.strokeAlpha = strokeAlpha;
  18696. }
  18697. setStrokeRGBColor(r, g, b) {
  18698. this.current.strokeColor = _util.Util.makeHexColor(r, g, b);
  18699. }
  18700. setFillAlpha(fillAlpha) {
  18701. this.current.fillAlpha = fillAlpha;
  18702. }
  18703. setFillRGBColor(r, g, b) {
  18704. this.current.fillColor = _util.Util.makeHexColor(r, g, b);
  18705. this.current.tspan = this.svgFactory.createElement("svg:tspan");
  18706. this.current.xcoords = [];
  18707. this.current.ycoords = [];
  18708. }
  18709. setStrokeColorN(args) {
  18710. this.current.strokeColor = this._makeColorN_Pattern(args);
  18711. }
  18712. setFillColorN(args) {
  18713. this.current.fillColor = this._makeColorN_Pattern(args);
  18714. }
  18715. shadingFill(args) {
  18716. const width = this.viewport.width;
  18717. const height = this.viewport.height;
  18718. const inv = _util.Util.inverseTransform(this.transformMatrix);
  18719. const bl = _util.Util.applyTransform([0, 0], inv);
  18720. const br = _util.Util.applyTransform([0, height], inv);
  18721. const ul = _util.Util.applyTransform([width, 0], inv);
  18722. const ur = _util.Util.applyTransform([width, height], inv);
  18723. const x0 = Math.min(bl[0], br[0], ul[0], ur[0]);
  18724. const y0 = Math.min(bl[1], br[1], ul[1], ur[1]);
  18725. const x1 = Math.max(bl[0], br[0], ul[0], ur[0]);
  18726. const y1 = Math.max(bl[1], br[1], ul[1], ur[1]);
  18727. const rect = this.svgFactory.createElement("svg:rect");
  18728. rect.setAttributeNS(null, "x", x0);
  18729. rect.setAttributeNS(null, "y", y0);
  18730. rect.setAttributeNS(null, "width", x1 - x0);
  18731. rect.setAttributeNS(null, "height", y1 - y0);
  18732. rect.setAttributeNS(null, "fill", this._makeShadingPattern(args));
  18733. if (this.current.fillAlpha < 1) {
  18734. rect.setAttributeNS(null, "fill-opacity", this.current.fillAlpha);
  18735. }
  18736. this._ensureTransformGroup().append(rect);
  18737. }
  18738. _makeColorN_Pattern(args) {
  18739. if (args[0] === "TilingPattern") {
  18740. return this._makeTilingPattern(args);
  18741. }
  18742. return this._makeShadingPattern(args);
  18743. }
  18744. _makeTilingPattern(args) {
  18745. const color = args[1];
  18746. const operatorList = args[2];
  18747. const matrix = args[3] || _util.IDENTITY_MATRIX;
  18748. const [x0, y0, x1, y1] = args[4];
  18749. const xstep = args[5];
  18750. const ystep = args[6];
  18751. const paintType = args[7];
  18752. const tilingId = `shading${shadingCount++}`;
  18753. const [tx0, ty0, tx1, ty1] = _util.Util.normalizeRect([..._util.Util.applyTransform([x0, y0], matrix), ..._util.Util.applyTransform([x1, y1], matrix)]);
  18754. const [xscale, yscale] = _util.Util.singularValueDecompose2dScale(matrix);
  18755. const txstep = xstep * xscale;
  18756. const tystep = ystep * yscale;
  18757. const tiling = this.svgFactory.createElement("svg:pattern");
  18758. tiling.setAttributeNS(null, "id", tilingId);
  18759. tiling.setAttributeNS(null, "patternUnits", "userSpaceOnUse");
  18760. tiling.setAttributeNS(null, "width", txstep);
  18761. tiling.setAttributeNS(null, "height", tystep);
  18762. tiling.setAttributeNS(null, "x", `${tx0}`);
  18763. tiling.setAttributeNS(null, "y", `${ty0}`);
  18764. const svg = this.svg;
  18765. const transformMatrix = this.transformMatrix;
  18766. const fillColor = this.current.fillColor;
  18767. const strokeColor = this.current.strokeColor;
  18768. const bbox = this.svgFactory.create(tx1 - tx0, ty1 - ty0);
  18769. this.svg = bbox;
  18770. this.transformMatrix = matrix;
  18771. if (paintType === 2) {
  18772. const cssColor = _util.Util.makeHexColor(...color);
  18773. this.current.fillColor = cssColor;
  18774. this.current.strokeColor = cssColor;
  18775. }
  18776. this.executeOpTree(this.convertOpList(operatorList));
  18777. this.svg = svg;
  18778. this.transformMatrix = transformMatrix;
  18779. this.current.fillColor = fillColor;
  18780. this.current.strokeColor = strokeColor;
  18781. tiling.append(bbox.childNodes[0]);
  18782. this.defs.append(tiling);
  18783. return `url(#${tilingId})`;
  18784. }
  18785. _makeShadingPattern(args) {
  18786. if (typeof args === "string") {
  18787. args = this.objs.get(args);
  18788. }
  18789. switch (args[0]) {
  18790. case "RadialAxial":
  18791. const shadingId = `shading${shadingCount++}`;
  18792. const colorStops = args[3];
  18793. let gradient;
  18794. switch (args[1]) {
  18795. case "axial":
  18796. const point0 = args[4];
  18797. const point1 = args[5];
  18798. gradient = this.svgFactory.createElement("svg:linearGradient");
  18799. gradient.setAttributeNS(null, "id", shadingId);
  18800. gradient.setAttributeNS(null, "gradientUnits", "userSpaceOnUse");
  18801. gradient.setAttributeNS(null, "x1", point0[0]);
  18802. gradient.setAttributeNS(null, "y1", point0[1]);
  18803. gradient.setAttributeNS(null, "x2", point1[0]);
  18804. gradient.setAttributeNS(null, "y2", point1[1]);
  18805. break;
  18806. case "radial":
  18807. const focalPoint = args[4];
  18808. const circlePoint = args[5];
  18809. const focalRadius = args[6];
  18810. const circleRadius = args[7];
  18811. gradient = this.svgFactory.createElement("svg:radialGradient");
  18812. gradient.setAttributeNS(null, "id", shadingId);
  18813. gradient.setAttributeNS(null, "gradientUnits", "userSpaceOnUse");
  18814. gradient.setAttributeNS(null, "cx", circlePoint[0]);
  18815. gradient.setAttributeNS(null, "cy", circlePoint[1]);
  18816. gradient.setAttributeNS(null, "r", circleRadius);
  18817. gradient.setAttributeNS(null, "fx", focalPoint[0]);
  18818. gradient.setAttributeNS(null, "fy", focalPoint[1]);
  18819. gradient.setAttributeNS(null, "fr", focalRadius);
  18820. break;
  18821. default:
  18822. throw new Error(`Unknown RadialAxial type: ${args[1]}`);
  18823. }
  18824. for (const colorStop of colorStops) {
  18825. const stop = this.svgFactory.createElement("svg:stop");
  18826. stop.setAttributeNS(null, "offset", colorStop[0]);
  18827. stop.setAttributeNS(null, "stop-color", colorStop[1]);
  18828. gradient.append(stop);
  18829. }
  18830. this.defs.append(gradient);
  18831. return `url(#${shadingId})`;
  18832. case "Mesh":
  18833. (0, _util.warn)("Unimplemented pattern Mesh");
  18834. return null;
  18835. case "Dummy":
  18836. return "hotpink";
  18837. default:
  18838. throw new Error(`Unknown IR type: ${args[0]}`);
  18839. }
  18840. }
  18841. setDash(dashArray, dashPhase) {
  18842. this.current.dashArray = dashArray;
  18843. this.current.dashPhase = dashPhase;
  18844. }
  18845. constructPath(ops, args) {
  18846. const current = this.current;
  18847. let x = current.x,
  18848. y = current.y;
  18849. let d = [];
  18850. let j = 0;
  18851. for (const op of ops) {
  18852. switch (op | 0) {
  18853. case _util.OPS.rectangle:
  18854. x = args[j++];
  18855. y = args[j++];
  18856. const width = args[j++];
  18857. const height = args[j++];
  18858. const xw = x + width;
  18859. const yh = y + height;
  18860. d.push("M", pf(x), pf(y), "L", pf(xw), pf(y), "L", pf(xw), pf(yh), "L", pf(x), pf(yh), "Z");
  18861. break;
  18862. case _util.OPS.moveTo:
  18863. x = args[j++];
  18864. y = args[j++];
  18865. d.push("M", pf(x), pf(y));
  18866. break;
  18867. case _util.OPS.lineTo:
  18868. x = args[j++];
  18869. y = args[j++];
  18870. d.push("L", pf(x), pf(y));
  18871. break;
  18872. case _util.OPS.curveTo:
  18873. x = args[j + 4];
  18874. y = args[j + 5];
  18875. d.push("C", pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]), pf(x), pf(y));
  18876. j += 6;
  18877. break;
  18878. case _util.OPS.curveTo2:
  18879. d.push("C", pf(x), pf(y), pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]));
  18880. x = args[j + 2];
  18881. y = args[j + 3];
  18882. j += 4;
  18883. break;
  18884. case _util.OPS.curveTo3:
  18885. x = args[j + 2];
  18886. y = args[j + 3];
  18887. d.push("C", pf(args[j]), pf(args[j + 1]), pf(x), pf(y), pf(x), pf(y));
  18888. j += 4;
  18889. break;
  18890. case _util.OPS.closePath:
  18891. d.push("Z");
  18892. break;
  18893. }
  18894. }
  18895. d = d.join(" ");
  18896. if (current.path && ops.length > 0 && ops[0] !== _util.OPS.rectangle && ops[0] !== _util.OPS.moveTo) {
  18897. d = current.path.getAttributeNS(null, "d") + d;
  18898. } else {
  18899. current.path = this.svgFactory.createElement("svg:path");
  18900. this._ensureTransformGroup().append(current.path);
  18901. }
  18902. current.path.setAttributeNS(null, "d", d);
  18903. current.path.setAttributeNS(null, "fill", "none");
  18904. current.element = current.path;
  18905. current.setCurrentPoint(x, y);
  18906. }
  18907. endPath() {
  18908. const current = this.current;
  18909. current.path = null;
  18910. if (!this.pendingClip) {
  18911. return;
  18912. }
  18913. if (!current.element) {
  18914. this.pendingClip = null;
  18915. return;
  18916. }
  18917. const clipId = `clippath${clipCount++}`;
  18918. const clipPath = this.svgFactory.createElement("svg:clipPath");
  18919. clipPath.setAttributeNS(null, "id", clipId);
  18920. clipPath.setAttributeNS(null, "transform", pm(this.transformMatrix));
  18921. const clipElement = current.element.cloneNode(true);
  18922. if (this.pendingClip === "evenodd") {
  18923. clipElement.setAttributeNS(null, "clip-rule", "evenodd");
  18924. } else {
  18925. clipElement.setAttributeNS(null, "clip-rule", "nonzero");
  18926. }
  18927. this.pendingClip = null;
  18928. clipPath.append(clipElement);
  18929. this.defs.append(clipPath);
  18930. if (current.activeClipUrl) {
  18931. current.clipGroup = null;
  18932. for (const prev of this.extraStack) {
  18933. prev.clipGroup = null;
  18934. }
  18935. clipPath.setAttributeNS(null, "clip-path", current.activeClipUrl);
  18936. }
  18937. current.activeClipUrl = `url(#${clipId})`;
  18938. this.tgrp = null;
  18939. }
  18940. clip(type) {
  18941. this.pendingClip = type;
  18942. }
  18943. closePath() {
  18944. const current = this.current;
  18945. if (current.path) {
  18946. const d = `${current.path.getAttributeNS(null, "d")}Z`;
  18947. current.path.setAttributeNS(null, "d", d);
  18948. }
  18949. }
  18950. setLeading(leading) {
  18951. this.current.leading = -leading;
  18952. }
  18953. setTextRise(textRise) {
  18954. this.current.textRise = textRise;
  18955. }
  18956. setTextRenderingMode(textRenderingMode) {
  18957. this.current.textRenderingMode = textRenderingMode;
  18958. }
  18959. setHScale(scale) {
  18960. this.current.textHScale = scale / 100;
  18961. }
  18962. setRenderingIntent(intent) {}
  18963. setFlatness(flatness) {}
  18964. setGState(states) {
  18965. for (const [key, value] of states) {
  18966. switch (key) {
  18967. case "LW":
  18968. this.setLineWidth(value);
  18969. break;
  18970. case "LC":
  18971. this.setLineCap(value);
  18972. break;
  18973. case "LJ":
  18974. this.setLineJoin(value);
  18975. break;
  18976. case "ML":
  18977. this.setMiterLimit(value);
  18978. break;
  18979. case "D":
  18980. this.setDash(value[0], value[1]);
  18981. break;
  18982. case "RI":
  18983. this.setRenderingIntent(value);
  18984. break;
  18985. case "FL":
  18986. this.setFlatness(value);
  18987. break;
  18988. case "Font":
  18989. this.setFont(value);
  18990. break;
  18991. case "CA":
  18992. this.setStrokeAlpha(value);
  18993. break;
  18994. case "ca":
  18995. this.setFillAlpha(value);
  18996. break;
  18997. default:
  18998. (0, _util.warn)(`Unimplemented graphic state operator ${key}`);
  18999. break;
  19000. }
  19001. }
  19002. }
  19003. fill() {
  19004. const current = this.current;
  19005. if (current.element) {
  19006. current.element.setAttributeNS(null, "fill", current.fillColor);
  19007. current.element.setAttributeNS(null, "fill-opacity", current.fillAlpha);
  19008. this.endPath();
  19009. }
  19010. }
  19011. stroke() {
  19012. const current = this.current;
  19013. if (current.element) {
  19014. this._setStrokeAttributes(current.element);
  19015. current.element.setAttributeNS(null, "fill", "none");
  19016. this.endPath();
  19017. }
  19018. }
  19019. _setStrokeAttributes(element) {
  19020. let lineWidthScale = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
  19021. const current = this.current;
  19022. let dashArray = current.dashArray;
  19023. if (lineWidthScale !== 1 && dashArray.length > 0) {
  19024. dashArray = dashArray.map(function (value) {
  19025. return lineWidthScale * value;
  19026. });
  19027. }
  19028. element.setAttributeNS(null, "stroke", current.strokeColor);
  19029. element.setAttributeNS(null, "stroke-opacity", current.strokeAlpha);
  19030. element.setAttributeNS(null, "stroke-miterlimit", pf(current.miterLimit));
  19031. element.setAttributeNS(null, "stroke-linecap", current.lineCap);
  19032. element.setAttributeNS(null, "stroke-linejoin", current.lineJoin);
  19033. element.setAttributeNS(null, "stroke-width", pf(lineWidthScale * current.lineWidth) + "px");
  19034. element.setAttributeNS(null, "stroke-dasharray", dashArray.map(pf).join(" "));
  19035. element.setAttributeNS(null, "stroke-dashoffset", pf(lineWidthScale * current.dashPhase) + "px");
  19036. }
  19037. eoFill() {
  19038. var _this$current$element;
  19039. (_this$current$element = this.current.element) === null || _this$current$element === void 0 ? void 0 : _this$current$element.setAttributeNS(null, "fill-rule", "evenodd");
  19040. this.fill();
  19041. }
  19042. fillStroke() {
  19043. this.stroke();
  19044. this.fill();
  19045. }
  19046. eoFillStroke() {
  19047. var _this$current$element2;
  19048. (_this$current$element2 = this.current.element) === null || _this$current$element2 === void 0 ? void 0 : _this$current$element2.setAttributeNS(null, "fill-rule", "evenodd");
  19049. this.fillStroke();
  19050. }
  19051. closeStroke() {
  19052. this.closePath();
  19053. this.stroke();
  19054. }
  19055. closeFillStroke() {
  19056. this.closePath();
  19057. this.fillStroke();
  19058. }
  19059. closeEOFillStroke() {
  19060. this.closePath();
  19061. this.eoFillStroke();
  19062. }
  19063. paintSolidColorImageMask() {
  19064. const rect = this.svgFactory.createElement("svg:rect");
  19065. rect.setAttributeNS(null, "x", "0");
  19066. rect.setAttributeNS(null, "y", "0");
  19067. rect.setAttributeNS(null, "width", "1px");
  19068. rect.setAttributeNS(null, "height", "1px");
  19069. rect.setAttributeNS(null, "fill", this.current.fillColor);
  19070. this._ensureTransformGroup().append(rect);
  19071. }
  19072. paintImageXObject(objId) {
  19073. const imgData = this.getObject(objId);
  19074. if (!imgData) {
  19075. (0, _util.warn)(`Dependent image with object ID ${objId} is not ready yet`);
  19076. return;
  19077. }
  19078. this.paintInlineImageXObject(imgData);
  19079. }
  19080. paintInlineImageXObject(imgData, mask) {
  19081. const width = imgData.width;
  19082. const height = imgData.height;
  19083. const imgSrc = convertImgDataToPng(imgData, this.forceDataSchema, !!mask);
  19084. const cliprect = this.svgFactory.createElement("svg:rect");
  19085. cliprect.setAttributeNS(null, "x", "0");
  19086. cliprect.setAttributeNS(null, "y", "0");
  19087. cliprect.setAttributeNS(null, "width", pf(width));
  19088. cliprect.setAttributeNS(null, "height", pf(height));
  19089. this.current.element = cliprect;
  19090. this.clip("nonzero");
  19091. const imgEl = this.svgFactory.createElement("svg:image");
  19092. imgEl.setAttributeNS(XLINK_NS, "xlink:href", imgSrc);
  19093. imgEl.setAttributeNS(null, "x", "0");
  19094. imgEl.setAttributeNS(null, "y", pf(-height));
  19095. imgEl.setAttributeNS(null, "width", pf(width) + "px");
  19096. imgEl.setAttributeNS(null, "height", pf(height) + "px");
  19097. imgEl.setAttributeNS(null, "transform", `scale(${pf(1 / width)} ${pf(-1 / height)})`);
  19098. if (mask) {
  19099. mask.append(imgEl);
  19100. } else {
  19101. this._ensureTransformGroup().append(imgEl);
  19102. }
  19103. }
  19104. paintImageMaskXObject(img) {
  19105. const imgData = this.getObject(img.data, img);
  19106. if (imgData.bitmap) {
  19107. (0, _util.warn)("paintImageMaskXObject: ImageBitmap support is not implemented, " + "ensure that the `isOffscreenCanvasSupported` API parameter is disabled.");
  19108. return;
  19109. }
  19110. const current = this.current;
  19111. const width = imgData.width;
  19112. const height = imgData.height;
  19113. const fillColor = current.fillColor;
  19114. current.maskId = `mask${maskCount++}`;
  19115. const mask = this.svgFactory.createElement("svg:mask");
  19116. mask.setAttributeNS(null, "id", current.maskId);
  19117. const rect = this.svgFactory.createElement("svg:rect");
  19118. rect.setAttributeNS(null, "x", "0");
  19119. rect.setAttributeNS(null, "y", "0");
  19120. rect.setAttributeNS(null, "width", pf(width));
  19121. rect.setAttributeNS(null, "height", pf(height));
  19122. rect.setAttributeNS(null, "fill", fillColor);
  19123. rect.setAttributeNS(null, "mask", `url(#${current.maskId})`);
  19124. this.defs.append(mask);
  19125. this._ensureTransformGroup().append(rect);
  19126. this.paintInlineImageXObject(imgData, mask);
  19127. }
  19128. paintFormXObjectBegin(matrix, bbox) {
  19129. if (Array.isArray(matrix) && matrix.length === 6) {
  19130. this.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
  19131. }
  19132. if (bbox) {
  19133. const width = bbox[2] - bbox[0];
  19134. const height = bbox[3] - bbox[1];
  19135. const cliprect = this.svgFactory.createElement("svg:rect");
  19136. cliprect.setAttributeNS(null, "x", bbox[0]);
  19137. cliprect.setAttributeNS(null, "y", bbox[1]);
  19138. cliprect.setAttributeNS(null, "width", pf(width));
  19139. cliprect.setAttributeNS(null, "height", pf(height));
  19140. this.current.element = cliprect;
  19141. this.clip("nonzero");
  19142. this.endPath();
  19143. }
  19144. }
  19145. paintFormXObjectEnd() {}
  19146. _initialize(viewport) {
  19147. const svg = this.svgFactory.create(viewport.width, viewport.height);
  19148. const definitions = this.svgFactory.createElement("svg:defs");
  19149. svg.append(definitions);
  19150. this.defs = definitions;
  19151. const rootGroup = this.svgFactory.createElement("svg:g");
  19152. rootGroup.setAttributeNS(null, "transform", pm(viewport.transform));
  19153. svg.append(rootGroup);
  19154. this.svg = rootGroup;
  19155. return svg;
  19156. }
  19157. _ensureClipGroup() {
  19158. if (!this.current.clipGroup) {
  19159. const clipGroup = this.svgFactory.createElement("svg:g");
  19160. clipGroup.setAttributeNS(null, "clip-path", this.current.activeClipUrl);
  19161. this.svg.append(clipGroup);
  19162. this.current.clipGroup = clipGroup;
  19163. }
  19164. return this.current.clipGroup;
  19165. }
  19166. _ensureTransformGroup() {
  19167. if (!this.tgrp) {
  19168. this.tgrp = this.svgFactory.createElement("svg:g");
  19169. this.tgrp.setAttributeNS(null, "transform", pm(this.transformMatrix));
  19170. if (this.current.activeClipUrl) {
  19171. this._ensureClipGroup().append(this.tgrp);
  19172. } else {
  19173. this.svg.append(this.tgrp);
  19174. }
  19175. }
  19176. return this.tgrp;
  19177. }
  19178. };
  19179. }
  19180. /***/ })
  19181. /******/ ]);
  19182. /************************************************************************/
  19183. /******/ // The module cache
  19184. /******/ var __webpack_module_cache__ = {};
  19185. /******/
  19186. /******/ // The require function
  19187. /******/ function __w_pdfjs_require__(moduleId) {
  19188. /******/ // Check if module is in cache
  19189. /******/ var cachedModule = __webpack_module_cache__[moduleId];
  19190. /******/ if (cachedModule !== undefined) {
  19191. /******/ return cachedModule.exports;
  19192. /******/ }
  19193. /******/ // Create a new module (and put it into the cache)
  19194. /******/ var module = __webpack_module_cache__[moduleId] = {
  19195. /******/ // no module.id needed
  19196. /******/ // no module.loaded needed
  19197. /******/ exports: {}
  19198. /******/ };
  19199. /******/
  19200. /******/ // Execute the module function
  19201. /******/ __webpack_modules__[moduleId](module, module.exports, __w_pdfjs_require__);
  19202. /******/
  19203. /******/ // Return the exports of the module
  19204. /******/ return module.exports;
  19205. /******/ }
  19206. /******/
  19207. /************************************************************************/
  19208. var __webpack_exports__ = {};
  19209. // This entry need to be wrapped in an IIFE because it need to be in strict mode.
  19210. (() => {
  19211. "use strict";
  19212. var exports = __webpack_exports__;
  19213. Object.defineProperty(exports, "__esModule", ({
  19214. value: true
  19215. }));
  19216. Object.defineProperty(exports, "AbortException", ({
  19217. enumerable: true,
  19218. get: function () {
  19219. return _util.AbortException;
  19220. }
  19221. }));
  19222. Object.defineProperty(exports, "AnnotationEditorLayer", ({
  19223. enumerable: true,
  19224. get: function () {
  19225. return _annotation_editor_layer.AnnotationEditorLayer;
  19226. }
  19227. }));
  19228. Object.defineProperty(exports, "AnnotationEditorParamsType", ({
  19229. enumerable: true,
  19230. get: function () {
  19231. return _util.AnnotationEditorParamsType;
  19232. }
  19233. }));
  19234. Object.defineProperty(exports, "AnnotationEditorType", ({
  19235. enumerable: true,
  19236. get: function () {
  19237. return _util.AnnotationEditorType;
  19238. }
  19239. }));
  19240. Object.defineProperty(exports, "AnnotationEditorUIManager", ({
  19241. enumerable: true,
  19242. get: function () {
  19243. return _tools.AnnotationEditorUIManager;
  19244. }
  19245. }));
  19246. Object.defineProperty(exports, "AnnotationLayer", ({
  19247. enumerable: true,
  19248. get: function () {
  19249. return _annotation_layer.AnnotationLayer;
  19250. }
  19251. }));
  19252. Object.defineProperty(exports, "AnnotationMode", ({
  19253. enumerable: true,
  19254. get: function () {
  19255. return _util.AnnotationMode;
  19256. }
  19257. }));
  19258. Object.defineProperty(exports, "CMapCompressionType", ({
  19259. enumerable: true,
  19260. get: function () {
  19261. return _util.CMapCompressionType;
  19262. }
  19263. }));
  19264. Object.defineProperty(exports, "FeatureTest", ({
  19265. enumerable: true,
  19266. get: function () {
  19267. return _util.FeatureTest;
  19268. }
  19269. }));
  19270. Object.defineProperty(exports, "GlobalWorkerOptions", ({
  19271. enumerable: true,
  19272. get: function () {
  19273. return _worker_options.GlobalWorkerOptions;
  19274. }
  19275. }));
  19276. Object.defineProperty(exports, "InvalidPDFException", ({
  19277. enumerable: true,
  19278. get: function () {
  19279. return _util.InvalidPDFException;
  19280. }
  19281. }));
  19282. Object.defineProperty(exports, "MissingPDFException", ({
  19283. enumerable: true,
  19284. get: function () {
  19285. return _util.MissingPDFException;
  19286. }
  19287. }));
  19288. Object.defineProperty(exports, "OPS", ({
  19289. enumerable: true,
  19290. get: function () {
  19291. return _util.OPS;
  19292. }
  19293. }));
  19294. Object.defineProperty(exports, "PDFDataRangeTransport", ({
  19295. enumerable: true,
  19296. get: function () {
  19297. return _api.PDFDataRangeTransport;
  19298. }
  19299. }));
  19300. Object.defineProperty(exports, "PDFDateString", ({
  19301. enumerable: true,
  19302. get: function () {
  19303. return _display_utils.PDFDateString;
  19304. }
  19305. }));
  19306. Object.defineProperty(exports, "PDFWorker", ({
  19307. enumerable: true,
  19308. get: function () {
  19309. return _api.PDFWorker;
  19310. }
  19311. }));
  19312. Object.defineProperty(exports, "PasswordResponses", ({
  19313. enumerable: true,
  19314. get: function () {
  19315. return _util.PasswordResponses;
  19316. }
  19317. }));
  19318. Object.defineProperty(exports, "PermissionFlag", ({
  19319. enumerable: true,
  19320. get: function () {
  19321. return _util.PermissionFlag;
  19322. }
  19323. }));
  19324. Object.defineProperty(exports, "PixelsPerInch", ({
  19325. enumerable: true,
  19326. get: function () {
  19327. return _display_utils.PixelsPerInch;
  19328. }
  19329. }));
  19330. Object.defineProperty(exports, "RenderingCancelledException", ({
  19331. enumerable: true,
  19332. get: function () {
  19333. return _display_utils.RenderingCancelledException;
  19334. }
  19335. }));
  19336. Object.defineProperty(exports, "SVGGraphics", ({
  19337. enumerable: true,
  19338. get: function () {
  19339. return _svg.SVGGraphics;
  19340. }
  19341. }));
  19342. Object.defineProperty(exports, "UNSUPPORTED_FEATURES", ({
  19343. enumerable: true,
  19344. get: function () {
  19345. return _util.UNSUPPORTED_FEATURES;
  19346. }
  19347. }));
  19348. Object.defineProperty(exports, "UnexpectedResponseException", ({
  19349. enumerable: true,
  19350. get: function () {
  19351. return _util.UnexpectedResponseException;
  19352. }
  19353. }));
  19354. Object.defineProperty(exports, "Util", ({
  19355. enumerable: true,
  19356. get: function () {
  19357. return _util.Util;
  19358. }
  19359. }));
  19360. Object.defineProperty(exports, "VerbosityLevel", ({
  19361. enumerable: true,
  19362. get: function () {
  19363. return _util.VerbosityLevel;
  19364. }
  19365. }));
  19366. Object.defineProperty(exports, "XfaLayer", ({
  19367. enumerable: true,
  19368. get: function () {
  19369. return _xfa_layer.XfaLayer;
  19370. }
  19371. }));
  19372. Object.defineProperty(exports, "build", ({
  19373. enumerable: true,
  19374. get: function () {
  19375. return _api.build;
  19376. }
  19377. }));
  19378. Object.defineProperty(exports, "createPromiseCapability", ({
  19379. enumerable: true,
  19380. get: function () {
  19381. return _util.createPromiseCapability;
  19382. }
  19383. }));
  19384. Object.defineProperty(exports, "createValidAbsoluteUrl", ({
  19385. enumerable: true,
  19386. get: function () {
  19387. return _util.createValidAbsoluteUrl;
  19388. }
  19389. }));
  19390. Object.defineProperty(exports, "getDocument", ({
  19391. enumerable: true,
  19392. get: function () {
  19393. return _api.getDocument;
  19394. }
  19395. }));
  19396. Object.defineProperty(exports, "getFilenameFromUrl", ({
  19397. enumerable: true,
  19398. get: function () {
  19399. return _display_utils.getFilenameFromUrl;
  19400. }
  19401. }));
  19402. Object.defineProperty(exports, "getPdfFilenameFromUrl", ({
  19403. enumerable: true,
  19404. get: function () {
  19405. return _display_utils.getPdfFilenameFromUrl;
  19406. }
  19407. }));
  19408. Object.defineProperty(exports, "getXfaPageViewport", ({
  19409. enumerable: true,
  19410. get: function () {
  19411. return _display_utils.getXfaPageViewport;
  19412. }
  19413. }));
  19414. Object.defineProperty(exports, "isDataScheme", ({
  19415. enumerable: true,
  19416. get: function () {
  19417. return _display_utils.isDataScheme;
  19418. }
  19419. }));
  19420. Object.defineProperty(exports, "isPdfFile", ({
  19421. enumerable: true,
  19422. get: function () {
  19423. return _display_utils.isPdfFile;
  19424. }
  19425. }));
  19426. Object.defineProperty(exports, "loadScript", ({
  19427. enumerable: true,
  19428. get: function () {
  19429. return _display_utils.loadScript;
  19430. }
  19431. }));
  19432. Object.defineProperty(exports, "renderTextLayer", ({
  19433. enumerable: true,
  19434. get: function () {
  19435. return _text_layer.renderTextLayer;
  19436. }
  19437. }));
  19438. Object.defineProperty(exports, "setLayerDimensions", ({
  19439. enumerable: true,
  19440. get: function () {
  19441. return _display_utils.setLayerDimensions;
  19442. }
  19443. }));
  19444. Object.defineProperty(exports, "shadow", ({
  19445. enumerable: true,
  19446. get: function () {
  19447. return _util.shadow;
  19448. }
  19449. }));
  19450. Object.defineProperty(exports, "updateTextLayer", ({
  19451. enumerable: true,
  19452. get: function () {
  19453. return _text_layer.updateTextLayer;
  19454. }
  19455. }));
  19456. Object.defineProperty(exports, "version", ({
  19457. enumerable: true,
  19458. get: function () {
  19459. return _api.version;
  19460. }
  19461. }));
  19462. var _util = __w_pdfjs_require__(1);
  19463. var _api = __w_pdfjs_require__(135);
  19464. var _display_utils = __w_pdfjs_require__(139);
  19465. var _text_layer = __w_pdfjs_require__(158);
  19466. var _annotation_editor_layer = __w_pdfjs_require__(159);
  19467. var _tools = __w_pdfjs_require__(138);
  19468. var _annotation_layer = __w_pdfjs_require__(164);
  19469. var _worker_options = __w_pdfjs_require__(146);
  19470. var _svg = __w_pdfjs_require__(167);
  19471. var _xfa_layer = __w_pdfjs_require__(166);
  19472. const pdfjsVersion = '3.4.120';
  19473. const pdfjsBuild = 'af6414988';
  19474. })();
  19475. /******/ return __webpack_exports__;
  19476. /******/ })()
  19477. ;
  19478. });
  19479. //# sourceMappingURL=pdf.js.map