plist.js 227 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987
  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.plist = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
  2. (function (Buffer){
  3. /**
  4. * Module dependencies.
  5. */
  6. var base64 = require('base64-js');
  7. var xmlbuilder = require('xmlbuilder');
  8. /**
  9. * Module exports.
  10. */
  11. exports.build = build;
  12. /**
  13. * Accepts a `Date` instance and returns an ISO date string.
  14. *
  15. * @param {Date} d - Date instance to serialize
  16. * @returns {String} ISO date string representation of `d`
  17. * @api private
  18. */
  19. function ISODateString(d){
  20. function pad(n){
  21. return n < 10 ? '0' + n : n;
  22. }
  23. return d.getUTCFullYear()+'-'
  24. + pad(d.getUTCMonth()+1)+'-'
  25. + pad(d.getUTCDate())+'T'
  26. + pad(d.getUTCHours())+':'
  27. + pad(d.getUTCMinutes())+':'
  28. + pad(d.getUTCSeconds())+'Z';
  29. }
  30. /**
  31. * Returns the internal "type" of `obj` via the
  32. * `Object.prototype.toString()` trick.
  33. *
  34. * @param {Mixed} obj - any value
  35. * @returns {String} the internal "type" name
  36. * @api private
  37. */
  38. var toString = Object.prototype.toString;
  39. function type (obj) {
  40. var m = toString.call(obj).match(/\[object (.*)\]/);
  41. return m ? m[1] : m;
  42. }
  43. /**
  44. * Generate an XML plist string from the input object `obj`.
  45. *
  46. * @param {Object} obj - the object to convert
  47. * @param {Object} [opts] - optional options object
  48. * @returns {String} converted plist XML string
  49. * @api public
  50. */
  51. function build (obj, opts) {
  52. var XMLHDR = {
  53. version: '1.0',
  54. encoding: 'UTF-8'
  55. };
  56. var XMLDTD = {
  57. pubid: '-//Apple//DTD PLIST 1.0//EN',
  58. sysid: 'http://www.apple.com/DTDs/PropertyList-1.0.dtd'
  59. };
  60. var doc = xmlbuilder.create('plist');
  61. doc.dec(XMLHDR.version, XMLHDR.encoding, XMLHDR.standalone);
  62. doc.dtd(XMLDTD.pubid, XMLDTD.sysid);
  63. doc.att('version', '1.0');
  64. walk_obj(obj, doc);
  65. if (!opts) opts = {};
  66. // default `pretty` to `true`
  67. opts.pretty = opts.pretty !== false;
  68. return doc.end(opts);
  69. }
  70. /**
  71. * depth first, recursive traversal of a javascript object. when complete,
  72. * next_child contains a reference to the build XML object.
  73. *
  74. * @api private
  75. */
  76. function walk_obj(next, next_child) {
  77. var tag_type, i, prop;
  78. var name = type(next);
  79. if ('Undefined' == name) {
  80. return;
  81. } else if (Array.isArray(next)) {
  82. next_child = next_child.ele('array');
  83. for (i = 0; i < next.length; i++) {
  84. walk_obj(next[i], next_child);
  85. }
  86. } else if (Buffer.isBuffer(next)) {
  87. next_child.ele('data').raw(next.toString('base64'));
  88. } else if ('Object' == name) {
  89. next_child = next_child.ele('dict');
  90. for (prop in next) {
  91. if (next.hasOwnProperty(prop)) {
  92. next_child.ele('key').txt(prop);
  93. walk_obj(next[prop], next_child);
  94. }
  95. }
  96. } else if ('Number' == name) {
  97. // detect if this is an integer or real
  98. // TODO: add an ability to force one way or another via a "cast"
  99. tag_type = (next % 1 === 0) ? 'integer' : 'real';
  100. next_child.ele(tag_type).txt(next.toString());
  101. } else if ('Date' == name) {
  102. next_child.ele('date').txt(ISODateString(new Date(next)));
  103. } else if ('Boolean' == name) {
  104. next_child.ele(next ? 'true' : 'false');
  105. } else if ('String' == name) {
  106. next_child.ele('string').txt(next);
  107. } else if ('ArrayBuffer' == name) {
  108. next_child.ele('data').raw(base64.fromByteArray(next));
  109. } else if (next && next.buffer && 'ArrayBuffer' == type(next.buffer)) {
  110. // a typed array
  111. next_child.ele('data').raw(base64.fromByteArray(new Uint8Array(next.buffer), next_child));
  112. }
  113. }
  114. }).call(this,{"isBuffer":require("../node_modules/is-buffer/index.js")})
  115. },{"../node_modules/is-buffer/index.js":10,"base64-js":5,"xmlbuilder":87}],2:[function(require,module,exports){
  116. /**
  117. * Module dependencies.
  118. */
  119. var fs = require('fs');
  120. var parse = require('./parse');
  121. var deprecate = require('util-deprecate');
  122. /**
  123. * Module exports.
  124. */
  125. exports.parseFile = deprecate(parseFile, '`parseFile()` is deprecated. ' +
  126. 'Use `parseString()` instead.');
  127. exports.parseFileSync = deprecate(parseFileSync, '`parseFileSync()` is deprecated. ' +
  128. 'Use `parseStringSync()` instead.');
  129. /**
  130. * Parses file `filename` as a .plist file.
  131. * Invokes `fn` callback function when done.
  132. *
  133. * @param {String} filename - name of the file to read
  134. * @param {Function} fn - callback function
  135. * @api public
  136. * @deprecated use parseString() instead
  137. */
  138. function parseFile (filename, fn) {
  139. fs.readFile(filename, { encoding: 'utf8' }, onread);
  140. function onread (err, inxml) {
  141. if (err) return fn(err);
  142. parse.parseString(inxml, fn);
  143. }
  144. }
  145. /**
  146. * Parses file `filename` as a .plist file.
  147. * Returns a when done.
  148. *
  149. * @param {String} filename - name of the file to read
  150. * @param {Function} fn - callback function
  151. * @api public
  152. * @deprecated use parseStringSync() instead
  153. */
  154. function parseFileSync (filename) {
  155. var inxml = fs.readFileSync(filename, 'utf8');
  156. return parse.parseStringSync(inxml);
  157. }
  158. },{"./parse":3,"fs":6,"util-deprecate":70}],3:[function(require,module,exports){
  159. (function (Buffer){
  160. /**
  161. * Module dependencies.
  162. */
  163. var deprecate = require('util-deprecate');
  164. var DOMParser = require('xmldom').DOMParser;
  165. /**
  166. * Module exports.
  167. */
  168. exports.parse = parse;
  169. exports.parseString = deprecate(parseString, '`parseString()` is deprecated. ' +
  170. 'It\'s not actually async. Use `parse()` instead.');
  171. exports.parseStringSync = deprecate(parseStringSync, '`parseStringSync()` is ' +
  172. 'deprecated. Use `parse()` instead.');
  173. /**
  174. * We ignore raw text (usually whitespace), <!-- xml comments -->,
  175. * and raw CDATA nodes.
  176. *
  177. * @param {Element} node
  178. * @returns {Boolean}
  179. * @api private
  180. */
  181. function shouldIgnoreNode (node) {
  182. return node.nodeType === 3 // text
  183. || node.nodeType === 8 // comment
  184. || node.nodeType === 4; // cdata
  185. }
  186. /**
  187. * Parses a Plist XML string. Returns an Object.
  188. *
  189. * @param {String} xml - the XML String to decode
  190. * @returns {Mixed} the decoded value from the Plist XML
  191. * @api public
  192. */
  193. function parse (xml) {
  194. var doc = new DOMParser().parseFromString(xml);
  195. if (doc.documentElement.nodeName !== 'plist') {
  196. throw new Error('malformed document. First element should be <plist>');
  197. }
  198. var plist = parsePlistXML(doc.documentElement);
  199. // the root <plist> node gets interpreted as an Array,
  200. // so pull out the inner data first
  201. if (plist.length == 1) plist = plist[0];
  202. return plist;
  203. }
  204. /**
  205. * Parses a Plist XML string. Returns an Object. Takes a `callback` function.
  206. *
  207. * @param {String} xml - the XML String to decode
  208. * @param {Function} callback - callback function
  209. * @returns {Mixed} the decoded value from the Plist XML
  210. * @api public
  211. * @deprecated not actually async. use parse() instead
  212. */
  213. function parseString (xml, callback) {
  214. var doc, error, plist;
  215. try {
  216. doc = new DOMParser().parseFromString(xml);
  217. plist = parsePlistXML(doc.documentElement);
  218. } catch(e) {
  219. error = e;
  220. }
  221. callback(error, plist);
  222. }
  223. /**
  224. * Parses a Plist XML string. Returns an Object.
  225. *
  226. * @param {String} xml - the XML String to decode
  227. * @param {Function} callback - callback function
  228. * @returns {Mixed} the decoded value from the Plist XML
  229. * @api public
  230. * @deprecated use parse() instead
  231. */
  232. function parseStringSync (xml) {
  233. var doc = new DOMParser().parseFromString(xml);
  234. var plist;
  235. if (doc.documentElement.nodeName !== 'plist') {
  236. throw new Error('malformed document. First element should be <plist>');
  237. }
  238. plist = parsePlistXML(doc.documentElement);
  239. // if the plist is an array with 1 element, pull it out of the array
  240. if (plist.length == 1) {
  241. plist = plist[0];
  242. }
  243. return plist;
  244. }
  245. /**
  246. * Convert an XML based plist document into a JSON representation.
  247. *
  248. * @param {Object} xml_node - current XML node in the plist
  249. * @returns {Mixed} built up JSON object
  250. * @api private
  251. */
  252. function parsePlistXML (node) {
  253. var i, new_obj, key, val, new_arr, res, d;
  254. if (!node)
  255. return null;
  256. if (node.nodeName === 'plist') {
  257. new_arr = [];
  258. for (i=0; i < node.childNodes.length; i++) {
  259. // ignore comment nodes (text)
  260. if (!shouldIgnoreNode(node.childNodes[i])) {
  261. new_arr.push( parsePlistXML(node.childNodes[i]));
  262. }
  263. }
  264. return new_arr;
  265. } else if (node.nodeName === 'dict') {
  266. new_obj = {};
  267. key = null;
  268. for (i=0; i < node.childNodes.length; i++) {
  269. // ignore comment nodes (text)
  270. if (!shouldIgnoreNode(node.childNodes[i])) {
  271. if (key === null) {
  272. key = parsePlistXML(node.childNodes[i]);
  273. } else {
  274. new_obj[key] = parsePlistXML(node.childNodes[i]);
  275. key = null;
  276. }
  277. }
  278. }
  279. return new_obj;
  280. } else if (node.nodeName === 'array') {
  281. new_arr = [];
  282. for (i=0; i < node.childNodes.length; i++) {
  283. // ignore comment nodes (text)
  284. if (!shouldIgnoreNode(node.childNodes[i])) {
  285. res = parsePlistXML(node.childNodes[i]);
  286. if (null != res) new_arr.push(res);
  287. }
  288. }
  289. return new_arr;
  290. } else if (node.nodeName === '#text') {
  291. // TODO: what should we do with text types? (CDATA sections)
  292. } else if (node.nodeName === 'key') {
  293. return node.childNodes[0].nodeValue;
  294. } else if (node.nodeName === 'string') {
  295. res = '';
  296. for (d=0; d < node.childNodes.length; d++) {
  297. res += node.childNodes[d].nodeValue;
  298. }
  299. return res;
  300. } else if (node.nodeName === 'integer') {
  301. // parse as base 10 integer
  302. return parseInt(node.childNodes[0].nodeValue, 10);
  303. } else if (node.nodeName === 'real') {
  304. res = '';
  305. for (d=0; d < node.childNodes.length; d++) {
  306. if (node.childNodes[d].nodeType === 3) {
  307. res += node.childNodes[d].nodeValue;
  308. }
  309. }
  310. return parseFloat(res);
  311. } else if (node.nodeName === 'data') {
  312. res = '';
  313. for (d=0; d < node.childNodes.length; d++) {
  314. if (node.childNodes[d].nodeType === 3) {
  315. res += node.childNodes[d].nodeValue.replace(/\s+/g, '');
  316. }
  317. }
  318. // decode base64 data to a Buffer instance
  319. return new Buffer(res, 'base64');
  320. } else if (node.nodeName === 'date') {
  321. return new Date(node.childNodes[0].nodeValue);
  322. } else if (node.nodeName === 'true') {
  323. return true;
  324. } else if (node.nodeName === 'false') {
  325. return false;
  326. }
  327. }
  328. }).call(this,require("buffer").Buffer)
  329. },{"buffer":7,"util-deprecate":70,"xmldom":88}],4:[function(require,module,exports){
  330. var i;
  331. /**
  332. * Parser functions.
  333. */
  334. var parserFunctions = require('./parse');
  335. for (i in parserFunctions) exports[i] = parserFunctions[i];
  336. /**
  337. * Builder functions.
  338. */
  339. var builderFunctions = require('./build');
  340. for (i in builderFunctions) exports[i] = builderFunctions[i];
  341. /**
  342. * Add Node.js-specific functions (they're deprecated…).
  343. */
  344. var nodeFunctions = require('./node');
  345. for (i in nodeFunctions) exports[i] = nodeFunctions[i];
  346. },{"./build":1,"./node":2,"./parse":3}],5:[function(require,module,exports){
  347. var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
  348. ;(function (exports) {
  349. 'use strict';
  350. var Arr = (typeof Uint8Array !== 'undefined')
  351. ? Uint8Array
  352. : Array
  353. var PLUS = '+'.charCodeAt(0)
  354. var SLASH = '/'.charCodeAt(0)
  355. var NUMBER = '0'.charCodeAt(0)
  356. var LOWER = 'a'.charCodeAt(0)
  357. var UPPER = 'A'.charCodeAt(0)
  358. var PLUS_URL_SAFE = '-'.charCodeAt(0)
  359. var SLASH_URL_SAFE = '_'.charCodeAt(0)
  360. function decode (elt) {
  361. var code = elt.charCodeAt(0)
  362. if (code === PLUS ||
  363. code === PLUS_URL_SAFE)
  364. return 62 // '+'
  365. if (code === SLASH ||
  366. code === SLASH_URL_SAFE)
  367. return 63 // '/'
  368. if (code < NUMBER)
  369. return -1 //no match
  370. if (code < NUMBER + 10)
  371. return code - NUMBER + 26 + 26
  372. if (code < UPPER + 26)
  373. return code - UPPER
  374. if (code < LOWER + 26)
  375. return code - LOWER + 26
  376. }
  377. function b64ToByteArray (b64) {
  378. var i, j, l, tmp, placeHolders, arr
  379. if (b64.length % 4 > 0) {
  380. throw new Error('Invalid string. Length must be a multiple of 4')
  381. }
  382. // the number of equal signs (place holders)
  383. // if there are two placeholders, than the two characters before it
  384. // represent one byte
  385. // if there is only one, then the three characters before it represent 2 bytes
  386. // this is just a cheap hack to not do indexOf twice
  387. var len = b64.length
  388. placeHolders = '=' === b64.charAt(len - 2) ? 2 : '=' === b64.charAt(len - 1) ? 1 : 0
  389. // base64 is 4/3 + up to two characters of the original data
  390. arr = new Arr(b64.length * 3 / 4 - placeHolders)
  391. // if there are placeholders, only get up to the last complete 4 chars
  392. l = placeHolders > 0 ? b64.length - 4 : b64.length
  393. var L = 0
  394. function push (v) {
  395. arr[L++] = v
  396. }
  397. for (i = 0, j = 0; i < l; i += 4, j += 3) {
  398. tmp = (decode(b64.charAt(i)) << 18) | (decode(b64.charAt(i + 1)) << 12) | (decode(b64.charAt(i + 2)) << 6) | decode(b64.charAt(i + 3))
  399. push((tmp & 0xFF0000) >> 16)
  400. push((tmp & 0xFF00) >> 8)
  401. push(tmp & 0xFF)
  402. }
  403. if (placeHolders === 2) {
  404. tmp = (decode(b64.charAt(i)) << 2) | (decode(b64.charAt(i + 1)) >> 4)
  405. push(tmp & 0xFF)
  406. } else if (placeHolders === 1) {
  407. tmp = (decode(b64.charAt(i)) << 10) | (decode(b64.charAt(i + 1)) << 4) | (decode(b64.charAt(i + 2)) >> 2)
  408. push((tmp >> 8) & 0xFF)
  409. push(tmp & 0xFF)
  410. }
  411. return arr
  412. }
  413. function uint8ToBase64 (uint8) {
  414. var i,
  415. extraBytes = uint8.length % 3, // if we have 1 byte left, pad 2 bytes
  416. output = "",
  417. temp, length
  418. function encode (num) {
  419. return lookup.charAt(num)
  420. }
  421. function tripletToBase64 (num) {
  422. return encode(num >> 18 & 0x3F) + encode(num >> 12 & 0x3F) + encode(num >> 6 & 0x3F) + encode(num & 0x3F)
  423. }
  424. // go through the array every three bytes, we'll deal with trailing stuff later
  425. for (i = 0, length = uint8.length - extraBytes; i < length; i += 3) {
  426. temp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2])
  427. output += tripletToBase64(temp)
  428. }
  429. // pad the end with zeros, but make sure to not forget the extra bytes
  430. switch (extraBytes) {
  431. case 1:
  432. temp = uint8[uint8.length - 1]
  433. output += encode(temp >> 2)
  434. output += encode((temp << 4) & 0x3F)
  435. output += '=='
  436. break
  437. case 2:
  438. temp = (uint8[uint8.length - 2] << 8) + (uint8[uint8.length - 1])
  439. output += encode(temp >> 10)
  440. output += encode((temp >> 4) & 0x3F)
  441. output += encode((temp << 2) & 0x3F)
  442. output += '='
  443. break
  444. }
  445. return output
  446. }
  447. exports.toByteArray = b64ToByteArray
  448. exports.fromByteArray = uint8ToBase64
  449. }(typeof exports === 'undefined' ? (this.base64js = {}) : exports))
  450. },{}],6:[function(require,module,exports){
  451. },{}],7:[function(require,module,exports){
  452. (function (global){
  453. /*!
  454. * The buffer module from node.js, for the browser.
  455. *
  456. * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
  457. * @license MIT
  458. */
  459. /* eslint-disable no-proto */
  460. var base64 = require('base64-js')
  461. var ieee754 = require('ieee754')
  462. var isArray = require('is-array')
  463. exports.Buffer = Buffer
  464. exports.SlowBuffer = SlowBuffer
  465. exports.INSPECT_MAX_BYTES = 50
  466. Buffer.poolSize = 8192 // not used by this implementation
  467. var rootParent = {}
  468. /**
  469. * If `Buffer.TYPED_ARRAY_SUPPORT`:
  470. * === true Use Uint8Array implementation (fastest)
  471. * === false Use Object implementation (most compatible, even IE6)
  472. *
  473. * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
  474. * Opera 11.6+, iOS 4.2+.
  475. *
  476. * Due to various browser bugs, sometimes the Object implementation will be used even
  477. * when the browser supports typed arrays.
  478. *
  479. * Note:
  480. *
  481. * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
  482. * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
  483. *
  484. * - Safari 5-7 lacks support for changing the `Object.prototype.constructor` property
  485. * on objects.
  486. *
  487. * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
  488. *
  489. * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
  490. * incorrect length in some situations.
  491. * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
  492. * get the Object implementation, which is slower but behaves correctly.
  493. */
  494. Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined
  495. ? global.TYPED_ARRAY_SUPPORT
  496. : typedArraySupport()
  497. function typedArraySupport () {
  498. function Bar () {}
  499. try {
  500. var arr = new Uint8Array(1)
  501. arr.foo = function () { return 42 }
  502. arr.constructor = Bar
  503. return arr.foo() === 42 && // typed array instances can be augmented
  504. arr.constructor === Bar && // constructor can be set
  505. typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
  506. arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
  507. } catch (e) {
  508. return false
  509. }
  510. }
  511. function kMaxLength () {
  512. return Buffer.TYPED_ARRAY_SUPPORT
  513. ? 0x7fffffff
  514. : 0x3fffffff
  515. }
  516. /**
  517. * Class: Buffer
  518. * =============
  519. *
  520. * The Buffer constructor returns instances of `Uint8Array` that are augmented
  521. * with function properties for all the node `Buffer` API functions. We use
  522. * `Uint8Array` so that square bracket notation works as expected -- it returns
  523. * a single octet.
  524. *
  525. * By augmenting the instances, we can avoid modifying the `Uint8Array`
  526. * prototype.
  527. */
  528. function Buffer (arg) {
  529. if (!(this instanceof Buffer)) {
  530. // Avoid going through an ArgumentsAdaptorTrampoline in the common case.
  531. if (arguments.length > 1) return new Buffer(arg, arguments[1])
  532. return new Buffer(arg)
  533. }
  534. this.length = 0
  535. this.parent = undefined
  536. // Common case.
  537. if (typeof arg === 'number') {
  538. return fromNumber(this, arg)
  539. }
  540. // Slightly less common case.
  541. if (typeof arg === 'string') {
  542. return fromString(this, arg, arguments.length > 1 ? arguments[1] : 'utf8')
  543. }
  544. // Unusual.
  545. return fromObject(this, arg)
  546. }
  547. function fromNumber (that, length) {
  548. that = allocate(that, length < 0 ? 0 : checked(length) | 0)
  549. if (!Buffer.TYPED_ARRAY_SUPPORT) {
  550. for (var i = 0; i < length; i++) {
  551. that[i] = 0
  552. }
  553. }
  554. return that
  555. }
  556. function fromString (that, string, encoding) {
  557. if (typeof encoding !== 'string' || encoding === '') encoding = 'utf8'
  558. // Assumption: byteLength() return value is always < kMaxLength.
  559. var length = byteLength(string, encoding) | 0
  560. that = allocate(that, length)
  561. that.write(string, encoding)
  562. return that
  563. }
  564. function fromObject (that, object) {
  565. if (Buffer.isBuffer(object)) return fromBuffer(that, object)
  566. if (isArray(object)) return fromArray(that, object)
  567. if (object == null) {
  568. throw new TypeError('must start with number, buffer, array or string')
  569. }
  570. if (typeof ArrayBuffer !== 'undefined') {
  571. if (object.buffer instanceof ArrayBuffer) {
  572. return fromTypedArray(that, object)
  573. }
  574. if (object instanceof ArrayBuffer) {
  575. return fromArrayBuffer(that, object)
  576. }
  577. }
  578. if (object.length) return fromArrayLike(that, object)
  579. return fromJsonObject(that, object)
  580. }
  581. function fromBuffer (that, buffer) {
  582. var length = checked(buffer.length) | 0
  583. that = allocate(that, length)
  584. buffer.copy(that, 0, 0, length)
  585. return that
  586. }
  587. function fromArray (that, array) {
  588. var length = checked(array.length) | 0
  589. that = allocate(that, length)
  590. for (var i = 0; i < length; i += 1) {
  591. that[i] = array[i] & 255
  592. }
  593. return that
  594. }
  595. // Duplicate of fromArray() to keep fromArray() monomorphic.
  596. function fromTypedArray (that, array) {
  597. var length = checked(array.length) | 0
  598. that = allocate(that, length)
  599. // Truncating the elements is probably not what people expect from typed
  600. // arrays with BYTES_PER_ELEMENT > 1 but it's compatible with the behavior
  601. // of the old Buffer constructor.
  602. for (var i = 0; i < length; i += 1) {
  603. that[i] = array[i] & 255
  604. }
  605. return that
  606. }
  607. function fromArrayBuffer (that, array) {
  608. if (Buffer.TYPED_ARRAY_SUPPORT) {
  609. // Return an augmented `Uint8Array` instance, for best performance
  610. array.byteLength
  611. that = Buffer._augment(new Uint8Array(array))
  612. } else {
  613. // Fallback: Return an object instance of the Buffer class
  614. that = fromTypedArray(that, new Uint8Array(array))
  615. }
  616. return that
  617. }
  618. function fromArrayLike (that, array) {
  619. var length = checked(array.length) | 0
  620. that = allocate(that, length)
  621. for (var i = 0; i < length; i += 1) {
  622. that[i] = array[i] & 255
  623. }
  624. return that
  625. }
  626. // Deserialize { type: 'Buffer', data: [1,2,3,...] } into a Buffer object.
  627. // Returns a zero-length buffer for inputs that don't conform to the spec.
  628. function fromJsonObject (that, object) {
  629. var array
  630. var length = 0
  631. if (object.type === 'Buffer' && isArray(object.data)) {
  632. array = object.data
  633. length = checked(array.length) | 0
  634. }
  635. that = allocate(that, length)
  636. for (var i = 0; i < length; i += 1) {
  637. that[i] = array[i] & 255
  638. }
  639. return that
  640. }
  641. if (Buffer.TYPED_ARRAY_SUPPORT) {
  642. Buffer.prototype.__proto__ = Uint8Array.prototype
  643. Buffer.__proto__ = Uint8Array
  644. }
  645. function allocate (that, length) {
  646. if (Buffer.TYPED_ARRAY_SUPPORT) {
  647. // Return an augmented `Uint8Array` instance, for best performance
  648. that = Buffer._augment(new Uint8Array(length))
  649. that.__proto__ = Buffer.prototype
  650. } else {
  651. // Fallback: Return an object instance of the Buffer class
  652. that.length = length
  653. that._isBuffer = true
  654. }
  655. var fromPool = length !== 0 && length <= Buffer.poolSize >>> 1
  656. if (fromPool) that.parent = rootParent
  657. return that
  658. }
  659. function checked (length) {
  660. // Note: cannot use `length < kMaxLength` here because that fails when
  661. // length is NaN (which is otherwise coerced to zero.)
  662. if (length >= kMaxLength()) {
  663. throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
  664. 'size: 0x' + kMaxLength().toString(16) + ' bytes')
  665. }
  666. return length | 0
  667. }
  668. function SlowBuffer (subject, encoding) {
  669. if (!(this instanceof SlowBuffer)) return new SlowBuffer(subject, encoding)
  670. var buf = new Buffer(subject, encoding)
  671. delete buf.parent
  672. return buf
  673. }
  674. Buffer.isBuffer = function isBuffer (b) {
  675. return !!(b != null && b._isBuffer)
  676. }
  677. Buffer.compare = function compare (a, b) {
  678. if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
  679. throw new TypeError('Arguments must be Buffers')
  680. }
  681. if (a === b) return 0
  682. var x = a.length
  683. var y = b.length
  684. var i = 0
  685. var len = Math.min(x, y)
  686. while (i < len) {
  687. if (a[i] !== b[i]) break
  688. ++i
  689. }
  690. if (i !== len) {
  691. x = a[i]
  692. y = b[i]
  693. }
  694. if (x < y) return -1
  695. if (y < x) return 1
  696. return 0
  697. }
  698. Buffer.isEncoding = function isEncoding (encoding) {
  699. switch (String(encoding).toLowerCase()) {
  700. case 'hex':
  701. case 'utf8':
  702. case 'utf-8':
  703. case 'ascii':
  704. case 'binary':
  705. case 'base64':
  706. case 'raw':
  707. case 'ucs2':
  708. case 'ucs-2':
  709. case 'utf16le':
  710. case 'utf-16le':
  711. return true
  712. default:
  713. return false
  714. }
  715. }
  716. Buffer.concat = function concat (list, length) {
  717. if (!isArray(list)) throw new TypeError('list argument must be an Array of Buffers.')
  718. if (list.length === 0) {
  719. return new Buffer(0)
  720. }
  721. var i
  722. if (length === undefined) {
  723. length = 0
  724. for (i = 0; i < list.length; i++) {
  725. length += list[i].length
  726. }
  727. }
  728. var buf = new Buffer(length)
  729. var pos = 0
  730. for (i = 0; i < list.length; i++) {
  731. var item = list[i]
  732. item.copy(buf, pos)
  733. pos += item.length
  734. }
  735. return buf
  736. }
  737. function byteLength (string, encoding) {
  738. if (typeof string !== 'string') string = '' + string
  739. var len = string.length
  740. if (len === 0) return 0
  741. // Use a for loop to avoid recursion
  742. var loweredCase = false
  743. for (;;) {
  744. switch (encoding) {
  745. case 'ascii':
  746. case 'binary':
  747. // Deprecated
  748. case 'raw':
  749. case 'raws':
  750. return len
  751. case 'utf8':
  752. case 'utf-8':
  753. return utf8ToBytes(string).length
  754. case 'ucs2':
  755. case 'ucs-2':
  756. case 'utf16le':
  757. case 'utf-16le':
  758. return len * 2
  759. case 'hex':
  760. return len >>> 1
  761. case 'base64':
  762. return base64ToBytes(string).length
  763. default:
  764. if (loweredCase) return utf8ToBytes(string).length // assume utf8
  765. encoding = ('' + encoding).toLowerCase()
  766. loweredCase = true
  767. }
  768. }
  769. }
  770. Buffer.byteLength = byteLength
  771. // pre-set for values that may exist in the future
  772. Buffer.prototype.length = undefined
  773. Buffer.prototype.parent = undefined
  774. function slowToString (encoding, start, end) {
  775. var loweredCase = false
  776. start = start | 0
  777. end = end === undefined || end === Infinity ? this.length : end | 0
  778. if (!encoding) encoding = 'utf8'
  779. if (start < 0) start = 0
  780. if (end > this.length) end = this.length
  781. if (end <= start) return ''
  782. while (true) {
  783. switch (encoding) {
  784. case 'hex':
  785. return hexSlice(this, start, end)
  786. case 'utf8':
  787. case 'utf-8':
  788. return utf8Slice(this, start, end)
  789. case 'ascii':
  790. return asciiSlice(this, start, end)
  791. case 'binary':
  792. return binarySlice(this, start, end)
  793. case 'base64':
  794. return base64Slice(this, start, end)
  795. case 'ucs2':
  796. case 'ucs-2':
  797. case 'utf16le':
  798. case 'utf-16le':
  799. return utf16leSlice(this, start, end)
  800. default:
  801. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  802. encoding = (encoding + '').toLowerCase()
  803. loweredCase = true
  804. }
  805. }
  806. }
  807. Buffer.prototype.toString = function toString () {
  808. var length = this.length | 0
  809. if (length === 0) return ''
  810. if (arguments.length === 0) return utf8Slice(this, 0, length)
  811. return slowToString.apply(this, arguments)
  812. }
  813. Buffer.prototype.equals = function equals (b) {
  814. if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
  815. if (this === b) return true
  816. return Buffer.compare(this, b) === 0
  817. }
  818. Buffer.prototype.inspect = function inspect () {
  819. var str = ''
  820. var max = exports.INSPECT_MAX_BYTES
  821. if (this.length > 0) {
  822. str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
  823. if (this.length > max) str += ' ... '
  824. }
  825. return '<Buffer ' + str + '>'
  826. }
  827. Buffer.prototype.compare = function compare (b) {
  828. if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
  829. if (this === b) return 0
  830. return Buffer.compare(this, b)
  831. }
  832. Buffer.prototype.indexOf = function indexOf (val, byteOffset) {
  833. if (byteOffset > 0x7fffffff) byteOffset = 0x7fffffff
  834. else if (byteOffset < -0x80000000) byteOffset = -0x80000000
  835. byteOffset >>= 0
  836. if (this.length === 0) return -1
  837. if (byteOffset >= this.length) return -1
  838. // Negative offsets start from the end of the buffer
  839. if (byteOffset < 0) byteOffset = Math.max(this.length + byteOffset, 0)
  840. if (typeof val === 'string') {
  841. if (val.length === 0) return -1 // special case: looking for empty string always fails
  842. return String.prototype.indexOf.call(this, val, byteOffset)
  843. }
  844. if (Buffer.isBuffer(val)) {
  845. return arrayIndexOf(this, val, byteOffset)
  846. }
  847. if (typeof val === 'number') {
  848. if (Buffer.TYPED_ARRAY_SUPPORT && Uint8Array.prototype.indexOf === 'function') {
  849. return Uint8Array.prototype.indexOf.call(this, val, byteOffset)
  850. }
  851. return arrayIndexOf(this, [ val ], byteOffset)
  852. }
  853. function arrayIndexOf (arr, val, byteOffset) {
  854. var foundIndex = -1
  855. for (var i = 0; byteOffset + i < arr.length; i++) {
  856. if (arr[byteOffset + i] === val[foundIndex === -1 ? 0 : i - foundIndex]) {
  857. if (foundIndex === -1) foundIndex = i
  858. if (i - foundIndex + 1 === val.length) return byteOffset + foundIndex
  859. } else {
  860. foundIndex = -1
  861. }
  862. }
  863. return -1
  864. }
  865. throw new TypeError('val must be string, number or Buffer')
  866. }
  867. // `get` is deprecated
  868. Buffer.prototype.get = function get (offset) {
  869. console.log('.get() is deprecated. Access using array indexes instead.')
  870. return this.readUInt8(offset)
  871. }
  872. // `set` is deprecated
  873. Buffer.prototype.set = function set (v, offset) {
  874. console.log('.set() is deprecated. Access using array indexes instead.')
  875. return this.writeUInt8(v, offset)
  876. }
  877. function hexWrite (buf, string, offset, length) {
  878. offset = Number(offset) || 0
  879. var remaining = buf.length - offset
  880. if (!length) {
  881. length = remaining
  882. } else {
  883. length = Number(length)
  884. if (length > remaining) {
  885. length = remaining
  886. }
  887. }
  888. // must be an even number of digits
  889. var strLen = string.length
  890. if (strLen % 2 !== 0) throw new Error('Invalid hex string')
  891. if (length > strLen / 2) {
  892. length = strLen / 2
  893. }
  894. for (var i = 0; i < length; i++) {
  895. var parsed = parseInt(string.substr(i * 2, 2), 16)
  896. if (isNaN(parsed)) throw new Error('Invalid hex string')
  897. buf[offset + i] = parsed
  898. }
  899. return i
  900. }
  901. function utf8Write (buf, string, offset, length) {
  902. return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
  903. }
  904. function asciiWrite (buf, string, offset, length) {
  905. return blitBuffer(asciiToBytes(string), buf, offset, length)
  906. }
  907. function binaryWrite (buf, string, offset, length) {
  908. return asciiWrite(buf, string, offset, length)
  909. }
  910. function base64Write (buf, string, offset, length) {
  911. return blitBuffer(base64ToBytes(string), buf, offset, length)
  912. }
  913. function ucs2Write (buf, string, offset, length) {
  914. return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
  915. }
  916. Buffer.prototype.write = function write (string, offset, length, encoding) {
  917. // Buffer#write(string)
  918. if (offset === undefined) {
  919. encoding = 'utf8'
  920. length = this.length
  921. offset = 0
  922. // Buffer#write(string, encoding)
  923. } else if (length === undefined && typeof offset === 'string') {
  924. encoding = offset
  925. length = this.length
  926. offset = 0
  927. // Buffer#write(string, offset[, length][, encoding])
  928. } else if (isFinite(offset)) {
  929. offset = offset | 0
  930. if (isFinite(length)) {
  931. length = length | 0
  932. if (encoding === undefined) encoding = 'utf8'
  933. } else {
  934. encoding = length
  935. length = undefined
  936. }
  937. // legacy write(string, encoding, offset, length) - remove in v0.13
  938. } else {
  939. var swap = encoding
  940. encoding = offset
  941. offset = length | 0
  942. length = swap
  943. }
  944. var remaining = this.length - offset
  945. if (length === undefined || length > remaining) length = remaining
  946. if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
  947. throw new RangeError('attempt to write outside buffer bounds')
  948. }
  949. if (!encoding) encoding = 'utf8'
  950. var loweredCase = false
  951. for (;;) {
  952. switch (encoding) {
  953. case 'hex':
  954. return hexWrite(this, string, offset, length)
  955. case 'utf8':
  956. case 'utf-8':
  957. return utf8Write(this, string, offset, length)
  958. case 'ascii':
  959. return asciiWrite(this, string, offset, length)
  960. case 'binary':
  961. return binaryWrite(this, string, offset, length)
  962. case 'base64':
  963. // Warning: maxLength not taken into account in base64Write
  964. return base64Write(this, string, offset, length)
  965. case 'ucs2':
  966. case 'ucs-2':
  967. case 'utf16le':
  968. case 'utf-16le':
  969. return ucs2Write(this, string, offset, length)
  970. default:
  971. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  972. encoding = ('' + encoding).toLowerCase()
  973. loweredCase = true
  974. }
  975. }
  976. }
  977. Buffer.prototype.toJSON = function toJSON () {
  978. return {
  979. type: 'Buffer',
  980. data: Array.prototype.slice.call(this._arr || this, 0)
  981. }
  982. }
  983. function base64Slice (buf, start, end) {
  984. if (start === 0 && end === buf.length) {
  985. return base64.fromByteArray(buf)
  986. } else {
  987. return base64.fromByteArray(buf.slice(start, end))
  988. }
  989. }
  990. function utf8Slice (buf, start, end) {
  991. end = Math.min(buf.length, end)
  992. var res = []
  993. var i = start
  994. while (i < end) {
  995. var firstByte = buf[i]
  996. var codePoint = null
  997. var bytesPerSequence = (firstByte > 0xEF) ? 4
  998. : (firstByte > 0xDF) ? 3
  999. : (firstByte > 0xBF) ? 2
  1000. : 1
  1001. if (i + bytesPerSequence <= end) {
  1002. var secondByte, thirdByte, fourthByte, tempCodePoint
  1003. switch (bytesPerSequence) {
  1004. case 1:
  1005. if (firstByte < 0x80) {
  1006. codePoint = firstByte
  1007. }
  1008. break
  1009. case 2:
  1010. secondByte = buf[i + 1]
  1011. if ((secondByte & 0xC0) === 0x80) {
  1012. tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
  1013. if (tempCodePoint > 0x7F) {
  1014. codePoint = tempCodePoint
  1015. }
  1016. }
  1017. break
  1018. case 3:
  1019. secondByte = buf[i + 1]
  1020. thirdByte = buf[i + 2]
  1021. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
  1022. tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
  1023. if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
  1024. codePoint = tempCodePoint
  1025. }
  1026. }
  1027. break
  1028. case 4:
  1029. secondByte = buf[i + 1]
  1030. thirdByte = buf[i + 2]
  1031. fourthByte = buf[i + 3]
  1032. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
  1033. tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
  1034. if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
  1035. codePoint = tempCodePoint
  1036. }
  1037. }
  1038. }
  1039. }
  1040. if (codePoint === null) {
  1041. // we did not generate a valid codePoint so insert a
  1042. // replacement char (U+FFFD) and advance only 1 byte
  1043. codePoint = 0xFFFD
  1044. bytesPerSequence = 1
  1045. } else if (codePoint > 0xFFFF) {
  1046. // encode to utf16 (surrogate pair dance)
  1047. codePoint -= 0x10000
  1048. res.push(codePoint >>> 10 & 0x3FF | 0xD800)
  1049. codePoint = 0xDC00 | codePoint & 0x3FF
  1050. }
  1051. res.push(codePoint)
  1052. i += bytesPerSequence
  1053. }
  1054. return decodeCodePointsArray(res)
  1055. }
  1056. // Based on http://stackoverflow.com/a/22747272/680742, the browser with
  1057. // the lowest limit is Chrome, with 0x10000 args.
  1058. // We go 1 magnitude less, for safety
  1059. var MAX_ARGUMENTS_LENGTH = 0x1000
  1060. function decodeCodePointsArray (codePoints) {
  1061. var len = codePoints.length
  1062. if (len <= MAX_ARGUMENTS_LENGTH) {
  1063. return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
  1064. }
  1065. // Decode in chunks to avoid "call stack size exceeded".
  1066. var res = ''
  1067. var i = 0
  1068. while (i < len) {
  1069. res += String.fromCharCode.apply(
  1070. String,
  1071. codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
  1072. )
  1073. }
  1074. return res
  1075. }
  1076. function asciiSlice (buf, start, end) {
  1077. var ret = ''
  1078. end = Math.min(buf.length, end)
  1079. for (var i = start; i < end; i++) {
  1080. ret += String.fromCharCode(buf[i] & 0x7F)
  1081. }
  1082. return ret
  1083. }
  1084. function binarySlice (buf, start, end) {
  1085. var ret = ''
  1086. end = Math.min(buf.length, end)
  1087. for (var i = start; i < end; i++) {
  1088. ret += String.fromCharCode(buf[i])
  1089. }
  1090. return ret
  1091. }
  1092. function hexSlice (buf, start, end) {
  1093. var len = buf.length
  1094. if (!start || start < 0) start = 0
  1095. if (!end || end < 0 || end > len) end = len
  1096. var out = ''
  1097. for (var i = start; i < end; i++) {
  1098. out += toHex(buf[i])
  1099. }
  1100. return out
  1101. }
  1102. function utf16leSlice (buf, start, end) {
  1103. var bytes = buf.slice(start, end)
  1104. var res = ''
  1105. for (var i = 0; i < bytes.length; i += 2) {
  1106. res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
  1107. }
  1108. return res
  1109. }
  1110. Buffer.prototype.slice = function slice (start, end) {
  1111. var len = this.length
  1112. start = ~~start
  1113. end = end === undefined ? len : ~~end
  1114. if (start < 0) {
  1115. start += len
  1116. if (start < 0) start = 0
  1117. } else if (start > len) {
  1118. start = len
  1119. }
  1120. if (end < 0) {
  1121. end += len
  1122. if (end < 0) end = 0
  1123. } else if (end > len) {
  1124. end = len
  1125. }
  1126. if (end < start) end = start
  1127. var newBuf
  1128. if (Buffer.TYPED_ARRAY_SUPPORT) {
  1129. newBuf = Buffer._augment(this.subarray(start, end))
  1130. } else {
  1131. var sliceLen = end - start
  1132. newBuf = new Buffer(sliceLen, undefined)
  1133. for (var i = 0; i < sliceLen; i++) {
  1134. newBuf[i] = this[i + start]
  1135. }
  1136. }
  1137. if (newBuf.length) newBuf.parent = this.parent || this
  1138. return newBuf
  1139. }
  1140. /*
  1141. * Need to make sure that buffer isn't trying to write out of bounds.
  1142. */
  1143. function checkOffset (offset, ext, length) {
  1144. if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
  1145. if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
  1146. }
  1147. Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
  1148. offset = offset | 0
  1149. byteLength = byteLength | 0
  1150. if (!noAssert) checkOffset(offset, byteLength, this.length)
  1151. var val = this[offset]
  1152. var mul = 1
  1153. var i = 0
  1154. while (++i < byteLength && (mul *= 0x100)) {
  1155. val += this[offset + i] * mul
  1156. }
  1157. return val
  1158. }
  1159. Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
  1160. offset = offset | 0
  1161. byteLength = byteLength | 0
  1162. if (!noAssert) {
  1163. checkOffset(offset, byteLength, this.length)
  1164. }
  1165. var val = this[offset + --byteLength]
  1166. var mul = 1
  1167. while (byteLength > 0 && (mul *= 0x100)) {
  1168. val += this[offset + --byteLength] * mul
  1169. }
  1170. return val
  1171. }
  1172. Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
  1173. if (!noAssert) checkOffset(offset, 1, this.length)
  1174. return this[offset]
  1175. }
  1176. Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
  1177. if (!noAssert) checkOffset(offset, 2, this.length)
  1178. return this[offset] | (this[offset + 1] << 8)
  1179. }
  1180. Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
  1181. if (!noAssert) checkOffset(offset, 2, this.length)
  1182. return (this[offset] << 8) | this[offset + 1]
  1183. }
  1184. Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
  1185. if (!noAssert) checkOffset(offset, 4, this.length)
  1186. return ((this[offset]) |
  1187. (this[offset + 1] << 8) |
  1188. (this[offset + 2] << 16)) +
  1189. (this[offset + 3] * 0x1000000)
  1190. }
  1191. Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
  1192. if (!noAssert) checkOffset(offset, 4, this.length)
  1193. return (this[offset] * 0x1000000) +
  1194. ((this[offset + 1] << 16) |
  1195. (this[offset + 2] << 8) |
  1196. this[offset + 3])
  1197. }
  1198. Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
  1199. offset = offset | 0
  1200. byteLength = byteLength | 0
  1201. if (!noAssert) checkOffset(offset, byteLength, this.length)
  1202. var val = this[offset]
  1203. var mul = 1
  1204. var i = 0
  1205. while (++i < byteLength && (mul *= 0x100)) {
  1206. val += this[offset + i] * mul
  1207. }
  1208. mul *= 0x80
  1209. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  1210. return val
  1211. }
  1212. Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
  1213. offset = offset | 0
  1214. byteLength = byteLength | 0
  1215. if (!noAssert) checkOffset(offset, byteLength, this.length)
  1216. var i = byteLength
  1217. var mul = 1
  1218. var val = this[offset + --i]
  1219. while (i > 0 && (mul *= 0x100)) {
  1220. val += this[offset + --i] * mul
  1221. }
  1222. mul *= 0x80
  1223. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  1224. return val
  1225. }
  1226. Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
  1227. if (!noAssert) checkOffset(offset, 1, this.length)
  1228. if (!(this[offset] & 0x80)) return (this[offset])
  1229. return ((0xff - this[offset] + 1) * -1)
  1230. }
  1231. Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
  1232. if (!noAssert) checkOffset(offset, 2, this.length)
  1233. var val = this[offset] | (this[offset + 1] << 8)
  1234. return (val & 0x8000) ? val | 0xFFFF0000 : val
  1235. }
  1236. Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
  1237. if (!noAssert) checkOffset(offset, 2, this.length)
  1238. var val = this[offset + 1] | (this[offset] << 8)
  1239. return (val & 0x8000) ? val | 0xFFFF0000 : val
  1240. }
  1241. Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
  1242. if (!noAssert) checkOffset(offset, 4, this.length)
  1243. return (this[offset]) |
  1244. (this[offset + 1] << 8) |
  1245. (this[offset + 2] << 16) |
  1246. (this[offset + 3] << 24)
  1247. }
  1248. Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
  1249. if (!noAssert) checkOffset(offset, 4, this.length)
  1250. return (this[offset] << 24) |
  1251. (this[offset + 1] << 16) |
  1252. (this[offset + 2] << 8) |
  1253. (this[offset + 3])
  1254. }
  1255. Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
  1256. if (!noAssert) checkOffset(offset, 4, this.length)
  1257. return ieee754.read(this, offset, true, 23, 4)
  1258. }
  1259. Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
  1260. if (!noAssert) checkOffset(offset, 4, this.length)
  1261. return ieee754.read(this, offset, false, 23, 4)
  1262. }
  1263. Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
  1264. if (!noAssert) checkOffset(offset, 8, this.length)
  1265. return ieee754.read(this, offset, true, 52, 8)
  1266. }
  1267. Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
  1268. if (!noAssert) checkOffset(offset, 8, this.length)
  1269. return ieee754.read(this, offset, false, 52, 8)
  1270. }
  1271. function checkInt (buf, value, offset, ext, max, min) {
  1272. if (!Buffer.isBuffer(buf)) throw new TypeError('buffer must be a Buffer instance')
  1273. if (value > max || value < min) throw new RangeError('value is out of bounds')
  1274. if (offset + ext > buf.length) throw new RangeError('index out of range')
  1275. }
  1276. Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
  1277. value = +value
  1278. offset = offset | 0
  1279. byteLength = byteLength | 0
  1280. if (!noAssert) checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0)
  1281. var mul = 1
  1282. var i = 0
  1283. this[offset] = value & 0xFF
  1284. while (++i < byteLength && (mul *= 0x100)) {
  1285. this[offset + i] = (value / mul) & 0xFF
  1286. }
  1287. return offset + byteLength
  1288. }
  1289. Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
  1290. value = +value
  1291. offset = offset | 0
  1292. byteLength = byteLength | 0
  1293. if (!noAssert) checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0)
  1294. var i = byteLength - 1
  1295. var mul = 1
  1296. this[offset + i] = value & 0xFF
  1297. while (--i >= 0 && (mul *= 0x100)) {
  1298. this[offset + i] = (value / mul) & 0xFF
  1299. }
  1300. return offset + byteLength
  1301. }
  1302. Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
  1303. value = +value
  1304. offset = offset | 0
  1305. if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
  1306. if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
  1307. this[offset] = (value & 0xff)
  1308. return offset + 1
  1309. }
  1310. function objectWriteUInt16 (buf, value, offset, littleEndian) {
  1311. if (value < 0) value = 0xffff + value + 1
  1312. for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; i++) {
  1313. buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
  1314. (littleEndian ? i : 1 - i) * 8
  1315. }
  1316. }
  1317. Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
  1318. value = +value
  1319. offset = offset | 0
  1320. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  1321. if (Buffer.TYPED_ARRAY_SUPPORT) {
  1322. this[offset] = (value & 0xff)
  1323. this[offset + 1] = (value >>> 8)
  1324. } else {
  1325. objectWriteUInt16(this, value, offset, true)
  1326. }
  1327. return offset + 2
  1328. }
  1329. Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
  1330. value = +value
  1331. offset = offset | 0
  1332. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  1333. if (Buffer.TYPED_ARRAY_SUPPORT) {
  1334. this[offset] = (value >>> 8)
  1335. this[offset + 1] = (value & 0xff)
  1336. } else {
  1337. objectWriteUInt16(this, value, offset, false)
  1338. }
  1339. return offset + 2
  1340. }
  1341. function objectWriteUInt32 (buf, value, offset, littleEndian) {
  1342. if (value < 0) value = 0xffffffff + value + 1
  1343. for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; i++) {
  1344. buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
  1345. }
  1346. }
  1347. Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
  1348. value = +value
  1349. offset = offset | 0
  1350. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  1351. if (Buffer.TYPED_ARRAY_SUPPORT) {
  1352. this[offset + 3] = (value >>> 24)
  1353. this[offset + 2] = (value >>> 16)
  1354. this[offset + 1] = (value >>> 8)
  1355. this[offset] = (value & 0xff)
  1356. } else {
  1357. objectWriteUInt32(this, value, offset, true)
  1358. }
  1359. return offset + 4
  1360. }
  1361. Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
  1362. value = +value
  1363. offset = offset | 0
  1364. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  1365. if (Buffer.TYPED_ARRAY_SUPPORT) {
  1366. this[offset] = (value >>> 24)
  1367. this[offset + 1] = (value >>> 16)
  1368. this[offset + 2] = (value >>> 8)
  1369. this[offset + 3] = (value & 0xff)
  1370. } else {
  1371. objectWriteUInt32(this, value, offset, false)
  1372. }
  1373. return offset + 4
  1374. }
  1375. Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
  1376. value = +value
  1377. offset = offset | 0
  1378. if (!noAssert) {
  1379. var limit = Math.pow(2, 8 * byteLength - 1)
  1380. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  1381. }
  1382. var i = 0
  1383. var mul = 1
  1384. var sub = value < 0 ? 1 : 0
  1385. this[offset] = value & 0xFF
  1386. while (++i < byteLength && (mul *= 0x100)) {
  1387. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  1388. }
  1389. return offset + byteLength
  1390. }
  1391. Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
  1392. value = +value
  1393. offset = offset | 0
  1394. if (!noAssert) {
  1395. var limit = Math.pow(2, 8 * byteLength - 1)
  1396. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  1397. }
  1398. var i = byteLength - 1
  1399. var mul = 1
  1400. var sub = value < 0 ? 1 : 0
  1401. this[offset + i] = value & 0xFF
  1402. while (--i >= 0 && (mul *= 0x100)) {
  1403. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  1404. }
  1405. return offset + byteLength
  1406. }
  1407. Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
  1408. value = +value
  1409. offset = offset | 0
  1410. if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
  1411. if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
  1412. if (value < 0) value = 0xff + value + 1
  1413. this[offset] = (value & 0xff)
  1414. return offset + 1
  1415. }
  1416. Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
  1417. value = +value
  1418. offset = offset | 0
  1419. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  1420. if (Buffer.TYPED_ARRAY_SUPPORT) {
  1421. this[offset] = (value & 0xff)
  1422. this[offset + 1] = (value >>> 8)
  1423. } else {
  1424. objectWriteUInt16(this, value, offset, true)
  1425. }
  1426. return offset + 2
  1427. }
  1428. Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
  1429. value = +value
  1430. offset = offset | 0
  1431. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  1432. if (Buffer.TYPED_ARRAY_SUPPORT) {
  1433. this[offset] = (value >>> 8)
  1434. this[offset + 1] = (value & 0xff)
  1435. } else {
  1436. objectWriteUInt16(this, value, offset, false)
  1437. }
  1438. return offset + 2
  1439. }
  1440. Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
  1441. value = +value
  1442. offset = offset | 0
  1443. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  1444. if (Buffer.TYPED_ARRAY_SUPPORT) {
  1445. this[offset] = (value & 0xff)
  1446. this[offset + 1] = (value >>> 8)
  1447. this[offset + 2] = (value >>> 16)
  1448. this[offset + 3] = (value >>> 24)
  1449. } else {
  1450. objectWriteUInt32(this, value, offset, true)
  1451. }
  1452. return offset + 4
  1453. }
  1454. Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
  1455. value = +value
  1456. offset = offset | 0
  1457. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  1458. if (value < 0) value = 0xffffffff + value + 1
  1459. if (Buffer.TYPED_ARRAY_SUPPORT) {
  1460. this[offset] = (value >>> 24)
  1461. this[offset + 1] = (value >>> 16)
  1462. this[offset + 2] = (value >>> 8)
  1463. this[offset + 3] = (value & 0xff)
  1464. } else {
  1465. objectWriteUInt32(this, value, offset, false)
  1466. }
  1467. return offset + 4
  1468. }
  1469. function checkIEEE754 (buf, value, offset, ext, max, min) {
  1470. if (value > max || value < min) throw new RangeError('value is out of bounds')
  1471. if (offset + ext > buf.length) throw new RangeError('index out of range')
  1472. if (offset < 0) throw new RangeError('index out of range')
  1473. }
  1474. function writeFloat (buf, value, offset, littleEndian, noAssert) {
  1475. if (!noAssert) {
  1476. checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
  1477. }
  1478. ieee754.write(buf, value, offset, littleEndian, 23, 4)
  1479. return offset + 4
  1480. }
  1481. Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
  1482. return writeFloat(this, value, offset, true, noAssert)
  1483. }
  1484. Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
  1485. return writeFloat(this, value, offset, false, noAssert)
  1486. }
  1487. function writeDouble (buf, value, offset, littleEndian, noAssert) {
  1488. if (!noAssert) {
  1489. checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
  1490. }
  1491. ieee754.write(buf, value, offset, littleEndian, 52, 8)
  1492. return offset + 8
  1493. }
  1494. Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
  1495. return writeDouble(this, value, offset, true, noAssert)
  1496. }
  1497. Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
  1498. return writeDouble(this, value, offset, false, noAssert)
  1499. }
  1500. // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
  1501. Buffer.prototype.copy = function copy (target, targetStart, start, end) {
  1502. if (!start) start = 0
  1503. if (!end && end !== 0) end = this.length
  1504. if (targetStart >= target.length) targetStart = target.length
  1505. if (!targetStart) targetStart = 0
  1506. if (end > 0 && end < start) end = start
  1507. // Copy 0 bytes; we're done
  1508. if (end === start) return 0
  1509. if (target.length === 0 || this.length === 0) return 0
  1510. // Fatal error conditions
  1511. if (targetStart < 0) {
  1512. throw new RangeError('targetStart out of bounds')
  1513. }
  1514. if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
  1515. if (end < 0) throw new RangeError('sourceEnd out of bounds')
  1516. // Are we oob?
  1517. if (end > this.length) end = this.length
  1518. if (target.length - targetStart < end - start) {
  1519. end = target.length - targetStart + start
  1520. }
  1521. var len = end - start
  1522. var i
  1523. if (this === target && start < targetStart && targetStart < end) {
  1524. // descending copy from end
  1525. for (i = len - 1; i >= 0; i--) {
  1526. target[i + targetStart] = this[i + start]
  1527. }
  1528. } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
  1529. // ascending copy from start
  1530. for (i = 0; i < len; i++) {
  1531. target[i + targetStart] = this[i + start]
  1532. }
  1533. } else {
  1534. target._set(this.subarray(start, start + len), targetStart)
  1535. }
  1536. return len
  1537. }
  1538. // fill(value, start=0, end=buffer.length)
  1539. Buffer.prototype.fill = function fill (value, start, end) {
  1540. if (!value) value = 0
  1541. if (!start) start = 0
  1542. if (!end) end = this.length
  1543. if (end < start) throw new RangeError('end < start')
  1544. // Fill 0 bytes; we're done
  1545. if (end === start) return
  1546. if (this.length === 0) return
  1547. if (start < 0 || start >= this.length) throw new RangeError('start out of bounds')
  1548. if (end < 0 || end > this.length) throw new RangeError('end out of bounds')
  1549. var i
  1550. if (typeof value === 'number') {
  1551. for (i = start; i < end; i++) {
  1552. this[i] = value
  1553. }
  1554. } else {
  1555. var bytes = utf8ToBytes(value.toString())
  1556. var len = bytes.length
  1557. for (i = start; i < end; i++) {
  1558. this[i] = bytes[i % len]
  1559. }
  1560. }
  1561. return this
  1562. }
  1563. /**
  1564. * Creates a new `ArrayBuffer` with the *copied* memory of the buffer instance.
  1565. * Added in Node 0.12. Only available in browsers that support ArrayBuffer.
  1566. */
  1567. Buffer.prototype.toArrayBuffer = function toArrayBuffer () {
  1568. if (typeof Uint8Array !== 'undefined') {
  1569. if (Buffer.TYPED_ARRAY_SUPPORT) {
  1570. return (new Buffer(this)).buffer
  1571. } else {
  1572. var buf = new Uint8Array(this.length)
  1573. for (var i = 0, len = buf.length; i < len; i += 1) {
  1574. buf[i] = this[i]
  1575. }
  1576. return buf.buffer
  1577. }
  1578. } else {
  1579. throw new TypeError('Buffer.toArrayBuffer not supported in this browser')
  1580. }
  1581. }
  1582. // HELPER FUNCTIONS
  1583. // ================
  1584. var BP = Buffer.prototype
  1585. /**
  1586. * Augment a Uint8Array *instance* (not the Uint8Array class!) with Buffer methods
  1587. */
  1588. Buffer._augment = function _augment (arr) {
  1589. arr.constructor = Buffer
  1590. arr._isBuffer = true
  1591. // save reference to original Uint8Array set method before overwriting
  1592. arr._set = arr.set
  1593. // deprecated
  1594. arr.get = BP.get
  1595. arr.set = BP.set
  1596. arr.write = BP.write
  1597. arr.toString = BP.toString
  1598. arr.toLocaleString = BP.toString
  1599. arr.toJSON = BP.toJSON
  1600. arr.equals = BP.equals
  1601. arr.compare = BP.compare
  1602. arr.indexOf = BP.indexOf
  1603. arr.copy = BP.copy
  1604. arr.slice = BP.slice
  1605. arr.readUIntLE = BP.readUIntLE
  1606. arr.readUIntBE = BP.readUIntBE
  1607. arr.readUInt8 = BP.readUInt8
  1608. arr.readUInt16LE = BP.readUInt16LE
  1609. arr.readUInt16BE = BP.readUInt16BE
  1610. arr.readUInt32LE = BP.readUInt32LE
  1611. arr.readUInt32BE = BP.readUInt32BE
  1612. arr.readIntLE = BP.readIntLE
  1613. arr.readIntBE = BP.readIntBE
  1614. arr.readInt8 = BP.readInt8
  1615. arr.readInt16LE = BP.readInt16LE
  1616. arr.readInt16BE = BP.readInt16BE
  1617. arr.readInt32LE = BP.readInt32LE
  1618. arr.readInt32BE = BP.readInt32BE
  1619. arr.readFloatLE = BP.readFloatLE
  1620. arr.readFloatBE = BP.readFloatBE
  1621. arr.readDoubleLE = BP.readDoubleLE
  1622. arr.readDoubleBE = BP.readDoubleBE
  1623. arr.writeUInt8 = BP.writeUInt8
  1624. arr.writeUIntLE = BP.writeUIntLE
  1625. arr.writeUIntBE = BP.writeUIntBE
  1626. arr.writeUInt16LE = BP.writeUInt16LE
  1627. arr.writeUInt16BE = BP.writeUInt16BE
  1628. arr.writeUInt32LE = BP.writeUInt32LE
  1629. arr.writeUInt32BE = BP.writeUInt32BE
  1630. arr.writeIntLE = BP.writeIntLE
  1631. arr.writeIntBE = BP.writeIntBE
  1632. arr.writeInt8 = BP.writeInt8
  1633. arr.writeInt16LE = BP.writeInt16LE
  1634. arr.writeInt16BE = BP.writeInt16BE
  1635. arr.writeInt32LE = BP.writeInt32LE
  1636. arr.writeInt32BE = BP.writeInt32BE
  1637. arr.writeFloatLE = BP.writeFloatLE
  1638. arr.writeFloatBE = BP.writeFloatBE
  1639. arr.writeDoubleLE = BP.writeDoubleLE
  1640. arr.writeDoubleBE = BP.writeDoubleBE
  1641. arr.fill = BP.fill
  1642. arr.inspect = BP.inspect
  1643. arr.toArrayBuffer = BP.toArrayBuffer
  1644. return arr
  1645. }
  1646. var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g
  1647. function base64clean (str) {
  1648. // Node strips out invalid characters like \n and \t from the string, base64-js does not
  1649. str = stringtrim(str).replace(INVALID_BASE64_RE, '')
  1650. // Node converts strings with length < 2 to ''
  1651. if (str.length < 2) return ''
  1652. // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
  1653. while (str.length % 4 !== 0) {
  1654. str = str + '='
  1655. }
  1656. return str
  1657. }
  1658. function stringtrim (str) {
  1659. if (str.trim) return str.trim()
  1660. return str.replace(/^\s+|\s+$/g, '')
  1661. }
  1662. function toHex (n) {
  1663. if (n < 16) return '0' + n.toString(16)
  1664. return n.toString(16)
  1665. }
  1666. function utf8ToBytes (string, units) {
  1667. units = units || Infinity
  1668. var codePoint
  1669. var length = string.length
  1670. var leadSurrogate = null
  1671. var bytes = []
  1672. for (var i = 0; i < length; i++) {
  1673. codePoint = string.charCodeAt(i)
  1674. // is surrogate component
  1675. if (codePoint > 0xD7FF && codePoint < 0xE000) {
  1676. // last char was a lead
  1677. if (!leadSurrogate) {
  1678. // no lead yet
  1679. if (codePoint > 0xDBFF) {
  1680. // unexpected trail
  1681. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  1682. continue
  1683. } else if (i + 1 === length) {
  1684. // unpaired lead
  1685. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  1686. continue
  1687. }
  1688. // valid lead
  1689. leadSurrogate = codePoint
  1690. continue
  1691. }
  1692. // 2 leads in a row
  1693. if (codePoint < 0xDC00) {
  1694. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  1695. leadSurrogate = codePoint
  1696. continue
  1697. }
  1698. // valid surrogate pair
  1699. codePoint = leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00 | 0x10000
  1700. } else if (leadSurrogate) {
  1701. // valid bmp char, but last char was a lead
  1702. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  1703. }
  1704. leadSurrogate = null
  1705. // encode utf8
  1706. if (codePoint < 0x80) {
  1707. if ((units -= 1) < 0) break
  1708. bytes.push(codePoint)
  1709. } else if (codePoint < 0x800) {
  1710. if ((units -= 2) < 0) break
  1711. bytes.push(
  1712. codePoint >> 0x6 | 0xC0,
  1713. codePoint & 0x3F | 0x80
  1714. )
  1715. } else if (codePoint < 0x10000) {
  1716. if ((units -= 3) < 0) break
  1717. bytes.push(
  1718. codePoint >> 0xC | 0xE0,
  1719. codePoint >> 0x6 & 0x3F | 0x80,
  1720. codePoint & 0x3F | 0x80
  1721. )
  1722. } else if (codePoint < 0x110000) {
  1723. if ((units -= 4) < 0) break
  1724. bytes.push(
  1725. codePoint >> 0x12 | 0xF0,
  1726. codePoint >> 0xC & 0x3F | 0x80,
  1727. codePoint >> 0x6 & 0x3F | 0x80,
  1728. codePoint & 0x3F | 0x80
  1729. )
  1730. } else {
  1731. throw new Error('Invalid code point')
  1732. }
  1733. }
  1734. return bytes
  1735. }
  1736. function asciiToBytes (str) {
  1737. var byteArray = []
  1738. for (var i = 0; i < str.length; i++) {
  1739. // Node's code seems to be doing this and not & 0x7F..
  1740. byteArray.push(str.charCodeAt(i) & 0xFF)
  1741. }
  1742. return byteArray
  1743. }
  1744. function utf16leToBytes (str, units) {
  1745. var c, hi, lo
  1746. var byteArray = []
  1747. for (var i = 0; i < str.length; i++) {
  1748. if ((units -= 2) < 0) break
  1749. c = str.charCodeAt(i)
  1750. hi = c >> 8
  1751. lo = c % 256
  1752. byteArray.push(lo)
  1753. byteArray.push(hi)
  1754. }
  1755. return byteArray
  1756. }
  1757. function base64ToBytes (str) {
  1758. return base64.toByteArray(base64clean(str))
  1759. }
  1760. function blitBuffer (src, dst, offset, length) {
  1761. for (var i = 0; i < length; i++) {
  1762. if ((i + offset >= dst.length) || (i >= src.length)) break
  1763. dst[i + offset] = src[i]
  1764. }
  1765. return i
  1766. }
  1767. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  1768. },{"base64-js":5,"ieee754":8,"is-array":9}],8:[function(require,module,exports){
  1769. exports.read = function (buffer, offset, isLE, mLen, nBytes) {
  1770. var e, m
  1771. var eLen = nBytes * 8 - mLen - 1
  1772. var eMax = (1 << eLen) - 1
  1773. var eBias = eMax >> 1
  1774. var nBits = -7
  1775. var i = isLE ? (nBytes - 1) : 0
  1776. var d = isLE ? -1 : 1
  1777. var s = buffer[offset + i]
  1778. i += d
  1779. e = s & ((1 << (-nBits)) - 1)
  1780. s >>= (-nBits)
  1781. nBits += eLen
  1782. for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {}
  1783. m = e & ((1 << (-nBits)) - 1)
  1784. e >>= (-nBits)
  1785. nBits += mLen
  1786. for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {}
  1787. if (e === 0) {
  1788. e = 1 - eBias
  1789. } else if (e === eMax) {
  1790. return m ? NaN : ((s ? -1 : 1) * Infinity)
  1791. } else {
  1792. m = m + Math.pow(2, mLen)
  1793. e = e - eBias
  1794. }
  1795. return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
  1796. }
  1797. exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
  1798. var e, m, c
  1799. var eLen = nBytes * 8 - mLen - 1
  1800. var eMax = (1 << eLen) - 1
  1801. var eBias = eMax >> 1
  1802. var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
  1803. var i = isLE ? 0 : (nBytes - 1)
  1804. var d = isLE ? 1 : -1
  1805. var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
  1806. value = Math.abs(value)
  1807. if (isNaN(value) || value === Infinity) {
  1808. m = isNaN(value) ? 1 : 0
  1809. e = eMax
  1810. } else {
  1811. e = Math.floor(Math.log(value) / Math.LN2)
  1812. if (value * (c = Math.pow(2, -e)) < 1) {
  1813. e--
  1814. c *= 2
  1815. }
  1816. if (e + eBias >= 1) {
  1817. value += rt / c
  1818. } else {
  1819. value += rt * Math.pow(2, 1 - eBias)
  1820. }
  1821. if (value * c >= 2) {
  1822. e++
  1823. c /= 2
  1824. }
  1825. if (e + eBias >= eMax) {
  1826. m = 0
  1827. e = eMax
  1828. } else if (e + eBias >= 1) {
  1829. m = (value * c - 1) * Math.pow(2, mLen)
  1830. e = e + eBias
  1831. } else {
  1832. m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
  1833. e = 0
  1834. }
  1835. }
  1836. for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
  1837. e = (e << mLen) | m
  1838. eLen += mLen
  1839. for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
  1840. buffer[offset + i - d] |= s * 128
  1841. }
  1842. },{}],9:[function(require,module,exports){
  1843. /**
  1844. * isArray
  1845. */
  1846. var isArray = Array.isArray;
  1847. /**
  1848. * toString
  1849. */
  1850. var str = Object.prototype.toString;
  1851. /**
  1852. * Whether or not the given `val`
  1853. * is an array.
  1854. *
  1855. * example:
  1856. *
  1857. * isArray([]);
  1858. * // > true
  1859. * isArray(arguments);
  1860. * // > false
  1861. * isArray('');
  1862. * // > false
  1863. *
  1864. * @param {mixed} val
  1865. * @return {bool}
  1866. */
  1867. module.exports = isArray || function (val) {
  1868. return !! val && '[object Array]' == str.call(val);
  1869. };
  1870. },{}],10:[function(require,module,exports){
  1871. /**
  1872. * Determine if an object is Buffer
  1873. *
  1874. * Author: Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
  1875. * License: MIT
  1876. *
  1877. * `npm install is-buffer`
  1878. */
  1879. module.exports = function (obj) {
  1880. return !!(obj != null &&
  1881. (obj._isBuffer || // For Safari 5-7 (missing Object.prototype.constructor)
  1882. (obj.constructor &&
  1883. typeof obj.constructor.isBuffer === 'function' &&
  1884. obj.constructor.isBuffer(obj))
  1885. ))
  1886. }
  1887. },{}],11:[function(require,module,exports){
  1888. /**
  1889. * Gets the last element of `array`.
  1890. *
  1891. * @static
  1892. * @memberOf _
  1893. * @category Array
  1894. * @param {Array} array The array to query.
  1895. * @returns {*} Returns the last element of `array`.
  1896. * @example
  1897. *
  1898. * _.last([1, 2, 3]);
  1899. * // => 3
  1900. */
  1901. function last(array) {
  1902. var length = array ? array.length : 0;
  1903. return length ? array[length - 1] : undefined;
  1904. }
  1905. module.exports = last;
  1906. },{}],12:[function(require,module,exports){
  1907. var arrayEvery = require('../internal/arrayEvery'),
  1908. baseCallback = require('../internal/baseCallback'),
  1909. baseEvery = require('../internal/baseEvery'),
  1910. isArray = require('../lang/isArray'),
  1911. isIterateeCall = require('../internal/isIterateeCall');
  1912. /**
  1913. * Checks if `predicate` returns truthy for **all** elements of `collection`.
  1914. * The predicate is bound to `thisArg` and invoked with three arguments:
  1915. * (value, index|key, collection).
  1916. *
  1917. * If a property name is provided for `predicate` the created `_.property`
  1918. * style callback returns the property value of the given element.
  1919. *
  1920. * If a value is also provided for `thisArg` the created `_.matchesProperty`
  1921. * style callback returns `true` for elements that have a matching property
  1922. * value, else `false`.
  1923. *
  1924. * If an object is provided for `predicate` the created `_.matches` style
  1925. * callback returns `true` for elements that have the properties of the given
  1926. * object, else `false`.
  1927. *
  1928. * @static
  1929. * @memberOf _
  1930. * @alias all
  1931. * @category Collection
  1932. * @param {Array|Object|string} collection The collection to iterate over.
  1933. * @param {Function|Object|string} [predicate=_.identity] The function invoked
  1934. * per iteration.
  1935. * @param {*} [thisArg] The `this` binding of `predicate`.
  1936. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  1937. * else `false`.
  1938. * @example
  1939. *
  1940. * _.every([true, 1, null, 'yes'], Boolean);
  1941. * // => false
  1942. *
  1943. * var users = [
  1944. * { 'user': 'barney', 'active': false },
  1945. * { 'user': 'fred', 'active': false }
  1946. * ];
  1947. *
  1948. * // using the `_.matches` callback shorthand
  1949. * _.every(users, { 'user': 'barney', 'active': false });
  1950. * // => false
  1951. *
  1952. * // using the `_.matchesProperty` callback shorthand
  1953. * _.every(users, 'active', false);
  1954. * // => true
  1955. *
  1956. * // using the `_.property` callback shorthand
  1957. * _.every(users, 'active');
  1958. * // => false
  1959. */
  1960. function every(collection, predicate, thisArg) {
  1961. var func = isArray(collection) ? arrayEvery : baseEvery;
  1962. if (thisArg && isIterateeCall(collection, predicate, thisArg)) {
  1963. predicate = undefined;
  1964. }
  1965. if (typeof predicate != 'function' || thisArg !== undefined) {
  1966. predicate = baseCallback(predicate, thisArg, 3);
  1967. }
  1968. return func(collection, predicate);
  1969. }
  1970. module.exports = every;
  1971. },{"../internal/arrayEvery":14,"../internal/baseCallback":18,"../internal/baseEvery":22,"../internal/isIterateeCall":47,"../lang/isArray":56}],13:[function(require,module,exports){
  1972. /** Used as the `TypeError` message for "Functions" methods. */
  1973. var FUNC_ERROR_TEXT = 'Expected a function';
  1974. /* Native method references for those with the same name as other `lodash` methods. */
  1975. var nativeMax = Math.max;
  1976. /**
  1977. * Creates a function that invokes `func` with the `this` binding of the
  1978. * created function and arguments from `start` and beyond provided as an array.
  1979. *
  1980. * **Note:** This method is based on the [rest parameter](https://developer.mozilla.org/Web/JavaScript/Reference/Functions/rest_parameters).
  1981. *
  1982. * @static
  1983. * @memberOf _
  1984. * @category Function
  1985. * @param {Function} func The function to apply a rest parameter to.
  1986. * @param {number} [start=func.length-1] The start position of the rest parameter.
  1987. * @returns {Function} Returns the new function.
  1988. * @example
  1989. *
  1990. * var say = _.restParam(function(what, names) {
  1991. * return what + ' ' + _.initial(names).join(', ') +
  1992. * (_.size(names) > 1 ? ', & ' : '') + _.last(names);
  1993. * });
  1994. *
  1995. * say('hello', 'fred', 'barney', 'pebbles');
  1996. * // => 'hello fred, barney, & pebbles'
  1997. */
  1998. function restParam(func, start) {
  1999. if (typeof func != 'function') {
  2000. throw new TypeError(FUNC_ERROR_TEXT);
  2001. }
  2002. start = nativeMax(start === undefined ? (func.length - 1) : (+start || 0), 0);
  2003. return function() {
  2004. var args = arguments,
  2005. index = -1,
  2006. length = nativeMax(args.length - start, 0),
  2007. rest = Array(length);
  2008. while (++index < length) {
  2009. rest[index] = args[start + index];
  2010. }
  2011. switch (start) {
  2012. case 0: return func.call(this, rest);
  2013. case 1: return func.call(this, args[0], rest);
  2014. case 2: return func.call(this, args[0], args[1], rest);
  2015. }
  2016. var otherArgs = Array(start + 1);
  2017. index = -1;
  2018. while (++index < start) {
  2019. otherArgs[index] = args[index];
  2020. }
  2021. otherArgs[start] = rest;
  2022. return func.apply(this, otherArgs);
  2023. };
  2024. }
  2025. module.exports = restParam;
  2026. },{}],14:[function(require,module,exports){
  2027. /**
  2028. * A specialized version of `_.every` for arrays without support for callback
  2029. * shorthands and `this` binding.
  2030. *
  2031. * @private
  2032. * @param {Array} array The array to iterate over.
  2033. * @param {Function} predicate The function invoked per iteration.
  2034. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  2035. * else `false`.
  2036. */
  2037. function arrayEvery(array, predicate) {
  2038. var index = -1,
  2039. length = array.length;
  2040. while (++index < length) {
  2041. if (!predicate(array[index], index, array)) {
  2042. return false;
  2043. }
  2044. }
  2045. return true;
  2046. }
  2047. module.exports = arrayEvery;
  2048. },{}],15:[function(require,module,exports){
  2049. /**
  2050. * A specialized version of `_.some` for arrays without support for callback
  2051. * shorthands and `this` binding.
  2052. *
  2053. * @private
  2054. * @param {Array} array The array to iterate over.
  2055. * @param {Function} predicate The function invoked per iteration.
  2056. * @returns {boolean} Returns `true` if any element passes the predicate check,
  2057. * else `false`.
  2058. */
  2059. function arraySome(array, predicate) {
  2060. var index = -1,
  2061. length = array.length;
  2062. while (++index < length) {
  2063. if (predicate(array[index], index, array)) {
  2064. return true;
  2065. }
  2066. }
  2067. return false;
  2068. }
  2069. module.exports = arraySome;
  2070. },{}],16:[function(require,module,exports){
  2071. var keys = require('../object/keys');
  2072. /**
  2073. * A specialized version of `_.assign` for customizing assigned values without
  2074. * support for argument juggling, multiple sources, and `this` binding `customizer`
  2075. * functions.
  2076. *
  2077. * @private
  2078. * @param {Object} object The destination object.
  2079. * @param {Object} source The source object.
  2080. * @param {Function} customizer The function to customize assigned values.
  2081. * @returns {Object} Returns `object`.
  2082. */
  2083. function assignWith(object, source, customizer) {
  2084. var index = -1,
  2085. props = keys(source),
  2086. length = props.length;
  2087. while (++index < length) {
  2088. var key = props[index],
  2089. value = object[key],
  2090. result = customizer(value, source[key], key, object, source);
  2091. if ((result === result ? (result !== value) : (value === value)) ||
  2092. (value === undefined && !(key in object))) {
  2093. object[key] = result;
  2094. }
  2095. }
  2096. return object;
  2097. }
  2098. module.exports = assignWith;
  2099. },{"../object/keys":65}],17:[function(require,module,exports){
  2100. var baseCopy = require('./baseCopy'),
  2101. keys = require('../object/keys');
  2102. /**
  2103. * The base implementation of `_.assign` without support for argument juggling,
  2104. * multiple sources, and `customizer` functions.
  2105. *
  2106. * @private
  2107. * @param {Object} object The destination object.
  2108. * @param {Object} source The source object.
  2109. * @returns {Object} Returns `object`.
  2110. */
  2111. function baseAssign(object, source) {
  2112. return source == null
  2113. ? object
  2114. : baseCopy(source, keys(source), object);
  2115. }
  2116. module.exports = baseAssign;
  2117. },{"../object/keys":65,"./baseCopy":19}],18:[function(require,module,exports){
  2118. var baseMatches = require('./baseMatches'),
  2119. baseMatchesProperty = require('./baseMatchesProperty'),
  2120. bindCallback = require('./bindCallback'),
  2121. identity = require('../utility/identity'),
  2122. property = require('../utility/property');
  2123. /**
  2124. * The base implementation of `_.callback` which supports specifying the
  2125. * number of arguments to provide to `func`.
  2126. *
  2127. * @private
  2128. * @param {*} [func=_.identity] The value to convert to a callback.
  2129. * @param {*} [thisArg] The `this` binding of `func`.
  2130. * @param {number} [argCount] The number of arguments to provide to `func`.
  2131. * @returns {Function} Returns the callback.
  2132. */
  2133. function baseCallback(func, thisArg, argCount) {
  2134. var type = typeof func;
  2135. if (type == 'function') {
  2136. return thisArg === undefined
  2137. ? func
  2138. : bindCallback(func, thisArg, argCount);
  2139. }
  2140. if (func == null) {
  2141. return identity;
  2142. }
  2143. if (type == 'object') {
  2144. return baseMatches(func);
  2145. }
  2146. return thisArg === undefined
  2147. ? property(func)
  2148. : baseMatchesProperty(func, thisArg);
  2149. }
  2150. module.exports = baseCallback;
  2151. },{"../utility/identity":68,"../utility/property":69,"./baseMatches":29,"./baseMatchesProperty":30,"./bindCallback":35}],19:[function(require,module,exports){
  2152. /**
  2153. * Copies properties of `source` to `object`.
  2154. *
  2155. * @private
  2156. * @param {Object} source The object to copy properties from.
  2157. * @param {Array} props The property names to copy.
  2158. * @param {Object} [object={}] The object to copy properties to.
  2159. * @returns {Object} Returns `object`.
  2160. */
  2161. function baseCopy(source, props, object) {
  2162. object || (object = {});
  2163. var index = -1,
  2164. length = props.length;
  2165. while (++index < length) {
  2166. var key = props[index];
  2167. object[key] = source[key];
  2168. }
  2169. return object;
  2170. }
  2171. module.exports = baseCopy;
  2172. },{}],20:[function(require,module,exports){
  2173. var isObject = require('../lang/isObject');
  2174. /**
  2175. * The base implementation of `_.create` without support for assigning
  2176. * properties to the created object.
  2177. *
  2178. * @private
  2179. * @param {Object} prototype The object to inherit from.
  2180. * @returns {Object} Returns the new object.
  2181. */
  2182. var baseCreate = (function() {
  2183. function object() {}
  2184. return function(prototype) {
  2185. if (isObject(prototype)) {
  2186. object.prototype = prototype;
  2187. var result = new object;
  2188. object.prototype = undefined;
  2189. }
  2190. return result || {};
  2191. };
  2192. }());
  2193. module.exports = baseCreate;
  2194. },{"../lang/isObject":60}],21:[function(require,module,exports){
  2195. var baseForOwn = require('./baseForOwn'),
  2196. createBaseEach = require('./createBaseEach');
  2197. /**
  2198. * The base implementation of `_.forEach` without support for callback
  2199. * shorthands and `this` binding.
  2200. *
  2201. * @private
  2202. * @param {Array|Object|string} collection The collection to iterate over.
  2203. * @param {Function} iteratee The function invoked per iteration.
  2204. * @returns {Array|Object|string} Returns `collection`.
  2205. */
  2206. var baseEach = createBaseEach(baseForOwn);
  2207. module.exports = baseEach;
  2208. },{"./baseForOwn":24,"./createBaseEach":37}],22:[function(require,module,exports){
  2209. var baseEach = require('./baseEach');
  2210. /**
  2211. * The base implementation of `_.every` without support for callback
  2212. * shorthands and `this` binding.
  2213. *
  2214. * @private
  2215. * @param {Array|Object|string} collection The collection to iterate over.
  2216. * @param {Function} predicate The function invoked per iteration.
  2217. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  2218. * else `false`
  2219. */
  2220. function baseEvery(collection, predicate) {
  2221. var result = true;
  2222. baseEach(collection, function(value, index, collection) {
  2223. result = !!predicate(value, index, collection);
  2224. return result;
  2225. });
  2226. return result;
  2227. }
  2228. module.exports = baseEvery;
  2229. },{"./baseEach":21}],23:[function(require,module,exports){
  2230. var createBaseFor = require('./createBaseFor');
  2231. /**
  2232. * The base implementation of `baseForIn` and `baseForOwn` which iterates
  2233. * over `object` properties returned by `keysFunc` invoking `iteratee` for
  2234. * each property. Iteratee functions may exit iteration early by explicitly
  2235. * returning `false`.
  2236. *
  2237. * @private
  2238. * @param {Object} object The object to iterate over.
  2239. * @param {Function} iteratee The function invoked per iteration.
  2240. * @param {Function} keysFunc The function to get the keys of `object`.
  2241. * @returns {Object} Returns `object`.
  2242. */
  2243. var baseFor = createBaseFor();
  2244. module.exports = baseFor;
  2245. },{"./createBaseFor":38}],24:[function(require,module,exports){
  2246. var baseFor = require('./baseFor'),
  2247. keys = require('../object/keys');
  2248. /**
  2249. * The base implementation of `_.forOwn` without support for callback
  2250. * shorthands and `this` binding.
  2251. *
  2252. * @private
  2253. * @param {Object} object The object to iterate over.
  2254. * @param {Function} iteratee The function invoked per iteration.
  2255. * @returns {Object} Returns `object`.
  2256. */
  2257. function baseForOwn(object, iteratee) {
  2258. return baseFor(object, iteratee, keys);
  2259. }
  2260. module.exports = baseForOwn;
  2261. },{"../object/keys":65,"./baseFor":23}],25:[function(require,module,exports){
  2262. var toObject = require('./toObject');
  2263. /**
  2264. * The base implementation of `get` without support for string paths
  2265. * and default values.
  2266. *
  2267. * @private
  2268. * @param {Object} object The object to query.
  2269. * @param {Array} path The path of the property to get.
  2270. * @param {string} [pathKey] The key representation of path.
  2271. * @returns {*} Returns the resolved value.
  2272. */
  2273. function baseGet(object, path, pathKey) {
  2274. if (object == null) {
  2275. return;
  2276. }
  2277. if (pathKey !== undefined && pathKey in toObject(object)) {
  2278. path = [pathKey];
  2279. }
  2280. var index = 0,
  2281. length = path.length;
  2282. while (object != null && index < length) {
  2283. object = object[path[index++]];
  2284. }
  2285. return (index && index == length) ? object : undefined;
  2286. }
  2287. module.exports = baseGet;
  2288. },{"./toObject":53}],26:[function(require,module,exports){
  2289. var baseIsEqualDeep = require('./baseIsEqualDeep'),
  2290. isObject = require('../lang/isObject'),
  2291. isObjectLike = require('./isObjectLike');
  2292. /**
  2293. * The base implementation of `_.isEqual` without support for `this` binding
  2294. * `customizer` functions.
  2295. *
  2296. * @private
  2297. * @param {*} value The value to compare.
  2298. * @param {*} other The other value to compare.
  2299. * @param {Function} [customizer] The function to customize comparing values.
  2300. * @param {boolean} [isLoose] Specify performing partial comparisons.
  2301. * @param {Array} [stackA] Tracks traversed `value` objects.
  2302. * @param {Array} [stackB] Tracks traversed `other` objects.
  2303. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  2304. */
  2305. function baseIsEqual(value, other, customizer, isLoose, stackA, stackB) {
  2306. if (value === other) {
  2307. return true;
  2308. }
  2309. if (value == null || other == null || (!isObject(value) && !isObjectLike(other))) {
  2310. return value !== value && other !== other;
  2311. }
  2312. return baseIsEqualDeep(value, other, baseIsEqual, customizer, isLoose, stackA, stackB);
  2313. }
  2314. module.exports = baseIsEqual;
  2315. },{"../lang/isObject":60,"./baseIsEqualDeep":27,"./isObjectLike":50}],27:[function(require,module,exports){
  2316. var equalArrays = require('./equalArrays'),
  2317. equalByTag = require('./equalByTag'),
  2318. equalObjects = require('./equalObjects'),
  2319. isArray = require('../lang/isArray'),
  2320. isTypedArray = require('../lang/isTypedArray');
  2321. /** `Object#toString` result references. */
  2322. var argsTag = '[object Arguments]',
  2323. arrayTag = '[object Array]',
  2324. objectTag = '[object Object]';
  2325. /** Used for native method references. */
  2326. var objectProto = Object.prototype;
  2327. /** Used to check objects for own properties. */
  2328. var hasOwnProperty = objectProto.hasOwnProperty;
  2329. /**
  2330. * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
  2331. * of values.
  2332. */
  2333. var objToString = objectProto.toString;
  2334. /**
  2335. * A specialized version of `baseIsEqual` for arrays and objects which performs
  2336. * deep comparisons and tracks traversed objects enabling objects with circular
  2337. * references to be compared.
  2338. *
  2339. * @private
  2340. * @param {Object} object The object to compare.
  2341. * @param {Object} other The other object to compare.
  2342. * @param {Function} equalFunc The function to determine equivalents of values.
  2343. * @param {Function} [customizer] The function to customize comparing objects.
  2344. * @param {boolean} [isLoose] Specify performing partial comparisons.
  2345. * @param {Array} [stackA=[]] Tracks traversed `value` objects.
  2346. * @param {Array} [stackB=[]] Tracks traversed `other` objects.
  2347. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  2348. */
  2349. function baseIsEqualDeep(object, other, equalFunc, customizer, isLoose, stackA, stackB) {
  2350. var objIsArr = isArray(object),
  2351. othIsArr = isArray(other),
  2352. objTag = arrayTag,
  2353. othTag = arrayTag;
  2354. if (!objIsArr) {
  2355. objTag = objToString.call(object);
  2356. if (objTag == argsTag) {
  2357. objTag = objectTag;
  2358. } else if (objTag != objectTag) {
  2359. objIsArr = isTypedArray(object);
  2360. }
  2361. }
  2362. if (!othIsArr) {
  2363. othTag = objToString.call(other);
  2364. if (othTag == argsTag) {
  2365. othTag = objectTag;
  2366. } else if (othTag != objectTag) {
  2367. othIsArr = isTypedArray(other);
  2368. }
  2369. }
  2370. var objIsObj = objTag == objectTag,
  2371. othIsObj = othTag == objectTag,
  2372. isSameTag = objTag == othTag;
  2373. if (isSameTag && !(objIsArr || objIsObj)) {
  2374. return equalByTag(object, other, objTag);
  2375. }
  2376. if (!isLoose) {
  2377. var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
  2378. othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
  2379. if (objIsWrapped || othIsWrapped) {
  2380. return equalFunc(objIsWrapped ? object.value() : object, othIsWrapped ? other.value() : other, customizer, isLoose, stackA, stackB);
  2381. }
  2382. }
  2383. if (!isSameTag) {
  2384. return false;
  2385. }
  2386. // Assume cyclic values are equal.
  2387. // For more information on detecting circular references see https://es5.github.io/#JO.
  2388. stackA || (stackA = []);
  2389. stackB || (stackB = []);
  2390. var length = stackA.length;
  2391. while (length--) {
  2392. if (stackA[length] == object) {
  2393. return stackB[length] == other;
  2394. }
  2395. }
  2396. // Add `object` and `other` to the stack of traversed objects.
  2397. stackA.push(object);
  2398. stackB.push(other);
  2399. var result = (objIsArr ? equalArrays : equalObjects)(object, other, equalFunc, customizer, isLoose, stackA, stackB);
  2400. stackA.pop();
  2401. stackB.pop();
  2402. return result;
  2403. }
  2404. module.exports = baseIsEqualDeep;
  2405. },{"../lang/isArray":56,"../lang/isTypedArray":62,"./equalArrays":39,"./equalByTag":40,"./equalObjects":41}],28:[function(require,module,exports){
  2406. var baseIsEqual = require('./baseIsEqual'),
  2407. toObject = require('./toObject');
  2408. /**
  2409. * The base implementation of `_.isMatch` without support for callback
  2410. * shorthands and `this` binding.
  2411. *
  2412. * @private
  2413. * @param {Object} object The object to inspect.
  2414. * @param {Array} matchData The propery names, values, and compare flags to match.
  2415. * @param {Function} [customizer] The function to customize comparing objects.
  2416. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  2417. */
  2418. function baseIsMatch(object, matchData, customizer) {
  2419. var index = matchData.length,
  2420. length = index,
  2421. noCustomizer = !customizer;
  2422. if (object == null) {
  2423. return !length;
  2424. }
  2425. object = toObject(object);
  2426. while (index--) {
  2427. var data = matchData[index];
  2428. if ((noCustomizer && data[2])
  2429. ? data[1] !== object[data[0]]
  2430. : !(data[0] in object)
  2431. ) {
  2432. return false;
  2433. }
  2434. }
  2435. while (++index < length) {
  2436. data = matchData[index];
  2437. var key = data[0],
  2438. objValue = object[key],
  2439. srcValue = data[1];
  2440. if (noCustomizer && data[2]) {
  2441. if (objValue === undefined && !(key in object)) {
  2442. return false;
  2443. }
  2444. } else {
  2445. var result = customizer ? customizer(objValue, srcValue, key) : undefined;
  2446. if (!(result === undefined ? baseIsEqual(srcValue, objValue, customizer, true) : result)) {
  2447. return false;
  2448. }
  2449. }
  2450. }
  2451. return true;
  2452. }
  2453. module.exports = baseIsMatch;
  2454. },{"./baseIsEqual":26,"./toObject":53}],29:[function(require,module,exports){
  2455. var baseIsMatch = require('./baseIsMatch'),
  2456. getMatchData = require('./getMatchData'),
  2457. toObject = require('./toObject');
  2458. /**
  2459. * The base implementation of `_.matches` which does not clone `source`.
  2460. *
  2461. * @private
  2462. * @param {Object} source The object of property values to match.
  2463. * @returns {Function} Returns the new function.
  2464. */
  2465. function baseMatches(source) {
  2466. var matchData = getMatchData(source);
  2467. if (matchData.length == 1 && matchData[0][2]) {
  2468. var key = matchData[0][0],
  2469. value = matchData[0][1];
  2470. return function(object) {
  2471. if (object == null) {
  2472. return false;
  2473. }
  2474. return object[key] === value && (value !== undefined || (key in toObject(object)));
  2475. };
  2476. }
  2477. return function(object) {
  2478. return baseIsMatch(object, matchData);
  2479. };
  2480. }
  2481. module.exports = baseMatches;
  2482. },{"./baseIsMatch":28,"./getMatchData":43,"./toObject":53}],30:[function(require,module,exports){
  2483. var baseGet = require('./baseGet'),
  2484. baseIsEqual = require('./baseIsEqual'),
  2485. baseSlice = require('./baseSlice'),
  2486. isArray = require('../lang/isArray'),
  2487. isKey = require('./isKey'),
  2488. isStrictComparable = require('./isStrictComparable'),
  2489. last = require('../array/last'),
  2490. toObject = require('./toObject'),
  2491. toPath = require('./toPath');
  2492. /**
  2493. * The base implementation of `_.matchesProperty` which does not clone `srcValue`.
  2494. *
  2495. * @private
  2496. * @param {string} path The path of the property to get.
  2497. * @param {*} srcValue The value to compare.
  2498. * @returns {Function} Returns the new function.
  2499. */
  2500. function baseMatchesProperty(path, srcValue) {
  2501. var isArr = isArray(path),
  2502. isCommon = isKey(path) && isStrictComparable(srcValue),
  2503. pathKey = (path + '');
  2504. path = toPath(path);
  2505. return function(object) {
  2506. if (object == null) {
  2507. return false;
  2508. }
  2509. var key = pathKey;
  2510. object = toObject(object);
  2511. if ((isArr || !isCommon) && !(key in object)) {
  2512. object = path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1));
  2513. if (object == null) {
  2514. return false;
  2515. }
  2516. key = last(path);
  2517. object = toObject(object);
  2518. }
  2519. return object[key] === srcValue
  2520. ? (srcValue !== undefined || (key in object))
  2521. : baseIsEqual(srcValue, object[key], undefined, true);
  2522. };
  2523. }
  2524. module.exports = baseMatchesProperty;
  2525. },{"../array/last":11,"../lang/isArray":56,"./baseGet":25,"./baseIsEqual":26,"./baseSlice":33,"./isKey":48,"./isStrictComparable":51,"./toObject":53,"./toPath":54}],31:[function(require,module,exports){
  2526. /**
  2527. * The base implementation of `_.property` without support for deep paths.
  2528. *
  2529. * @private
  2530. * @param {string} key The key of the property to get.
  2531. * @returns {Function} Returns the new function.
  2532. */
  2533. function baseProperty(key) {
  2534. return function(object) {
  2535. return object == null ? undefined : object[key];
  2536. };
  2537. }
  2538. module.exports = baseProperty;
  2539. },{}],32:[function(require,module,exports){
  2540. var baseGet = require('./baseGet'),
  2541. toPath = require('./toPath');
  2542. /**
  2543. * A specialized version of `baseProperty` which supports deep paths.
  2544. *
  2545. * @private
  2546. * @param {Array|string} path The path of the property to get.
  2547. * @returns {Function} Returns the new function.
  2548. */
  2549. function basePropertyDeep(path) {
  2550. var pathKey = (path + '');
  2551. path = toPath(path);
  2552. return function(object) {
  2553. return baseGet(object, path, pathKey);
  2554. };
  2555. }
  2556. module.exports = basePropertyDeep;
  2557. },{"./baseGet":25,"./toPath":54}],33:[function(require,module,exports){
  2558. /**
  2559. * The base implementation of `_.slice` without an iteratee call guard.
  2560. *
  2561. * @private
  2562. * @param {Array} array The array to slice.
  2563. * @param {number} [start=0] The start position.
  2564. * @param {number} [end=array.length] The end position.
  2565. * @returns {Array} Returns the slice of `array`.
  2566. */
  2567. function baseSlice(array, start, end) {
  2568. var index = -1,
  2569. length = array.length;
  2570. start = start == null ? 0 : (+start || 0);
  2571. if (start < 0) {
  2572. start = -start > length ? 0 : (length + start);
  2573. }
  2574. end = (end === undefined || end > length) ? length : (+end || 0);
  2575. if (end < 0) {
  2576. end += length;
  2577. }
  2578. length = start > end ? 0 : ((end - start) >>> 0);
  2579. start >>>= 0;
  2580. var result = Array(length);
  2581. while (++index < length) {
  2582. result[index] = array[index + start];
  2583. }
  2584. return result;
  2585. }
  2586. module.exports = baseSlice;
  2587. },{}],34:[function(require,module,exports){
  2588. /**
  2589. * Converts `value` to a string if it's not one. An empty string is returned
  2590. * for `null` or `undefined` values.
  2591. *
  2592. * @private
  2593. * @param {*} value The value to process.
  2594. * @returns {string} Returns the string.
  2595. */
  2596. function baseToString(value) {
  2597. return value == null ? '' : (value + '');
  2598. }
  2599. module.exports = baseToString;
  2600. },{}],35:[function(require,module,exports){
  2601. var identity = require('../utility/identity');
  2602. /**
  2603. * A specialized version of `baseCallback` which only supports `this` binding
  2604. * and specifying the number of arguments to provide to `func`.
  2605. *
  2606. * @private
  2607. * @param {Function} func The function to bind.
  2608. * @param {*} thisArg The `this` binding of `func`.
  2609. * @param {number} [argCount] The number of arguments to provide to `func`.
  2610. * @returns {Function} Returns the callback.
  2611. */
  2612. function bindCallback(func, thisArg, argCount) {
  2613. if (typeof func != 'function') {
  2614. return identity;
  2615. }
  2616. if (thisArg === undefined) {
  2617. return func;
  2618. }
  2619. switch (argCount) {
  2620. case 1: return function(value) {
  2621. return func.call(thisArg, value);
  2622. };
  2623. case 3: return function(value, index, collection) {
  2624. return func.call(thisArg, value, index, collection);
  2625. };
  2626. case 4: return function(accumulator, value, index, collection) {
  2627. return func.call(thisArg, accumulator, value, index, collection);
  2628. };
  2629. case 5: return function(value, other, key, object, source) {
  2630. return func.call(thisArg, value, other, key, object, source);
  2631. };
  2632. }
  2633. return function() {
  2634. return func.apply(thisArg, arguments);
  2635. };
  2636. }
  2637. module.exports = bindCallback;
  2638. },{"../utility/identity":68}],36:[function(require,module,exports){
  2639. var bindCallback = require('./bindCallback'),
  2640. isIterateeCall = require('./isIterateeCall'),
  2641. restParam = require('../function/restParam');
  2642. /**
  2643. * Creates a `_.assign`, `_.defaults`, or `_.merge` function.
  2644. *
  2645. * @private
  2646. * @param {Function} assigner The function to assign values.
  2647. * @returns {Function} Returns the new assigner function.
  2648. */
  2649. function createAssigner(assigner) {
  2650. return restParam(function(object, sources) {
  2651. var index = -1,
  2652. length = object == null ? 0 : sources.length,
  2653. customizer = length > 2 ? sources[length - 2] : undefined,
  2654. guard = length > 2 ? sources[2] : undefined,
  2655. thisArg = length > 1 ? sources[length - 1] : undefined;
  2656. if (typeof customizer == 'function') {
  2657. customizer = bindCallback(customizer, thisArg, 5);
  2658. length -= 2;
  2659. } else {
  2660. customizer = typeof thisArg == 'function' ? thisArg : undefined;
  2661. length -= (customizer ? 1 : 0);
  2662. }
  2663. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  2664. customizer = length < 3 ? undefined : customizer;
  2665. length = 1;
  2666. }
  2667. while (++index < length) {
  2668. var source = sources[index];
  2669. if (source) {
  2670. assigner(object, source, customizer);
  2671. }
  2672. }
  2673. return object;
  2674. });
  2675. }
  2676. module.exports = createAssigner;
  2677. },{"../function/restParam":13,"./bindCallback":35,"./isIterateeCall":47}],37:[function(require,module,exports){
  2678. var getLength = require('./getLength'),
  2679. isLength = require('./isLength'),
  2680. toObject = require('./toObject');
  2681. /**
  2682. * Creates a `baseEach` or `baseEachRight` function.
  2683. *
  2684. * @private
  2685. * @param {Function} eachFunc The function to iterate over a collection.
  2686. * @param {boolean} [fromRight] Specify iterating from right to left.
  2687. * @returns {Function} Returns the new base function.
  2688. */
  2689. function createBaseEach(eachFunc, fromRight) {
  2690. return function(collection, iteratee) {
  2691. var length = collection ? getLength(collection) : 0;
  2692. if (!isLength(length)) {
  2693. return eachFunc(collection, iteratee);
  2694. }
  2695. var index = fromRight ? length : -1,
  2696. iterable = toObject(collection);
  2697. while ((fromRight ? index-- : ++index < length)) {
  2698. if (iteratee(iterable[index], index, iterable) === false) {
  2699. break;
  2700. }
  2701. }
  2702. return collection;
  2703. };
  2704. }
  2705. module.exports = createBaseEach;
  2706. },{"./getLength":42,"./isLength":49,"./toObject":53}],38:[function(require,module,exports){
  2707. var toObject = require('./toObject');
  2708. /**
  2709. * Creates a base function for `_.forIn` or `_.forInRight`.
  2710. *
  2711. * @private
  2712. * @param {boolean} [fromRight] Specify iterating from right to left.
  2713. * @returns {Function} Returns the new base function.
  2714. */
  2715. function createBaseFor(fromRight) {
  2716. return function(object, iteratee, keysFunc) {
  2717. var iterable = toObject(object),
  2718. props = keysFunc(object),
  2719. length = props.length,
  2720. index = fromRight ? length : -1;
  2721. while ((fromRight ? index-- : ++index < length)) {
  2722. var key = props[index];
  2723. if (iteratee(iterable[key], key, iterable) === false) {
  2724. break;
  2725. }
  2726. }
  2727. return object;
  2728. };
  2729. }
  2730. module.exports = createBaseFor;
  2731. },{"./toObject":53}],39:[function(require,module,exports){
  2732. var arraySome = require('./arraySome');
  2733. /**
  2734. * A specialized version of `baseIsEqualDeep` for arrays with support for
  2735. * partial deep comparisons.
  2736. *
  2737. * @private
  2738. * @param {Array} array The array to compare.
  2739. * @param {Array} other The other array to compare.
  2740. * @param {Function} equalFunc The function to determine equivalents of values.
  2741. * @param {Function} [customizer] The function to customize comparing arrays.
  2742. * @param {boolean} [isLoose] Specify performing partial comparisons.
  2743. * @param {Array} [stackA] Tracks traversed `value` objects.
  2744. * @param {Array} [stackB] Tracks traversed `other` objects.
  2745. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
  2746. */
  2747. function equalArrays(array, other, equalFunc, customizer, isLoose, stackA, stackB) {
  2748. var index = -1,
  2749. arrLength = array.length,
  2750. othLength = other.length;
  2751. if (arrLength != othLength && !(isLoose && othLength > arrLength)) {
  2752. return false;
  2753. }
  2754. // Ignore non-index properties.
  2755. while (++index < arrLength) {
  2756. var arrValue = array[index],
  2757. othValue = other[index],
  2758. result = customizer ? customizer(isLoose ? othValue : arrValue, isLoose ? arrValue : othValue, index) : undefined;
  2759. if (result !== undefined) {
  2760. if (result) {
  2761. continue;
  2762. }
  2763. return false;
  2764. }
  2765. // Recursively compare arrays (susceptible to call stack limits).
  2766. if (isLoose) {
  2767. if (!arraySome(other, function(othValue) {
  2768. return arrValue === othValue || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB);
  2769. })) {
  2770. return false;
  2771. }
  2772. } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB))) {
  2773. return false;
  2774. }
  2775. }
  2776. return true;
  2777. }
  2778. module.exports = equalArrays;
  2779. },{"./arraySome":15}],40:[function(require,module,exports){
  2780. /** `Object#toString` result references. */
  2781. var boolTag = '[object Boolean]',
  2782. dateTag = '[object Date]',
  2783. errorTag = '[object Error]',
  2784. numberTag = '[object Number]',
  2785. regexpTag = '[object RegExp]',
  2786. stringTag = '[object String]';
  2787. /**
  2788. * A specialized version of `baseIsEqualDeep` for comparing objects of
  2789. * the same `toStringTag`.
  2790. *
  2791. * **Note:** This function only supports comparing values with tags of
  2792. * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
  2793. *
  2794. * @private
  2795. * @param {Object} object The object to compare.
  2796. * @param {Object} other The other object to compare.
  2797. * @param {string} tag The `toStringTag` of the objects to compare.
  2798. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  2799. */
  2800. function equalByTag(object, other, tag) {
  2801. switch (tag) {
  2802. case boolTag:
  2803. case dateTag:
  2804. // Coerce dates and booleans to numbers, dates to milliseconds and booleans
  2805. // to `1` or `0` treating invalid dates coerced to `NaN` as not equal.
  2806. return +object == +other;
  2807. case errorTag:
  2808. return object.name == other.name && object.message == other.message;
  2809. case numberTag:
  2810. // Treat `NaN` vs. `NaN` as equal.
  2811. return (object != +object)
  2812. ? other != +other
  2813. : object == +other;
  2814. case regexpTag:
  2815. case stringTag:
  2816. // Coerce regexes to strings and treat strings primitives and string
  2817. // objects as equal. See https://es5.github.io/#x15.10.6.4 for more details.
  2818. return object == (other + '');
  2819. }
  2820. return false;
  2821. }
  2822. module.exports = equalByTag;
  2823. },{}],41:[function(require,module,exports){
  2824. var keys = require('../object/keys');
  2825. /** Used for native method references. */
  2826. var objectProto = Object.prototype;
  2827. /** Used to check objects for own properties. */
  2828. var hasOwnProperty = objectProto.hasOwnProperty;
  2829. /**
  2830. * A specialized version of `baseIsEqualDeep` for objects with support for
  2831. * partial deep comparisons.
  2832. *
  2833. * @private
  2834. * @param {Object} object The object to compare.
  2835. * @param {Object} other The other object to compare.
  2836. * @param {Function} equalFunc The function to determine equivalents of values.
  2837. * @param {Function} [customizer] The function to customize comparing values.
  2838. * @param {boolean} [isLoose] Specify performing partial comparisons.
  2839. * @param {Array} [stackA] Tracks traversed `value` objects.
  2840. * @param {Array} [stackB] Tracks traversed `other` objects.
  2841. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  2842. */
  2843. function equalObjects(object, other, equalFunc, customizer, isLoose, stackA, stackB) {
  2844. var objProps = keys(object),
  2845. objLength = objProps.length,
  2846. othProps = keys(other),
  2847. othLength = othProps.length;
  2848. if (objLength != othLength && !isLoose) {
  2849. return false;
  2850. }
  2851. var index = objLength;
  2852. while (index--) {
  2853. var key = objProps[index];
  2854. if (!(isLoose ? key in other : hasOwnProperty.call(other, key))) {
  2855. return false;
  2856. }
  2857. }
  2858. var skipCtor = isLoose;
  2859. while (++index < objLength) {
  2860. key = objProps[index];
  2861. var objValue = object[key],
  2862. othValue = other[key],
  2863. result = customizer ? customizer(isLoose ? othValue : objValue, isLoose? objValue : othValue, key) : undefined;
  2864. // Recursively compare objects (susceptible to call stack limits).
  2865. if (!(result === undefined ? equalFunc(objValue, othValue, customizer, isLoose, stackA, stackB) : result)) {
  2866. return false;
  2867. }
  2868. skipCtor || (skipCtor = key == 'constructor');
  2869. }
  2870. if (!skipCtor) {
  2871. var objCtor = object.constructor,
  2872. othCtor = other.constructor;
  2873. // Non `Object` object instances with different constructors are not equal.
  2874. if (objCtor != othCtor &&
  2875. ('constructor' in object && 'constructor' in other) &&
  2876. !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
  2877. typeof othCtor == 'function' && othCtor instanceof othCtor)) {
  2878. return false;
  2879. }
  2880. }
  2881. return true;
  2882. }
  2883. module.exports = equalObjects;
  2884. },{"../object/keys":65}],42:[function(require,module,exports){
  2885. var baseProperty = require('./baseProperty');
  2886. /**
  2887. * Gets the "length" property value of `object`.
  2888. *
  2889. * **Note:** This function is used to avoid a [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792)
  2890. * that affects Safari on at least iOS 8.1-8.3 ARM64.
  2891. *
  2892. * @private
  2893. * @param {Object} object The object to query.
  2894. * @returns {*} Returns the "length" value.
  2895. */
  2896. var getLength = baseProperty('length');
  2897. module.exports = getLength;
  2898. },{"./baseProperty":31}],43:[function(require,module,exports){
  2899. var isStrictComparable = require('./isStrictComparable'),
  2900. pairs = require('../object/pairs');
  2901. /**
  2902. * Gets the propery names, values, and compare flags of `object`.
  2903. *
  2904. * @private
  2905. * @param {Object} object The object to query.
  2906. * @returns {Array} Returns the match data of `object`.
  2907. */
  2908. function getMatchData(object) {
  2909. var result = pairs(object),
  2910. length = result.length;
  2911. while (length--) {
  2912. result[length][2] = isStrictComparable(result[length][1]);
  2913. }
  2914. return result;
  2915. }
  2916. module.exports = getMatchData;
  2917. },{"../object/pairs":67,"./isStrictComparable":51}],44:[function(require,module,exports){
  2918. var isNative = require('../lang/isNative');
  2919. /**
  2920. * Gets the native function at `key` of `object`.
  2921. *
  2922. * @private
  2923. * @param {Object} object The object to query.
  2924. * @param {string} key The key of the method to get.
  2925. * @returns {*} Returns the function if it's native, else `undefined`.
  2926. */
  2927. function getNative(object, key) {
  2928. var value = object == null ? undefined : object[key];
  2929. return isNative(value) ? value : undefined;
  2930. }
  2931. module.exports = getNative;
  2932. },{"../lang/isNative":59}],45:[function(require,module,exports){
  2933. var getLength = require('./getLength'),
  2934. isLength = require('./isLength');
  2935. /**
  2936. * Checks if `value` is array-like.
  2937. *
  2938. * @private
  2939. * @param {*} value The value to check.
  2940. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  2941. */
  2942. function isArrayLike(value) {
  2943. return value != null && isLength(getLength(value));
  2944. }
  2945. module.exports = isArrayLike;
  2946. },{"./getLength":42,"./isLength":49}],46:[function(require,module,exports){
  2947. /** Used to detect unsigned integer values. */
  2948. var reIsUint = /^\d+$/;
  2949. /**
  2950. * Used as the [maximum length](http://ecma-international.org/ecma-262/6.0/#sec-number.max_safe_integer)
  2951. * of an array-like value.
  2952. */
  2953. var MAX_SAFE_INTEGER = 9007199254740991;
  2954. /**
  2955. * Checks if `value` is a valid array-like index.
  2956. *
  2957. * @private
  2958. * @param {*} value The value to check.
  2959. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  2960. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  2961. */
  2962. function isIndex(value, length) {
  2963. value = (typeof value == 'number' || reIsUint.test(value)) ? +value : -1;
  2964. length = length == null ? MAX_SAFE_INTEGER : length;
  2965. return value > -1 && value % 1 == 0 && value < length;
  2966. }
  2967. module.exports = isIndex;
  2968. },{}],47:[function(require,module,exports){
  2969. var isArrayLike = require('./isArrayLike'),
  2970. isIndex = require('./isIndex'),
  2971. isObject = require('../lang/isObject');
  2972. /**
  2973. * Checks if the provided arguments are from an iteratee call.
  2974. *
  2975. * @private
  2976. * @param {*} value The potential iteratee value argument.
  2977. * @param {*} index The potential iteratee index or key argument.
  2978. * @param {*} object The potential iteratee object argument.
  2979. * @returns {boolean} Returns `true` if the arguments are from an iteratee call, else `false`.
  2980. */
  2981. function isIterateeCall(value, index, object) {
  2982. if (!isObject(object)) {
  2983. return false;
  2984. }
  2985. var type = typeof index;
  2986. if (type == 'number'
  2987. ? (isArrayLike(object) && isIndex(index, object.length))
  2988. : (type == 'string' && index in object)) {
  2989. var other = object[index];
  2990. return value === value ? (value === other) : (other !== other);
  2991. }
  2992. return false;
  2993. }
  2994. module.exports = isIterateeCall;
  2995. },{"../lang/isObject":60,"./isArrayLike":45,"./isIndex":46}],48:[function(require,module,exports){
  2996. var isArray = require('../lang/isArray'),
  2997. toObject = require('./toObject');
  2998. /** Used to match property names within property paths. */
  2999. var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\n\\]|\\.)*?\1)\]/,
  3000. reIsPlainProp = /^\w*$/;
  3001. /**
  3002. * Checks if `value` is a property name and not a property path.
  3003. *
  3004. * @private
  3005. * @param {*} value The value to check.
  3006. * @param {Object} [object] The object to query keys on.
  3007. * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
  3008. */
  3009. function isKey(value, object) {
  3010. var type = typeof value;
  3011. if ((type == 'string' && reIsPlainProp.test(value)) || type == 'number') {
  3012. return true;
  3013. }
  3014. if (isArray(value)) {
  3015. return false;
  3016. }
  3017. var result = !reIsDeepProp.test(value);
  3018. return result || (object != null && value in toObject(object));
  3019. }
  3020. module.exports = isKey;
  3021. },{"../lang/isArray":56,"./toObject":53}],49:[function(require,module,exports){
  3022. /**
  3023. * Used as the [maximum length](http://ecma-international.org/ecma-262/6.0/#sec-number.max_safe_integer)
  3024. * of an array-like value.
  3025. */
  3026. var MAX_SAFE_INTEGER = 9007199254740991;
  3027. /**
  3028. * Checks if `value` is a valid array-like length.
  3029. *
  3030. * **Note:** This function is based on [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength).
  3031. *
  3032. * @private
  3033. * @param {*} value The value to check.
  3034. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  3035. */
  3036. function isLength(value) {
  3037. return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  3038. }
  3039. module.exports = isLength;
  3040. },{}],50:[function(require,module,exports){
  3041. /**
  3042. * Checks if `value` is object-like.
  3043. *
  3044. * @private
  3045. * @param {*} value The value to check.
  3046. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  3047. */
  3048. function isObjectLike(value) {
  3049. return !!value && typeof value == 'object';
  3050. }
  3051. module.exports = isObjectLike;
  3052. },{}],51:[function(require,module,exports){
  3053. var isObject = require('../lang/isObject');
  3054. /**
  3055. * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
  3056. *
  3057. * @private
  3058. * @param {*} value The value to check.
  3059. * @returns {boolean} Returns `true` if `value` if suitable for strict
  3060. * equality comparisons, else `false`.
  3061. */
  3062. function isStrictComparable(value) {
  3063. return value === value && !isObject(value);
  3064. }
  3065. module.exports = isStrictComparable;
  3066. },{"../lang/isObject":60}],52:[function(require,module,exports){
  3067. var isArguments = require('../lang/isArguments'),
  3068. isArray = require('../lang/isArray'),
  3069. isIndex = require('./isIndex'),
  3070. isLength = require('./isLength'),
  3071. keysIn = require('../object/keysIn');
  3072. /** Used for native method references. */
  3073. var objectProto = Object.prototype;
  3074. /** Used to check objects for own properties. */
  3075. var hasOwnProperty = objectProto.hasOwnProperty;
  3076. /**
  3077. * A fallback implementation of `Object.keys` which creates an array of the
  3078. * own enumerable property names of `object`.
  3079. *
  3080. * @private
  3081. * @param {Object} object The object to query.
  3082. * @returns {Array} Returns the array of property names.
  3083. */
  3084. function shimKeys(object) {
  3085. var props = keysIn(object),
  3086. propsLength = props.length,
  3087. length = propsLength && object.length;
  3088. var allowIndexes = !!length && isLength(length) &&
  3089. (isArray(object) || isArguments(object));
  3090. var index = -1,
  3091. result = [];
  3092. while (++index < propsLength) {
  3093. var key = props[index];
  3094. if ((allowIndexes && isIndex(key, length)) || hasOwnProperty.call(object, key)) {
  3095. result.push(key);
  3096. }
  3097. }
  3098. return result;
  3099. }
  3100. module.exports = shimKeys;
  3101. },{"../lang/isArguments":55,"../lang/isArray":56,"../object/keysIn":66,"./isIndex":46,"./isLength":49}],53:[function(require,module,exports){
  3102. var isObject = require('../lang/isObject');
  3103. /**
  3104. * Converts `value` to an object if it's not one.
  3105. *
  3106. * @private
  3107. * @param {*} value The value to process.
  3108. * @returns {Object} Returns the object.
  3109. */
  3110. function toObject(value) {
  3111. return isObject(value) ? value : Object(value);
  3112. }
  3113. module.exports = toObject;
  3114. },{"../lang/isObject":60}],54:[function(require,module,exports){
  3115. var baseToString = require('./baseToString'),
  3116. isArray = require('../lang/isArray');
  3117. /** Used to match property names within property paths. */
  3118. var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\n\\]|\\.)*?)\2)\]/g;
  3119. /** Used to match backslashes in property paths. */
  3120. var reEscapeChar = /\\(\\)?/g;
  3121. /**
  3122. * Converts `value` to property path array if it's not one.
  3123. *
  3124. * @private
  3125. * @param {*} value The value to process.
  3126. * @returns {Array} Returns the property path array.
  3127. */
  3128. function toPath(value) {
  3129. if (isArray(value)) {
  3130. return value;
  3131. }
  3132. var result = [];
  3133. baseToString(value).replace(rePropName, function(match, number, quote, string) {
  3134. result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match));
  3135. });
  3136. return result;
  3137. }
  3138. module.exports = toPath;
  3139. },{"../lang/isArray":56,"./baseToString":34}],55:[function(require,module,exports){
  3140. var isArrayLike = require('../internal/isArrayLike'),
  3141. isObjectLike = require('../internal/isObjectLike');
  3142. /** Used for native method references. */
  3143. var objectProto = Object.prototype;
  3144. /** Used to check objects for own properties. */
  3145. var hasOwnProperty = objectProto.hasOwnProperty;
  3146. /** Native method references. */
  3147. var propertyIsEnumerable = objectProto.propertyIsEnumerable;
  3148. /**
  3149. * Checks if `value` is classified as an `arguments` object.
  3150. *
  3151. * @static
  3152. * @memberOf _
  3153. * @category Lang
  3154. * @param {*} value The value to check.
  3155. * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
  3156. * @example
  3157. *
  3158. * _.isArguments(function() { return arguments; }());
  3159. * // => true
  3160. *
  3161. * _.isArguments([1, 2, 3]);
  3162. * // => false
  3163. */
  3164. function isArguments(value) {
  3165. return isObjectLike(value) && isArrayLike(value) &&
  3166. hasOwnProperty.call(value, 'callee') && !propertyIsEnumerable.call(value, 'callee');
  3167. }
  3168. module.exports = isArguments;
  3169. },{"../internal/isArrayLike":45,"../internal/isObjectLike":50}],56:[function(require,module,exports){
  3170. var getNative = require('../internal/getNative'),
  3171. isLength = require('../internal/isLength'),
  3172. isObjectLike = require('../internal/isObjectLike');
  3173. /** `Object#toString` result references. */
  3174. var arrayTag = '[object Array]';
  3175. /** Used for native method references. */
  3176. var objectProto = Object.prototype;
  3177. /**
  3178. * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
  3179. * of values.
  3180. */
  3181. var objToString = objectProto.toString;
  3182. /* Native method references for those with the same name as other `lodash` methods. */
  3183. var nativeIsArray = getNative(Array, 'isArray');
  3184. /**
  3185. * Checks if `value` is classified as an `Array` object.
  3186. *
  3187. * @static
  3188. * @memberOf _
  3189. * @category Lang
  3190. * @param {*} value The value to check.
  3191. * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
  3192. * @example
  3193. *
  3194. * _.isArray([1, 2, 3]);
  3195. * // => true
  3196. *
  3197. * _.isArray(function() { return arguments; }());
  3198. * // => false
  3199. */
  3200. var isArray = nativeIsArray || function(value) {
  3201. return isObjectLike(value) && isLength(value.length) && objToString.call(value) == arrayTag;
  3202. };
  3203. module.exports = isArray;
  3204. },{"../internal/getNative":44,"../internal/isLength":49,"../internal/isObjectLike":50}],57:[function(require,module,exports){
  3205. var isArguments = require('./isArguments'),
  3206. isArray = require('./isArray'),
  3207. isArrayLike = require('../internal/isArrayLike'),
  3208. isFunction = require('./isFunction'),
  3209. isObjectLike = require('../internal/isObjectLike'),
  3210. isString = require('./isString'),
  3211. keys = require('../object/keys');
  3212. /**
  3213. * Checks if `value` is empty. A value is considered empty unless it's an
  3214. * `arguments` object, array, string, or jQuery-like collection with a length
  3215. * greater than `0` or an object with own enumerable properties.
  3216. *
  3217. * @static
  3218. * @memberOf _
  3219. * @category Lang
  3220. * @param {Array|Object|string} value The value to inspect.
  3221. * @returns {boolean} Returns `true` if `value` is empty, else `false`.
  3222. * @example
  3223. *
  3224. * _.isEmpty(null);
  3225. * // => true
  3226. *
  3227. * _.isEmpty(true);
  3228. * // => true
  3229. *
  3230. * _.isEmpty(1);
  3231. * // => true
  3232. *
  3233. * _.isEmpty([1, 2, 3]);
  3234. * // => false
  3235. *
  3236. * _.isEmpty({ 'a': 1 });
  3237. * // => false
  3238. */
  3239. function isEmpty(value) {
  3240. if (value == null) {
  3241. return true;
  3242. }
  3243. if (isArrayLike(value) && (isArray(value) || isString(value) || isArguments(value) ||
  3244. (isObjectLike(value) && isFunction(value.splice)))) {
  3245. return !value.length;
  3246. }
  3247. return !keys(value).length;
  3248. }
  3249. module.exports = isEmpty;
  3250. },{"../internal/isArrayLike":45,"../internal/isObjectLike":50,"../object/keys":65,"./isArguments":55,"./isArray":56,"./isFunction":58,"./isString":61}],58:[function(require,module,exports){
  3251. var isObject = require('./isObject');
  3252. /** `Object#toString` result references. */
  3253. var funcTag = '[object Function]';
  3254. /** Used for native method references. */
  3255. var objectProto = Object.prototype;
  3256. /**
  3257. * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
  3258. * of values.
  3259. */
  3260. var objToString = objectProto.toString;
  3261. /**
  3262. * Checks if `value` is classified as a `Function` object.
  3263. *
  3264. * @static
  3265. * @memberOf _
  3266. * @category Lang
  3267. * @param {*} value The value to check.
  3268. * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
  3269. * @example
  3270. *
  3271. * _.isFunction(_);
  3272. * // => true
  3273. *
  3274. * _.isFunction(/abc/);
  3275. * // => false
  3276. */
  3277. function isFunction(value) {
  3278. // The use of `Object#toString` avoids issues with the `typeof` operator
  3279. // in older versions of Chrome and Safari which return 'function' for regexes
  3280. // and Safari 8 which returns 'object' for typed array constructors.
  3281. return isObject(value) && objToString.call(value) == funcTag;
  3282. }
  3283. module.exports = isFunction;
  3284. },{"./isObject":60}],59:[function(require,module,exports){
  3285. var isFunction = require('./isFunction'),
  3286. isObjectLike = require('../internal/isObjectLike');
  3287. /** Used to detect host constructors (Safari > 5). */
  3288. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  3289. /** Used for native method references. */
  3290. var objectProto = Object.prototype;
  3291. /** Used to resolve the decompiled source of functions. */
  3292. var fnToString = Function.prototype.toString;
  3293. /** Used to check objects for own properties. */
  3294. var hasOwnProperty = objectProto.hasOwnProperty;
  3295. /** Used to detect if a method is native. */
  3296. var reIsNative = RegExp('^' +
  3297. fnToString.call(hasOwnProperty).replace(/[\\^$.*+?()[\]{}|]/g, '\\$&')
  3298. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  3299. );
  3300. /**
  3301. * Checks if `value` is a native function.
  3302. *
  3303. * @static
  3304. * @memberOf _
  3305. * @category Lang
  3306. * @param {*} value The value to check.
  3307. * @returns {boolean} Returns `true` if `value` is a native function, else `false`.
  3308. * @example
  3309. *
  3310. * _.isNative(Array.prototype.push);
  3311. * // => true
  3312. *
  3313. * _.isNative(_);
  3314. * // => false
  3315. */
  3316. function isNative(value) {
  3317. if (value == null) {
  3318. return false;
  3319. }
  3320. if (isFunction(value)) {
  3321. return reIsNative.test(fnToString.call(value));
  3322. }
  3323. return isObjectLike(value) && reIsHostCtor.test(value);
  3324. }
  3325. module.exports = isNative;
  3326. },{"../internal/isObjectLike":50,"./isFunction":58}],60:[function(require,module,exports){
  3327. /**
  3328. * Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`.
  3329. * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  3330. *
  3331. * @static
  3332. * @memberOf _
  3333. * @category Lang
  3334. * @param {*} value The value to check.
  3335. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  3336. * @example
  3337. *
  3338. * _.isObject({});
  3339. * // => true
  3340. *
  3341. * _.isObject([1, 2, 3]);
  3342. * // => true
  3343. *
  3344. * _.isObject(1);
  3345. * // => false
  3346. */
  3347. function isObject(value) {
  3348. // Avoid a V8 JIT bug in Chrome 19-20.
  3349. // See https://code.google.com/p/v8/issues/detail?id=2291 for more details.
  3350. var type = typeof value;
  3351. return !!value && (type == 'object' || type == 'function');
  3352. }
  3353. module.exports = isObject;
  3354. },{}],61:[function(require,module,exports){
  3355. var isObjectLike = require('../internal/isObjectLike');
  3356. /** `Object#toString` result references. */
  3357. var stringTag = '[object String]';
  3358. /** Used for native method references. */
  3359. var objectProto = Object.prototype;
  3360. /**
  3361. * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
  3362. * of values.
  3363. */
  3364. var objToString = objectProto.toString;
  3365. /**
  3366. * Checks if `value` is classified as a `String` primitive or object.
  3367. *
  3368. * @static
  3369. * @memberOf _
  3370. * @category Lang
  3371. * @param {*} value The value to check.
  3372. * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
  3373. * @example
  3374. *
  3375. * _.isString('abc');
  3376. * // => true
  3377. *
  3378. * _.isString(1);
  3379. * // => false
  3380. */
  3381. function isString(value) {
  3382. return typeof value == 'string' || (isObjectLike(value) && objToString.call(value) == stringTag);
  3383. }
  3384. module.exports = isString;
  3385. },{"../internal/isObjectLike":50}],62:[function(require,module,exports){
  3386. var isLength = require('../internal/isLength'),
  3387. isObjectLike = require('../internal/isObjectLike');
  3388. /** `Object#toString` result references. */
  3389. var argsTag = '[object Arguments]',
  3390. arrayTag = '[object Array]',
  3391. boolTag = '[object Boolean]',
  3392. dateTag = '[object Date]',
  3393. errorTag = '[object Error]',
  3394. funcTag = '[object Function]',
  3395. mapTag = '[object Map]',
  3396. numberTag = '[object Number]',
  3397. objectTag = '[object Object]',
  3398. regexpTag = '[object RegExp]',
  3399. setTag = '[object Set]',
  3400. stringTag = '[object String]',
  3401. weakMapTag = '[object WeakMap]';
  3402. var arrayBufferTag = '[object ArrayBuffer]',
  3403. float32Tag = '[object Float32Array]',
  3404. float64Tag = '[object Float64Array]',
  3405. int8Tag = '[object Int8Array]',
  3406. int16Tag = '[object Int16Array]',
  3407. int32Tag = '[object Int32Array]',
  3408. uint8Tag = '[object Uint8Array]',
  3409. uint8ClampedTag = '[object Uint8ClampedArray]',
  3410. uint16Tag = '[object Uint16Array]',
  3411. uint32Tag = '[object Uint32Array]';
  3412. /** Used to identify `toStringTag` values of typed arrays. */
  3413. var typedArrayTags = {};
  3414. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
  3415. typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
  3416. typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
  3417. typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
  3418. typedArrayTags[uint32Tag] = true;
  3419. typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
  3420. typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
  3421. typedArrayTags[dateTag] = typedArrayTags[errorTag] =
  3422. typedArrayTags[funcTag] = typedArrayTags[mapTag] =
  3423. typedArrayTags[numberTag] = typedArrayTags[objectTag] =
  3424. typedArrayTags[regexpTag] = typedArrayTags[setTag] =
  3425. typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false;
  3426. /** Used for native method references. */
  3427. var objectProto = Object.prototype;
  3428. /**
  3429. * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
  3430. * of values.
  3431. */
  3432. var objToString = objectProto.toString;
  3433. /**
  3434. * Checks if `value` is classified as a typed array.
  3435. *
  3436. * @static
  3437. * @memberOf _
  3438. * @category Lang
  3439. * @param {*} value The value to check.
  3440. * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
  3441. * @example
  3442. *
  3443. * _.isTypedArray(new Uint8Array);
  3444. * // => true
  3445. *
  3446. * _.isTypedArray([]);
  3447. * // => false
  3448. */
  3449. function isTypedArray(value) {
  3450. return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[objToString.call(value)];
  3451. }
  3452. module.exports = isTypedArray;
  3453. },{"../internal/isLength":49,"../internal/isObjectLike":50}],63:[function(require,module,exports){
  3454. var assignWith = require('../internal/assignWith'),
  3455. baseAssign = require('../internal/baseAssign'),
  3456. createAssigner = require('../internal/createAssigner');
  3457. /**
  3458. * Assigns own enumerable properties of source object(s) to the destination
  3459. * object. Subsequent sources overwrite property assignments of previous sources.
  3460. * If `customizer` is provided it's invoked to produce the assigned values.
  3461. * The `customizer` is bound to `thisArg` and invoked with five arguments:
  3462. * (objectValue, sourceValue, key, object, source).
  3463. *
  3464. * **Note:** This method mutates `object` and is based on
  3465. * [`Object.assign`](http://ecma-international.org/ecma-262/6.0/#sec-object.assign).
  3466. *
  3467. * @static
  3468. * @memberOf _
  3469. * @alias extend
  3470. * @category Object
  3471. * @param {Object} object The destination object.
  3472. * @param {...Object} [sources] The source objects.
  3473. * @param {Function} [customizer] The function to customize assigned values.
  3474. * @param {*} [thisArg] The `this` binding of `customizer`.
  3475. * @returns {Object} Returns `object`.
  3476. * @example
  3477. *
  3478. * _.assign({ 'user': 'barney' }, { 'age': 40 }, { 'user': 'fred' });
  3479. * // => { 'user': 'fred', 'age': 40 }
  3480. *
  3481. * // using a customizer callback
  3482. * var defaults = _.partialRight(_.assign, function(value, other) {
  3483. * return _.isUndefined(value) ? other : value;
  3484. * });
  3485. *
  3486. * defaults({ 'user': 'barney' }, { 'age': 36 }, { 'user': 'fred' });
  3487. * // => { 'user': 'barney', 'age': 36 }
  3488. */
  3489. var assign = createAssigner(function(object, source, customizer) {
  3490. return customizer
  3491. ? assignWith(object, source, customizer)
  3492. : baseAssign(object, source);
  3493. });
  3494. module.exports = assign;
  3495. },{"../internal/assignWith":16,"../internal/baseAssign":17,"../internal/createAssigner":36}],64:[function(require,module,exports){
  3496. var baseAssign = require('../internal/baseAssign'),
  3497. baseCreate = require('../internal/baseCreate'),
  3498. isIterateeCall = require('../internal/isIterateeCall');
  3499. /**
  3500. * Creates an object that inherits from the given `prototype` object. If a
  3501. * `properties` object is provided its own enumerable properties are assigned
  3502. * to the created object.
  3503. *
  3504. * @static
  3505. * @memberOf _
  3506. * @category Object
  3507. * @param {Object} prototype The object to inherit from.
  3508. * @param {Object} [properties] The properties to assign to the object.
  3509. * @param- {Object} [guard] Enables use as a callback for functions like `_.map`.
  3510. * @returns {Object} Returns the new object.
  3511. * @example
  3512. *
  3513. * function Shape() {
  3514. * this.x = 0;
  3515. * this.y = 0;
  3516. * }
  3517. *
  3518. * function Circle() {
  3519. * Shape.call(this);
  3520. * }
  3521. *
  3522. * Circle.prototype = _.create(Shape.prototype, {
  3523. * 'constructor': Circle
  3524. * });
  3525. *
  3526. * var circle = new Circle;
  3527. * circle instanceof Circle;
  3528. * // => true
  3529. *
  3530. * circle instanceof Shape;
  3531. * // => true
  3532. */
  3533. function create(prototype, properties, guard) {
  3534. var result = baseCreate(prototype);
  3535. if (guard && isIterateeCall(prototype, properties, guard)) {
  3536. properties = undefined;
  3537. }
  3538. return properties ? baseAssign(result, properties) : result;
  3539. }
  3540. module.exports = create;
  3541. },{"../internal/baseAssign":17,"../internal/baseCreate":20,"../internal/isIterateeCall":47}],65:[function(require,module,exports){
  3542. var getNative = require('../internal/getNative'),
  3543. isArrayLike = require('../internal/isArrayLike'),
  3544. isObject = require('../lang/isObject'),
  3545. shimKeys = require('../internal/shimKeys');
  3546. /* Native method references for those with the same name as other `lodash` methods. */
  3547. var nativeKeys = getNative(Object, 'keys');
  3548. /**
  3549. * Creates an array of the own enumerable property names of `object`.
  3550. *
  3551. * **Note:** Non-object values are coerced to objects. See the
  3552. * [ES spec](http://ecma-international.org/ecma-262/6.0/#sec-object.keys)
  3553. * for more details.
  3554. *
  3555. * @static
  3556. * @memberOf _
  3557. * @category Object
  3558. * @param {Object} object The object to query.
  3559. * @returns {Array} Returns the array of property names.
  3560. * @example
  3561. *
  3562. * function Foo() {
  3563. * this.a = 1;
  3564. * this.b = 2;
  3565. * }
  3566. *
  3567. * Foo.prototype.c = 3;
  3568. *
  3569. * _.keys(new Foo);
  3570. * // => ['a', 'b'] (iteration order is not guaranteed)
  3571. *
  3572. * _.keys('hi');
  3573. * // => ['0', '1']
  3574. */
  3575. var keys = !nativeKeys ? shimKeys : function(object) {
  3576. var Ctor = object == null ? undefined : object.constructor;
  3577. if ((typeof Ctor == 'function' && Ctor.prototype === object) ||
  3578. (typeof object != 'function' && isArrayLike(object))) {
  3579. return shimKeys(object);
  3580. }
  3581. return isObject(object) ? nativeKeys(object) : [];
  3582. };
  3583. module.exports = keys;
  3584. },{"../internal/getNative":44,"../internal/isArrayLike":45,"../internal/shimKeys":52,"../lang/isObject":60}],66:[function(require,module,exports){
  3585. var isArguments = require('../lang/isArguments'),
  3586. isArray = require('../lang/isArray'),
  3587. isIndex = require('../internal/isIndex'),
  3588. isLength = require('../internal/isLength'),
  3589. isObject = require('../lang/isObject');
  3590. /** Used for native method references. */
  3591. var objectProto = Object.prototype;
  3592. /** Used to check objects for own properties. */
  3593. var hasOwnProperty = objectProto.hasOwnProperty;
  3594. /**
  3595. * Creates an array of the own and inherited enumerable property names of `object`.
  3596. *
  3597. * **Note:** Non-object values are coerced to objects.
  3598. *
  3599. * @static
  3600. * @memberOf _
  3601. * @category Object
  3602. * @param {Object} object The object to query.
  3603. * @returns {Array} Returns the array of property names.
  3604. * @example
  3605. *
  3606. * function Foo() {
  3607. * this.a = 1;
  3608. * this.b = 2;
  3609. * }
  3610. *
  3611. * Foo.prototype.c = 3;
  3612. *
  3613. * _.keysIn(new Foo);
  3614. * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
  3615. */
  3616. function keysIn(object) {
  3617. if (object == null) {
  3618. return [];
  3619. }
  3620. if (!isObject(object)) {
  3621. object = Object(object);
  3622. }
  3623. var length = object.length;
  3624. length = (length && isLength(length) &&
  3625. (isArray(object) || isArguments(object)) && length) || 0;
  3626. var Ctor = object.constructor,
  3627. index = -1,
  3628. isProto = typeof Ctor == 'function' && Ctor.prototype === object,
  3629. result = Array(length),
  3630. skipIndexes = length > 0;
  3631. while (++index < length) {
  3632. result[index] = (index + '');
  3633. }
  3634. for (var key in object) {
  3635. if (!(skipIndexes && isIndex(key, length)) &&
  3636. !(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
  3637. result.push(key);
  3638. }
  3639. }
  3640. return result;
  3641. }
  3642. module.exports = keysIn;
  3643. },{"../internal/isIndex":46,"../internal/isLength":49,"../lang/isArguments":55,"../lang/isArray":56,"../lang/isObject":60}],67:[function(require,module,exports){
  3644. var keys = require('./keys'),
  3645. toObject = require('../internal/toObject');
  3646. /**
  3647. * Creates a two dimensional array of the key-value pairs for `object`,
  3648. * e.g. `[[key1, value1], [key2, value2]]`.
  3649. *
  3650. * @static
  3651. * @memberOf _
  3652. * @category Object
  3653. * @param {Object} object The object to query.
  3654. * @returns {Array} Returns the new array of key-value pairs.
  3655. * @example
  3656. *
  3657. * _.pairs({ 'barney': 36, 'fred': 40 });
  3658. * // => [['barney', 36], ['fred', 40]] (iteration order is not guaranteed)
  3659. */
  3660. function pairs(object) {
  3661. object = toObject(object);
  3662. var index = -1,
  3663. props = keys(object),
  3664. length = props.length,
  3665. result = Array(length);
  3666. while (++index < length) {
  3667. var key = props[index];
  3668. result[index] = [key, object[key]];
  3669. }
  3670. return result;
  3671. }
  3672. module.exports = pairs;
  3673. },{"../internal/toObject":53,"./keys":65}],68:[function(require,module,exports){
  3674. /**
  3675. * This method returns the first argument provided to it.
  3676. *
  3677. * @static
  3678. * @memberOf _
  3679. * @category Utility
  3680. * @param {*} value Any value.
  3681. * @returns {*} Returns `value`.
  3682. * @example
  3683. *
  3684. * var object = { 'user': 'fred' };
  3685. *
  3686. * _.identity(object) === object;
  3687. * // => true
  3688. */
  3689. function identity(value) {
  3690. return value;
  3691. }
  3692. module.exports = identity;
  3693. },{}],69:[function(require,module,exports){
  3694. var baseProperty = require('../internal/baseProperty'),
  3695. basePropertyDeep = require('../internal/basePropertyDeep'),
  3696. isKey = require('../internal/isKey');
  3697. /**
  3698. * Creates a function that returns the property value at `path` on a
  3699. * given object.
  3700. *
  3701. * @static
  3702. * @memberOf _
  3703. * @category Utility
  3704. * @param {Array|string} path The path of the property to get.
  3705. * @returns {Function} Returns the new function.
  3706. * @example
  3707. *
  3708. * var objects = [
  3709. * { 'a': { 'b': { 'c': 2 } } },
  3710. * { 'a': { 'b': { 'c': 1 } } }
  3711. * ];
  3712. *
  3713. * _.map(objects, _.property('a.b.c'));
  3714. * // => [2, 1]
  3715. *
  3716. * _.pluck(_.sortBy(objects, _.property(['a', 'b', 'c'])), 'a.b.c');
  3717. * // => [1, 2]
  3718. */
  3719. function property(path) {
  3720. return isKey(path) ? baseProperty(path) : basePropertyDeep(path);
  3721. }
  3722. module.exports = property;
  3723. },{"../internal/baseProperty":31,"../internal/basePropertyDeep":32,"../internal/isKey":48}],70:[function(require,module,exports){
  3724. (function (global){
  3725. /**
  3726. * Module exports.
  3727. */
  3728. module.exports = deprecate;
  3729. /**
  3730. * Mark that a method should not be used.
  3731. * Returns a modified function which warns once by default.
  3732. *
  3733. * If `localStorage.noDeprecation = true` is set, then it is a no-op.
  3734. *
  3735. * If `localStorage.throwDeprecation = true` is set, then deprecated functions
  3736. * will throw an Error when invoked.
  3737. *
  3738. * If `localStorage.traceDeprecation = true` is set, then deprecated functions
  3739. * will invoke `console.trace()` instead of `console.error()`.
  3740. *
  3741. * @param {Function} fn - the function to deprecate
  3742. * @param {String} msg - the string to print to the console when `fn` is invoked
  3743. * @returns {Function} a new "deprecated" version of `fn`
  3744. * @api public
  3745. */
  3746. function deprecate (fn, msg) {
  3747. if (config('noDeprecation')) {
  3748. return fn;
  3749. }
  3750. var warned = false;
  3751. function deprecated() {
  3752. if (!warned) {
  3753. if (config('throwDeprecation')) {
  3754. throw new Error(msg);
  3755. } else if (config('traceDeprecation')) {
  3756. console.trace(msg);
  3757. } else {
  3758. console.warn(msg);
  3759. }
  3760. warned = true;
  3761. }
  3762. return fn.apply(this, arguments);
  3763. }
  3764. return deprecated;
  3765. }
  3766. /**
  3767. * Checks `localStorage` for boolean values for the given `name`.
  3768. *
  3769. * @param {String} name
  3770. * @returns {Boolean}
  3771. * @api private
  3772. */
  3773. function config (name) {
  3774. // accessing global.localStorage can trigger a DOMException in sandboxed iframes
  3775. try {
  3776. if (!global.localStorage) return false;
  3777. } catch (_) {
  3778. return false;
  3779. }
  3780. var val = global.localStorage[name];
  3781. if (null == val) return false;
  3782. return String(val).toLowerCase() === 'true';
  3783. }
  3784. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  3785. },{}],71:[function(require,module,exports){
  3786. // Generated by CoffeeScript 1.9.1
  3787. (function() {
  3788. var XMLAttribute, create;
  3789. create = require('lodash/object/create');
  3790. module.exports = XMLAttribute = (function() {
  3791. function XMLAttribute(parent, name, value) {
  3792. this.stringify = parent.stringify;
  3793. if (name == null) {
  3794. throw new Error("Missing attribute name of element " + parent.name);
  3795. }
  3796. if (value == null) {
  3797. throw new Error("Missing attribute value for attribute " + name + " of element " + parent.name);
  3798. }
  3799. this.name = this.stringify.attName(name);
  3800. this.value = this.stringify.attValue(value);
  3801. }
  3802. XMLAttribute.prototype.clone = function() {
  3803. return create(XMLAttribute.prototype, this);
  3804. };
  3805. XMLAttribute.prototype.toString = function(options, level) {
  3806. return ' ' + this.name + '="' + this.value + '"';
  3807. };
  3808. return XMLAttribute;
  3809. })();
  3810. }).call(this);
  3811. },{"lodash/object/create":64}],72:[function(require,module,exports){
  3812. // Generated by CoffeeScript 1.9.1
  3813. (function() {
  3814. var XMLBuilder, XMLDeclaration, XMLDocType, XMLElement, XMLStringifier;
  3815. XMLStringifier = require('./XMLStringifier');
  3816. XMLDeclaration = require('./XMLDeclaration');
  3817. XMLDocType = require('./XMLDocType');
  3818. XMLElement = require('./XMLElement');
  3819. module.exports = XMLBuilder = (function() {
  3820. function XMLBuilder(name, options) {
  3821. var root, temp;
  3822. if (name == null) {
  3823. throw new Error("Root element needs a name");
  3824. }
  3825. if (options == null) {
  3826. options = {};
  3827. }
  3828. this.options = options;
  3829. this.stringify = new XMLStringifier(options);
  3830. temp = new XMLElement(this, 'doc');
  3831. root = temp.element(name);
  3832. root.isRoot = true;
  3833. root.documentObject = this;
  3834. this.rootObject = root;
  3835. if (!options.headless) {
  3836. root.declaration(options);
  3837. if ((options.pubID != null) || (options.sysID != null)) {
  3838. root.doctype(options);
  3839. }
  3840. }
  3841. }
  3842. XMLBuilder.prototype.root = function() {
  3843. return this.rootObject;
  3844. };
  3845. XMLBuilder.prototype.end = function(options) {
  3846. return this.toString(options);
  3847. };
  3848. XMLBuilder.prototype.toString = function(options) {
  3849. var indent, newline, offset, pretty, r, ref, ref1, ref2;
  3850. pretty = (options != null ? options.pretty : void 0) || false;
  3851. indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' ';
  3852. offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0;
  3853. newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n';
  3854. r = '';
  3855. if (this.xmldec != null) {
  3856. r += this.xmldec.toString(options);
  3857. }
  3858. if (this.doctype != null) {
  3859. r += this.doctype.toString(options);
  3860. }
  3861. r += this.rootObject.toString(options);
  3862. if (pretty && r.slice(-newline.length) === newline) {
  3863. r = r.slice(0, -newline.length);
  3864. }
  3865. return r;
  3866. };
  3867. return XMLBuilder;
  3868. })();
  3869. }).call(this);
  3870. },{"./XMLDeclaration":79,"./XMLDocType":80,"./XMLElement":81,"./XMLStringifier":85}],73:[function(require,module,exports){
  3871. // Generated by CoffeeScript 1.9.1
  3872. (function() {
  3873. var XMLCData, XMLNode, create,
  3874. extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  3875. hasProp = {}.hasOwnProperty;
  3876. create = require('lodash/object/create');
  3877. XMLNode = require('./XMLNode');
  3878. module.exports = XMLCData = (function(superClass) {
  3879. extend(XMLCData, superClass);
  3880. function XMLCData(parent, text) {
  3881. XMLCData.__super__.constructor.call(this, parent);
  3882. if (text == null) {
  3883. throw new Error("Missing CDATA text");
  3884. }
  3885. this.text = this.stringify.cdata(text);
  3886. }
  3887. XMLCData.prototype.clone = function() {
  3888. return create(XMLCData.prototype, this);
  3889. };
  3890. XMLCData.prototype.toString = function(options, level) {
  3891. var indent, newline, offset, pretty, r, ref, ref1, ref2, space;
  3892. pretty = (options != null ? options.pretty : void 0) || false;
  3893. indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' ';
  3894. offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0;
  3895. newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n';
  3896. level || (level = 0);
  3897. space = new Array(level + offset + 1).join(indent);
  3898. r = '';
  3899. if (pretty) {
  3900. r += space;
  3901. }
  3902. r += '<![CDATA[' + this.text + ']]>';
  3903. if (pretty) {
  3904. r += newline;
  3905. }
  3906. return r;
  3907. };
  3908. return XMLCData;
  3909. })(XMLNode);
  3910. }).call(this);
  3911. },{"./XMLNode":82,"lodash/object/create":64}],74:[function(require,module,exports){
  3912. // Generated by CoffeeScript 1.9.1
  3913. (function() {
  3914. var XMLComment, XMLNode, create,
  3915. extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  3916. hasProp = {}.hasOwnProperty;
  3917. create = require('lodash/object/create');
  3918. XMLNode = require('./XMLNode');
  3919. module.exports = XMLComment = (function(superClass) {
  3920. extend(XMLComment, superClass);
  3921. function XMLComment(parent, text) {
  3922. XMLComment.__super__.constructor.call(this, parent);
  3923. if (text == null) {
  3924. throw new Error("Missing comment text");
  3925. }
  3926. this.text = this.stringify.comment(text);
  3927. }
  3928. XMLComment.prototype.clone = function() {
  3929. return create(XMLComment.prototype, this);
  3930. };
  3931. XMLComment.prototype.toString = function(options, level) {
  3932. var indent, newline, offset, pretty, r, ref, ref1, ref2, space;
  3933. pretty = (options != null ? options.pretty : void 0) || false;
  3934. indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' ';
  3935. offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0;
  3936. newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n';
  3937. level || (level = 0);
  3938. space = new Array(level + offset + 1).join(indent);
  3939. r = '';
  3940. if (pretty) {
  3941. r += space;
  3942. }
  3943. r += '<!-- ' + this.text + ' -->';
  3944. if (pretty) {
  3945. r += newline;
  3946. }
  3947. return r;
  3948. };
  3949. return XMLComment;
  3950. })(XMLNode);
  3951. }).call(this);
  3952. },{"./XMLNode":82,"lodash/object/create":64}],75:[function(require,module,exports){
  3953. // Generated by CoffeeScript 1.9.1
  3954. (function() {
  3955. var XMLDTDAttList, create;
  3956. create = require('lodash/object/create');
  3957. module.exports = XMLDTDAttList = (function() {
  3958. function XMLDTDAttList(parent, elementName, attributeName, attributeType, defaultValueType, defaultValue) {
  3959. this.stringify = parent.stringify;
  3960. if (elementName == null) {
  3961. throw new Error("Missing DTD element name");
  3962. }
  3963. if (attributeName == null) {
  3964. throw new Error("Missing DTD attribute name");
  3965. }
  3966. if (!attributeType) {
  3967. throw new Error("Missing DTD attribute type");
  3968. }
  3969. if (!defaultValueType) {
  3970. throw new Error("Missing DTD attribute default");
  3971. }
  3972. if (defaultValueType.indexOf('#') !== 0) {
  3973. defaultValueType = '#' + defaultValueType;
  3974. }
  3975. if (!defaultValueType.match(/^(#REQUIRED|#IMPLIED|#FIXED|#DEFAULT)$/)) {
  3976. throw new Error("Invalid default value type; expected: #REQUIRED, #IMPLIED, #FIXED or #DEFAULT");
  3977. }
  3978. if (defaultValue && !defaultValueType.match(/^(#FIXED|#DEFAULT)$/)) {
  3979. throw new Error("Default value only applies to #FIXED or #DEFAULT");
  3980. }
  3981. this.elementName = this.stringify.eleName(elementName);
  3982. this.attributeName = this.stringify.attName(attributeName);
  3983. this.attributeType = this.stringify.dtdAttType(attributeType);
  3984. this.defaultValue = this.stringify.dtdAttDefault(defaultValue);
  3985. this.defaultValueType = defaultValueType;
  3986. }
  3987. XMLDTDAttList.prototype.toString = function(options, level) {
  3988. var indent, newline, offset, pretty, r, ref, ref1, ref2, space;
  3989. pretty = (options != null ? options.pretty : void 0) || false;
  3990. indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' ';
  3991. offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0;
  3992. newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n';
  3993. level || (level = 0);
  3994. space = new Array(level + offset + 1).join(indent);
  3995. r = '';
  3996. if (pretty) {
  3997. r += space;
  3998. }
  3999. r += '<!ATTLIST ' + this.elementName + ' ' + this.attributeName + ' ' + this.attributeType;
  4000. if (this.defaultValueType !== '#DEFAULT') {
  4001. r += ' ' + this.defaultValueType;
  4002. }
  4003. if (this.defaultValue) {
  4004. r += ' "' + this.defaultValue + '"';
  4005. }
  4006. r += '>';
  4007. if (pretty) {
  4008. r += newline;
  4009. }
  4010. return r;
  4011. };
  4012. return XMLDTDAttList;
  4013. })();
  4014. }).call(this);
  4015. },{"lodash/object/create":64}],76:[function(require,module,exports){
  4016. // Generated by CoffeeScript 1.9.1
  4017. (function() {
  4018. var XMLDTDElement, create;
  4019. create = require('lodash/object/create');
  4020. module.exports = XMLDTDElement = (function() {
  4021. function XMLDTDElement(parent, name, value) {
  4022. this.stringify = parent.stringify;
  4023. if (name == null) {
  4024. throw new Error("Missing DTD element name");
  4025. }
  4026. if (!value) {
  4027. value = '(#PCDATA)';
  4028. }
  4029. if (Array.isArray(value)) {
  4030. value = '(' + value.join(',') + ')';
  4031. }
  4032. this.name = this.stringify.eleName(name);
  4033. this.value = this.stringify.dtdElementValue(value);
  4034. }
  4035. XMLDTDElement.prototype.toString = function(options, level) {
  4036. var indent, newline, offset, pretty, r, ref, ref1, ref2, space;
  4037. pretty = (options != null ? options.pretty : void 0) || false;
  4038. indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' ';
  4039. offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0;
  4040. newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n';
  4041. level || (level = 0);
  4042. space = new Array(level + offset + 1).join(indent);
  4043. r = '';
  4044. if (pretty) {
  4045. r += space;
  4046. }
  4047. r += '<!ELEMENT ' + this.name + ' ' + this.value + '>';
  4048. if (pretty) {
  4049. r += newline;
  4050. }
  4051. return r;
  4052. };
  4053. return XMLDTDElement;
  4054. })();
  4055. }).call(this);
  4056. },{"lodash/object/create":64}],77:[function(require,module,exports){
  4057. // Generated by CoffeeScript 1.9.1
  4058. (function() {
  4059. var XMLDTDEntity, create, isObject;
  4060. create = require('lodash/object/create');
  4061. isObject = require('lodash/lang/isObject');
  4062. module.exports = XMLDTDEntity = (function() {
  4063. function XMLDTDEntity(parent, pe, name, value) {
  4064. this.stringify = parent.stringify;
  4065. if (name == null) {
  4066. throw new Error("Missing entity name");
  4067. }
  4068. if (value == null) {
  4069. throw new Error("Missing entity value");
  4070. }
  4071. this.pe = !!pe;
  4072. this.name = this.stringify.eleName(name);
  4073. if (!isObject(value)) {
  4074. this.value = this.stringify.dtdEntityValue(value);
  4075. } else {
  4076. if (!value.pubID && !value.sysID) {
  4077. throw new Error("Public and/or system identifiers are required for an external entity");
  4078. }
  4079. if (value.pubID && !value.sysID) {
  4080. throw new Error("System identifier is required for a public external entity");
  4081. }
  4082. if (value.pubID != null) {
  4083. this.pubID = this.stringify.dtdPubID(value.pubID);
  4084. }
  4085. if (value.sysID != null) {
  4086. this.sysID = this.stringify.dtdSysID(value.sysID);
  4087. }
  4088. if (value.nData != null) {
  4089. this.nData = this.stringify.dtdNData(value.nData);
  4090. }
  4091. if (this.pe && this.nData) {
  4092. throw new Error("Notation declaration is not allowed in a parameter entity");
  4093. }
  4094. }
  4095. }
  4096. XMLDTDEntity.prototype.toString = function(options, level) {
  4097. var indent, newline, offset, pretty, r, ref, ref1, ref2, space;
  4098. pretty = (options != null ? options.pretty : void 0) || false;
  4099. indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' ';
  4100. offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0;
  4101. newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n';
  4102. level || (level = 0);
  4103. space = new Array(level + offset + 1).join(indent);
  4104. r = '';
  4105. if (pretty) {
  4106. r += space;
  4107. }
  4108. r += '<!ENTITY';
  4109. if (this.pe) {
  4110. r += ' %';
  4111. }
  4112. r += ' ' + this.name;
  4113. if (this.value) {
  4114. r += ' "' + this.value + '"';
  4115. } else {
  4116. if (this.pubID && this.sysID) {
  4117. r += ' PUBLIC "' + this.pubID + '" "' + this.sysID + '"';
  4118. } else if (this.sysID) {
  4119. r += ' SYSTEM "' + this.sysID + '"';
  4120. }
  4121. if (this.nData) {
  4122. r += ' NDATA ' + this.nData;
  4123. }
  4124. }
  4125. r += '>';
  4126. if (pretty) {
  4127. r += newline;
  4128. }
  4129. return r;
  4130. };
  4131. return XMLDTDEntity;
  4132. })();
  4133. }).call(this);
  4134. },{"lodash/lang/isObject":60,"lodash/object/create":64}],78:[function(require,module,exports){
  4135. // Generated by CoffeeScript 1.9.1
  4136. (function() {
  4137. var XMLDTDNotation, create;
  4138. create = require('lodash/object/create');
  4139. module.exports = XMLDTDNotation = (function() {
  4140. function XMLDTDNotation(parent, name, value) {
  4141. this.stringify = parent.stringify;
  4142. if (name == null) {
  4143. throw new Error("Missing notation name");
  4144. }
  4145. if (!value.pubID && !value.sysID) {
  4146. throw new Error("Public or system identifiers are required for an external entity");
  4147. }
  4148. this.name = this.stringify.eleName(name);
  4149. if (value.pubID != null) {
  4150. this.pubID = this.stringify.dtdPubID(value.pubID);
  4151. }
  4152. if (value.sysID != null) {
  4153. this.sysID = this.stringify.dtdSysID(value.sysID);
  4154. }
  4155. }
  4156. XMLDTDNotation.prototype.toString = function(options, level) {
  4157. var indent, newline, offset, pretty, r, ref, ref1, ref2, space;
  4158. pretty = (options != null ? options.pretty : void 0) || false;
  4159. indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' ';
  4160. offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0;
  4161. newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n';
  4162. level || (level = 0);
  4163. space = new Array(level + offset + 1).join(indent);
  4164. r = '';
  4165. if (pretty) {
  4166. r += space;
  4167. }
  4168. r += '<!NOTATION ' + this.name;
  4169. if (this.pubID && this.sysID) {
  4170. r += ' PUBLIC "' + this.pubID + '" "' + this.sysID + '"';
  4171. } else if (this.pubID) {
  4172. r += ' PUBLIC "' + this.pubID + '"';
  4173. } else if (this.sysID) {
  4174. r += ' SYSTEM "' + this.sysID + '"';
  4175. }
  4176. r += '>';
  4177. if (pretty) {
  4178. r += newline;
  4179. }
  4180. return r;
  4181. };
  4182. return XMLDTDNotation;
  4183. })();
  4184. }).call(this);
  4185. },{"lodash/object/create":64}],79:[function(require,module,exports){
  4186. // Generated by CoffeeScript 1.9.1
  4187. (function() {
  4188. var XMLDeclaration, XMLNode, create, isObject,
  4189. extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  4190. hasProp = {}.hasOwnProperty;
  4191. create = require('lodash/object/create');
  4192. isObject = require('lodash/lang/isObject');
  4193. XMLNode = require('./XMLNode');
  4194. module.exports = XMLDeclaration = (function(superClass) {
  4195. extend(XMLDeclaration, superClass);
  4196. function XMLDeclaration(parent, version, encoding, standalone) {
  4197. var ref;
  4198. XMLDeclaration.__super__.constructor.call(this, parent);
  4199. if (isObject(version)) {
  4200. ref = version, version = ref.version, encoding = ref.encoding, standalone = ref.standalone;
  4201. }
  4202. if (!version) {
  4203. version = '1.0';
  4204. }
  4205. this.version = this.stringify.xmlVersion(version);
  4206. if (encoding != null) {
  4207. this.encoding = this.stringify.xmlEncoding(encoding);
  4208. }
  4209. if (standalone != null) {
  4210. this.standalone = this.stringify.xmlStandalone(standalone);
  4211. }
  4212. }
  4213. XMLDeclaration.prototype.toString = function(options, level) {
  4214. var indent, newline, offset, pretty, r, ref, ref1, ref2, space;
  4215. pretty = (options != null ? options.pretty : void 0) || false;
  4216. indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' ';
  4217. offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0;
  4218. newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n';
  4219. level || (level = 0);
  4220. space = new Array(level + offset + 1).join(indent);
  4221. r = '';
  4222. if (pretty) {
  4223. r += space;
  4224. }
  4225. r += '<?xml';
  4226. r += ' version="' + this.version + '"';
  4227. if (this.encoding != null) {
  4228. r += ' encoding="' + this.encoding + '"';
  4229. }
  4230. if (this.standalone != null) {
  4231. r += ' standalone="' + this.standalone + '"';
  4232. }
  4233. r += '?>';
  4234. if (pretty) {
  4235. r += newline;
  4236. }
  4237. return r;
  4238. };
  4239. return XMLDeclaration;
  4240. })(XMLNode);
  4241. }).call(this);
  4242. },{"./XMLNode":82,"lodash/lang/isObject":60,"lodash/object/create":64}],80:[function(require,module,exports){
  4243. // Generated by CoffeeScript 1.9.1
  4244. (function() {
  4245. var XMLCData, XMLComment, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDocType, XMLProcessingInstruction, create, isObject;
  4246. create = require('lodash/object/create');
  4247. isObject = require('lodash/lang/isObject');
  4248. XMLCData = require('./XMLCData');
  4249. XMLComment = require('./XMLComment');
  4250. XMLDTDAttList = require('./XMLDTDAttList');
  4251. XMLDTDEntity = require('./XMLDTDEntity');
  4252. XMLDTDElement = require('./XMLDTDElement');
  4253. XMLDTDNotation = require('./XMLDTDNotation');
  4254. XMLProcessingInstruction = require('./XMLProcessingInstruction');
  4255. module.exports = XMLDocType = (function() {
  4256. function XMLDocType(parent, pubID, sysID) {
  4257. var ref, ref1;
  4258. this.documentObject = parent;
  4259. this.stringify = this.documentObject.stringify;
  4260. this.children = [];
  4261. if (isObject(pubID)) {
  4262. ref = pubID, pubID = ref.pubID, sysID = ref.sysID;
  4263. }
  4264. if (sysID == null) {
  4265. ref1 = [pubID, sysID], sysID = ref1[0], pubID = ref1[1];
  4266. }
  4267. if (pubID != null) {
  4268. this.pubID = this.stringify.dtdPubID(pubID);
  4269. }
  4270. if (sysID != null) {
  4271. this.sysID = this.stringify.dtdSysID(sysID);
  4272. }
  4273. }
  4274. XMLDocType.prototype.element = function(name, value) {
  4275. var child;
  4276. child = new XMLDTDElement(this, name, value);
  4277. this.children.push(child);
  4278. return this;
  4279. };
  4280. XMLDocType.prototype.attList = function(elementName, attributeName, attributeType, defaultValueType, defaultValue) {
  4281. var child;
  4282. child = new XMLDTDAttList(this, elementName, attributeName, attributeType, defaultValueType, defaultValue);
  4283. this.children.push(child);
  4284. return this;
  4285. };
  4286. XMLDocType.prototype.entity = function(name, value) {
  4287. var child;
  4288. child = new XMLDTDEntity(this, false, name, value);
  4289. this.children.push(child);
  4290. return this;
  4291. };
  4292. XMLDocType.prototype.pEntity = function(name, value) {
  4293. var child;
  4294. child = new XMLDTDEntity(this, true, name, value);
  4295. this.children.push(child);
  4296. return this;
  4297. };
  4298. XMLDocType.prototype.notation = function(name, value) {
  4299. var child;
  4300. child = new XMLDTDNotation(this, name, value);
  4301. this.children.push(child);
  4302. return this;
  4303. };
  4304. XMLDocType.prototype.cdata = function(value) {
  4305. var child;
  4306. child = new XMLCData(this, value);
  4307. this.children.push(child);
  4308. return this;
  4309. };
  4310. XMLDocType.prototype.comment = function(value) {
  4311. var child;
  4312. child = new XMLComment(this, value);
  4313. this.children.push(child);
  4314. return this;
  4315. };
  4316. XMLDocType.prototype.instruction = function(target, value) {
  4317. var child;
  4318. child = new XMLProcessingInstruction(this, target, value);
  4319. this.children.push(child);
  4320. return this;
  4321. };
  4322. XMLDocType.prototype.root = function() {
  4323. return this.documentObject.root();
  4324. };
  4325. XMLDocType.prototype.document = function() {
  4326. return this.documentObject;
  4327. };
  4328. XMLDocType.prototype.toString = function(options, level) {
  4329. var child, i, indent, len, newline, offset, pretty, r, ref, ref1, ref2, ref3, space;
  4330. pretty = (options != null ? options.pretty : void 0) || false;
  4331. indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' ';
  4332. offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0;
  4333. newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n';
  4334. level || (level = 0);
  4335. space = new Array(level + offset + 1).join(indent);
  4336. r = '';
  4337. if (pretty) {
  4338. r += space;
  4339. }
  4340. r += '<!DOCTYPE ' + this.root().name;
  4341. if (this.pubID && this.sysID) {
  4342. r += ' PUBLIC "' + this.pubID + '" "' + this.sysID + '"';
  4343. } else if (this.sysID) {
  4344. r += ' SYSTEM "' + this.sysID + '"';
  4345. }
  4346. if (this.children.length > 0) {
  4347. r += ' [';
  4348. if (pretty) {
  4349. r += newline;
  4350. }
  4351. ref3 = this.children;
  4352. for (i = 0, len = ref3.length; i < len; i++) {
  4353. child = ref3[i];
  4354. r += child.toString(options, level + 1);
  4355. }
  4356. r += ']';
  4357. }
  4358. r += '>';
  4359. if (pretty) {
  4360. r += newline;
  4361. }
  4362. return r;
  4363. };
  4364. XMLDocType.prototype.ele = function(name, value) {
  4365. return this.element(name, value);
  4366. };
  4367. XMLDocType.prototype.att = function(elementName, attributeName, attributeType, defaultValueType, defaultValue) {
  4368. return this.attList(elementName, attributeName, attributeType, defaultValueType, defaultValue);
  4369. };
  4370. XMLDocType.prototype.ent = function(name, value) {
  4371. return this.entity(name, value);
  4372. };
  4373. XMLDocType.prototype.pent = function(name, value) {
  4374. return this.pEntity(name, value);
  4375. };
  4376. XMLDocType.prototype.not = function(name, value) {
  4377. return this.notation(name, value);
  4378. };
  4379. XMLDocType.prototype.dat = function(value) {
  4380. return this.cdata(value);
  4381. };
  4382. XMLDocType.prototype.com = function(value) {
  4383. return this.comment(value);
  4384. };
  4385. XMLDocType.prototype.ins = function(target, value) {
  4386. return this.instruction(target, value);
  4387. };
  4388. XMLDocType.prototype.up = function() {
  4389. return this.root();
  4390. };
  4391. XMLDocType.prototype.doc = function() {
  4392. return this.document();
  4393. };
  4394. return XMLDocType;
  4395. })();
  4396. }).call(this);
  4397. },{"./XMLCData":73,"./XMLComment":74,"./XMLDTDAttList":75,"./XMLDTDElement":76,"./XMLDTDEntity":77,"./XMLDTDNotation":78,"./XMLProcessingInstruction":83,"lodash/lang/isObject":60,"lodash/object/create":64}],81:[function(require,module,exports){
  4398. // Generated by CoffeeScript 1.9.1
  4399. (function() {
  4400. var XMLAttribute, XMLElement, XMLNode, XMLProcessingInstruction, create, every, isFunction, isObject,
  4401. extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  4402. hasProp = {}.hasOwnProperty;
  4403. create = require('lodash/object/create');
  4404. isObject = require('lodash/lang/isObject');
  4405. isFunction = require('lodash/lang/isFunction');
  4406. every = require('lodash/collection/every');
  4407. XMLNode = require('./XMLNode');
  4408. XMLAttribute = require('./XMLAttribute');
  4409. XMLProcessingInstruction = require('./XMLProcessingInstruction');
  4410. module.exports = XMLElement = (function(superClass) {
  4411. extend(XMLElement, superClass);
  4412. function XMLElement(parent, name, attributes) {
  4413. XMLElement.__super__.constructor.call(this, parent);
  4414. if (name == null) {
  4415. throw new Error("Missing element name");
  4416. }
  4417. this.name = this.stringify.eleName(name);
  4418. this.children = [];
  4419. this.instructions = [];
  4420. this.attributes = {};
  4421. if (attributes != null) {
  4422. this.attribute(attributes);
  4423. }
  4424. }
  4425. XMLElement.prototype.clone = function() {
  4426. var att, attName, clonedSelf, i, len, pi, ref, ref1;
  4427. clonedSelf = create(XMLElement.prototype, this);
  4428. if (clonedSelf.isRoot) {
  4429. clonedSelf.documentObject = null;
  4430. }
  4431. clonedSelf.attributes = {};
  4432. ref = this.attributes;
  4433. for (attName in ref) {
  4434. if (!hasProp.call(ref, attName)) continue;
  4435. att = ref[attName];
  4436. clonedSelf.attributes[attName] = att.clone();
  4437. }
  4438. clonedSelf.instructions = [];
  4439. ref1 = this.instructions;
  4440. for (i = 0, len = ref1.length; i < len; i++) {
  4441. pi = ref1[i];
  4442. clonedSelf.instructions.push(pi.clone());
  4443. }
  4444. clonedSelf.children = [];
  4445. this.children.forEach(function(child) {
  4446. var clonedChild;
  4447. clonedChild = child.clone();
  4448. clonedChild.parent = clonedSelf;
  4449. return clonedSelf.children.push(clonedChild);
  4450. });
  4451. return clonedSelf;
  4452. };
  4453. XMLElement.prototype.attribute = function(name, value) {
  4454. var attName, attValue;
  4455. if (name != null) {
  4456. name = name.valueOf();
  4457. }
  4458. if (isObject(name)) {
  4459. for (attName in name) {
  4460. if (!hasProp.call(name, attName)) continue;
  4461. attValue = name[attName];
  4462. this.attribute(attName, attValue);
  4463. }
  4464. } else {
  4465. if (isFunction(value)) {
  4466. value = value.apply();
  4467. }
  4468. if (!this.options.skipNullAttributes || (value != null)) {
  4469. this.attributes[name] = new XMLAttribute(this, name, value);
  4470. }
  4471. }
  4472. return this;
  4473. };
  4474. XMLElement.prototype.removeAttribute = function(name) {
  4475. var attName, i, len;
  4476. if (name == null) {
  4477. throw new Error("Missing attribute name");
  4478. }
  4479. name = name.valueOf();
  4480. if (Array.isArray(name)) {
  4481. for (i = 0, len = name.length; i < len; i++) {
  4482. attName = name[i];
  4483. delete this.attributes[attName];
  4484. }
  4485. } else {
  4486. delete this.attributes[name];
  4487. }
  4488. return this;
  4489. };
  4490. XMLElement.prototype.instruction = function(target, value) {
  4491. var i, insTarget, insValue, instruction, len;
  4492. if (target != null) {
  4493. target = target.valueOf();
  4494. }
  4495. if (value != null) {
  4496. value = value.valueOf();
  4497. }
  4498. if (Array.isArray(target)) {
  4499. for (i = 0, len = target.length; i < len; i++) {
  4500. insTarget = target[i];
  4501. this.instruction(insTarget);
  4502. }
  4503. } else if (isObject(target)) {
  4504. for (insTarget in target) {
  4505. if (!hasProp.call(target, insTarget)) continue;
  4506. insValue = target[insTarget];
  4507. this.instruction(insTarget, insValue);
  4508. }
  4509. } else {
  4510. if (isFunction(value)) {
  4511. value = value.apply();
  4512. }
  4513. instruction = new XMLProcessingInstruction(this, target, value);
  4514. this.instructions.push(instruction);
  4515. }
  4516. return this;
  4517. };
  4518. XMLElement.prototype.toString = function(options, level) {
  4519. var att, child, i, indent, instruction, j, len, len1, name, newline, offset, pretty, r, ref, ref1, ref2, ref3, ref4, ref5, space;
  4520. pretty = (options != null ? options.pretty : void 0) || false;
  4521. indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' ';
  4522. offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0;
  4523. newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n';
  4524. level || (level = 0);
  4525. space = new Array(level + offset + 1).join(indent);
  4526. r = '';
  4527. ref3 = this.instructions;
  4528. for (i = 0, len = ref3.length; i < len; i++) {
  4529. instruction = ref3[i];
  4530. r += instruction.toString(options, level);
  4531. }
  4532. if (pretty) {
  4533. r += space;
  4534. }
  4535. r += '<' + this.name;
  4536. ref4 = this.attributes;
  4537. for (name in ref4) {
  4538. if (!hasProp.call(ref4, name)) continue;
  4539. att = ref4[name];
  4540. r += att.toString(options);
  4541. }
  4542. if (this.children.length === 0 || every(this.children, function(e) {
  4543. return e.value === '';
  4544. })) {
  4545. r += '/>';
  4546. if (pretty) {
  4547. r += newline;
  4548. }
  4549. } else if (pretty && this.children.length === 1 && (this.children[0].value != null)) {
  4550. r += '>';
  4551. r += this.children[0].value;
  4552. r += '</' + this.name + '>';
  4553. r += newline;
  4554. } else {
  4555. r += '>';
  4556. if (pretty) {
  4557. r += newline;
  4558. }
  4559. ref5 = this.children;
  4560. for (j = 0, len1 = ref5.length; j < len1; j++) {
  4561. child = ref5[j];
  4562. r += child.toString(options, level + 1);
  4563. }
  4564. if (pretty) {
  4565. r += space;
  4566. }
  4567. r += '</' + this.name + '>';
  4568. if (pretty) {
  4569. r += newline;
  4570. }
  4571. }
  4572. return r;
  4573. };
  4574. XMLElement.prototype.att = function(name, value) {
  4575. return this.attribute(name, value);
  4576. };
  4577. XMLElement.prototype.ins = function(target, value) {
  4578. return this.instruction(target, value);
  4579. };
  4580. XMLElement.prototype.a = function(name, value) {
  4581. return this.attribute(name, value);
  4582. };
  4583. XMLElement.prototype.i = function(target, value) {
  4584. return this.instruction(target, value);
  4585. };
  4586. return XMLElement;
  4587. })(XMLNode);
  4588. }).call(this);
  4589. },{"./XMLAttribute":71,"./XMLNode":82,"./XMLProcessingInstruction":83,"lodash/collection/every":12,"lodash/lang/isFunction":58,"lodash/lang/isObject":60,"lodash/object/create":64}],82:[function(require,module,exports){
  4590. // Generated by CoffeeScript 1.9.1
  4591. (function() {
  4592. var XMLCData, XMLComment, XMLDeclaration, XMLDocType, XMLElement, XMLNode, XMLRaw, XMLText, isEmpty, isFunction, isObject,
  4593. hasProp = {}.hasOwnProperty;
  4594. isObject = require('lodash/lang/isObject');
  4595. isFunction = require('lodash/lang/isFunction');
  4596. isEmpty = require('lodash/lang/isEmpty');
  4597. XMLElement = null;
  4598. XMLCData = null;
  4599. XMLComment = null;
  4600. XMLDeclaration = null;
  4601. XMLDocType = null;
  4602. XMLRaw = null;
  4603. XMLText = null;
  4604. module.exports = XMLNode = (function() {
  4605. function XMLNode(parent) {
  4606. this.parent = parent;
  4607. this.options = this.parent.options;
  4608. this.stringify = this.parent.stringify;
  4609. if (XMLElement === null) {
  4610. XMLElement = require('./XMLElement');
  4611. XMLCData = require('./XMLCData');
  4612. XMLComment = require('./XMLComment');
  4613. XMLDeclaration = require('./XMLDeclaration');
  4614. XMLDocType = require('./XMLDocType');
  4615. XMLRaw = require('./XMLRaw');
  4616. XMLText = require('./XMLText');
  4617. }
  4618. }
  4619. XMLNode.prototype.element = function(name, attributes, text) {
  4620. var childNode, item, j, k, key, lastChild, len, len1, ref, val;
  4621. lastChild = null;
  4622. if (attributes == null) {
  4623. attributes = {};
  4624. }
  4625. attributes = attributes.valueOf();
  4626. if (!isObject(attributes)) {
  4627. ref = [attributes, text], text = ref[0], attributes = ref[1];
  4628. }
  4629. if (name != null) {
  4630. name = name.valueOf();
  4631. }
  4632. if (Array.isArray(name)) {
  4633. for (j = 0, len = name.length; j < len; j++) {
  4634. item = name[j];
  4635. lastChild = this.element(item);
  4636. }
  4637. } else if (isFunction(name)) {
  4638. lastChild = this.element(name.apply());
  4639. } else if (isObject(name)) {
  4640. for (key in name) {
  4641. if (!hasProp.call(name, key)) continue;
  4642. val = name[key];
  4643. if (isFunction(val)) {
  4644. val = val.apply();
  4645. }
  4646. if ((isObject(val)) && (isEmpty(val))) {
  4647. val = null;
  4648. }
  4649. if (!this.options.ignoreDecorators && this.stringify.convertAttKey && key.indexOf(this.stringify.convertAttKey) === 0) {
  4650. lastChild = this.attribute(key.substr(this.stringify.convertAttKey.length), val);
  4651. } else if (!this.options.ignoreDecorators && this.stringify.convertPIKey && key.indexOf(this.stringify.convertPIKey) === 0) {
  4652. lastChild = this.instruction(key.substr(this.stringify.convertPIKey.length), val);
  4653. } else if (Array.isArray(val)) {
  4654. for (k = 0, len1 = val.length; k < len1; k++) {
  4655. item = val[k];
  4656. childNode = {};
  4657. childNode[key] = item;
  4658. lastChild = this.element(childNode);
  4659. }
  4660. } else if (isObject(val)) {
  4661. lastChild = this.element(key);
  4662. lastChild.element(val);
  4663. } else {
  4664. lastChild = this.element(key, val);
  4665. }
  4666. }
  4667. } else {
  4668. if (!this.options.ignoreDecorators && this.stringify.convertTextKey && name.indexOf(this.stringify.convertTextKey) === 0) {
  4669. lastChild = this.text(text);
  4670. } else if (!this.options.ignoreDecorators && this.stringify.convertCDataKey && name.indexOf(this.stringify.convertCDataKey) === 0) {
  4671. lastChild = this.cdata(text);
  4672. } else if (!this.options.ignoreDecorators && this.stringify.convertCommentKey && name.indexOf(this.stringify.convertCommentKey) === 0) {
  4673. lastChild = this.comment(text);
  4674. } else if (!this.options.ignoreDecorators && this.stringify.convertRawKey && name.indexOf(this.stringify.convertRawKey) === 0) {
  4675. lastChild = this.raw(text);
  4676. } else {
  4677. lastChild = this.node(name, attributes, text);
  4678. }
  4679. }
  4680. if (lastChild == null) {
  4681. throw new Error("Could not create any elements with: " + name);
  4682. }
  4683. return lastChild;
  4684. };
  4685. XMLNode.prototype.insertBefore = function(name, attributes, text) {
  4686. var child, i, removed;
  4687. if (this.isRoot) {
  4688. throw new Error("Cannot insert elements at root level");
  4689. }
  4690. i = this.parent.children.indexOf(this);
  4691. removed = this.parent.children.splice(i);
  4692. child = this.parent.element(name, attributes, text);
  4693. Array.prototype.push.apply(this.parent.children, removed);
  4694. return child;
  4695. };
  4696. XMLNode.prototype.insertAfter = function(name, attributes, text) {
  4697. var child, i, removed;
  4698. if (this.isRoot) {
  4699. throw new Error("Cannot insert elements at root level");
  4700. }
  4701. i = this.parent.children.indexOf(this);
  4702. removed = this.parent.children.splice(i + 1);
  4703. child = this.parent.element(name, attributes, text);
  4704. Array.prototype.push.apply(this.parent.children, removed);
  4705. return child;
  4706. };
  4707. XMLNode.prototype.remove = function() {
  4708. var i, ref;
  4709. if (this.isRoot) {
  4710. throw new Error("Cannot remove the root element");
  4711. }
  4712. i = this.parent.children.indexOf(this);
  4713. [].splice.apply(this.parent.children, [i, i - i + 1].concat(ref = [])), ref;
  4714. return this.parent;
  4715. };
  4716. XMLNode.prototype.node = function(name, attributes, text) {
  4717. var child, ref;
  4718. if (name != null) {
  4719. name = name.valueOf();
  4720. }
  4721. if (attributes == null) {
  4722. attributes = {};
  4723. }
  4724. attributes = attributes.valueOf();
  4725. if (!isObject(attributes)) {
  4726. ref = [attributes, text], text = ref[0], attributes = ref[1];
  4727. }
  4728. child = new XMLElement(this, name, attributes);
  4729. if (text != null) {
  4730. child.text(text);
  4731. }
  4732. this.children.push(child);
  4733. return child;
  4734. };
  4735. XMLNode.prototype.text = function(value) {
  4736. var child;
  4737. child = new XMLText(this, value);
  4738. this.children.push(child);
  4739. return this;
  4740. };
  4741. XMLNode.prototype.cdata = function(value) {
  4742. var child;
  4743. child = new XMLCData(this, value);
  4744. this.children.push(child);
  4745. return this;
  4746. };
  4747. XMLNode.prototype.comment = function(value) {
  4748. var child;
  4749. child = new XMLComment(this, value);
  4750. this.children.push(child);
  4751. return this;
  4752. };
  4753. XMLNode.prototype.raw = function(value) {
  4754. var child;
  4755. child = new XMLRaw(this, value);
  4756. this.children.push(child);
  4757. return this;
  4758. };
  4759. XMLNode.prototype.declaration = function(version, encoding, standalone) {
  4760. var doc, xmldec;
  4761. doc = this.document();
  4762. xmldec = new XMLDeclaration(doc, version, encoding, standalone);
  4763. doc.xmldec = xmldec;
  4764. return doc.root();
  4765. };
  4766. XMLNode.prototype.doctype = function(pubID, sysID) {
  4767. var doc, doctype;
  4768. doc = this.document();
  4769. doctype = new XMLDocType(doc, pubID, sysID);
  4770. doc.doctype = doctype;
  4771. return doctype;
  4772. };
  4773. XMLNode.prototype.up = function() {
  4774. if (this.isRoot) {
  4775. throw new Error("The root node has no parent. Use doc() if you need to get the document object.");
  4776. }
  4777. return this.parent;
  4778. };
  4779. XMLNode.prototype.root = function() {
  4780. var child;
  4781. if (this.isRoot) {
  4782. return this;
  4783. }
  4784. child = this.parent;
  4785. while (!child.isRoot) {
  4786. child = child.parent;
  4787. }
  4788. return child;
  4789. };
  4790. XMLNode.prototype.document = function() {
  4791. return this.root().documentObject;
  4792. };
  4793. XMLNode.prototype.end = function(options) {
  4794. return this.document().toString(options);
  4795. };
  4796. XMLNode.prototype.prev = function() {
  4797. var i;
  4798. if (this.isRoot) {
  4799. throw new Error("Root node has no siblings");
  4800. }
  4801. i = this.parent.children.indexOf(this);
  4802. if (i < 1) {
  4803. throw new Error("Already at the first node");
  4804. }
  4805. return this.parent.children[i - 1];
  4806. };
  4807. XMLNode.prototype.next = function() {
  4808. var i;
  4809. if (this.isRoot) {
  4810. throw new Error("Root node has no siblings");
  4811. }
  4812. i = this.parent.children.indexOf(this);
  4813. if (i === -1 || i === this.parent.children.length - 1) {
  4814. throw new Error("Already at the last node");
  4815. }
  4816. return this.parent.children[i + 1];
  4817. };
  4818. XMLNode.prototype.importXMLBuilder = function(xmlbuilder) {
  4819. var clonedRoot;
  4820. clonedRoot = xmlbuilder.root().clone();
  4821. clonedRoot.parent = this;
  4822. clonedRoot.isRoot = false;
  4823. this.children.push(clonedRoot);
  4824. return this;
  4825. };
  4826. XMLNode.prototype.ele = function(name, attributes, text) {
  4827. return this.element(name, attributes, text);
  4828. };
  4829. XMLNode.prototype.nod = function(name, attributes, text) {
  4830. return this.node(name, attributes, text);
  4831. };
  4832. XMLNode.prototype.txt = function(value) {
  4833. return this.text(value);
  4834. };
  4835. XMLNode.prototype.dat = function(value) {
  4836. return this.cdata(value);
  4837. };
  4838. XMLNode.prototype.com = function(value) {
  4839. return this.comment(value);
  4840. };
  4841. XMLNode.prototype.doc = function() {
  4842. return this.document();
  4843. };
  4844. XMLNode.prototype.dec = function(version, encoding, standalone) {
  4845. return this.declaration(version, encoding, standalone);
  4846. };
  4847. XMLNode.prototype.dtd = function(pubID, sysID) {
  4848. return this.doctype(pubID, sysID);
  4849. };
  4850. XMLNode.prototype.e = function(name, attributes, text) {
  4851. return this.element(name, attributes, text);
  4852. };
  4853. XMLNode.prototype.n = function(name, attributes, text) {
  4854. return this.node(name, attributes, text);
  4855. };
  4856. XMLNode.prototype.t = function(value) {
  4857. return this.text(value);
  4858. };
  4859. XMLNode.prototype.d = function(value) {
  4860. return this.cdata(value);
  4861. };
  4862. XMLNode.prototype.c = function(value) {
  4863. return this.comment(value);
  4864. };
  4865. XMLNode.prototype.r = function(value) {
  4866. return this.raw(value);
  4867. };
  4868. XMLNode.prototype.u = function() {
  4869. return this.up();
  4870. };
  4871. return XMLNode;
  4872. })();
  4873. }).call(this);
  4874. },{"./XMLCData":73,"./XMLComment":74,"./XMLDeclaration":79,"./XMLDocType":80,"./XMLElement":81,"./XMLRaw":84,"./XMLText":86,"lodash/lang/isEmpty":57,"lodash/lang/isFunction":58,"lodash/lang/isObject":60}],83:[function(require,module,exports){
  4875. // Generated by CoffeeScript 1.9.1
  4876. (function() {
  4877. var XMLProcessingInstruction, create;
  4878. create = require('lodash/object/create');
  4879. module.exports = XMLProcessingInstruction = (function() {
  4880. function XMLProcessingInstruction(parent, target, value) {
  4881. this.stringify = parent.stringify;
  4882. if (target == null) {
  4883. throw new Error("Missing instruction target");
  4884. }
  4885. this.target = this.stringify.insTarget(target);
  4886. if (value) {
  4887. this.value = this.stringify.insValue(value);
  4888. }
  4889. }
  4890. XMLProcessingInstruction.prototype.clone = function() {
  4891. return create(XMLProcessingInstruction.prototype, this);
  4892. };
  4893. XMLProcessingInstruction.prototype.toString = function(options, level) {
  4894. var indent, newline, offset, pretty, r, ref, ref1, ref2, space;
  4895. pretty = (options != null ? options.pretty : void 0) || false;
  4896. indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' ';
  4897. offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0;
  4898. newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n';
  4899. level || (level = 0);
  4900. space = new Array(level + offset + 1).join(indent);
  4901. r = '';
  4902. if (pretty) {
  4903. r += space;
  4904. }
  4905. r += '<?';
  4906. r += this.target;
  4907. if (this.value) {
  4908. r += ' ' + this.value;
  4909. }
  4910. r += '?>';
  4911. if (pretty) {
  4912. r += newline;
  4913. }
  4914. return r;
  4915. };
  4916. return XMLProcessingInstruction;
  4917. })();
  4918. }).call(this);
  4919. },{"lodash/object/create":64}],84:[function(require,module,exports){
  4920. // Generated by CoffeeScript 1.9.1
  4921. (function() {
  4922. var XMLNode, XMLRaw, create,
  4923. extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  4924. hasProp = {}.hasOwnProperty;
  4925. create = require('lodash/object/create');
  4926. XMLNode = require('./XMLNode');
  4927. module.exports = XMLRaw = (function(superClass) {
  4928. extend(XMLRaw, superClass);
  4929. function XMLRaw(parent, text) {
  4930. XMLRaw.__super__.constructor.call(this, parent);
  4931. if (text == null) {
  4932. throw new Error("Missing raw text");
  4933. }
  4934. this.value = this.stringify.raw(text);
  4935. }
  4936. XMLRaw.prototype.clone = function() {
  4937. return create(XMLRaw.prototype, this);
  4938. };
  4939. XMLRaw.prototype.toString = function(options, level) {
  4940. var indent, newline, offset, pretty, r, ref, ref1, ref2, space;
  4941. pretty = (options != null ? options.pretty : void 0) || false;
  4942. indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' ';
  4943. offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0;
  4944. newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n';
  4945. level || (level = 0);
  4946. space = new Array(level + offset + 1).join(indent);
  4947. r = '';
  4948. if (pretty) {
  4949. r += space;
  4950. }
  4951. r += this.value;
  4952. if (pretty) {
  4953. r += newline;
  4954. }
  4955. return r;
  4956. };
  4957. return XMLRaw;
  4958. })(XMLNode);
  4959. }).call(this);
  4960. },{"./XMLNode":82,"lodash/object/create":64}],85:[function(require,module,exports){
  4961. // Generated by CoffeeScript 1.9.1
  4962. (function() {
  4963. var XMLStringifier,
  4964. bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
  4965. hasProp = {}.hasOwnProperty;
  4966. module.exports = XMLStringifier = (function() {
  4967. function XMLStringifier(options) {
  4968. this.assertLegalChar = bind(this.assertLegalChar, this);
  4969. var key, ref, value;
  4970. this.allowSurrogateChars = options != null ? options.allowSurrogateChars : void 0;
  4971. ref = (options != null ? options.stringify : void 0) || {};
  4972. for (key in ref) {
  4973. if (!hasProp.call(ref, key)) continue;
  4974. value = ref[key];
  4975. this[key] = value;
  4976. }
  4977. }
  4978. XMLStringifier.prototype.eleName = function(val) {
  4979. val = '' + val || '';
  4980. return this.assertLegalChar(val);
  4981. };
  4982. XMLStringifier.prototype.eleText = function(val) {
  4983. val = '' + val || '';
  4984. return this.assertLegalChar(this.elEscape(val));
  4985. };
  4986. XMLStringifier.prototype.cdata = function(val) {
  4987. val = '' + val || '';
  4988. if (val.match(/]]>/)) {
  4989. throw new Error("Invalid CDATA text: " + val);
  4990. }
  4991. return this.assertLegalChar(val);
  4992. };
  4993. XMLStringifier.prototype.comment = function(val) {
  4994. val = '' + val || '';
  4995. if (val.match(/--/)) {
  4996. throw new Error("Comment text cannot contain double-hypen: " + val);
  4997. }
  4998. return this.assertLegalChar(val);
  4999. };
  5000. XMLStringifier.prototype.raw = function(val) {
  5001. return '' + val || '';
  5002. };
  5003. XMLStringifier.prototype.attName = function(val) {
  5004. return '' + val || '';
  5005. };
  5006. XMLStringifier.prototype.attValue = function(val) {
  5007. val = '' + val || '';
  5008. return this.attEscape(val);
  5009. };
  5010. XMLStringifier.prototype.insTarget = function(val) {
  5011. return '' + val || '';
  5012. };
  5013. XMLStringifier.prototype.insValue = function(val) {
  5014. val = '' + val || '';
  5015. if (val.match(/\?>/)) {
  5016. throw new Error("Invalid processing instruction value: " + val);
  5017. }
  5018. return val;
  5019. };
  5020. XMLStringifier.prototype.xmlVersion = function(val) {
  5021. val = '' + val || '';
  5022. if (!val.match(/1\.[0-9]+/)) {
  5023. throw new Error("Invalid version number: " + val);
  5024. }
  5025. return val;
  5026. };
  5027. XMLStringifier.prototype.xmlEncoding = function(val) {
  5028. val = '' + val || '';
  5029. if (!val.match(/^[A-Za-z](?:[A-Za-z0-9._-]|-)*$/)) {
  5030. throw new Error("Invalid encoding: " + val);
  5031. }
  5032. return val;
  5033. };
  5034. XMLStringifier.prototype.xmlStandalone = function(val) {
  5035. if (val) {
  5036. return "yes";
  5037. } else {
  5038. return "no";
  5039. }
  5040. };
  5041. XMLStringifier.prototype.dtdPubID = function(val) {
  5042. return '' + val || '';
  5043. };
  5044. XMLStringifier.prototype.dtdSysID = function(val) {
  5045. return '' + val || '';
  5046. };
  5047. XMLStringifier.prototype.dtdElementValue = function(val) {
  5048. return '' + val || '';
  5049. };
  5050. XMLStringifier.prototype.dtdAttType = function(val) {
  5051. return '' + val || '';
  5052. };
  5053. XMLStringifier.prototype.dtdAttDefault = function(val) {
  5054. if (val != null) {
  5055. return '' + val || '';
  5056. } else {
  5057. return val;
  5058. }
  5059. };
  5060. XMLStringifier.prototype.dtdEntityValue = function(val) {
  5061. return '' + val || '';
  5062. };
  5063. XMLStringifier.prototype.dtdNData = function(val) {
  5064. return '' + val || '';
  5065. };
  5066. XMLStringifier.prototype.convertAttKey = '@';
  5067. XMLStringifier.prototype.convertPIKey = '?';
  5068. XMLStringifier.prototype.convertTextKey = '#text';
  5069. XMLStringifier.prototype.convertCDataKey = '#cdata';
  5070. XMLStringifier.prototype.convertCommentKey = '#comment';
  5071. XMLStringifier.prototype.convertRawKey = '#raw';
  5072. XMLStringifier.prototype.assertLegalChar = function(str) {
  5073. var chars, chr;
  5074. if (this.allowSurrogateChars) {
  5075. chars = /[\u0000-\u0008\u000B-\u000C\u000E-\u001F\uFFFE-\uFFFF]/;
  5076. } else {
  5077. chars = /[\u0000-\u0008\u000B-\u000C\u000E-\u001F\uD800-\uDFFF\uFFFE-\uFFFF]/;
  5078. }
  5079. chr = str.match(chars);
  5080. if (chr) {
  5081. throw new Error("Invalid character (" + chr + ") in string: " + str + " at index " + chr.index);
  5082. }
  5083. return str;
  5084. };
  5085. XMLStringifier.prototype.elEscape = function(str) {
  5086. return str.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\r/g, '&#xD;');
  5087. };
  5088. XMLStringifier.prototype.attEscape = function(str) {
  5089. return str.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/"/g, '&quot;');
  5090. };
  5091. return XMLStringifier;
  5092. })();
  5093. }).call(this);
  5094. },{}],86:[function(require,module,exports){
  5095. // Generated by CoffeeScript 1.9.1
  5096. (function() {
  5097. var XMLNode, XMLText, create,
  5098. extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  5099. hasProp = {}.hasOwnProperty;
  5100. create = require('lodash/object/create');
  5101. XMLNode = require('./XMLNode');
  5102. module.exports = XMLText = (function(superClass) {
  5103. extend(XMLText, superClass);
  5104. function XMLText(parent, text) {
  5105. XMLText.__super__.constructor.call(this, parent);
  5106. if (text == null) {
  5107. throw new Error("Missing element text");
  5108. }
  5109. this.value = this.stringify.eleText(text);
  5110. }
  5111. XMLText.prototype.clone = function() {
  5112. return create(XMLText.prototype, this);
  5113. };
  5114. XMLText.prototype.toString = function(options, level) {
  5115. var indent, newline, offset, pretty, r, ref, ref1, ref2, space;
  5116. pretty = (options != null ? options.pretty : void 0) || false;
  5117. indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' ';
  5118. offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0;
  5119. newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n';
  5120. level || (level = 0);
  5121. space = new Array(level + offset + 1).join(indent);
  5122. r = '';
  5123. if (pretty) {
  5124. r += space;
  5125. }
  5126. r += this.value;
  5127. if (pretty) {
  5128. r += newline;
  5129. }
  5130. return r;
  5131. };
  5132. return XMLText;
  5133. })(XMLNode);
  5134. }).call(this);
  5135. },{"./XMLNode":82,"lodash/object/create":64}],87:[function(require,module,exports){
  5136. // Generated by CoffeeScript 1.9.1
  5137. (function() {
  5138. var XMLBuilder, assign;
  5139. assign = require('lodash/object/assign');
  5140. XMLBuilder = require('./XMLBuilder');
  5141. module.exports.create = function(name, xmldec, doctype, options) {
  5142. options = assign({}, xmldec, doctype, options);
  5143. return new XMLBuilder(name, options).root();
  5144. };
  5145. }).call(this);
  5146. },{"./XMLBuilder":72,"lodash/object/assign":63}],88:[function(require,module,exports){
  5147. function DOMParser(options){
  5148. this.options = options ||{locator:{}};
  5149. }
  5150. DOMParser.prototype.parseFromString = function(source,mimeType){
  5151. var options = this.options;
  5152. var sax = new XMLReader();
  5153. var domBuilder = options.domBuilder || new DOMHandler();//contentHandler and LexicalHandler
  5154. var errorHandler = options.errorHandler;
  5155. var locator = options.locator;
  5156. var defaultNSMap = options.xmlns||{};
  5157. var entityMap = {'lt':'<','gt':'>','amp':'&','quot':'"','apos':"'"}
  5158. if(locator){
  5159. domBuilder.setDocumentLocator(locator)
  5160. }
  5161. sax.errorHandler = buildErrorHandler(errorHandler,domBuilder,locator);
  5162. sax.domBuilder = options.domBuilder || domBuilder;
  5163. if(/\/x?html?$/.test(mimeType)){
  5164. entityMap.nbsp = '\xa0';
  5165. entityMap.copy = '\xa9';
  5166. defaultNSMap['']= 'http://www.w3.org/1999/xhtml';
  5167. }
  5168. if(source){
  5169. sax.parse(source,defaultNSMap,entityMap);
  5170. }else{
  5171. sax.errorHandler.error("invalid document source");
  5172. }
  5173. return domBuilder.document;
  5174. }
  5175. function buildErrorHandler(errorImpl,domBuilder,locator){
  5176. if(!errorImpl){
  5177. if(domBuilder instanceof DOMHandler){
  5178. return domBuilder;
  5179. }
  5180. errorImpl = domBuilder ;
  5181. }
  5182. var errorHandler = {}
  5183. var isCallback = errorImpl instanceof Function;
  5184. locator = locator||{}
  5185. function build(key){
  5186. var fn = errorImpl[key];
  5187. if(!fn){
  5188. if(isCallback){
  5189. fn = errorImpl.length == 2?function(msg){errorImpl(key,msg)}:errorImpl;
  5190. }else{
  5191. var i=arguments.length;
  5192. while(--i){
  5193. if(fn = errorImpl[arguments[i]]){
  5194. break;
  5195. }
  5196. }
  5197. }
  5198. }
  5199. errorHandler[key] = fn && function(msg){
  5200. fn(msg+_locator(locator));
  5201. }||function(){};
  5202. }
  5203. build('warning','warn');
  5204. build('error','warn','warning');
  5205. build('fatalError','warn','warning','error');
  5206. return errorHandler;
  5207. }
  5208. /**
  5209. * +ContentHandler+ErrorHandler
  5210. * +LexicalHandler+EntityResolver2
  5211. * -DeclHandler-DTDHandler
  5212. *
  5213. * DefaultHandler:EntityResolver, DTDHandler, ContentHandler, ErrorHandler
  5214. * DefaultHandler2:DefaultHandler,LexicalHandler, DeclHandler, EntityResolver2
  5215. * @link http://www.saxproject.org/apidoc/org/xml/sax/helpers/DefaultHandler.html
  5216. */
  5217. function DOMHandler() {
  5218. this.cdata = false;
  5219. }
  5220. function position(locator,node){
  5221. node.lineNumber = locator.lineNumber;
  5222. node.columnNumber = locator.columnNumber;
  5223. }
  5224. /**
  5225. * @see org.xml.sax.ContentHandler#startDocument
  5226. * @link http://www.saxproject.org/apidoc/org/xml/sax/ContentHandler.html
  5227. */
  5228. DOMHandler.prototype = {
  5229. startDocument : function() {
  5230. this.document = new DOMImplementation().createDocument(null, null, null);
  5231. if (this.locator) {
  5232. this.document.documentURI = this.locator.systemId;
  5233. }
  5234. },
  5235. startElement:function(namespaceURI, localName, qName, attrs) {
  5236. var doc = this.document;
  5237. var el = doc.createElementNS(namespaceURI, qName||localName);
  5238. var len = attrs.length;
  5239. appendElement(this, el);
  5240. this.currentElement = el;
  5241. this.locator && position(this.locator,el)
  5242. for (var i = 0 ; i < len; i++) {
  5243. var namespaceURI = attrs.getURI(i);
  5244. var value = attrs.getValue(i);
  5245. var qName = attrs.getQName(i);
  5246. var attr = doc.createAttributeNS(namespaceURI, qName);
  5247. if( attr.getOffset){
  5248. position(attr.getOffset(1),attr)
  5249. }
  5250. attr.value = attr.nodeValue = value;
  5251. el.setAttributeNode(attr)
  5252. }
  5253. },
  5254. endElement:function(namespaceURI, localName, qName) {
  5255. var current = this.currentElement
  5256. var tagName = current.tagName;
  5257. this.currentElement = current.parentNode;
  5258. },
  5259. startPrefixMapping:function(prefix, uri) {
  5260. },
  5261. endPrefixMapping:function(prefix) {
  5262. },
  5263. processingInstruction:function(target, data) {
  5264. var ins = this.document.createProcessingInstruction(target, data);
  5265. this.locator && position(this.locator,ins)
  5266. appendElement(this, ins);
  5267. },
  5268. ignorableWhitespace:function(ch, start, length) {
  5269. },
  5270. characters:function(chars, start, length) {
  5271. chars = _toString.apply(this,arguments)
  5272. //console.log(chars)
  5273. if(this.currentElement && chars){
  5274. if (this.cdata) {
  5275. var charNode = this.document.createCDATASection(chars);
  5276. this.currentElement.appendChild(charNode);
  5277. } else {
  5278. var charNode = this.document.createTextNode(chars);
  5279. this.currentElement.appendChild(charNode);
  5280. }
  5281. this.locator && position(this.locator,charNode)
  5282. }
  5283. },
  5284. skippedEntity:function(name) {
  5285. },
  5286. endDocument:function() {
  5287. this.document.normalize();
  5288. },
  5289. setDocumentLocator:function (locator) {
  5290. if(this.locator = locator){// && !('lineNumber' in locator)){
  5291. locator.lineNumber = 0;
  5292. }
  5293. },
  5294. //LexicalHandler
  5295. comment:function(chars, start, length) {
  5296. chars = _toString.apply(this,arguments)
  5297. var comm = this.document.createComment(chars);
  5298. this.locator && position(this.locator,comm)
  5299. appendElement(this, comm);
  5300. },
  5301. startCDATA:function() {
  5302. //used in characters() methods
  5303. this.cdata = true;
  5304. },
  5305. endCDATA:function() {
  5306. this.cdata = false;
  5307. },
  5308. startDTD:function(name, publicId, systemId) {
  5309. var impl = this.document.implementation;
  5310. if (impl && impl.createDocumentType) {
  5311. var dt = impl.createDocumentType(name, publicId, systemId);
  5312. this.locator && position(this.locator,dt)
  5313. appendElement(this, dt);
  5314. }
  5315. },
  5316. /**
  5317. * @see org.xml.sax.ErrorHandler
  5318. * @link http://www.saxproject.org/apidoc/org/xml/sax/ErrorHandler.html
  5319. */
  5320. warning:function(error) {
  5321. console.warn(error,_locator(this.locator));
  5322. },
  5323. error:function(error) {
  5324. console.error(error,_locator(this.locator));
  5325. },
  5326. fatalError:function(error) {
  5327. console.error(error,_locator(this.locator));
  5328. throw error;
  5329. }
  5330. }
  5331. function _locator(l){
  5332. if(l){
  5333. return '\n@'+(l.systemId ||'')+'#[line:'+l.lineNumber+',col:'+l.columnNumber+']'
  5334. }
  5335. }
  5336. function _toString(chars,start,length){
  5337. if(typeof chars == 'string'){
  5338. return chars.substr(start,length)
  5339. }else{//java sax connect width xmldom on rhino(what about: "? && !(chars instanceof String)")
  5340. if(chars.length >= start+length || start){
  5341. return new java.lang.String(chars,start,length)+'';
  5342. }
  5343. return chars;
  5344. }
  5345. }
  5346. /*
  5347. * @link http://www.saxproject.org/apidoc/org/xml/sax/ext/LexicalHandler.html
  5348. * used method of org.xml.sax.ext.LexicalHandler:
  5349. * #comment(chars, start, length)
  5350. * #startCDATA()
  5351. * #endCDATA()
  5352. * #startDTD(name, publicId, systemId)
  5353. *
  5354. *
  5355. * IGNORED method of org.xml.sax.ext.LexicalHandler:
  5356. * #endDTD()
  5357. * #startEntity(name)
  5358. * #endEntity(name)
  5359. *
  5360. *
  5361. * @link http://www.saxproject.org/apidoc/org/xml/sax/ext/DeclHandler.html
  5362. * IGNORED method of org.xml.sax.ext.DeclHandler
  5363. * #attributeDecl(eName, aName, type, mode, value)
  5364. * #elementDecl(name, model)
  5365. * #externalEntityDecl(name, publicId, systemId)
  5366. * #internalEntityDecl(name, value)
  5367. * @link http://www.saxproject.org/apidoc/org/xml/sax/ext/EntityResolver2.html
  5368. * IGNORED method of org.xml.sax.EntityResolver2
  5369. * #resolveEntity(String name,String publicId,String baseURI,String systemId)
  5370. * #resolveEntity(publicId, systemId)
  5371. * #getExternalSubset(name, baseURI)
  5372. * @link http://www.saxproject.org/apidoc/org/xml/sax/DTDHandler.html
  5373. * IGNORED method of org.xml.sax.DTDHandler
  5374. * #notationDecl(name, publicId, systemId) {};
  5375. * #unparsedEntityDecl(name, publicId, systemId, notationName) {};
  5376. */
  5377. "endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g,function(key){
  5378. DOMHandler.prototype[key] = function(){return null}
  5379. })
  5380. /* Private static helpers treated below as private instance methods, so don't need to add these to the public API; we might use a Relator to also get rid of non-standard public properties */
  5381. function appendElement (hander,node) {
  5382. if (!hander.currentElement) {
  5383. hander.document.appendChild(node);
  5384. } else {
  5385. hander.currentElement.appendChild(node);
  5386. }
  5387. }//appendChild and setAttributeNS are preformance key
  5388. if(typeof require == 'function'){
  5389. var XMLReader = require('./sax').XMLReader;
  5390. var DOMImplementation = exports.DOMImplementation = require('./dom').DOMImplementation;
  5391. exports.XMLSerializer = require('./dom').XMLSerializer ;
  5392. exports.DOMParser = DOMParser;
  5393. }
  5394. },{"./dom":89,"./sax":90}],89:[function(require,module,exports){
  5395. /*
  5396. * DOM Level 2
  5397. * Object DOMException
  5398. * @see http://www.w3.org/TR/REC-DOM-Level-1/ecma-script-language-binding.html
  5399. * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/ecma-script-binding.html
  5400. */
  5401. function copy(src,dest){
  5402. for(var p in src){
  5403. dest[p] = src[p];
  5404. }
  5405. }
  5406. /**
  5407. ^\w+\.prototype\.([_\w]+)\s*=\s*((?:.*\{\s*?[\r\n][\s\S]*?^})|\S.*?(?=[;\r\n]));?
  5408. ^\w+\.prototype\.([_\w]+)\s*=\s*(\S.*?(?=[;\r\n]));?
  5409. */
  5410. function _extends(Class,Super){
  5411. var pt = Class.prototype;
  5412. if(Object.create){
  5413. var ppt = Object.create(Super.prototype)
  5414. pt.__proto__ = ppt;
  5415. }
  5416. if(!(pt instanceof Super)){
  5417. function t(){};
  5418. t.prototype = Super.prototype;
  5419. t = new t();
  5420. copy(pt,t);
  5421. Class.prototype = pt = t;
  5422. }
  5423. if(pt.constructor != Class){
  5424. if(typeof Class != 'function'){
  5425. console.error("unknow Class:"+Class)
  5426. }
  5427. pt.constructor = Class
  5428. }
  5429. }
  5430. var htmlns = 'http://www.w3.org/1999/xhtml' ;
  5431. // Node Types
  5432. var NodeType = {}
  5433. var ELEMENT_NODE = NodeType.ELEMENT_NODE = 1;
  5434. var ATTRIBUTE_NODE = NodeType.ATTRIBUTE_NODE = 2;
  5435. var TEXT_NODE = NodeType.TEXT_NODE = 3;
  5436. var CDATA_SECTION_NODE = NodeType.CDATA_SECTION_NODE = 4;
  5437. var ENTITY_REFERENCE_NODE = NodeType.ENTITY_REFERENCE_NODE = 5;
  5438. var ENTITY_NODE = NodeType.ENTITY_NODE = 6;
  5439. var PROCESSING_INSTRUCTION_NODE = NodeType.PROCESSING_INSTRUCTION_NODE = 7;
  5440. var COMMENT_NODE = NodeType.COMMENT_NODE = 8;
  5441. var DOCUMENT_NODE = NodeType.DOCUMENT_NODE = 9;
  5442. var DOCUMENT_TYPE_NODE = NodeType.DOCUMENT_TYPE_NODE = 10;
  5443. var DOCUMENT_FRAGMENT_NODE = NodeType.DOCUMENT_FRAGMENT_NODE = 11;
  5444. var NOTATION_NODE = NodeType.NOTATION_NODE = 12;
  5445. // ExceptionCode
  5446. var ExceptionCode = {}
  5447. var ExceptionMessage = {};
  5448. var INDEX_SIZE_ERR = ExceptionCode.INDEX_SIZE_ERR = ((ExceptionMessage[1]="Index size error"),1);
  5449. var DOMSTRING_SIZE_ERR = ExceptionCode.DOMSTRING_SIZE_ERR = ((ExceptionMessage[2]="DOMString size error"),2);
  5450. var HIERARCHY_REQUEST_ERR = ExceptionCode.HIERARCHY_REQUEST_ERR = ((ExceptionMessage[3]="Hierarchy request error"),3);
  5451. var WRONG_DOCUMENT_ERR = ExceptionCode.WRONG_DOCUMENT_ERR = ((ExceptionMessage[4]="Wrong document"),4);
  5452. var INVALID_CHARACTER_ERR = ExceptionCode.INVALID_CHARACTER_ERR = ((ExceptionMessage[5]="Invalid character"),5);
  5453. var NO_DATA_ALLOWED_ERR = ExceptionCode.NO_DATA_ALLOWED_ERR = ((ExceptionMessage[6]="No data allowed"),6);
  5454. var NO_MODIFICATION_ALLOWED_ERR = ExceptionCode.NO_MODIFICATION_ALLOWED_ERR = ((ExceptionMessage[7]="No modification allowed"),7);
  5455. var NOT_FOUND_ERR = ExceptionCode.NOT_FOUND_ERR = ((ExceptionMessage[8]="Not found"),8);
  5456. var NOT_SUPPORTED_ERR = ExceptionCode.NOT_SUPPORTED_ERR = ((ExceptionMessage[9]="Not supported"),9);
  5457. var INUSE_ATTRIBUTE_ERR = ExceptionCode.INUSE_ATTRIBUTE_ERR = ((ExceptionMessage[10]="Attribute in use"),10);
  5458. //level2
  5459. var INVALID_STATE_ERR = ExceptionCode.INVALID_STATE_ERR = ((ExceptionMessage[11]="Invalid state"),11);
  5460. var SYNTAX_ERR = ExceptionCode.SYNTAX_ERR = ((ExceptionMessage[12]="Syntax error"),12);
  5461. var INVALID_MODIFICATION_ERR = ExceptionCode.INVALID_MODIFICATION_ERR = ((ExceptionMessage[13]="Invalid modification"),13);
  5462. var NAMESPACE_ERR = ExceptionCode.NAMESPACE_ERR = ((ExceptionMessage[14]="Invalid namespace"),14);
  5463. var INVALID_ACCESS_ERR = ExceptionCode.INVALID_ACCESS_ERR = ((ExceptionMessage[15]="Invalid access"),15);
  5464. function DOMException(code, message) {
  5465. if(message instanceof Error){
  5466. var error = message;
  5467. }else{
  5468. error = this;
  5469. Error.call(this, ExceptionMessage[code]);
  5470. this.message = ExceptionMessage[code];
  5471. if(Error.captureStackTrace) Error.captureStackTrace(this, DOMException);
  5472. }
  5473. error.code = code;
  5474. if(message) this.message = this.message + ": " + message;
  5475. return error;
  5476. };
  5477. DOMException.prototype = Error.prototype;
  5478. copy(ExceptionCode,DOMException)
  5479. /**
  5480. * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-536297177
  5481. * The NodeList interface provides the abstraction of an ordered collection of nodes, without defining or constraining how this collection is implemented. NodeList objects in the DOM are live.
  5482. * The items in the NodeList are accessible via an integral index, starting from 0.
  5483. */
  5484. function NodeList() {
  5485. };
  5486. NodeList.prototype = {
  5487. /**
  5488. * The number of nodes in the list. The range of valid child node indices is 0 to length-1 inclusive.
  5489. * @standard level1
  5490. */
  5491. length:0,
  5492. /**
  5493. * Returns the indexth item in the collection. If index is greater than or equal to the number of nodes in the list, this returns null.
  5494. * @standard level1
  5495. * @param index unsigned long
  5496. * Index into the collection.
  5497. * @return Node
  5498. * The node at the indexth position in the NodeList, or null if that is not a valid index.
  5499. */
  5500. item: function(index) {
  5501. return this[index] || null;
  5502. }
  5503. };
  5504. function LiveNodeList(node,refresh){
  5505. this._node = node;
  5506. this._refresh = refresh
  5507. _updateLiveList(this);
  5508. }
  5509. function _updateLiveList(list){
  5510. var inc = list._node._inc || list._node.ownerDocument._inc;
  5511. if(list._inc != inc){
  5512. var ls = list._refresh(list._node);
  5513. //console.log(ls.length)
  5514. __set__(list,'length',ls.length);
  5515. copy(ls,list);
  5516. list._inc = inc;
  5517. }
  5518. }
  5519. LiveNodeList.prototype.item = function(i){
  5520. _updateLiveList(this);
  5521. return this[i];
  5522. }
  5523. _extends(LiveNodeList,NodeList);
  5524. /**
  5525. *
  5526. * Objects implementing the NamedNodeMap interface are used to represent collections of nodes that can be accessed by name. Note that NamedNodeMap does not inherit from NodeList; NamedNodeMaps are not maintained in any particular order. Objects contained in an object implementing NamedNodeMap may also be accessed by an ordinal index, but this is simply to allow convenient enumeration of the contents of a NamedNodeMap, and does not imply that the DOM specifies an order to these Nodes.
  5527. * NamedNodeMap objects in the DOM are live.
  5528. * used for attributes or DocumentType entities
  5529. */
  5530. function NamedNodeMap() {
  5531. };
  5532. function _findNodeIndex(list,node){
  5533. var i = list.length;
  5534. while(i--){
  5535. if(list[i] === node){return i}
  5536. }
  5537. }
  5538. function _addNamedNode(el,list,newAttr,oldAttr){
  5539. if(oldAttr){
  5540. list[_findNodeIndex(list,oldAttr)] = newAttr;
  5541. }else{
  5542. list[list.length++] = newAttr;
  5543. }
  5544. if(el){
  5545. newAttr.ownerElement = el;
  5546. var doc = el.ownerDocument;
  5547. if(doc){
  5548. oldAttr && _onRemoveAttribute(doc,el,oldAttr);
  5549. _onAddAttribute(doc,el,newAttr);
  5550. }
  5551. }
  5552. }
  5553. function _removeNamedNode(el,list,attr){
  5554. var i = _findNodeIndex(list,attr);
  5555. if(i>=0){
  5556. var lastIndex = list.length-1
  5557. while(i<lastIndex){
  5558. list[i] = list[++i]
  5559. }
  5560. list.length = lastIndex;
  5561. if(el){
  5562. var doc = el.ownerDocument;
  5563. if(doc){
  5564. _onRemoveAttribute(doc,el,attr);
  5565. attr.ownerElement = null;
  5566. }
  5567. }
  5568. }else{
  5569. throw DOMException(NOT_FOUND_ERR,new Error())
  5570. }
  5571. }
  5572. NamedNodeMap.prototype = {
  5573. length:0,
  5574. item:NodeList.prototype.item,
  5575. getNamedItem: function(key) {
  5576. // if(key.indexOf(':')>0 || key == 'xmlns'){
  5577. // return null;
  5578. // }
  5579. var i = this.length;
  5580. while(i--){
  5581. var attr = this[i];
  5582. if(attr.nodeName == key){
  5583. return attr;
  5584. }
  5585. }
  5586. },
  5587. setNamedItem: function(attr) {
  5588. var el = attr.ownerElement;
  5589. if(el && el!=this._ownerElement){
  5590. throw new DOMException(INUSE_ATTRIBUTE_ERR);
  5591. }
  5592. var oldAttr = this.getNamedItem(attr.nodeName);
  5593. _addNamedNode(this._ownerElement,this,attr,oldAttr);
  5594. return oldAttr;
  5595. },
  5596. /* returns Node */
  5597. setNamedItemNS: function(attr) {// raises: WRONG_DOCUMENT_ERR,NO_MODIFICATION_ALLOWED_ERR,INUSE_ATTRIBUTE_ERR
  5598. var el = attr.ownerElement, oldAttr;
  5599. if(el && el!=this._ownerElement){
  5600. throw new DOMException(INUSE_ATTRIBUTE_ERR);
  5601. }
  5602. oldAttr = this.getNamedItemNS(attr.namespaceURI,attr.localName);
  5603. _addNamedNode(this._ownerElement,this,attr,oldAttr);
  5604. return oldAttr;
  5605. },
  5606. /* returns Node */
  5607. removeNamedItem: function(key) {
  5608. var attr = this.getNamedItem(key);
  5609. _removeNamedNode(this._ownerElement,this,attr);
  5610. return attr;
  5611. },// raises: NOT_FOUND_ERR,NO_MODIFICATION_ALLOWED_ERR
  5612. //for level2
  5613. removeNamedItemNS:function(namespaceURI,localName){
  5614. var attr = this.getNamedItemNS(namespaceURI,localName);
  5615. _removeNamedNode(this._ownerElement,this,attr);
  5616. return attr;
  5617. },
  5618. getNamedItemNS: function(namespaceURI, localName) {
  5619. var i = this.length;
  5620. while(i--){
  5621. var node = this[i];
  5622. if(node.localName == localName && node.namespaceURI == namespaceURI){
  5623. return node;
  5624. }
  5625. }
  5626. return null;
  5627. }
  5628. };
  5629. /**
  5630. * @see http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-102161490
  5631. */
  5632. function DOMImplementation(/* Object */ features) {
  5633. this._features = {};
  5634. if (features) {
  5635. for (var feature in features) {
  5636. this._features = features[feature];
  5637. }
  5638. }
  5639. };
  5640. DOMImplementation.prototype = {
  5641. hasFeature: function(/* string */ feature, /* string */ version) {
  5642. var versions = this._features[feature.toLowerCase()];
  5643. if (versions && (!version || version in versions)) {
  5644. return true;
  5645. } else {
  5646. return false;
  5647. }
  5648. },
  5649. // Introduced in DOM Level 2:
  5650. createDocument:function(namespaceURI, qualifiedName, doctype){// raises:INVALID_CHARACTER_ERR,NAMESPACE_ERR,WRONG_DOCUMENT_ERR
  5651. var doc = new Document();
  5652. doc.doctype = doctype;
  5653. if(doctype){
  5654. doc.appendChild(doctype);
  5655. }
  5656. doc.implementation = this;
  5657. doc.childNodes = new NodeList();
  5658. if(qualifiedName){
  5659. var root = doc.createElementNS(namespaceURI,qualifiedName);
  5660. doc.appendChild(root);
  5661. }
  5662. return doc;
  5663. },
  5664. // Introduced in DOM Level 2:
  5665. createDocumentType:function(qualifiedName, publicId, systemId){// raises:INVALID_CHARACTER_ERR,NAMESPACE_ERR
  5666. var node = new DocumentType();
  5667. node.name = qualifiedName;
  5668. node.nodeName = qualifiedName;
  5669. node.publicId = publicId;
  5670. node.systemId = systemId;
  5671. // Introduced in DOM Level 2:
  5672. //readonly attribute DOMString internalSubset;
  5673. //TODO:..
  5674. // readonly attribute NamedNodeMap entities;
  5675. // readonly attribute NamedNodeMap notations;
  5676. return node;
  5677. }
  5678. };
  5679. /**
  5680. * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-1950641247
  5681. */
  5682. function Node() {
  5683. };
  5684. Node.prototype = {
  5685. firstChild : null,
  5686. lastChild : null,
  5687. previousSibling : null,
  5688. nextSibling : null,
  5689. attributes : null,
  5690. parentNode : null,
  5691. childNodes : null,
  5692. ownerDocument : null,
  5693. nodeValue : null,
  5694. namespaceURI : null,
  5695. prefix : null,
  5696. localName : null,
  5697. // Modified in DOM Level 2:
  5698. insertBefore:function(newChild, refChild){//raises
  5699. return _insertBefore(this,newChild,refChild);
  5700. },
  5701. replaceChild:function(newChild, oldChild){//raises
  5702. this.insertBefore(newChild,oldChild);
  5703. if(oldChild){
  5704. this.removeChild(oldChild);
  5705. }
  5706. },
  5707. removeChild:function(oldChild){
  5708. return _removeChild(this,oldChild);
  5709. },
  5710. appendChild:function(newChild){
  5711. return this.insertBefore(newChild,null);
  5712. },
  5713. hasChildNodes:function(){
  5714. return this.firstChild != null;
  5715. },
  5716. cloneNode:function(deep){
  5717. return cloneNode(this.ownerDocument||this,this,deep);
  5718. },
  5719. // Modified in DOM Level 2:
  5720. normalize:function(){
  5721. var child = this.firstChild;
  5722. while(child){
  5723. var next = child.nextSibling;
  5724. if(next && next.nodeType == TEXT_NODE && child.nodeType == TEXT_NODE){
  5725. this.removeChild(next);
  5726. child.appendData(next.data);
  5727. }else{
  5728. child.normalize();
  5729. child = next;
  5730. }
  5731. }
  5732. },
  5733. // Introduced in DOM Level 2:
  5734. isSupported:function(feature, version){
  5735. return this.ownerDocument.implementation.hasFeature(feature,version);
  5736. },
  5737. // Introduced in DOM Level 2:
  5738. hasAttributes:function(){
  5739. return this.attributes.length>0;
  5740. },
  5741. lookupPrefix:function(namespaceURI){
  5742. var el = this;
  5743. while(el){
  5744. var map = el._nsMap;
  5745. //console.dir(map)
  5746. if(map){
  5747. for(var n in map){
  5748. if(map[n] == namespaceURI){
  5749. return n;
  5750. }
  5751. }
  5752. }
  5753. el = el.nodeType == 2?el.ownerDocument : el.parentNode;
  5754. }
  5755. return null;
  5756. },
  5757. // Introduced in DOM Level 3:
  5758. lookupNamespaceURI:function(prefix){
  5759. var el = this;
  5760. while(el){
  5761. var map = el._nsMap;
  5762. //console.dir(map)
  5763. if(map){
  5764. if(prefix in map){
  5765. return map[prefix] ;
  5766. }
  5767. }
  5768. el = el.nodeType == 2?el.ownerDocument : el.parentNode;
  5769. }
  5770. return null;
  5771. },
  5772. // Introduced in DOM Level 3:
  5773. isDefaultNamespace:function(namespaceURI){
  5774. var prefix = this.lookupPrefix(namespaceURI);
  5775. return prefix == null;
  5776. }
  5777. };
  5778. function _xmlEncoder(c){
  5779. return c == '<' && '&lt;' ||
  5780. c == '>' && '&gt;' ||
  5781. c == '&' && '&amp;' ||
  5782. c == '"' && '&quot;' ||
  5783. '&#'+c.charCodeAt()+';'
  5784. }
  5785. copy(NodeType,Node);
  5786. copy(NodeType,Node.prototype);
  5787. /**
  5788. * @param callback return true for continue,false for break
  5789. * @return boolean true: break visit;
  5790. */
  5791. function _visitNode(node,callback){
  5792. if(callback(node)){
  5793. return true;
  5794. }
  5795. if(node = node.firstChild){
  5796. do{
  5797. if(_visitNode(node,callback)){return true}
  5798. }while(node=node.nextSibling)
  5799. }
  5800. }
  5801. function Document(){
  5802. }
  5803. function _onAddAttribute(doc,el,newAttr){
  5804. doc && doc._inc++;
  5805. var ns = newAttr.namespaceURI ;
  5806. if(ns == 'http://www.w3.org/2000/xmlns/'){
  5807. //update namespace
  5808. el._nsMap[newAttr.prefix?newAttr.localName:''] = newAttr.value
  5809. }
  5810. }
  5811. function _onRemoveAttribute(doc,el,newAttr,remove){
  5812. doc && doc._inc++;
  5813. var ns = newAttr.namespaceURI ;
  5814. if(ns == 'http://www.w3.org/2000/xmlns/'){
  5815. //update namespace
  5816. delete el._nsMap[newAttr.prefix?newAttr.localName:'']
  5817. }
  5818. }
  5819. function _onUpdateChild(doc,el,newChild){
  5820. if(doc && doc._inc){
  5821. doc._inc++;
  5822. //update childNodes
  5823. var cs = el.childNodes;
  5824. if(newChild){
  5825. cs[cs.length++] = newChild;
  5826. }else{
  5827. //console.log(1)
  5828. var child = el.firstChild;
  5829. var i = 0;
  5830. while(child){
  5831. cs[i++] = child;
  5832. child =child.nextSibling;
  5833. }
  5834. cs.length = i;
  5835. }
  5836. }
  5837. }
  5838. /**
  5839. * attributes;
  5840. * children;
  5841. *
  5842. * writeable properties:
  5843. * nodeValue,Attr:value,CharacterData:data
  5844. * prefix
  5845. */
  5846. function _removeChild(parentNode,child){
  5847. var previous = child.previousSibling;
  5848. var next = child.nextSibling;
  5849. if(previous){
  5850. previous.nextSibling = next;
  5851. }else{
  5852. parentNode.firstChild = next
  5853. }
  5854. if(next){
  5855. next.previousSibling = previous;
  5856. }else{
  5857. parentNode.lastChild = previous;
  5858. }
  5859. _onUpdateChild(parentNode.ownerDocument,parentNode);
  5860. return child;
  5861. }
  5862. /**
  5863. * preformance key(refChild == null)
  5864. */
  5865. function _insertBefore(parentNode,newChild,nextChild){
  5866. var cp = newChild.parentNode;
  5867. if(cp){
  5868. cp.removeChild(newChild);//remove and update
  5869. }
  5870. if(newChild.nodeType === DOCUMENT_FRAGMENT_NODE){
  5871. var newFirst = newChild.firstChild;
  5872. if (newFirst == null) {
  5873. return newChild;
  5874. }
  5875. var newLast = newChild.lastChild;
  5876. }else{
  5877. newFirst = newLast = newChild;
  5878. }
  5879. var pre = nextChild ? nextChild.previousSibling : parentNode.lastChild;
  5880. newFirst.previousSibling = pre;
  5881. newLast.nextSibling = nextChild;
  5882. if(pre){
  5883. pre.nextSibling = newFirst;
  5884. }else{
  5885. parentNode.firstChild = newFirst;
  5886. }
  5887. if(nextChild == null){
  5888. parentNode.lastChild = newLast;
  5889. }else{
  5890. nextChild.previousSibling = newLast;
  5891. }
  5892. do{
  5893. newFirst.parentNode = parentNode;
  5894. }while(newFirst !== newLast && (newFirst= newFirst.nextSibling))
  5895. _onUpdateChild(parentNode.ownerDocument||parentNode,parentNode);
  5896. //console.log(parentNode.lastChild.nextSibling == null)
  5897. if (newChild.nodeType == DOCUMENT_FRAGMENT_NODE) {
  5898. newChild.firstChild = newChild.lastChild = null;
  5899. }
  5900. return newChild;
  5901. }
  5902. function _appendSingleChild(parentNode,newChild){
  5903. var cp = newChild.parentNode;
  5904. if(cp){
  5905. var pre = parentNode.lastChild;
  5906. cp.removeChild(newChild);//remove and update
  5907. var pre = parentNode.lastChild;
  5908. }
  5909. var pre = parentNode.lastChild;
  5910. newChild.parentNode = parentNode;
  5911. newChild.previousSibling = pre;
  5912. newChild.nextSibling = null;
  5913. if(pre){
  5914. pre.nextSibling = newChild;
  5915. }else{
  5916. parentNode.firstChild = newChild;
  5917. }
  5918. parentNode.lastChild = newChild;
  5919. _onUpdateChild(parentNode.ownerDocument,parentNode,newChild);
  5920. return newChild;
  5921. //console.log("__aa",parentNode.lastChild.nextSibling == null)
  5922. }
  5923. Document.prototype = {
  5924. //implementation : null,
  5925. nodeName : '#document',
  5926. nodeType : DOCUMENT_NODE,
  5927. doctype : null,
  5928. documentElement : null,
  5929. _inc : 1,
  5930. insertBefore : function(newChild, refChild){//raises
  5931. if(newChild.nodeType == DOCUMENT_FRAGMENT_NODE){
  5932. var child = newChild.firstChild;
  5933. while(child){
  5934. var next = child.nextSibling;
  5935. this.insertBefore(child,refChild);
  5936. child = next;
  5937. }
  5938. return newChild;
  5939. }
  5940. if(this.documentElement == null && newChild.nodeType == 1){
  5941. this.documentElement = newChild;
  5942. }
  5943. return _insertBefore(this,newChild,refChild),(newChild.ownerDocument = this),newChild;
  5944. },
  5945. removeChild : function(oldChild){
  5946. if(this.documentElement == oldChild){
  5947. this.documentElement = null;
  5948. }
  5949. return _removeChild(this,oldChild);
  5950. },
  5951. // Introduced in DOM Level 2:
  5952. importNode : function(importedNode,deep){
  5953. return importNode(this,importedNode,deep);
  5954. },
  5955. // Introduced in DOM Level 2:
  5956. getElementById : function(id){
  5957. var rtv = null;
  5958. _visitNode(this.documentElement,function(node){
  5959. if(node.nodeType == 1){
  5960. if(node.getAttribute('id') == id){
  5961. rtv = node;
  5962. return true;
  5963. }
  5964. }
  5965. })
  5966. return rtv;
  5967. },
  5968. //document factory method:
  5969. createElement : function(tagName){
  5970. var node = new Element();
  5971. node.ownerDocument = this;
  5972. node.nodeName = tagName;
  5973. node.tagName = tagName;
  5974. node.childNodes = new NodeList();
  5975. var attrs = node.attributes = new NamedNodeMap();
  5976. attrs._ownerElement = node;
  5977. return node;
  5978. },
  5979. createDocumentFragment : function(){
  5980. var node = new DocumentFragment();
  5981. node.ownerDocument = this;
  5982. node.childNodes = new NodeList();
  5983. return node;
  5984. },
  5985. createTextNode : function(data){
  5986. var node = new Text();
  5987. node.ownerDocument = this;
  5988. node.appendData(data)
  5989. return node;
  5990. },
  5991. createComment : function(data){
  5992. var node = new Comment();
  5993. node.ownerDocument = this;
  5994. node.appendData(data)
  5995. return node;
  5996. },
  5997. createCDATASection : function(data){
  5998. var node = new CDATASection();
  5999. node.ownerDocument = this;
  6000. node.appendData(data)
  6001. return node;
  6002. },
  6003. createProcessingInstruction : function(target,data){
  6004. var node = new ProcessingInstruction();
  6005. node.ownerDocument = this;
  6006. node.tagName = node.target = target;
  6007. node.nodeValue= node.data = data;
  6008. return node;
  6009. },
  6010. createAttribute : function(name){
  6011. var node = new Attr();
  6012. node.ownerDocument = this;
  6013. node.name = name;
  6014. node.nodeName = name;
  6015. node.localName = name;
  6016. node.specified = true;
  6017. return node;
  6018. },
  6019. createEntityReference : function(name){
  6020. var node = new EntityReference();
  6021. node.ownerDocument = this;
  6022. node.nodeName = name;
  6023. return node;
  6024. },
  6025. // Introduced in DOM Level 2:
  6026. createElementNS : function(namespaceURI,qualifiedName){
  6027. var node = new Element();
  6028. var pl = qualifiedName.split(':');
  6029. var attrs = node.attributes = new NamedNodeMap();
  6030. node.childNodes = new NodeList();
  6031. node.ownerDocument = this;
  6032. node.nodeName = qualifiedName;
  6033. node.tagName = qualifiedName;
  6034. node.namespaceURI = namespaceURI;
  6035. if(pl.length == 2){
  6036. node.prefix = pl[0];
  6037. node.localName = pl[1];
  6038. }else{
  6039. //el.prefix = null;
  6040. node.localName = qualifiedName;
  6041. }
  6042. attrs._ownerElement = node;
  6043. return node;
  6044. },
  6045. // Introduced in DOM Level 2:
  6046. createAttributeNS : function(namespaceURI,qualifiedName){
  6047. var node = new Attr();
  6048. var pl = qualifiedName.split(':');
  6049. node.ownerDocument = this;
  6050. node.nodeName = qualifiedName;
  6051. node.name = qualifiedName;
  6052. node.namespaceURI = namespaceURI;
  6053. node.specified = true;
  6054. if(pl.length == 2){
  6055. node.prefix = pl[0];
  6056. node.localName = pl[1];
  6057. }else{
  6058. //el.prefix = null;
  6059. node.localName = qualifiedName;
  6060. }
  6061. return node;
  6062. }
  6063. };
  6064. _extends(Document,Node);
  6065. function Element() {
  6066. this._nsMap = {};
  6067. };
  6068. Element.prototype = {
  6069. nodeType : ELEMENT_NODE,
  6070. hasAttribute : function(name){
  6071. return this.getAttributeNode(name)!=null;
  6072. },
  6073. getAttribute : function(name){
  6074. var attr = this.getAttributeNode(name);
  6075. return attr && attr.value || '';
  6076. },
  6077. getAttributeNode : function(name){
  6078. return this.attributes.getNamedItem(name);
  6079. },
  6080. setAttribute : function(name, value){
  6081. var attr = this.ownerDocument.createAttribute(name);
  6082. attr.value = attr.nodeValue = "" + value;
  6083. this.setAttributeNode(attr)
  6084. },
  6085. removeAttribute : function(name){
  6086. var attr = this.getAttributeNode(name)
  6087. attr && this.removeAttributeNode(attr);
  6088. },
  6089. //four real opeartion method
  6090. appendChild:function(newChild){
  6091. if(newChild.nodeType === DOCUMENT_FRAGMENT_NODE){
  6092. return this.insertBefore(newChild,null);
  6093. }else{
  6094. return _appendSingleChild(this,newChild);
  6095. }
  6096. },
  6097. setAttributeNode : function(newAttr){
  6098. return this.attributes.setNamedItem(newAttr);
  6099. },
  6100. setAttributeNodeNS : function(newAttr){
  6101. return this.attributes.setNamedItemNS(newAttr);
  6102. },
  6103. removeAttributeNode : function(oldAttr){
  6104. return this.attributes.removeNamedItem(oldAttr.nodeName);
  6105. },
  6106. //get real attribute name,and remove it by removeAttributeNode
  6107. removeAttributeNS : function(namespaceURI, localName){
  6108. var old = this.getAttributeNodeNS(namespaceURI, localName);
  6109. old && this.removeAttributeNode(old);
  6110. },
  6111. hasAttributeNS : function(namespaceURI, localName){
  6112. return this.getAttributeNodeNS(namespaceURI, localName)!=null;
  6113. },
  6114. getAttributeNS : function(namespaceURI, localName){
  6115. var attr = this.getAttributeNodeNS(namespaceURI, localName);
  6116. return attr && attr.value || '';
  6117. },
  6118. setAttributeNS : function(namespaceURI, qualifiedName, value){
  6119. var attr = this.ownerDocument.createAttributeNS(namespaceURI, qualifiedName);
  6120. attr.value = attr.nodeValue = value;
  6121. this.setAttributeNode(attr)
  6122. },
  6123. getAttributeNodeNS : function(namespaceURI, localName){
  6124. return this.attributes.getNamedItemNS(namespaceURI, localName);
  6125. },
  6126. getElementsByTagName : function(tagName){
  6127. return new LiveNodeList(this,function(base){
  6128. var ls = [];
  6129. _visitNode(base,function(node){
  6130. if(node !== base && node.nodeType == ELEMENT_NODE && (tagName === '*' || node.tagName == tagName)){
  6131. ls.push(node);
  6132. }
  6133. });
  6134. return ls;
  6135. });
  6136. },
  6137. getElementsByTagNameNS : function(namespaceURI, localName){
  6138. return new LiveNodeList(this,function(base){
  6139. var ls = [];
  6140. _visitNode(base,function(node){
  6141. if(node !== base && node.nodeType === ELEMENT_NODE && node.namespaceURI === namespaceURI && (localName === '*' || node.localName == localName)){
  6142. ls.push(node);
  6143. }
  6144. });
  6145. return ls;
  6146. });
  6147. }
  6148. };
  6149. Document.prototype.getElementsByTagName = Element.prototype.getElementsByTagName;
  6150. Document.prototype.getElementsByTagNameNS = Element.prototype.getElementsByTagNameNS;
  6151. _extends(Element,Node);
  6152. function Attr() {
  6153. };
  6154. Attr.prototype.nodeType = ATTRIBUTE_NODE;
  6155. _extends(Attr,Node);
  6156. function CharacterData() {
  6157. };
  6158. CharacterData.prototype = {
  6159. data : '',
  6160. substringData : function(offset, count) {
  6161. return this.data.substring(offset, offset+count);
  6162. },
  6163. appendData: function(text) {
  6164. text = this.data+text;
  6165. this.nodeValue = this.data = text;
  6166. this.length = text.length;
  6167. },
  6168. insertData: function(offset,text) {
  6169. this.replaceData(offset,0,text);
  6170. },
  6171. appendChild:function(newChild){
  6172. //if(!(newChild instanceof CharacterData)){
  6173. throw new Error(ExceptionMessage[3])
  6174. //}
  6175. return Node.prototype.appendChild.apply(this,arguments)
  6176. },
  6177. deleteData: function(offset, count) {
  6178. this.replaceData(offset,count,"");
  6179. },
  6180. replaceData: function(offset, count, text) {
  6181. var start = this.data.substring(0,offset);
  6182. var end = this.data.substring(offset+count);
  6183. text = start + text + end;
  6184. this.nodeValue = this.data = text;
  6185. this.length = text.length;
  6186. }
  6187. }
  6188. _extends(CharacterData,Node);
  6189. function Text() {
  6190. };
  6191. Text.prototype = {
  6192. nodeName : "#text",
  6193. nodeType : TEXT_NODE,
  6194. splitText : function(offset) {
  6195. var text = this.data;
  6196. var newText = text.substring(offset);
  6197. text = text.substring(0, offset);
  6198. this.data = this.nodeValue = text;
  6199. this.length = text.length;
  6200. var newNode = this.ownerDocument.createTextNode(newText);
  6201. if(this.parentNode){
  6202. this.parentNode.insertBefore(newNode, this.nextSibling);
  6203. }
  6204. return newNode;
  6205. }
  6206. }
  6207. _extends(Text,CharacterData);
  6208. function Comment() {
  6209. };
  6210. Comment.prototype = {
  6211. nodeName : "#comment",
  6212. nodeType : COMMENT_NODE
  6213. }
  6214. _extends(Comment,CharacterData);
  6215. function CDATASection() {
  6216. };
  6217. CDATASection.prototype = {
  6218. nodeName : "#cdata-section",
  6219. nodeType : CDATA_SECTION_NODE
  6220. }
  6221. _extends(CDATASection,CharacterData);
  6222. function DocumentType() {
  6223. };
  6224. DocumentType.prototype.nodeType = DOCUMENT_TYPE_NODE;
  6225. _extends(DocumentType,Node);
  6226. function Notation() {
  6227. };
  6228. Notation.prototype.nodeType = NOTATION_NODE;
  6229. _extends(Notation,Node);
  6230. function Entity() {
  6231. };
  6232. Entity.prototype.nodeType = ENTITY_NODE;
  6233. _extends(Entity,Node);
  6234. function EntityReference() {
  6235. };
  6236. EntityReference.prototype.nodeType = ENTITY_REFERENCE_NODE;
  6237. _extends(EntityReference,Node);
  6238. function DocumentFragment() {
  6239. };
  6240. DocumentFragment.prototype.nodeName = "#document-fragment";
  6241. DocumentFragment.prototype.nodeType = DOCUMENT_FRAGMENT_NODE;
  6242. _extends(DocumentFragment,Node);
  6243. function ProcessingInstruction() {
  6244. }
  6245. ProcessingInstruction.prototype.nodeType = PROCESSING_INSTRUCTION_NODE;
  6246. _extends(ProcessingInstruction,Node);
  6247. function XMLSerializer(){}
  6248. XMLSerializer.prototype.serializeToString = function(node){
  6249. var buf = [];
  6250. serializeToString(node,buf);
  6251. return buf.join('');
  6252. }
  6253. Node.prototype.toString =function(){
  6254. return XMLSerializer.prototype.serializeToString(this);
  6255. }
  6256. function serializeToString(node,buf){
  6257. switch(node.nodeType){
  6258. case ELEMENT_NODE:
  6259. var attrs = node.attributes;
  6260. var len = attrs.length;
  6261. var child = node.firstChild;
  6262. var nodeName = node.tagName;
  6263. var isHTML = htmlns === node.namespaceURI
  6264. buf.push('<',nodeName);
  6265. for(var i=0;i<len;i++){
  6266. serializeToString(attrs.item(i),buf,isHTML);
  6267. }
  6268. if(child || isHTML && !/^(?:meta|link|img|br|hr|input)$/i.test(nodeName)){
  6269. buf.push('>');
  6270. //if is cdata child node
  6271. if(isHTML && /^script$/i.test(nodeName)){
  6272. if(child){
  6273. buf.push(child.data);
  6274. }
  6275. }else{
  6276. while(child){
  6277. serializeToString(child,buf);
  6278. child = child.nextSibling;
  6279. }
  6280. }
  6281. buf.push('</',nodeName,'>');
  6282. }else{
  6283. buf.push('/>');
  6284. }
  6285. return;
  6286. case DOCUMENT_NODE:
  6287. case DOCUMENT_FRAGMENT_NODE:
  6288. var child = node.firstChild;
  6289. while(child){
  6290. serializeToString(child,buf);
  6291. child = child.nextSibling;
  6292. }
  6293. return;
  6294. case ATTRIBUTE_NODE:
  6295. return buf.push(' ',node.name,'="',node.value.replace(/[<&"]/g,_xmlEncoder),'"');
  6296. case TEXT_NODE:
  6297. return buf.push(node.data.replace(/[<&]/g,_xmlEncoder));
  6298. case CDATA_SECTION_NODE:
  6299. return buf.push( '<![CDATA[',node.data,']]>');
  6300. case COMMENT_NODE:
  6301. return buf.push( "<!--",node.data,"-->");
  6302. case DOCUMENT_TYPE_NODE:
  6303. var pubid = node.publicId;
  6304. var sysid = node.systemId;
  6305. buf.push('<!DOCTYPE ',node.name);
  6306. if(pubid){
  6307. buf.push(' PUBLIC "',pubid);
  6308. if (sysid && sysid!='.') {
  6309. buf.push( '" "',sysid);
  6310. }
  6311. buf.push('">');
  6312. }else if(sysid && sysid!='.'){
  6313. buf.push(' SYSTEM "',sysid,'">');
  6314. }else{
  6315. var sub = node.internalSubset;
  6316. if(sub){
  6317. buf.push(" [",sub,"]");
  6318. }
  6319. buf.push(">");
  6320. }
  6321. return;
  6322. case PROCESSING_INSTRUCTION_NODE:
  6323. return buf.push( "<?",node.target," ",node.data,"?>");
  6324. case ENTITY_REFERENCE_NODE:
  6325. return buf.push( '&',node.nodeName,';');
  6326. //case ENTITY_NODE:
  6327. //case NOTATION_NODE:
  6328. default:
  6329. buf.push('??',node.nodeName);
  6330. }
  6331. }
  6332. function importNode(doc,node,deep){
  6333. var node2;
  6334. switch (node.nodeType) {
  6335. case ELEMENT_NODE:
  6336. node2 = node.cloneNode(false);
  6337. node2.ownerDocument = doc;
  6338. //var attrs = node2.attributes;
  6339. //var len = attrs.length;
  6340. //for(var i=0;i<len;i++){
  6341. //node2.setAttributeNodeNS(importNode(doc,attrs.item(i),deep));
  6342. //}
  6343. case DOCUMENT_FRAGMENT_NODE:
  6344. break;
  6345. case ATTRIBUTE_NODE:
  6346. deep = true;
  6347. break;
  6348. //case ENTITY_REFERENCE_NODE:
  6349. //case PROCESSING_INSTRUCTION_NODE:
  6350. ////case TEXT_NODE:
  6351. //case CDATA_SECTION_NODE:
  6352. //case COMMENT_NODE:
  6353. // deep = false;
  6354. // break;
  6355. //case DOCUMENT_NODE:
  6356. //case DOCUMENT_TYPE_NODE:
  6357. //cannot be imported.
  6358. //case ENTITY_NODE:
  6359. //case NOTATION_NODE:
  6360. //can not hit in level3
  6361. //default:throw e;
  6362. }
  6363. if(!node2){
  6364. node2 = node.cloneNode(false);//false
  6365. }
  6366. node2.ownerDocument = doc;
  6367. node2.parentNode = null;
  6368. if(deep){
  6369. var child = node.firstChild;
  6370. while(child){
  6371. node2.appendChild(importNode(doc,child,deep));
  6372. child = child.nextSibling;
  6373. }
  6374. }
  6375. return node2;
  6376. }
  6377. //
  6378. //var _relationMap = {firstChild:1,lastChild:1,previousSibling:1,nextSibling:1,
  6379. // attributes:1,childNodes:1,parentNode:1,documentElement:1,doctype,};
  6380. function cloneNode(doc,node,deep){
  6381. var node2 = new node.constructor();
  6382. for(var n in node){
  6383. var v = node[n];
  6384. if(typeof v != 'object' ){
  6385. if(v != node2[n]){
  6386. node2[n] = v;
  6387. }
  6388. }
  6389. }
  6390. if(node.childNodes){
  6391. node2.childNodes = new NodeList();
  6392. }
  6393. node2.ownerDocument = doc;
  6394. switch (node2.nodeType) {
  6395. case ELEMENT_NODE:
  6396. var attrs = node.attributes;
  6397. var attrs2 = node2.attributes = new NamedNodeMap();
  6398. var len = attrs.length
  6399. attrs2._ownerElement = node2;
  6400. for(var i=0;i<len;i++){
  6401. node2.setAttributeNode(cloneNode(doc,attrs.item(i),true));
  6402. }
  6403. break;;
  6404. case ATTRIBUTE_NODE:
  6405. deep = true;
  6406. }
  6407. if(deep){
  6408. var child = node.firstChild;
  6409. while(child){
  6410. node2.appendChild(cloneNode(doc,child,deep));
  6411. child = child.nextSibling;
  6412. }
  6413. }
  6414. return node2;
  6415. }
  6416. function __set__(object,key,value){
  6417. object[key] = value
  6418. }
  6419. //do dynamic
  6420. try{
  6421. if(Object.defineProperty){
  6422. Object.defineProperty(LiveNodeList.prototype,'length',{
  6423. get:function(){
  6424. _updateLiveList(this);
  6425. return this.$$length;
  6426. }
  6427. });
  6428. Object.defineProperty(Node.prototype,'textContent',{
  6429. get:function(){
  6430. return getTextContent(this);
  6431. },
  6432. set:function(data){
  6433. switch(this.nodeType){
  6434. case 1:
  6435. case 11:
  6436. while(this.firstChild){
  6437. this.removeChild(this.firstChild);
  6438. }
  6439. if(data || String(data)){
  6440. this.appendChild(this.ownerDocument.createTextNode(data));
  6441. }
  6442. break;
  6443. default:
  6444. //TODO:
  6445. this.data = data;
  6446. this.value = value;
  6447. this.nodeValue = data;
  6448. }
  6449. }
  6450. })
  6451. function getTextContent(node){
  6452. switch(node.nodeType){
  6453. case 1:
  6454. case 11:
  6455. var buf = [];
  6456. node = node.firstChild;
  6457. while(node){
  6458. if(node.nodeType!==7 && node.nodeType !==8){
  6459. buf.push(getTextContent(node));
  6460. }
  6461. node = node.nextSibling;
  6462. }
  6463. return buf.join('');
  6464. default:
  6465. return node.nodeValue;
  6466. }
  6467. }
  6468. __set__ = function(object,key,value){
  6469. //console.log(value)
  6470. object['$$'+key] = value
  6471. }
  6472. }
  6473. }catch(e){//ie8
  6474. }
  6475. if(typeof require == 'function'){
  6476. exports.DOMImplementation = DOMImplementation;
  6477. exports.XMLSerializer = XMLSerializer;
  6478. }
  6479. },{}],90:[function(require,module,exports){
  6480. //[4] NameStartChar ::= ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
  6481. //[4a] NameChar ::= NameStartChar | "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]
  6482. //[5] Name ::= NameStartChar (NameChar)*
  6483. var nameStartChar = /[A-Z_a-z\xC0-\xD6\xD8-\xF6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]///\u10000-\uEFFFF
  6484. var nameChar = new RegExp("[\\-\\.0-9"+nameStartChar.source.slice(1,-1)+"\u00B7\u0300-\u036F\\ux203F-\u2040]");
  6485. var tagNamePattern = new RegExp('^'+nameStartChar.source+nameChar.source+'*(?:\:'+nameStartChar.source+nameChar.source+'*)?$');
  6486. //var tagNamePattern = /^[a-zA-Z_][\w\-\.]*(?:\:[a-zA-Z_][\w\-\.]*)?$/
  6487. //var handlers = 'resolveEntity,getExternalSubset,characters,endDocument,endElement,endPrefixMapping,ignorableWhitespace,processingInstruction,setDocumentLocator,skippedEntity,startDocument,startElement,startPrefixMapping,notationDecl,unparsedEntityDecl,error,fatalError,warning,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,comment,endCDATA,endDTD,endEntity,startCDATA,startDTD,startEntity'.split(',')
  6488. //S_TAG, S_ATTR, S_EQ, S_V
  6489. //S_ATTR_S, S_E, S_S, S_C
  6490. var S_TAG = 0;//tag name offerring
  6491. var S_ATTR = 1;//attr name offerring
  6492. var S_ATTR_S=2;//attr name end and space offer
  6493. var S_EQ = 3;//=space?
  6494. var S_V = 4;//attr value(no quot value only)
  6495. var S_E = 5;//attr value end and no space(quot end)
  6496. var S_S = 6;//(attr value end || tag end ) && (space offer)
  6497. var S_C = 7;//closed el<el />
  6498. function XMLReader(){
  6499. }
  6500. XMLReader.prototype = {
  6501. parse:function(source,defaultNSMap,entityMap){
  6502. var domBuilder = this.domBuilder;
  6503. domBuilder.startDocument();
  6504. _copy(defaultNSMap ,defaultNSMap = {})
  6505. parse(source,defaultNSMap,entityMap,
  6506. domBuilder,this.errorHandler);
  6507. domBuilder.endDocument();
  6508. }
  6509. }
  6510. function parse(source,defaultNSMapCopy,entityMap,domBuilder,errorHandler){
  6511. function fixedFromCharCode(code) {
  6512. // String.prototype.fromCharCode does not supports
  6513. // > 2 bytes unicode chars directly
  6514. if (code > 0xffff) {
  6515. code -= 0x10000;
  6516. var surrogate1 = 0xd800 + (code >> 10)
  6517. , surrogate2 = 0xdc00 + (code & 0x3ff);
  6518. return String.fromCharCode(surrogate1, surrogate2);
  6519. } else {
  6520. return String.fromCharCode(code);
  6521. }
  6522. }
  6523. function entityReplacer(a){
  6524. var k = a.slice(1,-1);
  6525. if(k in entityMap){
  6526. return entityMap[k];
  6527. }else if(k.charAt(0) === '#'){
  6528. return fixedFromCharCode(parseInt(k.substr(1).replace('x','0x')))
  6529. }else{
  6530. errorHandler.error('entity not found:'+a);
  6531. return a;
  6532. }
  6533. }
  6534. function appendText(end){//has some bugs
  6535. var xt = source.substring(start,end).replace(/&#?\w+;/g,entityReplacer);
  6536. locator&&position(start);
  6537. domBuilder.characters(xt,0,end-start);
  6538. start = end
  6539. }
  6540. function position(start,m){
  6541. while(start>=endPos && (m = linePattern.exec(source))){
  6542. startPos = m.index;
  6543. endPos = startPos + m[0].length;
  6544. locator.lineNumber++;
  6545. //console.log('line++:',locator,startPos,endPos)
  6546. }
  6547. locator.columnNumber = start-startPos+1;
  6548. }
  6549. var startPos = 0;
  6550. var endPos = 0;
  6551. var linePattern = /.+(?:\r\n?|\n)|.*$/g
  6552. var locator = domBuilder.locator;
  6553. var parseStack = [{currentNSMap:defaultNSMapCopy}]
  6554. var closeMap = {};
  6555. var start = 0;
  6556. while(true){
  6557. var i = source.indexOf('<',start);
  6558. if(i<0){
  6559. if(!source.substr(start).match(/^\s*$/)){
  6560. var doc = domBuilder.document;
  6561. var text = doc.createTextNode(source.substr(start));
  6562. doc.appendChild(text);
  6563. domBuilder.currentElement = text;
  6564. }
  6565. return;
  6566. }
  6567. if(i>start){
  6568. appendText(i);
  6569. }
  6570. switch(source.charAt(i+1)){
  6571. case '/':
  6572. var end = source.indexOf('>',i+3);
  6573. var tagName = source.substring(i+2,end);
  6574. var config = parseStack.pop();
  6575. var localNSMap = config.localNSMap;
  6576. if(config.tagName != tagName){
  6577. errorHandler.fatalError("end tag name: "+tagName+' is not match the current start tagName:'+config.tagName );
  6578. }
  6579. domBuilder.endElement(config.uri,config.localName,tagName);
  6580. if(localNSMap){
  6581. for(var prefix in localNSMap){
  6582. domBuilder.endPrefixMapping(prefix) ;
  6583. }
  6584. }
  6585. end++;
  6586. break;
  6587. // end elment
  6588. case '?':// <?...?>
  6589. locator&&position(i);
  6590. end = parseInstruction(source,i,domBuilder);
  6591. break;
  6592. case '!':// <!doctype,<![CDATA,<!--
  6593. locator&&position(i);
  6594. end = parseDCC(source,i,domBuilder,errorHandler);
  6595. break;
  6596. default:
  6597. try{
  6598. locator&&position(i);
  6599. var el = new ElementAttributes();
  6600. //elStartEnd
  6601. var end = parseElementStartPart(source,i,el,entityReplacer,errorHandler);
  6602. var len = el.length;
  6603. //position fixed
  6604. if(len && locator){
  6605. var backup = copyLocator(locator,{});
  6606. for(var i = 0;i<len;i++){
  6607. var a = el[i];
  6608. position(a.offset);
  6609. a.offset = copyLocator(locator,{});
  6610. }
  6611. copyLocator(backup,locator);
  6612. }
  6613. if(!el.closed && fixSelfClosed(source,end,el.tagName,closeMap)){
  6614. el.closed = true;
  6615. if(!entityMap.nbsp){
  6616. errorHandler.warning('unclosed xml attribute');
  6617. }
  6618. }
  6619. appendElement(el,domBuilder,parseStack);
  6620. if(el.uri === 'http://www.w3.org/1999/xhtml' && !el.closed){
  6621. end = parseHtmlSpecialContent(source,end,el.tagName,entityReplacer,domBuilder)
  6622. }else{
  6623. end++;
  6624. }
  6625. }catch(e){
  6626. errorHandler.error('element parse error: '+e);
  6627. end = -1;
  6628. }
  6629. }
  6630. if(end<0){
  6631. //TODO: 这里有可能sax回退,有位置错误风险
  6632. appendText(i+1);
  6633. }else{
  6634. start = end;
  6635. }
  6636. }
  6637. }
  6638. function copyLocator(f,t){
  6639. t.lineNumber = f.lineNumber;
  6640. t.columnNumber = f.columnNumber;
  6641. return t;
  6642. }
  6643. /**
  6644. * @see #appendElement(source,elStartEnd,el,selfClosed,entityReplacer,domBuilder,parseStack);
  6645. * @return end of the elementStartPart(end of elementEndPart for selfClosed el)
  6646. */
  6647. function parseElementStartPart(source,start,el,entityReplacer,errorHandler){
  6648. var attrName;
  6649. var value;
  6650. var p = ++start;
  6651. var s = S_TAG;//status
  6652. while(true){
  6653. var c = source.charAt(p);
  6654. switch(c){
  6655. case '=':
  6656. if(s === S_ATTR){//attrName
  6657. attrName = source.slice(start,p);
  6658. s = S_EQ;
  6659. }else if(s === S_ATTR_S){
  6660. s = S_EQ;
  6661. }else{
  6662. //fatalError: equal must after attrName or space after attrName
  6663. throw new Error('attribute equal must after attrName');
  6664. }
  6665. break;
  6666. case '\'':
  6667. case '"':
  6668. if(s === S_EQ){//equal
  6669. start = p+1;
  6670. p = source.indexOf(c,start)
  6671. if(p>0){
  6672. value = source.slice(start,p).replace(/&#?\w+;/g,entityReplacer);
  6673. el.add(attrName,value,start-1);
  6674. s = S_E;
  6675. }else{
  6676. //fatalError: no end quot match
  6677. throw new Error('attribute value no end \''+c+'\' match');
  6678. }
  6679. }else if(s == S_V){
  6680. value = source.slice(start,p).replace(/&#?\w+;/g,entityReplacer);
  6681. //console.log(attrName,value,start,p)
  6682. el.add(attrName,value,start);
  6683. //console.dir(el)
  6684. errorHandler.warning('attribute "'+attrName+'" missed start quot('+c+')!!');
  6685. start = p+1;
  6686. s = S_E
  6687. }else{
  6688. //fatalError: no equal before
  6689. throw new Error('attribute value must after "="');
  6690. }
  6691. break;
  6692. case '/':
  6693. switch(s){
  6694. case S_TAG:
  6695. el.setTagName(source.slice(start,p));
  6696. case S_E:
  6697. case S_S:
  6698. case S_C:
  6699. s = S_C;
  6700. el.closed = true;
  6701. case S_V:
  6702. case S_ATTR:
  6703. case S_ATTR_S:
  6704. break;
  6705. //case S_EQ:
  6706. default:
  6707. throw new Error("attribute invalid close char('/')")
  6708. }
  6709. break;
  6710. case ''://end document
  6711. //throw new Error('unexpected end of input')
  6712. errorHandler.error('unexpected end of input');
  6713. case '>':
  6714. switch(s){
  6715. case S_TAG:
  6716. el.setTagName(source.slice(start,p));
  6717. case S_E:
  6718. case S_S:
  6719. case S_C:
  6720. break;//normal
  6721. case S_V://Compatible state
  6722. case S_ATTR:
  6723. value = source.slice(start,p);
  6724. if(value.slice(-1) === '/'){
  6725. el.closed = true;
  6726. value = value.slice(0,-1)
  6727. }
  6728. case S_ATTR_S:
  6729. if(s === S_ATTR_S){
  6730. value = attrName;
  6731. }
  6732. if(s == S_V){
  6733. errorHandler.warning('attribute "'+value+'" missed quot(")!!');
  6734. el.add(attrName,value.replace(/&#?\w+;/g,entityReplacer),start)
  6735. }else{
  6736. errorHandler.warning('attribute "'+value+'" missed value!! "'+value+'" instead!!')
  6737. el.add(value,value,start)
  6738. }
  6739. break;
  6740. case S_EQ:
  6741. throw new Error('attribute value missed!!');
  6742. }
  6743. // console.log(tagName,tagNamePattern,tagNamePattern.test(tagName))
  6744. return p;
  6745. /*xml space '\x20' | #x9 | #xD | #xA; */
  6746. case '\u0080':
  6747. c = ' ';
  6748. default:
  6749. if(c<= ' '){//space
  6750. switch(s){
  6751. case S_TAG:
  6752. el.setTagName(source.slice(start,p));//tagName
  6753. s = S_S;
  6754. break;
  6755. case S_ATTR:
  6756. attrName = source.slice(start,p)
  6757. s = S_ATTR_S;
  6758. break;
  6759. case S_V:
  6760. var value = source.slice(start,p).replace(/&#?\w+;/g,entityReplacer);
  6761. errorHandler.warning('attribute "'+value+'" missed quot(")!!');
  6762. el.add(attrName,value,start)
  6763. case S_E:
  6764. s = S_S;
  6765. break;
  6766. //case S_S:
  6767. //case S_EQ:
  6768. //case S_ATTR_S:
  6769. // void();break;
  6770. //case S_C:
  6771. //ignore warning
  6772. }
  6773. }else{//not space
  6774. //S_TAG, S_ATTR, S_EQ, S_V
  6775. //S_ATTR_S, S_E, S_S, S_C
  6776. switch(s){
  6777. //case S_TAG:void();break;
  6778. //case S_ATTR:void();break;
  6779. //case S_V:void();break;
  6780. case S_ATTR_S:
  6781. errorHandler.warning('attribute "'+attrName+'" missed value!! "'+attrName+'" instead!!')
  6782. el.add(attrName,attrName,start);
  6783. start = p;
  6784. s = S_ATTR;
  6785. break;
  6786. case S_E:
  6787. errorHandler.warning('attribute space is required"'+attrName+'"!!')
  6788. case S_S:
  6789. s = S_ATTR;
  6790. start = p;
  6791. break;
  6792. case S_EQ:
  6793. s = S_V;
  6794. start = p;
  6795. break;
  6796. case S_C:
  6797. throw new Error("elements closed character '/' and '>' must be connected to");
  6798. }
  6799. }
  6800. }
  6801. p++;
  6802. }
  6803. }
  6804. /**
  6805. * @return end of the elementStartPart(end of elementEndPart for selfClosed el)
  6806. */
  6807. function appendElement(el,domBuilder,parseStack){
  6808. var tagName = el.tagName;
  6809. var localNSMap = null;
  6810. var currentNSMap = parseStack[parseStack.length-1].currentNSMap;
  6811. var i = el.length;
  6812. while(i--){
  6813. var a = el[i];
  6814. var qName = a.qName;
  6815. var value = a.value;
  6816. var nsp = qName.indexOf(':');
  6817. if(nsp>0){
  6818. var prefix = a.prefix = qName.slice(0,nsp);
  6819. var localName = qName.slice(nsp+1);
  6820. var nsPrefix = prefix === 'xmlns' && localName
  6821. }else{
  6822. localName = qName;
  6823. prefix = null
  6824. nsPrefix = qName === 'xmlns' && ''
  6825. }
  6826. //can not set prefix,because prefix !== ''
  6827. a.localName = localName ;
  6828. //prefix == null for no ns prefix attribute
  6829. if(nsPrefix !== false){//hack!!
  6830. if(localNSMap == null){
  6831. localNSMap = {}
  6832. //console.log(currentNSMap,0)
  6833. _copy(currentNSMap,currentNSMap={})
  6834. //console.log(currentNSMap,1)
  6835. }
  6836. currentNSMap[nsPrefix] = localNSMap[nsPrefix] = value;
  6837. a.uri = 'http://www.w3.org/2000/xmlns/'
  6838. domBuilder.startPrefixMapping(nsPrefix, value)
  6839. }
  6840. }
  6841. var i = el.length;
  6842. while(i--){
  6843. a = el[i];
  6844. var prefix = a.prefix;
  6845. if(prefix){//no prefix attribute has no namespace
  6846. if(prefix === 'xml'){
  6847. a.uri = 'http://www.w3.org/XML/1998/namespace';
  6848. }if(prefix !== 'xmlns'){
  6849. a.uri = currentNSMap[prefix]
  6850. //{console.log('###'+a.qName,domBuilder.locator.systemId+'',currentNSMap,a.uri)}
  6851. }
  6852. }
  6853. }
  6854. var nsp = tagName.indexOf(':');
  6855. if(nsp>0){
  6856. prefix = el.prefix = tagName.slice(0,nsp);
  6857. localName = el.localName = tagName.slice(nsp+1);
  6858. }else{
  6859. prefix = null;//important!!
  6860. localName = el.localName = tagName;
  6861. }
  6862. //no prefix element has default namespace
  6863. var ns = el.uri = currentNSMap[prefix || ''];
  6864. domBuilder.startElement(ns,localName,tagName,el);
  6865. //endPrefixMapping and startPrefixMapping have not any help for dom builder
  6866. //localNSMap = null
  6867. if(el.closed){
  6868. domBuilder.endElement(ns,localName,tagName);
  6869. if(localNSMap){
  6870. for(prefix in localNSMap){
  6871. domBuilder.endPrefixMapping(prefix)
  6872. }
  6873. }
  6874. }else{
  6875. el.currentNSMap = currentNSMap;
  6876. el.localNSMap = localNSMap;
  6877. parseStack.push(el);
  6878. }
  6879. }
  6880. function parseHtmlSpecialContent(source,elStartEnd,tagName,entityReplacer,domBuilder){
  6881. if(/^(?:script|textarea)$/i.test(tagName)){
  6882. var elEndStart = source.indexOf('</'+tagName+'>',elStartEnd);
  6883. var text = source.substring(elStartEnd+1,elEndStart);
  6884. if(/[&<]/.test(text)){
  6885. if(/^script$/i.test(tagName)){
  6886. //if(!/\]\]>/.test(text)){
  6887. //lexHandler.startCDATA();
  6888. domBuilder.characters(text,0,text.length);
  6889. //lexHandler.endCDATA();
  6890. return elEndStart;
  6891. //}
  6892. }//}else{//text area
  6893. text = text.replace(/&#?\w+;/g,entityReplacer);
  6894. domBuilder.characters(text,0,text.length);
  6895. return elEndStart;
  6896. //}
  6897. }
  6898. }
  6899. return elStartEnd+1;
  6900. }
  6901. function fixSelfClosed(source,elStartEnd,tagName,closeMap){
  6902. //if(tagName in closeMap){
  6903. var pos = closeMap[tagName];
  6904. if(pos == null){
  6905. //console.log(tagName)
  6906. pos = closeMap[tagName] = source.lastIndexOf('</'+tagName+'>')
  6907. }
  6908. return pos<elStartEnd;
  6909. //}
  6910. }
  6911. function _copy(source,target){
  6912. for(var n in source){target[n] = source[n]}
  6913. }
  6914. function parseDCC(source,start,domBuilder,errorHandler){//sure start with '<!'
  6915. var next= source.charAt(start+2)
  6916. switch(next){
  6917. case '-':
  6918. if(source.charAt(start + 3) === '-'){
  6919. var end = source.indexOf('-->',start+4);
  6920. //append comment source.substring(4,end)//<!--
  6921. if(end>start){
  6922. domBuilder.comment(source,start+4,end-start-4);
  6923. return end+3;
  6924. }else{
  6925. errorHandler.error("Unclosed comment");
  6926. return -1;
  6927. }
  6928. }else{
  6929. //error
  6930. return -1;
  6931. }
  6932. default:
  6933. if(source.substr(start+3,6) == 'CDATA['){
  6934. var end = source.indexOf(']]>',start+9);
  6935. domBuilder.startCDATA();
  6936. domBuilder.characters(source,start+9,end-start-9);
  6937. domBuilder.endCDATA()
  6938. return end+3;
  6939. }
  6940. //<!DOCTYPE
  6941. //startDTD(java.lang.String name, java.lang.String publicId, java.lang.String systemId)
  6942. var matchs = split(source,start);
  6943. var len = matchs.length;
  6944. if(len>1 && /!doctype/i.test(matchs[0][0])){
  6945. var name = matchs[1][0];
  6946. var pubid = len>3 && /^public$/i.test(matchs[2][0]) && matchs[3][0]
  6947. var sysid = len>4 && matchs[4][0];
  6948. var lastMatch = matchs[len-1]
  6949. domBuilder.startDTD(name,pubid && pubid.replace(/^(['"])(.*?)\1$/,'$2'),
  6950. sysid && sysid.replace(/^(['"])(.*?)\1$/,'$2'));
  6951. domBuilder.endDTD();
  6952. return lastMatch.index+lastMatch[0].length
  6953. }
  6954. }
  6955. return -1;
  6956. }
  6957. function parseInstruction(source,start,domBuilder){
  6958. var end = source.indexOf('?>',start);
  6959. if(end){
  6960. var match = source.substring(start,end).match(/^<\?(\S*)\s*([\s\S]*?)\s*$/);
  6961. if(match){
  6962. var len = match[0].length;
  6963. domBuilder.processingInstruction(match[1], match[2]) ;
  6964. return end+2;
  6965. }else{//error
  6966. return -1;
  6967. }
  6968. }
  6969. return -1;
  6970. }
  6971. /**
  6972. * @param source
  6973. */
  6974. function ElementAttributes(source){
  6975. }
  6976. ElementAttributes.prototype = {
  6977. setTagName:function(tagName){
  6978. if(!tagNamePattern.test(tagName)){
  6979. throw new Error('invalid tagName:'+tagName)
  6980. }
  6981. this.tagName = tagName
  6982. },
  6983. add:function(qName,value,offset){
  6984. if(!tagNamePattern.test(qName)){
  6985. throw new Error('invalid attribute:'+qName)
  6986. }
  6987. this[this.length++] = {qName:qName,value:value,offset:offset}
  6988. },
  6989. length:0,
  6990. getLocalName:function(i){return this[i].localName},
  6991. getOffset:function(i){return this[i].offset},
  6992. getQName:function(i){return this[i].qName},
  6993. getURI:function(i){return this[i].uri},
  6994. getValue:function(i){return this[i].value}
  6995. // ,getIndex:function(uri, localName)){
  6996. // if(localName){
  6997. //
  6998. // }else{
  6999. // var qName = uri
  7000. // }
  7001. // },
  7002. // getValue:function(){return this.getValue(this.getIndex.apply(this,arguments))},
  7003. // getType:function(uri,localName){}
  7004. // getType:function(i){},
  7005. }
  7006. function _set_proto_(thiz,parent){
  7007. thiz.__proto__ = parent;
  7008. return thiz;
  7009. }
  7010. if(!(_set_proto_({},_set_proto_.prototype) instanceof _set_proto_)){
  7011. _set_proto_ = function(thiz,parent){
  7012. function p(){};
  7013. p.prototype = parent;
  7014. p = new p();
  7015. for(parent in thiz){
  7016. p[parent] = thiz[parent];
  7017. }
  7018. return p;
  7019. }
  7020. }
  7021. function split(source,start){
  7022. var match;
  7023. var buf = [];
  7024. var reg = /'[^']+'|"[^"]+"|[^\s<>\/=]+=?|(\/?\s*>|<)/g;
  7025. reg.lastIndex = start;
  7026. reg.exec(source);//skip <
  7027. while(match = reg.exec(source)){
  7028. buf.push(match);
  7029. if(match[1])return buf;
  7030. }
  7031. }
  7032. if(typeof require == 'function'){
  7033. exports.XMLReader = XMLReader;
  7034. }
  7035. },{}]},{},[4])(4)
  7036. });