luckyexcel.umd.js 524 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489
  1. (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.LuckyExcel = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
  2. 'use strict'
  3. exports.byteLength = byteLength
  4. exports.toByteArray = toByteArray
  5. exports.fromByteArray = fromByteArray
  6. var lookup = []
  7. var revLookup = []
  8. var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
  9. var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
  10. for (var i = 0, len = code.length; i < len; ++i) {
  11. lookup[i] = code[i]
  12. revLookup[code.charCodeAt(i)] = i
  13. }
  14. // Support decoding URL-safe base64 strings, as Node.js does.
  15. // See: https://en.wikipedia.org/wiki/Base64#URL_applications
  16. revLookup['-'.charCodeAt(0)] = 62
  17. revLookup['_'.charCodeAt(0)] = 63
  18. function getLens (b64) {
  19. var len = b64.length
  20. if (len % 4 > 0) {
  21. throw new Error('Invalid string. Length must be a multiple of 4')
  22. }
  23. // Trim off extra bytes after placeholder bytes are found
  24. // See: https://github.com/beatgammit/base64-js/issues/42
  25. var validLen = b64.indexOf('=')
  26. if (validLen === -1) validLen = len
  27. var placeHoldersLen = validLen === len
  28. ? 0
  29. : 4 - (validLen % 4)
  30. return [validLen, placeHoldersLen]
  31. }
  32. // base64 is 4/3 + up to two characters of the original data
  33. function byteLength (b64) {
  34. var lens = getLens(b64)
  35. var validLen = lens[0]
  36. var placeHoldersLen = lens[1]
  37. return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
  38. }
  39. function _byteLength (b64, validLen, placeHoldersLen) {
  40. return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
  41. }
  42. function toByteArray (b64) {
  43. var tmp
  44. var lens = getLens(b64)
  45. var validLen = lens[0]
  46. var placeHoldersLen = lens[1]
  47. var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
  48. var curByte = 0
  49. // if there are placeholders, only get up to the last complete 4 chars
  50. var len = placeHoldersLen > 0
  51. ? validLen - 4
  52. : validLen
  53. var i
  54. for (i = 0; i < len; i += 4) {
  55. tmp =
  56. (revLookup[b64.charCodeAt(i)] << 18) |
  57. (revLookup[b64.charCodeAt(i + 1)] << 12) |
  58. (revLookup[b64.charCodeAt(i + 2)] << 6) |
  59. revLookup[b64.charCodeAt(i + 3)]
  60. arr[curByte++] = (tmp >> 16) & 0xFF
  61. arr[curByte++] = (tmp >> 8) & 0xFF
  62. arr[curByte++] = tmp & 0xFF
  63. }
  64. if (placeHoldersLen === 2) {
  65. tmp =
  66. (revLookup[b64.charCodeAt(i)] << 2) |
  67. (revLookup[b64.charCodeAt(i + 1)] >> 4)
  68. arr[curByte++] = tmp & 0xFF
  69. }
  70. if (placeHoldersLen === 1) {
  71. tmp =
  72. (revLookup[b64.charCodeAt(i)] << 10) |
  73. (revLookup[b64.charCodeAt(i + 1)] << 4) |
  74. (revLookup[b64.charCodeAt(i + 2)] >> 2)
  75. arr[curByte++] = (tmp >> 8) & 0xFF
  76. arr[curByte++] = tmp & 0xFF
  77. }
  78. return arr
  79. }
  80. function tripletToBase64 (num) {
  81. return lookup[num >> 18 & 0x3F] +
  82. lookup[num >> 12 & 0x3F] +
  83. lookup[num >> 6 & 0x3F] +
  84. lookup[num & 0x3F]
  85. }
  86. function encodeChunk (uint8, start, end) {
  87. var tmp
  88. var output = []
  89. for (var i = start; i < end; i += 3) {
  90. tmp =
  91. ((uint8[i] << 16) & 0xFF0000) +
  92. ((uint8[i + 1] << 8) & 0xFF00) +
  93. (uint8[i + 2] & 0xFF)
  94. output.push(tripletToBase64(tmp))
  95. }
  96. return output.join('')
  97. }
  98. function fromByteArray (uint8) {
  99. var tmp
  100. var len = uint8.length
  101. var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
  102. var parts = []
  103. var maxChunkLength = 16383 // must be multiple of 3
  104. // go through the array every three bytes, we'll deal with trailing stuff later
  105. for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
  106. parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))
  107. }
  108. // pad the end with zeros, but make sure to not forget the extra bytes
  109. if (extraBytes === 1) {
  110. tmp = uint8[len - 1]
  111. parts.push(
  112. lookup[tmp >> 2] +
  113. lookup[(tmp << 4) & 0x3F] +
  114. '=='
  115. )
  116. } else if (extraBytes === 2) {
  117. tmp = (uint8[len - 2] << 8) + uint8[len - 1]
  118. parts.push(
  119. lookup[tmp >> 10] +
  120. lookup[(tmp >> 4) & 0x3F] +
  121. lookup[(tmp << 2) & 0x3F] +
  122. '='
  123. )
  124. }
  125. return parts.join('')
  126. }
  127. },{}],2:[function(require,module,exports){
  128. },{}],3:[function(require,module,exports){
  129. (function (global,Buffer){(function (){
  130. /*!
  131. * The buffer module from node.js, for the browser.
  132. *
  133. * @author Feross Aboukhadijeh <http://feross.org>
  134. * @license MIT
  135. */
  136. /* eslint-disable no-proto */
  137. 'use strict'
  138. var base64 = require('base64-js')
  139. var ieee754 = require('ieee754')
  140. var isArray = require('isarray')
  141. exports.Buffer = Buffer
  142. exports.SlowBuffer = SlowBuffer
  143. exports.INSPECT_MAX_BYTES = 50
  144. /**
  145. * If `Buffer.TYPED_ARRAY_SUPPORT`:
  146. * === true Use Uint8Array implementation (fastest)
  147. * === false Use Object implementation (most compatible, even IE6)
  148. *
  149. * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
  150. * Opera 11.6+, iOS 4.2+.
  151. *
  152. * Due to various browser bugs, sometimes the Object implementation will be used even
  153. * when the browser supports typed arrays.
  154. *
  155. * Note:
  156. *
  157. * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
  158. * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
  159. *
  160. * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
  161. *
  162. * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
  163. * incorrect length in some situations.
  164. * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
  165. * get the Object implementation, which is slower but behaves correctly.
  166. */
  167. Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined
  168. ? global.TYPED_ARRAY_SUPPORT
  169. : typedArraySupport()
  170. /*
  171. * Export kMaxLength after typed array support is determined.
  172. */
  173. exports.kMaxLength = kMaxLength()
  174. function typedArraySupport () {
  175. try {
  176. var arr = new Uint8Array(1)
  177. arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}
  178. return arr.foo() === 42 && // typed array instances can be augmented
  179. typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
  180. arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
  181. } catch (e) {
  182. return false
  183. }
  184. }
  185. function kMaxLength () {
  186. return Buffer.TYPED_ARRAY_SUPPORT
  187. ? 0x7fffffff
  188. : 0x3fffffff
  189. }
  190. function createBuffer (that, length) {
  191. if (kMaxLength() < length) {
  192. throw new RangeError('Invalid typed array length')
  193. }
  194. if (Buffer.TYPED_ARRAY_SUPPORT) {
  195. // Return an augmented `Uint8Array` instance, for best performance
  196. that = new Uint8Array(length)
  197. that.__proto__ = Buffer.prototype
  198. } else {
  199. // Fallback: Return an object instance of the Buffer class
  200. if (that === null) {
  201. that = new Buffer(length)
  202. }
  203. that.length = length
  204. }
  205. return that
  206. }
  207. /**
  208. * The Buffer constructor returns instances of `Uint8Array` that have their
  209. * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
  210. * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
  211. * and the `Uint8Array` methods. Square bracket notation works as expected -- it
  212. * returns a single octet.
  213. *
  214. * The `Uint8Array` prototype remains unmodified.
  215. */
  216. function Buffer (arg, encodingOrOffset, length) {
  217. if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {
  218. return new Buffer(arg, encodingOrOffset, length)
  219. }
  220. // Common case.
  221. if (typeof arg === 'number') {
  222. if (typeof encodingOrOffset === 'string') {
  223. throw new Error(
  224. 'If encoding is specified then the first argument must be a string'
  225. )
  226. }
  227. return allocUnsafe(this, arg)
  228. }
  229. return from(this, arg, encodingOrOffset, length)
  230. }
  231. Buffer.poolSize = 8192 // not used by this implementation
  232. // TODO: Legacy, not needed anymore. Remove in next major version.
  233. Buffer._augment = function (arr) {
  234. arr.__proto__ = Buffer.prototype
  235. return arr
  236. }
  237. function from (that, value, encodingOrOffset, length) {
  238. if (typeof value === 'number') {
  239. throw new TypeError('"value" argument must not be a number')
  240. }
  241. if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
  242. return fromArrayBuffer(that, value, encodingOrOffset, length)
  243. }
  244. if (typeof value === 'string') {
  245. return fromString(that, value, encodingOrOffset)
  246. }
  247. return fromObject(that, value)
  248. }
  249. /**
  250. * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
  251. * if value is a number.
  252. * Buffer.from(str[, encoding])
  253. * Buffer.from(array)
  254. * Buffer.from(buffer)
  255. * Buffer.from(arrayBuffer[, byteOffset[, length]])
  256. **/
  257. Buffer.from = function (value, encodingOrOffset, length) {
  258. return from(null, value, encodingOrOffset, length)
  259. }
  260. if (Buffer.TYPED_ARRAY_SUPPORT) {
  261. Buffer.prototype.__proto__ = Uint8Array.prototype
  262. Buffer.__proto__ = Uint8Array
  263. if (typeof Symbol !== 'undefined' && Symbol.species &&
  264. Buffer[Symbol.species] === Buffer) {
  265. // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
  266. Object.defineProperty(Buffer, Symbol.species, {
  267. value: null,
  268. configurable: true
  269. })
  270. }
  271. }
  272. function assertSize (size) {
  273. if (typeof size !== 'number') {
  274. throw new TypeError('"size" argument must be a number')
  275. } else if (size < 0) {
  276. throw new RangeError('"size" argument must not be negative')
  277. }
  278. }
  279. function alloc (that, size, fill, encoding) {
  280. assertSize(size)
  281. if (size <= 0) {
  282. return createBuffer(that, size)
  283. }
  284. if (fill !== undefined) {
  285. // Only pay attention to encoding if it's a string. This
  286. // prevents accidentally sending in a number that would
  287. // be interpretted as a start offset.
  288. return typeof encoding === 'string'
  289. ? createBuffer(that, size).fill(fill, encoding)
  290. : createBuffer(that, size).fill(fill)
  291. }
  292. return createBuffer(that, size)
  293. }
  294. /**
  295. * Creates a new filled Buffer instance.
  296. * alloc(size[, fill[, encoding]])
  297. **/
  298. Buffer.alloc = function (size, fill, encoding) {
  299. return alloc(null, size, fill, encoding)
  300. }
  301. function allocUnsafe (that, size) {
  302. assertSize(size)
  303. that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)
  304. if (!Buffer.TYPED_ARRAY_SUPPORT) {
  305. for (var i = 0; i < size; ++i) {
  306. that[i] = 0
  307. }
  308. }
  309. return that
  310. }
  311. /**
  312. * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
  313. * */
  314. Buffer.allocUnsafe = function (size) {
  315. return allocUnsafe(null, size)
  316. }
  317. /**
  318. * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
  319. */
  320. Buffer.allocUnsafeSlow = function (size) {
  321. return allocUnsafe(null, size)
  322. }
  323. function fromString (that, string, encoding) {
  324. if (typeof encoding !== 'string' || encoding === '') {
  325. encoding = 'utf8'
  326. }
  327. if (!Buffer.isEncoding(encoding)) {
  328. throw new TypeError('"encoding" must be a valid string encoding')
  329. }
  330. var length = byteLength(string, encoding) | 0
  331. that = createBuffer(that, length)
  332. var actual = that.write(string, encoding)
  333. if (actual !== length) {
  334. // Writing a hex string, for example, that contains invalid characters will
  335. // cause everything after the first invalid character to be ignored. (e.g.
  336. // 'abxxcd' will be treated as 'ab')
  337. that = that.slice(0, actual)
  338. }
  339. return that
  340. }
  341. function fromArrayLike (that, array) {
  342. var length = array.length < 0 ? 0 : checked(array.length) | 0
  343. that = createBuffer(that, length)
  344. for (var i = 0; i < length; i += 1) {
  345. that[i] = array[i] & 255
  346. }
  347. return that
  348. }
  349. function fromArrayBuffer (that, array, byteOffset, length) {
  350. array.byteLength // this throws if `array` is not a valid ArrayBuffer
  351. if (byteOffset < 0 || array.byteLength < byteOffset) {
  352. throw new RangeError('\'offset\' is out of bounds')
  353. }
  354. if (array.byteLength < byteOffset + (length || 0)) {
  355. throw new RangeError('\'length\' is out of bounds')
  356. }
  357. if (byteOffset === undefined && length === undefined) {
  358. array = new Uint8Array(array)
  359. } else if (length === undefined) {
  360. array = new Uint8Array(array, byteOffset)
  361. } else {
  362. array = new Uint8Array(array, byteOffset, length)
  363. }
  364. if (Buffer.TYPED_ARRAY_SUPPORT) {
  365. // Return an augmented `Uint8Array` instance, for best performance
  366. that = array
  367. that.__proto__ = Buffer.prototype
  368. } else {
  369. // Fallback: Return an object instance of the Buffer class
  370. that = fromArrayLike(that, array)
  371. }
  372. return that
  373. }
  374. function fromObject (that, obj) {
  375. if (Buffer.isBuffer(obj)) {
  376. var len = checked(obj.length) | 0
  377. that = createBuffer(that, len)
  378. if (that.length === 0) {
  379. return that
  380. }
  381. obj.copy(that, 0, 0, len)
  382. return that
  383. }
  384. if (obj) {
  385. if ((typeof ArrayBuffer !== 'undefined' &&
  386. obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
  387. if (typeof obj.length !== 'number' || isnan(obj.length)) {
  388. return createBuffer(that, 0)
  389. }
  390. return fromArrayLike(that, obj)
  391. }
  392. if (obj.type === 'Buffer' && isArray(obj.data)) {
  393. return fromArrayLike(that, obj.data)
  394. }
  395. }
  396. throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
  397. }
  398. function checked (length) {
  399. // Note: cannot use `length < kMaxLength()` here because that fails when
  400. // length is NaN (which is otherwise coerced to zero.)
  401. if (length >= kMaxLength()) {
  402. throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
  403. 'size: 0x' + kMaxLength().toString(16) + ' bytes')
  404. }
  405. return length | 0
  406. }
  407. function SlowBuffer (length) {
  408. if (+length != length) { // eslint-disable-line eqeqeq
  409. length = 0
  410. }
  411. return Buffer.alloc(+length)
  412. }
  413. Buffer.isBuffer = function isBuffer (b) {
  414. return !!(b != null && b._isBuffer)
  415. }
  416. Buffer.compare = function compare (a, b) {
  417. if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
  418. throw new TypeError('Arguments must be Buffers')
  419. }
  420. if (a === b) return 0
  421. var x = a.length
  422. var y = b.length
  423. for (var i = 0, len = Math.min(x, y); i < len; ++i) {
  424. if (a[i] !== b[i]) {
  425. x = a[i]
  426. y = b[i]
  427. break
  428. }
  429. }
  430. if (x < y) return -1
  431. if (y < x) return 1
  432. return 0
  433. }
  434. Buffer.isEncoding = function isEncoding (encoding) {
  435. switch (String(encoding).toLowerCase()) {
  436. case 'hex':
  437. case 'utf8':
  438. case 'utf-8':
  439. case 'ascii':
  440. case 'latin1':
  441. case 'binary':
  442. case 'base64':
  443. case 'ucs2':
  444. case 'ucs-2':
  445. case 'utf16le':
  446. case 'utf-16le':
  447. return true
  448. default:
  449. return false
  450. }
  451. }
  452. Buffer.concat = function concat (list, length) {
  453. if (!isArray(list)) {
  454. throw new TypeError('"list" argument must be an Array of Buffers')
  455. }
  456. if (list.length === 0) {
  457. return Buffer.alloc(0)
  458. }
  459. var i
  460. if (length === undefined) {
  461. length = 0
  462. for (i = 0; i < list.length; ++i) {
  463. length += list[i].length
  464. }
  465. }
  466. var buffer = Buffer.allocUnsafe(length)
  467. var pos = 0
  468. for (i = 0; i < list.length; ++i) {
  469. var buf = list[i]
  470. if (!Buffer.isBuffer(buf)) {
  471. throw new TypeError('"list" argument must be an Array of Buffers')
  472. }
  473. buf.copy(buffer, pos)
  474. pos += buf.length
  475. }
  476. return buffer
  477. }
  478. function byteLength (string, encoding) {
  479. if (Buffer.isBuffer(string)) {
  480. return string.length
  481. }
  482. if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&
  483. (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
  484. return string.byteLength
  485. }
  486. if (typeof string !== 'string') {
  487. string = '' + string
  488. }
  489. var len = string.length
  490. if (len === 0) return 0
  491. // Use a for loop to avoid recursion
  492. var loweredCase = false
  493. for (;;) {
  494. switch (encoding) {
  495. case 'ascii':
  496. case 'latin1':
  497. case 'binary':
  498. return len
  499. case 'utf8':
  500. case 'utf-8':
  501. case undefined:
  502. return utf8ToBytes(string).length
  503. case 'ucs2':
  504. case 'ucs-2':
  505. case 'utf16le':
  506. case 'utf-16le':
  507. return len * 2
  508. case 'hex':
  509. return len >>> 1
  510. case 'base64':
  511. return base64ToBytes(string).length
  512. default:
  513. if (loweredCase) return utf8ToBytes(string).length // assume utf8
  514. encoding = ('' + encoding).toLowerCase()
  515. loweredCase = true
  516. }
  517. }
  518. }
  519. Buffer.byteLength = byteLength
  520. function slowToString (encoding, start, end) {
  521. var loweredCase = false
  522. // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
  523. // property of a typed array.
  524. // This behaves neither like String nor Uint8Array in that we set start/end
  525. // to their upper/lower bounds if the value passed is out of range.
  526. // undefined is handled specially as per ECMA-262 6th Edition,
  527. // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
  528. if (start === undefined || start < 0) {
  529. start = 0
  530. }
  531. // Return early if start > this.length. Done here to prevent potential uint32
  532. // coercion fail below.
  533. if (start > this.length) {
  534. return ''
  535. }
  536. if (end === undefined || end > this.length) {
  537. end = this.length
  538. }
  539. if (end <= 0) {
  540. return ''
  541. }
  542. // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
  543. end >>>= 0
  544. start >>>= 0
  545. if (end <= start) {
  546. return ''
  547. }
  548. if (!encoding) encoding = 'utf8'
  549. while (true) {
  550. switch (encoding) {
  551. case 'hex':
  552. return hexSlice(this, start, end)
  553. case 'utf8':
  554. case 'utf-8':
  555. return utf8Slice(this, start, end)
  556. case 'ascii':
  557. return asciiSlice(this, start, end)
  558. case 'latin1':
  559. case 'binary':
  560. return latin1Slice(this, start, end)
  561. case 'base64':
  562. return base64Slice(this, start, end)
  563. case 'ucs2':
  564. case 'ucs-2':
  565. case 'utf16le':
  566. case 'utf-16le':
  567. return utf16leSlice(this, start, end)
  568. default:
  569. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  570. encoding = (encoding + '').toLowerCase()
  571. loweredCase = true
  572. }
  573. }
  574. }
  575. // The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect
  576. // Buffer instances.
  577. Buffer.prototype._isBuffer = true
  578. function swap (b, n, m) {
  579. var i = b[n]
  580. b[n] = b[m]
  581. b[m] = i
  582. }
  583. Buffer.prototype.swap16 = function swap16 () {
  584. var len = this.length
  585. if (len % 2 !== 0) {
  586. throw new RangeError('Buffer size must be a multiple of 16-bits')
  587. }
  588. for (var i = 0; i < len; i += 2) {
  589. swap(this, i, i + 1)
  590. }
  591. return this
  592. }
  593. Buffer.prototype.swap32 = function swap32 () {
  594. var len = this.length
  595. if (len % 4 !== 0) {
  596. throw new RangeError('Buffer size must be a multiple of 32-bits')
  597. }
  598. for (var i = 0; i < len; i += 4) {
  599. swap(this, i, i + 3)
  600. swap(this, i + 1, i + 2)
  601. }
  602. return this
  603. }
  604. Buffer.prototype.swap64 = function swap64 () {
  605. var len = this.length
  606. if (len % 8 !== 0) {
  607. throw new RangeError('Buffer size must be a multiple of 64-bits')
  608. }
  609. for (var i = 0; i < len; i += 8) {
  610. swap(this, i, i + 7)
  611. swap(this, i + 1, i + 6)
  612. swap(this, i + 2, i + 5)
  613. swap(this, i + 3, i + 4)
  614. }
  615. return this
  616. }
  617. Buffer.prototype.toString = function toString () {
  618. var length = this.length | 0
  619. if (length === 0) return ''
  620. if (arguments.length === 0) return utf8Slice(this, 0, length)
  621. return slowToString.apply(this, arguments)
  622. }
  623. Buffer.prototype.equals = function equals (b) {
  624. if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
  625. if (this === b) return true
  626. return Buffer.compare(this, b) === 0
  627. }
  628. Buffer.prototype.inspect = function inspect () {
  629. var str = ''
  630. var max = exports.INSPECT_MAX_BYTES
  631. if (this.length > 0) {
  632. str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
  633. if (this.length > max) str += ' ... '
  634. }
  635. return '<Buffer ' + str + '>'
  636. }
  637. Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
  638. if (!Buffer.isBuffer(target)) {
  639. throw new TypeError('Argument must be a Buffer')
  640. }
  641. if (start === undefined) {
  642. start = 0
  643. }
  644. if (end === undefined) {
  645. end = target ? target.length : 0
  646. }
  647. if (thisStart === undefined) {
  648. thisStart = 0
  649. }
  650. if (thisEnd === undefined) {
  651. thisEnd = this.length
  652. }
  653. if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
  654. throw new RangeError('out of range index')
  655. }
  656. if (thisStart >= thisEnd && start >= end) {
  657. return 0
  658. }
  659. if (thisStart >= thisEnd) {
  660. return -1
  661. }
  662. if (start >= end) {
  663. return 1
  664. }
  665. start >>>= 0
  666. end >>>= 0
  667. thisStart >>>= 0
  668. thisEnd >>>= 0
  669. if (this === target) return 0
  670. var x = thisEnd - thisStart
  671. var y = end - start
  672. var len = Math.min(x, y)
  673. var thisCopy = this.slice(thisStart, thisEnd)
  674. var targetCopy = target.slice(start, end)
  675. for (var i = 0; i < len; ++i) {
  676. if (thisCopy[i] !== targetCopy[i]) {
  677. x = thisCopy[i]
  678. y = targetCopy[i]
  679. break
  680. }
  681. }
  682. if (x < y) return -1
  683. if (y < x) return 1
  684. return 0
  685. }
  686. // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
  687. // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
  688. //
  689. // Arguments:
  690. // - buffer - a Buffer to search
  691. // - val - a string, Buffer, or number
  692. // - byteOffset - an index into `buffer`; will be clamped to an int32
  693. // - encoding - an optional encoding, relevant is val is a string
  694. // - dir - true for indexOf, false for lastIndexOf
  695. function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
  696. // Empty buffer means no match
  697. if (buffer.length === 0) return -1
  698. // Normalize byteOffset
  699. if (typeof byteOffset === 'string') {
  700. encoding = byteOffset
  701. byteOffset = 0
  702. } else if (byteOffset > 0x7fffffff) {
  703. byteOffset = 0x7fffffff
  704. } else if (byteOffset < -0x80000000) {
  705. byteOffset = -0x80000000
  706. }
  707. byteOffset = +byteOffset // Coerce to Number.
  708. if (isNaN(byteOffset)) {
  709. // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
  710. byteOffset = dir ? 0 : (buffer.length - 1)
  711. }
  712. // Normalize byteOffset: negative offsets start from the end of the buffer
  713. if (byteOffset < 0) byteOffset = buffer.length + byteOffset
  714. if (byteOffset >= buffer.length) {
  715. if (dir) return -1
  716. else byteOffset = buffer.length - 1
  717. } else if (byteOffset < 0) {
  718. if (dir) byteOffset = 0
  719. else return -1
  720. }
  721. // Normalize val
  722. if (typeof val === 'string') {
  723. val = Buffer.from(val, encoding)
  724. }
  725. // Finally, search either indexOf (if dir is true) or lastIndexOf
  726. if (Buffer.isBuffer(val)) {
  727. // Special case: looking for empty string/buffer always fails
  728. if (val.length === 0) {
  729. return -1
  730. }
  731. return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
  732. } else if (typeof val === 'number') {
  733. val = val & 0xFF // Search for a byte value [0-255]
  734. if (Buffer.TYPED_ARRAY_SUPPORT &&
  735. typeof Uint8Array.prototype.indexOf === 'function') {
  736. if (dir) {
  737. return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
  738. } else {
  739. return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
  740. }
  741. }
  742. return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
  743. }
  744. throw new TypeError('val must be string, number or Buffer')
  745. }
  746. function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
  747. var indexSize = 1
  748. var arrLength = arr.length
  749. var valLength = val.length
  750. if (encoding !== undefined) {
  751. encoding = String(encoding).toLowerCase()
  752. if (encoding === 'ucs2' || encoding === 'ucs-2' ||
  753. encoding === 'utf16le' || encoding === 'utf-16le') {
  754. if (arr.length < 2 || val.length < 2) {
  755. return -1
  756. }
  757. indexSize = 2
  758. arrLength /= 2
  759. valLength /= 2
  760. byteOffset /= 2
  761. }
  762. }
  763. function read (buf, i) {
  764. if (indexSize === 1) {
  765. return buf[i]
  766. } else {
  767. return buf.readUInt16BE(i * indexSize)
  768. }
  769. }
  770. var i
  771. if (dir) {
  772. var foundIndex = -1
  773. for (i = byteOffset; i < arrLength; i++) {
  774. if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
  775. if (foundIndex === -1) foundIndex = i
  776. if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
  777. } else {
  778. if (foundIndex !== -1) i -= i - foundIndex
  779. foundIndex = -1
  780. }
  781. }
  782. } else {
  783. if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
  784. for (i = byteOffset; i >= 0; i--) {
  785. var found = true
  786. for (var j = 0; j < valLength; j++) {
  787. if (read(arr, i + j) !== read(val, j)) {
  788. found = false
  789. break
  790. }
  791. }
  792. if (found) return i
  793. }
  794. }
  795. return -1
  796. }
  797. Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
  798. return this.indexOf(val, byteOffset, encoding) !== -1
  799. }
  800. Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
  801. return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
  802. }
  803. Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
  804. return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
  805. }
  806. function hexWrite (buf, string, offset, length) {
  807. offset = Number(offset) || 0
  808. var remaining = buf.length - offset
  809. if (!length) {
  810. length = remaining
  811. } else {
  812. length = Number(length)
  813. if (length > remaining) {
  814. length = remaining
  815. }
  816. }
  817. // must be an even number of digits
  818. var strLen = string.length
  819. if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')
  820. if (length > strLen / 2) {
  821. length = strLen / 2
  822. }
  823. for (var i = 0; i < length; ++i) {
  824. var parsed = parseInt(string.substr(i * 2, 2), 16)
  825. if (isNaN(parsed)) return i
  826. buf[offset + i] = parsed
  827. }
  828. return i
  829. }
  830. function utf8Write (buf, string, offset, length) {
  831. return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
  832. }
  833. function asciiWrite (buf, string, offset, length) {
  834. return blitBuffer(asciiToBytes(string), buf, offset, length)
  835. }
  836. function latin1Write (buf, string, offset, length) {
  837. return asciiWrite(buf, string, offset, length)
  838. }
  839. function base64Write (buf, string, offset, length) {
  840. return blitBuffer(base64ToBytes(string), buf, offset, length)
  841. }
  842. function ucs2Write (buf, string, offset, length) {
  843. return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
  844. }
  845. Buffer.prototype.write = function write (string, offset, length, encoding) {
  846. // Buffer#write(string)
  847. if (offset === undefined) {
  848. encoding = 'utf8'
  849. length = this.length
  850. offset = 0
  851. // Buffer#write(string, encoding)
  852. } else if (length === undefined && typeof offset === 'string') {
  853. encoding = offset
  854. length = this.length
  855. offset = 0
  856. // Buffer#write(string, offset[, length][, encoding])
  857. } else if (isFinite(offset)) {
  858. offset = offset | 0
  859. if (isFinite(length)) {
  860. length = length | 0
  861. if (encoding === undefined) encoding = 'utf8'
  862. } else {
  863. encoding = length
  864. length = undefined
  865. }
  866. // legacy write(string, encoding, offset, length) - remove in v0.13
  867. } else {
  868. throw new Error(
  869. 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
  870. )
  871. }
  872. var remaining = this.length - offset
  873. if (length === undefined || length > remaining) length = remaining
  874. if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
  875. throw new RangeError('Attempt to write outside buffer bounds')
  876. }
  877. if (!encoding) encoding = 'utf8'
  878. var loweredCase = false
  879. for (;;) {
  880. switch (encoding) {
  881. case 'hex':
  882. return hexWrite(this, string, offset, length)
  883. case 'utf8':
  884. case 'utf-8':
  885. return utf8Write(this, string, offset, length)
  886. case 'ascii':
  887. return asciiWrite(this, string, offset, length)
  888. case 'latin1':
  889. case 'binary':
  890. return latin1Write(this, string, offset, length)
  891. case 'base64':
  892. // Warning: maxLength not taken into account in base64Write
  893. return base64Write(this, string, offset, length)
  894. case 'ucs2':
  895. case 'ucs-2':
  896. case 'utf16le':
  897. case 'utf-16le':
  898. return ucs2Write(this, string, offset, length)
  899. default:
  900. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  901. encoding = ('' + encoding).toLowerCase()
  902. loweredCase = true
  903. }
  904. }
  905. }
  906. Buffer.prototype.toJSON = function toJSON () {
  907. return {
  908. type: 'Buffer',
  909. data: Array.prototype.slice.call(this._arr || this, 0)
  910. }
  911. }
  912. function base64Slice (buf, start, end) {
  913. if (start === 0 && end === buf.length) {
  914. return base64.fromByteArray(buf)
  915. } else {
  916. return base64.fromByteArray(buf.slice(start, end))
  917. }
  918. }
  919. function utf8Slice (buf, start, end) {
  920. end = Math.min(buf.length, end)
  921. var res = []
  922. var i = start
  923. while (i < end) {
  924. var firstByte = buf[i]
  925. var codePoint = null
  926. var bytesPerSequence = (firstByte > 0xEF) ? 4
  927. : (firstByte > 0xDF) ? 3
  928. : (firstByte > 0xBF) ? 2
  929. : 1
  930. if (i + bytesPerSequence <= end) {
  931. var secondByte, thirdByte, fourthByte, tempCodePoint
  932. switch (bytesPerSequence) {
  933. case 1:
  934. if (firstByte < 0x80) {
  935. codePoint = firstByte
  936. }
  937. break
  938. case 2:
  939. secondByte = buf[i + 1]
  940. if ((secondByte & 0xC0) === 0x80) {
  941. tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
  942. if (tempCodePoint > 0x7F) {
  943. codePoint = tempCodePoint
  944. }
  945. }
  946. break
  947. case 3:
  948. secondByte = buf[i + 1]
  949. thirdByte = buf[i + 2]
  950. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
  951. tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
  952. if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
  953. codePoint = tempCodePoint
  954. }
  955. }
  956. break
  957. case 4:
  958. secondByte = buf[i + 1]
  959. thirdByte = buf[i + 2]
  960. fourthByte = buf[i + 3]
  961. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
  962. tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
  963. if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
  964. codePoint = tempCodePoint
  965. }
  966. }
  967. }
  968. }
  969. if (codePoint === null) {
  970. // we did not generate a valid codePoint so insert a
  971. // replacement char (U+FFFD) and advance only 1 byte
  972. codePoint = 0xFFFD
  973. bytesPerSequence = 1
  974. } else if (codePoint > 0xFFFF) {
  975. // encode to utf16 (surrogate pair dance)
  976. codePoint -= 0x10000
  977. res.push(codePoint >>> 10 & 0x3FF | 0xD800)
  978. codePoint = 0xDC00 | codePoint & 0x3FF
  979. }
  980. res.push(codePoint)
  981. i += bytesPerSequence
  982. }
  983. return decodeCodePointsArray(res)
  984. }
  985. // Based on http://stackoverflow.com/a/22747272/680742, the browser with
  986. // the lowest limit is Chrome, with 0x10000 args.
  987. // We go 1 magnitude less, for safety
  988. var MAX_ARGUMENTS_LENGTH = 0x1000
  989. function decodeCodePointsArray (codePoints) {
  990. var len = codePoints.length
  991. if (len <= MAX_ARGUMENTS_LENGTH) {
  992. return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
  993. }
  994. // Decode in chunks to avoid "call stack size exceeded".
  995. var res = ''
  996. var i = 0
  997. while (i < len) {
  998. res += String.fromCharCode.apply(
  999. String,
  1000. codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
  1001. )
  1002. }
  1003. return res
  1004. }
  1005. function asciiSlice (buf, start, end) {
  1006. var ret = ''
  1007. end = Math.min(buf.length, end)
  1008. for (var i = start; i < end; ++i) {
  1009. ret += String.fromCharCode(buf[i] & 0x7F)
  1010. }
  1011. return ret
  1012. }
  1013. function latin1Slice (buf, start, end) {
  1014. var ret = ''
  1015. end = Math.min(buf.length, end)
  1016. for (var i = start; i < end; ++i) {
  1017. ret += String.fromCharCode(buf[i])
  1018. }
  1019. return ret
  1020. }
  1021. function hexSlice (buf, start, end) {
  1022. var len = buf.length
  1023. if (!start || start < 0) start = 0
  1024. if (!end || end < 0 || end > len) end = len
  1025. var out = ''
  1026. for (var i = start; i < end; ++i) {
  1027. out += toHex(buf[i])
  1028. }
  1029. return out
  1030. }
  1031. function utf16leSlice (buf, start, end) {
  1032. var bytes = buf.slice(start, end)
  1033. var res = ''
  1034. for (var i = 0; i < bytes.length; i += 2) {
  1035. res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
  1036. }
  1037. return res
  1038. }
  1039. Buffer.prototype.slice = function slice (start, end) {
  1040. var len = this.length
  1041. start = ~~start
  1042. end = end === undefined ? len : ~~end
  1043. if (start < 0) {
  1044. start += len
  1045. if (start < 0) start = 0
  1046. } else if (start > len) {
  1047. start = len
  1048. }
  1049. if (end < 0) {
  1050. end += len
  1051. if (end < 0) end = 0
  1052. } else if (end > len) {
  1053. end = len
  1054. }
  1055. if (end < start) end = start
  1056. var newBuf
  1057. if (Buffer.TYPED_ARRAY_SUPPORT) {
  1058. newBuf = this.subarray(start, end)
  1059. newBuf.__proto__ = Buffer.prototype
  1060. } else {
  1061. var sliceLen = end - start
  1062. newBuf = new Buffer(sliceLen, undefined)
  1063. for (var i = 0; i < sliceLen; ++i) {
  1064. newBuf[i] = this[i + start]
  1065. }
  1066. }
  1067. return newBuf
  1068. }
  1069. /*
  1070. * Need to make sure that buffer isn't trying to write out of bounds.
  1071. */
  1072. function checkOffset (offset, ext, length) {
  1073. if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
  1074. if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
  1075. }
  1076. Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
  1077. offset = offset | 0
  1078. byteLength = byteLength | 0
  1079. if (!noAssert) checkOffset(offset, byteLength, this.length)
  1080. var val = this[offset]
  1081. var mul = 1
  1082. var i = 0
  1083. while (++i < byteLength && (mul *= 0x100)) {
  1084. val += this[offset + i] * mul
  1085. }
  1086. return val
  1087. }
  1088. Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
  1089. offset = offset | 0
  1090. byteLength = byteLength | 0
  1091. if (!noAssert) {
  1092. checkOffset(offset, byteLength, this.length)
  1093. }
  1094. var val = this[offset + --byteLength]
  1095. var mul = 1
  1096. while (byteLength > 0 && (mul *= 0x100)) {
  1097. val += this[offset + --byteLength] * mul
  1098. }
  1099. return val
  1100. }
  1101. Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
  1102. if (!noAssert) checkOffset(offset, 1, this.length)
  1103. return this[offset]
  1104. }
  1105. Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
  1106. if (!noAssert) checkOffset(offset, 2, this.length)
  1107. return this[offset] | (this[offset + 1] << 8)
  1108. }
  1109. Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
  1110. if (!noAssert) checkOffset(offset, 2, this.length)
  1111. return (this[offset] << 8) | this[offset + 1]
  1112. }
  1113. Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
  1114. if (!noAssert) checkOffset(offset, 4, this.length)
  1115. return ((this[offset]) |
  1116. (this[offset + 1] << 8) |
  1117. (this[offset + 2] << 16)) +
  1118. (this[offset + 3] * 0x1000000)
  1119. }
  1120. Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
  1121. if (!noAssert) checkOffset(offset, 4, this.length)
  1122. return (this[offset] * 0x1000000) +
  1123. ((this[offset + 1] << 16) |
  1124. (this[offset + 2] << 8) |
  1125. this[offset + 3])
  1126. }
  1127. Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
  1128. offset = offset | 0
  1129. byteLength = byteLength | 0
  1130. if (!noAssert) checkOffset(offset, byteLength, this.length)
  1131. var val = this[offset]
  1132. var mul = 1
  1133. var i = 0
  1134. while (++i < byteLength && (mul *= 0x100)) {
  1135. val += this[offset + i] * mul
  1136. }
  1137. mul *= 0x80
  1138. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  1139. return val
  1140. }
  1141. Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
  1142. offset = offset | 0
  1143. byteLength = byteLength | 0
  1144. if (!noAssert) checkOffset(offset, byteLength, this.length)
  1145. var i = byteLength
  1146. var mul = 1
  1147. var val = this[offset + --i]
  1148. while (i > 0 && (mul *= 0x100)) {
  1149. val += this[offset + --i] * mul
  1150. }
  1151. mul *= 0x80
  1152. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  1153. return val
  1154. }
  1155. Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
  1156. if (!noAssert) checkOffset(offset, 1, this.length)
  1157. if (!(this[offset] & 0x80)) return (this[offset])
  1158. return ((0xff - this[offset] + 1) * -1)
  1159. }
  1160. Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
  1161. if (!noAssert) checkOffset(offset, 2, this.length)
  1162. var val = this[offset] | (this[offset + 1] << 8)
  1163. return (val & 0x8000) ? val | 0xFFFF0000 : val
  1164. }
  1165. Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
  1166. if (!noAssert) checkOffset(offset, 2, this.length)
  1167. var val = this[offset + 1] | (this[offset] << 8)
  1168. return (val & 0x8000) ? val | 0xFFFF0000 : val
  1169. }
  1170. Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
  1171. if (!noAssert) checkOffset(offset, 4, this.length)
  1172. return (this[offset]) |
  1173. (this[offset + 1] << 8) |
  1174. (this[offset + 2] << 16) |
  1175. (this[offset + 3] << 24)
  1176. }
  1177. Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
  1178. if (!noAssert) checkOffset(offset, 4, this.length)
  1179. return (this[offset] << 24) |
  1180. (this[offset + 1] << 16) |
  1181. (this[offset + 2] << 8) |
  1182. (this[offset + 3])
  1183. }
  1184. Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
  1185. if (!noAssert) checkOffset(offset, 4, this.length)
  1186. return ieee754.read(this, offset, true, 23, 4)
  1187. }
  1188. Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
  1189. if (!noAssert) checkOffset(offset, 4, this.length)
  1190. return ieee754.read(this, offset, false, 23, 4)
  1191. }
  1192. Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
  1193. if (!noAssert) checkOffset(offset, 8, this.length)
  1194. return ieee754.read(this, offset, true, 52, 8)
  1195. }
  1196. Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
  1197. if (!noAssert) checkOffset(offset, 8, this.length)
  1198. return ieee754.read(this, offset, false, 52, 8)
  1199. }
  1200. function checkInt (buf, value, offset, ext, max, min) {
  1201. if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
  1202. if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
  1203. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  1204. }
  1205. Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
  1206. value = +value
  1207. offset = offset | 0
  1208. byteLength = byteLength | 0
  1209. if (!noAssert) {
  1210. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  1211. checkInt(this, value, offset, byteLength, maxBytes, 0)
  1212. }
  1213. var mul = 1
  1214. var i = 0
  1215. this[offset] = value & 0xFF
  1216. while (++i < byteLength && (mul *= 0x100)) {
  1217. this[offset + i] = (value / mul) & 0xFF
  1218. }
  1219. return offset + byteLength
  1220. }
  1221. Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
  1222. value = +value
  1223. offset = offset | 0
  1224. byteLength = byteLength | 0
  1225. if (!noAssert) {
  1226. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  1227. checkInt(this, value, offset, byteLength, maxBytes, 0)
  1228. }
  1229. var i = byteLength - 1
  1230. var mul = 1
  1231. this[offset + i] = value & 0xFF
  1232. while (--i >= 0 && (mul *= 0x100)) {
  1233. this[offset + i] = (value / mul) & 0xFF
  1234. }
  1235. return offset + byteLength
  1236. }
  1237. Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
  1238. value = +value
  1239. offset = offset | 0
  1240. if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
  1241. if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
  1242. this[offset] = (value & 0xff)
  1243. return offset + 1
  1244. }
  1245. function objectWriteUInt16 (buf, value, offset, littleEndian) {
  1246. if (value < 0) value = 0xffff + value + 1
  1247. for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {
  1248. buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
  1249. (littleEndian ? i : 1 - i) * 8
  1250. }
  1251. }
  1252. Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
  1253. value = +value
  1254. offset = offset | 0
  1255. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  1256. if (Buffer.TYPED_ARRAY_SUPPORT) {
  1257. this[offset] = (value & 0xff)
  1258. this[offset + 1] = (value >>> 8)
  1259. } else {
  1260. objectWriteUInt16(this, value, offset, true)
  1261. }
  1262. return offset + 2
  1263. }
  1264. Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
  1265. value = +value
  1266. offset = offset | 0
  1267. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  1268. if (Buffer.TYPED_ARRAY_SUPPORT) {
  1269. this[offset] = (value >>> 8)
  1270. this[offset + 1] = (value & 0xff)
  1271. } else {
  1272. objectWriteUInt16(this, value, offset, false)
  1273. }
  1274. return offset + 2
  1275. }
  1276. function objectWriteUInt32 (buf, value, offset, littleEndian) {
  1277. if (value < 0) value = 0xffffffff + value + 1
  1278. for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {
  1279. buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
  1280. }
  1281. }
  1282. Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
  1283. value = +value
  1284. offset = offset | 0
  1285. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  1286. if (Buffer.TYPED_ARRAY_SUPPORT) {
  1287. this[offset + 3] = (value >>> 24)
  1288. this[offset + 2] = (value >>> 16)
  1289. this[offset + 1] = (value >>> 8)
  1290. this[offset] = (value & 0xff)
  1291. } else {
  1292. objectWriteUInt32(this, value, offset, true)
  1293. }
  1294. return offset + 4
  1295. }
  1296. Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
  1297. value = +value
  1298. offset = offset | 0
  1299. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  1300. if (Buffer.TYPED_ARRAY_SUPPORT) {
  1301. this[offset] = (value >>> 24)
  1302. this[offset + 1] = (value >>> 16)
  1303. this[offset + 2] = (value >>> 8)
  1304. this[offset + 3] = (value & 0xff)
  1305. } else {
  1306. objectWriteUInt32(this, value, offset, false)
  1307. }
  1308. return offset + 4
  1309. }
  1310. Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
  1311. value = +value
  1312. offset = offset | 0
  1313. if (!noAssert) {
  1314. var limit = Math.pow(2, 8 * byteLength - 1)
  1315. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  1316. }
  1317. var i = 0
  1318. var mul = 1
  1319. var sub = 0
  1320. this[offset] = value & 0xFF
  1321. while (++i < byteLength && (mul *= 0x100)) {
  1322. if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
  1323. sub = 1
  1324. }
  1325. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  1326. }
  1327. return offset + byteLength
  1328. }
  1329. Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
  1330. value = +value
  1331. offset = offset | 0
  1332. if (!noAssert) {
  1333. var limit = Math.pow(2, 8 * byteLength - 1)
  1334. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  1335. }
  1336. var i = byteLength - 1
  1337. var mul = 1
  1338. var sub = 0
  1339. this[offset + i] = value & 0xFF
  1340. while (--i >= 0 && (mul *= 0x100)) {
  1341. if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
  1342. sub = 1
  1343. }
  1344. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  1345. }
  1346. return offset + byteLength
  1347. }
  1348. Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
  1349. value = +value
  1350. offset = offset | 0
  1351. if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
  1352. if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
  1353. if (value < 0) value = 0xff + value + 1
  1354. this[offset] = (value & 0xff)
  1355. return offset + 1
  1356. }
  1357. Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
  1358. value = +value
  1359. offset = offset | 0
  1360. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  1361. if (Buffer.TYPED_ARRAY_SUPPORT) {
  1362. this[offset] = (value & 0xff)
  1363. this[offset + 1] = (value >>> 8)
  1364. } else {
  1365. objectWriteUInt16(this, value, offset, true)
  1366. }
  1367. return offset + 2
  1368. }
  1369. Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
  1370. value = +value
  1371. offset = offset | 0
  1372. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  1373. if (Buffer.TYPED_ARRAY_SUPPORT) {
  1374. this[offset] = (value >>> 8)
  1375. this[offset + 1] = (value & 0xff)
  1376. } else {
  1377. objectWriteUInt16(this, value, offset, false)
  1378. }
  1379. return offset + 2
  1380. }
  1381. Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
  1382. value = +value
  1383. offset = offset | 0
  1384. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  1385. if (Buffer.TYPED_ARRAY_SUPPORT) {
  1386. this[offset] = (value & 0xff)
  1387. this[offset + 1] = (value >>> 8)
  1388. this[offset + 2] = (value >>> 16)
  1389. this[offset + 3] = (value >>> 24)
  1390. } else {
  1391. objectWriteUInt32(this, value, offset, true)
  1392. }
  1393. return offset + 4
  1394. }
  1395. Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
  1396. value = +value
  1397. offset = offset | 0
  1398. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  1399. if (value < 0) value = 0xffffffff + value + 1
  1400. if (Buffer.TYPED_ARRAY_SUPPORT) {
  1401. this[offset] = (value >>> 24)
  1402. this[offset + 1] = (value >>> 16)
  1403. this[offset + 2] = (value >>> 8)
  1404. this[offset + 3] = (value & 0xff)
  1405. } else {
  1406. objectWriteUInt32(this, value, offset, false)
  1407. }
  1408. return offset + 4
  1409. }
  1410. function checkIEEE754 (buf, value, offset, ext, max, min) {
  1411. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  1412. if (offset < 0) throw new RangeError('Index out of range')
  1413. }
  1414. function writeFloat (buf, value, offset, littleEndian, noAssert) {
  1415. if (!noAssert) {
  1416. checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
  1417. }
  1418. ieee754.write(buf, value, offset, littleEndian, 23, 4)
  1419. return offset + 4
  1420. }
  1421. Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
  1422. return writeFloat(this, value, offset, true, noAssert)
  1423. }
  1424. Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
  1425. return writeFloat(this, value, offset, false, noAssert)
  1426. }
  1427. function writeDouble (buf, value, offset, littleEndian, noAssert) {
  1428. if (!noAssert) {
  1429. checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
  1430. }
  1431. ieee754.write(buf, value, offset, littleEndian, 52, 8)
  1432. return offset + 8
  1433. }
  1434. Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
  1435. return writeDouble(this, value, offset, true, noAssert)
  1436. }
  1437. Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
  1438. return writeDouble(this, value, offset, false, noAssert)
  1439. }
  1440. // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
  1441. Buffer.prototype.copy = function copy (target, targetStart, start, end) {
  1442. if (!start) start = 0
  1443. if (!end && end !== 0) end = this.length
  1444. if (targetStart >= target.length) targetStart = target.length
  1445. if (!targetStart) targetStart = 0
  1446. if (end > 0 && end < start) end = start
  1447. // Copy 0 bytes; we're done
  1448. if (end === start) return 0
  1449. if (target.length === 0 || this.length === 0) return 0
  1450. // Fatal error conditions
  1451. if (targetStart < 0) {
  1452. throw new RangeError('targetStart out of bounds')
  1453. }
  1454. if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
  1455. if (end < 0) throw new RangeError('sourceEnd out of bounds')
  1456. // Are we oob?
  1457. if (end > this.length) end = this.length
  1458. if (target.length - targetStart < end - start) {
  1459. end = target.length - targetStart + start
  1460. }
  1461. var len = end - start
  1462. var i
  1463. if (this === target && start < targetStart && targetStart < end) {
  1464. // descending copy from end
  1465. for (i = len - 1; i >= 0; --i) {
  1466. target[i + targetStart] = this[i + start]
  1467. }
  1468. } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
  1469. // ascending copy from start
  1470. for (i = 0; i < len; ++i) {
  1471. target[i + targetStart] = this[i + start]
  1472. }
  1473. } else {
  1474. Uint8Array.prototype.set.call(
  1475. target,
  1476. this.subarray(start, start + len),
  1477. targetStart
  1478. )
  1479. }
  1480. return len
  1481. }
  1482. // Usage:
  1483. // buffer.fill(number[, offset[, end]])
  1484. // buffer.fill(buffer[, offset[, end]])
  1485. // buffer.fill(string[, offset[, end]][, encoding])
  1486. Buffer.prototype.fill = function fill (val, start, end, encoding) {
  1487. // Handle string cases:
  1488. if (typeof val === 'string') {
  1489. if (typeof start === 'string') {
  1490. encoding = start
  1491. start = 0
  1492. end = this.length
  1493. } else if (typeof end === 'string') {
  1494. encoding = end
  1495. end = this.length
  1496. }
  1497. if (val.length === 1) {
  1498. var code = val.charCodeAt(0)
  1499. if (code < 256) {
  1500. val = code
  1501. }
  1502. }
  1503. if (encoding !== undefined && typeof encoding !== 'string') {
  1504. throw new TypeError('encoding must be a string')
  1505. }
  1506. if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
  1507. throw new TypeError('Unknown encoding: ' + encoding)
  1508. }
  1509. } else if (typeof val === 'number') {
  1510. val = val & 255
  1511. }
  1512. // Invalid ranges are not set to a default, so can range check early.
  1513. if (start < 0 || this.length < start || this.length < end) {
  1514. throw new RangeError('Out of range index')
  1515. }
  1516. if (end <= start) {
  1517. return this
  1518. }
  1519. start = start >>> 0
  1520. end = end === undefined ? this.length : end >>> 0
  1521. if (!val) val = 0
  1522. var i
  1523. if (typeof val === 'number') {
  1524. for (i = start; i < end; ++i) {
  1525. this[i] = val
  1526. }
  1527. } else {
  1528. var bytes = Buffer.isBuffer(val)
  1529. ? val
  1530. : utf8ToBytes(new Buffer(val, encoding).toString())
  1531. var len = bytes.length
  1532. for (i = 0; i < end - start; ++i) {
  1533. this[i + start] = bytes[i % len]
  1534. }
  1535. }
  1536. return this
  1537. }
  1538. // HELPER FUNCTIONS
  1539. // ================
  1540. var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g
  1541. function base64clean (str) {
  1542. // Node strips out invalid characters like \n and \t from the string, base64-js does not
  1543. str = stringtrim(str).replace(INVALID_BASE64_RE, '')
  1544. // Node converts strings with length < 2 to ''
  1545. if (str.length < 2) return ''
  1546. // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
  1547. while (str.length % 4 !== 0) {
  1548. str = str + '='
  1549. }
  1550. return str
  1551. }
  1552. function stringtrim (str) {
  1553. if (str.trim) return str.trim()
  1554. return str.replace(/^\s+|\s+$/g, '')
  1555. }
  1556. function toHex (n) {
  1557. if (n < 16) return '0' + n.toString(16)
  1558. return n.toString(16)
  1559. }
  1560. function utf8ToBytes (string, units) {
  1561. units = units || Infinity
  1562. var codePoint
  1563. var length = string.length
  1564. var leadSurrogate = null
  1565. var bytes = []
  1566. for (var i = 0; i < length; ++i) {
  1567. codePoint = string.charCodeAt(i)
  1568. // is surrogate component
  1569. if (codePoint > 0xD7FF && codePoint < 0xE000) {
  1570. // last char was a lead
  1571. if (!leadSurrogate) {
  1572. // no lead yet
  1573. if (codePoint > 0xDBFF) {
  1574. // unexpected trail
  1575. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  1576. continue
  1577. } else if (i + 1 === length) {
  1578. // unpaired lead
  1579. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  1580. continue
  1581. }
  1582. // valid lead
  1583. leadSurrogate = codePoint
  1584. continue
  1585. }
  1586. // 2 leads in a row
  1587. if (codePoint < 0xDC00) {
  1588. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  1589. leadSurrogate = codePoint
  1590. continue
  1591. }
  1592. // valid surrogate pair
  1593. codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
  1594. } else if (leadSurrogate) {
  1595. // valid bmp char, but last char was a lead
  1596. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  1597. }
  1598. leadSurrogate = null
  1599. // encode utf8
  1600. if (codePoint < 0x80) {
  1601. if ((units -= 1) < 0) break
  1602. bytes.push(codePoint)
  1603. } else if (codePoint < 0x800) {
  1604. if ((units -= 2) < 0) break
  1605. bytes.push(
  1606. codePoint >> 0x6 | 0xC0,
  1607. codePoint & 0x3F | 0x80
  1608. )
  1609. } else if (codePoint < 0x10000) {
  1610. if ((units -= 3) < 0) break
  1611. bytes.push(
  1612. codePoint >> 0xC | 0xE0,
  1613. codePoint >> 0x6 & 0x3F | 0x80,
  1614. codePoint & 0x3F | 0x80
  1615. )
  1616. } else if (codePoint < 0x110000) {
  1617. if ((units -= 4) < 0) break
  1618. bytes.push(
  1619. codePoint >> 0x12 | 0xF0,
  1620. codePoint >> 0xC & 0x3F | 0x80,
  1621. codePoint >> 0x6 & 0x3F | 0x80,
  1622. codePoint & 0x3F | 0x80
  1623. )
  1624. } else {
  1625. throw new Error('Invalid code point')
  1626. }
  1627. }
  1628. return bytes
  1629. }
  1630. function asciiToBytes (str) {
  1631. var byteArray = []
  1632. for (var i = 0; i < str.length; ++i) {
  1633. // Node's code seems to be doing this and not & 0x7F..
  1634. byteArray.push(str.charCodeAt(i) & 0xFF)
  1635. }
  1636. return byteArray
  1637. }
  1638. function utf16leToBytes (str, units) {
  1639. var c, hi, lo
  1640. var byteArray = []
  1641. for (var i = 0; i < str.length; ++i) {
  1642. if ((units -= 2) < 0) break
  1643. c = str.charCodeAt(i)
  1644. hi = c >> 8
  1645. lo = c % 256
  1646. byteArray.push(lo)
  1647. byteArray.push(hi)
  1648. }
  1649. return byteArray
  1650. }
  1651. function base64ToBytes (str) {
  1652. return base64.toByteArray(base64clean(str))
  1653. }
  1654. function blitBuffer (src, dst, offset, length) {
  1655. for (var i = 0; i < length; ++i) {
  1656. if ((i + offset >= dst.length) || (i >= src.length)) break
  1657. dst[i + offset] = src[i]
  1658. }
  1659. return i
  1660. }
  1661. function isnan (val) {
  1662. return val !== val // eslint-disable-line no-self-compare
  1663. }
  1664. }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer)
  1665. },{"base64-js":1,"buffer":3,"ieee754":7,"isarray":9}],4:[function(require,module,exports){
  1666. // Copyright Joyent, Inc. and other Node contributors.
  1667. //
  1668. // Permission is hereby granted, free of charge, to any person obtaining a
  1669. // copy of this software and associated documentation files (the
  1670. // "Software"), to deal in the Software without restriction, including
  1671. // without limitation the rights to use, copy, modify, merge, publish,
  1672. // distribute, sublicense, and/or sell copies of the Software, and to permit
  1673. // persons to whom the Software is furnished to do so, subject to the
  1674. // following conditions:
  1675. //
  1676. // The above copyright notice and this permission notice shall be included
  1677. // in all copies or substantial portions of the Software.
  1678. //
  1679. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  1680. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  1681. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  1682. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  1683. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  1684. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  1685. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  1686. // NOTE: These type checking functions intentionally don't use `instanceof`
  1687. // because it is fragile and can be easily faked with `Object.create()`.
  1688. function isArray(arg) {
  1689. if (Array.isArray) {
  1690. return Array.isArray(arg);
  1691. }
  1692. return objectToString(arg) === '[object Array]';
  1693. }
  1694. exports.isArray = isArray;
  1695. function isBoolean(arg) {
  1696. return typeof arg === 'boolean';
  1697. }
  1698. exports.isBoolean = isBoolean;
  1699. function isNull(arg) {
  1700. return arg === null;
  1701. }
  1702. exports.isNull = isNull;
  1703. function isNullOrUndefined(arg) {
  1704. return arg == null;
  1705. }
  1706. exports.isNullOrUndefined = isNullOrUndefined;
  1707. function isNumber(arg) {
  1708. return typeof arg === 'number';
  1709. }
  1710. exports.isNumber = isNumber;
  1711. function isString(arg) {
  1712. return typeof arg === 'string';
  1713. }
  1714. exports.isString = isString;
  1715. function isSymbol(arg) {
  1716. return typeof arg === 'symbol';
  1717. }
  1718. exports.isSymbol = isSymbol;
  1719. function isUndefined(arg) {
  1720. return arg === void 0;
  1721. }
  1722. exports.isUndefined = isUndefined;
  1723. function isRegExp(re) {
  1724. return objectToString(re) === '[object RegExp]';
  1725. }
  1726. exports.isRegExp = isRegExp;
  1727. function isObject(arg) {
  1728. return typeof arg === 'object' && arg !== null;
  1729. }
  1730. exports.isObject = isObject;
  1731. function isDate(d) {
  1732. return objectToString(d) === '[object Date]';
  1733. }
  1734. exports.isDate = isDate;
  1735. function isError(e) {
  1736. return (objectToString(e) === '[object Error]' || e instanceof Error);
  1737. }
  1738. exports.isError = isError;
  1739. function isFunction(arg) {
  1740. return typeof arg === 'function';
  1741. }
  1742. exports.isFunction = isFunction;
  1743. function isPrimitive(arg) {
  1744. return arg === null ||
  1745. typeof arg === 'boolean' ||
  1746. typeof arg === 'number' ||
  1747. typeof arg === 'string' ||
  1748. typeof arg === 'symbol' || // ES6 symbol
  1749. typeof arg === 'undefined';
  1750. }
  1751. exports.isPrimitive = isPrimitive;
  1752. exports.isBuffer = require('buffer').Buffer.isBuffer;
  1753. function objectToString(o) {
  1754. return Object.prototype.toString.call(o);
  1755. }
  1756. },{"buffer":3}],5:[function(require,module,exports){
  1757. !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).dayjs=e()}(this,(function(){"use strict";var t=1e3,e=6e4,n=36e5,r="millisecond",i="second",s="minute",u="hour",a="day",o="week",c="month",f="quarter",h="year",d="date",l="Invalid Date",$=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,y=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,M={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(t){var e=["th","st","nd","rd"],n=t%100;return"["+t+(e[(n-20)%10]||e[n]||e[0])+"]"}},m=function(t,e,n){var r=String(t);return!r||r.length>=e?t:""+Array(e+1-r.length).join(n)+t},v={s:m,z:function(t){var e=-t.utcOffset(),n=Math.abs(e),r=Math.floor(n/60),i=n%60;return(e<=0?"+":"-")+m(r,2,"0")+":"+m(i,2,"0")},m:function t(e,n){if(e.date()<n.date())return-t(n,e);var r=12*(n.year()-e.year())+(n.month()-e.month()),i=e.clone().add(r,c),s=n-i<0,u=e.clone().add(r+(s?-1:1),c);return+(-(r+(n-i)/(s?i-u:u-i))||0)},a:function(t){return t<0?Math.ceil(t)||0:Math.floor(t)},p:function(t){return{M:c,y:h,w:o,d:a,D:d,h:u,m:s,s:i,ms:r,Q:f}[t]||String(t||"").toLowerCase().replace(/s$/,"")},u:function(t){return void 0===t}},g="en",D={};D[g]=M;var p="$isDayjsObject",S=function(t){return t instanceof _||!(!t||!t[p])},w=function t(e,n,r){var i;if(!e)return g;if("string"==typeof e){var s=e.toLowerCase();D[s]&&(i=s),n&&(D[s]=n,i=s);var u=e.split("-");if(!i&&u.length>1)return t(u[0])}else{var a=e.name;D[a]=e,i=a}return!r&&i&&(g=i),i||!r&&g},O=function(t,e){if(S(t))return t.clone();var n="object"==typeof e?e:{};return n.date=t,n.args=arguments,new _(n)},b=v;b.l=w,b.i=S,b.w=function(t,e){return O(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var _=function(){function M(t){this.$L=w(t.locale,null,!0),this.parse(t),this.$x=this.$x||t.x||{},this[p]=!0}var m=M.prototype;return m.parse=function(t){this.$d=function(t){var e=t.date,n=t.utc;if(null===e)return new Date(NaN);if(b.u(e))return new Date;if(e instanceof Date)return new Date(e);if("string"==typeof e&&!/Z$/i.test(e)){var r=e.match($);if(r){var i=r[2]-1||0,s=(r[7]||"0").substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)}}return new Date(e)}(t),this.init()},m.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds()},m.$utils=function(){return b},m.isValid=function(){return!(this.$d.toString()===l)},m.isSame=function(t,e){var n=O(t);return this.startOf(e)<=n&&n<=this.endOf(e)},m.isAfter=function(t,e){return O(t)<this.startOf(e)},m.isBefore=function(t,e){return this.endOf(e)<O(t)},m.$g=function(t,e,n){return b.u(t)?this[e]:this.set(n,t)},m.unix=function(){return Math.floor(this.valueOf()/1e3)},m.valueOf=function(){return this.$d.getTime()},m.startOf=function(t,e){var n=this,r=!!b.u(e)||e,f=b.p(t),l=function(t,e){var i=b.w(n.$u?Date.UTC(n.$y,e,t):new Date(n.$y,e,t),n);return r?i:i.endOf(a)},$=function(t,e){return b.w(n.toDate()[t].apply(n.toDate("s"),(r?[0,0,0,0]:[23,59,59,999]).slice(e)),n)},y=this.$W,M=this.$M,m=this.$D,v="set"+(this.$u?"UTC":"");switch(f){case h:return r?l(1,0):l(31,11);case c:return r?l(1,M):l(0,M+1);case o:var g=this.$locale().weekStart||0,D=(y<g?y+7:y)-g;return l(r?m-D:m+(6-D),M);case a:case d:return $(v+"Hours",0);case u:return $(v+"Minutes",1);case s:return $(v+"Seconds",2);case i:return $(v+"Milliseconds",3);default:return this.clone()}},m.endOf=function(t){return this.startOf(t,!1)},m.$set=function(t,e){var n,o=b.p(t),f="set"+(this.$u?"UTC":""),l=(n={},n[a]=f+"Date",n[d]=f+"Date",n[c]=f+"Month",n[h]=f+"FullYear",n[u]=f+"Hours",n[s]=f+"Minutes",n[i]=f+"Seconds",n[r]=f+"Milliseconds",n)[o],$=o===a?this.$D+(e-this.$W):e;if(o===c||o===h){var y=this.clone().set(d,1);y.$d[l]($),y.init(),this.$d=y.set(d,Math.min(this.$D,y.daysInMonth())).$d}else l&&this.$d[l]($);return this.init(),this},m.set=function(t,e){return this.clone().$set(t,e)},m.get=function(t){return this[b.p(t)]()},m.add=function(r,f){var d,l=this;r=Number(r);var $=b.p(f),y=function(t){var e=O(l);return b.w(e.date(e.date()+Math.round(t*r)),l)};if($===c)return this.set(c,this.$M+r);if($===h)return this.set(h,this.$y+r);if($===a)return y(1);if($===o)return y(7);var M=(d={},d[s]=e,d[u]=n,d[i]=t,d)[$]||1,m=this.$d.getTime()+r*M;return b.w(m,this)},m.subtract=function(t,e){return this.add(-1*t,e)},m.format=function(t){var e=this,n=this.$locale();if(!this.isValid())return n.invalidDate||l;var r=t||"YYYY-MM-DDTHH:mm:ssZ",i=b.z(this),s=this.$H,u=this.$m,a=this.$M,o=n.weekdays,c=n.months,f=n.meridiem,h=function(t,n,i,s){return t&&(t[n]||t(e,r))||i[n].slice(0,s)},d=function(t){return b.s(s%12||12,t,"0")},$=f||function(t,e,n){var r=t<12?"AM":"PM";return n?r.toLowerCase():r};return r.replace(y,(function(t,r){return r||function(t){switch(t){case"YY":return String(e.$y).slice(-2);case"YYYY":return b.s(e.$y,4,"0");case"M":return a+1;case"MM":return b.s(a+1,2,"0");case"MMM":return h(n.monthsShort,a,c,3);case"MMMM":return h(c,a);case"D":return e.$D;case"DD":return b.s(e.$D,2,"0");case"d":return String(e.$W);case"dd":return h(n.weekdaysMin,e.$W,o,2);case"ddd":return h(n.weekdaysShort,e.$W,o,3);case"dddd":return o[e.$W];case"H":return String(s);case"HH":return b.s(s,2,"0");case"h":return d(1);case"hh":return d(2);case"a":return $(s,u,!0);case"A":return $(s,u,!1);case"m":return String(u);case"mm":return b.s(u,2,"0");case"s":return String(e.$s);case"ss":return b.s(e.$s,2,"0");case"SSS":return b.s(e.$ms,3,"0");case"Z":return i}return null}(t)||i.replace(":","")}))},m.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},m.diff=function(r,d,l){var $,y=this,M=b.p(d),m=O(r),v=(m.utcOffset()-this.utcOffset())*e,g=this-m,D=function(){return b.m(y,m)};switch(M){case h:$=D()/12;break;case c:$=D();break;case f:$=D()/3;break;case o:$=(g-v)/6048e5;break;case a:$=(g-v)/864e5;break;case u:$=g/n;break;case s:$=g/e;break;case i:$=g/t;break;default:$=g}return l?$:b.a($)},m.daysInMonth=function(){return this.endOf(c).$D},m.$locale=function(){return D[this.$L]},m.locale=function(t,e){if(!t)return this.$L;var n=this.clone(),r=w(t,e,!0);return r&&(n.$L=r),n},m.clone=function(){return b.w(this.$d,this)},m.toDate=function(){return new Date(this.valueOf())},m.toJSON=function(){return this.isValid()?this.toISOString():null},m.toISOString=function(){return this.$d.toISOString()},m.toString=function(){return this.$d.toUTCString()},M}(),k=_.prototype;return O.prototype=k,[["$ms",r],["$s",i],["$m",s],["$H",u],["$W",a],["$M",c],["$y",h],["$D",d]].forEach((function(t){k[t[1]]=function(e){return this.$g(e,t[0],t[1])}})),O.extend=function(t,e){return t.$i||(t(e,_,O),t.$i=!0),O},O.locale=w,O.isDayjs=S,O.unix=function(t){return O(1e3*t)},O.en=D[g],O.Ls=D,O.p={},O}));
  1758. },{}],6:[function(require,module,exports){
  1759. // Copyright Joyent, Inc. and other Node contributors.
  1760. //
  1761. // Permission is hereby granted, free of charge, to any person obtaining a
  1762. // copy of this software and associated documentation files (the
  1763. // "Software"), to deal in the Software without restriction, including
  1764. // without limitation the rights to use, copy, modify, merge, publish,
  1765. // distribute, sublicense, and/or sell copies of the Software, and to permit
  1766. // persons to whom the Software is furnished to do so, subject to the
  1767. // following conditions:
  1768. //
  1769. // The above copyright notice and this permission notice shall be included
  1770. // in all copies or substantial portions of the Software.
  1771. //
  1772. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  1773. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  1774. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  1775. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  1776. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  1777. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  1778. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  1779. function EventEmitter() {
  1780. this._events = this._events || {};
  1781. this._maxListeners = this._maxListeners || undefined;
  1782. }
  1783. module.exports = EventEmitter;
  1784. // Backwards-compat with node 0.10.x
  1785. EventEmitter.EventEmitter = EventEmitter;
  1786. EventEmitter.prototype._events = undefined;
  1787. EventEmitter.prototype._maxListeners = undefined;
  1788. // By default EventEmitters will print a warning if more than 10 listeners are
  1789. // added to it. This is a useful default which helps finding memory leaks.
  1790. EventEmitter.defaultMaxListeners = 10;
  1791. // Obviously not all Emitters should be limited to 10. This function allows
  1792. // that to be increased. Set to zero for unlimited.
  1793. EventEmitter.prototype.setMaxListeners = function(n) {
  1794. if (!isNumber(n) || n < 0 || isNaN(n))
  1795. throw TypeError('n must be a positive number');
  1796. this._maxListeners = n;
  1797. return this;
  1798. };
  1799. EventEmitter.prototype.emit = function(type) {
  1800. var er, handler, len, args, i, listeners;
  1801. if (!this._events)
  1802. this._events = {};
  1803. // If there is no 'error' event listener then throw.
  1804. if (type === 'error') {
  1805. if (!this._events.error ||
  1806. (isObject(this._events.error) && !this._events.error.length)) {
  1807. er = arguments[1];
  1808. if (er instanceof Error) {
  1809. throw er; // Unhandled 'error' event
  1810. } else {
  1811. // At least give some kind of context to the user
  1812. var err = new Error('Uncaught, unspecified "error" event. (' + er + ')');
  1813. err.context = er;
  1814. throw err;
  1815. }
  1816. }
  1817. }
  1818. handler = this._events[type];
  1819. if (isUndefined(handler))
  1820. return false;
  1821. if (isFunction(handler)) {
  1822. switch (arguments.length) {
  1823. // fast cases
  1824. case 1:
  1825. handler.call(this);
  1826. break;
  1827. case 2:
  1828. handler.call(this, arguments[1]);
  1829. break;
  1830. case 3:
  1831. handler.call(this, arguments[1], arguments[2]);
  1832. break;
  1833. // slower
  1834. default:
  1835. args = Array.prototype.slice.call(arguments, 1);
  1836. handler.apply(this, args);
  1837. }
  1838. } else if (isObject(handler)) {
  1839. args = Array.prototype.slice.call(arguments, 1);
  1840. listeners = handler.slice();
  1841. len = listeners.length;
  1842. for (i = 0; i < len; i++)
  1843. listeners[i].apply(this, args);
  1844. }
  1845. return true;
  1846. };
  1847. EventEmitter.prototype.addListener = function(type, listener) {
  1848. var m;
  1849. if (!isFunction(listener))
  1850. throw TypeError('listener must be a function');
  1851. if (!this._events)
  1852. this._events = {};
  1853. // To avoid recursion in the case that type === "newListener"! Before
  1854. // adding it to the listeners, first emit "newListener".
  1855. if (this._events.newListener)
  1856. this.emit('newListener', type,
  1857. isFunction(listener.listener) ?
  1858. listener.listener : listener);
  1859. if (!this._events[type])
  1860. // Optimize the case of one listener. Don't need the extra array object.
  1861. this._events[type] = listener;
  1862. else if (isObject(this._events[type]))
  1863. // If we've already got an array, just append.
  1864. this._events[type].push(listener);
  1865. else
  1866. // Adding the second element, need to change to array.
  1867. this._events[type] = [this._events[type], listener];
  1868. // Check for listener leak
  1869. if (isObject(this._events[type]) && !this._events[type].warned) {
  1870. if (!isUndefined(this._maxListeners)) {
  1871. m = this._maxListeners;
  1872. } else {
  1873. m = EventEmitter.defaultMaxListeners;
  1874. }
  1875. if (m && m > 0 && this._events[type].length > m) {
  1876. this._events[type].warned = true;
  1877. console.error('(node) warning: possible EventEmitter memory ' +
  1878. 'leak detected. %d listeners added. ' +
  1879. 'Use emitter.setMaxListeners() to increase limit.',
  1880. this._events[type].length);
  1881. if (typeof console.trace === 'function') {
  1882. // not supported in IE 10
  1883. console.trace();
  1884. }
  1885. }
  1886. }
  1887. return this;
  1888. };
  1889. EventEmitter.prototype.on = EventEmitter.prototype.addListener;
  1890. EventEmitter.prototype.once = function(type, listener) {
  1891. if (!isFunction(listener))
  1892. throw TypeError('listener must be a function');
  1893. var fired = false;
  1894. function g() {
  1895. this.removeListener(type, g);
  1896. if (!fired) {
  1897. fired = true;
  1898. listener.apply(this, arguments);
  1899. }
  1900. }
  1901. g.listener = listener;
  1902. this.on(type, g);
  1903. return this;
  1904. };
  1905. // emits a 'removeListener' event iff the listener was removed
  1906. EventEmitter.prototype.removeListener = function(type, listener) {
  1907. var list, position, length, i;
  1908. if (!isFunction(listener))
  1909. throw TypeError('listener must be a function');
  1910. if (!this._events || !this._events[type])
  1911. return this;
  1912. list = this._events[type];
  1913. length = list.length;
  1914. position = -1;
  1915. if (list === listener ||
  1916. (isFunction(list.listener) && list.listener === listener)) {
  1917. delete this._events[type];
  1918. if (this._events.removeListener)
  1919. this.emit('removeListener', type, listener);
  1920. } else if (isObject(list)) {
  1921. for (i = length; i-- > 0;) {
  1922. if (list[i] === listener ||
  1923. (list[i].listener && list[i].listener === listener)) {
  1924. position = i;
  1925. break;
  1926. }
  1927. }
  1928. if (position < 0)
  1929. return this;
  1930. if (list.length === 1) {
  1931. list.length = 0;
  1932. delete this._events[type];
  1933. } else {
  1934. list.splice(position, 1);
  1935. }
  1936. if (this._events.removeListener)
  1937. this.emit('removeListener', type, listener);
  1938. }
  1939. return this;
  1940. };
  1941. EventEmitter.prototype.removeAllListeners = function(type) {
  1942. var key, listeners;
  1943. if (!this._events)
  1944. return this;
  1945. // not listening for removeListener, no need to emit
  1946. if (!this._events.removeListener) {
  1947. if (arguments.length === 0)
  1948. this._events = {};
  1949. else if (this._events[type])
  1950. delete this._events[type];
  1951. return this;
  1952. }
  1953. // emit removeListener for all listeners on all events
  1954. if (arguments.length === 0) {
  1955. for (key in this._events) {
  1956. if (key === 'removeListener') continue;
  1957. this.removeAllListeners(key);
  1958. }
  1959. this.removeAllListeners('removeListener');
  1960. this._events = {};
  1961. return this;
  1962. }
  1963. listeners = this._events[type];
  1964. if (isFunction(listeners)) {
  1965. this.removeListener(type, listeners);
  1966. } else if (listeners) {
  1967. // LIFO order
  1968. while (listeners.length)
  1969. this.removeListener(type, listeners[listeners.length - 1]);
  1970. }
  1971. delete this._events[type];
  1972. return this;
  1973. };
  1974. EventEmitter.prototype.listeners = function(type) {
  1975. var ret;
  1976. if (!this._events || !this._events[type])
  1977. ret = [];
  1978. else if (isFunction(this._events[type]))
  1979. ret = [this._events[type]];
  1980. else
  1981. ret = this._events[type].slice();
  1982. return ret;
  1983. };
  1984. EventEmitter.prototype.listenerCount = function(type) {
  1985. if (this._events) {
  1986. var evlistener = this._events[type];
  1987. if (isFunction(evlistener))
  1988. return 1;
  1989. else if (evlistener)
  1990. return evlistener.length;
  1991. }
  1992. return 0;
  1993. };
  1994. EventEmitter.listenerCount = function(emitter, type) {
  1995. return emitter.listenerCount(type);
  1996. };
  1997. function isFunction(arg) {
  1998. return typeof arg === 'function';
  1999. }
  2000. function isNumber(arg) {
  2001. return typeof arg === 'number';
  2002. }
  2003. function isObject(arg) {
  2004. return typeof arg === 'object' && arg !== null;
  2005. }
  2006. function isUndefined(arg) {
  2007. return arg === void 0;
  2008. }
  2009. },{}],7:[function(require,module,exports){
  2010. /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
  2011. exports.read = function (buffer, offset, isLE, mLen, nBytes) {
  2012. var e, m
  2013. var eLen = (nBytes * 8) - mLen - 1
  2014. var eMax = (1 << eLen) - 1
  2015. var eBias = eMax >> 1
  2016. var nBits = -7
  2017. var i = isLE ? (nBytes - 1) : 0
  2018. var d = isLE ? -1 : 1
  2019. var s = buffer[offset + i]
  2020. i += d
  2021. e = s & ((1 << (-nBits)) - 1)
  2022. s >>= (-nBits)
  2023. nBits += eLen
  2024. for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  2025. m = e & ((1 << (-nBits)) - 1)
  2026. e >>= (-nBits)
  2027. nBits += mLen
  2028. for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  2029. if (e === 0) {
  2030. e = 1 - eBias
  2031. } else if (e === eMax) {
  2032. return m ? NaN : ((s ? -1 : 1) * Infinity)
  2033. } else {
  2034. m = m + Math.pow(2, mLen)
  2035. e = e - eBias
  2036. }
  2037. return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
  2038. }
  2039. exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
  2040. var e, m, c
  2041. var eLen = (nBytes * 8) - mLen - 1
  2042. var eMax = (1 << eLen) - 1
  2043. var eBias = eMax >> 1
  2044. var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
  2045. var i = isLE ? 0 : (nBytes - 1)
  2046. var d = isLE ? 1 : -1
  2047. var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
  2048. value = Math.abs(value)
  2049. if (isNaN(value) || value === Infinity) {
  2050. m = isNaN(value) ? 1 : 0
  2051. e = eMax
  2052. } else {
  2053. e = Math.floor(Math.log(value) / Math.LN2)
  2054. if (value * (c = Math.pow(2, -e)) < 1) {
  2055. e--
  2056. c *= 2
  2057. }
  2058. if (e + eBias >= 1) {
  2059. value += rt / c
  2060. } else {
  2061. value += rt * Math.pow(2, 1 - eBias)
  2062. }
  2063. if (value * c >= 2) {
  2064. e++
  2065. c /= 2
  2066. }
  2067. if (e + eBias >= eMax) {
  2068. m = 0
  2069. e = eMax
  2070. } else if (e + eBias >= 1) {
  2071. m = ((value * c) - 1) * Math.pow(2, mLen)
  2072. e = e + eBias
  2073. } else {
  2074. m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
  2075. e = 0
  2076. }
  2077. }
  2078. for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
  2079. e = (e << mLen) | m
  2080. eLen += mLen
  2081. for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
  2082. buffer[offset + i - d] |= s * 128
  2083. }
  2084. },{}],8:[function(require,module,exports){
  2085. if (typeof Object.create === 'function') {
  2086. // implementation from standard node.js 'util' module
  2087. module.exports = function inherits(ctor, superCtor) {
  2088. if (superCtor) {
  2089. ctor.super_ = superCtor
  2090. ctor.prototype = Object.create(superCtor.prototype, {
  2091. constructor: {
  2092. value: ctor,
  2093. enumerable: false,
  2094. writable: true,
  2095. configurable: true
  2096. }
  2097. })
  2098. }
  2099. };
  2100. } else {
  2101. // old school shim for old browsers
  2102. module.exports = function inherits(ctor, superCtor) {
  2103. if (superCtor) {
  2104. ctor.super_ = superCtor
  2105. var TempCtor = function () {}
  2106. TempCtor.prototype = superCtor.prototype
  2107. ctor.prototype = new TempCtor()
  2108. ctor.prototype.constructor = ctor
  2109. }
  2110. }
  2111. }
  2112. },{}],9:[function(require,module,exports){
  2113. var toString = {}.toString;
  2114. module.exports = Array.isArray || function (arr) {
  2115. return toString.call(arr) == '[object Array]';
  2116. };
  2117. },{}],10:[function(require,module,exports){
  2118. (function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,setImmediate){(function (){
  2119. /*!
  2120. JSZip v3.10.1 - A JavaScript class for generating and reading zip files
  2121. <http://stuartk.com/jszip>
  2122. (c) 2009-2016 Stuart Knightley <stuart [at] stuartk.com>
  2123. Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/main/LICENSE.markdown.
  2124. JSZip uses the library pako released under the MIT license :
  2125. https://github.com/nodeca/pako/blob/main/LICENSE
  2126. */
  2127. !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).JSZip=e()}}(function(){return function s(a,o,h){function u(r,e){if(!o[r]){if(!a[r]){var t="function"==typeof require&&require;if(!e&&t)return t(r,!0);if(l)return l(r,!0);var n=new Error("Cannot find module '"+r+"'");throw n.code="MODULE_NOT_FOUND",n}var i=o[r]={exports:{}};a[r][0].call(i.exports,function(e){var t=a[r][1][e];return u(t||e)},i,i.exports,s,a,o,h)}return o[r].exports}for(var l="function"==typeof require&&require,e=0;e<h.length;e++)u(h[e]);return u}({1:[function(e,t,r){"use strict";var d=e("./utils"),c=e("./support"),p="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";r.encode=function(e){for(var t,r,n,i,s,a,o,h=[],u=0,l=e.length,f=l,c="string"!==d.getTypeOf(e);u<e.length;)f=l-u,n=c?(t=e[u++],r=u<l?e[u++]:0,u<l?e[u++]:0):(t=e.charCodeAt(u++),r=u<l?e.charCodeAt(u++):0,u<l?e.charCodeAt(u++):0),i=t>>2,s=(3&t)<<4|r>>4,a=1<f?(15&r)<<2|n>>6:64,o=2<f?63&n:64,h.push(p.charAt(i)+p.charAt(s)+p.charAt(a)+p.charAt(o));return h.join("")},r.decode=function(e){var t,r,n,i,s,a,o=0,h=0,u="data:";if(e.substr(0,u.length)===u)throw new Error("Invalid base64 input, it looks like a data url.");var l,f=3*(e=e.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(e.charAt(e.length-1)===p.charAt(64)&&f--,e.charAt(e.length-2)===p.charAt(64)&&f--,f%1!=0)throw new Error("Invalid base64 input, bad content length.");for(l=c.uint8array?new Uint8Array(0|f):new Array(0|f);o<e.length;)t=p.indexOf(e.charAt(o++))<<2|(i=p.indexOf(e.charAt(o++)))>>4,r=(15&i)<<4|(s=p.indexOf(e.charAt(o++)))>>2,n=(3&s)<<6|(a=p.indexOf(e.charAt(o++))),l[h++]=t,64!==s&&(l[h++]=r),64!==a&&(l[h++]=n);return l}},{"./support":30,"./utils":32}],2:[function(e,t,r){"use strict";var n=e("./external"),i=e("./stream/DataWorker"),s=e("./stream/Crc32Probe"),a=e("./stream/DataLengthProbe");function o(e,t,r,n,i){this.compressedSize=e,this.uncompressedSize=t,this.crc32=r,this.compression=n,this.compressedContent=i}o.prototype={getContentWorker:function(){var e=new i(n.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new a("data_length")),t=this;return e.on("end",function(){if(this.streamInfo.data_length!==t.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),e},getCompressedWorker:function(){return new i(n.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},o.createWorkerFrom=function(e,t,r){return e.pipe(new s).pipe(new a("uncompressedSize")).pipe(t.compressWorker(r)).pipe(new a("compressedSize")).withStreamInfo("compression",t)},t.exports=o},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(e,t,r){"use strict";var n=e("./stream/GenericWorker");r.STORE={magic:"\0\0",compressWorker:function(){return new n("STORE compression")},uncompressWorker:function(){return new n("STORE decompression")}},r.DEFLATE=e("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(e,t,r){"use strict";var n=e("./utils");var o=function(){for(var e,t=[],r=0;r<256;r++){e=r;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[r]=e}return t}();t.exports=function(e,t){return void 0!==e&&e.length?"string"!==n.getTypeOf(e)?function(e,t,r,n){var i=o,s=n+r;e^=-1;for(var a=n;a<s;a++)e=e>>>8^i[255&(e^t[a])];return-1^e}(0|t,e,e.length,0):function(e,t,r,n){var i=o,s=n+r;e^=-1;for(var a=n;a<s;a++)e=e>>>8^i[255&(e^t.charCodeAt(a))];return-1^e}(0|t,e,e.length,0):0}},{"./utils":32}],5:[function(e,t,r){"use strict";r.base64=!1,r.binary=!1,r.dir=!1,r.createFolders=!0,r.date=null,r.compression=null,r.compressionOptions=null,r.comment=null,r.unixPermissions=null,r.dosPermissions=null},{}],6:[function(e,t,r){"use strict";var n=null;n="undefined"!=typeof Promise?Promise:e("lie"),t.exports={Promise:n}},{lie:37}],7:[function(e,t,r){"use strict";var n="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array,i=e("pako"),s=e("./utils"),a=e("./stream/GenericWorker"),o=n?"uint8array":"array";function h(e,t){a.call(this,"FlateWorker/"+e),this._pako=null,this._pakoAction=e,this._pakoOptions=t,this.meta={}}r.magic="\b\0",s.inherits(h,a),h.prototype.processChunk=function(e){this.meta=e.meta,null===this._pako&&this._createPako(),this._pako.push(s.transformTo(o,e.data),!1)},h.prototype.flush=function(){a.prototype.flush.call(this),null===this._pako&&this._createPako(),this._pako.push([],!0)},h.prototype.cleanUp=function(){a.prototype.cleanUp.call(this),this._pako=null},h.prototype._createPako=function(){this._pako=new i[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var t=this;this._pako.onData=function(e){t.push({data:e,meta:t.meta})}},r.compressWorker=function(e){return new h("Deflate",e)},r.uncompressWorker=function(){return new h("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(e,t,r){"use strict";function A(e,t){var r,n="";for(r=0;r<t;r++)n+=String.fromCharCode(255&e),e>>>=8;return n}function n(e,t,r,n,i,s){var a,o,h=e.file,u=e.compression,l=s!==O.utf8encode,f=I.transformTo("string",s(h.name)),c=I.transformTo("string",O.utf8encode(h.name)),d=h.comment,p=I.transformTo("string",s(d)),m=I.transformTo("string",O.utf8encode(d)),_=c.length!==h.name.length,g=m.length!==d.length,b="",v="",y="",w=h.dir,k=h.date,x={crc32:0,compressedSize:0,uncompressedSize:0};t&&!r||(x.crc32=e.crc32,x.compressedSize=e.compressedSize,x.uncompressedSize=e.uncompressedSize);var S=0;t&&(S|=8),l||!_&&!g||(S|=2048);var z=0,C=0;w&&(z|=16),"UNIX"===i?(C=798,z|=function(e,t){var r=e;return e||(r=t?16893:33204),(65535&r)<<16}(h.unixPermissions,w)):(C=20,z|=function(e){return 63&(e||0)}(h.dosPermissions)),a=k.getUTCHours(),a<<=6,a|=k.getUTCMinutes(),a<<=5,a|=k.getUTCSeconds()/2,o=k.getUTCFullYear()-1980,o<<=4,o|=k.getUTCMonth()+1,o<<=5,o|=k.getUTCDate(),_&&(v=A(1,1)+A(B(f),4)+c,b+="up"+A(v.length,2)+v),g&&(y=A(1,1)+A(B(p),4)+m,b+="uc"+A(y.length,2)+y);var E="";return E+="\n\0",E+=A(S,2),E+=u.magic,E+=A(a,2),E+=A(o,2),E+=A(x.crc32,4),E+=A(x.compressedSize,4),E+=A(x.uncompressedSize,4),E+=A(f.length,2),E+=A(b.length,2),{fileRecord:R.LOCAL_FILE_HEADER+E+f+b,dirRecord:R.CENTRAL_FILE_HEADER+A(C,2)+E+A(p.length,2)+"\0\0\0\0"+A(z,4)+A(n,4)+f+b+p}}var I=e("../utils"),i=e("../stream/GenericWorker"),O=e("../utf8"),B=e("../crc32"),R=e("../signature");function s(e,t,r,n){i.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=t,this.zipPlatform=r,this.encodeFileName=n,this.streamFiles=e,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}I.inherits(s,i),s.prototype.push=function(e){var t=e.meta.percent||0,r=this.entriesCount,n=this._sources.length;this.accumulate?this.contentBuffer.push(e):(this.bytesWritten+=e.data.length,i.prototype.push.call(this,{data:e.data,meta:{currentFile:this.currentFile,percent:r?(t+100*(r-n-1))/r:100}}))},s.prototype.openedSource=function(e){this.currentSourceOffset=this.bytesWritten,this.currentFile=e.file.name;var t=this.streamFiles&&!e.file.dir;if(t){var r=n(e,t,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:r.fileRecord,meta:{percent:0}})}else this.accumulate=!0},s.prototype.closedSource=function(e){this.accumulate=!1;var t=this.streamFiles&&!e.file.dir,r=n(e,t,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(r.dirRecord),t)this.push({data:function(e){return R.DATA_DESCRIPTOR+A(e.crc32,4)+A(e.compressedSize,4)+A(e.uncompressedSize,4)}(e),meta:{percent:100}});else for(this.push({data:r.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},s.prototype.flush=function(){for(var e=this.bytesWritten,t=0;t<this.dirRecords.length;t++)this.push({data:this.dirRecords[t],meta:{percent:100}});var r=this.bytesWritten-e,n=function(e,t,r,n,i){var s=I.transformTo("string",i(n));return R.CENTRAL_DIRECTORY_END+"\0\0\0\0"+A(e,2)+A(e,2)+A(t,4)+A(r,4)+A(s.length,2)+s}(this.dirRecords.length,r,e,this.zipComment,this.encodeFileName);this.push({data:n,meta:{percent:100}})},s.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},s.prototype.registerPrevious=function(e){this._sources.push(e);var t=this;return e.on("data",function(e){t.processChunk(e)}),e.on("end",function(){t.closedSource(t.previous.streamInfo),t._sources.length?t.prepareNextSource():t.end()}),e.on("error",function(e){t.error(e)}),this},s.prototype.resume=function(){return!!i.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},s.prototype.error=function(e){var t=this._sources;if(!i.prototype.error.call(this,e))return!1;for(var r=0;r<t.length;r++)try{t[r].error(e)}catch(e){}return!0},s.prototype.lock=function(){i.prototype.lock.call(this);for(var e=this._sources,t=0;t<e.length;t++)e[t].lock()},t.exports=s},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(e,t,r){"use strict";var u=e("../compressions"),n=e("./ZipFileWorker");r.generateWorker=function(e,a,t){var o=new n(a.streamFiles,t,a.platform,a.encodeFileName),h=0;try{e.forEach(function(e,t){h++;var r=function(e,t){var r=e||t,n=u[r];if(!n)throw new Error(r+" is not a valid compression method !");return n}(t.options.compression,a.compression),n=t.options.compressionOptions||a.compressionOptions||{},i=t.dir,s=t.date;t._compressWorker(r,n).withStreamInfo("file",{name:e,dir:i,date:s,comment:t.comment||"",unixPermissions:t.unixPermissions,dosPermissions:t.dosPermissions}).pipe(o)}),o.entriesCount=h}catch(e){o.error(e)}return o}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(e,t,r){"use strict";function n(){if(!(this instanceof n))return new n;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var e=new n;for(var t in this)"function"!=typeof this[t]&&(e[t]=this[t]);return e}}(n.prototype=e("./object")).loadAsync=e("./load"),n.support=e("./support"),n.defaults=e("./defaults"),n.version="3.10.1",n.loadAsync=function(e,t){return(new n).loadAsync(e,t)},n.external=e("./external"),t.exports=n},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(e,t,r){"use strict";var u=e("./utils"),i=e("./external"),n=e("./utf8"),s=e("./zipEntries"),a=e("./stream/Crc32Probe"),l=e("./nodejsUtils");function f(n){return new i.Promise(function(e,t){var r=n.decompressed.getContentWorker().pipe(new a);r.on("error",function(e){t(e)}).on("end",function(){r.streamInfo.crc32!==n.decompressed.crc32?t(new Error("Corrupted zip : CRC32 mismatch")):e()}).resume()})}t.exports=function(e,o){var h=this;return o=u.extend(o||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:n.utf8decode}),l.isNode&&l.isStream(e)?i.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):u.prepareContent("the loaded zip file",e,!0,o.optimizedBinaryString,o.base64).then(function(e){var t=new s(o);return t.load(e),t}).then(function(e){var t=[i.Promise.resolve(e)],r=e.files;if(o.checkCRC32)for(var n=0;n<r.length;n++)t.push(f(r[n]));return i.Promise.all(t)}).then(function(e){for(var t=e.shift(),r=t.files,n=0;n<r.length;n++){var i=r[n],s=i.fileNameStr,a=u.resolve(i.fileNameStr);h.file(a,i.decompressed,{binary:!0,optimizedBinaryString:!0,date:i.date,dir:i.dir,comment:i.fileCommentStr.length?i.fileCommentStr:null,unixPermissions:i.unixPermissions,dosPermissions:i.dosPermissions,createFolders:o.createFolders}),i.dir||(h.file(a).unsafeOriginalName=s)}return t.zipComment.length&&(h.comment=t.zipComment),h})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(e,t,r){"use strict";var n=e("../utils"),i=e("../stream/GenericWorker");function s(e,t){i.call(this,"Nodejs stream input adapter for "+e),this._upstreamEnded=!1,this._bindStream(t)}n.inherits(s,i),s.prototype._bindStream=function(e){var t=this;(this._stream=e).pause(),e.on("data",function(e){t.push({data:e,meta:{percent:0}})}).on("error",function(e){t.isPaused?this.generatedError=e:t.error(e)}).on("end",function(){t.isPaused?t._upstreamEnded=!0:t.end()})},s.prototype.pause=function(){return!!i.prototype.pause.call(this)&&(this._stream.pause(),!0)},s.prototype.resume=function(){return!!i.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},t.exports=s},{"../stream/GenericWorker":28,"../utils":32}],13:[function(e,t,r){"use strict";var i=e("readable-stream").Readable;function n(e,t,r){i.call(this,t),this._helper=e;var n=this;e.on("data",function(e,t){n.push(e)||n._helper.pause(),r&&r(t)}).on("error",function(e){n.emit("error",e)}).on("end",function(){n.push(null)})}e("../utils").inherits(n,i),n.prototype._read=function(){this._helper.resume()},t.exports=n},{"../utils":32,"readable-stream":16}],14:[function(e,t,r){"use strict";t.exports={isNode:"undefined"!=typeof Buffer,newBufferFrom:function(e,t){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(e,t);if("number"==typeof e)throw new Error('The "data" argument must not be a number');return new Buffer(e,t)},allocBuffer:function(e){if(Buffer.alloc)return Buffer.alloc(e);var t=new Buffer(e);return t.fill(0),t},isBuffer:function(e){return Buffer.isBuffer(e)},isStream:function(e){return e&&"function"==typeof e.on&&"function"==typeof e.pause&&"function"==typeof e.resume}}},{}],15:[function(e,t,r){"use strict";function s(e,t,r){var n,i=u.getTypeOf(t),s=u.extend(r||{},f);s.date=s.date||new Date,null!==s.compression&&(s.compression=s.compression.toUpperCase()),"string"==typeof s.unixPermissions&&(s.unixPermissions=parseInt(s.unixPermissions,8)),s.unixPermissions&&16384&s.unixPermissions&&(s.dir=!0),s.dosPermissions&&16&s.dosPermissions&&(s.dir=!0),s.dir&&(e=g(e)),s.createFolders&&(n=_(e))&&b.call(this,n,!0);var a="string"===i&&!1===s.binary&&!1===s.base64;r&&void 0!==r.binary||(s.binary=!a),(t instanceof c&&0===t.uncompressedSize||s.dir||!t||0===t.length)&&(s.base64=!1,s.binary=!0,t="",s.compression="STORE",i="string");var o=null;o=t instanceof c||t instanceof l?t:p.isNode&&p.isStream(t)?new m(e,t):u.prepareContent(e,t,s.binary,s.optimizedBinaryString,s.base64);var h=new d(e,o,s);this.files[e]=h}var i=e("./utf8"),u=e("./utils"),l=e("./stream/GenericWorker"),a=e("./stream/StreamHelper"),f=e("./defaults"),c=e("./compressedObject"),d=e("./zipObject"),o=e("./generate"),p=e("./nodejsUtils"),m=e("./nodejs/NodejsStreamInputAdapter"),_=function(e){"/"===e.slice(-1)&&(e=e.substring(0,e.length-1));var t=e.lastIndexOf("/");return 0<t?e.substring(0,t):""},g=function(e){return"/"!==e.slice(-1)&&(e+="/"),e},b=function(e,t){return t=void 0!==t?t:f.createFolders,e=g(e),this.files[e]||s.call(this,e,null,{dir:!0,createFolders:t}),this.files[e]};function h(e){return"[object RegExp]"===Object.prototype.toString.call(e)}var n={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(e){var t,r,n;for(t in this.files)n=this.files[t],(r=t.slice(this.root.length,t.length))&&t.slice(0,this.root.length)===this.root&&e(r,n)},filter:function(r){var n=[];return this.forEach(function(e,t){r(e,t)&&n.push(t)}),n},file:function(e,t,r){if(1!==arguments.length)return e=this.root+e,s.call(this,e,t,r),this;if(h(e)){var n=e;return this.filter(function(e,t){return!t.dir&&n.test(e)})}var i=this.files[this.root+e];return i&&!i.dir?i:null},folder:function(r){if(!r)return this;if(h(r))return this.filter(function(e,t){return t.dir&&r.test(e)});var e=this.root+r,t=b.call(this,e),n=this.clone();return n.root=t.name,n},remove:function(r){r=this.root+r;var e=this.files[r];if(e||("/"!==r.slice(-1)&&(r+="/"),e=this.files[r]),e&&!e.dir)delete this.files[r];else for(var t=this.filter(function(e,t){return t.name.slice(0,r.length)===r}),n=0;n<t.length;n++)delete this.files[t[n].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(e){var t,r={};try{if((r=u.extend(e||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:i.utf8encode})).type=r.type.toLowerCase(),r.compression=r.compression.toUpperCase(),"binarystring"===r.type&&(r.type="string"),!r.type)throw new Error("No output type specified.");u.checkSupport(r.type),"darwin"!==r.platform&&"freebsd"!==r.platform&&"linux"!==r.platform&&"sunos"!==r.platform||(r.platform="UNIX"),"win32"===r.platform&&(r.platform="DOS");var n=r.comment||this.comment||"";t=o.generateWorker(this,r,n)}catch(e){(t=new l("error")).error(e)}return new a(t,r.type||"string",r.mimeType)},generateAsync:function(e,t){return this.generateInternalStream(e).accumulate(t)},generateNodeStream:function(e,t){return(e=e||{}).type||(e.type="nodebuffer"),this.generateInternalStream(e).toNodejsStream(t)}};t.exports=n},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(e,t,r){"use strict";t.exports=e("stream")},{stream:void 0}],17:[function(e,t,r){"use strict";var n=e("./DataReader");function i(e){n.call(this,e);for(var t=0;t<this.data.length;t++)e[t]=255&e[t]}e("../utils").inherits(i,n),i.prototype.byteAt=function(e){return this.data[this.zero+e]},i.prototype.lastIndexOfSignature=function(e){for(var t=e.charCodeAt(0),r=e.charCodeAt(1),n=e.charCodeAt(2),i=e.charCodeAt(3),s=this.length-4;0<=s;--s)if(this.data[s]===t&&this.data[s+1]===r&&this.data[s+2]===n&&this.data[s+3]===i)return s-this.zero;return-1},i.prototype.readAndCheckSignature=function(e){var t=e.charCodeAt(0),r=e.charCodeAt(1),n=e.charCodeAt(2),i=e.charCodeAt(3),s=this.readData(4);return t===s[0]&&r===s[1]&&n===s[2]&&i===s[3]},i.prototype.readData=function(e){if(this.checkOffset(e),0===e)return[];var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i},{"../utils":32,"./DataReader":18}],18:[function(e,t,r){"use strict";var n=e("../utils");function i(e){this.data=e,this.length=e.length,this.index=0,this.zero=0}i.prototype={checkOffset:function(e){this.checkIndex(this.index+e)},checkIndex:function(e){if(this.length<this.zero+e||e<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+e+"). Corrupted zip ?")},setIndex:function(e){this.checkIndex(e),this.index=e},skip:function(e){this.setIndex(this.index+e)},byteAt:function(){},readInt:function(e){var t,r=0;for(this.checkOffset(e),t=this.index+e-1;t>=this.index;t--)r=(r<<8)+this.byteAt(t);return this.index+=e,r},readString:function(e){return n.transformTo("string",this.readData(e))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var e=this.readInt(4);return new Date(Date.UTC(1980+(e>>25&127),(e>>21&15)-1,e>>16&31,e>>11&31,e>>5&63,(31&e)<<1))}},t.exports=i},{"../utils":32}],19:[function(e,t,r){"use strict";var n=e("./Uint8ArrayReader");function i(e){n.call(this,e)}e("../utils").inherits(i,n),i.prototype.readData=function(e){this.checkOffset(e);var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(e,t,r){"use strict";var n=e("./DataReader");function i(e){n.call(this,e)}e("../utils").inherits(i,n),i.prototype.byteAt=function(e){return this.data.charCodeAt(this.zero+e)},i.prototype.lastIndexOfSignature=function(e){return this.data.lastIndexOf(e)-this.zero},i.prototype.readAndCheckSignature=function(e){return e===this.readData(4)},i.prototype.readData=function(e){this.checkOffset(e);var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i},{"../utils":32,"./DataReader":18}],21:[function(e,t,r){"use strict";var n=e("./ArrayReader");function i(e){n.call(this,e)}e("../utils").inherits(i,n),i.prototype.readData=function(e){if(this.checkOffset(e),0===e)return new Uint8Array(0);var t=this.data.subarray(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i},{"../utils":32,"./ArrayReader":17}],22:[function(e,t,r){"use strict";var n=e("../utils"),i=e("../support"),s=e("./ArrayReader"),a=e("./StringReader"),o=e("./NodeBufferReader"),h=e("./Uint8ArrayReader");t.exports=function(e){var t=n.getTypeOf(e);return n.checkSupport(t),"string"!==t||i.uint8array?"nodebuffer"===t?new o(e):i.uint8array?new h(n.transformTo("uint8array",e)):new s(n.transformTo("array",e)):new a(e)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(e,t,r){"use strict";r.LOCAL_FILE_HEADER="PK",r.CENTRAL_FILE_HEADER="PK",r.CENTRAL_DIRECTORY_END="PK",r.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK",r.ZIP64_CENTRAL_DIRECTORY_END="PK",r.DATA_DESCRIPTOR="PK\b"},{}],24:[function(e,t,r){"use strict";var n=e("./GenericWorker"),i=e("../utils");function s(e){n.call(this,"ConvertWorker to "+e),this.destType=e}i.inherits(s,n),s.prototype.processChunk=function(e){this.push({data:i.transformTo(this.destType,e.data),meta:e.meta})},t.exports=s},{"../utils":32,"./GenericWorker":28}],25:[function(e,t,r){"use strict";var n=e("./GenericWorker"),i=e("../crc32");function s(){n.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}e("../utils").inherits(s,n),s.prototype.processChunk=function(e){this.streamInfo.crc32=i(e.data,this.streamInfo.crc32||0),this.push(e)},t.exports=s},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(e,t,r){"use strict";var n=e("../utils"),i=e("./GenericWorker");function s(e){i.call(this,"DataLengthProbe for "+e),this.propName=e,this.withStreamInfo(e,0)}n.inherits(s,i),s.prototype.processChunk=function(e){if(e){var t=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=t+e.data.length}i.prototype.processChunk.call(this,e)},t.exports=s},{"../utils":32,"./GenericWorker":28}],27:[function(e,t,r){"use strict";var n=e("../utils"),i=e("./GenericWorker");function s(e){i.call(this,"DataWorker");var t=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,e.then(function(e){t.dataIsReady=!0,t.data=e,t.max=e&&e.length||0,t.type=n.getTypeOf(e),t.isPaused||t._tickAndRepeat()},function(e){t.error(e)})}n.inherits(s,i),s.prototype.cleanUp=function(){i.prototype.cleanUp.call(this),this.data=null},s.prototype.resume=function(){return!!i.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,n.delay(this._tickAndRepeat,[],this)),!0)},s.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(n.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},s.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var e=null,t=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":e=this.data.substring(this.index,t);break;case"uint8array":e=this.data.subarray(this.index,t);break;case"array":case"nodebuffer":e=this.data.slice(this.index,t)}return this.index=t,this.push({data:e,meta:{percent:this.max?this.index/this.max*100:0}})},t.exports=s},{"../utils":32,"./GenericWorker":28}],28:[function(e,t,r){"use strict";function n(e){this.name=e||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}n.prototype={push:function(e){this.emit("data",e)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(e){this.emit("error",e)}return!0},error:function(e){return!this.isFinished&&(this.isPaused?this.generatedError=e:(this.isFinished=!0,this.emit("error",e),this.previous&&this.previous.error(e),this.cleanUp()),!0)},on:function(e,t){return this._listeners[e].push(t),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(e,t){if(this._listeners[e])for(var r=0;r<this._listeners[e].length;r++)this._listeners[e][r].call(this,t)},pipe:function(e){return e.registerPrevious(this)},registerPrevious:function(e){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=e.streamInfo,this.mergeStreamInfo(),this.previous=e;var t=this;return e.on("data",function(e){t.processChunk(e)}),e.on("end",function(){t.end()}),e.on("error",function(e){t.error(e)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var e=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),e=!0),this.previous&&this.previous.resume(),!e},flush:function(){},processChunk:function(e){this.push(e)},withStreamInfo:function(e,t){return this.extraStreamInfo[e]=t,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var e in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,e)&&(this.streamInfo[e]=this.extraStreamInfo[e])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var e="Worker "+this.name;return this.previous?this.previous+" -> "+e:e}},t.exports=n},{}],29:[function(e,t,r){"use strict";var h=e("../utils"),i=e("./ConvertWorker"),s=e("./GenericWorker"),u=e("../base64"),n=e("../support"),a=e("../external"),o=null;if(n.nodestream)try{o=e("../nodejs/NodejsStreamOutputAdapter")}catch(e){}function l(e,o){return new a.Promise(function(t,r){var n=[],i=e._internalType,s=e._outputType,a=e._mimeType;e.on("data",function(e,t){n.push(e),o&&o(t)}).on("error",function(e){n=[],r(e)}).on("end",function(){try{var e=function(e,t,r){switch(e){case"blob":return h.newBlob(h.transformTo("arraybuffer",t),r);case"base64":return u.encode(t);default:return h.transformTo(e,t)}}(s,function(e,t){var r,n=0,i=null,s=0;for(r=0;r<t.length;r++)s+=t[r].length;switch(e){case"string":return t.join("");case"array":return Array.prototype.concat.apply([],t);case"uint8array":for(i=new Uint8Array(s),r=0;r<t.length;r++)i.set(t[r],n),n+=t[r].length;return i;case"nodebuffer":return Buffer.concat(t);default:throw new Error("concat : unsupported type '"+e+"'")}}(i,n),a);t(e)}catch(e){r(e)}n=[]}).resume()})}function f(e,t,r){var n=t;switch(t){case"blob":case"arraybuffer":n="uint8array";break;case"base64":n="string"}try{this._internalType=n,this._outputType=t,this._mimeType=r,h.checkSupport(n),this._worker=e.pipe(new i(n)),e.lock()}catch(e){this._worker=new s("error"),this._worker.error(e)}}f.prototype={accumulate:function(e){return l(this,e)},on:function(e,t){var r=this;return"data"===e?this._worker.on(e,function(e){t.call(r,e.data,e.meta)}):this._worker.on(e,function(){h.delay(t,arguments,r)}),this},resume:function(){return h.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(e){if(h.checkSupport("nodestream"),"nodebuffer"!==this._outputType)throw new Error(this._outputType+" is not supported by this method");return new o(this,{objectMode:"nodebuffer"!==this._outputType},e)}},t.exports=f},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(e,t,r){"use strict";if(r.base64=!0,r.array=!0,r.string=!0,r.arraybuffer="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array,r.nodebuffer="undefined"!=typeof Buffer,r.uint8array="undefined"!=typeof Uint8Array,"undefined"==typeof ArrayBuffer)r.blob=!1;else{var n=new ArrayBuffer(0);try{r.blob=0===new Blob([n],{type:"application/zip"}).size}catch(e){try{var i=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);i.append(n),r.blob=0===i.getBlob("application/zip").size}catch(e){r.blob=!1}}}try{r.nodestream=!!e("readable-stream").Readable}catch(e){r.nodestream=!1}},{"readable-stream":16}],31:[function(e,t,s){"use strict";for(var o=e("./utils"),h=e("./support"),r=e("./nodejsUtils"),n=e("./stream/GenericWorker"),u=new Array(256),i=0;i<256;i++)u[i]=252<=i?6:248<=i?5:240<=i?4:224<=i?3:192<=i?2:1;u[254]=u[254]=1;function a(){n.call(this,"utf-8 decode"),this.leftOver=null}function l(){n.call(this,"utf-8 encode")}s.utf8encode=function(e){return h.nodebuffer?r.newBufferFrom(e,"utf-8"):function(e){var t,r,n,i,s,a=e.length,o=0;for(i=0;i<a;i++)55296==(64512&(r=e.charCodeAt(i)))&&i+1<a&&56320==(64512&(n=e.charCodeAt(i+1)))&&(r=65536+(r-55296<<10)+(n-56320),i++),o+=r<128?1:r<2048?2:r<65536?3:4;for(t=h.uint8array?new Uint8Array(o):new Array(o),i=s=0;s<o;i++)55296==(64512&(r=e.charCodeAt(i)))&&i+1<a&&56320==(64512&(n=e.charCodeAt(i+1)))&&(r=65536+(r-55296<<10)+(n-56320),i++),r<128?t[s++]=r:(r<2048?t[s++]=192|r>>>6:(r<65536?t[s++]=224|r>>>12:(t[s++]=240|r>>>18,t[s++]=128|r>>>12&63),t[s++]=128|r>>>6&63),t[s++]=128|63&r);return t}(e)},s.utf8decode=function(e){return h.nodebuffer?o.transformTo("nodebuffer",e).toString("utf-8"):function(e){var t,r,n,i,s=e.length,a=new Array(2*s);for(t=r=0;t<s;)if((n=e[t++])<128)a[r++]=n;else if(4<(i=u[n]))a[r++]=65533,t+=i-1;else{for(n&=2===i?31:3===i?15:7;1<i&&t<s;)n=n<<6|63&e[t++],i--;1<i?a[r++]=65533:n<65536?a[r++]=n:(n-=65536,a[r++]=55296|n>>10&1023,a[r++]=56320|1023&n)}return a.length!==r&&(a.subarray?a=a.subarray(0,r):a.length=r),o.applyFromCharCode(a)}(e=o.transformTo(h.uint8array?"uint8array":"array",e))},o.inherits(a,n),a.prototype.processChunk=function(e){var t=o.transformTo(h.uint8array?"uint8array":"array",e.data);if(this.leftOver&&this.leftOver.length){if(h.uint8array){var r=t;(t=new Uint8Array(r.length+this.leftOver.length)).set(this.leftOver,0),t.set(r,this.leftOver.length)}else t=this.leftOver.concat(t);this.leftOver=null}var n=function(e,t){var r;for((t=t||e.length)>e.length&&(t=e.length),r=t-1;0<=r&&128==(192&e[r]);)r--;return r<0?t:0===r?t:r+u[e[r]]>t?r:t}(t),i=t;n!==t.length&&(h.uint8array?(i=t.subarray(0,n),this.leftOver=t.subarray(n,t.length)):(i=t.slice(0,n),this.leftOver=t.slice(n,t.length))),this.push({data:s.utf8decode(i),meta:e.meta})},a.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:s.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},s.Utf8DecodeWorker=a,o.inherits(l,n),l.prototype.processChunk=function(e){this.push({data:s.utf8encode(e.data),meta:e.meta})},s.Utf8EncodeWorker=l},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(e,t,a){"use strict";var o=e("./support"),h=e("./base64"),r=e("./nodejsUtils"),u=e("./external");function n(e){return e}function l(e,t){for(var r=0;r<e.length;++r)t[r]=255&e.charCodeAt(r);return t}e("setimmediate"),a.newBlob=function(t,r){a.checkSupport("blob");try{return new Blob([t],{type:r})}catch(e){try{var n=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return n.append(t),n.getBlob(r)}catch(e){throw new Error("Bug : can't construct the Blob.")}}};var i={stringifyByChunk:function(e,t,r){var n=[],i=0,s=e.length;if(s<=r)return String.fromCharCode.apply(null,e);for(;i<s;)"array"===t||"nodebuffer"===t?n.push(String.fromCharCode.apply(null,e.slice(i,Math.min(i+r,s)))):n.push(String.fromCharCode.apply(null,e.subarray(i,Math.min(i+r,s)))),i+=r;return n.join("")},stringifyByChar:function(e){for(var t="",r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t},applyCanBeUsed:{uint8array:function(){try{return o.uint8array&&1===String.fromCharCode.apply(null,new Uint8Array(1)).length}catch(e){return!1}}(),nodebuffer:function(){try{return o.nodebuffer&&1===String.fromCharCode.apply(null,r.allocBuffer(1)).length}catch(e){return!1}}()}};function s(e){var t=65536,r=a.getTypeOf(e),n=!0;if("uint8array"===r?n=i.applyCanBeUsed.uint8array:"nodebuffer"===r&&(n=i.applyCanBeUsed.nodebuffer),n)for(;1<t;)try{return i.stringifyByChunk(e,r,t)}catch(e){t=Math.floor(t/2)}return i.stringifyByChar(e)}function f(e,t){for(var r=0;r<e.length;r++)t[r]=e[r];return t}a.applyFromCharCode=s;var c={};c.string={string:n,array:function(e){return l(e,new Array(e.length))},arraybuffer:function(e){return c.string.uint8array(e).buffer},uint8array:function(e){return l(e,new Uint8Array(e.length))},nodebuffer:function(e){return l(e,r.allocBuffer(e.length))}},c.array={string:s,array:n,arraybuffer:function(e){return new Uint8Array(e).buffer},uint8array:function(e){return new Uint8Array(e)},nodebuffer:function(e){return r.newBufferFrom(e)}},c.arraybuffer={string:function(e){return s(new Uint8Array(e))},array:function(e){return f(new Uint8Array(e),new Array(e.byteLength))},arraybuffer:n,uint8array:function(e){return new Uint8Array(e)},nodebuffer:function(e){return r.newBufferFrom(new Uint8Array(e))}},c.uint8array={string:s,array:function(e){return f(e,new Array(e.length))},arraybuffer:function(e){return e.buffer},uint8array:n,nodebuffer:function(e){return r.newBufferFrom(e)}},c.nodebuffer={string:s,array:function(e){return f(e,new Array(e.length))},arraybuffer:function(e){return c.nodebuffer.uint8array(e).buffer},uint8array:function(e){return f(e,new Uint8Array(e.length))},nodebuffer:n},a.transformTo=function(e,t){if(t=t||"",!e)return t;a.checkSupport(e);var r=a.getTypeOf(t);return c[r][e](t)},a.resolve=function(e){for(var t=e.split("/"),r=[],n=0;n<t.length;n++){var i=t[n];"."===i||""===i&&0!==n&&n!==t.length-1||(".."===i?r.pop():r.push(i))}return r.join("/")},a.getTypeOf=function(e){return"string"==typeof e?"string":"[object Array]"===Object.prototype.toString.call(e)?"array":o.nodebuffer&&r.isBuffer(e)?"nodebuffer":o.uint8array&&e instanceof Uint8Array?"uint8array":o.arraybuffer&&e instanceof ArrayBuffer?"arraybuffer":void 0},a.checkSupport=function(e){if(!o[e.toLowerCase()])throw new Error(e+" is not supported by this platform")},a.MAX_VALUE_16BITS=65535,a.MAX_VALUE_32BITS=-1,a.pretty=function(e){var t,r,n="";for(r=0;r<(e||"").length;r++)n+="\\x"+((t=e.charCodeAt(r))<16?"0":"")+t.toString(16).toUpperCase();return n},a.delay=function(e,t,r){setImmediate(function(){e.apply(r||null,t||[])})},a.inherits=function(e,t){function r(){}r.prototype=t.prototype,e.prototype=new r},a.extend=function(){var e,t,r={};for(e=0;e<arguments.length;e++)for(t in arguments[e])Object.prototype.hasOwnProperty.call(arguments[e],t)&&void 0===r[t]&&(r[t]=arguments[e][t]);return r},a.prepareContent=function(r,e,n,i,s){return u.Promise.resolve(e).then(function(n){return o.blob&&(n instanceof Blob||-1!==["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(n)))&&"undefined"!=typeof FileReader?new u.Promise(function(t,r){var e=new FileReader;e.onload=function(e){t(e.target.result)},e.onerror=function(e){r(e.target.error)},e.readAsArrayBuffer(n)}):n}).then(function(e){var t=a.getTypeOf(e);return t?("arraybuffer"===t?e=a.transformTo("uint8array",e):"string"===t&&(s?e=h.decode(e):n&&!0!==i&&(e=function(e){return l(e,o.uint8array?new Uint8Array(e.length):new Array(e.length))}(e))),e):u.Promise.reject(new Error("Can't read the data of '"+r+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(e,t,r){"use strict";var n=e("./reader/readerFor"),i=e("./utils"),s=e("./signature"),a=e("./zipEntry"),o=e("./support");function h(e){this.files=[],this.loadOptions=e}h.prototype={checkSignature:function(e){if(!this.reader.readAndCheckSignature(e)){this.reader.index-=4;var t=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+i.pretty(t)+", expected "+i.pretty(e)+")")}},isSignature:function(e,t){var r=this.reader.index;this.reader.setIndex(e);var n=this.reader.readString(4)===t;return this.reader.setIndex(r),n},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var e=this.reader.readData(this.zipCommentLength),t=o.uint8array?"uint8array":"array",r=i.transformTo(t,e);this.zipComment=this.loadOptions.decodeFileName(r)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var e,t,r,n=this.zip64EndOfCentralSize-44;0<n;)e=this.reader.readInt(2),t=this.reader.readInt(4),r=this.reader.readData(t),this.zip64ExtensibleData[e]={id:e,length:t,value:r}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var e,t;for(e=0;e<this.files.length;e++)t=this.files[e],this.reader.setIndex(t.localHeaderOffset),this.checkSignature(s.LOCAL_FILE_HEADER),t.readLocalPart(this.reader),t.handleUTF8(),t.processAttributes()},readCentralDir:function(){var e;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(s.CENTRAL_FILE_HEADER);)(e=new a({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(e);if(this.centralDirRecords!==this.files.length&&0!==this.centralDirRecords&&0===this.files.length)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var e=this.reader.lastIndexOfSignature(s.CENTRAL_DIRECTORY_END);if(e<0)throw!this.isSignature(0,s.LOCAL_FILE_HEADER)?new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html"):new Error("Corrupted zip: can't find end of central directory");this.reader.setIndex(e);var t=e;if(this.checkSignature(s.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===i.MAX_VALUE_16BITS||this.diskWithCentralDirStart===i.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===i.MAX_VALUE_16BITS||this.centralDirRecords===i.MAX_VALUE_16BITS||this.centralDirSize===i.MAX_VALUE_32BITS||this.centralDirOffset===i.MAX_VALUE_32BITS){if(this.zip64=!0,(e=this.reader.lastIndexOfSignature(s.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(e),this.checkSignature(s.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,s.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(s.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(s.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var r=this.centralDirOffset+this.centralDirSize;this.zip64&&(r+=20,r+=12+this.zip64EndOfCentralSize);var n=t-r;if(0<n)this.isSignature(t,s.CENTRAL_FILE_HEADER)||(this.reader.zero=n);else if(n<0)throw new Error("Corrupted zip: missing "+Math.abs(n)+" bytes.")},prepareReader:function(e){this.reader=n(e)},load:function(e){this.prepareReader(e),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},t.exports=h},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(e,t,r){"use strict";var n=e("./reader/readerFor"),s=e("./utils"),i=e("./compressedObject"),a=e("./crc32"),o=e("./utf8"),h=e("./compressions"),u=e("./support");function l(e,t){this.options=e,this.loadOptions=t}l.prototype={isEncrypted:function(){return 1==(1&this.bitFlag)},useUTF8:function(){return 2048==(2048&this.bitFlag)},readLocalPart:function(e){var t,r;if(e.skip(22),this.fileNameLength=e.readInt(2),r=e.readInt(2),this.fileName=e.readData(this.fileNameLength),e.skip(r),-1===this.compressedSize||-1===this.uncompressedSize)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if(null===(t=function(e){for(var t in h)if(Object.prototype.hasOwnProperty.call(h,t)&&h[t].magic===e)return h[t];return null}(this.compressionMethod)))throw new Error("Corrupted zip : compression "+s.pretty(this.compressionMethod)+" unknown (inner file : "+s.transformTo("string",this.fileName)+")");this.decompressed=new i(this.compressedSize,this.uncompressedSize,this.crc32,t,e.readData(this.compressedSize))},readCentralPart:function(e){this.versionMadeBy=e.readInt(2),e.skip(2),this.bitFlag=e.readInt(2),this.compressionMethod=e.readString(2),this.date=e.readDate(),this.crc32=e.readInt(4),this.compressedSize=e.readInt(4),this.uncompressedSize=e.readInt(4);var t=e.readInt(2);if(this.extraFieldsLength=e.readInt(2),this.fileCommentLength=e.readInt(2),this.diskNumberStart=e.readInt(2),this.internalFileAttributes=e.readInt(2),this.externalFileAttributes=e.readInt(4),this.localHeaderOffset=e.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");e.skip(t),this.readExtraFields(e),this.parseZIP64ExtraField(e),this.fileComment=e.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var e=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),0==e&&(this.dosPermissions=63&this.externalFileAttributes),3==e&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||"/"!==this.fileNameStr.slice(-1)||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var e=n(this.extraFields[1].value);this.uncompressedSize===s.MAX_VALUE_32BITS&&(this.uncompressedSize=e.readInt(8)),this.compressedSize===s.MAX_VALUE_32BITS&&(this.compressedSize=e.readInt(8)),this.localHeaderOffset===s.MAX_VALUE_32BITS&&(this.localHeaderOffset=e.readInt(8)),this.diskNumberStart===s.MAX_VALUE_32BITS&&(this.diskNumberStart=e.readInt(4))}},readExtraFields:function(e){var t,r,n,i=e.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});e.index+4<i;)t=e.readInt(2),r=e.readInt(2),n=e.readData(r),this.extraFields[t]={id:t,length:r,value:n};e.setIndex(i)},handleUTF8:function(){var e=u.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=o.utf8decode(this.fileName),this.fileCommentStr=o.utf8decode(this.fileComment);else{var t=this.findExtraFieldUnicodePath();if(null!==t)this.fileNameStr=t;else{var r=s.transformTo(e,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(r)}var n=this.findExtraFieldUnicodeComment();if(null!==n)this.fileCommentStr=n;else{var i=s.transformTo(e,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(i)}}},findExtraFieldUnicodePath:function(){var e=this.extraFields[28789];if(e){var t=n(e.value);return 1!==t.readInt(1)?null:a(this.fileName)!==t.readInt(4)?null:o.utf8decode(t.readData(e.length-5))}return null},findExtraFieldUnicodeComment:function(){var e=this.extraFields[25461];if(e){var t=n(e.value);return 1!==t.readInt(1)?null:a(this.fileComment)!==t.readInt(4)?null:o.utf8decode(t.readData(e.length-5))}return null}},t.exports=l},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(e,t,r){"use strict";function n(e,t,r){this.name=e,this.dir=r.dir,this.date=r.date,this.comment=r.comment,this.unixPermissions=r.unixPermissions,this.dosPermissions=r.dosPermissions,this._data=t,this._dataBinary=r.binary,this.options={compression:r.compression,compressionOptions:r.compressionOptions}}var s=e("./stream/StreamHelper"),i=e("./stream/DataWorker"),a=e("./utf8"),o=e("./compressedObject"),h=e("./stream/GenericWorker");n.prototype={internalStream:function(e){var t=null,r="string";try{if(!e)throw new Error("No output type specified.");var n="string"===(r=e.toLowerCase())||"text"===r;"binarystring"!==r&&"text"!==r||(r="string"),t=this._decompressWorker();var i=!this._dataBinary;i&&!n&&(t=t.pipe(new a.Utf8EncodeWorker)),!i&&n&&(t=t.pipe(new a.Utf8DecodeWorker))}catch(e){(t=new h("error")).error(e)}return new s(t,r,"")},async:function(e,t){return this.internalStream(e).accumulate(t)},nodeStream:function(e,t){return this.internalStream(e||"nodebuffer").toNodejsStream(t)},_compressWorker:function(e,t){if(this._data instanceof o&&this._data.compression.magic===e.magic)return this._data.getCompressedWorker();var r=this._decompressWorker();return this._dataBinary||(r=r.pipe(new a.Utf8EncodeWorker)),o.createWorkerFrom(r,e,t)},_decompressWorker:function(){return this._data instanceof o?this._data.getContentWorker():this._data instanceof h?this._data:new i(this._data)}};for(var u=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],l=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},f=0;f<u.length;f++)n.prototype[u[f]]=l;t.exports=n},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(e,l,t){(function(t){"use strict";var r,n,e=t.MutationObserver||t.WebKitMutationObserver;if(e){var i=0,s=new e(u),a=t.document.createTextNode("");s.observe(a,{characterData:!0}),r=function(){a.data=i=++i%2}}else if(t.setImmediate||void 0===t.MessageChannel)r="document"in t&&"onreadystatechange"in t.document.createElement("script")?function(){var e=t.document.createElement("script");e.onreadystatechange=function(){u(),e.onreadystatechange=null,e.parentNode.removeChild(e),e=null},t.document.documentElement.appendChild(e)}:function(){setTimeout(u,0)};else{var o=new t.MessageChannel;o.port1.onmessage=u,r=function(){o.port2.postMessage(0)}}var h=[];function u(){var e,t;n=!0;for(var r=h.length;r;){for(t=h,h=[],e=-1;++e<r;)t[e]();r=h.length}n=!1}l.exports=function(e){1!==h.push(e)||n||r()}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],37:[function(e,t,r){"use strict";var i=e("immediate");function u(){}var l={},s=["REJECTED"],a=["FULFILLED"],n=["PENDING"];function o(e){if("function"!=typeof e)throw new TypeError("resolver must be a function");this.state=n,this.queue=[],this.outcome=void 0,e!==u&&d(this,e)}function h(e,t,r){this.promise=e,"function"==typeof t&&(this.onFulfilled=t,this.callFulfilled=this.otherCallFulfilled),"function"==typeof r&&(this.onRejected=r,this.callRejected=this.otherCallRejected)}function f(t,r,n){i(function(){var e;try{e=r(n)}catch(e){return l.reject(t,e)}e===t?l.reject(t,new TypeError("Cannot resolve promise with itself")):l.resolve(t,e)})}function c(e){var t=e&&e.then;if(e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof t)return function(){t.apply(e,arguments)}}function d(t,e){var r=!1;function n(e){r||(r=!0,l.reject(t,e))}function i(e){r||(r=!0,l.resolve(t,e))}var s=p(function(){e(i,n)});"error"===s.status&&n(s.value)}function p(e,t){var r={};try{r.value=e(t),r.status="success"}catch(e){r.status="error",r.value=e}return r}(t.exports=o).prototype.finally=function(t){if("function"!=typeof t)return this;var r=this.constructor;return this.then(function(e){return r.resolve(t()).then(function(){return e})},function(e){return r.resolve(t()).then(function(){throw e})})},o.prototype.catch=function(e){return this.then(null,e)},o.prototype.then=function(e,t){if("function"!=typeof e&&this.state===a||"function"!=typeof t&&this.state===s)return this;var r=new this.constructor(u);this.state!==n?f(r,this.state===a?e:t,this.outcome):this.queue.push(new h(r,e,t));return r},h.prototype.callFulfilled=function(e){l.resolve(this.promise,e)},h.prototype.otherCallFulfilled=function(e){f(this.promise,this.onFulfilled,e)},h.prototype.callRejected=function(e){l.reject(this.promise,e)},h.prototype.otherCallRejected=function(e){f(this.promise,this.onRejected,e)},l.resolve=function(e,t){var r=p(c,t);if("error"===r.status)return l.reject(e,r.value);var n=r.value;if(n)d(e,n);else{e.state=a,e.outcome=t;for(var i=-1,s=e.queue.length;++i<s;)e.queue[i].callFulfilled(t)}return e},l.reject=function(e,t){e.state=s,e.outcome=t;for(var r=-1,n=e.queue.length;++r<n;)e.queue[r].callRejected(t);return e},o.resolve=function(e){if(e instanceof this)return e;return l.resolve(new this(u),e)},o.reject=function(e){var t=new this(u);return l.reject(t,e)},o.all=function(e){var r=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var n=e.length,i=!1;if(!n)return this.resolve([]);var s=new Array(n),a=0,t=-1,o=new this(u);for(;++t<n;)h(e[t],t);return o;function h(e,t){r.resolve(e).then(function(e){s[t]=e,++a!==n||i||(i=!0,l.resolve(o,s))},function(e){i||(i=!0,l.reject(o,e))})}},o.race=function(e){var t=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var r=e.length,n=!1;if(!r)return this.resolve([]);var i=-1,s=new this(u);for(;++i<r;)a=e[i],t.resolve(a).then(function(e){n||(n=!0,l.resolve(s,e))},function(e){n||(n=!0,l.reject(s,e))});var a;return s}},{immediate:36}],38:[function(e,t,r){"use strict";var n={};(0,e("./lib/utils/common").assign)(n,e("./lib/deflate"),e("./lib/inflate"),e("./lib/zlib/constants")),t.exports=n},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(e,t,r){"use strict";var a=e("./zlib/deflate"),o=e("./utils/common"),h=e("./utils/strings"),i=e("./zlib/messages"),s=e("./zlib/zstream"),u=Object.prototype.toString,l=0,f=-1,c=0,d=8;function p(e){if(!(this instanceof p))return new p(e);this.options=o.assign({level:f,method:d,chunkSize:16384,windowBits:15,memLevel:8,strategy:c,to:""},e||{});var t=this.options;t.raw&&0<t.windowBits?t.windowBits=-t.windowBits:t.gzip&&0<t.windowBits&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new s,this.strm.avail_out=0;var r=a.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(r!==l)throw new Error(i[r]);if(t.header&&a.deflateSetHeader(this.strm,t.header),t.dictionary){var n;if(n="string"==typeof t.dictionary?h.string2buf(t.dictionary):"[object ArrayBuffer]"===u.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,(r=a.deflateSetDictionary(this.strm,n))!==l)throw new Error(i[r]);this._dict_set=!0}}function n(e,t){var r=new p(t);if(r.push(e,!0),r.err)throw r.msg||i[r.err];return r.result}p.prototype.push=function(e,t){var r,n,i=this.strm,s=this.options.chunkSize;if(this.ended)return!1;n=t===~~t?t:!0===t?4:0,"string"==typeof e?i.input=h.string2buf(e):"[object ArrayBuffer]"===u.call(e)?i.input=new Uint8Array(e):i.input=e,i.next_in=0,i.avail_in=i.input.length;do{if(0===i.avail_out&&(i.output=new o.Buf8(s),i.next_out=0,i.avail_out=s),1!==(r=a.deflate(i,n))&&r!==l)return this.onEnd(r),!(this.ended=!0);0!==i.avail_out&&(0!==i.avail_in||4!==n&&2!==n)||("string"===this.options.to?this.onData(h.buf2binstring(o.shrinkBuf(i.output,i.next_out))):this.onData(o.shrinkBuf(i.output,i.next_out)))}while((0<i.avail_in||0===i.avail_out)&&1!==r);return 4===n?(r=a.deflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===l):2!==n||(this.onEnd(l),!(i.avail_out=0))},p.prototype.onData=function(e){this.chunks.push(e)},p.prototype.onEnd=function(e){e===l&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=o.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},r.Deflate=p,r.deflate=n,r.deflateRaw=function(e,t){return(t=t||{}).raw=!0,n(e,t)},r.gzip=function(e,t){return(t=t||{}).gzip=!0,n(e,t)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(e,t,r){"use strict";var c=e("./zlib/inflate"),d=e("./utils/common"),p=e("./utils/strings"),m=e("./zlib/constants"),n=e("./zlib/messages"),i=e("./zlib/zstream"),s=e("./zlib/gzheader"),_=Object.prototype.toString;function a(e){if(!(this instanceof a))return new a(e);this.options=d.assign({chunkSize:16384,windowBits:0,to:""},e||{});var t=this.options;t.raw&&0<=t.windowBits&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(0<=t.windowBits&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),15<t.windowBits&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new i,this.strm.avail_out=0;var r=c.inflateInit2(this.strm,t.windowBits);if(r!==m.Z_OK)throw new Error(n[r]);this.header=new s,c.inflateGetHeader(this.strm,this.header)}function o(e,t){var r=new a(t);if(r.push(e,!0),r.err)throw r.msg||n[r.err];return r.result}a.prototype.push=function(e,t){var r,n,i,s,a,o,h=this.strm,u=this.options.chunkSize,l=this.options.dictionary,f=!1;if(this.ended)return!1;n=t===~~t?t:!0===t?m.Z_FINISH:m.Z_NO_FLUSH,"string"==typeof e?h.input=p.binstring2buf(e):"[object ArrayBuffer]"===_.call(e)?h.input=new Uint8Array(e):h.input=e,h.next_in=0,h.avail_in=h.input.length;do{if(0===h.avail_out&&(h.output=new d.Buf8(u),h.next_out=0,h.avail_out=u),(r=c.inflate(h,m.Z_NO_FLUSH))===m.Z_NEED_DICT&&l&&(o="string"==typeof l?p.string2buf(l):"[object ArrayBuffer]"===_.call(l)?new Uint8Array(l):l,r=c.inflateSetDictionary(this.strm,o)),r===m.Z_BUF_ERROR&&!0===f&&(r=m.Z_OK,f=!1),r!==m.Z_STREAM_END&&r!==m.Z_OK)return this.onEnd(r),!(this.ended=!0);h.next_out&&(0!==h.avail_out&&r!==m.Z_STREAM_END&&(0!==h.avail_in||n!==m.Z_FINISH&&n!==m.Z_SYNC_FLUSH)||("string"===this.options.to?(i=p.utf8border(h.output,h.next_out),s=h.next_out-i,a=p.buf2string(h.output,i),h.next_out=s,h.avail_out=u-s,s&&d.arraySet(h.output,h.output,i,s,0),this.onData(a)):this.onData(d.shrinkBuf(h.output,h.next_out)))),0===h.avail_in&&0===h.avail_out&&(f=!0)}while((0<h.avail_in||0===h.avail_out)&&r!==m.Z_STREAM_END);return r===m.Z_STREAM_END&&(n=m.Z_FINISH),n===m.Z_FINISH?(r=c.inflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===m.Z_OK):n!==m.Z_SYNC_FLUSH||(this.onEnd(m.Z_OK),!(h.avail_out=0))},a.prototype.onData=function(e){this.chunks.push(e)},a.prototype.onEnd=function(e){e===m.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=d.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},r.Inflate=a,r.inflate=o,r.inflateRaw=function(e,t){return(t=t||{}).raw=!0,o(e,t)},r.ungzip=o},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(e,t,r){"use strict";var n="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;r.assign=function(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var r=t.shift();if(r){if("object"!=typeof r)throw new TypeError(r+"must be non-object");for(var n in r)r.hasOwnProperty(n)&&(e[n]=r[n])}}return e},r.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)};var i={arraySet:function(e,t,r,n,i){if(t.subarray&&e.subarray)e.set(t.subarray(r,r+n),i);else for(var s=0;s<n;s++)e[i+s]=t[r+s]},flattenChunks:function(e){var t,r,n,i,s,a;for(t=n=0,r=e.length;t<r;t++)n+=e[t].length;for(a=new Uint8Array(n),t=i=0,r=e.length;t<r;t++)s=e[t],a.set(s,i),i+=s.length;return a}},s={arraySet:function(e,t,r,n,i){for(var s=0;s<n;s++)e[i+s]=t[r+s]},flattenChunks:function(e){return[].concat.apply([],e)}};r.setTyped=function(e){e?(r.Buf8=Uint8Array,r.Buf16=Uint16Array,r.Buf32=Int32Array,r.assign(r,i)):(r.Buf8=Array,r.Buf16=Array,r.Buf32=Array,r.assign(r,s))},r.setTyped(n)},{}],42:[function(e,t,r){"use strict";var h=e("./common"),i=!0,s=!0;try{String.fromCharCode.apply(null,[0])}catch(e){i=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){s=!1}for(var u=new h.Buf8(256),n=0;n<256;n++)u[n]=252<=n?6:248<=n?5:240<=n?4:224<=n?3:192<=n?2:1;function l(e,t){if(t<65537&&(e.subarray&&s||!e.subarray&&i))return String.fromCharCode.apply(null,h.shrinkBuf(e,t));for(var r="",n=0;n<t;n++)r+=String.fromCharCode(e[n]);return r}u[254]=u[254]=1,r.string2buf=function(e){var t,r,n,i,s,a=e.length,o=0;for(i=0;i<a;i++)55296==(64512&(r=e.charCodeAt(i)))&&i+1<a&&56320==(64512&(n=e.charCodeAt(i+1)))&&(r=65536+(r-55296<<10)+(n-56320),i++),o+=r<128?1:r<2048?2:r<65536?3:4;for(t=new h.Buf8(o),i=s=0;s<o;i++)55296==(64512&(r=e.charCodeAt(i)))&&i+1<a&&56320==(64512&(n=e.charCodeAt(i+1)))&&(r=65536+(r-55296<<10)+(n-56320),i++),r<128?t[s++]=r:(r<2048?t[s++]=192|r>>>6:(r<65536?t[s++]=224|r>>>12:(t[s++]=240|r>>>18,t[s++]=128|r>>>12&63),t[s++]=128|r>>>6&63),t[s++]=128|63&r);return t},r.buf2binstring=function(e){return l(e,e.length)},r.binstring2buf=function(e){for(var t=new h.Buf8(e.length),r=0,n=t.length;r<n;r++)t[r]=e.charCodeAt(r);return t},r.buf2string=function(e,t){var r,n,i,s,a=t||e.length,o=new Array(2*a);for(r=n=0;r<a;)if((i=e[r++])<128)o[n++]=i;else if(4<(s=u[i]))o[n++]=65533,r+=s-1;else{for(i&=2===s?31:3===s?15:7;1<s&&r<a;)i=i<<6|63&e[r++],s--;1<s?o[n++]=65533:i<65536?o[n++]=i:(i-=65536,o[n++]=55296|i>>10&1023,o[n++]=56320|1023&i)}return l(o,n)},r.utf8border=function(e,t){var r;for((t=t||e.length)>e.length&&(t=e.length),r=t-1;0<=r&&128==(192&e[r]);)r--;return r<0?t:0===r?t:r+u[e[r]]>t?r:t}},{"./common":41}],43:[function(e,t,r){"use strict";t.exports=function(e,t,r,n){for(var i=65535&e|0,s=e>>>16&65535|0,a=0;0!==r;){for(r-=a=2e3<r?2e3:r;s=s+(i=i+t[n++]|0)|0,--a;);i%=65521,s%=65521}return i|s<<16|0}},{}],44:[function(e,t,r){"use strict";t.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(e,t,r){"use strict";var o=function(){for(var e,t=[],r=0;r<256;r++){e=r;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[r]=e}return t}();t.exports=function(e,t,r,n){var i=o,s=n+r;e^=-1;for(var a=n;a<s;a++)e=e>>>8^i[255&(e^t[a])];return-1^e}},{}],46:[function(e,t,r){"use strict";var h,c=e("../utils/common"),u=e("./trees"),d=e("./adler32"),p=e("./crc32"),n=e("./messages"),l=0,f=4,m=0,_=-2,g=-1,b=4,i=2,v=8,y=9,s=286,a=30,o=19,w=2*s+1,k=15,x=3,S=258,z=S+x+1,C=42,E=113,A=1,I=2,O=3,B=4;function R(e,t){return e.msg=n[t],t}function T(e){return(e<<1)-(4<e?9:0)}function D(e){for(var t=e.length;0<=--t;)e[t]=0}function F(e){var t=e.state,r=t.pending;r>e.avail_out&&(r=e.avail_out),0!==r&&(c.arraySet(e.output,t.pending_buf,t.pending_out,r,e.next_out),e.next_out+=r,t.pending_out+=r,e.total_out+=r,e.avail_out-=r,t.pending-=r,0===t.pending&&(t.pending_out=0))}function N(e,t){u._tr_flush_block(e,0<=e.block_start?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,F(e.strm)}function U(e,t){e.pending_buf[e.pending++]=t}function P(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function L(e,t){var r,n,i=e.max_chain_length,s=e.strstart,a=e.prev_length,o=e.nice_match,h=e.strstart>e.w_size-z?e.strstart-(e.w_size-z):0,u=e.window,l=e.w_mask,f=e.prev,c=e.strstart+S,d=u[s+a-1],p=u[s+a];e.prev_length>=e.good_match&&(i>>=2),o>e.lookahead&&(o=e.lookahead);do{if(u[(r=t)+a]===p&&u[r+a-1]===d&&u[r]===u[s]&&u[++r]===u[s+1]){s+=2,r++;do{}while(u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&s<c);if(n=S-(c-s),s=c-S,a<n){if(e.match_start=t,o<=(a=n))break;d=u[s+a-1],p=u[s+a]}}}while((t=f[t&l])>h&&0!=--i);return a<=e.lookahead?a:e.lookahead}function j(e){var t,r,n,i,s,a,o,h,u,l,f=e.w_size;do{if(i=e.window_size-e.lookahead-e.strstart,e.strstart>=f+(f-z)){for(c.arraySet(e.window,e.window,f,f,0),e.match_start-=f,e.strstart-=f,e.block_start-=f,t=r=e.hash_size;n=e.head[--t],e.head[t]=f<=n?n-f:0,--r;);for(t=r=f;n=e.prev[--t],e.prev[t]=f<=n?n-f:0,--r;);i+=f}if(0===e.strm.avail_in)break;if(a=e.strm,o=e.window,h=e.strstart+e.lookahead,u=i,l=void 0,l=a.avail_in,u<l&&(l=u),r=0===l?0:(a.avail_in-=l,c.arraySet(o,a.input,a.next_in,l,h),1===a.state.wrap?a.adler=d(a.adler,o,l,h):2===a.state.wrap&&(a.adler=p(a.adler,o,l,h)),a.next_in+=l,a.total_in+=l,l),e.lookahead+=r,e.lookahead+e.insert>=x)for(s=e.strstart-e.insert,e.ins_h=e.window[s],e.ins_h=(e.ins_h<<e.hash_shift^e.window[s+1])&e.hash_mask;e.insert&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[s+x-1])&e.hash_mask,e.prev[s&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=s,s++,e.insert--,!(e.lookahead+e.insert<x)););}while(e.lookahead<z&&0!==e.strm.avail_in)}function Z(e,t){for(var r,n;;){if(e.lookahead<z){if(j(e),e.lookahead<z&&t===l)return A;if(0===e.lookahead)break}if(r=0,e.lookahead>=x&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+x-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==r&&e.strstart-r<=e.w_size-z&&(e.match_length=L(e,r)),e.match_length>=x)if(n=u._tr_tally(e,e.strstart-e.match_start,e.match_length-x),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=x){for(e.match_length--;e.strstart++,e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+x-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart,0!=--e.match_length;);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+1])&e.hash_mask;else n=u._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(n&&(N(e,!1),0===e.strm.avail_out))return A}return e.insert=e.strstart<x-1?e.strstart:x-1,t===f?(N(e,!0),0===e.strm.avail_out?O:B):e.last_lit&&(N(e,!1),0===e.strm.avail_out)?A:I}function W(e,t){for(var r,n,i;;){if(e.lookahead<z){if(j(e),e.lookahead<z&&t===l)return A;if(0===e.lookahead)break}if(r=0,e.lookahead>=x&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+x-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=x-1,0!==r&&e.prev_length<e.max_lazy_match&&e.strstart-r<=e.w_size-z&&(e.match_length=L(e,r),e.match_length<=5&&(1===e.strategy||e.match_length===x&&4096<e.strstart-e.match_start)&&(e.match_length=x-1)),e.prev_length>=x&&e.match_length<=e.prev_length){for(i=e.strstart+e.lookahead-x,n=u._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-x),e.lookahead-=e.prev_length-1,e.prev_length-=2;++e.strstart<=i&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+x-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!=--e.prev_length;);if(e.match_available=0,e.match_length=x-1,e.strstart++,n&&(N(e,!1),0===e.strm.avail_out))return A}else if(e.match_available){if((n=u._tr_tally(e,0,e.window[e.strstart-1]))&&N(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return A}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(n=u._tr_tally(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<x-1?e.strstart:x-1,t===f?(N(e,!0),0===e.strm.avail_out?O:B):e.last_lit&&(N(e,!1),0===e.strm.avail_out)?A:I}function M(e,t,r,n,i){this.good_length=e,this.max_lazy=t,this.nice_length=r,this.max_chain=n,this.func=i}function H(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=v,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new c.Buf16(2*w),this.dyn_dtree=new c.Buf16(2*(2*a+1)),this.bl_tree=new c.Buf16(2*(2*o+1)),D(this.dyn_ltree),D(this.dyn_dtree),D(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new c.Buf16(k+1),this.heap=new c.Buf16(2*s+1),D(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new c.Buf16(2*s+1),D(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function G(e){var t;return e&&e.state?(e.total_in=e.total_out=0,e.data_type=i,(t=e.state).pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?C:E,e.adler=2===t.wrap?0:1,t.last_flush=l,u._tr_init(t),m):R(e,_)}function K(e){var t=G(e);return t===m&&function(e){e.window_size=2*e.w_size,D(e.head),e.max_lazy_match=h[e.level].max_lazy,e.good_match=h[e.level].good_length,e.nice_match=h[e.level].nice_length,e.max_chain_length=h[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=x-1,e.match_available=0,e.ins_h=0}(e.state),t}function Y(e,t,r,n,i,s){if(!e)return _;var a=1;if(t===g&&(t=6),n<0?(a=0,n=-n):15<n&&(a=2,n-=16),i<1||y<i||r!==v||n<8||15<n||t<0||9<t||s<0||b<s)return R(e,_);8===n&&(n=9);var o=new H;return(e.state=o).strm=e,o.wrap=a,o.gzhead=null,o.w_bits=n,o.w_size=1<<o.w_bits,o.w_mask=o.w_size-1,o.hash_bits=i+7,o.hash_size=1<<o.hash_bits,o.hash_mask=o.hash_size-1,o.hash_shift=~~((o.hash_bits+x-1)/x),o.window=new c.Buf8(2*o.w_size),o.head=new c.Buf16(o.hash_size),o.prev=new c.Buf16(o.w_size),o.lit_bufsize=1<<i+6,o.pending_buf_size=4*o.lit_bufsize,o.pending_buf=new c.Buf8(o.pending_buf_size),o.d_buf=1*o.lit_bufsize,o.l_buf=3*o.lit_bufsize,o.level=t,o.strategy=s,o.method=r,K(e)}h=[new M(0,0,0,0,function(e,t){var r=65535;for(r>e.pending_buf_size-5&&(r=e.pending_buf_size-5);;){if(e.lookahead<=1){if(j(e),0===e.lookahead&&t===l)return A;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var n=e.block_start+r;if((0===e.strstart||e.strstart>=n)&&(e.lookahead=e.strstart-n,e.strstart=n,N(e,!1),0===e.strm.avail_out))return A;if(e.strstart-e.block_start>=e.w_size-z&&(N(e,!1),0===e.strm.avail_out))return A}return e.insert=0,t===f?(N(e,!0),0===e.strm.avail_out?O:B):(e.strstart>e.block_start&&(N(e,!1),e.strm.avail_out),A)}),new M(4,4,8,4,Z),new M(4,5,16,8,Z),new M(4,6,32,32,Z),new M(4,4,16,16,W),new M(8,16,32,32,W),new M(8,16,128,128,W),new M(8,32,128,256,W),new M(32,128,258,1024,W),new M(32,258,258,4096,W)],r.deflateInit=function(e,t){return Y(e,t,v,15,8,0)},r.deflateInit2=Y,r.deflateReset=K,r.deflateResetKeep=G,r.deflateSetHeader=function(e,t){return e&&e.state?2!==e.state.wrap?_:(e.state.gzhead=t,m):_},r.deflate=function(e,t){var r,n,i,s;if(!e||!e.state||5<t||t<0)return e?R(e,_):_;if(n=e.state,!e.output||!e.input&&0!==e.avail_in||666===n.status&&t!==f)return R(e,0===e.avail_out?-5:_);if(n.strm=e,r=n.last_flush,n.last_flush=t,n.status===C)if(2===n.wrap)e.adler=0,U(n,31),U(n,139),U(n,8),n.gzhead?(U(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),U(n,255&n.gzhead.time),U(n,n.gzhead.time>>8&255),U(n,n.gzhead.time>>16&255),U(n,n.gzhead.time>>24&255),U(n,9===n.level?2:2<=n.strategy||n.level<2?4:0),U(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(U(n,255&n.gzhead.extra.length),U(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=p(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69):(U(n,0),U(n,0),U(n,0),U(n,0),U(n,0),U(n,9===n.level?2:2<=n.strategy||n.level<2?4:0),U(n,3),n.status=E);else{var a=v+(n.w_bits-8<<4)<<8;a|=(2<=n.strategy||n.level<2?0:n.level<6?1:6===n.level?2:3)<<6,0!==n.strstart&&(a|=32),a+=31-a%31,n.status=E,P(n,a),0!==n.strstart&&(P(n,e.adler>>>16),P(n,65535&e.adler)),e.adler=1}if(69===n.status)if(n.gzhead.extra){for(i=n.pending;n.gzindex<(65535&n.gzhead.extra.length)&&(n.pending!==n.pending_buf_size||(n.gzhead.hcrc&&n.pending>i&&(e.adler=p(e.adler,n.pending_buf,n.pending-i,i)),F(e),i=n.pending,n.pending!==n.pending_buf_size));)U(n,255&n.gzhead.extra[n.gzindex]),n.gzindex++;n.gzhead.hcrc&&n.pending>i&&(e.adler=p(e.adler,n.pending_buf,n.pending-i,i)),n.gzindex===n.gzhead.extra.length&&(n.gzindex=0,n.status=73)}else n.status=73;if(73===n.status)if(n.gzhead.name){i=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>i&&(e.adler=p(e.adler,n.pending_buf,n.pending-i,i)),F(e),i=n.pending,n.pending===n.pending_buf_size)){s=1;break}s=n.gzindex<n.gzhead.name.length?255&n.gzhead.name.charCodeAt(n.gzindex++):0,U(n,s)}while(0!==s);n.gzhead.hcrc&&n.pending>i&&(e.adler=p(e.adler,n.pending_buf,n.pending-i,i)),0===s&&(n.gzindex=0,n.status=91)}else n.status=91;if(91===n.status)if(n.gzhead.comment){i=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>i&&(e.adler=p(e.adler,n.pending_buf,n.pending-i,i)),F(e),i=n.pending,n.pending===n.pending_buf_size)){s=1;break}s=n.gzindex<n.gzhead.comment.length?255&n.gzhead.comment.charCodeAt(n.gzindex++):0,U(n,s)}while(0!==s);n.gzhead.hcrc&&n.pending>i&&(e.adler=p(e.adler,n.pending_buf,n.pending-i,i)),0===s&&(n.status=103)}else n.status=103;if(103===n.status&&(n.gzhead.hcrc?(n.pending+2>n.pending_buf_size&&F(e),n.pending+2<=n.pending_buf_size&&(U(n,255&e.adler),U(n,e.adler>>8&255),e.adler=0,n.status=E)):n.status=E),0!==n.pending){if(F(e),0===e.avail_out)return n.last_flush=-1,m}else if(0===e.avail_in&&T(t)<=T(r)&&t!==f)return R(e,-5);if(666===n.status&&0!==e.avail_in)return R(e,-5);if(0!==e.avail_in||0!==n.lookahead||t!==l&&666!==n.status){var o=2===n.strategy?function(e,t){for(var r;;){if(0===e.lookahead&&(j(e),0===e.lookahead)){if(t===l)return A;break}if(e.match_length=0,r=u._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(N(e,!1),0===e.strm.avail_out))return A}return e.insert=0,t===f?(N(e,!0),0===e.strm.avail_out?O:B):e.last_lit&&(N(e,!1),0===e.strm.avail_out)?A:I}(n,t):3===n.strategy?function(e,t){for(var r,n,i,s,a=e.window;;){if(e.lookahead<=S){if(j(e),e.lookahead<=S&&t===l)return A;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=x&&0<e.strstart&&(n=a[i=e.strstart-1])===a[++i]&&n===a[++i]&&n===a[++i]){s=e.strstart+S;do{}while(n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&i<s);e.match_length=S-(s-i),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=x?(r=u._tr_tally(e,1,e.match_length-x),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=u._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(N(e,!1),0===e.strm.avail_out))return A}return e.insert=0,t===f?(N(e,!0),0===e.strm.avail_out?O:B):e.last_lit&&(N(e,!1),0===e.strm.avail_out)?A:I}(n,t):h[n.level].func(n,t);if(o!==O&&o!==B||(n.status=666),o===A||o===O)return 0===e.avail_out&&(n.last_flush=-1),m;if(o===I&&(1===t?u._tr_align(n):5!==t&&(u._tr_stored_block(n,0,0,!1),3===t&&(D(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),F(e),0===e.avail_out))return n.last_flush=-1,m}return t!==f?m:n.wrap<=0?1:(2===n.wrap?(U(n,255&e.adler),U(n,e.adler>>8&255),U(n,e.adler>>16&255),U(n,e.adler>>24&255),U(n,255&e.total_in),U(n,e.total_in>>8&255),U(n,e.total_in>>16&255),U(n,e.total_in>>24&255)):(P(n,e.adler>>>16),P(n,65535&e.adler)),F(e),0<n.wrap&&(n.wrap=-n.wrap),0!==n.pending?m:1)},r.deflateEnd=function(e){var t;return e&&e.state?(t=e.state.status)!==C&&69!==t&&73!==t&&91!==t&&103!==t&&t!==E&&666!==t?R(e,_):(e.state=null,t===E?R(e,-3):m):_},r.deflateSetDictionary=function(e,t){var r,n,i,s,a,o,h,u,l=t.length;if(!e||!e.state)return _;if(2===(s=(r=e.state).wrap)||1===s&&r.status!==C||r.lookahead)return _;for(1===s&&(e.adler=d(e.adler,t,l,0)),r.wrap=0,l>=r.w_size&&(0===s&&(D(r.head),r.strstart=0,r.block_start=0,r.insert=0),u=new c.Buf8(r.w_size),c.arraySet(u,t,l-r.w_size,r.w_size,0),t=u,l=r.w_size),a=e.avail_in,o=e.next_in,h=e.input,e.avail_in=l,e.next_in=0,e.input=t,j(r);r.lookahead>=x;){for(n=r.strstart,i=r.lookahead-(x-1);r.ins_h=(r.ins_h<<r.hash_shift^r.window[n+x-1])&r.hash_mask,r.prev[n&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=n,n++,--i;);r.strstart=n,r.lookahead=x-1,j(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=x-1,r.match_available=0,e.next_in=o,e.input=h,e.avail_in=a,r.wrap=s,m},r.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(e,t,r){"use strict";t.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(e,t,r){"use strict";t.exports=function(e,t){var r,n,i,s,a,o,h,u,l,f,c,d,p,m,_,g,b,v,y,w,k,x,S,z,C;r=e.state,n=e.next_in,z=e.input,i=n+(e.avail_in-5),s=e.next_out,C=e.output,a=s-(t-e.avail_out),o=s+(e.avail_out-257),h=r.dmax,u=r.wsize,l=r.whave,f=r.wnext,c=r.window,d=r.hold,p=r.bits,m=r.lencode,_=r.distcode,g=(1<<r.lenbits)-1,b=(1<<r.distbits)-1;e:do{p<15&&(d+=z[n++]<<p,p+=8,d+=z[n++]<<p,p+=8),v=m[d&g];t:for(;;){if(d>>>=y=v>>>24,p-=y,0===(y=v>>>16&255))C[s++]=65535&v;else{if(!(16&y)){if(0==(64&y)){v=m[(65535&v)+(d&(1<<y)-1)];continue t}if(32&y){r.mode=12;break e}e.msg="invalid literal/length code",r.mode=30;break e}w=65535&v,(y&=15)&&(p<y&&(d+=z[n++]<<p,p+=8),w+=d&(1<<y)-1,d>>>=y,p-=y),p<15&&(d+=z[n++]<<p,p+=8,d+=z[n++]<<p,p+=8),v=_[d&b];r:for(;;){if(d>>>=y=v>>>24,p-=y,!(16&(y=v>>>16&255))){if(0==(64&y)){v=_[(65535&v)+(d&(1<<y)-1)];continue r}e.msg="invalid distance code",r.mode=30;break e}if(k=65535&v,p<(y&=15)&&(d+=z[n++]<<p,(p+=8)<y&&(d+=z[n++]<<p,p+=8)),h<(k+=d&(1<<y)-1)){e.msg="invalid distance too far back",r.mode=30;break e}if(d>>>=y,p-=y,(y=s-a)<k){if(l<(y=k-y)&&r.sane){e.msg="invalid distance too far back",r.mode=30;break e}if(S=c,(x=0)===f){if(x+=u-y,y<w){for(w-=y;C[s++]=c[x++],--y;);x=s-k,S=C}}else if(f<y){if(x+=u+f-y,(y-=f)<w){for(w-=y;C[s++]=c[x++],--y;);if(x=0,f<w){for(w-=y=f;C[s++]=c[x++],--y;);x=s-k,S=C}}}else if(x+=f-y,y<w){for(w-=y;C[s++]=c[x++],--y;);x=s-k,S=C}for(;2<w;)C[s++]=S[x++],C[s++]=S[x++],C[s++]=S[x++],w-=3;w&&(C[s++]=S[x++],1<w&&(C[s++]=S[x++]))}else{for(x=s-k;C[s++]=C[x++],C[s++]=C[x++],C[s++]=C[x++],2<(w-=3););w&&(C[s++]=C[x++],1<w&&(C[s++]=C[x++]))}break}}break}}while(n<i&&s<o);n-=w=p>>3,d&=(1<<(p-=w<<3))-1,e.next_in=n,e.next_out=s,e.avail_in=n<i?i-n+5:5-(n-i),e.avail_out=s<o?o-s+257:257-(s-o),r.hold=d,r.bits=p}},{}],49:[function(e,t,r){"use strict";var I=e("../utils/common"),O=e("./adler32"),B=e("./crc32"),R=e("./inffast"),T=e("./inftrees"),D=1,F=2,N=0,U=-2,P=1,n=852,i=592;function L(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function s(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new I.Buf16(320),this.work=new I.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function a(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=P,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new I.Buf32(n),t.distcode=t.distdyn=new I.Buf32(i),t.sane=1,t.back=-1,N):U}function o(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,a(e)):U}function h(e,t){var r,n;return e&&e.state?(n=e.state,t<0?(r=0,t=-t):(r=1+(t>>4),t<48&&(t&=15)),t&&(t<8||15<t)?U:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=r,n.wbits=t,o(e))):U}function u(e,t){var r,n;return e?(n=new s,(e.state=n).window=null,(r=h(e,t))!==N&&(e.state=null),r):U}var l,f,c=!0;function j(e){if(c){var t;for(l=new I.Buf32(512),f=new I.Buf32(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(T(D,e.lens,0,288,l,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;T(F,e.lens,0,32,f,0,e.work,{bits:5}),c=!1}e.lencode=l,e.lenbits=9,e.distcode=f,e.distbits=5}function Z(e,t,r,n){var i,s=e.state;return null===s.window&&(s.wsize=1<<s.wbits,s.wnext=0,s.whave=0,s.window=new I.Buf8(s.wsize)),n>=s.wsize?(I.arraySet(s.window,t,r-s.wsize,s.wsize,0),s.wnext=0,s.whave=s.wsize):(n<(i=s.wsize-s.wnext)&&(i=n),I.arraySet(s.window,t,r-n,i,s.wnext),(n-=i)?(I.arraySet(s.window,t,r-n,n,0),s.wnext=n,s.whave=s.wsize):(s.wnext+=i,s.wnext===s.wsize&&(s.wnext=0),s.whave<s.wsize&&(s.whave+=i))),0}r.inflateReset=o,r.inflateReset2=h,r.inflateResetKeep=a,r.inflateInit=function(e){return u(e,15)},r.inflateInit2=u,r.inflate=function(e,t){var r,n,i,s,a,o,h,u,l,f,c,d,p,m,_,g,b,v,y,w,k,x,S,z,C=0,E=new I.Buf8(4),A=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!e||!e.state||!e.output||!e.input&&0!==e.avail_in)return U;12===(r=e.state).mode&&(r.mode=13),a=e.next_out,i=e.output,h=e.avail_out,s=e.next_in,n=e.input,o=e.avail_in,u=r.hold,l=r.bits,f=o,c=h,x=N;e:for(;;)switch(r.mode){case P:if(0===r.wrap){r.mode=13;break}for(;l<16;){if(0===o)break e;o--,u+=n[s++]<<l,l+=8}if(2&r.wrap&&35615===u){E[r.check=0]=255&u,E[1]=u>>>8&255,r.check=B(r.check,E,2,0),l=u=0,r.mode=2;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&u)<<8)+(u>>8))%31){e.msg="incorrect header check",r.mode=30;break}if(8!=(15&u)){e.msg="unknown compression method",r.mode=30;break}if(l-=4,k=8+(15&(u>>>=4)),0===r.wbits)r.wbits=k;else if(k>r.wbits){e.msg="invalid window size",r.mode=30;break}r.dmax=1<<k,e.adler=r.check=1,r.mode=512&u?10:12,l=u=0;break;case 2:for(;l<16;){if(0===o)break e;o--,u+=n[s++]<<l,l+=8}if(r.flags=u,8!=(255&r.flags)){e.msg="unknown compression method",r.mode=30;break}if(57344&r.flags){e.msg="unknown header flags set",r.mode=30;break}r.head&&(r.head.text=u>>8&1),512&r.flags&&(E[0]=255&u,E[1]=u>>>8&255,r.check=B(r.check,E,2,0)),l=u=0,r.mode=3;case 3:for(;l<32;){if(0===o)break e;o--,u+=n[s++]<<l,l+=8}r.head&&(r.head.time=u),512&r.flags&&(E[0]=255&u,E[1]=u>>>8&255,E[2]=u>>>16&255,E[3]=u>>>24&255,r.check=B(r.check,E,4,0)),l=u=0,r.mode=4;case 4:for(;l<16;){if(0===o)break e;o--,u+=n[s++]<<l,l+=8}r.head&&(r.head.xflags=255&u,r.head.os=u>>8),512&r.flags&&(E[0]=255&u,E[1]=u>>>8&255,r.check=B(r.check,E,2,0)),l=u=0,r.mode=5;case 5:if(1024&r.flags){for(;l<16;){if(0===o)break e;o--,u+=n[s++]<<l,l+=8}r.length=u,r.head&&(r.head.extra_len=u),512&r.flags&&(E[0]=255&u,E[1]=u>>>8&255,r.check=B(r.check,E,2,0)),l=u=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&r.flags&&(o<(d=r.length)&&(d=o),d&&(r.head&&(k=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Array(r.head.extra_len)),I.arraySet(r.head.extra,n,s,d,k)),512&r.flags&&(r.check=B(r.check,n,d,s)),o-=d,s+=d,r.length-=d),r.length))break e;r.length=0,r.mode=7;case 7:if(2048&r.flags){if(0===o)break e;for(d=0;k=n[s+d++],r.head&&k&&r.length<65536&&(r.head.name+=String.fromCharCode(k)),k&&d<o;);if(512&r.flags&&(r.check=B(r.check,n,d,s)),o-=d,s+=d,k)break e}else r.head&&(r.head.name=null);r.length=0,r.mode=8;case 8:if(4096&r.flags){if(0===o)break e;for(d=0;k=n[s+d++],r.head&&k&&r.length<65536&&(r.head.comment+=String.fromCharCode(k)),k&&d<o;);if(512&r.flags&&(r.check=B(r.check,n,d,s)),o-=d,s+=d,k)break e}else r.head&&(r.head.comment=null);r.mode=9;case 9:if(512&r.flags){for(;l<16;){if(0===o)break e;o--,u+=n[s++]<<l,l+=8}if(u!==(65535&r.check)){e.msg="header crc mismatch",r.mode=30;break}l=u=0}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=12;break;case 10:for(;l<32;){if(0===o)break e;o--,u+=n[s++]<<l,l+=8}e.adler=r.check=L(u),l=u=0,r.mode=11;case 11:if(0===r.havedict)return e.next_out=a,e.avail_out=h,e.next_in=s,e.avail_in=o,r.hold=u,r.bits=l,2;e.adler=r.check=1,r.mode=12;case 12:if(5===t||6===t)break e;case 13:if(r.last){u>>>=7&l,l-=7&l,r.mode=27;break}for(;l<3;){if(0===o)break e;o--,u+=n[s++]<<l,l+=8}switch(r.last=1&u,l-=1,3&(u>>>=1)){case 0:r.mode=14;break;case 1:if(j(r),r.mode=20,6!==t)break;u>>>=2,l-=2;break e;case 2:r.mode=17;break;case 3:e.msg="invalid block type",r.mode=30}u>>>=2,l-=2;break;case 14:for(u>>>=7&l,l-=7&l;l<32;){if(0===o)break e;o--,u+=n[s++]<<l,l+=8}if((65535&u)!=(u>>>16^65535)){e.msg="invalid stored block lengths",r.mode=30;break}if(r.length=65535&u,l=u=0,r.mode=15,6===t)break e;case 15:r.mode=16;case 16:if(d=r.length){if(o<d&&(d=o),h<d&&(d=h),0===d)break e;I.arraySet(i,n,s,d,a),o-=d,s+=d,h-=d,a+=d,r.length-=d;break}r.mode=12;break;case 17:for(;l<14;){if(0===o)break e;o--,u+=n[s++]<<l,l+=8}if(r.nlen=257+(31&u),u>>>=5,l-=5,r.ndist=1+(31&u),u>>>=5,l-=5,r.ncode=4+(15&u),u>>>=4,l-=4,286<r.nlen||30<r.ndist){e.msg="too many length or distance symbols",r.mode=30;break}r.have=0,r.mode=18;case 18:for(;r.have<r.ncode;){for(;l<3;){if(0===o)break e;o--,u+=n[s++]<<l,l+=8}r.lens[A[r.have++]]=7&u,u>>>=3,l-=3}for(;r.have<19;)r.lens[A[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,S={bits:r.lenbits},x=T(0,r.lens,0,19,r.lencode,0,r.work,S),r.lenbits=S.bits,x){e.msg="invalid code lengths set",r.mode=30;break}r.have=0,r.mode=19;case 19:for(;r.have<r.nlen+r.ndist;){for(;g=(C=r.lencode[u&(1<<r.lenbits)-1])>>>16&255,b=65535&C,!((_=C>>>24)<=l);){if(0===o)break e;o--,u+=n[s++]<<l,l+=8}if(b<16)u>>>=_,l-=_,r.lens[r.have++]=b;else{if(16===b){for(z=_+2;l<z;){if(0===o)break e;o--,u+=n[s++]<<l,l+=8}if(u>>>=_,l-=_,0===r.have){e.msg="invalid bit length repeat",r.mode=30;break}k=r.lens[r.have-1],d=3+(3&u),u>>>=2,l-=2}else if(17===b){for(z=_+3;l<z;){if(0===o)break e;o--,u+=n[s++]<<l,l+=8}l-=_,k=0,d=3+(7&(u>>>=_)),u>>>=3,l-=3}else{for(z=_+7;l<z;){if(0===o)break e;o--,u+=n[s++]<<l,l+=8}l-=_,k=0,d=11+(127&(u>>>=_)),u>>>=7,l-=7}if(r.have+d>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=30;break}for(;d--;)r.lens[r.have++]=k}}if(30===r.mode)break;if(0===r.lens[256]){e.msg="invalid code -- missing end-of-block",r.mode=30;break}if(r.lenbits=9,S={bits:r.lenbits},x=T(D,r.lens,0,r.nlen,r.lencode,0,r.work,S),r.lenbits=S.bits,x){e.msg="invalid literal/lengths set",r.mode=30;break}if(r.distbits=6,r.distcode=r.distdyn,S={bits:r.distbits},x=T(F,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,S),r.distbits=S.bits,x){e.msg="invalid distances set",r.mode=30;break}if(r.mode=20,6===t)break e;case 20:r.mode=21;case 21:if(6<=o&&258<=h){e.next_out=a,e.avail_out=h,e.next_in=s,e.avail_in=o,r.hold=u,r.bits=l,R(e,c),a=e.next_out,i=e.output,h=e.avail_out,s=e.next_in,n=e.input,o=e.avail_in,u=r.hold,l=r.bits,12===r.mode&&(r.back=-1);break}for(r.back=0;g=(C=r.lencode[u&(1<<r.lenbits)-1])>>>16&255,b=65535&C,!((_=C>>>24)<=l);){if(0===o)break e;o--,u+=n[s++]<<l,l+=8}if(g&&0==(240&g)){for(v=_,y=g,w=b;g=(C=r.lencode[w+((u&(1<<v+y)-1)>>v)])>>>16&255,b=65535&C,!(v+(_=C>>>24)<=l);){if(0===o)break e;o--,u+=n[s++]<<l,l+=8}u>>>=v,l-=v,r.back+=v}if(u>>>=_,l-=_,r.back+=_,r.length=b,0===g){r.mode=26;break}if(32&g){r.back=-1,r.mode=12;break}if(64&g){e.msg="invalid literal/length code",r.mode=30;break}r.extra=15&g,r.mode=22;case 22:if(r.extra){for(z=r.extra;l<z;){if(0===o)break e;o--,u+=n[s++]<<l,l+=8}r.length+=u&(1<<r.extra)-1,u>>>=r.extra,l-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=23;case 23:for(;g=(C=r.distcode[u&(1<<r.distbits)-1])>>>16&255,b=65535&C,!((_=C>>>24)<=l);){if(0===o)break e;o--,u+=n[s++]<<l,l+=8}if(0==(240&g)){for(v=_,y=g,w=b;g=(C=r.distcode[w+((u&(1<<v+y)-1)>>v)])>>>16&255,b=65535&C,!(v+(_=C>>>24)<=l);){if(0===o)break e;o--,u+=n[s++]<<l,l+=8}u>>>=v,l-=v,r.back+=v}if(u>>>=_,l-=_,r.back+=_,64&g){e.msg="invalid distance code",r.mode=30;break}r.offset=b,r.extra=15&g,r.mode=24;case 24:if(r.extra){for(z=r.extra;l<z;){if(0===o)break e;o--,u+=n[s++]<<l,l+=8}r.offset+=u&(1<<r.extra)-1,u>>>=r.extra,l-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=30;break}r.mode=25;case 25:if(0===h)break e;if(d=c-h,r.offset>d){if((d=r.offset-d)>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=30;break}p=d>r.wnext?(d-=r.wnext,r.wsize-d):r.wnext-d,d>r.length&&(d=r.length),m=r.window}else m=i,p=a-r.offset,d=r.length;for(h<d&&(d=h),h-=d,r.length-=d;i[a++]=m[p++],--d;);0===r.length&&(r.mode=21);break;case 26:if(0===h)break e;i[a++]=r.length,h--,r.mode=21;break;case 27:if(r.wrap){for(;l<32;){if(0===o)break e;o--,u|=n[s++]<<l,l+=8}if(c-=h,e.total_out+=c,r.total+=c,c&&(e.adler=r.check=r.flags?B(r.check,i,c,a-c):O(r.check,i,c,a-c)),c=h,(r.flags?u:L(u))!==r.check){e.msg="incorrect data check",r.mode=30;break}l=u=0}r.mode=28;case 28:if(r.wrap&&r.flags){for(;l<32;){if(0===o)break e;o--,u+=n[s++]<<l,l+=8}if(u!==(4294967295&r.total)){e.msg="incorrect length check",r.mode=30;break}l=u=0}r.mode=29;case 29:x=1;break e;case 30:x=-3;break e;case 31:return-4;case 32:default:return U}return e.next_out=a,e.avail_out=h,e.next_in=s,e.avail_in=o,r.hold=u,r.bits=l,(r.wsize||c!==e.avail_out&&r.mode<30&&(r.mode<27||4!==t))&&Z(e,e.output,e.next_out,c-e.avail_out)?(r.mode=31,-4):(f-=e.avail_in,c-=e.avail_out,e.total_in+=f,e.total_out+=c,r.total+=c,r.wrap&&c&&(e.adler=r.check=r.flags?B(r.check,i,c,e.next_out-c):O(r.check,i,c,e.next_out-c)),e.data_type=r.bits+(r.last?64:0)+(12===r.mode?128:0)+(20===r.mode||15===r.mode?256:0),(0==f&&0===c||4===t)&&x===N&&(x=-5),x)},r.inflateEnd=function(e){if(!e||!e.state)return U;var t=e.state;return t.window&&(t.window=null),e.state=null,N},r.inflateGetHeader=function(e,t){var r;return e&&e.state?0==(2&(r=e.state).wrap)?U:((r.head=t).done=!1,N):U},r.inflateSetDictionary=function(e,t){var r,n=t.length;return e&&e.state?0!==(r=e.state).wrap&&11!==r.mode?U:11===r.mode&&O(1,t,n,0)!==r.check?-3:Z(e,t,n,n)?(r.mode=31,-4):(r.havedict=1,N):U},r.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(e,t,r){"use strict";var D=e("../utils/common"),F=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],N=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],U=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],P=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];t.exports=function(e,t,r,n,i,s,a,o){var h,u,l,f,c,d,p,m,_,g=o.bits,b=0,v=0,y=0,w=0,k=0,x=0,S=0,z=0,C=0,E=0,A=null,I=0,O=new D.Buf16(16),B=new D.Buf16(16),R=null,T=0;for(b=0;b<=15;b++)O[b]=0;for(v=0;v<n;v++)O[t[r+v]]++;for(k=g,w=15;1<=w&&0===O[w];w--);if(w<k&&(k=w),0===w)return i[s++]=20971520,i[s++]=20971520,o.bits=1,0;for(y=1;y<w&&0===O[y];y++);for(k<y&&(k=y),b=z=1;b<=15;b++)if(z<<=1,(z-=O[b])<0)return-1;if(0<z&&(0===e||1!==w))return-1;for(B[1]=0,b=1;b<15;b++)B[b+1]=B[b]+O[b];for(v=0;v<n;v++)0!==t[r+v]&&(a[B[t[r+v]]++]=v);if(d=0===e?(A=R=a,19):1===e?(A=F,I-=257,R=N,T-=257,256):(A=U,R=P,-1),b=y,c=s,S=v=E=0,l=-1,f=(C=1<<(x=k))-1,1===e&&852<C||2===e&&592<C)return 1;for(;;){for(p=b-S,_=a[v]<d?(m=0,a[v]):a[v]>d?(m=R[T+a[v]],A[I+a[v]]):(m=96,0),h=1<<b-S,y=u=1<<x;i[c+(E>>S)+(u-=h)]=p<<24|m<<16|_|0,0!==u;);for(h=1<<b-1;E&h;)h>>=1;if(0!==h?(E&=h-1,E+=h):E=0,v++,0==--O[b]){if(b===w)break;b=t[r+a[v]]}if(k<b&&(E&f)!==l){for(0===S&&(S=k),c+=y,z=1<<(x=b-S);x+S<w&&!((z-=O[x+S])<=0);)x++,z<<=1;if(C+=1<<x,1===e&&852<C||2===e&&592<C)return 1;i[l=E&f]=k<<24|x<<16|c-s|0}}return 0!==E&&(i[c+E]=b-S<<24|64<<16|0),o.bits=k,0}},{"../utils/common":41}],51:[function(e,t,r){"use strict";t.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(e,t,r){"use strict";var i=e("../utils/common"),o=0,h=1;function n(e){for(var t=e.length;0<=--t;)e[t]=0}var s=0,a=29,u=256,l=u+1+a,f=30,c=19,_=2*l+1,g=15,d=16,p=7,m=256,b=16,v=17,y=18,w=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],k=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],x=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],S=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],z=new Array(2*(l+2));n(z);var C=new Array(2*f);n(C);var E=new Array(512);n(E);var A=new Array(256);n(A);var I=new Array(a);n(I);var O,B,R,T=new Array(f);function D(e,t,r,n,i){this.static_tree=e,this.extra_bits=t,this.extra_base=r,this.elems=n,this.max_length=i,this.has_stree=e&&e.length}function F(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function N(e){return e<256?E[e]:E[256+(e>>>7)]}function U(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function P(e,t,r){e.bi_valid>d-r?(e.bi_buf|=t<<e.bi_valid&65535,U(e,e.bi_buf),e.bi_buf=t>>d-e.bi_valid,e.bi_valid+=r-d):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=r)}function L(e,t,r){P(e,r[2*t],r[2*t+1])}function j(e,t){for(var r=0;r|=1&e,e>>>=1,r<<=1,0<--t;);return r>>>1}function Z(e,t,r){var n,i,s=new Array(g+1),a=0;for(n=1;n<=g;n++)s[n]=a=a+r[n-1]<<1;for(i=0;i<=t;i++){var o=e[2*i+1];0!==o&&(e[2*i]=j(s[o]++,o))}}function W(e){var t;for(t=0;t<l;t++)e.dyn_ltree[2*t]=0;for(t=0;t<f;t++)e.dyn_dtree[2*t]=0;for(t=0;t<c;t++)e.bl_tree[2*t]=0;e.dyn_ltree[2*m]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function M(e){8<e.bi_valid?U(e,e.bi_buf):0<e.bi_valid&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function H(e,t,r,n){var i=2*t,s=2*r;return e[i]<e[s]||e[i]===e[s]&&n[t]<=n[r]}function G(e,t,r){for(var n=e.heap[r],i=r<<1;i<=e.heap_len&&(i<e.heap_len&&H(t,e.heap[i+1],e.heap[i],e.depth)&&i++,!H(t,n,e.heap[i],e.depth));)e.heap[r]=e.heap[i],r=i,i<<=1;e.heap[r]=n}function K(e,t,r){var n,i,s,a,o=0;if(0!==e.last_lit)for(;n=e.pending_buf[e.d_buf+2*o]<<8|e.pending_buf[e.d_buf+2*o+1],i=e.pending_buf[e.l_buf+o],o++,0===n?L(e,i,t):(L(e,(s=A[i])+u+1,t),0!==(a=w[s])&&P(e,i-=I[s],a),L(e,s=N(--n),r),0!==(a=k[s])&&P(e,n-=T[s],a)),o<e.last_lit;);L(e,m,t)}function Y(e,t){var r,n,i,s=t.dyn_tree,a=t.stat_desc.static_tree,o=t.stat_desc.has_stree,h=t.stat_desc.elems,u=-1;for(e.heap_len=0,e.heap_max=_,r=0;r<h;r++)0!==s[2*r]?(e.heap[++e.heap_len]=u=r,e.depth[r]=0):s[2*r+1]=0;for(;e.heap_len<2;)s[2*(i=e.heap[++e.heap_len]=u<2?++u:0)]=1,e.depth[i]=0,e.opt_len--,o&&(e.static_len-=a[2*i+1]);for(t.max_code=u,r=e.heap_len>>1;1<=r;r--)G(e,s,r);for(i=h;r=e.heap[1],e.heap[1]=e.heap[e.heap_len--],G(e,s,1),n=e.heap[1],e.heap[--e.heap_max]=r,e.heap[--e.heap_max]=n,s[2*i]=s[2*r]+s[2*n],e.depth[i]=(e.depth[r]>=e.depth[n]?e.depth[r]:e.depth[n])+1,s[2*r+1]=s[2*n+1]=i,e.heap[1]=i++,G(e,s,1),2<=e.heap_len;);e.heap[--e.heap_max]=e.heap[1],function(e,t){var r,n,i,s,a,o,h=t.dyn_tree,u=t.max_code,l=t.stat_desc.static_tree,f=t.stat_desc.has_stree,c=t.stat_desc.extra_bits,d=t.stat_desc.extra_base,p=t.stat_desc.max_length,m=0;for(s=0;s<=g;s++)e.bl_count[s]=0;for(h[2*e.heap[e.heap_max]+1]=0,r=e.heap_max+1;r<_;r++)p<(s=h[2*h[2*(n=e.heap[r])+1]+1]+1)&&(s=p,m++),h[2*n+1]=s,u<n||(e.bl_count[s]++,a=0,d<=n&&(a=c[n-d]),o=h[2*n],e.opt_len+=o*(s+a),f&&(e.static_len+=o*(l[2*n+1]+a)));if(0!==m){do{for(s=p-1;0===e.bl_count[s];)s--;e.bl_count[s]--,e.bl_count[s+1]+=2,e.bl_count[p]--,m-=2}while(0<m);for(s=p;0!==s;s--)for(n=e.bl_count[s];0!==n;)u<(i=e.heap[--r])||(h[2*i+1]!==s&&(e.opt_len+=(s-h[2*i+1])*h[2*i],h[2*i+1]=s),n--)}}(e,t),Z(s,u,e.bl_count)}function X(e,t,r){var n,i,s=-1,a=t[1],o=0,h=7,u=4;for(0===a&&(h=138,u=3),t[2*(r+1)+1]=65535,n=0;n<=r;n++)i=a,a=t[2*(n+1)+1],++o<h&&i===a||(o<u?e.bl_tree[2*i]+=o:0!==i?(i!==s&&e.bl_tree[2*i]++,e.bl_tree[2*b]++):o<=10?e.bl_tree[2*v]++:e.bl_tree[2*y]++,s=i,u=(o=0)===a?(h=138,3):i===a?(h=6,3):(h=7,4))}function V(e,t,r){var n,i,s=-1,a=t[1],o=0,h=7,u=4;for(0===a&&(h=138,u=3),n=0;n<=r;n++)if(i=a,a=t[2*(n+1)+1],!(++o<h&&i===a)){if(o<u)for(;L(e,i,e.bl_tree),0!=--o;);else 0!==i?(i!==s&&(L(e,i,e.bl_tree),o--),L(e,b,e.bl_tree),P(e,o-3,2)):o<=10?(L(e,v,e.bl_tree),P(e,o-3,3)):(L(e,y,e.bl_tree),P(e,o-11,7));s=i,u=(o=0)===a?(h=138,3):i===a?(h=6,3):(h=7,4)}}n(T);var q=!1;function J(e,t,r,n){P(e,(s<<1)+(n?1:0),3),function(e,t,r,n){M(e),n&&(U(e,r),U(e,~r)),i.arraySet(e.pending_buf,e.window,t,r,e.pending),e.pending+=r}(e,t,r,!0)}r._tr_init=function(e){q||(function(){var e,t,r,n,i,s=new Array(g+1);for(n=r=0;n<a-1;n++)for(I[n]=r,e=0;e<1<<w[n];e++)A[r++]=n;for(A[r-1]=n,n=i=0;n<16;n++)for(T[n]=i,e=0;e<1<<k[n];e++)E[i++]=n;for(i>>=7;n<f;n++)for(T[n]=i<<7,e=0;e<1<<k[n]-7;e++)E[256+i++]=n;for(t=0;t<=g;t++)s[t]=0;for(e=0;e<=143;)z[2*e+1]=8,e++,s[8]++;for(;e<=255;)z[2*e+1]=9,e++,s[9]++;for(;e<=279;)z[2*e+1]=7,e++,s[7]++;for(;e<=287;)z[2*e+1]=8,e++,s[8]++;for(Z(z,l+1,s),e=0;e<f;e++)C[2*e+1]=5,C[2*e]=j(e,5);O=new D(z,w,u+1,l,g),B=new D(C,k,0,f,g),R=new D(new Array(0),x,0,c,p)}(),q=!0),e.l_desc=new F(e.dyn_ltree,O),e.d_desc=new F(e.dyn_dtree,B),e.bl_desc=new F(e.bl_tree,R),e.bi_buf=0,e.bi_valid=0,W(e)},r._tr_stored_block=J,r._tr_flush_block=function(e,t,r,n){var i,s,a=0;0<e.level?(2===e.strm.data_type&&(e.strm.data_type=function(e){var t,r=4093624447;for(t=0;t<=31;t++,r>>>=1)if(1&r&&0!==e.dyn_ltree[2*t])return o;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return h;for(t=32;t<u;t++)if(0!==e.dyn_ltree[2*t])return h;return o}(e)),Y(e,e.l_desc),Y(e,e.d_desc),a=function(e){var t;for(X(e,e.dyn_ltree,e.l_desc.max_code),X(e,e.dyn_dtree,e.d_desc.max_code),Y(e,e.bl_desc),t=c-1;3<=t&&0===e.bl_tree[2*S[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t}(e),i=e.opt_len+3+7>>>3,(s=e.static_len+3+7>>>3)<=i&&(i=s)):i=s=r+5,r+4<=i&&-1!==t?J(e,t,r,n):4===e.strategy||s===i?(P(e,2+(n?1:0),3),K(e,z,C)):(P(e,4+(n?1:0),3),function(e,t,r,n){var i;for(P(e,t-257,5),P(e,r-1,5),P(e,n-4,4),i=0;i<n;i++)P(e,e.bl_tree[2*S[i]+1],3);V(e,e.dyn_ltree,t-1),V(e,e.dyn_dtree,r-1)}(e,e.l_desc.max_code+1,e.d_desc.max_code+1,a+1),K(e,e.dyn_ltree,e.dyn_dtree)),W(e),n&&M(e)},r._tr_tally=function(e,t,r){return e.pending_buf[e.d_buf+2*e.last_lit]=t>>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&r,e.last_lit++,0===t?e.dyn_ltree[2*r]++:(e.matches++,t--,e.dyn_ltree[2*(A[r]+u+1)]++,e.dyn_dtree[2*N(t)]++),e.last_lit===e.lit_bufsize-1},r._tr_align=function(e){P(e,2,3),L(e,m,z),function(e){16===e.bi_valid?(U(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):8<=e.bi_valid&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}(e)}},{"../utils/common":41}],53:[function(e,t,r){"use strict";t.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(e,t,r){(function(e){!function(r,n){"use strict";if(!r.setImmediate){var i,s,t,a,o=1,h={},u=!1,l=r.document,e=Object.getPrototypeOf&&Object.getPrototypeOf(r);e=e&&e.setTimeout?e:r,i="[object process]"==={}.toString.call(r.process)?function(e){process.nextTick(function(){c(e)})}:function(){if(r.postMessage&&!r.importScripts){var e=!0,t=r.onmessage;return r.onmessage=function(){e=!1},r.postMessage("","*"),r.onmessage=t,e}}()?(a="setImmediate$"+Math.random()+"$",r.addEventListener?r.addEventListener("message",d,!1):r.attachEvent("onmessage",d),function(e){r.postMessage(a+e,"*")}):r.MessageChannel?((t=new MessageChannel).port1.onmessage=function(e){c(e.data)},function(e){t.port2.postMessage(e)}):l&&"onreadystatechange"in l.createElement("script")?(s=l.documentElement,function(e){var t=l.createElement("script");t.onreadystatechange=function(){c(e),t.onreadystatechange=null,s.removeChild(t),t=null},s.appendChild(t)}):function(e){setTimeout(c,0,e)},e.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),r=0;r<t.length;r++)t[r]=arguments[r+1];var n={callback:e,args:t};return h[o]=n,i(o),o++},e.clearImmediate=f}function f(e){delete h[e]}function c(e){if(u)setTimeout(c,0,e);else{var t=h[e];if(t){u=!0;try{!function(e){var t=e.callback,r=e.args;switch(r.length){case 0:t();break;case 1:t(r[0]);break;case 2:t(r[0],r[1]);break;case 3:t(r[0],r[1],r[2]);break;default:t.apply(n,r)}}(t)}finally{f(e),u=!1}}}}function d(e){e.source===r&&"string"==typeof e.data&&0===e.data.indexOf(a)&&c(+e.data.slice(a.length))}}("undefined"==typeof self?void 0===e?this:e:self)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[10])(10)});
  2128. }).call(this)}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],require("timers").setImmediate)
  2129. },{"_process":12,"buffer":3,"timers":31}],11:[function(require,module,exports){
  2130. (function (process){(function (){
  2131. 'use strict';
  2132. if (typeof process === 'undefined' ||
  2133. !process.version ||
  2134. process.version.indexOf('v0.') === 0 ||
  2135. process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) {
  2136. module.exports = { nextTick: nextTick };
  2137. } else {
  2138. module.exports = process
  2139. }
  2140. function nextTick(fn, arg1, arg2, arg3) {
  2141. if (typeof fn !== 'function') {
  2142. throw new TypeError('"callback" argument must be a function');
  2143. }
  2144. var len = arguments.length;
  2145. var args, i;
  2146. switch (len) {
  2147. case 0:
  2148. case 1:
  2149. return process.nextTick(fn);
  2150. case 2:
  2151. return process.nextTick(function afterTickOne() {
  2152. fn.call(null, arg1);
  2153. });
  2154. case 3:
  2155. return process.nextTick(function afterTickTwo() {
  2156. fn.call(null, arg1, arg2);
  2157. });
  2158. case 4:
  2159. return process.nextTick(function afterTickThree() {
  2160. fn.call(null, arg1, arg2, arg3);
  2161. });
  2162. default:
  2163. args = new Array(len - 1);
  2164. i = 0;
  2165. while (i < args.length) {
  2166. args[i++] = arguments[i];
  2167. }
  2168. return process.nextTick(function afterTick() {
  2169. fn.apply(null, args);
  2170. });
  2171. }
  2172. }
  2173. }).call(this)}).call(this,require('_process'))
  2174. },{"_process":12}],12:[function(require,module,exports){
  2175. // shim for using process in browser
  2176. var process = module.exports = {};
  2177. // cached from whatever global is present so that test runners that stub it
  2178. // don't break things. But we need to wrap it in a try catch in case it is
  2179. // wrapped in strict mode code which doesn't define any globals. It's inside a
  2180. // function because try/catches deoptimize in certain engines.
  2181. var cachedSetTimeout;
  2182. var cachedClearTimeout;
  2183. function defaultSetTimout() {
  2184. throw new Error('setTimeout has not been defined');
  2185. }
  2186. function defaultClearTimeout () {
  2187. throw new Error('clearTimeout has not been defined');
  2188. }
  2189. (function () {
  2190. try {
  2191. if (typeof setTimeout === 'function') {
  2192. cachedSetTimeout = setTimeout;
  2193. } else {
  2194. cachedSetTimeout = defaultSetTimout;
  2195. }
  2196. } catch (e) {
  2197. cachedSetTimeout = defaultSetTimout;
  2198. }
  2199. try {
  2200. if (typeof clearTimeout === 'function') {
  2201. cachedClearTimeout = clearTimeout;
  2202. } else {
  2203. cachedClearTimeout = defaultClearTimeout;
  2204. }
  2205. } catch (e) {
  2206. cachedClearTimeout = defaultClearTimeout;
  2207. }
  2208. } ())
  2209. function runTimeout(fun) {
  2210. if (cachedSetTimeout === setTimeout) {
  2211. //normal enviroments in sane situations
  2212. return setTimeout(fun, 0);
  2213. }
  2214. // if setTimeout wasn't available but was latter defined
  2215. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  2216. cachedSetTimeout = setTimeout;
  2217. return setTimeout(fun, 0);
  2218. }
  2219. try {
  2220. // when when somebody has screwed with setTimeout but no I.E. maddness
  2221. return cachedSetTimeout(fun, 0);
  2222. } catch(e){
  2223. try {
  2224. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  2225. return cachedSetTimeout.call(null, fun, 0);
  2226. } catch(e){
  2227. // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
  2228. return cachedSetTimeout.call(this, fun, 0);
  2229. }
  2230. }
  2231. }
  2232. function runClearTimeout(marker) {
  2233. if (cachedClearTimeout === clearTimeout) {
  2234. //normal enviroments in sane situations
  2235. return clearTimeout(marker);
  2236. }
  2237. // if clearTimeout wasn't available but was latter defined
  2238. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  2239. cachedClearTimeout = clearTimeout;
  2240. return clearTimeout(marker);
  2241. }
  2242. try {
  2243. // when when somebody has screwed with setTimeout but no I.E. maddness
  2244. return cachedClearTimeout(marker);
  2245. } catch (e){
  2246. try {
  2247. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  2248. return cachedClearTimeout.call(null, marker);
  2249. } catch (e){
  2250. // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
  2251. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  2252. return cachedClearTimeout.call(this, marker);
  2253. }
  2254. }
  2255. }
  2256. var queue = [];
  2257. var draining = false;
  2258. var currentQueue;
  2259. var queueIndex = -1;
  2260. function cleanUpNextTick() {
  2261. if (!draining || !currentQueue) {
  2262. return;
  2263. }
  2264. draining = false;
  2265. if (currentQueue.length) {
  2266. queue = currentQueue.concat(queue);
  2267. } else {
  2268. queueIndex = -1;
  2269. }
  2270. if (queue.length) {
  2271. drainQueue();
  2272. }
  2273. }
  2274. function drainQueue() {
  2275. if (draining) {
  2276. return;
  2277. }
  2278. var timeout = runTimeout(cleanUpNextTick);
  2279. draining = true;
  2280. var len = queue.length;
  2281. while(len) {
  2282. currentQueue = queue;
  2283. queue = [];
  2284. while (++queueIndex < len) {
  2285. if (currentQueue) {
  2286. currentQueue[queueIndex].run();
  2287. }
  2288. }
  2289. queueIndex = -1;
  2290. len = queue.length;
  2291. }
  2292. currentQueue = null;
  2293. draining = false;
  2294. runClearTimeout(timeout);
  2295. }
  2296. process.nextTick = function (fun) {
  2297. var args = new Array(arguments.length - 1);
  2298. if (arguments.length > 1) {
  2299. for (var i = 1; i < arguments.length; i++) {
  2300. args[i - 1] = arguments[i];
  2301. }
  2302. }
  2303. queue.push(new Item(fun, args));
  2304. if (queue.length === 1 && !draining) {
  2305. runTimeout(drainQueue);
  2306. }
  2307. };
  2308. // v8 likes predictible objects
  2309. function Item(fun, array) {
  2310. this.fun = fun;
  2311. this.array = array;
  2312. }
  2313. Item.prototype.run = function () {
  2314. this.fun.apply(null, this.array);
  2315. };
  2316. process.title = 'browser';
  2317. process.browser = true;
  2318. process.env = {};
  2319. process.argv = [];
  2320. process.version = ''; // empty string to avoid regexp issues
  2321. process.versions = {};
  2322. function noop() {}
  2323. process.on = noop;
  2324. process.addListener = noop;
  2325. process.once = noop;
  2326. process.off = noop;
  2327. process.removeListener = noop;
  2328. process.removeAllListeners = noop;
  2329. process.emit = noop;
  2330. process.prependListener = noop;
  2331. process.prependOnceListener = noop;
  2332. process.listeners = function (name) { return [] }
  2333. process.binding = function (name) {
  2334. throw new Error('process.binding is not supported');
  2335. };
  2336. process.cwd = function () { return '/' };
  2337. process.chdir = function (dir) {
  2338. throw new Error('process.chdir is not supported');
  2339. };
  2340. process.umask = function() { return 0; };
  2341. },{}],13:[function(require,module,exports){
  2342. module.exports = require('./lib/_stream_duplex.js');
  2343. },{"./lib/_stream_duplex.js":14}],14:[function(require,module,exports){
  2344. // Copyright Joyent, Inc. and other Node contributors.
  2345. //
  2346. // Permission is hereby granted, free of charge, to any person obtaining a
  2347. // copy of this software and associated documentation files (the
  2348. // "Software"), to deal in the Software without restriction, including
  2349. // without limitation the rights to use, copy, modify, merge, publish,
  2350. // distribute, sublicense, and/or sell copies of the Software, and to permit
  2351. // persons to whom the Software is furnished to do so, subject to the
  2352. // following conditions:
  2353. //
  2354. // The above copyright notice and this permission notice shall be included
  2355. // in all copies or substantial portions of the Software.
  2356. //
  2357. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  2358. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  2359. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  2360. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  2361. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  2362. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  2363. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  2364. // a duplex stream is just a stream that is both readable and writable.
  2365. // Since JS doesn't have multiple prototypal inheritance, this class
  2366. // prototypally inherits from Readable, and then parasitically from
  2367. // Writable.
  2368. 'use strict';
  2369. /*<replacement>*/
  2370. var pna = require('process-nextick-args');
  2371. /*</replacement>*/
  2372. /*<replacement>*/
  2373. var objectKeys = Object.keys || function (obj) {
  2374. var keys = [];
  2375. for (var key in obj) {
  2376. keys.push(key);
  2377. }return keys;
  2378. };
  2379. /*</replacement>*/
  2380. module.exports = Duplex;
  2381. /*<replacement>*/
  2382. var util = Object.create(require('core-util-is'));
  2383. util.inherits = require('inherits');
  2384. /*</replacement>*/
  2385. var Readable = require('./_stream_readable');
  2386. var Writable = require('./_stream_writable');
  2387. util.inherits(Duplex, Readable);
  2388. {
  2389. // avoid scope creep, the keys array can then be collected
  2390. var keys = objectKeys(Writable.prototype);
  2391. for (var v = 0; v < keys.length; v++) {
  2392. var method = keys[v];
  2393. if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
  2394. }
  2395. }
  2396. function Duplex(options) {
  2397. if (!(this instanceof Duplex)) return new Duplex(options);
  2398. Readable.call(this, options);
  2399. Writable.call(this, options);
  2400. if (options && options.readable === false) this.readable = false;
  2401. if (options && options.writable === false) this.writable = false;
  2402. this.allowHalfOpen = true;
  2403. if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;
  2404. this.once('end', onend);
  2405. }
  2406. Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', {
  2407. // making it explicit this property is not enumerable
  2408. // because otherwise some prototype manipulation in
  2409. // userland will fail
  2410. enumerable: false,
  2411. get: function () {
  2412. return this._writableState.highWaterMark;
  2413. }
  2414. });
  2415. // the no-half-open enforcer
  2416. function onend() {
  2417. // if we allow half-open state, or if the writable side ended,
  2418. // then we're ok.
  2419. if (this.allowHalfOpen || this._writableState.ended) return;
  2420. // no more data can be written.
  2421. // But allow more writes to happen in this tick.
  2422. pna.nextTick(onEndNT, this);
  2423. }
  2424. function onEndNT(self) {
  2425. self.end();
  2426. }
  2427. Object.defineProperty(Duplex.prototype, 'destroyed', {
  2428. get: function () {
  2429. if (this._readableState === undefined || this._writableState === undefined) {
  2430. return false;
  2431. }
  2432. return this._readableState.destroyed && this._writableState.destroyed;
  2433. },
  2434. set: function (value) {
  2435. // we ignore the value if the stream
  2436. // has not been initialized yet
  2437. if (this._readableState === undefined || this._writableState === undefined) {
  2438. return;
  2439. }
  2440. // backward compatibility, the user is explicitly
  2441. // managing destroyed
  2442. this._readableState.destroyed = value;
  2443. this._writableState.destroyed = value;
  2444. }
  2445. });
  2446. Duplex.prototype._destroy = function (err, cb) {
  2447. this.push(null);
  2448. this.end();
  2449. pna.nextTick(cb, err);
  2450. };
  2451. },{"./_stream_readable":16,"./_stream_writable":18,"core-util-is":4,"inherits":8,"process-nextick-args":11}],15:[function(require,module,exports){
  2452. // Copyright Joyent, Inc. and other Node contributors.
  2453. //
  2454. // Permission is hereby granted, free of charge, to any person obtaining a
  2455. // copy of this software and associated documentation files (the
  2456. // "Software"), to deal in the Software without restriction, including
  2457. // without limitation the rights to use, copy, modify, merge, publish,
  2458. // distribute, sublicense, and/or sell copies of the Software, and to permit
  2459. // persons to whom the Software is furnished to do so, subject to the
  2460. // following conditions:
  2461. //
  2462. // The above copyright notice and this permission notice shall be included
  2463. // in all copies or substantial portions of the Software.
  2464. //
  2465. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  2466. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  2467. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  2468. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  2469. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  2470. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  2471. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  2472. // a passthrough stream.
  2473. // basically just the most minimal sort of Transform stream.
  2474. // Every written chunk gets output as-is.
  2475. 'use strict';
  2476. module.exports = PassThrough;
  2477. var Transform = require('./_stream_transform');
  2478. /*<replacement>*/
  2479. var util = Object.create(require('core-util-is'));
  2480. util.inherits = require('inherits');
  2481. /*</replacement>*/
  2482. util.inherits(PassThrough, Transform);
  2483. function PassThrough(options) {
  2484. if (!(this instanceof PassThrough)) return new PassThrough(options);
  2485. Transform.call(this, options);
  2486. }
  2487. PassThrough.prototype._transform = function (chunk, encoding, cb) {
  2488. cb(null, chunk);
  2489. };
  2490. },{"./_stream_transform":17,"core-util-is":4,"inherits":8}],16:[function(require,module,exports){
  2491. (function (process,global){(function (){
  2492. // Copyright Joyent, Inc. and other Node contributors.
  2493. //
  2494. // Permission is hereby granted, free of charge, to any person obtaining a
  2495. // copy of this software and associated documentation files (the
  2496. // "Software"), to deal in the Software without restriction, including
  2497. // without limitation the rights to use, copy, modify, merge, publish,
  2498. // distribute, sublicense, and/or sell copies of the Software, and to permit
  2499. // persons to whom the Software is furnished to do so, subject to the
  2500. // following conditions:
  2501. //
  2502. // The above copyright notice and this permission notice shall be included
  2503. // in all copies or substantial portions of the Software.
  2504. //
  2505. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  2506. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  2507. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  2508. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  2509. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  2510. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  2511. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  2512. 'use strict';
  2513. /*<replacement>*/
  2514. var pna = require('process-nextick-args');
  2515. /*</replacement>*/
  2516. module.exports = Readable;
  2517. /*<replacement>*/
  2518. var isArray = require('isarray');
  2519. /*</replacement>*/
  2520. /*<replacement>*/
  2521. var Duplex;
  2522. /*</replacement>*/
  2523. Readable.ReadableState = ReadableState;
  2524. /*<replacement>*/
  2525. var EE = require('events').EventEmitter;
  2526. var EElistenerCount = function (emitter, type) {
  2527. return emitter.listeners(type).length;
  2528. };
  2529. /*</replacement>*/
  2530. /*<replacement>*/
  2531. var Stream = require('./internal/streams/stream');
  2532. /*</replacement>*/
  2533. /*<replacement>*/
  2534. var Buffer = require('safe-buffer').Buffer;
  2535. var OurUint8Array = (typeof global !== 'undefined' ? global : typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : {}).Uint8Array || function () {};
  2536. function _uint8ArrayToBuffer(chunk) {
  2537. return Buffer.from(chunk);
  2538. }
  2539. function _isUint8Array(obj) {
  2540. return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
  2541. }
  2542. /*</replacement>*/
  2543. /*<replacement>*/
  2544. var util = Object.create(require('core-util-is'));
  2545. util.inherits = require('inherits');
  2546. /*</replacement>*/
  2547. /*<replacement>*/
  2548. var debugUtil = require('util');
  2549. var debug = void 0;
  2550. if (debugUtil && debugUtil.debuglog) {
  2551. debug = debugUtil.debuglog('stream');
  2552. } else {
  2553. debug = function () {};
  2554. }
  2555. /*</replacement>*/
  2556. var BufferList = require('./internal/streams/BufferList');
  2557. var destroyImpl = require('./internal/streams/destroy');
  2558. var StringDecoder;
  2559. util.inherits(Readable, Stream);
  2560. var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];
  2561. function prependListener(emitter, event, fn) {
  2562. // Sadly this is not cacheable as some libraries bundle their own
  2563. // event emitter implementation with them.
  2564. if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn);
  2565. // This is a hack to make sure that our error handler is attached before any
  2566. // userland ones. NEVER DO THIS. This is here only because this code needs
  2567. // to continue to work with older versions of Node.js that do not include
  2568. // the prependListener() method. The goal is to eventually remove this hack.
  2569. if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]];
  2570. }
  2571. function ReadableState(options, stream) {
  2572. Duplex = Duplex || require('./_stream_duplex');
  2573. options = options || {};
  2574. // Duplex streams are both readable and writable, but share
  2575. // the same options object.
  2576. // However, some cases require setting options to different
  2577. // values for the readable and the writable sides of the duplex stream.
  2578. // These options can be provided separately as readableXXX and writableXXX.
  2579. var isDuplex = stream instanceof Duplex;
  2580. // object stream flag. Used to make read(n) ignore n and to
  2581. // make all the buffer merging and length checks go away
  2582. this.objectMode = !!options.objectMode;
  2583. if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode;
  2584. // the point at which it stops calling _read() to fill the buffer
  2585. // Note: 0 is a valid value, means "don't call _read preemptively ever"
  2586. var hwm = options.highWaterMark;
  2587. var readableHwm = options.readableHighWaterMark;
  2588. var defaultHwm = this.objectMode ? 16 : 16 * 1024;
  2589. if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (readableHwm || readableHwm === 0)) this.highWaterMark = readableHwm;else this.highWaterMark = defaultHwm;
  2590. // cast to ints.
  2591. this.highWaterMark = Math.floor(this.highWaterMark);
  2592. // A linked list is used to store data chunks instead of an array because the
  2593. // linked list can remove elements from the beginning faster than
  2594. // array.shift()
  2595. this.buffer = new BufferList();
  2596. this.length = 0;
  2597. this.pipes = null;
  2598. this.pipesCount = 0;
  2599. this.flowing = null;
  2600. this.ended = false;
  2601. this.endEmitted = false;
  2602. this.reading = false;
  2603. // a flag to be able to tell if the event 'readable'/'data' is emitted
  2604. // immediately, or on a later tick. We set this to true at first, because
  2605. // any actions that shouldn't happen until "later" should generally also
  2606. // not happen before the first read call.
  2607. this.sync = true;
  2608. // whenever we return null, then we set a flag to say
  2609. // that we're awaiting a 'readable' event emission.
  2610. this.needReadable = false;
  2611. this.emittedReadable = false;
  2612. this.readableListening = false;
  2613. this.resumeScheduled = false;
  2614. // has it been destroyed
  2615. this.destroyed = false;
  2616. // Crypto is kind of old and crusty. Historically, its default string
  2617. // encoding is 'binary' so we have to make this configurable.
  2618. // Everything else in the universe uses 'utf8', though.
  2619. this.defaultEncoding = options.defaultEncoding || 'utf8';
  2620. // the number of writers that are awaiting a drain event in .pipe()s
  2621. this.awaitDrain = 0;
  2622. // if true, a maybeReadMore has been scheduled
  2623. this.readingMore = false;
  2624. this.decoder = null;
  2625. this.encoding = null;
  2626. if (options.encoding) {
  2627. if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;
  2628. this.decoder = new StringDecoder(options.encoding);
  2629. this.encoding = options.encoding;
  2630. }
  2631. }
  2632. function Readable(options) {
  2633. Duplex = Duplex || require('./_stream_duplex');
  2634. if (!(this instanceof Readable)) return new Readable(options);
  2635. this._readableState = new ReadableState(options, this);
  2636. // legacy
  2637. this.readable = true;
  2638. if (options) {
  2639. if (typeof options.read === 'function') this._read = options.read;
  2640. if (typeof options.destroy === 'function') this._destroy = options.destroy;
  2641. }
  2642. Stream.call(this);
  2643. }
  2644. Object.defineProperty(Readable.prototype, 'destroyed', {
  2645. get: function () {
  2646. if (this._readableState === undefined) {
  2647. return false;
  2648. }
  2649. return this._readableState.destroyed;
  2650. },
  2651. set: function (value) {
  2652. // we ignore the value if the stream
  2653. // has not been initialized yet
  2654. if (!this._readableState) {
  2655. return;
  2656. }
  2657. // backward compatibility, the user is explicitly
  2658. // managing destroyed
  2659. this._readableState.destroyed = value;
  2660. }
  2661. });
  2662. Readable.prototype.destroy = destroyImpl.destroy;
  2663. Readable.prototype._undestroy = destroyImpl.undestroy;
  2664. Readable.prototype._destroy = function (err, cb) {
  2665. this.push(null);
  2666. cb(err);
  2667. };
  2668. // Manually shove something into the read() buffer.
  2669. // This returns true if the highWaterMark has not been hit yet,
  2670. // similar to how Writable.write() returns true if you should
  2671. // write() some more.
  2672. Readable.prototype.push = function (chunk, encoding) {
  2673. var state = this._readableState;
  2674. var skipChunkCheck;
  2675. if (!state.objectMode) {
  2676. if (typeof chunk === 'string') {
  2677. encoding = encoding || state.defaultEncoding;
  2678. if (encoding !== state.encoding) {
  2679. chunk = Buffer.from(chunk, encoding);
  2680. encoding = '';
  2681. }
  2682. skipChunkCheck = true;
  2683. }
  2684. } else {
  2685. skipChunkCheck = true;
  2686. }
  2687. return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);
  2688. };
  2689. // Unshift should *always* be something directly out of read()
  2690. Readable.prototype.unshift = function (chunk) {
  2691. return readableAddChunk(this, chunk, null, true, false);
  2692. };
  2693. function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {
  2694. var state = stream._readableState;
  2695. if (chunk === null) {
  2696. state.reading = false;
  2697. onEofChunk(stream, state);
  2698. } else {
  2699. var er;
  2700. if (!skipChunkCheck) er = chunkInvalid(state, chunk);
  2701. if (er) {
  2702. stream.emit('error', er);
  2703. } else if (state.objectMode || chunk && chunk.length > 0) {
  2704. if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) {
  2705. chunk = _uint8ArrayToBuffer(chunk);
  2706. }
  2707. if (addToFront) {
  2708. if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true);
  2709. } else if (state.ended) {
  2710. stream.emit('error', new Error('stream.push() after EOF'));
  2711. } else {
  2712. state.reading = false;
  2713. if (state.decoder && !encoding) {
  2714. chunk = state.decoder.write(chunk);
  2715. if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state);
  2716. } else {
  2717. addChunk(stream, state, chunk, false);
  2718. }
  2719. }
  2720. } else if (!addToFront) {
  2721. state.reading = false;
  2722. }
  2723. }
  2724. return needMoreData(state);
  2725. }
  2726. function addChunk(stream, state, chunk, addToFront) {
  2727. if (state.flowing && state.length === 0 && !state.sync) {
  2728. stream.emit('data', chunk);
  2729. stream.read(0);
  2730. } else {
  2731. // update the buffer info.
  2732. state.length += state.objectMode ? 1 : chunk.length;
  2733. if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);
  2734. if (state.needReadable) emitReadable(stream);
  2735. }
  2736. maybeReadMore(stream, state);
  2737. }
  2738. function chunkInvalid(state, chunk) {
  2739. var er;
  2740. if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
  2741. er = new TypeError('Invalid non-string/buffer chunk');
  2742. }
  2743. return er;
  2744. }
  2745. // if it's past the high water mark, we can push in some more.
  2746. // Also, if we have no data yet, we can stand some
  2747. // more bytes. This is to work around cases where hwm=0,
  2748. // such as the repl. Also, if the push() triggered a
  2749. // readable event, and the user called read(largeNumber) such that
  2750. // needReadable was set, then we ought to push more, so that another
  2751. // 'readable' event will be triggered.
  2752. function needMoreData(state) {
  2753. return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);
  2754. }
  2755. Readable.prototype.isPaused = function () {
  2756. return this._readableState.flowing === false;
  2757. };
  2758. // backwards compatibility.
  2759. Readable.prototype.setEncoding = function (enc) {
  2760. if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;
  2761. this._readableState.decoder = new StringDecoder(enc);
  2762. this._readableState.encoding = enc;
  2763. return this;
  2764. };
  2765. // Don't raise the hwm > 8MB
  2766. var MAX_HWM = 0x800000;
  2767. function computeNewHighWaterMark(n) {
  2768. if (n >= MAX_HWM) {
  2769. n = MAX_HWM;
  2770. } else {
  2771. // Get the next highest power of 2 to prevent increasing hwm excessively in
  2772. // tiny amounts
  2773. n--;
  2774. n |= n >>> 1;
  2775. n |= n >>> 2;
  2776. n |= n >>> 4;
  2777. n |= n >>> 8;
  2778. n |= n >>> 16;
  2779. n++;
  2780. }
  2781. return n;
  2782. }
  2783. // This function is designed to be inlinable, so please take care when making
  2784. // changes to the function body.
  2785. function howMuchToRead(n, state) {
  2786. if (n <= 0 || state.length === 0 && state.ended) return 0;
  2787. if (state.objectMode) return 1;
  2788. if (n !== n) {
  2789. // Only flow one buffer at a time
  2790. if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;
  2791. }
  2792. // If we're asking for more than the current hwm, then raise the hwm.
  2793. if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);
  2794. if (n <= state.length) return n;
  2795. // Don't have enough
  2796. if (!state.ended) {
  2797. state.needReadable = true;
  2798. return 0;
  2799. }
  2800. return state.length;
  2801. }
  2802. // you can override either this method, or the async _read(n) below.
  2803. Readable.prototype.read = function (n) {
  2804. debug('read', n);
  2805. n = parseInt(n, 10);
  2806. var state = this._readableState;
  2807. var nOrig = n;
  2808. if (n !== 0) state.emittedReadable = false;
  2809. // if we're doing read(0) to trigger a readable event, but we
  2810. // already have a bunch of data in the buffer, then just trigger
  2811. // the 'readable' event and move on.
  2812. if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) {
  2813. debug('read: emitReadable', state.length, state.ended);
  2814. if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);
  2815. return null;
  2816. }
  2817. n = howMuchToRead(n, state);
  2818. // if we've ended, and we're now clear, then finish it up.
  2819. if (n === 0 && state.ended) {
  2820. if (state.length === 0) endReadable(this);
  2821. return null;
  2822. }
  2823. // All the actual chunk generation logic needs to be
  2824. // *below* the call to _read. The reason is that in certain
  2825. // synthetic stream cases, such as passthrough streams, _read
  2826. // may be a completely synchronous operation which may change
  2827. // the state of the read buffer, providing enough data when
  2828. // before there was *not* enough.
  2829. //
  2830. // So, the steps are:
  2831. // 1. Figure out what the state of things will be after we do
  2832. // a read from the buffer.
  2833. //
  2834. // 2. If that resulting state will trigger a _read, then call _read.
  2835. // Note that this may be asynchronous, or synchronous. Yes, it is
  2836. // deeply ugly to write APIs this way, but that still doesn't mean
  2837. // that the Readable class should behave improperly, as streams are
  2838. // designed to be sync/async agnostic.
  2839. // Take note if the _read call is sync or async (ie, if the read call
  2840. // has returned yet), so that we know whether or not it's safe to emit
  2841. // 'readable' etc.
  2842. //
  2843. // 3. Actually pull the requested chunks out of the buffer and return.
  2844. // if we need a readable event, then we need to do some reading.
  2845. var doRead = state.needReadable;
  2846. debug('need readable', doRead);
  2847. // if we currently have less than the highWaterMark, then also read some
  2848. if (state.length === 0 || state.length - n < state.highWaterMark) {
  2849. doRead = true;
  2850. debug('length less than watermark', doRead);
  2851. }
  2852. // however, if we've ended, then there's no point, and if we're already
  2853. // reading, then it's unnecessary.
  2854. if (state.ended || state.reading) {
  2855. doRead = false;
  2856. debug('reading or ended', doRead);
  2857. } else if (doRead) {
  2858. debug('do read');
  2859. state.reading = true;
  2860. state.sync = true;
  2861. // if the length is currently zero, then we *need* a readable event.
  2862. if (state.length === 0) state.needReadable = true;
  2863. // call internal read method
  2864. this._read(state.highWaterMark);
  2865. state.sync = false;
  2866. // If _read pushed data synchronously, then `reading` will be false,
  2867. // and we need to re-evaluate how much data we can return to the user.
  2868. if (!state.reading) n = howMuchToRead(nOrig, state);
  2869. }
  2870. var ret;
  2871. if (n > 0) ret = fromList(n, state);else ret = null;
  2872. if (ret === null) {
  2873. state.needReadable = true;
  2874. n = 0;
  2875. } else {
  2876. state.length -= n;
  2877. }
  2878. if (state.length === 0) {
  2879. // If we have nothing in the buffer, then we want to know
  2880. // as soon as we *do* get something into the buffer.
  2881. if (!state.ended) state.needReadable = true;
  2882. // If we tried to read() past the EOF, then emit end on the next tick.
  2883. if (nOrig !== n && state.ended) endReadable(this);
  2884. }
  2885. if (ret !== null) this.emit('data', ret);
  2886. return ret;
  2887. };
  2888. function onEofChunk(stream, state) {
  2889. if (state.ended) return;
  2890. if (state.decoder) {
  2891. var chunk = state.decoder.end();
  2892. if (chunk && chunk.length) {
  2893. state.buffer.push(chunk);
  2894. state.length += state.objectMode ? 1 : chunk.length;
  2895. }
  2896. }
  2897. state.ended = true;
  2898. // emit 'readable' now to make sure it gets picked up.
  2899. emitReadable(stream);
  2900. }
  2901. // Don't emit readable right away in sync mode, because this can trigger
  2902. // another read() call => stack overflow. This way, it might trigger
  2903. // a nextTick recursion warning, but that's not so bad.
  2904. function emitReadable(stream) {
  2905. var state = stream._readableState;
  2906. state.needReadable = false;
  2907. if (!state.emittedReadable) {
  2908. debug('emitReadable', state.flowing);
  2909. state.emittedReadable = true;
  2910. if (state.sync) pna.nextTick(emitReadable_, stream);else emitReadable_(stream);
  2911. }
  2912. }
  2913. function emitReadable_(stream) {
  2914. debug('emit readable');
  2915. stream.emit('readable');
  2916. flow(stream);
  2917. }
  2918. // at this point, the user has presumably seen the 'readable' event,
  2919. // and called read() to consume some data. that may have triggered
  2920. // in turn another _read(n) call, in which case reading = true if
  2921. // it's in progress.
  2922. // However, if we're not ended, or reading, and the length < hwm,
  2923. // then go ahead and try to read some more preemptively.
  2924. function maybeReadMore(stream, state) {
  2925. if (!state.readingMore) {
  2926. state.readingMore = true;
  2927. pna.nextTick(maybeReadMore_, stream, state);
  2928. }
  2929. }
  2930. function maybeReadMore_(stream, state) {
  2931. var len = state.length;
  2932. while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) {
  2933. debug('maybeReadMore read 0');
  2934. stream.read(0);
  2935. if (len === state.length)
  2936. // didn't get any data, stop spinning.
  2937. break;else len = state.length;
  2938. }
  2939. state.readingMore = false;
  2940. }
  2941. // abstract method. to be overridden in specific implementation classes.
  2942. // call cb(er, data) where data is <= n in length.
  2943. // for virtual (non-string, non-buffer) streams, "length" is somewhat
  2944. // arbitrary, and perhaps not very meaningful.
  2945. Readable.prototype._read = function (n) {
  2946. this.emit('error', new Error('_read() is not implemented'));
  2947. };
  2948. Readable.prototype.pipe = function (dest, pipeOpts) {
  2949. var src = this;
  2950. var state = this._readableState;
  2951. switch (state.pipesCount) {
  2952. case 0:
  2953. state.pipes = dest;
  2954. break;
  2955. case 1:
  2956. state.pipes = [state.pipes, dest];
  2957. break;
  2958. default:
  2959. state.pipes.push(dest);
  2960. break;
  2961. }
  2962. state.pipesCount += 1;
  2963. debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);
  2964. var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;
  2965. var endFn = doEnd ? onend : unpipe;
  2966. if (state.endEmitted) pna.nextTick(endFn);else src.once('end', endFn);
  2967. dest.on('unpipe', onunpipe);
  2968. function onunpipe(readable, unpipeInfo) {
  2969. debug('onunpipe');
  2970. if (readable === src) {
  2971. if (unpipeInfo && unpipeInfo.hasUnpiped === false) {
  2972. unpipeInfo.hasUnpiped = true;
  2973. cleanup();
  2974. }
  2975. }
  2976. }
  2977. function onend() {
  2978. debug('onend');
  2979. dest.end();
  2980. }
  2981. // when the dest drains, it reduces the awaitDrain counter
  2982. // on the source. This would be more elegant with a .once()
  2983. // handler in flow(), but adding and removing repeatedly is
  2984. // too slow.
  2985. var ondrain = pipeOnDrain(src);
  2986. dest.on('drain', ondrain);
  2987. var cleanedUp = false;
  2988. function cleanup() {
  2989. debug('cleanup');
  2990. // cleanup event handlers once the pipe is broken
  2991. dest.removeListener('close', onclose);
  2992. dest.removeListener('finish', onfinish);
  2993. dest.removeListener('drain', ondrain);
  2994. dest.removeListener('error', onerror);
  2995. dest.removeListener('unpipe', onunpipe);
  2996. src.removeListener('end', onend);
  2997. src.removeListener('end', unpipe);
  2998. src.removeListener('data', ondata);
  2999. cleanedUp = true;
  3000. // if the reader is waiting for a drain event from this
  3001. // specific writer, then it would cause it to never start
  3002. // flowing again.
  3003. // So, if this is awaiting a drain, then we just call it now.
  3004. // If we don't know, then assume that we are waiting for one.
  3005. if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();
  3006. }
  3007. // If the user pushes more data while we're writing to dest then we'll end up
  3008. // in ondata again. However, we only want to increase awaitDrain once because
  3009. // dest will only emit one 'drain' event for the multiple writes.
  3010. // => Introduce a guard on increasing awaitDrain.
  3011. var increasedAwaitDrain = false;
  3012. src.on('data', ondata);
  3013. function ondata(chunk) {
  3014. debug('ondata');
  3015. increasedAwaitDrain = false;
  3016. var ret = dest.write(chunk);
  3017. if (false === ret && !increasedAwaitDrain) {
  3018. // If the user unpiped during `dest.write()`, it is possible
  3019. // to get stuck in a permanently paused state if that write
  3020. // also returned false.
  3021. // => Check whether `dest` is still a piping destination.
  3022. if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {
  3023. debug('false write response, pause', state.awaitDrain);
  3024. state.awaitDrain++;
  3025. increasedAwaitDrain = true;
  3026. }
  3027. src.pause();
  3028. }
  3029. }
  3030. // if the dest has an error, then stop piping into it.
  3031. // however, don't suppress the throwing behavior for this.
  3032. function onerror(er) {
  3033. debug('onerror', er);
  3034. unpipe();
  3035. dest.removeListener('error', onerror);
  3036. if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er);
  3037. }
  3038. // Make sure our error handler is attached before userland ones.
  3039. prependListener(dest, 'error', onerror);
  3040. // Both close and finish should trigger unpipe, but only once.
  3041. function onclose() {
  3042. dest.removeListener('finish', onfinish);
  3043. unpipe();
  3044. }
  3045. dest.once('close', onclose);
  3046. function onfinish() {
  3047. debug('onfinish');
  3048. dest.removeListener('close', onclose);
  3049. unpipe();
  3050. }
  3051. dest.once('finish', onfinish);
  3052. function unpipe() {
  3053. debug('unpipe');
  3054. src.unpipe(dest);
  3055. }
  3056. // tell the dest that it's being piped to
  3057. dest.emit('pipe', src);
  3058. // start the flow if it hasn't been started already.
  3059. if (!state.flowing) {
  3060. debug('pipe resume');
  3061. src.resume();
  3062. }
  3063. return dest;
  3064. };
  3065. function pipeOnDrain(src) {
  3066. return function () {
  3067. var state = src._readableState;
  3068. debug('pipeOnDrain', state.awaitDrain);
  3069. if (state.awaitDrain) state.awaitDrain--;
  3070. if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {
  3071. state.flowing = true;
  3072. flow(src);
  3073. }
  3074. };
  3075. }
  3076. Readable.prototype.unpipe = function (dest) {
  3077. var state = this._readableState;
  3078. var unpipeInfo = { hasUnpiped: false };
  3079. // if we're not piping anywhere, then do nothing.
  3080. if (state.pipesCount === 0) return this;
  3081. // just one destination. most common case.
  3082. if (state.pipesCount === 1) {
  3083. // passed in one, but it's not the right one.
  3084. if (dest && dest !== state.pipes) return this;
  3085. if (!dest) dest = state.pipes;
  3086. // got a match.
  3087. state.pipes = null;
  3088. state.pipesCount = 0;
  3089. state.flowing = false;
  3090. if (dest) dest.emit('unpipe', this, unpipeInfo);
  3091. return this;
  3092. }
  3093. // slow case. multiple pipe destinations.
  3094. if (!dest) {
  3095. // remove all.
  3096. var dests = state.pipes;
  3097. var len = state.pipesCount;
  3098. state.pipes = null;
  3099. state.pipesCount = 0;
  3100. state.flowing = false;
  3101. for (var i = 0; i < len; i++) {
  3102. dests[i].emit('unpipe', this, { hasUnpiped: false });
  3103. }return this;
  3104. }
  3105. // try to find the right one.
  3106. var index = indexOf(state.pipes, dest);
  3107. if (index === -1) return this;
  3108. state.pipes.splice(index, 1);
  3109. state.pipesCount -= 1;
  3110. if (state.pipesCount === 1) state.pipes = state.pipes[0];
  3111. dest.emit('unpipe', this, unpipeInfo);
  3112. return this;
  3113. };
  3114. // set up data events if they are asked for
  3115. // Ensure readable listeners eventually get something
  3116. Readable.prototype.on = function (ev, fn) {
  3117. var res = Stream.prototype.on.call(this, ev, fn);
  3118. if (ev === 'data') {
  3119. // Start flowing on next tick if stream isn't explicitly paused
  3120. if (this._readableState.flowing !== false) this.resume();
  3121. } else if (ev === 'readable') {
  3122. var state = this._readableState;
  3123. if (!state.endEmitted && !state.readableListening) {
  3124. state.readableListening = state.needReadable = true;
  3125. state.emittedReadable = false;
  3126. if (!state.reading) {
  3127. pna.nextTick(nReadingNextTick, this);
  3128. } else if (state.length) {
  3129. emitReadable(this);
  3130. }
  3131. }
  3132. }
  3133. return res;
  3134. };
  3135. Readable.prototype.addListener = Readable.prototype.on;
  3136. function nReadingNextTick(self) {
  3137. debug('readable nexttick read 0');
  3138. self.read(0);
  3139. }
  3140. // pause() and resume() are remnants of the legacy readable stream API
  3141. // If the user uses them, then switch into old mode.
  3142. Readable.prototype.resume = function () {
  3143. var state = this._readableState;
  3144. if (!state.flowing) {
  3145. debug('resume');
  3146. state.flowing = true;
  3147. resume(this, state);
  3148. }
  3149. return this;
  3150. };
  3151. function resume(stream, state) {
  3152. if (!state.resumeScheduled) {
  3153. state.resumeScheduled = true;
  3154. pna.nextTick(resume_, stream, state);
  3155. }
  3156. }
  3157. function resume_(stream, state) {
  3158. if (!state.reading) {
  3159. debug('resume read 0');
  3160. stream.read(0);
  3161. }
  3162. state.resumeScheduled = false;
  3163. state.awaitDrain = 0;
  3164. stream.emit('resume');
  3165. flow(stream);
  3166. if (state.flowing && !state.reading) stream.read(0);
  3167. }
  3168. Readable.prototype.pause = function () {
  3169. debug('call pause flowing=%j', this._readableState.flowing);
  3170. if (false !== this._readableState.flowing) {
  3171. debug('pause');
  3172. this._readableState.flowing = false;
  3173. this.emit('pause');
  3174. }
  3175. return this;
  3176. };
  3177. function flow(stream) {
  3178. var state = stream._readableState;
  3179. debug('flow', state.flowing);
  3180. while (state.flowing && stream.read() !== null) {}
  3181. }
  3182. // wrap an old-style stream as the async data source.
  3183. // This is *not* part of the readable stream interface.
  3184. // It is an ugly unfortunate mess of history.
  3185. Readable.prototype.wrap = function (stream) {
  3186. var _this = this;
  3187. var state = this._readableState;
  3188. var paused = false;
  3189. stream.on('end', function () {
  3190. debug('wrapped end');
  3191. if (state.decoder && !state.ended) {
  3192. var chunk = state.decoder.end();
  3193. if (chunk && chunk.length) _this.push(chunk);
  3194. }
  3195. _this.push(null);
  3196. });
  3197. stream.on('data', function (chunk) {
  3198. debug('wrapped data');
  3199. if (state.decoder) chunk = state.decoder.write(chunk);
  3200. // don't skip over falsy values in objectMode
  3201. if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;
  3202. var ret = _this.push(chunk);
  3203. if (!ret) {
  3204. paused = true;
  3205. stream.pause();
  3206. }
  3207. });
  3208. // proxy all the other methods.
  3209. // important when wrapping filters and duplexes.
  3210. for (var i in stream) {
  3211. if (this[i] === undefined && typeof stream[i] === 'function') {
  3212. this[i] = function (method) {
  3213. return function () {
  3214. return stream[method].apply(stream, arguments);
  3215. };
  3216. }(i);
  3217. }
  3218. }
  3219. // proxy certain important events.
  3220. for (var n = 0; n < kProxyEvents.length; n++) {
  3221. stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));
  3222. }
  3223. // when we try to consume some more bytes, simply unpause the
  3224. // underlying stream.
  3225. this._read = function (n) {
  3226. debug('wrapped _read', n);
  3227. if (paused) {
  3228. paused = false;
  3229. stream.resume();
  3230. }
  3231. };
  3232. return this;
  3233. };
  3234. Object.defineProperty(Readable.prototype, 'readableHighWaterMark', {
  3235. // making it explicit this property is not enumerable
  3236. // because otherwise some prototype manipulation in
  3237. // userland will fail
  3238. enumerable: false,
  3239. get: function () {
  3240. return this._readableState.highWaterMark;
  3241. }
  3242. });
  3243. // exposed for testing purposes only.
  3244. Readable._fromList = fromList;
  3245. // Pluck off n bytes from an array of buffers.
  3246. // Length is the combined lengths of all the buffers in the list.
  3247. // This function is designed to be inlinable, so please take care when making
  3248. // changes to the function body.
  3249. function fromList(n, state) {
  3250. // nothing buffered
  3251. if (state.length === 0) return null;
  3252. var ret;
  3253. if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) {
  3254. // read it all, truncate the list
  3255. if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.head.data;else ret = state.buffer.concat(state.length);
  3256. state.buffer.clear();
  3257. } else {
  3258. // read part of list
  3259. ret = fromListPartial(n, state.buffer, state.decoder);
  3260. }
  3261. return ret;
  3262. }
  3263. // Extracts only enough buffered data to satisfy the amount requested.
  3264. // This function is designed to be inlinable, so please take care when making
  3265. // changes to the function body.
  3266. function fromListPartial(n, list, hasStrings) {
  3267. var ret;
  3268. if (n < list.head.data.length) {
  3269. // slice is the same for buffers and strings
  3270. ret = list.head.data.slice(0, n);
  3271. list.head.data = list.head.data.slice(n);
  3272. } else if (n === list.head.data.length) {
  3273. // first chunk is a perfect match
  3274. ret = list.shift();
  3275. } else {
  3276. // result spans more than one buffer
  3277. ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list);
  3278. }
  3279. return ret;
  3280. }
  3281. // Copies a specified amount of characters from the list of buffered data
  3282. // chunks.
  3283. // This function is designed to be inlinable, so please take care when making
  3284. // changes to the function body.
  3285. function copyFromBufferString(n, list) {
  3286. var p = list.head;
  3287. var c = 1;
  3288. var ret = p.data;
  3289. n -= ret.length;
  3290. while (p = p.next) {
  3291. var str = p.data;
  3292. var nb = n > str.length ? str.length : n;
  3293. if (nb === str.length) ret += str;else ret += str.slice(0, n);
  3294. n -= nb;
  3295. if (n === 0) {
  3296. if (nb === str.length) {
  3297. ++c;
  3298. if (p.next) list.head = p.next;else list.head = list.tail = null;
  3299. } else {
  3300. list.head = p;
  3301. p.data = str.slice(nb);
  3302. }
  3303. break;
  3304. }
  3305. ++c;
  3306. }
  3307. list.length -= c;
  3308. return ret;
  3309. }
  3310. // Copies a specified amount of bytes from the list of buffered data chunks.
  3311. // This function is designed to be inlinable, so please take care when making
  3312. // changes to the function body.
  3313. function copyFromBuffer(n, list) {
  3314. var ret = Buffer.allocUnsafe(n);
  3315. var p = list.head;
  3316. var c = 1;
  3317. p.data.copy(ret);
  3318. n -= p.data.length;
  3319. while (p = p.next) {
  3320. var buf = p.data;
  3321. var nb = n > buf.length ? buf.length : n;
  3322. buf.copy(ret, ret.length - n, 0, nb);
  3323. n -= nb;
  3324. if (n === 0) {
  3325. if (nb === buf.length) {
  3326. ++c;
  3327. if (p.next) list.head = p.next;else list.head = list.tail = null;
  3328. } else {
  3329. list.head = p;
  3330. p.data = buf.slice(nb);
  3331. }
  3332. break;
  3333. }
  3334. ++c;
  3335. }
  3336. list.length -= c;
  3337. return ret;
  3338. }
  3339. function endReadable(stream) {
  3340. var state = stream._readableState;
  3341. // If we get here before consuming all the bytes, then that is a
  3342. // bug in node. Should never happen.
  3343. if (state.length > 0) throw new Error('"endReadable()" called on non-empty stream');
  3344. if (!state.endEmitted) {
  3345. state.ended = true;
  3346. pna.nextTick(endReadableNT, state, stream);
  3347. }
  3348. }
  3349. function endReadableNT(state, stream) {
  3350. // Check that we didn't get one last unshift.
  3351. if (!state.endEmitted && state.length === 0) {
  3352. state.endEmitted = true;
  3353. stream.readable = false;
  3354. stream.emit('end');
  3355. }
  3356. }
  3357. function indexOf(xs, x) {
  3358. for (var i = 0, l = xs.length; i < l; i++) {
  3359. if (xs[i] === x) return i;
  3360. }
  3361. return -1;
  3362. }
  3363. }).call(this)}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  3364. },{"./_stream_duplex":14,"./internal/streams/BufferList":19,"./internal/streams/destroy":20,"./internal/streams/stream":21,"_process":12,"core-util-is":4,"events":6,"inherits":8,"isarray":9,"process-nextick-args":11,"safe-buffer":26,"string_decoder/":30,"util":2}],17:[function(require,module,exports){
  3365. // Copyright Joyent, Inc. and other Node contributors.
  3366. //
  3367. // Permission is hereby granted, free of charge, to any person obtaining a
  3368. // copy of this software and associated documentation files (the
  3369. // "Software"), to deal in the Software without restriction, including
  3370. // without limitation the rights to use, copy, modify, merge, publish,
  3371. // distribute, sublicense, and/or sell copies of the Software, and to permit
  3372. // persons to whom the Software is furnished to do so, subject to the
  3373. // following conditions:
  3374. //
  3375. // The above copyright notice and this permission notice shall be included
  3376. // in all copies or substantial portions of the Software.
  3377. //
  3378. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  3379. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  3380. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  3381. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  3382. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  3383. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  3384. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  3385. // a transform stream is a readable/writable stream where you do
  3386. // something with the data. Sometimes it's called a "filter",
  3387. // but that's not a great name for it, since that implies a thing where
  3388. // some bits pass through, and others are simply ignored. (That would
  3389. // be a valid example of a transform, of course.)
  3390. //
  3391. // While the output is causally related to the input, it's not a
  3392. // necessarily symmetric or synchronous transformation. For example,
  3393. // a zlib stream might take multiple plain-text writes(), and then
  3394. // emit a single compressed chunk some time in the future.
  3395. //
  3396. // Here's how this works:
  3397. //
  3398. // The Transform stream has all the aspects of the readable and writable
  3399. // stream classes. When you write(chunk), that calls _write(chunk,cb)
  3400. // internally, and returns false if there's a lot of pending writes
  3401. // buffered up. When you call read(), that calls _read(n) until
  3402. // there's enough pending readable data buffered up.
  3403. //
  3404. // In a transform stream, the written data is placed in a buffer. When
  3405. // _read(n) is called, it transforms the queued up data, calling the
  3406. // buffered _write cb's as it consumes chunks. If consuming a single
  3407. // written chunk would result in multiple output chunks, then the first
  3408. // outputted bit calls the readcb, and subsequent chunks just go into
  3409. // the read buffer, and will cause it to emit 'readable' if necessary.
  3410. //
  3411. // This way, back-pressure is actually determined by the reading side,
  3412. // since _read has to be called to start processing a new chunk. However,
  3413. // a pathological inflate type of transform can cause excessive buffering
  3414. // here. For example, imagine a stream where every byte of input is
  3415. // interpreted as an integer from 0-255, and then results in that many
  3416. // bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in
  3417. // 1kb of data being output. In this case, you could write a very small
  3418. // amount of input, and end up with a very large amount of output. In
  3419. // such a pathological inflating mechanism, there'd be no way to tell
  3420. // the system to stop doing the transform. A single 4MB write could
  3421. // cause the system to run out of memory.
  3422. //
  3423. // However, even in such a pathological case, only a single written chunk
  3424. // would be consumed, and then the rest would wait (un-transformed) until
  3425. // the results of the previous transformed chunk were consumed.
  3426. 'use strict';
  3427. module.exports = Transform;
  3428. var Duplex = require('./_stream_duplex');
  3429. /*<replacement>*/
  3430. var util = Object.create(require('core-util-is'));
  3431. util.inherits = require('inherits');
  3432. /*</replacement>*/
  3433. util.inherits(Transform, Duplex);
  3434. function afterTransform(er, data) {
  3435. var ts = this._transformState;
  3436. ts.transforming = false;
  3437. var cb = ts.writecb;
  3438. if (!cb) {
  3439. return this.emit('error', new Error('write callback called multiple times'));
  3440. }
  3441. ts.writechunk = null;
  3442. ts.writecb = null;
  3443. if (data != null) // single equals check for both `null` and `undefined`
  3444. this.push(data);
  3445. cb(er);
  3446. var rs = this._readableState;
  3447. rs.reading = false;
  3448. if (rs.needReadable || rs.length < rs.highWaterMark) {
  3449. this._read(rs.highWaterMark);
  3450. }
  3451. }
  3452. function Transform(options) {
  3453. if (!(this instanceof Transform)) return new Transform(options);
  3454. Duplex.call(this, options);
  3455. this._transformState = {
  3456. afterTransform: afterTransform.bind(this),
  3457. needTransform: false,
  3458. transforming: false,
  3459. writecb: null,
  3460. writechunk: null,
  3461. writeencoding: null
  3462. };
  3463. // start out asking for a readable event once data is transformed.
  3464. this._readableState.needReadable = true;
  3465. // we have implemented the _read method, and done the other things
  3466. // that Readable wants before the first _read call, so unset the
  3467. // sync guard flag.
  3468. this._readableState.sync = false;
  3469. if (options) {
  3470. if (typeof options.transform === 'function') this._transform = options.transform;
  3471. if (typeof options.flush === 'function') this._flush = options.flush;
  3472. }
  3473. // When the writable side finishes, then flush out anything remaining.
  3474. this.on('prefinish', prefinish);
  3475. }
  3476. function prefinish() {
  3477. var _this = this;
  3478. if (typeof this._flush === 'function') {
  3479. this._flush(function (er, data) {
  3480. done(_this, er, data);
  3481. });
  3482. } else {
  3483. done(this, null, null);
  3484. }
  3485. }
  3486. Transform.prototype.push = function (chunk, encoding) {
  3487. this._transformState.needTransform = false;
  3488. return Duplex.prototype.push.call(this, chunk, encoding);
  3489. };
  3490. // This is the part where you do stuff!
  3491. // override this function in implementation classes.
  3492. // 'chunk' is an input chunk.
  3493. //
  3494. // Call `push(newChunk)` to pass along transformed output
  3495. // to the readable side. You may call 'push' zero or more times.
  3496. //
  3497. // Call `cb(err)` when you are done with this chunk. If you pass
  3498. // an error, then that'll put the hurt on the whole operation. If you
  3499. // never call cb(), then you'll never get another chunk.
  3500. Transform.prototype._transform = function (chunk, encoding, cb) {
  3501. throw new Error('_transform() is not implemented');
  3502. };
  3503. Transform.prototype._write = function (chunk, encoding, cb) {
  3504. var ts = this._transformState;
  3505. ts.writecb = cb;
  3506. ts.writechunk = chunk;
  3507. ts.writeencoding = encoding;
  3508. if (!ts.transforming) {
  3509. var rs = this._readableState;
  3510. if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);
  3511. }
  3512. };
  3513. // Doesn't matter what the args are here.
  3514. // _transform does all the work.
  3515. // That we got here means that the readable side wants more data.
  3516. Transform.prototype._read = function (n) {
  3517. var ts = this._transformState;
  3518. if (ts.writechunk !== null && ts.writecb && !ts.transforming) {
  3519. ts.transforming = true;
  3520. this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
  3521. } else {
  3522. // mark that we need a transform, so that any data that comes in
  3523. // will get processed, now that we've asked for it.
  3524. ts.needTransform = true;
  3525. }
  3526. };
  3527. Transform.prototype._destroy = function (err, cb) {
  3528. var _this2 = this;
  3529. Duplex.prototype._destroy.call(this, err, function (err2) {
  3530. cb(err2);
  3531. _this2.emit('close');
  3532. });
  3533. };
  3534. function done(stream, er, data) {
  3535. if (er) return stream.emit('error', er);
  3536. if (data != null) // single equals check for both `null` and `undefined`
  3537. stream.push(data);
  3538. // if there's nothing in the write buffer, then that means
  3539. // that nothing more will ever be provided
  3540. if (stream._writableState.length) throw new Error('Calling transform done when ws.length != 0');
  3541. if (stream._transformState.transforming) throw new Error('Calling transform done when still transforming');
  3542. return stream.push(null);
  3543. }
  3544. },{"./_stream_duplex":14,"core-util-is":4,"inherits":8}],18:[function(require,module,exports){
  3545. (function (process,global,setImmediate){(function (){
  3546. // Copyright Joyent, Inc. and other Node contributors.
  3547. //
  3548. // Permission is hereby granted, free of charge, to any person obtaining a
  3549. // copy of this software and associated documentation files (the
  3550. // "Software"), to deal in the Software without restriction, including
  3551. // without limitation the rights to use, copy, modify, merge, publish,
  3552. // distribute, sublicense, and/or sell copies of the Software, and to permit
  3553. // persons to whom the Software is furnished to do so, subject to the
  3554. // following conditions:
  3555. //
  3556. // The above copyright notice and this permission notice shall be included
  3557. // in all copies or substantial portions of the Software.
  3558. //
  3559. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  3560. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  3561. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  3562. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  3563. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  3564. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  3565. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  3566. // A bit simpler than readable streams.
  3567. // Implement an async ._write(chunk, encoding, cb), and it'll handle all
  3568. // the drain event emission and buffering.
  3569. 'use strict';
  3570. /*<replacement>*/
  3571. var pna = require('process-nextick-args');
  3572. /*</replacement>*/
  3573. module.exports = Writable;
  3574. /* <replacement> */
  3575. function WriteReq(chunk, encoding, cb) {
  3576. this.chunk = chunk;
  3577. this.encoding = encoding;
  3578. this.callback = cb;
  3579. this.next = null;
  3580. }
  3581. // It seems a linked list but it is not
  3582. // there will be only 2 of these for each stream
  3583. function CorkedRequest(state) {
  3584. var _this = this;
  3585. this.next = null;
  3586. this.entry = null;
  3587. this.finish = function () {
  3588. onCorkedFinish(_this, state);
  3589. };
  3590. }
  3591. /* </replacement> */
  3592. /*<replacement>*/
  3593. var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick;
  3594. /*</replacement>*/
  3595. /*<replacement>*/
  3596. var Duplex;
  3597. /*</replacement>*/
  3598. Writable.WritableState = WritableState;
  3599. /*<replacement>*/
  3600. var util = Object.create(require('core-util-is'));
  3601. util.inherits = require('inherits');
  3602. /*</replacement>*/
  3603. /*<replacement>*/
  3604. var internalUtil = {
  3605. deprecate: require('util-deprecate')
  3606. };
  3607. /*</replacement>*/
  3608. /*<replacement>*/
  3609. var Stream = require('./internal/streams/stream');
  3610. /*</replacement>*/
  3611. /*<replacement>*/
  3612. var Buffer = require('safe-buffer').Buffer;
  3613. var OurUint8Array = (typeof global !== 'undefined' ? global : typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : {}).Uint8Array || function () {};
  3614. function _uint8ArrayToBuffer(chunk) {
  3615. return Buffer.from(chunk);
  3616. }
  3617. function _isUint8Array(obj) {
  3618. return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
  3619. }
  3620. /*</replacement>*/
  3621. var destroyImpl = require('./internal/streams/destroy');
  3622. util.inherits(Writable, Stream);
  3623. function nop() {}
  3624. function WritableState(options, stream) {
  3625. Duplex = Duplex || require('./_stream_duplex');
  3626. options = options || {};
  3627. // Duplex streams are both readable and writable, but share
  3628. // the same options object.
  3629. // However, some cases require setting options to different
  3630. // values for the readable and the writable sides of the duplex stream.
  3631. // These options can be provided separately as readableXXX and writableXXX.
  3632. var isDuplex = stream instanceof Duplex;
  3633. // object stream flag to indicate whether or not this stream
  3634. // contains buffers or objects.
  3635. this.objectMode = !!options.objectMode;
  3636. if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode;
  3637. // the point at which write() starts returning false
  3638. // Note: 0 is a valid value, means that we always return false if
  3639. // the entire buffer is not flushed immediately on write()
  3640. var hwm = options.highWaterMark;
  3641. var writableHwm = options.writableHighWaterMark;
  3642. var defaultHwm = this.objectMode ? 16 : 16 * 1024;
  3643. if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (writableHwm || writableHwm === 0)) this.highWaterMark = writableHwm;else this.highWaterMark = defaultHwm;
  3644. // cast to ints.
  3645. this.highWaterMark = Math.floor(this.highWaterMark);
  3646. // if _final has been called
  3647. this.finalCalled = false;
  3648. // drain event flag.
  3649. this.needDrain = false;
  3650. // at the start of calling end()
  3651. this.ending = false;
  3652. // when end() has been called, and returned
  3653. this.ended = false;
  3654. // when 'finish' is emitted
  3655. this.finished = false;
  3656. // has it been destroyed
  3657. this.destroyed = false;
  3658. // should we decode strings into buffers before passing to _write?
  3659. // this is here so that some node-core streams can optimize string
  3660. // handling at a lower level.
  3661. var noDecode = options.decodeStrings === false;
  3662. this.decodeStrings = !noDecode;
  3663. // Crypto is kind of old and crusty. Historically, its default string
  3664. // encoding is 'binary' so we have to make this configurable.
  3665. // Everything else in the universe uses 'utf8', though.
  3666. this.defaultEncoding = options.defaultEncoding || 'utf8';
  3667. // not an actual buffer we keep track of, but a measurement
  3668. // of how much we're waiting to get pushed to some underlying
  3669. // socket or file.
  3670. this.length = 0;
  3671. // a flag to see when we're in the middle of a write.
  3672. this.writing = false;
  3673. // when true all writes will be buffered until .uncork() call
  3674. this.corked = 0;
  3675. // a flag to be able to tell if the onwrite cb is called immediately,
  3676. // or on a later tick. We set this to true at first, because any
  3677. // actions that shouldn't happen until "later" should generally also
  3678. // not happen before the first write call.
  3679. this.sync = true;
  3680. // a flag to know if we're processing previously buffered items, which
  3681. // may call the _write() callback in the same tick, so that we don't
  3682. // end up in an overlapped onwrite situation.
  3683. this.bufferProcessing = false;
  3684. // the callback that's passed to _write(chunk,cb)
  3685. this.onwrite = function (er) {
  3686. onwrite(stream, er);
  3687. };
  3688. // the callback that the user supplies to write(chunk,encoding,cb)
  3689. this.writecb = null;
  3690. // the amount that is being written when _write is called.
  3691. this.writelen = 0;
  3692. this.bufferedRequest = null;
  3693. this.lastBufferedRequest = null;
  3694. // number of pending user-supplied write callbacks
  3695. // this must be 0 before 'finish' can be emitted
  3696. this.pendingcb = 0;
  3697. // emit prefinish if the only thing we're waiting for is _write cbs
  3698. // This is relevant for synchronous Transform streams
  3699. this.prefinished = false;
  3700. // True if the error was already emitted and should not be thrown again
  3701. this.errorEmitted = false;
  3702. // count buffered requests
  3703. this.bufferedRequestCount = 0;
  3704. // allocate the first CorkedRequest, there is always
  3705. // one allocated and free to use, and we maintain at most two
  3706. this.corkedRequestsFree = new CorkedRequest(this);
  3707. }
  3708. WritableState.prototype.getBuffer = function getBuffer() {
  3709. var current = this.bufferedRequest;
  3710. var out = [];
  3711. while (current) {
  3712. out.push(current);
  3713. current = current.next;
  3714. }
  3715. return out;
  3716. };
  3717. (function () {
  3718. try {
  3719. Object.defineProperty(WritableState.prototype, 'buffer', {
  3720. get: internalUtil.deprecate(function () {
  3721. return this.getBuffer();
  3722. }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')
  3723. });
  3724. } catch (_) {}
  3725. })();
  3726. // Test _writableState for inheritance to account for Duplex streams,
  3727. // whose prototype chain only points to Readable.
  3728. var realHasInstance;
  3729. if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {
  3730. realHasInstance = Function.prototype[Symbol.hasInstance];
  3731. Object.defineProperty(Writable, Symbol.hasInstance, {
  3732. value: function (object) {
  3733. if (realHasInstance.call(this, object)) return true;
  3734. if (this !== Writable) return false;
  3735. return object && object._writableState instanceof WritableState;
  3736. }
  3737. });
  3738. } else {
  3739. realHasInstance = function (object) {
  3740. return object instanceof this;
  3741. };
  3742. }
  3743. function Writable(options) {
  3744. Duplex = Duplex || require('./_stream_duplex');
  3745. // Writable ctor is applied to Duplexes, too.
  3746. // `realHasInstance` is necessary because using plain `instanceof`
  3747. // would return false, as no `_writableState` property is attached.
  3748. // Trying to use the custom `instanceof` for Writable here will also break the
  3749. // Node.js LazyTransform implementation, which has a non-trivial getter for
  3750. // `_writableState` that would lead to infinite recursion.
  3751. if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) {
  3752. return new Writable(options);
  3753. }
  3754. this._writableState = new WritableState(options, this);
  3755. // legacy.
  3756. this.writable = true;
  3757. if (options) {
  3758. if (typeof options.write === 'function') this._write = options.write;
  3759. if (typeof options.writev === 'function') this._writev = options.writev;
  3760. if (typeof options.destroy === 'function') this._destroy = options.destroy;
  3761. if (typeof options.final === 'function') this._final = options.final;
  3762. }
  3763. Stream.call(this);
  3764. }
  3765. // Otherwise people can pipe Writable streams, which is just wrong.
  3766. Writable.prototype.pipe = function () {
  3767. this.emit('error', new Error('Cannot pipe, not readable'));
  3768. };
  3769. function writeAfterEnd(stream, cb) {
  3770. var er = new Error('write after end');
  3771. // TODO: defer error events consistently everywhere, not just the cb
  3772. stream.emit('error', er);
  3773. pna.nextTick(cb, er);
  3774. }
  3775. // Checks that a user-supplied chunk is valid, especially for the particular
  3776. // mode the stream is in. Currently this means that `null` is never accepted
  3777. // and undefined/non-string values are only allowed in object mode.
  3778. function validChunk(stream, state, chunk, cb) {
  3779. var valid = true;
  3780. var er = false;
  3781. if (chunk === null) {
  3782. er = new TypeError('May not write null values to stream');
  3783. } else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
  3784. er = new TypeError('Invalid non-string/buffer chunk');
  3785. }
  3786. if (er) {
  3787. stream.emit('error', er);
  3788. pna.nextTick(cb, er);
  3789. valid = false;
  3790. }
  3791. return valid;
  3792. }
  3793. Writable.prototype.write = function (chunk, encoding, cb) {
  3794. var state = this._writableState;
  3795. var ret = false;
  3796. var isBuf = !state.objectMode && _isUint8Array(chunk);
  3797. if (isBuf && !Buffer.isBuffer(chunk)) {
  3798. chunk = _uint8ArrayToBuffer(chunk);
  3799. }
  3800. if (typeof encoding === 'function') {
  3801. cb = encoding;
  3802. encoding = null;
  3803. }
  3804. if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;
  3805. if (typeof cb !== 'function') cb = nop;
  3806. if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {
  3807. state.pendingcb++;
  3808. ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);
  3809. }
  3810. return ret;
  3811. };
  3812. Writable.prototype.cork = function () {
  3813. var state = this._writableState;
  3814. state.corked++;
  3815. };
  3816. Writable.prototype.uncork = function () {
  3817. var state = this._writableState;
  3818. if (state.corked) {
  3819. state.corked--;
  3820. if (!state.writing && !state.corked && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
  3821. }
  3822. };
  3823. Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
  3824. // node::ParseEncoding() requires lower case.
  3825. if (typeof encoding === 'string') encoding = encoding.toLowerCase();
  3826. if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding);
  3827. this._writableState.defaultEncoding = encoding;
  3828. return this;
  3829. };
  3830. function decodeChunk(state, chunk, encoding) {
  3831. if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {
  3832. chunk = Buffer.from(chunk, encoding);
  3833. }
  3834. return chunk;
  3835. }
  3836. Object.defineProperty(Writable.prototype, 'writableHighWaterMark', {
  3837. // making it explicit this property is not enumerable
  3838. // because otherwise some prototype manipulation in
  3839. // userland will fail
  3840. enumerable: false,
  3841. get: function () {
  3842. return this._writableState.highWaterMark;
  3843. }
  3844. });
  3845. // if we're already writing something, then just put this
  3846. // in the queue, and wait our turn. Otherwise, call _write
  3847. // If we return false, then we need a drain event, so set that flag.
  3848. function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {
  3849. if (!isBuf) {
  3850. var newChunk = decodeChunk(state, chunk, encoding);
  3851. if (chunk !== newChunk) {
  3852. isBuf = true;
  3853. encoding = 'buffer';
  3854. chunk = newChunk;
  3855. }
  3856. }
  3857. var len = state.objectMode ? 1 : chunk.length;
  3858. state.length += len;
  3859. var ret = state.length < state.highWaterMark;
  3860. // we must ensure that previous needDrain will not be reset to false.
  3861. if (!ret) state.needDrain = true;
  3862. if (state.writing || state.corked) {
  3863. var last = state.lastBufferedRequest;
  3864. state.lastBufferedRequest = {
  3865. chunk: chunk,
  3866. encoding: encoding,
  3867. isBuf: isBuf,
  3868. callback: cb,
  3869. next: null
  3870. };
  3871. if (last) {
  3872. last.next = state.lastBufferedRequest;
  3873. } else {
  3874. state.bufferedRequest = state.lastBufferedRequest;
  3875. }
  3876. state.bufferedRequestCount += 1;
  3877. } else {
  3878. doWrite(stream, state, false, len, chunk, encoding, cb);
  3879. }
  3880. return ret;
  3881. }
  3882. function doWrite(stream, state, writev, len, chunk, encoding, cb) {
  3883. state.writelen = len;
  3884. state.writecb = cb;
  3885. state.writing = true;
  3886. state.sync = true;
  3887. if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);
  3888. state.sync = false;
  3889. }
  3890. function onwriteError(stream, state, sync, er, cb) {
  3891. --state.pendingcb;
  3892. if (sync) {
  3893. // defer the callback if we are being called synchronously
  3894. // to avoid piling up things on the stack
  3895. pna.nextTick(cb, er);
  3896. // this can emit finish, and it will always happen
  3897. // after error
  3898. pna.nextTick(finishMaybe, stream, state);
  3899. stream._writableState.errorEmitted = true;
  3900. stream.emit('error', er);
  3901. } else {
  3902. // the caller expect this to happen before if
  3903. // it is async
  3904. cb(er);
  3905. stream._writableState.errorEmitted = true;
  3906. stream.emit('error', er);
  3907. // this can emit finish, but finish must
  3908. // always follow error
  3909. finishMaybe(stream, state);
  3910. }
  3911. }
  3912. function onwriteStateUpdate(state) {
  3913. state.writing = false;
  3914. state.writecb = null;
  3915. state.length -= state.writelen;
  3916. state.writelen = 0;
  3917. }
  3918. function onwrite(stream, er) {
  3919. var state = stream._writableState;
  3920. var sync = state.sync;
  3921. var cb = state.writecb;
  3922. onwriteStateUpdate(state);
  3923. if (er) onwriteError(stream, state, sync, er, cb);else {
  3924. // Check if we're actually ready to finish, but don't emit yet
  3925. var finished = needFinish(state);
  3926. if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {
  3927. clearBuffer(stream, state);
  3928. }
  3929. if (sync) {
  3930. /*<replacement>*/
  3931. asyncWrite(afterWrite, stream, state, finished, cb);
  3932. /*</replacement>*/
  3933. } else {
  3934. afterWrite(stream, state, finished, cb);
  3935. }
  3936. }
  3937. }
  3938. function afterWrite(stream, state, finished, cb) {
  3939. if (!finished) onwriteDrain(stream, state);
  3940. state.pendingcb--;
  3941. cb();
  3942. finishMaybe(stream, state);
  3943. }
  3944. // Must force callback to be called on nextTick, so that we don't
  3945. // emit 'drain' before the write() consumer gets the 'false' return
  3946. // value, and has a chance to attach a 'drain' listener.
  3947. function onwriteDrain(stream, state) {
  3948. if (state.length === 0 && state.needDrain) {
  3949. state.needDrain = false;
  3950. stream.emit('drain');
  3951. }
  3952. }
  3953. // if there's something in the buffer waiting, then process it
  3954. function clearBuffer(stream, state) {
  3955. state.bufferProcessing = true;
  3956. var entry = state.bufferedRequest;
  3957. if (stream._writev && entry && entry.next) {
  3958. // Fast case, write everything using _writev()
  3959. var l = state.bufferedRequestCount;
  3960. var buffer = new Array(l);
  3961. var holder = state.corkedRequestsFree;
  3962. holder.entry = entry;
  3963. var count = 0;
  3964. var allBuffers = true;
  3965. while (entry) {
  3966. buffer[count] = entry;
  3967. if (!entry.isBuf) allBuffers = false;
  3968. entry = entry.next;
  3969. count += 1;
  3970. }
  3971. buffer.allBuffers = allBuffers;
  3972. doWrite(stream, state, true, state.length, buffer, '', holder.finish);
  3973. // doWrite is almost always async, defer these to save a bit of time
  3974. // as the hot path ends with doWrite
  3975. state.pendingcb++;
  3976. state.lastBufferedRequest = null;
  3977. if (holder.next) {
  3978. state.corkedRequestsFree = holder.next;
  3979. holder.next = null;
  3980. } else {
  3981. state.corkedRequestsFree = new CorkedRequest(state);
  3982. }
  3983. state.bufferedRequestCount = 0;
  3984. } else {
  3985. // Slow case, write chunks one-by-one
  3986. while (entry) {
  3987. var chunk = entry.chunk;
  3988. var encoding = entry.encoding;
  3989. var cb = entry.callback;
  3990. var len = state.objectMode ? 1 : chunk.length;
  3991. doWrite(stream, state, false, len, chunk, encoding, cb);
  3992. entry = entry.next;
  3993. state.bufferedRequestCount--;
  3994. // if we didn't call the onwrite immediately, then
  3995. // it means that we need to wait until it does.
  3996. // also, that means that the chunk and cb are currently
  3997. // being processed, so move the buffer counter past them.
  3998. if (state.writing) {
  3999. break;
  4000. }
  4001. }
  4002. if (entry === null) state.lastBufferedRequest = null;
  4003. }
  4004. state.bufferedRequest = entry;
  4005. state.bufferProcessing = false;
  4006. }
  4007. Writable.prototype._write = function (chunk, encoding, cb) {
  4008. cb(new Error('_write() is not implemented'));
  4009. };
  4010. Writable.prototype._writev = null;
  4011. Writable.prototype.end = function (chunk, encoding, cb) {
  4012. var state = this._writableState;
  4013. if (typeof chunk === 'function') {
  4014. cb = chunk;
  4015. chunk = null;
  4016. encoding = null;
  4017. } else if (typeof encoding === 'function') {
  4018. cb = encoding;
  4019. encoding = null;
  4020. }
  4021. if (chunk !== null && chunk !== undefined) this.write(chunk, encoding);
  4022. // .end() fully uncorks
  4023. if (state.corked) {
  4024. state.corked = 1;
  4025. this.uncork();
  4026. }
  4027. // ignore unnecessary end() calls.
  4028. if (!state.ending) endWritable(this, state, cb);
  4029. };
  4030. function needFinish(state) {
  4031. return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
  4032. }
  4033. function callFinal(stream, state) {
  4034. stream._final(function (err) {
  4035. state.pendingcb--;
  4036. if (err) {
  4037. stream.emit('error', err);
  4038. }
  4039. state.prefinished = true;
  4040. stream.emit('prefinish');
  4041. finishMaybe(stream, state);
  4042. });
  4043. }
  4044. function prefinish(stream, state) {
  4045. if (!state.prefinished && !state.finalCalled) {
  4046. if (typeof stream._final === 'function') {
  4047. state.pendingcb++;
  4048. state.finalCalled = true;
  4049. pna.nextTick(callFinal, stream, state);
  4050. } else {
  4051. state.prefinished = true;
  4052. stream.emit('prefinish');
  4053. }
  4054. }
  4055. }
  4056. function finishMaybe(stream, state) {
  4057. var need = needFinish(state);
  4058. if (need) {
  4059. prefinish(stream, state);
  4060. if (state.pendingcb === 0) {
  4061. state.finished = true;
  4062. stream.emit('finish');
  4063. }
  4064. }
  4065. return need;
  4066. }
  4067. function endWritable(stream, state, cb) {
  4068. state.ending = true;
  4069. finishMaybe(stream, state);
  4070. if (cb) {
  4071. if (state.finished) pna.nextTick(cb);else stream.once('finish', cb);
  4072. }
  4073. state.ended = true;
  4074. stream.writable = false;
  4075. }
  4076. function onCorkedFinish(corkReq, state, err) {
  4077. var entry = corkReq.entry;
  4078. corkReq.entry = null;
  4079. while (entry) {
  4080. var cb = entry.callback;
  4081. state.pendingcb--;
  4082. cb(err);
  4083. entry = entry.next;
  4084. }
  4085. // reuse the free corkReq.
  4086. state.corkedRequestsFree.next = corkReq;
  4087. }
  4088. Object.defineProperty(Writable.prototype, 'destroyed', {
  4089. get: function () {
  4090. if (this._writableState === undefined) {
  4091. return false;
  4092. }
  4093. return this._writableState.destroyed;
  4094. },
  4095. set: function (value) {
  4096. // we ignore the value if the stream
  4097. // has not been initialized yet
  4098. if (!this._writableState) {
  4099. return;
  4100. }
  4101. // backward compatibility, the user is explicitly
  4102. // managing destroyed
  4103. this._writableState.destroyed = value;
  4104. }
  4105. });
  4106. Writable.prototype.destroy = destroyImpl.destroy;
  4107. Writable.prototype._undestroy = destroyImpl.undestroy;
  4108. Writable.prototype._destroy = function (err, cb) {
  4109. this.end();
  4110. cb(err);
  4111. };
  4112. }).call(this)}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("timers").setImmediate)
  4113. },{"./_stream_duplex":14,"./internal/streams/destroy":20,"./internal/streams/stream":21,"_process":12,"core-util-is":4,"inherits":8,"process-nextick-args":11,"safe-buffer":26,"timers":31,"util-deprecate":32}],19:[function(require,module,exports){
  4114. 'use strict';
  4115. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4116. var Buffer = require('safe-buffer').Buffer;
  4117. var util = require('util');
  4118. function copyBuffer(src, target, offset) {
  4119. src.copy(target, offset);
  4120. }
  4121. module.exports = function () {
  4122. function BufferList() {
  4123. _classCallCheck(this, BufferList);
  4124. this.head = null;
  4125. this.tail = null;
  4126. this.length = 0;
  4127. }
  4128. BufferList.prototype.push = function push(v) {
  4129. var entry = { data: v, next: null };
  4130. if (this.length > 0) this.tail.next = entry;else this.head = entry;
  4131. this.tail = entry;
  4132. ++this.length;
  4133. };
  4134. BufferList.prototype.unshift = function unshift(v) {
  4135. var entry = { data: v, next: this.head };
  4136. if (this.length === 0) this.tail = entry;
  4137. this.head = entry;
  4138. ++this.length;
  4139. };
  4140. BufferList.prototype.shift = function shift() {
  4141. if (this.length === 0) return;
  4142. var ret = this.head.data;
  4143. if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next;
  4144. --this.length;
  4145. return ret;
  4146. };
  4147. BufferList.prototype.clear = function clear() {
  4148. this.head = this.tail = null;
  4149. this.length = 0;
  4150. };
  4151. BufferList.prototype.join = function join(s) {
  4152. if (this.length === 0) return '';
  4153. var p = this.head;
  4154. var ret = '' + p.data;
  4155. while (p = p.next) {
  4156. ret += s + p.data;
  4157. }return ret;
  4158. };
  4159. BufferList.prototype.concat = function concat(n) {
  4160. if (this.length === 0) return Buffer.alloc(0);
  4161. var ret = Buffer.allocUnsafe(n >>> 0);
  4162. var p = this.head;
  4163. var i = 0;
  4164. while (p) {
  4165. copyBuffer(p.data, ret, i);
  4166. i += p.data.length;
  4167. p = p.next;
  4168. }
  4169. return ret;
  4170. };
  4171. return BufferList;
  4172. }();
  4173. if (util && util.inspect && util.inspect.custom) {
  4174. module.exports.prototype[util.inspect.custom] = function () {
  4175. var obj = util.inspect({ length: this.length });
  4176. return this.constructor.name + ' ' + obj;
  4177. };
  4178. }
  4179. },{"safe-buffer":26,"util":2}],20:[function(require,module,exports){
  4180. 'use strict';
  4181. /*<replacement>*/
  4182. var pna = require('process-nextick-args');
  4183. /*</replacement>*/
  4184. // undocumented cb() API, needed for core, not for public API
  4185. function destroy(err, cb) {
  4186. var _this = this;
  4187. var readableDestroyed = this._readableState && this._readableState.destroyed;
  4188. var writableDestroyed = this._writableState && this._writableState.destroyed;
  4189. if (readableDestroyed || writableDestroyed) {
  4190. if (cb) {
  4191. cb(err);
  4192. } else if (err) {
  4193. if (!this._writableState) {
  4194. pna.nextTick(emitErrorNT, this, err);
  4195. } else if (!this._writableState.errorEmitted) {
  4196. this._writableState.errorEmitted = true;
  4197. pna.nextTick(emitErrorNT, this, err);
  4198. }
  4199. }
  4200. return this;
  4201. }
  4202. // we set destroyed to true before firing error callbacks in order
  4203. // to make it re-entrance safe in case destroy() is called within callbacks
  4204. if (this._readableState) {
  4205. this._readableState.destroyed = true;
  4206. }
  4207. // if this is a duplex stream mark the writable part as destroyed as well
  4208. if (this._writableState) {
  4209. this._writableState.destroyed = true;
  4210. }
  4211. this._destroy(err || null, function (err) {
  4212. if (!cb && err) {
  4213. if (!_this._writableState) {
  4214. pna.nextTick(emitErrorNT, _this, err);
  4215. } else if (!_this._writableState.errorEmitted) {
  4216. _this._writableState.errorEmitted = true;
  4217. pna.nextTick(emitErrorNT, _this, err);
  4218. }
  4219. } else if (cb) {
  4220. cb(err);
  4221. }
  4222. });
  4223. return this;
  4224. }
  4225. function undestroy() {
  4226. if (this._readableState) {
  4227. this._readableState.destroyed = false;
  4228. this._readableState.reading = false;
  4229. this._readableState.ended = false;
  4230. this._readableState.endEmitted = false;
  4231. }
  4232. if (this._writableState) {
  4233. this._writableState.destroyed = false;
  4234. this._writableState.ended = false;
  4235. this._writableState.ending = false;
  4236. this._writableState.finalCalled = false;
  4237. this._writableState.prefinished = false;
  4238. this._writableState.finished = false;
  4239. this._writableState.errorEmitted = false;
  4240. }
  4241. }
  4242. function emitErrorNT(self, err) {
  4243. self.emit('error', err);
  4244. }
  4245. module.exports = {
  4246. destroy: destroy,
  4247. undestroy: undestroy
  4248. };
  4249. },{"process-nextick-args":11}],21:[function(require,module,exports){
  4250. module.exports = require('events').EventEmitter;
  4251. },{"events":6}],22:[function(require,module,exports){
  4252. module.exports = require('./readable').PassThrough
  4253. },{"./readable":23}],23:[function(require,module,exports){
  4254. exports = module.exports = require('./lib/_stream_readable.js');
  4255. exports.Stream = exports;
  4256. exports.Readable = exports;
  4257. exports.Writable = require('./lib/_stream_writable.js');
  4258. exports.Duplex = require('./lib/_stream_duplex.js');
  4259. exports.Transform = require('./lib/_stream_transform.js');
  4260. exports.PassThrough = require('./lib/_stream_passthrough.js');
  4261. },{"./lib/_stream_duplex.js":14,"./lib/_stream_passthrough.js":15,"./lib/_stream_readable.js":16,"./lib/_stream_transform.js":17,"./lib/_stream_writable.js":18}],24:[function(require,module,exports){
  4262. module.exports = require('./readable').Transform
  4263. },{"./readable":23}],25:[function(require,module,exports){
  4264. module.exports = require('./lib/_stream_writable.js');
  4265. },{"./lib/_stream_writable.js":18}],26:[function(require,module,exports){
  4266. /* eslint-disable node/no-deprecated-api */
  4267. var buffer = require('buffer')
  4268. var Buffer = buffer.Buffer
  4269. // alternative to using Object.keys for old browsers
  4270. function copyProps (src, dst) {
  4271. for (var key in src) {
  4272. dst[key] = src[key]
  4273. }
  4274. }
  4275. if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
  4276. module.exports = buffer
  4277. } else {
  4278. // Copy properties from require('buffer')
  4279. copyProps(buffer, exports)
  4280. exports.Buffer = SafeBuffer
  4281. }
  4282. function SafeBuffer (arg, encodingOrOffset, length) {
  4283. return Buffer(arg, encodingOrOffset, length)
  4284. }
  4285. // Copy static methods from Buffer
  4286. copyProps(Buffer, SafeBuffer)
  4287. SafeBuffer.from = function (arg, encodingOrOffset, length) {
  4288. if (typeof arg === 'number') {
  4289. throw new TypeError('Argument must not be a number')
  4290. }
  4291. return Buffer(arg, encodingOrOffset, length)
  4292. }
  4293. SafeBuffer.alloc = function (size, fill, encoding) {
  4294. if (typeof size !== 'number') {
  4295. throw new TypeError('Argument must be a number')
  4296. }
  4297. var buf = Buffer(size)
  4298. if (fill !== undefined) {
  4299. if (typeof encoding === 'string') {
  4300. buf.fill(fill, encoding)
  4301. } else {
  4302. buf.fill(fill)
  4303. }
  4304. } else {
  4305. buf.fill(0)
  4306. }
  4307. return buf
  4308. }
  4309. SafeBuffer.allocUnsafe = function (size) {
  4310. if (typeof size !== 'number') {
  4311. throw new TypeError('Argument must be a number')
  4312. }
  4313. return Buffer(size)
  4314. }
  4315. SafeBuffer.allocUnsafeSlow = function (size) {
  4316. if (typeof size !== 'number') {
  4317. throw new TypeError('Argument must be a number')
  4318. }
  4319. return buffer.SlowBuffer(size)
  4320. }
  4321. },{"buffer":3}],27:[function(require,module,exports){
  4322. (function (Buffer){(function (){
  4323. ;(function (sax) { // wrapper for non-node envs
  4324. sax.parser = function (strict, opt) { return new SAXParser(strict, opt) }
  4325. sax.SAXParser = SAXParser
  4326. sax.SAXStream = SAXStream
  4327. sax.createStream = createStream
  4328. // When we pass the MAX_BUFFER_LENGTH position, start checking for buffer overruns.
  4329. // When we check, schedule the next check for MAX_BUFFER_LENGTH - (max(buffer lengths)),
  4330. // since that's the earliest that a buffer overrun could occur. This way, checks are
  4331. // as rare as required, but as often as necessary to ensure never crossing this bound.
  4332. // Furthermore, buffers are only tested at most once per write(), so passing a very
  4333. // large string into write() might have undesirable effects, but this is manageable by
  4334. // the caller, so it is assumed to be safe. Thus, a call to write() may, in the extreme
  4335. // edge case, result in creating at most one complete copy of the string passed in.
  4336. // Set to Infinity to have unlimited buffers.
  4337. sax.MAX_BUFFER_LENGTH = 64 * 1024
  4338. var buffers = [
  4339. 'comment', 'sgmlDecl', 'textNode', 'tagName', 'doctype',
  4340. 'procInstName', 'procInstBody', 'entity', 'attribName',
  4341. 'attribValue', 'cdata', 'script'
  4342. ]
  4343. sax.EVENTS = [
  4344. 'text',
  4345. 'processinginstruction',
  4346. 'sgmldeclaration',
  4347. 'doctype',
  4348. 'comment',
  4349. 'opentagstart',
  4350. 'attribute',
  4351. 'opentag',
  4352. 'closetag',
  4353. 'opencdata',
  4354. 'cdata',
  4355. 'closecdata',
  4356. 'error',
  4357. 'end',
  4358. 'ready',
  4359. 'script',
  4360. 'opennamespace',
  4361. 'closenamespace'
  4362. ]
  4363. function SAXParser (strict, opt) {
  4364. if (!(this instanceof SAXParser)) {
  4365. return new SAXParser(strict, opt)
  4366. }
  4367. var parser = this
  4368. clearBuffers(parser)
  4369. parser.q = parser.c = ''
  4370. parser.bufferCheckPosition = sax.MAX_BUFFER_LENGTH
  4371. parser.opt = opt || {}
  4372. parser.opt.lowercase = parser.opt.lowercase || parser.opt.lowercasetags
  4373. parser.looseCase = parser.opt.lowercase ? 'toLowerCase' : 'toUpperCase'
  4374. parser.tags = []
  4375. parser.closed = parser.closedRoot = parser.sawRoot = false
  4376. parser.tag = parser.error = null
  4377. parser.strict = !!strict
  4378. parser.noscript = !!(strict || parser.opt.noscript)
  4379. parser.state = S.BEGIN
  4380. parser.strictEntities = parser.opt.strictEntities
  4381. parser.ENTITIES = parser.strictEntities ? Object.create(sax.XML_ENTITIES) : Object.create(sax.ENTITIES)
  4382. parser.attribList = []
  4383. // namespaces form a prototype chain.
  4384. // it always points at the current tag,
  4385. // which protos to its parent tag.
  4386. if (parser.opt.xmlns) {
  4387. parser.ns = Object.create(rootNS)
  4388. }
  4389. // disallow unquoted attribute values if not otherwise configured
  4390. // and strict mode is true
  4391. if (parser.opt.unquotedAttributeValues === undefined) {
  4392. parser.opt.unquotedAttributeValues = !strict;
  4393. }
  4394. // mostly just for error reporting
  4395. parser.trackPosition = parser.opt.position !== false
  4396. if (parser.trackPosition) {
  4397. parser.position = parser.line = parser.column = 0
  4398. }
  4399. emit(parser, 'onready')
  4400. }
  4401. if (!Object.create) {
  4402. Object.create = function (o) {
  4403. function F () {}
  4404. F.prototype = o
  4405. var newf = new F()
  4406. return newf
  4407. }
  4408. }
  4409. if (!Object.keys) {
  4410. Object.keys = function (o) {
  4411. var a = []
  4412. for (var i in o) if (o.hasOwnProperty(i)) a.push(i)
  4413. return a
  4414. }
  4415. }
  4416. function checkBufferLength (parser) {
  4417. var maxAllowed = Math.max(sax.MAX_BUFFER_LENGTH, 10)
  4418. var maxActual = 0
  4419. for (var i = 0, l = buffers.length; i < l; i++) {
  4420. var len = parser[buffers[i]].length
  4421. if (len > maxAllowed) {
  4422. // Text/cdata nodes can get big, and since they're buffered,
  4423. // we can get here under normal conditions.
  4424. // Avoid issues by emitting the text node now,
  4425. // so at least it won't get any bigger.
  4426. switch (buffers[i]) {
  4427. case 'textNode':
  4428. closeText(parser)
  4429. break
  4430. case 'cdata':
  4431. emitNode(parser, 'oncdata', parser.cdata)
  4432. parser.cdata = ''
  4433. break
  4434. case 'script':
  4435. emitNode(parser, 'onscript', parser.script)
  4436. parser.script = ''
  4437. break
  4438. default:
  4439. error(parser, 'Max buffer length exceeded: ' + buffers[i])
  4440. }
  4441. }
  4442. maxActual = Math.max(maxActual, len)
  4443. }
  4444. // schedule the next check for the earliest possible buffer overrun.
  4445. var m = sax.MAX_BUFFER_LENGTH - maxActual
  4446. parser.bufferCheckPosition = m + parser.position
  4447. }
  4448. function clearBuffers (parser) {
  4449. for (var i = 0, l = buffers.length; i < l; i++) {
  4450. parser[buffers[i]] = ''
  4451. }
  4452. }
  4453. function flushBuffers (parser) {
  4454. closeText(parser)
  4455. if (parser.cdata !== '') {
  4456. emitNode(parser, 'oncdata', parser.cdata)
  4457. parser.cdata = ''
  4458. }
  4459. if (parser.script !== '') {
  4460. emitNode(parser, 'onscript', parser.script)
  4461. parser.script = ''
  4462. }
  4463. }
  4464. SAXParser.prototype = {
  4465. end: function () { end(this) },
  4466. write: write,
  4467. resume: function () { this.error = null; return this },
  4468. close: function () { return this.write(null) },
  4469. flush: function () { flushBuffers(this) }
  4470. }
  4471. var Stream
  4472. try {
  4473. Stream = require('stream').Stream
  4474. } catch (ex) {
  4475. Stream = function () {}
  4476. }
  4477. if (!Stream) Stream = function () {}
  4478. var streamWraps = sax.EVENTS.filter(function (ev) {
  4479. return ev !== 'error' && ev !== 'end'
  4480. })
  4481. function createStream (strict, opt) {
  4482. return new SAXStream(strict, opt)
  4483. }
  4484. function SAXStream (strict, opt) {
  4485. if (!(this instanceof SAXStream)) {
  4486. return new SAXStream(strict, opt)
  4487. }
  4488. Stream.apply(this)
  4489. this._parser = new SAXParser(strict, opt)
  4490. this.writable = true
  4491. this.readable = true
  4492. var me = this
  4493. this._parser.onend = function () {
  4494. me.emit('end')
  4495. }
  4496. this._parser.onerror = function (er) {
  4497. me.emit('error', er)
  4498. // if didn't throw, then means error was handled.
  4499. // go ahead and clear error, so we can write again.
  4500. me._parser.error = null
  4501. }
  4502. this._decoder = null
  4503. streamWraps.forEach(function (ev) {
  4504. Object.defineProperty(me, 'on' + ev, {
  4505. get: function () {
  4506. return me._parser['on' + ev]
  4507. },
  4508. set: function (h) {
  4509. if (!h) {
  4510. me.removeAllListeners(ev)
  4511. me._parser['on' + ev] = h
  4512. return h
  4513. }
  4514. me.on(ev, h)
  4515. },
  4516. enumerable: true,
  4517. configurable: false
  4518. })
  4519. })
  4520. }
  4521. SAXStream.prototype = Object.create(Stream.prototype, {
  4522. constructor: {
  4523. value: SAXStream
  4524. }
  4525. })
  4526. SAXStream.prototype.write = function (data) {
  4527. if (typeof Buffer === 'function' &&
  4528. typeof Buffer.isBuffer === 'function' &&
  4529. Buffer.isBuffer(data)) {
  4530. if (!this._decoder) {
  4531. var SD = require('string_decoder').StringDecoder
  4532. this._decoder = new SD('utf8')
  4533. }
  4534. data = this._decoder.write(data)
  4535. }
  4536. this._parser.write(data.toString())
  4537. this.emit('data', data)
  4538. return true
  4539. }
  4540. SAXStream.prototype.end = function (chunk) {
  4541. if (chunk && chunk.length) {
  4542. this.write(chunk)
  4543. }
  4544. this._parser.end()
  4545. return true
  4546. }
  4547. SAXStream.prototype.on = function (ev, handler) {
  4548. var me = this
  4549. if (!me._parser['on' + ev] && streamWraps.indexOf(ev) !== -1) {
  4550. me._parser['on' + ev] = function () {
  4551. var args = arguments.length === 1 ? [arguments[0]] : Array.apply(null, arguments)
  4552. args.splice(0, 0, ev)
  4553. me.emit.apply(me, args)
  4554. }
  4555. }
  4556. return Stream.prototype.on.call(me, ev, handler)
  4557. }
  4558. // this really needs to be replaced with character classes.
  4559. // XML allows all manner of ridiculous numbers and digits.
  4560. var CDATA = '[CDATA['
  4561. var DOCTYPE = 'DOCTYPE'
  4562. var XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace'
  4563. var XMLNS_NAMESPACE = 'http://www.w3.org/2000/xmlns/'
  4564. var rootNS = { xml: XML_NAMESPACE, xmlns: XMLNS_NAMESPACE }
  4565. // http://www.w3.org/TR/REC-xml/#NT-NameStartChar
  4566. // This implementation works on strings, a single character at a time
  4567. // as such, it cannot ever support astral-plane characters (10000-EFFFF)
  4568. // without a significant breaking change to either this parser, or the
  4569. // JavaScript language. Implementation of an emoji-capable xml parser
  4570. // is left as an exercise for the reader.
  4571. var nameStart = /[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/
  4572. var nameBody = /[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/
  4573. var entityStart = /[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/
  4574. var entityBody = /[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/
  4575. function isWhitespace (c) {
  4576. return c === ' ' || c === '\n' || c === '\r' || c === '\t'
  4577. }
  4578. function isQuote (c) {
  4579. return c === '"' || c === '\''
  4580. }
  4581. function isAttribEnd (c) {
  4582. return c === '>' || isWhitespace(c)
  4583. }
  4584. function isMatch (regex, c) {
  4585. return regex.test(c)
  4586. }
  4587. function notMatch (regex, c) {
  4588. return !isMatch(regex, c)
  4589. }
  4590. var S = 0
  4591. sax.STATE = {
  4592. BEGIN: S++, // leading byte order mark or whitespace
  4593. BEGIN_WHITESPACE: S++, // leading whitespace
  4594. TEXT: S++, // general stuff
  4595. TEXT_ENTITY: S++, // &amp and such.
  4596. OPEN_WAKA: S++, // <
  4597. SGML_DECL: S++, // <!BLARG
  4598. SGML_DECL_QUOTED: S++, // <!BLARG foo "bar
  4599. DOCTYPE: S++, // <!DOCTYPE
  4600. DOCTYPE_QUOTED: S++, // <!DOCTYPE "//blah
  4601. DOCTYPE_DTD: S++, // <!DOCTYPE "//blah" [ ...
  4602. DOCTYPE_DTD_QUOTED: S++, // <!DOCTYPE "//blah" [ "foo
  4603. COMMENT_STARTING: S++, // <!-
  4604. COMMENT: S++, // <!--
  4605. COMMENT_ENDING: S++, // <!-- blah -
  4606. COMMENT_ENDED: S++, // <!-- blah --
  4607. CDATA: S++, // <![CDATA[ something
  4608. CDATA_ENDING: S++, // ]
  4609. CDATA_ENDING_2: S++, // ]]
  4610. PROC_INST: S++, // <?hi
  4611. PROC_INST_BODY: S++, // <?hi there
  4612. PROC_INST_ENDING: S++, // <?hi "there" ?
  4613. OPEN_TAG: S++, // <strong
  4614. OPEN_TAG_SLASH: S++, // <strong /
  4615. ATTRIB: S++, // <a
  4616. ATTRIB_NAME: S++, // <a foo
  4617. ATTRIB_NAME_SAW_WHITE: S++, // <a foo _
  4618. ATTRIB_VALUE: S++, // <a foo=
  4619. ATTRIB_VALUE_QUOTED: S++, // <a foo="bar
  4620. ATTRIB_VALUE_CLOSED: S++, // <a foo="bar"
  4621. ATTRIB_VALUE_UNQUOTED: S++, // <a foo=bar
  4622. ATTRIB_VALUE_ENTITY_Q: S++, // <foo bar="&quot;"
  4623. ATTRIB_VALUE_ENTITY_U: S++, // <foo bar=&quot
  4624. CLOSE_TAG: S++, // </a
  4625. CLOSE_TAG_SAW_WHITE: S++, // </a >
  4626. SCRIPT: S++, // <script> ...
  4627. SCRIPT_ENDING: S++ // <script> ... <
  4628. }
  4629. sax.XML_ENTITIES = {
  4630. 'amp': '&',
  4631. 'gt': '>',
  4632. 'lt': '<',
  4633. 'quot': '"',
  4634. 'apos': "'"
  4635. }
  4636. sax.ENTITIES = {
  4637. 'amp': '&',
  4638. 'gt': '>',
  4639. 'lt': '<',
  4640. 'quot': '"',
  4641. 'apos': "'",
  4642. 'AElig': 198,
  4643. 'Aacute': 193,
  4644. 'Acirc': 194,
  4645. 'Agrave': 192,
  4646. 'Aring': 197,
  4647. 'Atilde': 195,
  4648. 'Auml': 196,
  4649. 'Ccedil': 199,
  4650. 'ETH': 208,
  4651. 'Eacute': 201,
  4652. 'Ecirc': 202,
  4653. 'Egrave': 200,
  4654. 'Euml': 203,
  4655. 'Iacute': 205,
  4656. 'Icirc': 206,
  4657. 'Igrave': 204,
  4658. 'Iuml': 207,
  4659. 'Ntilde': 209,
  4660. 'Oacute': 211,
  4661. 'Ocirc': 212,
  4662. 'Ograve': 210,
  4663. 'Oslash': 216,
  4664. 'Otilde': 213,
  4665. 'Ouml': 214,
  4666. 'THORN': 222,
  4667. 'Uacute': 218,
  4668. 'Ucirc': 219,
  4669. 'Ugrave': 217,
  4670. 'Uuml': 220,
  4671. 'Yacute': 221,
  4672. 'aacute': 225,
  4673. 'acirc': 226,
  4674. 'aelig': 230,
  4675. 'agrave': 224,
  4676. 'aring': 229,
  4677. 'atilde': 227,
  4678. 'auml': 228,
  4679. 'ccedil': 231,
  4680. 'eacute': 233,
  4681. 'ecirc': 234,
  4682. 'egrave': 232,
  4683. 'eth': 240,
  4684. 'euml': 235,
  4685. 'iacute': 237,
  4686. 'icirc': 238,
  4687. 'igrave': 236,
  4688. 'iuml': 239,
  4689. 'ntilde': 241,
  4690. 'oacute': 243,
  4691. 'ocirc': 244,
  4692. 'ograve': 242,
  4693. 'oslash': 248,
  4694. 'otilde': 245,
  4695. 'ouml': 246,
  4696. 'szlig': 223,
  4697. 'thorn': 254,
  4698. 'uacute': 250,
  4699. 'ucirc': 251,
  4700. 'ugrave': 249,
  4701. 'uuml': 252,
  4702. 'yacute': 253,
  4703. 'yuml': 255,
  4704. 'copy': 169,
  4705. 'reg': 174,
  4706. 'nbsp': 160,
  4707. 'iexcl': 161,
  4708. 'cent': 162,
  4709. 'pound': 163,
  4710. 'curren': 164,
  4711. 'yen': 165,
  4712. 'brvbar': 166,
  4713. 'sect': 167,
  4714. 'uml': 168,
  4715. 'ordf': 170,
  4716. 'laquo': 171,
  4717. 'not': 172,
  4718. 'shy': 173,
  4719. 'macr': 175,
  4720. 'deg': 176,
  4721. 'plusmn': 177,
  4722. 'sup1': 185,
  4723. 'sup2': 178,
  4724. 'sup3': 179,
  4725. 'acute': 180,
  4726. 'micro': 181,
  4727. 'para': 182,
  4728. 'middot': 183,
  4729. 'cedil': 184,
  4730. 'ordm': 186,
  4731. 'raquo': 187,
  4732. 'frac14': 188,
  4733. 'frac12': 189,
  4734. 'frac34': 190,
  4735. 'iquest': 191,
  4736. 'times': 215,
  4737. 'divide': 247,
  4738. 'OElig': 338,
  4739. 'oelig': 339,
  4740. 'Scaron': 352,
  4741. 'scaron': 353,
  4742. 'Yuml': 376,
  4743. 'fnof': 402,
  4744. 'circ': 710,
  4745. 'tilde': 732,
  4746. 'Alpha': 913,
  4747. 'Beta': 914,
  4748. 'Gamma': 915,
  4749. 'Delta': 916,
  4750. 'Epsilon': 917,
  4751. 'Zeta': 918,
  4752. 'Eta': 919,
  4753. 'Theta': 920,
  4754. 'Iota': 921,
  4755. 'Kappa': 922,
  4756. 'Lambda': 923,
  4757. 'Mu': 924,
  4758. 'Nu': 925,
  4759. 'Xi': 926,
  4760. 'Omicron': 927,
  4761. 'Pi': 928,
  4762. 'Rho': 929,
  4763. 'Sigma': 931,
  4764. 'Tau': 932,
  4765. 'Upsilon': 933,
  4766. 'Phi': 934,
  4767. 'Chi': 935,
  4768. 'Psi': 936,
  4769. 'Omega': 937,
  4770. 'alpha': 945,
  4771. 'beta': 946,
  4772. 'gamma': 947,
  4773. 'delta': 948,
  4774. 'epsilon': 949,
  4775. 'zeta': 950,
  4776. 'eta': 951,
  4777. 'theta': 952,
  4778. 'iota': 953,
  4779. 'kappa': 954,
  4780. 'lambda': 955,
  4781. 'mu': 956,
  4782. 'nu': 957,
  4783. 'xi': 958,
  4784. 'omicron': 959,
  4785. 'pi': 960,
  4786. 'rho': 961,
  4787. 'sigmaf': 962,
  4788. 'sigma': 963,
  4789. 'tau': 964,
  4790. 'upsilon': 965,
  4791. 'phi': 966,
  4792. 'chi': 967,
  4793. 'psi': 968,
  4794. 'omega': 969,
  4795. 'thetasym': 977,
  4796. 'upsih': 978,
  4797. 'piv': 982,
  4798. 'ensp': 8194,
  4799. 'emsp': 8195,
  4800. 'thinsp': 8201,
  4801. 'zwnj': 8204,
  4802. 'zwj': 8205,
  4803. 'lrm': 8206,
  4804. 'rlm': 8207,
  4805. 'ndash': 8211,
  4806. 'mdash': 8212,
  4807. 'lsquo': 8216,
  4808. 'rsquo': 8217,
  4809. 'sbquo': 8218,
  4810. 'ldquo': 8220,
  4811. 'rdquo': 8221,
  4812. 'bdquo': 8222,
  4813. 'dagger': 8224,
  4814. 'Dagger': 8225,
  4815. 'bull': 8226,
  4816. 'hellip': 8230,
  4817. 'permil': 8240,
  4818. 'prime': 8242,
  4819. 'Prime': 8243,
  4820. 'lsaquo': 8249,
  4821. 'rsaquo': 8250,
  4822. 'oline': 8254,
  4823. 'frasl': 8260,
  4824. 'euro': 8364,
  4825. 'image': 8465,
  4826. 'weierp': 8472,
  4827. 'real': 8476,
  4828. 'trade': 8482,
  4829. 'alefsym': 8501,
  4830. 'larr': 8592,
  4831. 'uarr': 8593,
  4832. 'rarr': 8594,
  4833. 'darr': 8595,
  4834. 'harr': 8596,
  4835. 'crarr': 8629,
  4836. 'lArr': 8656,
  4837. 'uArr': 8657,
  4838. 'rArr': 8658,
  4839. 'dArr': 8659,
  4840. 'hArr': 8660,
  4841. 'forall': 8704,
  4842. 'part': 8706,
  4843. 'exist': 8707,
  4844. 'empty': 8709,
  4845. 'nabla': 8711,
  4846. 'isin': 8712,
  4847. 'notin': 8713,
  4848. 'ni': 8715,
  4849. 'prod': 8719,
  4850. 'sum': 8721,
  4851. 'minus': 8722,
  4852. 'lowast': 8727,
  4853. 'radic': 8730,
  4854. 'prop': 8733,
  4855. 'infin': 8734,
  4856. 'ang': 8736,
  4857. 'and': 8743,
  4858. 'or': 8744,
  4859. 'cap': 8745,
  4860. 'cup': 8746,
  4861. 'int': 8747,
  4862. 'there4': 8756,
  4863. 'sim': 8764,
  4864. 'cong': 8773,
  4865. 'asymp': 8776,
  4866. 'ne': 8800,
  4867. 'equiv': 8801,
  4868. 'le': 8804,
  4869. 'ge': 8805,
  4870. 'sub': 8834,
  4871. 'sup': 8835,
  4872. 'nsub': 8836,
  4873. 'sube': 8838,
  4874. 'supe': 8839,
  4875. 'oplus': 8853,
  4876. 'otimes': 8855,
  4877. 'perp': 8869,
  4878. 'sdot': 8901,
  4879. 'lceil': 8968,
  4880. 'rceil': 8969,
  4881. 'lfloor': 8970,
  4882. 'rfloor': 8971,
  4883. 'lang': 9001,
  4884. 'rang': 9002,
  4885. 'loz': 9674,
  4886. 'spades': 9824,
  4887. 'clubs': 9827,
  4888. 'hearts': 9829,
  4889. 'diams': 9830
  4890. }
  4891. Object.keys(sax.ENTITIES).forEach(function (key) {
  4892. var e = sax.ENTITIES[key]
  4893. var s = typeof e === 'number' ? String.fromCharCode(e) : e
  4894. sax.ENTITIES[key] = s
  4895. })
  4896. for (var s in sax.STATE) {
  4897. sax.STATE[sax.STATE[s]] = s
  4898. }
  4899. // shorthand
  4900. S = sax.STATE
  4901. function emit (parser, event, data) {
  4902. parser[event] && parser[event](data)
  4903. }
  4904. function emitNode (parser, nodeType, data) {
  4905. if (parser.textNode) closeText(parser)
  4906. emit(parser, nodeType, data)
  4907. }
  4908. function closeText (parser) {
  4909. parser.textNode = textopts(parser.opt, parser.textNode)
  4910. if (parser.textNode) emit(parser, 'ontext', parser.textNode)
  4911. parser.textNode = ''
  4912. }
  4913. function textopts (opt, text) {
  4914. if (opt.trim) text = text.trim()
  4915. if (opt.normalize) text = text.replace(/\s+/g, ' ')
  4916. return text
  4917. }
  4918. function error (parser, er) {
  4919. closeText(parser)
  4920. if (parser.trackPosition) {
  4921. er += '\nLine: ' + parser.line +
  4922. '\nColumn: ' + parser.column +
  4923. '\nChar: ' + parser.c
  4924. }
  4925. er = new Error(er)
  4926. parser.error = er
  4927. emit(parser, 'onerror', er)
  4928. return parser
  4929. }
  4930. function end (parser) {
  4931. if (parser.sawRoot && !parser.closedRoot) strictFail(parser, 'Unclosed root tag')
  4932. if ((parser.state !== S.BEGIN) &&
  4933. (parser.state !== S.BEGIN_WHITESPACE) &&
  4934. (parser.state !== S.TEXT)) {
  4935. error(parser, 'Unexpected end')
  4936. }
  4937. closeText(parser)
  4938. parser.c = ''
  4939. parser.closed = true
  4940. emit(parser, 'onend')
  4941. SAXParser.call(parser, parser.strict, parser.opt)
  4942. return parser
  4943. }
  4944. function strictFail (parser, message) {
  4945. if (typeof parser !== 'object' || !(parser instanceof SAXParser)) {
  4946. throw new Error('bad call to strictFail')
  4947. }
  4948. if (parser.strict) {
  4949. error(parser, message)
  4950. }
  4951. }
  4952. function newTag (parser) {
  4953. if (!parser.strict) parser.tagName = parser.tagName[parser.looseCase]()
  4954. var parent = parser.tags[parser.tags.length - 1] || parser
  4955. var tag = parser.tag = { name: parser.tagName, attributes: {} }
  4956. // will be overridden if tag contails an xmlns="foo" or xmlns:foo="bar"
  4957. if (parser.opt.xmlns) {
  4958. tag.ns = parent.ns
  4959. }
  4960. parser.attribList.length = 0
  4961. emitNode(parser, 'onopentagstart', tag)
  4962. }
  4963. function qname (name, attribute) {
  4964. var i = name.indexOf(':')
  4965. var qualName = i < 0 ? [ '', name ] : name.split(':')
  4966. var prefix = qualName[0]
  4967. var local = qualName[1]
  4968. // <x "xmlns"="http://foo">
  4969. if (attribute && name === 'xmlns') {
  4970. prefix = 'xmlns'
  4971. local = ''
  4972. }
  4973. return { prefix: prefix, local: local }
  4974. }
  4975. function attrib (parser) {
  4976. if (!parser.strict) {
  4977. parser.attribName = parser.attribName[parser.looseCase]()
  4978. }
  4979. if (parser.attribList.indexOf(parser.attribName) !== -1 ||
  4980. parser.tag.attributes.hasOwnProperty(parser.attribName)) {
  4981. parser.attribName = parser.attribValue = ''
  4982. return
  4983. }
  4984. if (parser.opt.xmlns) {
  4985. var qn = qname(parser.attribName, true)
  4986. var prefix = qn.prefix
  4987. var local = qn.local
  4988. if (prefix === 'xmlns') {
  4989. // namespace binding attribute. push the binding into scope
  4990. if (local === 'xml' && parser.attribValue !== XML_NAMESPACE) {
  4991. strictFail(parser,
  4992. 'xml: prefix must be bound to ' + XML_NAMESPACE + '\n' +
  4993. 'Actual: ' + parser.attribValue)
  4994. } else if (local === 'xmlns' && parser.attribValue !== XMLNS_NAMESPACE) {
  4995. strictFail(parser,
  4996. 'xmlns: prefix must be bound to ' + XMLNS_NAMESPACE + '\n' +
  4997. 'Actual: ' + parser.attribValue)
  4998. } else {
  4999. var tag = parser.tag
  5000. var parent = parser.tags[parser.tags.length - 1] || parser
  5001. if (tag.ns === parent.ns) {
  5002. tag.ns = Object.create(parent.ns)
  5003. }
  5004. tag.ns[local] = parser.attribValue
  5005. }
  5006. }
  5007. // defer onattribute events until all attributes have been seen
  5008. // so any new bindings can take effect. preserve attribute order
  5009. // so deferred events can be emitted in document order
  5010. parser.attribList.push([parser.attribName, parser.attribValue])
  5011. } else {
  5012. // in non-xmlns mode, we can emit the event right away
  5013. parser.tag.attributes[parser.attribName] = parser.attribValue
  5014. emitNode(parser, 'onattribute', {
  5015. name: parser.attribName,
  5016. value: parser.attribValue
  5017. })
  5018. }
  5019. parser.attribName = parser.attribValue = ''
  5020. }
  5021. function openTag (parser, selfClosing) {
  5022. if (parser.opt.xmlns) {
  5023. // emit namespace binding events
  5024. var tag = parser.tag
  5025. // add namespace info to tag
  5026. var qn = qname(parser.tagName)
  5027. tag.prefix = qn.prefix
  5028. tag.local = qn.local
  5029. tag.uri = tag.ns[qn.prefix] || ''
  5030. if (tag.prefix && !tag.uri) {
  5031. strictFail(parser, 'Unbound namespace prefix: ' +
  5032. JSON.stringify(parser.tagName))
  5033. tag.uri = qn.prefix
  5034. }
  5035. var parent = parser.tags[parser.tags.length - 1] || parser
  5036. if (tag.ns && parent.ns !== tag.ns) {
  5037. Object.keys(tag.ns).forEach(function (p) {
  5038. emitNode(parser, 'onopennamespace', {
  5039. prefix: p,
  5040. uri: tag.ns[p]
  5041. })
  5042. })
  5043. }
  5044. // handle deferred onattribute events
  5045. // Note: do not apply default ns to attributes:
  5046. // http://www.w3.org/TR/REC-xml-names/#defaulting
  5047. for (var i = 0, l = parser.attribList.length; i < l; i++) {
  5048. var nv = parser.attribList[i]
  5049. var name = nv[0]
  5050. var value = nv[1]
  5051. var qualName = qname(name, true)
  5052. var prefix = qualName.prefix
  5053. var local = qualName.local
  5054. var uri = prefix === '' ? '' : (tag.ns[prefix] || '')
  5055. var a = {
  5056. name: name,
  5057. value: value,
  5058. prefix: prefix,
  5059. local: local,
  5060. uri: uri
  5061. }
  5062. // if there's any attributes with an undefined namespace,
  5063. // then fail on them now.
  5064. if (prefix && prefix !== 'xmlns' && !uri) {
  5065. strictFail(parser, 'Unbound namespace prefix: ' +
  5066. JSON.stringify(prefix))
  5067. a.uri = prefix
  5068. }
  5069. parser.tag.attributes[name] = a
  5070. emitNode(parser, 'onattribute', a)
  5071. }
  5072. parser.attribList.length = 0
  5073. }
  5074. parser.tag.isSelfClosing = !!selfClosing
  5075. // process the tag
  5076. parser.sawRoot = true
  5077. parser.tags.push(parser.tag)
  5078. emitNode(parser, 'onopentag', parser.tag)
  5079. if (!selfClosing) {
  5080. // special case for <script> in non-strict mode.
  5081. if (!parser.noscript && parser.tagName.toLowerCase() === 'script') {
  5082. parser.state = S.SCRIPT
  5083. } else {
  5084. parser.state = S.TEXT
  5085. }
  5086. parser.tag = null
  5087. parser.tagName = ''
  5088. }
  5089. parser.attribName = parser.attribValue = ''
  5090. parser.attribList.length = 0
  5091. }
  5092. function closeTag (parser) {
  5093. if (!parser.tagName) {
  5094. strictFail(parser, 'Weird empty close tag.')
  5095. parser.textNode += '</>'
  5096. parser.state = S.TEXT
  5097. return
  5098. }
  5099. if (parser.script) {
  5100. if (parser.tagName !== 'script') {
  5101. parser.script += '</' + parser.tagName + '>'
  5102. parser.tagName = ''
  5103. parser.state = S.SCRIPT
  5104. return
  5105. }
  5106. emitNode(parser, 'onscript', parser.script)
  5107. parser.script = ''
  5108. }
  5109. // first make sure that the closing tag actually exists.
  5110. // <a><b></c></b></a> will close everything, otherwise.
  5111. var t = parser.tags.length
  5112. var tagName = parser.tagName
  5113. if (!parser.strict) {
  5114. tagName = tagName[parser.looseCase]()
  5115. }
  5116. var closeTo = tagName
  5117. while (t--) {
  5118. var close = parser.tags[t]
  5119. if (close.name !== closeTo) {
  5120. // fail the first time in strict mode
  5121. strictFail(parser, 'Unexpected close tag')
  5122. } else {
  5123. break
  5124. }
  5125. }
  5126. // didn't find it. we already failed for strict, so just abort.
  5127. if (t < 0) {
  5128. strictFail(parser, 'Unmatched closing tag: ' + parser.tagName)
  5129. parser.textNode += '</' + parser.tagName + '>'
  5130. parser.state = S.TEXT
  5131. return
  5132. }
  5133. parser.tagName = tagName
  5134. var s = parser.tags.length
  5135. while (s-- > t) {
  5136. var tag = parser.tag = parser.tags.pop()
  5137. parser.tagName = parser.tag.name
  5138. emitNode(parser, 'onclosetag', parser.tagName)
  5139. var x = {}
  5140. for (var i in tag.ns) {
  5141. x[i] = tag.ns[i]
  5142. }
  5143. var parent = parser.tags[parser.tags.length - 1] || parser
  5144. if (parser.opt.xmlns && tag.ns !== parent.ns) {
  5145. // remove namespace bindings introduced by tag
  5146. Object.keys(tag.ns).forEach(function (p) {
  5147. var n = tag.ns[p]
  5148. emitNode(parser, 'onclosenamespace', { prefix: p, uri: n })
  5149. })
  5150. }
  5151. }
  5152. if (t === 0) parser.closedRoot = true
  5153. parser.tagName = parser.attribValue = parser.attribName = ''
  5154. parser.attribList.length = 0
  5155. parser.state = S.TEXT
  5156. }
  5157. function parseEntity (parser) {
  5158. var entity = parser.entity
  5159. var entityLC = entity.toLowerCase()
  5160. var num
  5161. var numStr = ''
  5162. if (parser.ENTITIES[entity]) {
  5163. return parser.ENTITIES[entity]
  5164. }
  5165. if (parser.ENTITIES[entityLC]) {
  5166. return parser.ENTITIES[entityLC]
  5167. }
  5168. entity = entityLC
  5169. if (entity.charAt(0) === '#') {
  5170. if (entity.charAt(1) === 'x') {
  5171. entity = entity.slice(2)
  5172. num = parseInt(entity, 16)
  5173. numStr = num.toString(16)
  5174. } else {
  5175. entity = entity.slice(1)
  5176. num = parseInt(entity, 10)
  5177. numStr = num.toString(10)
  5178. }
  5179. }
  5180. entity = entity.replace(/^0+/, '')
  5181. if (isNaN(num) || numStr.toLowerCase() !== entity) {
  5182. strictFail(parser, 'Invalid character entity')
  5183. return '&' + parser.entity + ';'
  5184. }
  5185. return String.fromCodePoint(num)
  5186. }
  5187. function beginWhiteSpace (parser, c) {
  5188. if (c === '<') {
  5189. parser.state = S.OPEN_WAKA
  5190. parser.startTagPosition = parser.position
  5191. } else if (!isWhitespace(c)) {
  5192. // have to process this as a text node.
  5193. // weird, but happens.
  5194. strictFail(parser, 'Non-whitespace before first tag.')
  5195. parser.textNode = c
  5196. parser.state = S.TEXT
  5197. }
  5198. }
  5199. function charAt (chunk, i) {
  5200. var result = ''
  5201. if (i < chunk.length) {
  5202. result = chunk.charAt(i)
  5203. }
  5204. return result
  5205. }
  5206. function write (chunk) {
  5207. var parser = this
  5208. if (this.error) {
  5209. throw this.error
  5210. }
  5211. if (parser.closed) {
  5212. return error(parser,
  5213. 'Cannot write after close. Assign an onready handler.')
  5214. }
  5215. if (chunk === null) {
  5216. return end(parser)
  5217. }
  5218. if (typeof chunk === 'object') {
  5219. chunk = chunk.toString()
  5220. }
  5221. var i = 0
  5222. var c = ''
  5223. while (true) {
  5224. c = charAt(chunk, i++)
  5225. parser.c = c
  5226. if (!c) {
  5227. break
  5228. }
  5229. if (parser.trackPosition) {
  5230. parser.position++
  5231. if (c === '\n') {
  5232. parser.line++
  5233. parser.column = 0
  5234. } else {
  5235. parser.column++
  5236. }
  5237. }
  5238. switch (parser.state) {
  5239. case S.BEGIN:
  5240. parser.state = S.BEGIN_WHITESPACE
  5241. if (c === '\uFEFF') {
  5242. continue
  5243. }
  5244. beginWhiteSpace(parser, c)
  5245. continue
  5246. case S.BEGIN_WHITESPACE:
  5247. beginWhiteSpace(parser, c)
  5248. continue
  5249. case S.TEXT:
  5250. if (parser.sawRoot && !parser.closedRoot) {
  5251. var starti = i - 1
  5252. while (c && c !== '<' && c !== '&') {
  5253. c = charAt(chunk, i++)
  5254. if (c && parser.trackPosition) {
  5255. parser.position++
  5256. if (c === '\n') {
  5257. parser.line++
  5258. parser.column = 0
  5259. } else {
  5260. parser.column++
  5261. }
  5262. }
  5263. }
  5264. parser.textNode += chunk.substring(starti, i - 1)
  5265. }
  5266. if (c === '<' && !(parser.sawRoot && parser.closedRoot && !parser.strict)) {
  5267. parser.state = S.OPEN_WAKA
  5268. parser.startTagPosition = parser.position
  5269. } else {
  5270. if (!isWhitespace(c) && (!parser.sawRoot || parser.closedRoot)) {
  5271. strictFail(parser, 'Text data outside of root node.')
  5272. }
  5273. if (c === '&') {
  5274. parser.state = S.TEXT_ENTITY
  5275. } else {
  5276. parser.textNode += c
  5277. }
  5278. }
  5279. continue
  5280. case S.SCRIPT:
  5281. // only non-strict
  5282. if (c === '<') {
  5283. parser.state = S.SCRIPT_ENDING
  5284. } else {
  5285. parser.script += c
  5286. }
  5287. continue
  5288. case S.SCRIPT_ENDING:
  5289. if (c === '/') {
  5290. parser.state = S.CLOSE_TAG
  5291. } else {
  5292. parser.script += '<' + c
  5293. parser.state = S.SCRIPT
  5294. }
  5295. continue
  5296. case S.OPEN_WAKA:
  5297. // either a /, ?, !, or text is coming next.
  5298. if (c === '!') {
  5299. parser.state = S.SGML_DECL
  5300. parser.sgmlDecl = ''
  5301. } else if (isWhitespace(c)) {
  5302. // wait for it...
  5303. } else if (isMatch(nameStart, c)) {
  5304. parser.state = S.OPEN_TAG
  5305. parser.tagName = c
  5306. } else if (c === '/') {
  5307. parser.state = S.CLOSE_TAG
  5308. parser.tagName = ''
  5309. } else if (c === '?') {
  5310. parser.state = S.PROC_INST
  5311. parser.procInstName = parser.procInstBody = ''
  5312. } else {
  5313. strictFail(parser, 'Unencoded <')
  5314. // if there was some whitespace, then add that in.
  5315. if (parser.startTagPosition + 1 < parser.position) {
  5316. var pad = parser.position - parser.startTagPosition
  5317. c = new Array(pad).join(' ') + c
  5318. }
  5319. parser.textNode += '<' + c
  5320. parser.state = S.TEXT
  5321. }
  5322. continue
  5323. case S.SGML_DECL:
  5324. if (parser.sgmlDecl + c === '--') {
  5325. parser.state = S.COMMENT
  5326. parser.comment = ''
  5327. parser.sgmlDecl = ''
  5328. continue;
  5329. }
  5330. if (parser.doctype && parser.doctype !== true && parser.sgmlDecl) {
  5331. parser.state = S.DOCTYPE_DTD
  5332. parser.doctype += '<!' + parser.sgmlDecl + c
  5333. parser.sgmlDecl = ''
  5334. } else if ((parser.sgmlDecl + c).toUpperCase() === CDATA) {
  5335. emitNode(parser, 'onopencdata')
  5336. parser.state = S.CDATA
  5337. parser.sgmlDecl = ''
  5338. parser.cdata = ''
  5339. } else if ((parser.sgmlDecl + c).toUpperCase() === DOCTYPE) {
  5340. parser.state = S.DOCTYPE
  5341. if (parser.doctype || parser.sawRoot) {
  5342. strictFail(parser,
  5343. 'Inappropriately located doctype declaration')
  5344. }
  5345. parser.doctype = ''
  5346. parser.sgmlDecl = ''
  5347. } else if (c === '>') {
  5348. emitNode(parser, 'onsgmldeclaration', parser.sgmlDecl)
  5349. parser.sgmlDecl = ''
  5350. parser.state = S.TEXT
  5351. } else if (isQuote(c)) {
  5352. parser.state = S.SGML_DECL_QUOTED
  5353. parser.sgmlDecl += c
  5354. } else {
  5355. parser.sgmlDecl += c
  5356. }
  5357. continue
  5358. case S.SGML_DECL_QUOTED:
  5359. if (c === parser.q) {
  5360. parser.state = S.SGML_DECL
  5361. parser.q = ''
  5362. }
  5363. parser.sgmlDecl += c
  5364. continue
  5365. case S.DOCTYPE:
  5366. if (c === '>') {
  5367. parser.state = S.TEXT
  5368. emitNode(parser, 'ondoctype', parser.doctype)
  5369. parser.doctype = true // just remember that we saw it.
  5370. } else {
  5371. parser.doctype += c
  5372. if (c === '[') {
  5373. parser.state = S.DOCTYPE_DTD
  5374. } else if (isQuote(c)) {
  5375. parser.state = S.DOCTYPE_QUOTED
  5376. parser.q = c
  5377. }
  5378. }
  5379. continue
  5380. case S.DOCTYPE_QUOTED:
  5381. parser.doctype += c
  5382. if (c === parser.q) {
  5383. parser.q = ''
  5384. parser.state = S.DOCTYPE
  5385. }
  5386. continue
  5387. case S.DOCTYPE_DTD:
  5388. if (c === ']') {
  5389. parser.doctype += c
  5390. parser.state = S.DOCTYPE
  5391. } else if (c === '<') {
  5392. parser.state = S.OPEN_WAKA
  5393. parser.startTagPosition = parser.position
  5394. } else if (isQuote(c)) {
  5395. parser.doctype += c
  5396. parser.state = S.DOCTYPE_DTD_QUOTED
  5397. parser.q = c
  5398. } else {
  5399. parser.doctype += c
  5400. }
  5401. continue
  5402. case S.DOCTYPE_DTD_QUOTED:
  5403. parser.doctype += c
  5404. if (c === parser.q) {
  5405. parser.state = S.DOCTYPE_DTD
  5406. parser.q = ''
  5407. }
  5408. continue
  5409. case S.COMMENT:
  5410. if (c === '-') {
  5411. parser.state = S.COMMENT_ENDING
  5412. } else {
  5413. parser.comment += c
  5414. }
  5415. continue
  5416. case S.COMMENT_ENDING:
  5417. if (c === '-') {
  5418. parser.state = S.COMMENT_ENDED
  5419. parser.comment = textopts(parser.opt, parser.comment)
  5420. if (parser.comment) {
  5421. emitNode(parser, 'oncomment', parser.comment)
  5422. }
  5423. parser.comment = ''
  5424. } else {
  5425. parser.comment += '-' + c
  5426. parser.state = S.COMMENT
  5427. }
  5428. continue
  5429. case S.COMMENT_ENDED:
  5430. if (c !== '>') {
  5431. strictFail(parser, 'Malformed comment')
  5432. // allow <!-- blah -- bloo --> in non-strict mode,
  5433. // which is a comment of " blah -- bloo "
  5434. parser.comment += '--' + c
  5435. parser.state = S.COMMENT
  5436. } else if (parser.doctype && parser.doctype !== true) {
  5437. parser.state = S.DOCTYPE_DTD
  5438. } else {
  5439. parser.state = S.TEXT
  5440. }
  5441. continue
  5442. case S.CDATA:
  5443. if (c === ']') {
  5444. parser.state = S.CDATA_ENDING
  5445. } else {
  5446. parser.cdata += c
  5447. }
  5448. continue
  5449. case S.CDATA_ENDING:
  5450. if (c === ']') {
  5451. parser.state = S.CDATA_ENDING_2
  5452. } else {
  5453. parser.cdata += ']' + c
  5454. parser.state = S.CDATA
  5455. }
  5456. continue
  5457. case S.CDATA_ENDING_2:
  5458. if (c === '>') {
  5459. if (parser.cdata) {
  5460. emitNode(parser, 'oncdata', parser.cdata)
  5461. }
  5462. emitNode(parser, 'onclosecdata')
  5463. parser.cdata = ''
  5464. parser.state = S.TEXT
  5465. } else if (c === ']') {
  5466. parser.cdata += ']'
  5467. } else {
  5468. parser.cdata += ']]' + c
  5469. parser.state = S.CDATA
  5470. }
  5471. continue
  5472. case S.PROC_INST:
  5473. if (c === '?') {
  5474. parser.state = S.PROC_INST_ENDING
  5475. } else if (isWhitespace(c)) {
  5476. parser.state = S.PROC_INST_BODY
  5477. } else {
  5478. parser.procInstName += c
  5479. }
  5480. continue
  5481. case S.PROC_INST_BODY:
  5482. if (!parser.procInstBody && isWhitespace(c)) {
  5483. continue
  5484. } else if (c === '?') {
  5485. parser.state = S.PROC_INST_ENDING
  5486. } else {
  5487. parser.procInstBody += c
  5488. }
  5489. continue
  5490. case S.PROC_INST_ENDING:
  5491. if (c === '>') {
  5492. emitNode(parser, 'onprocessinginstruction', {
  5493. name: parser.procInstName,
  5494. body: parser.procInstBody
  5495. })
  5496. parser.procInstName = parser.procInstBody = ''
  5497. parser.state = S.TEXT
  5498. } else {
  5499. parser.procInstBody += '?' + c
  5500. parser.state = S.PROC_INST_BODY
  5501. }
  5502. continue
  5503. case S.OPEN_TAG:
  5504. if (isMatch(nameBody, c)) {
  5505. parser.tagName += c
  5506. } else {
  5507. newTag(parser)
  5508. if (c === '>') {
  5509. openTag(parser)
  5510. } else if (c === '/') {
  5511. parser.state = S.OPEN_TAG_SLASH
  5512. } else {
  5513. if (!isWhitespace(c)) {
  5514. strictFail(parser, 'Invalid character in tag name')
  5515. }
  5516. parser.state = S.ATTRIB
  5517. }
  5518. }
  5519. continue
  5520. case S.OPEN_TAG_SLASH:
  5521. if (c === '>') {
  5522. openTag(parser, true)
  5523. closeTag(parser)
  5524. } else {
  5525. strictFail(parser, 'Forward-slash in opening tag not followed by >')
  5526. parser.state = S.ATTRIB
  5527. }
  5528. continue
  5529. case S.ATTRIB:
  5530. // haven't read the attribute name yet.
  5531. if (isWhitespace(c)) {
  5532. continue
  5533. } else if (c === '>') {
  5534. openTag(parser)
  5535. } else if (c === '/') {
  5536. parser.state = S.OPEN_TAG_SLASH
  5537. } else if (isMatch(nameStart, c)) {
  5538. parser.attribName = c
  5539. parser.attribValue = ''
  5540. parser.state = S.ATTRIB_NAME
  5541. } else {
  5542. strictFail(parser, 'Invalid attribute name')
  5543. }
  5544. continue
  5545. case S.ATTRIB_NAME:
  5546. if (c === '=') {
  5547. parser.state = S.ATTRIB_VALUE
  5548. } else if (c === '>') {
  5549. strictFail(parser, 'Attribute without value')
  5550. parser.attribValue = parser.attribName
  5551. attrib(parser)
  5552. openTag(parser)
  5553. } else if (isWhitespace(c)) {
  5554. parser.state = S.ATTRIB_NAME_SAW_WHITE
  5555. } else if (isMatch(nameBody, c)) {
  5556. parser.attribName += c
  5557. } else {
  5558. strictFail(parser, 'Invalid attribute name')
  5559. }
  5560. continue
  5561. case S.ATTRIB_NAME_SAW_WHITE:
  5562. if (c === '=') {
  5563. parser.state = S.ATTRIB_VALUE
  5564. } else if (isWhitespace(c)) {
  5565. continue
  5566. } else {
  5567. strictFail(parser, 'Attribute without value')
  5568. parser.tag.attributes[parser.attribName] = ''
  5569. parser.attribValue = ''
  5570. emitNode(parser, 'onattribute', {
  5571. name: parser.attribName,
  5572. value: ''
  5573. })
  5574. parser.attribName = ''
  5575. if (c === '>') {
  5576. openTag(parser)
  5577. } else if (isMatch(nameStart, c)) {
  5578. parser.attribName = c
  5579. parser.state = S.ATTRIB_NAME
  5580. } else {
  5581. strictFail(parser, 'Invalid attribute name')
  5582. parser.state = S.ATTRIB
  5583. }
  5584. }
  5585. continue
  5586. case S.ATTRIB_VALUE:
  5587. if (isWhitespace(c)) {
  5588. continue
  5589. } else if (isQuote(c)) {
  5590. parser.q = c
  5591. parser.state = S.ATTRIB_VALUE_QUOTED
  5592. } else {
  5593. if (!parser.opt.unquotedAttributeValues) {
  5594. error(parser, 'Unquoted attribute value')
  5595. }
  5596. parser.state = S.ATTRIB_VALUE_UNQUOTED
  5597. parser.attribValue = c
  5598. }
  5599. continue
  5600. case S.ATTRIB_VALUE_QUOTED:
  5601. if (c !== parser.q) {
  5602. if (c === '&') {
  5603. parser.state = S.ATTRIB_VALUE_ENTITY_Q
  5604. } else {
  5605. parser.attribValue += c
  5606. }
  5607. continue
  5608. }
  5609. attrib(parser)
  5610. parser.q = ''
  5611. parser.state = S.ATTRIB_VALUE_CLOSED
  5612. continue
  5613. case S.ATTRIB_VALUE_CLOSED:
  5614. if (isWhitespace(c)) {
  5615. parser.state = S.ATTRIB
  5616. } else if (c === '>') {
  5617. openTag(parser)
  5618. } else if (c === '/') {
  5619. parser.state = S.OPEN_TAG_SLASH
  5620. } else if (isMatch(nameStart, c)) {
  5621. strictFail(parser, 'No whitespace between attributes')
  5622. parser.attribName = c
  5623. parser.attribValue = ''
  5624. parser.state = S.ATTRIB_NAME
  5625. } else {
  5626. strictFail(parser, 'Invalid attribute name')
  5627. }
  5628. continue
  5629. case S.ATTRIB_VALUE_UNQUOTED:
  5630. if (!isAttribEnd(c)) {
  5631. if (c === '&') {
  5632. parser.state = S.ATTRIB_VALUE_ENTITY_U
  5633. } else {
  5634. parser.attribValue += c
  5635. }
  5636. continue
  5637. }
  5638. attrib(parser)
  5639. if (c === '>') {
  5640. openTag(parser)
  5641. } else {
  5642. parser.state = S.ATTRIB
  5643. }
  5644. continue
  5645. case S.CLOSE_TAG:
  5646. if (!parser.tagName) {
  5647. if (isWhitespace(c)) {
  5648. continue
  5649. } else if (notMatch(nameStart, c)) {
  5650. if (parser.script) {
  5651. parser.script += '</' + c
  5652. parser.state = S.SCRIPT
  5653. } else {
  5654. strictFail(parser, 'Invalid tagname in closing tag.')
  5655. }
  5656. } else {
  5657. parser.tagName = c
  5658. }
  5659. } else if (c === '>') {
  5660. closeTag(parser)
  5661. } else if (isMatch(nameBody, c)) {
  5662. parser.tagName += c
  5663. } else if (parser.script) {
  5664. parser.script += '</' + parser.tagName
  5665. parser.tagName = ''
  5666. parser.state = S.SCRIPT
  5667. } else {
  5668. if (!isWhitespace(c)) {
  5669. strictFail(parser, 'Invalid tagname in closing tag')
  5670. }
  5671. parser.state = S.CLOSE_TAG_SAW_WHITE
  5672. }
  5673. continue
  5674. case S.CLOSE_TAG_SAW_WHITE:
  5675. if (isWhitespace(c)) {
  5676. continue
  5677. }
  5678. if (c === '>') {
  5679. closeTag(parser)
  5680. } else {
  5681. strictFail(parser, 'Invalid characters in closing tag')
  5682. }
  5683. continue
  5684. case S.TEXT_ENTITY:
  5685. case S.ATTRIB_VALUE_ENTITY_Q:
  5686. case S.ATTRIB_VALUE_ENTITY_U:
  5687. var returnState
  5688. var buffer
  5689. switch (parser.state) {
  5690. case S.TEXT_ENTITY:
  5691. returnState = S.TEXT
  5692. buffer = 'textNode'
  5693. break
  5694. case S.ATTRIB_VALUE_ENTITY_Q:
  5695. returnState = S.ATTRIB_VALUE_QUOTED
  5696. buffer = 'attribValue'
  5697. break
  5698. case S.ATTRIB_VALUE_ENTITY_U:
  5699. returnState = S.ATTRIB_VALUE_UNQUOTED
  5700. buffer = 'attribValue'
  5701. break
  5702. }
  5703. if (c === ';') {
  5704. var parsedEntity = parseEntity(parser)
  5705. if (parser.opt.unparsedEntities && !Object.values(sax.XML_ENTITIES).includes(parsedEntity)) {
  5706. parser.entity = ''
  5707. parser.state = returnState
  5708. parser.write(parsedEntity)
  5709. } else {
  5710. parser[buffer] += parsedEntity
  5711. parser.entity = ''
  5712. parser.state = returnState
  5713. }
  5714. } else if (isMatch(parser.entity.length ? entityBody : entityStart, c)) {
  5715. parser.entity += c
  5716. } else {
  5717. strictFail(parser, 'Invalid character in entity name')
  5718. parser[buffer] += '&' + parser.entity + c
  5719. parser.entity = ''
  5720. parser.state = returnState
  5721. }
  5722. continue
  5723. default: /* istanbul ignore next */ {
  5724. throw new Error(parser, 'Unknown state: ' + parser.state)
  5725. }
  5726. }
  5727. } // while
  5728. if (parser.position >= parser.bufferCheckPosition) {
  5729. checkBufferLength(parser)
  5730. }
  5731. return parser
  5732. }
  5733. /*! http://mths.be/fromcodepoint v0.1.0 by @mathias */
  5734. /* istanbul ignore next */
  5735. if (!String.fromCodePoint) {
  5736. (function () {
  5737. var stringFromCharCode = String.fromCharCode
  5738. var floor = Math.floor
  5739. var fromCodePoint = function () {
  5740. var MAX_SIZE = 0x4000
  5741. var codeUnits = []
  5742. var highSurrogate
  5743. var lowSurrogate
  5744. var index = -1
  5745. var length = arguments.length
  5746. if (!length) {
  5747. return ''
  5748. }
  5749. var result = ''
  5750. while (++index < length) {
  5751. var codePoint = Number(arguments[index])
  5752. if (
  5753. !isFinite(codePoint) || // `NaN`, `+Infinity`, or `-Infinity`
  5754. codePoint < 0 || // not a valid Unicode code point
  5755. codePoint > 0x10FFFF || // not a valid Unicode code point
  5756. floor(codePoint) !== codePoint // not an integer
  5757. ) {
  5758. throw RangeError('Invalid code point: ' + codePoint)
  5759. }
  5760. if (codePoint <= 0xFFFF) { // BMP code point
  5761. codeUnits.push(codePoint)
  5762. } else { // Astral code point; split in surrogate halves
  5763. // http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
  5764. codePoint -= 0x10000
  5765. highSurrogate = (codePoint >> 10) + 0xD800
  5766. lowSurrogate = (codePoint % 0x400) + 0xDC00
  5767. codeUnits.push(highSurrogate, lowSurrogate)
  5768. }
  5769. if (index + 1 === length || codeUnits.length > MAX_SIZE) {
  5770. result += stringFromCharCode.apply(null, codeUnits)
  5771. codeUnits.length = 0
  5772. }
  5773. }
  5774. return result
  5775. }
  5776. /* istanbul ignore next */
  5777. if (Object.defineProperty) {
  5778. Object.defineProperty(String, 'fromCodePoint', {
  5779. value: fromCodePoint,
  5780. configurable: true,
  5781. writable: true
  5782. })
  5783. } else {
  5784. String.fromCodePoint = fromCodePoint
  5785. }
  5786. }())
  5787. }
  5788. })(typeof exports === 'undefined' ? this.sax = {} : exports)
  5789. }).call(this)}).call(this,require("buffer").Buffer)
  5790. },{"buffer":3,"stream":28,"string_decoder":29}],28:[function(require,module,exports){
  5791. // Copyright Joyent, Inc. and other Node contributors.
  5792. //
  5793. // Permission is hereby granted, free of charge, to any person obtaining a
  5794. // copy of this software and associated documentation files (the
  5795. // "Software"), to deal in the Software without restriction, including
  5796. // without limitation the rights to use, copy, modify, merge, publish,
  5797. // distribute, sublicense, and/or sell copies of the Software, and to permit
  5798. // persons to whom the Software is furnished to do so, subject to the
  5799. // following conditions:
  5800. //
  5801. // The above copyright notice and this permission notice shall be included
  5802. // in all copies or substantial portions of the Software.
  5803. //
  5804. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  5805. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  5806. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  5807. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  5808. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  5809. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  5810. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  5811. module.exports = Stream;
  5812. var EE = require('events').EventEmitter;
  5813. var inherits = require('inherits');
  5814. inherits(Stream, EE);
  5815. Stream.Readable = require('readable-stream/readable.js');
  5816. Stream.Writable = require('readable-stream/writable.js');
  5817. Stream.Duplex = require('readable-stream/duplex.js');
  5818. Stream.Transform = require('readable-stream/transform.js');
  5819. Stream.PassThrough = require('readable-stream/passthrough.js');
  5820. // Backwards-compat with node 0.4.x
  5821. Stream.Stream = Stream;
  5822. // old-style streams. Note that the pipe method (the only relevant
  5823. // part of this class) is overridden in the Readable class.
  5824. function Stream() {
  5825. EE.call(this);
  5826. }
  5827. Stream.prototype.pipe = function(dest, options) {
  5828. var source = this;
  5829. function ondata(chunk) {
  5830. if (dest.writable) {
  5831. if (false === dest.write(chunk) && source.pause) {
  5832. source.pause();
  5833. }
  5834. }
  5835. }
  5836. source.on('data', ondata);
  5837. function ondrain() {
  5838. if (source.readable && source.resume) {
  5839. source.resume();
  5840. }
  5841. }
  5842. dest.on('drain', ondrain);
  5843. // If the 'end' option is not supplied, dest.end() will be called when
  5844. // source gets the 'end' or 'close' events. Only dest.end() once.
  5845. if (!dest._isStdio && (!options || options.end !== false)) {
  5846. source.on('end', onend);
  5847. source.on('close', onclose);
  5848. }
  5849. var didOnEnd = false;
  5850. function onend() {
  5851. if (didOnEnd) return;
  5852. didOnEnd = true;
  5853. dest.end();
  5854. }
  5855. function onclose() {
  5856. if (didOnEnd) return;
  5857. didOnEnd = true;
  5858. if (typeof dest.destroy === 'function') dest.destroy();
  5859. }
  5860. // don't leave dangling pipes when there are errors.
  5861. function onerror(er) {
  5862. cleanup();
  5863. if (EE.listenerCount(this, 'error') === 0) {
  5864. throw er; // Unhandled stream error in pipe.
  5865. }
  5866. }
  5867. source.on('error', onerror);
  5868. dest.on('error', onerror);
  5869. // remove all the event listeners that were added.
  5870. function cleanup() {
  5871. source.removeListener('data', ondata);
  5872. dest.removeListener('drain', ondrain);
  5873. source.removeListener('end', onend);
  5874. source.removeListener('close', onclose);
  5875. source.removeListener('error', onerror);
  5876. dest.removeListener('error', onerror);
  5877. source.removeListener('end', cleanup);
  5878. source.removeListener('close', cleanup);
  5879. dest.removeListener('close', cleanup);
  5880. }
  5881. source.on('end', cleanup);
  5882. source.on('close', cleanup);
  5883. dest.on('close', cleanup);
  5884. dest.emit('pipe', source);
  5885. // Allow for unix-like usage: A.pipe(B).pipe(C)
  5886. return dest;
  5887. };
  5888. },{"events":6,"inherits":8,"readable-stream/duplex.js":13,"readable-stream/passthrough.js":22,"readable-stream/readable.js":23,"readable-stream/transform.js":24,"readable-stream/writable.js":25}],29:[function(require,module,exports){
  5889. // Copyright Joyent, Inc. and other Node contributors.
  5890. //
  5891. // Permission is hereby granted, free of charge, to any person obtaining a
  5892. // copy of this software and associated documentation files (the
  5893. // "Software"), to deal in the Software without restriction, including
  5894. // without limitation the rights to use, copy, modify, merge, publish,
  5895. // distribute, sublicense, and/or sell copies of the Software, and to permit
  5896. // persons to whom the Software is furnished to do so, subject to the
  5897. // following conditions:
  5898. //
  5899. // The above copyright notice and this permission notice shall be included
  5900. // in all copies or substantial portions of the Software.
  5901. //
  5902. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  5903. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  5904. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  5905. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  5906. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  5907. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  5908. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  5909. var Buffer = require('buffer').Buffer;
  5910. var isBufferEncoding = Buffer.isEncoding
  5911. || function(encoding) {
  5912. switch (encoding && encoding.toLowerCase()) {
  5913. case 'hex': case 'utf8': case 'utf-8': case 'ascii': case 'binary': case 'base64': case 'ucs2': case 'ucs-2': case 'utf16le': case 'utf-16le': case 'raw': return true;
  5914. default: return false;
  5915. }
  5916. }
  5917. function assertEncoding(encoding) {
  5918. if (encoding && !isBufferEncoding(encoding)) {
  5919. throw new Error('Unknown encoding: ' + encoding);
  5920. }
  5921. }
  5922. // StringDecoder provides an interface for efficiently splitting a series of
  5923. // buffers into a series of JS strings without breaking apart multi-byte
  5924. // characters. CESU-8 is handled as part of the UTF-8 encoding.
  5925. //
  5926. // @TODO Handling all encodings inside a single object makes it very difficult
  5927. // to reason about this code, so it should be split up in the future.
  5928. // @TODO There should be a utf8-strict encoding that rejects invalid UTF-8 code
  5929. // points as used by CESU-8.
  5930. var StringDecoder = exports.StringDecoder = function(encoding) {
  5931. this.encoding = (encoding || 'utf8').toLowerCase().replace(/[-_]/, '');
  5932. assertEncoding(encoding);
  5933. switch (this.encoding) {
  5934. case 'utf8':
  5935. // CESU-8 represents each of Surrogate Pair by 3-bytes
  5936. this.surrogateSize = 3;
  5937. break;
  5938. case 'ucs2':
  5939. case 'utf16le':
  5940. // UTF-16 represents each of Surrogate Pair by 2-bytes
  5941. this.surrogateSize = 2;
  5942. this.detectIncompleteChar = utf16DetectIncompleteChar;
  5943. break;
  5944. case 'base64':
  5945. // Base-64 stores 3 bytes in 4 chars, and pads the remainder.
  5946. this.surrogateSize = 3;
  5947. this.detectIncompleteChar = base64DetectIncompleteChar;
  5948. break;
  5949. default:
  5950. this.write = passThroughWrite;
  5951. return;
  5952. }
  5953. // Enough space to store all bytes of a single character. UTF-8 needs 4
  5954. // bytes, but CESU-8 may require up to 6 (3 bytes per surrogate).
  5955. this.charBuffer = new Buffer(6);
  5956. // Number of bytes received for the current incomplete multi-byte character.
  5957. this.charReceived = 0;
  5958. // Number of bytes expected for the current incomplete multi-byte character.
  5959. this.charLength = 0;
  5960. };
  5961. // write decodes the given buffer and returns it as JS string that is
  5962. // guaranteed to not contain any partial multi-byte characters. Any partial
  5963. // character found at the end of the buffer is buffered up, and will be
  5964. // returned when calling write again with the remaining bytes.
  5965. //
  5966. // Note: Converting a Buffer containing an orphan surrogate to a String
  5967. // currently works, but converting a String to a Buffer (via `new Buffer`, or
  5968. // Buffer#write) will replace incomplete surrogates with the unicode
  5969. // replacement character. See https://codereview.chromium.org/121173009/ .
  5970. StringDecoder.prototype.write = function(buffer) {
  5971. var charStr = '';
  5972. // if our last write ended with an incomplete multibyte character
  5973. while (this.charLength) {
  5974. // determine how many remaining bytes this buffer has to offer for this char
  5975. var available = (buffer.length >= this.charLength - this.charReceived) ?
  5976. this.charLength - this.charReceived :
  5977. buffer.length;
  5978. // add the new bytes to the char buffer
  5979. buffer.copy(this.charBuffer, this.charReceived, 0, available);
  5980. this.charReceived += available;
  5981. if (this.charReceived < this.charLength) {
  5982. // still not enough chars in this buffer? wait for more ...
  5983. return '';
  5984. }
  5985. // remove bytes belonging to the current character from the buffer
  5986. buffer = buffer.slice(available, buffer.length);
  5987. // get the character that was split
  5988. charStr = this.charBuffer.slice(0, this.charLength).toString(this.encoding);
  5989. // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character
  5990. var charCode = charStr.charCodeAt(charStr.length - 1);
  5991. if (charCode >= 0xD800 && charCode <= 0xDBFF) {
  5992. this.charLength += this.surrogateSize;
  5993. charStr = '';
  5994. continue;
  5995. }
  5996. this.charReceived = this.charLength = 0;
  5997. // if there are no more bytes in this buffer, just emit our char
  5998. if (buffer.length === 0) {
  5999. return charStr;
  6000. }
  6001. break;
  6002. }
  6003. // determine and set charLength / charReceived
  6004. this.detectIncompleteChar(buffer);
  6005. var end = buffer.length;
  6006. if (this.charLength) {
  6007. // buffer the incomplete character bytes we got
  6008. buffer.copy(this.charBuffer, 0, buffer.length - this.charReceived, end);
  6009. end -= this.charReceived;
  6010. }
  6011. charStr += buffer.toString(this.encoding, 0, end);
  6012. var end = charStr.length - 1;
  6013. var charCode = charStr.charCodeAt(end);
  6014. // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character
  6015. if (charCode >= 0xD800 && charCode <= 0xDBFF) {
  6016. var size = this.surrogateSize;
  6017. this.charLength += size;
  6018. this.charReceived += size;
  6019. this.charBuffer.copy(this.charBuffer, size, 0, size);
  6020. buffer.copy(this.charBuffer, 0, 0, size);
  6021. return charStr.substring(0, end);
  6022. }
  6023. // or just emit the charStr
  6024. return charStr;
  6025. };
  6026. // detectIncompleteChar determines if there is an incomplete UTF-8 character at
  6027. // the end of the given buffer. If so, it sets this.charLength to the byte
  6028. // length that character, and sets this.charReceived to the number of bytes
  6029. // that are available for this character.
  6030. StringDecoder.prototype.detectIncompleteChar = function(buffer) {
  6031. // determine how many bytes we have to check at the end of this buffer
  6032. var i = (buffer.length >= 3) ? 3 : buffer.length;
  6033. // Figure out if one of the last i bytes of our buffer announces an
  6034. // incomplete char.
  6035. for (; i > 0; i--) {
  6036. var c = buffer[buffer.length - i];
  6037. // See http://en.wikipedia.org/wiki/UTF-8#Description
  6038. // 110XXXXX
  6039. if (i == 1 && c >> 5 == 0x06) {
  6040. this.charLength = 2;
  6041. break;
  6042. }
  6043. // 1110XXXX
  6044. if (i <= 2 && c >> 4 == 0x0E) {
  6045. this.charLength = 3;
  6046. break;
  6047. }
  6048. // 11110XXX
  6049. if (i <= 3 && c >> 3 == 0x1E) {
  6050. this.charLength = 4;
  6051. break;
  6052. }
  6053. }
  6054. this.charReceived = i;
  6055. };
  6056. StringDecoder.prototype.end = function(buffer) {
  6057. var res = '';
  6058. if (buffer && buffer.length)
  6059. res = this.write(buffer);
  6060. if (this.charReceived) {
  6061. var cr = this.charReceived;
  6062. var buf = this.charBuffer;
  6063. var enc = this.encoding;
  6064. res += buf.slice(0, cr).toString(enc);
  6065. }
  6066. return res;
  6067. };
  6068. function passThroughWrite(buffer) {
  6069. return buffer.toString(this.encoding);
  6070. }
  6071. function utf16DetectIncompleteChar(buffer) {
  6072. this.charReceived = buffer.length % 2;
  6073. this.charLength = this.charReceived ? 2 : 0;
  6074. }
  6075. function base64DetectIncompleteChar(buffer) {
  6076. this.charReceived = buffer.length % 3;
  6077. this.charLength = this.charReceived ? 3 : 0;
  6078. }
  6079. },{"buffer":3}],30:[function(require,module,exports){
  6080. // Copyright Joyent, Inc. and other Node contributors.
  6081. //
  6082. // Permission is hereby granted, free of charge, to any person obtaining a
  6083. // copy of this software and associated documentation files (the
  6084. // "Software"), to deal in the Software without restriction, including
  6085. // without limitation the rights to use, copy, modify, merge, publish,
  6086. // distribute, sublicense, and/or sell copies of the Software, and to permit
  6087. // persons to whom the Software is furnished to do so, subject to the
  6088. // following conditions:
  6089. //
  6090. // The above copyright notice and this permission notice shall be included
  6091. // in all copies or substantial portions of the Software.
  6092. //
  6093. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  6094. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  6095. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  6096. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  6097. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  6098. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  6099. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  6100. 'use strict';
  6101. /*<replacement>*/
  6102. var Buffer = require('safe-buffer').Buffer;
  6103. /*</replacement>*/
  6104. var isEncoding = Buffer.isEncoding || function (encoding) {
  6105. encoding = '' + encoding;
  6106. switch (encoding && encoding.toLowerCase()) {
  6107. case 'hex':case 'utf8':case 'utf-8':case 'ascii':case 'binary':case 'base64':case 'ucs2':case 'ucs-2':case 'utf16le':case 'utf-16le':case 'raw':
  6108. return true;
  6109. default:
  6110. return false;
  6111. }
  6112. };
  6113. function _normalizeEncoding(enc) {
  6114. if (!enc) return 'utf8';
  6115. var retried;
  6116. while (true) {
  6117. switch (enc) {
  6118. case 'utf8':
  6119. case 'utf-8':
  6120. return 'utf8';
  6121. case 'ucs2':
  6122. case 'ucs-2':
  6123. case 'utf16le':
  6124. case 'utf-16le':
  6125. return 'utf16le';
  6126. case 'latin1':
  6127. case 'binary':
  6128. return 'latin1';
  6129. case 'base64':
  6130. case 'ascii':
  6131. case 'hex':
  6132. return enc;
  6133. default:
  6134. if (retried) return; // undefined
  6135. enc = ('' + enc).toLowerCase();
  6136. retried = true;
  6137. }
  6138. }
  6139. };
  6140. // Do not cache `Buffer.isEncoding` when checking encoding names as some
  6141. // modules monkey-patch it to support additional encodings
  6142. function normalizeEncoding(enc) {
  6143. var nenc = _normalizeEncoding(enc);
  6144. if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc);
  6145. return nenc || enc;
  6146. }
  6147. // StringDecoder provides an interface for efficiently splitting a series of
  6148. // buffers into a series of JS strings without breaking apart multi-byte
  6149. // characters.
  6150. exports.StringDecoder = StringDecoder;
  6151. function StringDecoder(encoding) {
  6152. this.encoding = normalizeEncoding(encoding);
  6153. var nb;
  6154. switch (this.encoding) {
  6155. case 'utf16le':
  6156. this.text = utf16Text;
  6157. this.end = utf16End;
  6158. nb = 4;
  6159. break;
  6160. case 'utf8':
  6161. this.fillLast = utf8FillLast;
  6162. nb = 4;
  6163. break;
  6164. case 'base64':
  6165. this.text = base64Text;
  6166. this.end = base64End;
  6167. nb = 3;
  6168. break;
  6169. default:
  6170. this.write = simpleWrite;
  6171. this.end = simpleEnd;
  6172. return;
  6173. }
  6174. this.lastNeed = 0;
  6175. this.lastTotal = 0;
  6176. this.lastChar = Buffer.allocUnsafe(nb);
  6177. }
  6178. StringDecoder.prototype.write = function (buf) {
  6179. if (buf.length === 0) return '';
  6180. var r;
  6181. var i;
  6182. if (this.lastNeed) {
  6183. r = this.fillLast(buf);
  6184. if (r === undefined) return '';
  6185. i = this.lastNeed;
  6186. this.lastNeed = 0;
  6187. } else {
  6188. i = 0;
  6189. }
  6190. if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i);
  6191. return r || '';
  6192. };
  6193. StringDecoder.prototype.end = utf8End;
  6194. // Returns only complete characters in a Buffer
  6195. StringDecoder.prototype.text = utf8Text;
  6196. // Attempts to complete a partial non-UTF-8 character using bytes from a Buffer
  6197. StringDecoder.prototype.fillLast = function (buf) {
  6198. if (this.lastNeed <= buf.length) {
  6199. buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed);
  6200. return this.lastChar.toString(this.encoding, 0, this.lastTotal);
  6201. }
  6202. buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length);
  6203. this.lastNeed -= buf.length;
  6204. };
  6205. // Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a
  6206. // continuation byte. If an invalid byte is detected, -2 is returned.
  6207. function utf8CheckByte(byte) {
  6208. if (byte <= 0x7F) return 0;else if (byte >> 5 === 0x06) return 2;else if (byte >> 4 === 0x0E) return 3;else if (byte >> 3 === 0x1E) return 4;
  6209. return byte >> 6 === 0x02 ? -1 : -2;
  6210. }
  6211. // Checks at most 3 bytes at the end of a Buffer in order to detect an
  6212. // incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4)
  6213. // needed to complete the UTF-8 character (if applicable) are returned.
  6214. function utf8CheckIncomplete(self, buf, i) {
  6215. var j = buf.length - 1;
  6216. if (j < i) return 0;
  6217. var nb = utf8CheckByte(buf[j]);
  6218. if (nb >= 0) {
  6219. if (nb > 0) self.lastNeed = nb - 1;
  6220. return nb;
  6221. }
  6222. if (--j < i || nb === -2) return 0;
  6223. nb = utf8CheckByte(buf[j]);
  6224. if (nb >= 0) {
  6225. if (nb > 0) self.lastNeed = nb - 2;
  6226. return nb;
  6227. }
  6228. if (--j < i || nb === -2) return 0;
  6229. nb = utf8CheckByte(buf[j]);
  6230. if (nb >= 0) {
  6231. if (nb > 0) {
  6232. if (nb === 2) nb = 0;else self.lastNeed = nb - 3;
  6233. }
  6234. return nb;
  6235. }
  6236. return 0;
  6237. }
  6238. // Validates as many continuation bytes for a multi-byte UTF-8 character as
  6239. // needed or are available. If we see a non-continuation byte where we expect
  6240. // one, we "replace" the validated continuation bytes we've seen so far with
  6241. // a single UTF-8 replacement character ('\ufffd'), to match v8's UTF-8 decoding
  6242. // behavior. The continuation byte check is included three times in the case
  6243. // where all of the continuation bytes for a character exist in the same buffer.
  6244. // It is also done this way as a slight performance increase instead of using a
  6245. // loop.
  6246. function utf8CheckExtraBytes(self, buf, p) {
  6247. if ((buf[0] & 0xC0) !== 0x80) {
  6248. self.lastNeed = 0;
  6249. return '\ufffd';
  6250. }
  6251. if (self.lastNeed > 1 && buf.length > 1) {
  6252. if ((buf[1] & 0xC0) !== 0x80) {
  6253. self.lastNeed = 1;
  6254. return '\ufffd';
  6255. }
  6256. if (self.lastNeed > 2 && buf.length > 2) {
  6257. if ((buf[2] & 0xC0) !== 0x80) {
  6258. self.lastNeed = 2;
  6259. return '\ufffd';
  6260. }
  6261. }
  6262. }
  6263. }
  6264. // Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer.
  6265. function utf8FillLast(buf) {
  6266. var p = this.lastTotal - this.lastNeed;
  6267. var r = utf8CheckExtraBytes(this, buf, p);
  6268. if (r !== undefined) return r;
  6269. if (this.lastNeed <= buf.length) {
  6270. buf.copy(this.lastChar, p, 0, this.lastNeed);
  6271. return this.lastChar.toString(this.encoding, 0, this.lastTotal);
  6272. }
  6273. buf.copy(this.lastChar, p, 0, buf.length);
  6274. this.lastNeed -= buf.length;
  6275. }
  6276. // Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a
  6277. // partial character, the character's bytes are buffered until the required
  6278. // number of bytes are available.
  6279. function utf8Text(buf, i) {
  6280. var total = utf8CheckIncomplete(this, buf, i);
  6281. if (!this.lastNeed) return buf.toString('utf8', i);
  6282. this.lastTotal = total;
  6283. var end = buf.length - (total - this.lastNeed);
  6284. buf.copy(this.lastChar, 0, end);
  6285. return buf.toString('utf8', i, end);
  6286. }
  6287. // For UTF-8, a replacement character is added when ending on a partial
  6288. // character.
  6289. function utf8End(buf) {
  6290. var r = buf && buf.length ? this.write(buf) : '';
  6291. if (this.lastNeed) return r + '\ufffd';
  6292. return r;
  6293. }
  6294. // UTF-16LE typically needs two bytes per character, but even if we have an even
  6295. // number of bytes available, we need to check if we end on a leading/high
  6296. // surrogate. In that case, we need to wait for the next two bytes in order to
  6297. // decode the last character properly.
  6298. function utf16Text(buf, i) {
  6299. if ((buf.length - i) % 2 === 0) {
  6300. var r = buf.toString('utf16le', i);
  6301. if (r) {
  6302. var c = r.charCodeAt(r.length - 1);
  6303. if (c >= 0xD800 && c <= 0xDBFF) {
  6304. this.lastNeed = 2;
  6305. this.lastTotal = 4;
  6306. this.lastChar[0] = buf[buf.length - 2];
  6307. this.lastChar[1] = buf[buf.length - 1];
  6308. return r.slice(0, -1);
  6309. }
  6310. }
  6311. return r;
  6312. }
  6313. this.lastNeed = 1;
  6314. this.lastTotal = 2;
  6315. this.lastChar[0] = buf[buf.length - 1];
  6316. return buf.toString('utf16le', i, buf.length - 1);
  6317. }
  6318. // For UTF-16LE we do not explicitly append special replacement characters if we
  6319. // end on a partial character, we simply let v8 handle that.
  6320. function utf16End(buf) {
  6321. var r = buf && buf.length ? this.write(buf) : '';
  6322. if (this.lastNeed) {
  6323. var end = this.lastTotal - this.lastNeed;
  6324. return r + this.lastChar.toString('utf16le', 0, end);
  6325. }
  6326. return r;
  6327. }
  6328. function base64Text(buf, i) {
  6329. var n = (buf.length - i) % 3;
  6330. if (n === 0) return buf.toString('base64', i);
  6331. this.lastNeed = 3 - n;
  6332. this.lastTotal = 3;
  6333. if (n === 1) {
  6334. this.lastChar[0] = buf[buf.length - 1];
  6335. } else {
  6336. this.lastChar[0] = buf[buf.length - 2];
  6337. this.lastChar[1] = buf[buf.length - 1];
  6338. }
  6339. return buf.toString('base64', i, buf.length - n);
  6340. }
  6341. function base64End(buf) {
  6342. var r = buf && buf.length ? this.write(buf) : '';
  6343. if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed);
  6344. return r;
  6345. }
  6346. // Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex)
  6347. function simpleWrite(buf) {
  6348. return buf.toString(this.encoding);
  6349. }
  6350. function simpleEnd(buf) {
  6351. return buf && buf.length ? this.write(buf) : '';
  6352. }
  6353. },{"safe-buffer":26}],31:[function(require,module,exports){
  6354. (function (setImmediate,clearImmediate){(function (){
  6355. var nextTick = require('process/browser.js').nextTick;
  6356. var apply = Function.prototype.apply;
  6357. var slice = Array.prototype.slice;
  6358. var immediateIds = {};
  6359. var nextImmediateId = 0;
  6360. // DOM APIs, for completeness
  6361. exports.setTimeout = function() {
  6362. return new Timeout(apply.call(setTimeout, window, arguments), clearTimeout);
  6363. };
  6364. exports.setInterval = function() {
  6365. return new Timeout(apply.call(setInterval, window, arguments), clearInterval);
  6366. };
  6367. exports.clearTimeout =
  6368. exports.clearInterval = function(timeout) { timeout.close(); };
  6369. function Timeout(id, clearFn) {
  6370. this._id = id;
  6371. this._clearFn = clearFn;
  6372. }
  6373. Timeout.prototype.unref = Timeout.prototype.ref = function() {};
  6374. Timeout.prototype.close = function() {
  6375. this._clearFn.call(window, this._id);
  6376. };
  6377. // Does not start the time, just sets up the members needed.
  6378. exports.enroll = function(item, msecs) {
  6379. clearTimeout(item._idleTimeoutId);
  6380. item._idleTimeout = msecs;
  6381. };
  6382. exports.unenroll = function(item) {
  6383. clearTimeout(item._idleTimeoutId);
  6384. item._idleTimeout = -1;
  6385. };
  6386. exports._unrefActive = exports.active = function(item) {
  6387. clearTimeout(item._idleTimeoutId);
  6388. var msecs = item._idleTimeout;
  6389. if (msecs >= 0) {
  6390. item._idleTimeoutId = setTimeout(function onTimeout() {
  6391. if (item._onTimeout)
  6392. item._onTimeout();
  6393. }, msecs);
  6394. }
  6395. };
  6396. // That's not how node.js implements it but the exposed api is the same.
  6397. exports.setImmediate = typeof setImmediate === "function" ? setImmediate : function(fn) {
  6398. var id = nextImmediateId++;
  6399. var args = arguments.length < 2 ? false : slice.call(arguments, 1);
  6400. immediateIds[id] = true;
  6401. nextTick(function onNextTick() {
  6402. if (immediateIds[id]) {
  6403. // fn.call() is faster so we optimize for the common use-case
  6404. // @see http://jsperf.com/call-apply-segu
  6405. if (args) {
  6406. fn.apply(null, args);
  6407. } else {
  6408. fn.call(null);
  6409. }
  6410. // Prevent ids from leaking
  6411. exports.clearImmediate(id);
  6412. }
  6413. });
  6414. return id;
  6415. };
  6416. exports.clearImmediate = typeof clearImmediate === "function" ? clearImmediate : function(id) {
  6417. delete immediateIds[id];
  6418. };
  6419. }).call(this)}).call(this,require("timers").setImmediate,require("timers").clearImmediate)
  6420. },{"process/browser.js":12,"timers":31}],32:[function(require,module,exports){
  6421. (function (global){(function (){
  6422. /**
  6423. * Module exports.
  6424. */
  6425. module.exports = deprecate;
  6426. /**
  6427. * Mark that a method should not be used.
  6428. * Returns a modified function which warns once by default.
  6429. *
  6430. * If `localStorage.noDeprecation = true` is set, then it is a no-op.
  6431. *
  6432. * If `localStorage.throwDeprecation = true` is set, then deprecated functions
  6433. * will throw an Error when invoked.
  6434. *
  6435. * If `localStorage.traceDeprecation = true` is set, then deprecated functions
  6436. * will invoke `console.trace()` instead of `console.error()`.
  6437. *
  6438. * @param {Function} fn - the function to deprecate
  6439. * @param {String} msg - the string to print to the console when `fn` is invoked
  6440. * @returns {Function} a new "deprecated" version of `fn`
  6441. * @api public
  6442. */
  6443. function deprecate (fn, msg) {
  6444. if (config('noDeprecation')) {
  6445. return fn;
  6446. }
  6447. var warned = false;
  6448. function deprecated() {
  6449. if (!warned) {
  6450. if (config('throwDeprecation')) {
  6451. throw new Error(msg);
  6452. } else if (config('traceDeprecation')) {
  6453. console.trace(msg);
  6454. } else {
  6455. console.warn(msg);
  6456. }
  6457. warned = true;
  6458. }
  6459. return fn.apply(this, arguments);
  6460. }
  6461. return deprecated;
  6462. }
  6463. /**
  6464. * Checks `localStorage` for boolean values for the given `name`.
  6465. *
  6466. * @param {String} name
  6467. * @returns {Boolean}
  6468. * @api private
  6469. */
  6470. function config (name) {
  6471. // accessing global.localStorage can trigger a DOMException in sandboxed iframes
  6472. try {
  6473. if (!global.localStorage) return false;
  6474. } catch (_) {
  6475. return false;
  6476. }
  6477. var val = global.localStorage[name];
  6478. if (null == val) return false;
  6479. return String(val).toLowerCase() === 'true';
  6480. }
  6481. }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  6482. },{}],33:[function(require,module,exports){
  6483. module.exports = {
  6484. isArray: function(value) {
  6485. if (Array.isArray) {
  6486. return Array.isArray(value);
  6487. }
  6488. // fallback for older browsers like IE 8
  6489. return Object.prototype.toString.call( value ) === '[object Array]';
  6490. }
  6491. };
  6492. },{}],34:[function(require,module,exports){
  6493. /*jslint node:true */
  6494. var xml2js = require('./xml2js');
  6495. var xml2json = require('./xml2json');
  6496. var js2xml = require('./js2xml');
  6497. var json2xml = require('./json2xml');
  6498. module.exports = {
  6499. xml2js: xml2js,
  6500. xml2json: xml2json,
  6501. js2xml: js2xml,
  6502. json2xml: json2xml
  6503. };
  6504. },{"./js2xml":35,"./json2xml":36,"./xml2js":38,"./xml2json":39}],35:[function(require,module,exports){
  6505. var helper = require('./options-helper');
  6506. var isArray = require('./array-helper').isArray;
  6507. var currentElement, currentElementName;
  6508. function validateOptions(userOptions) {
  6509. var options = helper.copyOptions(userOptions);
  6510. helper.ensureFlagExists('ignoreDeclaration', options);
  6511. helper.ensureFlagExists('ignoreInstruction', options);
  6512. helper.ensureFlagExists('ignoreAttributes', options);
  6513. helper.ensureFlagExists('ignoreText', options);
  6514. helper.ensureFlagExists('ignoreComment', options);
  6515. helper.ensureFlagExists('ignoreCdata', options);
  6516. helper.ensureFlagExists('ignoreDoctype', options);
  6517. helper.ensureFlagExists('compact', options);
  6518. helper.ensureFlagExists('indentText', options);
  6519. helper.ensureFlagExists('indentCdata', options);
  6520. helper.ensureFlagExists('indentAttributes', options);
  6521. helper.ensureFlagExists('indentInstruction', options);
  6522. helper.ensureFlagExists('fullTagEmptyElement', options);
  6523. helper.ensureFlagExists('noQuotesForNativeAttributes', options);
  6524. helper.ensureSpacesExists(options);
  6525. if (typeof options.spaces === 'number') {
  6526. options.spaces = Array(options.spaces + 1).join(' ');
  6527. }
  6528. helper.ensureKeyExists('declaration', options);
  6529. helper.ensureKeyExists('instruction', options);
  6530. helper.ensureKeyExists('attributes', options);
  6531. helper.ensureKeyExists('text', options);
  6532. helper.ensureKeyExists('comment', options);
  6533. helper.ensureKeyExists('cdata', options);
  6534. helper.ensureKeyExists('doctype', options);
  6535. helper.ensureKeyExists('type', options);
  6536. helper.ensureKeyExists('name', options);
  6537. helper.ensureKeyExists('elements', options);
  6538. helper.checkFnExists('doctype', options);
  6539. helper.checkFnExists('instruction', options);
  6540. helper.checkFnExists('cdata', options);
  6541. helper.checkFnExists('comment', options);
  6542. helper.checkFnExists('text', options);
  6543. helper.checkFnExists('instructionName', options);
  6544. helper.checkFnExists('elementName', options);
  6545. helper.checkFnExists('attributeName', options);
  6546. helper.checkFnExists('attributeValue', options);
  6547. helper.checkFnExists('attributes', options);
  6548. helper.checkFnExists('fullTagEmptyElement', options);
  6549. return options;
  6550. }
  6551. function writeIndentation(options, depth, firstLine) {
  6552. return (!firstLine && options.spaces ? '\n' : '') + Array(depth + 1).join(options.spaces);
  6553. }
  6554. function writeAttributes(attributes, options, depth) {
  6555. if (options.ignoreAttributes) {
  6556. return '';
  6557. }
  6558. if ('attributesFn' in options) {
  6559. attributes = options.attributesFn(attributes, currentElementName, currentElement);
  6560. }
  6561. var key, attr, attrName, quote, result = [];
  6562. for (key in attributes) {
  6563. if (attributes.hasOwnProperty(key) && attributes[key] !== null && attributes[key] !== undefined) {
  6564. quote = options.noQuotesForNativeAttributes && typeof attributes[key] !== 'string' ? '' : '"';
  6565. attr = '' + attributes[key]; // ensure number and boolean are converted to String
  6566. attr = attr.replace(/"/g, '&quot;');
  6567. attrName = 'attributeNameFn' in options ? options.attributeNameFn(key, attr, currentElementName, currentElement) : key;
  6568. result.push((options.spaces && options.indentAttributes? writeIndentation(options, depth+1, false) : ' '));
  6569. result.push(attrName + '=' + quote + ('attributeValueFn' in options ? options.attributeValueFn(attr, key, currentElementName, currentElement) : attr) + quote);
  6570. }
  6571. }
  6572. if (attributes && Object.keys(attributes).length && options.spaces && options.indentAttributes) {
  6573. result.push(writeIndentation(options, depth, false));
  6574. }
  6575. return result.join('');
  6576. }
  6577. function writeDeclaration(declaration, options, depth) {
  6578. currentElement = declaration;
  6579. currentElementName = 'xml';
  6580. return options.ignoreDeclaration ? '' : '<?' + 'xml' + writeAttributes(declaration[options.attributesKey], options, depth) + '?>';
  6581. }
  6582. function writeInstruction(instruction, options, depth) {
  6583. if (options.ignoreInstruction) {
  6584. return '';
  6585. }
  6586. var key;
  6587. for (key in instruction) {
  6588. if (instruction.hasOwnProperty(key)) {
  6589. break;
  6590. }
  6591. }
  6592. var instructionName = 'instructionNameFn' in options ? options.instructionNameFn(key, instruction[key], currentElementName, currentElement) : key;
  6593. if (typeof instruction[key] === 'object') {
  6594. currentElement = instruction;
  6595. currentElementName = instructionName;
  6596. return '<?' + instructionName + writeAttributes(instruction[key][options.attributesKey], options, depth) + '?>';
  6597. } else {
  6598. var instructionValue = instruction[key] ? instruction[key] : '';
  6599. if ('instructionFn' in options) instructionValue = options.instructionFn(instructionValue, key, currentElementName, currentElement);
  6600. return '<?' + instructionName + (instructionValue ? ' ' + instructionValue : '') + '?>';
  6601. }
  6602. }
  6603. function writeComment(comment, options) {
  6604. return options.ignoreComment ? '' : '<!--' + ('commentFn' in options ? options.commentFn(comment, currentElementName, currentElement) : comment) + '-->';
  6605. }
  6606. function writeCdata(cdata, options) {
  6607. return options.ignoreCdata ? '' : '<![CDATA[' + ('cdataFn' in options ? options.cdataFn(cdata, currentElementName, currentElement) : cdata.replace(']]>', ']]]]><![CDATA[>')) + ']]>';
  6608. }
  6609. function writeDoctype(doctype, options) {
  6610. return options.ignoreDoctype ? '' : '<!DOCTYPE ' + ('doctypeFn' in options ? options.doctypeFn(doctype, currentElementName, currentElement) : doctype) + '>';
  6611. }
  6612. function writeText(text, options) {
  6613. if (options.ignoreText) return '';
  6614. text = '' + text; // ensure Number and Boolean are converted to String
  6615. text = text.replace(/&amp;/g, '&'); // desanitize to avoid double sanitization
  6616. text = text.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
  6617. return 'textFn' in options ? options.textFn(text, currentElementName, currentElement) : text;
  6618. }
  6619. function hasContent(element, options) {
  6620. var i;
  6621. if (element.elements && element.elements.length) {
  6622. for (i = 0; i < element.elements.length; ++i) {
  6623. switch (element.elements[i][options.typeKey]) {
  6624. case 'text':
  6625. if (options.indentText) {
  6626. return true;
  6627. }
  6628. break; // skip to next key
  6629. case 'cdata':
  6630. if (options.indentCdata) {
  6631. return true;
  6632. }
  6633. break; // skip to next key
  6634. case 'instruction':
  6635. if (options.indentInstruction) {
  6636. return true;
  6637. }
  6638. break; // skip to next key
  6639. case 'doctype':
  6640. case 'comment':
  6641. case 'element':
  6642. return true;
  6643. default:
  6644. return true;
  6645. }
  6646. }
  6647. }
  6648. return false;
  6649. }
  6650. function writeElement(element, options, depth) {
  6651. currentElement = element;
  6652. currentElementName = element.name;
  6653. var xml = [], elementName = 'elementNameFn' in options ? options.elementNameFn(element.name, element) : element.name;
  6654. xml.push('<' + elementName);
  6655. if (element[options.attributesKey]) {
  6656. xml.push(writeAttributes(element[options.attributesKey], options, depth));
  6657. }
  6658. var withClosingTag = element[options.elementsKey] && element[options.elementsKey].length || element[options.attributesKey] && element[options.attributesKey]['xml:space'] === 'preserve';
  6659. if (!withClosingTag) {
  6660. if ('fullTagEmptyElementFn' in options) {
  6661. withClosingTag = options.fullTagEmptyElementFn(element.name, element);
  6662. } else {
  6663. withClosingTag = options.fullTagEmptyElement;
  6664. }
  6665. }
  6666. if (withClosingTag) {
  6667. xml.push('>');
  6668. if (element[options.elementsKey] && element[options.elementsKey].length) {
  6669. xml.push(writeElements(element[options.elementsKey], options, depth + 1));
  6670. currentElement = element;
  6671. currentElementName = element.name;
  6672. }
  6673. xml.push(options.spaces && hasContent(element, options) ? '\n' + Array(depth + 1).join(options.spaces) : '');
  6674. xml.push('</' + elementName + '>');
  6675. } else {
  6676. xml.push('/>');
  6677. }
  6678. return xml.join('');
  6679. }
  6680. function writeElements(elements, options, depth, firstLine) {
  6681. return elements.reduce(function (xml, element) {
  6682. var indent = writeIndentation(options, depth, firstLine && !xml);
  6683. switch (element.type) {
  6684. case 'element': return xml + indent + writeElement(element, options, depth);
  6685. case 'comment': return xml + indent + writeComment(element[options.commentKey], options);
  6686. case 'doctype': return xml + indent + writeDoctype(element[options.doctypeKey], options);
  6687. case 'cdata': return xml + (options.indentCdata ? indent : '') + writeCdata(element[options.cdataKey], options);
  6688. case 'text': return xml + (options.indentText ? indent : '') + writeText(element[options.textKey], options);
  6689. case 'instruction':
  6690. var instruction = {};
  6691. instruction[element[options.nameKey]] = element[options.attributesKey] ? element : element[options.instructionKey];
  6692. return xml + (options.indentInstruction ? indent : '') + writeInstruction(instruction, options, depth);
  6693. }
  6694. }, '');
  6695. }
  6696. function hasContentCompact(element, options, anyContent) {
  6697. var key;
  6698. for (key in element) {
  6699. if (element.hasOwnProperty(key)) {
  6700. switch (key) {
  6701. case options.parentKey:
  6702. case options.attributesKey:
  6703. break; // skip to next key
  6704. case options.textKey:
  6705. if (options.indentText || anyContent) {
  6706. return true;
  6707. }
  6708. break; // skip to next key
  6709. case options.cdataKey:
  6710. if (options.indentCdata || anyContent) {
  6711. return true;
  6712. }
  6713. break; // skip to next key
  6714. case options.instructionKey:
  6715. if (options.indentInstruction || anyContent) {
  6716. return true;
  6717. }
  6718. break; // skip to next key
  6719. case options.doctypeKey:
  6720. case options.commentKey:
  6721. return true;
  6722. default:
  6723. return true;
  6724. }
  6725. }
  6726. }
  6727. return false;
  6728. }
  6729. function writeElementCompact(element, name, options, depth, indent) {
  6730. currentElement = element;
  6731. currentElementName = name;
  6732. var elementName = 'elementNameFn' in options ? options.elementNameFn(name, element) : name;
  6733. if (typeof element === 'undefined' || element === null || element === '') {
  6734. return 'fullTagEmptyElementFn' in options && options.fullTagEmptyElementFn(name, element) || options.fullTagEmptyElement ? '<' + elementName + '></' + elementName + '>' : '<' + elementName + '/>';
  6735. }
  6736. var xml = [];
  6737. if (name) {
  6738. xml.push('<' + elementName);
  6739. if (typeof element !== 'object') {
  6740. xml.push('>' + writeText(element,options) + '</' + elementName + '>');
  6741. return xml.join('');
  6742. }
  6743. if (element[options.attributesKey]) {
  6744. xml.push(writeAttributes(element[options.attributesKey], options, depth));
  6745. }
  6746. var withClosingTag = hasContentCompact(element, options, true) || element[options.attributesKey] && element[options.attributesKey]['xml:space'] === 'preserve';
  6747. if (!withClosingTag) {
  6748. if ('fullTagEmptyElementFn' in options) {
  6749. withClosingTag = options.fullTagEmptyElementFn(name, element);
  6750. } else {
  6751. withClosingTag = options.fullTagEmptyElement;
  6752. }
  6753. }
  6754. if (withClosingTag) {
  6755. xml.push('>');
  6756. } else {
  6757. xml.push('/>');
  6758. return xml.join('');
  6759. }
  6760. }
  6761. xml.push(writeElementsCompact(element, options, depth + 1, false));
  6762. currentElement = element;
  6763. currentElementName = name;
  6764. if (name) {
  6765. xml.push((indent ? writeIndentation(options, depth, false) : '') + '</' + elementName + '>');
  6766. }
  6767. return xml.join('');
  6768. }
  6769. function writeElementsCompact(element, options, depth, firstLine) {
  6770. var i, key, nodes, xml = [];
  6771. for (key in element) {
  6772. if (element.hasOwnProperty(key)) {
  6773. nodes = isArray(element[key]) ? element[key] : [element[key]];
  6774. for (i = 0; i < nodes.length; ++i) {
  6775. switch (key) {
  6776. case options.declarationKey: xml.push(writeDeclaration(nodes[i], options, depth)); break;
  6777. case options.instructionKey: xml.push((options.indentInstruction ? writeIndentation(options, depth, firstLine) : '') + writeInstruction(nodes[i], options, depth)); break;
  6778. case options.attributesKey: case options.parentKey: break; // skip
  6779. case options.textKey: xml.push((options.indentText ? writeIndentation(options, depth, firstLine) : '') + writeText(nodes[i], options)); break;
  6780. case options.cdataKey: xml.push((options.indentCdata ? writeIndentation(options, depth, firstLine) : '') + writeCdata(nodes[i], options)); break;
  6781. case options.doctypeKey: xml.push(writeIndentation(options, depth, firstLine) + writeDoctype(nodes[i], options)); break;
  6782. case options.commentKey: xml.push(writeIndentation(options, depth, firstLine) + writeComment(nodes[i], options)); break;
  6783. default: xml.push(writeIndentation(options, depth, firstLine) + writeElementCompact(nodes[i], key, options, depth, hasContentCompact(nodes[i], options)));
  6784. }
  6785. firstLine = firstLine && !xml.length;
  6786. }
  6787. }
  6788. }
  6789. return xml.join('');
  6790. }
  6791. module.exports = function (js, options) {
  6792. options = validateOptions(options);
  6793. var xml = [];
  6794. currentElement = js;
  6795. currentElementName = '_root_';
  6796. if (options.compact) {
  6797. xml.push(writeElementsCompact(js, options, 0, true));
  6798. } else {
  6799. if (js[options.declarationKey]) {
  6800. xml.push(writeDeclaration(js[options.declarationKey], options, 0));
  6801. }
  6802. if (js[options.elementsKey] && js[options.elementsKey].length) {
  6803. xml.push(writeElements(js[options.elementsKey], options, 0, !xml.length));
  6804. }
  6805. }
  6806. return xml.join('');
  6807. };
  6808. },{"./array-helper":33,"./options-helper":37}],36:[function(require,module,exports){
  6809. (function (Buffer){(function (){
  6810. var js2xml = require('./js2xml.js');
  6811. module.exports = function (json, options) {
  6812. if (json instanceof Buffer) {
  6813. json = json.toString();
  6814. }
  6815. var js = null;
  6816. if (typeof (json) === 'string') {
  6817. try {
  6818. js = JSON.parse(json);
  6819. } catch (e) {
  6820. throw new Error('The JSON structure is invalid');
  6821. }
  6822. } else {
  6823. js = json;
  6824. }
  6825. return js2xml(js, options);
  6826. };
  6827. }).call(this)}).call(this,require("buffer").Buffer)
  6828. },{"./js2xml.js":35,"buffer":3}],37:[function(require,module,exports){
  6829. var isArray = require('./array-helper').isArray;
  6830. module.exports = {
  6831. copyOptions: function (options) {
  6832. var key, copy = {};
  6833. for (key in options) {
  6834. if (options.hasOwnProperty(key)) {
  6835. copy[key] = options[key];
  6836. }
  6837. }
  6838. return copy;
  6839. },
  6840. ensureFlagExists: function (item, options) {
  6841. if (!(item in options) || typeof options[item] !== 'boolean') {
  6842. options[item] = false;
  6843. }
  6844. },
  6845. ensureSpacesExists: function (options) {
  6846. if (!('spaces' in options) || (typeof options.spaces !== 'number' && typeof options.spaces !== 'string')) {
  6847. options.spaces = 0;
  6848. }
  6849. },
  6850. ensureAlwaysArrayExists: function (options) {
  6851. if (!('alwaysArray' in options) || (typeof options.alwaysArray !== 'boolean' && !isArray(options.alwaysArray))) {
  6852. options.alwaysArray = false;
  6853. }
  6854. },
  6855. ensureKeyExists: function (key, options) {
  6856. if (!(key + 'Key' in options) || typeof options[key + 'Key'] !== 'string') {
  6857. options[key + 'Key'] = options.compact ? '_' + key : key;
  6858. }
  6859. },
  6860. checkFnExists: function (key, options) {
  6861. return key + 'Fn' in options;
  6862. }
  6863. };
  6864. },{"./array-helper":33}],38:[function(require,module,exports){
  6865. var sax = require('sax');
  6866. var expat /*= require('node-expat');*/ = { on: function () { }, parse: function () { } };
  6867. var helper = require('./options-helper');
  6868. var isArray = require('./array-helper').isArray;
  6869. var options;
  6870. var pureJsParser = true;
  6871. var currentElement;
  6872. function validateOptions(userOptions) {
  6873. options = helper.copyOptions(userOptions);
  6874. helper.ensureFlagExists('ignoreDeclaration', options);
  6875. helper.ensureFlagExists('ignoreInstruction', options);
  6876. helper.ensureFlagExists('ignoreAttributes', options);
  6877. helper.ensureFlagExists('ignoreText', options);
  6878. helper.ensureFlagExists('ignoreComment', options);
  6879. helper.ensureFlagExists('ignoreCdata', options);
  6880. helper.ensureFlagExists('ignoreDoctype', options);
  6881. helper.ensureFlagExists('compact', options);
  6882. helper.ensureFlagExists('alwaysChildren', options);
  6883. helper.ensureFlagExists('addParent', options);
  6884. helper.ensureFlagExists('trim', options);
  6885. helper.ensureFlagExists('nativeType', options);
  6886. helper.ensureFlagExists('nativeTypeAttributes', options);
  6887. helper.ensureFlagExists('sanitize', options);
  6888. helper.ensureFlagExists('instructionHasAttributes', options);
  6889. helper.ensureFlagExists('captureSpacesBetweenElements', options);
  6890. helper.ensureAlwaysArrayExists(options);
  6891. helper.ensureKeyExists('declaration', options);
  6892. helper.ensureKeyExists('instruction', options);
  6893. helper.ensureKeyExists('attributes', options);
  6894. helper.ensureKeyExists('text', options);
  6895. helper.ensureKeyExists('comment', options);
  6896. helper.ensureKeyExists('cdata', options);
  6897. helper.ensureKeyExists('doctype', options);
  6898. helper.ensureKeyExists('type', options);
  6899. helper.ensureKeyExists('name', options);
  6900. helper.ensureKeyExists('elements', options);
  6901. helper.ensureKeyExists('parent', options);
  6902. helper.checkFnExists('doctype', options);
  6903. helper.checkFnExists('instruction', options);
  6904. helper.checkFnExists('cdata', options);
  6905. helper.checkFnExists('comment', options);
  6906. helper.checkFnExists('text', options);
  6907. helper.checkFnExists('instructionName', options);
  6908. helper.checkFnExists('elementName', options);
  6909. helper.checkFnExists('attributeName', options);
  6910. helper.checkFnExists('attributeValue', options);
  6911. helper.checkFnExists('attributes', options);
  6912. return options;
  6913. }
  6914. function nativeType(value) {
  6915. var nValue = Number(value);
  6916. if (!isNaN(nValue)) {
  6917. return nValue;
  6918. }
  6919. var bValue = value.toLowerCase();
  6920. if (bValue === 'true') {
  6921. return true;
  6922. } else if (bValue === 'false') {
  6923. return false;
  6924. }
  6925. return value;
  6926. }
  6927. function addField(type, value) {
  6928. var key;
  6929. if (options.compact) {
  6930. if (
  6931. !currentElement[options[type + 'Key']] &&
  6932. (isArray(options.alwaysArray) ? options.alwaysArray.indexOf(options[type + 'Key']) !== -1 : options.alwaysArray)
  6933. ) {
  6934. currentElement[options[type + 'Key']] = [];
  6935. }
  6936. if (currentElement[options[type + 'Key']] && !isArray(currentElement[options[type + 'Key']])) {
  6937. currentElement[options[type + 'Key']] = [currentElement[options[type + 'Key']]];
  6938. }
  6939. if (type + 'Fn' in options && typeof value === 'string') {
  6940. value = options[type + 'Fn'](value, currentElement);
  6941. }
  6942. if (type === 'instruction' && ('instructionFn' in options || 'instructionNameFn' in options)) {
  6943. for (key in value) {
  6944. if (value.hasOwnProperty(key)) {
  6945. if ('instructionFn' in options) {
  6946. value[key] = options.instructionFn(value[key], key, currentElement);
  6947. } else {
  6948. var temp = value[key];
  6949. delete value[key];
  6950. value[options.instructionNameFn(key, temp, currentElement)] = temp;
  6951. }
  6952. }
  6953. }
  6954. }
  6955. if (isArray(currentElement[options[type + 'Key']])) {
  6956. currentElement[options[type + 'Key']].push(value);
  6957. } else {
  6958. currentElement[options[type + 'Key']] = value;
  6959. }
  6960. } else {
  6961. if (!currentElement[options.elementsKey]) {
  6962. currentElement[options.elementsKey] = [];
  6963. }
  6964. var element = {};
  6965. element[options.typeKey] = type;
  6966. if (type === 'instruction') {
  6967. for (key in value) {
  6968. if (value.hasOwnProperty(key)) {
  6969. break;
  6970. }
  6971. }
  6972. element[options.nameKey] = 'instructionNameFn' in options ? options.instructionNameFn(key, value, currentElement) : key;
  6973. if (options.instructionHasAttributes) {
  6974. element[options.attributesKey] = value[key][options.attributesKey];
  6975. if ('instructionFn' in options) {
  6976. element[options.attributesKey] = options.instructionFn(element[options.attributesKey], key, currentElement);
  6977. }
  6978. } else {
  6979. if ('instructionFn' in options) {
  6980. value[key] = options.instructionFn(value[key], key, currentElement);
  6981. }
  6982. element[options.instructionKey] = value[key];
  6983. }
  6984. } else {
  6985. if (type + 'Fn' in options) {
  6986. value = options[type + 'Fn'](value, currentElement);
  6987. }
  6988. element[options[type + 'Key']] = value;
  6989. }
  6990. if (options.addParent) {
  6991. element[options.parentKey] = currentElement;
  6992. }
  6993. currentElement[options.elementsKey].push(element);
  6994. }
  6995. }
  6996. function manipulateAttributes(attributes) {
  6997. if ('attributesFn' in options && attributes) {
  6998. attributes = options.attributesFn(attributes, currentElement);
  6999. }
  7000. if ((options.trim || 'attributeValueFn' in options || 'attributeNameFn' in options || options.nativeTypeAttributes) && attributes) {
  7001. var key;
  7002. for (key in attributes) {
  7003. if (attributes.hasOwnProperty(key)) {
  7004. if (options.trim) attributes[key] = attributes[key].trim();
  7005. if (options.nativeTypeAttributes) {
  7006. attributes[key] = nativeType(attributes[key]);
  7007. }
  7008. if ('attributeValueFn' in options) attributes[key] = options.attributeValueFn(attributes[key], key, currentElement);
  7009. if ('attributeNameFn' in options) {
  7010. var temp = attributes[key];
  7011. delete attributes[key];
  7012. attributes[options.attributeNameFn(key, attributes[key], currentElement)] = temp;
  7013. }
  7014. }
  7015. }
  7016. }
  7017. return attributes;
  7018. }
  7019. function onInstruction(instruction) {
  7020. var attributes = {};
  7021. if (instruction.body && (instruction.name.toLowerCase() === 'xml' || options.instructionHasAttributes)) {
  7022. var attrsRegExp = /([\w:-]+)\s*=\s*(?:"([^"]*)"|'([^']*)'|(\w+))\s*/g;
  7023. var match;
  7024. while ((match = attrsRegExp.exec(instruction.body)) !== null) {
  7025. attributes[match[1]] = match[2] || match[3] || match[4];
  7026. }
  7027. attributes = manipulateAttributes(attributes);
  7028. }
  7029. if (instruction.name.toLowerCase() === 'xml') {
  7030. if (options.ignoreDeclaration) {
  7031. return;
  7032. }
  7033. currentElement[options.declarationKey] = {};
  7034. if (Object.keys(attributes).length) {
  7035. currentElement[options.declarationKey][options.attributesKey] = attributes;
  7036. }
  7037. if (options.addParent) {
  7038. currentElement[options.declarationKey][options.parentKey] = currentElement;
  7039. }
  7040. } else {
  7041. if (options.ignoreInstruction) {
  7042. return;
  7043. }
  7044. if (options.trim) {
  7045. instruction.body = instruction.body.trim();
  7046. }
  7047. var value = {};
  7048. if (options.instructionHasAttributes && Object.keys(attributes).length) {
  7049. value[instruction.name] = {};
  7050. value[instruction.name][options.attributesKey] = attributes;
  7051. } else {
  7052. value[instruction.name] = instruction.body;
  7053. }
  7054. addField('instruction', value);
  7055. }
  7056. }
  7057. function onStartElement(name, attributes) {
  7058. var element;
  7059. if (typeof name === 'object') {
  7060. attributes = name.attributes;
  7061. name = name.name;
  7062. }
  7063. attributes = manipulateAttributes(attributes);
  7064. if ('elementNameFn' in options) {
  7065. name = options.elementNameFn(name, currentElement);
  7066. }
  7067. if (options.compact) {
  7068. element = {};
  7069. if (!options.ignoreAttributes && attributes && Object.keys(attributes).length) {
  7070. element[options.attributesKey] = {};
  7071. var key;
  7072. for (key in attributes) {
  7073. if (attributes.hasOwnProperty(key)) {
  7074. element[options.attributesKey][key] = attributes[key];
  7075. }
  7076. }
  7077. }
  7078. if (
  7079. !(name in currentElement) &&
  7080. (isArray(options.alwaysArray) ? options.alwaysArray.indexOf(name) !== -1 : options.alwaysArray)
  7081. ) {
  7082. currentElement[name] = [];
  7083. }
  7084. if (currentElement[name] && !isArray(currentElement[name])) {
  7085. currentElement[name] = [currentElement[name]];
  7086. }
  7087. if (isArray(currentElement[name])) {
  7088. currentElement[name].push(element);
  7089. } else {
  7090. currentElement[name] = element;
  7091. }
  7092. } else {
  7093. if (!currentElement[options.elementsKey]) {
  7094. currentElement[options.elementsKey] = [];
  7095. }
  7096. element = {};
  7097. element[options.typeKey] = 'element';
  7098. element[options.nameKey] = name;
  7099. if (!options.ignoreAttributes && attributes && Object.keys(attributes).length) {
  7100. element[options.attributesKey] = attributes;
  7101. }
  7102. if (options.alwaysChildren) {
  7103. element[options.elementsKey] = [];
  7104. }
  7105. currentElement[options.elementsKey].push(element);
  7106. }
  7107. element[options.parentKey] = currentElement; // will be deleted in onEndElement() if !options.addParent
  7108. currentElement = element;
  7109. }
  7110. function onText(text) {
  7111. if (options.ignoreText) {
  7112. return;
  7113. }
  7114. if (!text.trim() && !options.captureSpacesBetweenElements) {
  7115. return;
  7116. }
  7117. if (options.trim) {
  7118. text = text.trim();
  7119. }
  7120. if (options.nativeType) {
  7121. text = nativeType(text);
  7122. }
  7123. if (options.sanitize) {
  7124. text = text.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
  7125. }
  7126. addField('text', text);
  7127. }
  7128. function onComment(comment) {
  7129. if (options.ignoreComment) {
  7130. return;
  7131. }
  7132. if (options.trim) {
  7133. comment = comment.trim();
  7134. }
  7135. addField('comment', comment);
  7136. }
  7137. function onEndElement(name) {
  7138. var parentElement = currentElement[options.parentKey];
  7139. if (!options.addParent) {
  7140. delete currentElement[options.parentKey];
  7141. }
  7142. currentElement = parentElement;
  7143. }
  7144. function onCdata(cdata) {
  7145. if (options.ignoreCdata) {
  7146. return;
  7147. }
  7148. if (options.trim) {
  7149. cdata = cdata.trim();
  7150. }
  7151. addField('cdata', cdata);
  7152. }
  7153. function onDoctype(doctype) {
  7154. if (options.ignoreDoctype) {
  7155. return;
  7156. }
  7157. doctype = doctype.replace(/^ /, '');
  7158. if (options.trim) {
  7159. doctype = doctype.trim();
  7160. }
  7161. addField('doctype', doctype);
  7162. }
  7163. function onError(error) {
  7164. error.note = error; //console.error(error);
  7165. }
  7166. module.exports = function (xml, userOptions) {
  7167. var parser = pureJsParser ? sax.parser(true, {}) : parser = new expat.Parser('UTF-8');
  7168. var result = {};
  7169. currentElement = result;
  7170. options = validateOptions(userOptions);
  7171. if (pureJsParser) {
  7172. parser.opt = {strictEntities: true};
  7173. parser.onopentag = onStartElement;
  7174. parser.ontext = onText;
  7175. parser.oncomment = onComment;
  7176. parser.onclosetag = onEndElement;
  7177. parser.onerror = onError;
  7178. parser.oncdata = onCdata;
  7179. parser.ondoctype = onDoctype;
  7180. parser.onprocessinginstruction = onInstruction;
  7181. } else {
  7182. parser.on('startElement', onStartElement);
  7183. parser.on('text', onText);
  7184. parser.on('comment', onComment);
  7185. parser.on('endElement', onEndElement);
  7186. parser.on('error', onError);
  7187. //parser.on('startCdata', onStartCdata);
  7188. //parser.on('endCdata', onEndCdata);
  7189. //parser.on('entityDecl', onEntityDecl);
  7190. }
  7191. if (pureJsParser) {
  7192. parser.write(xml).close();
  7193. } else {
  7194. if (!parser.parse(xml)) {
  7195. throw new Error('XML parsing error: ' + parser.getError());
  7196. }
  7197. }
  7198. if (result[options.elementsKey]) {
  7199. var temp = result[options.elementsKey];
  7200. delete result[options.elementsKey];
  7201. result[options.elementsKey] = temp;
  7202. delete result.text;
  7203. }
  7204. return result;
  7205. };
  7206. },{"./array-helper":33,"./options-helper":37,"sax":27}],39:[function(require,module,exports){
  7207. var helper = require('./options-helper');
  7208. var xml2js = require('./xml2js');
  7209. function validateOptions (userOptions) {
  7210. var options = helper.copyOptions(userOptions);
  7211. helper.ensureSpacesExists(options);
  7212. return options;
  7213. }
  7214. module.exports = function(xml, userOptions) {
  7215. var options, js, json, parentKey;
  7216. options = validateOptions(userOptions);
  7217. js = xml2js(xml, options);
  7218. parentKey = 'compact' in options && options.compact ? '_parent' : 'parent';
  7219. // parentKey = ptions.compact ? '_parent' : 'parent'; // consider this
  7220. if ('addParent' in options && options.addParent) {
  7221. json = JSON.stringify(js, function (k, v) { return k === parentKey? '_' : v; }, options.spaces);
  7222. } else {
  7223. json = JSON.stringify(js, null, options.spaces);
  7224. }
  7225. return json.replace(/\u2028/g, '\\u2028').replace(/\u2029/g, '\\u2029');
  7226. };
  7227. },{"./options-helper":37,"./xml2js":38}],40:[function(require,module,exports){
  7228. "use strict";
  7229. var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
  7230. return mod && mod.__esModule ? mod : {
  7231. "default": mod
  7232. };
  7233. };
  7234. Object.defineProperty(exports, "__esModule", {
  7235. value: true
  7236. });
  7237. exports.HandleZip = void 0;
  7238. var jszip_1 = __importDefault(require("jszip"));
  7239. var method_1 = require("./common/method");
  7240. var HandleZip = /** @class */function () {
  7241. function HandleZip(file) {
  7242. // Support nodejs fs to read files
  7243. // if(file instanceof File){
  7244. this.uploadFile = file;
  7245. // }
  7246. }
  7247. HandleZip.prototype.unzipFile = function (successFunc, errorFunc) {
  7248. // var new_zip:JSZip = new JSZip();
  7249. jszip_1["default"].loadAsync(this.uploadFile) // 1) read the Blob
  7250. .then(function (zip) {
  7251. var fileList = {},
  7252. lastIndex = Object.keys(zip.files).length,
  7253. index = 0;
  7254. zip.forEach(function (relativePath, zipEntry) {
  7255. var fileName = zipEntry.name;
  7256. var fileNameArr = fileName.split(".");
  7257. var suffix = fileNameArr[fileNameArr.length - 1].toLowerCase();
  7258. var fileType = "string";
  7259. if (suffix in {
  7260. "png": 1,
  7261. "jpeg": 1,
  7262. "jpg": 1,
  7263. "gif": 1,
  7264. "bmp": 1,
  7265. "tif": 1,
  7266. "webp": 1
  7267. }) {
  7268. fileType = "base64";
  7269. } else if (suffix == "emf") {
  7270. fileType = "arraybuffer";
  7271. }
  7272. zipEntry.async(fileType).then(function (data) {
  7273. if (fileType == "base64") {
  7274. data = "data:image/" + suffix + ";base64," + data;
  7275. }
  7276. fileList[zipEntry.name] = data;
  7277. // console.log(lastIndex, index);
  7278. if (lastIndex == index + 1) {
  7279. successFunc(fileList);
  7280. }
  7281. index++;
  7282. });
  7283. });
  7284. }, function (e) {
  7285. errorFunc(e);
  7286. });
  7287. };
  7288. HandleZip.prototype.unzipFileByUrl = function (url, successFunc, errorFunc) {
  7289. var new_zip = new jszip_1["default"]();
  7290. method_1.getBinaryContent(url, function (err, data) {
  7291. if (err) {
  7292. throw err; // or handle err
  7293. }
  7294. jszip_1["default"].loadAsync(data).then(function (zip) {
  7295. var fileList = {},
  7296. lastIndex = Object.keys(zip.files).length,
  7297. index = 0;
  7298. zip.forEach(function (relativePath, zipEntry) {
  7299. var fileName = zipEntry.name;
  7300. var fileNameArr = fileName.split(".");
  7301. var suffix = fileNameArr[fileNameArr.length - 1].toLowerCase();
  7302. var fileType = "string";
  7303. if (suffix in {
  7304. "png": 1,
  7305. "jpeg": 1,
  7306. "jpg": 1,
  7307. "gif": 1,
  7308. "bmp": 1,
  7309. "tif": 1,
  7310. "webp": 1
  7311. }) {
  7312. fileType = "base64";
  7313. } else if (suffix == "emf") {
  7314. fileType = "arraybuffer";
  7315. }
  7316. zipEntry.async(fileType).then(function (data) {
  7317. if (fileType == "base64") {
  7318. data = "data:image/" + suffix + ";base64," + data;
  7319. }
  7320. fileList[zipEntry.name] = data;
  7321. // console.log(lastIndex, index);
  7322. if (lastIndex == index + 1) {
  7323. successFunc(fileList);
  7324. }
  7325. index++;
  7326. });
  7327. });
  7328. }, function (e) {
  7329. errorFunc(e);
  7330. });
  7331. });
  7332. };
  7333. HandleZip.prototype.newZipFile = function () {
  7334. var zip = new jszip_1["default"]();
  7335. this.workBook = zip;
  7336. };
  7337. //title:"nested/hello.txt", content:"Hello Worldasdfasfasdfasfasfasfasfasdfas"
  7338. HandleZip.prototype.addToZipFile = function (title, content) {
  7339. if (this.workBook == null) {
  7340. var zip = new jszip_1["default"]();
  7341. this.workBook = zip;
  7342. }
  7343. this.workBook.file(title, content);
  7344. };
  7345. return HandleZip;
  7346. }();
  7347. exports.HandleZip = HandleZip;
  7348. },{"./common/method":49,"jszip":10}],41:[function(require,module,exports){
  7349. "use strict";
  7350. Object.defineProperty(exports, "__esModule", {
  7351. value: true
  7352. });
  7353. exports.LuckyImageBase = exports.LuckysheetCalcChain = exports.LuckySheetConfigMerge = exports.LuckySheetborderInfoCellValueStyle = exports.LuckySheetborderInfoCellValue = exports.LuckySheetborderInfoCellForImp = exports.LuckyConfig = exports.LuckyInlineString = exports.LuckySheetCellFormat = exports.LuckySheetCelldataValue = exports.LuckySheetCelldataBase = exports.LuckyFileInfo = exports.LuckySheetBase = exports.LuckyFileBase = void 0;
  7354. var LuckyFileBase = /** @class */function () {
  7355. function LuckyFileBase() {}
  7356. return LuckyFileBase;
  7357. }();
  7358. exports.LuckyFileBase = LuckyFileBase;
  7359. var LuckySheetBase = /** @class */function () {
  7360. function LuckySheetBase() {}
  7361. return LuckySheetBase;
  7362. }();
  7363. exports.LuckySheetBase = LuckySheetBase;
  7364. var LuckyFileInfo = /** @class */function () {
  7365. function LuckyFileInfo() {}
  7366. return LuckyFileInfo;
  7367. }();
  7368. exports.LuckyFileInfo = LuckyFileInfo;
  7369. var LuckySheetCelldataBase = /** @class */function () {
  7370. function LuckySheetCelldataBase() {}
  7371. return LuckySheetCelldataBase;
  7372. }();
  7373. exports.LuckySheetCelldataBase = LuckySheetCelldataBase;
  7374. var LuckySheetCelldataValue = /** @class */function () {
  7375. function LuckySheetCelldataValue() {}
  7376. return LuckySheetCelldataValue;
  7377. }();
  7378. exports.LuckySheetCelldataValue = LuckySheetCelldataValue;
  7379. var LuckySheetCellFormat = /** @class */function () {
  7380. function LuckySheetCellFormat() {}
  7381. return LuckySheetCellFormat;
  7382. }();
  7383. exports.LuckySheetCellFormat = LuckySheetCellFormat;
  7384. var LuckyInlineString = /** @class */function () {
  7385. function LuckyInlineString() {}
  7386. return LuckyInlineString;
  7387. }();
  7388. exports.LuckyInlineString = LuckyInlineString;
  7389. var LuckyConfig = /** @class */function () {
  7390. function LuckyConfig() {}
  7391. return LuckyConfig;
  7392. }();
  7393. exports.LuckyConfig = LuckyConfig;
  7394. var LuckySheetborderInfoCellForImp = /** @class */function () {
  7395. function LuckySheetborderInfoCellForImp() {}
  7396. return LuckySheetborderInfoCellForImp;
  7397. }();
  7398. exports.LuckySheetborderInfoCellForImp = LuckySheetborderInfoCellForImp;
  7399. var LuckySheetborderInfoCellValue = /** @class */function () {
  7400. function LuckySheetborderInfoCellValue() {}
  7401. return LuckySheetborderInfoCellValue;
  7402. }();
  7403. exports.LuckySheetborderInfoCellValue = LuckySheetborderInfoCellValue;
  7404. var LuckySheetborderInfoCellValueStyle = /** @class */function () {
  7405. function LuckySheetborderInfoCellValueStyle() {}
  7406. return LuckySheetborderInfoCellValueStyle;
  7407. }();
  7408. exports.LuckySheetborderInfoCellValueStyle = LuckySheetborderInfoCellValueStyle;
  7409. var LuckySheetConfigMerge = /** @class */function () {
  7410. function LuckySheetConfigMerge() {}
  7411. return LuckySheetConfigMerge;
  7412. }();
  7413. exports.LuckySheetConfigMerge = LuckySheetConfigMerge;
  7414. var LuckysheetCalcChain = /** @class */function () {
  7415. function LuckysheetCalcChain() {}
  7416. return LuckysheetCalcChain;
  7417. }();
  7418. exports.LuckysheetCalcChain = LuckysheetCalcChain;
  7419. var LuckyImageBase = /** @class */function () {
  7420. function LuckyImageBase() {}
  7421. return LuckyImageBase;
  7422. }();
  7423. exports.LuckyImageBase = LuckyImageBase;
  7424. },{}],42:[function(require,module,exports){
  7425. "use strict";
  7426. var __extends = void 0 && (void 0).__extends || function () {
  7427. var _extendStatics = function extendStatics(d, b) {
  7428. _extendStatics = Object.setPrototypeOf || {
  7429. __proto__: []
  7430. } instanceof Array && function (d, b) {
  7431. d.__proto__ = b;
  7432. } || function (d, b) {
  7433. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  7434. };
  7435. return _extendStatics(d, b);
  7436. };
  7437. return function (d, b) {
  7438. _extendStatics(d, b);
  7439. function __() {
  7440. this.constructor = d;
  7441. }
  7442. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  7443. };
  7444. }();
  7445. Object.defineProperty(exports, "__esModule", {
  7446. value: true
  7447. });
  7448. exports.LuckySheetCelldata = void 0;
  7449. var ReadXml_1 = require("./ReadXml");
  7450. var method_1 = require("../common/method");
  7451. var constant_1 = require("../common/constant");
  7452. var LuckyBase_1 = require("./LuckyBase");
  7453. var LuckySheetCelldata = /** @class */function (_super) {
  7454. __extends(LuckySheetCelldata, _super);
  7455. function LuckySheetCelldata(cell, styles, sharedStrings, mergeCells, sheetFile, ReadXml) {
  7456. var _this =
  7457. //Private
  7458. _super.call(this) || this;
  7459. _this.cell = cell;
  7460. _this.sheetFile = sheetFile;
  7461. _this.styles = styles;
  7462. _this.sharedStrings = sharedStrings;
  7463. _this.readXml = ReadXml;
  7464. _this.mergeCells = mergeCells;
  7465. var attrList = cell.attributeList;
  7466. var r = attrList.r,
  7467. s = attrList.s,
  7468. t = attrList.t;
  7469. var range = method_1.getcellrange(r);
  7470. _this.r = range.row[0];
  7471. _this.c = range.column[0];
  7472. _this.v = _this.generateValue(s, t);
  7473. return _this;
  7474. }
  7475. /**
  7476. * @param s Style index ,start 1
  7477. * @param t Cell type, Optional value is ST_CellType, it's found at constat.ts
  7478. */
  7479. LuckySheetCelldata.prototype.generateValue = function (s, t) {
  7480. var _this = this;
  7481. var v = this.cell.getInnerElements("v");
  7482. var f = this.cell.getInnerElements("f");
  7483. if (v == null) {
  7484. v = this.cell.getInnerElements("t");
  7485. }
  7486. var cellXfs = this.styles["cellXfs"];
  7487. var cellStyleXfs = this.styles["cellStyleXfs"];
  7488. var cellStyles = this.styles["cellStyles"];
  7489. var fonts = this.styles["fonts"];
  7490. var fills = this.styles["fills"];
  7491. var borders = this.styles["borders"];
  7492. var numfmts = this.styles["numfmts"];
  7493. var clrScheme = this.styles["clrScheme"];
  7494. var sharedStrings = this.sharedStrings;
  7495. var cellValue = new LuckyBase_1.LuckySheetCelldataValue();
  7496. if (f != null) {
  7497. var formula = f[0],
  7498. attrList = formula.attributeList;
  7499. var t_1 = attrList.t,
  7500. ref = attrList.ref,
  7501. si = attrList.si;
  7502. var formulaValue = f[0].value;
  7503. if (t_1 == "shared") {
  7504. this._fomulaRef = ref;
  7505. this._formulaType = t_1;
  7506. this._formulaSi = si;
  7507. }
  7508. // console.log(ref, t, si);
  7509. if (ref != null || formulaValue != null && formulaValue.length > 0) {
  7510. formulaValue = method_1.escapeCharacter(formulaValue);
  7511. cellValue.f = "=" + formulaValue;
  7512. }
  7513. }
  7514. var familyFont = null;
  7515. var quotePrefix;
  7516. if (s != null) {
  7517. var sNum = parseInt(s);
  7518. var cellXf = cellXfs[sNum];
  7519. var xfId = cellXf.attributeList.xfId;
  7520. var numFmtId = void 0,
  7521. fontId = void 0,
  7522. fillId = void 0,
  7523. borderId = void 0;
  7524. var horizontal = void 0,
  7525. vertical = void 0,
  7526. wrapText = void 0,
  7527. textRotation = void 0,
  7528. shrinkToFit = void 0,
  7529. indent = void 0,
  7530. applyProtection = void 0;
  7531. if (xfId != null) {
  7532. var cellStyleXf = cellStyleXfs[parseInt(xfId)];
  7533. var attrList = cellStyleXf.attributeList;
  7534. var applyNumberFormat_1 = attrList.applyNumberFormat;
  7535. var applyFont_1 = attrList.applyFont;
  7536. var applyFill_1 = attrList.applyFill;
  7537. var applyBorder_1 = attrList.applyBorder;
  7538. var applyAlignment_1 = attrList.applyAlignment;
  7539. // let applyProtection = attrList.applyProtection;
  7540. applyProtection = attrList.applyProtection;
  7541. quotePrefix = attrList.quotePrefix;
  7542. if (applyNumberFormat_1 != "0" && attrList.numFmtId != null) {
  7543. // if(attrList.numFmtId!="0"){
  7544. numFmtId = attrList.numFmtId;
  7545. // }
  7546. }
  7547. if (applyFont_1 != "0" && attrList.fontId != null) {
  7548. fontId = attrList.fontId;
  7549. }
  7550. if (applyFill_1 != "0" && attrList.fillId != null) {
  7551. fillId = attrList.fillId;
  7552. }
  7553. if (applyBorder_1 != "0" && attrList.borderId != null) {
  7554. borderId = attrList.borderId;
  7555. }
  7556. if (applyAlignment_1 != null && applyAlignment_1 != "0") {
  7557. var alignment = cellStyleXf.getInnerElements("alignment");
  7558. if (alignment != null) {
  7559. var attrList_1 = alignment[0].attributeList;
  7560. if (attrList_1.horizontal != null) {
  7561. horizontal = attrList_1.horizontal;
  7562. }
  7563. if (attrList_1.vertical != null) {
  7564. vertical = attrList_1.vertical;
  7565. }
  7566. if (attrList_1.wrapText != null) {
  7567. wrapText = attrList_1.wrapText;
  7568. }
  7569. if (attrList_1.textRotation != null) {
  7570. textRotation = attrList_1.textRotation;
  7571. }
  7572. if (attrList_1.shrinkToFit != null) {
  7573. shrinkToFit = attrList_1.shrinkToFit;
  7574. }
  7575. if (attrList_1.indent != null) {
  7576. indent = attrList_1.indent;
  7577. }
  7578. }
  7579. }
  7580. }
  7581. var applyNumberFormat = cellXf.attributeList.applyNumberFormat;
  7582. var applyFont = cellXf.attributeList.applyFont;
  7583. var applyFill = cellXf.attributeList.applyFill;
  7584. var applyBorder = cellXf.attributeList.applyBorder;
  7585. var applyAlignment = cellXf.attributeList.applyAlignment;
  7586. if (cellXf.attributeList.applyProtection != null) {
  7587. applyProtection = cellXf.attributeList.applyProtection;
  7588. }
  7589. if (cellXf.attributeList.quotePrefix != null) {
  7590. quotePrefix = cellXf.attributeList.quotePrefix;
  7591. }
  7592. if (applyNumberFormat != "0" && cellXf.attributeList.numFmtId != null) {
  7593. numFmtId = cellXf.attributeList.numFmtId;
  7594. }
  7595. if (applyFont != "0") {
  7596. fontId = cellXf.attributeList.fontId;
  7597. }
  7598. if (applyFill != "0") {
  7599. fillId = cellXf.attributeList.fillId;
  7600. }
  7601. if (applyBorder != "0") {
  7602. borderId = cellXf.attributeList.borderId;
  7603. }
  7604. if (applyAlignment != "0") {
  7605. var alignment = cellXf.getInnerElements("alignment");
  7606. if (alignment != null && alignment.length > 0) {
  7607. var attrList = alignment[0].attributeList;
  7608. if (attrList.horizontal != null) {
  7609. horizontal = attrList.horizontal;
  7610. }
  7611. if (attrList.vertical != null) {
  7612. vertical = attrList.vertical;
  7613. }
  7614. if (attrList.wrapText != null) {
  7615. wrapText = attrList.wrapText;
  7616. }
  7617. if (attrList.textRotation != null) {
  7618. textRotation = attrList.textRotation;
  7619. }
  7620. if (attrList.shrinkToFit != null) {
  7621. shrinkToFit = attrList.shrinkToFit;
  7622. }
  7623. if (attrList.indent != null) {
  7624. indent = attrList.indent;
  7625. }
  7626. }
  7627. }
  7628. if (numFmtId != undefined) {
  7629. var numf = numfmts[parseInt(numFmtId)];
  7630. var cellFormat = new LuckyBase_1.LuckySheetCellFormat();
  7631. cellFormat.fa = method_1.escapeCharacter(numf);
  7632. // console.log(numf, numFmtId, this.v);
  7633. cellFormat.t = t || 'd';
  7634. cellValue.ct = cellFormat;
  7635. }
  7636. if (fillId != undefined) {
  7637. var fillIdNum = parseInt(fillId);
  7638. var fill = fills[fillIdNum];
  7639. // console.log(cellValue.v);
  7640. var bg = this.getBackgroundByFill(fill, clrScheme);
  7641. if (bg != null) {
  7642. cellValue.bg = bg;
  7643. }
  7644. }
  7645. if (fontId != undefined) {
  7646. var fontIdNum = parseInt(fontId);
  7647. var font = fonts[fontIdNum];
  7648. if (font != null) {
  7649. var sz = font.getInnerElements("sz"); //font size
  7650. var colors = font.getInnerElements("color"); //font color
  7651. var family = font.getInnerElements("name"); //font family
  7652. var familyOverrides = font.getInnerElements("family"); //font family will be overrided by name
  7653. var charset = font.getInnerElements("charset"); //font charset
  7654. var bolds = font.getInnerElements("b"); //font bold
  7655. var italics = font.getInnerElements("i"); //font italic
  7656. var strikes = font.getInnerElements("strike"); //font italic
  7657. var underlines = font.getInnerElements("u"); //font italic
  7658. if (sz != null && sz.length > 0) {
  7659. var fs = sz[0].attributeList.val;
  7660. if (fs != null) {
  7661. cellValue.fs = parseInt(fs);
  7662. }
  7663. }
  7664. if (colors != null && colors.length > 0) {
  7665. var color = colors[0];
  7666. var fc = ReadXml_1.getColor(color, this.styles, "t");
  7667. if (fc != null) {
  7668. cellValue.fc = fc;
  7669. }
  7670. }
  7671. if (familyOverrides != null && familyOverrides.length > 0) {
  7672. var val = familyOverrides[0].attributeList.val;
  7673. if (val != null) {
  7674. familyFont = constant_1.fontFamilys[val];
  7675. }
  7676. }
  7677. if (family != null && family.length > 0) {
  7678. var val = family[0].attributeList.val;
  7679. if (val != null) {
  7680. cellValue.ff = val;
  7681. }
  7682. }
  7683. if (bolds != null && bolds.length > 0) {
  7684. var bold = bolds[0].attributeList.val;
  7685. if (bold == "0") {
  7686. cellValue.bl = 0;
  7687. } else {
  7688. cellValue.bl = 1;
  7689. }
  7690. }
  7691. if (italics != null && italics.length > 0) {
  7692. var italic = italics[0].attributeList.val;
  7693. if (italic == "0") {
  7694. cellValue.it = 0;
  7695. } else {
  7696. cellValue.it = 1;
  7697. }
  7698. }
  7699. if (strikes != null && strikes.length > 0) {
  7700. var strike = strikes[0].attributeList.val;
  7701. if (strike == "0") {
  7702. cellValue.cl = 0;
  7703. } else {
  7704. cellValue.cl = 1;
  7705. }
  7706. }
  7707. if (underlines != null && underlines.length > 0) {
  7708. var underline = underlines[0].attributeList.val;
  7709. if (underline == "single") {
  7710. cellValue.un = 1;
  7711. } else if (underline == "double") {
  7712. cellValue.un = 2;
  7713. } else if (underline == "singleAccounting") {
  7714. cellValue.un = 3;
  7715. } else if (underline == "doubleAccounting") {
  7716. cellValue.un = 4;
  7717. } else {
  7718. cellValue.un = 0;
  7719. }
  7720. }
  7721. }
  7722. }
  7723. // vt: number | undefined//Vertical alignment, 0 middle, 1 up, 2 down, alignment
  7724. // ht: number | undefined//Horizontal alignment,0 center, 1 left, 2 right, alignment
  7725. // tr: number | undefined //Text rotation,0: 0、1: 45 、2: -45、3 Vertical text、4: 90 、5: -90, alignment
  7726. // tb: number | undefined //Text wrap,0 truncation, 1 overflow, 2 word wrap, alignment
  7727. if (horizontal != undefined) {
  7728. //Horizontal alignment
  7729. if (horizontal == "center") {
  7730. cellValue.ht = 0;
  7731. } else if (horizontal == "centerContinuous") {
  7732. cellValue.ht = 0; //luckysheet unsupport
  7733. } else if (horizontal == "left") {
  7734. cellValue.ht = 1;
  7735. } else if (horizontal == "right") {
  7736. cellValue.ht = 2;
  7737. } else if (horizontal == "distributed") {
  7738. cellValue.ht = 0; //luckysheet unsupport
  7739. } else if (horizontal == "fill") {
  7740. cellValue.ht = 1; //luckysheet unsupport
  7741. } else if (horizontal == "general") {
  7742. cellValue.ht = 1; //luckysheet unsupport
  7743. } else if (horizontal == "justify") {
  7744. cellValue.ht = 0; //luckysheet unsupport
  7745. } else {
  7746. cellValue.ht = 1;
  7747. }
  7748. }
  7749. if (vertical != undefined) {
  7750. //Vertical alignment
  7751. if (vertical == "bottom") {
  7752. cellValue.vt = 2;
  7753. } else if (vertical == "center") {
  7754. cellValue.vt = 0;
  7755. } else if (vertical == "distributed") {
  7756. cellValue.vt = 0; //luckysheet unsupport
  7757. } else if (vertical == "justify") {
  7758. cellValue.vt = 0; //luckysheet unsupport
  7759. } else if (vertical == "top") {
  7760. cellValue.vt = 1;
  7761. } else {
  7762. cellValue.vt = 1;
  7763. }
  7764. } else {
  7765. //sometimes bottom style is lost after setting it in excel
  7766. //when vertical is undefined set it to 2.
  7767. cellValue.vt = 2;
  7768. }
  7769. if (wrapText != undefined) {
  7770. if (wrapText == "1") {
  7771. cellValue.tb = 2;
  7772. } else {
  7773. cellValue.tb = 1;
  7774. }
  7775. } else {
  7776. cellValue.tb = 1;
  7777. }
  7778. if (textRotation != undefined) {
  7779. // tr: number | undefined //Text rotation,0: 0、1: 45 、2: -45、3 Vertical text、4: 90 、5: -90, alignment
  7780. if (textRotation == "255") {
  7781. cellValue.tr = 3;
  7782. }
  7783. // else if(textRotation=="45"){
  7784. // cellValue.tr = 1;
  7785. // }
  7786. // else if(textRotation=="90"){
  7787. // cellValue.tr = 4;
  7788. // }
  7789. // else if(textRotation=="135"){
  7790. // cellValue.tr = 2;
  7791. // }
  7792. // else if(textRotation=="180"){
  7793. // cellValue.tr = 5;
  7794. // }
  7795. else {
  7796. cellValue.tr = 0;
  7797. cellValue.rt = parseInt(textRotation);
  7798. }
  7799. }
  7800. if (shrinkToFit != undefined) {//luckysheet unsupport
  7801. }
  7802. if (indent != undefined) {//luckysheet unsupport
  7803. }
  7804. if (borderId != undefined) {
  7805. var borderIdNum = parseInt(borderId);
  7806. var border = borders[borderIdNum];
  7807. // this._borderId = borderIdNum;
  7808. var borderObject = new LuckyBase_1.LuckySheetborderInfoCellForImp();
  7809. borderObject.rangeType = "cell";
  7810. // borderObject.cells = [];
  7811. var borderCellValue = new LuckyBase_1.LuckySheetborderInfoCellValue();
  7812. borderCellValue.row_index = this.r;
  7813. borderCellValue.col_index = this.c;
  7814. var lefts = border.getInnerElements("left");
  7815. var rights = border.getInnerElements("right");
  7816. var tops = border.getInnerElements("top");
  7817. var bottoms = border.getInnerElements("bottom");
  7818. var diagonals = border.getInnerElements("diagonal");
  7819. var starts = border.getInnerElements("start");
  7820. var ends = border.getInnerElements("end");
  7821. var left = this.getBorderInfo(lefts);
  7822. var right = this.getBorderInfo(rights);
  7823. var top_1 = this.getBorderInfo(tops);
  7824. var bottom = this.getBorderInfo(bottoms);
  7825. var diagonal = this.getBorderInfo(diagonals);
  7826. var start = this.getBorderInfo(starts);
  7827. var end = this.getBorderInfo(ends);
  7828. var isAdd = false;
  7829. if (start != null && start.color != null) {
  7830. borderCellValue.l = start;
  7831. isAdd = true;
  7832. }
  7833. if (end != null && end.color != null) {
  7834. borderCellValue.r = end;
  7835. isAdd = true;
  7836. }
  7837. if (left != null && left.color != null) {
  7838. borderCellValue.l = left;
  7839. isAdd = true;
  7840. }
  7841. if (right != null && right.color != null) {
  7842. borderCellValue.r = right;
  7843. isAdd = true;
  7844. }
  7845. if (top_1 != null && top_1.color != null) {
  7846. borderCellValue.t = top_1;
  7847. isAdd = true;
  7848. }
  7849. if (bottom != null && bottom.color != null) {
  7850. borderCellValue.b = bottom;
  7851. isAdd = true;
  7852. }
  7853. if (isAdd) {
  7854. borderObject.value = borderCellValue;
  7855. // this.config._borderInfo[borderId] = borderObject;
  7856. this._borderObject = borderObject;
  7857. }
  7858. }
  7859. } else {
  7860. cellValue.tb = 1;
  7861. }
  7862. if (v != null) {
  7863. var value = v[0].value;
  7864. if (/&#\d+;/.test(value)) {
  7865. value = this.htmlDecode(value);
  7866. }
  7867. if (t == constant_1.ST_CellType["SharedString"]) {
  7868. var siIndex = parseInt(v[0].value);
  7869. var sharedSI = sharedStrings[siIndex];
  7870. var rFlag = sharedSI.getInnerElements("r");
  7871. if (rFlag == null) {
  7872. var tFlag = sharedSI.getInnerElements("t");
  7873. if (tFlag != null) {
  7874. var text_1 = "";
  7875. tFlag.forEach(function (t) {
  7876. text_1 += t.value;
  7877. });
  7878. text_1 = method_1.escapeCharacter(text_1);
  7879. //isContainMultiType(text) &&
  7880. if (familyFont == "Roman" && text_1.length > 0) {
  7881. var textArray = text_1.split("");
  7882. var preWordType = null,
  7883. wordText = "",
  7884. preWholef = null;
  7885. var wholef = "Times New Roman";
  7886. if (cellValue.ff != null) {
  7887. wholef = cellValue.ff;
  7888. }
  7889. var cellFormat = cellValue.ct;
  7890. if (cellFormat == null) {
  7891. cellFormat = new LuckyBase_1.LuckySheetCellFormat();
  7892. }
  7893. if (cellFormat.s == null) {
  7894. cellFormat.s = [];
  7895. }
  7896. for (var i = 0; i < textArray.length; i++) {
  7897. var w = textArray[i];
  7898. var type = null,
  7899. ff = wholef;
  7900. if (method_1.isChinese(w)) {
  7901. type = "c";
  7902. ff = "宋体";
  7903. } else if (method_1.isJapanese(w)) {
  7904. type = "j";
  7905. ff = "Yu Gothic";
  7906. } else if (method_1.isKoera(w)) {
  7907. type = "k";
  7908. ff = "Malgun Gothic";
  7909. } else {
  7910. type = "e";
  7911. }
  7912. if (type != preWordType && preWordType != null || i == textArray.length - 1) {
  7913. var InlineString = new LuckyBase_1.LuckyInlineString();
  7914. InlineString.ff = preWholef;
  7915. if (cellValue.fc != null) {
  7916. InlineString.fc = cellValue.fc;
  7917. }
  7918. if (cellValue.fs != null) {
  7919. InlineString.fs = cellValue.fs;
  7920. }
  7921. if (cellValue.cl != null) {
  7922. InlineString.cl = cellValue.cl;
  7923. }
  7924. if (cellValue.un != null) {
  7925. InlineString.un = cellValue.un;
  7926. }
  7927. if (cellValue.bl != null) {
  7928. InlineString.bl = cellValue.bl;
  7929. }
  7930. if (cellValue.it != null) {
  7931. InlineString.it = cellValue.it;
  7932. }
  7933. if (i == textArray.length - 1) {
  7934. if (type == preWordType) {
  7935. InlineString.ff = ff;
  7936. InlineString.v = wordText + w;
  7937. } else {
  7938. InlineString.ff = preWholef;
  7939. InlineString.v = wordText;
  7940. cellFormat.s.push(InlineString);
  7941. var InlineStringLast = new LuckyBase_1.LuckyInlineString();
  7942. InlineStringLast.ff = ff;
  7943. InlineStringLast.v = w;
  7944. if (cellValue.fc != null) {
  7945. InlineStringLast.fc = cellValue.fc;
  7946. }
  7947. if (cellValue.fs != null) {
  7948. InlineStringLast.fs = cellValue.fs;
  7949. }
  7950. if (cellValue.cl != null) {
  7951. InlineStringLast.cl = cellValue.cl;
  7952. }
  7953. if (cellValue.un != null) {
  7954. InlineStringLast.un = cellValue.un;
  7955. }
  7956. if (cellValue.bl != null) {
  7957. InlineStringLast.bl = cellValue.bl;
  7958. }
  7959. if (cellValue.it != null) {
  7960. InlineStringLast.it = cellValue.it;
  7961. }
  7962. cellFormat.s.push(InlineStringLast);
  7963. break;
  7964. }
  7965. } else {
  7966. InlineString.v = wordText;
  7967. }
  7968. cellFormat.s.push(InlineString);
  7969. wordText = w;
  7970. } else {
  7971. wordText += w;
  7972. }
  7973. preWordType = type;
  7974. preWholef = ff;
  7975. }
  7976. cellFormat.t = "inlineStr";
  7977. // cellFormat.s = [InlineString];
  7978. cellValue.ct = cellFormat;
  7979. // console.log(cellValue);
  7980. } else {
  7981. text_1 = this.replaceSpecialWrap(text_1);
  7982. if (text_1.indexOf("\r\n") > -1 || text_1.indexOf("\n") > -1) {
  7983. var InlineString = new LuckyBase_1.LuckyInlineString();
  7984. InlineString.v = text_1;
  7985. var cellFormat = cellValue.ct;
  7986. if (cellFormat == null) {
  7987. cellFormat = new LuckyBase_1.LuckySheetCellFormat();
  7988. }
  7989. if (cellValue.ff != null) {
  7990. InlineString.ff = cellValue.ff;
  7991. }
  7992. if (cellValue.fc != null) {
  7993. InlineString.fc = cellValue.fc;
  7994. }
  7995. if (cellValue.fs != null) {
  7996. InlineString.fs = cellValue.fs;
  7997. }
  7998. if (cellValue.cl != null) {
  7999. InlineString.cl = cellValue.cl;
  8000. }
  8001. if (cellValue.un != null) {
  8002. InlineString.un = cellValue.un;
  8003. }
  8004. if (cellValue.bl != null) {
  8005. InlineString.bl = cellValue.bl;
  8006. }
  8007. if (cellValue.it != null) {
  8008. InlineString.it = cellValue.it;
  8009. }
  8010. cellFormat.t = "inlineStr";
  8011. cellFormat.s = [InlineString];
  8012. cellValue.ct = cellFormat;
  8013. } else {
  8014. cellValue.v = text_1;
  8015. quotePrefix = "1";
  8016. }
  8017. }
  8018. }
  8019. } else {
  8020. var styles_1 = [];
  8021. rFlag.forEach(function (r) {
  8022. var tFlag = r.getInnerElements("t");
  8023. var rPr = r.getInnerElements("rPr");
  8024. var InlineString = new LuckyBase_1.LuckyInlineString();
  8025. if (tFlag != null && tFlag.length > 0) {
  8026. var text = tFlag[0].value;
  8027. text = _this.replaceSpecialWrap(text);
  8028. text = method_1.escapeCharacter(text);
  8029. InlineString.v = text;
  8030. }
  8031. if (rPr != null && rPr.length > 0) {
  8032. var frpr = rPr[0];
  8033. var sz = ReadXml_1.getlineStringAttr(frpr, "sz"),
  8034. rFont = ReadXml_1.getlineStringAttr(frpr, "rFont"),
  8035. family = ReadXml_1.getlineStringAttr(frpr, "family"),
  8036. charset = ReadXml_1.getlineStringAttr(frpr, "charset"),
  8037. scheme = ReadXml_1.getlineStringAttr(frpr, "scheme"),
  8038. b = ReadXml_1.getlineStringAttr(frpr, "b"),
  8039. i = ReadXml_1.getlineStringAttr(frpr, "i"),
  8040. u = ReadXml_1.getlineStringAttr(frpr, "u"),
  8041. strike = ReadXml_1.getlineStringAttr(frpr, "strike"),
  8042. vertAlign = ReadXml_1.getlineStringAttr(frpr, "vertAlign"),
  8043. color = void 0;
  8044. var cEle = frpr.getInnerElements("color");
  8045. if (cEle != null && cEle.length > 0) {
  8046. color = ReadXml_1.getColor(cEle[0], _this.styles, "t");
  8047. }
  8048. var ff = void 0;
  8049. // if(family!=null){
  8050. // ff = fontFamilys[family];
  8051. // }
  8052. if (rFont != null) {
  8053. ff = rFont;
  8054. }
  8055. if (ff != null) {
  8056. InlineString.ff = ff;
  8057. } else if (cellValue.ff != null) {
  8058. InlineString.ff = cellValue.ff;
  8059. }
  8060. if (color != null) {
  8061. InlineString.fc = color;
  8062. } else if (cellValue.fc != null) {
  8063. InlineString.fc = cellValue.fc;
  8064. }
  8065. if (sz != null) {
  8066. InlineString.fs = parseInt(sz);
  8067. } else if (cellValue.fs != null) {
  8068. InlineString.fs = cellValue.fs;
  8069. }
  8070. if (strike != null) {
  8071. InlineString.cl = parseInt(strike);
  8072. } else if (cellValue.cl != null) {
  8073. InlineString.cl = cellValue.cl;
  8074. }
  8075. if (u != null) {
  8076. InlineString.un = parseInt(u);
  8077. } else if (cellValue.un != null) {
  8078. InlineString.un = cellValue.un;
  8079. }
  8080. if (b != null) {
  8081. InlineString.bl = parseInt(b);
  8082. } else if (cellValue.bl != null) {
  8083. InlineString.bl = cellValue.bl;
  8084. }
  8085. if (i != null) {
  8086. InlineString.it = parseInt(i);
  8087. } else if (cellValue.it != null) {
  8088. InlineString.it = cellValue.it;
  8089. }
  8090. if (vertAlign != null) {
  8091. InlineString.va = parseInt(vertAlign);
  8092. }
  8093. // ff:string | undefined //font family
  8094. // fc:string | undefined//font color
  8095. // fs:number | undefined//font size
  8096. // cl:number | undefined//strike
  8097. // un:number | undefined//underline
  8098. // bl:number | undefined//blod
  8099. // it:number | undefined//italic
  8100. // v:string | undefined
  8101. } else {
  8102. if (InlineString.ff == null && cellValue.ff != null) {
  8103. InlineString.ff = cellValue.ff;
  8104. }
  8105. if (InlineString.fc == null && cellValue.fc != null) {
  8106. InlineString.fc = cellValue.fc;
  8107. }
  8108. if (InlineString.fs == null && cellValue.fs != null) {
  8109. InlineString.fs = cellValue.fs;
  8110. }
  8111. if (InlineString.cl == null && cellValue.cl != null) {
  8112. InlineString.cl = cellValue.cl;
  8113. }
  8114. if (InlineString.un == null && cellValue.un != null) {
  8115. InlineString.un = cellValue.un;
  8116. }
  8117. if (InlineString.bl == null && cellValue.bl != null) {
  8118. InlineString.bl = cellValue.bl;
  8119. }
  8120. if (InlineString.it == null && cellValue.it != null) {
  8121. InlineString.it = cellValue.it;
  8122. }
  8123. }
  8124. styles_1.push(InlineString);
  8125. });
  8126. var cellFormat = cellValue.ct;
  8127. if (cellFormat == null) {
  8128. cellFormat = new LuckyBase_1.LuckySheetCellFormat();
  8129. }
  8130. cellFormat.t = "inlineStr";
  8131. cellFormat.s = styles_1;
  8132. cellValue.ct = cellFormat;
  8133. }
  8134. }
  8135. // to be confirmed
  8136. else if (t == constant_1.ST_CellType["InlineString"] && v != null) {
  8137. cellValue.v = "'" + value;
  8138. } else {
  8139. value = method_1.escapeCharacter(value);
  8140. cellValue.v = value;
  8141. }
  8142. }
  8143. if (quotePrefix != null) {
  8144. cellValue.qp = parseInt(quotePrefix);
  8145. }
  8146. return cellValue;
  8147. };
  8148. LuckySheetCelldata.prototype.replaceSpecialWrap = function (text) {
  8149. text = text.replace(/_x000D_/g, "").replace(/&#13;&#10;/g, "\r\n").replace(/&#13;/g, "\r").replace(/&#10;/g, "\n");
  8150. return text;
  8151. };
  8152. LuckySheetCelldata.prototype.getBackgroundByFill = function (fill, clrScheme) {
  8153. var patternFills = fill.getInnerElements("patternFill");
  8154. if (patternFills != null) {
  8155. var patternFill = patternFills[0];
  8156. var fgColors = patternFill.getInnerElements("fgColor");
  8157. var bgColors = patternFill.getInnerElements("bgColor");
  8158. var fg = void 0,
  8159. bg = void 0;
  8160. if (fgColors != null) {
  8161. var fgColor = fgColors[0];
  8162. fg = ReadXml_1.getColor(fgColor, this.styles);
  8163. }
  8164. if (bgColors != null) {
  8165. var bgColor = bgColors[0];
  8166. bg = ReadXml_1.getColor(bgColor, this.styles);
  8167. }
  8168. // console.log(fgColors,bgColors,clrScheme);
  8169. if (fg != null) {
  8170. return fg;
  8171. } else if (bg != null) {
  8172. return bg;
  8173. }
  8174. } else {
  8175. var gradientfills = fill.getInnerElements("gradientFill");
  8176. if (gradientfills != null) {
  8177. //graient color fill handler
  8178. return null;
  8179. }
  8180. }
  8181. };
  8182. LuckySheetCelldata.prototype.getBorderInfo = function (borders) {
  8183. if (borders == null) {
  8184. return null;
  8185. }
  8186. var border = borders[0],
  8187. attrList = border.attributeList;
  8188. var clrScheme = this.styles["clrScheme"];
  8189. var style = attrList.style;
  8190. if (style == null || style == "none") {
  8191. return null;
  8192. }
  8193. var colors = border.getInnerElements("color");
  8194. var colorRet = "#000000";
  8195. if (colors != null) {
  8196. var color = colors[0];
  8197. colorRet = ReadXml_1.getColor(color, this.styles, "b");
  8198. if (colorRet == null) {
  8199. colorRet = "#000000";
  8200. }
  8201. }
  8202. var ret = new LuckyBase_1.LuckySheetborderInfoCellValueStyle();
  8203. ret.style = constant_1.borderTypes[style];
  8204. ret.color = colorRet;
  8205. return ret;
  8206. };
  8207. LuckySheetCelldata.prototype.htmlDecode = function (str) {
  8208. return str.replace(/&#(x)?([^&]{1,5});/g, function ($, $1, $2) {
  8209. return String.fromCharCode(parseInt($2, $1 ? 16 : 10));
  8210. });
  8211. };
  8212. ;
  8213. return LuckySheetCelldata;
  8214. }(LuckyBase_1.LuckySheetCelldataBase);
  8215. exports.LuckySheetCelldata = LuckySheetCelldata;
  8216. },{"../common/constant":47,"../common/method":49,"./LuckyBase":41,"./ReadXml":46}],43:[function(require,module,exports){
  8217. "use strict";
  8218. var __extends = void 0 && (void 0).__extends || function () {
  8219. var _extendStatics = function extendStatics(d, b) {
  8220. _extendStatics = Object.setPrototypeOf || {
  8221. __proto__: []
  8222. } instanceof Array && function (d, b) {
  8223. d.__proto__ = b;
  8224. } || function (d, b) {
  8225. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  8226. };
  8227. return _extendStatics(d, b);
  8228. };
  8229. return function (d, b) {
  8230. _extendStatics(d, b);
  8231. function __() {
  8232. this.constructor = d;
  8233. }
  8234. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  8235. };
  8236. }();
  8237. Object.defineProperty(exports, "__esModule", {
  8238. value: true
  8239. });
  8240. exports.LuckyFile = void 0;
  8241. var LuckySheet_1 = require("./LuckySheet");
  8242. var constant_1 = require("../common/constant");
  8243. var ReadXml_1 = require("./ReadXml");
  8244. var method_1 = require("../common/method");
  8245. var LuckyBase_1 = require("./LuckyBase");
  8246. var LuckyImage_1 = require("./LuckyImage");
  8247. var xml_js_1 = require("xml-js");
  8248. /** 定义 xml-js 解析出来的 xml-js 结果对象类型 */
  8249. var LuckyFile = /** @class */function (_super) {
  8250. __extends(LuckyFile, _super);
  8251. function LuckyFile(files, fileName) {
  8252. var _this = _super.call(this) || this;
  8253. _this.columnWidthSet = [];
  8254. _this.rowHeightSet = [];
  8255. _this.files = files;
  8256. _this.fileName = fileName;
  8257. _this.readXml = new ReadXml_1.ReadXml(files);
  8258. _this.getSheetNameList();
  8259. _this.sharedStrings = _this.readXml.getElementsByTagName("sst/si", constant_1.sharedStringsFile);
  8260. _this.calcChain = _this.readXml.getElementsByTagName("calcChain/c", constant_1.calcChainFile);
  8261. _this.styles = {};
  8262. _this.styles["cellXfs"] = _this.readXml.getElementsByTagName("cellXfs/xf", constant_1.stylesFile);
  8263. _this.styles["cellStyleXfs"] = _this.readXml.getElementsByTagName("cellStyleXfs/xf", constant_1.stylesFile);
  8264. _this.styles["cellStyles"] = _this.readXml.getElementsByTagName("cellStyles/cellStyle", constant_1.stylesFile);
  8265. _this.styles["fonts"] = _this.readXml.getElementsByTagName("fonts/font", constant_1.stylesFile);
  8266. _this.styles["fills"] = _this.readXml.getElementsByTagName("fills/fill", constant_1.stylesFile);
  8267. _this.styles["borders"] = _this.readXml.getElementsByTagName("borders/border", constant_1.stylesFile);
  8268. _this.styles["clrScheme"] = _this.readXml.getElementsByTagName("a:clrScheme/a:dk1|a:lt1|a:dk2|a:lt2|a:accent1|a:accent2|a:accent3|a:accent4|a:accent5|a:accent6|a:hlink|a:folHlink", constant_1.theme1File);
  8269. _this.styles["indexedColors"] = _this.readXml.getElementsByTagName("colors/indexedColors/rgbColor", constant_1.stylesFile);
  8270. _this.styles["mruColors"] = _this.readXml.getElementsByTagName("colors/mruColors/color", constant_1.stylesFile);
  8271. _this.imageList = new LuckyImage_1.ImageList(files);
  8272. var numfmts = _this.readXml.getElementsByTagName("numFmt/numFmt", constant_1.stylesFile);
  8273. var numFmtDefaultC = JSON.parse(JSON.stringify(constant_1.numFmtDefault));
  8274. for (var i = 0; i < numfmts.length; i++) {
  8275. var attrList = numfmts[i].attributeList;
  8276. var numfmtid = method_1.getXmlAttibute(attrList, "numFmtId", "49");
  8277. var formatcode = method_1.getXmlAttibute(attrList, "formatCode", "@");
  8278. // console.log(numfmtid, formatcode);
  8279. if (!(numfmtid in constant_1.numFmtDefault)) {
  8280. numFmtDefaultC[numfmtid] = constant_1.numFmtDefaultMap[formatcode] || formatcode;
  8281. }
  8282. }
  8283. // console.log(JSON.stringify(numFmtDefaultC), numfmts);
  8284. _this.styles["numfmts"] = numFmtDefaultC;
  8285. return _this;
  8286. }
  8287. /**
  8288. * @return All sheet name of workbook
  8289. */
  8290. LuckyFile.prototype.getSheetNameList = function () {
  8291. var workbookRelList = this.readXml.getElementsByTagName("Relationships/Relationship", constant_1.workbookRels);
  8292. if (workbookRelList == null) {
  8293. return;
  8294. }
  8295. var regex = new RegExp("worksheets/[^/]*?.xml");
  8296. var sheetNames = {};
  8297. for (var i = 0; i < workbookRelList.length; i++) {
  8298. var rel = workbookRelList[i],
  8299. attrList = rel.attributeList;
  8300. var id = attrList["Id"],
  8301. target = attrList["Target"];
  8302. if (regex.test(target)) {
  8303. if (target.indexOf("/xl") === 0) {
  8304. sheetNames[id] = target.substr(1);
  8305. } else {
  8306. sheetNames[id] = "xl/" + target;
  8307. }
  8308. }
  8309. }
  8310. this.sheetNameList = sheetNames;
  8311. };
  8312. /**
  8313. * @param sheetName WorkSheet'name
  8314. * @return sheet file name and path in zip
  8315. */
  8316. LuckyFile.prototype.getSheetFileBysheetId = function (sheetId) {
  8317. // for(let i=0;i<this.sheetNameList.length;i++){
  8318. // let sheetFileName = this.sheetNameList[i];
  8319. // if(sheetFileName.indexOf("sheet"+sheetId)>-1){
  8320. // return sheetFileName;
  8321. // }
  8322. // }
  8323. return this.sheetNameList[sheetId];
  8324. };
  8325. /**
  8326. * @return workBook information
  8327. */
  8328. LuckyFile.prototype.getWorkBookInfo = function () {
  8329. var Company = this.readXml.getElementsByTagName("Company", constant_1.appFile);
  8330. var AppVersion = this.readXml.getElementsByTagName("AppVersion", constant_1.appFile);
  8331. var creator = this.readXml.getElementsByTagName("dc:creator", constant_1.coreFile);
  8332. var lastModifiedBy = this.readXml.getElementsByTagName("cp:lastModifiedBy", constant_1.coreFile);
  8333. var created = this.readXml.getElementsByTagName("dcterms:created", constant_1.coreFile);
  8334. var modified = this.readXml.getElementsByTagName("dcterms:modified", constant_1.coreFile);
  8335. this.info = new LuckyBase_1.LuckyFileInfo();
  8336. this.info.name = this.fileName;
  8337. this.info.creator = creator.length > 0 ? creator[0].value : "";
  8338. this.info.lastmodifiedby = lastModifiedBy.length > 0 ? lastModifiedBy[0].value : "";
  8339. this.info.createdTime = created.length > 0 ? created[0].value : "";
  8340. this.info.modifiedTime = modified.length > 0 ? modified[0].value : "";
  8341. this.info.company = Company.length > 0 ? Company[0].value : "";
  8342. this.info.appversion = AppVersion.length > 0 ? AppVersion[0].value : "";
  8343. };
  8344. /**
  8345. * @return All sheet , include whole information
  8346. */
  8347. LuckyFile.prototype.getSheetsFull = function (isInitialCell) {
  8348. if (isInitialCell === void 0) {
  8349. isInitialCell = true;
  8350. }
  8351. var sheets = this.readXml.getElementsByTagName("sheets/sheet", constant_1.workBookFile);
  8352. var sheetList = {};
  8353. for (var key in sheets) {
  8354. var sheet = sheets[key];
  8355. sheetList[sheet.attributeList.name] = sheet.attributeList["sheetId"];
  8356. }
  8357. this.sheets = [];
  8358. var order = 0;
  8359. for (var key in sheets) {
  8360. var sheet = sheets[key];
  8361. var sheetName = sheet.attributeList.name;
  8362. var sheetId = sheet.attributeList["sheetId"];
  8363. var rid = sheet.attributeList["r:id"];
  8364. var sheetFile = this.getSheetFileBysheetId(rid);
  8365. var hide = sheet.attributeList.state === "hidden" ? 1 : 0;
  8366. var drawing = this.readXml.getElementsByTagName("worksheet/drawing", sheetFile),
  8367. drawingFile = void 0,
  8368. drawingRelsFile = void 0;
  8369. if (drawing != null && drawing.length > 0) {
  8370. var attrList = drawing[0].attributeList;
  8371. var rid_1 = method_1.getXmlAttibute(attrList, "r:id", null);
  8372. if (rid_1 != null) {
  8373. drawingFile = this.getDrawingFile(rid_1, sheetFile);
  8374. drawingRelsFile = this.getDrawingRelsFile(drawingFile);
  8375. }
  8376. }
  8377. if (sheetFile != null) {
  8378. var sheet_1 = new LuckySheet_1.LuckySheet(sheetName, sheetId, order, isInitialCell, {
  8379. sheetFile: sheetFile,
  8380. readXml: this.readXml,
  8381. sheetList: sheetList,
  8382. styles: this.styles,
  8383. sharedStrings: this.sharedStrings,
  8384. calcChain: this.calcChain,
  8385. imageList: this.imageList,
  8386. drawingFile: drawingFile,
  8387. drawingRelsFile: drawingRelsFile,
  8388. hide: hide
  8389. });
  8390. this.columnWidthSet = [];
  8391. this.rowHeightSet = [];
  8392. this.imagePositionCaculation(sheet_1);
  8393. this.sheets.push(sheet_1);
  8394. order++;
  8395. }
  8396. }
  8397. };
  8398. /**
  8399. * @return All Comment , include whole information
  8400. * 1. readXml.getFileByName 获取当前 sheetIndex 的批注 xml 字符串
  8401. * 2. 利用 xml-js 将 xml 文件转成 json 对象
  8402. * 3. 正确识别 r c ps 属性,并真实封装到 sheets 数据上
  8403. */
  8404. // xl/comments1.xml
  8405. LuckyFile.prototype.getComment = function () {
  8406. var comments = [];
  8407. for (var i = 0; i < this.sheets.length; i++) {
  8408. // 返回值是一个字符串 - xml 字符串
  8409. var xml = this.readXml.getFileByName("xl/comments" + (i + 1) + ".xml");
  8410. if (!xml) continue;
  8411. comments.push({
  8412. sheetIndex: this.sheets[i].index,
  8413. xml: xml
  8414. });
  8415. }
  8416. this.xmlCommentToJson(comments);
  8417. // 应该提供原始数据供用户使用
  8418. this.comments = comments;
  8419. };
  8420. /**
  8421. * 将 xml 文件转成 JSON 对象
  8422. * @param comments
  8423. */
  8424. LuckyFile.prototype.xmlCommentToJson = function (comments) {
  8425. /**
  8426. * 对 comments 进行处理
  8427. * 1. 转出来的对象 一个sheet页有几个批注,则 json.elements[0].elements 就有几项数据项,但是不建议直接写 0 还是应该循环实现数据获取
  8428. */
  8429. var commentsList = [];
  8430. // 循环对象进行xml解析
  8431. comments.forEach(function (_a) {
  8432. var sheetIndex = _a.sheetIndex,
  8433. xml = _a.xml;
  8434. var jsonString = xml_js_1.xml2json(xml);
  8435. if (!jsonString) return;
  8436. var json = JSON.parse(jsonString);
  8437. for (var i = 0; i < json.elements.length; i++) {
  8438. // 这里的item 是每一个外层的xml信息集合
  8439. var item = json.elements[i];
  8440. if (!item.elements) continue;
  8441. // 只有name = ‘commentList’ 才是批注集合
  8442. item.elements.forEach(function (commentList) {
  8443. if (commentList.name !== "commentList") return;
  8444. // 注意!!! 这里的 commentList 仅是当前sheet 页的批注集合
  8445. commentList.elements.forEach(function (comment) {
  8446. // 注意!!! 这里的 comment 才是每一个具体的 批注
  8447. if (comment.name !== "comment") return;
  8448. // 批注可能是一个,因此不能直接取 1,还是应该 循环 实现数据获取
  8449. // 这里可以获取到 当前批注的 r c 位置信息
  8450. var rc = comment.attributes.ref;
  8451. var _a = method_1.parseCellReference(rc),
  8452. r = _a.r,
  8453. c = _a.c;
  8454. // 将 rc 转成 luckysheet r c
  8455. // 获取内容
  8456. // 1. 正常内容(没有颜色、样式等)
  8457. var content = "";
  8458. try {
  8459. var ps = comment.elements[0].elements[1].elements[1];
  8460. if (ps.attributes["xml:space"] === "preserve") {
  8461. content = ps.elements[0].text;
  8462. }
  8463. } catch (error) {
  8464. try {
  8465. // 尝试获取内容(有颜色、样式等)应该是存在于 preserve 下一个 item 才取到内容
  8466. var ps = comment.elements[0].elements[2].elements[1];
  8467. content = ps.elements[0].text;
  8468. } catch (error) {
  8469. console.error("\u5355\u5143\u683C" + rc + "\u6279\u6CE8\u5185\u5BB9\u89E3\u6790\u5931\u8D25\uFF01Luckysheet \u4E0D\u652F\u6301\u6279\u6CE8\u6837\u5F0F\uFF0C\u8BF7\u79FB\u9664\u6837\u5F0F\u540E\u91CD\u8BD5\uFF01");
  8470. }
  8471. }
  8472. if (!content) {
  8473. console.error("\u5355\u5143\u683C" + rc + "\u6279\u6CE8\u5185\u5BB9\u89E3\u6790\u5931\u8D25\uFF01Luckysheet \u4E0D\u652F\u6301\u6279\u6CE8\u6837\u5F0F\uFF0C\u8BF7\u79FB\u9664\u6837\u5F0F\u540E\u91CD\u8BD5\uFF01");
  8474. }
  8475. commentsList.push({
  8476. sheetIndex: sheetIndex,
  8477. r: r,
  8478. c: c,
  8479. content: content
  8480. });
  8481. });
  8482. });
  8483. }
  8484. });
  8485. return commentsList;
  8486. };
  8487. LuckyFile.prototype.extendArray = function (index, sets, def, hidden, lens) {
  8488. if (index < sets.length) {
  8489. return;
  8490. }
  8491. var startIndex = sets.length,
  8492. endIndex = index;
  8493. var allGap = 0;
  8494. if (startIndex > 0) {
  8495. allGap = sets[startIndex - 1];
  8496. }
  8497. // else{
  8498. // sets.push(0);
  8499. // }
  8500. for (var i = startIndex; i <= endIndex; i++) {
  8501. var gap = def,
  8502. istring = i.toString();
  8503. if (istring in hidden) {
  8504. gap = 0;
  8505. } else if (istring in lens) {
  8506. gap = lens[istring];
  8507. }
  8508. allGap += Math.round(gap + 1);
  8509. sets.push(allGap);
  8510. }
  8511. };
  8512. LuckyFile.prototype.imagePositionCaculation = function (sheet) {
  8513. var images = sheet.images,
  8514. defaultColWidth = sheet.defaultColWidth,
  8515. defaultRowHeight = sheet.defaultRowHeight;
  8516. var colhidden = {};
  8517. if (sheet.config.colhidden) {
  8518. colhidden = sheet.config.colhidden;
  8519. }
  8520. var columnlen = {};
  8521. if (sheet.config.columnlen) {
  8522. columnlen = sheet.config.columnlen;
  8523. }
  8524. var rowhidden = {};
  8525. if (sheet.config.rowhidden) {
  8526. rowhidden = sheet.config.rowhidden;
  8527. }
  8528. var rowlen = {};
  8529. if (sheet.config.rowlen) {
  8530. rowlen = sheet.config.rowlen;
  8531. }
  8532. for (var key in images) {
  8533. var imageObject = images[key]; //Image, luckyImage
  8534. var fromCol = imageObject.fromCol;
  8535. var fromColOff = imageObject.fromColOff;
  8536. var fromRow = imageObject.fromRow;
  8537. var fromRowOff = imageObject.fromRowOff;
  8538. var toCol = imageObject.toCol;
  8539. var toColOff = imageObject.toColOff;
  8540. var toRow = imageObject.toRow;
  8541. var toRowOff = imageObject.toRowOff;
  8542. var x_n = 0,
  8543. y_n = 0;
  8544. var cx_n = 0,
  8545. cy_n = 0;
  8546. if (fromCol >= this.columnWidthSet.length) {
  8547. this.extendArray(fromCol, this.columnWidthSet, defaultColWidth, colhidden, columnlen);
  8548. }
  8549. if (fromCol == 0) {
  8550. x_n = 0;
  8551. } else {
  8552. x_n = this.columnWidthSet[fromCol - 1];
  8553. }
  8554. x_n = x_n + fromColOff;
  8555. if (fromRow >= this.rowHeightSet.length) {
  8556. this.extendArray(fromRow, this.rowHeightSet, defaultRowHeight, rowhidden, rowlen);
  8557. }
  8558. if (fromRow == 0) {
  8559. y_n = 0;
  8560. } else {
  8561. y_n = this.rowHeightSet[fromRow - 1];
  8562. }
  8563. y_n = y_n + fromRowOff;
  8564. if (toCol >= this.columnWidthSet.length) {
  8565. this.extendArray(toCol, this.columnWidthSet, defaultColWidth, colhidden, columnlen);
  8566. }
  8567. if (toCol == 0) {
  8568. cx_n = 0;
  8569. } else {
  8570. cx_n = this.columnWidthSet[toCol - 1];
  8571. }
  8572. cx_n = cx_n + toColOff - x_n;
  8573. if (toRow >= this.rowHeightSet.length) {
  8574. this.extendArray(toRow, this.rowHeightSet, defaultRowHeight, rowhidden, rowlen);
  8575. }
  8576. if (toRow == 0) {
  8577. cy_n = 0;
  8578. } else {
  8579. cy_n = this.rowHeightSet[toRow - 1];
  8580. }
  8581. cy_n = cy_n + toRowOff - y_n;
  8582. console.log(defaultColWidth, colhidden, columnlen);
  8583. console.log(fromCol, this.columnWidthSet[fromCol], fromColOff);
  8584. console.log(toCol, this.columnWidthSet[toCol], toColOff, JSON.stringify(this.columnWidthSet));
  8585. imageObject.originWidth = cx_n;
  8586. imageObject.originHeight = cy_n;
  8587. imageObject.crop.height = cy_n;
  8588. imageObject.crop.width = cx_n;
  8589. imageObject["default"].height = cy_n;
  8590. imageObject["default"].left = x_n;
  8591. imageObject["default"].top = y_n;
  8592. imageObject["default"].width = cx_n;
  8593. }
  8594. //console.log(this.columnWidthSet, this.rowHeightSet);
  8595. };
  8596. /**
  8597. * @return drawing file string
  8598. */
  8599. LuckyFile.prototype.getDrawingFile = function (rid, sheetFile) {
  8600. var sheetRelsPath = "xl/worksheets/_rels/";
  8601. var sheetFileArr = sheetFile.split("/");
  8602. var sheetRelsName = sheetFileArr[sheetFileArr.length - 1];
  8603. var sheetRelsFile = sheetRelsPath + sheetRelsName + ".rels";
  8604. var drawing = this.readXml.getElementsByTagName("Relationships/Relationship", sheetRelsFile);
  8605. if (drawing.length > 0) {
  8606. for (var i = 0; i < drawing.length; i++) {
  8607. var relationship = drawing[i];
  8608. var attrList = relationship.attributeList;
  8609. var relationshipId = method_1.getXmlAttibute(attrList, "Id", null);
  8610. if (relationshipId == rid) {
  8611. var target = method_1.getXmlAttibute(attrList, "Target", null);
  8612. if (target != null) {
  8613. return target.replace(/\.\.\//g, "");
  8614. }
  8615. }
  8616. }
  8617. }
  8618. return null;
  8619. };
  8620. LuckyFile.prototype.getDrawingRelsFile = function (drawingFile) {
  8621. var drawingRelsPath = "xl/drawings/_rels/";
  8622. var drawingFileArr = drawingFile.split("/");
  8623. var drawingRelsName = drawingFileArr[drawingFileArr.length - 1];
  8624. var drawingRelsFile = drawingRelsPath + drawingRelsName + ".rels";
  8625. return drawingRelsFile;
  8626. };
  8627. /**
  8628. * @return All sheet base information widthout cell and config
  8629. */
  8630. LuckyFile.prototype.getSheetsWithoutCell = function () {
  8631. this.getSheetsFull(false);
  8632. };
  8633. /**
  8634. * @return LuckySheet file json
  8635. */
  8636. LuckyFile.prototype.Parse = function () {
  8637. // let xml = this.readXml;
  8638. this.getWorkBookInfo();
  8639. this.getSheetsFull();
  8640. // 解析 批注
  8641. this.getComment();
  8642. return this.toJsonString(this);
  8643. };
  8644. LuckyFile.prototype.toJsonString = function (file) {
  8645. var LuckyOutPutFile = new LuckyBase_1.LuckyFileBase();
  8646. LuckyOutPutFile.info = file.info;
  8647. LuckyOutPutFile.sheets = [];
  8648. LuckyOutPutFile.comments = this.comments;
  8649. file.sheets.forEach(function (sheet) {
  8650. var sheetout = new LuckyBase_1.LuckySheetBase();
  8651. //let attrName = ["name","color","config","index","status","order","row","column","luckysheet_select_save","scrollLeft","scrollTop","zoomRatio","showGridLines","defaultColWidth","defaultRowHeight","celldata","chart","isPivotTable","pivotTable","luckysheet_conditionformat_save","freezen","calcChain"];
  8652. if (sheet.name != null) {
  8653. sheetout.name = sheet.name;
  8654. }
  8655. if (sheet.color != null) {
  8656. sheetout.color = sheet.color;
  8657. }
  8658. if (sheet.config != null) {
  8659. sheetout.config = sheet.config;
  8660. // if(sheetout.config._borderInfo!=null){
  8661. // delete sheetout.config._borderInfo;
  8662. // }
  8663. }
  8664. if (sheet.index != null) {
  8665. sheetout.index = sheet.index;
  8666. }
  8667. if (sheet.status != null) {
  8668. sheetout.status = sheet.status;
  8669. }
  8670. if (sheet.order != null) {
  8671. sheetout.order = sheet.order;
  8672. }
  8673. if (sheet.row != null) {
  8674. sheetout.row = sheet.row;
  8675. }
  8676. if (sheet.column != null) {
  8677. sheetout.column = sheet.column;
  8678. }
  8679. if (sheet.luckysheet_select_save != null) {
  8680. sheetout.luckysheet_select_save = sheet.luckysheet_select_save;
  8681. }
  8682. if (sheet.scrollLeft != null) {
  8683. sheetout.scrollLeft = sheet.scrollLeft;
  8684. }
  8685. if (sheet.scrollTop != null) {
  8686. sheetout.scrollTop = sheet.scrollTop;
  8687. }
  8688. if (sheet.zoomRatio != null) {
  8689. sheetout.zoomRatio = sheet.zoomRatio;
  8690. }
  8691. if (sheet.showGridLines != null) {
  8692. sheetout.showGridLines = sheet.showGridLines;
  8693. }
  8694. if (sheet.defaultColWidth != null) {
  8695. sheetout.defaultColWidth = sheet.defaultColWidth;
  8696. }
  8697. if (sheet.defaultRowHeight != null) {
  8698. sheetout.defaultRowHeight = sheet.defaultRowHeight;
  8699. }
  8700. if (sheet.celldata != null) {
  8701. // sheetout.celldata = sheet.celldata;
  8702. sheetout.celldata = [];
  8703. sheet.celldata.forEach(function (cell) {
  8704. var cellout = new LuckyBase_1.LuckySheetCelldataBase();
  8705. cellout.r = cell.r;
  8706. cellout.c = cell.c;
  8707. cellout.v = cell.v;
  8708. sheetout.celldata.push(cellout);
  8709. });
  8710. }
  8711. if (sheet.chart != null) {
  8712. sheetout.chart = sheet.chart;
  8713. }
  8714. if (sheet.isPivotTable != null) {
  8715. sheetout.isPivotTable = sheet.isPivotTable;
  8716. }
  8717. if (sheet.pivotTable != null) {
  8718. sheetout.pivotTable = sheet.pivotTable;
  8719. }
  8720. if (sheet.luckysheet_conditionformat_save != null) {
  8721. sheetout.luckysheet_conditionformat_save = sheet.luckysheet_conditionformat_save;
  8722. }
  8723. if (sheet.freezen != null) {
  8724. sheetout.freezen = sheet.freezen;
  8725. }
  8726. if (sheet.calcChain != null) {
  8727. sheetout.calcChain = sheet.calcChain;
  8728. }
  8729. if (sheet.images != null) {
  8730. sheetout.images = sheet.images;
  8731. }
  8732. if (sheet.dataVerification != null) {
  8733. sheetout.dataVerification = sheet.dataVerification;
  8734. }
  8735. if (sheet.hyperlink != null) {
  8736. sheetout.hyperlink = sheet.hyperlink;
  8737. }
  8738. if (sheet.hide != null) {
  8739. sheetout.hide = sheet.hide;
  8740. }
  8741. LuckyOutPutFile.sheets.push(sheetout);
  8742. });
  8743. var commentsList = this.xmlCommentToJson(this.comments);
  8744. // 结束后,将 commentsList 处理为this.sheets的 ps 字段
  8745. commentsList.forEach(function (_a) {
  8746. var sheetIndex = _a.sheetIndex,
  8747. r = _a.r,
  8748. c = _a.c,
  8749. content = _a.content;
  8750. // 获取到当前 sheetIndex 的 sheet
  8751. var sheet = LuckyOutPutFile.sheets.find(function (sheet) {
  8752. return sheet.index === sheetIndex;
  8753. });
  8754. if (!sheet) return;
  8755. // 对 celldata 进行处理
  8756. sheet.celldata.forEach(function (cell) {
  8757. if (cell.r === r && cell.c === c) {
  8758. // 找到对应的 cell,将 content 赋值给 ps 字段
  8759. cell.v.ps = {
  8760. value: content
  8761. };
  8762. }
  8763. });
  8764. });
  8765. // 要对插件输出的对象进行处理 this.sheets 是携带 xml 原始数据的结构,不能直接给用户使用
  8766. return JSON.stringify(LuckyOutPutFile);
  8767. };
  8768. return LuckyFile;
  8769. }(LuckyBase_1.LuckyFileBase);
  8770. exports.LuckyFile = LuckyFile;
  8771. },{"../common/constant":47,"../common/method":49,"./LuckyBase":41,"./LuckyImage":44,"./LuckySheet":45,"./ReadXml":46,"xml-js":34}],44:[function(require,module,exports){
  8772. "use strict";
  8773. var __extends = void 0 && (void 0).__extends || function () {
  8774. var _extendStatics = function extendStatics(d, b) {
  8775. _extendStatics = Object.setPrototypeOf || {
  8776. __proto__: []
  8777. } instanceof Array && function (d, b) {
  8778. d.__proto__ = b;
  8779. } || function (d, b) {
  8780. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  8781. };
  8782. return _extendStatics(d, b);
  8783. };
  8784. return function (d, b) {
  8785. _extendStatics(d, b);
  8786. function __() {
  8787. this.constructor = d;
  8788. }
  8789. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  8790. };
  8791. }();
  8792. Object.defineProperty(exports, "__esModule", {
  8793. value: true
  8794. });
  8795. exports.ImageList = void 0;
  8796. var LuckyBase_1 = require("./LuckyBase");
  8797. var emf_1 = require("../common/emf");
  8798. var ImageList = /** @class */function () {
  8799. function ImageList(files) {
  8800. if (files == null) {
  8801. return;
  8802. }
  8803. this.images = {};
  8804. for (var fileKey in files) {
  8805. // let reg = new RegExp("xl/media/image1.png", "g");
  8806. if (fileKey.indexOf("xl/media/") > -1) {
  8807. var fileNameArr = fileKey.split(".");
  8808. var suffix = fileNameArr[fileNameArr.length - 1].toLowerCase();
  8809. if (suffix in {
  8810. "png": 1,
  8811. "jpeg": 1,
  8812. "jpg": 1,
  8813. "gif": 1,
  8814. "bmp": 1,
  8815. "tif": 1,
  8816. "webp": 1,
  8817. "emf": 1
  8818. }) {
  8819. if (suffix == "emf") {
  8820. var pNum = 0; // number of the page, that you want to render
  8821. var scale = 1; // the scale of the document
  8822. var wrt = new emf_1.ToContext2D(pNum, scale);
  8823. var inp, out, stt;
  8824. emf_1.FromEMF.K = [];
  8825. inp = emf_1.FromEMF.C;
  8826. out = emf_1.FromEMF.K;
  8827. stt = 4;
  8828. for (var p in inp) out[inp[p]] = p.slice(stt);
  8829. emf_1.FromEMF.Parse(files[fileKey], wrt);
  8830. this.images[fileKey] = wrt.canvas.toDataURL("image/png");
  8831. } else {
  8832. this.images[fileKey] = files[fileKey];
  8833. }
  8834. }
  8835. }
  8836. }
  8837. }
  8838. ImageList.prototype.getImageByName = function (pathName) {
  8839. if (pathName in this.images) {
  8840. var base64 = this.images[pathName];
  8841. return new Image(pathName, base64);
  8842. }
  8843. return null;
  8844. };
  8845. return ImageList;
  8846. }();
  8847. exports.ImageList = ImageList;
  8848. var Image = /** @class */function (_super) {
  8849. __extends(Image, _super);
  8850. function Image(pathName, base64) {
  8851. var _this = _super.call(this) || this;
  8852. _this.src = base64;
  8853. return _this;
  8854. }
  8855. Image.prototype.setDefault = function () {};
  8856. return Image;
  8857. }(LuckyBase_1.LuckyImageBase);
  8858. },{"../common/emf":48,"./LuckyBase":41}],45:[function(require,module,exports){
  8859. "use strict";
  8860. var __extends = void 0 && (void 0).__extends || function () {
  8861. var _extendStatics = function extendStatics(d, b) {
  8862. _extendStatics = Object.setPrototypeOf || {
  8863. __proto__: []
  8864. } instanceof Array && function (d, b) {
  8865. d.__proto__ = b;
  8866. } || function (d, b) {
  8867. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  8868. };
  8869. return _extendStatics(d, b);
  8870. };
  8871. return function (d, b) {
  8872. _extendStatics(d, b);
  8873. function __() {
  8874. this.constructor = d;
  8875. }
  8876. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  8877. };
  8878. }();
  8879. var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
  8880. return mod && mod.__esModule ? mod : {
  8881. "default": mod
  8882. };
  8883. };
  8884. Object.defineProperty(exports, "__esModule", {
  8885. value: true
  8886. });
  8887. exports.LuckySheet = void 0;
  8888. var LuckyCell_1 = require("./LuckyCell");
  8889. var method_1 = require("../common/method");
  8890. var constant_1 = require("../common/constant");
  8891. var ReadXml_1 = require("./ReadXml");
  8892. var LuckyBase_1 = require("./LuckyBase");
  8893. var dayjs_1 = __importDefault(require("dayjs"));
  8894. var LuckySheet = /** @class */function (_super) {
  8895. __extends(LuckySheet, _super);
  8896. function LuckySheet(sheetName, sheetId, sheetOrder, isInitialCell, allFileOption) {
  8897. if (isInitialCell === void 0) {
  8898. isInitialCell = false;
  8899. }
  8900. var _this =
  8901. //Private
  8902. _super.call(this) || this;
  8903. _this.isInitialCell = isInitialCell;
  8904. _this.readXml = allFileOption.readXml;
  8905. _this.sheetFile = allFileOption.sheetFile;
  8906. _this.styles = allFileOption.styles;
  8907. _this.sharedStrings = allFileOption.sharedStrings;
  8908. _this.calcChainEles = allFileOption.calcChain;
  8909. _this.sheetList = allFileOption.sheetList;
  8910. _this.imageList = allFileOption.imageList;
  8911. _this.hide = allFileOption.hide;
  8912. //Output
  8913. _this.name = sheetName;
  8914. _this.index = sheetId;
  8915. _this.order = sheetOrder.toString();
  8916. _this.config = new LuckyBase_1.LuckyConfig();
  8917. _this.celldata = [];
  8918. _this.mergeCells = _this.readXml.getElementsByTagName("mergeCells/mergeCell", _this.sheetFile);
  8919. var clrScheme = _this.styles["clrScheme"];
  8920. var sheetView = _this.readXml.getElementsByTagName("sheetViews/sheetView", _this.sheetFile);
  8921. var showGridLines = "1",
  8922. tabSelected = "0",
  8923. zoomScale = "100",
  8924. activeCell = "A1";
  8925. if (sheetView.length > 0) {
  8926. var attrList = sheetView[0].attributeList;
  8927. showGridLines = method_1.getXmlAttibute(attrList, "showGridLines", "1");
  8928. tabSelected = method_1.getXmlAttibute(attrList, "tabSelected", "0");
  8929. zoomScale = method_1.getXmlAttibute(attrList, "zoomScale", "100");
  8930. // let colorId = getXmlAttibute(attrList, "colorId", "0");
  8931. var selections = sheetView[0].getInnerElements("selection");
  8932. if (selections != null && selections.length > 0) {
  8933. activeCell = method_1.getXmlAttibute(selections[0].attributeList, "activeCell", "A1");
  8934. var range = method_1.getcellrange(activeCell, _this.sheetList, sheetId);
  8935. _this.luckysheet_select_save = [];
  8936. _this.luckysheet_select_save.push(range);
  8937. }
  8938. }
  8939. _this.showGridLines = showGridLines;
  8940. _this.status = tabSelected;
  8941. _this.zoomRatio = parseInt(zoomScale) / 100;
  8942. var tabColors = _this.readXml.getElementsByTagName("sheetPr/tabColor", _this.sheetFile);
  8943. if (tabColors != null && tabColors.length > 0) {
  8944. var tabColor = tabColors[0],
  8945. attrList = tabColor.attributeList;
  8946. // if(attrList.rgb!=null){
  8947. var tc = ReadXml_1.getColor(tabColor, _this.styles, "b");
  8948. _this.color = tc;
  8949. // }
  8950. }
  8951. var sheetFormatPr = _this.readXml.getElementsByTagName("sheetFormatPr", _this.sheetFile);
  8952. var defaultColWidth, defaultRowHeight;
  8953. if (sheetFormatPr.length > 0) {
  8954. var attrList = sheetFormatPr[0].attributeList;
  8955. defaultColWidth = method_1.getXmlAttibute(attrList, "defaultColWidth", "9.21");
  8956. defaultRowHeight = method_1.getXmlAttibute(attrList, "defaultRowHeight", "19");
  8957. }
  8958. _this.defaultColWidth = method_1.getColumnWidthPixel(parseFloat(defaultColWidth));
  8959. _this.defaultRowHeight = method_1.getRowHeightPixel(parseFloat(defaultRowHeight));
  8960. _this.generateConfigColumnLenAndHidden();
  8961. var cellOtherInfo = _this.generateConfigRowLenAndHiddenAddCell();
  8962. if (_this.calcChain == null) {
  8963. _this.calcChain = [];
  8964. }
  8965. var formulaListExist = {};
  8966. for (var c = 0; c < _this.calcChainEles.length; c++) {
  8967. var calcChainEle = _this.calcChainEles[c],
  8968. attrList = calcChainEle.attributeList;
  8969. if (attrList.i != sheetId) {
  8970. continue;
  8971. }
  8972. var r = attrList.r,
  8973. i = attrList.i,
  8974. l = attrList.l,
  8975. s = attrList.s,
  8976. a = attrList.a,
  8977. t = attrList.t;
  8978. var range = method_1.getcellrange(r);
  8979. var chain = new LuckyBase_1.LuckysheetCalcChain();
  8980. chain.r = range.row[0];
  8981. chain.c = range.column[0];
  8982. chain.index = _this.index;
  8983. _this.calcChain.push(chain);
  8984. formulaListExist["r" + r + "c" + c] = null;
  8985. }
  8986. if (_this.formulaRefList != null) {
  8987. for (var key in _this.formulaRefList) {
  8988. var funclist = _this.formulaRefList[key];
  8989. var mainFunc = funclist["mainRef"],
  8990. mainCellValue = mainFunc.cellValue;
  8991. var formulaTxt = mainFunc.fv;
  8992. var mainR = mainCellValue.r,
  8993. mainC = mainCellValue.c;
  8994. // let refRange = getcellrange(ref);
  8995. for (var name_1 in funclist) {
  8996. if (name_1 == "mainRef") {
  8997. continue;
  8998. }
  8999. var funcValue = funclist[name_1],
  9000. cellValue = funcValue.cellValue;
  9001. if (cellValue == null) {
  9002. continue;
  9003. }
  9004. var r = cellValue.r,
  9005. c = cellValue.c;
  9006. var func = formulaTxt;
  9007. var offsetRow = r - mainR,
  9008. offsetCol = c - mainC;
  9009. if (offsetRow > 0) {
  9010. func = "=" + method_1.fromulaRef.functionCopy(func, "down", offsetRow);
  9011. } else if (offsetRow < 0) {
  9012. func = "=" + method_1.fromulaRef.functionCopy(func, "up", Math.abs(offsetRow));
  9013. }
  9014. if (offsetCol > 0) {
  9015. func = "=" + method_1.fromulaRef.functionCopy(func, "right", offsetCol);
  9016. } else if (offsetCol < 0) {
  9017. func = "=" + method_1.fromulaRef.functionCopy(func, "left", Math.abs(offsetCol));
  9018. }
  9019. // console.log(offsetRow, offsetCol, func);
  9020. cellValue.v.f = func;
  9021. //添加共享公式链
  9022. var chain = new LuckyBase_1.LuckysheetCalcChain();
  9023. chain.r = cellValue.r;
  9024. chain.c = cellValue.c;
  9025. chain.index = _this.index;
  9026. _this.calcChain.push(chain);
  9027. }
  9028. }
  9029. }
  9030. //There may be formulas that do not appear in calcChain
  9031. for (var key in cellOtherInfo.formulaList) {
  9032. if (!(key in formulaListExist)) {
  9033. var formulaListItem = cellOtherInfo.formulaList[key];
  9034. var chain = new LuckyBase_1.LuckysheetCalcChain();
  9035. chain.r = formulaListItem.r;
  9036. chain.c = formulaListItem.c;
  9037. chain.index = _this.index;
  9038. _this.calcChain.push(chain);
  9039. }
  9040. }
  9041. // dataVerification config
  9042. _this.dataVerification = _this.generateConfigDataValidations();
  9043. // hyperlink config
  9044. _this.hyperlink = _this.generateConfigHyperlinks();
  9045. // sheet hide
  9046. _this.hide = _this.hide;
  9047. if (_this.mergeCells != null) {
  9048. for (var i = 0; i < _this.mergeCells.length; i++) {
  9049. var merge = _this.mergeCells[i],
  9050. attrList = merge.attributeList;
  9051. var ref = attrList.ref;
  9052. if (ref == null) {
  9053. continue;
  9054. }
  9055. var range = method_1.getcellrange(ref, _this.sheetList, sheetId);
  9056. var mergeValue = new LuckyBase_1.LuckySheetConfigMerge();
  9057. mergeValue.r = range.row[0];
  9058. mergeValue.c = range.column[0];
  9059. mergeValue.rs = range.row[1] - range.row[0] + 1;
  9060. mergeValue.cs = range.column[1] - range.column[0] + 1;
  9061. if (_this.config.merge == null) {
  9062. _this.config.merge = {};
  9063. }
  9064. _this.config.merge[range.row[0] + "_" + range.column[0]] = mergeValue;
  9065. }
  9066. }
  9067. var drawingFile = allFileOption.drawingFile,
  9068. drawingRelsFile = allFileOption.drawingRelsFile;
  9069. if (drawingFile != null && drawingRelsFile != null) {
  9070. var twoCellAnchors = _this.readXml.getElementsByTagName("xdr:twoCellAnchor", drawingFile);
  9071. if (twoCellAnchors != null && twoCellAnchors.length > 0) {
  9072. for (var i = 0; i < twoCellAnchors.length; i++) {
  9073. var twoCellAnchor = twoCellAnchors[i];
  9074. var editAs = method_1.getXmlAttibute(twoCellAnchor.attributeList, "editAs", "twoCell");
  9075. var xdrFroms = twoCellAnchor.getInnerElements("xdr:from"),
  9076. xdrTos = twoCellAnchor.getInnerElements("xdr:to");
  9077. var xdr_blipfills = twoCellAnchor.getInnerElements("a:blip");
  9078. if (xdrFroms != null && xdr_blipfills != null && xdrFroms.length > 0 && xdr_blipfills.length > 0) {
  9079. var xdrFrom = xdrFroms[0],
  9080. xdrTo = xdrTos[0],
  9081. xdr_blipfill = xdr_blipfills[0];
  9082. var rembed = method_1.getXmlAttibute(xdr_blipfill.attributeList, "r:embed", null);
  9083. var imageObject = _this.getBase64ByRid(rembed, drawingRelsFile);
  9084. // let aoff = xdr_xfrm.getInnerElements("a:off"), aext = xdr_xfrm.getInnerElements("a:ext");
  9085. // if(aoff!=null && aext!=null && aoff.length>0 && aext.length>0){
  9086. // let aoffAttribute = aoff[0].attributeList, aextAttribute = aext[0].attributeList;
  9087. // let x = getXmlAttibute(aoffAttribute, "x", null);
  9088. // let y = getXmlAttibute(aoffAttribute, "y", null);
  9089. // let cx = getXmlAttibute(aextAttribute, "cx", null);
  9090. // let cy = getXmlAttibute(aextAttribute, "cy", null);
  9091. // if(x!=null && y!=null && cx!=null && cy!=null && imageObject !=null){
  9092. // let x_n = getPxByEMUs(parseInt(x), "c"),y_n = getPxByEMUs(parseInt(y));
  9093. // let cx_n = getPxByEMUs(parseInt(cx), "c"),cy_n = getPxByEMUs(parseInt(cy));
  9094. var x_n = 0,
  9095. y_n = 0;
  9096. var cx_n = 0,
  9097. cy_n = 0;
  9098. imageObject.fromCol = _this.getXdrValue(xdrFrom.getInnerElements("xdr:col"));
  9099. imageObject.fromColOff = method_1.getPxByEMUs(_this.getXdrValue(xdrFrom.getInnerElements("xdr:colOff")));
  9100. imageObject.fromRow = _this.getXdrValue(xdrFrom.getInnerElements("xdr:row"));
  9101. imageObject.fromRowOff = method_1.getPxByEMUs(_this.getXdrValue(xdrFrom.getInnerElements("xdr:rowOff")));
  9102. imageObject.toCol = _this.getXdrValue(xdrTo.getInnerElements("xdr:col"));
  9103. imageObject.toColOff = method_1.getPxByEMUs(_this.getXdrValue(xdrTo.getInnerElements("xdr:colOff")));
  9104. imageObject.toRow = _this.getXdrValue(xdrTo.getInnerElements("xdr:row"));
  9105. imageObject.toRowOff = method_1.getPxByEMUs(_this.getXdrValue(xdrTo.getInnerElements("xdr:rowOff")));
  9106. imageObject.originWidth = cx_n;
  9107. imageObject.originHeight = cy_n;
  9108. if (editAs == "absolute") {
  9109. imageObject.type = "3";
  9110. } else if (editAs == "oneCell") {
  9111. imageObject.type = "2";
  9112. } else {
  9113. imageObject.type = "1";
  9114. }
  9115. imageObject.isFixedPos = false;
  9116. imageObject.fixedLeft = 0;
  9117. imageObject.fixedTop = 0;
  9118. var imageBorder = {
  9119. color: "#000",
  9120. radius: 0,
  9121. style: "solid",
  9122. width: 0
  9123. };
  9124. imageObject.border = imageBorder;
  9125. var imageCrop = {
  9126. height: cy_n,
  9127. offsetLeft: 0,
  9128. offsetTop: 0,
  9129. width: cx_n
  9130. };
  9131. imageObject.crop = imageCrop;
  9132. var imageDefault = {
  9133. height: cy_n,
  9134. left: x_n,
  9135. top: y_n,
  9136. width: cx_n
  9137. };
  9138. imageObject["default"] = imageDefault;
  9139. if (_this.images == null) {
  9140. _this.images = {};
  9141. }
  9142. _this.images[method_1.generateRandomIndex("image")] = imageObject;
  9143. // }
  9144. // }
  9145. }
  9146. }
  9147. }
  9148. }
  9149. return _this;
  9150. }
  9151. LuckySheet.prototype.getXdrValue = function (ele) {
  9152. if (ele == null || ele.length == 0) {
  9153. return null;
  9154. }
  9155. return parseInt(ele[0].value);
  9156. };
  9157. LuckySheet.prototype.getBase64ByRid = function (rid, drawingRelsFile) {
  9158. var Relationships = this.readXml.getElementsByTagName("Relationships/Relationship", drawingRelsFile);
  9159. if (Relationships != null && Relationships.length > 0) {
  9160. for (var i = 0; i < Relationships.length; i++) {
  9161. var Relationship = Relationships[i];
  9162. var attrList = Relationship.attributeList;
  9163. var Id = method_1.getXmlAttibute(attrList, "Id", null);
  9164. var src = method_1.getXmlAttibute(attrList, "Target", null);
  9165. if (Id == rid) {
  9166. src = src.replace(/\.\.\//g, "");
  9167. src = "xl/" + src;
  9168. var imgage = this.imageList.getImageByName(src);
  9169. return imgage;
  9170. }
  9171. }
  9172. }
  9173. return null;
  9174. };
  9175. /**
  9176. * @desc This will convert cols/col to luckysheet config of column'width
  9177. */
  9178. LuckySheet.prototype.generateConfigColumnLenAndHidden = function () {
  9179. var cols = this.readXml.getElementsByTagName("cols/col", this.sheetFile);
  9180. for (var i = 0; i < cols.length; i++) {
  9181. var col = cols[i],
  9182. attrList = col.attributeList;
  9183. var min = method_1.getXmlAttibute(attrList, "min", null);
  9184. var max = method_1.getXmlAttibute(attrList, "max", null);
  9185. var width = method_1.getXmlAttibute(attrList, "width", null);
  9186. var hidden = method_1.getXmlAttibute(attrList, "hidden", null);
  9187. var customWidth = method_1.getXmlAttibute(attrList, "customWidth", null);
  9188. if (min == null || max == null) {
  9189. continue;
  9190. }
  9191. var minNum = parseInt(min) - 1,
  9192. maxNum = parseInt(max) - 1,
  9193. widthNum = parseFloat(width);
  9194. for (var m = minNum; m <= maxNum; m++) {
  9195. if (width != null) {
  9196. if (this.config.columnlen == null) {
  9197. this.config.columnlen = {};
  9198. }
  9199. this.config.columnlen[m] = method_1.getColumnWidthPixel(widthNum);
  9200. }
  9201. if (hidden == "1") {
  9202. if (this.config.colhidden == null) {
  9203. this.config.colhidden = {};
  9204. }
  9205. this.config.colhidden[m] = 0;
  9206. if (this.config.columnlen) {
  9207. delete this.config.columnlen[m];
  9208. }
  9209. }
  9210. if (customWidth != null) {
  9211. if (this.config.customWidth == null) {
  9212. this.config.customWidth = {};
  9213. }
  9214. this.config.customWidth[m] = 1;
  9215. }
  9216. }
  9217. }
  9218. };
  9219. /**
  9220. * @desc This will convert cols/col to luckysheet config of column'width
  9221. */
  9222. LuckySheet.prototype.generateConfigRowLenAndHiddenAddCell = function () {
  9223. var rows = this.readXml.getElementsByTagName("sheetData/row", this.sheetFile);
  9224. var cellOtherInfo = {};
  9225. var formulaList = {};
  9226. cellOtherInfo.formulaList = formulaList;
  9227. for (var i = 0; i < rows.length; i++) {
  9228. var row = rows[i],
  9229. attrList = row.attributeList;
  9230. var rowNo = method_1.getXmlAttibute(attrList, "r", null);
  9231. var height = method_1.getXmlAttibute(attrList, "ht", null);
  9232. var hidden = method_1.getXmlAttibute(attrList, "hidden", null);
  9233. var customHeight = method_1.getXmlAttibute(attrList, "customHeight", null);
  9234. if (rowNo == null) {
  9235. continue;
  9236. }
  9237. var rowNoNum = parseInt(rowNo) - 1;
  9238. if (height != null) {
  9239. var heightNum = parseFloat(height);
  9240. if (this.config.rowlen == null) {
  9241. this.config.rowlen = {};
  9242. }
  9243. this.config.rowlen[rowNoNum] = method_1.getRowHeightPixel(heightNum);
  9244. }
  9245. if (hidden == "1") {
  9246. if (this.config.rowhidden == null) {
  9247. this.config.rowhidden = {};
  9248. }
  9249. this.config.rowhidden[rowNoNum] = 0;
  9250. if (this.config.rowlen) {
  9251. delete this.config.rowlen[rowNoNum];
  9252. }
  9253. }
  9254. if (customHeight != null) {
  9255. if (this.config.customHeight == null) {
  9256. this.config.customHeight = {};
  9257. }
  9258. this.config.customHeight[rowNoNum] = 1;
  9259. }
  9260. if (this.isInitialCell) {
  9261. var cells = row.getInnerElements("c");
  9262. for (var key in cells) {
  9263. var cell = cells[key];
  9264. var cellValue = new LuckyCell_1.LuckySheetCelldata(cell, this.styles, this.sharedStrings, this.mergeCells, this.sheetFile, this.readXml);
  9265. if (cellValue._borderObject != null) {
  9266. if (this.config.borderInfo == null) {
  9267. this.config.borderInfo = [];
  9268. }
  9269. this.config.borderInfo.push(cellValue._borderObject);
  9270. delete cellValue._borderObject;
  9271. }
  9272. // let borderId = cellValue._borderId;
  9273. // if(borderId!=null){
  9274. // let borders = this.styles["borders"] as Element[];
  9275. // if(this.config._borderInfo==null){
  9276. // this.config._borderInfo = {};
  9277. // }
  9278. // if( borderId in this.config._borderInfo){
  9279. // this.config._borderInfo[borderId].cells.push(cellValue.r + "_" + cellValue.c);
  9280. // }
  9281. // else{
  9282. // let border = borders[borderId];
  9283. // let borderObject = new LuckySheetborderInfoCellForImp();
  9284. // borderObject.rangeType = "cellGroup";
  9285. // borderObject.cells = [];
  9286. // let borderCellValue = new LuckySheetborderInfoCellValue();
  9287. // let lefts = border.getInnerElements("left");
  9288. // let rights = border.getInnerElements("right");
  9289. // let tops = border.getInnerElements("top");
  9290. // let bottoms = border.getInnerElements("bottom");
  9291. // let diagonals = border.getInnerElements("diagonal");
  9292. // let left = this.getBorderInfo(lefts);
  9293. // let right = this.getBorderInfo(rights);
  9294. // let top = this.getBorderInfo(tops);
  9295. // let bottom = this.getBorderInfo(bottoms);
  9296. // let diagonal = this.getBorderInfo(diagonals);
  9297. // let isAdd = false;
  9298. // if(left!=null && left.color!=null){
  9299. // borderCellValue.l = left;
  9300. // isAdd = true;
  9301. // }
  9302. // if(right!=null && right.color!=null){
  9303. // borderCellValue.r = right;
  9304. // isAdd = true;
  9305. // }
  9306. // if(top!=null && top.color!=null){
  9307. // borderCellValue.t = top;
  9308. // isAdd = true;
  9309. // }
  9310. // if(bottom!=null && bottom.color!=null){
  9311. // borderCellValue.b = bottom;
  9312. // isAdd = true;
  9313. // }
  9314. // if(isAdd){
  9315. // borderObject.value = borderCellValue;
  9316. // this.config._borderInfo[borderId] = borderObject;
  9317. // }
  9318. // }
  9319. // }
  9320. if (cellValue._formulaType == "shared") {
  9321. if (this.formulaRefList == null) {
  9322. this.formulaRefList = {};
  9323. }
  9324. if (this.formulaRefList[cellValue._formulaSi] == null) {
  9325. this.formulaRefList[cellValue._formulaSi] = {};
  9326. }
  9327. var fv = void 0;
  9328. if (cellValue.v != null) {
  9329. fv = cellValue.v.f;
  9330. }
  9331. var refValue = {
  9332. t: cellValue._formulaType,
  9333. ref: cellValue._fomulaRef,
  9334. si: cellValue._formulaSi,
  9335. fv: fv,
  9336. cellValue: cellValue
  9337. };
  9338. if (cellValue._fomulaRef != null) {
  9339. this.formulaRefList[cellValue._formulaSi]["mainRef"] = refValue;
  9340. } else {
  9341. this.formulaRefList[cellValue._formulaSi][cellValue.r + "_" + cellValue.c] = refValue;
  9342. }
  9343. // console.log(refValue, this.formulaRefList);
  9344. }
  9345. //There may be formulas that do not appear in calcChain
  9346. if (cellValue.v != null && cellValue.v.f != null) {
  9347. var formulaCell = {
  9348. r: cellValue.r,
  9349. c: cellValue.c
  9350. };
  9351. cellOtherInfo.formulaList["r" + cellValue.r + "c" + cellValue.c] = formulaCell;
  9352. }
  9353. this.celldata.push(cellValue);
  9354. }
  9355. }
  9356. }
  9357. return cellOtherInfo;
  9358. };
  9359. /**
  9360. * luckysheet config of dataValidations
  9361. *
  9362. * @returns {IluckysheetDataVerification} - dataValidations config
  9363. */
  9364. LuckySheet.prototype.generateConfigDataValidations = function () {
  9365. var rows = this.readXml.getElementsByTagName("dataValidations/dataValidation", this.sheetFile);
  9366. var extLst = this.readXml.getElementsByTagName("extLst/ext/x14:dataValidations/x14:dataValidation", this.sheetFile) || [];
  9367. rows = rows.concat(extLst);
  9368. var dataVerification = {};
  9369. for (var i = 0; i < rows.length; i++) {
  9370. var row = rows[i];
  9371. var attrList = row.attributeList;
  9372. var formulaValue = row.value;
  9373. var type = method_1.getXmlAttibute(attrList, "type", null);
  9374. if (!type) {
  9375. continue;
  9376. }
  9377. var operator = "",
  9378. sqref = "",
  9379. sqrefIndexArr = [],
  9380. valueArr = [];
  9381. var _prohibitInput = method_1.getXmlAttibute(attrList, "allowBlank", null) !== "1" ? false : true;
  9382. // x14 processing
  9383. var formulaReg = new RegExp(/<x14:formula1>|<xm:sqref>/g);
  9384. if (formulaReg.test(formulaValue) && (extLst === null || extLst === void 0 ? void 0 : extLst.length) >= 0) {
  9385. operator = method_1.getXmlAttibute(attrList, "operator", null);
  9386. var peelOffData = method_1.getPeelOffX14(formulaValue);
  9387. sqref = peelOffData === null || peelOffData === void 0 ? void 0 : peelOffData.sqref;
  9388. sqrefIndexArr = method_1.getMultiSequenceToNum(sqref);
  9389. valueArr = method_1.getMultiFormulaValue(peelOffData === null || peelOffData === void 0 ? void 0 : peelOffData.formula);
  9390. } else {
  9391. operator = method_1.getXmlAttibute(attrList, "operator", null);
  9392. sqref = method_1.getXmlAttibute(attrList, "sqref", null);
  9393. sqrefIndexArr = method_1.getMultiSequenceToNum(sqref);
  9394. valueArr = method_1.getMultiFormulaValue(formulaValue);
  9395. }
  9396. var _type = constant_1.DATA_VERIFICATION_MAP[type];
  9397. var _type2 = null;
  9398. var _value1 = (valueArr === null || valueArr === void 0 ? void 0 : valueArr.length) >= 1 ? valueArr[0] : "";
  9399. var _value2 = (valueArr === null || valueArr === void 0 ? void 0 : valueArr.length) === 2 ? valueArr[1] : "";
  9400. var _hint = method_1.getXmlAttibute(attrList, "prompt", null);
  9401. var _hintShow = _hint ? true : false;
  9402. var matchType = constant_1.COMMON_TYPE2.includes(_type) ? "common" : _type;
  9403. _type2 = operator ? constant_1.DATA_VERIFICATION_TYPE2_MAP[matchType][operator] : "bw";
  9404. // mobile phone number processing
  9405. if (_type === "text_content" && ((_value1 === null || _value1 === void 0 ? void 0 : _value1.includes("LEN")) || (_value1 === null || _value1 === void 0 ? void 0 : _value1.includes("len"))) && (_value1 === null || _value1 === void 0 ? void 0 : _value1.includes("=11"))) {
  9406. _type = "validity";
  9407. _type2 = "phone";
  9408. }
  9409. // date processing
  9410. if (_type === "date") {
  9411. var D1900 = new Date(1899, 11, 30, 0, 0, 0);
  9412. _value1 = dayjs_1["default"](D1900).clone().add(Number(_value1), "day").format("YYYY-MM-DD");
  9413. _value2 = dayjs_1["default"](D1900).clone().add(Number(_value2), "day").format("YYYY-MM-DD");
  9414. }
  9415. // checkbox and dropdown processing
  9416. if (_type === "checkbox" || _type === "dropdown") {
  9417. _type2 = null;
  9418. }
  9419. // dynamically add dataVerifications
  9420. for (var _i = 0, sqrefIndexArr_1 = sqrefIndexArr; _i < sqrefIndexArr_1.length; _i++) {
  9421. var ref = sqrefIndexArr_1[_i];
  9422. dataVerification[ref] = {
  9423. type: _type,
  9424. type2: _type2,
  9425. value1: _value1,
  9426. value2: _value2,
  9427. checked: false,
  9428. remote: false,
  9429. prohibitInput: _prohibitInput,
  9430. hintShow: _hintShow,
  9431. hintText: _hint
  9432. };
  9433. }
  9434. }
  9435. return dataVerification;
  9436. };
  9437. /**
  9438. * luckysheet config of hyperlink
  9439. *
  9440. * @returns {IluckysheetHyperlink} - hyperlink config
  9441. */
  9442. LuckySheet.prototype.generateConfigHyperlinks = function () {
  9443. var _a;
  9444. var rows = this.readXml.getElementsByTagName("hyperlinks/hyperlink", this.sheetFile);
  9445. var hyperlink = {};
  9446. var _loop_1 = function _loop_1(i) {
  9447. var row = rows[i];
  9448. var attrList = row.attributeList;
  9449. var ref = method_1.getXmlAttibute(attrList, "ref", null),
  9450. refArr = method_1.getMultiSequenceToNum(ref),
  9451. _display = method_1.getXmlAttibute(attrList, "display", null),
  9452. _address = method_1.getXmlAttibute(attrList, "location", null),
  9453. _tooltip = method_1.getXmlAttibute(attrList, "tooltip", null);
  9454. var _type = _address ? "internal" : "external";
  9455. // external hyperlink
  9456. if (!_address) {
  9457. var rid_1 = attrList["r:id"];
  9458. var sheetFile = this_1.sheetFile;
  9459. var relationshipList = this_1.readXml.getElementsByTagName("Relationships/Relationship", "xl/worksheets/_rels/" + sheetFile.replace(constant_1.worksheetFilePath, "") + ".rels");
  9460. var findRid = relationshipList === null || relationshipList === void 0 ? void 0 : relationshipList.find(function (e) {
  9461. return e.attributeList["Id"] === rid_1;
  9462. });
  9463. if (findRid) {
  9464. _address = findRid.attributeList["Target"];
  9465. _type = (_a = findRid.attributeList["TargetMode"]) === null || _a === void 0 ? void 0 : _a.toLocaleLowerCase();
  9466. }
  9467. }
  9468. // match R1C1
  9469. var addressReg = new RegExp(/^.*!R([\d$])+C([\d$])*$/g);
  9470. if (addressReg.test(_address)) {
  9471. _address = method_1.getTransR1C1ToSequence(_address);
  9472. }
  9473. // dynamically add hyperlinks
  9474. for (var _i = 0, refArr_1 = refArr; _i < refArr_1.length; _i++) {
  9475. var ref_1 = refArr_1[_i];
  9476. hyperlink[ref_1] = {
  9477. linkAddress: _address,
  9478. linkTooltip: _tooltip || "",
  9479. linkType: _type,
  9480. display: _display || ""
  9481. };
  9482. }
  9483. };
  9484. var this_1 = this;
  9485. for (var i = 0; i < rows.length; i++) {
  9486. _loop_1(i);
  9487. }
  9488. return hyperlink;
  9489. };
  9490. return LuckySheet;
  9491. }(LuckyBase_1.LuckySheetBase);
  9492. exports.LuckySheet = LuckySheet;
  9493. },{"../common/constant":47,"../common/method":49,"./LuckyBase":41,"./LuckyCell":42,"./ReadXml":46,"dayjs":5}],46:[function(require,module,exports){
  9494. "use strict";
  9495. var __extends = void 0 && (void 0).__extends || function () {
  9496. var _extendStatics = function extendStatics(d, b) {
  9497. _extendStatics = Object.setPrototypeOf || {
  9498. __proto__: []
  9499. } instanceof Array && function (d, b) {
  9500. d.__proto__ = b;
  9501. } || function (d, b) {
  9502. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  9503. };
  9504. return _extendStatics(d, b);
  9505. };
  9506. return function (d, b) {
  9507. _extendStatics(d, b);
  9508. function __() {
  9509. this.constructor = d;
  9510. }
  9511. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  9512. };
  9513. }();
  9514. Object.defineProperty(exports, "__esModule", {
  9515. value: true
  9516. });
  9517. exports.getlineStringAttr = exports.getColor = exports.Element = exports.ReadXml = void 0;
  9518. var constant_1 = require("../common/constant");
  9519. var method_1 = require("../common/method");
  9520. var xmloperation = /** @class */function () {
  9521. function xmloperation() {}
  9522. /**
  9523. * @param tag Search xml tag name , div,title etc.
  9524. * @param file Xml string
  9525. * @return Xml element string
  9526. */
  9527. xmloperation.prototype.getElementsByOneTag = function (tag, file) {
  9528. //<a:[^/>: ]+?>.*?</a:[^/>: ]+?>
  9529. var readTagReg;
  9530. if (tag.indexOf("|") > -1) {
  9531. var tags = tag.split("|"),
  9532. tagsRegTxt = "";
  9533. for (var i = 0; i < tags.length; i++) {
  9534. var t = tags[i];
  9535. tagsRegTxt += "|<" + t + " [^>]+?[^/]>[\\s\\S]*?</" + t + ">|<" + t + " [^>]+?/>|<" + t + ">[\\s\\S]*?</" + t + ">|<" + t + "/>";
  9536. }
  9537. tagsRegTxt = tagsRegTxt.substr(1, tagsRegTxt.length);
  9538. readTagReg = new RegExp(tagsRegTxt, "g");
  9539. } else {
  9540. readTagReg = new RegExp("<" + tag + " [^>]+?[^/]>[\\s\\S]*?</" + tag + ">|<" + tag + " [^>]+?/>|<" + tag + ">[\\s\\S]*?</" + tag + ">|<" + tag + "/>", "g");
  9541. }
  9542. var ret = file.match(readTagReg);
  9543. if (ret == null) {
  9544. return [];
  9545. } else {
  9546. return ret;
  9547. }
  9548. };
  9549. return xmloperation;
  9550. }();
  9551. var ReadXml = /** @class */function (_super) {
  9552. __extends(ReadXml, _super);
  9553. function ReadXml(files) {
  9554. var _this = _super.call(this) || this;
  9555. _this.originFile = files;
  9556. return _this;
  9557. }
  9558. /**
  9559. * @param path Search xml tag group , div,title etc.
  9560. * @param fileName One of uploadfileList, uploadfileList is file group, {key:value}
  9561. * @return Xml element calss
  9562. */
  9563. ReadXml.prototype.getElementsByTagName = function (path, fileName) {
  9564. var file = this.getFileByName(fileName);
  9565. var pathArr = path.split("/"),
  9566. ret;
  9567. for (var key in pathArr) {
  9568. var path_1 = pathArr[key];
  9569. if (ret == undefined) {
  9570. ret = this.getElementsByOneTag(path_1, file);
  9571. } else {
  9572. if (ret instanceof Array) {
  9573. var items = [];
  9574. for (var key_1 in ret) {
  9575. var item = ret[key_1];
  9576. items = items.concat(this.getElementsByOneTag(path_1, item));
  9577. }
  9578. ret = items;
  9579. } else {
  9580. ret = this.getElementsByOneTag(path_1, ret);
  9581. }
  9582. }
  9583. }
  9584. var elements = [];
  9585. for (var i = 0; i < ret.length; i++) {
  9586. var ele = new Element(ret[i]);
  9587. elements.push(ele);
  9588. }
  9589. return elements;
  9590. };
  9591. /**
  9592. * @param name One of uploadfileList's name, search for file by this parameter
  9593. * @retrun Select a file from uploadfileList
  9594. */
  9595. ReadXml.prototype.getFileByName = function (name) {
  9596. for (var fileKey in this.originFile) {
  9597. if (fileKey.indexOf(name) > -1) {
  9598. return this.originFile[fileKey];
  9599. }
  9600. }
  9601. return "";
  9602. };
  9603. return ReadXml;
  9604. }(xmloperation);
  9605. exports.ReadXml = ReadXml;
  9606. var Element = /** @class */function (_super) {
  9607. __extends(Element, _super);
  9608. function Element(str) {
  9609. var _this = _super.call(this) || this;
  9610. _this.elementString = str;
  9611. _this.setValue();
  9612. var readAttrReg = new RegExp('[a-zA-Z0-9_:]*?=".*?"', "g");
  9613. var attrList = _this.container.match(readAttrReg);
  9614. _this.attributeList = {};
  9615. if (attrList != null) {
  9616. for (var key in attrList) {
  9617. var attrFull = attrList[key];
  9618. // let al= attrFull.split("=");
  9619. if (attrFull.length == 0) {
  9620. continue;
  9621. }
  9622. var attrKey = attrFull.substr(0, attrFull.indexOf("="));
  9623. var attrValue = attrFull.substr(attrFull.indexOf("=") + 1);
  9624. if (attrKey == null || attrValue == null || attrKey.length == 0 || attrValue.length == 0) {
  9625. continue;
  9626. }
  9627. _this.attributeList[attrKey] = attrValue.substr(1, attrValue.length - 2);
  9628. }
  9629. }
  9630. return _this;
  9631. }
  9632. /**
  9633. * @param name Get attribute by key in element
  9634. * @return Single attribute
  9635. */
  9636. Element.prototype.get = function (name) {
  9637. return this.attributeList[name];
  9638. };
  9639. /**
  9640. * @param tag Get elements by tag in elementString
  9641. * @return Element group
  9642. */
  9643. Element.prototype.getInnerElements = function (tag) {
  9644. var ret = this.getElementsByOneTag(tag, this.elementString);
  9645. var elements = [];
  9646. for (var i = 0; i < ret.length; i++) {
  9647. var ele = new Element(ret[i]);
  9648. elements.push(ele);
  9649. }
  9650. if (elements.length == 0) {
  9651. return null;
  9652. }
  9653. return elements;
  9654. };
  9655. /**
  9656. * @desc get xml dom value and container, <container>value</container>
  9657. */
  9658. Element.prototype.setValue = function () {
  9659. var str = this.elementString;
  9660. if (str.substr(str.length - 2, 2) == "/>") {
  9661. this.value = "";
  9662. this.container = str;
  9663. } else {
  9664. var firstTag = this.getFirstTag();
  9665. var firstTagReg = new RegExp("(<" + firstTag + " [^>]+?[^/]>)([\\s\\S]*?)</" + firstTag + ">|(<" + firstTag + ">)([\\s\\S]*?)</" + firstTag + ">", "g");
  9666. var result = firstTagReg.exec(str);
  9667. if (result != null) {
  9668. if (result[1] != null) {
  9669. this.container = result[1];
  9670. this.value = result[2];
  9671. } else {
  9672. this.container = result[3];
  9673. this.value = result[4];
  9674. }
  9675. }
  9676. }
  9677. };
  9678. /**
  9679. * @desc get xml dom first tag, <a><b></b></a>, get a
  9680. */
  9681. Element.prototype.getFirstTag = function () {
  9682. var str = this.elementString;
  9683. var firstTag = str.substr(0, str.indexOf(" "));
  9684. if (firstTag == "" || firstTag.indexOf(">") > -1) {
  9685. firstTag = str.substr(0, str.indexOf(">"));
  9686. }
  9687. firstTag = firstTag.substr(1, firstTag.length);
  9688. return firstTag;
  9689. };
  9690. return Element;
  9691. }(xmloperation);
  9692. exports.Element = Element;
  9693. function combineIndexedColor(indexedColorsInner, indexedColors) {
  9694. var ret = {};
  9695. if (indexedColorsInner == null || indexedColorsInner.length == 0) {
  9696. return indexedColors;
  9697. }
  9698. for (var key in indexedColors) {
  9699. var value = indexedColors[key],
  9700. kn = parseInt(key);
  9701. var inner = indexedColorsInner[kn];
  9702. if (inner == null) {
  9703. ret[key] = value;
  9704. } else {
  9705. var rgb = inner.attributeList.rgb;
  9706. ret[key] = rgb;
  9707. }
  9708. }
  9709. return ret;
  9710. }
  9711. //clrScheme:Element[]
  9712. function getColor(color, styles, type) {
  9713. if (type === void 0) {
  9714. type = "g";
  9715. }
  9716. var attrList = color.attributeList;
  9717. var clrScheme = styles["clrScheme"];
  9718. var indexedColorsInner = styles["indexedColors"];
  9719. var mruColorsInner = styles["mruColors"];
  9720. var indexedColorsList = combineIndexedColor(indexedColorsInner, constant_1.indexedColors);
  9721. var indexed = attrList.indexed,
  9722. rgb = attrList.rgb,
  9723. theme = attrList.theme,
  9724. tint = attrList.tint;
  9725. var bg;
  9726. if (indexed != null) {
  9727. var indexedNum = parseInt(indexed);
  9728. bg = indexedColorsList[indexedNum];
  9729. if (bg != null) {
  9730. bg = bg.substring(bg.length - 6, bg.length);
  9731. bg = "#" + bg;
  9732. }
  9733. } else if (rgb != null) {
  9734. rgb = rgb.substring(rgb.length - 6, rgb.length);
  9735. bg = "#" + rgb;
  9736. } else if (theme != null) {
  9737. var themeNum = parseInt(theme);
  9738. if (themeNum == 0) {
  9739. themeNum = 1;
  9740. } else if (themeNum == 1) {
  9741. themeNum = 0;
  9742. } else if (themeNum == 2) {
  9743. themeNum = 3;
  9744. } else if (themeNum == 3) {
  9745. themeNum = 2;
  9746. }
  9747. var clrSchemeElement = clrScheme[themeNum];
  9748. if (clrSchemeElement != null) {
  9749. var clrs = clrSchemeElement.getInnerElements("a:sysClr|a:srgbClr");
  9750. if (clrs != null) {
  9751. var clr = clrs[0];
  9752. var clrAttrList = clr.attributeList;
  9753. // console.log(clr.container, );
  9754. if (clr.container.indexOf("sysClr") > -1) {
  9755. // if(type=="g" && clrAttrList.val=="windowText"){
  9756. // bg = null;
  9757. // }
  9758. // else if((type=="t" || type=="b") && clrAttrList.val=="window"){
  9759. // bg = null;
  9760. // }
  9761. // else
  9762. if (clrAttrList.lastClr != null) {
  9763. bg = "#" + clrAttrList.lastClr;
  9764. } else if (clrAttrList.val != null) {
  9765. bg = "#" + clrAttrList.val;
  9766. }
  9767. } else if (clr.container.indexOf("srgbClr") > -1) {
  9768. // console.log(clrAttrList.val);
  9769. bg = "#" + clrAttrList.val;
  9770. }
  9771. }
  9772. }
  9773. }
  9774. if (tint != null) {
  9775. var tintNum = parseFloat(tint);
  9776. if (bg != null) {
  9777. bg = method_1.LightenDarkenColor(bg, tintNum);
  9778. }
  9779. }
  9780. return bg;
  9781. }
  9782. exports.getColor = getColor;
  9783. /**
  9784. * @dom xml attribute object
  9785. * @attr attribute name
  9786. * @d if attribute is null, return default value
  9787. * @return attribute value
  9788. */
  9789. function getlineStringAttr(frpr, attr) {
  9790. var attrEle = frpr.getInnerElements(attr),
  9791. value;
  9792. if (attrEle != null && attrEle.length > 0) {
  9793. if (attr == "b" || attr == "i" || attr == "strike") {
  9794. value = "1";
  9795. } else if (attr == "u") {
  9796. var v = attrEle[0].attributeList.val;
  9797. if (v == "double") {
  9798. value = "2";
  9799. } else if (v == "singleAccounting") {
  9800. value = "3";
  9801. } else if (v == "doubleAccounting") {
  9802. value = "4";
  9803. } else {
  9804. value = "1";
  9805. }
  9806. } else if (attr == "vertAlign") {
  9807. var v = attrEle[0].attributeList.val;
  9808. if (v == "subscript") {
  9809. value = "1";
  9810. } else if (v == "superscript") {
  9811. value = "2";
  9812. }
  9813. } else {
  9814. value = attrEle[0].attributeList.val;
  9815. }
  9816. }
  9817. return value;
  9818. }
  9819. exports.getlineStringAttr = getlineStringAttr;
  9820. },{"../common/constant":47,"../common/method":49}],47:[function(require,module,exports){
  9821. "use strict";
  9822. Object.defineProperty(exports, "__esModule", {
  9823. value: true
  9824. });
  9825. exports.DATA_VERIFICATION_TYPE2_MAP = exports.COMMON_TYPE2 = exports.DATA_VERIFICATION_MAP = exports.fontFamilys = exports.numFmtDefaultMap = exports.borderTypes = exports.OEM_CHARSET = exports.indexedColors = exports.numFmtDefault = exports.BuiltInCellStyles = exports.ST_CellType = exports.workbookRels = exports.theme1File = exports.worksheetFilePath = exports.sharedStringsFile = exports.stylesFile = exports.calcChainFile = exports.workBookFile = exports.contentTypesFile = exports.appFile = exports.coreFile = exports.columeHeader_word_index = exports.columeHeader_word = void 0;
  9826. exports.columeHeader_word = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];
  9827. exports.columeHeader_word_index = {
  9828. 'A': 0,
  9829. 'B': 1,
  9830. 'C': 2,
  9831. 'D': 3,
  9832. 'E': 4,
  9833. 'F': 5,
  9834. 'G': 6,
  9835. 'H': 7,
  9836. 'I': 8,
  9837. 'J': 9,
  9838. 'K': 10,
  9839. 'L': 11,
  9840. 'M': 12,
  9841. 'N': 13,
  9842. 'O': 14,
  9843. 'P': 15,
  9844. 'Q': 16,
  9845. 'R': 17,
  9846. 'S': 18,
  9847. 'T': 19,
  9848. 'U': 20,
  9849. 'V': 21,
  9850. 'W': 22,
  9851. 'X': 23,
  9852. 'Y': 24,
  9853. 'Z': 25
  9854. };
  9855. exports.coreFile = "docProps/core.xml";
  9856. exports.appFile = "docProps/app.xml";
  9857. exports.contentTypesFile = "[Content_Types].xml";
  9858. exports.workBookFile = "xl/workbook.xml";
  9859. exports.calcChainFile = "xl/calcChain.xml";
  9860. exports.stylesFile = "xl/styles.xml";
  9861. exports.sharedStringsFile = "xl/sharedStrings.xml";
  9862. exports.worksheetFilePath = "xl/worksheets/";
  9863. exports.theme1File = "xl/theme/theme1.xml";
  9864. exports.workbookRels = "xl/_rels/workbook.xml.rels";
  9865. //Excel Built-In cell type
  9866. exports.ST_CellType = {
  9867. "Boolean": "b",
  9868. "Date": "d",
  9869. "Error": "e",
  9870. "InlineString": "inlineStr",
  9871. "Number": "n",
  9872. "SharedString": "s",
  9873. "String": "str"
  9874. };
  9875. //Excel Built-In cell style
  9876. exports.BuiltInCellStyles = {
  9877. "0": "Normal"
  9878. };
  9879. exports.numFmtDefault = {
  9880. "0": 'General',
  9881. "1": '0',
  9882. "2": '0.00',
  9883. "3": '#,##0',
  9884. "4": '#,##0.00',
  9885. "9": '0%',
  9886. "10": '0.00%',
  9887. "11": '0.00E+00',
  9888. "12": '# ?/?',
  9889. "13": '# ??/??',
  9890. "14": 'm/d/yy',
  9891. "15": 'd-mmm-yy',
  9892. "16": 'd-mmm',
  9893. "17": 'mmm-yy',
  9894. "18": 'h:mm AM/PM',
  9895. "19": 'h:mm:ss AM/PM',
  9896. "20": 'h:mm',
  9897. "21": 'h:mm:ss',
  9898. "22": 'm/d/yy h:mm',
  9899. "37": '#,##0 ;(#,##0)',
  9900. "38": '#,##0 ;[Red](#,##0)',
  9901. "39": '#,##0.00;(#,##0.00)',
  9902. "40": '#,##0.00;[Red](#,##0.00)',
  9903. "45": 'mm:ss',
  9904. "46": '[h]:mm:ss',
  9905. "47": 'mmss.0',
  9906. "48": '##0.0E+0',
  9907. "49": '@'
  9908. };
  9909. exports.indexedColors = {
  9910. "0": '00000000',
  9911. "1": '00FFFFFF',
  9912. "2": '00FF0000',
  9913. "3": '0000FF00',
  9914. "4": '000000FF',
  9915. "5": '00FFFF00',
  9916. "6": '00FF00FF',
  9917. "7": '0000FFFF',
  9918. "8": '00000000',
  9919. "9": '00FFFFFF',
  9920. "10": '00FF0000',
  9921. "11": '0000FF00',
  9922. "12": '000000FF',
  9923. "13": '00FFFF00',
  9924. "14": '00FF00FF',
  9925. "15": '0000FFFF',
  9926. "16": '00800000',
  9927. "17": '00008000',
  9928. "18": '00000080',
  9929. "19": '00808000',
  9930. "20": '00800080',
  9931. "21": '00008080',
  9932. "22": '00C0C0C0',
  9933. "23": '00808080',
  9934. "24": '009999FF',
  9935. "25": '00993366',
  9936. "26": '00FFFFCC',
  9937. "27": '00CCFFFF',
  9938. "28": '00660066',
  9939. "29": '00FF8080',
  9940. "30": '000066CC',
  9941. "31": '00CCCCFF',
  9942. "32": '00000080',
  9943. "33": '00FF00FF',
  9944. "34": '00FFFF00',
  9945. "35": '0000FFFF',
  9946. "36": '00800080',
  9947. "37": '00800000',
  9948. "38": '00008080',
  9949. "39": '000000FF',
  9950. "40": '0000CCFF',
  9951. "41": '00CCFFFF',
  9952. "42": '00CCFFCC',
  9953. "43": '00FFFF99',
  9954. "44": '0099CCFF',
  9955. "45": '00FF99CC',
  9956. "46": '00CC99FF',
  9957. "47": '00FFCC99',
  9958. "48": '003366FF',
  9959. "49": '0033CCCC',
  9960. "50": '0099CC00',
  9961. "51": '00FFCC00',
  9962. "52": '00FF9900',
  9963. "53": '00FF6600',
  9964. "54": '00666699',
  9965. "55": '00969696',
  9966. "56": '00003366',
  9967. "57": '00339966',
  9968. "58": '00003300',
  9969. "59": '00333300',
  9970. "60": '00993300',
  9971. "61": '00993366',
  9972. "62": '00333399',
  9973. "63": '00333333',
  9974. "64": null,
  9975. "65": null
  9976. };
  9977. exports.OEM_CHARSET = {
  9978. "0": "ANSI_CHARSET",
  9979. "1": "DEFAULT_CHARSET",
  9980. "2": "SYMBOL_CHARSET",
  9981. "77": "MAC_CHARSET",
  9982. "128": "SHIFTJIS_CHARSET",
  9983. "129": "HANGUL_CHARSET",
  9984. "130": "JOHAB_CHARSET",
  9985. "134": "GB2312_CHARSET",
  9986. "136": "CHINESEBIG5_CHARSET",
  9987. "161": "GREEK_CHARSET",
  9988. "162": "TURKISH_CHARSET",
  9989. "163": "VIETNAMESE_CHARSET",
  9990. "177": "HEBREW_CHARSET",
  9991. "178": "ARABIC_CHARSET",
  9992. "186": "BALTIC_CHARSET",
  9993. "204": "RUSSIAN_CHARSET",
  9994. "222": "THAI_CHARSET",
  9995. "238": "EASTEUROPE_CHARSET",
  9996. "255": "OEM_CHARSET"
  9997. };
  9998. exports.borderTypes = {
  9999. "none": 0,
  10000. "thin": 1,
  10001. "hair": 2,
  10002. "dotted": 3,
  10003. "dashed": 4,
  10004. "dashDot": 5,
  10005. "dashDotDot": 6,
  10006. "double": 7,
  10007. "medium": 8,
  10008. "mediumDashed": 9,
  10009. "mediumDashDot": 10,
  10010. "mediumDashDotDot": 11,
  10011. "slantDashDot": 12,
  10012. "thick": 13
  10013. };
  10014. exports.numFmtDefaultMap = {
  10015. "yyyy/m/d;@": "yyyy/MM/dd",
  10016. "yyyy&quot;年&quot;m&quot;月&quot;d&quot;日&quot;;@": "yyyy&quot;年&quot;MM&quot;月&quot;dd&quot;日&quot;",
  10017. "[$-409]yyyy/m/d\\ h:mm\\ AM/PM;@": "yyyy/MM/dd hh:mm AM/PM"
  10018. };
  10019. exports.fontFamilys = {
  10020. "0": "defualt",
  10021. "1": "Roman",
  10022. "2": "Swiss",
  10023. "3": "Modern",
  10024. "4": "Script",
  10025. "5": "Decorative"
  10026. };
  10027. exports.DATA_VERIFICATION_MAP = {
  10028. list: "dropdown",
  10029. whole: "number_integer",
  10030. decimal: "number_decimal",
  10031. custom: "text_content",
  10032. textLength: "text_length",
  10033. date: "date",
  10034. "unknown1": "number",
  10035. "unknown2": "checkbox",
  10036. "unknown3": "validity"
  10037. };
  10038. exports.COMMON_TYPE2 = ["number", "number_integer", "number_decimal", "text_length"];
  10039. exports.DATA_VERIFICATION_TYPE2_MAP = {
  10040. common: {
  10041. between: "bw",
  10042. notBetween: "nb",
  10043. equal: "eq",
  10044. notEqualTo: "ne",
  10045. moreThanThe: "gt",
  10046. lessThan: "lt",
  10047. greaterOrEqualTo: "gte",
  10048. lessThanOrEqualTo: "lte"
  10049. },
  10050. text_content: {
  10051. include: "include",
  10052. exclude: "exclude",
  10053. equal: "equal"
  10054. },
  10055. date: {
  10056. between: "bw",
  10057. notBetween: "nb",
  10058. equal: "eq",
  10059. notEqualTo: "ne",
  10060. earlierThan: "bf",
  10061. noEarlierThan: "nbf",
  10062. laterThan: "af",
  10063. noLaterThan: "naf"
  10064. },
  10065. validity: {
  10066. card: "card",
  10067. phone: "phone"
  10068. }
  10069. };
  10070. },{}],48:[function(require,module,exports){
  10071. "use strict";
  10072. Object.defineProperty(exports, "__esModule", {
  10073. value: true
  10074. });
  10075. exports.ToContext2D = exports.FromEMF = exports.UDOC = void 0;
  10076. exports.UDOC = {};
  10077. exports.UDOC.G = {
  10078. concat: function concat(p, r) {
  10079. for (var i = 0; i < r.cmds.length; i++) p.cmds.push(r.cmds[i]);
  10080. for (var i = 0; i < r.crds.length; i++) p.crds.push(r.crds[i]);
  10081. },
  10082. getBB: function getBB(ps) {
  10083. var x0 = 1e99,
  10084. y0 = 1e99,
  10085. x1 = -x0,
  10086. y1 = -y0;
  10087. for (var i = 0; i < ps.length; i += 2) {
  10088. var x = ps[i],
  10089. y = ps[i + 1];
  10090. if (x < x0) x0 = x;else if (x > x1) x1 = x;
  10091. if (y < y0) y0 = y;else if (y > y1) y1 = y;
  10092. }
  10093. return [x0, y0, x1, y1];
  10094. },
  10095. rectToPath: function rectToPath(r) {
  10096. return {
  10097. cmds: ["M", "L", "L", "L", "Z"],
  10098. crds: [r[0], r[1], r[2], r[1], r[2], r[3], r[0], r[3]]
  10099. };
  10100. },
  10101. // a inside b
  10102. insideBox: function insideBox(a, b) {
  10103. return b[0] <= a[0] && b[1] <= a[1] && a[2] <= b[2] && a[3] <= b[3];
  10104. },
  10105. isBox: function isBox(p, bb) {
  10106. var sameCrd8 = function sameCrd8(pcrd, crds) {
  10107. for (var o = 0; o < 8; o += 2) {
  10108. var eq = true;
  10109. for (var j = 0; j < 8; j++) if (Math.abs(crds[j] - pcrd[j + o & 7]) >= 2) {
  10110. eq = false;
  10111. break;
  10112. }
  10113. if (eq) return true;
  10114. }
  10115. return false;
  10116. };
  10117. if (p.cmds.length > 10) return false;
  10118. var cmds = p.cmds.join(""),
  10119. crds = p.crds;
  10120. var sameRect = false;
  10121. if (cmds == "MLLLZ" && crds.length == 8 || cmds == "MLLLLZ" && crds.length == 10) {
  10122. if (crds.length == 10) crds = crds.slice(0, 8);
  10123. var x0 = bb[0],
  10124. y0 = bb[1],
  10125. x1 = bb[2],
  10126. y1 = bb[3];
  10127. if (!sameRect) sameRect = sameCrd8(crds, [x0, y0, x1, y0, x1, y1, x0, y1]);
  10128. if (!sameRect) sameRect = sameCrd8(crds, [x0, y1, x1, y1, x1, y0, x0, y0]);
  10129. }
  10130. return sameRect;
  10131. },
  10132. boxArea: function boxArea(a) {
  10133. var w = a[2] - a[0],
  10134. h = a[3] - a[1];
  10135. return w * h;
  10136. },
  10137. newPath: function newPath(gst) {
  10138. gst.pth = {
  10139. cmds: [],
  10140. crds: []
  10141. };
  10142. },
  10143. moveTo: function moveTo(gst, x, y) {
  10144. var p = exports.UDOC.M.multPoint(gst.ctm, [x, y]); //if(gst.cpos[0]==p[0] && gst.cpos[1]==p[1]) return;
  10145. gst.pth.cmds.push("M");
  10146. gst.pth.crds.push(p[0], p[1]);
  10147. gst.cpos = p;
  10148. },
  10149. lineTo: function lineTo(gst, x, y) {
  10150. var p = exports.UDOC.M.multPoint(gst.ctm, [x, y]);
  10151. if (gst.cpos[0] == p[0] && gst.cpos[1] == p[1]) return;
  10152. gst.pth.cmds.push("L");
  10153. gst.pth.crds.push(p[0], p[1]);
  10154. gst.cpos = p;
  10155. },
  10156. curveTo: function curveTo(gst, x1, y1, x2, y2, x3, y3) {
  10157. var p;
  10158. p = exports.UDOC.M.multPoint(gst.ctm, [x1, y1]);
  10159. x1 = p[0];
  10160. y1 = p[1];
  10161. p = exports.UDOC.M.multPoint(gst.ctm, [x2, y2]);
  10162. x2 = p[0];
  10163. y2 = p[1];
  10164. p = exports.UDOC.M.multPoint(gst.ctm, [x3, y3]);
  10165. x3 = p[0];
  10166. y3 = p[1];
  10167. gst.cpos = p;
  10168. gst.pth.cmds.push("C");
  10169. gst.pth.crds.push(x1, y1, x2, y2, x3, y3);
  10170. },
  10171. closePath: function closePath(gst) {
  10172. gst.pth.cmds.push("Z");
  10173. },
  10174. arc: function arc(gst, x, y, r, a0, a1, neg) {
  10175. // circle from a0 counter-clock-wise to a1
  10176. if (neg) while (a1 > a0) a1 -= 2 * Math.PI;else while (a1 < a0) a1 += 2 * Math.PI;
  10177. var th = (a1 - a0) / 4;
  10178. var x0 = Math.cos(th / 2),
  10179. y0 = -Math.sin(th / 2);
  10180. var x1 = (4 - x0) / 3,
  10181. y1 = y0 == 0 ? y0 : (1 - x0) * (3 - x0) / (3 * y0);
  10182. var x2 = x1,
  10183. y2 = -y1;
  10184. var x3 = x0,
  10185. y3 = -y0;
  10186. var p0 = [x0, y0],
  10187. p1 = [x1, y1],
  10188. p2 = [x2, y2],
  10189. p3 = [x3, y3];
  10190. var pth = {
  10191. cmds: [gst.pth.cmds.length == 0 ? "M" : "L", "C", "C", "C", "C"],
  10192. crds: [x0, y0, x1, y1, x2, y2, x3, y3]
  10193. };
  10194. var rot = [1, 0, 0, 1, 0, 0];
  10195. exports.UDOC.M.rotate(rot, -th);
  10196. for (var i = 0; i < 3; i++) {
  10197. p1 = exports.UDOC.M.multPoint(rot, p1);
  10198. p2 = exports.UDOC.M.multPoint(rot, p2);
  10199. p3 = exports.UDOC.M.multPoint(rot, p3);
  10200. pth.crds.push(p1[0], p1[1], p2[0], p2[1], p3[0], p3[1]);
  10201. }
  10202. var sc = [r, 0, 0, r, x, y];
  10203. exports.UDOC.M.rotate(rot, -a0 + th / 2);
  10204. exports.UDOC.M.concat(rot, sc);
  10205. exports.UDOC.M.multArray(rot, pth.crds);
  10206. exports.UDOC.M.multArray(gst.ctm, pth.crds);
  10207. exports.UDOC.G.concat(gst.pth, pth);
  10208. var y = pth.crds.pop();
  10209. x = pth.crds.pop();
  10210. gst.cpos = [x, y];
  10211. },
  10212. toPoly: function toPoly(p) {
  10213. if (p.cmds[0] != "M" || p.cmds[p.cmds.length - 1] != "Z") return null;
  10214. for (var i = 1; i < p.cmds.length - 1; i++) if (p.cmds[i] != "L") return null;
  10215. var out = [],
  10216. cl = p.crds.length;
  10217. if (p.crds[0] == p.crds[cl - 2] && p.crds[1] == p.crds[cl - 1]) cl -= 2;
  10218. for (var i = 0; i < cl; i += 2) out.push([p.crds[i], p.crds[i + 1]]);
  10219. if (exports.UDOC.G.polyArea(p.crds) < 0) out.reverse();
  10220. return out;
  10221. },
  10222. fromPoly: function fromPoly(p) {
  10223. var o = {
  10224. cmds: [],
  10225. crds: []
  10226. };
  10227. for (var i = 0; i < p.length; i++) {
  10228. o.crds.push(p[i][0], p[i][1]);
  10229. o.cmds.push(i == 0 ? "M" : "L");
  10230. }
  10231. o.cmds.push("Z");
  10232. return o;
  10233. },
  10234. polyArea: function polyArea(p) {
  10235. if (p.length < 6) return 0;
  10236. var l = p.length - 2;
  10237. var sum = (p[0] - p[l]) * (p[l + 1] + p[1]);
  10238. for (var i = 0; i < l; i += 2) sum += (p[i + 2] - p[i]) * (p[i + 1] + p[i + 3]);
  10239. return -sum * 0.5;
  10240. },
  10241. polyClip: function polyClip(p0, p1) {
  10242. var cp1, cp2, s, e;
  10243. var inside = function inside(p) {
  10244. return (cp2[0] - cp1[0]) * (p[1] - cp1[1]) > (cp2[1] - cp1[1]) * (p[0] - cp1[0]);
  10245. };
  10246. var isc = function isc() {
  10247. var dc = [cp1[0] - cp2[0], cp1[1] - cp2[1]],
  10248. dp = [s[0] - e[0], s[1] - e[1]],
  10249. n1 = cp1[0] * cp2[1] - cp1[1] * cp2[0],
  10250. n2 = s[0] * e[1] - s[1] * e[0],
  10251. n3 = 1.0 / (dc[0] * dp[1] - dc[1] * dp[0]);
  10252. return [(n1 * dp[0] - n2 * dc[0]) * n3, (n1 * dp[1] - n2 * dc[1]) * n3];
  10253. };
  10254. var out = p0;
  10255. cp1 = p1[p1.length - 1];
  10256. for (var j in p1) {
  10257. var cp2 = p1[j];
  10258. var inp = out;
  10259. out = [];
  10260. s = inp[inp.length - 1]; //last on the input list
  10261. for (var i in inp) {
  10262. var e = inp[i];
  10263. if (inside(e)) {
  10264. if (!inside(s)) {
  10265. out.push(isc());
  10266. }
  10267. out.push(e);
  10268. } else if (inside(s)) {
  10269. out.push(isc());
  10270. }
  10271. s = e;
  10272. }
  10273. cp1 = cp2;
  10274. }
  10275. return out;
  10276. }
  10277. };
  10278. exports.UDOC.M = {
  10279. getScale: function getScale(m) {
  10280. return Math.sqrt(Math.abs(m[0] * m[3] - m[1] * m[2]));
  10281. },
  10282. translate: function translate(m, x, y) {
  10283. exports.UDOC.M.concat(m, [1, 0, 0, 1, x, y]);
  10284. },
  10285. rotate: function rotate(m, a) {
  10286. exports.UDOC.M.concat(m, [Math.cos(a), -Math.sin(a), Math.sin(a), Math.cos(a), 0, 0]);
  10287. },
  10288. scale: function scale(m, x, y) {
  10289. exports.UDOC.M.concat(m, [x, 0, 0, y, 0, 0]);
  10290. },
  10291. concat: function concat(m, w) {
  10292. var a = m[0],
  10293. b = m[1],
  10294. c = m[2],
  10295. d = m[3],
  10296. tx = m[4],
  10297. ty = m[5];
  10298. m[0] = a * w[0] + b * w[2];
  10299. m[1] = a * w[1] + b * w[3];
  10300. m[2] = c * w[0] + d * w[2];
  10301. m[3] = c * w[1] + d * w[3];
  10302. m[4] = tx * w[0] + ty * w[2] + w[4];
  10303. m[5] = tx * w[1] + ty * w[3] + w[5];
  10304. },
  10305. invert: function invert(m) {
  10306. var a = m[0],
  10307. b = m[1],
  10308. c = m[2],
  10309. d = m[3],
  10310. tx = m[4],
  10311. ty = m[5],
  10312. adbc = a * d - b * c;
  10313. m[0] = d / adbc;
  10314. m[1] = -b / adbc;
  10315. m[2] = -c / adbc;
  10316. m[3] = a / adbc;
  10317. m[4] = (c * ty - d * tx) / adbc;
  10318. m[5] = (b * tx - a * ty) / adbc;
  10319. },
  10320. multPoint: function multPoint(m, p) {
  10321. var x = p[0],
  10322. y = p[1];
  10323. return [x * m[0] + y * m[2] + m[4], x * m[1] + y * m[3] + m[5]];
  10324. },
  10325. multArray: function multArray(m, a) {
  10326. for (var i = 0; i < a.length; i += 2) {
  10327. var x = a[i],
  10328. y = a[i + 1];
  10329. a[i] = x * m[0] + y * m[2] + m[4];
  10330. a[i + 1] = x * m[1] + y * m[3] + m[5];
  10331. }
  10332. }
  10333. };
  10334. exports.UDOC.C = {
  10335. srgbGamma: function srgbGamma(x) {
  10336. return x < 0.0031308 ? 12.92 * x : 1.055 * Math.pow(x, 1.0 / 2.4) - 0.055;
  10337. },
  10338. cmykToRgb: function cmykToRgb(clr) {
  10339. var c = clr[0],
  10340. m = clr[1],
  10341. y = clr[2],
  10342. k = clr[3];
  10343. // return [1-Math.min(1,c+k), 1-Math.min(1, m+k), 1-Math.min(1,y+k)];
  10344. var r = 255 + c * (-4.387332384609988 * c + 54.48615194189176 * m + 18.82290502165302 * y + 212.25662451639585 * k + -285.2331026137004) + m * (1.7149763477362134 * m - 5.6096736904047315 * y + -17.873870861415444 * k - 5.497006427196366) + y * (-2.5217340131683033 * y - 21.248923337353073 * k + 17.5119270841813) + k * (-21.86122147463605 * k - 189.48180835922747);
  10345. var g = 255 + c * (8.841041422036149 * c + 60.118027045597366 * m + 6.871425592049007 * y + 31.159100130055922 * k + -79.2970844816548) + m * (-15.310361306967817 * m + 17.575251261109482 * y + 131.35250912493976 * k - 190.9453302588951) + y * (4.444339102852739 * y + 9.8632861493405 * k - 24.86741582555878) + k * (-20.737325471181034 * k - 187.80453709719578);
  10346. var b = 255 + c * (0.8842522430003296 * c + 8.078677503112928 * m + 30.89978309703729 * y - 0.23883238689178934 * k + -14.183576799673286) + m * (10.49593273432072 * m + 63.02378494754052 * y + 50.606957656360734 * k - 112.23884253719248) + y * (0.03296041114873217 * y + 115.60384449646641 * k + -193.58209356861505) + k * (-22.33816807309886 * k - 180.12613974708367);
  10347. return [Math.max(0, Math.min(1, r / 255)), Math.max(0, Math.min(1, g / 255)), Math.max(0, Math.min(1, b / 255))];
  10348. //var iK = 1-c[3];
  10349. //return [(1-c[0])*iK, (1-c[1])*iK, (1-c[2])*iK];
  10350. },
  10351. labToRgb: function labToRgb(lab) {
  10352. var k = 903.3,
  10353. e = 0.008856,
  10354. L = lab[0],
  10355. a = lab[1],
  10356. b = lab[2];
  10357. var fy = (L + 16) / 116,
  10358. fy3 = fy * fy * fy;
  10359. var fz = fy - b / 200,
  10360. fz3 = fz * fz * fz;
  10361. var fx = a / 500 + fy,
  10362. fx3 = fx * fx * fx;
  10363. var zr = fz3 > e ? fz3 : (116 * fz - 16) / k;
  10364. var yr = fy3 > e ? fy3 : (116 * fy - 16) / k;
  10365. var xr = fx3 > e ? fx3 : (116 * fx - 16) / k;
  10366. var X = xr * 96.72,
  10367. Y = yr * 100,
  10368. Z = zr * 81.427,
  10369. xyz = [X / 100, Y / 100, Z / 100];
  10370. var x2s = [3.1338561, -1.6168667, -0.4906146, -0.9787684, 1.9161415, 0.0334540, 0.0719453, -0.2289914, 1.4052427];
  10371. var rgb = [x2s[0] * xyz[0] + x2s[1] * xyz[1] + x2s[2] * xyz[2], x2s[3] * xyz[0] + x2s[4] * xyz[1] + x2s[5] * xyz[2], x2s[6] * xyz[0] + x2s[7] * xyz[1] + x2s[8] * xyz[2]];
  10372. for (var i = 0; i < 3; i++) rgb[i] = Math.max(0, Math.min(1, exports.UDOC.C.srgbGamma(rgb[i])));
  10373. return rgb;
  10374. }
  10375. };
  10376. exports.UDOC.getState = function (crds) {
  10377. return {
  10378. font: exports.UDOC.getFont(),
  10379. dd: {
  10380. flat: 1
  10381. },
  10382. space: "/DeviceGray",
  10383. // fill
  10384. ca: 1,
  10385. colr: [0, 0, 0],
  10386. sspace: "/DeviceGray",
  10387. // stroke
  10388. CA: 1,
  10389. COLR: [0, 0, 0],
  10390. bmode: "/Normal",
  10391. SA: false,
  10392. OPM: 0,
  10393. AIS: false,
  10394. OP: false,
  10395. op: false,
  10396. SMask: "/None",
  10397. lwidth: 1,
  10398. lcap: 0,
  10399. ljoin: 0,
  10400. mlimit: 10,
  10401. SM: 0.1,
  10402. doff: 0,
  10403. dash: [],
  10404. ctm: [1, 0, 0, 1, 0, 0],
  10405. cpos: [0, 0],
  10406. pth: {
  10407. cmds: [],
  10408. crds: []
  10409. },
  10410. cpth: crds ? exports.UDOC.G.rectToPath(crds) : null // clipping path
  10411. };
  10412. };
  10413. exports.UDOC.getFont = function () {
  10414. return {
  10415. Tc: 0,
  10416. Tw: 0,
  10417. Th: 100,
  10418. Tl: 0,
  10419. Tf: "Helvetica-Bold",
  10420. Tfs: 1,
  10421. Tmode: 0,
  10422. Trise: 0,
  10423. Tk: 0,
  10424. Tal: 0,
  10425. Tun: 0,
  10426. Tm: [1, 0, 0, 1, 0, 0],
  10427. Tlm: [1, 0, 0, 1, 0, 0],
  10428. Trm: [1, 0, 0, 1, 0, 0]
  10429. };
  10430. };
  10431. exports.FromEMF = function () {};
  10432. exports.FromEMF.Parse = function (buff, genv) {
  10433. buff = new Uint8Array(buff);
  10434. var off = 0;
  10435. //console.log(buff.slice(0,32));
  10436. var prms = {
  10437. fill: false,
  10438. strk: false,
  10439. bb: [0, 0, 1, 1],
  10440. wbb: [0, 0, 1, 1],
  10441. fnt: {
  10442. nam: "Arial",
  10443. hgh: 25,
  10444. und: false,
  10445. orn: 0
  10446. },
  10447. tclr: [0, 0, 0],
  10448. talg: 0
  10449. },
  10450. gst,
  10451. tab = [],
  10452. sts = [];
  10453. var rI = exports.FromEMF.B.readShort,
  10454. rU = exports.FromEMF.B.readUshort,
  10455. rI32 = exports.FromEMF.B.readInt,
  10456. rU32 = exports.FromEMF.B.readUint,
  10457. rF32 = exports.FromEMF.B.readFloat;
  10458. var opn = 0;
  10459. while (true) {
  10460. var fnc = rU32(buff, off);
  10461. off += 4;
  10462. var fnm = exports.FromEMF.K[fnc];
  10463. var siz = rU32(buff, off);
  10464. off += 4;
  10465. //if(gst && isNaN(gst.ctm[0])) throw "e";
  10466. //console.log(fnc,fnm,siz);
  10467. var loff = off;
  10468. //if(opn++==253) break;
  10469. var obj = null,
  10470. oid = 0;
  10471. //console.log(fnm, siz);
  10472. if (false) {} else if (fnm == "EOF") {
  10473. break;
  10474. } else if (fnm == "HEADER") {
  10475. prms.bb = exports.FromEMF._readBox(buff, loff);
  10476. loff += 16; //console.log(fnm, prms.bb);
  10477. genv.StartPage(prms.bb[0], prms.bb[1], prms.bb[2], prms.bb[3]);
  10478. gst = exports.UDOC.getState(prms.bb);
  10479. } else if (fnm == "SAVEDC") sts.push(JSON.stringify(gst), JSON.stringify(prms));else if (fnm == "RESTOREDC") {
  10480. var dif = rI32(buff, loff);
  10481. loff += 4;
  10482. while (dif < -1) {
  10483. sts.pop();
  10484. sts.pop();
  10485. }
  10486. prms = JSON.parse(sts.pop());
  10487. gst = JSON.parse(sts.pop());
  10488. } else if (fnm == "SELECTCLIPPATH") {
  10489. gst.cpth = JSON.parse(JSON.stringify(gst.pth));
  10490. } else if (["SETMAPMODE", "SETPOLYFILLMODE", "SETBKMODE" /*,"SETVIEWPORTEXTEX"*/, "SETICMMODE", "SETROP2", "EXTSELECTCLIPRGN"].indexOf(fnm) != -1) {}
  10491. //else if(fnm=="INTERSECTCLIPRECT") { var r=prms.crct=FromEMF._readBox(buff, loff); /*var y0=r[1],y1=r[3]; if(y0>y1){r[1]=y1; r[3]=y0;}*/ console.log(prms.crct); }
  10492. else if (fnm == "SETMITERLIMIT") gst.mlimit = rU32(buff, loff);else if (fnm == "SETTEXTCOLOR") prms.tclr = [buff[loff] / 255, buff[loff + 1] / 255, buff[loff + 2] / 255];else if (fnm == "SETTEXTALIGN") prms.talg = rU32(buff, loff);else if (fnm == "SETVIEWPORTEXTEX" || fnm == "SETVIEWPORTORGEX") {
  10493. if (prms.vbb == null) prms.vbb = [];
  10494. var coff = fnm == "SETVIEWPORTORGEX" ? 0 : 2;
  10495. prms.vbb[coff] = rI32(buff, loff);
  10496. loff += 4;
  10497. prms.vbb[coff + 1] = rI32(buff, loff);
  10498. loff += 4;
  10499. //console.log(prms.vbb);
  10500. if (fnm == "SETVIEWPORTEXTEX") exports.FromEMF._updateCtm(prms, gst);
  10501. } else if (fnm == "SETWINDOWEXTEX" || fnm == "SETWINDOWORGEX") {
  10502. var coff = fnm == "SETWINDOWORGEX" ? 0 : 2;
  10503. prms.wbb[coff] = rI32(buff, loff);
  10504. loff += 4;
  10505. prms.wbb[coff + 1] = rI32(buff, loff);
  10506. loff += 4;
  10507. if (fnm == "SETWINDOWEXTEX") exports.FromEMF._updateCtm(prms, gst);
  10508. }
  10509. //else if(fnm=="SETMETARGN") {}
  10510. else if (fnm == "COMMENT") {
  10511. var ds = rU32(buff, loff);
  10512. loff += 4;
  10513. } else if (fnm == "SELECTOBJECT") {
  10514. var ind = rU32(buff, loff);
  10515. loff += 4;
  10516. //console.log(ind.toString(16), tab, tab[ind]);
  10517. if (ind == 0x80000000) {
  10518. prms.fill = true;
  10519. gst.colr = [1, 1, 1];
  10520. } // white brush
  10521. else if (ind == 0x80000005) {
  10522. prms.fill = false;
  10523. } // null brush
  10524. else if (ind == 0x80000007) {
  10525. prms.strk = true;
  10526. prms.lwidth = 1;
  10527. gst.COLR = [0, 0, 0];
  10528. } // black pen
  10529. else if (ind == 0x80000008) {
  10530. prms.strk = false;
  10531. } // null pen
  10532. else if (ind == 0x8000000d) {} // system font
  10533. else if (ind == 0x8000000e) {} // device default font
  10534. else {
  10535. var co = tab[ind]; //console.log(ind, co);
  10536. if (co.t == "b") {
  10537. prms.fill = co.stl != 1;
  10538. if (co.stl == 0) {} else if (co.stl == 1) {} else throw co.stl + " e";
  10539. gst.colr = co.clr;
  10540. } else if (co.t == "p") {
  10541. prms.strk = co.stl != 5;
  10542. gst.lwidth = co.wid;
  10543. gst.COLR = co.clr;
  10544. } else if (co.t == "f") {
  10545. prms.fnt = co;
  10546. gst.font.Tf = co.nam;
  10547. gst.font.Tfs = Math.abs(co.hgh);
  10548. gst.font.Tun = co.und;
  10549. } else throw "e";
  10550. }
  10551. } else if (fnm == "DELETEOBJECT") {
  10552. var ind = rU32(buff, loff);
  10553. loff += 4;
  10554. if (tab[ind] != null) tab[ind] = null;else throw "e";
  10555. } else if (fnm == "CREATEBRUSHINDIRECT") {
  10556. oid = rU32(buff, loff);
  10557. loff += 4;
  10558. obj = {
  10559. t: "b"
  10560. };
  10561. obj.stl = rU32(buff, loff);
  10562. loff += 4;
  10563. obj.clr = [buff[loff] / 255, buff[loff + 1] / 255, buff[loff + 2] / 255];
  10564. loff += 4;
  10565. obj.htc = rU32(buff, loff);
  10566. loff += 4;
  10567. //console.log(oid, obj);
  10568. } else if (fnm == "CREATEPEN" || fnm == "EXTCREATEPEN") {
  10569. oid = rU32(buff, loff);
  10570. loff += 4;
  10571. obj = {
  10572. t: "p"
  10573. };
  10574. if (fnm == "EXTCREATEPEN") {
  10575. loff += 16;
  10576. obj.stl = rU32(buff, loff);
  10577. loff += 4;
  10578. obj.wid = rU32(buff, loff);
  10579. loff += 4;
  10580. //obj.stl = rU32(buff, loff);
  10581. loff += 4;
  10582. } else {
  10583. obj.stl = rU32(buff, loff);
  10584. loff += 4;
  10585. obj.wid = rU32(buff, loff);
  10586. loff += 4;
  10587. loff += 4;
  10588. }
  10589. obj.clr = [buff[loff] / 255, buff[loff + 1] / 255, buff[loff + 2] / 255];
  10590. loff += 4;
  10591. } else if (fnm == "EXTCREATEFONTINDIRECTW") {
  10592. oid = rU32(buff, loff);
  10593. loff += 4;
  10594. obj = {
  10595. t: "f",
  10596. nam: ""
  10597. };
  10598. obj.hgh = rI32(buff, loff);
  10599. loff += 4;
  10600. loff += 4 * 2;
  10601. obj.orn = rI32(buff, loff) / 10;
  10602. loff += 4;
  10603. var wgh = rU32(buff, loff);
  10604. loff += 4; //console.log(fnm, obj.orn, wgh);
  10605. //console.log(rU32(buff,loff), rU32(buff,loff+4), buff.slice(loff,loff+8));
  10606. obj.und = buff[loff + 1];
  10607. obj.stk = buff[loff + 2];
  10608. loff += 4 * 2;
  10609. while (rU(buff, loff) != 0) {
  10610. obj.nam += String.fromCharCode(rU(buff, loff));
  10611. loff += 2;
  10612. }
  10613. if (wgh > 500) obj.nam += "-Bold";
  10614. //console.log(wgh, obj.nam);
  10615. } else if (fnm == "EXTTEXTOUTW") {
  10616. //console.log(buff.slice(loff-8, loff-8+siz));
  10617. loff += 16;
  10618. var mod = rU32(buff, loff);
  10619. loff += 4; //console.log(mod);
  10620. var scx = rF32(buff, loff);
  10621. loff += 4;
  10622. var scy = rF32(buff, loff);
  10623. loff += 4;
  10624. var rfx = rI32(buff, loff);
  10625. loff += 4;
  10626. var rfy = rI32(buff, loff);
  10627. loff += 4;
  10628. //console.log(mod, scx, scy,rfx,rfy);
  10629. gst.font.Tm = [1, 0, 0, -1, 0, 0];
  10630. exports.UDOC.M.rotate(gst.font.Tm, prms.fnt.orn * Math.PI / 180);
  10631. exports.UDOC.M.translate(gst.font.Tm, rfx, rfy);
  10632. var alg = prms.talg; //console.log(alg.toString(2));
  10633. if ((alg & 6) == 6) gst.font.Tal = 2;else if ((alg & 7) == 0) gst.font.Tal = 0;else throw alg + " e";
  10634. if ((alg & 24) == 24) {} // baseline
  10635. else if ((alg & 24) == 0) exports.UDOC.M.translate(gst.font.Tm, 0, gst.font.Tfs);else throw "e";
  10636. var crs = rU32(buff, loff);
  10637. loff += 4;
  10638. var ofs = rU32(buff, loff);
  10639. loff += 4;
  10640. var ops = rU32(buff, loff);
  10641. loff += 4; //if(ops!=0) throw "e";
  10642. //console.log(ofs,ops,crs);
  10643. loff += 16;
  10644. var ofD = rU32(buff, loff);
  10645. loff += 4; //console.log(ops, ofD, loff, ofs+off-8);
  10646. ofs += off - 8; //console.log(crs, ops);
  10647. var str = "";
  10648. for (var i = 0; i < crs; i++) {
  10649. var cc = rU(buff, ofs + i * 2);
  10650. str += String.fromCharCode(cc);
  10651. }
  10652. ;
  10653. var oclr = gst.colr;
  10654. gst.colr = prms.tclr;
  10655. //console.log(str, gst.colr, gst.font.Tm);
  10656. //var otfs = gst.font.Tfs; gst.font.Tfs *= 1/gst.ctm[0];
  10657. genv.PutText(gst, str, str.length * gst.font.Tfs * 0.5);
  10658. gst.colr = oclr;
  10659. //gst.font.Tfs = otfs;
  10660. //console.log(rfx, rfy, scx, ops, rcX, rcY, rcW, rcH, offDx, str);
  10661. } else if (fnm == "BEGINPATH") {
  10662. exports.UDOC.G.newPath(gst);
  10663. } else if (fnm == "ENDPATH") {} else if (fnm == "CLOSEFIGURE") exports.UDOC.G.closePath(gst);else if (fnm == "MOVETOEX") {
  10664. exports.UDOC.G.moveTo(gst, rI32(buff, loff), rI32(buff, loff + 4));
  10665. } else if (fnm == "LINETO") {
  10666. if (gst.pth.cmds.length == 0) {
  10667. var im = gst.ctm.slice(0);
  10668. exports.UDOC.M.invert(im);
  10669. var p = exports.UDOC.M.multPoint(im, gst.cpos);
  10670. exports.UDOC.G.moveTo(gst, p[0], p[1]);
  10671. }
  10672. exports.UDOC.G.lineTo(gst, rI32(buff, loff), rI32(buff, loff + 4));
  10673. } else if (fnm == "POLYGON" || fnm == "POLYGON16" || fnm == "POLYLINE" || fnm == "POLYLINE16" || fnm == "POLYLINETO" || fnm == "POLYLINETO16") {
  10674. loff += 16;
  10675. var ndf = fnm.startsWith("POLYGON"),
  10676. isTo = fnm.indexOf("TO") != -1;
  10677. var cnt = rU32(buff, loff);
  10678. loff += 4;
  10679. if (!isTo) exports.UDOC.G.newPath(gst);
  10680. loff = exports.FromEMF._drawPoly(buff, loff, cnt, gst, fnm.endsWith("16") ? 2 : 4, ndf, isTo);
  10681. if (!isTo) exports.FromEMF._draw(genv, gst, prms, ndf);
  10682. //console.log(prms, gst.lwidth);
  10683. //console.log(JSON.parse(JSON.stringify(gst.pth)));
  10684. } else if (fnm == "POLYPOLYGON16") {
  10685. loff += 16;
  10686. var ndf = fnm.startsWith("POLYPOLYGON"),
  10687. isTo = fnm.indexOf("TO") != -1;
  10688. var nop = rU32(buff, loff);
  10689. loff += 4;
  10690. loff += 4;
  10691. var pi = loff;
  10692. loff += nop * 4;
  10693. if (!isTo) exports.UDOC.G.newPath(gst);
  10694. for (var i = 0; i < nop; i++) {
  10695. var ppp = rU(buff, pi + i * 4);
  10696. loff = exports.FromEMF._drawPoly(buff, loff, ppp, gst, fnm.endsWith("16") ? 2 : 4, ndf, isTo);
  10697. }
  10698. if (!isTo) exports.FromEMF._draw(genv, gst, prms, ndf);
  10699. } else if (fnm == "POLYBEZIER" || fnm == "POLYBEZIER16" || fnm == "POLYBEZIERTO" || fnm == "POLYBEZIERTO16") {
  10700. loff += 16;
  10701. var is16 = fnm.endsWith("16"),
  10702. rC = is16 ? rI : rI32,
  10703. nl = is16 ? 2 : 4;
  10704. var cnt = rU32(buff, loff);
  10705. loff += 4;
  10706. if (fnm.indexOf("TO") == -1) {
  10707. exports.UDOC.G.moveTo(gst, rC(buff, loff), rC(buff, loff + nl));
  10708. loff += 2 * nl;
  10709. cnt--;
  10710. }
  10711. while (cnt > 0) {
  10712. exports.UDOC.G.curveTo(gst, rC(buff, loff), rC(buff, loff + nl), rC(buff, loff + 2 * nl), rC(buff, loff + 3 * nl), rC(buff, loff + 4 * nl), rC(buff, loff + 5 * nl));
  10713. loff += 6 * nl;
  10714. cnt -= 3;
  10715. }
  10716. //console.log(JSON.parse(JSON.stringify(gst.pth)));
  10717. } else if (fnm == "RECTANGLE" || fnm == "ELLIPSE") {
  10718. exports.UDOC.G.newPath(gst);
  10719. var bx = exports.FromEMF._readBox(buff, loff);
  10720. if (fnm == "RECTANGLE") {
  10721. exports.UDOC.G.moveTo(gst, bx[0], bx[1]);
  10722. exports.UDOC.G.lineTo(gst, bx[2], bx[1]);
  10723. exports.UDOC.G.lineTo(gst, bx[2], bx[3]);
  10724. exports.UDOC.G.lineTo(gst, bx[0], bx[3]);
  10725. } else {
  10726. var x = (bx[0] + bx[2]) / 2,
  10727. y = (bx[1] + bx[3]) / 2;
  10728. exports.UDOC.G.arc(gst, x, y, (bx[2] - bx[0]) / 2, 0, 2 * Math.PI, false);
  10729. }
  10730. exports.UDOC.G.closePath(gst);
  10731. exports.FromEMF._draw(genv, gst, prms, true);
  10732. //console.log(prms, gst.lwidth);
  10733. } else if (fnm == "FILLPATH") genv.Fill(gst, false);else if (fnm == "STROKEPATH") genv.Stroke(gst);else if (fnm == "STROKEANDFILLPATH") {
  10734. genv.Fill(gst, false);
  10735. genv.Stroke(gst);
  10736. } else if (fnm == "SETWORLDTRANSFORM" || fnm == "MODIFYWORLDTRANSFORM") {
  10737. var mat = [];
  10738. for (var i = 0; i < 6; i++) mat.push(rF32(buff, loff + i * 4));
  10739. loff += 24;
  10740. //console.log(fnm, gst.ctm.slice(0), mat);
  10741. if (fnm == "SETWORLDTRANSFORM") gst.ctm = mat;else {
  10742. var mod = rU32(buff, loff);
  10743. loff += 4;
  10744. if (mod == 2) {
  10745. var om = gst.ctm;
  10746. gst.ctm = mat;
  10747. exports.UDOC.M.concat(gst.ctm, om);
  10748. } else throw "e";
  10749. }
  10750. } else if (fnm == "SETSTRETCHBLTMODE") {
  10751. var sm = rU32(buff, loff);
  10752. loff += 4;
  10753. } else if (fnm == "STRETCHDIBITS") {
  10754. var bx = exports.FromEMF._readBox(buff, loff);
  10755. loff += 16;
  10756. var xD = rI32(buff, loff);
  10757. loff += 4;
  10758. var yD = rI32(buff, loff);
  10759. loff += 4;
  10760. var xS = rI32(buff, loff);
  10761. loff += 4;
  10762. var yS = rI32(buff, loff);
  10763. loff += 4;
  10764. var wS = rI32(buff, loff);
  10765. loff += 4;
  10766. var hS = rI32(buff, loff);
  10767. loff += 4;
  10768. var ofH = rU32(buff, loff) + off - 8;
  10769. loff += 4;
  10770. var szH = rU32(buff, loff);
  10771. loff += 4;
  10772. var ofB = rU32(buff, loff) + off - 8;
  10773. loff += 4;
  10774. var szB = rU32(buff, loff);
  10775. loff += 4;
  10776. var usg = rU32(buff, loff);
  10777. loff += 4;
  10778. if (usg != 0) throw "e";
  10779. var bop = rU32(buff, loff);
  10780. loff += 4;
  10781. var wD = rI32(buff, loff);
  10782. loff += 4;
  10783. var hD = rI32(buff, loff);
  10784. loff += 4; //console.log(bop, wD, hD);
  10785. //console.log(ofH, szH, ofB, szB, ofH+40);
  10786. //console.log(bx, xD,yD,wD,hD);
  10787. //console.log(xS,yS,wS,hS);
  10788. //console.log(ofH,szH,ofB,szB,usg,bop);
  10789. var hl = rU32(buff, ofH);
  10790. ofH += 4;
  10791. var w = rU32(buff, ofH);
  10792. ofH += 4;
  10793. var h = rU32(buff, ofH);
  10794. ofH += 4;
  10795. if (w != wS || h != hS) throw "e";
  10796. var ps = rU(buff, ofH);
  10797. ofH += 2;
  10798. var bc = rU(buff, ofH);
  10799. ofH += 2;
  10800. if (bc != 8 && bc != 24 && bc != 32) throw bc + " e";
  10801. var cpr = rU32(buff, ofH);
  10802. ofH += 4;
  10803. if (cpr != 0) throw cpr + " e";
  10804. var sz = rU32(buff, ofH);
  10805. ofH += 4;
  10806. var xpm = rU32(buff, ofH);
  10807. ofH += 4;
  10808. var ypm = rU32(buff, ofH);
  10809. ofH += 4;
  10810. var cu = rU32(buff, ofH);
  10811. ofH += 4;
  10812. var ci = rU32(buff, ofH);
  10813. ofH += 4; //console.log(hl, w, h, ps, bc, cpr, sz, xpm, ypm, cu, ci);
  10814. //console.log(hl,w,h,",",xS,yS,wS,hS,",",xD,yD,wD,hD,",",xpm,ypm);
  10815. var rl = Math.floor((w * ps * bc + 31 & ~31) / 8);
  10816. var img = new Uint8Array(w * h * 4);
  10817. if (bc == 8) {
  10818. for (var y = 0; y < h; y++) for (var x = 0; x < w; x++) {
  10819. var qi = y * w + x << 2,
  10820. ind = buff[ofB + (h - 1 - y) * rl + x] << 2;
  10821. img[qi] = buff[ofH + ind + 2];
  10822. img[qi + 1] = buff[ofH + ind + 1];
  10823. img[qi + 2] = buff[ofH + ind + 0];
  10824. img[qi + 3] = 255;
  10825. }
  10826. }
  10827. if (bc == 24) {
  10828. for (var y = 0; y < h; y++) for (var x = 0; x < w; x++) {
  10829. var qi = y * w + x << 2,
  10830. ti = ofB + (h - 1 - y) * rl + x * 3;
  10831. img[qi] = buff[ti + 2];
  10832. img[qi + 1] = buff[ti + 1];
  10833. img[qi + 2] = buff[ti + 0];
  10834. img[qi + 3] = 255;
  10835. }
  10836. }
  10837. if (bc == 32) {
  10838. for (var y = 0; y < h; y++) for (var x = 0; x < w; x++) {
  10839. var qi = y * w + x << 2,
  10840. ti = ofB + (h - 1 - y) * rl + x * 4;
  10841. img[qi] = buff[ti + 2];
  10842. img[qi + 1] = buff[ti + 1];
  10843. img[qi + 2] = buff[ti + 0];
  10844. img[qi + 3] = buff[ti + 3];
  10845. }
  10846. }
  10847. var ctm = gst.ctm.slice(0);
  10848. gst.ctm = [1, 0, 0, 1, 0, 0];
  10849. exports.UDOC.M.scale(gst.ctm, wD, -hD);
  10850. exports.UDOC.M.translate(gst.ctm, xD, yD + hD);
  10851. exports.UDOC.M.concat(gst.ctm, ctm);
  10852. genv.PutImage(gst, img, w, h);
  10853. gst.ctm = ctm;
  10854. } else {
  10855. console.log(fnm, siz);
  10856. }
  10857. if (obj != null) tab[oid] = obj;
  10858. off += siz - 8;
  10859. }
  10860. //genv.Stroke(gst);
  10861. genv.ShowPage();
  10862. genv.Done();
  10863. };
  10864. exports.FromEMF._readBox = function (buff, off) {
  10865. var b = [];
  10866. for (var i = 0; i < 4; i++) b[i] = exports.FromEMF.B.readInt(buff, off + i * 4);
  10867. return b;
  10868. };
  10869. exports.FromEMF._updateCtm = function (prms, gst) {
  10870. var mat = [1, 0, 0, 1, 0, 0];
  10871. var wbb = prms.wbb,
  10872. bb = prms.bb,
  10873. vbb = prms.vbb && prms.vbb.length == 4 ? prms.vbb : prms.bb;
  10874. //var y0 = bb[1], y1 = bb[3]; bb[1]=Math.min(y0,y1); bb[3]=Math.max(y0,y1);
  10875. exports.UDOC.M.translate(mat, -wbb[0], -wbb[1]);
  10876. exports.UDOC.M.scale(mat, 1 / wbb[2], 1 / wbb[3]);
  10877. exports.UDOC.M.scale(mat, vbb[2], vbb[3]);
  10878. //UDOC.M.scale(mat, vbb[2]/(bb[2]-bb[0]), vbb[3]/(bb[3]-bb[1]));
  10879. //UDOC.M.scale(mat, bb[2]-bb[0],bb[3]-bb[1]);
  10880. gst.ctm = mat;
  10881. };
  10882. exports.FromEMF._draw = function (genv, gst, prms, needFill) {
  10883. if (prms.fill && needFill) genv.Fill(gst, false);
  10884. if (prms.strk && gst.lwidth != 0) genv.Stroke(gst);
  10885. };
  10886. exports.FromEMF._drawPoly = function (buff, off, ppp, gst, nl, clos, justLine) {
  10887. var rS = nl == 2 ? exports.FromEMF.B.readShort : exports.FromEMF.B.readInt;
  10888. for (var j = 0; j < ppp; j++) {
  10889. var px = rS(buff, off);
  10890. off += nl;
  10891. var py = rS(buff, off);
  10892. off += nl;
  10893. if (j == 0 && !justLine) exports.UDOC.G.moveTo(gst, px, py);else exports.UDOC.G.lineTo(gst, px, py);
  10894. }
  10895. if (clos) exports.UDOC.G.closePath(gst);
  10896. return off;
  10897. };
  10898. exports.FromEMF.B = {
  10899. uint8: new Uint8Array(4),
  10900. readShort: function readShort(buff, p) {
  10901. var u8 = exports.FromEMF.B.uint8;
  10902. u8[0] = buff[p];
  10903. u8[1] = buff[p + 1];
  10904. return exports.FromEMF.B.int16[0];
  10905. },
  10906. readUshort: function readUshort(buff, p) {
  10907. var u8 = exports.FromEMF.B.uint8;
  10908. u8[0] = buff[p];
  10909. u8[1] = buff[p + 1];
  10910. return exports.FromEMF.B.uint16[0];
  10911. },
  10912. readInt: function readInt(buff, p) {
  10913. var u8 = exports.FromEMF.B.uint8;
  10914. u8[0] = buff[p];
  10915. u8[1] = buff[p + 1];
  10916. u8[2] = buff[p + 2];
  10917. u8[3] = buff[p + 3];
  10918. return exports.FromEMF.B.int32[0];
  10919. },
  10920. readUint: function readUint(buff, p) {
  10921. var u8 = exports.FromEMF.B.uint8;
  10922. u8[0] = buff[p];
  10923. u8[1] = buff[p + 1];
  10924. u8[2] = buff[p + 2];
  10925. u8[3] = buff[p + 3];
  10926. return exports.FromEMF.B.uint32[0];
  10927. },
  10928. readFloat: function readFloat(buff, p) {
  10929. var u8 = exports.FromEMF.B.uint8;
  10930. u8[0] = buff[p];
  10931. u8[1] = buff[p + 1];
  10932. u8[2] = buff[p + 2];
  10933. u8[3] = buff[p + 3];
  10934. return exports.FromEMF.B.flot32[0];
  10935. },
  10936. readASCII: function readASCII(buff, p, l) {
  10937. var s = "";
  10938. for (var i = 0; i < l; i++) s += String.fromCharCode(buff[p + i]);
  10939. return s;
  10940. }
  10941. };
  10942. exports.FromEMF.B.int16 = new Int16Array(exports.FromEMF.B.uint8.buffer);
  10943. exports.FromEMF.B.uint16 = new Uint16Array(exports.FromEMF.B.uint8.buffer);
  10944. exports.FromEMF.B.int32 = new Int32Array(exports.FromEMF.B.uint8.buffer);
  10945. exports.FromEMF.B.uint32 = new Uint32Array(exports.FromEMF.B.uint8.buffer);
  10946. exports.FromEMF.B.flot32 = new Float32Array(exports.FromEMF.B.uint8.buffer);
  10947. exports.FromEMF.C = {
  10948. EMR_HEADER: 0x00000001,
  10949. EMR_POLYBEZIER: 0x00000002,
  10950. EMR_POLYGON: 0x00000003,
  10951. EMR_POLYLINE: 0x00000004,
  10952. EMR_POLYBEZIERTO: 0x00000005,
  10953. EMR_POLYLINETO: 0x00000006,
  10954. EMR_POLYPOLYLINE: 0x00000007,
  10955. EMR_POLYPOLYGON: 0x00000008,
  10956. EMR_SETWINDOWEXTEX: 0x00000009,
  10957. EMR_SETWINDOWORGEX: 0x0000000A,
  10958. EMR_SETVIEWPORTEXTEX: 0x0000000B,
  10959. EMR_SETVIEWPORTORGEX: 0x0000000C,
  10960. EMR_SETBRUSHORGEX: 0x0000000D,
  10961. EMR_EOF: 0x0000000E,
  10962. EMR_SETPIXELV: 0x0000000F,
  10963. EMR_SETMAPPERFLAGS: 0x00000010,
  10964. EMR_SETMAPMODE: 0x00000011,
  10965. EMR_SETBKMODE: 0x00000012,
  10966. EMR_SETPOLYFILLMODE: 0x00000013,
  10967. EMR_SETROP2: 0x00000014,
  10968. EMR_SETSTRETCHBLTMODE: 0x00000015,
  10969. EMR_SETTEXTALIGN: 0x00000016,
  10970. EMR_SETCOLORADJUSTMENT: 0x00000017,
  10971. EMR_SETTEXTCOLOR: 0x00000018,
  10972. EMR_SETBKCOLOR: 0x00000019,
  10973. EMR_OFFSETCLIPRGN: 0x0000001A,
  10974. EMR_MOVETOEX: 0x0000001B,
  10975. EMR_SETMETARGN: 0x0000001C,
  10976. EMR_EXCLUDECLIPRECT: 0x0000001D,
  10977. EMR_INTERSECTCLIPRECT: 0x0000001E,
  10978. EMR_SCALEVIEWPORTEXTEX: 0x0000001F,
  10979. EMR_SCALEWINDOWEXTEX: 0x00000020,
  10980. EMR_SAVEDC: 0x00000021,
  10981. EMR_RESTOREDC: 0x00000022,
  10982. EMR_SETWORLDTRANSFORM: 0x00000023,
  10983. EMR_MODIFYWORLDTRANSFORM: 0x00000024,
  10984. EMR_SELECTOBJECT: 0x00000025,
  10985. EMR_CREATEPEN: 0x00000026,
  10986. EMR_CREATEBRUSHINDIRECT: 0x00000027,
  10987. EMR_DELETEOBJECT: 0x00000028,
  10988. EMR_ANGLEARC: 0x00000029,
  10989. EMR_ELLIPSE: 0x0000002A,
  10990. EMR_RECTANGLE: 0x0000002B,
  10991. EMR_ROUNDRECT: 0x0000002C,
  10992. EMR_ARC: 0x0000002D,
  10993. EMR_CHORD: 0x0000002E,
  10994. EMR_PIE: 0x0000002F,
  10995. EMR_SELECTPALETTE: 0x00000030,
  10996. EMR_CREATEPALETTE: 0x00000031,
  10997. EMR_SETPALETTEENTRIES: 0x00000032,
  10998. EMR_RESIZEPALETTE: 0x00000033,
  10999. EMR_REALIZEPALETTE: 0x00000034,
  11000. EMR_EXTFLOODFILL: 0x00000035,
  11001. EMR_LINETO: 0x00000036,
  11002. EMR_ARCTO: 0x00000037,
  11003. EMR_POLYDRAW: 0x00000038,
  11004. EMR_SETARCDIRECTION: 0x00000039,
  11005. EMR_SETMITERLIMIT: 0x0000003A,
  11006. EMR_BEGINPATH: 0x0000003B,
  11007. EMR_ENDPATH: 0x0000003C,
  11008. EMR_CLOSEFIGURE: 0x0000003D,
  11009. EMR_FILLPATH: 0x0000003E,
  11010. EMR_STROKEANDFILLPATH: 0x0000003F,
  11011. EMR_STROKEPATH: 0x00000040,
  11012. EMR_FLATTENPATH: 0x00000041,
  11013. EMR_WIDENPATH: 0x00000042,
  11014. EMR_SELECTCLIPPATH: 0x00000043,
  11015. EMR_ABORTPATH: 0x00000044,
  11016. EMR_COMMENT: 0x00000046,
  11017. EMR_FILLRGN: 0x00000047,
  11018. EMR_FRAMERGN: 0x00000048,
  11019. EMR_INVERTRGN: 0x00000049,
  11020. EMR_PAINTRGN: 0x0000004A,
  11021. EMR_EXTSELECTCLIPRGN: 0x0000004B,
  11022. EMR_BITBLT: 0x0000004C,
  11023. EMR_STRETCHBLT: 0x0000004D,
  11024. EMR_MASKBLT: 0x0000004E,
  11025. EMR_PLGBLT: 0x0000004F,
  11026. EMR_SETDIBITSTODEVICE: 0x00000050,
  11027. EMR_STRETCHDIBITS: 0x00000051,
  11028. EMR_EXTCREATEFONTINDIRECTW: 0x00000052,
  11029. EMR_EXTTEXTOUTA: 0x00000053,
  11030. EMR_EXTTEXTOUTW: 0x00000054,
  11031. EMR_POLYBEZIER16: 0x00000055,
  11032. EMR_POLYGON16: 0x00000056,
  11033. EMR_POLYLINE16: 0x00000057,
  11034. EMR_POLYBEZIERTO16: 0x00000058,
  11035. EMR_POLYLINETO16: 0x00000059,
  11036. EMR_POLYPOLYLINE16: 0x0000005A,
  11037. EMR_POLYPOLYGON16: 0x0000005B,
  11038. EMR_POLYDRAW16: 0x0000005C,
  11039. EMR_CREATEMONOBRUSH: 0x0000005D,
  11040. EMR_CREATEDIBPATTERNBRUSHPT: 0x0000005E,
  11041. EMR_EXTCREATEPEN: 0x0000005F,
  11042. EMR_POLYTEXTOUTA: 0x00000060,
  11043. EMR_POLYTEXTOUTW: 0x00000061,
  11044. EMR_SETICMMODE: 0x00000062,
  11045. EMR_CREATECOLORSPACE: 0x00000063,
  11046. EMR_SETCOLORSPACE: 0x00000064,
  11047. EMR_DELETECOLORSPACE: 0x00000065,
  11048. EMR_GLSRECORD: 0x00000066,
  11049. EMR_GLSBOUNDEDRECORD: 0x00000067,
  11050. EMR_PIXELFORMAT: 0x00000068,
  11051. EMR_DRAWESCAPE: 0x00000069,
  11052. EMR_EXTESCAPE: 0x0000006A,
  11053. EMR_SMALLTEXTOUT: 0x0000006C,
  11054. EMR_FORCEUFIMAPPING: 0x0000006D,
  11055. EMR_NAMEDESCAPE: 0x0000006E,
  11056. EMR_COLORCORRECTPALETTE: 0x0000006F,
  11057. EMR_SETICMPROFILEA: 0x00000070,
  11058. EMR_SETICMPROFILEW: 0x00000071,
  11059. EMR_ALPHABLEND: 0x00000072,
  11060. EMR_SETLAYOUT: 0x00000073,
  11061. EMR_TRANSPARENTBLT: 0x00000074,
  11062. EMR_GRADIENTFILL: 0x00000076,
  11063. EMR_SETLINKEDUFIS: 0x00000077,
  11064. EMR_SETTEXTJUSTIFICATION: 0x00000078,
  11065. EMR_COLORMATCHTOTARGETW: 0x00000079,
  11066. EMR_CREATECOLORSPACEW: 0x0000007A
  11067. };
  11068. exports.FromEMF.K = [];
  11069. // (function() {
  11070. // var inp, out, stt;
  11071. // inp = FromEMF.C; out = FromEMF.K; stt=4;
  11072. // for(var p in inp) out[inp[p]] = p.slice(stt);
  11073. // } )();
  11074. exports.ToContext2D = function (needPage, scale) {
  11075. this.canvas = document.createElement("canvas");
  11076. this.ctx = this.canvas.getContext("2d");
  11077. this.bb = null;
  11078. this.currPage = 0;
  11079. this.needPage = needPage;
  11080. this.scale = scale;
  11081. };
  11082. exports.ToContext2D.prototype.StartPage = function (x, y, w, h) {
  11083. if (this.currPage != this.needPage) return;
  11084. this.bb = [x, y, w, h];
  11085. var scl = this.scale,
  11086. dpr = window.devicePixelRatio;
  11087. var cnv = this.canvas,
  11088. ctx = this.ctx;
  11089. cnv.width = Math.round(w * scl);
  11090. cnv.height = Math.round(h * scl);
  11091. ctx.translate(0, h * scl);
  11092. ctx.scale(scl, -scl);
  11093. cnv.setAttribute("style", "border:1px solid; width:" + cnv.width / dpr + "px; height:" + cnv.height / dpr + "px");
  11094. };
  11095. exports.ToContext2D.prototype.Fill = function (gst, evenOdd) {
  11096. if (this.currPage != this.needPage) return;
  11097. var ctx = this.ctx;
  11098. ctx.beginPath();
  11099. this._setStyle(gst, ctx);
  11100. this._draw(gst.pth, ctx);
  11101. ctx.fill();
  11102. };
  11103. exports.ToContext2D.prototype.Stroke = function (gst) {
  11104. if (this.currPage != this.needPage) return;
  11105. var ctx = this.ctx;
  11106. ctx.beginPath();
  11107. this._setStyle(gst, ctx);
  11108. this._draw(gst.pth, ctx);
  11109. ctx.stroke();
  11110. };
  11111. exports.ToContext2D.prototype.PutText = function (gst, str, stw) {
  11112. if (this.currPage != this.needPage) return;
  11113. var scl = this._scale(gst.ctm);
  11114. var ctx = this.ctx;
  11115. this._setStyle(gst, ctx);
  11116. ctx.save();
  11117. var m = [1, 0, 0, -1, 0, 0];
  11118. this._concat(m, gst.font.Tm);
  11119. this._concat(m, gst.ctm);
  11120. //console.log(str, m, gst); throw "e";
  11121. ctx.transform(m[0], m[1], m[2], m[3], m[4], m[5]);
  11122. ctx.fillText(str, 0, 0);
  11123. ctx.restore();
  11124. };
  11125. exports.ToContext2D.prototype.PutImage = function (gst, buff, w, h, msk) {
  11126. if (this.currPage != this.needPage) return;
  11127. var ctx = this.ctx;
  11128. if (buff.length == w * h * 4) {
  11129. buff = buff.slice(0);
  11130. if (msk && msk.length == w * h * 4) for (var i = 0; i < buff.length; i += 4) buff[i + 3] = msk[i + 1];
  11131. var cnv = document.createElement("canvas"),
  11132. cctx = cnv.getContext("2d");
  11133. cnv.width = w;
  11134. cnv.height = h;
  11135. var imgd = cctx.createImageData(w, h);
  11136. for (var i = 0; i < buff.length; i++) imgd.data[i] = buff[i];
  11137. cctx.putImageData(imgd, 0, 0);
  11138. ctx.save();
  11139. var m = [1, 0, 0, 1, 0, 0];
  11140. this._concat(m, [1 / w, 0, 0, -1 / h, 0, 1]);
  11141. this._concat(m, gst.ctm);
  11142. ctx.transform(m[0], m[1], m[2], m[3], m[4], m[5]);
  11143. ctx.drawImage(cnv, 0, 0);
  11144. ctx.restore();
  11145. }
  11146. };
  11147. exports.ToContext2D.prototype.ShowPage = function () {
  11148. this.currPage++;
  11149. };
  11150. exports.ToContext2D.prototype.Done = function () {};
  11151. function _flt(n) {
  11152. return "" + parseFloat(n.toFixed(2));
  11153. }
  11154. exports.ToContext2D.prototype._setStyle = function (gst, ctx) {
  11155. var scl = this._scale(gst.ctm);
  11156. ctx.fillStyle = this._getFill(gst.colr, gst.ca, ctx);
  11157. ctx.strokeStyle = this._getFill(gst.COLR, gst.CA, ctx);
  11158. ctx.lineCap = ["butt", "round", "square"][gst.lcap];
  11159. ctx.lineJoin = ["miter", "round", "bevel"][gst.ljoin];
  11160. ctx.lineWidth = gst.lwidth * scl;
  11161. var dsh = gst.dash.slice(0);
  11162. for (var i = 0; i < dsh.length; i++) dsh[i] = _flt(dsh[i] * scl);
  11163. ctx.setLineDash(dsh);
  11164. ctx.miterLimit = gst.mlimit * scl;
  11165. var fn = gst.font.Tf,
  11166. ln = fn.toLowerCase();
  11167. var p0 = ln.indexOf("bold") != -1 ? "bold " : "";
  11168. var p1 = ln.indexOf("italic") != -1 || ln.indexOf("oblique") != -1 ? "italic " : "";
  11169. ctx.font = p0 + p1 + gst.font.Tfs + "px \"" + fn + "\"";
  11170. };
  11171. exports.ToContext2D.prototype._getFill = function (colr, ca, ctx) {
  11172. if (colr.typ == null) return this._colr(colr, ca);else {
  11173. var grd = colr,
  11174. crd = grd.crds,
  11175. mat = grd.mat,
  11176. scl = this._scale(mat),
  11177. gf;
  11178. if (grd.typ == "lin") {
  11179. var p0 = this._multPoint(mat, crd.slice(0, 2)),
  11180. p1 = this._multPoint(mat, crd.slice(2));
  11181. gf = ctx.createLinearGradient(p0[0], p0[1], p1[0], p1[1]);
  11182. } else if (grd.typ == "rad") {
  11183. var p0 = this._multPoint(mat, crd.slice(0, 2)),
  11184. p1 = this._multPoint(mat, crd.slice(3));
  11185. gf = ctx.createRadialGradient(p0[0], p0[1], crd[2] * scl, p1[0], p1[1], crd[5] * scl);
  11186. }
  11187. for (var i = 0; i < grd.grad.length; i++) gf.addColorStop(grd.grad[i][0], this._colr(grd.grad[i][1], ca));
  11188. return gf;
  11189. }
  11190. };
  11191. exports.ToContext2D.prototype._colr = function (c, a) {
  11192. return "rgba(" + Math.round(c[0] * 255) + "," + Math.round(c[1] * 255) + "," + Math.round(c[2] * 255) + "," + a + ")";
  11193. };
  11194. exports.ToContext2D.prototype._scale = function (m) {
  11195. return Math.sqrt(Math.abs(m[0] * m[3] - m[1] * m[2]));
  11196. };
  11197. exports.ToContext2D.prototype._concat = function (m, w) {
  11198. var a = m[0],
  11199. b = m[1],
  11200. c = m[2],
  11201. d = m[3],
  11202. tx = m[4],
  11203. ty = m[5];
  11204. m[0] = a * w[0] + b * w[2];
  11205. m[1] = a * w[1] + b * w[3];
  11206. m[2] = c * w[0] + d * w[2];
  11207. m[3] = c * w[1] + d * w[3];
  11208. m[4] = tx * w[0] + ty * w[2] + w[4];
  11209. m[5] = tx * w[1] + ty * w[3] + w[5];
  11210. };
  11211. exports.ToContext2D.prototype._multPoint = function (m, p) {
  11212. var x = p[0],
  11213. y = p[1];
  11214. return [x * m[0] + y * m[2] + m[4], x * m[1] + y * m[3] + m[5]];
  11215. }, exports.ToContext2D.prototype._draw = function (path, ctx) {
  11216. var c = 0,
  11217. crds = path.crds;
  11218. for (var j = 0; j < path.cmds.length; j++) {
  11219. var cmd = path.cmds[j];
  11220. if (cmd == "M") {
  11221. ctx.moveTo(crds[c], crds[c + 1]);
  11222. c += 2;
  11223. } else if (cmd == "L") {
  11224. ctx.lineTo(crds[c], crds[c + 1]);
  11225. c += 2;
  11226. } else if (cmd == "C") {
  11227. ctx.bezierCurveTo(crds[c], crds[c + 1], crds[c + 2], crds[c + 3], crds[c + 4], crds[c + 5]);
  11228. c += 6;
  11229. } else if (cmd == "Q") {
  11230. ctx.quadraticCurveTo(crds[c], crds[c + 1], crds[c + 2], crds[c + 3]);
  11231. c += 4;
  11232. } else if (cmd == "Z") {
  11233. ctx.closePath();
  11234. }
  11235. }
  11236. };
  11237. },{}],49:[function(require,module,exports){
  11238. "use strict";
  11239. Object.defineProperty(exports, "__esModule", {
  11240. value: true
  11241. });
  11242. exports.getMultiFormulaValue = exports.getPeelOffX14 = exports.getTransR1C1ToSequence = exports.getSingleSequenceToNum = exports.getSqrefRawArrFormat = exports.getRegionSequence = exports.getMultiSequenceToNum = exports.getBinaryContent = exports.isContainMultiType = exports.isKoera = exports.isJapanese = exports.isChinese = exports.fromulaRef = exports.escapeCharacter = exports.generateRandomIndex = exports.LightenDarkenColor = exports.getRowHeightPixel = exports.getColumnWidthPixel = exports.getXmlAttibute = exports.getPxByEMUs = exports.getptToPxRatioByDPI = exports.parseCellReference = exports.getcellrange = exports.getRangetxt = void 0;
  11243. var constant_1 = require("./constant");
  11244. function getRangetxt(range, sheettxt) {
  11245. var row0 = range["row"][0],
  11246. row1 = range["row"][1];
  11247. var column0 = range["column"][0],
  11248. column1 = range["column"][1];
  11249. if (row0 == null && row1 == null) {
  11250. return sheettxt + chatatABC(column0) + ":" + chatatABC(column1);
  11251. } else if (column0 == null && column1 == null) {
  11252. return sheettxt + (row0 + 1) + ":" + (row1 + 1);
  11253. } else {
  11254. if (column0 == column1 && row0 == row1) {
  11255. return sheettxt + chatatABC(column0) + (row0 + 1);
  11256. } else {
  11257. return sheettxt + chatatABC(column0) + (row0 + 1) + ":" + chatatABC(column1) + (row1 + 1);
  11258. }
  11259. }
  11260. }
  11261. exports.getRangetxt = getRangetxt;
  11262. function getcellrange(txt, sheets, sheetId) {
  11263. if (sheets === void 0) {
  11264. sheets = {};
  11265. }
  11266. if (sheetId === void 0) {
  11267. sheetId = "1";
  11268. }
  11269. var val = txt.split("!");
  11270. var sheettxt = "",
  11271. rangetxt = "",
  11272. sheetIndex = -1;
  11273. if (val.length > 1) {
  11274. sheettxt = val[0];
  11275. rangetxt = val[1];
  11276. var si = sheets[sheettxt];
  11277. if (si == null) {
  11278. sheetIndex = parseInt(sheetId);
  11279. } else {
  11280. sheetIndex = parseInt(si);
  11281. }
  11282. } else {
  11283. sheetIndex = parseInt(sheetId);
  11284. rangetxt = val[0];
  11285. }
  11286. if (rangetxt.indexOf(":") == -1) {
  11287. var row = parseInt(rangetxt.replace(/[^0-9]/g, "")) - 1;
  11288. var col = ABCatNum(rangetxt.replace(/[^A-Za-z]/g, ""));
  11289. if (!isNaN(row) && !isNaN(col)) {
  11290. return {
  11291. row: [row, row],
  11292. column: [col, col],
  11293. sheetIndex: sheetIndex
  11294. };
  11295. } else {
  11296. return null;
  11297. }
  11298. } else {
  11299. var rangetxtArray = rangetxt.split(":");
  11300. var row = [],
  11301. col = [];
  11302. row[0] = parseInt(rangetxtArray[0].replace(/[^0-9]/g, "")) - 1;
  11303. row[1] = parseInt(rangetxtArray[1].replace(/[^0-9]/g, "")) - 1;
  11304. // if (isNaN(row[0])) {
  11305. // row[0] = 0;
  11306. // }
  11307. // if (isNaN(row[1])) {
  11308. // row[1] = sheetdata.length - 1;
  11309. // }
  11310. if (row[0] > row[1]) {
  11311. return null;
  11312. }
  11313. col[0] = ABCatNum(rangetxtArray[0].replace(/[^A-Za-z]/g, ""));
  11314. col[1] = ABCatNum(rangetxtArray[1].replace(/[^A-Za-z]/g, ""));
  11315. // if (isNaN(col[0])) {
  11316. // col[0] = 0;
  11317. // }
  11318. // if (isNaN(col[1])) {
  11319. // col[1] = sheetdata[0].length - 1;
  11320. // }
  11321. if (col[0] > col[1]) {
  11322. return null;
  11323. }
  11324. return {
  11325. row: row,
  11326. column: col,
  11327. sheetIndex: sheetIndex
  11328. };
  11329. }
  11330. }
  11331. exports.getcellrange = getcellrange;
  11332. function parseCellReference(cellRef) {
  11333. var regex = /^([A-Z]+)(\d+)$/;
  11334. var match = cellRef.match(regex);
  11335. if (!match) {
  11336. throw new Error("Invalid cell reference: " + cellRef);
  11337. }
  11338. var columnRef = match[1];
  11339. var rowRef = parseInt(match[2], 10);
  11340. // Convert column reference to column number (0-based)
  11341. var columnNumber = 0;
  11342. for (var i = 0; i < columnRef.length; i++) {
  11343. columnNumber = columnNumber * 26 + (columnRef.charCodeAt(i) - "A".charCodeAt(0) + 1);
  11344. }
  11345. columnNumber -= 1; // Convert to 0-based index
  11346. // Row number is already 1-based, so subtract 1 to make it 0-based
  11347. var rowNumber = rowRef - 1;
  11348. return {
  11349. r: rowNumber,
  11350. c: columnNumber
  11351. };
  11352. }
  11353. exports.parseCellReference = parseCellReference;
  11354. //列下标 字母转数字
  11355. function ABCatNum(abc) {
  11356. abc = abc.toUpperCase();
  11357. var abc_len = abc.length;
  11358. if (abc_len == 0) {
  11359. return NaN;
  11360. }
  11361. var abc_array = abc.split("");
  11362. var wordlen = constant_1.columeHeader_word.length;
  11363. var ret = 0;
  11364. for (var i = abc_len - 1; i >= 0; i--) {
  11365. if (i == abc_len - 1) {
  11366. ret += constant_1.columeHeader_word_index[abc_array[i]];
  11367. } else {
  11368. ret += Math.pow(wordlen, abc_len - i - 1) * (constant_1.columeHeader_word_index[abc_array[i]] + 1);
  11369. }
  11370. }
  11371. return ret;
  11372. }
  11373. //列下标 数字转字母
  11374. function chatatABC(index) {
  11375. var wordlen = constant_1.columeHeader_word.length;
  11376. if (index < wordlen) {
  11377. return constant_1.columeHeader_word[index];
  11378. } else {
  11379. var last = 0,
  11380. pre = 0,
  11381. ret = "";
  11382. var i = 1,
  11383. n = 0;
  11384. while (index >= wordlen / (wordlen - 1) * (Math.pow(wordlen, i++) - 1)) {
  11385. n = i;
  11386. }
  11387. var index_ab = index - wordlen / (wordlen - 1) * (Math.pow(wordlen, n - 1) - 1); //970
  11388. last = index_ab + 1;
  11389. for (var x = n; x > 0; x--) {
  11390. var last1 = last,
  11391. x1 = x; //-702=268, 3
  11392. if (x == 1) {
  11393. last1 = last1 % wordlen;
  11394. if (last1 == 0) {
  11395. last1 = 26;
  11396. }
  11397. return ret + constant_1.columeHeader_word[last1 - 1];
  11398. }
  11399. last1 = Math.ceil(last1 / Math.pow(wordlen, x - 1));
  11400. //last1 = last1 % wordlen;
  11401. ret += constant_1.columeHeader_word[last1 - 1];
  11402. if (x > 1) {
  11403. last = last - (last1 - 1) * wordlen;
  11404. }
  11405. }
  11406. }
  11407. }
  11408. /**
  11409. * @return ratio, default 0.75 1in = 2.54cm = 25.4mm = 72pt = 6pc, pt = 1/72 In, px = 1/dpi In
  11410. */
  11411. function getptToPxRatioByDPI() {
  11412. return 72 / 96;
  11413. }
  11414. exports.getptToPxRatioByDPI = getptToPxRatioByDPI;
  11415. /**
  11416. * @emus EMUs, Excel drawing unit
  11417. * @return pixel
  11418. */
  11419. function getPxByEMUs(emus) {
  11420. if (emus == null) {
  11421. return 0;
  11422. }
  11423. var inch = emus / 914400;
  11424. var pt = inch * 72;
  11425. var px = pt / getptToPxRatioByDPI();
  11426. return px;
  11427. }
  11428. exports.getPxByEMUs = getPxByEMUs;
  11429. /**
  11430. * @dom xml attribute object
  11431. * @attr attribute name
  11432. * @d if attribute is null, return default value
  11433. * @return attribute value
  11434. */
  11435. function getXmlAttibute(dom, attr, d) {
  11436. var value = dom[attr];
  11437. value = value == null ? d : value;
  11438. return value;
  11439. }
  11440. exports.getXmlAttibute = getXmlAttibute;
  11441. /**
  11442. * @columnWidth Excel column width
  11443. * @return pixel column width
  11444. */
  11445. function getColumnWidthPixel(columnWidth) {
  11446. var pix = Math.round((columnWidth - 0.83) * 8 + 5);
  11447. return pix;
  11448. }
  11449. exports.getColumnWidthPixel = getColumnWidthPixel;
  11450. /**
  11451. * @rowHeight Excel row height
  11452. * @return pixel row height
  11453. */
  11454. function getRowHeightPixel(rowHeight) {
  11455. var pix = Math.round(rowHeight / getptToPxRatioByDPI());
  11456. return pix;
  11457. }
  11458. exports.getRowHeightPixel = getRowHeightPixel;
  11459. function LightenDarkenColor(sixColor, tint) {
  11460. var hex = sixColor.substring(sixColor.length - 6, sixColor.length);
  11461. var rgbArray = hexToRgbArray("#" + hex);
  11462. var hslArray = rgbToHsl(rgbArray[0], rgbArray[1], rgbArray[2]);
  11463. if (tint > 0) {
  11464. hslArray[2] = hslArray[2] * (1.0 - tint) + tint;
  11465. } else if (tint < 0) {
  11466. hslArray[2] = hslArray[2] * (1.0 + tint);
  11467. } else {
  11468. return "#" + hex;
  11469. }
  11470. var newRgbArray = hslToRgb(hslArray[0], hslArray[1], hslArray[2]);
  11471. return rgbToHex("RGB(" + newRgbArray.join(",") + ")");
  11472. }
  11473. exports.LightenDarkenColor = LightenDarkenColor;
  11474. function rgbToHex(rgb) {
  11475. //十六进制颜色值的正则表达式
  11476. var reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/;
  11477. // 如果是rgb颜色表示
  11478. if (/^(rgb|RGB)/.test(rgb)) {
  11479. var aColor = rgb.replace(/(?:\(|\)|rgb|RGB)*/g, "").split(",");
  11480. var strHex = "#";
  11481. for (var i = 0; i < aColor.length; i++) {
  11482. var hex = Number(aColor[i]).toString(16);
  11483. if (hex.length < 2) {
  11484. hex = "0" + hex;
  11485. }
  11486. strHex += hex;
  11487. }
  11488. if (strHex.length !== 7) {
  11489. strHex = rgb;
  11490. }
  11491. return strHex;
  11492. } else if (reg.test(rgb)) {
  11493. var aNum = rgb.replace(/#/, "").split("");
  11494. if (aNum.length === 6) {
  11495. return rgb;
  11496. } else if (aNum.length === 3) {
  11497. var numHex = "#";
  11498. for (var i = 0; i < aNum.length; i += 1) {
  11499. numHex += aNum[i] + aNum[i];
  11500. }
  11501. return numHex;
  11502. }
  11503. }
  11504. return rgb;
  11505. }
  11506. function hexToRgb(hex) {
  11507. var sColor = hex.toLowerCase();
  11508. //十六进制颜色值的正则表达式
  11509. var reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/;
  11510. // 如果是16进制颜色
  11511. if (sColor && reg.test(sColor)) {
  11512. if (sColor.length === 4) {
  11513. var sColorNew = "#";
  11514. for (var i = 1; i < 4; i += 1) {
  11515. sColorNew += sColor.slice(i, i + 1).concat(sColor.slice(i, i + 1));
  11516. }
  11517. sColor = sColorNew;
  11518. }
  11519. //处理六位的颜色值
  11520. var sColorChange = [];
  11521. for (var i = 1; i < 7; i += 2) {
  11522. sColorChange.push(parseInt("0x" + sColor.slice(i, i + 2)));
  11523. }
  11524. return "RGB(" + sColorChange.join(",") + ")";
  11525. }
  11526. return sColor;
  11527. }
  11528. function hexToRgbArray(hex) {
  11529. var sColor = hex.toLowerCase();
  11530. //十六进制颜色值的正则表达式
  11531. var reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/;
  11532. // 如果是16进制颜色
  11533. if (sColor && reg.test(sColor)) {
  11534. if (sColor.length === 4) {
  11535. var sColorNew = "#";
  11536. for (var i = 1; i < 4; i += 1) {
  11537. sColorNew += sColor.slice(i, i + 1).concat(sColor.slice(i, i + 1));
  11538. }
  11539. sColor = sColorNew;
  11540. }
  11541. //处理六位的颜色值
  11542. var sColorChange = [];
  11543. for (var i = 1; i < 7; i += 2) {
  11544. sColorChange.push(parseInt("0x" + sColor.slice(i, i + 2)));
  11545. }
  11546. return sColorChange;
  11547. }
  11548. return null;
  11549. }
  11550. /**
  11551. * HSL颜色值转换为RGB.
  11552. * 换算公式改编自 http://en.wikipedia.org/wiki/HSL_color_space.
  11553. * h, s, 和 l 设定在 [0, 1] 之间
  11554. * 返回的 r, g, 和 b 在 [0, 255]之间
  11555. *
  11556. * @param Number h 色相
  11557. * @param Number s 饱和度
  11558. * @param Number l 亮度
  11559. * @return Array RGB色值数值
  11560. */
  11561. function hslToRgb(h, s, l) {
  11562. var r, g, b;
  11563. if (s == 0) {
  11564. r = g = b = l; // achromatic
  11565. } else {
  11566. var hue2rgb = function hue2rgb(p, q, t) {
  11567. if (t < 0) t += 1;
  11568. if (t > 1) t -= 1;
  11569. if (t < 1 / 6) return p + (q - p) * 6 * t;
  11570. if (t < 1 / 2) return q;
  11571. if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;
  11572. return p;
  11573. };
  11574. var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
  11575. var p = 2 * l - q;
  11576. r = hue2rgb(p, q, h + 1 / 3);
  11577. g = hue2rgb(p, q, h);
  11578. b = hue2rgb(p, q, h - 1 / 3);
  11579. }
  11580. return [Math.round(r * 255), Math.round(g * 255), Math.round(b * 255)];
  11581. }
  11582. /**
  11583. * RGB 颜色值转换为 HSL.
  11584. * 转换公式参考自 http://en.wikipedia.org/wiki/HSL_color_space.
  11585. * r, g, 和 b 需要在 [0, 255] 范围内
  11586. * 返回的 h, s, 和 l 在 [0, 1] 之间
  11587. *
  11588. * @param Number r 红色色值
  11589. * @param Number g 绿色色值
  11590. * @param Number b 蓝色色值
  11591. * @return Array HSL各值数组
  11592. */
  11593. function rgbToHsl(r, g, b) {
  11594. r /= 255, g /= 255, b /= 255;
  11595. var max = Math.max(r, g, b),
  11596. min = Math.min(r, g, b);
  11597. var h,
  11598. s,
  11599. l = (max + min) / 2;
  11600. if (max == min) {
  11601. h = s = 0; // achromatic
  11602. } else {
  11603. var d = max - min;
  11604. s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
  11605. switch (max) {
  11606. case r:
  11607. h = (g - b) / d + (g < b ? 6 : 0);
  11608. break;
  11609. case g:
  11610. h = (b - r) / d + 2;
  11611. break;
  11612. case b:
  11613. h = (r - g) / d + 4;
  11614. break;
  11615. }
  11616. h /= 6;
  11617. }
  11618. return [h, s, l];
  11619. }
  11620. function generateRandomIndex(prefix) {
  11621. if (prefix == null) {
  11622. prefix = "Sheet";
  11623. }
  11624. var userAgent = window.navigator.userAgent.replace(/[^a-zA-Z0-9]/g, "").split("");
  11625. var mid = "";
  11626. for (var i = 0; i < 5; i++) {
  11627. mid += userAgent[Math.round(Math.random() * (userAgent.length - 1))];
  11628. }
  11629. var time = new Date().getTime();
  11630. return prefix + "_" + mid + "_" + time;
  11631. }
  11632. exports.generateRandomIndex = generateRandomIndex;
  11633. function escapeCharacter(str) {
  11634. if (str == null || str.length == 0) {
  11635. return str;
  11636. }
  11637. return str.replace(/&amp;/g, "&").replace(/&quot;/g, '"').replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&nbsp;/g, " ").replace(/&apos;/g, "'").replace(/&iexcl;/g, "¡").replace(/&cent;/g, "¢").replace(/&pound;/g, "£").replace(/&curren;/g, "¤").replace(/&yen;/g, "¥").replace(/&brvbar;/g, "¦").replace(/&sect;/g, "§").replace(/&uml;/g, "¨").replace(/&copy;/g, "©").replace(/&ordf;/g, "ª").replace(/&laquo;/g, "«").replace(/&not;/g, "¬").replace(/&shy;/g, "­").replace(/&reg;/g, "®").replace(/&macr;/g, "¯").replace(/&deg;/g, "°").replace(/&plusmn;/g, "±").replace(/&sup2;/g, "²").replace(/&sup3;/g, "³").replace(/&acute;/g, "´").replace(/&micro;/g, "µ").replace(/&para;/g, "¶").replace(/&middot;/g, "·").replace(/&cedil;/g, "¸").replace(/&sup1;/g, "¹").replace(/&ordm;/g, "º").replace(/&raquo;/g, "»").replace(/&frac14;/g, "¼").replace(/&frac12;/g, "½").replace(/&frac34;/g, "¾").replace(/&iquest;/g, "¿").replace(/&times;/g, "×").replace(/&divide;/g, "÷").replace(/&Agrave;/g, "À").replace(/&Aacute;/g, "Á").replace(/&Acirc;/g, "Â").replace(/&Atilde;/g, "Ã").replace(/&Auml;/g, "Ä").replace(/&Aring;/g, "Å").replace(/&AElig;/g, "Æ").replace(/&Ccedil;/g, "Ç").replace(/&Egrave;/g, "È").replace(/&Eacute;/g, "É").replace(/&Ecirc;/g, "Ê").replace(/&Euml;/g, "Ë").replace(/&Igrave;/g, "Ì").replace(/&Iacute;/g, "Í").replace(/&Icirc;/g, "Î").replace(/&Iuml;/g, "Ï").replace(/&ETH;/g, "Ð").replace(/&Ntilde;/g, "Ñ").replace(/&Ograve;/g, "Ò").replace(/&Oacute;/g, "Ó").replace(/&Ocirc;/g, "Ô").replace(/&Otilde;/g, "Õ").replace(/&Ouml;/g, "Ö").replace(/&Oslash;/g, "Ø").replace(/&Ugrave;/g, "Ù").replace(/&Uacute;/g, "Ú").replace(/&Ucirc;/g, "Û").replace(/&Uuml;/g, "Ü").replace(/&Yacute;/g, "Ý").replace(/&THORN;/g, "Þ").replace(/&szlig;/g, "ß").replace(/&agrave;/g, "à").replace(/&aacute;/g, "á").replace(/&acirc;/g, "â").replace(/&atilde;/g, "ã").replace(/&auml;/g, "ä").replace(/&aring;/g, "å").replace(/&aelig;/g, "æ").replace(/&ccedil;/g, "ç").replace(/&egrave;/g, "è").replace(/&eacute;/g, "é").replace(/&ecirc;/g, "ê").replace(/&euml;/g, "ë").replace(/&igrave;/g, "ì").replace(/&iacute;/g, "í").replace(/&icirc;/g, "î").replace(/&iuml;/g, "ï").replace(/&eth;/g, "ð").replace(/&ntilde;/g, "ñ").replace(/&ograve;/g, "ò").replace(/&oacute;/g, "ó").replace(/&ocirc;/g, "ô").replace(/&otilde;/g, "õ").replace(/&ouml;/g, "ö").replace(/&oslash;/g, "ø").replace(/&ugrave;/g, "ù").replace(/&uacute;/g, "ú").replace(/&ucirc;/g, "û").replace(/&uuml;/g, "ü").replace(/&yacute;/g, "ý").replace(/&thorn;/g, "þ").replace(/&yuml;/g, "ÿ");
  11638. }
  11639. exports.escapeCharacter = escapeCharacter;
  11640. var fromulaRef = /** @class */function () {
  11641. function fromulaRef() {}
  11642. fromulaRef.trim = function (str) {
  11643. if (str == null) {
  11644. str = "";
  11645. }
  11646. return str.replace(/(^\s*)|(\s*$)/g, "");
  11647. };
  11648. fromulaRef.functionCopy = function (txt, mode, step) {
  11649. var _this = this;
  11650. if (_this.operatorjson == null) {
  11651. var arr = _this.operator.split("|"),
  11652. op = {};
  11653. for (var i_1 = 0; i_1 < arr.length; i_1++) {
  11654. op[arr[i_1].toString()] = 1;
  11655. }
  11656. _this.operatorjson = op;
  11657. }
  11658. if (mode == null) {
  11659. mode = "down";
  11660. }
  11661. if (step == null) {
  11662. step = 1;
  11663. }
  11664. if (txt.substr(0, 1) == "=") {
  11665. txt = txt.substr(1);
  11666. }
  11667. var funcstack = txt.split("");
  11668. var i = 0,
  11669. str = "",
  11670. function_str = "",
  11671. ispassby = true;
  11672. var matchConfig = {
  11673. bracket: 0,
  11674. comma: 0,
  11675. squote: 0,
  11676. dquote: 0
  11677. };
  11678. while (i < funcstack.length) {
  11679. var s = funcstack[i];
  11680. if (s == "(" && matchConfig.dquote == 0) {
  11681. matchConfig.bracket += 1;
  11682. if (str.length > 0) {
  11683. function_str += str + "(";
  11684. } else {
  11685. function_str += "(";
  11686. }
  11687. str = "";
  11688. } else if (s == ")" && matchConfig.dquote == 0) {
  11689. matchConfig.bracket -= 1;
  11690. function_str += _this.functionCopy(str, mode, step) + ")";
  11691. str = "";
  11692. } else if (s == '"' && matchConfig.squote == 0) {
  11693. if (matchConfig.dquote > 0) {
  11694. function_str += str + '"';
  11695. matchConfig.dquote -= 1;
  11696. str = "";
  11697. } else {
  11698. matchConfig.dquote += 1;
  11699. str += '"';
  11700. }
  11701. } else if (s == "," && matchConfig.dquote == 0) {
  11702. function_str += _this.functionCopy(str, mode, step) + ",";
  11703. str = "";
  11704. } else if (s == "&" && matchConfig.dquote == 0) {
  11705. if (str.length > 0) {
  11706. function_str += _this.functionCopy(str, mode, step) + "&";
  11707. str = "";
  11708. } else {
  11709. function_str += "&";
  11710. }
  11711. } else if (s in _this.operatorjson && matchConfig.dquote == 0) {
  11712. var s_next = "";
  11713. if (i + 1 < funcstack.length) {
  11714. s_next = funcstack[i + 1];
  11715. }
  11716. var p = i - 1,
  11717. s_pre = null;
  11718. if (p >= 0) {
  11719. do {
  11720. s_pre = funcstack[p--];
  11721. } while (p >= 0 && s_pre == " ");
  11722. }
  11723. if (s + s_next in _this.operatorjson) {
  11724. if (str.length > 0) {
  11725. function_str += _this.functionCopy(str, mode, step) + s + s_next;
  11726. str = "";
  11727. } else {
  11728. function_str += s + s_next;
  11729. }
  11730. i++;
  11731. } else if (!/[^0-9]/.test(s_next) && s == "-" && (s_pre == "(" || s_pre == null || s_pre == "," || s_pre == " " || s_pre in _this.operatorjson)) {
  11732. str += s;
  11733. } else {
  11734. if (str.length > 0) {
  11735. function_str += _this.functionCopy(str, mode, step) + s;
  11736. str = "";
  11737. } else {
  11738. function_str += s;
  11739. }
  11740. }
  11741. } else {
  11742. str += s;
  11743. }
  11744. if (i == funcstack.length - 1) {
  11745. if (_this.iscelldata(_this.trim(str))) {
  11746. if (mode == "down") {
  11747. function_str += _this.downparam(_this.trim(str), step);
  11748. } else if (mode == "up") {
  11749. function_str += _this.upparam(_this.trim(str), step);
  11750. } else if (mode == "left") {
  11751. function_str += _this.leftparam(_this.trim(str), step);
  11752. } else if (mode == "right") {
  11753. function_str += _this.rightparam(_this.trim(str), step);
  11754. }
  11755. } else {
  11756. function_str += _this.trim(str);
  11757. }
  11758. }
  11759. i++;
  11760. }
  11761. return function_str;
  11762. };
  11763. fromulaRef.downparam = function (txt, step) {
  11764. return this.updateparam("d", txt, step);
  11765. };
  11766. fromulaRef.upparam = function (txt, step) {
  11767. return this.updateparam("u", txt, step);
  11768. };
  11769. fromulaRef.leftparam = function (txt, step) {
  11770. return this.updateparam("l", txt, step);
  11771. };
  11772. fromulaRef.rightparam = function (txt, step) {
  11773. return this.updateparam("r", txt, step);
  11774. };
  11775. fromulaRef.updateparam = function (orient, txt, step) {
  11776. var _this = this;
  11777. var val = txt.split("!"),
  11778. rangetxt,
  11779. prefix = "";
  11780. if (val.length > 1) {
  11781. rangetxt = val[1];
  11782. prefix = val[0] + "!";
  11783. } else {
  11784. rangetxt = val[0];
  11785. }
  11786. if (rangetxt.indexOf(":") == -1) {
  11787. var row = parseInt(rangetxt.replace(/[^0-9]/g, ""));
  11788. var col = ABCatNum(rangetxt.replace(/[^A-Za-z]/g, ""));
  11789. var freezonFuc = _this.isfreezonFuc(rangetxt);
  11790. var $row = freezonFuc[0] ? "$" : "",
  11791. $col = freezonFuc[1] ? "$" : "";
  11792. if (orient == "u" && !freezonFuc[0]) {
  11793. row -= step;
  11794. } else if (orient == "r" && !freezonFuc[1]) {
  11795. col += step;
  11796. } else if (orient == "l" && !freezonFuc[1]) {
  11797. col -= step;
  11798. } else if (!freezonFuc[0]) {
  11799. row += step;
  11800. }
  11801. if (row < 0 || col < 0) {
  11802. return _this.error.r;
  11803. }
  11804. if (!isNaN(row) && !isNaN(col)) {
  11805. return prefix + $col + chatatABC(col) + $row + row;
  11806. } else if (!isNaN(row)) {
  11807. return prefix + $row + row;
  11808. } else if (!isNaN(col)) {
  11809. return prefix + $col + chatatABC(col);
  11810. } else {
  11811. return txt;
  11812. }
  11813. } else {
  11814. rangetxt = rangetxt.split(":");
  11815. var row = [],
  11816. col = [];
  11817. row[0] = parseInt(rangetxt[0].replace(/[^0-9]/g, ""));
  11818. row[1] = parseInt(rangetxt[1].replace(/[^0-9]/g, ""));
  11819. if (row[0] > row[1]) {
  11820. return txt;
  11821. }
  11822. col[0] = ABCatNum(rangetxt[0].replace(/[^A-Za-z]/g, ""));
  11823. col[1] = ABCatNum(rangetxt[1].replace(/[^A-Za-z]/g, ""));
  11824. if (col[0] > col[1]) {
  11825. return txt;
  11826. }
  11827. var freezonFuc0 = _this.isfreezonFuc(rangetxt[0]);
  11828. var freezonFuc1 = _this.isfreezonFuc(rangetxt[1]);
  11829. var $row0 = freezonFuc0[0] ? "$" : "",
  11830. $col0 = freezonFuc0[1] ? "$" : "";
  11831. var $row1 = freezonFuc1[0] ? "$" : "",
  11832. $col1 = freezonFuc1[1] ? "$" : "";
  11833. if (orient == "u") {
  11834. if (!freezonFuc0[0]) {
  11835. row[0] -= step;
  11836. }
  11837. if (!freezonFuc1[0]) {
  11838. row[1] -= step;
  11839. }
  11840. } else if (orient == "r") {
  11841. if (!freezonFuc0[1]) {
  11842. col[0] += step;
  11843. }
  11844. if (!freezonFuc1[1]) {
  11845. col[1] += step;
  11846. }
  11847. } else if (orient == "l") {
  11848. if (!freezonFuc0[1]) {
  11849. col[0] -= step;
  11850. }
  11851. if (!freezonFuc1[1]) {
  11852. col[1] -= step;
  11853. }
  11854. } else {
  11855. if (!freezonFuc0[0]) {
  11856. row[0] += step;
  11857. }
  11858. if (!freezonFuc1[0]) {
  11859. row[1] += step;
  11860. }
  11861. }
  11862. if (row[0] < 0 || col[0] < 0) {
  11863. return _this.error.r;
  11864. }
  11865. if (isNaN(col[0]) && isNaN(col[1])) {
  11866. return prefix + $row0 + row[0] + ":" + $row1 + row[1];
  11867. } else if (isNaN(row[0]) && isNaN(row[1])) {
  11868. return prefix + $col0 + chatatABC(col[0]) + ":" + $col1 + chatatABC(col[1]);
  11869. } else {
  11870. return prefix + $col0 + chatatABC(col[0]) + $row0 + row[0] + ":" + $col1 + chatatABC(col[1]) + $row1 + row[1];
  11871. }
  11872. }
  11873. };
  11874. fromulaRef.iscelldata = function (txt) {
  11875. //判断是否为单元格格式
  11876. var val = txt.split("!"),
  11877. rangetxt;
  11878. if (val.length > 1) {
  11879. rangetxt = val[1];
  11880. } else {
  11881. rangetxt = val[0];
  11882. }
  11883. var reg_cell = /^(([a-zA-Z]+)|([$][a-zA-Z]+))(([0-9]+)|([$][0-9]+))$/g; //增加正则判断单元格为字母+数字的格式:如 A1:B3
  11884. var reg_cellRange = /^(((([a-zA-Z]+)|([$][a-zA-Z]+))(([0-9]+)|([$][0-9]+)))|((([a-zA-Z]+)|([$][a-zA-Z]+))))$/g; //增加正则判断单元格为字母+数字或字母的格式:如 A1:B3,A:A
  11885. if (rangetxt.indexOf(":") == -1) {
  11886. var row = parseInt(rangetxt.replace(/[^0-9]/g, "")) - 1;
  11887. var col = ABCatNum(rangetxt.replace(/[^A-Za-z]/g, ""));
  11888. if (!isNaN(row) && !isNaN(col) && rangetxt.toString().match(reg_cell)) {
  11889. return true;
  11890. } else if (!isNaN(row)) {
  11891. return false;
  11892. } else if (!isNaN(col)) {
  11893. return false;
  11894. } else {
  11895. return false;
  11896. }
  11897. } else {
  11898. reg_cellRange = /^(((([a-zA-Z]+)|([$][a-zA-Z]+))(([0-9]+)|([$][0-9]+)))|((([a-zA-Z]+)|([$][a-zA-Z]+)))|((([0-9]+)|([$][0-9]+s))))$/g;
  11899. rangetxt = rangetxt.split(":");
  11900. var row = [],
  11901. col = [];
  11902. row[0] = parseInt(rangetxt[0].replace(/[^0-9]/g, "")) - 1;
  11903. row[1] = parseInt(rangetxt[1].replace(/[^0-9]/g, "")) - 1;
  11904. if (row[0] > row[1]) {
  11905. return false;
  11906. }
  11907. col[0] = ABCatNum(rangetxt[0].replace(/[^A-Za-z]/g, ""));
  11908. col[1] = ABCatNum(rangetxt[1].replace(/[^A-Za-z]/g, ""));
  11909. if (col[0] > col[1]) {
  11910. return false;
  11911. }
  11912. if (rangetxt[0].toString().match(reg_cellRange) && rangetxt[1].toString().match(reg_cellRange)) {
  11913. return true;
  11914. } else {
  11915. return false;
  11916. }
  11917. }
  11918. };
  11919. fromulaRef.isfreezonFuc = function (txt) {
  11920. var row = txt.replace(/[^0-9]/g, "");
  11921. var col = txt.replace(/[^A-Za-z]/g, "");
  11922. var row$ = txt.substr(txt.indexOf(row) - 1, 1);
  11923. var col$ = txt.substr(txt.indexOf(col) - 1, 1);
  11924. var ret = [false, false];
  11925. if (row$ == "$") {
  11926. ret[0] = true;
  11927. }
  11928. if (col$ == "$") {
  11929. ret[1] = true;
  11930. }
  11931. return ret;
  11932. };
  11933. fromulaRef.operator = "==|!=|<>|<=|>=|=|+|-|>|<|/|*|%|&|^";
  11934. fromulaRef.error = {
  11935. v: "#VALUE!",
  11936. n: "#NAME?",
  11937. na: "#N/A",
  11938. r: "#REF!",
  11939. d: "#DIV/0!",
  11940. nm: "#NUM!",
  11941. nl: "#NULL!",
  11942. sp: "#SPILL!"
  11943. };
  11944. fromulaRef.operatorjson = null;
  11945. return fromulaRef;
  11946. }();
  11947. exports.fromulaRef = fromulaRef;
  11948. function isChinese(temp) {
  11949. var re = /[^\u4e00-\u9fa5]/;
  11950. var reg = /[\u3002|\uff1f|\uff01|\uff0c|\u3001|\uff1b|\uff1a|\u201c|\u201d|\u2018|\u2019|\uff08|\uff09|\u300a|\u300b|\u3008|\u3009|\u3010|\u3011|\u300e|\u300f|\u300c|\u300d|\ufe43|\ufe44|\u3014|\u3015|\u2026|\u2014|\uff5e|\ufe4f|\uffe5]/;
  11951. if (reg.test(temp)) return true;
  11952. if (re.test(temp)) return false;
  11953. return true;
  11954. }
  11955. exports.isChinese = isChinese;
  11956. function isJapanese(temp) {
  11957. var re = /[^\u0800-\u4e00]/;
  11958. if (re.test(temp)) return false;
  11959. return true;
  11960. }
  11961. exports.isJapanese = isJapanese;
  11962. function isKoera(chr) {
  11963. if (chr > 0x3130 && chr < 0x318f || chr >= 0xac00 && chr <= 0xd7a3) {
  11964. return true;
  11965. }
  11966. return false;
  11967. }
  11968. exports.isKoera = isKoera;
  11969. function isContainMultiType(str) {
  11970. var isUnicode = false;
  11971. if (escape(str).indexOf("%u") > -1) {
  11972. isUnicode = true;
  11973. }
  11974. var isNot = false;
  11975. var reg = /[0-9a-z]/gi;
  11976. if (reg.test(str)) {
  11977. isNot = true;
  11978. }
  11979. var reEnSign = /[\x00-\xff]+/g;
  11980. if (reEnSign.test(str)) {
  11981. isNot = true;
  11982. }
  11983. if (isUnicode && isNot) {
  11984. return true;
  11985. }
  11986. return false;
  11987. }
  11988. exports.isContainMultiType = isContainMultiType;
  11989. function getBinaryContent(path, options) {
  11990. var promise, resolve, reject;
  11991. var callback;
  11992. if (!options) {
  11993. options = {};
  11994. }
  11995. // taken from jQuery
  11996. var createStandardXHR = function createStandardXHR() {
  11997. try {
  11998. return new window.XMLHttpRequest();
  11999. } catch (e) {}
  12000. };
  12001. var createActiveXHR = function createActiveXHR() {
  12002. try {
  12003. return new window.ActiveXObject("Microsoft.XMLHTTP");
  12004. } catch (e) {}
  12005. };
  12006. // Create the request object
  12007. var createXHR = typeof window !== "undefined" && window.ActiveXObject ?
  12008. /* Microsoft failed to properly
  12009. * implement the XMLHttpRequest in IE7 (can't request local files),
  12010. * so we use the ActiveXObject when it is available
  12011. * Additionally XMLHttpRequest can be disabled in IE7/IE8 so
  12012. * we need a fallback.
  12013. */
  12014. function () {
  12015. return createStandardXHR() || createActiveXHR();
  12016. } :
  12017. // For all other browsers, use the standard XMLHttpRequest object
  12018. createStandardXHR;
  12019. // backward compatible callback
  12020. if (typeof options === "function") {
  12021. callback = options;
  12022. options = {};
  12023. } else if (typeof options.callback === "function") {
  12024. // callback inside options object
  12025. callback = options.callback;
  12026. }
  12027. resolve = function resolve(data) {
  12028. callback(null, data);
  12029. };
  12030. reject = function reject(err) {
  12031. callback(err, null);
  12032. };
  12033. try {
  12034. var xhr = createXHR();
  12035. xhr.open("GET", path, true);
  12036. // recent browsers
  12037. if ("responseType" in xhr) {
  12038. xhr.responseType = "arraybuffer";
  12039. }
  12040. // older browser
  12041. if (xhr.overrideMimeType) {
  12042. xhr.overrideMimeType("text/plain; charset=x-user-defined");
  12043. }
  12044. xhr.onreadystatechange = function (event) {
  12045. // use `xhr` and not `this`... thanks IE
  12046. if (xhr.readyState === 4) {
  12047. if (xhr.status === 200 || xhr.status === 0) {
  12048. try {
  12049. resolve(function (xhr) {
  12050. // for xhr.responseText, the 0xFF mask is applied by JSZip
  12051. return xhr.response || xhr.responseText;
  12052. }(xhr));
  12053. } catch (err) {
  12054. reject(new Error(err));
  12055. }
  12056. } else {
  12057. reject(new Error("Ajax error for " + path + " : " + this.status + " " + this.statusText));
  12058. }
  12059. }
  12060. };
  12061. if (options.progress) {
  12062. xhr.onprogress = function (e) {
  12063. options.progress({
  12064. path: path,
  12065. originalEvent: e,
  12066. percent: e.loaded / e.total * 100,
  12067. loaded: e.loaded,
  12068. total: e.total
  12069. });
  12070. };
  12071. }
  12072. xhr.send();
  12073. } catch (e) {
  12074. reject(new Error(e), null);
  12075. }
  12076. // returns a promise or undefined depending on whether a callback was
  12077. // provided
  12078. return promise;
  12079. }
  12080. exports.getBinaryContent = getBinaryContent;
  12081. /**
  12082. * multi sequence conversion
  12083. * example:
  12084. * 1、E14 -> 13_4
  12085. * 2、E14 J14 O14 T14 Y14 AD14 AI14 AN14 AS14 AX14 ->
  12086. * ['13_4', '13_9','13_14', '13_19', '13_24', '13_3', '13_8', '13_13', '13_18', '13_23']
  12087. * 3、E46:E47 -> ['45_4', '46_4']
  12088. *
  12089. * @param {string} sqref - before sequence
  12090. * @returns {string[]}
  12091. */
  12092. function getMultiSequenceToNum(sqref) {
  12093. if (!sqref || (sqref === null || sqref === void 0 ? void 0 : sqref.length) <= 0) return [];
  12094. sqref = sqref.toUpperCase();
  12095. var sqrefRawArr = sqref.split(" ");
  12096. var sqrefArr = sqrefRawArr.filter(function (e) {
  12097. return e && e.trim();
  12098. });
  12099. var sqrefLastArr = getSqrefRawArrFormat(sqrefArr);
  12100. var resArr = [];
  12101. for (var i = 0; i < sqrefLastArr.length; i++) {
  12102. var _res = getSingleSequenceToNum(sqrefLastArr[i]);
  12103. if (_res) resArr.push(_res);
  12104. }
  12105. return resArr;
  12106. }
  12107. exports.getMultiSequenceToNum = getMultiSequenceToNum;
  12108. /**
  12109. * get region sequence
  12110. * example:
  12111. * 1、[A1:C2'] -> ['A1', 'A2', 'B1', 'B2', 'C1', 'C2']
  12112. *
  12113. * @param {string[]} arr - formats arr
  12114. * @returns {string[]} - after arr
  12115. */
  12116. function getRegionSequence(arr) {
  12117. var _a, _b;
  12118. var formatArr = [];
  12119. var regEn = new RegExp(/[A-Z]+|[0-9]+/g);
  12120. var startArr = (_a = arr[0]) === null || _a === void 0 ? void 0 : _a.match(regEn);
  12121. var lastArr = (_b = arr[1]) === null || _b === void 0 ? void 0 : _b.match(regEn);
  12122. var columnMax = Math.max.apply(Math, [ABCatNum(startArr[0]), ABCatNum(lastArr[0])]);
  12123. var columnMin = Math.min.apply(Math, [ABCatNum(startArr[0]), ABCatNum(lastArr[0])]);
  12124. var rowMax = Math.max.apply(Math, [parseInt(startArr[1]), parseInt(lastArr[1])]);
  12125. var rowMin = Math.min.apply(Math, [parseInt(startArr[1]), parseInt(lastArr[1])]);
  12126. for (var i = columnMin; i <= columnMax; i++) {
  12127. for (var j = rowMin; j <= rowMax; j++) {
  12128. formatArr.push("" + chatatABC(i) + j);
  12129. }
  12130. }
  12131. return formatArr;
  12132. }
  12133. exports.getRegionSequence = getRegionSequence;
  12134. /**
  12135. * unified processing of conversion formats
  12136. * example:
  12137. * 1、['E38', 'A1:C2'] -> ['E38', 'A1', 'A2', 'B1', 'B2', 'C1', 'C2']
  12138. *
  12139. * @param {string[]} arr - formats arr
  12140. * @returns {string[]} - after arr
  12141. */
  12142. function getSqrefRawArrFormat(arr) {
  12143. arr === null || arr === void 0 ? void 0 : arr.map(function (el) {
  12144. if (el.includes(":")) {
  12145. var tempArr = el.split(":");
  12146. if ((tempArr === null || tempArr === void 0 ? void 0 : tempArr.length) === 2) {
  12147. arr = arr.concat(getRegionSequence(tempArr));
  12148. arr.splice(arr.indexOf(el), 1);
  12149. }
  12150. }
  12151. });
  12152. var resultArr = arr.filter(function (value, index, array) {
  12153. return array.indexOf(value) === index;
  12154. });
  12155. return resultArr;
  12156. }
  12157. exports.getSqrefRawArrFormat = getSqrefRawArrFormat;
  12158. /**
  12159. * single sequence to number
  12160. * example:
  12161. * 1、A1 -> 0_0
  12162. * 2、ES14 -> 13_4
  12163. *
  12164. * @param {string} sqref - before sequence
  12165. * @returns {string} - after sequence
  12166. */
  12167. function getSingleSequenceToNum(sqref) {
  12168. var sqrefArray = sqref.match(/[A-Z]+|[0-9]+/g);
  12169. var sqrefLen = sqrefArray.length;
  12170. var regEn = new RegExp("^[A-Z]+$");
  12171. var ret = "";
  12172. for (var i = sqrefLen - 1; i >= 0; i--) {
  12173. var cur = sqrefArray[i];
  12174. if (regEn.test(cur)) {
  12175. ret += ABCatNum(cur) + "_";
  12176. } else {
  12177. ret += parseInt(cur) - 1 + "_";
  12178. }
  12179. }
  12180. return ret.substring(0, ret.length - 1);
  12181. }
  12182. exports.getSingleSequenceToNum = getSingleSequenceToNum;
  12183. /**
  12184. * R1C1 to Sequence
  12185. * example: sheet2!R1C1 => sheet!A1
  12186. *
  12187. * @param {string} value - R1C1 value
  12188. * @returns
  12189. */
  12190. function getTransR1C1ToSequence(value) {
  12191. if (!value && (value === null || value === void 0 ? void 0 : value.length) <= 0) return "";
  12192. var len = value.length;
  12193. var index = value.lastIndexOf("!");
  12194. var valueArr = [value.slice(0, index), value.slice(index + 1, len)];
  12195. var repStr = valueArr[1] || "";
  12196. var indexR = repStr.indexOf("R");
  12197. var indexC = repStr.indexOf("C");
  12198. var row = Number(repStr.slice(indexR + 1, indexC));
  12199. var column = chatatABC(Number(repStr.slice(indexC + 1, repStr === null || repStr === void 0 ? void 0 : repStr.length)) - 1);
  12200. return valueArr[0] + "!" + column + row;
  12201. }
  12202. exports.getTransR1C1ToSequence = getTransR1C1ToSequence;
  12203. /**
  12204. * strip x14 format data
  12205. *
  12206. * @param {string} value
  12207. * @returns {Object} - { formula, sqref }
  12208. */
  12209. function getPeelOffX14(value) {
  12210. var _a;
  12211. if (!value || (value === null || value === void 0 ? void 0 : value.length) <= 0) return {};
  12212. // formula
  12213. var formulaReg = new RegExp("</x14:formula[^]>", "g");
  12214. var lastIndex = (_a = value.match(formulaReg)) === null || _a === void 0 ? void 0 : _a.length;
  12215. var lastValue = "</x14:formula" + lastIndex + ">";
  12216. var lastValueEnd = value.indexOf(lastValue);
  12217. var formulaValue = value.substring(0, lastValueEnd + lastValue.length);
  12218. formulaValue = formulaValue.replace(/<xm:f>/g, "").replace(/<\/xm:f>/g, "").replace(/x14:/g, "").replace(/\/x14:/g, "");
  12219. var formula = formulaValue;
  12220. // sqref
  12221. var xmSqrefLen = "<xm:sqref>".length;
  12222. var sqrefStart = value.indexOf("<xm:sqref>");
  12223. var sqrefEnd = value.indexOf("</xm:sqref>");
  12224. var sqref = value.substring(sqrefStart + xmSqrefLen, sqrefEnd);
  12225. return {
  12226. formula: formula,
  12227. sqref: sqref
  12228. };
  12229. }
  12230. exports.getPeelOffX14 = getPeelOffX14;
  12231. /**
  12232. * get the value in the formula
  12233. *
  12234. * @param {string} value - extracted value
  12235. * @returns {string[]}
  12236. */
  12237. function getMultiFormulaValue(value) {
  12238. var _a, _b;
  12239. if (!value || (value === null || value === void 0 ? void 0 : value.length) <= 0) return [];
  12240. var lenReg = new RegExp("formula", "g");
  12241. var len = (((_a = value.match(lenReg)) === null || _a === void 0 ? void 0 : _a.length) || 0) / 2;
  12242. if (len === 0) return [];
  12243. var retArr = [];
  12244. for (var i = 1; i <= len; i++) {
  12245. var startLen = (_b = "<formula" + i + ">") === null || _b === void 0 ? void 0 : _b.length;
  12246. var start = value.indexOf("<formula" + i + ">");
  12247. var end = value.indexOf("</formula" + i + ">");
  12248. var _value = value.substring(start + startLen, end);
  12249. retArr.push(escapeCharacter(_value.replace(/&quot;|^\"|\"$/g, "")));
  12250. }
  12251. return retArr;
  12252. }
  12253. exports.getMultiFormulaValue = getMultiFormulaValue;
  12254. },{"./constant":47}],50:[function(require,module,exports){
  12255. "use strict";
  12256. Object.defineProperty(exports, "__esModule", {
  12257. value: true
  12258. });
  12259. exports.LuckyExcel = void 0;
  12260. var LuckyFile_1 = require("./ToLuckySheet/LuckyFile");
  12261. // import {SecurityDoor,Car} from './content';
  12262. var HandleZip_1 = require("./HandleZip");
  12263. // //demo
  12264. // function demoHandler(){
  12265. // let upload = document.getElementById("Luckyexcel-demo-file");
  12266. // let selectADemo = document.getElementById("Luckyexcel-select-demo");
  12267. // let downlodDemo = document.getElementById("Luckyexcel-downlod-file");
  12268. // let mask = document.getElementById("lucky-mask-demo");
  12269. // if(upload){
  12270. // window.onload = () => {
  12271. // upload.addEventListener("change", function(evt){
  12272. // var files:FileList = (evt.target as any).files;
  12273. // if(files==null || files.length==0){
  12274. // alert("No files wait for import");
  12275. // return;
  12276. // }
  12277. // let name = files[0].name;
  12278. // let suffixArr = name.split("."), suffix = suffixArr[suffixArr.length-1];
  12279. // if(suffix!="xlsx"){
  12280. // alert("Currently only supports the import of xlsx files");
  12281. // return;
  12282. // }
  12283. // LuckyExcel.transformExcelToLucky(files[0], function(exportJson:any, luckysheetfile:string){
  12284. // if(exportJson.sheets==null || exportJson.sheets.length==0){
  12285. // alert("Failed to read the content of the excel file, currently does not support xls files!");
  12286. // return;
  12287. // }
  12288. // console.log(exportJson, luckysheetfile);
  12289. // window.luckysheet.destroy();
  12290. // window.luckysheet.create({
  12291. // container: 'luckysheet', //luckysheet is the container id
  12292. // showinfobar:false,
  12293. // data:exportJson.sheets,
  12294. // title:exportJson.info.name,
  12295. // userInfo:exportJson.info.name.creator
  12296. // });
  12297. // });
  12298. // });
  12299. // selectADemo.addEventListener("change", function(evt){
  12300. // var obj:any = selectADemo;
  12301. // var index = obj.selectedIndex;
  12302. // var value = obj.options[index].value;
  12303. // var name = obj.options[index].innerHTML;
  12304. // if(value==""){
  12305. // return;
  12306. // }
  12307. // mask.style.display = "flex";
  12308. // LuckyExcel.transformExcelToLuckyByUrl(value, name, function(exportJson:any, luckysheetfile:string){
  12309. // if(exportJson.sheets==null || exportJson.sheets.length==0){
  12310. // alert("Failed to read the content of the excel file, currently does not support xls files!");
  12311. // return;
  12312. // }
  12313. // console.log(exportJson, luckysheetfile);
  12314. // mask.style.display = "none";
  12315. // window.luckysheet.destroy();
  12316. // window.luckysheet.create({
  12317. // container: 'luckysheet', //luckysheet is the container id
  12318. // showinfobar:false,
  12319. // data:exportJson.sheets,
  12320. // title:exportJson.info.name,
  12321. // userInfo:exportJson.info.name.creator
  12322. // });
  12323. // });
  12324. // });
  12325. // downlodDemo.addEventListener("click", function(evt){
  12326. // var obj:any = selectADemo;
  12327. // var index = obj.selectedIndex;
  12328. // var value = obj.options[index].value;
  12329. // if(value.length==0){
  12330. // alert("Please select a demo file");
  12331. // return;
  12332. // }
  12333. // var elemIF:any = document.getElementById("Lucky-download-frame");
  12334. // if(elemIF==null){
  12335. // elemIF = document.createElement("iframe");
  12336. // elemIF.style.display = "none";
  12337. // elemIF.id = "Lucky-download-frame";
  12338. // document.body.appendChild(elemIF);
  12339. // }
  12340. // elemIF.src = value;
  12341. // // elemIF.parentNode.removeChild(elemIF);
  12342. // });
  12343. // }
  12344. // }
  12345. // }
  12346. // demoHandler();
  12347. // api
  12348. var LuckyExcel = /** @class */function () {
  12349. function LuckyExcel() {}
  12350. LuckyExcel.transformExcelToLucky = function (excelFile, callback, errorHandler) {
  12351. var handleZip = new HandleZip_1.HandleZip(excelFile);
  12352. handleZip.unzipFile(function (files) {
  12353. var luckyFile = new LuckyFile_1.LuckyFile(files, excelFile.name);
  12354. var luckysheetfile = luckyFile.Parse();
  12355. var exportJson = JSON.parse(luckysheetfile);
  12356. if (callback != undefined) {
  12357. callback(exportJson, luckysheetfile);
  12358. }
  12359. }, function (err) {
  12360. if (errorHandler) {
  12361. errorHandler(err);
  12362. } else {
  12363. console.error(err);
  12364. }
  12365. });
  12366. };
  12367. LuckyExcel.transformExcelToLuckyByUrl = function (url, name, callBack, errorHandler) {
  12368. var handleZip = new HandleZip_1.HandleZip();
  12369. handleZip.unzipFileByUrl(url, function (files) {
  12370. var luckyFile = new LuckyFile_1.LuckyFile(files, name);
  12371. var luckysheetfile = luckyFile.Parse();
  12372. var exportJson = JSON.parse(luckysheetfile);
  12373. if (callBack != undefined) {
  12374. callBack(exportJson, luckysheetfile);
  12375. }
  12376. }, function (err) {
  12377. if (errorHandler) {
  12378. errorHandler(err);
  12379. } else {
  12380. console.error(err);
  12381. }
  12382. });
  12383. };
  12384. LuckyExcel.transformLuckyToExcel = function (LuckyFile, callBack, errorHandler) {};
  12385. return LuckyExcel;
  12386. }();
  12387. exports.LuckyExcel = LuckyExcel;
  12388. },{"./HandleZip":40,"./ToLuckySheet/LuckyFile":43}],51:[function(require,module,exports){
  12389. "use strict";
  12390. var main_1 = require("./main");
  12391. module.exports = main_1.LuckyExcel;
  12392. },{"./main":50}]},{},[51])(51)
  12393. });